@arcgis/core 4.28.0-next.20230719 → 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 (334) 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/{e579ca7d4c1387e17305.js → 092fda62b6f62c2e4869.js} +2 -2
  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/{55705b1bbac91d7db0e7.js → 32d940b2c891bf6ff9a2.js} +1 -1
  30. package/assets/esri/core/workers/chunks/3a0349c79551a03c2d8e.js +1 -0
  31. package/assets/esri/core/workers/chunks/{7dbd3e6406fb3e3a1a8f.js → 3cf748c025f3936c1cb2.js} +1 -1
  32. package/assets/esri/core/workers/chunks/4481d1103363434f16da.js +1 -0
  33. package/assets/esri/core/workers/chunks/58e11ca7c6e27e0ece7e.js +1 -0
  34. package/assets/esri/core/workers/chunks/5ae325e6a795c72eac6c.js +1 -0
  35. package/assets/esri/core/workers/chunks/5e4dde2886a1027b4b96.js +1 -0
  36. package/assets/esri/core/workers/chunks/{357e0381b6d767585576.js → 675e16d99758e67e5f51.js} +1 -1
  37. package/assets/esri/core/workers/chunks/726bb661b9e6998572e7.js +1 -0
  38. package/assets/esri/core/workers/chunks/730eb7e5f617fdab4f10.js +1 -0
  39. package/assets/esri/core/workers/chunks/{5a2e6bed9431cf4f42b1.js → 740dc67038f554431f1b.js} +1 -1
  40. package/assets/esri/core/workers/chunks/7cab61c9e09580520990.js +1 -0
  41. package/assets/esri/core/workers/chunks/{09178454bda15bb7929a.js → 7fbdfd1527582c52f9b6.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{26546aa98a338051df66.js → 807742f38885fa90b4fe.js} +1 -1
  43. package/assets/esri/core/workers/chunks/82dfbc175b52c7a10475.js +1 -0
  44. package/assets/esri/core/workers/chunks/870a05451e074b58f19a.js +1 -0
  45. package/assets/esri/core/workers/chunks/88038ad401e5ec02f4d3.js +1 -0
  46. package/assets/esri/core/workers/chunks/88d63d1e56732d148f67.js +1 -0
  47. package/assets/esri/core/workers/chunks/8b72cd9340e8a44358ac.js +1 -0
  48. package/assets/esri/core/workers/chunks/8c5a8c1dfb086069bb06.js +1 -0
  49. package/assets/esri/core/workers/chunks/99a5a434e0bad48c7a5c.js +1 -0
  50. package/assets/esri/core/workers/chunks/9a5916c66dad91d01d5b.js +1 -0
  51. package/assets/esri/core/workers/chunks/9c133fd8c1fbd0295b86.js +1 -0
  52. package/assets/esri/core/workers/chunks/9cddb504079d396779ea.js +1 -0
  53. package/assets/esri/core/workers/chunks/a3a1d4f32e518e97d071.js +1 -0
  54. package/assets/esri/core/workers/chunks/{9548aa449fe3a300c015.js → a4fa40dc77e116c954ac.js} +1 -1
  55. package/assets/esri/core/workers/chunks/a54ec9929a7db879d5db.js +1 -0
  56. package/assets/esri/core/workers/chunks/afc5b84693757fda2bc8.js +1 -0
  57. package/assets/esri/core/workers/chunks/{591b5c277cfd3a4101a4.js → b08f2a4aa94087c6c367.js} +1 -1
  58. package/assets/esri/core/workers/chunks/c0e12f6a7bb2360e4c21.js +1 -0
  59. package/assets/esri/core/workers/chunks/c8e656cd470a17f538e9.js +1 -0
  60. package/assets/esri/core/workers/chunks/d0e203405f95e14b1399.js +1 -0
  61. package/assets/esri/core/workers/chunks/d61506497275bafba384.js +1 -0
  62. package/assets/esri/core/workers/chunks/{ec72f492f24e67e008ae.js → d8e58dc14d3495f0830c.js} +1 -1
  63. package/assets/esri/core/workers/chunks/db9a303ee0468d018def.js +1 -0
  64. package/assets/esri/core/workers/chunks/ddc393a012588f799f42.js +1 -0
  65. package/assets/esri/core/workers/chunks/de3baa85b1639c25458d.js +1 -0
  66. package/assets/esri/core/workers/chunks/e66cea26064ba8353af0.js +1 -0
  67. package/assets/esri/core/workers/chunks/ea478f2f4a19463e13fd.js +1 -0
  68. package/assets/esri/core/workers/chunks/eba197e45507f56f3ed0.js +1 -0
  69. package/assets/esri/core/workers/chunks/ebd006fcd568a7731115.js +1 -0
  70. package/assets/esri/core/workers/chunks/ef9a9a7d66d818720e20.js +1 -0
  71. package/assets/esri/core/workers/chunks/f3b458f55236566c940b.js +1 -0
  72. package/assets/esri/core/workers/chunks/fd0a91b9e0216cc269c3.js +1 -0
  73. package/assets/esri/core/workers/chunks/{a4fe220a912b1f428e49.js → fdd6403a8390d629392b.js} +1 -1
  74. package/assets/esri/themes/base/widgets/_Directions.scss +13 -7
  75. package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +108 -4
  76. package/assets/esri/themes/dark/main.css +1 -1
  77. package/assets/esri/themes/light/main.css +1 -1
  78. package/assets/esri/themes/light/view.css +1 -1
  79. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer.json +1 -1
  80. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_en.json +1 -1
  81. package/chunks/ComponentShader.glsl.js +1 -1
  82. package/chunks/LineSeries.js +1 -1
  83. package/chunks/Theme.js +1 -1
  84. package/chunks/array.js +1 -1
  85. package/chunks/chartUtilsAm5.js +1 -1
  86. package/core/Collection.js +1 -1
  87. package/core/accessorSupport/decorators/subclass.js +1 -1
  88. package/core/accessorSupport/ensureType.js +1 -1
  89. package/core/accessorSupport/get.js +1 -1
  90. package/core/accessorSupport/tracking.js +1 -1
  91. package/core/accessorSupport/utils.js +1 -1
  92. package/core/libs/rbush/PooledRBush.js +1 -1
  93. package/core/urlUtils.js +1 -1
  94. package/geometry/GeometryCursor.js +1 -1
  95. package/geometry/support/TileClipper.js +1 -1
  96. package/geometry/support/geodesicUtils.js +1 -1
  97. package/interfaces.d.ts +9 -3
  98. package/layers/BuildingSceneLayer.js +1 -1
  99. package/layers/IntegratedMeshLayer.js +1 -1
  100. package/layers/LinkChartLayer.js +1 -1
  101. package/layers/PointCloudLayer.js +1 -1
  102. package/layers/SceneLayer.js +1 -1
  103. package/layers/VectorTileLayer.js +1 -1
  104. package/layers/VoxelLayer.js +1 -1
  105. package/layers/VoxelWasmPerSceneView.js +1 -1
  106. package/layers/WCSLayer.js +1 -1
  107. package/layers/effects/EffectView.js +1 -1
  108. package/layers/graphics/sources/geojson/geojson.js +1 -1
  109. package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
  110. package/layers/mixins/ArcGISCachedService.js +1 -1
  111. package/layers/orientedImagery/core/ExposurePoint.js +1 -1
  112. package/layers/orientedImagery/core/bestImageUtils.js +1 -1
  113. package/layers/orientedImagery/queries.js +1 -1
  114. package/layers/save/featureLayerUtils.js +1 -1
  115. package/layers/support/ElevationQuery.js +1 -1
  116. package/layers/support/MultidimensionalSubset.js +1 -1
  117. package/layers/support/Sublayer.js +1 -1
  118. package/layers/support/TileInfo.js +1 -1
  119. package/layers/support/TileInfoTilemapCache.js +1 -1
  120. package/layers/support/TilemapCache.js +1 -1
  121. package/layers/support/rasterDatasets/multidimensionalUtils.js +1 -1
  122. package/layers/support/rasterDatasets/pamParser.js +1 -1
  123. package/layers/support/rasterDatasets/wcsCoverageParser.js +1 -1
  124. package/layers/support/rasterFormats/Raw.js +1 -1
  125. package/layers/support/rasterFormats/TiffDecoder.js +1 -1
  126. package/layers/support/rasterFunctions/ExtractBandFunction.js +1 -1
  127. package/layers/support/rasterFunctions/colormaps.js +1 -1
  128. package/layers/support/rasterFunctions/pixelUtils.js +1 -1
  129. package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
  130. package/layers/video/VideoController.js +1 -1
  131. package/layers/voxel/VoxelDimension.js +1 -1
  132. package/layers/voxel/VoxelTransferFunctionStyle.js +1 -1
  133. package/layers/voxel/VoxelVolume.js +1 -1
  134. package/package.json +1 -1
  135. package/renderers/support/RasterSymbolizer.js +1 -1
  136. package/renderers/support/colorRampUtils.js +1 -1
  137. package/renderers/visualVariables/support/visualVariableUtils.js +1 -1
  138. package/rest/query/operations/pbfDehydratedFeatureSet.js +1 -1
  139. package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
  140. package/rest/support/generateRendererUtils.js +1 -1
  141. package/smartMapping/raster/renderers/classBreaks.js +1 -1
  142. package/smartMapping/renderers/color.js +1 -1
  143. package/smartMapping/renderers/support/utils.js +1 -1
  144. package/smartMapping/renderers/type.js +1 -1
  145. package/smartMapping/renderers/univariateColorSize.js +1 -1
  146. package/smartMapping/support/adapters/support/utils.js +1 -1
  147. package/statistics/utils.js +1 -1
  148. package/support/elevationInfoUtils.js +1 -1
  149. package/support/revision.js +1 -1
  150. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  151. package/symbols/cim/GeometryWalker.js +1 -1
  152. package/symbols/cim/cimAnalyzer.js +1 -1
  153. package/symbols/cim/effects/EffectArrow.js +1 -1
  154. package/symbols/cim/effects/EffectControlMeasureLine.js +1 -1
  155. package/symbols/support/symbolUtils.js +1 -1
  156. package/views/2d/constraints/ZoomConstraint.js +1 -1
  157. package/views/2d/engine/flow/dataUtils.js +1 -1
  158. package/views/2d/engine/flow/utils.js +1 -1
  159. package/views/2d/engine/vectorTiles/VectorTile.js +1 -1
  160. package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
  161. package/views/2d/engine/vectorTiles/expression/expression.js +1 -1
  162. package/views/2d/engine/vectorTiles/style/VectorTileSource.js +1 -1
  163. package/views/2d/engine/vectorTiles/tileInfoUtils.js +1 -1
  164. package/views/2d/engine/webgl/TurboLine.js +1 -1
  165. package/views/2d/engine/webgl/mesh/MeshData.js +1 -1
  166. package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
  167. package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
  168. package/views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js +1 -1
  169. package/views/2d/layers/BaseLayerView2D.js +1 -1
  170. package/views/2d/layers/BaseLayerViewGL2D.js +1 -1
  171. package/views/2d/layers/BitmapTileLayerView2D.js +1 -1
  172. package/views/2d/layers/MediaLayerView2D.js +1 -1
  173. package/views/2d/layers/TileLayerView2D.js +1 -1
  174. package/views/2d/layers/VectorTileLayerView2D.js +1 -1
  175. package/views/2d/layers/WMTSLayerView2D.js +1 -1
  176. package/views/2d/layers/features/support/rendererUtils.js +1 -1
  177. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  178. package/views/2d/layers/support/vectorTileDebugUtils.js +5 -0
  179. package/views/2d/tiling/TileInfoView.js +1 -1
  180. package/views/2d/tiling/TileInfoViewPOT.js +1 -1
  181. package/views/2d/tiling/TileQueue.js +1 -1
  182. package/views/2d/tiling.js +1 -1
  183. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  184. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  185. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  186. package/views/3d/externalRenderers/ExternalRendererStore.js +1 -1
  187. package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
  188. package/views/3d/interactive/visualElements/LaserlineVisualElement.js +1 -1
  189. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  190. package/views/3d/layers/TiledLayerView3D.js +1 -1
  191. package/views/3d/layers/VectorTileLayerView3D.js +1 -1
  192. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  193. package/views/3d/layers/graphics/Labeler.js +1 -1
  194. package/views/3d/layers/i3s/PointRenderer.js +1 -1
  195. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  196. package/views/3d/layers/support/featureReference.js +1 -1
  197. package/views/3d/support/LaserLineRenderer.js +1 -1
  198. package/views/3d/terrain/Overlay.js +1 -1
  199. package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
  200. package/views/3d/terrain/OverlayManager.js +1 -1
  201. package/views/3d/terrain/OverlayRenderTarget.js +1 -1
  202. package/views/3d/terrain/OverlayRenderer.js +1 -1
  203. package/views/3d/terrain/TerrainRenderer.js +1 -1
  204. package/views/3d/terrain/TerrainSurface.js +1 -1
  205. package/views/3d/terrain/TileCompositor.js +1 -1
  206. package/views/3d/terrain/TileRenderer.js +1 -1
  207. package/views/3d/terrain/TilingScheme.js +1 -1
  208. package/views/3d/webgl-engine/collections/Component/ComponentData.js +1 -1
  209. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  210. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateAmbientOcclusion.glsl.js +1 -1
  211. package/views/3d/webgl-engine/core/shaderModules/interfaces.js +1 -1
  212. package/views/3d/webgl-engine/effects/RenderPlugin.js +5 -0
  213. package/views/3d/webgl-engine/effects/RenderPluginManager.js +5 -0
  214. package/views/3d/webgl-engine/effects/ScreenSpaceGeometry.js +5 -0
  215. package/views/3d/webgl-engine/effects/SmaaRenderPass.js +5 -0
  216. package/views/3d/webgl-engine/lib/CompositingHelper.js +1 -1
  217. package/views/3d/webgl-engine/lib/GLMaterials.js +1 -1
  218. package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
  219. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  220. package/views/3d/webgl-engine/lib/PathBuilder.js +1 -1
  221. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  222. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  223. package/views/3d/webgl-engine/lib/SSAOHelper.js +1 -1
  224. package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
  225. package/views/3d/webgl-engine/lib/WebGLLayer.js +1 -1
  226. package/views/3d/webgl-engine/lib/lodRendering/LodComponentData.js +1 -1
  227. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  228. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  229. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  230. package/views/3d/webgl-engine/parts/requireUtils.js +1 -1
  231. package/views/3d/webgl-engine/statistics/RendererPerformanceInfo.js +1 -1
  232. package/views/LayerViewManager.js +1 -1
  233. package/views/MapView.js +1 -1
  234. package/views/SceneView.js +1 -1
  235. package/views/animation/pointToPoint/Path.js +1 -1
  236. package/views/draw/DrawOperation.js +1 -1
  237. package/views/draw/support/Reshape.js +1 -1
  238. package/views/draw/support/createUtils.js +1 -1
  239. package/views/interactive/SegmentLabels.js +1 -1
  240. package/views/interactive/editGeometry/EditGeometry.js +1 -1
  241. package/views/interactive/editGeometry/EditGeometryOperations.js +1 -1
  242. package/views/interactive/editGeometry/operations/UndoGroup.js +1 -1
  243. package/views/layers/GroupLayerView.js +1 -1
  244. package/views/layers/ImageryTileLayerView.js +1 -1
  245. package/views/webgl/ProgramCache.js +1 -1
  246. package/webscene/spec-certification/api.js +1 -1
  247. package/webscene/spec-certification/spec.js +1 -1
  248. package/webscene/spec-certification/utils.js +1 -1
  249. package/widgets/BuildingExplorer/BuildingNumericFilterViewModel.js +1 -1
  250. package/widgets/BuildingExplorer/BuildingPhase.js +1 -1
  251. package/widgets/BuildingExplorer/support/validation.js +1 -1
  252. package/widgets/Directions/support/resources.js +1 -1
  253. package/widgets/Directions.js +1 -1
  254. package/widgets/Editor/EditorViewModel.js +1 -1
  255. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  256. package/widgets/Editor/Workflow.js +1 -1
  257. package/widgets/Editor.js +1 -1
  258. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  259. package/widgets/FeatureForm/FieldInput.js +1 -1
  260. package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
  261. package/widgets/FeatureForm.js +1 -1
  262. package/widgets/FeatureTemplates/FeatureTemplatesViewModel.js +1 -1
  263. package/widgets/FeatureTemplates.js +1 -1
  264. package/widgets/Features.js +1 -1
  265. package/widgets/Histogram/HistogramViewModel.js +1 -1
  266. package/widgets/HistogramRangeSlider/HistogramRangeSliderViewModel.js +1 -1
  267. package/widgets/Legend/styles/Card.js +1 -1
  268. package/widgets/Legend/styles/support/univariateUtils.js +1 -1
  269. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  270. package/widgets/Legend/support/colorRampUtils.js +1 -1
  271. package/widgets/Legend/support/sizeRampUtils.js +1 -1
  272. package/widgets/Legend/support/utils.js +1 -1
  273. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  274. package/widgets/OrientedImageryViewer/arcUtils.js +5 -0
  275. package/widgets/OrientedImageryViewer/constants.js +5 -0
  276. package/widgets/OrientedImageryViewer/utils.js +5 -0
  277. package/widgets/OrientedImageryViewer.js +1 -1
  278. package/widgets/Popup/PopupViewModel.js +1 -1
  279. package/widgets/Popup.js +1 -1
  280. package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
  281. package/widgets/ScaleRangeSlider/ScaleRanges.js +1 -1
  282. package/widgets/ValuePicker/ValuePickerSlider.js +1 -1
  283. package/widgets/smartMapping/ClassedSizeSlider.js +1 -1
  284. package/widgets/smartMapping/ColorSizeSlider.js +1 -1
  285. package/widgets/smartMapping/HeatmapSlider/HeatmapSliderViewModel.js +1 -1
  286. package/widgets/smartMapping/SizeSlider.js +1 -1
  287. package/widgets/smartMapping/SmartMappingPrimaryHandleSliderViewModel.js +1 -1
  288. package/widgets/smartMapping/SmartMappingSliderViewModel.js +1 -1
  289. package/widgets/support/ColorPicker.js +1 -1
  290. package/assets/esri/core/workers/chunks/07bb40162d97d098bc19.js +0 -1
  291. package/assets/esri/core/workers/chunks/0a18317566c1fcb68422.js +0 -1
  292. package/assets/esri/core/workers/chunks/0de65e03db8c611af9fb.js +0 -1
  293. package/assets/esri/core/workers/chunks/1a60d23a92bcf91dbb22.js +0 -1
  294. package/assets/esri/core/workers/chunks/205a0b34b698d5329854.js +0 -1
  295. package/assets/esri/core/workers/chunks/2158a6ec165503ec4711.js +0 -1
  296. package/assets/esri/core/workers/chunks/25211d5904ee9d5f4a9d.js +0 -1
  297. package/assets/esri/core/workers/chunks/26b12d1ea713c1e07701.js +0 -1
  298. package/assets/esri/core/workers/chunks/2bfa7ee324c32a56b0d3.js +0 -1
  299. package/assets/esri/core/workers/chunks/370a992bd308bd806f48.js +0 -1
  300. package/assets/esri/core/workers/chunks/3892650ecc61322f6f7f.js +0 -1
  301. package/assets/esri/core/workers/chunks/38d168e9a29c40de179d.js +0 -1
  302. package/assets/esri/core/workers/chunks/4bf1c6c7e0a3051dc797.js +0 -1
  303. package/assets/esri/core/workers/chunks/524156c3f5383c2dd0e3.js +0 -1
  304. package/assets/esri/core/workers/chunks/59666ecb7c2c1f5a13b2.js +0 -1
  305. package/assets/esri/core/workers/chunks/5ae98195bdfd7dc0c44e.js +0 -1
  306. package/assets/esri/core/workers/chunks/5c005c9514354c77ec27.js +0 -1
  307. package/assets/esri/core/workers/chunks/5d46fd68878c973bcfab.js +0 -1
  308. package/assets/esri/core/workers/chunks/5dd23092c8a8a5ccd5d0.js +0 -1
  309. package/assets/esri/core/workers/chunks/620ec5c75561183d3d73.js +0 -1
  310. package/assets/esri/core/workers/chunks/68512670816f59c0e6a5.js +0 -1
  311. package/assets/esri/core/workers/chunks/6c7374ebc18b46b3480a.js +0 -1
  312. package/assets/esri/core/workers/chunks/75ba2af92da232067adb.js +0 -1
  313. package/assets/esri/core/workers/chunks/7c1f0598a016516dcec3.js +0 -1
  314. package/assets/esri/core/workers/chunks/8dcec8d1b670d2b7ea2b.js +0 -1
  315. package/assets/esri/core/workers/chunks/8e07dfb6fc2673b640cb.js +0 -1
  316. package/assets/esri/core/workers/chunks/9008dde941cb3973de20.js +0 -1
  317. package/assets/esri/core/workers/chunks/9050b167355588b7003d.js +0 -1
  318. package/assets/esri/core/workers/chunks/9230d68799f0b0b9ef36.js +0 -1
  319. package/assets/esri/core/workers/chunks/94d124453e90a5ab1706.js +0 -1
  320. package/assets/esri/core/workers/chunks/9ca312af9c056b1efe40.js +0 -1
  321. package/assets/esri/core/workers/chunks/b0a57718a0765d1c8df0.js +0 -1
  322. package/assets/esri/core/workers/chunks/b431b81a7bf45dd527da.js +0 -1
  323. package/assets/esri/core/workers/chunks/bda311ad48efdb265939.js +0 -1
  324. package/assets/esri/core/workers/chunks/da547c3cabe4a89c3ce6.js +0 -1
  325. package/assets/esri/core/workers/chunks/dd295fa57b45b7ec4ec5.js +0 -1
  326. package/assets/esri/core/workers/chunks/eb92aa372e706ce5a5eb.js +0 -1
  327. package/assets/esri/core/workers/chunks/f553b464e969d45bf451.js +0 -1
  328. package/assets/esri/core/workers/chunks/f5865294983eb160de8c.js +0 -1
  329. package/assets/esri/core/workers/chunks/fdb7b1fbdb6fe091ad83.js +0 -1
  330. package/assets/esri/core/workers/chunks/fe8544bf3bbbacd74b8b.js +0 -1
  331. package/views/2d/tiling/PagedTileQueue.js +0 -5
  332. package/views/3d/webgl-engine/lib/RenderPluginManager.js +0 -5
  333. package/views/3d/webgl-engine/lib/SmaaRenderPass.js +0 -5
  334. /package/views/3d/webgl-engine/{lib → effects}/SmaaRenderPassData.js +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import{releaseMaybe as t}from"../../../../core/maybe.js";import{c as e}from"../../../../chunks/vec4.js";import{f as i}from"../../../../chunks/vec4f64.js";import{ColorFormat as r,DepthFormat as h}from"../core/FBOCache.js";import{TransparencyPassType as s}from"./TransparencyPassType.js";import{ClearBufferBit as o}from"../../../webgl/enums.js";import{ensureAttachmentMaxSize as c}from"../../../webgl/FramebufferObject.js";class a{constructor(t,e){this._fbos=t,this.compositingHelper=e,this._width=4,this._height=4,this._backgroundColor=i(0,0,0,1)}dispose(){this._color=t(this._color),this.releaseBuffers()}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){e(this._backgroundColor,t)}get framebuffer(){return this.color.detachDepth(),this.color.attachDepth(this.depth),this.color.fbo}get colorTexture(){return this.color.colorTexture}get depthTexture(){return this.depth.attachment}initializeFrame(t){const e=this._fbos.rctx;this._width=t.fullWidth,this._height=t.fullHeight,c(this,e.parameters.maxTextureSize);const i=this._color;this._color=null,this.releaseBuffers(),this.bindFbo(),e.setClearStencil(0);const r=this._backgroundColor;return e.setClearColor(r[0]*r[3],r[1]*r[3],r[2]*r[3],r[3]),e.clearSafe(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT|o.STENCIL_BUFFER_BIT),i}releaseBuffers(){this._color?.detachDepth(),this._depth=t(this._depth)}compositeAtmosphereToMain(t,e,i,r){this._bindTarget(this.color),this.compositingHelper.compositeAtmosphere(t,i,r,e),this._bindTarget(this.color,this.depth)}renderHUDVisibility(t,e,i){return t?.fbo.width===this._width&&t?.fbo.height===this._height||(t?.release(),t=this._fbos.acquire(r.RGBA4,this._width,this._height)),t.attachDepth(i||this.depth),this._fbos.rctx.bindFramebuffer(t.fbo),this.renderToFBO(e,_),t.detachDepth(),t}compositeToHUDVisibility(t,e){this._fbos.rctx.bindFramebuffer(t.hudVisibility?.fbo),this.compositingHelper.compositeHUD(t,e)}renderOITPass(t,e,i){let o,c;switch(e){case s.Color:o=this._fbos.acquire(r.RGBA16F,this._width,this._height),c=[0,0,0,0];break;case s.Alpha:o=this._fbos.acquire(r.R16F,this._width,this._height),c=[1,1,1,1];break;case s.FrontFace:o=this._fbos.acquire(r.RGBA,this._width,this._height),c=[0,0,0,0]}return i?(o.acquireDepth(h.DEPTH16_BUFFER),this._fbos.rctx.bindFramebuffer(o.fbo),this.renderToFBO(t,c,!0,!0),o.releaseDepth()):(o.attachDepth(this.depth),this._fbos.rctx.bindFramebuffer(o.fbo),this.renderToFBO(t,c),o.detachDepth()),o}compositeToFramebuffer(t,e,i,r){this.bindFbo(),this.compositingHelper.composite(t,e,i,r)}compositeTransparentOntoOpaque(t,e,i,r,h){h?(this._fbos.rctx.bindFramebuffer(h.fbo),this._fbos.rctx.setClearColor(0,0,0,1e-13),this._fbos.rctx.clearSafe(o.COLOR_BUFFER_BIT)):this.bindFbo(),this.compositingHelper.compositeOIT(t,e.colorTexture,i.colorTexture,r.colorTexture)}renderDepthDetached(t){this._bindTarget(this.color),t(),this._bindTarget(this.color,this.depth)}renderToCachedFBO(e,i,s,o=r.RGBA,c=h.DEPTH16_BUFFER,a=this._width,_=this._height){return e?.fbo.width===a&&e?.fbo.height===_||(e=t(e)),e=e??this._fbos.acquire(o,a,_),null!=c&&e.acquireDepth(c),this._fbos.rctx.bindFramebuffer(e.fbo),this.renderToFBO(i,s,!0,!0),e}renderToFBO(t,e,i=!1,r=!1){const h=this._fbos.rctx;let s=0;if(e){const t=1e-13,i=Math.max(t,e[3]);h.setClearColor(e[0],e[1],e[2],i),s|=o.COLOR_BUFFER_BIT}i&&(s|=o.DEPTH_BUFFER_BIT),!1===r?r=0:(!0===r&&(r=255),s|=o.STENCIL_BUFFER_BIT),s&&h.clearSafe(s,r),t(),h.gl.flush()}renderToTargets(t,e,i,r,h=!1,s=!1){this._bindTarget(e,i),this.renderToFBO(t,r,h,s),e.detachDepth()}bindFbo(){this._bindTarget(this.color,this.depth)}_bindTarget(t,e){t.detachDepth(),t.attachDepth(e),this._fbos.rctx.bindFramebuffer(t.fbo)}get gpuMemoryUsage(){return(this._color?.colorTexture?.gpuMemoryUsage??0)+(this._depth?.memoryUsage??0)}get width(){return this._width}get height(){return this._height}get color(){return this._color||(this._color=this._fbos.acquire(r.RGBA,this._width,this._height)),this._color}get depth(){return this._depth||(this._depth=this._fbos.acquireDepth(h.DEPTH_STENCIL_TEXTURE,this._width,this._height)),this._depth}}const _=[0,1,0,1];export{a as OffscreenRendering};
5
+ import"../../../../core/has.js";import{releaseMaybe as t}from"../../../../core/maybe.js";import{c as e}from"../../../../chunks/vec4.js";import{f as r}from"../../../../chunks/vec4f64.js";import{ColorFormat as i,DepthFormat as h}from"../core/FBOCache.js";import{TransparencyPassType as s}from"./TransparencyPassType.js";import{ClearBufferBit as o}from"../../../webgl/enums.js";import{ensureAttachmentMaxSize as c}from"../../../webgl/FramebufferObject.js";class a{constructor(t,e){this._fbos=t,this.compositingHelper=e,this._width=4,this._height=4,this._backgroundColor=r(0,0,0,1)}dispose(){this._color=t(this._color),this.releaseBuffers()}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){e(this._backgroundColor,t)}get framebuffer(){return this.color.detachDepth(),this.color.attachDepth(this.depth),this.color.fbo}get colorTexture(){return this.color.colorTexture}get depthTexture(){return this.depth.attachment}initializeFrame(t){const e=this._fbos.rctx;this._width=t.fullWidth,this._height=t.fullHeight,c(this,e.parameters.maxTextureSize);const r=this._color;this._color=null,this.releaseBuffers(),this.bindFbo(),e.setClearStencil(0);const i=this._backgroundColor;return e.setClearColor(i[0]*i[3],i[1]*i[3],i[2]*i[3],i[3]),e.clearSafe(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT|o.STENCIL_BUFFER_BIT),r}releaseBuffers(){this._color?.detachDepth(),this._depth=t(this._depth)}renderHUDVisibility(t,e,r){return t?.fbo.width===this._width&&t?.fbo.height===this._height||(t?.release(),t=this._fbos.acquire(i.RGBA4,this._width,this._height)),t.attachDepth(r||this.depth),this._fbos.rctx.bindFramebuffer(t.fbo),this.renderToFBO(e,_),t.detachDepth(),t}compositeToHUDVisibility(t,e){this._fbos.rctx.bindFramebuffer(t.hudVisibility?.fbo),this.compositingHelper.compositeHUD(t,e)}renderOITPass(t,e,r){let o,c;switch(e){case s.Color:o=this._fbos.acquire(i.RGBA16F,this._width,this._height),c=[0,0,0,0];break;case s.Alpha:o=this._fbos.acquire(i.R16F,this._width,this._height),c=[1,1,1,1];break;case s.FrontFace:o=this._fbos.acquire(i.RGBA,this._width,this._height),c=[0,0,0,0]}return r?(o.acquireDepth(h.DEPTH16_BUFFER),this._fbos.rctx.bindFramebuffer(o.fbo),this.renderToFBO(t,c,!0,!0),o.releaseDepth()):(o.attachDepth(this.depth),this._fbos.rctx.bindFramebuffer(o.fbo),this.renderToFBO(t,c),o.detachDepth()),o}compositeToFramebuffer(t,e,r,i){this.bindFbo(),this.compositingHelper.composite(t,e,r,i)}compositeTransparentOntoOpaque(t,e,r,i,h){h?(this._fbos.rctx.bindFramebuffer(h.fbo),this._fbos.rctx.setClearColor(0,0,0,1e-13),this._fbos.rctx.clearSafe(o.COLOR_BUFFER_BIT)):this.bindFbo(),this.compositingHelper.compositeOIT(t,e.colorTexture,r.colorTexture,i.colorTexture)}renderDepthDetached(t){this._bindTarget(this.color),t(),this._bindTarget(this.color,this.depth)}renderToCachedFBO(e,r,s,o=i.RGBA,c=h.DEPTH16_BUFFER,a=this._width,_=this._height){return e?.fbo.width===a&&e?.fbo.height===_||(e=t(e)),e=e??this._fbos.acquire(o,a,_),null!=c&&e.acquireDepth(c),this._fbos.rctx.bindFramebuffer(e.fbo),this.renderToFBO(r,s,!0,!0),e}renderToFBO(t,e,r=!1,i=!1){const h=this._fbos.rctx;let s=0;if(e){const t=1e-13,r=Math.max(t,e[3]);h.setClearColor(e[0],e[1],e[2],r),s|=o.COLOR_BUFFER_BIT}r&&(s|=o.DEPTH_BUFFER_BIT),!1===i?i=0:(!0===i&&(i=255),s|=o.STENCIL_BUFFER_BIT),s&&h.clearSafe(s,i),t(),h.gl.flush()}renderToTargets(t,e,r,i,h=!1,s=!1){this._bindTarget(e,r),this.renderToFBO(t,i,h,s),e.detachDepth()}bindFbo(){this._bindTarget(this.color,this.depth)}_bindTarget(t,e){t.detachDepth(),t.attachDepth(e),this._fbos.rctx.bindFramebuffer(t.fbo)}get gpuMemoryUsage(){return(this._color?.colorTexture?.gpuMemoryUsage??0)+(this._depth?.memoryUsage??0)}get width(){return this._width}get height(){return this._height}get color(){return this._color||(this._color=this._fbos.acquire(i.RGBA,this._width,this._height)),this._color}get depth(){return this._depth||(this._depth=this._fbos.acquireDepth(h.DEPTH_STENCIL_TEXTURE,this._width,this._height)),this._depth}}const _=[0,1,0,1];export{a as OffscreenRendering};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{newFloatArray as t,floatSubArray as e}from"../../../../geometry/support/FloatArray.js";import{newIntArray as i,compactIndices as s}from"../../../../geometry/support/Indices.js";class r{constructor(s,r,o,h,p,n={}){this.path=s,this.profile=r,this.extruder=o,this.startCap=h,this.endCap=p,this.options=n,this._extrusionVertexCount=0;const l=this.path.vertices.length-2;this.numExtrusionProfiles=o.numProfilesPerJoin()*l+2,this.numVerticesTotal=r.vertices.length*this.numExtrusionProfiles,this.startCap.vertexBufferStart=this.numVerticesTotal;const a=this.startCap.numVertices;this.numVerticesTotal+=a,this.endCap.vertexBufferStart=this.numVerticesTotal;const u=this.endCap.numVertices;this.numVerticesTotal+=u,this.pathVertexData=i(1*this.numVerticesTotal),this.profileRightAxes=t(4*this.numVerticesTotal),this.profileUpAxes=t(4*this.numVerticesTotal),this.profileVertexAndNormals=t(4*this.numVerticesTotal),this.positions=e(s.positions,s.offset,3*s.vertices.length),this._rebuildGeometry(),this.buildTopology()}emitVertex(t,e,i,s,r){const o=4*this._extrusionVertexCount;if(this.profileRightAxes[o]=e.right[0],this.profileRightAxes[o+1]=e.right[1],this.profileRightAxes[o+2]=e.right[2],this.profileUpAxes[o]=e.up[0],this.profileUpAxes[o+1]=e.up[1],this.profileUpAxes[o+2]=e.up[2],this.profileVertexAndNormals[o]=i[0],this.profileVertexAndNormals[o+1]=i[1],this.profileVertexAndNormals[o+2]=s[0],this.profileVertexAndNormals[o+3]=s[1],this.pathVertexData[this._extrusionVertexCount]=t,r){const e=this.path.vertices[t],i=e.maxStretchDistance;this.profileRightAxes[o+3]=e.rotationRight[0]*i,this.profileUpAxes[o+3]=e.rotationRight[1]*i}else this.profileRightAxes[o+3]=0,this.profileUpAxes[o+3]=0;++this._extrusionVertexCount}emitCapVertex(t,e,i,s,r,o){const h=4*this._extrusionVertexCount;this.profileRightAxes[h]=e.right[0],this.profileRightAxes[h+1]=e.right[1],this.profileRightAxes[h+2]=e.right[2],this.profileRightAxes[h+3]=r,this.profileUpAxes[h]=e.up[0],this.profileUpAxes[h+1]=e.up[1],this.profileUpAxes[h+2]=e.up[2],this.profileUpAxes[h+3]=o,this.profileVertexAndNormals[h]=i[0],this.profileVertexAndNormals[h+1]=i[1],this.profileVertexAndNormals[h+2]=s[0],this.profileVertexAndNormals[h+3]=s[1],this.pathVertexData[this._extrusionVertexCount]=t,++this._extrusionVertexCount}_rebuildGeometry(){this._extrusionVertexCount=0;const{positions:t,offset:i,vertices:s}=this.path;this.positions=e(t,i,3*s.length);let r=0;const o=(t,e,i,s,o)=>this.emitCapVertex(r,t,e,i,s,o),h=(t,e,i,s)=>this.emitVertex(r,t,e,i,s);for(this.startCap.rebuildConnectingProfileGeometry(s[r],this.profile,o),r=1;r<s.length-1;++r)this.extruder.extrude(s[r],this.profile,h);this.endCap.rebuildConnectingProfileGeometry(s[r],this.profile,o),r=0,this.startCap.rebuildCapGeometry(s[r],o),r=s.length-1,this.endCap.rebuildCapGeometry(s[r],o)}buildTopology(){const t=this.profile.vertices.length,e=this.profile.numSegments,i=this.numExtrusionProfiles-1;let r=3*(2*(e*i));this.startCap.indexBufferStart=r,this.startCap.firstProfileVertexIndex=0,r+=this.startCap.numIndices,this.endCap.indexBufferStart=r,this.endCap.firstProfileVertexIndex=t*(this.numExtrusionProfiles-1);const o=new Array,h=new Array,p=new Array,n=(t,e,i)=>{o.push(t),o.push(e),o.push(i),h.push(t),h.push(e),h.push(i),p.push(this.pathVertexData[t]),p.push(this.pathVertexData[e]),p.push(this.pathVertexData[i])};for(let s=0;s<e;++s){const e=this.profile.indices[2*s],r=this.profile.indices[2*s+1];for(let s=0;s<i;++s){const i=s*t+e,o=(s+1)*t+r,h=s*t+r;n(i,(s+1)*t+e,o),n(i,o,h)}}this.startCap.buildTopology(this.path.vertices[0],n),this.endCap.buildTopology(this.path.vertices.at(-1),n),this.vertexIndices=s(o),this.normalIndices=s(h),this.pathVertexIndices=s(p)}onPathChanged(){this._rebuildGeometry()}}export{r as PathBuilder};
5
+ import{newFloatArray as t,floatSubArray as e}from"../../../../geometry/support/FloatArray.js";import{newIntArray as i,compactIndices as s}from"../../../../geometry/support/Indices.js";class r{constructor(s,r,h,o,p,n={}){this.path=s,this.profile=r,this.extruder=h,this.startCap=o,this.endCap=p,this.options=n,this._extrusionVertexCount=0;const l=this.path.vertices.length-2;this.numExtrusionProfiles=h.numProfilesPerJoin()*l+2,this.numVerticesTotal=r.vertices.length*this.numExtrusionProfiles,this.startCap.vertexBufferStart=this.numVerticesTotal;const a=this.startCap.numVertices;this.numVerticesTotal+=a,this.endCap.vertexBufferStart=this.numVerticesTotal;const u=this.endCap.numVertices;this.numVerticesTotal+=u,this.pathVertexData=i(1*this.numVerticesTotal),this.profileRightAxes=t(4*this.numVerticesTotal),this.profileUpAxes=t(4*this.numVerticesTotal),this.profileVertexAndNormals=t(4*this.numVerticesTotal),this.positions=e(s.positions,s.offset,3*s.vertices.length),this._rebuildGeometry(),this.buildTopology()}emitVertex(t,e,i,s,r){const h=4*this._extrusionVertexCount;if(this.profileRightAxes[h]=e.right[0],this.profileRightAxes[h+1]=e.right[1],this.profileRightAxes[h+2]=e.right[2],this.profileUpAxes[h]=e.up[0],this.profileUpAxes[h+1]=e.up[1],this.profileUpAxes[h+2]=e.up[2],this.profileVertexAndNormals[h]=i[0],this.profileVertexAndNormals[h+1]=i[1],this.profileVertexAndNormals[h+2]=s[0],this.profileVertexAndNormals[h+3]=s[1],this.pathVertexData[this._extrusionVertexCount]=t,r){const e=this.path.vertices[t],i=e.maxStretchDistance;this.profileRightAxes[h+3]=e.rotationRight[0]*i,this.profileUpAxes[h+3]=e.rotationRight[1]*i}else this.profileRightAxes[h+3]=0,this.profileUpAxes[h+3]=0;++this._extrusionVertexCount}emitCapVertex(t,e,i,s,r,h){const o=4*this._extrusionVertexCount;this.profileRightAxes[o]=e.right[0],this.profileRightAxes[o+1]=e.right[1],this.profileRightAxes[o+2]=e.right[2],this.profileRightAxes[o+3]=r,this.profileUpAxes[o]=e.up[0],this.profileUpAxes[o+1]=e.up[1],this.profileUpAxes[o+2]=e.up[2],this.profileUpAxes[o+3]=h,this.profileVertexAndNormals[o]=i[0],this.profileVertexAndNormals[o+1]=i[1],this.profileVertexAndNormals[o+2]=s[0],this.profileVertexAndNormals[o+3]=s[1],this.pathVertexData[this._extrusionVertexCount]=t,++this._extrusionVertexCount}_rebuildGeometry(){this._extrusionVertexCount=0;const{positions:t,offset:i,vertices:s}=this.path;this.positions=e(t,i,3*s.length);let r=0;const h=(t,e,i,s,h)=>this.emitCapVertex(r,t,e,i,s,h),o=(t,e,i,s)=>this.emitVertex(r,t,e,i,s);for(this.startCap.rebuildConnectingProfileGeometry(s[r],this.profile,h),r=1;r<s.length-1;++r)this.extruder.extrude(s[r],this.profile,o);this.endCap.rebuildConnectingProfileGeometry(s[r],this.profile,h),r=0,this.startCap.rebuildCapGeometry(s[r],h),r=s.length-1,this.endCap.rebuildCapGeometry(s[r],h)}buildTopology(){const t=this.profile.vertices.length,e=this.profile.numSegments,i=this.numExtrusionProfiles-1;let r=3*(2*(e*i));this.startCap.indexBufferStart=r,this.startCap.firstProfileVertexIndex=0,r+=this.startCap.numIndices,this.endCap.indexBufferStart=r,this.endCap.firstProfileVertexIndex=t*(this.numExtrusionProfiles-1);const h=new Array,o=new Array,p=new Array,n=(t,e,i)=>{h.push(t),h.push(e),h.push(i),o.push(t),o.push(e),o.push(i),p.push(this.pathVertexData[t]),p.push(this.pathVertexData[e]),p.push(this.pathVertexData[i])};for(let s=0;s<e;++s){const e=this.profile.indices[2*s],r=this.profile.indices[2*s+1];for(let s=0;s<i;++s){const i=s*t+e,h=(s+1)*t+r,o=s*t+r;n(i,(s+1)*t+e,h),n(i,h,o)}}this.startCap.buildTopology(this.path.vertices[0],n),this.endCap.buildTopology(this.path.vertices[this.path.vertices.length-1],n),this.vertexIndices=s(h),this.normalIndices=s(o),this.pathVertexIndices=s(p)}onPathChanged(){this._rebuildGeometry()}}export{r as PathBuilder};
@@ -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 A}from"../../../../chunks/boundedPlane.js";import P from"../../support/debugFlags.js";import{TransparencyMode as E}from"../../terrain/TerrainRenderer.js";import{FBOCache as b,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{AnimationTimeStep as w}from"./AnimationTimeStep.js";import{Decorations as D,RenderRequestType as N,StencilBits as M}from"./basicInterfaces.js";import{BoundingInfo as H}from"./BoundingInfo.js";import{ZERO as L,union as x}from"./depthRange.js";import{depthRangeFromScene as F}from"./depthRangeUtils.js";import{Highlight as v}from"./Highlight.js";import{RenderOccludedFlag as U}from"./Material.js";import{OffscreenRendering as G}from"./OffscreenRendering.js";import{RenderContext as q}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as B}from"./rendererUtils.js";import{setupFeatureDefaults as j,RenderFeature as V}from"./RenderFeature.js";import{RenderPluginManager as Q}from"./RenderPluginManager.js";import{RenderSlot as k}from"./RenderSlot.js";import{ShadowAccumulator as W}from"./ShadowAccumulator.js";import{ShadowHighlight as Y}from"./ShadowHighlight.js";import{ShadowMap as X,SnapshotSlot as z}from"./ShadowMap.js";import J from"./SliceHelper.js";import{SmaaRenderPass as K}from"./SmaaRenderPass.js";import{SSAOHelper as Z}from"./SSAOHelper.js";import{TransparencyPassType as $}from"./TransparencyPassType.js";import{EdgeView as ee}from"./edgeRendering/EdgeView.js";import{Transparency as re}from"./edgeRendering/interfaces.js";import{MergedRenderer as te}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as se}from"../shaders/CompositingTechniqueConfiguration.js";import{RendererPerformanceInfo as ie,PerformanceCategory as ae}from"../statistics/RendererPerformanceInfo.js";import{RenderState as ne}from"../../../support/RenderState.js";import{PixelFormat as he,PixelType as oe,ClearBufferBit as de}from"../../../webgl/enums.js";let le=class extends r{get _bindParameters(){return this._renderContext.bindParameters}updateRenderFeatures(e=null,r=!has("disable-feature:high-quality-idle")){this._renderStateFeatures=j(r,e),this.notifyChange("_renderStateFeatures"),this.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(V.HighQualityTransparency)}get hasReflections(){return this.hasWater&&(this._ssrEnabled||this.isFeatureEnabled(V.WaterReflection))}get hasDecorations(){return this._materialRenderersHas.decorations||this._renderPlugins.hasDecorations}get hasHighlights(){return this._materialRenderersHas.highlights||this._renderPlugins.requiresOutput(C.Highlight)}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(V.HighResolutionAtmosphere)}get hasWater(){return this._materialRenderersHas.water||this._hasOverlayWater}constructor(e,r,t,s,i,a,n,_){super({}),this._stage=e,this._materialRepository=r,this._techniqueRepository=s,this._rctx=i,this._compositingHelper=a,this._magnifierHelper=n,this._requestRender=_,this._materialRenderers=new h,this._needsTransparentPass=!1,this._materialRenderersHas={hudElements:!1,highlights:!1,water:!1,decorations:!1,occludees:!1},this._hasOverlayWater=!1,this._renderOverlay=e=>{},this._isRendering=!1,this._fallbackDepthStencilTexture=null,this._sliceHelper=new J,this._state=ne.IDLE,this._highQualityTransparencyEnabled=!0,this._terrainRenderingEnabled=!0,this._terrainTransparency=E.Opaque,this._ssrEnabled=!1,this._ssaoEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new w,this._renderHiddenTransparentEdges=()=>{},this.fboCache=new b(i),this._renderStateFeatures=j(!has("disable-feature:high-quality-idle"),e.view.qualityProfile),this._offscreen=new G(this.fboCache,this._compositingHelper),this.performanceInfo=new ie(this._rctx),this._shadowMap=new X(this.fboCache,e.viewingMode),this._ssaoHelper=new Z(e.view,this.fboCache,s,_),this._highlight=new v(s,this.fboCache),this._shadowHighlight=new Y(this._rctx,e.viewingMode),this._shadowAccumulator=new W(this.fboCache,s,e,(e=>{const r=this.shadowsEnabled;this._shadowMap.enabled=!0,this._prepare(e.camera,e.contentCamera),this._renderPlugins.prepareRender(),this._shadowMap.enabled=r}),((e,r,t)=>{e.shadowMap.start(e.camera,r,t,!0,this._stage.view.qualitySettings.maximumPixelRatio),this._renderShadowCascades(C.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._prepare(e.camera,e.contentCamera)}),_),this._renderContext=new q(this._rctx,this._offscreen,this._shadowMap,this._ssaoHelper,this._sliceHelper),this._renderPlugins=new Q({renderContext:this._renderContext,techniqueRepository:s,textureRepository:t,materialRepository:this._materialRepository,requestRender:_,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this.renderPassManager=new I(this._rctx,this._techniqueRepository),this._renderPlugins.add(this.renderPassManager),this._smaaPass=new K({view:this._stage.view}),this._renderPlugins.add(this._smaaPass),this.addHandles([o((()=>this._stage.view.state.camera),(()=>_()),d),o((()=>P.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(re.TRANSPARENT):()=>{},_()}),l),o((()=>this._ssaoEnabled||this.isFeatureEnabled(V.SSAO)),(e=>this._ssaoHelper.enabled=e),d)])}normalizeCtorArgs(){return{}}destroy(){this._smaaPass.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.destroy(),this._releaseFBOs(),this._bindParameters.linearDepth=n(this._bindParameters.linearDepth),this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility),this.fboCache.destroy(),H.prune()}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth),this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth)}disposeOffscreenBuffers(){this._releaseFBOs(),this._offscreen.dispose(),this._shadowMap.disposeOffscreenBuffers(),this._ssaoHelper.disposeOffscreenBuffers()}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=B(e);let n=!1;a.forEach(((t,s)=>{if(r.done)return;let i=this._materialRenderers.find((e=>e.material===s));null==i&&t.adds.length>0&&(i=new te(this._rctx,this._materialRepository,s),this._materialRenderers.push(i)),i&&(i.modify(t),i.isEmpty&&(n=!0)),t.removes.forEach((r=>e.removes.removeUnordered(r))),t.adds.forEach((r=>e.adds.removeUnordered(r))),t.updates.forEach((r=>e.updates.removeUnordered(r))),r.madeProgress()})),n&&this._materialRenderers.filterInPlace((e=>!e.isEmpty||(e.dispose(),!1))),this._updateHasFlags(),this._requestRender()}_updateHasFlags(){const has=this._materialRenderersHas;has.decorations=!1,has.highlights=!1,has.hudElements=!1,has.water=!1,has.occludees=!1,this._materialRenderers.forAll((e=>{has.highlights||=e.hasHighlights,has.occludees||=e.hasOccludees,has.water||=e.hasWater,has.decorations||=e.isDecoration,has.hudElements||=e.canRender(k.LINE_CALLOUTS_HUD_DEPTH,C.Color)||e.canRender(k.HUD_MATERIAL,C.Color)||e.canRender(k.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:n,contentCamera:h,mode:o,alignPixelEnabled:d}=t;this._state=o,this._renderOverlay(i),this.performanceInfo.advance(ae.OVERLAY),this._renderContext.time=i,this._bindParameters.transparencyPassType=$.NONE,this._bindParameters.alignPixelEnabled=d,this._bindParameters.decorations=s;const l=A(this._sliceHelper.plane);s===D.OFF&&(this._sliceHelper.plane=null),this._rctx.bindFramebuffer(e),n.setGLViewport(this._rctx);const _=a.initializeFrame(n);this.hasReflections?this._bindParameters.ssr.lastFrameColor=_:_?.release(),this._prepare(n,h),this._renderPlugins.prepareRender(),this.performanceInfo.advance(ae.PREPARE);const p=this._computeDepthRange(n);this._renderShadowMap(e,n,this._bindParameters.lighting.mainLight.direction,p),this.performanceInfo.advance(ae.SHADOW_MAP),this._ensureBindParameters(n,h);const m=this._terrainRenderingEnabled&&(this._terrainTransparency===E.Semitransparent||this._terrainTransparency===E.TransparentWithDraped),c=this._highQualityTransparency&&m,u=this._needsTransparentPass||this._renderPlugins.canRender(k.TRANSPARENT_MATERIAL);this._prepareShaders(c,u),this._renderLinearDepth(),this.performanceInfo.advance(ae.LINEAR_DEPTH),this._accumulateShadows(p,n,h),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(c),this._setMultipassTerrain(c),this._renderEdges(re.OPAQUE),this.performanceInfo.advance(ae.OPAQUE_EDGES),a.bindFbo(),this._renderSlot(k.VOXEL),this.performanceInfo.advance(ae.VOXEL),this._renderHiddenTransparentEdges(),u&&(this._oitEnabled?this._renderOITPass(_e.Geometry):this._renderTransparentGeometry()),this.performanceInfo.advance(ae.TRANSPARENT);const f=this._renderGeometryLinearDepth(c);this._renderHUDVisibility(f),c||this._renderInternalSlot(k.LINE_CALLOUTS),this.performanceInfo.advance(ae.HUD_VISIBILITY),this._renderObjectAndLayerIdColor(r),this.performanceInfo.advance(ae.OBJECT_AND_LAYER_ID_COLOR),this._renderEdges(re.TRANSPARENT,f),f?.release(),this.performanceInfo.advance(ae.TRANSPARENT_EDGES);const g=m?this._renderTransparentTerrain():null;if(g&&this._bindParameters.hudVisibility&&(c?this._renderLineCallouts(O.Occluded):a.compositeToHUDVisibility(this._bindParameters,g.colorTexture),this._renderHUD(O.Occluded,a.framebuffer),this.performanceInfo.advance(ae.HUD_OCCLUDED)),this.performanceInfo.advance(ae.TRANSPARENT_TERRAIN),this._setTerrainCulling(!1),g&&(a.compositeToFramebuffer(this._bindParameters,g.colorTexture,se.PremultipliedAlpha,1),g.release(),c&&(this._renderEdges(re.OPAQUE),this.performanceInfo.advance(ae.OPAQUE_EDGES),u&&(this._oitEnabled?this._renderOITPass(_e.Geometry):this._renderTransparentGeometry()),this.performanceInfo.advance(ae.TRANSPARENT),this._renderEdges(re.TRANSPARENT),this.performanceInfo.advance(ae.TRANSPARENT_EDGES))),c&&this._renderLineCallouts(O.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),a.bindFbo(),this._renderInternalSlot(k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderSlot(k.POSTPROCESSING_ENVIRONMENT_TRANSPARENT),this._renderSlot(k.LASERLINES),this.performanceInfo.advance(ae.ENVIRONMENT),this._renderPlugins.needsLaserlineWithContrastControl){const{width:e,height:r,depth:t}=a,s=this.fboCache.acquire(S.RGBA,e,r),i=()=>this._renderSlot(k.LASERLINES_CONTRAST_CONTROL);a.renderToTargets(i,s,t,me),a.compositeToFramebuffer(this._bindParameters,s.colorTexture,se.PremultipliedAlpha,1),s.release()}this.performanceInfo.advance(ae.LASER_LINE),this._renderOccluded(),this.performanceInfo.advance(ae.OCCLUDED);const T=s===D.ON&&this._magnifierHelper.enabled,R=T&&null==e?this.fboCache.acquire(S.RGBA,a.width,a.height).acquireDepth(y.DEPTH16_BUFFER):null,P=R?.fbo??e;this._bindParameters.output=P,this._rctx.bindFramebuffer(P);const b=this._offscreen.colorTexture;this.renderPlugins.canRender(k.ANTIALIASING)?this._renderSlot(k.ANTIALIASING):null!=b&&this._compositingHelper.composite(this._bindParameters,b,se.None),this.performanceInfo.advance(ae.ANTIALIASING),this._renderHUD(O.NotOccluded,P),this.performanceInfo.advance(ae.HUD),this._renderHighlights(P,this._bindParameters),this.performanceInfo.advance(ae.HIGHLIGHTS),T&&this._magnifierHelper.render(this._rctx,this._bindParameters),P!==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=l,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(k.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._prepareInternalSlots(this._materialRenderers,k.LINE_CALLOUTS),r&&this._prepareTransparencySlots(),this._prepareInternalSlots(this._materialRenderers,k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._prepareSlots(k.POSTPROCESSING_ENVIRONMENT_TRANSPARENT,k.LASERLINES),this._rctx.gl.flush()}_renderObjectAndLayerIdColor(e){if(null==e||!has("enable-feature:objectAndLayerId-rendering"))return;const r=this._renderContext.output;this._rctx.bindFramebuffer(e),this._offscreen.renderToFBO((()=>this._renderGeometryAndTransparentTerrainPass(C.ObjectAndLayerIdColor)),[0,0,0,0],!0,!0),this._rctx.bindFramebuffer(e),this._offscreen.renderToFBO((()=>{this._bindParameters.hudRenderStyle=O.NotOccluded,this._renderInternalSlot(k.HUD_MATERIAL)}),void 0,!0,!0),this._renderContext.output=r}finish(e){this._hasAnimations||this._animationTimestep.clear();const r=this.performanceInfo.gpuSamplingEnabled,t=e===N.BACKGROUND;if(t||r){const e=t?this.performanceInfo.elapsedTime:0,s=r?this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.getError(),i=Math.max(e,s);this._animationTimestep.frame(i,t)}}readDepthPixels(e,r,t){const s=this._bindParameters.linearDepth?.fbo;if(s?.colorTexture)return void s.readPixels(r[0],r[1],r[2],r[3],he.RGBA,oe.UNSIGNED_BYTE,t);const i=this.fboCache.acquire(S.RGBA,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(V.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._shadowHighlight.updateParameters(r,t),this._needsShadowHighlight?(this._renderShadowCascades(C.ShadowHighlight,this._shadowMap),i.moveSnapshot(z.Highlight),i.clear(),this._renderShadowCascades(C.ShadowExcludeHighlight,this._shadowMap),i.copySnapshot(z.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 L;const r=F(e,this._materialRenderers,this._stage.layers);return x(r,this.renderPlugins.queryDepthRange(e)),r.near=Math.max(e.near,r.near),r.far=Math.min(e.far,r.far),r}_renderGeometryAndTransparentTerrainPass(e){this._renderContext.output=e,this._prepareSlots(k.TRANSPARENT_TERRAIN),this._renderGeometryPass(e),this._renderTransparentTerrain()}_renderGeometryPass(e){this._renderContext.output=e,this._prepareSlots(k.TRANSPARENT_MATERIAL),this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderSSAO(e){if(!this._ssaoHelper.active)return;const r=this._offscreen.renderToCachedFBO(null,(()=>this._renderGeometryAndTransparentTerrainPass(C.Normal)),[0,0,0,0],S.RGBA4,y.DEPTH24_BUFFER);r.releaseDepth(),this._offscreen.bindFbo(),this._ssaoHelper.render(this._bindParameters,e,r.colorTexture),r.release()}_prepareOpaqueGeometrySlots(){this._prepareSlots(k.INTEGRATED_MESH,k.OPAQUE_TERRAIN,k.OPAQUE_MATERIAL,k.POSTPROCESSING_ENVIRONMENT_OPAQUE),this._prepareInternalSlots(this._materialRenderers,k.OPAQUE_MATERIAL)}_renderOpaqueGeometry(){this._renderSlot(k.INTEGRATED_MESH),this._renderSlot(k.OPAQUE_TERRAIN),this._renderInternalSlot(k.OPAQUE_MATERIAL),this._renderSlot(k.OPAQUE_MATERIAL),this._renderSlot(k.POSTPROCESSING_ENVIRONMENT_OPAQUE)}_renderTransparentGeometry(){this._renderInternalSlot(k.TRANSPARENT_MATERIAL),this._renderSlot(k.TRANSPARENT_MATERIAL)}_renderTransparentTerrain(){const e=this._renderPlugins.prepare(k.TRANSPARENT_TERRAIN);if(0===e.size)return;const r=()=>this._renderPlugins.render(e);if(this._renderContext.output!==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,k.OCCLUSION_PIXELS)?(this._bindParameters.hudVisibility=this._offscreen.renderHUDVisibility(this._bindParameters.hudVisibility,(()=>this._renderInternalSlot(k.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(k.LINE_CALLOUTS),{width:r,height:t,color:s}=this._offscreen,i=this.fboCache.acquireDepth(y.DEPTH16_BUFFER,r,t);this._offscreen.renderToTargets(e,s,i,void 0,!0,!0),i.release()}else this._renderInternalSlot(k.LINE_CALLOUTS)}_renderHUD(e,r){if(this._materialRenderersHas.hudElements)if(this._oitEnabled){const t=this._renderOITPass(_e.HUD,e);this._rctx.bindFramebuffer(r),this._compositingHelper.composite(this._bindParameters,t.colorTexture,se.PremultipliedAlpha),t.release()}else if(e===O.Occluded){const 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,k.LINE_CALLOUTS_HUD_DEPTH,k.HUD_MATERIAL,k.LABEL_MATERIAL),this._renderInternalSlot(k.LINE_CALLOUTS_HUD_DEPTH),this._renderInternalSlot(k.HUD_MATERIAL),this._renderInternalSlot(k.LABEL_MATERIAL)}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._shadowHighlight.isVisible&&this.hasHighlights}_renderHighlights(e,r){if(!this.hasHighlights||r.decorations===D.OFF)return;const t=()=>{this._renderGeometryAndTransparentTerrainPass(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,k.TRANSPARENT_MATERIAL),this._prepareSlots(k.TRANSPARENT_MATERIAL),this._renderContext.output=C.Color,this._bindParameters.transparencyPassType=$.Color,this._prepareInternalSlots(this._materialRenderers,k.TRANSPARENT_MATERIAL),this._prepareSlots(k.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=$.FrontFace,this._prepareInternalSlots(this._materialRenderers,k.TRANSPARENT_MATERIAL),this._prepareSlots(k.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=$.NONE}_renderOITPass(e,r=O.Both){const t=e===_e.HUD,s=t?this.fboCache.acquire(S.RGBA,this._offscreen.width,this._offscreen.height):null,i=t?()=>this._renderHUDElements(r):()=>this._renderTransparentGeometry(),a=this._renderContext.output;this._renderContext.output=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===U.OccludeAndTransparentStencil&&(e|=r.material.renderOccluded,ce.push(r))}));const r=this._offscreen,t=(t,s,i,a,n)=>{if(0==(e&s))return;const{width:h,height:o,depth:d}=r,l=this.fboCache.acquire(S.RGBA,h,o);r.renderToTargets(i,l,d,[0,0,0,0],a,n),r.compositeToFramebuffer(this._bindParameters,l.colorTexture,se.PremultipliedAlpha,t),l.release()};0!==ce.length&&(this._prepareInternalSlots(ce,k.OCCLUDER_MATERIAL,k.TRANSPARENT_OCCLUDER_MATERIAL),this._renderInternalSlot(k.OCCLUDER_MATERIAL,ce),t(.5,U.OccludeAndTransparentStencil,(()=>this._renderInternalSlot(k.TRANSPARENT_OCCLUDER_MATERIAL,ce)),!1,!1)),ce.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&(r.material.renderOccluded===U.OccludeAndTransparent||r.material.renderOccluded===U.Transparent||r.material.renderOccluded===U.Opaque)&&(e|=r.material.renderOccluded,ce.push(r))}));const s=this._renderPlugins.renderOccludedFlags;if(e|=s,!e)return;const i=e=>{this._renderContext.renderOccludedMask=e,this._prepareInternalSlots(ce,k.OPAQUE_MATERIAL,k.TRANSPARENT_MATERIAL,k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),s>U.Occlude&&this._renderSlot(k.OCCLUDED_TERRAIN),this._renderInternalSlot(k.OPAQUE_MATERIAL,ce),this._renderInternalSlot(k.TRANSPARENT_MATERIAL,ce),this._renderInternalSlot(k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,ce),this._renderContext.resetRenderOccludedMask()};this._renderContext.output=C.Color,t(.5,U.OccludeAndTransparent,(()=>i(U.OccludeAndTransparent)),!0,M.OutlineVisualElementMask),t(.5,U.Transparent,(()=>i(U.Transparent)),!0,M.OutlineVisualElementMask),t(1,U.Opaque,(()=>i(U.Opaque)),!0,M.OutlineVisualElementMask),ce.clear()}_prepare(e,r){this._needsTransparentPass=this._materialRenderers.some((e=>e.canRender(k.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._ssaoHelper?.gpuMemoryUsage??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._ssaoHelper?.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,ssao:this._ssaoHelper,highlight:this._highlight,lighting:this._bindParameters.lighting,materialRenderers:this._materialRenderers,shadowAccumulator:this._shadowAccumulator,weatherIsFading:this._bindParameters.cloudsFade.isFading,resetRenderStateFeatures:()=>{e._renderStateFeatures=j(),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{disposeMaybe as e,releaseMaybe as s}from"../../../../core/maybe.js";import{Milliseconds as t}from"../../../../core/time.js";import{s as r}from"../../../../chunks/vec2.js";import{ColorFormat as i}from"../core/FBOCache.js";import{createQuadVAO as a}from"./glUtil3D.js";import{SSAOBlurTechnique as o}from"./SSAOBlurTechnique.js";import{noiseData as h}from"./SSAONoiseData.js";import{SSAOTechnique as n}from"./SSAOTechnique.js";import{g as u}from"../../../../chunks/SSAO.glsl.js";import{SSAOPassParameters as _,BlurDrawParameters as l}from"../shaders/SSAOParameters.js";import{PrimitiveType as m,ClearBufferBit as c,TextureWrapMode as d,PixelFormat as p}from"../../../webgl/enums.js";import{Texture as b}from"../../../webgl/Texture.js";import{TextureDescriptor as T}from"../../../webgl/TextureDescriptor.js";import{vertexCount as f}from"../../../webgl/Util.js";const w=2;class q{constructor(e,s,t,r){this._view=e,this._fbos=s,this._techniques=t,this._requestRender=r,this._quadVAO=null,this._passParameters=new _,this._drawParameters=new l}dispose(){this.enabled=!1,this._quadVAO=e(this._quadVAO)}destroy(){this.dispose()}disposeOffscreenBuffers(){this._ssaoFBO=s(this._ssaoFBO)}set enabled(e){e?this._enable():this._disable()}get enabled(){return null!=this._enableTime}get active(){return this.enabled&&this._ssaoTechnique.compiled&&this._blurTechnique.compiled}get colorTexture(){return this._ssaoFBO?.colorTexture}render(e,t,o){if(null==this._enableTime||null==e.linearDepth?.colorTexture||null==o)return;if(!this.active)return this._enableTime=t,void this._requestRender();0===this._enableTime&&(this._enableTime=t),this._ssaoFBO=s(this._ssaoFBO);const h=this._fbos.rctx,n=e.camera,_=this._view.qualitySettings.fadeDuration,l=_>0?Math.min(_,t-this._enableTime)/_:1;this._passParameters.normalTexture=o,this._passParameters.depthTexture=e.linearDepth?.colorTexture,this._passParameters.projScale=1/n.computeRenderPixelSizeAtDist(1),this._passParameters.intensity=4*O/u(n)**6*l;const d=n.fullViewport,p=d[2],b=d[3],T=p/w,q=b/w,P=this._fbos.acquire(i.RED,p,b);null==this._quadVAO&&(this._quadVAO=a(this._fbos.rctx)),h.bindFramebuffer(P.fbo),h.setViewport(0,0,p,b);h.bindTechnique(this._ssaoTechnique,this._passParameters,e).bindDraw(this._drawParameters,e,this._passParameters),h.bindVAO(this._quadVAO);const A=f(this._quadVAO,"geometry");h.drawArrays(m.TRIANGLE_STRIP,0,A);const x=h.bindTechnique(this._blurTechnique,this._passParameters,e);h.setViewport(0,0,T,q);const g=this._fbos.acquire(i.RED,T,q);h.bindFramebuffer(g.fbo),this._drawParameters.colorTexture=P.colorTexture,r(this._drawParameters.blurSize,0,w/b),x.bindDraw(this._drawParameters,e,this._passParameters),h.setViewport(0,0,T,q),h.drawArrays(m.TRIANGLE_STRIP,0,A),P.release(),this._ssaoFBO=this._fbos.acquire(i.RED,T,q),h.bindFramebuffer(this._ssaoFBO.fbo),h.setViewport(0,0,p,b),h.setClearColor(1,1,1,0),h.clear(c.COLOR_BUFFER_BIT),h.setViewport(0,0,T,q),this._drawParameters.colorTexture=g.colorTexture,r(this._drawParameters.blurSize,w/p,0),x.bindDraw(this._drawParameters,e,this._passParameters),h.drawArrays(m.TRIANGLE_STRIP,0,A),h.setViewport(d[0],d[1],d[2],d[3]),g.release(),l<1&&this._requestRender()}_enable(){if(null!=this._enableTime)return;const e=Uint8Array.from(atob(h),(e=>e.charCodeAt(0))),s=new T;s.wrapMode=d.CLAMP_TO_EDGE,s.pixelFormat=p.RGB,s.wrapMode=d.REPEAT,s.hasMipmap=!0,s.width=32,s.height=32,this._passParameters.noiseTexture=new b(this._fbos.rctx,s,e),null==this._ssaoTechnique&&(this._ssaoTechnique=this._techniques.acquire(n)),null==this._blurTechnique&&(this._blurTechnique=this._techniques.acquire(o)),this._enableTime=t(0),this._requestRender()}_disable(){this._enableTime=null,this._passParameters.noiseTexture=e(this._passParameters.noiseTexture),this._ssaoFBO=s(this._ssaoFBO)}get gpuMemoryUsage(){return this._ssaoFBO?.fbo.gpuMemoryUsage??0}}const O=.5;export{q as SSAOHelper,w as blurSizePixels};
5
+ import{disposeMaybe as e}from"../../../../core/maybe.js";import{Milliseconds as s}from"../../../../core/time.js";import{s as r}from"../../../../chunks/vec2.js";import{ColorFormat as t}from"../core/FBOCache.js";import{createQuadVAO as i}from"./glUtil3D.js";import{SSAOBlurTechnique as a}from"./SSAOBlurTechnique.js";import{noiseData as o}from"./SSAONoiseData.js";import{SSAOTechnique as h}from"./SSAOTechnique.js";import{g as n}from"../../../../chunks/SSAO.glsl.js";import{SSAOPassParameters as u,BlurDrawParameters as l}from"../shaders/SSAOParameters.js";import{PrimitiveType as m,ClearBufferBit as _,TextureWrapMode as c,PixelFormat as d}from"../../../webgl/enums.js";import{Texture as b}from"../../../webgl/Texture.js";import{TextureDescriptor as p}from"../../../webgl/TextureDescriptor.js";import{vertexCount as T}from"../../../webgl/Util.js";const f=2;class w{constructor(e,s,r,t){this._view=e,this._fbos=s,this._techniques=r,this._requestRender=t,this._quadVAO=null,this._passParameters=new u,this._drawParameters=new l}dispose(){this.enabled=!1,this._quadVAO=e(this._quadVAO)}destroy(){this.dispose()}set enabled(e){e?this._enable():this._disable()}get enabled(){return null!=this._enableTime}get active(){return this.enabled&&this._ssaoTechnique.compiled&&this._blurTechnique.compiled}render(e,s,a){if(null==this._enableTime||null==e.linearDepth?.colorTexture||null==a)return;if(!this.active)return this._enableTime=s,void this._requestRender();0===this._enableTime&&(this._enableTime=s);const o=this._fbos.rctx,h=e.camera,u=this._view.qualitySettings.fadeDuration,l=u>0?Math.min(u,s-this._enableTime)/u:1;this._passParameters.normalTexture=a,this._passParameters.depthTexture=e.linearDepth?.colorTexture,this._passParameters.projScale=1/h.computeRenderPixelSizeAtDist(1),this._passParameters.intensity=4*q/n(h)**6*l;const c=h.fullViewport,d=c[2],b=c[3],p=d/f,w=b/f,P=this._fbos.acquire(t.RED,d,b);null==this._quadVAO&&(this._quadVAO=i(this._fbos.rctx)),o.bindFramebuffer(P.fbo),o.setViewport(0,0,d,b);o.bindTechnique(this._ssaoTechnique,this._passParameters,e).bindDraw(this._drawParameters,e,this._passParameters),o.bindVAO(this._quadVAO);const A=T(this._quadVAO,"geometry");o.drawArrays(m.TRIANGLE_STRIP,0,A);const x=o.bindTechnique(this._blurTechnique,this._passParameters,e);o.setViewport(0,0,p,w);const R=this._fbos.acquire(t.RED,p,w);o.bindFramebuffer(R.fbo),this._drawParameters.colorTexture=P.colorTexture,r(this._drawParameters.blurSize,0,f/b),x.bindDraw(this._drawParameters,e,this._passParameters),o.setViewport(0,0,p,w),o.drawArrays(m.TRIANGLE_STRIP,0,A),P.release();const S=this._fbos.acquire(t.RED,p,w);return o.bindFramebuffer(S.fbo),o.setViewport(0,0,d,b),o.setClearColor(1,1,1,0),o.clear(_.COLOR_BUFFER_BIT),o.setViewport(0,0,p,w),this._drawParameters.colorTexture=R.colorTexture,r(this._drawParameters.blurSize,f/d,0),x.bindDraw(this._drawParameters,e,this._passParameters),o.drawArrays(m.TRIANGLE_STRIP,0,A),o.setViewport(c[0],c[1],c[2],c[3]),R.release(),l<1&&this._requestRender(),S}_enable(){if(null!=this._enableTime)return;const e=Uint8Array.from(atob(o),(e=>e.charCodeAt(0))),r=new p;r.wrapMode=c.CLAMP_TO_EDGE,r.pixelFormat=d.RGB,r.wrapMode=c.REPEAT,r.hasMipmap=!0,r.width=32,r.height=32,this._passParameters.noiseTexture=new b(this._fbos.rctx,r,e),null==this._ssaoTechnique&&(this._ssaoTechnique=this._techniques.acquire(h)),null==this._blurTechnique&&(this._blurTechnique=this._techniques.acquire(a)),this._enableTime=s(0),this._requestRender()}_disable(){this._enableTime=null,this._passParameters.noiseTexture=e(this._passParameters.noiseTexture)}}const q=.5;export{w as SSAOHelper,f as blurSizePixels};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import t from"../../../../core/PooledArray.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{a as n}from"../../../../chunks/vec2f64.js";import{OverlayTarget as a}from"../../terrain/Intersector.js";import{ChangeSet as o}from"./ChangeSet.js";import{newIntersectorResult as d}from"./Intersector.js";import{StoreResults as h,IntersectorType as l}from"./IntersectorInterfaces.js";import{DirtyOperation as c,DirtyState as m}from"./ModelDirtyTypes.js";import{splitRenderGeometryChangeSetByMaterial as p}from"./rendererUtils.js";import{MergedRenderer as g}from"../materials/renderers/MergedRenderer.js";let u=class extends r{constructor(e){super(e),this._pending=new _,this._changes=new o,this._materialRenderers=new t,this._sortedMaterialRenderers=new t,this._geometries=new Map,this._hasHighlights=!1,this._hasWater=!1}destroy(){this._changes.prune(),this._materialRenderers.forAll((e=>e.dispose())),this._materialRenderers.clear(),this._sortedMaterialRenderers.clear(),this._geometries.clear(),this._pending.clear()}get updating(){return!this._pending.empty||this._changes.updates.length>0}get rctx(){return this.rendererContext.rctx}get _materialRepository(){return this.rendererContext.materialRepository}get _localOriginFactory(){return this.rendererContext.localOriginFactory}get hasHighlights(){return this._hasHighlights}get hasWater(){return this._hasWater}get rendersOccluded(){return this._materialRenderers.some((e=>e.rendersOccluded))}get isEmpty(){return!this.updating&&0===this._materialRenderers.length&&0===this._geometries.size}get usedMemory(){return this._materialRenderers.reduce(((e,r)=>e+r.usedMemory),0)}commitChanges(){if(!this.updating)return!1;this._processAddsRemoves();const e=p(this._changes);let r=!1,t=!1,s=!1;return e.forEach(((e,i)=>{let n=this._materialRenderers.find((e=>e.material===i));if(!n&&e.adds.length>0&&(n=new g(this.rctx,this._materialRepository,i),this._materialRenderers.push(n),r=!0,t=!0,s=!0),!n)return;const a=t||n.hasHighlights,o=s||n.hasWater;n.modify(e),t=t||a!==n.hasHighlights,s=s||o!==n.hasWater,n.isEmpty&&(this._materialRenderers.removeUnordered(n),n.dispose(),r=!0)})),this._changes.clear(),r&&this._updateSortedMaterialRenderers(),t&&(this._hasHighlights=this._materialRenderers.some((e=>e.hasHighlights))),s&&(this._hasWater=this._materialRenderers.some((e=>e.hasWater))),this.notifyChange("updating"),!0}addGeometries(e,r){if(0===e.length)return;const t=this._validateRenderGeometries(e);for(const i of t)this._geometries.set(i.id,i);const s=this._pending.empty;for(const i of t)this._pending.adds.add(i);s&&this.notifyChange("updating"),r===c.UPDATE&&this._notifyGraphicGeometryChanged(e)}removeGeometries(e,r){const t=this._pending.empty,s=this._pending.adds;for(const i of e)s.has(i)?(this._pending.removed.add(i),s.delete(i)):this._pending.removed.has(i)||this._pending.removes.add(i),this._geometries.delete(i.id);t&&!this._pending.empty&&this.notifyChange("updating"),r===c.UPDATE&&this._notifyGraphicGeometryChanged(e)}modifyGeometries(e,r){const t=0===this._changes.updates.length;for(const s of e){const e=this._changes.updates.pushNew();e.renderGeometry=this._validateRenderGeometry(s),e.updateType=r}switch(t&&this._changes.updates.length>0&&this.notifyChange("updating"),r){case m.TRANSFORMATION:case m.GEOMETRY:return this._notifyGraphicGeometryChanged(e);case m.VISIBILITY:return this._notifyGraphicVisibilityChanged(e)}}updateAnimation(e){let r=!1;return this._sortedMaterialRenderers.forAll((t=>r=t.updateAnimation(e)||r)),r}render(e){this._sortedMaterialRenderers.forAll((r=>{if(r.material.shouldRender(e)){const t=r.prepareTechnique(e);null!=t&&r.render(e,t)}}))}intersect(e,r,t,s,i){return this._geometries.forEach((n=>{if(s&&!s(n))return;this._intersectRenderGeometry(n,t,r,0,e,i);const a=this.rendererContext.longitudeCyclical;a&&(n.boundingSphere[0]-n.boundingSphere[3]<a.min&&this._intersectRenderGeometry(n,t,r,a.range,e,i),n.boundingSphere[0]+n.boundingSphere[3]>a.max&&this._intersectRenderGeometry(n,t,r,-a.range,e,i)),i++})),i}_updateSortedMaterialRenderers(){this._sortedMaterialRenderers.clear();let e=0;this._materialRenderers.forAll((r=>{r.material.insertOrder=e++,this._sortedMaterialRenderers.push(r)})),this._sortedMaterialRenderers.sort(((e,r)=>{const t=r.material.renderPriority-e.material.renderPriority;return 0!==t?t:e.material.insertOrder-r.material.insertOrder}))}_processAddsRemoves(){this._changes.adds.clear(),this._changes.removes.clear(),this._changes.adds.pushArray(Array.from(this._pending.adds)),this._changes.removes.pushArray(Array.from(this._pending.removes));for(let e=0;e<this._changes.updates.length;){const r=this._changes.updates.data[e];this._pending.has(r.renderGeometry)?this._changes.updates.removeUnorderedIndex(e):e++}this._pending.clear()}_intersectRenderGeometry(e,r,t,s,i,n){if(!e.visible)return;let a=0;s+=e.transformation[12],a=e.transformation[13],f[0]=t[0]-s,f[1]=t[1]-a,e.screenToWorldRatio=this.rendererContext.screenToWorldRatio,e.material.intersectDraped(e,null,i,f,((t,s,a)=>{y(r,a,e.material.renderPriority,n,i,e.layerUid,e.graphicUid)}),r)}_notifyGraphicGeometryChanged(e){if(null==this.drapeSource.notifyGraphicGeometryChanged)return;let r;for(const t of e){const e=t.graphicUid;null!=e&&e!==r&&(this.drapeSource.notifyGraphicGeometryChanged(e),r=e)}}_notifyGraphicVisibilityChanged(e){if(null==this.drapeSource.notifyGraphicVisibilityChanged)return;let r;for(const t of e){const e=t.graphicUid;null!=e&&e!==r&&(this.drapeSource.notifyGraphicVisibilityChanged(e),r=e)}}_validateRenderGeometries(e){for(const r of e)this._validateRenderGeometry(r);return e}_validateRenderGeometry(e){return null==e.localOrigin&&(e.localOrigin=this._localOriginFactory.getOrigin(e.boundingSphere)),e}get test(){return{sortedMaterialRenderers:this._sortedMaterialRenderers}}};e([s()],u.prototype,"drapeSource",void 0),e([s()],u.prototype,"updating",null),e([s()],u.prototype,"rctx",null),e([s()],u.prototype,"rendererContext",void 0),e([s()],u.prototype,"_materialRepository",null),e([s()],u.prototype,"_localOriginFactory",null),e([s({readOnly:!0})],u.prototype,"isEmpty",null),e([s()],u.prototype,"_materialRenderers",void 0),e([s()],u.prototype,"_geometries",void 0),u=e([i("esri.views.3d.webgl-engine.lib.SortedRenderGeometryRenderer")],u);class _{constructor(){this.adds=new Set,this.removes=new Set,this.removed=new Set}get empty(){return 0===this.adds.size&&0===this.removes.size&&0===this.removed.size}has(e){return this.adds.has(e)||this.removes.has(e)||this.removed.has(e)}clear(){this.adds.clear(),this.removes.clear(),this.removed.clear()}}function y(e,r,t,s,i,n,o){const c=new a(n,o,r),m=r=>{r.set(l.OVERLAY,c,e.dist,e.normal,e.transformation,t,s)};if((null==i.results.min.drapedLayerOrder||t>=i.results.min.drapedLayerOrder)&&(null==i.results.min.dist||i.results.ground.dist<=i.results.min.dist)&&m(i.results.min),i.options.store!==h.MIN&&(null==i.results.max.drapedLayerOrder||t<i.results.max.drapedLayerOrder)&&(null==i.results.max.dist||i.results.ground.dist>i.results.max.dist)&&m(i.results.max),i.options.store===h.ALL){const e=d(i.ray);m(e),i.results.all.push(e)}}const f=n();export{u as SortedRenderGeometryRenderer};
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{glLayout as r}from"../../../support/buffer/glUtil.js";import{Default3D as t}from"../DefaultVertexAttributeLocations.js";import{GLMaterials as e}from"../GLMaterials.js";import{newIntersectorResult as s}from"../Intersector.js";import{IntersectorType as o,StoreResults as i}from"../IntersectorInterfaces.js";import{VertexArrayObject as a}from"../VertexArrayObject.js";import{LodTarget as n}from"./Intersector.js";import{BufferObject as m}from"../../../../webgl/BufferObject.js";import{Usage as l}from"../../../../webgl/enums.js";class u{constructor(s,o){const i=s.renderContext.rctx,n=o.geometry;this._materialRepository=s.materialRepository,n.material.setParameters({instancedDoublePrecision:!0});const u=n.material.createBufferWriter(),f=u.vertexBufferLayout,d=u.elementCount(n),p=f.createBuffer(d);u.write(null,null,n,p,0),this.geometry=n,this.material=n.material,this.glMaterials=new e(n.material,this._materialRepository),this.vertexBufferLayout=f,this.vbo=m.createVertex(i,l.STATIC_DRAW,p.buffer),this.vao=new a(i,t,{geometry:r(f)},{geometry:this.vbo}),this.vertexCount=d}destroy(){this.glMaterials.destroy(),this.vbo.dispose(),this.vao.dispose()}get boundingInfo(){return this.geometry.boundingInfo}get triangleCount(){return this.vertexCount/3}intersect(r,t,e,a,m,l,u,f){const d=this.geometry.id;this.material.intersect(this.geometry,r.transform.transform,r,e,a,((e,a,p,c,y)=>{if(e>=0){if(null!=t&&!t(r.rayBegin,r.rayEnd,e))return;const c=new n(l.layerUid,l.graphicUid(m),d,p,u,f);if((null==r.results.min.drapedLayerOrder||y>=r.results.min.drapedLayerOrder)&&(null==r.results.min.dist||e<r.results.min.dist)&&r.results.min.set(o.LOD,c,e,a,r.transform.transform,y),r.options.store!==i.MIN&&(null==r.results.max.drapedLayerOrder||y>=r.results.max.drapedLayerOrder)&&(null==r.results.max.dist||e>r.results.max.dist)&&r.results.max.set(o.LOD,c,e,a,r.transform.transform,y),r.options.store===i.ALL){const t=s(r.results.min.ray);t.set(o.LOD,c,e,a,r.transform.transform,y),r.results.all.push(t)}}}))}}export{u as LodComponentData};
5
+ import{glLayout as r}from"../../../support/buffer/glUtil.js";import{Default3D as t}from"../DefaultVertexAttributeLocations.js";import{GLMaterials as e}from"../GLMaterials.js";import{newIntersectorResult as s}from"../Intersector.js";import{IntersectorType as o,StoreResults as i}from"../IntersectorInterfaces.js";import{VertexArrayObject as a}from"../VertexArrayObject.js";import{LodTarget as n}from"./Intersector.js";import{BufferObject as m}from"../../../../webgl/BufferObject.js";import{Usage as l}from"../../../../webgl/enums.js";class u{constructor(s,o){const i=s.renderContext.rctx,n=o.geometry;this._materialRepository=s.materialRepository,n.material.setParameters({instancedDoublePrecision:!0});const u=n.material.createBufferWriter(),f=u.vertexBufferLayout,d=u.elementCount(n),p=f.createBuffer(d);u.write(null,null,n,p,0),this.geometry=n,this.material=n.material,this.glMaterials=new e(n.material,this._materialRepository),this.vertexBufferLayout=f,this.vbo=m.createVertex(i,l.STATIC_DRAW,p.buffer),this.vao=new a(i,t,{geometry:r(f)},{geometry:this.vbo}),this.vertexCount=d}destroy(){this.glMaterials.dispose(),this.vbo.dispose(),this.vao.dispose()}get boundingInfo(){return this.geometry.boundingInfo}get triangleCount(){return this.vertexCount/3}intersect(r,t,e,a,m,l,u,f){const d=this.geometry.id;this.material.intersect(this.geometry,r.transform.transform,r,e,a,((e,a,p,c,y)=>{if(e>=0){if(null!=t&&!t(r.rayBegin,r.rayEnd,e))return;const c=new n(l.layerUid,l.graphicUid(m),d,p,u,f);if((null==r.results.min.drapedLayerOrder||y>=r.results.min.drapedLayerOrder)&&(null==r.results.min.dist||e<r.results.min.dist)&&r.results.min.set(o.LOD,c,e,a,r.transform.transform,y),r.options.store!==i.MIN&&(null==r.results.max.drapedLayerOrder||y>=r.results.max.drapedLayerOrder)&&(null==r.results.max.dist||e>r.results.max.dist)&&r.results.max.set(o.LOD,c,e,a,r.transform.transform,y),r.options.store===i.ALL){const t=s(r.results.min.ray);t.set(o.LOD,c,e,a,r.transform.transform,y),r.results.all.push(t)}}}))}}export{u as LodComponentData};
@@ -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{isSome as r}from"../../../../../core/arrayUtils.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{isAborted as n,throwIfAborted as s}from"../../../../../core/promiseUtils.js";import{property as i}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/has.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{c as l}from"../../../../../chunks/mat4f64.js";import{b as c,e as h,m as d}from"../../../../../chunks/vec3.js";import{c as u}from"../../../../../chunks/vec3f64.js";import{c as m,f as p}from"../../../../../chunks/vec4f64.js";import f from"../../../support/debugFlags.js";import{glLayout as _}from"../../../support/buffer/glUtil.js";import{newLayout as I}from"../../../support/buffer/InterleavedLayout.js";import{ShaderOutput as g}from"../../core/shaderLibrary/ShaderOutput.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 t{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=_(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,t){this._context=e;const a=e.renderContext.rctx,i=await Promise.allSettled(this.symbol.levels.map((r=>(this._defaultRenderInstanceData[0].push(new N(a,this._instanceBufferLayout)),this._highlightRenderInstanceData[0].push(new N(a,this._instanceBufferLayout)),O.create(e,r,t))))),o=i.map((e=>"fulfilled"===e.status?e.value:null)).filter(r);if(n(t)||o.length!==i.length){o.forEach((e=>e.destroy())),s(t);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&&this._highlightRenderInstanceData[0].some((e=>e.size>0))}prepareRender(e){if(!f.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)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=u();c(n,a,r);const s=n=>{this._instanceData.getCombinedModelTransform(n,W),e.transform.set(W),d(K,r,e.transform.inverse),d(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=a(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),c(k,k,n);const i=h(k,t)-k[3];s.boundingSphere.getVec(a,k),c(k,k,n);const o=h(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?(q(this._highlightRenderInstanceData[0][e],s,l),d|=b.HIGHLIGHT_ACTIVE):(q(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),f.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 q(e,t,r){const a=e.allocateHead();P(t,r,e.view,a)}function P(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=I().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([i({constructOnly:!0})],B.prototype,"symbol",void 0),e([i({constructOnly:!0})],B.prototype,"optionalFields",void 0),e([i({constructOnly:!0})],B.prototype,"metadata",void 0),e([i({constructOnly:!0})],B.prototype,"shaderTransformation",void 0),e([i()],B.prototype,"_instanceData",void 0),e([i()],B.prototype,"_cycleStartIndex",void 0),e([i({readOnly:!0})],B.prototype,"_enableLevelSelection",null),e([i()],B.prototype,"_updateCyclesWithStaticCamera",void 0),e([i({readOnly:!0})],B.prototype,"running",null),B=e([o("esri.views.3d.webgl-engine.lib.lodRendering.LodRenderer")],B);const z=u(),k=m(),W=l(),K=u(),Y=u(),J=[p(1,0,1,1),p(0,0,1,1),p(0,1,0,1),p(1,1,0,1),p(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{removeUnordered as e,filterInPlace as t}from"../../../../../core/arrayUtils.js";import{someMap as r}from"../../../../../core/MapUtils.js";import{NestedMap as s}from"../../../../../core/NestedMap.js";import i from"../../../../../core/PooledArray.js";import{m as a,a as n,t as o}from"../../../../../chunks/mat4.js";import{c as l}from"../../../../../chunks/mat4f64.js";import{glLayout as h}from"../../../support/buffer/glUtil.js";import{ShaderOutput as u}from"../../core/shaderLibrary/ShaderOutput.js";import{GLMaterials as c}from"../../lib/GLMaterials.js";import{RenderOccludedFlag as f}from"../../lib/Material.js";import{DirtyState as d}from"../../lib/ModelDirtyTypes.js";import{assert as m,setMatrixTranslation3 as g}from"../../lib/Util.js";import{DrawParameters as p}from"../DrawParameters.js";import{WaterMaterial as y}from"../WaterMaterial.js";import{BufferRange as _,mergeAdjacentRanges as w}from"./BufferRange.js";import{Instance as b}from"./Instance.js";import{PerBufferData as v,hasVao as O}from"./PerBufferData.js";import{PerOriginData as B}from"./PerOriginData.js";import{VaoCache as C}from"./VaoCache.js";class E{constructor(e,t,r){this._rctx=e,this.material=r,this._dataByOrigin=new Map,this._hasHighlights=!1,this._hasOccludees=!1,this._glMaterials=new c(this.material,t),this._bufferWriter=r.createBufferWriter(),this._vaoCache=new C(e,r.vertexAttributeLocations,h(this._bufferWriter.vertexBufferLayout))}dispose(){this._glMaterials.destroy(),this._dataByOrigin.forEach((e=>e.dispose())),this._dataByOrigin.clear(),this._vaoCache.dispose()}get isEmpty(){return 0===this._dataByOrigin.size}get hasHighlights(){return this._hasHighlights}get hasOccludees(){return this._hasOccludees}get hasWater(){return!this.isEmpty&&this.material instanceof y}get isDecoration(){return this.material.isDecoration}get rendersOccluded(){return!this.isEmpty&&this.material.renderOccluded!==f.Occlude}get numGeometries(){let e=0;return this._dataByOrigin.forEach((t=>e+=t.buffers.reduce(((e,t)=>e+t.instances.size),0))),e}get usedMemory(){let e=0;return this._dataByOrigin.forEach((t=>e+=t.buffers.reduce(((e,t)=>e+t.vao.memoryUsage),0))),e}forEachGeometry(e){this._dataByOrigin.forEach((t=>t.buffers.forEach((t=>t.instances.forEach((t=>e(t.geometry)))))))}modify(e){this._updateGeometries(e.updates),this._addAndRemoveGeometries(e.adds,e.removes),this._updateDrawCommands()}_updateGeometries(e){const t=this._bufferWriter,r=t.vertexBufferLayout.stride/4;for(const s of e){const e=s.renderGeometry,i=this._dataByOrigin.get(e.localOrigin.id),a=i?.findBuffer(e.id);if(null==a)return;const n=a.instances.get(e.id);if(s.updateType&(d.GEOMETRY|d.TRANSFORMATION)){const s=W(t.elementCount(n.geometry.geometry)*r),i=t.vertexBufferLayout.createView(s.buffer);this._writeGeometry(e,i,0),a.vao.vertexBuffers.geometry.setSubData(s,n.from*r,0,n.numElements*r),P()}s.updateType&(d.HIGHLIGHT|d.OCCLUDEE|d.VISIBILITY)&&(a.drawCommandsDirty=!0)}}_computeDeltas(e,t){const r=new s;for(const s of e){const e=s.localOrigin;if(null==e)continue;let t=r.get(e.id,null);null==t&&(t=new A(e.vec3),r.set(e.id,null,t)),t.changes.push(s)}for(const s of t){const e=s.localOrigin;if(null==e)continue;const t=this._dataByOrigin.get(e.id),i=t?.findBuffer(s.id);if(null==i)continue;let a=r.get(e.id,i);null==a&&(a=new A(e.vec3),r.set(e.id,i,a)),a.changes.push(s)}return r}_addAndRemoveGeometries(t,r){const{_bufferWriter:s,_dataByOrigin:i}=this,a=s.vertexBufferLayout.stride/4,n=this._computeDeltas(t,r);n.forEach(((t,r)=>{const o=t.get(null),l=null!=o?o.changes:[];n.delete(r,null);let h=i.get(r);if(t.forEach(((t,o)=>{if(n.delete(r,o),null==o)return void m(!1,"No VAO for removed geometries");if(o.instances.size===t.changes.length)return this._vaoCache.deleteVao(o.vao),e(h.buffers,o),void(0===h.buffers.length&&0===l.length&&i.delete(r));const u=o.numElements,c=o.vao.byteSize/4,f=l.reduce(((e,t)=>e+s.elementCount(t.geometry)),0),d=t.changes.reduce(((e,t)=>e+s.elementCount(t.geometry)),0),g=Math.min((u+f-d)*a,G),p=g>c;g>j&&g<c/2?(t.changes.forEach((({id:e})=>o.deleteInstance(e))),o.instances.forEach((({geometry:e})=>l.push(e))),this._vaoCache.deleteVao(o.vao),e(h.buffers,o)):p?this._applyAndRebuild(o,l,t):this._applyRemoves(o,t)})),l.length>0)for(null==h&&(h=new B(o.origin),i.set(r,h)),h.buffers.forEach((e=>this._applyAdds(e,l)));l.length>0;)h.buffers.push(this._applyAndRebuild(new v,l,null))}))}_updateDrawCommands(){this._hasHighlights=!1,this._hasOccludees=!1,this._dataByOrigin.forEach((e=>{e.buffers.forEach((e=>{e.drawCommandsDirty&&(e.hasHiddenInstances=!1,e.hasHighlights=!1,e.hasOccludees=!1,r(e.instances,(t=>(e.updateDrawState(t),e.hasHiddenInstances&&e.hasHighlights&&e.hasOccludees))),e.updateDrawCommands(this._bufferWriter.vertexBufferLayout.stride)),this._hasHighlights=this._hasHighlights||e.hasHighlights,this._hasOccludees=this._hasOccludees||e.hasOccludees}))}))}_applyAndRebuild(e,t,r){if(null!=r)for(const d of r.changes)e.deleteInstance(d.id);const s=this._bufferWriter,i=s.vertexBufferLayout.stride,a=i/4,n=Math.floor(G/a);let o=e.numElements;for(;t.length>0;){const r=t.pop(),i=s.elementCount(r.geometry);if(o+i>n&&o>0){t.push(r);break}o+=i;const a=new b(r,0,0);m(null==e.instances.get(r.id)),e.addInstance(r.id,a)}const l=o*a,h=W(l),u=s.vertexBufferLayout.createView(h.buffer);let c=0;e.hasHiddenInstances=!1,e.hasHighlights=!1,e.hasOccludees=!1,e.instances.forEach(((t,r)=>{this._writeGeometry(t.geometry,u,c);const i=c;c+=s.elementCount(t.geometry.geometry),e.updateInstance(r,i,c),e.updateDrawState(t)})),this._vaoCache.deleteVao(e.vao),e.vao=this._vaoCache.newVao(V(l)),e.vao.vertexBuffers.geometry.setSubData(h,0,0,c*a),P(),e.holes.clear();const f=e.holes.pushNew();return f.from=c,f.to=Math.floor(e.vao.byteSize/i),e.updateDrawCommands(i),e}_applyRemoves(e,t){if(0===t.changes.length)return;for(const n of t.changes){const t=n.id,r=e.instances.get(t);if(!r)continue;e.deleteInstance(t);const s=S.back();if(s){if(s.to===r.from){s.to=r.to;continue}if(s.from===r.to){s.from=r.from;continue}}const i=S.pushNew();i.from=r.from,i.to=r.to}w(S);const r=this._bufferWriter.vertexBufferLayout.stride/4,s=S.reduce(((e,t)=>Math.max(e,t.numElements)),0)*r,i=W(s);i.fill(0,0,s);const a=e.vao.vertexBuffers.geometry;S.forAll((e=>a.setSubData(i,e.from*r,0,e.numElements*r))),P(),e.holes.pushArray(S.data,S.length),S.forAll(((e,t)=>S.data[t]=null)),S.clear(),e.drawCommandsDirty=!0}_applyAdds(e,r){if(0===r.length)return;if(!O(e))return void this._applyAndRebuild(e,r,null);const s=this._bufferWriter,i=s.vertexBufferLayout.stride/4,a=e.numElements,n=r.reduce(((e,t)=>e+s.elementCount(t.geometry)),0),o=Math.min((a+n)*i,G),l=4*o;if(e.vao.byteSize<V(G-j)&&l>e.vao.byteSize)return void this._applyAndRebuild(e,r,null);w(e.holes);const h=new Array;for(const t of r){const r=s.elementCount(t.geometry),i=H(e.holes,r);h.push(i)}const u=e.vao.vertexBuffers.geometry;let c=0,f=0,d=0;const g=W(o),p=s.vertexBufferLayout.createView(g.buffer);r.forEach(((t,r)=>{const a=h[r];if(null==a)return;if(!(d===a)){const e=d-f;e>0&&u.setSubData(g,f*i,0,e*i),f=a,c=0}const n=s.elementCount(t.geometry);this._writeGeometry(t,p,c),c+=n,d=a+n;const o=new b(t,a,a+n);m(null==e.instances.get(t.id)),e.addInstance(t.id,o),e.drawCommandsDirty=!0}));const y=d-f;y>0&&u.setSubData(g,f*i,0,y*i),t(r,((e,t)=>null==h[t])),P()}_writeGeometry(e,t,r){const s=e.localOrigin.vec3;g(D,-s[0],-s[1],-s[2]);const i=a(M,D,e.transformation);n(x,i),o(x,x),this._bufferWriter.write(i,x,e.geometry,t,r)}updateAnimation(e){return this.material.update(e)}canRender(e,t){return this.material.canRender(e,t)}prepareTechnique(e){const{output:t,bindParameters:r}=e;if(!this.canRender(r.slot,t))return null;const s=t===u.Highlight||t===u.ShadowHighlight;if(s&&!this._hasHighlights)return null;const i=t===u.ShadowExcludeHighlight,a=!(s||i);for(const n of this._dataByOrigin.values())for(const o of n.buffers){if(s&&!o.hasHighlights)continue;const n=(s?o.drawCommandsHighlight:i&&o.needsMultipleCommands()?o.drawCommandsShadowHighlightRest:o.drawCommandsDefault)||null,l=a&&o.drawCommandsOccludees||null;if(n?.length||l?.length){const s=this._glMaterials.load(e.rctx,r.slot,t),i=null!=s?s.beginSlot(r):null;if(null!=i)return i}}return null}render(e,t){const{output:r,bindParameters:s}=e,i=r===u.Highlight||r===u.ShadowHighlight,a=r===u.ShadowExcludeHighlight,n=!(i||a),o=this._rctx;o.appleAmdDriverHelper?.resetIndicesType(),o.bindTechnique(t,this.material.parameters,s);for(const l of this._dataByOrigin.values())for(const e of l.buffers){if(i&&!e.hasHighlights)continue;const r=(i?e.drawCommandsHighlight:a&&e.needsMultipleCommands()?e.drawCommandsShadowHighlightRest:e.drawCommandsDefault)||null,h=n&&e.drawCommandsOccludees||null;if(r?.length||h?.length){t.program.bindDraw(new p(l.origin),s,this.material.parameters),t.ensureAttributeLocations(e.vao),o.bindVAO(e.vao),r?.length&&(t.bindPipelineState(o,s.slot,!1),r.forAll((e=>o.drawArrays(t.primitiveType,e.first,e.count)))),h?.length&&(t.bindPipelineState(o,s.slot,!0),h.forAll((e=>o.drawArrays(t.primitiveType,e.first,e.count))))}}}get test(){return{material:this.material,glMaterials:this._glMaterials,dataByOrigin:this._dataByOrigin}}}class A{constructor(e){this.origin=e,this.changes=new Array}}function H(e,t){let r;if(!e.some((e=>!(e.numElements<t)&&(r=e,!0))))return null;const s=r.from;return r.from+=t,r.from>=r.to&&e.removeUnordered(r),s}const D=l(),M=l(),x=l(),S=new i({allocator:e=>e||new _,deallocator:null}),j=65536,I=4*j,R=1024,L=16777216,G=L/4;let T=new Float32Array(j);function W(e){return T.length<e&&(T=new Float32Array(e)),T}function V(e){const t=4*e;return t<=R?R:t<I?I:Math.max(Math.min(Math.ceil(1.5*t/I)*I,L),t)}function P(){T=new Float32Array(2)}export{E as MergedRenderer};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{removeUnordered as t,filterInPlace as r}from"../../../../../core/arrayUtils.js";import{someMap as s}from"../../../../../core/MapUtils.js";import{disposeMaybe as i}from"../../../../../core/maybe.js";import{NestedMap as a}from"../../../../../core/NestedMap.js";import n from"../../../../../core/PooledArray.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{m as u,a as h,t as c}from"../../../../../chunks/mat4.js";import{c as f}from"../../../../../chunks/mat4f64.js";import{glLayout as d}from"../../../support/buffer/glUtil.js";import{ShaderOutput as m}from"../../core/shaderLibrary/ShaderOutput.js";import{SyncPrepareRenderPlugin as g}from"../../effects/RenderPlugin.js";import{GLMaterials as p}from"../../lib/GLMaterials.js";import{RenderOccludedFlag as y}from"../../lib/Material.js";import{DirtyState as _}from"../../lib/ModelDirtyTypes.js";import{assert as b,setMatrixTranslation3 as v}from"../../lib/Util.js";import{DrawParameters as w}from"../DrawParameters.js";import{WaterMaterial as O}from"../WaterMaterial.js";import{BufferRange as C,mergeAdjacentRanges as B}from"./BufferRange.js";import{Instance as E}from"./Instance.js";import{PerBufferData as A,hasVao as H}from"./PerBufferData.js";import{PerOriginData as D}from"./PerOriginData.js";import{VaoCache as M}from"./VaoCache.js";let x=class extends g{constructor(e){super(e),this._vaoCache=null,this._glMaterials=null,this._bufferWriter=null,this._dataByOrigin=new Map,this._hasHighlights=!1,this._hasOccludees=!1,this.renderSlots=[]}dispose(){this._glMaterials=i(this._glMaterials),this._dataByOrigin.forEach((e=>e.dispose())),this._dataByOrigin.clear(),this._vaoCache=i(this._vaoCache)}initializeRenderContext(e,t){this._glMaterials=new p(this.material,t??e.materialRepository),this._bufferWriter=this.material.createBufferWriter(),this._vaoCache=new M(e.renderContext.rctx,this.material.vertexAttributeLocations,d(this._bufferWriter.vertexBufferLayout))}uninitializeRenderContext(){}get isEmpty(){return 0===this._dataByOrigin.size}get hasHighlights(){return this._hasHighlights}get hasOccludees(){return this._hasOccludees}get hasWater(){return!this.isEmpty&&this.material instanceof O}get isDecoration(){return this.material.isDecoration}get rendersOccluded(){return!this.isEmpty&&this.material.renderOccluded!==y.Occlude}get numGeometries(){let e=0;return this._dataByOrigin.forEach((t=>e+=t.buffers.reduce(((e,t)=>e+t.instances.size),0))),e}get usedMemory(){let e=0;return this._dataByOrigin.forEach((t=>e+=t.buffers.reduce(((e,t)=>e+t.vao.memoryUsage),0))),e}forEachGeometry(e){this._dataByOrigin.forEach((t=>t.buffers.forEach((t=>t.instances.forEach((t=>e(t.geometry)))))))}modify(e){this._updateGeometries(e.updates),this._addAndRemoveGeometries(e.adds,e.removes),this._updateDrawCommands()}_updateGeometries(e){if(null===this._bufferWriter)return;const t=this._bufferWriter,r=t.vertexBufferLayout.stride/4;for(const s of e){const e=s.renderGeometry,i=this._dataByOrigin.get(e.localOrigin.id),a=i?.findBuffer(e.id);if(null==a)return;const n=a.instances.get(e.id);if(s.updateType&(_.GEOMETRY|_.TRANSFORMATION)){const s=N(t.elementCount(n.geometry.geometry)*r),i=t.vertexBufferLayout.createView(s.buffer);this._writeGeometry(e,i,0),a.vao.vertexBuffers.geometry.setSubData(s,n.from*r,0,n.numElements*r),F()}s.updateType&(_.HIGHLIGHT|_.OCCLUDEE|_.VISIBILITY)&&(a.drawCommandsDirty=!0)}}_computeDeltas(e,t){const r=new a;for(const s of e){const e=s.localOrigin;if(null==e)continue;let t=r.get(e.id,null);null==t&&(t=new S(e.vec3),r.set(e.id,null,t)),t.changes.push(s)}for(const s of t){const e=s.localOrigin;if(null==e)continue;const t=this._dataByOrigin.get(e.id),i=t?.findBuffer(s.id);if(null==i)continue;let a=r.get(e.id,i);null==a&&(a=new S(e.vec3),r.set(e.id,i,a)),a.changes.push(s)}return r}_addAndRemoveGeometries(e,r){if(null===this._bufferWriter||null===this._vaoCache)return;const{_bufferWriter:s,_dataByOrigin:i}=this,a=s.vertexBufferLayout.stride/4,n=this._computeDeltas(e,r);n.forEach(((e,r)=>{const o=e.get(null),l=null!=o?o.changes:[];n.delete(r,null);let u=i.get(r);if(e.forEach(((e,o)=>{if(n.delete(r,o),null==o)return void b(!1,"No VAO for removed geometries");if(o.instances.size===e.changes.length)return this._vaoCache.deleteVao(o.vao),t(u.buffers,o),void(0===u.buffers.length&&0===l.length&&i.delete(r));const h=o.numElements,c=o.vao.byteSize/4,f=l.reduce(((e,t)=>e+s.elementCount(t.geometry)),0),d=e.changes.reduce(((e,t)=>e+s.elementCount(t.geometry)),0),m=Math.min((h+f-d)*a,P),g=m>c;m>G&&m<c/2?(e.changes.forEach((({id:e})=>o.deleteInstance(e))),o.instances.forEach((({geometry:e})=>l.push(e))),this._vaoCache.deleteVao(o.vao),t(u.buffers,o)):g?this._applyAndRebuild(o,l,e):this._applyRemoves(o,e)})),l.length>0)for(null==u&&(u=new D(o.origin),i.set(r,u)),u.buffers.forEach((e=>this._applyAdds(e,l)));l.length>0;)u.buffers.push(this._applyAndRebuild(new A,l,null))}))}_updateDrawCommands(){this._hasHighlights=!1,this._hasOccludees=!1,this._dataByOrigin.forEach((e=>{e.buffers.forEach((e=>{e.drawCommandsDirty&&(e.hasHiddenInstances=!1,e.hasHighlights=!1,e.hasOccludees=!1,s(e.instances,(t=>(e.updateDrawState(t),e.hasHiddenInstances&&e.hasHighlights&&e.hasOccludees))),e.updateDrawCommands(this._bufferWriter.vertexBufferLayout.stride)),this._hasHighlights=this._hasHighlights||e.hasHighlights,this._hasOccludees=this._hasOccludees||e.hasOccludees}))}))}_applyAndRebuild(e,t,r){if(null!=r)for(const d of r.changes)e.deleteInstance(d.id);const s=this._bufferWriter,i=s.vertexBufferLayout.stride,a=i/4,n=Math.floor(P/a);let o=e.numElements;for(;t.length>0;){const r=t.pop(),i=s.elementCount(r.geometry);if(o+i>n&&o>0){t.push(r);break}o+=i;const a=new E(r,0,0);b(null==e.instances.get(r.id)),e.addInstance(r.id,a)}const l=o*a,u=N(l),h=s.vertexBufferLayout.createView(u.buffer);let c=0;e.hasHiddenInstances=!1,e.hasHighlights=!1,e.hasOccludees=!1,e.instances.forEach(((t,r)=>{this._writeGeometry(t.geometry,h,c);const i=c;c+=s.elementCount(t.geometry.geometry),e.updateInstance(r,i,c),e.updateDrawState(t)})),this._vaoCache.deleteVao(e.vao),e.vao=this._vaoCache.newVao(k(l)),e.vao.vertexBuffers.geometry.setSubData(u,0,0,c*a),F(),e.holes.clear();const f=e.holes.pushNew();return f.from=c,f.to=Math.floor(e.vao.byteSize/i),e.updateDrawCommands(i),e}_applyRemoves(e,t){if(0===t.changes.length||null===this._bufferWriter)return;for(const n of t.changes){const t=n.id,r=e.instances.get(t);if(!r)continue;e.deleteInstance(t);const s=L.back();if(s){if(s.to===r.from){s.to=r.to;continue}if(s.from===r.to){s.from=r.from;continue}}const i=L.pushNew();i.from=r.from,i.to=r.to}B(L);const r=this._bufferWriter.vertexBufferLayout.stride/4,s=L.reduce(((e,t)=>Math.max(e,t.numElements)),0)*r,i=N(s);i.fill(0,0,s);const a=e.vao.vertexBuffers.geometry;L.forAll((e=>a.setSubData(i,e.from*r,0,e.numElements*r))),F(),e.holes.pushArray(L.data,L.length),L.forAll(((e,t)=>L.data[t]=null)),L.clear(),e.drawCommandsDirty=!0}_applyAdds(e,t){if(0===t.length||null===this._bufferWriter)return;if(!H(e))return void this._applyAndRebuild(e,t,null);const s=this._bufferWriter,i=s.vertexBufferLayout.stride/4,a=e.numElements,n=t.reduce(((e,t)=>e+s.elementCount(t.geometry)),0),o=Math.min((a+n)*i,P),l=4*o;if(e.vao.byteSize<k(P-G)&&l>e.vao.byteSize)return void this._applyAndRebuild(e,t,null);B(e.holes);const u=new Array;for(const r of t){const t=s.elementCount(r.geometry),i=j(e.holes,t);u.push(i)}const h=e.vao.vertexBuffers.geometry;let c=0,f=0,d=0;const m=N(o),g=s.vertexBufferLayout.createView(m.buffer);t.forEach(((t,r)=>{const a=u[r];if(null==a)return;if(!(d===a)){const e=d-f;e>0&&h.setSubData(m,f*i,0,e*i),f=a,c=0}const n=s.elementCount(t.geometry);this._writeGeometry(t,g,c),c+=n,d=a+n;const o=new E(t,a,a+n);b(null==e.instances.get(t.id)),e.addInstance(t.id,o),e.drawCommandsDirty=!0}));const p=d-f;p>0&&h.setSubData(m,f*i,0,p*i),r(t,((e,t)=>null==u[t])),F()}_writeGeometry(e,t,r){if(null===this._bufferWriter)return;const s=e.localOrigin.vec3;v(R,-s[0],-s[1],-s[2]);const i=u(I,R,e.transformation);h(W,i),c(W,W),this._bufferWriter.write(i,W,e.geometry,t,r)}updateAnimation(e){return this.material.update(e)}canRender(e,t){return this.material.canRender(e,t)}prepareTechnique(e){const{output:t,bindParameters:r}=e;if(!this.canRender(r.slot,t))return null;const s=t===m.Highlight||t===m.ShadowHighlight;if(s&&!this._hasHighlights)return null;const i=t===m.ShadowExcludeHighlight,a=!(s||i);for(const n of this._dataByOrigin.values())for(const o of n.buffers){if(s&&!o.hasHighlights)continue;const n=(s?o.drawCommandsHighlight:i&&o.needsMultipleCommands()?o.drawCommandsShadowHighlightRest:o.drawCommandsDefault)||null,l=a&&o.drawCommandsOccludees||null;if(n?.length||l?.length){const s=this._glMaterials.load(e.rctx,r.slot,t),i=null!=s?s.beginSlot(r):null;if(null!=i)return i}}return null}render(e,t){const{output:r,bindParameters:s}=e,i=r===m.Highlight||r===m.ShadowHighlight,a=r===m.ShadowExcludeHighlight,n=!(i||a),o=e.rctx;o.appleAmdDriverHelper?.resetIndicesType(),o.bindTechnique(t,this.material.parameters,s);for(const l of this._dataByOrigin.values())for(const e of l.buffers){if(i&&!e.hasHighlights)continue;const r=(i?e.drawCommandsHighlight:a&&e.needsMultipleCommands()?e.drawCommandsShadowHighlightRest:e.drawCommandsDefault)||null,u=n&&e.drawCommandsOccludees||null;if(r?.length||u?.length){t.program.bindDraw(new w(l.origin),s,this.material.parameters),t.ensureAttributeLocations(e.vao),o.bindVAO(e.vao),r?.length&&(t.bindPipelineState(o,s.slot,!1),r.forAll((e=>o.drawArrays(t.primitiveType,e.first,e.count)))),u?.length&&(t.bindPipelineState(o,s.slot,!0),u.forAll((e=>o.drawArrays(t.primitiveType,e.first,e.count))))}}}get test(){return{material:this.material,glMaterials:this._glMaterials,dataByOrigin:this._dataByOrigin}}};e([o({constructOnly:!0})],x.prototype,"material",void 0),x=e([l("esri.views.3d.webgl-engine.materials.renderers.MergedRenderer")],x);class S{constructor(e){this.origin=e,this.changes=new Array}}function j(e,t){let r;if(!e.some((e=>!(e.numElements<t)&&(r=e,!0))))return null;const s=r.from;return r.from+=t,r.from>=r.to&&e.removeUnordered(r),s}const R=f(),I=f(),W=f(),L=new n({allocator:e=>e||new C,deallocator:null}),G=65536,T=4*G,V=1024,z=16777216,P=z/4;let U=new Float32Array(G);function N(e){return U.length<e&&(U=new Float32Array(e)),U}function k(e){const t=4*e;return t<=V?V:t<T?T:Math.max(Math.min(Math.ceil(1.5*t/T)*T,z),t)}function F(){U=new Float32Array(2)}export{x as MergedRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import 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 v}from"../lib/ObjectAndLayerIdRenderHelper.js";import{Renderer as j}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 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=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 j(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})],W.prototype,"_compositingHelper",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};
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};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{disposeMaybe as e}from"../../../../core/maybe.js";import t from"../../../../core/PerformanceSampler.js";import{Milliseconds as r}from"../../../../core/time.js";import{createElapsedTimerPool as i}from"../../../webgl/TimerPool.js";var a;!function(e){e.OVERLAY="overlay",e.PREPARE="prepare",e.SHADOW_MAP="shadow map",e.LINEAR_DEPTH="linear depth",e.ACCUMULATED_SHADOWS="accumulated shadows",e.OBJECT_AND_LAYER_ID_COLOR="object/layer id color",e.SSAO="SSAO",e.OPAQUE="opaque",e.OPAQUE_EDGES="opaque edges",e.VOXEL="voxel",e.TRANSPARENT="transparent",e.TRANSPARENT_EDGES="transparent edges",e.HUD_VISIBILITY="HUD visibility",e.TRANSPARENT_TERRAIN="transparent terrain",e.ENVIRONMENT="environment",e.LASER_LINE="laser line",e.OCCLUDED="occluded",e.ANTIALIASING="antialiasing",e.HIGHLIGHTS="highlights",e.HUD="HUD",e.HUD_OCCLUDED="HUD occluded",e.FINISH="finish"}(a||(a={}));const s="Total";class o{constructor(e){this._rctx=e,this._startTimeStampCPU=r(0),this._lastTimeStampCPU=r(0),this._totalCPUTime=new t(s),this._cpuTimeSamplers=new Map(Object.values(a).map((e=>[e,new t(e)]))),this._enableGPUTimer=0,this._totalGPUTime=new t("GPU"),this._gpuTimeSamplers=new Map(Object.values(a).map((e=>[e,new t(e)]))),this._totalTime=r(0),this._totalFrameCount=0}get totalCPUTimeSampler(){return this._totalCPUTime}get cpuTimeSamplers(){return Array.from(this._cpuTimeSamplers.values())}get totalGPUTimeSampler(){return this._totalGPUTime}get gpuTimeSamplers(){return Array.from(this._gpuTimeSamplers.values())}get gpuSamplingEnabled(){return null!=this._gpuTimerPool}get totalTime(){return this._totalTime}get totalFrameCount(){return this._totalFrameCount}get elapsedTime(){return r(performance.now()-this._startTimeStampCPU)}enableGPUPerformanceInfo(){if(null==this._gpuTimerPool){const e=[...Object.values(a),s];this._gpuTimerPool=i(this._rctx,e)}if(null==this._gpuTimerPool)return{hasGPUTimerSupport:!1,remove:()=>{}};++this._enableGPUTimer;let t=!1;return{hasGPUTimerSupport:!0,remove:()=>{t||(t=!0,--this._enableGPUTimer,0===this._enableGPUTimer&&(this._gpuTimerPool=e(this._gpuTimerPool)))}}}startFrame(){this._startTimeStampCPU=this._lastTimeStampCPU=r(performance.now()),this._gpuTimerPool&&this._gpuTimerPool.start()}advance(e){const t=r(performance.now());if(this._cpuTimeSamplers.get(e).record(t-this._lastTimeStampCPU),this._lastTimeStampCPU=t,this._gpuTimerPool){const t=this._gpuTimerPool.stop(e);this._gpuTimeSamplers.get(e).record(t),this._gpuTimerPool.start()}}finishFrame(){if(this._gpuTimerPool){const e=this._gpuTimerPool.stop(a.FINISH);this._gpuTimeSamplers.get(a.FINISH).record(e),this._rctx.gl.flush()}const e=r(performance.now()-this._startTimeStampCPU);this._totalTime=r(this._totalTime+e),this._totalCPUTime.record(e),this._gpuTimerPool&&this._totalGPUTime.record(this.gpuTimeSamplers.reduce(((e,t)=>e+(t.last||0)),0)),++this._totalFrameCount}}export{a as PerformanceCategory,o as RendererPerformanceInfo};
5
+ import{disposeMaybe as e}from"../../../../core/maybe.js";import t from"../../../../core/PerformanceSampler.js";import{Milliseconds as r}from"../../../../core/time.js";import{createElapsedTimerPool as i}from"../../../webgl/TimerPool.js";var a;!function(e){e.OVERLAY="overlay",e.PREPARE="prepare",e.SHADOW_MAP="shadow map",e.LINEAR_DEPTH="linear depth",e.ACCUMULATED_SHADOWS="accumulated shadows",e.OBJECT_AND_LAYER_ID_COLOR="object/layer id color",e.SSAO="SSAO",e.OPAQUE="opaque",e.OPAQUE_EDGES="opaque edges",e.VOXEL="voxel",e.TRANSPARENT="transparent",e.TRANSPARENT_EDGES="transparent edges",e.HUD_VISIBILITY="HUD visibility",e.TRANSPARENT_TERRAIN="transparent terrain",e.ENVIRONMENT="environment",e.LASER_LINES="laser lines",e.OCCLUDED="occluded",e.ANTIALIASING="antialiasing",e.HIGHLIGHTS="highlights",e.HUD="HUD",e.HUD_OCCLUDED="HUD occluded",e.FINISH="finish"}(a||(a={}));const s="Total";class o{constructor(e){this._rctx=e,this._startTimeStampCPU=r(0),this._lastTimeStampCPU=r(0),this._totalCPUTime=new t(s),this._cpuTimeSamplers=new Map(Object.values(a).map((e=>[e,new t(e)]))),this._enableGPUTimer=0,this._totalGPUTime=new t("GPU"),this._gpuTimeSamplers=new Map(Object.values(a).map((e=>[e,new t(e)]))),this._totalTime=r(0),this._totalFrameCount=0}get totalCPUTimeSampler(){return this._totalCPUTime}get cpuTimeSamplers(){return Array.from(this._cpuTimeSamplers.values())}get totalGPUTimeSampler(){return this._totalGPUTime}get gpuTimeSamplers(){return Array.from(this._gpuTimeSamplers.values())}get gpuSamplingEnabled(){return null!=this._gpuTimerPool}get totalTime(){return this._totalTime}get totalFrameCount(){return this._totalFrameCount}get elapsedTime(){return r(performance.now()-this._startTimeStampCPU)}enableGPUPerformanceInfo(){if(null==this._gpuTimerPool){const e=[...Object.values(a),s];this._gpuTimerPool=i(this._rctx,e)}if(null==this._gpuTimerPool)return{hasGPUTimerSupport:!1,remove:()=>{}};++this._enableGPUTimer;let t=!1;return{hasGPUTimerSupport:!0,remove:()=>{t||(t=!0,--this._enableGPUTimer,0===this._enableGPUTimer&&(this._gpuTimerPool=e(this._gpuTimerPool)))}}}startFrame(){this._startTimeStampCPU=this._lastTimeStampCPU=r(performance.now()),this._gpuTimerPool&&this._gpuTimerPool.start()}advance(e){const t=r(performance.now());if(this._cpuTimeSamplers.get(e).record(t-this._lastTimeStampCPU),this._lastTimeStampCPU=t,this._gpuTimerPool){const t=this._gpuTimerPool.stop(e);this._gpuTimeSamplers.get(e).record(t),this._gpuTimerPool.start()}}finishFrame(){if(this._gpuTimerPool){const e=this._gpuTimerPool.stop(a.FINISH);this._gpuTimeSamplers.get(a.FINISH).record(e),this._rctx.gl.flush()}const e=r(performance.now()-this._startTimeStampCPU);this._totalTime=r(this._totalTime+e),this._totalCPUTime.record(e),this._gpuTimerPool&&this._totalGPUTime.record(this.gpuTimeSamplers.reduce(((e,t)=>e+(t.last||0)),0)),++this._totalFrameCount}}export{a as PerformanceCategory,o as RendererPerformanceInfo};