@arcgis/core 4.33.0-next.20250423 → 4.33.0-next.20250425

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 (294) hide show
  1. package/Graphic.js +1 -1
  2. package/WebScene.js +1 -1
  3. package/analysis/Analysis.d.ts +4 -0
  4. package/analysis/Analysis.js +1 -1
  5. package/analysis/SliceAnalysis.js +1 -1
  6. package/analysis/SlicePlane.js +1 -1
  7. package/analysis/support/AnalysisOriginWebScene.d.ts +4 -0
  8. package/analysis/support/AnalysisOriginWebScene.js +5 -0
  9. package/analysis/support/SliceAnalysisExcludedLayer.js +5 -0
  10. package/assets/esri/core/workers/RemoteClient.js +1 -1
  11. package/assets/esri/core/workers/chunks/{d4d011eea16a89a5aad9.js → 0219c3f9408d3fa3c9a0.js} +1 -1
  12. package/assets/esri/core/workers/chunks/070839cb71c8e764b8d7.js +1 -0
  13. package/assets/esri/core/workers/chunks/19084a293694c5a00cae.js +1 -0
  14. package/assets/esri/core/workers/chunks/{8ba7d44eff348004f084.js → 1a6d2d090b643a87408a.js} +1 -1
  15. package/assets/esri/core/workers/chunks/1b8cc83aa1179245b2dc.js +1 -0
  16. package/assets/esri/core/workers/chunks/{5e5225623977e61fd0ef.js → 213adc87c843d627c5d6.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{fa8a3c75f9b41d31559b.js → 265f69d153b7b6f07e42.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{769b66cca8347f0f84db.js → 279bbd61b32577693a4a.js} +1 -1
  19. package/assets/esri/core/workers/chunks/290b065b377f9d2ee058.js +1 -0
  20. package/assets/esri/core/workers/chunks/29d3245261a7223124ed.js +1 -0
  21. package/assets/esri/core/workers/chunks/2bed8a5ed9ae3760fa2f.js +1 -0
  22. package/assets/esri/core/workers/chunks/2e3019ce49e972a815ca.js +1 -0
  23. package/assets/esri/core/workers/chunks/335b539893569e3d7b82.js +1 -0
  24. package/assets/esri/core/workers/chunks/38f5e6a202ce292edd9f.js +1 -0
  25. package/assets/esri/core/workers/chunks/415903f481392c72870f.js +1 -0
  26. package/assets/esri/core/workers/chunks/4351b3e54b309935faed.js +1 -0
  27. package/assets/esri/core/workers/chunks/4da99f058cca83937e9b.js +1 -0
  28. package/assets/esri/core/workers/chunks/5acdd49c5f1a49fdc6e7.js +1 -0
  29. package/assets/esri/core/workers/chunks/60f7cd05e88701f43d3f.js +1 -0
  30. package/assets/esri/core/workers/chunks/{26e0a0a13060cd3e4291.js → 626ba3a7dee952308566.js} +1 -1
  31. package/assets/esri/core/workers/chunks/7cd32b10ed0e18e44ef2.js +1 -0
  32. package/assets/esri/core/workers/chunks/9661ee8569ee208e6237.js +1 -0
  33. package/assets/esri/core/workers/chunks/968f2f841c011095a6d2.js +1 -0
  34. package/assets/esri/core/workers/chunks/974742af7beb000c4b4a.js +1 -0
  35. package/assets/esri/core/workers/chunks/{e27fa1e84f16b7f19a90.js → 9850ff14bd9c7da81c65.js} +1 -1
  36. package/assets/esri/core/workers/chunks/a0c51c4c30a5f749dfc6.js +1 -0
  37. package/assets/esri/core/workers/chunks/a2676f3f135ad5fdf872.js +1 -0
  38. package/assets/esri/core/workers/chunks/a8430e1e2142f1ce9b92.js +1 -0
  39. package/assets/esri/core/workers/chunks/{fdcbd28f38bc485ac5e3.js → ab6ecd8eeec5ff761b34.js} +1 -1
  40. package/assets/esri/core/workers/chunks/b53300b46646cfad2526.js +319 -0
  41. package/assets/esri/core/workers/chunks/bf543bdec3da0fe278fb.js +1 -0
  42. package/assets/esri/core/workers/chunks/{5bdd5ae2d2f23ef6b331.js → c87e2a63b96e0da77dfe.js} +1 -1
  43. package/assets/esri/core/workers/chunks/cc4dd739c4c7e3ccea3f.js +1 -0
  44. package/assets/esri/core/workers/chunks/d3a74087e076a3ae76ca.js +1 -0
  45. package/assets/esri/core/workers/chunks/{7c42281188b874ffcdad.js → db5913824d5e5a2a8365.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{48a1bb1e171dd06a7c6e.js → dd94585508f49863dc15.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{9408a72968cbd985dd24.js → f2cef954b58c6604642c.js} +34 -34
  48. package/assets/esri/core/workers/chunks/f52e597dca4b32a81881.js +1 -0
  49. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  50. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  51. package/chunks/BloomBlur.glsl.js +7 -7
  52. package/chunks/BloomComposition.glsl.js +24 -25
  53. package/chunks/ShadowCastAccumulate.glsl.js +13 -9
  54. package/chunks/ShadowCastVisualize.glsl.js +24 -9
  55. package/chunks/cameraUtilsSpherical.js +1 -1
  56. package/chunks/lyr3DMain.js +1 -1
  57. package/chunks/lyr3DWorker.js +1 -1
  58. package/chunks/sphere.js +1 -1
  59. package/core/Collection.js +1 -1
  60. package/core/JSONSupport.js +1 -1
  61. package/core/SetUtils.js +1 -1
  62. package/{views/webgl/GLObjectType.js → core/support/jsonUtils.js} +1 -1
  63. package/core/urlUtils.js +1 -1
  64. package/geometry/Mesh.js +1 -1
  65. package/geometry/support/normalizeUtilsSync.js +1 -1
  66. package/geometry/support/sphere.js +1 -1
  67. package/interfaces.d.ts +544 -116
  68. package/layers/DimensionLayer.js +1 -1
  69. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  70. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  71. package/layers/ParquetLayer.js +1 -1
  72. package/layers/RouteLayer.js +1 -1
  73. package/layers/SubtypeGroupLayer.js +1 -1
  74. package/layers/ViewshedLayer.js +1 -1
  75. package/layers/graphics/data/QueryEngine.js +1 -1
  76. package/layers/mixins/ImageryTileMixin.js +1 -1
  77. package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
  78. package/layers/orientedImagery/transformations/utils.js +1 -1
  79. package/layers/support/FieldsIndex.js +1 -1
  80. package/layers/support/ParquetEncodingLocation.d.ts +4 -0
  81. package/layers/support/ParquetEncodingLocation.js +1 -1
  82. package/layers/support/ParquetEncodingWkb.d.ts +4 -0
  83. package/layers/support/ParquetEncodingWkb.js +1 -1
  84. package/layers/support/RasterStorageInfo.js +1 -1
  85. package/layers/support/VideoElement.js +1 -1
  86. package/layers/support/layerUtils.js +1 -1
  87. package/layers/support/parquetUtils.d.ts +3 -0
  88. package/layers/support/parquetUtils.js +1 -1
  89. package/layers/support/rasterDatasets/BaseRaster.js +1 -1
  90. package/layers/support/rasterDatasets/FunctionRaster.js +1 -1
  91. package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
  92. package/layers/support/rasterDatasets/RawBlockCache.js +1 -1
  93. package/layers/support/rasterDatasets/TIFFRaster.js +1 -1
  94. package/layers/support/rasterFormats/TiffDecoder.js +1 -1
  95. package/layers/support/rasterFormats/pixelRangeUtils.js +1 -1
  96. package/layers/support/rasterFormats/{TiffTags.js → tiffTag.js} +1 -1
  97. package/layers/support/rasterFunctions/BandArithmeticFunction.js +1 -1
  98. package/layers/support/rasterFunctions/BaseRasterFunction.js +1 -1
  99. package/layers/support/rasterFunctions/ExtractBandFunction.js +1 -1
  100. package/layers/support/rasterFunctions/NDVIFunction.js +1 -1
  101. package/layers/support/rasterFunctions/RemapFunction.js +1 -1
  102. package/layers/support/rasterFunctions/rasterFunctionHelper.js +1 -1
  103. package/layers/support/videoUtils.js +5 -0
  104. package/package.json +2 -2
  105. package/portal/schemas/definitions.js +1 -1
  106. package/portal/schemas/integratedMesh3DTilesLayerItem.js +1 -1
  107. package/renderers/UniqueValueRenderer.js +1 -1
  108. package/renderers/support/colorRampUtils.js +1 -1
  109. package/support/revision.js +1 -1
  110. package/symbols/IconSymbol3DLayer.js +1 -1
  111. package/symbols/cim/effects/EffectTaperedPolygon.js +1 -1
  112. package/views/2d/engine/webgl/meshing/Mesh.js +1 -1
  113. package/views/2d/engine/webgl/shaderGraph/typed/TypedShaderProgram.js +1 -1
  114. package/views/2d/engine/webgl/textureUtils.js +1 -1
  115. package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
  116. package/views/2d/layers/MediaLayerView2D.js +1 -1
  117. package/views/2d/layers/TileLayerView2D.js +1 -1
  118. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  119. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  120. package/views/2d/layers/support/DebugOverlay.js +1 -1
  121. package/views/2d/layers/support/MediaLayerInteraction.js +1 -1
  122. package/views/3d/analysis/DirectLineMeasurementAnalysisView3D.js +1 -1
  123. package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
  124. package/views/3d/analysis/LineOfSightAnalysisView3D.js +1 -1
  125. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  126. package/views/3d/analysis/Slice/SliceVisualization.js +1 -1
  127. package/views/3d/analysis/SliceAnalysisView3D.js +1 -1
  128. package/views/3d/analysis/Viewshed/ViewshedAnalysisVisualization.js +1 -1
  129. package/views/3d/analysis/Viewshed/ViewshedVisualization.js +1 -1
  130. package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
  131. package/views/3d/camera/constraintUtils/distance.js +1 -1
  132. package/views/3d/camera/intersectionUtils.js +1 -1
  133. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  134. package/views/3d/environment/atmosphereUtils.js +1 -1
  135. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
  136. package/views/3d/interactive/visualElements/DrapedVisualElementResources.js +1 -1
  137. package/views/3d/interactive/visualElements/EngineVisualElement.js +1 -1
  138. package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
  139. package/views/3d/interactive/visualElements/LabelVisualElement.js +1 -1
  140. package/views/3d/interactive/visualElements/LaserlineVisualElement.js +1 -1
  141. package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
  142. package/views/3d/interactive/visualElements/MarkerVisualElement.js +1 -1
  143. package/views/3d/interactive/visualElements/MeasurementAreaVisualElement.js +1 -1
  144. package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
  145. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  146. package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
  147. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  148. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  149. package/views/3d/interactive/visualElements/SlicePlaneVisualElement.js +1 -1
  150. package/views/3d/interactive/visualElements/VerticesVisualElement.js +1 -1
  151. package/views/3d/interactive/visualElements/ViewshedShapeVisualElement.js +1 -1
  152. package/views/3d/interactive/visualElements/VisualElement.js +1 -1
  153. package/views/3d/interactive/visualElements/VisualElementResources.js +1 -1
  154. package/views/3d/layers/I3SMeshView3D.js +1 -1
  155. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  156. package/views/3d/layers/Lyr3DWorker.js +1 -1
  157. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  158. package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +1 -1
  159. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
  160. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorkerHandle.js +1 -1
  161. package/views/3d/layers/graphics/pipeline/PipelineCommand.js +1 -1
  162. package/views/3d/layers/graphics/pipeline/Tile3DManager.js +1 -1
  163. package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
  164. package/views/3d/layers/graphics/pipeline/rendering/RenderCommandContext.js +1 -1
  165. package/views/3d/layers/graphics/pipeline/symbolization/Factory.js +5 -0
  166. package/views/3d/layers/graphics/pipeline/symbolization/SimpleFeatureRenderer.js +5 -0
  167. package/views/3d/layers/graphics/pipeline/symbolization/TestObjectSymbol.js +1 -1
  168. package/views/3d/layers/graphics/pipeline/symbolization/TestSymbol.js +1 -1
  169. package/views/3d/layers/graphics/pipeline/symbolization/UniqueValueFeatureRenderer.js +1 -1
  170. package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
  171. package/views/3d/layers/support/MediaLayerInteraction.js +1 -1
  172. package/views/3d/state/ConstraintsManager.js +1 -1
  173. package/views/3d/state/NearFarHeuristic.js +1 -1
  174. package/views/3d/state/ViewState.js +1 -1
  175. package/views/3d/state/ViewStateManager.js +1 -1
  176. package/views/3d/state/utils/navigationUtils.js +1 -1
  177. package/views/3d/support/cameraUtilsSpherical.js +1 -1
  178. package/views/3d/support/geometryUtils/sphere.js +1 -1
  179. package/views/3d/terrain/OverlayRenderTargets.js +1 -1
  180. package/views/3d/webgl/ManagedDepthTexture.js +1 -1
  181. package/views/3d/webgl/ManagedFBO.js +1 -1
  182. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  183. package/views/3d/webgl-engine/core/FBOCacheFormats.js +5 -0
  184. package/views/3d/webgl-engine/core/shaderLibrary/Laserline.glsl.js +12 -20
  185. package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +1 -1
  186. package/views/3d/webgl-engine/core/shaderLibrary/util/BlendColorsPremultiplied.glsl.js +5 -0
  187. package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +1 -1
  188. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  189. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
  190. package/views/3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js +1 -1
  191. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  192. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  193. package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
  194. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  195. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  196. package/views/3d/webgl-engine/lib/DepthRange.js +1 -1
  197. package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
  198. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  199. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  200. package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
  201. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  202. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  203. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  204. package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
  205. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  206. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  207. package/views/3d/webgl-engine/shaders/ShadowCastAccumulate.glsl.js +1 -1
  208. package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechnique.js +1 -1
  209. package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechniqueConfiguration.js +5 -0
  210. package/views/3d/webgl-engine/shaders/ShadowCastVisualize.glsl.js +1 -1
  211. package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechnique.js +1 -1
  212. package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechniqueConfiguration.js +1 -1
  213. package/views/PopupView.js +1 -1
  214. package/views/SceneView.js +1 -1
  215. package/views/SelectionManager.js +1 -1
  216. package/views/VideoView.js +1 -1
  217. package/views/analysis/analysisViewUtils.js +1 -1
  218. package/views/input/InputManager.js +1 -1
  219. package/views/input/ViewEvents.js +1 -1
  220. package/views/support/selectionUtils.js +1 -1
  221. package/views/webgl/FBOAttachmentType.js +5 -0
  222. package/views/webgl/FramebufferObject.js +1 -1
  223. package/views/webgl/Renderbuffer.js +1 -1
  224. package/views/webgl/RenderbufferDescriptor.js +1 -1
  225. package/views/webgl/Texture.js +1 -1
  226. package/views/webgl/TextureDescriptor.js +1 -1
  227. package/views/webgl/textureUtils.js +1 -1
  228. package/webscene/InitialViewProperties.js +1 -1
  229. package/webscene/Presentation.js +1 -1
  230. package/webscene/Slide.js +1 -1
  231. package/webscene/SlideLegendInfo.js +1 -1
  232. package/webscene/background/ColorBackground.js +1 -1
  233. package/webscene/spec-certification/api.js +1 -1
  234. package/webscene/spec-certification/compare.js +1 -1
  235. package/webscene/spec-certification/index.js +1 -1
  236. package/webscene/spec-certification/spec.js +1 -1
  237. package/webscene/spec-certification/utils.js +1 -1
  238. package/webscene/support/Description.js +1 -1
  239. package/webscene/support/SlideElements.js +1 -1
  240. package/webscene/support/SlideEnvironment.js +1 -1
  241. package/webscene/support/SlideGround.js +1 -1
  242. package/webscene/support/SlideVisibleLayer.js +1 -1
  243. package/webscene/support/Title.js +1 -1
  244. package/webscene/support/analysisUtils.js +5 -0
  245. package/widgets/BatchAttributeForm/expressions/ExpressionsManager.js +1 -1
  246. package/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js +1 -1
  247. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  248. package/widgets/Editor/EditorViewModel.js +1 -1
  249. package/widgets/Editor/UpdateWorkflow.js +1 -1
  250. package/widgets/Editor/support/SketchController.js +5 -0
  251. package/widgets/Editor/workflowUtils.js +1 -1
  252. package/widgets/ElevationProfile/ElevationProfileInteraction.js +1 -1
  253. package/widgets/Feature/FeatureUtilityNetworkAssociationList.js +1 -1
  254. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
  255. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  256. package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
  257. package/widgets/FeatureTable/support/tableUtils.js +1 -1
  258. package/widgets/FeatureTable.js +1 -1
  259. package/widgets/LayerList/LayerListItem.js +1 -1
  260. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  261. package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
  262. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  263. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  264. package/widgets/ShadowCast/ThresholdOptions.js +1 -1
  265. package/widgets/Sketch/SketchViewModel.js +1 -1
  266. package/widgets/VideoPlayer.js +1 -1
  267. package/widgets/Widget.js +1 -1
  268. package/widgets/support/AnalysisViewModel.js +1 -1
  269. package/widgets/support/SelectionList.js +1 -1
  270. package/widgets/support/SnappingControls.js +1 -1
  271. package/assets/esri/core/workers/chunks/184d7c8ea818bec5c462.js +0 -1
  272. package/assets/esri/core/workers/chunks/22f604726529ee6f8c25.js +0 -1
  273. package/assets/esri/core/workers/chunks/244d2196bac5ef279436.js +0 -1
  274. package/assets/esri/core/workers/chunks/26fcbe053194bd78fcc3.js +0 -1
  275. package/assets/esri/core/workers/chunks/32f2e0c88046b39916cc.js +0 -1
  276. package/assets/esri/core/workers/chunks/388a763da712ca71ccf4.js +0 -1
  277. package/assets/esri/core/workers/chunks/4f8782b3b6ad414409e8.js +0 -1
  278. package/assets/esri/core/workers/chunks/5ffc3ca6c6a4d32e1282.js +0 -1
  279. package/assets/esri/core/workers/chunks/642a595353a86f3717e3.js +0 -1
  280. package/assets/esri/core/workers/chunks/8dd26b12c625d20196ed.js +0 -319
  281. package/assets/esri/core/workers/chunks/931275cfa2c55eb0f504.js +0 -1
  282. package/assets/esri/core/workers/chunks/93e9dfd1ba8f393c6c47.js +0 -1
  283. package/assets/esri/core/workers/chunks/95379fdd6917c8a84c71.js +0 -1
  284. package/assets/esri/core/workers/chunks/9b21dc4659922cc577cb.js +0 -1
  285. package/assets/esri/core/workers/chunks/a197c86d42cc9ce21924.js +0 -1
  286. package/assets/esri/core/workers/chunks/a276980c06d5d311a37e.js +0 -1
  287. package/assets/esri/core/workers/chunks/b42ecc7c3eb2fd8d1308.js +0 -1
  288. package/assets/esri/core/workers/chunks/ccc50f28f217e50cc2c3.js +0 -1
  289. package/assets/esri/core/workers/chunks/d04efa51da9b4eb3a8a7.js +0 -1
  290. package/assets/esri/core/workers/chunks/d81bebbb6fe000200d35.js +0 -1
  291. package/assets/esri/core/workers/chunks/dd8e72d6784a8ebc115d.js +0 -1
  292. package/assets/esri/core/workers/chunks/e9fba86036b8fe700a41.js +0 -1
  293. package/assets/esri/core/workers/chunks/ed3d1d0465f4a4d8df4a.js +0 -1
  294. package/views/webgl/formats.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/has.js";import{disposeMaybe as t}from"../../../../../core/maybe.js";import{property as i}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as n}from"../../../../../core/accessorSupport/decorators/subclass.js";import{c as s,g as r}from"../../../../../chunks/vec32.js";import{create as a,fromRay as o,getStart as l,getEnd as h}from"../../../../../geometry/support/clipRay.js";import{intersectClipRay as c}from"../../../../../geometry/support/frustum.js";import{copy as d}from"../../../../../geometry/support/lineSegment.js";import{wrap as p}from"../../../../../geometry/support/ray.js";import{ViewingMode as u}from"../../../../ViewingMode.js";import{InternalRenderCategory as m}from"../../../webgl.js";import g from"../../../webgl/RenderNode.js";import{Blit as _}from"../blit/Blit.js";import{LaserlinePathData as P}from"./LaserlinePathData.js";import{LaserlinePathPassParameters as b,LaserlinePathTechnique as f}from"./LaserlinePathTechnique.js";import{LaserlinePathTechniqueConfiguration as E}from"./LaserlinePathTechniqueConfiguration.js";import{LaserlineTechnique as D}from"./LaserlineTechnique.js";import{LaserlineTechniqueConfiguration as q}from"./LaserlineTechniqueConfiguration.js";import{RenderRequestType as T}from"../../lib/basicInterfaces.js";import{updateParameters as L}from"../../materials/internal/MaterialUtil.js";import{BlitMode as V}from"../../shaders/CompositingTechniqueConfiguration.js";import{FramebufferBit as C}from"../../../../webgl/enums.js";let j=class extends g{constructor(e){super(e),this.produces=m.LASERLINES,this.consumes={required:[m.LASERLINES,"normals"]},this.requireGeometryDepth=!0,this._configuration=new q,this._pathTechniqueConfiguration=new E,this._heightManifoldEnabled=!1,this._pointDistanceEnabled=!1,this._lineVerticalPlaneEnabled=!1,this._intersectsLineEnabled=!1,this._intersectsLineInfinite=!1,this._pathVerticalPlaneEnabled=!1,this._passParameters=new b;const t=e.view.stage.renderView.techniques,i=new E;i.contrastControlEnabled=e.contrastControlEnabled,t.precompile(f,i)}initialize(){this._passParameters.renderCoordsHelper=this.view.renderCoordsHelper,this._pathTechniqueConfiguration.spherical=this.view.state.viewingMode===u.Global,this._pathTechniqueConfiguration.contrastControlEnabled=this.contrastControlEnabled,this._techniques.precompile(f,this._pathTechniqueConfiguration),this._blit=new _(this._techniques,V.PremultipliedAlpha)}destroy(){this._pathVerticalPlaneData=t(this._pathVerticalPlaneData),this._blit=null}get _techniques(){return this.view.stage.renderView.techniques}get heightManifoldEnabled(){return this._heightManifoldEnabled}set heightManifoldEnabled(e){this._heightManifoldEnabled!==e&&(this._heightManifoldEnabled=e,this.requestRender(T.UPDATE))}get heightManifoldTarget(){return this._passParameters.heightManifoldTarget}set heightManifoldTarget(e){s(this._passParameters.heightManifoldTarget,e),this.requestRender(T.UPDATE)}get pointDistanceEnabled(){return this._pointDistanceEnabled}set pointDistanceEnabled(e){e!==this._pointDistanceEnabled&&(this._pointDistanceEnabled=e,this.requestRender(T.UPDATE))}get pointDistanceTarget(){return this._passParameters.pointDistanceTarget}set pointDistanceTarget(e){s(this._passParameters.pointDistanceTarget,e),this.requestRender(T.UPDATE)}get pointDistanceOrigin(){return this._passParameters.pointDistanceOrigin}set pointDistanceOrigin(e){s(this._passParameters.pointDistanceOrigin,e),this.requestRender(T.UPDATE)}get lineVerticalPlaneEnabled(){return this._lineVerticalPlaneEnabled}set lineVerticalPlaneEnabled(e){e!==this._lineVerticalPlaneEnabled&&(this._lineVerticalPlaneEnabled=e,this.requestRender(T.UPDATE))}get lineVerticalPlaneSegment(){return this._passParameters.lineVerticalPlaneSegment}set lineVerticalPlaneSegment(e){d(e,this._passParameters.lineVerticalPlaneSegment),this.requestRender(T.UPDATE)}get intersectsLineEnabled(){return this._intersectsLineEnabled}set intersectsLineEnabled(e){e!==this._intersectsLineEnabled&&(this._intersectsLineEnabled=e,this.requestRender(T.UPDATE))}get intersectsLineSegment(){return this._passParameters.intersectsLineSegment}set intersectsLineSegment(e){d(e,this._passParameters.intersectsLineSegment),this.requestRender(T.UPDATE)}get intersectsLineInfinite(){return this._intersectsLineInfinite}set intersectsLineInfinite(e){e!==this._intersectsLineInfinite&&(this._intersectsLineInfinite=e,this.requestRender(T.UPDATE))}get pathVerticalPlaneEnabled(){return this._pathVerticalPlaneEnabled}set pathVerticalPlaneEnabled(e){e!==this._pathVerticalPlaneEnabled&&(this._pathVerticalPlaneEnabled=e,null!=this._pathVerticalPlaneData&&this.requestRender(T.UPDATE))}set pathVerticalPlaneVertices(e){null==this._pathVerticalPlaneData&&(this._pathVerticalPlaneData=new P(this._passParameters.renderCoordsHelper)),this._pathVerticalPlaneData.vertices=e,this.pathVerticalPlaneEnabled&&this.requestRender(T.UPDATE)}set pathVerticalPlaneBuffers(e){null==this._pathVerticalPlaneData&&(this._pathVerticalPlaneData=new P(this._passParameters.renderCoordsHelper)),this._pathVerticalPlaneData.buffers=e,this.pathVerticalPlaneEnabled&&this.requestRender(T.UPDATE)}setParameters(e){L(this._passParameters,e)&&this.requestRender(T.UPDATE)}precompile(){this._acquireTechnique()}render(e){const t=e.find((({name:e})=>e===this.produces));if(!this.bindParameters.decorations||null==this._blit)return t;const i=this.renderingContext,n=e.find((({name:e})=>"normals"===e));this._passParameters.normals=n?.getTexture();const s=()=>{(this.heightManifoldEnabled||this.pointDistanceEnabled||this.lineVerticalPlaneSegment||this.intersectsLineEnabled)&&this._renderUnified(),this.pathVerticalPlaneEnabled&&this._renderPath()};if(!this.contrastControlEnabled)return i.bindFramebuffer(t.fbo),s(),t;this._passParameters.colors=t.getTexture();const r=this.fboCache.acquire(t.fbo.width,t.fbo.height,"laser lines");return i.bindFramebuffer(r.fbo),i.setClearColor(0,0,0,0),i.clear(C.COLOR|C.DEPTH),s(),i.unbindTexture(t.getTexture()),this._blit.blend(i,r,t,this.bindParameters)||this.requestRender(T.UPDATE),r.release(),t}_acquireTechnique(){return this._configuration.heightManifoldEnabled=this.heightManifoldEnabled,this._configuration.lineVerticalPlaneEnabled=this.lineVerticalPlaneEnabled,this._configuration.pointDistanceEnabled=this.pointDistanceEnabled,this._configuration.intersectsLineEnabled=this.intersectsLineEnabled,this._configuration.contrastControlEnabled=this.contrastControlEnabled,this._configuration.spherical=this.view.state.viewingMode===u.Global,this._techniques.get(D,this._configuration)}_renderUnified(){if(!this._updatePassParameters())return;const e=this._acquireTechnique();if(e.compiled){const t=this.renderingContext;t.bindTechnique(e,this.bindParameters,this._passParameters),t.screen.draw()}else this.requestRender(T.UPDATE)}_renderPath(){if(null==this._pathVerticalPlaneData)return;const e=this._techniques.get(f,this._pathTechniqueConfiguration);if(e.compiled){const t=this.renderingContext;this._passParameters.origin=this._pathVerticalPlaneData.origin,t.bindTechnique(e,this.bindParameters,this._passParameters),this._pathVerticalPlaneData.draw(t)}else this.requestRender(T.UPDATE)}_updatePassParameters(){if(!this._intersectsLineEnabled)return!0;const e=this.bindParameters.camera,t=this._passParameters;if(this._intersectsLineInfinite){if(o(p(t.intersectsLineSegment.origin,t.intersectsLineSegment.vector),w),w.c0=-Number.MAX_VALUE,!c(e.frustum,w))return!1;l(w,t.lineStartWorld),h(w,t.lineEndWorld)}else s(t.lineStartWorld,t.intersectsLineSegment.origin),r(t.lineEndWorld,t.intersectsLineSegment.origin,t.intersectsLineSegment.vector);return!0}get test(){}};e([i({constructOnly:!0})],j.prototype,"contrastControlEnabled",void 0),e([i({constructOnly:!0})],j.prototype,"isDecoration",void 0),e([i()],j.prototype,"produces",void 0),e([i()],j.prototype,"consumes",void 0),j=e([n("esri.views.3d.webgl-engine.effects.laserlines.LaserLineRenderer")],j);const w=a();export{j as LaserLineRenderer};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/has.js";import{disposeMaybe as t}from"../../../../../core/maybe.js";import{property as i}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as n}from"../../../../../core/accessorSupport/decorators/subclass.js";import{c as s,g as r}from"../../../../../chunks/vec32.js";import{create as a,fromRay as o,getStart as l,getEnd as h}from"../../../../../geometry/support/clipRay.js";import{intersectClipRay as c}from"../../../../../geometry/support/frustum.js";import{copy as d}from"../../../../../geometry/support/lineSegment.js";import{wrap as p}from"../../../../../geometry/support/ray.js";import{ViewingMode as u}from"../../../../ViewingMode.js";import{InternalRenderCategory as m}from"../../../webgl.js";import g from"../../../webgl/RenderNode.js";import{Blit as _}from"../blit/Blit.js";import{LaserlinePathData as P}from"./LaserlinePathData.js";import{LaserlinePathPassParameters as b,LaserlinePathTechnique as f}from"./LaserlinePathTechnique.js";import{LaserlinePathTechniqueConfiguration as E}from"./LaserlinePathTechniqueConfiguration.js";import{LaserlineTechnique as D}from"./LaserlineTechnique.js";import{LaserlineTechniqueConfiguration as q}from"./LaserlineTechniqueConfiguration.js";import{RenderRequestType as T}from"../../lib/basicInterfaces.js";import{updateParameters as L}from"../../materials/internal/MaterialUtil.js";import{BlitMode as V}from"../../shaders/CompositingTechniqueConfiguration.js";import{FramebufferBit as C}from"../../../../webgl/enums.js";let j=class extends g{constructor(e){super(e),this.isDecoration=!0,this.produces=m.LASERLINES,this.consumes={required:[m.LASERLINES,"normals"]},this.requireGeometryDepth=!0,this._configuration=new q,this._pathTechniqueConfiguration=new E,this._heightManifoldEnabled=!1,this._pointDistanceEnabled=!1,this._lineVerticalPlaneEnabled=!1,this._intersectsLineEnabled=!1,this._intersectsLineInfinite=!1,this._pathVerticalPlaneEnabled=!1,this._passParameters=new b;const t=e.view.stage.renderView.techniques,i=new E;i.contrastControlEnabled=e.contrastControlEnabled,t.precompile(f,i)}initialize(){this._passParameters.renderCoordsHelper=this.view.renderCoordsHelper,this._pathTechniqueConfiguration.spherical=this.view.state.viewingMode===u.Global,this._pathTechniqueConfiguration.contrastControlEnabled=this.contrastControlEnabled,this._techniques.precompile(f,this._pathTechniqueConfiguration),this._blit=new _(this._techniques,V.PremultipliedAlpha)}destroy(){this._pathVerticalPlaneData=t(this._pathVerticalPlaneData),this._blit=null}get _techniques(){return this.view.stage.renderView.techniques}get heightManifoldEnabled(){return this._heightManifoldEnabled}set heightManifoldEnabled(e){this._heightManifoldEnabled!==e&&(this._heightManifoldEnabled=e,this.requestRender(T.UPDATE))}get heightManifoldTarget(){return this._passParameters.heightManifoldTarget}set heightManifoldTarget(e){s(this._passParameters.heightManifoldTarget,e),this.requestRender(T.UPDATE)}get pointDistanceEnabled(){return this._pointDistanceEnabled}set pointDistanceEnabled(e){e!==this._pointDistanceEnabled&&(this._pointDistanceEnabled=e,this.requestRender(T.UPDATE))}get pointDistanceTarget(){return this._passParameters.pointDistanceTarget}set pointDistanceTarget(e){s(this._passParameters.pointDistanceTarget,e),this.requestRender(T.UPDATE)}get pointDistanceOrigin(){return this._passParameters.pointDistanceOrigin}set pointDistanceOrigin(e){s(this._passParameters.pointDistanceOrigin,e),this.requestRender(T.UPDATE)}get lineVerticalPlaneEnabled(){return this._lineVerticalPlaneEnabled}set lineVerticalPlaneEnabled(e){e!==this._lineVerticalPlaneEnabled&&(this._lineVerticalPlaneEnabled=e,this.requestRender(T.UPDATE))}get lineVerticalPlaneSegment(){return this._passParameters.lineVerticalPlaneSegment}set lineVerticalPlaneSegment(e){d(e,this._passParameters.lineVerticalPlaneSegment),this.requestRender(T.UPDATE)}get intersectsLineEnabled(){return this._intersectsLineEnabled}set intersectsLineEnabled(e){e!==this._intersectsLineEnabled&&(this._intersectsLineEnabled=e,this.requestRender(T.UPDATE))}get intersectsLineSegment(){return this._passParameters.intersectsLineSegment}set intersectsLineSegment(e){d(e,this._passParameters.intersectsLineSegment),this.requestRender(T.UPDATE)}get intersectsLineInfinite(){return this._intersectsLineInfinite}set intersectsLineInfinite(e){e!==this._intersectsLineInfinite&&(this._intersectsLineInfinite=e,this.requestRender(T.UPDATE))}get pathVerticalPlaneEnabled(){return this._pathVerticalPlaneEnabled}set pathVerticalPlaneEnabled(e){e!==this._pathVerticalPlaneEnabled&&(this._pathVerticalPlaneEnabled=e,null!=this._pathVerticalPlaneData&&this.requestRender(T.UPDATE))}set pathVerticalPlaneVertices(e){null==this._pathVerticalPlaneData&&(this._pathVerticalPlaneData=new P(this._passParameters.renderCoordsHelper)),this._pathVerticalPlaneData.vertices=e,this.pathVerticalPlaneEnabled&&this.requestRender(T.UPDATE)}set pathVerticalPlaneBuffers(e){null==this._pathVerticalPlaneData&&(this._pathVerticalPlaneData=new P(this._passParameters.renderCoordsHelper)),this._pathVerticalPlaneData.buffers=e,this.pathVerticalPlaneEnabled&&this.requestRender(T.UPDATE)}setParameters(e){L(this._passParameters,e)&&this.requestRender(T.UPDATE)}precompile(){this._acquireTechnique()}render(e){const t=e.find((({name:e})=>e===this.produces));if(this.isDecoration&&!this.bindParameters.decorations||null==this._blit)return t;const i=this.renderingContext,n=e.find((({name:e})=>"normals"===e));this._passParameters.normals=n?.getTexture();const s=()=>{(this.heightManifoldEnabled||this.pointDistanceEnabled||this.lineVerticalPlaneSegment||this.intersectsLineEnabled)&&this._renderUnified(),this.pathVerticalPlaneEnabled&&this._renderPath()};if(!this.contrastControlEnabled)return i.bindFramebuffer(t.fbo),s(),t;this._passParameters.colors=t.getTexture();const r=this.fboCache.acquire(t.fbo.width,t.fbo.height,"laser lines");return i.bindFramebuffer(r.fbo),i.setClearColor(0,0,0,0),i.clear(C.COLOR|C.DEPTH),s(),i.unbindTexture(t.getTexture()),this._blit.blend(i,r,t,this.bindParameters)||this.requestRender(T.UPDATE),r.release(),t}_acquireTechnique(){return this._configuration.heightManifoldEnabled=this.heightManifoldEnabled,this._configuration.lineVerticalPlaneEnabled=this.lineVerticalPlaneEnabled,this._configuration.pointDistanceEnabled=this.pointDistanceEnabled,this._configuration.intersectsLineEnabled=this.intersectsLineEnabled,this._configuration.contrastControlEnabled=this.contrastControlEnabled,this._configuration.spherical=this.view.state.viewingMode===u.Global,this._techniques.get(D,this._configuration)}_renderUnified(){if(!this._updatePassParameters())return;const e=this._acquireTechnique();if(e.compiled){const t=this.renderingContext;t.bindTechnique(e,this.bindParameters,this._passParameters),t.screen.draw()}else this.requestRender(T.UPDATE)}_renderPath(){if(null==this._pathVerticalPlaneData)return;const e=this._techniques.get(f,this._pathTechniqueConfiguration);if(e.compiled){const t=this.renderingContext;this._passParameters.origin=this._pathVerticalPlaneData.origin,t.bindTechnique(e,this.bindParameters,this._passParameters),this._pathVerticalPlaneData.draw(t)}else this.requestRender(T.UPDATE)}_updatePassParameters(){if(!this._intersectsLineEnabled)return!0;const e=this.bindParameters.camera,t=this._passParameters;if(this._intersectsLineInfinite){if(o(p(t.intersectsLineSegment.origin,t.intersectsLineSegment.vector),w),w.c0=-Number.MAX_VALUE,!c(e.frustum,w))return!1;l(w,t.lineStartWorld),h(w,t.lineEndWorld)}else s(t.lineStartWorld,t.intersectsLineSegment.origin),r(t.lineEndWorld,t.intersectsLineSegment.origin,t.intersectsLineSegment.vector);return!0}get test(){}};e([i({constructOnly:!0})],j.prototype,"contrastControlEnabled",void 0),e([i()],j.prototype,"isDecoration",void 0),e([i()],j.prototype,"produces",void 0),e([i()],j.prototype,"consumes",void 0),j=e([n("esri.views.3d.webgl-engine.effects.laserlines.LaserLineRenderer")],j);const w=a();export{j as LaserLineRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{disposeMaybe as r}from"../../../../../core/maybe.js";import{throwIfAborted as t}from"../../../../../core/promiseUtils.js";import{watch as s,syncAndInitial as i}from"../../../../../core/reactiveUtils.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as n}from"../../../../../support/requestImageUtils.js";import{InternalRenderCategory as c,RenderCategory as h}from"../../../webgl.js";import m from"../../../webgl/RenderNode.js";import{SMAABlendWeightsTechnique as l}from"./SMAABlendWeightsTechnique.js";import{SMAABlurTechnique as u}from"./SMAABlurTechnique.js";import{SMAAEdgeDetectTechnique as p}from"./SMAAEdgeDetectTechnique.js";import{SMAAPassParameters as d}from"./SMAAPassParameters.js";import{RenderRequestType as f}from"../../lib/basicInterfaces.js";import{PixelFormat as b,TextureSamplingMode as T,FramebufferBit as x,TextureWrapMode as _}from"../../../../webgl/enums.js";import{ColorFormat as g}from"../../../../webgl/formats.js";import{Texture as A}from"../../../../webgl/Texture.js";import{TextureDescriptor as C}from"../../../../webgl/TextureDescriptor.js";let w=class extends m{constructor(e){super(e),this.produces="disabled",this.consumes={required:[c.ANTIALIASING],optional:[h.COMPOSITE]},this._areaTexture=null,this._searchTexture=null,this._smaaParameters=new d}initialize(){this.addHandles([s((()=>this.isEnabled()),(e=>e?this.enable():this.disable()),i)])}async enable(){if(this.produces=c.ANTIALIASING,this._abortController||this._areaTexture&&this._searchTexture)return;this._abortController=new AbortController;const e=this._abortController.signal;try{const r=await import("./SMAAData.js");await this._loadTextures(r,e),this.requestRender(f.UPDATE)}catch{}this._abortController=null}async _loadTextures(e,r){t(r);const[s,i]=await Promise.allSettled([n(e.areaTexture,{signal:r}),n(e.searchTexure,{signal:r})]);if(t(r),"fulfilled"!==s.status||"fulfilled"!==i.status)return;const a=this.renderingContext;this._areaTexture=j(a,T.LINEAR,b.RGB,s.value),this._searchTexture=j(a,T.NEAREST,b.LUMINANCE,i.value)}disable(){this.produces="disabled"}destroy(){this._searchTexture=r(this._searchTexture),this._areaTexture=r(this._areaTexture)}precompile(){this.techniques.precompile(p),this.techniques.precompile(l),this.techniques.precompile(u)}render(e){const r=e.find((({name:e})=>e===c.ANTIALIASING));if(!this._areaTexture||!this._searchTexture)return this.requestRender(f.UPDATE),r;const t=this.techniques.get(p),s=this.techniques.get(l),i=this.techniques.get(u);if(!t.compiled||!s.compiled||!i.compiled)return this.requestRender(f.UPDATE),r;const a=e.find((({name:e})=>e===h.COMPOSITE));if(!a)return r;const o=a.fbo.width,n=a.fbo.height,m=this.renderingContext;m.setViewport(0,0,o,n);const d=this.fboCache.acquire(o,n,"smaa edges",g.RG8);m.bindFramebuffer(d.fbo),m.setClearColor(0,0,0,1),m.clear(x.COLOR),this._smaaParameters.color=a.getTexture();const b=this.bindParameters;m.bindTechnique(t,b,this._smaaParameters),m.screen.draw();const T=this.fboCache.acquire(o,n,"smaa blend");return m.bindFramebuffer(T.fbo),m.setClearColor(0,0,1,1),m.clear(x.COLOR),this._smaaParameters.inputTexture=d.getTexture(),this._smaaParameters.areaTexture=this._areaTexture,this._smaaParameters.searchTexture=this._searchTexture,m.bindTechnique(s,b,this._smaaParameters),m.screen.draw(),d.release(),m.bindFramebuffer(r.fbo),m.setClearColor(0,1,0,1),m.clear(x.COLOR),this._smaaParameters.inputTexture=T.getTexture(),m.bindTechnique(i,b,this._smaaParameters),m.screen.draw(),T.release(),r}};function j(e,r,t,s){const i=new C;return i.pixelFormat=t,i.wrapMode=_.CLAMP_TO_EDGE,i.width=s.width,i.height=s.height,i.samplingMode=r,new A(e,i,s)}e([a()],w.prototype,"produces",void 0),e([a()],w.prototype,"consumes",void 0),e([a({constructOnly:!0})],w.prototype,"isEnabled",void 0),e([a()],w.prototype,"_abortController",void 0),w=e([o("esri.views.3d.webgl-engine.effects.smaa.SMAA")],w);export{w as SMAA};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{disposeMaybe as r}from"../../../../../core/maybe.js";import{throwIfAborted as t}from"../../../../../core/promiseUtils.js";import{watch as s,syncAndInitial as i}from"../../../../../core/reactiveUtils.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as n}from"../../../../../support/requestImageUtils.js";import{InternalRenderCategory as c,RenderCategory as h}from"../../../webgl.js";import m from"../../../webgl/RenderNode.js";import{ColorFormat as u}from"../../core/FBOCacheFormats.js";import{SMAABlendWeightsTechnique as l}from"./SMAABlendWeightsTechnique.js";import{SMAABlurTechnique as p}from"./SMAABlurTechnique.js";import{SMAAEdgeDetectTechnique as d}from"./SMAAEdgeDetectTechnique.js";import{SMAAPassParameters as f}from"./SMAAPassParameters.js";import{RenderRequestType as T}from"../../lib/basicInterfaces.js";import{PixelFormat as b,TextureSamplingMode as x,FramebufferBit as _,TextureWrapMode as A}from"../../../../webgl/enums.js";import{Texture as g}from"../../../../webgl/Texture.js";import{TextureDescriptor as C}from"../../../../webgl/TextureDescriptor.js";let j=class extends m{constructor(e){super(e),this.produces="disabled",this.consumes={required:[c.ANTIALIASING],optional:[h.COMPOSITE]},this._areaTexture=null,this._searchTexture=null,this._smaaParameters=new f}initialize(){this.addHandles([s((()=>this.isEnabled()),(e=>e?this.enable():this.disable()),i)])}async enable(){if(this.produces=c.ANTIALIASING,this._abortController||this._areaTexture&&this._searchTexture)return;this._abortController=new AbortController;const e=this._abortController.signal;try{const r=await import("./SMAAData.js");await this._loadTextures(r,e),this.requestRender(T.UPDATE)}catch{}this._abortController=null}async _loadTextures(e,r){t(r);const[s,i]=await Promise.allSettled([n(e.areaTexture,{signal:r}),n(e.searchTexure,{signal:r})]);if(t(r),"fulfilled"!==s.status||"fulfilled"!==i.status)return;const a=this.renderingContext;this._areaTexture=w(a,x.LINEAR,b.RGB,s.value),this._searchTexture=w(a,x.NEAREST,b.LUMINANCE,i.value)}disable(){this.produces="disabled"}destroy(){this._searchTexture=r(this._searchTexture),this._areaTexture=r(this._areaTexture)}precompile(){this.techniques.precompile(d),this.techniques.precompile(l),this.techniques.precompile(p)}render(e){const r=e.find((({name:e})=>e===c.ANTIALIASING));if(!this._areaTexture||!this._searchTexture)return this.requestRender(T.UPDATE),r;const t=this.techniques.get(d),s=this.techniques.get(l),i=this.techniques.get(p);if(!t.compiled||!s.compiled||!i.compiled)return this.requestRender(T.UPDATE),r;const a=e.find((({name:e})=>e===h.COMPOSITE));if(!a)return r;const o=a.fbo.width,n=a.fbo.height,m=this.renderingContext;m.setViewport(0,0,o,n);const f=this.fboCache.acquire(o,n,"smaa edges",u.RG8UNORM);m.bindFramebuffer(f.fbo),m.setClearColor(0,0,0,1),m.clear(_.COLOR),this._smaaParameters.color=a.getTexture();const b=this.bindParameters;m.bindTechnique(t,b,this._smaaParameters),m.screen.draw();const x=this.fboCache.acquire(o,n,"smaa blend");return m.bindFramebuffer(x.fbo),m.setClearColor(0,0,1,1),m.clear(_.COLOR),this._smaaParameters.inputTexture=f.getTexture(),this._smaaParameters.areaTexture=this._areaTexture,this._smaaParameters.searchTexture=this._searchTexture,m.bindTechnique(s,b,this._smaaParameters),m.screen.draw(),f.release(),m.bindFramebuffer(r.fbo),m.setClearColor(0,1,0,1),m.clear(_.COLOR),this._smaaParameters.inputTexture=x.getTexture(),m.bindTechnique(i,b,this._smaaParameters),m.screen.draw(),x.release(),r}};function w(e,r,t,s){const i=new C;return i.pixelFormat=t,i.wrapMode=A.CLAMP_TO_EDGE,i.width=s.width,i.height=s.height,i.samplingMode=r,new g(e,i,s)}e([a()],j.prototype,"produces",void 0),e([a()],j.prototype,"consumes",void 0),e([a({constructOnly:!0})],j.prototype,"isEnabled",void 0),e([a()],j.prototype,"_abortController",void 0),j=e([o("esri.views.3d.webgl-engine.effects.smaa.SMAA")],j);export{j as SMAA};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{clamp as r}from"../../../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../../../core/maybe.js";import{watch as t}from"../../../../../core/reactiveUtils.js";import{Milliseconds as i}from"../../../../../core/time.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as m}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{InternalRenderCategory as n}from"../../../webgl.js";import p from"../../../webgl/RenderNode.js";import{distanceFadeEnd as c,distanceFadeStart as h}from"../../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{SSAOBlurTechnique as u}from"./SSAOBlurTechnique.js";import{noiseData as l}from"./SSAONoiseData.js";import{SSAOPassParameters as d,BlurDrawParameters as f}from"./SSAOParameters.js";import{SSAOTechnique as b}from"./SSAOTechnique.js";import{RenderRequestType as w}from"../../lib/basicInterfaces.js";import{g as T}from"../../../../../chunks/SSAO.glsl.js";import{TextureWrapMode as S,PixelFormat as _,DepthStencilAttachment as P,FramebufferBit as j}from"../../../../webgl/enums.js";import{ColorFormat as g}from"../../../../webgl/formats.js";import{Texture as x}from"../../../../webgl/Texture.js";import{TextureDescriptor as q}from"../../../../webgl/TextureDescriptor.js";const A=2;let O=class extends p{constructor(e){super(e),this.consumes={required:["normals"]},this.produces=n.SSAO,this.isEnabled=()=>!1,this._enableTime=i(0),this._passParameters=new d,this._drawParameters=new f}initialize(){const e=Uint8Array.from(atob(l),(e=>e.charCodeAt(0))),r=new q;r.wrapMode=S.CLAMP_TO_EDGE,r.pixelFormat=_.RGB,r.wrapMode=S.REPEAT,r.hasMipmap=!0,r.width=32,r.height=32,this._passParameters.noiseTexture=new x(this.renderingContext,r,e),this.techniques.precompile(b),this.techniques.precompile(u),this.addHandles(t((()=>this.isEnabled()),(()=>this._enableTime=i(0))))}destroy(){this._passParameters.noiseTexture=s(this._passParameters.noiseTexture)}render(e){const s=this.bindParameters,t=e.find((({name:e})=>"normals"===e)),o=t?.getTexture(),a=t?.getTexture(P),p=this.fboCache,l=s.camera,d=l.fullViewport[2],f=l.fullViewport[3],S=Math.round(d/A),_=Math.round(f/A),x=this.techniques.get(b),q=this.techniques.get(u);if(!x.compiled||!q.compiled)return this._enableTime=i(performance.now()),this.requestRender(w.UPDATE),p.acquire(S,_,n.SSAO,g.R8);0===this._enableTime&&(this._enableTime=i(performance.now()));const O=this.renderingContext,R=this.view.qualitySettings.fadeDuration,v=l.relativeElevation,C=r((c-v)/(c-h),0,1),E=R>0?Math.min(R,performance.now()-this._enableTime)/R:1,V=E*C;this._passParameters.normalTexture=o,this._passParameters.depthTexture=a,this._passParameters.projScale=1/l.computeScreenPixelSizeAtDist(1),this._passParameters.intensity=4*y/T(l)**6*V;const D=p.acquire(d,f,"ssao input",g.RG8);O.bindFramebuffer(D.fbo),O.setViewport(0,0,d,f),O.bindTechnique(x,s,this._passParameters,this._drawParameters),O.screen.draw();const M=p.acquire(S,_,"ssao blur",g.R8);O.bindFramebuffer(M.fbo),this._drawParameters.colorTexture=D.getTexture(),m(this._drawParameters.blurSize,0,A/f),O.bindTechnique(q,s,this._passParameters,this._drawParameters),O.setViewport(0,0,S,_),O.screen.draw(),D.release();const L=p.acquire(S,_,n.SSAO,g.R8);return O.bindFramebuffer(L.fbo),O.setViewport(0,0,d,f),O.setClearColor(1,1,1,0),O.clear(j.COLOR),this._drawParameters.colorTexture=M.getTexture(),m(this._drawParameters.blurSize,A/d,0),O.bindTechnique(q,s,this._passParameters,this._drawParameters),O.setViewport(0,0,S,_),O.screen.draw(),O.setViewport4fv(l.fullViewport),M.release(),E<1&&this.requestRender(w.UPDATE),L}};e([o()],O.prototype,"consumes",void 0),e([o()],O.prototype,"produces",void 0),e([o({constructOnly:!0})],O.prototype,"isEnabled",void 0),O=e([a("esri.views.3d.webgl-engine.effects.ssao.SSAO")],O);const y=.5;export{O as SSAO,A as blurSizePixels};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{clamp as r}from"../../../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../../../core/maybe.js";import{watch as t}from"../../../../../core/reactiveUtils.js";import{Milliseconds as i}from"../../../../../core/time.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as m}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{InternalRenderCategory as n}from"../../../webgl.js";import c from"../../../webgl/RenderNode.js";import{ColorFormat as p}from"../../core/FBOCacheFormats.js";import{distanceFadeEnd as h,distanceFadeStart as u}from"../../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{SSAOBlurTechnique as l}from"./SSAOBlurTechnique.js";import{noiseData as d}from"./SSAONoiseData.js";import{SSAOPassParameters as f,BlurDrawParameters as b}from"./SSAOParameters.js";import{SSAOTechnique as w}from"./SSAOTechnique.js";import{RenderRequestType as T}from"../../lib/basicInterfaces.js";import{g as S}from"../../../../../chunks/SSAO.glsl.js";import{TextureWrapMode as _,PixelFormat as P,DepthStencilAttachment as j,FramebufferBit as g}from"../../../../webgl/enums.js";import{Texture as x}from"../../../../webgl/Texture.js";import{TextureDescriptor as O}from"../../../../webgl/TextureDescriptor.js";const q=2;let A=class extends c{constructor(e){super(e),this.consumes={required:["normals"]},this.produces=n.SSAO,this.isEnabled=()=>!1,this._enableTime=i(0),this._passParameters=new f,this._drawParameters=new b}initialize(){const e=Uint8Array.from(atob(d),(e=>e.charCodeAt(0))),r=new O;r.wrapMode=_.CLAMP_TO_EDGE,r.pixelFormat=P.RGB,r.wrapMode=_.REPEAT,r.hasMipmap=!0,r.width=32,r.height=32,this._passParameters.noiseTexture=new x(this.renderingContext,r,e),this.techniques.precompile(w),this.techniques.precompile(l),this.addHandles(t((()=>this.isEnabled()),(()=>this._enableTime=i(0))))}destroy(){this._passParameters.noiseTexture=s(this._passParameters.noiseTexture)}render(e){const s=this.bindParameters,t=e.find((({name:e})=>"normals"===e)),o=t?.getTexture(),a=t?.getTexture(j),c=this.fboCache,d=s.camera,f=d.fullViewport[2],b=d.fullViewport[3],_=Math.round(f/q),P=Math.round(b/q),x=this.techniques.get(w),O=this.techniques.get(l);if(!x.compiled||!O.compiled)return this._enableTime=i(performance.now()),this.requestRender(T.UPDATE),c.acquire(_,P,n.SSAO,p.R8UNORM);0===this._enableTime&&(this._enableTime=i(performance.now()));const A=this.renderingContext,y=this.view.qualitySettings.fadeDuration,C=d.relativeElevation,M=r((h-C)/(h-u),0,1),v=y>0?Math.min(y,performance.now()-this._enableTime)/y:1,E=v*M;this._passParameters.normalTexture=o,this._passParameters.depthTexture=a,this._passParameters.projScale=1/d.computeScreenPixelSizeAtDist(1),this._passParameters.intensity=4*R/S(d)**6*E;const U=c.acquire(f,b,"ssao input",p.RG8UNORM);A.bindFramebuffer(U.fbo),A.setViewport(0,0,f,b),A.bindTechnique(x,s,this._passParameters,this._drawParameters),A.screen.draw();const V=c.acquire(_,P,"ssao blur",p.R8UNORM);A.bindFramebuffer(V.fbo),this._drawParameters.colorTexture=U.getTexture(),m(this._drawParameters.blurSize,0,q/b),A.bindTechnique(O,s,this._passParameters,this._drawParameters),A.setViewport(0,0,_,P),A.screen.draw(),U.release();const D=c.acquire(_,P,n.SSAO,p.R8UNORM);return A.bindFramebuffer(D.fbo),A.setViewport(0,0,f,b),A.setClearColor(1,1,1,0),A.clear(g.COLOR),this._drawParameters.colorTexture=V.getTexture(),m(this._drawParameters.blurSize,q/f,0),A.bindTechnique(O,s,this._passParameters,this._drawParameters),A.setViewport(0,0,_,P),A.screen.draw(),A.setViewport4fv(d.fullViewport),V.release(),v<1&&this.requestRender(T.UPDATE),D}};e([o()],A.prototype,"consumes",void 0),e([o()],A.prototype,"produces",void 0),e([o({constructOnly:!0})],A.prototype,"isEnabled",void 0),A=e([a("esri.views.3d.webgl-engine.effects.ssao.SSAO")],A);const R=.5;export{A as SSAO,q 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.33/esri/copyright.txt for details.
4
4
  */
5
- class t{constructor(t=1/0,r=-1/0){this.near=t,this.far=r}set(t,r){this.near=t,this.far=r}union(t){null!=t&&(this.near=Math.min(this.near,t.near),this.far=Math.max(this.far,t.far))}within(t){return this.near<=t&&t<=this.far}static{this.zero=new t(0,0)}}export{t as DepthRange};
5
+ class t{constructor(t=1/0,i=-1/0){this.near=t,this.far=i}set(t,i){this.near=t,this.far=i}union(t){null!=t&&(this.near=Math.min(this.near,t.near),this.far=Math.max(this.far,t.far))}within(t){return this.near<=t&&t<=this.far}static{this.zero=new t(0,0)}static{this.infinite=new t}}export{t as DepthRange};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{releaseMaybe as e}from"../../../../core/maybe.js";import{c as t}from"../../../../chunks/vec42.js";import{ZEROS as i}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ViewportSize as r}from"./BindParameters.js";import{FramebufferBit as o,ColorAttachment1 as h}from"../../../webgl/enums.js";import{ColorFormat as c,DepthFormat as l}from"../../../webgl/formats.js";import{ensureAttachmentMaxSize as _}from"../../../webgl/FramebufferObject.js";class a{constructor(e){this._fbos=e,this._requiresEmission=!1,this._size=new r(0,0),this._clearColor=s()}dispose(){this._color=e(this._color),this.releaseDepth()}initialize(e,i,s,r){this._size.width=e,this._size.height=i,_(this._size,this._fbos.rctx.parameters.maxTextureSize);const o=this._color;return this._color=null,this.releaseDepth(),this._requiresEmission=r,t(this._clearColor,s),o}releaseDepth(){this._color?.detachDepth(),this._depth=e(this._depth)}update(e){const t=this._ensureColor();t.attachDepth(this.depth),this._color=e(t)}bind(){const{rctx:e}=this._fbos,t=null==this._color;this.color.attachDepth(this.depth),e.bindFramebuffer(this.color.fbo),t&&(e.setClearStencil(0),e.setClearColor(this._clearColor[0],this._clearColor[1],this._clearColor[2],this._clearColor[3]),e.clear(o.COLOR|o.DEPTH|o.STENCIL),this._requiresEmission&&e.clearBuffer(1,i))}_acquireColor(){return this._requiresEmission?this._fbos.acquire(this._size.width,this._size.height,"acquired-color").acquireColor(h,c.RGBA16F,"emissive"):this._fbos.acquire(this._size.width,this._size.height,"acquired-color")}_acquireDepth(){return this._fbos.acquireDepth(l.DEPTH24_STENCIL8_TEXTURE,this._size.width,this._size.height,"depth")}get size(){return this._size}get color(){return this._ensureColor()}get depth(){return this._depth??=this._acquireDepth(),this._depth}_ensureColor(){return this._color??=this._acquireColor(),this._color}}export{a as MainFramebuffer};
5
+ import{releaseMaybe as e}from"../../../../core/maybe.js";import{c as t}from"../../../../chunks/vec42.js";import{ZEROS as i}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ColorFormat as r,DepthTextureFormat as o}from"../core/FBOCacheFormats.js";import{ViewportSize as h}from"./BindParameters.js";import{FramebufferBit as c,ColorAttachment1 as l}from"../../../webgl/enums.js";import{ensureAttachmentMaxSize as _}from"../../../webgl/FramebufferObject.js";class a{constructor(e){this._fbos=e,this._requiresEmission=!1,this._size=new h(0,0),this._clearColor=s()}dispose(){this._color=e(this._color),this.releaseDepth()}initialize(e,i,s,r){this._size.width=e,this._size.height=i,_(this._size,this._fbos.rctx.parameters.maxTextureSize);const o=this._color;return this._color=null,this.releaseDepth(),this._requiresEmission=r,t(this._clearColor,s),o}releaseDepth(){this._color?.detachDepth(),this._depth=e(this._depth)}update(e){const t=this._ensureColor();t.attachDepth(this.depth),this._color=e(t)}bind(){const{rctx:e}=this._fbos,t=null==this._color;this.color.attachDepth(this.depth),e.bindFramebuffer(this.color.fbo),t&&(e.setClearStencil(0),e.setClearColor(this._clearColor[0],this._clearColor[1],this._clearColor[2],this._clearColor[3]),e.clear(c.COLOR|c.DEPTH|c.STENCIL),this._requiresEmission&&e.clearBuffer(1,i))}_acquireColor(){return this._requiresEmission?this._fbos.acquire(this._size.width,this._size.height,"acquired-color").acquireColor(l,r.RGBA16FLOAT,"emissive"):this._fbos.acquire(this._size.width,this._size.height,"acquired-color")}_acquireDepth(){return this._fbos.acquireDepth(o.DEPTH24_STENCIL8,this._size.width,this._size.height,"depth")}get size(){return this._size}get color(){return this._ensureColor()}get depth(){return this._depth??=this._acquireDepth(),this._depth}_ensureColor(){return this._color??=this._acquireColor(),this._color}}export{a as MainFramebuffer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{unitRGBAFromColor as i}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{clamp as s,lerp as a}from"../../../../core/mathUtils.js";import{removeMaybe as n,abortMaybe as h,destroyMaybe as o,releaseMaybe as d}from"../../../../core/maybe.js";import{throwIfAborted as _}from"../../../../core/promiseUtils.js";import{watch as l,syncAndInitial as p,initial as u,sync as m}from"../../../../core/reactiveUtils.js";import{signal as c}from"../../../../core/signal.js";import{Milliseconds as g}from"../../../../core/time.js";import{property as f}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import{subclass as b}from"../../../../core/accessorSupport/decorators/subclass.js";import{equals as T,invert as E,multiply as A}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as R,create as P}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as S}from"../../../../chunks/vec42.js";import{ZEROS as I}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{fromValues as C,ZEROS as w}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as N}from"../../../../geometry/support/Indices.js";import{RenderCategory as D,InternalRenderCategory as O}from"../../webgl.js";import{debugFlags as y}from"../../support/debugFlags.js";import{FBOCache as x,defaultWebGLFBO as H}from"../core/FBOCache.js";import{RenderPassManager as L}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as M,isColorOrColorEmission as F}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as U}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{distanceFadeEnd as v}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as G}from"../effects/RenderNodes.js";import{RenderPluginManager as q}from"../effects/RenderPluginManager.js";import{Blit as V}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as j,renderHighlightBuffer as B}from"../effects/highlight/Highlight.js";import{OITBlend as Q}from"../effects/transparency/OITBlend.js";import{AnimationTimer as W}from"./AnimationTimer.js";import{AnimationTimeStep as k}from"./AnimationTimeStep.js";import{RenderRequestType as z}from"./basicInterfaces.js";import{BoundingInfo as X}from"./BoundingInfo.js";import{DepthRange as Y}from"./DepthRange.js";import{depthRangeFromScene as K}from"./depthRangeUtils.js";import{hudFragmentOpacityParameters as J}from"./hudFragmentOpacityParameters.js";import{MainFramebuffer as Z}from"./MainFramebuffer.js";import{RenderOccludedFlag as $}from"./Material.js";import{OITPass as ee}from"./OITPass.js";import{RenderContext as te,defaultRenderOccludedMask as re}from"./RenderContext.js";import{RendererBase as ie}from"./RendererBase.js";import{RendererTarget as se}from"./rendererUtils.js";import{setupFeatureDefaults as ae,RenderFeature as ne}from"./RenderFeature.js";import{RenderPluginInput as he}from"./RenderPluginInput.js";import{RenderSlot as oe}from"./RenderSlot.js";import{ShadowAccumulator as de}from"./ShadowAccumulator.js";import{ShadowMap as _e,SnapshotSlot as le}from"./ShadowMap.js";import pe from"./SliceHelper.js";import{Transparency as ue}from"./edgeRendering/interfaces.js";import{MergedRenderer as me}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as ce}from"../parts/renderUtils.js";import{RendererPerformanceInfo as ge,PerformanceCategory as fe}from"../statistics/RendererPerformanceInfo.js";import{RenderState as be}from"../../../support/RenderState.js";import{PixelFormat as Te,PixelType as Ee,DepthStencilAttachment as Ae,FramebufferBit as Re,ColorAttachment1 as Pe,ColorAttachment2 as Se}from"../../../webgl/enums.js";import{DepthFormat as Ie,ColorFormat as Ce}from"../../../webgl/formats.js";let we=class extends ie{constructor(e,t,r,s,a,n){super({stage:e}),this._techniques=r,this._rctx=s,this._compositingHelper=a,this._requestRender=n,this._pluginsHas={hudElements:!1,water:!1},this.renderPassManager=new L,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=C(0,0,0,1),this._sliceHelper=new pe,this._blit=null,this._oitblend=null,this._state=c(be.IDLE),this._highQualityTransparencyEnabled=!0,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new k,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=c(0),this._lastFrameTime=g(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new he,this._releaseNormals=e=>{e.some((({name:e})=>"normals"===e))&&this._pluginInput.release("normals")},this._debugNeedsDepth=!1,this.fboCache=new x(s),this._renderStateFeatures=c(ae(!has("disable-feature:high-quality-idle"),e.view.qualityProfile)),this._framebuffer=new Z(this.fboCache),this.performanceInfo=new ge(this._rctx),this._shadowMap=new _e(this.fboCache,e.viewingMode),this._shadowAccumulator=new de(this.fboCache,r,e,(e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t}),((t,r,i)=>{const s=e.view.qualitySettings.maximumPixelRatio;t.shadowMap.start(t.camera,r,i,!0,s),this._renderShadowCascades(M.Shadow,t.shadowMap),t.shadowMap.finish(),t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.contentCamera)}),n),this._renderContext=new te(this._rctx,this._shadowMap,r),this._nodes=new G(this._renderContext),this._plugins=new q({renderContext:this._renderContext,techniques:r,materials:t,requestRender:n,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this.addHandles([l((()=>e.view.state.camera),(()=>n()),p),l((()=>y.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(ue.TRANSPARENT):()=>{},n()}),u),l((()=>e.view.environment.background?.color),(e=>{const t=e?i(e):w;S(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()}),p),l((()=>e.view.state.camera.relativeElevation),(e=>this._inGlobeView=(e??1/0)>=v),p),l((()=>this._bindParameters.clouds.fadeFactor),(()=>this._bindParameters.fadeLighting()),m),l((()=>this._bindParameters.clouds.data?.state),(()=>n()),m),l((()=>e.view.state.highlights),(e=>{this._bindParameters.highlights=e,n()}),u)])}destroy(){this._gpuTimerHandle=n(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.dispose(),this._loadEdgeViewTask=h(this._loadEdgeViewTask),this._edgeView=o(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),this._plugins.destroy(),this._blit=null,this._oitblend=null,X.prune(),me.prune(),N()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _framebufferSize(){return this._framebuffer.size}updateRenderFeatures(e=null,t=!has("disable-feature:high-quality-idle")){this._renderStateFeatures.value=ae(t,e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate((i=>i.set(t,e,r))),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(ne.HighQualityTransparency)}get hasReflections(){return this._pluginsHas.water&&(this._ssrEnabled||this.isFeatureEnabled(ne.WaterReflection))}get _hasHighlights(){return this._plugins.produces(M.Highlight,oe.OPAQUE_MATERIAL,oe.TRANSPARENT_MATERIAL,oe.DRAPED_MATERIAL,oe.HUD_MATERIAL,oe.LABEL_MATERIAL)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(M.Highlight,oe.HUD_MATERIAL,oe.LABEL_MATERIAL)}get hasSSAO(){return(this.stage.view.qualitySettings.ambientOcclusion||this.isFeatureEnabled(ne.SSAO))&&!this._inGlobeView}get hasSMAA(){return this.stage.view.qualitySettings.antialiasingEnabled||this.isFeatureEnabled(ne.Antialiasing)}get fullResolutionAtmosphere(){return this.stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(ne.HighResolutionAtmosphere)}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=d(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.depth=d(this._bindParameters.depth),this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility)}get updating(){return this._loadEdgeViewTask&&!this._loadEdgeViewTask.finished||this._edgeView?.updating||this._shadowAccumulator.running||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=r((async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");_(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this.stage.view.renderSpatialReference,viewingMode:this.stage.view.stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:Ge(this.stage.view.resourceController)});return this.addHandles(l((()=>r.updating),(()=>this._requestRender()),m)),this._requestRender(),this._edgeViewCallbacks.forEach((e=>e(r))),this._edgeViewCallbacks.length=0,r}))),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&T(this._bindParameters.ssr.reprojectionMatrix,R)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:r}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&t.maxCascades!==e.shadowMapMaxCascades&&(t.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const t="virtual"!==e.environment.lighting.type;r.enableFillLights!==t&&(r.enableFillLights=t,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}set slicePlane(e){this._sliceHelper.plane!==e&&(this._sliceHelper.plane=e,this._requestRender())}get plugins(){return this._plugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}commit(e,t){return this._isRendering&&console.warn("Renderer.modify called while rendering"),!!super.commit(e,t,this._plugins.context)&&(this.updateHasFlags(),!0)}rendererAdded(e){this._plugins.add(e)}rendererRemoved(e){this._plugins.remove(e)}updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(M.Color,...Le),has.water=this._plugins.produces(M.Normal,oe.DRAPED_WATER),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new W(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const r=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?n(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,r=se.Default,i=!1){try{return this._isRendering=!0,this._render(e,t,r,i)}catch(s){console.error(`Exception during rendering: ${s}`)}finally{this._isRendering=!1}return new ce(this._pluginInput.get(D.FINAL),null)}_updateHUDOccludedFragmentOpacity(e,t){const{idleOpacity:r,navigatingOpacity:i,maxDelta:n,tiltFadeStart:h,tiltFadeEnd:o,altitudeStart:d,altitudeEnd:_}=J,l=this.stage.view,p=l.stateManager.camera,u=l.qualitySettings.fadeDuration,m=e===be.IDLE?r:i,c=s((p.tilt-h)/(o-h),0,1),g=s(((p.position.z??0)-d)/(_-d),0,1),f=a(a(1,m,c),1,g),b=this._bindParameters.hudOccludedFragmentOpacity;if(u<=0||b===f||0===this._lastFrameTime||this._lastFrameTime>t)return this._bindParameters.hudOccludedFragmentOpacity=f,void(this._lastFrameTime=t);const T=t-this._lastFrameTime;this._lastFrameTime=t;const E=Math.max(1-r,Math.abs(r-i)),A=Math.min(E*T/u,n);A>=Math.abs(f-b)?this._bindParameters.hudOccludedFragmentOpacity=f:(this._bindParameters.hudOccludedFragmentOpacity=b+Math.sign(f-b)*A,this._requestRender())}_render(e,t,r=se.Default,i){this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=r===se.Default,this._disposeBindBuffers();const{camera:s,contentCamera:a,mode:n,alignPixelEnabled:h}=e;this._state.value=n;const o=this._nodes.produces("magnifier-color"),_=this._nodes.produces(D.FINAL),l=this._nodes.require("emissive",O.TRANSPARENT_ENVIRONMENT,D.COMPOSITE,D.FINAL)>0&&this._plugins.hasEmissions,p=l?M.ColorEmission:M.Color;this._renderContext.time=t,this._renderContext.output=p,this._bindParameters.oitPass=ee.NONE,this._bindParameters.alignPixelEnabled=h,this._bindParameters.decorations=!i,this._bindParameters.mainDepth=null,this._bindParameters.slicePlane=this._sliceHelper.plane,this._bindParameters.viewshedEnabled=this._nodes.produces(O.VIEWSHED),this._renderOverlay(t),s.setGLViewport(this._rctx);const u=this._framebuffer,m=u.initialize(s.fullWidth,s.fullHeight,this._backgroundColor,l);this.hasReflections?(m?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=m):m?.release(),this._ensureBindParametersCamera(s,a),this._updateHUDOccludedFragmentOpacity(n,t),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!i;const c=this._highQualityTransparency&&this._hasTransparentTerrain,g=this._plugins.produces(M.Color,...xe);this._precompilePrepasses(),this.performanceInfo.advance(fe.PREPARE);const f=this._computeDepthRange(s);this._renderShadowMap(s,this._bindParameters.lighting.mainLight.direction,f),this._ensureBindParametersCamera(s,a),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(f,s,a),this._ensureBindParametersSSR(t),this._precompileShaders(c,g,p),this._renderContext.output=p,u.bind(),this._bindParameters.mainDepth=u.depth.attachment;const b=this.plugins.produces(M.Color,...ye);b&&this._renderOpaqueGeometry(),u.update((e=>this._renderNodes(D.OPAQUE,e,b))),this.fboCache.debugCallback?.(D.OPAQUE,u.color.fbo),u.update((e=>this._renderNodes(O.OPAQUE_ENVIRONMENT,e))),this.fboCache.debugCallback?.(O.OPAQUE_ENVIRONMENT,u.color.fbo),this._renderTerrainDepth(c),this._renderEdges(ue.OPAQUE),u.bind(),this._renderPlugins(oe.VOXEL,fe.VOXEL),this._renderHiddenTransparentEdges(),g&&(this._oitEnabled?this._renderOIT(Ne.Geometry,p):this._renderTransparentGeometry()),u.update((e=>this._renderNodes(D.TRANSPARENT,e,g))),this.fboCache.debugCallback?.(D.TRANSPARENT,u.color.fbo),this._renderGeometryDepth(c),this._renderHUDVisibility(),c||this._plugins.render(this._pluginInput,oe.LINE_CALLOUTS),this._renderEdges(ue.TRANSPARENT);const T=this._hasTransparentTerrain?this._renderTransparentTerrain():null;T&&(this.performanceInfo.advance(fe.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(c?this._renderLineCallouts(U.Occluded):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositingHelper.compositeHUD(this._bindParameters,T.getTexture())),this._renderHUD(U.Occluded,u.color,p))),this._bindParameters.cullAboveTerrain=!1,T&&(u.bind(),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,T.getTexture()),T.release(),c&&(this._renderEdges(ue.OPAQUE),g&&(this._oitEnabled?this._renderOIT(Ne.Geometry,p):this._renderTransparentGeometry(),this.performanceInfo.advance(fe.TRANSPARENT)),this._renderEdges(ue.TRANSPARENT))),this._bindParameters.ssao=d(this._bindParameters.ssao),c&&this._renderLineCallouts(U.NotOccluded),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment(),this._pluginInput.set(O.FOCUSAREA,this._renderFocusAreaGeometry()),u.update((e=>this._renderNodes(O.TRANSPARENT_ENVIRONMENT,e))),u.update((e=>this._renderNodes(O.VIEWSHED,e))),u.update((e=>this._renderNodes(O.LASERLINES,e))),u.update((e=>this._renderNodes(O.FOCUSAREA_COLOR,e))),u.update((e=>this._renderNodes(O.OCCLUDED,e))),this._pluginInput.set("highlights",this._renderHighlightPrepass());const E=r===se.ObjectAndLayerID?this._renderObjectAndLayerIdColor():null;u.update((e=>this._renderNodes(D.COMPOSITE,e))),this._pluginInput.release(O.FOCUSAREA);const A=!(r!==se.Default||_||o&&!i),R=this._pluginInput.get(D.COMPOSITE),P=A?H:this.fboCache.acquire(R.fbo.width,R.fbo.height,O.ANTIALIASING),S=this._nodes.produces(O.ANTIALIASING)?this._renderNodes(O.ANTIALIASING,P):this._blitFBO(R,P,!1);let I;this._pluginInput.set(O.ANTIALIASING,S),this._hasHUDHighlights?(this._renderHUD(U.NotOccluded,S,p),I=this._renderNodes(O.HIGHLIGHTS,S)):(I=this._renderNodes(O.HIGHLIGHTS,S),this._renderHUD(U.NotOccluded,I,p));const C=this._renderNodes(O.MAGNIFIER,I);return o&&!i&&r===se.Default&&!_&&this._blitFBO(C),_?(C.attachDepth(u.depth),this._blitFBO(this._renderNodes(D.FINAL,C)),C.detachDepth()):this._pluginInput.set(D.FINAL,C),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),u.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),r!==se.Default&&(this._releaseFBOs(),this._disposeOffscreenBuffers()),new ce(this._pluginInput.get(D.FINAL),E)}_precompileShaders(e,t,r){++this._plugins.context.techniques.precompiling,this._renderContext.output=r,this._precompileOpaqueGeometry(),this._nodes.precompile(O.OPAQUE_ENVIRONMENT),this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,this._renderContext.output=M.Depth,this._plugins.precompile(oe.TRANSPARENT_TERRAIN),e&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._renderContext.output=r,this._plugins.precompile(oe.TRANSPARENT_TERRAIN),t&&(this._precompileTransparentGeometry(),this._hasTransparentTerrain&&(this._bindParameters.cullAboveTerrain=!1,this._precompileTransparentGeometry(),this._bindParameters.cullAboveTerrain=e)),this._nodes.precompile(O.FOCUSAREA),this._needsHUDVisibility&&this._plugins.precompile(oe.OCCLUSION_PIXELS),this._plugins.precompile(oe.LINE_CALLOUTS),this._precompileHUD(U.Occluded),this._bindParameters.terrainDepthTest=!1,this._bindParameters.cullAboveTerrain=!1,this._nodes.precompile(O.VIEWSHED,O.LASERLINES,O.FOCUSAREA_COLOR,O.OCCLUDED,O.ANTIALIASING,O.HIGHLIGHTS);const i=this._bindParameters;i.highlightMixTexture=i.highlights.length>1?this._rctx.emptyTexture:null,this._precompileHUD(U.NotOccluded),this._hasHighlights&&(i.highlights.forEach(((e,t)=>{i.highlightLevel=t,this._precompileAllGeometry(M.Highlight)})),i.highlightLevel=null),i.highlightMixTexture=null,this._nodes.precompile(D.COMPOSITE,O.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(oe.TRANSPARENT_MATERIAL_WITHOUT_DEPTH),--this._plugins.context.techniques.precompiling}_renderFocusAreaGeometry(){if(!this._nodes.produces(O.FOCUSAREA))return null;const{width:e,height:t}=this._framebufferSize;let r=this.fboCache.acquire(e,t,O.FOCUSAREA);return r=this._nodes.render(r,this._pluginInput),this.performanceInfo.advance(fe.FOCUS_AREA_MASK),r}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._renderContext.output;++this._techniques.precompiling;const t=this._framebufferSize;let r=this.fboCache.acquire(t.width,t.height,"olid");return r.acquireDepth(Ie.DEPTH24_STENCIL8_TEXTURE),r=this._nodes.render(r,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(fe.OBJECT_AND_LAYER_ID_COLOR),this._renderContext.output=e,r}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=e===z.BACKGROUND;if(r||t){const e=r?this.performanceInfo.elapsedTime:0;let i=0;t?i=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const s=Math.max(e,i);this._animationTimestep.frame(s,r)}}readMainDepth(e,t){const{mainDepth:r,camera:i}=this._bindParameters;if(!r)return;const s=this.fboCache.acquire(this._framebufferSize.width,this._framebufferSize.height,"linear-depth");this._rctx.bindFramebuffer(s.fbo),i.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(w),this._compositingHelper.blitDepthToLinearDepth(this._bindParameters,r),this._rctx.setScissorTestEnabled(!1),this._rctx.setScissorRect(0,0,this._rctx.gl.canvas.width,this._rctx.gl.canvas.width),s.fbo?.readPixels(e[0],e[1],e[2],e[3],Te.RGBA,Ee.UNSIGNED_BYTE,t),s.release()}readHUDVisibility(e,t,r,i,s){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,i,Te.RGBA,Ee.UNSIGNED_BYTE,s)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"edges"),s=()=>t.render(this._bindParameters,e),a=this._bindParameters.geometryDepth;this.renderToTargets(s,i,a??this._framebuffer.depth,w),this._framebuffer.bind(),this._compositingHelper.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(e===ue.OPAQUE?fe.OPAQUE_EDGES:fe.TRANSPARENT_EDGES)}_renderOverlay(e){this._bindParameters.overlay=this.overlay?.render(e),this._bindParameters.overlay&&this.performanceInfo.advance(fe.OVERLAY)}_renderShadowMap(e,t,r){if(!this.shadowsEnabled)return;const i=this._shadowMap;i.start(e,t,r,this.isFeatureEnabled(ne.HighResolutionShadows),this.stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(M.ShadowHighlight,this._shadowMap),i.moveSnapshot(le.Highlight),this._renderShadowCascades(M.ShadowExcludeHighlight,this._shadowMap),i.copySnapshot(le.ExcludeHighlight),this._renderShadowCascades(M.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(M.Shadow),i.finish(),e.setGLViewport(this._rctx),this.performanceInfo.advance(fe.SHADOW_MAP)}_precompileShadowCascades(e){for(const t of this._shadowMap.cascades)t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.camera),this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e)}get _needsDepth(){return this._plugins.consumes(M.Depth)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._needsShadowAccumulation||this._debugNeedsDepth}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");if(e){const t=this._needsDepth?e.getAttachment(Ae):null;t?.retain(),this._pluginInput.set(O.SSAO,this._renderSSAO()),this._renderGeometryWithoutNormalsDepth(t)}else this._renderAllGeometryDepth()}_renderGeometryWithoutNormalsDepth(e){if(!this._needsDepth||!e)return void(this._bindParameters.depth=d(this._bindParameters.depth));const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"depth");r.attachDepth(e),e.release(),this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(Re.STENCIL),this._renderGeometryWithoutNormals(M.Depth),d(this._bindParameters.depth),this._bindParameters.depth=r.obtainDepthTexture(),r.release(),this.performanceInfo.advance(fe.DEPTH)}_renderAllGeometryDepth(){if(!this._needsDepth)return void(this._bindParameters.depth=d(this._bindParameters.depth));const e=this._framebufferSize,t=this.fboCache.acquire(e.width,e.height,"depth",Ie.DEPTH24_STENCIL8_TEXTURE);this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(Re.DEPTH|Re.STENCIL),this.renderAllGeometry(M.Depth),d(this._bindParameters.depth),this._bindParameters.depth=t.obtainDepthTexture(),t.release(),this.performanceInfo.advance(fe.DEPTH)}_renderTerrainDepth(e){if(this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,!e)return void(this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth));const t=this._renderContext.output;this._renderContext.output=M.Depth;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"terrain depth",Ie.DEPTH24_STENCIL8_TEXTURE);this._rctx.bindFramebuffer(i.fbo),this._rctx.clear(Re.DEPTH|Re.STENCIL),this._renderTransparentTerrain(),d(this._bindParameters.terrainDepth),this._bindParameters.terrainDepth=i.obtainDepthTexture(),this._renderContext.output=t,i.release()}_renderGeometryDepth(e){if(!e)return void(this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth));const t=this._renderContext.output,{width:r,height:i}=this._framebufferSize,s=this.fboCache.acquire(r,i,"geometry depth",Ie.DEPTH24_STENCIL8_TEXTURE);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(Re.DEPTH|Re.STENCIL),this._renderOpaqueAndTransparentGeometry(M.Depth),this._renderContext.output=t,d(this._bindParameters.geometryDepth),this._bindParameters.geometryDepth=s.obtainDepthTexture(),s.release()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowAccumulation}_computeDepthRange(e){if(!this._needsDepthRange)return Y.zero;const t=K(e,this._plugins.plugins,this.stage.layers);return t.union(this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}get _normalsRequired(){const e=this._nodes.require("normals",D.FINAL,D.COMPOSITE,D.OPAQUE,D.TRANSPARENT,O.VIEWSHED,O.LASERLINES);return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(M.Normal),this._needsDepth&&this._precompileAllGeometry(M.Depth),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(M.ShadowHighlight),this._precompileShadowCascades(M.ShadowExcludeHighlight),this._precompileShadowCascades(M.ShadowHighlight)):this._precompileShadowCascades(M.Shadow)),this._needsShadowAccumulation&&this._precompileAllGeometry(M.Shadow)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"normals",Ce.RGBA8);r.acquireDepth(Ie.DEPTH24_STENCIL8_TEXTURE),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(w,!0,!0),this._renderGeometryWithNormals(M.Normal);const i=this._nodes.optional("normals",D.FINAL,D.COMPOSITE,D.OPAQUE,D.TRANSPARENT,O.VIEWSHED);return r.retain(e+i-1),this.performanceInfo.advance(fe.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return void e?.detachDepth();H.setName(O.SSAO);const t=this._nodes.render(H,this._pluginInput);return this._bindParameters.ssao=t,e.detachDepth(),this._pluginInput.release("normals"),this.performanceInfo.advance(fe.SSAO),t}_precompileAllGeometry(e){const t=this._renderContext.output;this._renderContext.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(oe.TRANSPARENT_TERRAIN),this._renderContext.output=t}renderAllGeometry(e){this._renderContext.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentTerrain()}precompileSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const r of t)this._renderContext.renderOccludedMask=r,this.precompileSlots(e,...He);this._renderContext.renderOccludedMask=re}renderSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.forAll((e=>{const t=e.acquireTechniques(this._renderContext);t&&e.render(this._renderContext,t,this._pluginInput)}))}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>$.Occlude&&this._plugins.render(this._pluginInput,oe.OCCLUDED_TERRAIN),this.renderSlots(e,...He),this._renderContext.renderOccludedMask=re}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(this._pluginInput,oe.HUD_MATERIAL)}precompileViewshedShadowMap(){this._precompileAllGeometry(M.ViewshedShadow)}renderViewshedShadowMap(e){const{camera:t,contentCamera:r}=this._bindParameters,i=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(M.ViewshedShadow),this._ensureBindParametersCamera(t,r),this._bindParameters.camera.setGLViewport(this._rctx),this._renderContext.output=i}_renderOpaqueAndTransparentGeometry(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithNormals(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,...De),this._renderTransparentTerrain()}_renderGeometryWithoutNormals(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,...Oe)}_precompileOpaqueGeometry(){this._plugins.precompile(...ye)}_renderOpaqueGeometry(){this._plugins.render(this._pluginInput,...ye)}_renderTransparentGeometry(){this._plugins.render(this._pluginInput,...xe)}get _hasTransparentTerrain(){return this._plugins.produces(M.Color,oe.TRANSPARENT_TERRAIN)}_renderTransparentTerrain(){const e=()=>this._plugins.render(this._pluginInput,oe.TRANSPARENT_TERRAIN);if(!F(this._renderContext.output))return void e();const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"transparent terrain");return this.renderToTargets(e,r,this._framebuffer.depth,w),r}get _needsHUDVisibility(){return this._plugins.produces(this._renderContext.output,oe.OCCLUSION_PIXELS)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility));const{width:e,height:t}=this._framebufferSize;let r=this._bindParameters.hudVisibility;r?.fbo?.width===e&&r?.fbo?.height===t||(r?.release(),r=this.fboCache.acquire(e,t,"hud visibility",Ce.RGBA4),this._bindParameters.hudVisibility=r);const i=this._bindParameters.geometryDepth;r.attachDepth(i||this._framebuffer.depth),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(this._pluginInput,oe.OCCLUSION_PIXELS),r.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(fe.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===U.Occluded){const e=()=>this._plugins.render(this._pluginInput,oe.LINE_CALLOUTS),t=this._framebufferSize,r=this.fboCache.acquireDepth(Ie.DEPTH16_RENDERBUFFER,t.width,t.height,"line callouts");this.renderToTargets(e,this._framebuffer.color,r,void 0,!0,!0),r.release()}else this._plugins.render(this._pluginInput,oe.LINE_CALLOUTS)}_precompileHUD(e){if(this._precompileHUDOutput(e),this._hasHighlights){const t=this._renderContext.output;this._renderContext.output=M.Highlight,this._precompileHUDOutput(e),this._renderContext.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this._oitEnabled&&F(this._renderContext.output)?(this._bindParameters.oitPass=ee.ColorAlpha,this._plugins.precompile(...Le),this._bindParameters.oitPass=ee.FrontFace,this._plugins.precompile(...Le),this._bindParameters.oitPass=ee.NONE):this._plugins.precompile(...Le),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t,r){if(this._pluginsHas.hudElements){if(this._oitEnabled){const i=this._renderOIT(Ne.HUD,r,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,i.getTexture()),i.release()}else if(this._renderContext.output=r,e===U.Occluded){const t=()=>this._renderHUDElements(e),r=this._framebufferSize,i=this.fboCache.acquireDepth(Ie.DEPTH16_RENDERBUFFER,r.width,r.height,"hud");this.renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(Ie.DEPTH16_RENDERBUFFER),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(e===U.Occluded?fe.HUD_OCCLUDED:fe.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(this._pluginInput,...Le)}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(M.ShadowHighlight,oe.OPAQUE_MATERIAL)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:r}=this,i=this._framebufferSize,{highlights:s}=r,a=e.acquire(i.width,i.height,"highlights",s.length>j?Ce.RG8UI:Ce.R8UI);a.acquireDepth(Ie.DEPTH24_STENCIL8_TEXTURE),t.bindFramebuffer(a.fbo);const{gl:n}=t;return n.clearBufferuiv(n.COLOR,0,[0,0,0,0]),this._renderContext.output=M.Highlight,t.bindFramebuffer(a.fbo),B(t,e,i,r,(()=>this._renderHighlightGeometries())),this.performanceInfo.advance(fe.HIGHLIGHTS),a}_renderHighlightGeometries(){this._plugins.render(this._pluginInput,...Me),this._rctx.clear(Re.DEPTH),this._renderHUDElements(U.Both)}get _needsShadowAccumulation(){return this._shadowAccumulator.accumulating}_renderShadowAccumulation(e,t,r){this._needsShadowAccumulation&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,e,t,r)&&this.performanceInfo.advance(fe.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this._oitEnabled&&F(this._renderContext.output)?(this._bindParameters.oitPass=ee.ColorAlpha,this._plugins.precompile(...xe),this._bindParameters.oitPass=ee.FrontFace,this._plugins.precompile(...xe),this._bindParameters.oitPass=ee.NONE):this._plugins.precompile(...xe)}_renderOIT(e,t,r=U.Both){const i=e===Ne.HUD,s=this._framebufferSize,a=i?this.fboCache.acquire(s.width,s.height,"oit hud composite"):null,n=i?()=>this._renderHUDElements(r):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._renderContext.output;this._renderContext.output=t,h.oitPass=ee.ColorAlpha;const d=a?"oit hud color+alpha":"oit color+alpha",_=t===M.ColorEmission,l=this.fboCache.acquire(s.width,s.height,d,_?Ce.RGBA16F:Ce.RGBA16F_NEAREST);_&&l.acquireColor(Pe,Ce.RGBA16F,"emissive"),l.acquireColor(_?Se:Pe,Ce.R16F),a||l.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(l.fbo),this._rctx.clearFramebuffer([0,0,0,1]),_&&this._rctx.clearBuffer(1,I),n(),l.detachDepth(),h.oitPass=ee.FrontFace;const p=this.fboCache.acquire(s.width,s.height,a?"oit hud front":"oit front");return _&&p.acquireColor(Pe,Ce.RGBA16F,"emissive"),a?p.acquireDepth(Ie.DEPTH16_RENDERBUFFER):p.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(p.fbo),this._rctx.clearFramebuffer(w,!!a),n(),p.detachDepth(),h.oitPass=ee.NONE,a?(this._rctx.bindFramebuffer(a.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(Re.COLOR)):this._framebuffer.bind(),this._oitblend??=new Q(this._techniques),this._oitblend.blend(this._rctx,l,p,h,_),a?.detachDepth(),p.release(),l.release(),this._renderContext.output=o,a}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(fe.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(this._pluginInput,oe.TRANSPARENT_MATERIAL_WITHOUT_DEPTH),this.performanceInfo.advance(fe.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderPlugins(e,t){this._plugins.produces(this._renderContext.output,e)&&(this._plugins.render(this._pluginInput,e),this.performanceInfo.advance(t))}_renderNodes(e,t,r=!1){if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;const i=this._nodes.render(t,this._pluginInput,this._releaseNormals);return this.performanceInfo.advance(e),i}_blitFBO(e,t=H,r=!0){return this._blit??=new V(this._techniques),this._blit.blit(this._rctx,e,t,this._bindParameters),this._pluginInput.set(e.name,t),r&&e.release(),t}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=R:(E(Ue,this._bindParameters.camera.viewMatrix),E(Fe,this._bindParameters.camera.projectionMatrix),A(ve,Ue,Fe),A(ve,this._renderContext.lastFrameCamera.viewMatrix,ve),A(ve,this._renderContext.lastFrameCamera.projectionMatrix,ve),this._reprojectionMatrix=ve);const t=this.stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=R,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,r,i){this._bindParameters.updateLighting(e,t,r,i),this._requestRender(z.UPDATE)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}renderToTargets(e,t,r,i,s=!1,a=!1){t.attachDepth(r),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(i,s,a),e(),t.detachDepth()}get test(){}};var Ne;e([f({readOnly:!0})],we.prototype,"fullResolutionAtmosphere",null),e([f()],we.prototype,"_edgeView",void 0),e([f()],we.prototype,"updating",null),we=e([b("esri.views.3d.webgl-engine.lib.Renderer")],we),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(Ne||(Ne={}));const De=[oe.INTEGRATED_MESH,oe.OPAQUE_TERRAIN,oe.OPAQUE_MATERIAL,oe.TRANSPARENT_MATERIAL],Oe=[oe.OPAQUE_MATERIAL_WITHOUT_NORMALS,oe.TRANSPARENT_MATERIAL_WITHOUT_NORMALS],ye=[oe.INTEGRATED_MESH,oe.OPAQUE_TERRAIN,oe.OPAQUE_MATERIAL,oe.OPAQUE_MATERIAL_WITHOUT_NORMALS],xe=[oe.TRANSPARENT_MATERIAL,oe.TRANSPARENT_MATERIAL_WITHOUT_NORMALS],He=[oe.OPAQUE_MATERIAL,oe.TRANSPARENT_MATERIAL,oe.TRANSPARENT_MATERIAL_WITHOUT_DEPTH],Le=[oe.LINE_CALLOUTS_HUD_DEPTH,oe.HUD_MATERIAL,oe.LABEL_MATERIAL],Me=[oe.TRANSPARENT_MATERIAL,oe.TRANSPARENT_MATERIAL_WITHOUT_NORMALS,oe.OPAQUE_MATERIAL,oe.OPAQUE_MATERIAL_WITHOUT_NORMALS,oe.TRANSPARENT_TERRAIN,oe.INTEGRATED_MESH,oe.OPAQUE_TERRAIN],Fe=P(),Ue=P(),ve=P();function Ge(e){return t=>e.immediate.schedule(t)}export{we as Renderer};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{unitRGBAFromColor as i}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{clamp as s,lerp as a}from"../../../../core/mathUtils.js";import{removeMaybe as n,abortMaybe as h,destroyMaybe as o,releaseMaybe as d}from"../../../../core/maybe.js";import{throwIfAborted as l}from"../../../../core/promiseUtils.js";import{watch as _,syncAndInitial as p,initial as u,sync as m}from"../../../../core/reactiveUtils.js";import{signal as c}from"../../../../core/signal.js";import{Milliseconds as g}from"../../../../core/time.js";import{property as f}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import{subclass as b}from"../../../../core/accessorSupport/decorators/subclass.js";import{equals as A,invert as T,multiply as E}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as P,create as R}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as S}from"../../../../chunks/vec42.js";import{ZEROS as I}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{fromValues as C,ZEROS as w}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as D}from"../../../../geometry/support/Indices.js";import{RenderCategory as N,InternalRenderCategory as O}from"../../webgl.js";import{innerAtmosphereFadeStart as y}from"../../environment/atmosphereUtils.js";import{minNearDistanceInMeters as x}from"../../state/NearFarHeuristic.js";import{debugFlags as H}from"../../support/debugFlags.js";import{FBOCache as L,defaultWebGLFBO as M}from"../core/FBOCache.js";import{DepthTextureFormat as v,ColorFormat as F,DepthRenderbufferFormat as U}from"../core/FBOCacheFormats.js";import{RenderPassManager as G}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as q,isColorOrColorEmission as V}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as j}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{distanceFadeEnd as B}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as Q}from"../effects/RenderNodes.js";import{RenderPluginManager as W}from"../effects/RenderPluginManager.js";import{Blit as k}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as z,renderHighlightBuffer as Y}from"../effects/highlight/Highlight.js";import{OITBlend as X}from"../effects/transparency/OITBlend.js";import{AnimationTimer as K}from"./AnimationTimer.js";import{AnimationTimeStep as J}from"./AnimationTimeStep.js";import{RenderRequestType as Z}from"./basicInterfaces.js";import{BoundingInfo as $}from"./BoundingInfo.js";import{DepthRange as ee}from"./DepthRange.js";import{depthRangeFromScene as te,DepthRangeMode as re}from"./depthRangeUtils.js";import{hudFragmentOpacityParameters as ie}from"./hudFragmentOpacityParameters.js";import{MainFramebuffer as se}from"./MainFramebuffer.js";import{RenderOccludedFlag as ae}from"./Material.js";import{OITPass as ne}from"./OITPass.js";import{RenderContext as he,defaultRenderOccludedMask as oe}from"./RenderContext.js";import{RendererBase as de}from"./RendererBase.js";import{RendererTarget as le}from"./rendererUtils.js";import{setupFeatureDefaults as _e,RenderFeature as pe}from"./RenderFeature.js";import{RenderPluginInput as ue}from"./RenderPluginInput.js";import{RenderSlot as me}from"./RenderSlot.js";import{ShadowAccumulator as ce}from"./ShadowAccumulator.js";import{ShadowMap as ge,SnapshotSlot as fe}from"./ShadowMap.js";import be from"./SliceHelper.js";import{Transparency as Ae}from"./edgeRendering/interfaces.js";import{MergedRenderer as Te}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as Ee}from"../parts/renderUtils.js";import{RendererPerformanceInfo as Pe,PerformanceCategory as Re}from"../statistics/RendererPerformanceInfo.js";import{RenderState as Se}from"../../../support/RenderState.js";import{PixelFormat as Ie,PixelType as Ce,DepthStencilAttachment as we,FramebufferBit as De,ColorAttachment1 as Ne,ColorAttachment2 as Oe}from"../../../webgl/enums.js";let ye=class extends de{constructor(e,t,r,s,a,n){super({stage:e}),this._techniques=r,this._rctx=s,this._compositingHelper=a,this._requestRender=n,this._pluginsHas={hudElements:!1,water:!1},this.renderPassManager=new G,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=C(0,0,0,1),this._sliceHelper=new be,this._blit=null,this._oitblend=null,this.sceneDepthRange=c(ee.infinite),this._state=c(Se.IDLE),this._highQualityTransparencyEnabled=!0,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new J,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=c(0),this._lastFrameTime=g(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new ue,this._releaseNormals=e=>{e.some((({name:e})=>"normals"===e))&&this._pluginInput.release("normals")},this._debugNeedsDepth=!1,this.fboCache=new L(s),this._renderStateFeatures=c(_e(!has("disable-feature:high-quality-idle"),e.view.qualityProfile)),this._framebuffer=new se(this.fboCache),this.performanceInfo=new Pe(this._rctx),this._shadowMap=new ge(this.fboCache,e.viewingMode),this._shadowAccumulator=new ce(this.fboCache,r,e,(e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t}),((t,r,i)=>{const s=e.view.qualitySettings.maximumPixelRatio;t.shadowMap.start(t.camera,r,i,!0,s),this._renderShadowCascades(q.Shadow,t.shadowMap),t.shadowMap.finish(),t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.contentCamera)}),n),this._renderContext=new he(this._rctx,this._shadowMap,r),this._nodes=new Q(this._renderContext),this._plugins=new W({renderContext:this._renderContext,techniques:r,materials:t,requestRender:n,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this.addHandles([_((()=>e.view.state.camera),(()=>n()),p),_((()=>H.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(Ae.TRANSPARENT):()=>{},n()}),u),_((()=>e.view.environment.background?.color),(e=>{const t=e?i(e):w;S(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()}),p),_((()=>e.view.state.camera.relativeElevation),(e=>this._inGlobeView=(e??1/0)>=B),p),_((()=>this._bindParameters.clouds.fadeFactor),(()=>this._bindParameters.fadeLighting()),m),_((()=>this._bindParameters.clouds.data?.state),(()=>n()),m),_((()=>e.view.state.highlights),(e=>{this._bindParameters.highlights=e,n()}),u)])}destroy(){this._gpuTimerHandle=n(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.dispose(),this._loadEdgeViewTask=h(this._loadEdgeViewTask),this._edgeView=o(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),this._plugins.destroy(),this._blit=null,this._oitblend=null,$.prune(),Te.prune(),D()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _framebufferSize(){return this._framebuffer.size}updateRenderFeatures(e=null,t=!has("disable-feature:high-quality-idle")){this._renderStateFeatures.value=_e(t,e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate((i=>i.set(t,e,r))),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(pe.HighQualityTransparency)}get hasReflections(){return this._pluginsHas.water&&(this._ssrEnabled||this.isFeatureEnabled(pe.WaterReflection))}get _hasHighlights(){return this._plugins.produces(q.Highlight,me.OPAQUE_MATERIAL,me.TRANSPARENT_MATERIAL,me.DRAPED_MATERIAL,me.HUD_MATERIAL,me.LABEL_MATERIAL)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(q.Highlight,me.HUD_MATERIAL,me.LABEL_MATERIAL)}get hasSSAO(){return(this.stage.view.qualitySettings.ambientOcclusion||this.isFeatureEnabled(pe.SSAO))&&!this._inGlobeView}get hasSMAA(){return this.stage.view.qualitySettings.antialiasingEnabled||this.isFeatureEnabled(pe.Antialiasing)}get fullResolutionAtmosphere(){return this.stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(pe.HighResolutionAtmosphere)}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=d(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.depth=d(this._bindParameters.depth),this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility)}get updating(){return this._loadEdgeViewTask&&!this._loadEdgeViewTask.finished||this._edgeView?.updating||this._shadowAccumulator.running||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=r((async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");l(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this.stage.view.renderSpatialReference,viewingMode:this.stage.view.stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:Be(this.stage.view.resourceController)});return this.addHandles(_((()=>r.updating),(()=>this._requestRender()),m)),this._requestRender(),this._edgeViewCallbacks.forEach((e=>e(r))),this._edgeViewCallbacks.length=0,r}))),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&A(this._bindParameters.ssr.reprojectionMatrix,P)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:r}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&t.maxCascades!==e.shadowMapMaxCascades&&(t.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const t="virtual"!==e.environment.lighting.type;r.enableFillLights!==t&&(r.enableFillLights=t,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}set slicePlane(e){this._sliceHelper.plane!==e&&(this._sliceHelper.plane=e,this._requestRender())}get plugins(){return this._plugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}commit(e,t){return this._isRendering&&console.warn("Renderer.modify called while rendering"),!!super.commit(e,t,this._plugins.context)&&(this.updateHasFlags(),!0)}rendererAdded(e){this._plugins.add(e)}rendererRemoved(e){this._plugins.remove(e)}updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(q.Color,...Ue),has.water=this._plugins.produces(q.Normal,me.DRAPED_WATER),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new K(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const r=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?n(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,r=le.Default,i=!1){try{return this._isRendering=!0,this._render(e,t,r,i)}catch(s){console.error(`Exception during rendering: ${s}`)}finally{this._isRendering=!1}return new Ee(this._pluginInput.get(N.FINAL),null)}_updateHUDOccludedFragmentOpacity(e,t){const{idleOpacity:r,navigatingOpacity:i,maxDelta:n,tiltFadeStart:h,tiltFadeEnd:o,altitudeStart:d,altitudeEnd:l}=ie,_=this.stage.view,p=_.stateManager.camera,u=_.qualitySettings.fadeDuration,m=e===Se.IDLE?r:i,c=s((p.tilt-h)/(o-h),0,1),g=s(((p.position.z??0)-d)/(l-d),0,1),f=a(a(1,m,c),1,g),b=this._bindParameters.hudOccludedFragmentOpacity;if(u<=0||b===f||0===this._lastFrameTime||this._lastFrameTime>t)return this._bindParameters.hudOccludedFragmentOpacity=f,void(this._lastFrameTime=t);const A=t-this._lastFrameTime;this._lastFrameTime=t;const T=Math.max(1-r,Math.abs(r-i)),E=Math.min(T*A/u,n);E>=Math.abs(f-b)?this._bindParameters.hudOccludedFragmentOpacity=f:(this._bindParameters.hudOccludedFragmentOpacity=b+Math.sign(f-b)*E,this._requestRender())}_render(e,t,r=le.Default,i){this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=r===le.Default,this._disposeBindBuffers();const{camera:s,contentCamera:a,mode:n,alignPixelEnabled:h}=e;this._state.value=n;const o=this._nodes.produces("magnifier-color"),l=this._nodes.produces(N.FINAL),_=this._nodes.require("emissive",O.TRANSPARENT_ENVIRONMENT,N.COMPOSITE,N.FINAL)>0&&this._plugins.hasEmissions,p=_?q.ColorEmission:q.Color;this._renderContext.time=t,this._renderContext.output=p,this._bindParameters.oitPass=ne.NONE,this._bindParameters.alignPixelEnabled=h,this._bindParameters.decorations=!i,this._bindParameters.mainDepth=null,this._bindParameters.slicePlane=this._sliceHelper.plane,this._bindParameters.viewshedEnabled=this._nodes.produces(O.VIEWSHED),this._renderOverlay(t),s.setGLViewport(this._rctx);const u=this._framebuffer,m=u.initialize(s.fullWidth,s.fullHeight,this._backgroundColor,_);this.hasReflections?(m?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=m):m?.release(),this._ensureBindParametersCamera(s,a),this._updateHUDOccludedFragmentOpacity(n,t),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!i;const c=this._highQualityTransparency&&this._hasTransparentTerrain,g=this._plugins.produces(q.Color,...ve);this._precompilePrepasses(),this.performanceInfo.advance(Re.PREPARE);const f=this._computeShadowDepthRange(s);this._renderShadowMap(s,this._bindParameters.lighting.mainLight.direction,f),this._ensureBindParametersCamera(s,a),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(f,s,a),this._ensureBindParametersSSR(t),this._precompileShaders(c,g,p),this._renderContext.output=p,u.bind(),this._bindParameters.mainDepth=u.depth.attachment;const b=this.plugins.produces(q.Color,...Me);b&&this._renderOpaqueGeometry(),u.update((e=>this._renderNodes(N.OPAQUE,e,b))),this.fboCache.debugCallback?.(N.OPAQUE,u.color.fbo),u.update((e=>this._renderNodes(O.OPAQUE_ENVIRONMENT,e))),this.fboCache.debugCallback?.(O.OPAQUE_ENVIRONMENT,u.color.fbo),this._renderTerrainDepth(c),this._renderEdges(Ae.OPAQUE),u.bind(),this._renderPlugins(me.VOXEL,Re.VOXEL),this._renderHiddenTransparentEdges(),g&&(this._oitEnabled?this._renderOIT(xe.Geometry,p):this._renderTransparentGeometry()),u.update((e=>this._renderNodes(N.TRANSPARENT,e,g))),this.fboCache.debugCallback?.(N.TRANSPARENT,u.color.fbo),this._renderGeometryDepth(c),this._renderHUDVisibility(),c||this._plugins.render(this._pluginInput,me.LINE_CALLOUTS),this._renderEdges(Ae.TRANSPARENT);const A=this._hasTransparentTerrain?this._renderTransparentTerrain():null;A&&(this.performanceInfo.advance(Re.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(c?this._renderLineCallouts(j.Occluded):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositingHelper.compositeHUD(this._bindParameters,A.getTexture())),this._renderHUD(j.Occluded,u.color,p))),this._bindParameters.cullAboveTerrain=!1,A&&(u.bind(),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,A.getTexture()),A.release(),c&&(this._renderEdges(Ae.OPAQUE),g&&(this._oitEnabled?this._renderOIT(xe.Geometry,p):this._renderTransparentGeometry(),this.performanceInfo.advance(Re.TRANSPARENT)),this._renderEdges(Ae.TRANSPARENT))),this._bindParameters.ssao=d(this._bindParameters.ssao),c&&this._renderLineCallouts(j.NotOccluded),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment(),this._pluginInput.set(O.FOCUSAREA,this._renderFocusAreaGeometry()),u.update((e=>this._renderNodes(O.TRANSPARENT_ENVIRONMENT,e))),u.update((e=>this._renderNodes(O.VIEWSHED,e))),u.update((e=>this._renderNodes(O.LASERLINES,e))),u.update((e=>this._renderNodes(O.FOCUSAREA_COLOR,e))),u.update((e=>this._renderNodes(O.OCCLUDED,e))),this._pluginInput.set("highlights",this._renderHighlightPrepass());const T=r===le.ObjectAndLayerID?this._renderObjectAndLayerIdColor():null;u.update((e=>this._renderNodes(N.COMPOSITE,e))),this._pluginInput.release(O.FOCUSAREA);const E=!(r!==le.Default||l||o&&!i),P=this._pluginInput.get(N.COMPOSITE),R=E?M:this.fboCache.acquire(P.fbo.width,P.fbo.height,O.ANTIALIASING),S=this._nodes.produces(O.ANTIALIASING)?this._renderNodes(O.ANTIALIASING,R):this._blitFBO(P,R,!1);let I;this._pluginInput.set(O.ANTIALIASING,S),this._hasHUDHighlights?(this._renderHUD(j.NotOccluded,S,p),I=this._renderNodes(O.HIGHLIGHTS,S)):(I=this._renderNodes(O.HIGHLIGHTS,S),this._renderHUD(j.NotOccluded,I,p));const C=this._renderNodes(O.MAGNIFIER,I);return o&&!i&&r===le.Default&&!l&&this._blitFBO(C),l?(C.attachDepth(u.depth),this._blitFBO(this._renderNodes(N.FINAL,C)),C.detachDepth()):this._pluginInput.set(N.FINAL,C),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),u.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),r!==le.Default&&(this._releaseFBOs(),this._disposeOffscreenBuffers()),new Ee(this._pluginInput.get(N.FINAL),T)}_precompileShaders(e,t,r){++this._plugins.context.techniques.precompiling,this._renderContext.output=r,this._precompileOpaqueGeometry(),this._nodes.precompile(O.OPAQUE_ENVIRONMENT),this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,this._renderContext.output=q.Depth,this._plugins.precompile(me.TRANSPARENT_TERRAIN),e&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._renderContext.output=r,this._plugins.precompile(me.TRANSPARENT_TERRAIN),t&&(this._precompileTransparentGeometry(),this._hasTransparentTerrain&&(this._bindParameters.cullAboveTerrain=!1,this._precompileTransparentGeometry(),this._bindParameters.cullAboveTerrain=e)),this._nodes.precompile(O.FOCUSAREA),this._needsHUDVisibility&&this._plugins.precompile(me.OCCLUSION_PIXELS),this._plugins.precompile(me.LINE_CALLOUTS),this._precompileHUD(j.Occluded),this._bindParameters.terrainDepthTest=!1,this._bindParameters.cullAboveTerrain=!1,this._nodes.precompile(O.VIEWSHED,O.LASERLINES,O.FOCUSAREA_COLOR,O.OCCLUDED,O.ANTIALIASING,O.HIGHLIGHTS);const i=this._bindParameters;i.highlightMixTexture=i.highlights.length>1?this._rctx.emptyTexture:null,this._precompileHUD(j.NotOccluded),this._hasHighlights&&(i.highlights.forEach(((e,t)=>{i.highlightLevel=t,this._precompileAllGeometry(q.Highlight)})),i.highlightLevel=null),i.highlightMixTexture=null,this._nodes.precompile(N.COMPOSITE,O.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(me.TRANSPARENT_MATERIAL_WITHOUT_DEPTH),--this._plugins.context.techniques.precompiling}_renderFocusAreaGeometry(){if(!this._nodes.produces(O.FOCUSAREA))return null;const{width:e,height:t}=this._framebufferSize;let r=this.fboCache.acquire(e,t,O.FOCUSAREA);return r=this._nodes.render(r,this._pluginInput),this.performanceInfo.advance(Re.FOCUS_AREA_MASK),r}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._renderContext.output;++this._techniques.precompiling;const t=this._framebufferSize;let r=this.fboCache.acquire(t.width,t.height,"olid");return r.acquireDepth(v.DEPTH24_STENCIL8),r=this._nodes.render(r,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(Re.OBJECT_AND_LAYER_ID_COLOR),this._renderContext.output=e,r}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=e===Z.BACKGROUND;if(r||t){const e=r?this.performanceInfo.elapsedTime:0;let i=0;t?i=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const s=Math.max(e,i);this._animationTimestep.frame(s,r)}}readMainDepth(e,t){const{mainDepth:r,camera:i}=this._bindParameters;if(!r)return;const s=this.fboCache.acquire(this._framebufferSize.width,this._framebufferSize.height,"linear-depth");this._rctx.bindFramebuffer(s.fbo),i.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(w),this._compositingHelper.blitDepthToLinearDepth(this._bindParameters,r),this._rctx.setScissorTestEnabled(!1),this._rctx.setScissorRect(0,0,this._rctx.gl.canvas.width,this._rctx.gl.canvas.width),s.fbo?.readPixels(e[0],e[1],e[2],e[3],Ie.RGBA,Ce.UNSIGNED_BYTE,t),s.release()}readHUDVisibility(e,t,r,i,s){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,i,Ie.RGBA,Ce.UNSIGNED_BYTE,s)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"edges"),s=()=>t.render(this._bindParameters,e),a=this._bindParameters.geometryDepth;this.renderToTargets(s,i,a??this._framebuffer.depth,w),this._framebuffer.bind(),this._compositingHelper.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(e===Ae.OPAQUE?Re.OPAQUE_EDGES:Re.TRANSPARENT_EDGES)}_renderOverlay(e){this._bindParameters.overlay=this.overlay?.render(e),this._bindParameters.overlay&&this.performanceInfo.advance(Re.OVERLAY)}_renderShadowMap(e,t,r){if(!this.shadowsEnabled)return;const i=this._shadowMap;i.start(e,t,r,this.isFeatureEnabled(pe.HighResolutionShadows),this.stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(q.ShadowHighlight,this._shadowMap),i.moveSnapshot(fe.Highlight),this._renderShadowCascades(q.ShadowExcludeHighlight,this._shadowMap),i.copySnapshot(fe.ExcludeHighlight),this._renderShadowCascades(q.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(q.Shadow),i.finish(),e.setGLViewport(this._rctx),this.performanceInfo.advance(Re.SHADOW_MAP)}_precompileShadowCascades(e){for(const t of this._shadowMap.cascades)t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.camera),this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e)}get _needsDepth(){return this._plugins.consumes(q.Depth)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._needsShadowAccumulation||this._debugNeedsDepth}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");if(e){const t=this._needsDepth?e.getAttachment(we):null;t?.retain(),this._pluginInput.set(O.SSAO,this._renderSSAO()),this._renderGeometryWithoutNormalsDepth(t)}else this._renderAllGeometryDepth()}_renderGeometryWithoutNormalsDepth(e){if(!this._needsDepth||!e)return void(this._bindParameters.depth=d(this._bindParameters.depth));const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"depth");r.attachDepth(e),e.release(),this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(De.STENCIL),this._renderGeometryWithoutNormals(q.Depth),d(this._bindParameters.depth),this._bindParameters.depth=r.obtainDepthTexture(),r.release(),this.performanceInfo.advance(Re.DEPTH)}_renderAllGeometryDepth(){if(!this._needsDepth)return void(this._bindParameters.depth=d(this._bindParameters.depth));const e=this._framebufferSize,t=this.fboCache.acquire(e.width,e.height,"depth",v.DEPTH24_STENCIL8);this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(De.DEPTH|De.STENCIL),this.renderAllGeometry(q.Depth),d(this._bindParameters.depth),this._bindParameters.depth=t.obtainDepthTexture(),t.release(),this.performanceInfo.advance(Re.DEPTH)}_renderTerrainDepth(e){if(this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,!e)return void(this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth));const t=this._renderContext.output;this._renderContext.output=q.Depth;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"terrain depth",v.DEPTH24_STENCIL8);this._rctx.bindFramebuffer(i.fbo),this._rctx.clear(De.DEPTH|De.STENCIL),this._renderTransparentTerrain(),d(this._bindParameters.terrainDepth),this._bindParameters.terrainDepth=i.obtainDepthTexture(),this._renderContext.output=t,i.release()}_renderGeometryDepth(e){if(!e)return void(this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth));const t=this._renderContext.output,{width:r,height:i}=this._framebufferSize,s=this.fboCache.acquire(r,i,"geometry depth",v.DEPTH24_STENCIL8);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(De.DEPTH|De.STENCIL),this._renderOpaqueAndTransparentGeometry(q.Depth),this._renderContext.output=t,d(this._bindParameters.geometryDepth),this._bindParameters.geometryDepth=s.obtainDepthTexture(),s.release()}get _needsShadowDepthRange(){return this._shadowMap.enabled||this._needsShadowAccumulation}_computeShadowDepthRange(e){if(!this._needsShadowDepthRange)return ee.zero;const t=te(e,this._plugins.plugins,this.stage.layers,re.SHADOW_CASTERS);return t.union(this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}updateSceneDepthRange(e){if(!this.stage.view.state.isGlobal)return void(this.sceneDepthRange.value=ee.infinite);if((this.stage.view.renderCoordsHelper?.getAltitude(e.eye)??0)<y)return void(this.sceneDepthRange.value=ee.infinite);const t=e.clone();t.near=x,t.far=1e10;const r=te(t,this._plugins.plugins,this.stage.layers,re.FULL_SCENE);r.union(this._plugins.queryDepthRange(t)),this.sceneDepthRange.value.far===r.far&&this.sceneDepthRange.value.near===r.near||(this.sceneDepthRange.value=r)}get _normalsRequired(){const e=this._nodes.require("normals",N.FINAL,N.COMPOSITE,N.OPAQUE,N.TRANSPARENT,O.VIEWSHED,O.LASERLINES);return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(q.Normal),this._needsDepth&&this._precompileAllGeometry(q.Depth),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(q.ShadowHighlight),this._precompileShadowCascades(q.ShadowExcludeHighlight),this._precompileShadowCascades(q.ShadowHighlight)):this._precompileShadowCascades(q.Shadow)),this._needsShadowAccumulation&&this._precompileAllGeometry(q.Shadow)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"normals",F.RGBA8UNORM);r.acquireDepth(v.DEPTH24_STENCIL8),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(w,!0,!0),this._renderGeometryWithNormals(q.Normal);const i=this._nodes.optional("normals",N.FINAL,N.COMPOSITE,N.OPAQUE,N.TRANSPARENT,O.VIEWSHED);return r.retain(e+i-1),this.performanceInfo.advance(Re.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return void e?.detachDepth();M.setName(O.SSAO);const t=this._nodes.render(M,this._pluginInput);return this._bindParameters.ssao=t,e.detachDepth(),this._pluginInput.release("normals"),this.performanceInfo.advance(Re.SSAO),t}_precompileAllGeometry(e){const t=this._renderContext.output;this._renderContext.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(me.TRANSPARENT_TERRAIN),this._renderContext.output=t}renderAllGeometry(e){this._renderContext.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentTerrain()}precompileSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const r of t)this._renderContext.renderOccludedMask=r,this.precompileSlots(e,...Fe);this._renderContext.renderOccludedMask=oe}renderSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.forAll((e=>{const t=e.acquireTechniques(this._renderContext);t&&e.render(this._renderContext,t,this._pluginInput)}))}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>ae.Occlude&&this._plugins.render(this._pluginInput,me.OCCLUDED_TERRAIN),this.renderSlots(e,...Fe),this._renderContext.renderOccludedMask=oe}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(this._pluginInput,me.HUD_MATERIAL)}precompileViewshedShadowMap(){this._precompileAllGeometry(q.ViewshedShadow)}renderViewshedShadowMap(e){const{camera:t,contentCamera:r}=this._bindParameters,i=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(q.ViewshedShadow),this._ensureBindParametersCamera(t,r),this._bindParameters.camera.setGLViewport(this._rctx),this._renderContext.output=i}_renderOpaqueAndTransparentGeometry(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithNormals(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,...He),this._renderTransparentTerrain()}_renderGeometryWithoutNormals(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,...Le)}_precompileOpaqueGeometry(){this._plugins.precompile(...Me)}_renderOpaqueGeometry(){this._plugins.render(this._pluginInput,...Me)}_renderTransparentGeometry(){this._plugins.render(this._pluginInput,...ve)}get _hasTransparentTerrain(){return this._plugins.produces(q.Color,me.TRANSPARENT_TERRAIN)}_renderTransparentTerrain(){const e=()=>this._plugins.render(this._pluginInput,me.TRANSPARENT_TERRAIN);if(!V(this._renderContext.output))return void e();const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"transparent terrain");return this.renderToTargets(e,r,this._framebuffer.depth,w),r}get _needsHUDVisibility(){return this._plugins.produces(this._renderContext.output,me.OCCLUSION_PIXELS)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility));const{width:e,height:t}=this._framebufferSize;let r=this._bindParameters.hudVisibility;r?.fbo?.width===e&&r?.fbo?.height===t||(r?.release(),r=this.fboCache.acquire(e,t,"hud visibility",F.RGBA4UNORM),this._bindParameters.hudVisibility=r);const i=this._bindParameters.geometryDepth;r.attachDepth(i||this._framebuffer.depth),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(this._pluginInput,me.OCCLUSION_PIXELS),r.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(Re.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===j.Occluded){const e=()=>this._plugins.render(this._pluginInput,me.LINE_CALLOUTS),t=this._framebufferSize,r=this.fboCache.acquireDepth(U.DEPTH16,t.width,t.height,"line callouts");this.renderToTargets(e,this._framebuffer.color,r,void 0,!0,!0),r.release()}else this._plugins.render(this._pluginInput,me.LINE_CALLOUTS)}_precompileHUD(e){if(this._precompileHUDOutput(e),this._hasHighlights){const t=this._renderContext.output;this._renderContext.output=q.Highlight,this._precompileHUDOutput(e),this._renderContext.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this._oitEnabled&&V(this._renderContext.output)?(this._bindParameters.oitPass=ne.ColorAlpha,this._plugins.precompile(...Ue),this._bindParameters.oitPass=ne.FrontFace,this._plugins.precompile(...Ue),this._bindParameters.oitPass=ne.NONE):this._plugins.precompile(...Ue),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t,r){if(this._pluginsHas.hudElements){if(this._oitEnabled){const i=this._renderOIT(xe.HUD,r,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,i.getTexture()),i.release()}else if(this._renderContext.output=r,e===j.Occluded){const t=()=>this._renderHUDElements(e),r=this._framebufferSize,i=this.fboCache.acquireDepth(U.DEPTH16,r.width,r.height,"hud");this.renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(U.DEPTH16),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(e===j.Occluded?Re.HUD_OCCLUDED:Re.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(this._pluginInput,...Ue)}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(q.ShadowHighlight,me.OPAQUE_MATERIAL)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:r}=this,i=this._framebufferSize,{highlights:s}=r,a=e.acquire(i.width,i.height,"highlights",s.length>z?F.RG8UINT:F.R8UINT);a.acquireDepth(v.DEPTH24_STENCIL8),t.bindFramebuffer(a.fbo);const{gl:n}=t;return n.clearBufferuiv(n.COLOR,0,[0,0,0,0]),this._renderContext.output=q.Highlight,t.bindFramebuffer(a.fbo),Y(t,e,i,r,(()=>this._renderHighlightGeometries())),this.performanceInfo.advance(Re.HIGHLIGHTS),a}_renderHighlightGeometries(){this._plugins.render(this._pluginInput,...Ge),this._rctx.clear(De.DEPTH),this._renderHUDElements(j.Both)}get _needsShadowAccumulation(){return this._shadowAccumulator.accumulating}_renderShadowAccumulation(e,t,r){this._needsShadowAccumulation&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,e,t,r)&&this.performanceInfo.advance(Re.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this._oitEnabled&&V(this._renderContext.output)?(this._bindParameters.oitPass=ne.ColorAlpha,this._plugins.precompile(...ve),this._bindParameters.oitPass=ne.FrontFace,this._plugins.precompile(...ve),this._bindParameters.oitPass=ne.NONE):this._plugins.precompile(...ve)}_renderOIT(e,t,r=j.Both){const i=e===xe.HUD,s=this._framebufferSize,a=i?this.fboCache.acquire(s.width,s.height,"oit hud composite"):null,n=i?()=>this._renderHUDElements(r):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._renderContext.output;this._renderContext.output=t,h.oitPass=ne.ColorAlpha;const d=a?"oit hud color+alpha":"oit color+alpha",l=this.fboCache.acquire(s.width,s.height,d,F.RGBA16FLOAT),_=t===q.ColorEmission;_&&l.acquireColor(Ne,F.RGBA16FLOAT,"emissive"),l.acquireColor(_?Oe:Ne,F.R16FLOAT),a||l.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(l.fbo),this._rctx.clearFramebuffer([0,0,0,1]),_&&this._rctx.clearBuffer(1,I),n(),l.detachDepth(),h.oitPass=ne.FrontFace;const p=this.fboCache.acquire(s.width,s.height,a?"oit hud front":"oit front");return _&&p.acquireColor(Ne,F.RGBA16FLOAT,"emissive"),a?p.acquireDepth(U.DEPTH16):p.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(p.fbo),this._rctx.clearFramebuffer(w,!!a),n(),p.detachDepth(),h.oitPass=ne.NONE,a?(this._rctx.bindFramebuffer(a.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(De.COLOR)):this._framebuffer.bind(),this._oitblend??=new X(this._techniques),this._oitblend.blend(this._rctx,l,p,h,_),a?.detachDepth(),p.release(),l.release(),this._renderContext.output=o,a}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(Re.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(this._pluginInput,me.TRANSPARENT_MATERIAL_WITHOUT_DEPTH),this.performanceInfo.advance(Re.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderPlugins(e,t){this._plugins.produces(this._renderContext.output,e)&&(this._plugins.render(this._pluginInput,e),this.performanceInfo.advance(t))}_renderNodes(e,t,r=!1){if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;const i=this._nodes.render(t,this._pluginInput,this._releaseNormals);return this.performanceInfo.advance(e),i}_blitFBO(e,t=M,r=!0){return this._blit??=new k(this._techniques),this._blit.blit(this._rctx,e,t,this._bindParameters),this._pluginInput.set(e.name,t),r&&e.release(),t}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=P:(T(Ve,this._bindParameters.camera.viewMatrix),T(qe,this._bindParameters.camera.projectionMatrix),E(je,Ve,qe),E(je,this._renderContext.lastFrameCamera.viewMatrix,je),E(je,this._renderContext.lastFrameCamera.projectionMatrix,je),this._reprojectionMatrix=je);const t=this.stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=P,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,r,i){this._bindParameters.updateLighting(e,t,r,i),this._requestRender(Z.UPDATE)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}renderToTargets(e,t,r,i,s=!1,a=!1){t.attachDepth(r),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(i,s,a),e(),t.detachDepth()}get test(){}};var xe;e([f({readOnly:!0})],ye.prototype,"fullResolutionAtmosphere",null),e([f()],ye.prototype,"_edgeView",void 0),e([f()],ye.prototype,"updating",null),ye=e([b("esri.views.3d.webgl-engine.lib.Renderer")],ye),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(xe||(xe={}));const He=[me.INTEGRATED_MESH,me.OPAQUE_TERRAIN,me.OPAQUE_MATERIAL,me.TRANSPARENT_MATERIAL],Le=[me.OPAQUE_MATERIAL_WITHOUT_NORMALS,me.TRANSPARENT_MATERIAL_WITHOUT_NORMALS],Me=[me.INTEGRATED_MESH,me.OPAQUE_TERRAIN,me.OPAQUE_MATERIAL,me.OPAQUE_MATERIAL_WITHOUT_NORMALS],ve=[me.TRANSPARENT_MATERIAL,me.TRANSPARENT_MATERIAL_WITHOUT_NORMALS],Fe=[me.OPAQUE_MATERIAL,me.TRANSPARENT_MATERIAL,me.TRANSPARENT_MATERIAL_WITHOUT_DEPTH],Ue=[me.LINE_CALLOUTS_HUD_DEPTH,me.HUD_MATERIAL,me.LABEL_MATERIAL],Ge=[me.TRANSPARENT_MATERIAL,me.TRANSPARENT_MATERIAL_WITHOUT_NORMALS,me.OPAQUE_MATERIAL,me.OPAQUE_MATERIAL_WITHOUT_NORMALS,me.TRANSPARENT_TERRAIN,me.INTEGRATED_MESH,me.OPAQUE_TERRAIN],qe=R(),Ve=R(),je=R();function Be(e){return t=>e.immediate.schedule(t)}export{ye 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{equals as r}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{smoothstep as s}from"../../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../../core/maybe.js";import{watch as o,syncAndInitial as a,sync as n}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{G as _,c as l}from"../../../../chunks/vec32.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ReadShadowMapPassParameters as u}from"../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{BindParameters as p}from"./BindParameters.js";import{DepthRange as d}from"./DepthRange.js";import{createQuadVAO as g}from"./glUtil3D.js";import{ShadowCastRenderer as f,shadowCastDisabledElevationThreshold as b,shadowCastDisableElevationMax as w,shadowCastDisableElevationMin as v}from"./ShadowCastRenderer.js";import{ShadowMap as y}from"./ShadowMap.js";import{S as R}from"../../../../chunks/ShadowCastAccumulate.glsl.js";import{ShadowCastAccumulateTechnique as A}from"../shaders/ShadowCastAccumulateTechnique.js";import{TaskPriority as j}from"../../../support/Scheduler.js";import{PixelFormat as S,PixelType as F,SizedPixelFormat as C,TextureWrapMode as x,FramebufferBit as P}from"../../../webgl/enums.js";import{FramebufferObject as D}from"../../../webgl/FramebufferObject.js";import{TextureDescriptor as E}from"../../../webgl/TextureDescriptor.js";import{vertexCount as q}from"../../../webgl/Util.js";let M=class extends t{constructor(e,t,r,s,i,h){super({}),this.fbos=e,this._techniques=t,this._stage=r,this._prepareForShadowMapPass=s,this._renderToShadowMap=i,this._requestRender=h,this._progress=0,this._sampleCount=0,this._passParameters=new u,this._cachedLightDirections=[],this._depthRange=d.zero,this._previewing=!1,this._cameraForcedForScreenshot=!1,this._shadowAccumulatorKey="shadowAccumulator",this._rctx=e.rctx,this._bindParameters=new p(new y(e,r.viewingMode)),this._bindParameters.shadowMap.enabled=!0,this._vao=g(this._rctx),this._accumulationRenderer=new f(t,this._rctx,this,h);const c=this._stage.view.resourceController.scheduler;this.addHandles([c.registerTask(j.SHADOW_ACCUMULATOR,this),o((()=>r.renderView),(e=>{this.removeHandles(L),null!=e&&this.addHandles(e.events.on("force-camera-for-screenshot",(()=>this._cameraForcedForScreenshot=!0)),L)}),a),o((()=>this._previewing),(()=>this._requestRenderIfEnabled()),n)],this._shadowAccumulatorKey),t.precompile(A)}normalizeCtorArgs(){return{}}dispose(){this._disable(),this.removeHandles(this._shadowAccumulatorKey),this._accumulationRenderer=i(this._accumulationRenderer),this._bindParameters.shadowMap.dispose(),this._fbo=i(this._fbo),this._vao=i(this._vao),this._cachedLightDirections.length=0,this._sampleCount=0}get computedSamples(){return this._progress}get shadowCastTexture(){return this._fbo?.colorTexture}get accumulating(){return this._active&&this._previewing||this._refining}get _refining(){return this._active&&!this._doneAccumulating&&!this._previewing}get _active(){return null!=this._fbo&&this._sampleCount>0}get canAccumulate(){return null!=this._bindParameters.depth&&this._depthRange!==d.zero&&this._opacityFromElevation>b}get _doneAccumulating(){return this._progress>=this._sampleCount}get _lightDirections(){return this._cachedLightDirections}set _lightDirections(e){const t=this._cachedLightDirections;if(r(t,e,_))return;const s=Math.min(R,e.length);t.length=s,this._sampleCount=s;for(let r=0;r<s;++r)t[r]=l(t[r]??m(),e[r]);this._invalidate()}get _opacityFromElevation(){return this._accumulationRenderer.opacityFromElevation}set _opacityFromElevation(e){this._accumulationRenderer.opacityFromElevation=e}get running(){return this._refining&&this.canAccumulate&&this._progress>0}runTask(e){for(this._prepareForShadowMapPass(this._bindParameters);!e.done&&!this._doneAccumulating;)this._accumulateShadow(),e.madeProgress();this._requestRender()}renderAccumulation(e,t,r,s){if(this._depthRange=t,this._updateCamera(r),this._bindParameters.contentCamera=s,this._bindParameters.depth=e,this._passParameters.origin=this._bindParameters.camera.center,this.notifyChange("canAccumulate"),!this.accumulating||!this.canAccumulate)return!1;(this._previewing||0===this._progress||this._cameraForcedForScreenshot)&&this._clear();let i=this._cameraForcedForScreenshot?this._sampleCount:Math.min(T,this._sampleCount);i-=this._progress;for(let o=0;o<i;++o)this._accumulateShadow(),this._requestRender();return this._cameraForcedForScreenshot=!1,i>0}precompile(){this._accumulationRenderer.precompile()}render(e){this._accumulationRenderer.render(e)}setOptions(e){if(void 0!==e.enabled){const t=null!=this._fbo;e.enabled!==t&&(e.enabled?this._enable():this._disable())}void 0!==e.previewing&&(this._previewing=e.previewing),void 0!==e.lightDirections&&(this._lightDirections=e.lightDirections),this._accumulationRenderer.setOptions(e)}readAccumulatedShadow(e,t){return!this._active||!this._fbo||this._progress<1||e<0||e>=this._fbo.width||t<0||t>=this._fbo.height?0:(this._fbo.readPixels(e,t,1,1,S.RGBA,F.UNSIGNED_BYTE,O),O[0]/this._progress)}_enable(){this._progress=0;const e=new E;e.pixelFormat=S.RED,e.internalFormat=C.R8,e.wrapMode=x.CLAMP_TO_EDGE,this._fbo=new D(this._rctx,e),this._requestRender()}_disable(){this._fbo=i(this._fbo),this._requestRender()}_invalidate(){this._progress=0,this._requestRenderIfEnabled()}_clear(){this._rctx.bindFramebuffer(this._fbo),this._rctx.setClearColor(0,0,0,0),this._rctx.clear(P.COLOR),this._progress=0}_accumulateShadow(){this._renderToShadowMap(this._bindParameters,this._lightDirections[this._progress++],this._depthRange);const e=this._techniques.get(A);this._rctx.bindFramebuffer(this._fbo),this._rctx.bindTechnique(e,this._bindParameters,this._passParameters),this._rctx.bindVAO(this._vao),this._rctx.drawArrays(e.primitiveType,0,q(this._vao,"geometry"))}_updateCamera(e){const t=this._fbo;if(null==t)return;const r=this._bindParameters.camera;e.equals(r)||r.copyFrom(e),t.resize(e.fullWidth,e.fullHeight),this._opacityFromElevation=1-s(v,w,e.relativeElevation)}_requestRenderIfEnabled(){this._fbo&&this._requestRender()}get test(){}};e([h()],M.prototype,"_progress",void 0),e([h()],M.prototype,"_sampleCount",void 0),e([h()],M.prototype,"_fbo",void 0),e([h()],M.prototype,"_depthRange",void 0),e([h()],M.prototype,"_previewing",void 0),e([h()],M.prototype,"_accumulationRenderer",void 0),e([h()],M.prototype,"_refining",null),e([h()],M.prototype,"_active",null),e([h()],M.prototype,"canAccumulate",null),e([h()],M.prototype,"_doneAccumulating",null),e([h()],M.prototype,"_opacityFromElevation",null),e([h()],M.prototype,"running",null),M=e([c("esri.views.3d.webgl-engine.lib.ShadowAccumulator")],M);const T=6,L="renderView",O=new Uint8Array(4);export{M as ShadowAccumulator};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{equals as r}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{smoothstep as i}from"../../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../../core/maybe.js";import{watch as o,syncAndInitial as a,sync as n}from"../../../../core/reactiveUtils.js";import{signal as c}from"../../../../core/signal.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{G as l,c as m}from"../../../../chunks/vec32.js";import{create as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ReadShadowMapPassParameters as p}from"../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{BindParameters as d}from"./BindParameters.js";import{DepthRange as g}from"./DepthRange.js";import{createQuadVAO as f}from"./glUtil3D.js";import{ShadowCastRenderer as b,shadowCastDisabledElevationThreshold as v,shadowCastDisableElevationMax as w,shadowCastDisableElevationMin as S}from"./ShadowCastRenderer.js";import{ShadowMap as F}from"./ShadowMap.js";import{S as y}from"../../../../chunks/ShadowCastAccumulate.glsl.js";import{ShadowCastAccumulateTechnique as x}from"../shaders/ShadowCastAccumulateTechnique.js";import{ShadowCastAccumulateTechniqueConfiguration as R,ShadowCastAccumulateIndex as A}from"../shaders/ShadowCastAccumulateTechniqueConfiguration.js";import{TaskPriority as C}from"../../../support/Scheduler.js";import{PixelFormat as j,SizedPixelFormat as P,PixelType as D,TextureWrapMode as T,FramebufferBit as E}from"../../../webgl/enums.js";import{FramebufferObject as q}from"../../../webgl/FramebufferObject.js";import{TextureDescriptor as M}from"../../../webgl/TextureDescriptor.js";import{vertexCount as O}from"../../../webgl/Util.js";let L=class extends t{constructor(e,t,r,i,s,c){super({}),this.fbos=e,this._techniques=t,this._stage=r,this._prepareForShadowMapPass=i,this._renderToShadowMap=s,this._requestRender=c,this._primarySet=new G(new R(A.PRIMARY),(()=>this._requestRenderIfEnabled())),this._contextSet=new G(new R(A.CONTEXT),(()=>this._requestRenderIfEnabled())),this._passParameters=new p,this._depthRange=g.zero,this._previewing=!1,this._cameraForcedForScreenshot=!1,this._shadowAccumulatorKey=Symbol("shadowAccumulator"),this._rctx=e.rctx,this._bindParameters=new d(new F(e,r.viewingMode)),this._bindParameters.shadowMap.enabled=!0,this._vao=f(this._rctx),this._accumulationRenderer=new b(t,this._rctx,this,c);const h=this._stage.view.resourceController.scheduler;this.addHandles([h.registerTask(C.SHADOW_ACCUMULATOR,this),o((()=>r.renderView),(e=>{this.removeHandles(k),null!=e&&this.addHandles(e.events.on("force-camera-for-screenshot",(()=>this._cameraForcedForScreenshot=!0)),k)}),a),o((()=>this._previewing),(()=>this._requestRenderIfEnabled()),n),o((()=>this._pixelFormat),(()=>this._pixelFormatChanged()),n)],this._shadowAccumulatorKey);for(const o of this._accumulationSets())o.precompile(t)}*_accumulationSets(){yield this._primarySet,yield this._contextSet}normalizeCtorArgs(){return{}}dispose(){this._disable(),this.removeHandles(this._shadowAccumulatorKey),this._accumulationRenderer=s(this._accumulationRenderer),this._bindParameters.shadowMap.dispose(),this._fbo=s(this._fbo),this._vao=s(this._vao);for(const e of this._accumulationSets())e.destroy()}get computedSamples(){return[this._primarySet.progress,this._contextSet.progress]}get shadowCastTexture(){return this._fbo?.colorTexture}get accumulating(){return this._active&&this._previewing||this._refining}get _refining(){return this._active&&!this._doneAccumulating&&!this._previewing}get _active(){return null!=this._fbo&&[...this._accumulationSets()].some((e=>e.active))}get canAccumulate(){return null!=this._bindParameters.depth&&this._depthRange!==g.zero&&this._opacityFromElevation>v}get _doneAccumulating(){return[...this._accumulationSets()].every((e=>e.doneAccumulating))}get _opacityFromElevation(){return this._accumulationRenderer.opacityFromElevation}set _opacityFromElevation(e){this._accumulationRenderer.opacityFromElevation=e}get _numActive(){return[...this._accumulationSets()].reduce(((e,t)=>e+(t.active?1:0)),0)}get _pixelFormat(){return 1===this._numActive?{pixelFormat:j.RED,internalFormat:P.R8}:{pixelFormat:j.RG,internalFormat:P.RG8}}get running(){return this._refining&&this.canAccumulate&&[...this._accumulationSets()].some((e=>e.running))}runTask(e){this._prepareForShadowMapPass(this._bindParameters);let t=!1;for(const r of this._accumulationSets())this._runTaskForSet(r,e)&&(t=!0);t&&this._requestRender()}_runTaskForSet(e,t){let r=!1;for(;!t.done&&!e.doneAccumulating;)this._accumulateShadow(e),t.madeProgress(),r=!0;return r}renderAccumulation(e,t,r,i){if(this._depthRange=t,this._updateCamera(r),this._bindParameters.contentCamera=i,this._bindParameters.depth=e,this._passParameters.origin=this._bindParameters.camera.center,this.notifyChange("canAccumulate"),!this.accumulating||!this.canAccumulate)return!1;(this._previewing||[...this._accumulationSets()].every((e=>0===e.progress))||this._cameraForcedForScreenshot)&&this._clear();const s=this._accumulateSets();return this._cameraForcedForScreenshot=!1,s}_accumulateSets(){let e=!1;for(const t of this._accumulationSets())this._accumulateSet(t)&&(e=!0);return e&&this._requestRender(),e}_accumulateSet(e){let t=this._cameraForcedForScreenshot?e.sampleCount:Math.min(U,e.sampleCount);t-=e.progress;for(let r=0;r<t;++r)this._accumulateShadow(e);return t>0}precompile(){this._accumulationRenderer.precompile()}render(e){this._accumulationRenderer.render(e)}setOptions(e){void 0!==e.previewing&&(this._previewing=e.previewing),void 0!==e.lightDirections&&(this._primarySet.lightDirections=e.lightDirections),void 0!==e.lightDirectionsContext&&(this._contextSet.lightDirections=e.lightDirectionsContext),!0===e.enabled?this._enable():!1===e.enabled&&this._disable(),this._accumulationRenderer.setOptions(e)}readAccumulatedShadow(e,t){const r=this._primarySet.progress;return!this._active||!this._fbo||r<1||e<0||e>=this._fbo.width||t<0||t>=this._fbo.height?0:(this._fbo.readPixels(e,t,1,1,j.RGBA,D.UNSIGNED_BYTE,I),I[A.PRIMARY]/r)}_pixelFormatChanged(){const e=this._fbo?.colorTexture;if(!e)return;const{pixelFormat:t,internalFormat:r}=this._pixelFormat,{descriptor:i}=e;i.pixelFormat===t&&i.internalFormat===r||this._recreateFBO()}_recreateFBO(){this._disable(),this._enable()}_enable(){if(this._fbo)return;const{pixelFormat:e,internalFormat:t}=this._pixelFormat,r=new M;r.pixelFormat=e,r.internalFormat=t,r.wrapMode=T.CLAMP_TO_EDGE,this._fbo=new q(this._rctx,r);for(const i of this._accumulationSets())i.invalidate()}_disable(){this._fbo&&(this._fbo=s(this._fbo),this._requestRender())}_clear(){this._rctx.bindFramebuffer(this._fbo),this._rctx.setClearColor(0,0,0,0),this._rctx.clear(E.COLOR);for(const e of this._accumulationSets())e.clear()}_accumulateShadow(e){this._renderToShadowMap(this._bindParameters,e.lightDirections[e.progress++],this._depthRange);const t=this._techniques.get(x,e.configuration);this._rctx.bindFramebuffer(this._fbo),this._rctx.bindTechnique(t,this._bindParameters,this._passParameters),this._rctx.bindVAO(this._vao),this._rctx.drawArrays(t.primitiveType,0,O(this._vao,"geometry"))}_updateCamera(e){const t=this._fbo;if(null==t)return;const r=this._bindParameters.camera;e.equals(r)||r.copyFrom(e),t.resize(e.fullWidth,e.fullHeight),this._opacityFromElevation=1-i(S,w,e.relativeElevation)}_requestRenderIfEnabled(){this._fbo&&this._requestRender()}get test(){}};e([h()],L.prototype,"_fbo",void 0),e([h()],L.prototype,"_depthRange",void 0),e([h()],L.prototype,"_previewing",void 0),e([h()],L.prototype,"_accumulationRenderer",void 0),e([h()],L.prototype,"_refining",null),e([h()],L.prototype,"_active",null),e([h()],L.prototype,"canAccumulate",null),e([h()],L.prototype,"_doneAccumulating",null),e([h()],L.prototype,"_opacityFromElevation",null),e([h()],L.prototype,"_numActive",null),e([h()],L.prototype,"_pixelFormat",null),e([h()],L.prototype,"running",null),L=e([u("esri.views.3d.webgl-engine.lib.ShadowAccumulator")],L);const U=6,k="renderView",I=new Uint8Array(4);class G{constructor(e,t){this.configuration=e,this._requestRender=t,this._cachedLightDirections=[],this._progress=c(0),this._sampleCount=c(0)}get progress(){return this._progress.value}set progress(e){this._progress.value=e}get sampleCount(){return this._sampleCount.value}get doneAccumulating(){return this.progress>=this.sampleCount}get running(){return this.progress>0}get active(){return this.sampleCount>0}get lightDirections(){return this._cachedLightDirections}set lightDirections(e){const t=this._cachedLightDirections;if(r(t,e,l))return;const i=Math.min(y,e.length);t.length=i,this._sampleCount.value=i;for(let r=0;r<i;++r)t[r]=m(t[r]??_(),e[r]);this.invalidate()}destroy(){this._cachedLightDirections.length=0,this._sampleCount.value=0}invalidate(){this.clear(),this._requestRender()}clear(){this.progress=0}precompile(e){e.precompile(x,this.configuration)}}export{L as ShadowAccumulator};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as s}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{disposeMaybe as e}from"../../../../core/maybe.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import{a as r,c as o}from"../../../../chunks/vec42.js";import{createQuadVAO as n}from"./glUtil3D.js";import{S as h}from"../../../../chunks/ShadowCastVisualize.glsl.js";import{ShadowCastVisualizeTechnique as d}from"../shaders/ShadowCastVisualizeTechnique.js";import{ShadowCastVisualizeTechniqueConfiguration as l}from"../shaders/ShadowCastVisualizeTechniqueConfiguration.js";import{vertexCount as _}from"../../../webgl/Util.js";const c=4e4,p=5e4,m=1/512;let u=class extends t{constructor(s,t,e,i){super({}),this._techniques=s,this._rctx=t,this._data=e,this._requestRender=i,this._passParameters=new h(this._data),this._configuration=new l,this._enabled=!1,this._vao=n(t)}dispose(){this._stop(),this._vao=e(this._vao)}precompile(){this._showVisualization&&this._techniques.precompile(d,this._configuration)}render(s){if(!this._showVisualization)return;this._passParameters.sampleScale=1/this._data.computedSamples;const t=this._techniques.get(d,this._configuration);this._rctx.bindVAO(this._vao),this._rctx.bindTechnique(t,s,this._passParameters),this._rctx.drawArrays(t.primitiveType,0,_(this._vao,"geometry"))}setOptions(s){void 0!==s.enabled&&this._setEnabled(s.enabled),void 0!==s.color&&this._setColor(s.color),void 0!==s.threshold&&(this._threshold=s.threshold),void 0!==s.visualization&&(this._visualization=s.visualization),void 0!==s.bandSize&&(this._bandSize=s.bandSize),void 0!==s.bandsEnabled&&(this._bandsEnabled=s.bandsEnabled)}get opacityFromElevation(){return this._passParameters.opacityFromElevation}set opacityFromElevation(s){this._passParameters.opacityFromElevation!==s&&(this._passParameters.opacityFromElevation=s,this.notifyChange("opacityFromElevation"))}get _showVisualization(){return this._enabled&&this._data.computedSamples>0&&this.opacityFromElevation>m}get _threshold(){return this._passParameters.threshold}set _threshold(s){this._threshold!==s&&(this._passParameters.threshold=s,this._requestRenderIfEnabled())}get _visualization(){return this._configuration.visualization}set _visualization(s){s!==this._visualization&&(this._configuration.visualization=s,this._requestRenderIfEnabled())}get _bandSize(){return this._passParameters.bandSize}set _bandSize(s){s!==this._bandSize&&(this._passParameters.bandSize=s,this._requestRenderIfEnabled())}get _bandsEnabled(){return this._configuration.bandsEnabled}set _bandsEnabled(s){s!==this._bandsEnabled&&(this._configuration.bandsEnabled=s,this._requestRenderIfEnabled())}_setColor(s){const t=this._passParameters.color;r(s,t)||(o(this._passParameters.color,s),this._requestRenderIfEnabled())}_setEnabled(s){s!==this._enabled&&(s?this._start():this._stop())}_requestRenderIfEnabled(){this._enabled&&this._requestRender()}_start(){this._enabled=!0,this._requestRender()}_stop(){this._enabled=!1,this._requestRender()}};s([i()],u.prototype,"opacityFromElevation",null),u=s([a("esri.views.3d.webgl-engine.lib.ShadowCastRenderer")],u);export{u as ShadowCastRenderer,p as shadowCastDisableElevationMax,c as shadowCastDisableElevationMin,m as shadowCastDisabledElevationThreshold};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import s from"../../../../core/Accessor.js";import{disposeMaybe as t}from"../../../../core/maybe.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{a,c as o}from"../../../../chunks/vec42.js";import{createQuadVAO as h}from"./glUtil3D.js";import{S as n}from"../../../../chunks/ShadowCastVisualize.glsl.js";import{ShadowCastVisualizeTechnique as d}from"../shaders/ShadowCastVisualizeTechnique.js";import{ShadowCastVisualizeTechniqueConfiguration as l}from"../shaders/ShadowCastVisualizeTechniqueConfiguration.js";import{vertexCount as _}from"../../../webgl/Util.js";const p=4e4,m=5e4,c=1/512;let u=class extends s{constructor(e,s,t,i){super({}),this._techniques=e,this._rctx=s,this._data=t,this._requestRender=i,this._passParameters=new n(this._data),this._configuration=new l,this._enabled=!1,this._vao=h(s)}dispose(){this._stop(),this._vao=t(this._vao)}precompile(){this._showVisualization&&this._techniques.precompile(d,this._configuration)}render(e){if(!this._showVisualization)return;this._passParameters.sampleScale=[1/this._data.computedSamples[0],1/this._data.computedSamples[1]];const s=this._techniques.get(d,this._configuration);this._rctx.bindVAO(this._vao),this._rctx.bindTechnique(s,e,this._passParameters),this._rctx.drawArrays(s.primitiveType,0,_(this._vao,"geometry"))}setOptions(e){void 0!==e.enabled&&this._setEnabled(e.enabled),void 0!==e.thresholdColor&&this._setThresholdColor(e.thresholdColor),void 0!==e.gradientColor&&this._setGradientColor(e.gradientColor),void 0!==e.bandedGradientColor&&this._setBandedGradientColor(e.bandedGradientColor),void 0!==e.threshold&&(this._threshold=e.threshold),void 0!==e.visualization&&(this._visualization=e.visualization),void 0!==e.bandSize&&(this._bandSize=e.bandSize)}get opacityFromElevation(){return this._passParameters.opacityFromElevation}set opacityFromElevation(e){this._passParameters.opacityFromElevation!==e&&(this._passParameters.opacityFromElevation=e,this.notifyChange("opacityFromElevation"))}get _showVisualization(){return this._enabled&&(this._data.computedSamples[0]>0||this._data.computedSamples[1]>0)&&this.opacityFromElevation>c}get _threshold(){return this._passParameters.threshold}set _threshold(e){this._threshold!==e&&(this._passParameters.threshold=e,this._requestRenderIfEnabled())}get _visualization(){return this._configuration.visualization}set _visualization(e){e!==this._visualization&&(this._configuration.visualization=e,this._requestRenderIfEnabled())}get _bandSize(){return this._passParameters.bandSize}set _bandSize(e){e!==this._bandSize&&(this._passParameters.bandSize=e,this._requestRenderIfEnabled())}_setThresholdColor(e){const s=this._passParameters.thresholdColor;a(e,s)||(o(this._passParameters.thresholdColor,e),this._requestRenderIfEnabled())}_setGradientColor(e){const s=this._passParameters.gradientColor;a(e,s)||(o(this._passParameters.gradientColor,e),this._requestRenderIfEnabled())}_setBandedGradientColor(e){const s=this._passParameters.bandedGradientColor;a(e,s)||(o(this._passParameters.bandedGradientColor,e),this._requestRenderIfEnabled())}_setEnabled(e){e!==this._enabled&&(e?this._start():this._stop())}_requestRenderIfEnabled(){this._enabled&&this._requestRender()}_start(){this._enabled=!0,this._requestRender()}_stop(){this._enabled=!1,this._requestRender()}};e([i()],u.prototype,"opacityFromElevation",null),u=e([r("esri.views.3d.webgl-engine.lib.ShadowCastRenderer")],u);export{u as ShadowCastRenderer,m as shadowCastDisableElevationMax,p as shadowCastDisableElevationMin,c as shadowCastDisabledElevationThreshold};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import{clamp as t,lerp as s,acosClamped as e}from"../../../../core/mathUtils.js";import{releaseMaybe as i}from"../../../../core/maybe.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as r,multiply as h,invert as o,lookAt as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as c,create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as d,add as m,scale as u,lerp as _,squaredDistance as f,subtract as g,dot as p,negate as x,normalize as b,copy as w}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as M}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{p as C,c as j,v as T,t as y,i as D}from"../../../../chunks/vec32.js";import{create as H}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as v,t as S}from"../../../../chunks/vec42.js";import{create as R}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ViewingMode as E}from"../../../ViewingMode.js";import{CascadeCamera as O}from"./CascadeCamera.js";import{applyTextureResizeModulo as U}from"./textureUtils.js";import{assert as F,logWithBase as L,verify as Q,rayRay2D as V}from"./Util.js";import{TextureType as N,FramebufferBit as A}from"../../../webgl/enums.js";import{ColorFormat as B,DepthFormat as I}from"../../../webgl/formats.js";import{Texture as W}from"../../../webgl/Texture.js";var z;!function(t){t[t.Highlight=0]="Highlight",t[t.ExcludeHighlight=1]="ExcludeHighlight"}(z||(z={}));class P{constructor(){this.camera=new O,this.lightMat=l()}}class q{constructor(){this.maxNumCascadesHighQuality=4,this.maxNumCascadesLowQuality=4,this.textureSizeModHighQuality=1.3,this.textureSizeModLowQuality=.9,this.splitSchemeLambda=0}}class G{constructor(t,s){this._fbos=t,this._viewingMode=s,this._enabled=!1,this._snapshots=new Array,this._textureHeight=0,this._numCascades=1,this.settings=new q,this._projectionView=l(),this._projectionViewInverse=l(),this._modelViewLight=l(),this._cascadeDistances=[0,0,0,0,0],this._usedCascadeDistances=R(),this._cascades=[new P,new P,new P,new P],this._lastOrigin=null,this._maxTextureWidth=Math.min(has("esri-mobile")?4096:16384,t.rctx.parameters.maxTextureSize)}dispose(){this.enabled=!1,this.disposeOffscreenBuffers()}get depthTexture(){return this._handle?.getTexture()}get _textureWidth(){return this._textureHeight*this._numCascades}get numCascades(){return this._numCascades}get cascadeDistances(){return v(this._usedCascadeDistances,this._cascadeDistances[0],this._numCascades>1?this._cascadeDistances[1]:1/0,this._numCascades>2?this._cascadeDistances[2]:1/0,this._numCascades>3?this._cascadeDistances[3]:1/0)}disposeOffscreenBuffers(){this._handle=i(this._handle),this._discardSnapshots()}set maxCascades(s){this.settings.maxNumCascadesHighQuality=t(Math.floor(s),1,4)}get maxCascades(){return this.settings.maxNumCascadesHighQuality}set enabled(t){this._enabled=t,t||this.disposeOffscreenBuffers()}get enabled(){return this._enabled}get ready(){return this._enabled&&null!=this.depthTexture}get cascades(){for(let t=0;t<this._numCascades;++t)et[t]=this._cascades[t];return et.length=this._numCascades,et}start(t,s,e,i,a){F(this.enabled);const{near:r,far:h}=jt(e);this._computeCascadeDistances(r,h,i),this._textureHeight=this._computeTextureHeight(t,a,i),this._setupMatrices(t,s);const{viewMatrix:o,projectionMatrix:n}=t;for(let c=0;c<this._numCascades;++c)this._constructCascade(c,n,o,s);this._lastOrigin=null,this.clear()}finish(){F(this.enabled),this._handle?.detachDepth()}getShadowMapMatrices(t){if(!this._lastOrigin||!C(t,this._lastOrigin)){this._lastOrigin=this._lastOrigin||H(),j(this._lastOrigin,t);for(let s=0;s<this._numCascades;++s){r(it,this._cascades[s].lightMat,t);for(let t=0;t<16;++t)at[16*s+t]=it[t]}}return at}moveSnapshot(t){F(this.enabled),this._handle?.detachDepth(),this._snapshots[t]?.release(),this._snapshots[t]=this._handle,this._handle=null,this.clear()}copySnapshot(t){const s=this._handle?.getTexture()?.descriptor;if(!this.enabled||!s)return;this._snapshots[t]?.release();const{width:e,height:i}=s,a=t===z.Highlight?"shadow highlight snapshot":"shadow no highlight snapshot";this._snapshots[t]=this._fbos.acquire(e,i,a,B.RGBA4);const r=this._fbos.rctx;this._bindFbo();const h=r.bindTexture(this._snapshots[t]?.getTexture(),W.TEXTURE_UNIT_FOR_UPDATES);r.gl.copyTexSubImage2D(N.TEXTURE_2D,0,0,0,0,0,e,i),r.bindTexture(h,W.TEXTURE_UNIT_FOR_UPDATES)}getSnapshot(t){return this.enabled?this._snapshots[t]?.getTexture():null}clear(){const t=this._fbos.rctx;this._ensureFbo(),this._bindFbo(),t.setClearColor(1,1,1,1),t.clear(A.COLOR|A.DEPTH)}_computeTextureHeight({pixelRatio:t,fullWidth:s,fullHeight:e},i,a){const r=Math.min(window.devicePixelRatio,i)/t,h=a?this.settings.textureSizeModHighQuality:this.settings.textureSizeModLowQuality;return U(Math.max(s,e)*r*h,this._maxTextureWidth/this._numCascades)}_ensureFbo(){this._handle?.fbo?.width===this._textureWidth&&this._handle?.fbo.height===this._textureHeight||(this._handle?.release(),this._handle=this._fbos.acquire(this._textureWidth,this._textureHeight,"shadow map",B.RGBA4)),this._handle?.acquireDepth(I.DEPTH16_RENDERBUFFER)}_discardSnapshot(t){this._snapshots[t]=i(this._snapshots[t])}_discardSnapshots(){for(let t=0;t<this._snapshots.length;++t)this._discardSnapshot(t);this._snapshots.length=0}_bindFbo(){this._fbos.rctx.bindFramebuffer(this._handle?.fbo)}_constructCascade(t,s,e,i){const a=this._cascades[t],o=-this._cascadeDistances[t],n=-this._cascadeDistances[t+1],c=(s[10]*o+s[14])/Math.abs(s[11]*o+s[15]),l=(s[10]*n+s[14])/Math.abs(s[11]*n+s[15]);F(c<l);for(let r=0;r<8;++r){v(k,r%4==0||r%4==3?-1:1,r%4==0||r%4==1?-1:1,r<4?c:l,1);const t=J[r];S(t,k,this._projectionViewInverse),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3]}T(st,J[0]),a.camera.viewMatrix=r(X,this._modelViewLight,st);for(let r=0;r<8;++r)y(J[r],J[r],a.camera.viewMatrix);let d=J[0][2],m=J[0][2];for(let r=1;r<8;++r)d=Math.min(d,J[r][2]),m=Math.max(m,J[r][2]);d-=200,m+=200,a.camera.near=-m,a.camera.far=-d,Ct(e,i,d,m,a.camera),h(a.lightMat,a.camera.projectionMatrix,a.camera.viewMatrix);const u=this._textureHeight;a.camera.viewport=[t*u,0,u,u]}_setupMatrices(t,s){h(this._projectionView,t.projectionMatrix,t.viewMatrix),o(this._projectionViewInverse,this._projectionView);const e=this._viewingMode===E.Global?t.eye:D(st,0,0,1);n(this._modelViewLight,[0,0,0],[-s[0],-s[1],-s[2]],e)}_computeCascadeDistances(t,e,i){const a=i?this.settings.maxNumCascadesHighQuality:this.settings.maxNumCascadesLowQuality;this._numCascades=Math.min(1+Math.floor(L(e/t,4)),a);const r=(e-t)/this._numCascades,h=(e/t)**(1/this._numCascades);let o=t,n=t;for(let c=0;c<this._numCascades+1;++c)this._cascadeDistances[c]=s(o,n,this.settings.splitSchemeLambda),o*=h,n+=r}get test(){}}const X=l(),k=R(),J=[];for(let Tt=0;Tt<8;++Tt)J.push(R());const K=M(),Y=M(),Z=M(),$=M(),tt=M(),st=H(),et=[],it=l(),at=c.concat(c,c,c,c),rt=M(),ht=M(),ot=[M(),M(),M(),M()],nt=M(),ct=M(),lt=M(),dt=M(),mt=M(),ut=M(),_t=M();function ft(t,s,e,i,a,r,h,o){d(rt,0,0);for(let d=0;d<4;++d)m(rt,rt,t[d]);u(rt,rt,.25),d(ht,0,0);for(let d=4;d<8;++d)m(ht,ht,t[d]);u(ht,ht,.25),_(ot[0],t[4],t[5],.5),_(ot[1],t[5],t[6],.5),_(ot[2],t[6],t[7],.5),_(ot[3],t[7],t[4],.5);let n=0,c=f(ot[0],rt);for(let d=1;d<4;++d){const t=f(ot[d],rt);t<c&&(c=t,n=d)}g(nt,ot[n],t[n+4]);const l=nt[0];let M,C;nt[0]=-nt[1],nt[1]=l,g(ct,ht,rt),p(ct,nt)<0&&x(nt,nt),_(nt,nt,ct,e),b(nt,nt),M=C=p(g(lt,t[0],rt),nt);for(let d=1;d<8;++d){const s=p(g(lt,t[d],rt),nt);s<M?M=s:s>C&&(C=s)}w(i,rt),u(lt,nt,M-s),m(i,i,lt);let j=-1,T=1,y=0,D=0;for(let d=0;d<8;++d){g(dt,t[d],i),b(dt,dt);const s=nt[0]*dt[1]-nt[1]*dt[0];s>0?s>j&&(j=s,y=d):s<T&&(T=s,D=d)}Q(j>0,"leftArea"),Q(T<0,"rightArea"),u(mt,nt,M),m(mt,mt,rt),u(ut,nt,C),m(ut,ut,rt),_t[0]=-nt[1],_t[1]=nt[0];const H=V(i,t[D],ut,m(lt,ut,_t),1,a),v=V(i,t[y],ut,lt,1,r),S=V(i,t[y],mt,m(lt,mt,_t),1,h),R=V(i,t[D],mt,lt,1,o);Q(H,"rayRay"),Q(v,"rayRay"),Q(S,"rayRay"),Q(R,"rayRay")}function gt(t,s){return 3*s+t}const pt=M();function xt(t,s){return d(pt,t[s],t[s+3]),pt}const bt=M(),wt=a();function Mt(t,s,e,i,a){g(bt,e,i),u(bt,bt,.5),wt[0]=bt[0],wt[1]=bt[1],wt[2]=0,wt[3]=bt[1],wt[4]=-bt[0],wt[5]=0,wt[6]=bt[0]*bt[0]+bt[1]*bt[1],wt[7]=bt[0]*bt[1]-bt[1]*bt[0],wt[8]=1,wt[gt(0,2)]=-p(xt(wt,0),t),wt[gt(1,2)]=-p(xt(wt,1),t);let r=p(xt(wt,0),e)+wt[gt(0,2)],h=p(xt(wt,1),e)+wt[gt(1,2)],o=p(xt(wt,0),i)+wt[gt(0,2)],n=p(xt(wt,1),i)+wt[gt(1,2)];r=-(r+o)/(h+n),wt[gt(0,0)]+=wt[gt(1,0)]*r,wt[gt(0,1)]+=wt[gt(1,1)]*r,wt[gt(0,2)]+=wt[gt(1,2)]*r,r=1/(p(xt(wt,0),e)+wt[gt(0,2)]),h=1/(p(xt(wt,1),e)+wt[gt(1,2)]),wt[gt(0,0)]*=r,wt[gt(0,1)]*=r,wt[gt(0,2)]*=r,wt[gt(1,0)]*=h,wt[gt(1,1)]*=h,wt[gt(1,2)]*=h,wt[gt(2,0)]=wt[gt(1,0)],wt[gt(2,1)]=wt[gt(1,1)],wt[gt(2,2)]=wt[gt(1,2)],wt[gt(1,2)]+=1,r=p(xt(wt,1),s)+wt[gt(1,2)],h=p(xt(wt,2),s)+wt[gt(2,2)],o=p(xt(wt,1),e)+wt[gt(1,2)],n=p(xt(wt,2),e)+wt[gt(2,2)],r=-.5*(r/h+o/n),wt[gt(1,0)]+=wt[gt(2,0)]*r,wt[gt(1,1)]+=wt[gt(2,1)]*r,wt[gt(1,2)]+=wt[gt(2,2)]*r,r=p(xt(wt,1),s)+wt[gt(1,2)],h=p(xt(wt,2),s)+wt[gt(2,2)],o=-h/r,wt[gt(1,0)]*=o,wt[gt(1,1)]*=o,wt[gt(1,2)]*=o,a[0]=wt[0],a[1]=wt[1],a[2]=0,a[3]=wt[2],a[4]=wt[3],a[5]=wt[4],a[6]=0,a[7]=wt[5],a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=wt[6],a[13]=wt[7],a[14]=0,a[15]=wt[8]}function Ct(t,s,i,a,r){const h=1/J[0][3],o=1/J[4][3];F(h<o);let n=h+Math.sqrt(h*o);const c=Math.sin(e(t[2]*s[0]+t[6]*s[1]+t[10]*s[2]));n/=c,ft(J,n,c,K,Y,Z,$,tt),Mt(K,Y,$,tt,r.projectionMatrix),r.projectionMatrix[10]=2/(i-a),r.projectionMatrix[14]=-(i+a)/(i-a)}function jt(t){let{near:s,far:e}=t;return s<2&&(s=2),e<2&&(e=2),s>=e&&(s=2,e=4),{near:s,far:e}}export{G as ShadowMap,z as SnapshotSlot};
5
+ import has from"../../../../core/has.js";import{clamp as t,lerp as s,acosClamped as e}from"../../../../core/mathUtils.js";import{releaseMaybe as i}from"../../../../core/maybe.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as r,multiply as h,invert as o,lookAt as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as c,create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as d,add as m,scale as u,lerp as _,squaredDistance as f,subtract as g,dot as p,negate as x,normalize as b,copy as w}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as M}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{p as C,c as j,v as T,t as y,i as D}from"../../../../chunks/vec32.js";import{create as H}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as v,t as S}from"../../../../chunks/vec42.js";import{create as O}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ViewingMode as R}from"../../../ViewingMode.js";import{ColorFormat as E,DepthRenderbufferFormat as U}from"../core/FBOCacheFormats.js";import{CascadeCamera as F}from"./CascadeCamera.js";import{applyTextureResizeModulo as L}from"./textureUtils.js";import{assert as N,logWithBase as Q,verify as V,rayRay2D as A}from"./Util.js";import{TextureType as B,FramebufferBit as I}from"../../../webgl/enums.js";import{Texture as W}from"../../../webgl/Texture.js";var z;!function(t){t[t.Highlight=0]="Highlight",t[t.ExcludeHighlight=1]="ExcludeHighlight"}(z||(z={}));class P{constructor(){this.camera=new F,this.lightMat=l()}}class q{constructor(){this.maxNumCascadesHighQuality=4,this.maxNumCascadesLowQuality=4,this.textureSizeModHighQuality=1.3,this.textureSizeModLowQuality=.9,this.splitSchemeLambda=0}}class G{constructor(t,s){this._fbos=t,this._viewingMode=s,this._enabled=!1,this._snapshots=new Array,this._textureHeight=0,this._numCascades=1,this.settings=new q,this._projectionView=l(),this._projectionViewInverse=l(),this._modelViewLight=l(),this._cascadeDistances=[0,0,0,0,0],this._usedCascadeDistances=O(),this._cascades=[new P,new P,new P,new P],this._lastOrigin=null,this._maxTextureWidth=Math.min(has("esri-mobile")?4096:16384,t.rctx.parameters.maxTextureSize)}dispose(){this.enabled=!1,this.disposeOffscreenBuffers()}get depthTexture(){return this._handle?.getTexture()}get _textureWidth(){return this._textureHeight*this._numCascades}get numCascades(){return this._numCascades}get cascadeDistances(){return v(this._usedCascadeDistances,this._cascadeDistances[0],this._numCascades>1?this._cascadeDistances[1]:1/0,this._numCascades>2?this._cascadeDistances[2]:1/0,this._numCascades>3?this._cascadeDistances[3]:1/0)}disposeOffscreenBuffers(){this._handle=i(this._handle),this._discardSnapshots()}set maxCascades(s){this.settings.maxNumCascadesHighQuality=t(Math.floor(s),1,4)}get maxCascades(){return this.settings.maxNumCascadesHighQuality}set enabled(t){this._enabled=t,t||this.disposeOffscreenBuffers()}get enabled(){return this._enabled}get ready(){return this._enabled&&null!=this.depthTexture}get cascades(){for(let t=0;t<this._numCascades;++t)et[t]=this._cascades[t];return et.length=this._numCascades,et}start(t,s,e,i,a){N(this.enabled);const{near:r,far:h}=jt(e);this._computeCascadeDistances(r,h,i),this._textureHeight=this._computeTextureHeight(t,a,i),this._setupMatrices(t,s);const{viewMatrix:o,projectionMatrix:n}=t;for(let c=0;c<this._numCascades;++c)this._constructCascade(c,n,o,s);this._lastOrigin=null,this.clear()}finish(){N(this.enabled),this._handle?.detachDepth()}getShadowMapMatrices(t){if(!this._lastOrigin||!C(t,this._lastOrigin)){this._lastOrigin=this._lastOrigin||H(),j(this._lastOrigin,t);for(let s=0;s<this._numCascades;++s){r(it,this._cascades[s].lightMat,t);for(let t=0;t<16;++t)at[16*s+t]=it[t]}}return at}moveSnapshot(t){N(this.enabled),this._handle?.detachDepth(),this._snapshots[t]?.release(),this._snapshots[t]=this._handle,this._handle=null,this.clear()}copySnapshot(t){const s=this._handle?.getTexture()?.descriptor;if(!this.enabled||!s)return;this._snapshots[t]?.release();const{width:e,height:i}=s,a=t===z.Highlight?"shadow highlight snapshot":"shadow no highlight snapshot";this._snapshots[t]=this._fbos.acquire(e,i,a,E.RGBA4UNORM);const r=this._fbos.rctx;this._bindFbo();const h=r.bindTexture(this._snapshots[t]?.getTexture(),W.TEXTURE_UNIT_FOR_UPDATES);r.gl.copyTexSubImage2D(B.TEXTURE_2D,0,0,0,0,0,e,i),r.bindTexture(h,W.TEXTURE_UNIT_FOR_UPDATES)}getSnapshot(t){return this.enabled?this._snapshots[t]?.getTexture():null}clear(){const t=this._fbos.rctx;this._ensureFbo(),this._bindFbo(),t.setClearColor(1,1,1,1),t.clear(I.COLOR|I.DEPTH)}_computeTextureHeight({pixelRatio:t,fullWidth:s,fullHeight:e},i,a){const r=Math.min(window.devicePixelRatio,i)/t,h=a?this.settings.textureSizeModHighQuality:this.settings.textureSizeModLowQuality;return L(Math.max(s,e)*r*h,this._maxTextureWidth/this._numCascades)}_ensureFbo(){this._handle?.fbo?.width===this._textureWidth&&this._handle?.fbo.height===this._textureHeight||(this._handle?.release(),this._handle=this._fbos.acquire(this._textureWidth,this._textureHeight,"shadow map",E.RGBA4UNORM)),this._handle?.acquireDepth(U.DEPTH16)}_discardSnapshot(t){this._snapshots[t]=i(this._snapshots[t])}_discardSnapshots(){for(let t=0;t<this._snapshots.length;++t)this._discardSnapshot(t);this._snapshots.length=0}_bindFbo(){this._fbos.rctx.bindFramebuffer(this._handle?.fbo)}_constructCascade(t,s,e,i){const a=this._cascades[t],o=-this._cascadeDistances[t],n=-this._cascadeDistances[t+1],c=(s[10]*o+s[14])/Math.abs(s[11]*o+s[15]),l=(s[10]*n+s[14])/Math.abs(s[11]*n+s[15]);N(c<l);for(let r=0;r<8;++r){v(k,r%4==0||r%4==3?-1:1,r%4==0||r%4==1?-1:1,r<4?c:l,1);const t=J[r];S(t,k,this._projectionViewInverse),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3]}T(st,J[0]),a.camera.viewMatrix=r(X,this._modelViewLight,st);for(let r=0;r<8;++r)y(J[r],J[r],a.camera.viewMatrix);let d=J[0][2],m=J[0][2];for(let r=1;r<8;++r)d=Math.min(d,J[r][2]),m=Math.max(m,J[r][2]);d-=200,m+=200,a.camera.near=-m,a.camera.far=-d,Ct(e,i,d,m,a.camera),h(a.lightMat,a.camera.projectionMatrix,a.camera.viewMatrix);const u=this._textureHeight;a.camera.viewport=[t*u,0,u,u]}_setupMatrices(t,s){h(this._projectionView,t.projectionMatrix,t.viewMatrix),o(this._projectionViewInverse,this._projectionView);const e=this._viewingMode===R.Global?t.eye:D(st,0,0,1);n(this._modelViewLight,[0,0,0],[-s[0],-s[1],-s[2]],e)}_computeCascadeDistances(t,e,i){const a=i?this.settings.maxNumCascadesHighQuality:this.settings.maxNumCascadesLowQuality;this._numCascades=Math.min(1+Math.floor(Q(e/t,4)),a);const r=(e-t)/this._numCascades,h=(e/t)**(1/this._numCascades);let o=t,n=t;for(let c=0;c<this._numCascades+1;++c)this._cascadeDistances[c]=s(o,n,this.settings.splitSchemeLambda),o*=h,n+=r}get test(){}}const X=l(),k=O(),J=[];for(let Tt=0;Tt<8;++Tt)J.push(O());const K=M(),Y=M(),Z=M(),$=M(),tt=M(),st=H(),et=[],it=l(),at=c.concat(c,c,c,c),rt=M(),ht=M(),ot=[M(),M(),M(),M()],nt=M(),ct=M(),lt=M(),dt=M(),mt=M(),ut=M(),_t=M();function ft(t,s,e,i,a,r,h,o){d(rt,0,0);for(let d=0;d<4;++d)m(rt,rt,t[d]);u(rt,rt,.25),d(ht,0,0);for(let d=4;d<8;++d)m(ht,ht,t[d]);u(ht,ht,.25),_(ot[0],t[4],t[5],.5),_(ot[1],t[5],t[6],.5),_(ot[2],t[6],t[7],.5),_(ot[3],t[7],t[4],.5);let n=0,c=f(ot[0],rt);for(let d=1;d<4;++d){const t=f(ot[d],rt);t<c&&(c=t,n=d)}g(nt,ot[n],t[n+4]);const l=nt[0];let M,C;nt[0]=-nt[1],nt[1]=l,g(ct,ht,rt),p(ct,nt)<0&&x(nt,nt),_(nt,nt,ct,e),b(nt,nt),M=C=p(g(lt,t[0],rt),nt);for(let d=1;d<8;++d){const s=p(g(lt,t[d],rt),nt);s<M?M=s:s>C&&(C=s)}w(i,rt),u(lt,nt,M-s),m(i,i,lt);let j=-1,T=1,y=0,D=0;for(let d=0;d<8;++d){g(dt,t[d],i),b(dt,dt);const s=nt[0]*dt[1]-nt[1]*dt[0];s>0?s>j&&(j=s,y=d):s<T&&(T=s,D=d)}V(j>0,"leftArea"),V(T<0,"rightArea"),u(mt,nt,M),m(mt,mt,rt),u(ut,nt,C),m(ut,ut,rt),_t[0]=-nt[1],_t[1]=nt[0];const H=A(i,t[D],ut,m(lt,ut,_t),1,a),v=A(i,t[y],ut,lt,1,r),S=A(i,t[y],mt,m(lt,mt,_t),1,h),O=A(i,t[D],mt,lt,1,o);V(H,"rayRay"),V(v,"rayRay"),V(S,"rayRay"),V(O,"rayRay")}function gt(t,s){return 3*s+t}const pt=M();function xt(t,s){return d(pt,t[s],t[s+3]),pt}const bt=M(),wt=a();function Mt(t,s,e,i,a){g(bt,e,i),u(bt,bt,.5),wt[0]=bt[0],wt[1]=bt[1],wt[2]=0,wt[3]=bt[1],wt[4]=-bt[0],wt[5]=0,wt[6]=bt[0]*bt[0]+bt[1]*bt[1],wt[7]=bt[0]*bt[1]-bt[1]*bt[0],wt[8]=1,wt[gt(0,2)]=-p(xt(wt,0),t),wt[gt(1,2)]=-p(xt(wt,1),t);let r=p(xt(wt,0),e)+wt[gt(0,2)],h=p(xt(wt,1),e)+wt[gt(1,2)],o=p(xt(wt,0),i)+wt[gt(0,2)],n=p(xt(wt,1),i)+wt[gt(1,2)];r=-(r+o)/(h+n),wt[gt(0,0)]+=wt[gt(1,0)]*r,wt[gt(0,1)]+=wt[gt(1,1)]*r,wt[gt(0,2)]+=wt[gt(1,2)]*r,r=1/(p(xt(wt,0),e)+wt[gt(0,2)]),h=1/(p(xt(wt,1),e)+wt[gt(1,2)]),wt[gt(0,0)]*=r,wt[gt(0,1)]*=r,wt[gt(0,2)]*=r,wt[gt(1,0)]*=h,wt[gt(1,1)]*=h,wt[gt(1,2)]*=h,wt[gt(2,0)]=wt[gt(1,0)],wt[gt(2,1)]=wt[gt(1,1)],wt[gt(2,2)]=wt[gt(1,2)],wt[gt(1,2)]+=1,r=p(xt(wt,1),s)+wt[gt(1,2)],h=p(xt(wt,2),s)+wt[gt(2,2)],o=p(xt(wt,1),e)+wt[gt(1,2)],n=p(xt(wt,2),e)+wt[gt(2,2)],r=-.5*(r/h+o/n),wt[gt(1,0)]+=wt[gt(2,0)]*r,wt[gt(1,1)]+=wt[gt(2,1)]*r,wt[gt(1,2)]+=wt[gt(2,2)]*r,r=p(xt(wt,1),s)+wt[gt(1,2)],h=p(xt(wt,2),s)+wt[gt(2,2)],o=-h/r,wt[gt(1,0)]*=o,wt[gt(1,1)]*=o,wt[gt(1,2)]*=o,a[0]=wt[0],a[1]=wt[1],a[2]=0,a[3]=wt[2],a[4]=wt[3],a[5]=wt[4],a[6]=0,a[7]=wt[5],a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=wt[6],a[13]=wt[7],a[14]=0,a[15]=wt[8]}function Ct(t,s,i,a,r){const h=1/J[0][3],o=1/J[4][3];N(h<o);let n=h+Math.sqrt(h*o);const c=Math.sin(e(t[2]*s[0]+t[6]*s[1]+t[10]*s[2]));n/=c,ft(J,n,c,K,Y,Z,$,tt),Mt(K,Y,$,tt,r.projectionMatrix),r.projectionMatrix[10]=2/(i-a),r.projectionMatrix[14]=-(i+a)/(i-a)}function jt(t){let{near:s,far:e}=t;return s<2&&(s=2),e<2&&(e=2),s>=e&&(s=2,e=4),{near:s,far:e}}export{G as ShadowMap,z as SnapshotSlot};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import e from"../../../../core/Error.js";import t from"../../../../core/Evented.js";import{disposeMaybe as r,removeMaybe as s}from"../../../../core/maybe.js";import{throwIfAborted as a,onAbort as i,createAbortError as o}from"../../../../core/promiseUtils.js";import{isUint8Array as n,isArrayBuffer as l}from"../../../../core/typedArrayUtil.js";import{isBlobProtocol as m,isDataProtocol as h}from"../../../../core/urlUtils.js";import{requestImage as p}from"../../../../support/requestImageUtils.js";import{loadImageAsync as d}from"../../../../support/requestUtils.js";import{TextureEncodingMimeType as _}from"./basicInterfaces.js";import{createTextureKTX2 as c,createTextureBasis as u,estimateMemoryKTX2 as g,estimateMemoryBasis as T}from"./BasisUtil.js";import{ContentObject as E}from"./ContentObject.js";import{ContentObjectType as x}from"./ContentObjectType.js";import{createDDSTexture as y}from"./DDSUtil.js";import{ensureImageMaxSize as f}from"./textureUtils.js";import{assert as A}from"./Util.js";import{TextureWrapMode as D,TextureSamplingMode as I,PixelFormat as F}from"../../../webgl/enums.js";import{Texture as M}from"../../../webgl/Texture.js";import{TextureDescriptor as w}from"../../../webgl/TextureDescriptor.js";class C extends E{constructor(e,r){super(),this._data=e,this.type=x.Texture,this.events=new t,this._parameters={...P,...r},this._startPreload(e)}dispose(){this.unload(),this._data=this.update=void 0}_startPreload(e){e instanceof HTMLVideoElement?(this.update=t=>this._update(e,t),this._startPreloadVideoElement(e)):e instanceof HTMLImageElement&&this._startPreloadImageElement(e)}_startPreloadVideoElement(e){if(!(m(e.src)||"auto"===e.preload&&e.crossOrigin)){e.preload="auto",e.crossOrigin="anonymous";const t=!e.paused;if(e.src=e.src,t&&e.autoplay){const t=()=>{e.removeEventListener("canplay",t),e.play()};e.addEventListener("canplay",t)}}}_startPreloadImageElement(e){h(e.src)||m(e.src)||e.crossOrigin||(e.crossOrigin="anonymous",e.src=e.src)}_createDescriptor(e){const t=new w;return t.wrapMode=this._parameters.wrap??D.REPEAT,t.flipped=!this._parameters.noUnpackFlip,t.samplingMode=this._parameters.mipmap?I.LINEAR_MIPMAP_LINEAR:I.LINEAR,t.hasMipmap=!!this._parameters.mipmap,t.preMultiplyAlpha=!!this._parameters.preMultiplyAlpha,t.maxAnisotropy=this._parameters.maxAnisotropy??(this._parameters.mipmap?e.parameters.maxMaxAnisotropy:1),t}get glTexture(){return this._glTexture??this._emptyTexture}get loaded(){return null!=this._glTexture}get usedMemory(){return this._glTexture?.usedMemory||L(this._data,this._parameters)}load(e){if(this._loadingPromise)return this._loadingPromise;if(this._glTexture)return this._glTexture;const t=this._data;return null==t?(this._glTexture=new M(e,this._createDescriptor(e),null),this._glTexture):(this._emptyTexture=e.emptyTexture,this._parameters.reloadable||(this._data=void 0),"string"==typeof t?this._loadFromURL(e,t):t instanceof Image?this._loadFromImageElement(e,t):t instanceof HTMLVideoElement?this._loadFromVideoElement(e,t):t instanceof ImageData||t instanceof HTMLCanvasElement?this._loadFromImage(e,t):n(t)&&this._parameters.encoding===_.DDS_ENCODING?this._loadFromDDSData(e,t):l(t)&&this._parameters.encoding===_.DDS_ENCODING?this._loadFromDDSData(e,new Uint8Array(t)):(l(t)||n(t))&&this._parameters.encoding===_.KTX2_ENCODING?this._loadFromKTX2(e,t):(l(t)||n(t))&&this._parameters.encoding===_.BASIS_ENCODING?this._loadFromBasis(e,t):n(t)?this._loadFromPixelData(e,t):l(t)?this._loadFromPixelData(e,new Uint8Array(t)):null)}_update(e,t){return null==this._glTexture||e.readyState<HTMLMediaElement.HAVE_CURRENT_DATA||t===e.currentTime?t:(this._glTexture.setData(e),this._glTexture.descriptor.hasMipmap&&this._glTexture.generateMipmap(),this._parameters.updateCallback&&this._parameters.updateCallback(),e.currentTime)}_loadFromDDSData(e,t){return this._glTexture=y(e,this._createDescriptor(e),t),this._emptyTexture=null,this._glTexture}_loadFromKTX2(e,t){return this._loadAsync((()=>c(e,this._createDescriptor(e),t).then((e=>(this._glTexture=e,e)))))}_loadFromBasis(e,t){return this._loadAsync((()=>u(e,this._createDescriptor(e),t).then((e=>(this._glTexture=e,e)))))}_loadFromPixelData(e,t){A(this._parameters.width>0&&this._parameters.height>0);const r=this._createDescriptor(e);return r.pixelFormat=1===this._parameters.components?F.LUMINANCE:3===this._parameters.components?F.RGB:F.RGBA,r.width=this._parameters.width??0,r.height=this._parameters.height??0,this._glTexture=new M(e,r,t),this._glTexture}_loadFromURL(e,t){return this._loadAsync((async r=>{const s=await p(t,{signal:r});return a(r),this._loadFromImage(e,s)}))}_loadFromImageElement(e,t){return t.complete?this._loadFromImage(e,t):this._loadAsync((async r=>{const s=await d(t,t.src,!1,r);return a(r),this._loadFromImage(e,s)}))}_loadFromVideoElement(e,t){return t.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA?this._loadFromImage(e,t):this._loadFromVideoElementAsync(e,t)}_loadFromVideoElementAsync(t,r){return this._loadAsync((a=>new Promise(((n,l)=>{const m=()=>{r.removeEventListener("loadeddata",h),r.removeEventListener("error",p),s(d)},h=()=>{r.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA&&(m(),n(this._loadFromImage(t,r)))},p=t=>{m(),l(t||new e("texture:load-error","Failed to load video"))};r.addEventListener("loadeddata",h),r.addEventListener("error",p);const d=i(a,(()=>p(o())))}))))}_loadFromImage(e,t){let r=t;r instanceof HTMLVideoElement||(r=f(r,e.parameters));const s=j(r);this._parameters.width=s.width,this._parameters.height=s.height;const a=this._createDescriptor(e);return a.pixelFormat=3===this._parameters.components?F.RGB:F.RGBA,a.width=s.width,a.height=s.height,a.compressionHandle=this._parameters.compressionHandle,a.compressionCallback=this._parameters.compressionCallback,this._glTexture=new M(e,a,r),this._emptyTexture=null,this.events.emit("loaded"),this._glTexture}_loadAsync(e){const t=new AbortController;this._loadingController=t;const r=e(t.signal);this._loadingPromise=r;const s=()=>{this._loadingController===t&&(this._loadingController=null),this._loadingPromise===r&&(this._loadingPromise=null),this._emptyTexture=null};return r.then(s,s),r}unload(){if(this._glTexture=r(this._glTexture),this._emptyTexture=null,null!=this._loadingController){const e=this._loadingController;this._loadingController=null,this._loadingPromise=null,e.abort()}this.events.emit("unloaded")}get parameters(){return this._parameters}}function L(e,t){if(null==e)return 0;if(l(e)||n(e))return t.encoding===_.KTX2_ENCODING?g(e,!!t.mipmap):t.encoding===_.BASIS_ENCODING?T(e,!!t.mipmap):e.byteLength;const{width:r,height:s}=e instanceof Image||e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement?j(e):t;return(t.mipmap?4/3:1)*r*s*(t.components||4)||0}function j(e){return e instanceof HTMLVideoElement?{width:e.videoWidth,height:e.videoHeight}:e}const P={wrap:{s:D.REPEAT,t:D.REPEAT},mipmap:!0,noUnpackFlip:!1,preMultiplyAlpha:!1};export{C as Texture};
5
+ import"../../../../core/has.js";import e from"../../../../core/Error.js";import t from"../../../../core/Evented.js";import{disposeMaybe as r,removeMaybe as s}from"../../../../core/maybe.js";import{throwIfAborted as i,onAbort as a,createAbortError as o}from"../../../../core/promiseUtils.js";import{isUint8Array as n,isArrayBuffer as l}from"../../../../core/typedArrayUtil.js";import{isBlobProtocol as m,isDataProtocol as h}from"../../../../core/urlUtils.js";import{whenVideoPlayable as p}from"../../../../layers/support/videoUtils.js";import{requestImage as d}from"../../../../support/requestImageUtils.js";import{loadImageAsync as _}from"../../../../support/requestUtils.js";import{TextureEncodingMimeType as u}from"./basicInterfaces.js";import{createTextureKTX2 as c,createTextureBasis as g,estimateMemoryKTX2 as T,estimateMemoryBasis as E}from"./BasisUtil.js";import{ContentObject as x}from"./ContentObject.js";import{ContentObjectType as f}from"./ContentObjectType.js";import{createDDSTexture as y}from"./DDSUtil.js";import{ensureImageMaxSize as A}from"./textureUtils.js";import{assert as D}from"./Util.js";import{TextureWrapMode as I,TextureSamplingMode as F,PixelFormat as M}from"../../../webgl/enums.js";import{Texture as w}from"../../../webgl/Texture.js";import{TextureDescriptor as C}from"../../../webgl/TextureDescriptor.js";class j extends x{constructor(e,r){super(),this._data=e,this.type=f.Texture,this.events=new t,this._parameters={...N,...r},this._startPreload(e)}dispose(){this.unload(),this._data=this.update=void 0}_startPreload(e){e instanceof HTMLVideoElement?(this.update=t=>this._update(e,t),this._startPreloadVideoElement(e)):e instanceof HTMLImageElement&&this._startPreloadImageElement(e)}_startPreloadVideoElement(e){if(!(m(e.src)||"auto"===e.preload&&e.crossOrigin)){e.preload="auto",e.crossOrigin="anonymous";const t=e.paused;if(e.src=e.src,t&&e.autoplay){const t=[];p(e,(e=>t.push(e))).then((()=>{e.play()})).finally((()=>t.forEach((e=>e.remove()))))}}}_startPreloadImageElement(e){h(e.src)||m(e.src)||e.crossOrigin||(e.crossOrigin="anonymous",e.src=e.src)}_createDescriptor(e){const t=new C;return t.wrapMode=this._parameters.wrap??I.REPEAT,t.flipped=!this._parameters.noUnpackFlip,t.samplingMode=this._parameters.mipmap?F.LINEAR_MIPMAP_LINEAR:F.LINEAR,t.hasMipmap=!!this._parameters.mipmap,t.preMultiplyAlpha=!!this._parameters.preMultiplyAlpha,t.maxAnisotropy=this._parameters.maxAnisotropy??(this._parameters.mipmap?e.parameters.maxMaxAnisotropy:1),t}get glTexture(){return this._glTexture??this._emptyTexture}get loaded(){return null!=this._glTexture}get usedMemory(){return this._glTexture?.usedMemory||L(this._data,this._parameters)}load(e){if(this._loadingPromise)return this._loadingPromise;if(this._glTexture)return this._glTexture;const t=this._data;return null==t?(this._glTexture=new w(e,this._createDescriptor(e),null),this._glTexture):(this._emptyTexture=e.emptyTexture,this._parameters.reloadable||(this._data=void 0),"string"==typeof t?this._loadFromURL(e,t):t instanceof Image?this._loadFromImageElement(e,t):t instanceof HTMLVideoElement?this._loadFromVideoElement(e,t):t instanceof ImageData||t instanceof HTMLCanvasElement?this._loadFromImage(e,t):n(t)&&this._parameters.encoding===u.DDS_ENCODING?this._loadFromDDSData(e,t):l(t)&&this._parameters.encoding===u.DDS_ENCODING?this._loadFromDDSData(e,new Uint8Array(t)):(l(t)||n(t))&&this._parameters.encoding===u.KTX2_ENCODING?this._loadFromKTX2(e,t):(l(t)||n(t))&&this._parameters.encoding===u.BASIS_ENCODING?this._loadFromBasis(e,t):n(t)?this._loadFromPixelData(e,t):l(t)?this._loadFromPixelData(e,new Uint8Array(t)):null)}_update(e,t){return null==this._glTexture||e.readyState<HTMLMediaElement.HAVE_CURRENT_DATA||t===e.currentTime?t:(this._glTexture.setData(e),this._glTexture.descriptor.hasMipmap&&this._glTexture.generateMipmap(),this._parameters.updateCallback&&this._parameters.updateCallback(),e.currentTime)}_loadFromDDSData(e,t){return this._glTexture=y(e,this._createDescriptor(e),t),this._emptyTexture=null,this._glTexture}_loadFromKTX2(e,t){return this._loadAsync((()=>c(e,this._createDescriptor(e),t).then((e=>(this._glTexture=e,e)))))}_loadFromBasis(e,t){return this._loadAsync((()=>g(e,this._createDescriptor(e),t).then((e=>(this._glTexture=e,e)))))}_loadFromPixelData(e,t){D(this._parameters.width>0&&this._parameters.height>0);const r=this._createDescriptor(e);return r.pixelFormat=1===this._parameters.components?M.LUMINANCE:3===this._parameters.components?M.RGB:M.RGBA,r.width=this._parameters.width??0,r.height=this._parameters.height??0,this._glTexture=new w(e,r,t),this._glTexture}_loadFromURL(e,t){return this._loadAsync((async r=>{const s=await d(t,{signal:r});return i(r),this._loadFromImage(e,s)}))}_loadFromImageElement(e,t){return t.complete?this._loadFromImage(e,t):this._loadAsync((async r=>{const s=await _(t,t.src,!1,r);return i(r),this._loadFromImage(e,s)}))}_loadFromVideoElement(e,t){return t.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA?this._loadFromImage(e,t):this._loadFromVideoElementAsync(e,t)}_loadFromVideoElementAsync(t,r){return this._loadAsync((i=>new Promise(((n,l)=>{const m=()=>{r.removeEventListener("loadeddata",h),r.removeEventListener("error",p),s(d)},h=()=>{r.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA&&(m(),n(this._loadFromImage(t,r)))},p=t=>{m(),l(t||new e("texture:load-error","Failed to load video"))};r.addEventListener("loadeddata",h),r.addEventListener("error",p);const d=a(i,(()=>p(o())))}))))}_loadFromImage(e,t){let r=t;r instanceof HTMLVideoElement||(r=A(r,e.parameters));const s=P(r);this._parameters.width=s.width,this._parameters.height=s.height;const i=this._createDescriptor(e);return i.pixelFormat=3===this._parameters.components?M.RGB:M.RGBA,i.width=s.width,i.height=s.height,i.compressionHandle=this._parameters.compressionHandle,i.compressionCallback=this._parameters.compressionCallback,this._glTexture=new w(e,i,r),this._emptyTexture=null,this.events.emit("loaded"),this._glTexture}_loadAsync(e){const t=new AbortController;this._loadingController=t;const r=e(t.signal);this._loadingPromise=r;const s=()=>{this._loadingController===t&&(this._loadingController=null),this._loadingPromise===r&&(this._loadingPromise=null),this._emptyTexture=null};return r.then(s,s),r}unload(){if(this._glTexture=r(this._glTexture),this._emptyTexture=null,null!=this._loadingController){const e=this._loadingController;this._loadingController=null,this._loadingPromise=null,e.abort()}this.events.emit("unloaded")}get parameters(){return this._parameters}}function L(e,t){if(null==e)return 0;if(l(e)||n(e))return t.encoding===u.KTX2_ENCODING?T(e,!!t.mipmap):t.encoding===u.BASIS_ENCODING?E(e,!!t.mipmap):e.byteLength;const{width:r,height:s}=e instanceof Image||e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement?P(e):t;return(t.mipmap?4/3:1)*r*s*(t.components||4)||0}function P(e){return e instanceof HTMLVideoElement?{width:e.videoWidth,height:e.videoHeight}:e}const N={wrap:{s:I.REPEAT,t:I.REPEAT},mipmap:!0,noUnpackFlip:!1,preMultiplyAlpha:!1};export{j as Texture};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import s from"../../../../core/Collection.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../../core/maybe.js";import{watch as i,initial as o,when as a,sync as n}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{translate as c,fromTranslation as p,scale as w,mul as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{a as u,j as f}from"../../../../chunks/vec32.js";import{create as v,fromValues as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{l as V}from"../../../../chunks/sphere.js";import{InternalRenderCategory as g}from"../../webgl.js";import b from"../../webgl/RenderNode.js";import{RenderRequestType as M}from"./basicInterfaces.js";import{RenderFeature as j}from"./RenderFeature.js";import{ViewshedShadowMap as S}from"./ViewshedShadowMap.js";import{V as y}from"../../../../chunks/Viewshed.glsl.js";import{ViewshedTechnique as R}from"../shaders/ViewshedTechnique.js";let P=class extends b{get shadowMap(){return this._shadowMap}get hasViewsheds(){return this._viewsheds.length>0}get _contentPixelRatio(){return this.view.state.contentPixelRatio}get _viewshedsInView(){return this._viewsheds.items.filter((e=>E(this.view,e)))}constructor(e){super(e),this._passParameters=new y,this._viewsheds=new s,this._shadowMap=null,this.consumes={required:[g.VIEWSHED,"normals"]},this.produces=g.VIEWSHED,this.requireGeometryDepth=!0}initialize(){this._shadowMap=new S(this.fboCache),this.addHandles([i((()=>this.view.resolutionScale),(e=>{const s=this._shadowMap;s&&(s.settings.textureSizeQuality=e)}),o),a((()=>!this.hasViewsheds),(()=>this._shadowMap?.dispose())),i((()=>this._viewshedsInView.map((e=>[e.observerRenderSpace,e.heading,e.tilt,e.farDistance,e.horizontalFieldOfView,e.verticalFieldOfView]))),(()=>this.requestRender(M.UPDATE)),n)])}destroy(){this._shadowMap=r(this._shadowMap)}precompile(){if(this.hasViewsheds){this.techniques.precompile(R);for(const e of this._viewshedsInView)if(this._shadowMap?.isActive(e))return void this.view.stage.renderer.precompileViewshedShadowMap()}}render(e){const s=this.bindParameters,t=this.renderingContext,r=e.find((({name:e})=>e===g.VIEWSHED));if(!this.hasViewsheds||!s.depth)return r;this._passParameters.shadowMap=this._shadowMap??this._passParameters.shadowMap,this._passParameters.normals=e.find((({name:e})=>"normals"===e))?.getTexture();const i=this.techniques.get(R);if(!i?.compiled)return this.requestRender(M.UPDATE),r;const o=this.view.stage.renderer.isFeatureEnabled(j.HighResolutionViewshed);for(const a of this._viewshedsInView){if(!this._renderShadowCubeMap(s,a,o)||!this._shadowMap?.ready)continue;const e=this._setupViewshedParameters(a,s.camera);t.bindTechnique(i,s,e),t.bindFramebuffer(r.fbo),t.screen.draw()}return this.shadowMap?.dispose(),r}updateViewsheds(e){const s=this._viewsheds,{removes:t,adds:r}=e;if(t&&(Array.isArray(t)?s.removeMany(t):s.remove(t)),r)if(Array.isArray(r)){const e=r.filter((e=>!s.includes(e)));s.addMany(e)}else s.includes(r)||s.add(r)}_renderShadowCubeMap(e,s,t){const r=this._shadowMap;if(!r)return!1;const i=this.view.basemapTerrain.hasStencilEnabledExtents,o=r.start(e.camera,s,t,this._contentPixelRatio,i);return o&&r.faces.forEach((e=>this.view.stage.renderer.renderViewshedShadowMap(e))),r.finish(),o}_setupViewshedParameters(e,s){const r=this._shadowMap;if(!r)return this._passParameters;const i=this._passParameters,o=e.effectiveObserverRenderSpace;i.localOrigin=o,i.observerOffset=u(O,e.observerRenderSpace,e.effectiveObserverRenderSpace),i.fovs=[t(e.horizontalFieldOfView),t(e.verticalFieldOfView)],i.headingAndTilt=[t(e.heading),t(e.tiltParallelToSurface)],i.upVector=e.tiltedUpVector;const a=x(e.targetRenderSpace,o);i.targetVector=a;const n=new Array,h=new Array;for(let t=0;t<r.numActiveFaces;t++)c(q,r.viewshedViewMatrices[t],o),n.push(...q),A(r.viewshedProjectionMatrices[t],q,D),h.push(...D);return i.viewMatrices=n,i.projectionMatrices=h,i.volumeOffset=this.selectedViewshed?.()===e.viewshed?I(e,this.view,s.eye):0,i}get test(){return{viewsheds:this._viewsheds,shadowMap:this._shadowMap,viewshedsInView:this._viewshedsInView}}};function x(e,s){const t=v();return u(t,e,s)}function A(e,s,t){const r=_(.5,.5,.5);return p(t,r),w(t,t,r),m(t,t,e),m(t,t,s),t}function E(e,s){const t=V(s.observerRenderSpace,s.farDistanceRenderSpace);return!!e.ready&&e.frustum.intersectsSphere(t)}function I(e,s,t){if(null==e)return 0;const{observerRenderSpace:r,targetRenderSpace:i}=e,o=f(t,r)>f(t,i)?e.observer:e.target;return s.pixelSizeAt(o)}e([h()],P.prototype,"selectedViewshed",void 0),e([h()],P.prototype,"shadowMap",null),e([h()],P.prototype,"hasViewsheds",null),e([h()],P.prototype,"_contentPixelRatio",null),e([h()],P.prototype,"_viewshedsInView",null),e([h()],P.prototype,"consumes",void 0),e([h()],P.prototype,"produces",void 0),P=e([d("esri.views.3d.webgl-engine.lib.Viewshed")],P);const O=v(),q=l(),D=l();export{P as Viewshed,I as computeOffsetScale};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import s from"../../../../core/Collection.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../../core/maybe.js";import{watch as i,initial as o,when as a,sync as n}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{translate as c,fromTranslation as p,scale as w,mul as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{a as u,j as f}from"../../../../chunks/vec32.js";import{create as v,fromValues as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{l as V}from"../../../../chunks/sphere.js";import{InternalRenderCategory as g}from"../../webgl.js";import b from"../../webgl/RenderNode.js";import{RenderRequestType as M}from"./basicInterfaces.js";import{RenderFeature as j}from"./RenderFeature.js";import{ViewshedShadowMap as S}from"./ViewshedShadowMap.js";import{V as y}from"../../../../chunks/Viewshed.glsl.js";import{ViewshedTechnique as R}from"../shaders/ViewshedTechnique.js";let P=class extends b{get shadowMap(){return this._shadowMap}get hasViewsheds(){return this._viewsheds.length>0}get _contentPixelRatio(){return this.view.state.contentPixelRatio}get _viewshedsInView(){return this._viewsheds.items.filter((e=>E(this.view,e)))}constructor(e){super(e),this.isDecoration=!1,this._passParameters=new y,this._viewsheds=new s,this._shadowMap=null,this.consumes={required:[g.VIEWSHED,"normals"]},this.produces=g.VIEWSHED,this.requireGeometryDepth=!0}initialize(){this._shadowMap=new S(this.fboCache),this.addHandles([i((()=>this.view.resolutionScale),(e=>{const s=this._shadowMap;s&&(s.settings.textureSizeQuality=e)}),o),a((()=>!this.hasViewsheds),(()=>this._shadowMap?.dispose())),i((()=>this._viewshedsInView.map((e=>[e.observerRenderSpace,e.heading,e.tilt,e.farDistance,e.horizontalFieldOfView,e.verticalFieldOfView]))),(()=>this.requestRender(M.UPDATE)),n)])}destroy(){this._shadowMap=r(this._shadowMap)}precompile(){if(this.hasViewsheds){this.techniques.precompile(R);for(const e of this._viewshedsInView)if(this._shadowMap?.isActive(e))return void this.view.stage.renderer.precompileViewshedShadowMap()}}render(e){const s=this.bindParameters,t=this.renderingContext,r=e.find((({name:e})=>e===g.VIEWSHED));if(!this.hasViewsheds||!s.depth||this.isDecoration&&!s.decorations)return r;this._passParameters.shadowMap=this._shadowMap??this._passParameters.shadowMap,this._passParameters.normals=e.find((({name:e})=>"normals"===e))?.getTexture();const i=this.techniques.get(R);if(!i?.compiled)return this.requestRender(M.UPDATE),r;const o=this.view.stage.renderer.isFeatureEnabled(j.HighResolutionViewshed);for(const a of this._viewshedsInView){if(!this._renderShadowCubeMap(s,a,o)||!this._shadowMap?.ready)continue;const e=this._setupViewshedParameters(a,s.camera);t.bindTechnique(i,s,e),t.bindFramebuffer(r.fbo),t.screen.draw()}return this.shadowMap?.dispose(),r}updateViewsheds(e){const s=this._viewsheds,{removes:t,adds:r}=e;if(t&&(Array.isArray(t)?s.removeMany(t):s.remove(t)),r)if(Array.isArray(r)){const e=r.filter((e=>!s.includes(e)));s.addMany(e)}else s.includes(r)||s.add(r)}_renderShadowCubeMap(e,s,t){const r=this._shadowMap;if(!r)return!1;const i=this.view.basemapTerrain.hasStencilEnabledExtents,o=r.start(e.camera,s,t,this._contentPixelRatio,i);return o&&r.faces.forEach((e=>this.view.stage.renderer.renderViewshedShadowMap(e))),r.finish(),o}_setupViewshedParameters(e,s){const r=this._shadowMap;if(!r)return this._passParameters;const i=this._passParameters,o=e.effectiveObserverRenderSpace;i.localOrigin=o,i.observerOffset=u(I,e.observerRenderSpace,e.effectiveObserverRenderSpace),i.fovs=[t(e.horizontalFieldOfView),t(e.verticalFieldOfView)],i.headingAndTilt=[t(e.heading),t(e.tiltParallelToSurface)],i.upVector=e.tiltedUpVector;const a=x(e.targetRenderSpace,o);i.targetVector=a;const n=new Array,h=new Array;for(let t=0;t<r.numActiveFaces;t++)c(O,r.viewshedViewMatrices[t],o),n.push(...O),A(r.viewshedProjectionMatrices[t],O,q),h.push(...q);return i.viewMatrices=n,i.projectionMatrices=h,i.volumeOffset=this.selectedViewshed?.()===e.viewshed?D(e,this.view,s.eye):0,i}get test(){return{viewsheds:this._viewsheds,shadowMap:this._shadowMap,viewshedsInView:this._viewshedsInView}}};function x(e,s){const t=v();return u(t,e,s)}function A(e,s,t){const r=_(.5,.5,.5);return p(t,r),w(t,t,r),m(t,t,e),m(t,t,s),t}function E(e,s){const t=V(s.observerRenderSpace,s.farDistanceRenderSpace);return!!e.ready&&e.frustum.intersectsSphere(t)}function D(e,s,t){if(null==e)return 0;const{observerRenderSpace:r,targetRenderSpace:i}=e,o=f(t,r)>f(t,i)?e.observer:e.target;return s.pixelSizeAt(o)}e([h()],P.prototype,"selectedViewshed",void 0),e([h()],P.prototype,"isDecoration",void 0),e([h()],P.prototype,"shadowMap",null),e([h()],P.prototype,"hasViewsheds",null),e([h()],P.prototype,"_contentPixelRatio",null),e([h()],P.prototype,"_viewshedsInView",null),e([h()],P.prototype,"consumes",void 0),e([h()],P.prototype,"produces",void 0),P=e([d("esri.views.3d.webgl-engine.lib.Viewshed")],P);const I=v(),O=l(),q=l();export{P as Viewshed,D as computeOffsetScale};