@arcgis/core 4.28.0-next.20230720 → 4.28.0-next.20230721

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 (261) hide show
  1. package/Color.js +1 -1
  2. package/analysis/AreaMeasurementAnalysis.js +1 -1
  3. package/arcade/arcadeCompiler.js +1 -1
  4. package/arcade/featureSetUtils.js +1 -1
  5. package/arcade/featureset/actions/Top.js +1 -1
  6. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  7. package/arcade/featureset/support/FeatureSet.js +1 -1
  8. package/arcade/featureset/support/FeatureSetIterator.js +1 -1
  9. package/arcade/functions/convertdirection.js +1 -1
  10. package/arcade/functions/featuresetbase.js +1 -1
  11. package/arcade/functions/geomasync.js +1 -1
  12. package/arcade/functions/geomsync.js +1 -1
  13. package/arcade/lib/comment-handler.js +1 -1
  14. package/arcade/lib/parser.js +1 -1
  15. package/arcade/lib/scanner.js +1 -1
  16. package/assets/esri/core/workers/RemoteClient.js +1 -1
  17. package/assets/esri/core/workers/chunks/{75c28da8d0b02d612d69.js → 040b3fc9c9c0736dd893.js} +1 -1
  18. package/assets/esri/core/workers/chunks/0652f6a8d5221e978033.js +1 -0
  19. package/assets/esri/core/workers/chunks/{c13b332afdb3f6be1ec9.js → 092fda62b6f62c2e4869.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{57e0ad037188bd2997e7.js → 0af18a96cbd4e2d35436.js} +1 -1
  21. package/assets/esri/core/workers/chunks/0b5eeec0f66c87a46a0c.js +1 -0
  22. package/assets/esri/core/workers/chunks/{68e568b67b6fb34393db.js → 0cad2b991d0d0fd07846.js} +1 -1
  23. package/assets/esri/core/workers/chunks/0dccbc6c2559fdc0c2ad.js +1 -0
  24. package/assets/esri/core/workers/chunks/256a82f6f6e1405fbcc6.js +1 -0
  25. package/assets/esri/core/workers/chunks/{bb9213899049e1db90da.js → 2c57c9bd71637c5bed8a.js} +1 -1
  26. package/assets/esri/core/workers/chunks/2cdbabcbfe32286ec78d.js +1 -0
  27. package/assets/esri/core/workers/chunks/{2b1c83453a862e01954b.js → 2d9d80b2d0042a9c09fb.js} +1 -1
  28. package/assets/esri/core/workers/chunks/2f9aec2238ff6cb99e09.js +1 -0
  29. package/assets/esri/core/workers/chunks/{7dbd3e6406fb3e3a1a8f.js → 3cf748c025f3936c1cb2.js} +1 -1
  30. package/assets/esri/core/workers/chunks/4481d1103363434f16da.js +1 -0
  31. package/assets/esri/core/workers/chunks/5ae325e6a795c72eac6c.js +1 -0
  32. package/assets/esri/core/workers/chunks/5e4dde2886a1027b4b96.js +1 -0
  33. package/assets/esri/core/workers/chunks/730eb7e5f617fdab4f10.js +1 -0
  34. package/assets/esri/core/workers/chunks/{5a2e6bed9431cf4f42b1.js → 740dc67038f554431f1b.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{09178454bda15bb7929a.js → 7fbdfd1527582c52f9b6.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{1c026947505a9ff94a53.js → 807742f38885fa90b4fe.js} +1 -1
  37. package/assets/esri/core/workers/chunks/82dfbc175b52c7a10475.js +1 -0
  38. package/assets/esri/core/workers/chunks/870a05451e074b58f19a.js +1 -0
  39. package/assets/esri/core/workers/chunks/8c5a8c1dfb086069bb06.js +1 -0
  40. package/assets/esri/core/workers/chunks/99a5a434e0bad48c7a5c.js +1 -0
  41. package/assets/esri/core/workers/chunks/9a5916c66dad91d01d5b.js +1 -0
  42. package/assets/esri/core/workers/chunks/9c133fd8c1fbd0295b86.js +1 -0
  43. package/assets/esri/core/workers/chunks/9cddb504079d396779ea.js +1 -0
  44. package/assets/esri/core/workers/chunks/a3a1d4f32e518e97d071.js +1 -0
  45. package/assets/esri/core/workers/chunks/{9548aa449fe3a300c015.js → a4fa40dc77e116c954ac.js} +1 -1
  46. package/assets/esri/core/workers/chunks/a54ec9929a7db879d5db.js +1 -0
  47. package/assets/esri/core/workers/chunks/afc5b84693757fda2bc8.js +1 -0
  48. package/assets/esri/core/workers/chunks/{591b5c277cfd3a4101a4.js → b08f2a4aa94087c6c367.js} +1 -1
  49. package/assets/esri/core/workers/chunks/c0e12f6a7bb2360e4c21.js +1 -0
  50. package/assets/esri/core/workers/chunks/c8e656cd470a17f538e9.js +1 -0
  51. package/assets/esri/core/workers/chunks/d0e203405f95e14b1399.js +1 -0
  52. package/assets/esri/core/workers/chunks/{ec72f492f24e67e008ae.js → d8e58dc14d3495f0830c.js} +1 -1
  53. package/assets/esri/core/workers/chunks/ddc393a012588f799f42.js +1 -0
  54. package/assets/esri/core/workers/chunks/de3baa85b1639c25458d.js +1 -0
  55. package/assets/esri/core/workers/chunks/e66cea26064ba8353af0.js +1 -0
  56. package/assets/esri/core/workers/chunks/ea478f2f4a19463e13fd.js +1 -0
  57. package/assets/esri/core/workers/chunks/eba197e45507f56f3ed0.js +1 -0
  58. package/assets/esri/core/workers/chunks/ebd006fcd568a7731115.js +1 -0
  59. package/assets/esri/core/workers/chunks/ef9a9a7d66d818720e20.js +1 -0
  60. package/assets/esri/core/workers/chunks/f3b458f55236566c940b.js +1 -0
  61. package/assets/esri/core/workers/chunks/fd0a91b9e0216cc269c3.js +1 -0
  62. package/assets/esri/core/workers/chunks/{a4fe220a912b1f428e49.js → fdd6403a8390d629392b.js} +1 -1
  63. package/assets/esri/themes/base/widgets/_Directions.scss +13 -7
  64. package/assets/esri/themes/dark/main.css +1 -1
  65. package/assets/esri/themes/light/main.css +1 -1
  66. package/assets/esri/themes/light/view.css +1 -1
  67. package/chunks/array.js +1 -1
  68. package/core/Collection.js +1 -1
  69. package/core/accessorSupport/decorators/subclass.js +1 -1
  70. package/core/accessorSupport/ensureType.js +1 -1
  71. package/core/accessorSupport/get.js +1 -1
  72. package/core/accessorSupport/tracking.js +1 -1
  73. package/core/accessorSupport/utils.js +1 -1
  74. package/core/libs/rbush/PooledRBush.js +1 -1
  75. package/core/urlUtils.js +1 -1
  76. package/geometry/GeometryCursor.js +1 -1
  77. package/geometry/support/TileClipper.js +1 -1
  78. package/geometry/support/geodesicUtils.js +1 -1
  79. package/interfaces.d.ts +7 -1
  80. package/layers/LinkChartLayer.js +1 -1
  81. package/layers/VectorTileLayer.js +1 -1
  82. package/layers/VoxelLayer.js +1 -1
  83. package/layers/WCSLayer.js +1 -1
  84. package/layers/effects/EffectView.js +1 -1
  85. package/layers/graphics/sources/geojson/geojson.js +1 -1
  86. package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
  87. package/layers/mixins/ArcGISCachedService.js +1 -1
  88. package/layers/support/ElevationQuery.js +1 -1
  89. package/layers/support/MultidimensionalSubset.js +1 -1
  90. package/layers/support/TileInfo.js +1 -1
  91. package/layers/support/TileInfoTilemapCache.js +1 -1
  92. package/layers/support/TilemapCache.js +1 -1
  93. package/layers/support/rasterDatasets/multidimensionalUtils.js +1 -1
  94. package/layers/support/rasterDatasets/pamParser.js +1 -1
  95. package/layers/support/rasterDatasets/wcsCoverageParser.js +1 -1
  96. package/layers/support/rasterFormats/Raw.js +1 -1
  97. package/layers/support/rasterFormats/TiffDecoder.js +1 -1
  98. package/layers/support/rasterFunctions/ExtractBandFunction.js +1 -1
  99. package/layers/support/rasterFunctions/colormaps.js +1 -1
  100. package/layers/support/rasterFunctions/pixelUtils.js +1 -1
  101. package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
  102. package/layers/video/VideoController.js +1 -1
  103. package/layers/voxel/VoxelDimension.js +1 -1
  104. package/layers/voxel/VoxelTransferFunctionStyle.js +1 -1
  105. package/layers/voxel/VoxelVolume.js +1 -1
  106. package/package.json +1 -1
  107. package/renderers/support/RasterSymbolizer.js +1 -1
  108. package/renderers/support/colorRampUtils.js +1 -1
  109. package/renderers/visualVariables/support/visualVariableUtils.js +1 -1
  110. package/rest/query/operations/pbfDehydratedFeatureSet.js +1 -1
  111. package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
  112. package/rest/support/generateRendererUtils.js +1 -1
  113. package/smartMapping/raster/renderers/classBreaks.js +1 -1
  114. package/smartMapping/renderers/color.js +1 -1
  115. package/smartMapping/renderers/support/utils.js +1 -1
  116. package/smartMapping/renderers/type.js +1 -1
  117. package/smartMapping/renderers/univariateColorSize.js +1 -1
  118. package/smartMapping/support/adapters/support/utils.js +1 -1
  119. package/statistics/utils.js +1 -1
  120. package/support/revision.js +1 -1
  121. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  122. package/symbols/cim/GeometryWalker.js +1 -1
  123. package/symbols/cim/cimAnalyzer.js +1 -1
  124. package/symbols/cim/effects/EffectArrow.js +1 -1
  125. package/symbols/cim/effects/EffectControlMeasureLine.js +1 -1
  126. package/symbols/support/symbolUtils.js +1 -1
  127. package/views/2d/constraints/ZoomConstraint.js +1 -1
  128. package/views/2d/engine/flow/dataUtils.js +1 -1
  129. package/views/2d/engine/flow/utils.js +1 -1
  130. package/views/2d/engine/vectorTiles/VectorTile.js +1 -1
  131. package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
  132. package/views/2d/engine/vectorTiles/expression/expression.js +1 -1
  133. package/views/2d/engine/vectorTiles/style/VectorTileSource.js +1 -1
  134. package/views/2d/engine/vectorTiles/tileInfoUtils.js +1 -1
  135. package/views/2d/engine/webgl/TurboLine.js +1 -1
  136. package/views/2d/engine/webgl/mesh/MeshData.js +1 -1
  137. package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
  138. package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
  139. package/views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js +1 -1
  140. package/views/2d/layers/BaseLayerView2D.js +1 -1
  141. package/views/2d/layers/BaseLayerViewGL2D.js +1 -1
  142. package/views/2d/layers/BitmapTileLayerView2D.js +1 -1
  143. package/views/2d/layers/MediaLayerView2D.js +1 -1
  144. package/views/2d/layers/TileLayerView2D.js +1 -1
  145. package/views/2d/layers/VectorTileLayerView2D.js +1 -1
  146. package/views/2d/layers/WMTSLayerView2D.js +1 -1
  147. package/views/2d/layers/features/support/rendererUtils.js +1 -1
  148. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  149. package/views/2d/layers/support/vectorTileDebugUtils.js +5 -0
  150. package/views/2d/tiling/TileInfoView.js +1 -1
  151. package/views/2d/tiling/TileInfoViewPOT.js +1 -1
  152. package/views/2d/tiling/TileQueue.js +1 -1
  153. package/views/2d/tiling.js +1 -1
  154. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  155. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  156. package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
  157. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  158. package/views/3d/layers/TiledLayerView3D.js +1 -1
  159. package/views/3d/layers/VectorTileLayerView3D.js +1 -1
  160. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  161. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  162. package/views/3d/layers/support/featureReference.js +1 -1
  163. package/views/3d/support/LaserLineRenderer.js +1 -1
  164. package/views/3d/terrain/Overlay.js +1 -1
  165. package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
  166. package/views/3d/terrain/OverlayRenderTarget.js +1 -1
  167. package/views/3d/terrain/OverlayRenderer.js +1 -1
  168. package/views/3d/terrain/TerrainRenderer.js +1 -1
  169. package/views/3d/terrain/TileCompositor.js +1 -1
  170. package/views/3d/terrain/TileRenderer.js +1 -1
  171. package/views/3d/terrain/TilingScheme.js +1 -1
  172. package/views/3d/webgl-engine/collections/Component/ComponentData.js +1 -1
  173. package/views/3d/webgl-engine/core/shaderModules/interfaces.js +1 -1
  174. package/views/3d/webgl-engine/effects/ScreenSpaceGeometry.js +1 -1
  175. package/views/3d/webgl-engine/effects/SmaaRenderPass.js +1 -1
  176. package/views/3d/webgl-engine/lib/CompositingHelper.js +1 -1
  177. package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
  178. package/views/3d/webgl-engine/lib/PathBuilder.js +1 -1
  179. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  180. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  181. package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
  182. package/views/3d/webgl-engine/lib/WebGLLayer.js +1 -1
  183. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  184. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  185. package/views/3d/webgl-engine/parts/requireUtils.js +1 -1
  186. package/views/MapView.js +1 -1
  187. package/views/animation/pointToPoint/Path.js +1 -1
  188. package/views/draw/DrawOperation.js +1 -1
  189. package/views/draw/support/Reshape.js +1 -1
  190. package/views/draw/support/createUtils.js +1 -1
  191. package/views/interactive/SegmentLabels.js +1 -1
  192. package/views/interactive/editGeometry/EditGeometry.js +1 -1
  193. package/views/interactive/editGeometry/EditGeometryOperations.js +1 -1
  194. package/views/interactive/editGeometry/operations/UndoGroup.js +1 -1
  195. package/views/layers/GroupLayerView.js +1 -1
  196. package/views/webgl/ProgramCache.js +1 -1
  197. package/webscene/spec-certification/api.js +1 -1
  198. package/webscene/spec-certification/spec.js +1 -1
  199. package/webscene/spec-certification/utils.js +1 -1
  200. package/widgets/BuildingExplorer/BuildingNumericFilterViewModel.js +1 -1
  201. package/widgets/BuildingExplorer/BuildingPhase.js +1 -1
  202. package/widgets/BuildingExplorer/support/validation.js +1 -1
  203. package/widgets/Directions/support/resources.js +1 -1
  204. package/widgets/Directions.js +1 -1
  205. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  206. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  207. package/widgets/FeatureForm/FieldInput.js +1 -1
  208. package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
  209. package/widgets/FeatureForm.js +1 -1
  210. package/widgets/Features.js +1 -1
  211. package/widgets/Histogram/HistogramViewModel.js +1 -1
  212. package/widgets/HistogramRangeSlider/HistogramRangeSliderViewModel.js +1 -1
  213. package/widgets/Legend/styles/Card.js +1 -1
  214. package/widgets/Legend/styles/support/univariateUtils.js +1 -1
  215. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  216. package/widgets/Legend/support/colorRampUtils.js +1 -1
  217. package/widgets/Legend/support/sizeRampUtils.js +1 -1
  218. package/widgets/Legend/support/utils.js +1 -1
  219. package/widgets/Popup.js +1 -1
  220. package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
  221. package/widgets/ScaleRangeSlider/ScaleRanges.js +1 -1
  222. package/widgets/ValuePicker/ValuePickerSlider.js +1 -1
  223. package/widgets/smartMapping/ClassedSizeSlider.js +1 -1
  224. package/widgets/smartMapping/ColorSizeSlider.js +1 -1
  225. package/widgets/smartMapping/HeatmapSlider/HeatmapSliderViewModel.js +1 -1
  226. package/widgets/smartMapping/SizeSlider.js +1 -1
  227. package/widgets/smartMapping/SmartMappingPrimaryHandleSliderViewModel.js +1 -1
  228. package/widgets/smartMapping/SmartMappingSliderViewModel.js +1 -1
  229. package/assets/esri/core/workers/chunks/0210f4c2e1f3ed13041b.js +0 -1
  230. package/assets/esri/core/workers/chunks/07bb40162d97d098bc19.js +0 -1
  231. package/assets/esri/core/workers/chunks/0a18317566c1fcb68422.js +0 -1
  232. package/assets/esri/core/workers/chunks/0de65e03db8c611af9fb.js +0 -1
  233. package/assets/esri/core/workers/chunks/1a60d23a92bcf91dbb22.js +0 -1
  234. package/assets/esri/core/workers/chunks/205a0b34b698d5329854.js +0 -1
  235. package/assets/esri/core/workers/chunks/25211d5904ee9d5f4a9d.js +0 -1
  236. package/assets/esri/core/workers/chunks/26b12d1ea713c1e07701.js +0 -1
  237. package/assets/esri/core/workers/chunks/2bfa7ee324c32a56b0d3.js +0 -1
  238. package/assets/esri/core/workers/chunks/4510a17839405146130b.js +0 -1
  239. package/assets/esri/core/workers/chunks/524156c3f5383c2dd0e3.js +0 -1
  240. package/assets/esri/core/workers/chunks/59666ecb7c2c1f5a13b2.js +0 -1
  241. package/assets/esri/core/workers/chunks/5c005c9514354c77ec27.js +0 -1
  242. package/assets/esri/core/workers/chunks/620ec5c75561183d3d73.js +0 -1
  243. package/assets/esri/core/workers/chunks/68512670816f59c0e6a5.js +0 -1
  244. package/assets/esri/core/workers/chunks/6c7374ebc18b46b3480a.js +0 -1
  245. package/assets/esri/core/workers/chunks/75ba2af92da232067adb.js +0 -1
  246. package/assets/esri/core/workers/chunks/7c1f0598a016516dcec3.js +0 -1
  247. package/assets/esri/core/workers/chunks/8dcec8d1b670d2b7ea2b.js +0 -1
  248. package/assets/esri/core/workers/chunks/8e07dfb6fc2673b640cb.js +0 -1
  249. package/assets/esri/core/workers/chunks/9050b167355588b7003d.js +0 -1
  250. package/assets/esri/core/workers/chunks/9230d68799f0b0b9ef36.js +0 -1
  251. package/assets/esri/core/workers/chunks/af4083f2aad5f5d49dde.js +0 -1
  252. package/assets/esri/core/workers/chunks/b0a57718a0765d1c8df0.js +0 -1
  253. package/assets/esri/core/workers/chunks/b431b81a7bf45dd527da.js +0 -1
  254. package/assets/esri/core/workers/chunks/bda311ad48efdb265939.js +0 -1
  255. package/assets/esri/core/workers/chunks/d5cce09fbe16cbb8fee4.js +0 -1
  256. package/assets/esri/core/workers/chunks/da547c3cabe4a89c3ce6.js +0 -1
  257. package/assets/esri/core/workers/chunks/dd295fa57b45b7ec4ec5.js +0 -1
  258. package/assets/esri/core/workers/chunks/f553b464e969d45bf451.js +0 -1
  259. package/assets/esri/core/workers/chunks/f5865294983eb160de8c.js +0 -1
  260. package/assets/esri/core/workers/chunks/fdb7b1fbdb6fe091ad83.js +0 -1
  261. package/views/2d/tiling/PagedTileQueue.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.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 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 P}from"../../../../chunks/boundedPlane.js";import b from"../../support/debugFlags.js";import{TransparencyMode as A}from"../../terrain/TerrainRenderer.js";import{FBOCache as E,ColorFormat as S,DepthFormat as y}from"../core/FBOCache.js";import{RenderPassManager as I}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as C}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as O}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{RenderPluginManager as w}from"../effects/RenderPluginManager.js";import{SmaaRenderPass as D}from"../effects/SmaaRenderPass.js";import{AnimationTimeStep as N}from"./AnimationTimeStep.js";import{Decorations as M,RenderRequestType as H,StencilBits as L}from"./basicInterfaces.js";import{BoundingInfo as x}from"./BoundingInfo.js";import{ZERO as F,union as v}from"./depthRange.js";import{depthRangeFromScene as U}from"./depthRangeUtils.js";import{Highlight as G}from"./Highlight.js";import{RenderOccludedFlag as q}from"./Material.js";import{OffscreenRendering as B}from"./OffscreenRendering.js";import{RenderContext as j}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as V}from"./rendererUtils.js";import{setupFeatureDefaults as Q,RenderFeature as k}from"./RenderFeature.js";import{RenderSlot as W}from"./RenderSlot.js";import{ShadowAccumulator as Y}from"./ShadowAccumulator.js";import{ShadowHighlight as X}from"./ShadowHighlight.js";import{ShadowMap as z,SnapshotSlot as J}from"./ShadowMap.js";import K from"./SliceHelper.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=Q(r,e),this.notifyChange("_renderStateFeatures"),this.renderPlugins.renderFeatureChanged(),this._requestRender()}isFeatureEnabled(e,r=this._state){return this._renderStateFeatures.get(r,e)??!1}setFeatureEnabled(e,r,t){this._renderStateFeatures.set(r,e,t),this.notifyChange("_renderStateFeatures"),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(k.HighQualityTransparency)}get hasReflections(){return this.hasWater&&(this._ssrEnabled||this.isFeatureEnabled(k.WaterReflection))}get hasDecorations(){return this._materialRenderersHas.decorations||this._renderPlugins.hasDecorations}get hasHighlights(){return this._materialRenderersHas.highlights||this._renderPlugins.requiresOutput(C.Highlight)}get hasShadowHighlights(){return this._materialRenderersHas.highlights||this._renderPlugins.requiresOutput(C.ShadowHighlight)}get _magnifierEnabled(){return this._bindParameters.decorations===M.ON&&this._magnifierHelper.enabled}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(k.HighResolutionAtmosphere)}get hasWater(){return this._materialRenderersHas.water||this._hasOverlayWater}constructor(e,r,t,s,i,a,n,_,p){super({}),this._stage=e,this._materialRepository=r,this._techniqueRepository=s,this._rctx=i,this._compositingHelper=a,this._magnifierHelper=_,this._requestRender=p,this._materialRenderers=new h,this._needsTransparentPass=!1,this._materialRenderersHas={hudElements:!1,highlights:!1,water:!1,decorations:!1,occludees:!1},this._hasOverlayWater=!1,this._renderOverlay=e=>{},this._isRendering=!1,this._fallbackDepthStencilTexture=null,this._sliceHelper=new K,this._state=ne.IDLE,this._highQualityTransparencyEnabled=!0,this._terrainRenderingEnabled=!0,this._terrainTransparency=A.Opaque,this._ssrEnabled=!1,this._ssaoEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new N,this._renderHiddenTransparentEdges=()=>{},this.fboCache=new E(i),this._renderStateFeatures=Q(!has("disable-feature:high-quality-idle"),e.view.qualityProfile),this._offscreen=new B(this.fboCache,this._compositingHelper),this.performanceInfo=new ie(this._rctx),this._shadowMap=new z(this.fboCache,e.viewingMode),this._ssaoHelper=new Z(e.view,this.fboCache,s,p),this._highlight=new G(s,this.fboCache),this._shadowHighlight=new X(this._rctx,e.viewingMode),this._shadowAccumulator=new Y(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(C.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._prepare(e.camera,e.contentCamera)}),p),this._renderContext=new j(this._rctx,this._offscreen,this._shadowMap,this._ssaoHelper,this._sliceHelper),this._renderPlugins=new w({renderContext:this._renderContext,techniqueRepository:s,textureRepository:t,materialRepository:this._materialRepository,requestRender:p,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e),screen:n}),this.renderPassManager=new I,this._renderPlugins.add(this.renderPassManager),this._smaaPass=new D({view:this._stage.view}),this._renderPlugins.add(this._smaaPass),this.addHandles([o((()=>this._stage.view.state.camera),(()=>p()),d),o((()=>b.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(re.TRANSPARENT):()=>{},p()}),l),o((()=>this._ssaoEnabled||this.isFeatureEnabled(k.SSAO)),(e=>this._ssaoHelper.enabled=e),d)])}normalizeCtorArgs(){return{}}destroy(){this._smaaPass.disable(),this._smaaPass.destroy(),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.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),x.prune()}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth),this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth)}disposeOffscreenBuffers(){this._releaseFBOs(),this._disposeOffscreenBuffers()}_disposeOffscreenBuffers(){this._offscreen.dispose(),this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.linearDepth=n(this._bindParameters.linearDepth),this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility)}get updating(){return 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.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=V(e);let n=!1;a.forEach(((t,s)=>{if(r.done)return;let i=this._materialRenderers.find((e=>e.material===s));if(null==i&&t.adds.length>0){const e=new te({material:s});e.initializeRenderContext(this.renderPlugins._context),i=e,this._materialRenderers.push(i)}i&&(i.modify(t),i.isEmpty&&(n=!0)),t.removes.forEach((r=>e.removes.removeUnordered(r))),t.adds.forEach((r=>e.adds.removeUnordered(r))),t.updates.forEach((r=>e.updates.removeUnordered(r))),r.madeProgress()})),n&&this._materialRenderers.filterInPlace((e=>!e.isEmpty||(e.dispose(),!1))),this._updateHasFlags(),this._requestRender()}_updateHasFlags(){const has=this._materialRenderersHas;has.decorations=!1,has.highlights=!1,has.hudElements=!1,has.water=!1,has.occludees=!1,this._materialRenderers.forAll((e=>{has.highlights||=e.hasHighlights,has.occludees||=e.hasOccludees,has.water||=e.hasWater,has.decorations||=e.isDecoration,has.hudElements||=e.canRender(W.LINE_CALLOUTS_HUD_DEPTH,C.Color)||e.canRender(W.HUD_MATERIAL,C.Color)||e.canRender(W.LABEL_MATERIAL,C.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;const _=P(this._sliceHelper.plane);s===M.OFF&&(this._sliceHelper.plane=null),this._rctx.bindFramebuffer(e),h.setGLViewport(this._rctx);const p=a.initializeFrame(h);this.hasReflections?this._bindParameters.ssr.lastFrameColor=p:p?.release(),this._prepare(h,o),this._renderPlugins.prepareRender(),this.performanceInfo.advance(ae.PREPARE);const m=this._computeDepthRange(h);this._renderShadowMap(e,h,this._bindParameters.lighting.mainLight.direction,m),this.performanceInfo.advance(ae.SHADOW_MAP),this._ensureBindParameters(h,o);const c=this._terrainRenderingEnabled&&(this._terrainTransparency===A.Semitransparent||this._terrainTransparency===A.TransparentWithDraped),u=this._highQualityTransparency&&c,f=this._needsTransparentPass||this._renderPlugins.canRender(W.TRANSPARENT_MATERIAL);this._prepareShaders(u,f),this._renderLinearDepth(),this.performanceInfo.advance(ae.LINEAR_DEPTH),this._accumulateShadows(m,h,o),this.performanceInfo.advance(ae.ACCUMULATED_SHADOWS),this._ensureBindParametersSSR(i),this._renderSSAO(i),this.performanceInfo.advance(ae.SSAO),this._renderContext.output=C.Color,a.bindFbo(),this._renderOpaqueGeometry(),this.performanceInfo.advance(ae.OPAQUE),this._renderTerrainLinearDepth(u),this._setMultipassTerrain(u),this._renderEdges(re.OPAQUE),this.performanceInfo.advance(ae.OPAQUE_EDGES),a.bindFbo(),this._renderSlot(W.VOXEL),this.performanceInfo.advance(ae.VOXEL),this._renderHiddenTransparentEdges(),f&&(this._oitEnabled?this._renderOITPass(_e.Geometry):this._renderTransparentGeometry()),this.performanceInfo.advance(ae.TRANSPARENT);const g=this._renderGeometryLinearDepth(u);this._renderHUDVisibility(g),u||this._renderInternalSlot(W.LINE_CALLOUTS),this.performanceInfo.advance(ae.HUD_VISIBILITY),this._renderObjectAndLayerIdColor(r),this.performanceInfo.advance(ae.OBJECT_AND_LAYER_ID_COLOR),this._renderEdges(re.TRANSPARENT,g),g?.release(),this.performanceInfo.advance(ae.TRANSPARENT_EDGES);const T=c?this._renderTransparentTerrain():null;T&&this._bindParameters.hudVisibility&&(u?this._renderLineCallouts(O.Occluded):a.compositeToHUDVisibility(this._bindParameters,T.colorTexture),this._renderHUD(O.Occluded,a.framebuffer),this.performanceInfo.advance(ae.HUD_OCCLUDED)),this.performanceInfo.advance(ae.TRANSPARENT_TERRAIN),this._setTerrainCulling(!1),T&&(a.compositeToFramebuffer(this._bindParameters,T.colorTexture,se.PremultipliedAlpha,1),T.release(),u&&(this._renderEdges(re.OPAQUE),this.performanceInfo.advance(ae.OPAQUE_EDGES),f&&(this._oitEnabled?this._renderOITPass(_e.Geometry):this._renderTransparentGeometry()),this.performanceInfo.advance(ae.TRANSPARENT),this._renderEdges(re.TRANSPARENT),this.performanceInfo.advance(ae.TRANSPARENT_EDGES))),this._bindParameters.ssao=n(this._bindParameters.ssao),u&&this._renderLineCallouts(O.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),a.bindFbo(),this._renderInternalSlot(W.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderSlot(W.POSTPROCESSING_ENVIRONMENT_TRANSPARENT),this.performanceInfo.advance(ae.ENVIRONMENT),this._renderLaserlines(),this.performanceInfo.advance(ae.LASER_LINES),this._renderOccluded(),this.performanceInfo.advance(ae.OCCLUDED);const R=this._renderAntialiasing(e),b=R?.fbo??e;this.performanceInfo.advance(ae.ANTIALIASING),this._renderHUD(O.NotOccluded,b),this.performanceInfo.advance(ae.HUD),this._renderHighlights(b,this._bindParameters),this.performanceInfo.advance(ae.HIGHLIGHTS),this._magnifierEnabled&&this._magnifierHelper.render(this._rctx,this._bindParameters),b!==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=C.Color,this._prepareOpaqueGeometrySlots(),this._setMultipassTerrain(e),this._prepareSlots(W.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._prepareInternalSlots(this._materialRenderers,W.LINE_CALLOUTS),r&&this._prepareTransparencySlots(),this._prepareInternalSlots(this._materialRenderers,W.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._prepareSlots(W.POSTPROCESSING_ENVIRONMENT_TRANSPARENT,W.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(C.ObjectAndLayerIdColor)),[0,0,0,0],!0,!0),this._rctx.bindFramebuffer(e),this._offscreen.renderToFBO((()=>{this._bindParameters.hudRenderStyle=O.NotOccluded,this._renderInternalSlot(W.HUD_MATERIAL)}),void 0,!0,!0),this._renderContext.output=r}finish(e){this._hasAnimations||this._animationTimestep.clear();const r=this.performanceInfo.gpuSamplingEnabled,t=e===H.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(C.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(k.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._shadowHighlight.updateParameters(r,t),this._needsShadowHighlight?(this._renderShadowCascades(C.ShadowHighlight,this._shadowMap),i.moveSnapshot(J.Highlight),i.clear(),this._renderShadowCascades(C.ShadowExcludeHighlight,this._shadowMap),i.copySnapshot(J.Default),this._renderShadowCascades(C.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(C.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.requiresOutput(C.Depth)||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast}_renderLinearDepth(){this._needsLinearDepth?(this._bindParameters.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.linearDepth,(()=>this._renderGeometryAndTransparentTerrainPass(C.Depth)),[0,0,0,0],S.RGBA,y.DEPTH24_BUFFER),this._bindParameters.linearDepth.releaseDepth(),this._offscreen.bindFbo()):this._bindParameters.linearDepth=n(this._bindParameters.linearDepth)}_renderTerrainLinearDepth(e){if(e){const e=this._renderContext.output;this._renderContext.output=C.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(C.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 F;const r=U(e,this._materialRenderers,this._stage.layers);return v(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(W.TRANSPARENT_TERRAIN),this._renderGeometryPass(e),this._renderTransparentTerrain()}_renderGeometryPass(e){this._renderContext.output=e,this._prepareSlots(W.TRANSPARENT_MATERIAL),this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderSSAO(e){if(!this._ssaoHelper.active)return;const r=this._offscreen.renderToCachedFBO(null,(()=>this._renderGeometryAndTransparentTerrainPass(C.Normal)),[0,0,0,0],S.RGBA4,y.DEPTH24_BUFFER);r.releaseDepth(),this._offscreen.bindFbo(),this._bindParameters.ssao=this._ssaoHelper.render(this._bindParameters,e,r.colorTexture),r.release()}_prepareOpaqueGeometrySlots(){this._prepareSlots(W.INTEGRATED_MESH,W.OPAQUE_TERRAIN,W.OPAQUE_MATERIAL,W.POSTPROCESSING_ENVIRONMENT_OPAQUE),this._prepareInternalSlots(this._materialRenderers,W.OPAQUE_MATERIAL)}_renderOpaqueGeometry(){this._renderSlot(W.INTEGRATED_MESH),this._renderSlot(W.OPAQUE_TERRAIN),this._renderInternalSlot(W.OPAQUE_MATERIAL),this._renderSlot(W.OPAQUE_MATERIAL),this._renderSlot(W.POSTPROCESSING_ENVIRONMENT_OPAQUE)}_renderTransparentGeometry(){this._renderInternalSlot(W.TRANSPARENT_MATERIAL),this._renderSlot(W.TRANSPARENT_MATERIAL)}_renderTransparentTerrain(){const e=this._renderPlugins.prepare(W.TRANSPARENT_TERRAIN);if(0===e.size)return;const r=()=>this._renderPlugins.render(e);if(this._renderContext.output!==C.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){this._prepareInternalSlots(this._materialRenderers,W.OCCLUSION_PIXELS)?(this._bindParameters.hudVisibility=this._offscreen.renderHUDVisibility(this._bindParameters.hudVisibility,(()=>this._renderInternalSlot(W.OCCLUSION_PIXELS)),e),this._offscreen.bindFbo()):this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===O.Occluded){const e=()=>this._renderInternalSlot(W.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(W.LINE_CALLOUTS)}_renderLaserlines(){if(this._renderSlot(W.LASERLINES),this._renderPlugins.needsLaserlineWithContrastControl){const e=this._offscreen,{width:r,height:t,depth:s}=e,i=this.fboCache.acquire(S.RGBA,r,t),a=()=>this._renderSlot(W.LASERLINES_CONTRAST_CONTROL);e.renderToTargets(a,i,s,me),e.compositeToFramebuffer(this._bindParameters,i.colorTexture,se.PremultipliedAlpha,1),i.release()}}_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 r=()=>this._renderHUDElements(e),{width:t,height:s,color:i}=this._offscreen,a=this.fboCache.acquireDepth(y.DEPTH16_BUFFER,t,s);this._offscreen.renderToTargets(r,i,a,void 0,!0,!0),a.release()}else this._renderHUDElements(e)}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._prepareInternalSlots(this._materialRenderers,W.LINE_CALLOUTS_HUD_DEPTH,W.HUD_MATERIAL,W.LABEL_MATERIAL),this._renderInternalSlot(W.LINE_CALLOUTS_HUD_DEPTH),this._renderInternalSlot(W.HUD_MATERIAL),this._renderInternalSlot(W.LABEL_MATERIAL)}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._shadowHighlight.isVisible&&this.hasShadowHighlights}_renderHighlights(e,r){if(!this.hasHighlights||r.decorations===M.OFF)return;const t=()=>{this._renderGeometryAndTransparentTerrainPass(C.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=C.Alpha,this._bindParameters.transparencyPassType=$.Alpha,this._prepareInternalSlots(this._materialRenderers,W.TRANSPARENT_MATERIAL),this._prepareSlots(W.TRANSPARENT_MATERIAL),this._renderContext.output=C.Color,this._bindParameters.transparencyPassType=$.Color,this._prepareInternalSlots(this._materialRenderers,W.TRANSPARENT_MATERIAL),this._prepareSlots(W.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=$.FrontFace,this._prepareInternalSlots(this._materialRenderers,W.TRANSPARENT_MATERIAL),this._prepareSlots(W.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=C.Alpha,this._bindParameters.transparencyPassType=$.Alpha;const n=this._offscreen.renderOITPass(i,$.Alpha,t);this._renderContext.output=C.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===q.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,W.OCCLUDER_MATERIAL,W.TRANSPARENT_OCCLUDER_MATERIAL),this._renderInternalSlot(W.OCCLUDER_MATERIAL,ce),t(.5,q.OccludeAndTransparentStencil,(()=>this._renderInternalSlot(W.TRANSPARENT_OCCLUDER_MATERIAL,ce)),!1,!1)),ce.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&(r.material.renderOccluded===q.OccludeAndTransparent||r.material.renderOccluded===q.Transparent||r.material.renderOccluded===q.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,W.OPAQUE_MATERIAL,W.TRANSPARENT_MATERIAL,W.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),s>q.Occlude&&this._renderSlot(W.OCCLUDED_TERRAIN),this._renderInternalSlot(W.OPAQUE_MATERIAL,ce),this._renderInternalSlot(W.TRANSPARENT_MATERIAL,ce),this._renderInternalSlot(W.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,ce),this._renderContext.resetRenderOccludedMask()};this._renderContext.output=C.Color,t(.5,q.OccludeAndTransparent,(()=>i(q.OccludeAndTransparent)),!0,L.OutlineVisualElementMask),t(.5,q.Transparent,(()=>i(q.Transparent)),!0,L.OutlineVisualElementMask),t(1,q.Opaque,(()=>i(q.Opaque)),!0,L.OutlineVisualElementMask),ce.clear()}_renderAntialiasing(e){const r=this._offscreen,t=this._magnifierEnabled&&null==e?this.fboCache.acquire(S.RGBA,r.width,r.height).acquireDepth(y.DEPTH16_BUFFER):null,s=t?.fbo??e;this._bindParameters.output=s,this._rctx.bindFramebuffer(s);const i=this._offscreen.colorTexture;return this.renderPlugins.canRender(W.ANTIALIASING)?this._renderSlot(W.ANTIALIASING):null!=i&&this._compositingHelper.composite(this._bindParameters,i,se.None),t}_prepare(e,r){this._needsTransparentPass=this._materialRenderers.some((e=>e.canRender(W.TRANSPARENT_MATERIAL,C.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){let t=!1;for(const s of r)this._bindParameters.slot=s,e.forAll((e=>{e.material.shouldRender(this._renderContext)&&(t=null!=e.prepareTechnique(this._renderContext)||t)}));return t}_renderInternalSlot(e,r=this._materialRenderers){this._bindParameters.slot=e,r.forAll((e=>{if(e.material.shouldRender(this._renderContext)){const r=e.prepareTechnique(this._renderContext);r&&e.render(this._renderContext,r)}}))}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._bindParameters.ssao?.memoryUsage??0,vaos:this._materialRenderers.reduce(((e,r)=>e+r.usedMemory),0),plugins:this._renderPlugins.usedMemory}}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.edgeView?.usedMemory??0)+this._materialRenderers.reduce(((e,r)=>e+r.usedMemory),0)+this._renderPlugins.usedMemory}get test(){const e=this;return{offscreen:this._offscreen,shadowMap:this._shadowMap,highlight:this._highlight,lighting:this._bindParameters.lighting,materialRenderers:this._materialRenderers,shadowAccumulator:this._shadowAccumulator,weatherIsFading:this._bindParameters.cloudsFade.isFading,resetRenderStateFeatures:()=>{e._renderStateFeatures=Q(),this.renderPlugins.renderFeatureChanged(),this._requestRender()},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,"_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};
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 P}from"../../../../chunks/boundedPlane.js";import b from"../../support/debugFlags.js";import{TransparencyMode as A}from"../../terrain/TerrainRenderer.js";import{FBOCache as E,ColorFormat as S,DepthFormat as y}from"../core/FBOCache.js";import{RenderPassManager as I}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as C}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as O}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{RenderPluginManager as w}from"../effects/RenderPluginManager.js";import{SmaaRenderPass as D}from"../effects/SmaaRenderPass.js";import{AnimationTimeStep as N}from"./AnimationTimeStep.js";import{Decorations as M,RenderRequestType as H,StencilBits as L}from"./basicInterfaces.js";import{BoundingInfo as x}from"./BoundingInfo.js";import{ZERO as F,union as v}from"./depthRange.js";import{depthRangeFromScene as U}from"./depthRangeUtils.js";import{Highlight as G}from"./Highlight.js";import{RenderOccludedFlag as q}from"./Material.js";import{OffscreenRendering as B}from"./OffscreenRendering.js";import{RenderContext as j}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as V}from"./rendererUtils.js";import{setupFeatureDefaults as Q,RenderFeature as k}from"./RenderFeature.js";import{RenderSlot as W}from"./RenderSlot.js";import{ShadowAccumulator as Y}from"./ShadowAccumulator.js";import{ShadowHighlight as X}from"./ShadowHighlight.js";import{ShadowMap as z,SnapshotSlot as J}from"./ShadowMap.js";import K from"./SliceHelper.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=Q(r,e),this.notifyChange("_renderStateFeatures"),this.renderPlugins.renderFeatureChanged(),this._requestRender()}isFeatureEnabled(e,r=this._state){return this._renderStateFeatures.get(r,e)??!1}setFeatureEnabled(e,r,t){this._renderStateFeatures.set(r,e,t),this.notifyChange("_renderStateFeatures"),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(k.HighQualityTransparency)}get hasReflections(){return this.hasWater&&(this._ssrEnabled||this.isFeatureEnabled(k.WaterReflection))}get hasDecorations(){return this._materialRenderersHas.decorations||this._renderPlugins.hasDecorations}get hasHighlights(){return this._materialRenderersHas.highlights||this._renderPlugins.requiresOutput(C.Highlight)}get hasShadowHighlights(){return this._materialRenderersHas.highlights||this._renderPlugins.requiresOutput(C.ShadowHighlight)}get _magnifierEnabled(){return this._bindParameters.decorations===M.ON&&this._magnifierHelper.enabled}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(k.HighResolutionAtmosphere)}get hasWater(){return this._materialRenderersHas.water||this._hasOverlayWater}constructor(e,r,t,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 K,this._state=ne.IDLE,this._highQualityTransparencyEnabled=!0,this._terrainRenderingEnabled=!0,this._terrainTransparency=A.Opaque,this._ssrEnabled=!1,this._ssaoEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new N,this._renderHiddenTransparentEdges=()=>{},this.fboCache=new E(i),this._renderStateFeatures=Q(!has("disable-feature:high-quality-idle"),e.view.qualityProfile),this._offscreen=new B(this.fboCache,this._compositingHelper),this.performanceInfo=new ie(this._rctx),this._shadowMap=new z(this.fboCache,e.viewingMode),this._ssaoHelper=new Z(e.view,this.fboCache,s,_),this._highlight=new G(s,this.fboCache),this._shadowHighlight=new X(this._rctx,e.viewingMode),this._shadowAccumulator=new Y(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(C.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._prepare(e.camera,e.contentCamera)}),_),this._renderContext=new j(this._rctx,this._offscreen,this._shadowMap,this._ssaoHelper,this._sliceHelper),this._renderPlugins=new w({renderContext:this._renderContext,techniqueRepository:s,textureRepository:t,materialRepository:this._materialRepository,requestRender:_,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this.renderPassManager=new I,this._renderPlugins.add(this.renderPassManager),this._smaaPass=new D({view:this._stage.view}),this._renderPlugins.add(this._smaaPass),this.addHandles([o((()=>this._stage.view.state.camera),(()=>_()),d),o((()=>b.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(re.TRANSPARENT):()=>{},_()}),l),o((()=>this._ssaoEnabled||this.isFeatureEnabled(k.SSAO)),(e=>this._ssaoHelper.enabled=e),d)])}normalizeCtorArgs(){return{}}destroy(){this._smaaPass.disable(),this._smaaPass.destroy(),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.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),x.prune()}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth),this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth)}disposeOffscreenBuffers(){this._releaseFBOs(),this._disposeOffscreenBuffers()}_disposeOffscreenBuffers(){this._offscreen.dispose(),this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.linearDepth=n(this._bindParameters.linearDepth),this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility)}get updating(){return 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.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=V(e);let n=!1;a.forEach(((t,s)=>{if(r.done)return;let i=this._materialRenderers.find((e=>e.material===s));if(null==i&&t.adds.length>0){const e=new te({material:s});e.initializeRenderContext(this.renderPlugins._context),i=e,this._materialRenderers.push(i)}i&&(i.modify(t),i.isEmpty&&(n=!0)),t.removes.forEach((r=>e.removes.removeUnordered(r))),t.adds.forEach((r=>e.adds.removeUnordered(r))),t.updates.forEach((r=>e.updates.removeUnordered(r))),r.madeProgress()})),n&&this._materialRenderers.filterInPlace((e=>!e.isEmpty||(e.dispose(),!1))),this._updateHasFlags(),this._requestRender()}_updateHasFlags(){const has=this._materialRenderersHas;has.decorations=!1,has.highlights=!1,has.hudElements=!1,has.water=!1,has.occludees=!1,this._materialRenderers.forAll((e=>{has.highlights||=e.hasHighlights,has.occludees||=e.hasOccludees,has.water||=e.hasWater,has.decorations||=e.isDecoration,has.hudElements||=e.canRender(W.LINE_CALLOUTS_HUD_DEPTH,C.Color)||e.canRender(W.HUD_MATERIAL,C.Color)||e.canRender(W.LABEL_MATERIAL,C.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;const _=P(this._sliceHelper.plane);s===M.OFF&&(this._sliceHelper.plane=null),this._rctx.bindFramebuffer(e),h.setGLViewport(this._rctx);const p=a.initializeFrame(h);this.hasReflections?this._bindParameters.ssr.lastFrameColor=p:p?.release(),this._prepare(h,o),this._renderPlugins.prepareRender(),this.performanceInfo.advance(ae.PREPARE);const m=this._computeDepthRange(h);this._renderShadowMap(e,h,this._bindParameters.lighting.mainLight.direction,m),this.performanceInfo.advance(ae.SHADOW_MAP),this._ensureBindParameters(h,o);const c=this._terrainRenderingEnabled&&(this._terrainTransparency===A.Semitransparent||this._terrainTransparency===A.TransparentWithDraped),u=this._highQualityTransparency&&c,f=this._needsTransparentPass||this._renderPlugins.canRender(W.TRANSPARENT_MATERIAL);this._prepareShaders(u,f),this._renderLinearDepth(),this.performanceInfo.advance(ae.LINEAR_DEPTH),this._accumulateShadows(m,h,o),this.performanceInfo.advance(ae.ACCUMULATED_SHADOWS),this._ensureBindParametersSSR(i),this._renderSSAO(i),this.performanceInfo.advance(ae.SSAO),this._renderContext.output=C.Color,a.bindFbo(),this._renderOpaqueGeometry(),this.performanceInfo.advance(ae.OPAQUE),this._renderTerrainLinearDepth(u),this._setMultipassTerrain(u),this._renderEdges(re.OPAQUE),this.performanceInfo.advance(ae.OPAQUE_EDGES),a.bindFbo(),this._renderSlot(W.VOXEL),this.performanceInfo.advance(ae.VOXEL),this._renderHiddenTransparentEdges(),f&&(this._oitEnabled?this._renderOITPass(_e.Geometry):this._renderTransparentGeometry()),this.performanceInfo.advance(ae.TRANSPARENT);const g=this._renderGeometryLinearDepth(u);this._renderHUDVisibility(g),u||this._renderInternalSlot(W.LINE_CALLOUTS),this.performanceInfo.advance(ae.HUD_VISIBILITY),this._renderObjectAndLayerIdColor(r),this.performanceInfo.advance(ae.OBJECT_AND_LAYER_ID_COLOR),this._renderEdges(re.TRANSPARENT,g),g?.release(),this.performanceInfo.advance(ae.TRANSPARENT_EDGES);const T=c?this._renderTransparentTerrain():null;T&&this._bindParameters.hudVisibility&&(u?this._renderLineCallouts(O.Occluded):a.compositeToHUDVisibility(this._bindParameters,T.colorTexture),this._renderHUD(O.Occluded,a.framebuffer),this.performanceInfo.advance(ae.HUD_OCCLUDED)),this.performanceInfo.advance(ae.TRANSPARENT_TERRAIN),this._setTerrainCulling(!1),T&&(a.compositeToFramebuffer(this._bindParameters,T.colorTexture,se.PremultipliedAlpha,1),T.release(),u&&(this._renderEdges(re.OPAQUE),this.performanceInfo.advance(ae.OPAQUE_EDGES),f&&(this._oitEnabled?this._renderOITPass(_e.Geometry):this._renderTransparentGeometry()),this.performanceInfo.advance(ae.TRANSPARENT),this._renderEdges(re.TRANSPARENT),this.performanceInfo.advance(ae.TRANSPARENT_EDGES))),this._bindParameters.ssao=n(this._bindParameters.ssao),u&&this._renderLineCallouts(O.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),a.bindFbo(),this._renderInternalSlot(W.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderSlot(W.POSTPROCESSING_ENVIRONMENT_TRANSPARENT),this.performanceInfo.advance(ae.ENVIRONMENT),this._renderLaserlines(),this.performanceInfo.advance(ae.LASER_LINES),this._renderOccluded(),this.performanceInfo.advance(ae.OCCLUDED);const R=this._renderAntialiasing(e),b=R?.fbo??e;this.performanceInfo.advance(ae.ANTIALIASING),this._renderHUD(O.NotOccluded,b),this.performanceInfo.advance(ae.HUD),this._renderHighlights(b,this._bindParameters),this.performanceInfo.advance(ae.HIGHLIGHTS),this._magnifierEnabled&&this._magnifierHelper.render(this._rctx,this._bindParameters),b!==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=C.Color,this._prepareOpaqueGeometrySlots(),this._setMultipassTerrain(e),this._prepareSlots(W.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._prepareInternalSlots(this._materialRenderers,W.LINE_CALLOUTS),r&&this._prepareTransparencySlots(),this._prepareInternalSlots(this._materialRenderers,W.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._prepareSlots(W.POSTPROCESSING_ENVIRONMENT_TRANSPARENT,W.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(C.ObjectAndLayerIdColor)),[0,0,0,0],!0,!0),this._rctx.bindFramebuffer(e),this._offscreen.renderToFBO((()=>{this._bindParameters.hudRenderStyle=O.NotOccluded,this._renderInternalSlot(W.HUD_MATERIAL)}),void 0,!0,!0),this._renderContext.output=r}finish(e){this._hasAnimations||this._animationTimestep.clear();const r=this.performanceInfo.gpuSamplingEnabled,t=e===H.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(C.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(k.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._shadowHighlight.updateParameters(r,t),this._needsShadowHighlight?(this._renderShadowCascades(C.ShadowHighlight,this._shadowMap),i.moveSnapshot(J.Highlight),i.clear(),this._renderShadowCascades(C.ShadowExcludeHighlight,this._shadowMap),i.copySnapshot(J.Default),this._renderShadowCascades(C.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(C.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.requiresOutput(C.Depth)||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast}_renderLinearDepth(){this._needsLinearDepth?(this._bindParameters.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.linearDepth,(()=>this._renderGeometryAndTransparentTerrainPass(C.Depth)),[0,0,0,0],S.RGBA,y.DEPTH24_BUFFER),this._bindParameters.linearDepth.releaseDepth(),this._offscreen.bindFbo()):this._bindParameters.linearDepth=n(this._bindParameters.linearDepth)}_renderTerrainLinearDepth(e){if(e){const e=this._renderContext.output;this._renderContext.output=C.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(C.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 F;const r=U(e,this._materialRenderers,this._stage.layers);return v(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(W.TRANSPARENT_TERRAIN),this._renderGeometryPass(e),this._renderTransparentTerrain()}_renderGeometryPass(e){this._renderContext.output=e,this._prepareSlots(W.TRANSPARENT_MATERIAL),this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderSSAO(e){if(!this._ssaoHelper.active)return;const r=this._offscreen.renderToCachedFBO(null,(()=>this._renderGeometryAndTransparentTerrainPass(C.Normal)),[0,0,0,0],S.RGBA4,y.DEPTH24_BUFFER);r.releaseDepth(),this._offscreen.bindFbo(),this._bindParameters.ssao=this._ssaoHelper.render(this._bindParameters,e,r.colorTexture),r.release()}_prepareOpaqueGeometrySlots(){this._prepareSlots(W.INTEGRATED_MESH,W.OPAQUE_TERRAIN,W.OPAQUE_MATERIAL,W.POSTPROCESSING_ENVIRONMENT_OPAQUE),this._prepareInternalSlots(this._materialRenderers,W.OPAQUE_MATERIAL)}_renderOpaqueGeometry(){this._renderSlot(W.INTEGRATED_MESH),this._renderSlot(W.OPAQUE_TERRAIN),this._renderInternalSlot(W.OPAQUE_MATERIAL),this._renderSlot(W.OPAQUE_MATERIAL),this._renderSlot(W.POSTPROCESSING_ENVIRONMENT_OPAQUE)}_renderTransparentGeometry(){this._renderInternalSlot(W.TRANSPARENT_MATERIAL),this._renderSlot(W.TRANSPARENT_MATERIAL)}_renderTransparentTerrain(){const e=this._renderPlugins.prepare(W.TRANSPARENT_TERRAIN);if(0===e.size)return;const r=()=>this._renderPlugins.render(e);if(this._renderContext.output!==C.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){this._prepareInternalSlots(this._materialRenderers,W.OCCLUSION_PIXELS)?(this._bindParameters.hudVisibility=this._offscreen.renderHUDVisibility(this._bindParameters.hudVisibility,(()=>this._renderInternalSlot(W.OCCLUSION_PIXELS)),e),this._offscreen.bindFbo()):this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===O.Occluded){const e=()=>this._renderInternalSlot(W.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(W.LINE_CALLOUTS)}_renderLaserlines(){if(this._renderSlot(W.LASERLINES),this._renderPlugins.needsLaserlineWithContrastControl){const e=this._offscreen,{width:r,height:t,depth:s}=e,i=this.fboCache.acquire(S.RGBA,r,t),a=()=>this._renderSlot(W.LASERLINES_CONTRAST_CONTROL);e.renderToTargets(a,i,s,me),e.compositeToFramebuffer(this._bindParameters,i.colorTexture,se.PremultipliedAlpha,1),i.release()}}_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 r=()=>this._renderHUDElements(e),{width:t,height:s,color:i}=this._offscreen,a=this.fboCache.acquireDepth(y.DEPTH16_BUFFER,t,s);this._offscreen.renderToTargets(r,i,a,void 0,!0,!0),a.release()}else this._renderHUDElements(e)}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._prepareInternalSlots(this._materialRenderers,W.LINE_CALLOUTS_HUD_DEPTH,W.HUD_MATERIAL,W.LABEL_MATERIAL),this._renderInternalSlot(W.LINE_CALLOUTS_HUD_DEPTH),this._renderInternalSlot(W.HUD_MATERIAL),this._renderInternalSlot(W.LABEL_MATERIAL)}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._shadowHighlight.isVisible&&this.hasShadowHighlights}_renderHighlights(e,r){if(!this.hasHighlights||r.decorations===M.OFF)return;const t=()=>{this._renderGeometryAndTransparentTerrainPass(C.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=C.Alpha,this._bindParameters.transparencyPassType=$.Alpha,this._prepareInternalSlots(this._materialRenderers,W.TRANSPARENT_MATERIAL),this._prepareSlots(W.TRANSPARENT_MATERIAL),this._renderContext.output=C.Color,this._bindParameters.transparencyPassType=$.Color,this._prepareInternalSlots(this._materialRenderers,W.TRANSPARENT_MATERIAL),this._prepareSlots(W.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=$.FrontFace,this._prepareInternalSlots(this._materialRenderers,W.TRANSPARENT_MATERIAL),this._prepareSlots(W.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=C.Alpha,this._bindParameters.transparencyPassType=$.Alpha;const n=this._offscreen.renderOITPass(i,$.Alpha,t);this._renderContext.output=C.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===q.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,W.OCCLUDER_MATERIAL,W.TRANSPARENT_OCCLUDER_MATERIAL),this._renderInternalSlot(W.OCCLUDER_MATERIAL,ce),t(.5,q.OccludeAndTransparentStencil,(()=>this._renderInternalSlot(W.TRANSPARENT_OCCLUDER_MATERIAL,ce)),!1,!1)),ce.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&(r.material.renderOccluded===q.OccludeAndTransparent||r.material.renderOccluded===q.Transparent||r.material.renderOccluded===q.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,W.OPAQUE_MATERIAL,W.TRANSPARENT_MATERIAL,W.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),s>q.Occlude&&this._renderSlot(W.OCCLUDED_TERRAIN),this._renderInternalSlot(W.OPAQUE_MATERIAL,ce),this._renderInternalSlot(W.TRANSPARENT_MATERIAL,ce),this._renderInternalSlot(W.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,ce),this._renderContext.resetRenderOccludedMask()};this._renderContext.output=C.Color,t(.5,q.OccludeAndTransparent,(()=>i(q.OccludeAndTransparent)),!0,L.OutlineVisualElementMask),t(.5,q.Transparent,(()=>i(q.Transparent)),!0,L.OutlineVisualElementMask),t(1,q.Opaque,(()=>i(q.Opaque)),!0,L.OutlineVisualElementMask),ce.clear()}_renderAntialiasing(e){const r=this._offscreen,t=this._magnifierEnabled&&null==e?this.fboCache.acquire(S.RGBA,r.width,r.height).acquireDepth(y.DEPTH16_BUFFER):null,s=t?.fbo??e;this._bindParameters.output=s,this._rctx.bindFramebuffer(s);const i=this._offscreen.colorTexture;return this.renderPlugins.canRender(W.ANTIALIASING)?this._renderSlot(W.ANTIALIASING):null!=i&&this._compositingHelper.composite(this._bindParameters,i,se.None),t}_prepare(e,r){this._needsTransparentPass=this._materialRenderers.some((e=>e.canRender(W.TRANSPARENT_MATERIAL,C.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){let t=!1;for(const s of r)this._bindParameters.slot=s,e.forAll((e=>{e.material.shouldRender(this._renderContext)&&(t=null!=e.prepareTechnique(this._renderContext)||t)}));return t}_renderInternalSlot(e,r=this._materialRenderers){this._bindParameters.slot=e,r.forAll((e=>{if(e.material.shouldRender(this._renderContext)){const r=e.prepareTechnique(this._renderContext);r&&e.render(this._renderContext,r)}}))}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._bindParameters.ssao?.memoryUsage??0,vaos:this._materialRenderers.reduce(((e,r)=>e+r.usedMemory),0),plugins:this._renderPlugins.usedMemory}}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.edgeView?.usedMemory??0)+this._materialRenderers.reduce(((e,r)=>e+r.usedMemory),0)+this._renderPlugins.usedMemory}get test(){const e=this;return{offscreen:this._offscreen,shadowMap:this._shadowMap,highlight:this._highlight,lighting:this._bindParameters.lighting,materialRenderers:this._materialRenderers,shadowAccumulator:this._shadowAccumulator,weatherIsFading:this._bindParameters.cloudsFade.isFading,resetRenderStateFeatures:()=>{e._renderStateFeatures=Q(),this.renderPlugins.renderFeatureChanged(),this._requestRender()},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,"_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{AppleAmdDriverHelper as e}from"../../../webgl/AppleAmdDriverHelper.js";import{RenderingContext as r}from"../../../webgl/RenderingContext.js";class s extends r{constructor(e,r,s){super(e,r),this.gl=e,this.newCache=s,this._refCount=1,this._appleAmdDriverHelper=null}destroy(){--this._refCount>0||this.dispose()}ref(){++this._refCount}dispose(){super.dispose(),this._appleAmdDriverHelper?.dispose()}bindTechnique(e,r,s,t){return this.useProgram(e.program),e.bindPipelineState(this,s?.slot,!!t),e.program.bindPass(r,s),e.program}get appleAmdDriverHelper(){return this.driverTest.drawArraysRequiresIndicesTypeReset.result?(this._appleAmdDriverHelper=this._appleAmdDriverHelper??new e(this),this._appleAmdDriverHelper):null}get test(){return this.programCache.test}}export{s as RenderingContext};
5
+ import{ScreenSpaceGeometry as e}from"../effects/ScreenSpaceGeometry.js";import{AppleAmdDriverHelper as r}from"../../../webgl/AppleAmdDriverHelper.js";import{RenderingContext as s}from"../../../webgl/RenderingContext.js";class t extends s{constructor(r,s,t){super(r,s),this.gl=r,this.newCache=t,this._refCount=1,this._appleAmdDriverHelper=null,this.screen=new e(this)}destroy(){--this._refCount>0||this.dispose()}ref(){++this._refCount}dispose(){super.dispose(),this._appleAmdDriverHelper?.dispose(),this.screen.destroy()}bindTechnique(e,r,s,t){return this.useProgram(e.program),e.bindPipelineState(this,s?.slot,!!t),e.program.bindPass(r,s),e.program}get appleAmdDriverHelper(){return this.driverTest.drawArraysRequiresIndicesTypeReset.result?(this._appleAmdDriverHelper=this._appleAmdDriverHelper??new r(this),this._appleAmdDriverHelper):null}get test(){return{cachedWebGLObjects:this.programCache.test.cachedWebGLProgramObjects+this.screen.test.cachedWebGLObjects}}}export{t as RenderingContext};
@@ -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{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 m,DirtyState as c}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){const e=new g({material:i});e.initializeRenderContext(this.rendererContext.pluginContext,this._materialRepository),n=e,this._materialRenderers.push(n),r=!0,t=!0,s=!0}if(!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===m.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===m.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 c.TRANSFORMATION:case c.GEOMETRY:return this._notifyGraphicGeometryChanged(e);case c.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 m=new a(n,o,r),c=r=>{r.set(l.OVERLAY,m,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)&&c(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)&&c(i.results.max),i.options.store===h.ALL){const e=d(i.ray);c(e),i.results.all.push(e)}}const f=n();export{u 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 m,DirtyState as c}from"./ModelDirtyTypes.js";import{splitRenderGeometryChangeSetByMaterial as p}from"./rendererUtils.js";import{MergedRenderer as u}from"../materials/renderers/MergedRenderer.js";let g=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){const e=new u({material:i});e.initializeRenderContext(this.rendererContext.pluginContext,this._materialRepository),n=e,this._materialRenderers.push(n),r=!0,t=!0,s=!0}if(!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===m.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===m.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 c.TRANSFORMATION:case c.GEOMETRY:return this._notifyGraphicGeometryChanged(e);case c.VISIBILITY:return this._notifyGraphicVisibilityChanged(e)}}updateAnimation(e){let r=!1;return this._sortedMaterialRenderers.forAll((t=>r=t.updateAnimation(e)||r)),r}shouldRender(e){return this._sortedMaterialRenderers.some((r=>r.material.shouldRender(e)&&r.prepareTechnique(e)))}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()],g.prototype,"drapeSource",void 0),e([s()],g.prototype,"updating",null),e([s()],g.prototype,"rctx",null),e([s()],g.prototype,"rendererContext",void 0),e([s()],g.prototype,"_materialRepository",null),e([s()],g.prototype,"_localOriginFactory",null),e([s({readOnly:!0})],g.prototype,"isEmpty",null),e([s()],g.prototype,"_materialRenderers",void 0),e([s()],g.prototype,"_geometries",void 0),g=e([i("esri.views.3d.webgl-engine.lib.SortedRenderGeometryRenderer")],g);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 m=new a(n,o,r),c=r=>{r.set(l.OVERLAY,m,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)&&c(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)&&c(i.results.max),i.options.store===h.ALL){const e=d(i.ray);c(e),i.results.all.push(e)}}const f=n();export{g 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 e from"../../../../core/Evented.js";import t from"../../../../core/Handles.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import i from"../../../../core/PooledArray.js";import{ContentObject as r}from"./ContentObject.js";import{ContentObjectType as o}from"./ContentObjectType.js";import{DirtyEventNames as d}from"./DirtyEvents.js";import h from"./Octree.js";import{UpdatePolicy as c}from"./UpdatePolicy.js";class a extends r{get objects(){return this._objects}constructor(s,r,h=""){super(),this.stage=s,this.apiLayerUid=h,this.type=o.Layer,this.events=new e,this.visible=!0,this.pickable=!0,this.sliceable=!1,this._objects=new i,this._objectsAdded=new i,this._handles=new t,this.apiLayerUid=h,this.visible=r?.visible??!0,this.pickable=r?.pickable??!0,this.updatePolicy=r?.updatePolicy??c.ASYNC,this._disableOctree=r?.disableOctree??!1,s.add(this);for(const e of d)this._handles.add(this.events.on(e,(t=>s.handleEvent(e,t))))}destroy(){this._handles.size&&(this._handles.destroy(),this.stage.remove(this),this.invalidateSpatialQueryAccelerator())}add(e){this._objects.push(e),e.parentLayer=this,this.events.emit("layerObjectAdded",{layer:this,object:e}),null!=this._octree&&this._objectsAdded.push(e)}remove(e){this._objects.removeUnordered(e)&&(e.parentLayer=null,this.events.emit("layerObjectRemoved",{layer:this,object:e}),null!=this._octree&&(this._objectsAdded.removeUnordered(e)||this._octree.remove([e])))}addMany(e){this._objects.pushArray(e);for(const t of e)t.parentLayer=this;this.events.emit("layerObjectsAdded",{layer:this,objects:e}),null!=this._octree&&this._objectsAdded.pushArray(e)}removeMany(e){const t=new Array;if(this._objects.removeUnorderedMany(e,e.length,t),0!==t.length){for(const e of t)e.parentLayer=null;if(this.events.emit("layerObjectsRemoved",{layer:this,objects:t}),null!=this._octree){for(let e=0;e<t.length;)this._objectsAdded.removeUnordered(t[e])?(t[e]=t.at(-1),t.length-=1):++e;this._octree.remove(t)}}}sync(){this.updatePolicy!==c.SYNC&&this.stage.syncLayer(this.id)}notifyObjectBBChanged(e,t){null==this._octree||this._objectsAdded.includes(e)||this._octree.update(e,t)}getSpatialQueryAccelerator(){return null==this._octree&&this._objects.length>50&&!this._disableOctree?(this._octree=new h((e=>e.boundingVolumeWorldSpace.bounds)),this._octree.add(this._objects.data,this._objects.length)):null!=this._octree&&this._objectsAdded.length>0&&(this._octree.add(this._objectsAdded.data,this._objectsAdded.length),this._objectsAdded.clear()),this._octree}invalidateSpatialQueryAccelerator(){this._octree=s(this._octree),this._objectsAdded.clear()}}function n(e){return null!=e&&e.type===o.Layer}export{a as WebGLLayer,n as isWebGLLayer};
5
+ import e from"../../../../core/Evented.js";import t from"../../../../core/Handles.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import i from"../../../../core/PooledArray.js";import{ContentObject as r}from"./ContentObject.js";import{ContentObjectType as o}from"./ContentObjectType.js";import{DirtyEventNames as d}from"./DirtyEvents.js";import h from"./Octree.js";import{UpdatePolicy as c}from"./UpdatePolicy.js";class a extends r{get objects(){return this._objects}constructor(s,r,h=""){super(),this.stage=s,this.apiLayerUid=h,this.type=o.Layer,this.events=new e,this.visible=!0,this.pickable=!0,this.sliceable=!1,this._objects=new i,this._objectsAdded=new i,this._handles=new t,this.apiLayerUid=h,this.visible=r?.visible??!0,this.pickable=r?.pickable??!0,this.updatePolicy=r?.updatePolicy??c.ASYNC,this._disableOctree=r?.disableOctree??!1,s.add(this);for(const e of d)this._handles.add(this.events.on(e,(t=>s.handleEvent(e,t))))}destroy(){this._handles.size&&(this._handles.destroy(),this.stage.remove(this),this.invalidateSpatialQueryAccelerator())}add(e){this._objects.push(e),e.parentLayer=this,this.events.emit("layerObjectAdded",{layer:this,object:e}),null!=this._octree&&this._objectsAdded.push(e)}remove(e){this._objects.removeUnordered(e)&&(e.parentLayer=null,this.events.emit("layerObjectRemoved",{layer:this,object:e}),null!=this._octree&&(this._objectsAdded.removeUnordered(e)||this._octree.remove([e])))}addMany(e){this._objects.pushArray(e);for(const t of e)t.parentLayer=this;this.events.emit("layerObjectsAdded",{layer:this,objects:e}),null!=this._octree&&this._objectsAdded.pushArray(e)}removeMany(e){const t=new Array;if(this._objects.removeUnorderedMany(e,e.length,t),0!==t.length){for(const e of t)e.parentLayer=null;if(this.events.emit("layerObjectsRemoved",{layer:this,objects:t}),null!=this._octree){for(let e=0;e<t.length;)this._objectsAdded.removeUnordered(t[e])?(t[e]=t[t.length-1],t.length-=1):++e;this._octree.remove(t)}}}sync(){this.updatePolicy!==c.SYNC&&this.stage.syncLayer(this.id)}notifyObjectBBChanged(e,t){null==this._octree||this._objectsAdded.includes(e)||this._octree.update(e,t)}getSpatialQueryAccelerator(){return null==this._octree&&this._objects.length>50&&!this._disableOctree?(this._octree=new h((e=>e.boundingVolumeWorldSpace.bounds)),this._octree.add(this._objects.data,this._objects.length)):null!=this._octree&&this._objectsAdded.length>0&&(this._octree.add(this._objectsAdded.data,this._objectsAdded.length),this._objectsAdded.clear()),this._octree}invalidateSpatialQueryAccelerator(){this._octree=s(this._octree),this._objectsAdded.clear()}}function n(e){return null!=e&&e.type===o.Layer}export{a as WebGLLayer,n as isWebGLLayer};
@@ -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{isSome as t}from"../../../../../core/arrayUtils.js";import{destroyMaybe as r}from"../../../../../core/maybe.js";import{isAborted as a,throwIfAborted as n}from"../../../../../core/promiseUtils.js";import{property as s}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/has.js";import{subclass as i}from"../../../../../core/accessorSupport/decorators/subclass.js";import{c as o}from"../../../../../chunks/mat4f64.js";import{b as l,e as c,m as h}from"../../../../../chunks/vec3.js";import{c as d}from"../../../../../chunks/vec3f64.js";import{c as u,f as m}from"../../../../../chunks/vec4f64.js";import p from"../../../support/debugFlags.js";import{glLayout as f}from"../../../support/buffer/glUtil.js";import{newLayout as _}from"../../../support/buffer/InterleavedLayout.js";import{ShaderOutput as I}from"../../core/shaderLibrary/ShaderOutput.js";import{ASyncPreparesRenderPlugin as g}from"../../effects/RenderPlugin.js";import{Camera as y}from"../Camera.js";import{Default3D as C}from"../DefaultVertexAttributeLocations.js";import{IntersectorType as E}from"../IntersectorInterfaces.js";import v from"../Octree.js";import{RenderSlot as R}from"../RenderSlot.js";import{assert as A}from"../Util.js";import{VertexAttribute as D}from"../VertexAttribute.js";import{InstanceData as T,StateFlags as b}from"./InstanceData.js";import{InstanceOctree as L}from"./InstanceOctree.js";import{LevelSelector as S}from"./LevelSelector.js";import{LodLevel as O}from"./LodLevel.js";import{RenderInstanceData as N}from"./RenderInstanceData.js";import{colorMixModes as j}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as x}from"../../materials/renderers/utils.js";import{DefaultMaterialDrawParameters as M}from"../../shaders/DefaultMaterialTechnique.js";import{TaskPriority as U,noBudget as w}from"../../../../support/Scheduler.js";import{bindVertexBufferLayout as F,unbindVertexBufferLayout as V}from"../../../../webgl/Util.js";const H=e=>{const t=e.baseBoundingSphere.radius,r=e.levels.map((e=>e.minScreenSpaceRadius));return new S(t,r)};let B=class extends g{constructor(e,t){super(e),this.type=E.LOD,this.isGround=!1,this.renderSlots=[R.OPAQUE_MATERIAL,R.TRANSPARENT_MATERIAL],this._levels=[],this._defaultRenderInstanceData=[new Array],this._highlightRenderInstanceData=[new Array],this._allRenderInstanceData=[this._defaultRenderInstanceData[0],this._highlightRenderInstanceData[0]],this._instanceIndex=0,this._cycleStartIndex=0,this._slicePlane=!1,this._camera=new y,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this._instanceData=new T({shaderTransformation:e.shaderTransformation},e.optionalFields),this.addHandles(t.registerTask(U.LOD_RENDERER,this))}initialize(){this._instanceBufferLayout=G(this.optionalFields),this._glInstanceBufferLayout=f(this._instanceBufferLayout,1),this.addHandles([this._instanceData.events.on("instances-changed",(()=>this._requestUpdateCycle())),this._instanceData.events.on("instance-transform-changed",(({index:e})=>{this._requestUpdateCycle(),this.metadata.notifyGraphicGeometryChanged(e)})),this._instanceData.events.on("instance-visibility-changed",(({index:e})=>{this._requestUpdateCycle(!0),this.metadata.notifyGraphicVisibilityChanged(e)})),this._instanceData.events.on("instance-highlight-changed",(()=>this._requestUpdateCycle(!0)))])}get _enableLevelSelection(){return this.symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels.at(-1).boundingBox}get baseBoundingSphere(){return this._levels.at(-1).boundingSphere}get baseMaterial(){return this._levels.at(-1).components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerUid(){return this.metadata.layerUid}get instanceData(){return this._instanceData}get usedMemory(){return this._allRenderInstanceData.reduce(((e,t)=>t.reduce(((e,t)=>e+t.usedMemory),e)),0)}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach(((e,r)=>{const a=this._allRenderInstanceData[0][r].size+this._allRenderInstanceData[1][r].size,n=e.triangleCount;t.push({renderedInstances:a,renderedTriangles:a*n,trianglesPerInstance:n})})),{totalInstances:e,renderedInstances:t.reduce(((e,t)=>e+t.renderedInstances),0),renderedTriangles:t.reduce(((e,t)=>e+t.renderedTriangles),0),levels:t}}async initializeRenderContext(e,r){this._context=e;const s=e.renderContext.rctx,i=await Promise.allSettled(this.symbol.levels.map((t=>(this._defaultRenderInstanceData[0].push(new N(s,this._instanceBufferLayout)),this._highlightRenderInstanceData[0].push(new N(s,this._instanceBufferLayout)),O.create(e,t,r))))),o=i.map((e=>"fulfilled"===e.status?e.value:null)).filter(t);if(a(r)||o.length!==i.length){o.forEach((e=>e.destroy())),n(r);for(const e of i)if("rejected"===e.status)throw e.reason}this._levels=o,this._levelSelector=H(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach((e=>e.destroy())),this._defaultRenderInstanceData[0].forEach((e=>e.destroy())),this._highlightRenderInstanceData[0].forEach((e=>e.destroy()))}_hasTransparentLevels(){return this._levels.some((e=>e.components.some((e=>e.material.canRender(R.TRANSPARENT_MATERIAL,I.Color)))))}canRender(e){return e!==R.TRANSPARENT_MATERIAL||this._hasTransparentLevels()}requiresOutput(e){return(e===I.Highlight||e===I.ShadowHighlight)&&this._highlightRenderInstanceData[0].some((e=>e.size>0))}prepareRender(e){if(!p.LOD_INSTANCE_RENDERER_DISABLE_UPDATES){if(this._enableLevelSelection){const t=e.bindParameters.contentCamera.equals(this._camera);this._camera.copyFrom(e.bindParameters.contentCamera),t||this._requestUpdateCycle()}this._needFullCycle&&(this.runTask(w),this._needFullCycle=!1)}}prepareTechniques(e){if(!this.baseMaterial.isVisible()||!this.baseMaterial.isVisibleForOutput(e.output))return null;const t=this._getInstanceDatas(e.output);if(!t)return null;const r=new Array;return t.forEach((t=>this.levels.forEach(((a,n)=>{a.components.forEach((a=>r.push(this._beginComponent(e,t[n],a))))})))),r}render(e,t){const r=this._getInstanceDatas(e.output);if(!r||null==t)return;let a=0;e.rctx.bindVAO(),r.forEach((r=>this.levels.forEach(((n,s)=>{n.components.forEach((n=>this._renderComponent(e,t[a++],r[s],n,s)))}))))}_getInstanceDatas(e){const t=e!==I.Highlight&&e!==I.ShadowHighlight,r=e!==I.ShadowExcludeHighlight;return t&&r?this._allRenderInstanceData:t?this._defaultRenderInstanceData:r?this._highlightRenderInstanceData:null}intersect(e,t,r,a){if(!this.baseMaterial.isVisible()||null==this._octree)return;const n=d();l(n,a,r);const s=n=>{this._instanceData.getCombinedModelTransform(n,W),e.transform.set(W),h(K,r,e.transform.inverse),h(Y,a,e.transform.inverse);const s=this._instanceData.getState(n),i=this._instanceData.getLodLevel(n),o=this._levels.length;A(0!=(s&b.ACTIVE),"invalid instance state"),A(i>=0&&i<o,"invaid lod level"),this._levels[i].intersect(e,t,K,Y,n,this.metadata,o)};this.baseMaterial.parameters.verticalOffset?this._octree.forEach(s):this._octree.forEachAlongRay(r,n,s)}queryDepthRange(e){return this._queryDepthRangeOctree(e)}notifyShaderTransformationChanged(){this._invalidateOctree(),this._requestUpdateCycle()}get _octree(){if(null==this._octreeCached){const e=this._instanceData,t=e.view?.state;if(!t)return null;this._octreeCached=new L(e,this.baseBoundingSphere);for(let r=0;r<e.capacity;++r)t.get(r)&b.ACTIVE&&this._octreeCached.addInstance(r)}return this._octreeCached}_invalidateOctree(){this._octreeCached=r(this._octreeCached)}_queryDepthRangeOctree(e){if(null==this._octree)return{near:1/0,far:-1/0};const t=e.viewForward,r=this._octree.findClosest(t,v.DepthOrder.FRONT_TO_BACK,e.frustum),a=this._octree.findClosest(t,v.DepthOrder.BACK_TO_FRONT,e.frustum);if(null==r||null==a)return{near:1/0,far:-1/0};const n=e.eye,s=this._instanceData.view;s.boundingSphere.getVec(r,k),l(k,k,n);const i=c(k,t)-k[3];s.boundingSphere.getVec(a,k),l(k,k,n);const o=c(k,t)+k[3];return{near:Math.max(e.near,i),far:Math.min(e.far,o)}}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,this._cycleStartIndex=this._instanceIndex,e&&(this._needFullCycle=!0,this._context.requestRender())}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.startUpdateCycle()))))}get running(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}runTask(e){const{_enableLevelSelection:t,_camera:r,_levelSelector:a}=this;this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.beginUpdate()))));const n=this._instanceData,s=n.view;let i=n.size;const o=n.capacity;let l=this._instanceIndex;const c=Math.ceil(o/500);for(let h=0;h<i&&!e.done;++h){l===this._cycleStartIndex&&this._startUpdateCycle();const h=s.state.get(l);let d=0;if(!(h&b.ALLOCATED)){l=l+1===o?0:l+1,i++;continue}const u=s.lodLevel.get(l);if(h&b.DEFAULT_ACTIVE&&this._defaultRenderInstanceData[0][u].freeTail(),h&b.HIGHLIGHT_ACTIVE&&this._highlightRenderInstanceData[0][u].freeTail(),h&b.REMOVE)n.freeInstance(l);else if(h&b.VISIBLE){let e=0;t&&(s.modelOrigin.getVec(l,z),e=a.selectLevel(z,n.getCombinedMedianScaleFactor(l),r)),d=h&~(b.ACTIVE|b.TRANSFORM_CHANGED),e>=0&&(h&b.HIGHLIGHT?(P(this._highlightRenderInstanceData[0][e],s,l),d|=b.HIGHLIGHT_ACTIVE):(P(this._defaultRenderInstanceData[0][e],s,l),d|=b.DEFAULT_ACTIVE)),s.state.set(l,d),s.lodLevel.set(l,e)}else d=h&~(b.ACTIVE|b.TRANSFORM_CHANGED),s.state.set(l,d);if(null!=this._octreeCached){const e=!!(h&b.ACTIVE),t=!!(d&b.ACTIVE);!e&&t?this._octreeCached.addInstance(l):e&&!t?this._octreeCached.removeInstance(l):e&&t&&h&b.TRANSFORM_CHANGED&&(this._octreeCached.removeInstance(l),this._octreeCached.addInstance(l))}l=l+1===o?0:l+1,l%c==0&&e.madeProgress()}this._instanceIndex=l,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.endUpdate())))),this._context.requestRender()}_beginComponent(e,t,r){const{bindParameters:a,rctx:n,output:s}=e;if(0===t.size||!r.material.canRender(a.slot,e.output))return null;const i=r.glMaterials.load(n,a.slot,s);return null!=i?i.beginSlot(a):null}_renderComponent(e,t,r,a,n){if(!t)return;const{bindParameters:s,rctx:i}=e;i.appleAmdDriverHelper?.resetIndicesType();const o=i.bindTechnique(t,a.material.parameters,s);i.bindVAO(a.vao),t.ensureAttributeLocations(a.vao),o.bindDraw(Q,s,a.material.parameters),p.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&e.output===I.Color&&(o.setUniform4fv("externalColor",J[Math.min(n,J.length-1)]),o.setUniform1i("colorMixMode",j.replace));const l=r.capacity,c=r.headIndex,h=r.tailIndex,d=r.firstIndex,u=this._glInstanceBufferLayout,m=(e,n)=>{F(i,C,r.buffer,u,e),i.drawArraysInstanced(t.primitiveType,0,a.vertexCount,n-e),V(i,C,r.buffer,u)};a.material.parameters.transparent&&null!=d?c>h?(A(d>=h&&d<=c,"invalid firstIndex"),m(d,c),m(h,d)):c<h&&(d<=c?(A(d>=0&&d<=c,"invalid firstIndex"),m(d,c),m(h,l),m(0,d)):(A(d>=h&&d<=l,"invalid firstIndex"),m(d,l),m(0,c),m(h,d))):c>h?m(h,c):c<h&&(m(0,c),m(h,l)),i.bindVAO(null)}};function P(e,t,r){const a=e.allocateHead();q(t,r,e.view,a)}function q(e,t,r,a){x(e.modelOrigin,t,r.modelOriginHi,r.modelOriginLo,a),r.model.copyFrom(a,e.model,t),r.modelNormal.copyFrom(a,e.modelNormal,t),e.color&&r.color&&r.color.copyFrom(a,e.color,t),e.objectAndLayerIdColor&&r.objectAndLayerIdColor&&r.objectAndLayerIdColor.copyFrom(a,e.objectAndLayerIdColor,t),e.featureAttribute&&r.featureAttribute&&r.featureAttribute.copyFrom(a,e.featureAttribute,t)}function G(e){let t=_().vec3f(D.INSTANCEMODELORIGINHI).vec3f(D.INSTANCEMODELORIGINLO).mat3f(D.INSTANCEMODEL).mat3f(D.INSTANCEMODELNORMAL);return null!=e&&e.includes("featureAttribute")&&(t=t.vec4f(D.INSTANCEFEATUREATTRIBUTE)),null!=e&&e.includes("color")&&(t=t.vec4u8(D.INSTANCECOLOR)),null!=e&&e.includes("objectAndLayerIdColor")&&(t=t.vec4u8(D.INSTANCEOBJECTANDLAYERIDCOLOR)),t}e([s({constructOnly:!0})],B.prototype,"symbol",void 0),e([s({constructOnly:!0})],B.prototype,"optionalFields",void 0),e([s({constructOnly:!0})],B.prototype,"metadata",void 0),e([s({constructOnly:!0})],B.prototype,"shaderTransformation",void 0),e([s()],B.prototype,"_instanceData",void 0),e([s()],B.prototype,"_cycleStartIndex",void 0),e([s({readOnly:!0})],B.prototype,"_enableLevelSelection",null),e([s()],B.prototype,"_updateCyclesWithStaticCamera",void 0),e([s({readOnly:!0})],B.prototype,"running",null),B=e([i("esri.views.3d.webgl-engine.lib.lodRendering.LodRenderer")],B);const z=d(),k=u(),W=o(),K=d(),Y=d(),J=[m(1,0,1,1),m(0,0,1,1),m(0,1,0,1),m(1,1,0,1),m(1,0,0,1)],Q=new M;export{B as LodRenderer};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{isSome as t}from"../../../../../core/arrayUtils.js";import{destroyMaybe as r}from"../../../../../core/maybe.js";import{isAborted as a,throwIfAborted as n}from"../../../../../core/promiseUtils.js";import{property as s}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/has.js";import{subclass as i}from"../../../../../core/accessorSupport/decorators/subclass.js";import{c as o}from"../../../../../chunks/mat4f64.js";import{b as l,e as c,m as h}from"../../../../../chunks/vec3.js";import{c as d}from"../../../../../chunks/vec3f64.js";import{c as u,f as m}from"../../../../../chunks/vec4f64.js";import p from"../../../support/debugFlags.js";import{glLayout as _}from"../../../support/buffer/glUtil.js";import{newLayout as f}from"../../../support/buffer/InterleavedLayout.js";import{ShaderOutput as g}from"../../core/shaderLibrary/ShaderOutput.js";import{ASyncPreparesRenderPlugin as I}from"../../effects/RenderPlugin.js";import{Camera as y}from"../Camera.js";import{Default3D as C}from"../DefaultVertexAttributeLocations.js";import{IntersectorType as v}from"../IntersectorInterfaces.js";import E from"../Octree.js";import{RenderSlot as R}from"../RenderSlot.js";import{assert as A}from"../Util.js";import{VertexAttribute as D}from"../VertexAttribute.js";import{InstanceData as T,StateFlags as b}from"./InstanceData.js";import{InstanceOctree as L}from"./InstanceOctree.js";import{LevelSelector as S}from"./LevelSelector.js";import{LodLevel as O}from"./LodLevel.js";import{RenderInstanceData as N}from"./RenderInstanceData.js";import{colorMixModes as j}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as x}from"../../materials/renderers/utils.js";import{DefaultMaterialDrawParameters as M}from"../../shaders/DefaultMaterialTechnique.js";import{TaskPriority as U,noBudget as w}from"../../../../support/Scheduler.js";import{bindVertexBufferLayout as F,unbindVertexBufferLayout as V}from"../../../../webgl/Util.js";const H=e=>{const t=e.baseBoundingSphere.radius,r=e.levels.map((e=>e.minScreenSpaceRadius));return new S(t,r)};let B=class extends I{constructor(e,t){super(e),this.type=v.LOD,this.isGround=!1,this.renderSlots=[R.OPAQUE_MATERIAL,R.TRANSPARENT_MATERIAL],this._levels=[],this._defaultRenderInstanceData=[new Array],this._highlightRenderInstanceData=[new Array],this._allRenderInstanceData=[this._defaultRenderInstanceData[0],this._highlightRenderInstanceData[0]],this._instanceIndex=0,this._cycleStartIndex=0,this._slicePlane=!1,this._camera=new y,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this._instanceData=new T({shaderTransformation:e.shaderTransformation},e.optionalFields),this.addHandles(t.registerTask(U.LOD_RENDERER,this))}initialize(){this._instanceBufferLayout=G(this.optionalFields),this._glInstanceBufferLayout=_(this._instanceBufferLayout,1),this.addHandles([this._instanceData.events.on("instances-changed",(()=>this._requestUpdateCycle())),this._instanceData.events.on("instance-transform-changed",(({index:e})=>{this._requestUpdateCycle(),this.metadata.notifyGraphicGeometryChanged(e)})),this._instanceData.events.on("instance-visibility-changed",(({index:e})=>{this._requestUpdateCycle(!0),this.metadata.notifyGraphicVisibilityChanged(e)})),this._instanceData.events.on("instance-highlight-changed",(()=>this._requestUpdateCycle(!0)))])}get _enableLevelSelection(){return this.symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels[this._levels.length-1].boundingBox}get baseBoundingSphere(){return this._levels[this._levels.length-1].boundingSphere}get baseMaterial(){return this._levels[this._levels.length-1].components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerUid(){return this.metadata.layerUid}get instanceData(){return this._instanceData}get usedMemory(){return this._allRenderInstanceData.reduce(((e,t)=>t.reduce(((e,t)=>e+t.usedMemory),e)),0)}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach(((e,r)=>{const a=this._allRenderInstanceData[0][r].size+this._allRenderInstanceData[1][r].size,n=e.triangleCount;t.push({renderedInstances:a,renderedTriangles:a*n,trianglesPerInstance:n})})),{totalInstances:e,renderedInstances:t.reduce(((e,t)=>e+t.renderedInstances),0),renderedTriangles:t.reduce(((e,t)=>e+t.renderedTriangles),0),levels:t}}async initializeRenderContext(e,r){this._context=e;const s=e.renderContext.rctx,i=await Promise.allSettled(this.symbol.levels.map((t=>(this._defaultRenderInstanceData[0].push(new N(s,this._instanceBufferLayout)),this._highlightRenderInstanceData[0].push(new N(s,this._instanceBufferLayout)),O.create(e,t,r))))),o=i.map((e=>"fulfilled"===e.status?e.value:null)).filter(t);if(a(r)||o.length!==i.length){o.forEach((e=>e.destroy())),n(r);for(const e of i)if("rejected"===e.status)throw e.reason}this._levels=o,this._levelSelector=H(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach((e=>e.destroy())),this._defaultRenderInstanceData[0].forEach((e=>e.destroy())),this._highlightRenderInstanceData[0].forEach((e=>e.destroy()))}_hasTransparentLevels(){return this._levels.some((e=>e.components.some((e=>e.material.canRender(R.TRANSPARENT_MATERIAL,g.Color)))))}canRender(e){return e!==R.TRANSPARENT_MATERIAL||this._hasTransparentLevels()}requiresOutput(e){return(e===g.Highlight||e===g.ShadowHighlight)&&this._highlightRenderInstanceData[0].some((e=>e.size>0))}prepareRender(e){if(!p.LOD_INSTANCE_RENDERER_DISABLE_UPDATES){if(this._enableLevelSelection){const t=e.bindParameters.contentCamera.equals(this._camera);this._camera.copyFrom(e.bindParameters.contentCamera),t||this._requestUpdateCycle()}this._needFullCycle&&(this.runTask(w),this._needFullCycle=!1)}}prepareTechniques(e){if(!this.baseMaterial.isVisible()||!this.baseMaterial.isVisibleForOutput(e.output))return null;const t=this._getInstanceDatas(e.output);if(!t)return null;const r=new Array;return t.forEach((t=>this.levels.forEach(((a,n)=>{a.components.forEach((a=>r.push(this._beginComponent(e,t[n],a))))})))),r}render(e,t){const r=this._getInstanceDatas(e.output);if(!r||null==t)return;let a=0;e.rctx.bindVAO(),r.forEach((r=>this.levels.forEach(((n,s)=>{n.components.forEach((n=>this._renderComponent(e,t[a++],r[s],n,s)))}))))}_getInstanceDatas(e){const t=e!==g.Highlight&&e!==g.ShadowHighlight,r=e!==g.ShadowExcludeHighlight;return t&&r?this._allRenderInstanceData:t?this._defaultRenderInstanceData:r?this._highlightRenderInstanceData:null}intersect(e,t,r,a){if(!this.baseMaterial.isVisible()||null==this._octree)return;const n=d();l(n,a,r);const s=n=>{this._instanceData.getCombinedModelTransform(n,W),e.transform.set(W),h(K,r,e.transform.inverse),h(Y,a,e.transform.inverse);const s=this._instanceData.getState(n),i=this._instanceData.getLodLevel(n),o=this._levels.length;A(0!=(s&b.ACTIVE),"invalid instance state"),A(i>=0&&i<o,"invaid lod level"),this._levels[i].intersect(e,t,K,Y,n,this.metadata,o)};this.baseMaterial.parameters.verticalOffset?this._octree.forEach(s):this._octree.forEachAlongRay(r,n,s)}queryDepthRange(e){return this._queryDepthRangeOctree(e)}notifyShaderTransformationChanged(){this._invalidateOctree(),this._requestUpdateCycle()}get _octree(){if(null==this._octreeCached){const e=this._instanceData,t=e.view?.state;if(!t)return null;this._octreeCached=new L(e,this.baseBoundingSphere);for(let r=0;r<e.capacity;++r)t.get(r)&b.ACTIVE&&this._octreeCached.addInstance(r)}return this._octreeCached}_invalidateOctree(){this._octreeCached=r(this._octreeCached)}_queryDepthRangeOctree(e){if(null==this._octree)return{near:1/0,far:-1/0};const t=e.viewForward,r=this._octree.findClosest(t,E.DepthOrder.FRONT_TO_BACK,e.frustum),a=this._octree.findClosest(t,E.DepthOrder.BACK_TO_FRONT,e.frustum);if(null==r||null==a)return{near:1/0,far:-1/0};const n=e.eye,s=this._instanceData.view;s.boundingSphere.getVec(r,k),l(k,k,n);const i=c(k,t)-k[3];s.boundingSphere.getVec(a,k),l(k,k,n);const o=c(k,t)+k[3];return{near:Math.max(e.near,i),far:Math.min(e.far,o)}}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,this._cycleStartIndex=this._instanceIndex,e&&(this._needFullCycle=!0,this._context.requestRender())}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.startUpdateCycle()))))}get running(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}runTask(e){const{_enableLevelSelection:t,_camera:r,_levelSelector:a}=this;this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.beginUpdate()))));const n=this._instanceData,s=n.view;let i=n.size;const o=n.capacity;let l=this._instanceIndex;const c=Math.ceil(o/500);for(let h=0;h<i&&!e.done;++h){l===this._cycleStartIndex&&this._startUpdateCycle();const h=s.state.get(l);let d=0;if(!(h&b.ALLOCATED)){l=l+1===o?0:l+1,i++;continue}const u=s.lodLevel.get(l);if(h&b.DEFAULT_ACTIVE&&this._defaultRenderInstanceData[0][u].freeTail(),h&b.HIGHLIGHT_ACTIVE&&this._highlightRenderInstanceData[0][u].freeTail(),h&b.REMOVE)n.freeInstance(l);else if(h&b.VISIBLE){let e=0;t&&(s.modelOrigin.getVec(l,z),e=a.selectLevel(z,n.getCombinedMedianScaleFactor(l),r)),d=h&~(b.ACTIVE|b.TRANSFORM_CHANGED),e>=0&&(h&b.HIGHLIGHT?(P(this._highlightRenderInstanceData[0][e],s,l),d|=b.HIGHLIGHT_ACTIVE):(P(this._defaultRenderInstanceData[0][e],s,l),d|=b.DEFAULT_ACTIVE)),s.state.set(l,d),s.lodLevel.set(l,e)}else d=h&~(b.ACTIVE|b.TRANSFORM_CHANGED),s.state.set(l,d);if(null!=this._octreeCached){const e=!!(h&b.ACTIVE),t=!!(d&b.ACTIVE);!e&&t?this._octreeCached.addInstance(l):e&&!t?this._octreeCached.removeInstance(l):e&&t&&h&b.TRANSFORM_CHANGED&&(this._octreeCached.removeInstance(l),this._octreeCached.addInstance(l))}l=l+1===o?0:l+1,l%c==0&&e.madeProgress()}this._instanceIndex=l,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.endUpdate())))),this._context.requestRender()}_beginComponent(e,t,r){const{bindParameters:a,rctx:n,output:s}=e;if(0===t.size||!r.material.canRender(a.slot,e.output))return null;const i=r.glMaterials.load(n,a.slot,s);return null!=i?i.beginSlot(a):null}_renderComponent(e,t,r,a,n){if(!t)return;const{bindParameters:s,rctx:i}=e;i.appleAmdDriverHelper?.resetIndicesType();const o=i.bindTechnique(t,a.material.parameters,s);i.bindVAO(a.vao),t.ensureAttributeLocations(a.vao),o.bindDraw(Q,s,a.material.parameters),p.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&e.output===g.Color&&(o.setUniform4fv("externalColor",J[Math.min(n,J.length-1)]),o.setUniform1i("colorMixMode",j.replace));const l=r.capacity,c=r.headIndex,h=r.tailIndex,d=r.firstIndex,u=this._glInstanceBufferLayout,m=(e,n)=>{F(i,C,r.buffer,u,e),i.drawArraysInstanced(t.primitiveType,0,a.vertexCount,n-e),V(i,C,r.buffer,u)};a.material.parameters.transparent&&null!=d?c>h?(A(d>=h&&d<=c,"invalid firstIndex"),m(d,c),m(h,d)):c<h&&(d<=c?(A(d>=0&&d<=c,"invalid firstIndex"),m(d,c),m(h,l),m(0,d)):(A(d>=h&&d<=l,"invalid firstIndex"),m(d,l),m(0,c),m(h,d))):c>h?m(h,c):c<h&&(m(0,c),m(h,l)),i.bindVAO(null)}};function P(e,t,r){const a=e.allocateHead();q(t,r,e.view,a)}function q(e,t,r,a){x(e.modelOrigin,t,r.modelOriginHi,r.modelOriginLo,a),r.model.copyFrom(a,e.model,t),r.modelNormal.copyFrom(a,e.modelNormal,t),e.color&&r.color&&r.color.copyFrom(a,e.color,t),e.objectAndLayerIdColor&&r.objectAndLayerIdColor&&r.objectAndLayerIdColor.copyFrom(a,e.objectAndLayerIdColor,t),e.featureAttribute&&r.featureAttribute&&r.featureAttribute.copyFrom(a,e.featureAttribute,t)}function G(e){let t=f().vec3f(D.INSTANCEMODELORIGINHI).vec3f(D.INSTANCEMODELORIGINLO).mat3f(D.INSTANCEMODEL).mat3f(D.INSTANCEMODELNORMAL);return null!=e&&e.includes("featureAttribute")&&(t=t.vec4f(D.INSTANCEFEATUREATTRIBUTE)),null!=e&&e.includes("color")&&(t=t.vec4u8(D.INSTANCECOLOR)),null!=e&&e.includes("objectAndLayerIdColor")&&(t=t.vec4u8(D.INSTANCEOBJECTANDLAYERIDCOLOR)),t}e([s({constructOnly:!0})],B.prototype,"symbol",void 0),e([s({constructOnly:!0})],B.prototype,"optionalFields",void 0),e([s({constructOnly:!0})],B.prototype,"metadata",void 0),e([s({constructOnly:!0})],B.prototype,"shaderTransformation",void 0),e([s()],B.prototype,"_instanceData",void 0),e([s()],B.prototype,"_cycleStartIndex",void 0),e([s({readOnly:!0})],B.prototype,"_enableLevelSelection",null),e([s()],B.prototype,"_updateCyclesWithStaticCamera",void 0),e([s({readOnly:!0})],B.prototype,"running",null),B=e([i("esri.views.3d.webgl-engine.lib.lodRendering.LodRenderer")],B);const z=d(),k=u(),W=o(),K=d(),Y=d(),J=[m(1,0,1,1),m(0,0,1,1),m(0,1,0,1),m(1,1,0,1),m(1,0,0,1)],Q=new M;export{B as LodRenderer};
@@ -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 r from"../../../../core/Evented.js";import has from"../../../../core/has.js";import i from"../../../../core/Logger.js";import{removeMaybe as s,destroyMaybe as o}from"../../../../core/maybe.js";import{watch as n,initial as a,syncAndInitial as p}from"../../../../core/reactiveUtils.js";import{addFrameTask as h}from"../../../../core/scheduling.js";import{Milliseconds as d}from"../../../../core/time.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as l}from"../../../../core/accessorSupport/decorators/subclass.js";import{ComponentObjectCollection as m}from"../collections/Component/ComponentObjectCollection.js";import{ShaderTechniqueRepository as u}from"../core/shaderTechnique/ShaderTechniqueRepository.js";import{ScreenSpaceGeometry as _}from"../effects/ScreenSpaceGeometry.js";import{RenderRequestType as y,Decorations as f}from"../lib/basicInterfaces.js";import R from"../lib/CompositingHelper.js";import{textureToDepth as g}from"../lib/depthRangeUtils.js";import{GLMaterialRepository as x}from"../lib/GLMaterialRepository.js";import{MagnifierHelper as b}from"../lib/MagnifierHelper.js";import{UpdateParameters as j}from"../lib/Material.js";import{ObjectAndLayerIdRenderHelper as v}from"../lib/ObjectAndLayerIdRenderHelper.js";import{Renderer as w}from"../lib/Renderer.js";import{RenderingContext as T}from"../lib/RenderingContext.js";import{TextureRepository as A}from"../lib/TextureRepository.js";import{createMarkerTextureRepository as C}from"../materials/markerTextureRepository.js";import{createStippleTextureRepository as D}from"../materials/stippleTextureRepository.js";import{WaterTextureRepository as U}from"../materials/internal/WaterTextureRepository.js";import{getContextCache as O}from"./contextCache.js";import{removeLoadedShaderModules as q}from"./requireUtils.js";import{ScreenshotManager as S,ScreenshotContext as L}from"./ScreenshotManager.js";import{contextCache as H}from"./testUtils.js";import{RenderState as k}from"../../../support/RenderState.js";import{createContextForView as M}from"../../../webgl/contextUtils.js";import G from"../../../webgl/capabilities/isWebGL2Context.js";let W=class extends t{constructor(e){super({}),this.events=new r,this.waterTextureRepository=new U,this._magnifierHelper=new b,this.objectAndLayerIdRenderHelper=has("enable-feature:objectAndLayerId-rendering")?new v:null,this._needsUpdate=!0,this._needsRender=!0,this._idleSuspend=!0,this._needsWaterReflectionUpdate=!1,this._lastAnimationUpdate=0,this._container=e.container,this._viewingMode=e.viewingMode,this._initializeContext(e),this.addHandles([n((()=>this.waterTextureRepository?.updating),(()=>this.requestRender()),a),n((()=>e.view.qualityProfile),(e=>this.renderer?.updateRenderFeatures(e)),p),this._magnifierHelper.events.on("request-render",(()=>this.requestRender()))]);const{memoryController:t}=e.view.resourceController;this.stippleTextureRepository=D(this._rctx,t),this.markerTextureRepository=C(this._rctx,t),this._shaderTechniqueRepository=new u({rctx:this._rctx,viewingMode:e.viewingMode,stippleTextureRepository:this.stippleTextureRepository,waterTextureRepository:this.waterTextureRepository,markerTextureRepository:this.markerTextureRepository}),this._textureRepository=new A(e,this._shaderTechniqueRepository,this._rctx),this.addHandles(this._textureRepository.events.on("changed",(e=>this.requestRender(e)))),this._materialRepository=new x(this._textureRepository,this._shaderTechniqueRepository,(()=>this.requestRender()),(()=>this.requestRender())),this._screenGeometry=new _(this._rctx),this._compositingHelper=new R(this._rctx,this._shaderTechniqueRepository,this._screenGeometry),this.renderer=new w(e,this._materialRepository,this._textureRepository,this._shaderTechniqueRepository,this._rctx,this._compositingHelper,this._screenGeometry,this._magnifierHelper,(e=>this.requestRender(e)));const i={renderScene:(e,t,r,i,s)=>this.renderer.render(e,t,r,i,s),requestRenderScene:e=>this.requestRender(e),prepareOverlay:()=>e.options.screenshot.prepareOverlay(),renderOverlay:(t,r,i)=>e.options.screenshot.renderOverlay(t,r,i)};this._screenshotManager=new S(this._rctx,i,(e=>this.events.emit("force-camera-for-screenshot",e)),(()=>this.renderer.disposeOffscreenBuffers())),this._registerFrameTask(e)}normalizeCtorArgs(){return{}}destroy(){this._container.contains(this._canvas)&&this._container.removeChild(this._canvas),this._frameTask=s(this._frameTask),this._shaderTechniqueRepository=o(this._shaderTechniqueRepository)}requestRender(e=y.UPDATE){this._needsRender=!0,e===y.UPDATE&&(this._needsUpdate=!0)}get updating(){return this._needsUpdate||this._needsWaterReflectionUpdate||this.renderer.updating||this._textureRepository.updating||this.waterTextureRepository.updating||this._magnifierHelper.updating}get textureRepository(){return this._textureRepository}get compositingHelper(){return this._compositingHelper}set magnifier(e){this._magnifierHelper.magnifier=e}setIdleSuspend(e){this._idleSuspend!==e&&(this._idleSuspend=e,this.requestRender())}get renderingContext(){return this._rctx}get capabilities(){return this._rctx.capabilities}get canvas(){return this._canvas}takeScreenshot(e){return this._screenshotManager.takeScreenshot(e).then((e=>e[0]))}takeScreenshotWithOID(e){return e.objectAndLayerIdColor=!0,this._screenshotManager.takeScreenshot(e)}getAlpha(){return!!this._rctx.contextAttributes.alpha}getMinimalDepthForArea(e,t,r,i,s,o=s){const n=i.constrainWindowSize(t,r,s*i.pixelRatio,o*i.pixelRatio),a=this._ensureDepthBuffer(n);this.renderer.readDepthPixels(i,n,a);let p=Number.MAX_VALUE;for(let h=0;h<n[2]*n[3];h++){const e=g(4*h,a,i.nearFar);p>e&&e!==i.nearFar[0]&&e!==i.nearFar[1]&&(p=e)}if(null!=e){const s=e.pickDepth(t*i.pixelRatio,r*i.pixelRatio,i);null!=s&&p>s&&s!==i.nearFar[0]&&s!==i.nearFar[1]&&(p=s)}return p===Number.MAX_VALUE?void 0:p}_ensureDepthBuffer(e){const t=4*e[2]*e[3];return(null==this._tmpDepthBuffer||this._tmpDepthBuffer.byteLength<t)&&(this._tmpDepthBuffer=new Uint8Array(t)),this._tmpDepthBuffer}async reloadShaders(){q(),await this._shaderTechniqueRepository.reloadAll(),this.requestRender()}_registerFrameTask(e){const t=e.view.state;let r=!1,i=y.BACKGROUND,s=!1;const o={preRender:({time:s})=>{r=this.updating,i=this._needsUpdate?y.UPDATE:y.BACKGROUND,e.commitSyncLayers();const o=d(s-this._lastAnimationUpdate);if(o>this.renderer.animationTimestep||null!=t.forcedAnimationTime||r||this._needsRender){const e=d(o/this.renderer.animationTimeDilation),r=new j(t.camera,e,t.forcedAnimationTime);this.renderer.updateAnimation(r)&&this.requestRender(y.BACKGROUND),this._lastAnimationUpdate=s}},render:({time:e})=>{if((this._needsRender||!this._idleSuspend||!this.renderer.isCameraFinal||this._needsWaterReflectionUpdate)&&t.camera.fullWidth>0&&t.camera.fullHeight>0){const r=this._needsUpdate&&this._idleSuspend&&this.renderer.isCameraFinal;this._needsRender=!1,this._needsUpdate=!1,this._needsWaterReflectionUpdate=!1,this.renderer.render(null,null,t,f.ON,e),s=!0,r&&this.renderer.hasReflections&&(this.requestRender(y.BACKGROUND),this._needsWaterReflectionUpdate=!0)}},update:({time:e})=>{const r=this.renderer.hasSlicePlane||this._magnifierHelper.enabled||this.renderer.hasDecorations||this.renderer.hasHighlights,i=new L(t,r);this._textureRepository.update(),this._screenshotManager.update(i,e)},finish:()=>{s&&(this.renderer.finish(t.mode===k.IDLE?i:y.UPDATE),s=!1)}};this._frameTask=h(o)}_initializeContext(e){const t=e.options;this._canvas=t.canvas,this._canvas||(this._canvas=document.createElement("canvas")),this._canvas.setAttribute("style","width: 100%; height:100%; display:block;");const r={alpha:t.alpha||!1,premultipliedAlpha:!0,antialias:!1,depth:!0,stencil:t.stencil??!0,powerPreference:"high-performance",preserveDrawingBuffer:t.preserveDrawingBuffer??!1},s=M("3d",this._canvas,r);null!=s&&G(s)?(this._rctx=this._newRenderingContext(s,e),this._loadShaderOnlyExtensions(),!t.alpha&&this._rctx.contextAttributes.alpha&&i.getLogger(this).error("WebGL context has alpha channel even though no alpha channel was requested"),!this._rctx.contextAttributes.alpha&&has("safari")>=11&&(this._container.style.backgroundColor="black"),this._container.appendChild(this._canvas)):i.getLogger(this).error("A WebGL2 context could not be created.")}_newRenderingContext(e,t){const r={disabledExtensions:t.options.deactivatedWebGLExtensions||{},debugWebGLExtensions:t.options.debugWebGLExtensions||{},maxAnisotropy:8},i=(e,r)=>t.view.resourceController.memoryController.newCache(e,r);if(H.enabled){let t=E.get(e);return t?(t.configure(r),t.newCache=i,t.ref(),t):(t=new T(e,r,i),E.set(e,t),t.ref(),t)}return new T(e,r,i)}_loadShaderOnlyExtensions(){this._rctx.capabilities.enable("textureFloat")}getObjectAndLayerIdColor(e){return null!=this.objectAndLayerIdRenderHelper?this.objectAndLayerIdRenderHelper.getObjectAndLayerIdColor(e):null}get componentObjectCollection(){return null==this._componentObjectCollection&&(this._componentObjectCollection=new m(this.renderer.renderPassManager,this._viewingMode)),this._componentObjectCollection}set componentObjectCollection(e){this._componentObjectCollection=e}};e([c({type:Boolean,readOnly:!0})],W.prototype,"updating",null),e([c({autoDestroy:!0})],W.prototype,"_rctx",void 0),e([c({autoDestroy:!0})],W.prototype,"_container",void 0),e([c({autoDestroy:!0})],W.prototype,"_canvas",void 0),e([c({autoDestroy:!0})],W.prototype,"stippleTextureRepository",void 0),e([c({autoDestroy:!0})],W.prototype,"markerTextureRepository",void 0),e([c({autoDestroy:!0})],W.prototype,"waterTextureRepository",void 0),e([c({autoDestroy:!0})],W.prototype,"_magnifierHelper",void 0),e([c({readOnly:!0})],W.prototype,"objectAndLayerIdRenderHelper",void 0),e([c({autoDestroy:!0})],W.prototype,"_textureRepository",void 0),e([c({autoDestroy:!0})],W.prototype,"_screenGeometry",void 0),e([c({autoDestroy:!0,readOnly:!0})],W.prototype,"renderer",void 0),e([c({autoDestroy:!0})],W.prototype,"_screenshotManager",void 0),e([c()],W.prototype,"componentObjectCollection",null),e([c({autoDestroy:!0})],W.prototype,"_componentObjectCollection",void 0),e([c()],W.prototype,"_needsUpdate",void 0),e([c()],W.prototype,"_needsWaterReflectionUpdate",void 0),W=e([l("esri.views.3d.webgl-engine.parts.RenderView")],W);const E=O();export{W as RenderView};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import r from"../../../../core/Evented.js";import has from"../../../../core/has.js";import i from"../../../../core/Logger.js";import{removeMaybe as s,destroyMaybe as o}from"../../../../core/maybe.js";import{watch as n,initial as a,syncAndInitial as p}from"../../../../core/reactiveUtils.js";import{addFrameTask as h}from"../../../../core/scheduling.js";import{Milliseconds as d}from"../../../../core/time.js";import{property as l}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{ComponentObjectCollection as u}from"../collections/Component/ComponentObjectCollection.js";import{ShaderTechniqueRepository as m}from"../core/shaderTechnique/ShaderTechniqueRepository.js";import{RenderRequestType as _,Decorations as y}from"../lib/basicInterfaces.js";import f from"../lib/CompositingHelper.js";import{textureToDepth as R}from"../lib/depthRangeUtils.js";import{GLMaterialRepository as g}from"../lib/GLMaterialRepository.js";import{MagnifierHelper as x}from"../lib/MagnifierHelper.js";import{UpdateParameters as b}from"../lib/Material.js";import{ObjectAndLayerIdRenderHelper as j}from"../lib/ObjectAndLayerIdRenderHelper.js";import{Renderer as v}from"../lib/Renderer.js";import{RenderingContext as w}from"../lib/RenderingContext.js";import{TextureRepository as T}from"../lib/TextureRepository.js";import{createMarkerTextureRepository as A}from"../materials/markerTextureRepository.js";import{createStippleTextureRepository as C}from"../materials/stippleTextureRepository.js";import{WaterTextureRepository as D}from"../materials/internal/WaterTextureRepository.js";import{getContextCache as U}from"./contextCache.js";import{removeLoadedShaderModules as O}from"./requireUtils.js";import{ScreenshotManager as q,ScreenshotContext as L}from"./ScreenshotManager.js";import{contextCache as S}from"./testUtils.js";import{RenderState as H}from"../../../support/RenderState.js";import{createContextForView as k}from"../../../webgl/contextUtils.js";import M from"../../../webgl/capabilities/isWebGL2Context.js";let W=class extends t{constructor(e){super({}),this.events=new r,this.waterTextureRepository=new D,this._magnifierHelper=new x,this.objectAndLayerIdRenderHelper=has("enable-feature:objectAndLayerId-rendering")?new j:null,this._needsUpdate=!0,this._needsRender=!0,this._idleSuspend=!0,this._needsWaterReflectionUpdate=!1,this._lastAnimationUpdate=0,this._container=e.container,this._viewingMode=e.viewingMode,this._initializeContext(e),this.addHandles([n((()=>this.waterTextureRepository?.updating),(()=>this.requestRender()),a),n((()=>e.view.qualityProfile),(e=>this.renderer?.updateRenderFeatures(e)),p),this._magnifierHelper.events.on("request-render",(()=>this.requestRender()))]);const{memoryController:t}=e.view.resourceController;this.stippleTextureRepository=C(this._rctx,t),this.markerTextureRepository=A(this._rctx,t),this._shaderTechniqueRepository=new m({rctx:this._rctx,viewingMode:e.viewingMode,stippleTextureRepository:this.stippleTextureRepository,waterTextureRepository:this.waterTextureRepository,markerTextureRepository:this.markerTextureRepository}),this._textureRepository=new T(e,this._shaderTechniqueRepository,this._rctx),this.addHandles(this._textureRepository.events.on("changed",(e=>this.requestRender(e)))),this._materialRepository=new g(this._textureRepository,this._shaderTechniqueRepository,(()=>this.requestRender()),(()=>this.requestRender())),this._compositingHelper=new f(this._rctx,this._shaderTechniqueRepository),this.renderer=new v(e,this._materialRepository,this._textureRepository,this._shaderTechniqueRepository,this._rctx,this._compositingHelper,this._magnifierHelper,(e=>this.requestRender(e)));const i={renderScene:(e,t,r,i,s)=>this.renderer.render(e,t,r,i,s),requestRenderScene:e=>this.requestRender(e),prepareOverlay:()=>e.options.screenshot.prepareOverlay(),renderOverlay:(t,r,i)=>e.options.screenshot.renderOverlay(t,r,i)};this._screenshotManager=new q(this._rctx,i,(e=>this.events.emit("force-camera-for-screenshot",e)),(()=>this.renderer.disposeOffscreenBuffers())),this._registerFrameTask(e)}normalizeCtorArgs(){return{}}destroy(){this._container.contains(this._canvas)&&this._container.removeChild(this._canvas),this._frameTask=s(this._frameTask),this._shaderTechniqueRepository=o(this._shaderTechniqueRepository)}requestRender(e=_.UPDATE){this._needsRender=!0,e===_.UPDATE&&(this._needsUpdate=!0)}get updating(){return this._needsUpdate||this._needsWaterReflectionUpdate||this.renderer.updating||this._textureRepository.updating||this.waterTextureRepository.updating||this._magnifierHelper.updating}get textureRepository(){return this._textureRepository}get compositingHelper(){return this._compositingHelper}set magnifier(e){this._magnifierHelper.magnifier=e}setIdleSuspend(e){this._idleSuspend!==e&&(this._idleSuspend=e,this.requestRender())}get renderingContext(){return this._rctx}get capabilities(){return this._rctx.capabilities}get canvas(){return this._canvas}takeScreenshot(e){return this._screenshotManager.takeScreenshot(e).then((e=>e[0]))}takeScreenshotWithOID(e){return e.objectAndLayerIdColor=!0,this._screenshotManager.takeScreenshot(e)}getAlpha(){return!!this._rctx.contextAttributes.alpha}getMinimalDepthForArea(e,t,r,i,s,o=s){const n=i.constrainWindowSize(t,r,s*i.pixelRatio,o*i.pixelRatio),a=this._ensureDepthBuffer(n);this.renderer.readDepthPixels(i,n,a);let p=Number.MAX_VALUE;for(let h=0;h<n[2]*n[3];h++){const e=R(4*h,a,i.nearFar);p>e&&e!==i.nearFar[0]&&e!==i.nearFar[1]&&(p=e)}if(null!=e){const s=e.pickDepth(t*i.pixelRatio,r*i.pixelRatio,i);null!=s&&p>s&&s!==i.nearFar[0]&&s!==i.nearFar[1]&&(p=s)}return p===Number.MAX_VALUE?void 0:p}_ensureDepthBuffer(e){const t=4*e[2]*e[3];return(null==this._tmpDepthBuffer||this._tmpDepthBuffer.byteLength<t)&&(this._tmpDepthBuffer=new Uint8Array(t)),this._tmpDepthBuffer}async reloadShaders(){O(),await this._shaderTechniqueRepository.reloadAll(),this.requestRender()}_registerFrameTask(e){const t=e.view.state;let r=!1,i=_.BACKGROUND,s=!1;const o={preRender:({time:s})=>{r=this.updating,i=this._needsUpdate?_.UPDATE:_.BACKGROUND,e.commitSyncLayers();const o=d(s-this._lastAnimationUpdate);if(o>this.renderer.animationTimestep||null!=t.forcedAnimationTime||r||this._needsRender){const e=d(o/this.renderer.animationTimeDilation),r=new b(t.camera,e,t.forcedAnimationTime);this.renderer.updateAnimation(r)&&this.requestRender(_.BACKGROUND),this._lastAnimationUpdate=s}},render:({time:e})=>{if((this._needsRender||!this._idleSuspend||!this.renderer.isCameraFinal||this._needsWaterReflectionUpdate)&&t.camera.fullWidth>0&&t.camera.fullHeight>0){const r=this._needsUpdate&&this._idleSuspend&&this.renderer.isCameraFinal;this._needsRender=!1,this._needsUpdate=!1,this._needsWaterReflectionUpdate=!1,this.renderer.render(null,null,t,y.ON,e),s=!0,r&&this.renderer.hasReflections&&(this.requestRender(_.BACKGROUND),this._needsWaterReflectionUpdate=!0)}},update:({time:e})=>{const r=this.renderer.hasSlicePlane||this._magnifierHelper.enabled||this.renderer.hasDecorations||this.renderer.hasHighlights,i=new L(t,r);this._textureRepository.update(),this._screenshotManager.update(i,e)},finish:()=>{s&&(this.renderer.finish(t.mode===H.IDLE?i:_.UPDATE),s=!1)}};this._frameTask=h(o)}_initializeContext(e){const t=e.options;this._canvas=t.canvas,this._canvas||(this._canvas=document.createElement("canvas")),this._canvas.setAttribute("style","width: 100%; height:100%; display:block;");const r={alpha:t.alpha||!1,premultipliedAlpha:!0,antialias:!1,depth:!0,stencil:t.stencil??!0,powerPreference:"high-performance",preserveDrawingBuffer:t.preserveDrawingBuffer??!1},s=k("3d",this._canvas,r);null!=s&&M(s)?(this._rctx=this._newRenderingContext(s,e),this._loadShaderOnlyExtensions(),!t.alpha&&this._rctx.contextAttributes.alpha&&i.getLogger(this).error("WebGL context has alpha channel even though no alpha channel was requested"),!this._rctx.contextAttributes.alpha&&has("safari")>=11&&(this._container.style.backgroundColor="black"),this._container.appendChild(this._canvas)):i.getLogger(this).error("A WebGL2 context could not be created.")}_newRenderingContext(e,t){const r={disabledExtensions:t.options.deactivatedWebGLExtensions||{},debugWebGLExtensions:t.options.debugWebGLExtensions||{},maxAnisotropy:8},i=(e,r)=>t.view.resourceController.memoryController.newCache(e,r);if(S.enabled){let t=E.get(e);return t?(t.configure(r),t.newCache=i,t.ref(),t):(t=new w(e,r,i),E.set(e,t),t.ref(),t)}return new w(e,r,i)}_loadShaderOnlyExtensions(){this._rctx.capabilities.enable("textureFloat")}getObjectAndLayerIdColor(e){return null!=this.objectAndLayerIdRenderHelper?this.objectAndLayerIdRenderHelper.getObjectAndLayerIdColor(e):null}get componentObjectCollection(){return null==this._componentObjectCollection&&(this._componentObjectCollection=new u(this.renderer.renderPassManager,this._viewingMode)),this._componentObjectCollection}set componentObjectCollection(e){this._componentObjectCollection=e}};e([l({type:Boolean,readOnly:!0})],W.prototype,"updating",null),e([l({autoDestroy:!0})],W.prototype,"_rctx",void 0),e([l({autoDestroy:!0})],W.prototype,"_container",void 0),e([l({autoDestroy:!0})],W.prototype,"_canvas",void 0),e([l({autoDestroy:!0})],W.prototype,"stippleTextureRepository",void 0),e([l({autoDestroy:!0})],W.prototype,"markerTextureRepository",void 0),e([l({autoDestroy:!0})],W.prototype,"waterTextureRepository",void 0),e([l({autoDestroy:!0})],W.prototype,"_magnifierHelper",void 0),e([l({readOnly:!0})],W.prototype,"objectAndLayerIdRenderHelper",void 0),e([l({autoDestroy:!0})],W.prototype,"_textureRepository",void 0),e([l({autoDestroy:!0,readOnly:!0})],W.prototype,"renderer",void 0),e([l({autoDestroy:!0})],W.prototype,"_screenshotManager",void 0),e([l()],W.prototype,"componentObjectCollection",null),e([l({autoDestroy:!0})],W.prototype,"_componentObjectCollection",void 0),e([l()],W.prototype,"_needsUpdate",void 0),e([l()],W.prototype,"_needsWaterReflectionUpdate",void 0),W=e([c("esri.views.3d.webgl-engine.parts.RenderView")],W);const E=U();export{W as RenderView};
@@ -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
- function e(){const e=globalThis.require?.modules;if(e){const o=Object.keys(e);for(const s of o)-1!==s.search(".glsl")&&delete e[s]}}export{e as removeLoadedShaderModules};
5
+ function e(){const e=globalThis.require?.modules;if(e){const o=Object.keys(e);for(const s of o)s.includes(".glsl")&&delete e[s]}}export{e as removeLoadedShaderModules};
package/views/MapView.js CHANGED
@@ -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"../Viewpoint.js";import i from"../core/Collection.js";import r from"../core/CollectionFlattener.js";import s from"../core/Error.js";import has from"../core/has.js";import a from"../core/Logger.js";import{destroyMaybe as n}from"../core/maybe.js";import{watch as o,sync as p,syncAndInitial as l}from"../core/reactiveUtils.js";import{initialize as h}from"../core/workers/workers.js";import{property as g}from"../core/accessorSupport/decorators/property.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import"../core/arrayUtils.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import{ensureClass as c}from"../core/accessorSupport/ensureType.js";import{canProjectWithoutEngine as m,isLoadedOrLoad as y}from"../geometry/projection.js";import f from"../layers/support/TileInfo.js";import{BreakpointsOwner as w}from"./BreakpointsOwner.js";import{DOMContainer as M}from"./DOMContainer.js";import{PopupView as V}from"./PopupView.js";import v from"./View.js";import _ from"./2d/AnimationManager.js";import T from"./2d/FrameTask.js";import{GoToManager as b}from"./2d/GoToManager.js";import{layerView2DImporter as S}from"./2d/layerViewModuleImportUtils.js";import j from"./2d/MapViewConstraints.js";import"./2d/tiling/PagedTileQueue.js";import O from"./2d/tiling/TileInfoView.js";import"./2d/tiling/TileKey.js";import"./2d/tiling/TileQueue.js";import"./2d/tiling/TileStrategy.js";import{extentToScale as L}from"./2d/viewpointUtils.js";import{ViewStateManager as R}from"./2d/ViewStateManager.js";import k from"./2d/input/MapViewInputManager.js";import C from"./2d/layers/features/support/TileStore.js";import x from"./2d/support/HighlightOptions.js";import{hitTest as P}from"./2d/support/hitTestUtils.js";import{takeRawScreenshot as E,takeScreenshot as D}from"./2d/support/screenshotUtils.js";import{Timeline as z}from"./2d/support/Timeline.js";import{isSupportedScreenPointEvent as G,createScreenPointFromSupportedEvent as U}from"./support/screenUtils.js";import{check as q}from"./support/WebGLRequirements.js";import I from"./ui/DefaultUI.js";import N from"./ui/2d/DefaultUI2D.js";import F from"../webmap/background/ColorBackground.js";let A,W,$,H,B,Q;async function J(){const[,{GraphicsView2D:e,GraphicContainer:t,LabelManager:i,MapViewNavigation:r,MagnifierView2D:s,Stage:a}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);W=e,$=t,H=i,B=r,Q=s,A=a}const K=160;let X=class extends(w(V(M(v)))){constructor(e){super(e),this._magnifierView=null,this.stage=null,this._resolveWhenReady=[],this.rootLayerViews=new r({getCollections:()=>[this.basemapView?.baseLayerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:()=>null}),this.featuresTilingScheme=null,this.fullOpacity=1,this.goToManager=new b({view:this}),this.graphicsView=null,this.stateManager=new R({constraints:new j({view:this})}),this.labelManager=null,this.mapViewNavigation=null,this.renderingOptions={samplingMode:"dynamic",edgeLabelsVisible:!0,labelsAnimationTime:125,labelCollisionsEnabled:!0},this.supersampleScreenshotsEnabled=!0,this.supportsGround=!1,this._stationaryTimer=null,this.frameTask=new T(this),this.floors=new i,this.highlightOptions=new x,this.inputManager=new k({view:this}),this.map=null,this.spatialReferenceLocked=!1,this.timeline=new z,this.type="2d",this.ui=new N,this.test={takeScreenshot:async e=>E(this,e)},this.padding={top:0,right:0,bottom:0,left:0},this.addHandles([o((()=>this.viewpoint),(()=>{this._lastStationaryEventTimestamp=performance.now(),this._flipStationary(K)}),p),this.on("resize",(e=>this.stateManager.resize(e.width,e.height))),o((()=>this.animationManager?.animation),(e=>{this.animation=e}))]),h()}destroy(){this._set("preconditionsReady",!1),this.frameTask=n(this.frameTask),this.goToManager.destroy(),this.rootLayerViews.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get graphicsTileStore(){return new C(this.featuresTilingScheme)}get constraintsInfo(){const e=this.defaultsFromMap?.tileInfo,t=this.spatialReference;return{lods:e?.spatialReference?.equals(t)?e.lods:null,spatialReference:t}}get state(){return this.stateManager.state}get initialExtentRequired(){if(!this.stateManager)return!1;const{scale:e,constraints:t,center:i,viewpoint:r,extent:s}=this;let a=this.zoom;return!(this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties?.viewpoint)&&(!s&&(t?.effectiveLODs||(a=-1),(!i||0===e&&-1===a)&&(!r||null==r.targetGeometry||"extent"!==r.targetGeometry.type&&!r.scale)))}get _defaultsFromMapSettings(){return{required:{tileInfo:!0,heightModelInfo:!1,extent:!1},requiresExtentInSpatialReference:this.spatialReferenceLocked}}get typeSpecificPreconditionsReady(){const e=this._getDefaultViewpoint();if(!e)return!1;const t=this.spatialReference,i=e.targetGeometry;return!!m(i.spatialReference,t)||y()}set animation(e){const t=this._get("animation");if(e===t)return;if(t&&t.stop(),!e||e.isFulfilled())return this._set("animation",null),void(this.frameTask.animationInProgress=!1);this._set("animation",e),this.frameTask.animationInProgress=!0;const i=()=>{e===this._get("animation")&&(this._set("animation",null),this.frameTask?.requestFrame()),this.frameTask.animationInProgress=!1};e.when(i,i)}get background(){return Z(this.map)?this.map.initialViewProperties.background:null}set background(e){this._override("background",e)}get center(){return this.stateManager?.center??null}set center(e){this.stateManager.center=e}get constraints(){return this.stateManager?.constraints}set constraints(e){e.view=this;const t=this.stateManager.constraints;this.stateManager.constraints=e,t?.destroy()}get extent(){return this.stateManager?.extent??null}set extent(e){this.stateManager.extent=e}get padding(){return this.stateManager?.padding}set padding(e){this.stateManager&&(this.stateManager.padding=e)}get rendering(){return this.stage?.renderRequested??!1}get resizeAlign(){return this.stateManager.resizeAlign}set resizeAlign(e){this.stateManager.resizeAlign=e}get resolution(){return this.stateManager.resolution??0}get rotation(){return this.stateManager.rotation??0}set rotation(e){this.stateManager.rotation=e}get scale(){return this.stateManager?.scale??0}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get stationary(){return!(this.animation||this.navigating||this.resizing||this._stationaryTimer)}get updating(){const e=!this.destroyed&&(!this.layerViewManager||!this.labelManager||!this.graphicsView||!0===this.layerViewManager.updating||!0===this.labelManager.updating||!0===this.graphicsView.updating||this.allLayerViews.some((e=>!e.destroyed&&!("layerViews"in e)&&!0===e.updating)));if(has("esri-2d-log-updating")){const t=this.allLayerViews.reduce(((e,t)=>({...e,[t.layer.id]:!t.destroyed&&!("layerViews"in t)&&t.updating})),{});console.log(`Updating MapView: ${e}\n-> Null LayerViewManager: ${!this.layerViewManager}\n-> Null LabelManager: ${!this.labelManager}\n-> Null GraphicsView: ${!this.graphicsView}\n-> layerViewManager.updating: ${this.layerViewManager?.updating}\n-> labelManager.updating: ${this.labelManager?.updating}\n-> graphicsView.updating: ${this.graphicsView?.updating}\n-> allLayerViews: ${JSON.stringify(t)}\n`)}return e}get viewpoint(){return this.stateManager.viewpoint??null}set viewpoint(e){this.stateManager.viewpoint=e,this.frameTask.requestFrame()}get zoom(){return this.stateManager.zoom??-1}set zoom(e){this.stateManager.zoom=e}get navigating(){return!(!this.mapViewNavigation||!this.mapViewNavigation.interacting)}goTo(e,t){return this.goToManager.goTo(e,t)}async hitTest(e,t){return P(this,e,t)}async takeScreenshot(e){return D(this,e)}toMap(e){if(!this.ready)return null;const t=G(e)?U(this,e):e;return this.stateManager.toMap(t)}toScreen(e){return this.stateManager.toScreen(e)}on(e,t,i,r){const s=this.inputManager&&this.viewEvents.on(e,t,i,r);return s||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}whenLayerView(e){return super.whenLayerView(e)}graphicChanged(e){if(this.graphicsView){this.graphicsView.graphicUpdateHandler(e)}}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){return this.map&&"initialViewProperties"in this.map&&this.map?.initialViewProperties?.spatialReference||this.defaultsFromMap?.spatialReference||null}hasLayerViewModule(e){return S.hasLayerViewModule(e)}importLayerView(e){return S.importLayerView(e)}pixelSizeAt(){return this.ready?this.resolution:(a.getLogger(this).error("#pixelSizeAt()","Map view cannot be used before it is ready"),null)}popupHitTest(e){return this.hitTest(e).then((t=>({...t,mapPoint:this.toMap(e)})))}requestUpdate(){this.ready&&this.frameTask.requestUpdate()}validate(){let e=q(this.type);return has("safari")&&has("safari")<9&&(e=new s("mapview:browser-not-supported","This browser is not supported by MapView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:has("safari")})),null!=e?(a.getLogger(this).warn("#validate()",e.message),Promise.reject(e)):J()}_flipStationary(e){return null!==this._stationaryTimer||(this._stationaryTimer=setTimeout((()=>{this._stationaryTimer=null;const e=performance.now()-this._lastStationaryEventTimestamp;e<K&&(this._stationaryTimer=this._flipStationary(e))}),e)),this._stationaryTimer}_getDefaultViewpoint(){const{constraints:e,initialExtent:i,map:r,padding:s,size:a}=this;if(!e)return null;const n=r&&"initialViewProperties"in r?r.initialViewProperties:void 0,o=this.stateManager.getUserStartupOptions(this.size),p=n?.viewpoint,l=p?.targetGeometry?.extent??i,h=l?.center,g=p?.rotation??0,d=p?.scale||l&&L(l,[a[0]-s.left-s.right,a[1]-s.top-s.bottom]),u=o.center??h,c=o.rotation??g,m=o.scale??d;return u&&m?new t({targetGeometry:u,scale:m,rotation:c}):null}_startup(){this.timeline.begin("MapView Startup");const e=this._getDefaultViewpoint();this.stateManager.startup(e,this.size,this.spatialReference,this.defaultsFromMap.extent?.center),this.graphics.owner=this;const t=new A(this.surface,{canvas:this.renderCanvas,contextOptions:{disabledExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions},renderingOptions:this.renderingOptions,timeline:this.timeline});this.stage=t,this._magnifierView=new Q,this._magnifierView.magnifier=this.magnifier;const i=new H({view:this});this._set("labelManager",i);const r=new _({view:this});this._set("animationManager",r);const s=new B({view:this,animationManager:r});this._set("mapViewNavigation",s),this._setupSpatialReferenceDependentProperties(),this.handles.add([this.rootLayerViews.on("change",(()=>this._updateStageChildren())),t.on("webgl-error",(e=>this.fatalError=e.error)),o((()=>this.stationary),(e=>t.stationary=e),l),o((()=>this.background),(e=>{t.backgroundColor=e?.color,this._magnifierView.backgroundColor=e?.color}),l),o((()=>this.magnifier),(e=>this._magnifierView.magnifier=e),l),o((()=>this.renderingOptions),(e=>t.renderingOptions=e),l),o((()=>this.highlightOptions),(e=>t.highlightOptions=e),l),o((()=>this.state.id),(()=>t.state=this.state),l)],"map-view"),this._updateStageChildren();const a=this._resolveWhenReady;this._resolveWhenReady=[],a.forEach((e=>e(this))),this.timeline.end("MapView Startup"),this.frameTask.start(),this._set("ready",!0)}_teardown(){this._destroySpatialReferenceDependentProperties(),this.handles.remove("map-view"),this.mapViewNavigation.destroy(),this._set("mapViewNavigation",null),this.animationManager.destroy(),this._set("animationManager",null),this.layerViewManager.clear(),this.labelManager.destroy(),this._magnifierView.destroy(),this.stage.destroy(),this.stage=null,this._set("graphicsView",null),this._magnifierView=null,this._set("labelManager",null),this._set("mapViewNavigation",null),this.graphics.owner=null,this.frameTask.stop(),this._stationaryTimer&&(clearTimeout(this._stationaryTimer),this._stationaryTimer=null),this._set("ready",!1),this.stateManager.teardown(),this.animation=null}_updateStageChildren(){this.stage.removeAllChildren(),this.rootLayerViews.forEach((e=>{this.stage.addChild(e.container)}));const e=this.graphicsView;this.stage.addChild(e.container),this.stage.addChild(this._magnifierView)}_setupSpatialReferenceDependentProperties(){const e=new O(f.create({spatialReference:this.spatialReference,size:512,numLODs:36}));this._set("featuresTilingScheme",e);const t=new W({view:this,graphics:this.graphics,requestUpdateCallback:()=>this.requestUpdate(),container:new $(e)});this._set("graphicsView",t)}_destroySpatialReferenceDependentProperties(){const e=this.graphicsView;this._set("graphicsView",null),e.destroy(),this._set("featuresTilingScheme",null)}_spatialReferenceChanged(e){if(this.ready){this.frameTask.stop();for(const e of this.allLayerViews)e.processDetach();this._destroySpatialReferenceDependentProperties(),this.stateManager.changeSpatialReference(e),this.stage.state=this.state,this._setupSpatialReferenceDependentProperties();for(const e of this.allLayerViews)e.processAttach();this.frameTask.requestFrame(),this.frameTask.start(),this._updateStageChildren()}}};X.type="2d",e([g({readOnly:!0})],X.prototype,"animationManager",void 0),e([g({constructOnly:!0})],X.prototype,"deactivatedWebGLExtensions",void 0),e([g({constructOnly:!0})],X.prototype,"debugWebGLExtensions",void 0),e([g({readOnly:!0})],X.prototype,"featuresTilingScheme",void 0),e([g({readOnly:!0})],X.prototype,"fullOpacity",void 0),e([g()],X.prototype,"goToManager",void 0),e([g({readOnly:!0})],X.prototype,"graphicsTileStore",null),e([g()],X.prototype,"graphicsView",void 0),e([g()],X.prototype,"stateManager",void 0),e([g()],X.prototype,"constraintsInfo",null),e([g({readOnly:!0})],X.prototype,"state",null),e([g()],X.prototype,"initialExtentRequired",null),e([g()],X.prototype,"labelManager",void 0),e([g({readOnly:!0})],X.prototype,"mapViewNavigation",void 0),e([g({constructOnly:!0})],X.prototype,"renderCanvas",void 0),e([g()],X.prototype,"renderingOptions",void 0),e([g({constructOnly:!0})],X.prototype,"supersampleScreenshotsEnabled",void 0),e([g({readOnly:!0})],X.prototype,"supportsGround",void 0),e([g()],X.prototype,"_stationaryTimer",void 0),e([g()],X.prototype,"_defaultsFromMapSettings",null),e([g({readOnly:!0})],X.prototype,"typeSpecificPreconditionsReady",null),e([g()],X.prototype,"animation",null),e([g({type:F})],X.prototype,"background",null),e([g()],X.prototype,"center",null),e([g({type:j})],X.prototype,"constraints",null),e([g()],X.prototype,"extent",null),e([g()],X.prototype,"floors",void 0),e([g({type:x})],X.prototype,"highlightOptions",void 0),e([g({readOnly:!0})],X.prototype,"inputManager",void 0),e([g()],X.prototype,"map",void 0),e([g()],X.prototype,"padding",null),e([g({readOnly:!0})],X.prototype,"rendering",null),e([g()],X.prototype,"resizeAlign",null),e([g({readOnly:!0})],X.prototype,"resolution",null),e([g()],X.prototype,"rotation",null),e([g()],X.prototype,"scale",null),e([g({constructOnly:!0})],X.prototype,"spatialReferenceLocked",void 0),e([g()],X.prototype,"stationary",null),e([g({type:z,readOnly:!0})],X.prototype,"timeline",void 0),e([g({readOnly:!0})],X.prototype,"type",void 0),e([g({readOnly:!0})],X.prototype,"updating",null),e([g()],X.prototype,"viewpoint",null),e([g()],X.prototype,"zoom",null),e([g({readOnly:!0})],X.prototype,"navigating",null),e([g(),d((e=>e instanceof I?e:c(N,e)))],X.prototype,"ui",void 0),X=e([u("esri.views.MapView")],X);const Y=X;function Z(e){return"esri.WebMap"===e?.declaredClass}export{Y as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../Viewpoint.js";import i from"../core/Collection.js";import r from"../core/CollectionFlattener.js";import s from"../core/Error.js";import has from"../core/has.js";import a from"../core/Logger.js";import{destroyMaybe as n}from"../core/maybe.js";import{watch as o,sync as p,syncAndInitial as l}from"../core/reactiveUtils.js";import{initialize as h}from"../core/workers/workers.js";import{property as g}from"../core/accessorSupport/decorators/property.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import"../core/arrayUtils.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import{ensureClass as c}from"../core/accessorSupport/ensureType.js";import{canProjectWithoutEngine as m,isLoadedOrLoad as y}from"../geometry/projection.js";import f from"../layers/support/TileInfo.js";import{BreakpointsOwner as w}from"./BreakpointsOwner.js";import{DOMContainer as M}from"./DOMContainer.js";import{PopupView as V}from"./PopupView.js";import v from"./View.js";import _ from"./2d/AnimationManager.js";import T from"./2d/FrameTask.js";import{GoToManager as b}from"./2d/GoToManager.js";import{layerView2DImporter as S}from"./2d/layerViewModuleImportUtils.js";import j from"./2d/MapViewConstraints.js";import O from"./2d/tiling/TileInfoView.js";import"./2d/tiling/TileKey.js";import"./2d/tiling/TileQueue.js";import"./2d/tiling/TileStrategy.js";import{extentToScale as L}from"./2d/viewpointUtils.js";import{ViewStateManager as R}from"./2d/ViewStateManager.js";import k from"./2d/input/MapViewInputManager.js";import C from"./2d/layers/features/support/TileStore.js";import x from"./2d/support/HighlightOptions.js";import{hitTest as E}from"./2d/support/hitTestUtils.js";import{takeRawScreenshot as P,takeScreenshot as D}from"./2d/support/screenshotUtils.js";import{Timeline as z}from"./2d/support/Timeline.js";import{isSupportedScreenPointEvent as G,createScreenPointFromSupportedEvent as U}from"./support/screenUtils.js";import{check as q}from"./support/WebGLRequirements.js";import I from"./ui/DefaultUI.js";import N from"./ui/2d/DefaultUI2D.js";import F from"../webmap/background/ColorBackground.js";let A,W,$,H,B,J;async function K(){const[,{GraphicsView2D:e,GraphicContainer:t,LabelManager:i,MapViewNavigation:r,MagnifierView2D:s,Stage:a}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);W=e,$=t,H=i,B=r,J=s,A=a}const Q=160;let X=class extends(w(V(M(v)))){constructor(e){super(e),this._magnifierView=null,this.stage=null,this._resolveWhenReady=[],this.rootLayerViews=new r({getCollections:()=>[this.basemapView?.baseLayerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:()=>null}),this.featuresTilingScheme=null,this.fullOpacity=1,this.goToManager=new b({view:this}),this.graphicsView=null,this.stateManager=new R({constraints:new j({view:this})}),this.labelManager=null,this.mapViewNavigation=null,this.renderingOptions={samplingMode:"dynamic",edgeLabelsVisible:!0,labelsAnimationTime:125,labelCollisionsEnabled:!0},this.supersampleScreenshotsEnabled=!0,this.supportsGround=!1,this._stationaryTimer=null,this.frameTask=new T(this),this.floors=new i,this.highlightOptions=new x,this.inputManager=new k({view:this}),this.map=null,this.spatialReferenceLocked=!1,this.timeline=new z,this.type="2d",this.ui=new N,this.test={takeScreenshot:async e=>P(this,e)},this.padding={top:0,right:0,bottom:0,left:0},this.addHandles([o((()=>this.viewpoint),(()=>{this._lastStationaryEventTimestamp=performance.now(),this._flipStationary(Q)}),p),this.on("resize",(e=>this.stateManager.resize(e.width,e.height))),o((()=>this.animationManager?.animation),(e=>{this.animation=e}))]),h()}destroy(){this._set("preconditionsReady",!1),this.frameTask=n(this.frameTask),this.goToManager.destroy(),this.rootLayerViews.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get graphicsTileStore(){return new C(this.featuresTilingScheme)}get constraintsInfo(){const e=this.defaultsFromMap?.tileInfo,t=this.spatialReference;return{lods:e?.spatialReference?.equals(t)?e.lods:null,spatialReference:t}}get state(){return this.stateManager.state}get initialExtentRequired(){if(!this.stateManager)return!1;const{scale:e,constraints:t,center:i,viewpoint:r,extent:s}=this;let a=this.zoom;return!(this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties?.viewpoint)&&(!s&&(t?.effectiveLODs||(a=-1),(!i||0===e&&-1===a)&&(!r||null==r.targetGeometry||"extent"!==r.targetGeometry.type&&!r.scale)))}get _defaultsFromMapSettings(){return{required:{tileInfo:!0,heightModelInfo:!1,extent:!1},requiresExtentInSpatialReference:this.spatialReferenceLocked}}get typeSpecificPreconditionsReady(){const e=this._getDefaultViewpoint();if(!e)return!1;const t=this.spatialReference,i=e.targetGeometry;return!!m(i.spatialReference,t)||y()}set animation(e){const t=this._get("animation");if(e===t)return;if(t&&t.stop(),!e||e.isFulfilled())return this._set("animation",null),void(this.frameTask.animationInProgress=!1);this._set("animation",e),this.frameTask.animationInProgress=!0;const i=()=>{e===this._get("animation")&&(this._set("animation",null),this.frameTask?.requestFrame()),this.frameTask.animationInProgress=!1};e.when(i,i)}get background(){return Z(this.map)?this.map.initialViewProperties.background:null}set background(e){this._override("background",e)}get center(){return this.stateManager?.center??null}set center(e){this.stateManager.center=e}get constraints(){return this.stateManager?.constraints}set constraints(e){e.view=this;const t=this.stateManager.constraints;this.stateManager.constraints=e,t?.destroy()}get extent(){return this.stateManager?.extent??null}set extent(e){this.stateManager.extent=e}get padding(){return this.stateManager?.padding}set padding(e){this.stateManager&&(this.stateManager.padding=e)}get rendering(){return this.stage?.renderRequested??!1}get resizeAlign(){return this.stateManager.resizeAlign}set resizeAlign(e){this.stateManager.resizeAlign=e}get resolution(){return this.stateManager.resolution??0}get rotation(){return this.stateManager.rotation??0}set rotation(e){this.stateManager.rotation=e}get scale(){return this.stateManager?.scale??0}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get stationary(){return!(this.animation||this.navigating||this.resizing||this._stationaryTimer)}get updating(){const e=!this.destroyed&&(!this.layerViewManager||!this.labelManager||!this.graphicsView||!0===this.layerViewManager.updating||!0===this.labelManager.updating||!0===this.graphicsView.updating||this.allLayerViews.some((e=>!e.destroyed&&!("layerViews"in e)&&!0===e.updating)));if(has("esri-2d-log-updating")){const t=this.allLayerViews.reduce(((e,t)=>({...e,[t.layer.id]:!t.destroyed&&!("layerViews"in t)&&t.updating})),{});console.log(`Updating MapView: ${e}\n-> Null LayerViewManager: ${!this.layerViewManager}\n-> Null LabelManager: ${!this.labelManager}\n-> Null GraphicsView: ${!this.graphicsView}\n-> layerViewManager.updating: ${this.layerViewManager?.updating}\n-> labelManager.updating: ${this.labelManager?.updating}\n-> graphicsView.updating: ${this.graphicsView?.updating}\n-> allLayerViews: ${JSON.stringify(t)}\n`)}return e}get viewpoint(){return this.stateManager.viewpoint??null}set viewpoint(e){this.stateManager.viewpoint=e,this.frameTask.requestFrame()}get zoom(){return this.stateManager.zoom??-1}set zoom(e){this.stateManager.zoom=e}get navigating(){return!(!this.mapViewNavigation||!this.mapViewNavigation.interacting)}goTo(e,t){return this.goToManager.goTo(e,t)}async hitTest(e,t){return E(this,e,t)}async takeScreenshot(e){return D(this,e)}toMap(e){if(!this.ready)return null;const t=G(e)?U(this,e):e;return this.stateManager.toMap(t)}toScreen(e){return this.stateManager.toScreen(e)}on(e,t,i,r){const s=this.inputManager&&this.viewEvents.on(e,t,i,r);return s||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}whenLayerView(e){return super.whenLayerView(e)}graphicChanged(e){if(this.graphicsView){this.graphicsView.graphicUpdateHandler(e)}}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){return this.map&&"initialViewProperties"in this.map&&this.map?.initialViewProperties?.spatialReference||this.defaultsFromMap?.spatialReference||null}hasLayerViewModule(e){return S.hasLayerViewModule(e)}importLayerView(e){return S.importLayerView(e)}pixelSizeAt(){return this.ready?this.resolution:(a.getLogger(this).error("#pixelSizeAt()","Map view cannot be used before it is ready"),null)}popupHitTest(e){return this.hitTest(e).then((t=>({...t,mapPoint:this.toMap(e)})))}requestUpdate(){this.ready&&this.frameTask.requestUpdate()}validate(){let e=q(this.type);return has("safari")&&has("safari")<9&&(e=new s("mapview:browser-not-supported","This browser is not supported by MapView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:has("safari")})),null!=e?(a.getLogger(this).warn("#validate()",e.message),Promise.reject(e)):K()}_flipStationary(e){return null!==this._stationaryTimer||(this._stationaryTimer=setTimeout((()=>{this._stationaryTimer=null;const e=performance.now()-this._lastStationaryEventTimestamp;e<Q&&(this._stationaryTimer=this._flipStationary(e))}),e)),this._stationaryTimer}_getDefaultViewpoint(){const{constraints:e,initialExtent:i,map:r,padding:s,size:a}=this;if(!e)return null;const n=r&&"initialViewProperties"in r?r.initialViewProperties:void 0,o=this.stateManager.getUserStartupOptions(this.size),p=n?.viewpoint,l=p?.targetGeometry?.extent??i,h=l?.center,g=p?.rotation??0,d=p?.scale||l&&L(l,[a[0]-s.left-s.right,a[1]-s.top-s.bottom]),u=o.center??h,c=o.rotation??g,m=o.scale??d;return u&&m?new t({targetGeometry:u,scale:m,rotation:c}):null}_startup(){this.timeline.begin("MapView Startup");const e=this._getDefaultViewpoint();this.stateManager.startup(e,this.size,this.spatialReference,this.defaultsFromMap.extent?.center),this.graphics.owner=this;const t=new A(this.surface,{canvas:this.renderCanvas,contextOptions:{disabledExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions},renderingOptions:this.renderingOptions,timeline:this.timeline});this.stage=t,this._magnifierView=new J,this._magnifierView.magnifier=this.magnifier;const i=new H({view:this});this._set("labelManager",i);const r=new _({view:this});this._set("animationManager",r);const s=new B({view:this,animationManager:r});this._set("mapViewNavigation",s),this._setupSpatialReferenceDependentProperties(),this.handles.add([this.rootLayerViews.on("change",(()=>this._updateStageChildren())),t.on("webgl-error",(e=>this.fatalError=e.error)),o((()=>this.stationary),(e=>t.stationary=e),l),o((()=>this.background),(e=>{t.backgroundColor=e?.color,this._magnifierView.backgroundColor=e?.color}),l),o((()=>this.magnifier),(e=>this._magnifierView.magnifier=e),l),o((()=>this.renderingOptions),(e=>t.renderingOptions=e),l),o((()=>this.highlightOptions),(e=>t.highlightOptions=e),l),o((()=>this.state.id),(()=>t.state=this.state),l)],"map-view"),this._updateStageChildren();const a=this._resolveWhenReady;this._resolveWhenReady=[],a.forEach((e=>e(this))),this.timeline.end("MapView Startup"),this.frameTask.start(),this._set("ready",!0)}_teardown(){this._destroySpatialReferenceDependentProperties(),this.handles.remove("map-view"),this.mapViewNavigation.destroy(),this._set("mapViewNavigation",null),this.animationManager.destroy(),this._set("animationManager",null),this.layerViewManager.clear(),this.labelManager.destroy(),this._magnifierView.destroy(),this.stage.destroy(),this.stage=null,this._set("graphicsView",null),this._magnifierView=null,this._set("labelManager",null),this._set("mapViewNavigation",null),this.graphics.owner=null,this.frameTask.stop(),this._stationaryTimer&&(clearTimeout(this._stationaryTimer),this._stationaryTimer=null),this._set("ready",!1),this.stateManager.teardown(),this.animation=null}_updateStageChildren(){this.stage.removeAllChildren(),this.rootLayerViews.forEach((e=>{this.stage.addChild(e.container)}));const e=this.graphicsView;this.stage.addChild(e.container),this.stage.addChild(this._magnifierView)}_setupSpatialReferenceDependentProperties(){const e=new O(f.create({spatialReference:this.spatialReference,size:512,numLODs:36}));this._set("featuresTilingScheme",e);const t=new W({view:this,graphics:this.graphics,requestUpdateCallback:()=>this.requestUpdate(),container:new $(e)});this._set("graphicsView",t)}_destroySpatialReferenceDependentProperties(){const e=this.graphicsView;this._set("graphicsView",null),e.destroy(),this._set("featuresTilingScheme",null)}_spatialReferenceChanged(e){if(this.ready){this.frameTask.stop();for(const e of this.allLayerViews)e.processDetach();this._destroySpatialReferenceDependentProperties(),this.stateManager.changeSpatialReference(e),this.stage.state=this.state,this._setupSpatialReferenceDependentProperties();for(const e of this.allLayerViews)e.processAttach();this.frameTask.requestFrame(),this.frameTask.start(),this._updateStageChildren()}}};X.type="2d",e([g({readOnly:!0})],X.prototype,"animationManager",void 0),e([g({constructOnly:!0})],X.prototype,"deactivatedWebGLExtensions",void 0),e([g({constructOnly:!0})],X.prototype,"debugWebGLExtensions",void 0),e([g({readOnly:!0})],X.prototype,"featuresTilingScheme",void 0),e([g({readOnly:!0})],X.prototype,"fullOpacity",void 0),e([g()],X.prototype,"goToManager",void 0),e([g({readOnly:!0})],X.prototype,"graphicsTileStore",null),e([g()],X.prototype,"graphicsView",void 0),e([g()],X.prototype,"stateManager",void 0),e([g()],X.prototype,"constraintsInfo",null),e([g({readOnly:!0})],X.prototype,"state",null),e([g()],X.prototype,"initialExtentRequired",null),e([g()],X.prototype,"labelManager",void 0),e([g({readOnly:!0})],X.prototype,"mapViewNavigation",void 0),e([g({constructOnly:!0})],X.prototype,"renderCanvas",void 0),e([g()],X.prototype,"renderingOptions",void 0),e([g({constructOnly:!0})],X.prototype,"supersampleScreenshotsEnabled",void 0),e([g({readOnly:!0})],X.prototype,"supportsGround",void 0),e([g()],X.prototype,"_stationaryTimer",void 0),e([g()],X.prototype,"_defaultsFromMapSettings",null),e([g({readOnly:!0})],X.prototype,"typeSpecificPreconditionsReady",null),e([g()],X.prototype,"animation",null),e([g({type:F})],X.prototype,"background",null),e([g()],X.prototype,"center",null),e([g({type:j})],X.prototype,"constraints",null),e([g()],X.prototype,"extent",null),e([g()],X.prototype,"floors",void 0),e([g({type:x})],X.prototype,"highlightOptions",void 0),e([g({readOnly:!0})],X.prototype,"inputManager",void 0),e([g()],X.prototype,"map",void 0),e([g()],X.prototype,"padding",null),e([g({readOnly:!0})],X.prototype,"rendering",null),e([g()],X.prototype,"resizeAlign",null),e([g({readOnly:!0})],X.prototype,"resolution",null),e([g()],X.prototype,"rotation",null),e([g()],X.prototype,"scale",null),e([g({constructOnly:!0})],X.prototype,"spatialReferenceLocked",void 0),e([g()],X.prototype,"stationary",null),e([g({type:z,readOnly:!0})],X.prototype,"timeline",void 0),e([g({readOnly:!0})],X.prototype,"type",void 0),e([g({readOnly:!0})],X.prototype,"updating",null),e([g()],X.prototype,"viewpoint",null),e([g()],X.prototype,"zoom",null),e([g({readOnly:!0})],X.prototype,"navigating",null),e([g(),d((e=>e instanceof I?e:c(N,e)))],X.prototype,"ui",void 0),X=e([u("esri.views.MapView")],X);const Y=X;function Z(e){return"esri.WebMap"===e?.declaredClass}export{Y as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{Seconds as t}from"../../../core/time.js";let e=class{constructor(){this.segments=[]}get time(){return this.segments.reduce(((e,o)=>t(e+o.time)),t(0))}interpolateComponentsAt(t,e){t=Math.min(Math.max(t,0),1),t*=this.time;let o=0,a=0;const n=this.definition;for(let s=0;s<this.segments.length;s++){const m=this.segments[s],i=m.definition;if(t<=m.time||s===this.segments.length-1){if(e=this.segmentInterpolateComponentsAt(m,0===m.time?0:t/m.time,e),n.hasPan&&!isNaN(e.pan)&&isFinite(n.compared.pan)?e.pan=(o+i.compared.pan*e.pan)/n.compared.pan:e.pan=1,n.hasRotate&&!isNaN(e.rotate)&&isFinite(n.compared.rotate)?e.rotate=(a+i.compared.rotate*e.rotate)/n.compared.rotate:e.rotate=1,n.hasZoom&&!isNaN(e.zoom)&&isFinite(i.compared.targetZoom)){const t=e.zoom*(i.compared.targetZoom-i.compared.sourceZoom)+i.compared.sourceZoom,o=this.segments[0].definition.compared.sourceZoom,a=this.segments.at(-1).definition.compared.targetZoom;e.zoom=(t-o)/(a-o)}else e.zoom=1;return e}t-=m.time,o+=i.compared.pan,a+=i.compared.rotate}}segmentInterpolateComponentsAt(t,e,o){return t.interpolateComponentsAt(e,o)}};export{e as Path};
5
+ import{Seconds as t}from"../../../core/time.js";let e=class{constructor(){this.segments=[]}get time(){return this.segments.reduce(((e,o)=>t(e+o.time)),t(0))}interpolateComponentsAt(t,e){t=Math.min(Math.max(t,0),1),t*=this.time;let o=0,s=0;const n=this.definition;for(let a=0;a<this.segments.length;a++){const m=this.segments[a],i=m.definition;if(t<=m.time||a===this.segments.length-1){if(e=this.segmentInterpolateComponentsAt(m,0===m.time?0:t/m.time,e),n.hasPan&&!isNaN(e.pan)&&isFinite(n.compared.pan)?e.pan=(o+i.compared.pan*e.pan)/n.compared.pan:e.pan=1,n.hasRotate&&!isNaN(e.rotate)&&isFinite(n.compared.rotate)?e.rotate=(s+i.compared.rotate*e.rotate)/n.compared.rotate:e.rotate=1,n.hasZoom&&!isNaN(e.zoom)&&isFinite(i.compared.targetZoom)){const t=e.zoom*(i.compared.targetZoom-i.compared.sourceZoom)+i.compared.sourceZoom,o=this.segments[0].definition.compared.sourceZoom,s=this.segments[this.segments.length-1].definition.compared.targetZoom;e.zoom=(t-o)/(s-o)}else e.zoom=1;return e}t-=m.time,o+=i.compared.pan,s+=i.compared.rotate}}segmentInterpolateComponentsAt(t,e,o){return t.interpolateComponentsAt(e,o)}};export{e as Path};
@@ -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 i from"../../core/Evented.js";import{clone as n}from"../../core/lang.js";import{destroyMaybe as o,equalsMaybe as r}from"../../core/maybe.js";import{ignoreAbortErrors as s}from"../../core/promiseUtils.js";import{watch as a,syncAndInitial as p}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{diff as h}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{pointEquals as u}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as m}from"../../support/elevationInfoUtils.js";import{ViewingMode as v}from"../ViewingMode.js";import{defaultDrawingMode as y}from"./DrawingMode.js";import{DrawManipulator as _}from"./DrawManipulator.js";import{createCoordinateHelper as x}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as f,sceneSnappingAtLocation as S}from"../interactive/dragEventPipeline.js";import{EditGeometry as V,Component as w}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as O}from"../interactive/editGeometry/EditGeometryOperations.js";import T from"../interactive/sketch/SketchLabelOptions.js";import b from"../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as M}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as P}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as D}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as C}from"../interactive/snapping/snappingUtils.js";let I=class extends(i.EventedMixin(t)){constructor(e){super(e),this._createOperationCompleted=!1,this._pointerDownStates=new Set,this._stagedScreenPoint=null,this._stagedPointerType=null,this._updatingHandles=new g,this.isDraped=!0,this.labelOptions=new T,this.tooltipOptions=new b,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.lastVertex=null,null==e.elevationInfo&&(this.elevationInfo=m(!!e.hasZ))}initialize(){const{geometryType:e,view:t}=this,i=t.spatialReference,n="viewingMode"in t.state?t.state.viewingMode:v.Local,o="segment"===e||"multipoint"===e?"polyline":e;this.coordinateHelper=x(this.hasZ,this.hasM,i),this._editGeometryOperations=new O(new V(o,this.coordinateHelper)),this._snappingOperation=new D({view:t,constrainResult:e=>null==e?e:this._getEffectiveDrawSurface()?.constrainZ(e)}),this.addHandles([a((()=>this.stagedVertex),(e=>{null!=e&&this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(e)}],operation:"apply",type:"vertex-update"})}),{sync:!0,equals:(e,t)=>r(e,t,u)}),a((()=>this.view.viewpoint),((e,t)=>{e&&t&&h(e,t)&&this._onViewpointChange()}))]),this._activeComponent=new w(i,n),this._editGeometryOperations.data.components.push(this._activeComponent);const c=this.segmentLabels;null!=c&&(c.context={view:t,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.addHandles([a((()=>this.labelOptions.enabled),(e=>{c.visible=e}),p),this.on("cursor-update",(()=>{const e=this.stagedVertex;c.stagedVertex=null!=e?this.coordinateHelper.pointToVector(e):null}))])),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(e=>{const t=e.vertices.map((e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)}))),i=t.map((e=>e.coordinates));switch(e.type){case"vertex-add":this.emit(e.type,{...e,added:i,vertices:t});break;case"vertex-update":this.emit(e.type,{...e,updated:i,vertices:t});break;case"vertex-remove":this.emit(e.type,{...e,removed:i,vertices:t})}const n=this._activeComponent.getLastVertex(),o=null!=n?this.coordinateHelper.vectorToDehydratedPoint(n.pos):null;null!=o&&null!=this.lastVertex&&u(this.lastVertex,o)||(this.lastVertex=o)})));const l=this._manipulator=new _({grabbableForEvent:e=>"click"!==this.drawingMode||"touch"===e.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(l),l.grabbable="point"!==e,this.addHandles([this._createManipulatorDragPipeline(l),l.events.on("immediate-click",(e=>this._onImmediateClick(e))),l.events.on("immediate-double-click",(e=>this._onImmediateDoubleClick(e))),a((()=>({cursor:this.cursor,loading:this.loading})),(({cursor:e,loading:t})=>{l.cursor=t?"progress":e}),p)]),C(this,(()=>{const e=this.view.inputManager.latestPointerType??"mouse",t=this._getSnappingContext(e);null!=this.snappingManager&&this._updatingHandles.addPromise(s(this._snappingOperation.resnap(this.snappingManager,t)))}))}destroy(){o(this.segmentLabels),o(this._snappingOperation),this._editGeometryOperations=o(this._editGeometryOperations),this._updatingHandles.destroy()}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const e=this._getEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==e}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((e=>this.coordinateHelper.vectorToArray(e.pos)))}set drawingMode(e){this._set("drawingMode",e??y)}get interactive(){return this._manipulator.interactive}set interactive(e){this._manipulator.interactive=e}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get numVertices(){return null!=this.stagedVertex?this._activeComponent.vertices.length+1:this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get stagedVertex(){return this._snappingOperation.stagedPoint}set stagedVertex(e){this._snappingOperation.stagedPoint=n(e)}get updating(){return this._updatingHandles.updating}get vertices(){const e=this.committedVertices;return null!=this.stagedVertex&&e.push(this.coordinateHelper.pointToArray(this.stagedVertex)),e}cancel(){this.complete({aborted:!0})}commitStagedVertex(){if(this._snappingOperation.abort(),null!=this.stagedVertex){const{stagedVertex:e}=this;this.stagedVertex=null,this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(e))}}complete(e){const t=e&&e.aborted||!1;this._snappingOperation.abort(),null!=this.snappingManager&&this.snappingManager.doneSnapping(),"segment"===this.geometryType||"point"===this.geometryType?this.commitStagedVertex():this.stagedVertex=null;const i="multipoint"===this.geometryType&&0===this.numVertices||"polyline"===this.geometryType&&this.numVertices<2||"polygon"===this.geometryType&&this.numVertices<3;this._createOperationCompleted=!i,(this.isCompleted||t)&&this.emit("complete",{vertices:this.vertices.map(((e,t)=>({componentIndex:0,vertexIndex:t,coordinates:e}))),aborted:t,type:"complete"})}onInputEvent(e){switch(e.type){case"pointer-down":this._pointerDownStates.add(e.pointerId);break;case"pointer-up":this._pointerDownStates.delete(e.pointerId)}switch(e.type){case"pointer-move":return this._onPointerMove(e);case"hold":return this._onHold(e)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_closeOnClickVertexIndex(e){const t=this._activeComponent;if("polygon"===this.geometryType&&t.vertices.length>2){if(this._vertexWithinPointerDistance(t.vertices[0].pos,e))return 0;if(this._vertexWithinPointerDistance(t.vertices.at(-1).pos,e))return t.vertices.length-1}return null}_createManipulatorDragPipeline(e){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(e);case"freehand":return this._createManipulatorDragPipelineFreehand(e);case"hybrid":return this._createManipulatorDragPipelineHybrid(e)}}_createManipulatorDragPipelineClick(e){return f(e,((e,t,i,n)=>{const o="touch"===n&&this._snappingEnabled;if(this.isCompleted||!o)return;const{snappingStep:r,cancelSnapping:s}=P({predicate:()=>o,snappingManager:this.snappingManager,snappingContext:new M({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:n,visualizer:this.snappingVisualizer}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next((e=>(o&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),e))).next(s),t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(this.stagedVertex=e.mapStart,("segment"===this.geometryType||o&&0===this.numVertices)&&this.commitStagedVertex()),e))).next(S(this.view,this.elevationInfo)).next(...r).next((e=>(o&&(this.stagedVertex=e.mapEnd,"end"===e.action&&this.commitStagedVertex()),e))).next((e=>("end"===e.action&&("segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),e)))}))}_createManipulatorDragPipelineFreehand(e){return f(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return e}))}))}_createManipulatorDragPipelineHybrid(e){return f(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return e}))}))}get _drawAtFixedElevation(){return("segment"===this.geometryType||"polygon"===this.geometryType)&&this.numCommittedVertices>0}_getEffectiveDrawSurface(){if(null==this.elevationDrawSurface)return this.drawSurface;if(!this.coordinateHelper.hasZ())return this.elevationDrawSurface.defaultZ=null,this.elevationDrawSurface;let e=this.defaultZ,t=!1;return null!=this.elevationInfo&&"absolute-height"===this.elevationInfo.mode&&(t=!0),null!=this.snapToSceneEnabled&&(t=this.snapToSceneEnabled),null!=this.elevationInfo&&"on-the-ground"===this.elevationInfo.mode&&(t=!1),this._drawAtFixedElevation&&(e=this.coordinateHelper.getZ(this._activeComponent.vertices[0].pos),t=!1),t?this.drawSurface:(this.elevationDrawSurface.defaultZ=e,this.elevationDrawSurface)}_mapToScreen(e){return this._getEffectiveDrawSurface()?.mapToScreen(e)}_onHold(e){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===e.pointerType&&this._snappingEnabled&&(this.stagedVertex=e.mapPoint),e.stopPropagation()}_onImmediateClick(e){if("mouse"===e.pointerType&&2===e.button||this._manipulator.dragging)return;const t=this._activeComponent;if(null!=this._closeOnClickVertexIndex(e.screenPoint))return e.stopPropagation(),void this.complete();const i=this._screenToMap(e.screenPoint);if(null!=i)switch(this.drawingMode){case"freehand":"point"===this.geometryType&&(null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),this.complete());break;case"click":case"hybrid":this._snappingOperation.abort(),null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),("point"===this.geometryType||"segment"===this.geometryType&&2===t.vertices.length||"segment"===this.geometryType&&"hybrid"===this.drawingMode&&1===t.vertices.length)&&this.complete()}e.stopPropagation()}_onImmediateDoubleClick(e){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),e.stopPropagation())}_onPointerMove(e){const t=c(e.x,e.y);this._stagedScreenPoint=t,this._stagedPointerType=e.pointerType;const i=this._snappingOperation,n=this._manipulator;n.dragging||this._pointerDownStates.has(e.pointerId)||n.grabbing||!n.interactive?i.abort():(e.stopPropagation(),this._updateStagedVertexOnPointerMove(t,e.pointerType))}_onViewpointChange(){const e=this._manipulator;this._stagedScreenPoint&&!e.dragging&&!e.grabbing&&e.interactive?this._updateStagedVertexOnPointerMove(this._stagedScreenPoint,this._stagedPointerType??"mouse"):this._snappingOperation.abort()}_updateStagedVertexOnPointerMove(e,t){const i=this._snappingOperation,n=this._closeOnClickVertexIndex(e);if(null!=n)return this._closeOnVertex(n),void i.abort();const o=this._screenToMap(e),r=this._requiresScenePoint?this.drawSurface?.screenToMap(e):null;if(null==o)return this.cursor=null,void i.abort();this.cursor="crosshair";const a=this.snappingManager;if(null==a)return this.stagedVertex=o,void i.abort();const p=this._getSnappingContext(t);this._updatingHandles.addPromise(s(i.snap({point:o,scenePoint:r},a,p)))}_closeOnVertex(e){this.stagedVertex=null;const t={componentIndex:0,vertexIndex:e,coordinates:this.coordinateHelper.vectorToArray(this._activeComponent.vertices[e].pos)};this.emit("cursor-update",{updated:null,vertices:[t],operation:"apply",type:"vertex-update"})}_screenToMap(e){return this._getEffectiveDrawSurface()?.screenToMap(e)}_screenToMapDragEventStep(){let e=null;return t=>{if("start"===t.action&&(e=this._screenToMap(t.screenStart)),null==e)return null;const i=this._screenToMap(t.screenEnd);return null!=i?{...t,mapStart:e,mapEnd:i}:null}}_vertexWithinPointerDistance(e,t){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(e));return null!=n&&E(n,t,i)}_getSnappingContext(e){const t=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new M({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:e,visualizer:this.snappingVisualizer,selfSnappingZ:null!=t?{value:t,elevationInfo:this.elevationInfo}:null})}};function E(e,t,i){const n=e.x-t.x,o=e.y-t.y;return n*n+o*o<=i}e([l()],I.prototype,"_snappingEnabled",null),e([l()],I.prototype,"defaultZ",void 0),e([l()],I.prototype,"isDraped",void 0),e([l({value:y})],I.prototype,"drawingMode",null),e([l({constructOnly:!0})],I.prototype,"elevationDrawSurface",void 0),e([l({constructOnly:!0})],I.prototype,"elevationInfo",void 0),e([l({constructOnly:!0,type:T})],I.prototype,"labelOptions",void 0),e([l({constructOnly:!0,type:b})],I.prototype,"tooltipOptions",void 0),e([l({constructOnly:!0})],I.prototype,"geometryType",void 0),e([l({constructOnly:!0})],I.prototype,"hasM",void 0),e([l({constructOnly:!0})],I.prototype,"hasZ",void 0),e([l()],I.prototype,"cursor",void 0),e([l()],I.prototype,"loading",void 0),e([l({constructOnly:!0})],I.prototype,"manipulators",void 0),e([l({constructOnly:!0})],I.prototype,"drawSurface",void 0),e([l({constructOnly:!0})],I.prototype,"segmentLabels",void 0),e([l({constructOnly:!0})],I.prototype,"snappingManager",void 0),e([l({constructOnly:!0})],I.prototype,"snappingVisualizer",void 0),e([l()],I.prototype,"snapToSceneEnabled",void 0),e([l()],I.prototype,"_snappingOperation",void 0),e([l()],I.prototype,"stagedVertex",null),e([l()],I.prototype,"lastVertex",void 0),e([l()],I.prototype,"updating",null),e([l({constructOnly:!0})],I.prototype,"view",void 0),I=e([d("esri.views.draw.DrawOperation")],I);export{I as DrawOperation};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import i from"../../core/Evented.js";import{clone as n}from"../../core/lang.js";import{destroyMaybe as r,equalsMaybe as o}from"../../core/maybe.js";import{ignoreAbortErrors as s}from"../../core/promiseUtils.js";import{watch as a,syncAndInitial as p}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{diff as h}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{pointEquals as u}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as m}from"../../support/elevationInfoUtils.js";import{ViewingMode as v}from"../ViewingMode.js";import{defaultDrawingMode as y}from"./DrawingMode.js";import{DrawManipulator as _}from"./DrawManipulator.js";import{createCoordinateHelper as x}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as f,sceneSnappingAtLocation as S}from"../interactive/dragEventPipeline.js";import{EditGeometry as V,Component as w}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as O}from"../interactive/editGeometry/EditGeometryOperations.js";import T from"../interactive/sketch/SketchLabelOptions.js";import b from"../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as M}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as P}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as D}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as C}from"../interactive/snapping/snappingUtils.js";let I=class extends(i.EventedMixin(t)){constructor(e){super(e),this._createOperationCompleted=!1,this._pointerDownStates=new Set,this._stagedScreenPoint=null,this._stagedPointerType=null,this._updatingHandles=new g,this.isDraped=!0,this.labelOptions=new T,this.tooltipOptions=new b,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.lastVertex=null,null==e.elevationInfo&&(this.elevationInfo=m(!!e.hasZ))}initialize(){const{geometryType:e,view:t}=this,i=t.spatialReference,n="viewingMode"in t.state?t.state.viewingMode:v.Local,r="segment"===e||"multipoint"===e?"polyline":e;this.coordinateHelper=x(this.hasZ,this.hasM,i),this._editGeometryOperations=new O(new V(r,this.coordinateHelper)),this._snappingOperation=new D({view:t,constrainResult:e=>null==e?e:this._getEffectiveDrawSurface()?.constrainZ(e)}),this.addHandles([a((()=>this.stagedVertex),(e=>{null!=e&&this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(e)}],operation:"apply",type:"vertex-update"})}),{sync:!0,equals:(e,t)=>o(e,t,u)}),a((()=>this.view.viewpoint),((e,t)=>{e&&t&&h(e,t)&&this._onViewpointChange()}))]),this._activeComponent=new w(i,n),this._editGeometryOperations.data.components.push(this._activeComponent);const c=this.segmentLabels;null!=c&&(c.context={view:t,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.addHandles([a((()=>this.labelOptions.enabled),(e=>{c.visible=e}),p),this.on("cursor-update",(()=>{const e=this.stagedVertex;c.stagedVertex=null!=e?this.coordinateHelper.pointToVector(e):null}))])),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(e=>{const t=e.vertices.map((e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)}))),i=t.map((e=>e.coordinates));switch(e.type){case"vertex-add":this.emit(e.type,{...e,added:i,vertices:t});break;case"vertex-update":this.emit(e.type,{...e,updated:i,vertices:t});break;case"vertex-remove":this.emit(e.type,{...e,removed:i,vertices:t})}const n=this._activeComponent.getLastVertex(),r=null!=n?this.coordinateHelper.vectorToDehydratedPoint(n.pos):null;null!=r&&null!=this.lastVertex&&u(this.lastVertex,r)||(this.lastVertex=r)})));const l=this._manipulator=new _({grabbableForEvent:e=>"click"!==this.drawingMode||"touch"===e.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(l),l.grabbable="point"!==e,this.addHandles([this._createManipulatorDragPipeline(l),l.events.on("immediate-click",(e=>this._onImmediateClick(e))),l.events.on("immediate-double-click",(e=>this._onImmediateDoubleClick(e))),a((()=>({cursor:this.cursor,loading:this.loading})),(({cursor:e,loading:t})=>{l.cursor=t?"progress":e}),p)]),C(this,(()=>{const e=this.view.inputManager.latestPointerType??"mouse",t=this._getSnappingContext(e);null!=this.snappingManager&&this._updatingHandles.addPromise(s(this._snappingOperation.resnap(this.snappingManager,t)))}))}destroy(){r(this.segmentLabels),r(this._snappingOperation),this._editGeometryOperations=r(this._editGeometryOperations),this._updatingHandles.destroy()}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const e=this._getEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==e}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((e=>this.coordinateHelper.vectorToArray(e.pos)))}set drawingMode(e){this._set("drawingMode",e??y)}get interactive(){return this._manipulator.interactive}set interactive(e){this._manipulator.interactive=e}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get numVertices(){return null!=this.stagedVertex?this._activeComponent.vertices.length+1:this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get stagedVertex(){return this._snappingOperation.stagedPoint}set stagedVertex(e){this._snappingOperation.stagedPoint=n(e)}get updating(){return this._updatingHandles.updating}get vertices(){const e=this.committedVertices;return null!=this.stagedVertex&&e.push(this.coordinateHelper.pointToArray(this.stagedVertex)),e}cancel(){this.complete({aborted:!0})}commitStagedVertex(){if(this._snappingOperation.abort(),null!=this.stagedVertex){const{stagedVertex:e}=this;this.stagedVertex=null,this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(e))}}complete(e){const t=e&&e.aborted||!1;this._snappingOperation.abort(),null!=this.snappingManager&&this.snappingManager.doneSnapping(),"segment"===this.geometryType||"point"===this.geometryType?this.commitStagedVertex():this.stagedVertex=null;const i="multipoint"===this.geometryType&&0===this.numVertices||"polyline"===this.geometryType&&this.numVertices<2||"polygon"===this.geometryType&&this.numVertices<3;this._createOperationCompleted=!i,(this.isCompleted||t)&&this.emit("complete",{vertices:this.vertices.map(((e,t)=>({componentIndex:0,vertexIndex:t,coordinates:e}))),aborted:t,type:"complete"})}onInputEvent(e){switch(e.type){case"pointer-down":this._pointerDownStates.add(e.pointerId);break;case"pointer-up":this._pointerDownStates.delete(e.pointerId)}switch(e.type){case"pointer-move":return this._onPointerMove(e);case"hold":return this._onHold(e)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_closeOnClickVertexIndex(e){const t=this._activeComponent;if("polygon"===this.geometryType&&t.vertices.length>2){if(this._vertexWithinPointerDistance(t.vertices[0].pos,e))return 0;if(this._vertexWithinPointerDistance(t.vertices[t.vertices.length-1].pos,e))return t.vertices.length-1}return null}_createManipulatorDragPipeline(e){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(e);case"freehand":return this._createManipulatorDragPipelineFreehand(e);case"hybrid":return this._createManipulatorDragPipelineHybrid(e)}}_createManipulatorDragPipelineClick(e){return f(e,((e,t,i,n)=>{const r="touch"===n&&this._snappingEnabled;if(this.isCompleted||!r)return;const{snappingStep:o,cancelSnapping:s}=P({predicate:()=>r,snappingManager:this.snappingManager,snappingContext:new M({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:n,visualizer:this.snappingVisualizer}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next((e=>(r&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),e))).next(s),t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(this.stagedVertex=e.mapStart,("segment"===this.geometryType||r&&0===this.numVertices)&&this.commitStagedVertex()),e))).next(S(this.view,this.elevationInfo)).next(...o).next((e=>(r&&(this.stagedVertex=e.mapEnd,"end"===e.action&&this.commitStagedVertex()),e))).next((e=>("end"===e.action&&("segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),e)))}))}_createManipulatorDragPipelineFreehand(e){return f(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return e}))}))}_createManipulatorDragPipelineHybrid(e){return f(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return e}))}))}get _drawAtFixedElevation(){return("segment"===this.geometryType||"polygon"===this.geometryType)&&this.numCommittedVertices>0}_getEffectiveDrawSurface(){if(null==this.elevationDrawSurface)return this.drawSurface;if(!this.coordinateHelper.hasZ())return this.elevationDrawSurface.defaultZ=null,this.elevationDrawSurface;let e=this.defaultZ,t=!1;return null!=this.elevationInfo&&"absolute-height"===this.elevationInfo.mode&&(t=!0),null!=this.snapToSceneEnabled&&(t=this.snapToSceneEnabled),null!=this.elevationInfo&&"on-the-ground"===this.elevationInfo.mode&&(t=!1),this._drawAtFixedElevation&&(e=this.coordinateHelper.getZ(this._activeComponent.vertices[0].pos),t=!1),t?this.drawSurface:(this.elevationDrawSurface.defaultZ=e,this.elevationDrawSurface)}_mapToScreen(e){return this._getEffectiveDrawSurface()?.mapToScreen(e)}_onHold(e){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===e.pointerType&&this._snappingEnabled&&(this.stagedVertex=e.mapPoint),e.stopPropagation()}_onImmediateClick(e){if("mouse"===e.pointerType&&2===e.button||this._manipulator.dragging)return;const t=this._activeComponent;if(null!=this._closeOnClickVertexIndex(e.screenPoint))return e.stopPropagation(),void this.complete();const i=this._screenToMap(e.screenPoint);if(null!=i)switch(this.drawingMode){case"freehand":"point"===this.geometryType&&(null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),this.complete());break;case"click":case"hybrid":this._snappingOperation.abort(),null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),("point"===this.geometryType||"segment"===this.geometryType&&2===t.vertices.length||"segment"===this.geometryType&&"hybrid"===this.drawingMode&&1===t.vertices.length)&&this.complete()}e.stopPropagation()}_onImmediateDoubleClick(e){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),e.stopPropagation())}_onPointerMove(e){const t=c(e.x,e.y);this._stagedScreenPoint=t,this._stagedPointerType=e.pointerType;const i=this._snappingOperation,n=this._manipulator;n.dragging||this._pointerDownStates.has(e.pointerId)||n.grabbing||!n.interactive?i.abort():(e.stopPropagation(),this._updateStagedVertexOnPointerMove(t,e.pointerType))}_onViewpointChange(){const e=this._manipulator;this._stagedScreenPoint&&!e.dragging&&!e.grabbing&&e.interactive?this._updateStagedVertexOnPointerMove(this._stagedScreenPoint,this._stagedPointerType??"mouse"):this._snappingOperation.abort()}_updateStagedVertexOnPointerMove(e,t){const i=this._snappingOperation,n=this._closeOnClickVertexIndex(e);if(null!=n)return this._closeOnVertex(n),void i.abort();const r=this._screenToMap(e),o=this._requiresScenePoint?this.drawSurface?.screenToMap(e):null;if(null==r)return this.cursor=null,void i.abort();this.cursor="crosshair";const a=this.snappingManager;if(null==a)return this.stagedVertex=r,void i.abort();const p=this._getSnappingContext(t);this._updatingHandles.addPromise(s(i.snap({point:r,scenePoint:o},a,p)))}_closeOnVertex(e){this.stagedVertex=null;const t={componentIndex:0,vertexIndex:e,coordinates:this.coordinateHelper.vectorToArray(this._activeComponent.vertices[e].pos)};this.emit("cursor-update",{updated:null,vertices:[t],operation:"apply",type:"vertex-update"})}_screenToMap(e){return this._getEffectiveDrawSurface()?.screenToMap(e)}_screenToMapDragEventStep(){let e=null;return t=>{if("start"===t.action&&(e=this._screenToMap(t.screenStart)),null==e)return null;const i=this._screenToMap(t.screenEnd);return null!=i?{...t,mapStart:e,mapEnd:i}:null}}_vertexWithinPointerDistance(e,t){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(e));return null!=n&&E(n,t,i)}_getSnappingContext(e){const t=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new M({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:e,visualizer:this.snappingVisualizer,selfSnappingZ:null!=t?{value:t,elevationInfo:this.elevationInfo}:null})}};function E(e,t,i){const n=e.x-t.x,r=e.y-t.y;return n*n+r*r<=i}e([l()],I.prototype,"_snappingEnabled",null),e([l()],I.prototype,"defaultZ",void 0),e([l()],I.prototype,"isDraped",void 0),e([l({value:y})],I.prototype,"drawingMode",null),e([l({constructOnly:!0})],I.prototype,"elevationDrawSurface",void 0),e([l({constructOnly:!0})],I.prototype,"elevationInfo",void 0),e([l({constructOnly:!0,type:T})],I.prototype,"labelOptions",void 0),e([l({constructOnly:!0,type:b})],I.prototype,"tooltipOptions",void 0),e([l({constructOnly:!0})],I.prototype,"geometryType",void 0),e([l({constructOnly:!0})],I.prototype,"hasM",void 0),e([l({constructOnly:!0})],I.prototype,"hasZ",void 0),e([l()],I.prototype,"cursor",void 0),e([l()],I.prototype,"loading",void 0),e([l({constructOnly:!0})],I.prototype,"manipulators",void 0),e([l({constructOnly:!0})],I.prototype,"drawSurface",void 0),e([l({constructOnly:!0})],I.prototype,"segmentLabels",void 0),e([l({constructOnly:!0})],I.prototype,"snappingManager",void 0),e([l({constructOnly:!0})],I.prototype,"snappingVisualizer",void 0),e([l()],I.prototype,"snapToSceneEnabled",void 0),e([l()],I.prototype,"_snappingOperation",void 0),e([l()],I.prototype,"stagedVertex",null),e([l()],I.prototype,"lastVertex",void 0),e([l()],I.prototype,"updating",null),e([l({constructOnly:!0})],I.prototype,"view",void 0),I=e([d("esri.views.draw.DrawOperation")],I);export{I as DrawOperation};