@arcgis/core 4.31.0-next.20240708 → 4.31.0-next.20240710

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 (239) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{0975e54c50383375cc09.js → 14cf7411e8318a1bccb9.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{71852b8437ec66b9ef06.js → 2123ab24163a532ebc8d.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{c91b3800cf3891bf2d59.js → 252ff37bf5e12dae0b18.js} +1 -1
  5. package/assets/esri/core/workers/chunks/2799007b5f3f4a2e364c.js +51 -0
  6. package/assets/esri/core/workers/chunks/{ff5e6d823d512f87a527.js → 2dddb8a989b9c96572fe.js} +1 -1
  7. package/assets/esri/core/workers/chunks/34b5bab6239c7277f854.js +1 -0
  8. package/assets/esri/core/workers/chunks/543f9db420c99d429637.js +1 -0
  9. package/assets/esri/core/workers/chunks/{5089a12084a8a8fb93d8.js → 61e5179fb49866241128.js} +1 -1
  10. package/assets/esri/core/workers/chunks/632e3ba2b8a881df29a0.js +1 -0
  11. package/assets/esri/core/workers/chunks/63eb1cc923bb8dcb3cb3.js +1 -0
  12. package/assets/esri/core/workers/chunks/{380e2654bc7e07163df0.js → 725a0eae5248a933db05.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{1cc4a89c96a36d6b3d52.js → 7767559d56d16b644655.js} +1 -1
  14. package/assets/esri/core/workers/chunks/7baf288a07401f9e972d.js +1 -0
  15. package/assets/esri/core/workers/chunks/{43e83f4d827f59ff556a.js → 8087288f00dfdcc479b9.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{a5fbe1c95e49093e5af4.js → 8cce4b218568638e6e64.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{c7e2a97cb7bcd153bcef.js → 8e326def543268f8a08e.js} +1 -1
  18. package/assets/esri/core/workers/chunks/92cb45b18e151db007dc.js +1 -0
  19. package/assets/esri/core/workers/chunks/b2e8cc76381077b78d4c.js +1 -0
  20. package/assets/esri/core/workers/chunks/b6a8132708afcd988fa9.js +1 -0
  21. package/assets/esri/core/workers/chunks/{b4d850e82a8ae902d684.js → c44cc686774ff53c0a94.js} +1 -1
  22. package/assets/esri/core/workers/chunks/c52701477405c1fb2072.js +1 -0
  23. package/assets/esri/core/workers/chunks/{9ed11b9202013ca001ee.js → cfc2a1858a8bbb284979.js} +2 -2
  24. package/assets/esri/core/workers/chunks/{9ed11b9202013ca001ee.js.LICENSE.txt → cfc2a1858a8bbb284979.js.LICENSE.txt} +1 -1
  25. package/assets/esri/core/workers/chunks/d9863289c69d2550cd49.js +1 -0
  26. package/assets/esri/core/workers/chunks/e1f4df3a5b0b31521b3c.js +1 -0
  27. package/assets/esri/core/workers/chunks/ee72a006e25e94a4cd4a.js +1039 -0
  28. package/assets/esri/core/workers/chunks/{61505947371cebab9cbe.js → fdebfe55cd097714ec11.js} +1 -1
  29. package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +13 -18
  30. package/assets/esri/themes/dark/main.css +1 -1
  31. package/assets/esri/themes/light/main.css +1 -1
  32. package/assets/esri/themes/light/view.css +1 -1
  33. package/chunks/AtmosphereCompositing.glsl.js +6 -9
  34. package/chunks/BlendLayers.glsl.js +1 -7
  35. package/chunks/BlendWeights.glsl.js +81 -86
  36. package/chunks/Blur.glsl.js +1 -3
  37. package/chunks/ChapmanAtmosphere.glsl.js +3 -8
  38. package/chunks/CheckerBoard.glsl.js +3 -9
  39. package/chunks/Clouds.glsl.js +21 -10
  40. package/chunks/CloudsComposition.glsl.js +3 -7
  41. package/chunks/ColorMaterial.glsl.js +3 -9
  42. package/chunks/ComponentShader.glsl.js +41 -75
  43. package/chunks/Compositing.glsl.js +5 -7
  44. package/chunks/DefaultMaterial.glsl.js +68 -73
  45. package/chunks/EdgeDetect.glsl.js +29 -39
  46. package/chunks/EdgeShader.glsl.js +37 -60
  47. package/chunks/Fog.glsl.js +4 -9
  48. package/chunks/HUDCompositing.glsl.js +1 -3
  49. package/chunks/HUDMaterial.glsl.js +11 -20
  50. package/chunks/Heatmap.glsl.js +3 -11
  51. package/chunks/HeatmapDensity.glsl.js +12 -15
  52. package/chunks/HighlightApply.glsl.js +130 -174
  53. package/chunks/HighlightDownsample.glsl.js +29 -32
  54. package/chunks/ImageMaterial.glsl.js +11 -21
  55. package/chunks/LaserlinePath.glsl.js +6 -10
  56. package/chunks/Laserlines.glsl.js +8 -20
  57. package/chunks/LineCallout.glsl.js +91 -108
  58. package/chunks/LineMarker.glsl.js +62 -53
  59. package/chunks/Magnifier.glsl.js +4 -9
  60. package/chunks/MeasurementArrow.glsl.js +9 -15
  61. package/chunks/NativeLine.glsl.js +8 -12
  62. package/chunks/NoiseTextureAtlas.glsl.js +89 -86
  63. package/chunks/OITCompositing.glsl.js +8 -12
  64. package/chunks/OverlayCompositing.glsl.js +2 -4
  65. package/chunks/Path.glsl.js +31 -55
  66. package/chunks/Pattern.glsl.js +16 -20
  67. package/chunks/PointRenderer.glsl.js +39 -48
  68. package/chunks/Precipitation.glsl.js +22 -39
  69. package/chunks/RasterColorizer.glsl.js +25 -33
  70. package/chunks/RealisticTree.glsl.js +53 -65
  71. package/chunks/RibbonLine.glsl.js +31 -36
  72. package/chunks/SSAO.glsl.js +7 -10
  73. package/chunks/SSAOBlur.glsl.js +10 -14
  74. package/chunks/ShadedColorMaterial.glsl.js +12 -15
  75. package/chunks/ShadowCastAccumulate.glsl.js +6 -8
  76. package/chunks/ShadowCastVisualize.glsl.js +12 -18
  77. package/chunks/ShadowHighlight.glsl.js +49 -51
  78. package/chunks/SimpleAtmosphere.glsl.js +4 -13
  79. package/chunks/SlicePlaneMaterial.glsl.js +3 -7
  80. package/chunks/Stars.glsl.js +3 -7
  81. package/chunks/Terrain.glsl.js +20 -61
  82. package/chunks/TextureOnly.glsl.js +2 -4
  83. package/chunks/Viewshed.glsl.js +20 -38
  84. package/chunks/WaterSurface.glsl.js +34 -60
  85. package/core/accessorSupport/tracking.js +1 -1
  86. package/core/workers/registry.js +1 -1
  87. package/geometry/Circle.js +1 -1
  88. package/geometry/Polygon.js +1 -1
  89. package/geometry/Polyline.js +1 -1
  90. package/geometry/support/geodesicUtils.js +1 -1
  91. package/interfaces.d.ts +34 -4
  92. package/layers/WCSLayer.js +1 -1
  93. package/layers/mixins/ArcGISImageService.js +1 -1
  94. package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
  95. package/layers/support/SubtypeSublayer.js +1 -1
  96. package/layers/support/rasterDatasets/WCSRaster.js +1 -1
  97. package/layers/support/rasterDatasets/multidimensionalUtils.js +1 -1
  98. package/layers/support/rasterDatasets/wcsCoverageParser.js +1 -1
  99. package/package.json +3 -3
  100. package/support/revision.js +1 -1
  101. package/views/2d/engine/flow/styles/Imagery.js +1 -1
  102. package/views/2d/engine/flow/styles/Particles.js +1 -1
  103. package/views/2d/engine/flow/styles/Streamlines.js +1 -1
  104. package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
  105. package/views/2d/engine/vectorTiles/RenderBucket.js +1 -1
  106. package/views/2d/engine/vectorTiles/shaders/VTLMaterial.js +1 -1
  107. package/views/2d/engine/webgl/BitBlitRenderer.js +1 -1
  108. package/views/2d/engine/webgl/DefaultVertexAttributeLayouts.js +1 -1
  109. package/views/2d/engine/webgl/Mesh2D.js +1 -1
  110. package/views/2d/engine/webgl/Overlay.js +1 -1
  111. package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
  112. package/views/2d/engine/webgl/Utils.js +1 -1
  113. package/views/2d/engine/webgl/VertexStream.js +1 -1
  114. package/views/2d/engine/webgl/brushes/WGLBrushStencil.js +1 -1
  115. package/views/2d/engine/webgl/brushes/WGLBrushTileDebugInfo.js +1 -1
  116. package/views/2d/engine/webgl/brushes/WGLBrushVTLBackground.js +1 -1
  117. package/views/2d/engine/webgl/cpuMapped/MappedMesh.js +1 -1
  118. package/views/2d/engine/webgl/effects/highlight/HighlightRenderer.js +1 -1
  119. package/views/2d/engine/webgl/mesh/MeshData.js +1 -1
  120. package/views/2d/engine/webgl/meshing/Mesh.js +1 -1
  121. package/views/2d/engine/webgl/shaderGraph/ShaderBuilder2D.js +1 -1
  122. package/views/2d/engine/webgl/shaderGraph/techniques/FeatureInstanceStore.js +1 -1
  123. package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityTechnique.js +1 -1
  124. package/views/2d/engine/webgl/shaderGraph/techniques/heatmap/HeatmapTechnique.js +1 -1
  125. package/views/2d/layers/graphics/GraphicBoundsRenderer.js +1 -1
  126. package/views/2d/layers/support/DebugOverlay.js +1 -1
  127. package/views/2d/magnifier/MagnifierView2D.js +1 -1
  128. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  129. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  130. package/views/3d/environment/LocalAtmosphere.js +1 -1
  131. package/views/3d/environment/MarsAtmosphere.js +1 -1
  132. package/views/3d/environment/Precipitation.js +1 -1
  133. package/views/3d/environment/Stars.js +1 -1
  134. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  135. package/views/3d/interactive/editingTools/reshape/ReshapeTool3D.js +1 -1
  136. package/views/3d/interactive/editingTools/reshape/edgeOffsetUtils.js +1 -1
  137. package/views/3d/interactive/editingTools/reshape/reshapeTooltipUtils.js +1 -1
  138. package/views/3d/interactive/editingTools/transform/extentTransform/extentUtils.js +1 -1
  139. package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
  140. package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
  141. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  142. package/views/3d/layers/StreamLayerView3D.js +1 -1
  143. package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
  144. package/views/3d/layers/graphics/Graphics3DGraphicsPipeline.js +1 -1
  145. package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +5 -0
  146. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +5 -0
  147. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorkerHandle.js +5 -0
  148. package/views/3d/layers/graphics/pipeline/PBFPointFeaturesView.js +5 -0
  149. package/views/3d/layers/graphics/pipeline/TestSymbol.js +5 -0
  150. package/views/3d/layers/graphics/pipeline/Tile.js +5 -0
  151. package/views/3d/layers/graphics/pipeline/Tile3DFetcher.js +5 -0
  152. package/views/3d/layers/graphics/pipeline/Tile3DProcessor.js +5 -0
  153. package/views/3d/layers/i3s/PointRenderer.js +1 -1
  154. package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
  155. package/views/3d/layers/support/projectExtentUtils.js +1 -1
  156. package/views/3d/terrain/OverlayRenderer.js +1 -1
  157. package/views/3d/terrain/PatchGeometryFactory.js +1 -1
  158. package/views/3d/terrain/PatchRenderData.js +1 -1
  159. package/views/3d/terrain/TerrainRenderer.js +1 -1
  160. package/views/3d/terrain/TileCompositor.js +1 -1
  161. package/views/3d/webgl/ManagedFBObject.js +1 -1
  162. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  163. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  164. package/views/3d/webgl-engine/core/renderPasses/RenderPass.js +1 -1
  165. package/views/3d/webgl-engine/core/shaderLibrary/ScreenSpacePass.glsl.js +3 -5
  166. package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +3 -3
  167. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +29 -59
  168. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUDOcclusionPass.glsl.js +6 -12
  169. package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +11 -11
  170. package/views/3d/webgl-engine/core/shaderLibrary/shading/MarkerSizing.glsl.js +1 -1
  171. package/views/3d/webgl-engine/core/shaderLibrary/shading/MultipassTerrainTest.glsl.js +4 -7
  172. package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceReflections.glsl.js +1 -1
  173. package/views/3d/webgl-engine/core/shaderLibrary/shading/TextureTransformUV.glsl.js +6 -6
  174. package/views/3d/webgl-engine/core/shaderLibrary/shading/Water.glsl.js +4 -4
  175. package/views/3d/webgl-engine/core/shaderLibrary/terrain/TileComposite.glsl.js +2 -4
  176. package/views/3d/webgl-engine/core/shaderLibrary/util/LocalFromScreenSpace.glsl.js +2 -2
  177. package/views/3d/webgl-engine/core/shaderModules/ShaderBuilder.js +1 -1
  178. package/views/3d/webgl-engine/effects/RenderNodes.js +1 -1
  179. package/views/3d/webgl-engine/effects/ScreenSpaceGeometry.js +1 -1
  180. package/views/3d/webgl-engine/effects/blit/Blit.js +1 -1
  181. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  182. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  183. package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
  184. package/views/3d/webgl-engine/effects/laserlines/LaserlinePathData.js +1 -1
  185. package/views/3d/webgl-engine/effects/laserlines/LaserlinePathTechnique.js +1 -1
  186. package/views/3d/webgl-engine/effects/magnifier/MagnifierRenderNode.js +1 -1
  187. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  188. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  189. package/views/3d/webgl-engine/lib/DrapedHeatmapRenderer.js +1 -1
  190. package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
  191. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  192. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  193. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  194. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  195. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  196. package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
  197. package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
  198. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  199. package/views/3d/webgl-engine/lib/glUtil3D.js +1 -1
  200. package/views/3d/webgl-engine/lib/lodRendering/LodComponentData.js +1 -1
  201. package/views/3d/webgl-engine/materials/DrawParameters.js +1 -1
  202. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  203. package/views/3d/webgl-engine/materials/renderers/VaoCache.js +1 -1
  204. package/views/3d/webgl-engine/shaders/Heatmap.glsl.js +1 -1
  205. package/views/3d/webgl-engine/shaders/HighlightApply.glsl.js +1 -1
  206. package/views/3d/webgl-engine/shaders/OITCompositing.glsl.js +1 -1
  207. package/views/SceneView.js +1 -1
  208. package/views/draw/support/Box.js +1 -1
  209. package/views/interactive/tooltip/Tooltip.js +1 -1
  210. package/views/interactive/tooltip/fields/fields.js +1 -1
  211. package/views/webgl/RenderingContext.js +1 -1
  212. package/views/webgl/Util.js +1 -1
  213. package/views/webgl/VertexArrayObject.js +1 -1
  214. package/views/webgl/enums.js +1 -1
  215. package/views/webgl/heatmapTextureUtils.js +1 -1
  216. package/views/webgl/testDoublePrecisionArithmetic.js +1 -1
  217. package/views/webgl/testFloatBufferBlend.js +1 -1
  218. package/views/webgl/testSVGPremultipliedAlpha.js +1 -1
  219. package/widgets/ElevationProfile/ElevationProfileController.js +1 -1
  220. package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
  221. package/widgets/Feature/support/relatedFeatureUtils.js +1 -1
  222. package/widgets/FeatureForm.js +1 -1
  223. package/widgets/OrientedImageryViewer/constants.js +1 -1
  224. package/widgets/OrientedImageryViewer.js +1 -1
  225. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  226. package/widgets/UtilityNetworkTrace.js +1 -1
  227. package/widgets/support/TimezonePicker.js +1 -1
  228. package/assets/esri/core/workers/chunks/0cb2eb96ffb1dbed00eb.js +0 -1
  229. package/assets/esri/core/workers/chunks/0d6ed27fc9948f4ea061.js +0 -1
  230. package/assets/esri/core/workers/chunks/225b947ba4b2fcfd5630.js +0 -1
  231. package/assets/esri/core/workers/chunks/7c7c3068da3bf7467685.js +0 -1
  232. package/assets/esri/core/workers/chunks/812e18c65aa6e398c338.js +0 -1
  233. package/assets/esri/core/workers/chunks/85e5cdd723f68dec8c25.js +0 -1
  234. package/assets/esri/core/workers/chunks/a7e2ca5ede46395f0787.js +0 -1
  235. package/assets/esri/core/workers/chunks/aed0db145187d9eb52f2.js +0 -51
  236. package/assets/esri/core/workers/chunks/cf9a32a03b3d3b66effb.js +0 -1
  237. package/assets/esri/core/workers/chunks/d85c51abde781660b1f5.js +0 -1
  238. package/assets/esri/core/workers/chunks/e840e54455eb500b501d.js +0 -1098
  239. package/assets/esri/core/workers/chunks/fec53ce15ae52f8cb802.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/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 s}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{removeMaybe as i,abortMaybe as a,destroyMaybe as n,releaseMaybe as h}from"../../../../core/maybe.js";import o from"../../../../core/PooledArray.js";import{throwIfAborted as d}from"../../../../core/promiseUtils.js";import{watch as l,syncAndInitial as _,initial as u,sync as p}from"../../../../core/reactiveUtils.js";import{signal as c}from"../../../../core/signal.js";import{property as m}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/accessorSupport/interfaces.js";import"../../../../core/accessorSupport/tracking/Flags.js";import"../../../../core/Warning.js";import"../../../../core/Error.js";import{equals as f,invert as g,multiply as b}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as T,create as E}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as A}from"../../../../chunks/vec42.js";import{fromValues as R,ZEROS as P}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{a as S}from"../../../../chunks/boundedPlane.js";import{RenderCategory as w,InternalRenderCategory as C}from"../../webgl.js";import{debugFlags as I}from"../../support/debugFlags.js";import{TransparencyMode as O}from"../../terrain/TransparencyMode.js";import{DepthFormat as D,ColorFormat as y}from"../../webgl/formats.js";import{FBOCache as N,defaultWebGLFBO as x}from"../core/FBOCache.js";import{RenderPassManager as M}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as v}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as H}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{distanceFadeEnd as F}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as L}from"../effects/RenderNodes.js";import{isPrepareRenderPlugin as q}from"../effects/RenderPlugin.js";import{RenderPluginManager as U}from"../effects/RenderPluginManager.js";import{Blit as V}from"../effects/blit/Blit.js";import{AnimationTimeStep as j}from"./AnimationTimeStep.js";import{Decorations as G,RenderRequestType as B,StencilBits as Q}from"./basicInterfaces.js";import{BoundingInfo as k}from"./BoundingInfo.js";import{zero as W,union as z}from"./depthRange.js";import{depthRangeFromScene as X}from"./depthRangeUtils.js";import{MainFramebuffer as Y}from"./MainFramebuffer.js";import{RenderOccludedFlag as J}from"./Material.js";import{RenderContext as K,defaultRenderOccludedMask as $}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as Z,RendererTarget as ee}from"./rendererUtils.js";import{setupFeatureDefaults as te,RenderFeature as re}from"./RenderFeature.js";import{RenderPluginInput as se}from"./RenderPluginInput.js";import{RenderSlot as ie}from"./RenderSlot.js";import{ShadowAccumulator as ae}from"./ShadowAccumulator.js";import{ShadowMap as ne,SnapshotSlot as he}from"./ShadowMap.js";import oe from"./SliceHelper.js";import{TransparencyPassType as de}from"./TransparencyPassType.js";import{Viewshed as le}from"./Viewshed.js";import{Transparency as _e}from"./edgeRendering/interfaces.js";import{MergedRenderer as ue}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as pe}from"../shaders/CompositingTechniqueConfiguration.js";import{OITCompositingTechnique as ce}from"../shaders/OITCompositingTechnique.js";import{RendererPerformanceInfo as me,PerformanceCategory as fe}from"../statistics/RendererPerformanceInfo.js";import{RenderState as ge}from"../../../support/RenderState.js";import{DepthStencilAttachment as be,PixelFormat as Te,PixelType as Ee,ClearBufferBit as Ae,TextureType as Re,ColorAttachment as Pe}from"../../../webgl/enums.js";class Se{constructor(e,t,r,i,a,n){this._stage=e,this._techniques=r,this._rctx=i,this._compositingHelper=a,this._requestRender=n,this._pluginsHas={hudElements:!1,water:!1},this._hasOverlayWater=!1,this.renderOverlay=e=>{},this._renderers=new Map,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=R(0,0,0,1),this._sliceHelper=new oe,this._blit=null,this._state=c(ge.IDLE),this._highQualityTransparencyEnabled=!0,this._terrainTransparency=O.Opaque,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new j,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=c(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new se,this._releaseNormals=e=>{e.some((({name:e})=>"normals"===e))&&this._pluginInput.release("normals")},this._debugNeedsDepth=!1,this.fboCache=new N(i),this._renderStateFeatures=c(te(!has("disable-feature:high-quality-idle"),e.view.qualityProfile)),this._framebuffer=new Y(this.fboCache),this.performanceInfo=new me(this._rctx),this._shadowMap=new ne(this.fboCache,e.viewingMode),this._viewshed=new le({fboCache:this.fboCache,view:e.view},((e,t,r)=>{t.setGLViewport(this._rctx);const{camera:s,contentCamera:i}=e;this._ensureBindParametersCamera(t,t),this._renderAllGeometry(r),this._ensureBindParametersCamera(s,i),e.camera.setGLViewport(this._rctx)})),this._shadowAccumulator=new ae(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}),((e,t,r)=>{const s=this._stage.view.qualitySettings.maximumPixelRatio;e.shadowMap.start(e.camera,t,r,!0,s),this._renderShadowCascades(v.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(e.camera,e.contentCamera)}),n),this._renderContext=new K(this._rctx,this._shadowMap,this._sliceHelper,this._framebuffer),this._nodes=new L(this._renderContext),this._plugins=new U({renderContext:this._renderContext,techniques:r,materials:t,requestRender:n,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this.renderPassManager=new M,this._plugins.add(this.renderPassManager),this._plugins.add(this._viewshed),this._handles=[l((()=>this._stage.view.state.camera),(()=>n()),_),l((()=>I.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(_e.TRANSPARENT):()=>{},n()}),u),l((()=>this._stage.view.environment.background?.color),(e=>{const t=e?s(e):P;A(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()}),_),l((()=>this._stage.view.state.camera.relativeElevation),(e=>{this._inGlobeView=(e??1/0)>=F}),_)]}destroy(){this._handles.forEach((e=>e.remove())),this._gpuTimerHandle=i(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.dispose(),this._loadEdgeViewTask=a(this._loadEdgeViewTask),this._edgeView=n(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),this._plugins.destroy(),this._renderers.clear(),this._blit=n(this._blit),k.prune()}get _bindParameters(){return this._renderContext.bindParameters}get _framebufferSize(){return this._framebuffer.size}updateRenderFeatures(e=null,t=!has("disable-feature:high-quality-idle")){this._renderStateFeatures.value=te(t,e),this._plugins.renderFeatureChanged(),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate((s=>s.set(t,e,r))),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(re.HighQualityTransparency)}get hasReflections(){return(this._pluginsHas.water||this._hasOverlayWater)&&(this._ssrEnabled||this.isFeatureEnabled(re.WaterReflection))}get hasDecorations(){return this._plugins.hasDecorations||this._nodes.produces("magnifier-color")}get hasHighlights(){return this._plugins.produces(v.Highlight,ie.OPAQUE_MATERIAL,ie.TRANSPARENT_MATERIAL,ie.DRAPED_MATERIAL)}get hasSSAO(){return(this._stage.view.qualitySettings.ambientOcclusion||this.isFeatureEnabled(re.SSAO))&&!this._inGlobeView}get hasSMAA(){return this._stage.view.qualitySettings.antialiasingEnabled||this.isFeatureEnabled(re.Antialiasing)}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(re.HighResolutionAtmosphere)}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=h(this._bindParameters.ssr.lastFrameColor),this._bindParameters.multipassTerrain.depth=h(this._bindParameters.multipassTerrain.depth),this._bindParameters.multipassGeometry.depth=h(this._bindParameters.multipassGeometry.depth),this._pluginInput.release("highlight mix")}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._viewshed.shadowMap?.disposeOffscreenBuffers(),this._bindParameters.depth=h(this._bindParameters.depth),this._bindParameters.hudVisibility=h(this._bindParameters.hudVisibility)}get updating(){return null!=this._edgeView&&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");d(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:Me(this._stage.view.resourceController)});return this._handles.push(l((()=>r.updating),(()=>this._requestRender()),p)),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&&f(this._bindParameters.ssr.reprojectionMatrix,T)}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.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=e.slicePlane,this._requestRender()),void 0!==e.terrainTransparency&&this._terrainTransparency!==e.terrainTransparency&&(this._terrainTransparency=e.terrainTransparency,this._requestRender()),void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}get hasSlicePlane(){return!!this._sliceHelper.plane}get plugins(){return this._plugins}getMaterialRenderer(e){return this._renderers.get(e)}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,t){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:r,removes:s,updates:i}=e;if(0===r.length&&0===s.length&&0===i.length)return;Z(e).forEach(((r,s)=>{if(t.done)return;let i=this._renderers.get(s);null==i&&r.adds.length>0&&(i=new ue({material:s}),i.initializeRenderContext(this._plugins._context),this._plugins.add(i),this._renderers.set(s,i)),i&&(i.modify(r),0===i.numGeometries&&(this._renderers.delete(i.material),this._plugins.remove(i),i.destroy())),r.removes.forEach((t=>e.removes.removeUnordered(t))),r.adds.forEach((t=>e.adds.removeUnordered(t))),r.updates.forEach((t=>e.updates.removeUnordered(t))),t.madeProgress()})),this.updateHasFlags(),this._requestRender()}updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(v.Color,ie.LINE_CALLOUTS_HUD_DEPTH,ie.HUD_MATERIAL,ie.LABEL_MATERIAL),has.water=this._plugins.produces(v.Normal,ie.DRAPED_WATER),this._bindParameters.hasOccludees=this._plugins.hasOccludees}updateAnimation(e){const t=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(e),this._hasAnimations=this._nodes.updateAnimation()||this._hasAnimations,this._hasAnimations!==t&&(this._gpuTimerHandle=t?i(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=ee.Default,s=G.ON){try{return this._isRendering=!0,this._render(e,t,r,s)}catch(i){console.error(`Exception during rendering: ${i}`)}finally{this._isRendering=!1}return{screen:this._pluginInput.get("final-color"),oid:null}}_render(e,t,r=ee.Default,s=G.ON){this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=r===ee.Default,this._disposeBindBuffers();const i=this._framebuffer,{camera:a,contentCamera:n,mode:o,alignPixelEnabled:d}=e;this._state.value=o,this._bindParameters.overlay=this.renderOverlay(t),this._bindParameters.overlay&&this.performanceInfo.advance(fe.OVERLAY),this._renderContext.time=t,this._bindParameters.transparencyPassType=de.NONE,this._bindParameters.alignPixelEnabled=d,this._bindParameters.decorations=s,this._bindParameters.mainDepth=null,this._bindParameters.viewshedEnabled=this._viewshed.enabled;const l=this._nodes.produces("magnifier-color"),_=this._nodes.produces("final-color"),u=S(this._sliceHelper.plane);s===G.OFF&&(this._sliceHelper.plane=null),a.setGLViewport(this._rctx);const p=i.initialize(a.fullWidth,a.fullHeight,this._backgroundColor);this.hasReflections?this._bindParameters.ssr.lastFrameColor=p:p?.release(),this._ensureBindParametersCamera(a,n),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&s===G.ON;const c=this._plugins.produces(v.Color,ie.OPAQUE_TERRAIN)&&(this._terrainTransparency===O.Transparent||this._terrainTransparency===O.InvisibleWithDraped),m=this._highQualityTransparency&&c,f=this._plugins.produces(v.Color,...Oe);this._prepareShaders(m,f),this.performanceInfo.advance(fe.PREPARE);const g=this._computeDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,g),this._ensureBindParametersCamera(a,n);let b=this._renderNormals();this._pluginInput.set("normals",b);const T=this._needsDepth;if(b){let e=null;T&&(e=b.getAttachment(be),e?.retain()),this._pluginInput.set("ssao",this._renderSSAO()),this._renderNoSSAOGeometryDepth(T,e),b=null}else this._renderAllGeometryDepth(T);this._renderShadowAccumulation(g,a,n),this._ensureBindParametersSSR(t),this._renderContext.output=v.Color,i.bind(),this._bindParameters.mainDepth=i.depth.attachment;const E=this.plugins.produces(v.Color,...Ie);E&&this._renderOpaqueGeometry(),i.update((e=>this._renderNodes(w.OPAQUE,e,E))),this.fboCache.debugCallback?.("opaque-color",i.color.fbo),this._renderPlugins(ie.OPAQUE_ENVIRONMENT,fe.OPAQUE_ENVIRONMENT),this._renderMultipassTerrainDepth(m),this._setMultipassTerrain(m),this._renderEdges(_e.OPAQUE),i.bind(),this._renderPlugins(ie.VOXEL,fe.VOXEL),this._renderHiddenTransparentEdges(),f&&(this._oitEnabled?this._renderOITPass(we.Geometry):this._renderTransparentMaterial()),i.update((e=>this._renderNodes(w.TRANSPARENT,e,f))),this.fboCache.debugCallback?.("transparent-color",i.color.fbo),this._renderMultipassGeometryDepth(m),this._renderHUDVisibility(),m||this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS);const A=r===ee.ObjectAndLayerID?this._renderObjectAndLayerIdColor():null;this._renderEdges(_e.TRANSPARENT);const R=c?this._renderTransparentTerrain():null;R&&(this.performanceInfo.advance(fe.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(m?this._renderLineCallouts(H.Occluded):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositingHelper.compositeHUD(this._bindParameters,R.getTexture())),this._renderHUD(H.Occluded,i.color))),this._setTerrainCulling(!1),R&&(i.bind(),this._compositingHelper.composite(this._bindParameters,R.getTexture(),pe.PremultipliedAlpha),R.release(),m&&(this._renderEdges(_e.OPAQUE),f&&(this._oitEnabled?this._renderOITPass(we.Geometry):this._renderTransparentMaterial(),this.performanceInfo.advance(fe.TRANSPARENT)),this._renderEdges(_e.TRANSPARENT))),this._bindParameters.ssao=h(this._bindParameters.ssao),m&&this._renderLineCallouts(H.NotOccluded),this._setMultipassEnabled(!1),this._renderTransparentEnvironment(),this._renderViewshed(),i.update((e=>this._renderNodes(C.LASERLINES,e))),this._renderOccluded(),this._pluginInput.set("highlights",this._renderHighlightPrepass()),i.update((e=>this._renderNodes(w.COMPOSITE,e)));const P=this._nodes.produces("aa-color"),I=!(r!==ee.Default||_||l&&s===G.ON&&r===ee.Default),D=this._pluginInput.get("composite-color"),y=I?x:this.fboCache.acquire(D.fbo.width,D.fbo.height,"aa-color"),N=P?this._renderNodes(C.ANTIALIASING,y):this._blitToDefault(D,y,!1);this._pluginInput.set(C.ANTIALIASING,N),this._renderHUD(H.NotOccluded,N);const M=this._renderNodes(C.HIGHLIGHTS,N);let F=this._renderNodes(C.MAGNIFIER,M);return l&&s===G.ON&&r===ee.Default&&!_&&(F=this._blitToDefault(F)),_?(F.attachDepth(i.depth),this._blitToDefault(this._renderNodes(w.FINAL,F)),F.detachDepth()):this._pluginInput.set(w.FINAL,F),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),i.release(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=u,this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),r!==ee.Default&&(this._releaseFBOs(),this._disposeOffscreenBuffers()),{screen:this._pluginInput.get("final-color"),oid:A}}_prepareShaders(e,t){this._renderContext.output=v.Color,this._prepareOpaqueGeometry(),this._setMultipassTerrain(e),this._plugins.prepare(ie.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._plugins.prepare(ie.LINE_CALLOUTS),t&&this._prepareTransparencySlots(),this._plugins.prepare(ie.VIEWSHED,ie.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,ie.TRANSPARENT_ENVIRONMENT),this._rctx.gl.flush()}_renderObjectAndLayerIdColor(){if(!has("enable-feature:objectAndLayerId-rendering"))return;const e=this._renderContext.output,t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"oid");return r.acquireDepth(D.DEPTH_STENCIL_TEXTURE),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer([0,0,0,0],!0,!0),this._renderAllGeometry(v.ObjectAndLayerIdColor),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(void 0,!0,!0),this._bindParameters.hudRenderStyle=H.NotOccluded,this._plugins.render(this._pluginInput,ie.HUD_MATERIAL),this._renderContext.output=e,this.performanceInfo.advance(fe.OBJECT_AND_LAYER_ID_COLOR),r}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=e===B.BACKGROUND;if(r||t){const e=r?this.performanceInfo.elapsedTime:0,s=t?this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.getError(),i=Math.max(e,s);this._animationTimestep.frame(i,r)}}readDepthPixels(e,t){const{mainDepth:r,camera:s}=this._bindParameters;if(!r)return;const i=this.fboCache.acquire(this._framebufferSize.width,this._framebufferSize.height,"linear-depth");this._rctx.bindFramebuffer(i.fbo),s.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer([0,0,0,0]),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),i.fbo?.readPixels(e[0],e[1],e[2],e[3],Te.RGBA,Ee.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,t,r,s,i){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,s,Te.RGBA,Ee.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_setMultipassTerrain(e){this._setMultipassEnabled(e),this._setTerrainCulling(e)}_setMultipassEnabled(e){this._bindParameters.multipassEnabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const r=this._framebufferSize,s=this.fboCache.acquire(r.width,r.height,"edges"),i=()=>t.render(this._bindParameters,e),a=this._bindParameters.multipassGeometry.depth;this.renderToTargets(i,s,a??this._framebuffer.depth,Ce),this._framebuffer.bind(),this._compositingHelper.composite(this._bindParameters,s.getTexture(),pe.Alpha),s.release(),this.performanceInfo.advance(e===_e.OPAQUE?fe.OPAQUE_EDGES:fe.TRANSPARENT_EDGES)}_renderShadowMap(e,t,r){const s=this._shadowMap;s.enabled&&(s.start(e,t,r,this.isFeatureEnabled(re.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(v.ShadowHighlight,this._shadowMap),s.moveSnapshot(he.Highlight),this._renderShadowCascades(v.ShadowExcludeHighlight,this._shadowMap),s.copySnapshot(he.ExcludeHighlight),this._renderShadowCascades(v.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(v.Shadow),s.finish(),e.setGLViewport(this._rctx),this.performanceInfo.advance(fe.SHADOW_MAP))}_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(v.Depth)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast||this._debugNeedsDepth}_renderNoSSAOGeometryDepth(e,t){if(!e||!t)return void(this._bindParameters.depth=h(this._bindParameters.depth));const r=this._framebufferSize,s=this.fboCache.acquire(r.width,r.height,"depth");s.attachDepth(t),t.release(),this._rctx.bindFramebuffer(s.fbo),this._rctx.clearFramebuffer(void 0,!1,!0),this._renderGeometryExcludedFromSSAO(v.Depth),h(this._bindParameters.depth),this._bindParameters.depth=s.obtainDepthTexture(),s.release(),this.performanceInfo.advance(fe.DEPTH)}_renderAllGeometryDepth(e){if(!e)return void(this._bindParameters.depth=h(this._bindParameters.depth));const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"depth").acquireDepth(D.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(void 0,!0,!0),this._renderAllGeometry(v.Depth),h(this._bindParameters.depth),this._bindParameters.depth=r.obtainDepthTexture(),r.release(),this.performanceInfo.advance(fe.DEPTH)}_renderMultipassTerrainDepth(e){if(!e)return void(this._bindParameters.multipassTerrain.depth=h(this._bindParameters.multipassTerrain.depth));const t=this._renderContext.output;this._renderContext.output=v.Depth;const r=this._framebufferSize,s=this.fboCache.acquire(r.width,r.height,"terrain depth").acquireDepth(D.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(s.fbo),this._rctx.clearFramebuffer(void 0,!0,!0),this._renderTransparentTerrain(),h(this._bindParameters.multipassTerrain.depth),this._bindParameters.multipassTerrain.depth=s.obtainDepthTexture(),this._renderContext.output=t,s.release()}_renderMultipassGeometryDepth(e){if(!e)return void(this._bindParameters.multipassGeometry.depth=h(this._bindParameters.multipassGeometry.depth));const t=this._renderContext.output,r=this._framebufferSize,s=this.fboCache.acquire(r.width,r.height,"geometry depth").acquireDepth(D.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(s.fbo),this._rctx.clearFramebuffer(void 0,!0,!0),this._renderOpaqueGeometryAndTransparentMaterial(v.Depth),this._renderContext.output=t,h(this._bindParameters.multipassGeometry.depth),this._bindParameters.multipassGeometry.depth=s.obtainDepthTexture(),s.release()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return W;const t=X(e,this._plugins.plugins,this._stage.layers);return z(t,this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}_renderNormals(){const e=this._nodes.require("normals","final-color","composite-color","opaque-color","transparent-color","laserline-color"),t=(this.hasSSAO?1:0)+e;if(0===t)return;const r=this._framebufferSize,s=this.fboCache.acquire(r.width,r.height,"normals",y.RGBA);s.acquireDepth(D.DEPTH_STENCIL_TEXTURE),this._rctx.bindFramebuffer(s.fbo),this._rctx.clearFramebuffer([0,0,0,0],!0,!0),this._renderGeometryForSSAO(v.Normal);const i=this._nodes.optional("normals","final-color","composite-color","opaque-color","transparent-color")+(this._viewshedEnabled?1:0);return s.retain(t+i-1),this.performanceInfo.advance(fe.NORMALS),s}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return void e?.detachDepth();const t=this._nodes.render("ssao",this._pluginInput);return this._bindParameters.ssao=t,e.detachDepth(),this._pluginInput.release("normals"),this.performanceInfo.advance(fe.SSAO),t}_renderAllGeometry(e){this._renderContext.output=e,this._plugins.prepare(ie.TRANSPARENT_TERRAIN),this._renderOpaqueGeometryAndTransparentMaterial(e),this._renderTransparentTerrain()}_renderOpaqueGeometryAndTransparentMaterial(e){this._renderContext.output=e,this._plugins.prepare(ie.TRANSPARENT_MATERIAL,ie.TRANSPARENT_NO_SSAO_DEPTH),this._renderOpaqueGeometry(),this._renderTransparentMaterial()}_renderGeometryForSSAO(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,ie.INTEGRATED_MESH,ie.OPAQUE_TERRAIN,ie.OPAQUE_MATERIAL,ie.TRANSPARENT_MATERIAL),this._renderTransparentTerrain()}_renderGeometryExcludedFromSSAO(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,ie.OPAQUE_NO_SSAO_DEPTH,ie.TRANSPARENT_NO_SSAO_DEPTH)}_prepareOpaqueGeometry(){this._plugins.prepare(...Ie,ie.OPAQUE_ENVIRONMENT)}_renderOpaqueGeometry(){this._plugins.render(this._pluginInput,...Ie)}_renderTransparentMaterial(){this._plugins.render(this._pluginInput,...Oe)}_renderTransparentTerrain(){const e=this._renderContext.output;if(!this._plugins.produces(e,ie.TRANSPARENT_TERRAIN))return;const t=()=>this._plugins.render(this._pluginInput,ie.TRANSPARENT_TERRAIN);if(e!==v.Color)return void t();const r=this._framebufferSize,s=this.fboCache.acquire(r.width,r.height,"transparent terrain");return this.renderToTargets(t,s,this._framebuffer.depth,[0,0,0,0]),s}_renderHUDVisibility(){if(this._plugins.produces(this._renderContext.output,ie.OCCLUSION_PIXELS)){const e=()=>{const e=this._framebufferSize;let t=this._bindParameters.hudVisibility;const r=this._bindParameters.multipassGeometry.depth;return t?.fbo?.width===e.width&&t?.fbo?.height===e.height||(t?.release(),t=this.fboCache.acquire(e.width,e.height,"hud visibility",y.RGBA4)),t.attachDepth(r||this._framebuffer.depth),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(this._pluginInput,ie.OCCLUSION_PIXELS),t.detachDepth(),t};this._bindParameters.hudVisibility=e(),this._framebuffer.bind(),this.performanceInfo.advance(fe.HUD_VISIBILITY)}else this._bindParameters.hudVisibility=h(this._bindParameters.hudVisibility)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===H.Occluded){const e=()=>this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS),t=this._framebufferSize,r=this.fboCache.acquireDepth(D.DEPTH16_BUFFER,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,ie.LINE_CALLOUTS)}_renderHUD(e,t){if(this._pluginsHas.hudElements){if(this._oitEnabled){const r=this._renderOITPass(we.HUD,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.composite(this._bindParameters,r.getTexture(),pe.PremultipliedAlpha),r.release()}else if(e===H.Occluded){this._renderContext.output=v.Color;const t=()=>this._renderHUDElements(e),r=this._framebufferSize,s=this.fboCache.acquireDepth(D.DEPTH16_BUFFER,r.width,r.height,"hud");this.renderToTargets(t,this._framebuffer.color,s,void 0,!0,!0),s.release()}else this._renderContext.output=v.Color,t.acquireDepth(D.DEPTH16_BUFFER),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(e===H.Occluded?fe.HUD_OCCLUDED:fe.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.prepare(ie.LINE_CALLOUTS_HUD_DEPTH,ie.HUD_MATERIAL,ie.LABEL_MATERIAL),this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS_HUD_DEPTH,ie.HUD_MATERIAL,ie.LABEL_MATERIAL)}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._plugins.produces(v.ShadowHighlight,ie.OPAQUE_MATERIAL)}_renderHighlightPrepass(){if(!this.hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:r}=this,s=this._framebufferSize;let i=this._pluginInput.get("highlight mix");null==i&&(i=e.acquire(s.width,s.height,"highlight mix",y.RGBA),this._pluginInput.set("highlight mix",i),r.highlightTexture=i.getTexture()),t.bindFramebuffer(i.fbo);const a=[0,0,0,0];t.clearFramebuffer(a);const n=i.getTexture(),h=e.acquire(s.width,s.height,"highlights",y.RGBA);h.acquireDepth(D.DEPTH16_BUFFER),t.bindFramebuffer(h.fbo),t.clearFramebuffer(a,!0);const{highlightOrder:o}=this._stage.view,d=Math.min(16,o.length),{highlightGroupMap:l}=r;l.clear();for(let _=0;_<d;++_){const e=o.at(_);e&&l.set(e,_)}for(let _=0;_<d;++_)r.highlightLevel=_,r.highlightGroup=o.at(_),t.bindFramebuffer(h.fbo),t.clearFramebuffer(void 0,!0),this._renderAllGeometry(v.Highlight),0===_&&(t.clear(Ae.DEPTH_BUFFER_BIT),this._renderHUDElements(H.Both)),t.clear(Ae.DEPTH_BUFFER_BIT),t.bindTexture(n,0),t.gl.copyTexImage2D(Re.TEXTURE_2D,0,Te.RGBA,0,0,s.width,s.height,0);return h}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_renderShadowAccumulation(e,t,r){this._needsShadowCast&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,e,t,r)&&this.performanceInfo.advance(fe.ACCUMULATED_SHADOWS)}_prepareTransparencySlots(){this._renderContext.output=v.Color,this._bindParameters.transparencyPassType=de.ColorAlpha,this._plugins.prepare(...Oe),this._bindParameters.transparencyPassType=de.FrontFace,this._plugins.prepare(...Oe),this._bindParameters.transparencyPassType=de.NONE,this._techniques.acquire(ce).release()}_renderOITPass(e,t=H.Both){const r=e===we.HUD,s=this._framebufferSize,i=r?this.fboCache.acquire(s.width,s.height,"oit hud composite"):null,a=r?()=>this._renderHUDElements(t):()=>this._renderTransparentMaterial(),n=this._renderContext.output;return this._renderContext.output=v.Color,this._renderOIT(this._bindParameters,a,i),this._renderContext.output=n,i}_renderOIT(e,t,r){const s=this._framebufferSize;e.transparencyPassType=de.ColorAlpha;const i=r?"oit hud color alpha":"oit color alpha",a=this.fboCache.acquire(s.width,s.height,i,y.RGBA16F);a.acquireColor(Pe.COLOR_ATTACHMENT1,y.R16F),r||a.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(a.fbo),this._rctx.clearFramebuffer([0,0,0,1]),t(),a.detachDepth(),e.transparencyPassType=de.FrontFace;const n=this.fboCache.acquire(s.width,s.height,r?"oit hud front":"oit front");r?n.acquireDepth(D.DEPTH16_BUFFER):n.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(n.fbo),this._rctx.clearFramebuffer([0,0,0,0],!!r),t(),n.detachDepth(),e.transparencyPassType=de.NONE,r?(this._rctx.bindFramebuffer(r.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(Ae.COLOR_BUFFER_BIT)):this._framebuffer.bind(),this._compositingHelper.compositeOIT(e,a.getTexture(),a.getTexture(Pe.COLOR_ATTACHMENT1),n.getTexture()),r?.detachDepth(),n.release(),a.release()}_renderOccluded(){let e=0;De.clear(),this._plugins.plugins.forAll((t=>{if(!t.material)return;t.queryRenderOccludedState(J.OccludeAndTransparentStencil)&&(e|=J.OccludeAndTransparentStencil,De.push(t))}));const t=this._framebuffer,r=(r,s,i,a,n)=>{if(!(e&s))return;const h=this._framebufferSize,o=this.fboCache.acquire(h.width,h.height,"tmp color");let d;d=a?this.fboCache.acquireDepth(D.DEPTH_STENCIL_TEXTURE,h.width,h.height,"tmp depth"):t.depth,this.renderToTargets(i,o,d,[0,0,0,0],a,n),t.bind(),this._compositingHelper.composite(this._bindParameters,o.getTexture(),pe.PremultipliedAlpha,r),a&&d.release(),o.release()},s=(e,t)=>{this._bindParameters.slot=e,t.forAll((e=>{if(q(e)){const t=e.prepareTechnique(this._renderContext);t&&e.renderNode(this._renderContext,t)}}))};0!==De.length&&(s(ie.OCCLUDER_MATERIAL,De),r(.5,J.OccludeAndTransparentStencil,(()=>s(ie.TRANSPARENT_OCCLUDER_MATERIAL,De)),!1,!1));const i=De.length>0;De.clear(),this._plugins.plugins.forAll((t=>{if(!t.material)return;const r=t.queryRenderOccludedState(J.OccludeAndTransparent),s=t.queryRenderOccludedState(J.Transparent),i=t.queryRenderOccludedState(J.Opaque);(r||s||i)&&(e|=r?J.OccludeAndTransparent:s?J.Transparent:J.Opaque,De.push(t))}));const a=this._plugins.renderOccludedFlags;if(e|=a,!e)return;const n=e=>{this._renderContext.renderOccludedMask=e,a>J.Occlude&&this._plugins.render(this._pluginInput,ie.OCCLUDED_TERRAIN),s(ie.OPAQUE_MATERIAL,De),s(ie.TRANSPARENT_MATERIAL,De),s(ie.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,De),this._renderContext.renderOccludedMask=$};this._renderContext.output=v.Color,r(.5,J.OccludeAndTransparent,(()=>n(J.OccludeAndTransparent)),!0,Q.OutlineVisualElementMask),r(.5,J.Transparent,(()=>n(J.Transparent)),!0,Q.OutlineVisualElementMask),r(1,J.Opaque,(()=>n(J.Opaque)),!0,Q.OutlineVisualElementMask),(i||De.length>0)&&this.performanceInfo.advance(fe.OCCLUDED),De.clear()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this._framebuffer.bind(),this._plugins.render(this._pluginInput,ie.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,ie.TRANSPARENT_ENVIRONMENT),this.performanceInfo.advance(fe.TRANSPARENT_ENVIRONMENT)}_renderViewshed(){this._viewshedEnabled&&(this._viewshed.renderHighQuality=this.isFeatureEnabled(re.HighResolutionViewshed),this._plugins.render(this._pluginInput,ie.VIEWSHED),this._pluginInput.release("normals"),this.performanceInfo.advance(fe.VIEWSHED))}_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(!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;t.setName(e),this._pluginInput.set(e,t);const s=this._nodes.render(t,this._pluginInput,this._releaseNormals);return this.performanceInfo.advance(e),s}_blitToDefault(e,t=x,r=!0){this._blit??=new V(this._techniques);const s=this._blit.render(this._rctx,e,t,this._bindParameters,this._requestRender);return this._pluginInput.set(e.name,s),r&&e.release(),s}_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=T:(g(Ne,this._bindParameters.camera.viewMatrix),g(ye,this._bindParameters.camera.projectionMatrix),b(xe,Ne,ye),b(xe,this._renderContext.lastFrameCamera.viewMatrix,xe),b(xe,this._renderContext.lastFrameCamera.projectionMatrix,xe),this._reprojectionMatrix=xe);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=T,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}get _viewshedEnabled(){return this._viewshed.enabled&&this._plugins.produces(this._renderContext.output,ie.VIEWSHED)}renderToTargets(e,t,r,s,i=!1,a=!1){t.attachDepth(r),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(s,i,a),e(),t.detachDepth()}get test(){}}var we;e([m({readOnly:!0})],Se.prototype,"fullResolutionAtmosphere",null),e([m()],Se.prototype,"_edgeView",void 0),e([m()],Se.prototype,"updating",null),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(we||(we={}));const Ce=[0,0,0,0],Ie=[ie.INTEGRATED_MESH,ie.OPAQUE_TERRAIN,ie.OPAQUE_MATERIAL,ie.OPAQUE_NO_SSAO_DEPTH],Oe=[ie.TRANSPARENT_MATERIAL,ie.TRANSPARENT_NO_SSAO_DEPTH],De=new o,ye=E(),Ne=E(),xe=E();function Me(e){return t=>e.immediate.schedule(t)}export{Se 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 s}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{removeMaybe as i,abortMaybe as a,destroyMaybe as n,releaseMaybe as h}from"../../../../core/maybe.js";import o from"../../../../core/PooledArray.js";import{throwIfAborted as d}from"../../../../core/promiseUtils.js";import{watch as l,syncAndInitial as _,initial as u,sync as p}from"../../../../core/reactiveUtils.js";import{signal as c}from"../../../../core/signal.js";import{property as m}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/accessorSupport/interfaces.js";import"../../../../core/accessorSupport/tracking/Flags.js";import"../../../../core/Warning.js";import"../../../../core/Error.js";import{equals as f,invert as g,multiply as b}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as T,create as E}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as A}from"../../../../chunks/vec42.js";import{fromValues as P,ZEROS as R}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{a as S}from"../../../../chunks/boundedPlane.js";import{RenderCategory as w,InternalRenderCategory as C}from"../../webgl.js";import{debugFlags as O}from"../../support/debugFlags.js";import{TransparencyMode as I}from"../../terrain/TransparencyMode.js";import{DepthFormat as y,ColorFormat as D}from"../../webgl/formats.js";import{FBOCache as N,defaultWebGLFBO as x}from"../core/FBOCache.js";import{RenderPassManager as M}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as v}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as H}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{distanceFadeEnd as L}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as F}from"../effects/RenderNodes.js";import{isPrepareRenderPlugin as q}from"../effects/RenderPlugin.js";import{RenderPluginManager as U}from"../effects/RenderPluginManager.js";import{Blit as V}from"../effects/blit/Blit.js";import{AnimationTimeStep as j}from"./AnimationTimeStep.js";import{Decorations as G,RenderRequestType as B,StencilBits as Q}from"./basicInterfaces.js";import{BoundingInfo as k}from"./BoundingInfo.js";import{zero as W,union as z}from"./depthRange.js";import{depthRangeFromScene as X}from"./depthRangeUtils.js";import{MainFramebuffer as Y}from"./MainFramebuffer.js";import{RenderOccludedFlag as J}from"./Material.js";import{RenderContext as K,defaultRenderOccludedMask as $}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as Z,RendererTarget as ee}from"./rendererUtils.js";import{setupFeatureDefaults as te,RenderFeature as re}from"./RenderFeature.js";import{RenderPluginInput as se}from"./RenderPluginInput.js";import{RenderSlot as ie}from"./RenderSlot.js";import{ShadowAccumulator as ae}from"./ShadowAccumulator.js";import{ShadowMap as ne,SnapshotSlot as he}from"./ShadowMap.js";import oe from"./SliceHelper.js";import{TransparencyPassType as de}from"./TransparencyPassType.js";import{Viewshed as le}from"./Viewshed.js";import{Transparency as _e}from"./edgeRendering/interfaces.js";import{MergedRenderer as ue}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as pe}from"../shaders/CompositingTechniqueConfiguration.js";import{OITCompositingTechnique as ce}from"../shaders/OITCompositingTechnique.js";import{RendererPerformanceInfo as me,PerformanceCategory as fe}from"../statistics/RendererPerformanceInfo.js";import{RenderState as ge}from"../../../support/RenderState.js";import{DepthStencilAttachment as be,PixelFormat as Te,PixelType as Ee,FramebufferBit as Ae,TextureType as Pe,ColorAttachment as Re}from"../../../webgl/enums.js";class Se{constructor(e,t,r,i,a,n){this._stage=e,this._techniques=r,this._rctx=i,this._compositingHelper=a,this._requestRender=n,this._pluginsHas={hudElements:!1,water:!1},this._hasOverlayWater=!1,this.renderOverlay=e=>{},this._renderers=new Map,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=P(0,0,0,1),this._sliceHelper=new oe,this._blit=null,this._state=c(ge.IDLE),this._highQualityTransparencyEnabled=!0,this._terrainTransparency=I.Opaque,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new j,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=c(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new se,this._releaseNormals=e=>{e.some((({name:e})=>"normals"===e))&&this._pluginInput.release("normals")},this._debugNeedsDepth=!1,this.fboCache=new N(i),this._renderStateFeatures=c(te(!has("disable-feature:high-quality-idle"),e.view.qualityProfile)),this._framebuffer=new Y(this.fboCache),this.performanceInfo=new me(this._rctx),this._shadowMap=new ne(this.fboCache,e.viewingMode),this._viewshed=new le({fboCache:this.fboCache,view:e.view},((e,t,r)=>{t.setGLViewport(this._rctx);const{camera:s,contentCamera:i}=e;this._ensureBindParametersCamera(t,t),this._renderAllGeometry(r),this._ensureBindParametersCamera(s,i),e.camera.setGLViewport(this._rctx)})),this._shadowAccumulator=new ae(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}),((e,t,r)=>{const s=this._stage.view.qualitySettings.maximumPixelRatio;e.shadowMap.start(e.camera,t,r,!0,s),this._renderShadowCascades(v.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(e.camera,e.contentCamera)}),n),this._renderContext=new K(this._rctx,this._shadowMap,this._sliceHelper,this._framebuffer),this._nodes=new F(this._renderContext),this._plugins=new U({renderContext:this._renderContext,techniques:r,materials:t,requestRender:n,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this.renderPassManager=new M,this._plugins.add(this.renderPassManager),this._plugins.add(this._viewshed),this._handles=[l((()=>this._stage.view.state.camera),(()=>n()),_),l((()=>O.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(_e.TRANSPARENT):()=>{},n()}),u),l((()=>this._stage.view.environment.background?.color),(e=>{const t=e?s(e):R;A(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()}),_),l((()=>this._stage.view.state.camera.relativeElevation),(e=>{this._inGlobeView=(e??1/0)>=L}),_)]}destroy(){this._handles.forEach((e=>e.remove())),this._gpuTimerHandle=i(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.dispose(),this._loadEdgeViewTask=a(this._loadEdgeViewTask),this._edgeView=n(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),this._plugins.destroy(),this._renderers.clear(),this._blit=n(this._blit),k.prune()}get _bindParameters(){return this._renderContext.bindParameters}get _framebufferSize(){return this._framebuffer.size}updateRenderFeatures(e=null,t=!has("disable-feature:high-quality-idle")){this._renderStateFeatures.value=te(t,e),this._plugins.renderFeatureChanged(),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate((s=>s.set(t,e,r))),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(re.HighQualityTransparency)}get hasReflections(){return(this._pluginsHas.water||this._hasOverlayWater)&&(this._ssrEnabled||this.isFeatureEnabled(re.WaterReflection))}get hasDecorations(){return this._plugins.hasDecorations||this._nodes.produces("magnifier-color")}get hasHighlights(){return this._plugins.produces(v.Highlight,ie.OPAQUE_MATERIAL,ie.TRANSPARENT_MATERIAL,ie.DRAPED_MATERIAL)}get hasSSAO(){return(this._stage.view.qualitySettings.ambientOcclusion||this.isFeatureEnabled(re.SSAO))&&!this._inGlobeView}get hasSMAA(){return this._stage.view.qualitySettings.antialiasingEnabled||this.isFeatureEnabled(re.Antialiasing)}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(re.HighResolutionAtmosphere)}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=h(this._bindParameters.ssr.lastFrameColor),this._bindParameters.multipassTerrain.depth=h(this._bindParameters.multipassTerrain.depth),this._bindParameters.multipassGeometry.depth=h(this._bindParameters.multipassGeometry.depth),this._pluginInput.release("highlight mix")}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._viewshed.shadowMap?.disposeOffscreenBuffers(),this._bindParameters.depth=h(this._bindParameters.depth),this._bindParameters.hudVisibility=h(this._bindParameters.hudVisibility)}get updating(){return null!=this._edgeView&&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");d(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:Me(this._stage.view.resourceController)});return this._handles.push(l((()=>r.updating),(()=>this._requestRender()),p)),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&&f(this._bindParameters.ssr.reprojectionMatrix,T)}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.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=e.slicePlane,this._requestRender()),void 0!==e.terrainTransparency&&this._terrainTransparency!==e.terrainTransparency&&(this._terrainTransparency=e.terrainTransparency,this._requestRender()),void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}get hasSlicePlane(){return!!this._sliceHelper.plane}get plugins(){return this._plugins}getMaterialRenderer(e){return this._renderers.get(e)}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,t){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:r,removes:s,updates:i}=e;if(0===r.length&&0===s.length&&0===i.length)return;Z(e).forEach(((r,s)=>{if(t.done)return;let i=this._renderers.get(s);null==i&&r.adds.length>0&&(i=new ue({material:s}),i.initializeRenderContext(this._plugins._context),this._plugins.add(i),this._renderers.set(s,i)),i&&(i.modify(r),0===i.numGeometries&&(this._renderers.delete(i.material),this._plugins.remove(i),i.destroy())),r.removes.forEach((t=>e.removes.removeUnordered(t))),r.adds.forEach((t=>e.adds.removeUnordered(t))),r.updates.forEach((t=>e.updates.removeUnordered(t))),t.madeProgress()})),this.updateHasFlags(),this._requestRender()}updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(v.Color,ie.LINE_CALLOUTS_HUD_DEPTH,ie.HUD_MATERIAL,ie.LABEL_MATERIAL),has.water=this._plugins.produces(v.Normal,ie.DRAPED_WATER),this._bindParameters.hasOccludees=this._plugins.hasOccludees}updateAnimation(e){const t=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(e),this._hasAnimations=this._nodes.updateAnimation()||this._hasAnimations,this._hasAnimations!==t&&(this._gpuTimerHandle=t?i(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=ee.Default,s=G.ON){try{return this._isRendering=!0,this._render(e,t,r,s)}catch(i){console.error(`Exception during rendering: ${i}`)}finally{this._isRendering=!1}return{screen:this._pluginInput.get("final-color"),oid:null}}_render(e,t,r=ee.Default,s=G.ON){this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=r===ee.Default,this._disposeBindBuffers();const i=this._framebuffer,{camera:a,contentCamera:n,mode:o,alignPixelEnabled:d}=e;this._state.value=o,this._bindParameters.overlay=this.renderOverlay(t),this._bindParameters.overlay&&this.performanceInfo.advance(fe.OVERLAY),this._renderContext.time=t,this._bindParameters.transparencyPassType=de.NONE,this._bindParameters.alignPixelEnabled=d,this._bindParameters.decorations=s,this._bindParameters.mainDepth=null,this._bindParameters.viewshedEnabled=this._viewshed.enabled;const l=this._nodes.produces("magnifier-color"),_=this._nodes.produces("final-color"),u=S(this._sliceHelper.plane);s===G.OFF&&(this._sliceHelper.plane=null),a.setGLViewport(this._rctx);const p=i.initialize(a.fullWidth,a.fullHeight,this._backgroundColor);this.hasReflections?this._bindParameters.ssr.lastFrameColor=p:p?.release(),this._ensureBindParametersCamera(a,n),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&s===G.ON;const c=this._plugins.produces(v.Color,ie.OPAQUE_TERRAIN)&&(this._terrainTransparency===I.Transparent||this._terrainTransparency===I.InvisibleWithDraped),m=this._highQualityTransparency&&c,f=this._plugins.produces(v.Color,...Ie);this._prepareShaders(m,f),this.performanceInfo.advance(fe.PREPARE);const g=this._computeDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,g),this._ensureBindParametersCamera(a,n);let b=this._renderNormals();this._pluginInput.set("normals",b);const T=this._needsDepth;if(b){let e=null;T&&(e=b.getAttachment(be),e?.retain()),this._pluginInput.set("ssao",this._renderSSAO()),this._renderNoSSAOGeometryDepth(T,e),b=null}else this._renderAllGeometryDepth(T);this._renderShadowAccumulation(g,a,n),this._ensureBindParametersSSR(t),this._renderContext.output=v.Color,i.bind(),this._bindParameters.mainDepth=i.depth.attachment;const E=this.plugins.produces(v.Color,...Oe);E&&this._renderOpaqueGeometry(),i.update((e=>this._renderNodes(w.OPAQUE,e,E))),this.fboCache.debugCallback?.("opaque-color",i.color.fbo),this._renderPlugins(ie.OPAQUE_ENVIRONMENT,fe.OPAQUE_ENVIRONMENT),this._renderMultipassTerrainDepth(m),this._setMultipassTerrain(m),this._renderEdges(_e.OPAQUE),i.bind(),this._renderPlugins(ie.VOXEL,fe.VOXEL),this._renderHiddenTransparentEdges(),f&&(this._oitEnabled?this._renderOITPass(we.Geometry):this._renderTransparentMaterial()),i.update((e=>this._renderNodes(w.TRANSPARENT,e,f))),this.fboCache.debugCallback?.("transparent-color",i.color.fbo),this._renderMultipassGeometryDepth(m),this._renderHUDVisibility(),m||this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS);const A=r===ee.ObjectAndLayerID?this._renderObjectAndLayerIdColor():null;this._renderEdges(_e.TRANSPARENT);const P=c?this._renderTransparentTerrain():null;P&&(this.performanceInfo.advance(fe.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(m?this._renderLineCallouts(H.Occluded):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositingHelper.compositeHUD(this._bindParameters,P.getTexture())),this._renderHUD(H.Occluded,i.color))),this._setTerrainCulling(!1),P&&(i.bind(),this._compositingHelper.composite(this._bindParameters,P.getTexture(),pe.PremultipliedAlpha),P.release(),m&&(this._renderEdges(_e.OPAQUE),f&&(this._oitEnabled?this._renderOITPass(we.Geometry):this._renderTransparentMaterial(),this.performanceInfo.advance(fe.TRANSPARENT)),this._renderEdges(_e.TRANSPARENT))),this._bindParameters.ssao=h(this._bindParameters.ssao),m&&this._renderLineCallouts(H.NotOccluded),this._setMultipassEnabled(!1),this._renderTransparentEnvironment(),this._renderViewshed(),i.update((e=>this._renderNodes(C.LASERLINES,e))),this._renderOccluded(),this._pluginInput.set("highlights",this._renderHighlightPrepass()),i.update((e=>this._renderNodes(w.COMPOSITE,e)));const R=this._nodes.produces("aa-color"),O=!(r!==ee.Default||_||l&&s===G.ON&&r===ee.Default),y=this._pluginInput.get("composite-color"),D=O?x:this.fboCache.acquire(y.fbo.width,y.fbo.height,"aa-color"),N=R?this._renderNodes(C.ANTIALIASING,D):this._blitFBO(y,D,!1);this._pluginInput.set(C.ANTIALIASING,N),this._renderHUD(H.NotOccluded,N);const M=this._renderNodes(C.HIGHLIGHTS,N),L=this._renderNodes(C.MAGNIFIER,M);return l&&s===G.ON&&r===ee.Default&&!_&&this._blitFBO(L),_?(L.attachDepth(i.depth),this._blitFBO(this._renderNodes(w.FINAL,L)),L.detachDepth()):this._pluginInput.set(w.FINAL,L),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),i.release(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=u,this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),r!==ee.Default&&(this._releaseFBOs(),this._disposeOffscreenBuffers()),{screen:this._pluginInput.get("final-color"),oid:A}}_prepareShaders(e,t){this._renderContext.output=v.Color,this._prepareOpaqueGeometry(),this._setMultipassTerrain(e),this._plugins.prepare(ie.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._plugins.prepare(ie.LINE_CALLOUTS),t&&this._prepareTransparencySlots(),this._plugins.prepare(ie.VIEWSHED,ie.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,ie.TRANSPARENT_ENVIRONMENT),this._rctx.gl.flush()}_renderObjectAndLayerIdColor(){if(!has("enable-feature:objectAndLayerId-rendering"))return;const e=this._renderContext.output,t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"oid");return r.acquireDepth(y.DEPTH_STENCIL_TEXTURE),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer([0,0,0,0],!0,!0),this._renderAllGeometry(v.ObjectAndLayerIdColor),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(void 0,!0,!0),this._bindParameters.hudRenderStyle=H.NotOccluded,this._plugins.render(this._pluginInput,ie.HUD_MATERIAL),this._renderContext.output=e,this.performanceInfo.advance(fe.OBJECT_AND_LAYER_ID_COLOR),r}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=e===B.BACKGROUND;if(r||t){const e=r?this.performanceInfo.elapsedTime:0,s=t?this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.getError(),i=Math.max(e,s);this._animationTimestep.frame(i,r)}}readDepthPixels(e,t){const{mainDepth:r,camera:s}=this._bindParameters;if(!r)return;const i=this.fboCache.acquire(this._framebufferSize.width,this._framebufferSize.height,"linear-depth");this._rctx.bindFramebuffer(i.fbo),s.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer([0,0,0,0]),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),i.fbo?.readPixels(e[0],e[1],e[2],e[3],Te.RGBA,Ee.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,t,r,s,i){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,s,Te.RGBA,Ee.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_setMultipassTerrain(e){this._setMultipassEnabled(e),this._setTerrainCulling(e)}_setMultipassEnabled(e){this._bindParameters.multipassEnabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const r=this._framebufferSize,s=this.fboCache.acquire(r.width,r.height,"edges"),i=()=>t.render(this._bindParameters,e),a=this._bindParameters.multipassGeometry.depth;this.renderToTargets(i,s,a??this._framebuffer.depth,Ce),this._framebuffer.bind(),this._compositingHelper.composite(this._bindParameters,s.getTexture(),pe.Alpha),s.release(),this.performanceInfo.advance(e===_e.OPAQUE?fe.OPAQUE_EDGES:fe.TRANSPARENT_EDGES)}_renderShadowMap(e,t,r){const s=this._shadowMap;s.enabled&&(s.start(e,t,r,this.isFeatureEnabled(re.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(v.ShadowHighlight,this._shadowMap),s.moveSnapshot(he.Highlight),this._renderShadowCascades(v.ShadowExcludeHighlight,this._shadowMap),s.copySnapshot(he.ExcludeHighlight),this._renderShadowCascades(v.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(v.Shadow),s.finish(),e.setGLViewport(this._rctx),this.performanceInfo.advance(fe.SHADOW_MAP))}_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(v.Depth)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast||this._debugNeedsDepth}_renderNoSSAOGeometryDepth(e,t){if(!e||!t)return void(this._bindParameters.depth=h(this._bindParameters.depth));const r=this._framebufferSize,s=this.fboCache.acquire(r.width,r.height,"depth");s.attachDepth(t),t.release(),this._rctx.bindFramebuffer(s.fbo),this._rctx.clearFramebuffer(void 0,!1,!0),this._renderGeometryExcludedFromSSAO(v.Depth),h(this._bindParameters.depth),this._bindParameters.depth=s.obtainDepthTexture(),s.release(),this.performanceInfo.advance(fe.DEPTH)}_renderAllGeometryDepth(e){if(!e)return void(this._bindParameters.depth=h(this._bindParameters.depth));const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"depth").acquireDepth(y.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(void 0,!0,!0),this._renderAllGeometry(v.Depth),h(this._bindParameters.depth),this._bindParameters.depth=r.obtainDepthTexture(),r.release(),this.performanceInfo.advance(fe.DEPTH)}_renderMultipassTerrainDepth(e){if(!e)return void(this._bindParameters.multipassTerrain.depth=h(this._bindParameters.multipassTerrain.depth));const t=this._renderContext.output;this._renderContext.output=v.Depth;const r=this._framebufferSize,s=this.fboCache.acquire(r.width,r.height,"terrain depth").acquireDepth(y.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(s.fbo),this._rctx.clearFramebuffer(void 0,!0,!0),this._renderTransparentTerrain(),h(this._bindParameters.multipassTerrain.depth),this._bindParameters.multipassTerrain.depth=s.obtainDepthTexture(),this._renderContext.output=t,s.release()}_renderMultipassGeometryDepth(e){if(!e)return void(this._bindParameters.multipassGeometry.depth=h(this._bindParameters.multipassGeometry.depth));const t=this._renderContext.output,r=this._framebufferSize,s=this.fboCache.acquire(r.width,r.height,"geometry depth").acquireDepth(y.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(s.fbo),this._rctx.clearFramebuffer(void 0,!0,!0),this._renderOpaqueGeometryAndTransparentMaterial(v.Depth),this._renderContext.output=t,h(this._bindParameters.multipassGeometry.depth),this._bindParameters.multipassGeometry.depth=s.obtainDepthTexture(),s.release()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return W;const t=X(e,this._plugins.plugins,this._stage.layers);return z(t,this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}_renderNormals(){const e=this._nodes.require("normals","final-color","composite-color","opaque-color","transparent-color","laserline-color"),t=(this.hasSSAO?1:0)+e;if(0===t)return;const r=this._framebufferSize,s=this.fboCache.acquire(r.width,r.height,"normals",D.RGBA);s.acquireDepth(y.DEPTH_STENCIL_TEXTURE),this._rctx.bindFramebuffer(s.fbo),this._rctx.clearFramebuffer([0,0,0,0],!0,!0),this._renderGeometryForSSAO(v.Normal);const i=this._nodes.optional("normals","final-color","composite-color","opaque-color","transparent-color")+(this._viewshedEnabled?1:0);return s.retain(t+i-1),this.performanceInfo.advance(fe.NORMALS),s}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return void e?.detachDepth();x.setName("ssao");const t=this._nodes.render(x,this._pluginInput);return this._bindParameters.ssao=t,e.detachDepth(),this._pluginInput.release("normals"),this.performanceInfo.advance(fe.SSAO),t}_renderAllGeometry(e){this._renderContext.output=e,this._plugins.prepare(ie.TRANSPARENT_TERRAIN),this._renderOpaqueGeometryAndTransparentMaterial(e),this._renderTransparentTerrain()}_renderOpaqueGeometryAndTransparentMaterial(e){this._renderContext.output=e,this._plugins.prepare(ie.TRANSPARENT_MATERIAL,ie.TRANSPARENT_NO_SSAO_DEPTH),this._renderOpaqueGeometry(),this._renderTransparentMaterial()}_renderGeometryForSSAO(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,ie.INTEGRATED_MESH,ie.OPAQUE_TERRAIN,ie.OPAQUE_MATERIAL,ie.TRANSPARENT_MATERIAL),this._renderTransparentTerrain()}_renderGeometryExcludedFromSSAO(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,ie.OPAQUE_NO_SSAO_DEPTH,ie.TRANSPARENT_NO_SSAO_DEPTH)}_prepareOpaqueGeometry(){this._plugins.prepare(...Oe,ie.OPAQUE_ENVIRONMENT)}_renderOpaqueGeometry(){this._plugins.render(this._pluginInput,...Oe)}_renderTransparentMaterial(){this._plugins.render(this._pluginInput,...Ie)}_renderTransparentTerrain(){const e=this._renderContext.output;if(!this._plugins.produces(e,ie.TRANSPARENT_TERRAIN))return;const t=()=>this._plugins.render(this._pluginInput,ie.TRANSPARENT_TERRAIN);if(e!==v.Color)return void t();const r=this._framebufferSize,s=this.fboCache.acquire(r.width,r.height,"transparent terrain");return this.renderToTargets(t,s,this._framebuffer.depth,[0,0,0,0]),s}_renderHUDVisibility(){if(this._plugins.produces(this._renderContext.output,ie.OCCLUSION_PIXELS)){const e=()=>{const e=this._framebufferSize;let t=this._bindParameters.hudVisibility;const r=this._bindParameters.multipassGeometry.depth;return t?.fbo?.width===e.width&&t?.fbo?.height===e.height||(t?.release(),t=this.fboCache.acquire(e.width,e.height,"hud visibility",D.RGBA4)),t.attachDepth(r||this._framebuffer.depth),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(this._pluginInput,ie.OCCLUSION_PIXELS),t.detachDepth(),t};this._bindParameters.hudVisibility=e(),this._framebuffer.bind(),this.performanceInfo.advance(fe.HUD_VISIBILITY)}else this._bindParameters.hudVisibility=h(this._bindParameters.hudVisibility)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===H.Occluded){const e=()=>this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS),t=this._framebufferSize,r=this.fboCache.acquireDepth(y.DEPTH16_BUFFER,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,ie.LINE_CALLOUTS)}_renderHUD(e,t){if(this._pluginsHas.hudElements){if(this._oitEnabled){const r=this._renderOITPass(we.HUD,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.composite(this._bindParameters,r.getTexture(),pe.PremultipliedAlpha),r.release()}else if(e===H.Occluded){this._renderContext.output=v.Color;const t=()=>this._renderHUDElements(e),r=this._framebufferSize,s=this.fboCache.acquireDepth(y.DEPTH16_BUFFER,r.width,r.height,"hud");this.renderToTargets(t,this._framebuffer.color,s,void 0,!0,!0),s.release()}else this._renderContext.output=v.Color,t.acquireDepth(y.DEPTH16_BUFFER),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(e===H.Occluded?fe.HUD_OCCLUDED:fe.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.prepare(ie.LINE_CALLOUTS_HUD_DEPTH,ie.HUD_MATERIAL,ie.LABEL_MATERIAL),this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS_HUD_DEPTH,ie.HUD_MATERIAL,ie.LABEL_MATERIAL)}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._plugins.produces(v.ShadowHighlight,ie.OPAQUE_MATERIAL)}_renderHighlightPrepass(){if(!this.hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:r}=this,s=this._framebufferSize;let i=this._pluginInput.get("highlight mix");null==i&&(i=e.acquire(s.width,s.height,"highlight mix",D.RGBA),this._pluginInput.set("highlight mix",i),r.highlightTexture=i.getTexture()),t.bindFramebuffer(i.fbo);const a=[0,0,0,0];t.clearFramebuffer(a);const n=i.getTexture(),h=e.acquire(s.width,s.height,"highlights",D.RGBA);h.acquireDepth(y.DEPTH16_BUFFER),t.bindFramebuffer(h.fbo),t.clearFramebuffer(a,!0);const{highlightOrder:o}=this._stage.view,d=Math.min(16,o.length),{highlightGroupMap:l}=r;l.clear();for(let _=0;_<d;++_){const e=o.at(_);e&&l.set(e,_)}for(let _=0;_<d;++_)r.highlightLevel=_,r.highlightGroup=o.at(_),t.bindFramebuffer(h.fbo),t.clearFramebuffer(void 0,!0),this._renderAllGeometry(v.Highlight),0===_&&(t.clear(Ae.DEPTH),this._renderHUDElements(H.Both)),t.clear(Ae.DEPTH),t.bindTexture(n,0),t.gl.copyTexImage2D(Pe.TEXTURE_2D,0,Te.RGBA,0,0,s.width,s.height,0);return h}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_renderShadowAccumulation(e,t,r){this._needsShadowCast&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,e,t,r)&&this.performanceInfo.advance(fe.ACCUMULATED_SHADOWS)}_prepareTransparencySlots(){this._renderContext.output=v.Color,this._bindParameters.transparencyPassType=de.ColorAlpha,this._plugins.prepare(...Ie),this._bindParameters.transparencyPassType=de.FrontFace,this._plugins.prepare(...Ie),this._bindParameters.transparencyPassType=de.NONE,this._techniques.acquire(ce).release()}_renderOITPass(e,t=H.Both){const r=e===we.HUD,s=this._framebufferSize,i=r?this.fboCache.acquire(s.width,s.height,"oit hud composite"):null,a=r?()=>this._renderHUDElements(t):()=>this._renderTransparentMaterial(),n=this._renderContext.output;return this._renderContext.output=v.Color,this._renderOIT(this._bindParameters,a,i),this._renderContext.output=n,i}_renderOIT(e,t,r){const s=this._framebufferSize;e.transparencyPassType=de.ColorAlpha;const i=r?"oit hud color alpha":"oit color alpha",a=this.fboCache.acquire(s.width,s.height,i,D.RGBA16F);a.acquireColor(Re.COLOR_ATTACHMENT1,D.R16F),r||a.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(a.fbo),this._rctx.clearFramebuffer([0,0,0,1]),t(),a.detachDepth(),e.transparencyPassType=de.FrontFace;const n=this.fboCache.acquire(s.width,s.height,r?"oit hud front":"oit front");r?n.acquireDepth(y.DEPTH16_BUFFER):n.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(n.fbo),this._rctx.clearFramebuffer([0,0,0,0],!!r),t(),n.detachDepth(),e.transparencyPassType=de.NONE,r?(this._rctx.bindFramebuffer(r.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(Ae.COLOR)):this._framebuffer.bind(),this._compositingHelper.compositeOIT(e,a.getTexture(),a.getTexture(Re.COLOR_ATTACHMENT1),n.getTexture()),r?.detachDepth(),n.release(),a.release()}_renderOccluded(){let e=0;ye.clear(),this._plugins.plugins.forAll((t=>{if(!t.material)return;t.queryRenderOccludedState(J.OccludeAndTransparentStencil)&&(e|=J.OccludeAndTransparentStencil,ye.push(t))}));const t=this._framebuffer,r=(r,s,i,a,n)=>{if(!(e&s))return;const h=this._framebufferSize,o=this.fboCache.acquire(h.width,h.height,"tmp color");let d;d=a?this.fboCache.acquireDepth(y.DEPTH_STENCIL_TEXTURE,h.width,h.height,"tmp depth"):t.depth,this.renderToTargets(i,o,d,[0,0,0,0],a,n),t.bind(),this._compositingHelper.composite(this._bindParameters,o.getTexture(),pe.PremultipliedAlpha,r),a&&d.release(),o.release()},s=(e,t)=>{this._bindParameters.slot=e,t.forAll((e=>{if(q(e)){const t=e.prepareTechnique(this._renderContext);t&&e.renderNode(this._renderContext,t)}}))};0!==ye.length&&(s(ie.OCCLUDER_MATERIAL,ye),r(.5,J.OccludeAndTransparentStencil,(()=>s(ie.TRANSPARENT_OCCLUDER_MATERIAL,ye)),!1,!1));const i=ye.length>0;ye.clear(),this._plugins.plugins.forAll((t=>{if(!t.material)return;const r=t.queryRenderOccludedState(J.OccludeAndTransparent),s=t.queryRenderOccludedState(J.Transparent),i=t.queryRenderOccludedState(J.Opaque);(r||s||i)&&(e|=r?J.OccludeAndTransparent:s?J.Transparent:J.Opaque,ye.push(t))}));const a=this._plugins.renderOccludedFlags;if(e|=a,!e)return;const n=e=>{this._renderContext.renderOccludedMask=e,a>J.Occlude&&this._plugins.render(this._pluginInput,ie.OCCLUDED_TERRAIN),s(ie.OPAQUE_MATERIAL,ye),s(ie.TRANSPARENT_MATERIAL,ye),s(ie.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,ye),this._renderContext.renderOccludedMask=$};this._renderContext.output=v.Color,r(.5,J.OccludeAndTransparent,(()=>n(J.OccludeAndTransparent)),!0,Q.OutlineVisualElementMask),r(.5,J.Transparent,(()=>n(J.Transparent)),!0,Q.OutlineVisualElementMask),r(1,J.Opaque,(()=>n(J.Opaque)),!0,Q.OutlineVisualElementMask),(i||ye.length>0)&&this.performanceInfo.advance(fe.OCCLUDED),ye.clear()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this._framebuffer.bind(),this._plugins.render(this._pluginInput,ie.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,ie.TRANSPARENT_ENVIRONMENT),this.performanceInfo.advance(fe.TRANSPARENT_ENVIRONMENT)}_renderViewshed(){this._viewshedEnabled&&(this._viewshed.renderHighQuality=this.isFeatureEnabled(re.HighResolutionViewshed),this._plugins.render(this._pluginInput,ie.VIEWSHED),this._pluginInput.release("normals"),this.performanceInfo.advance(fe.VIEWSHED))}_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(!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;t.setName(e),this._pluginInput.set(e,t);const s=this._nodes.render(t,this._pluginInput,this._releaseNormals);return this.performanceInfo.advance(e),s}_blitFBO(e,t=x,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=T:(g(Ne,this._bindParameters.camera.viewMatrix),g(De,this._bindParameters.camera.projectionMatrix),b(xe,Ne,De),b(xe,this._renderContext.lastFrameCamera.viewMatrix,xe),b(xe,this._renderContext.lastFrameCamera.projectionMatrix,xe),this._reprojectionMatrix=xe);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=T,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}get _viewshedEnabled(){return this._viewshed.enabled&&this._plugins.produces(this._renderContext.output,ie.VIEWSHED)}renderToTargets(e,t,r,s,i=!1,a=!1){t.attachDepth(r),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(s,i,a),e(),t.detachDepth()}get test(){}}var we;e([m({readOnly:!0})],Se.prototype,"fullResolutionAtmosphere",null),e([m()],Se.prototype,"_edgeView",void 0),e([m()],Se.prototype,"updating",null),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(we||(we={}));const Ce=[0,0,0,0],Oe=[ie.INTEGRATED_MESH,ie.OPAQUE_TERRAIN,ie.OPAQUE_MATERIAL,ie.OPAQUE_NO_SSAO_DEPTH],Ie=[ie.TRANSPARENT_MATERIAL,ie.TRANSPARENT_NO_SSAO_DEPTH],ye=new o,De=E(),Ne=E(),xe=E();function Me(e){return t=>e.immediate.schedule(t)}export{Se 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.31/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import{NestedMap as e}from"../../../../core/NestedMap.js";import{ScreenSpaceGeometry as r}from"../effects/ScreenSpaceGeometry.js";import{VaoCache as s}from"../materials/renderers/VaoCache.js";import{AppleAmdDriverHelper as t}from"../../../webgl/AppleAmdDriverHelper.js";import{RenderingContext as i}from"../../../webgl/RenderingContext.js";class o extends i{constructor(s,t){super(s,t),this.gl=s,this._vaoCaches=new e,this._appleAmdDriverHelper=null,this._refCount=1,this._newCache=t.newCache,this.screen=new r(this)}configure(e){super.configure(e),this._newCache=e.newCache}destroy(){this._vaoCaches?.forAll((e=>e.dispose())),this._vaoCaches?.clear(),--this._refCount>0||this.dispose()}ref(){++this._refCount}dispose(){super.dispose(),this._appleAmdDriverHelper?.dispose(),this.screen.destroy(),this._vaoCaches.forAll((e=>e.dispose())),this._vaoCaches.clear()}get newCache(){return this._newCache}getVaoCache(e,r){const t=Array.from(e).join("."),i=JSON.stringify(r),o=this._vaoCaches.get(t,i);if(o)return o;const a=new s(this,e,r);return this._vaoCaches.set(t,i,a),a}bindTechnique(e,r,s,t,i){return this.useProgram(e.program),this.setPipelineState(e.getPipeline(!!i)),e.program.bindPass(s,r),t&&e.program.bindDraw(t,r,s),e.program}runAppleAmdDriverHelper(){this.driverTest.drawArraysRequiresIndicesTypeReset.result&&(this._appleAmdDriverHelper??=new t(this),this._appleAmdDriverHelper.run())}get test(){}}export{o as RenderingContext};
5
+ import"../../../../core/has.js";import{NestedMap as e}from"../../../../core/NestedMap.js";import{ScreenSpaceGeometry as r}from"../effects/ScreenSpaceGeometry.js";import{VaoCache as s}from"../materials/renderers/VaoCache.js";import{AppleAmdDriverHelper as t}from"../../../webgl/AppleAmdDriverHelper.js";import{RenderingContext as i}from"../../../webgl/RenderingContext.js";class o extends i{constructor(s,t){super(s,t),this.gl=s,this._vaoCaches=new e,this._appleAmdDriverHelper=null,this._refCount=1,this._newCache=t.newCache,this.screen=new r(this)}configure(e){super.configure(e),this._newCache=e.newCache}destroy(){this._vaoCaches?.forAll((e=>e.dispose())),this._vaoCaches?.clear(),--this._refCount>0||this.dispose()}ref(){++this._refCount}dispose(){super.dispose(),this._appleAmdDriverHelper?.dispose(),this.screen.destroy(),this._vaoCaches.forAll((e=>e.dispose())),this._vaoCaches.clear()}get newCache(){return this._newCache}getVaoCache(e,r){const t=Array.from(e).join("."),i=JSON.stringify(r),o=this._vaoCaches.get(t,i);if(o)return o;const a=new s(this,e,r);return this._vaoCaches.set(t,i,a),a}bindTechnique(e,r,s,t,i){return this.useProgram(e.program),this.setPipelineState(e.getPipeline(!!i)),s&&(e.program.bindPass(s,r),t&&e.program.bindDraw(r,s,t)),e.program}runAppleAmdDriverHelper(){this.driverTest.drawArraysRequiresIndicesTypeReset.result&&(this._appleAmdDriverHelper??=new t(this),this._appleAmdDriverHelper.run())}get test(){}}export{o as RenderingContext};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/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 i}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{smoothstep as r}from"../../../../core/mathUtils.js";import{disposeMaybe as s,releaseMaybe as o}from"../../../../core/maybe.js";import{watch as a,syncAndInitial as n,sync as h}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import{subclass as _}from"../../../../core/accessorSupport/decorators/subclass.js";import{G as u,c as l}from"../../../../chunks/vec32.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ReadShadowMapPassParameters as d}from"../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{BindParameters as p}from"./BindParameters.js";import{zero as g}from"./depthRange.js";import{createQuadVAO as f}from"./glUtil3D.js";import{ShadowCastRenderer as b,shadowCastDisabledElevationThreshold as w,shadowCastDisableElevationMax as v,shadowCastDisableElevationMin as A}from"./ShadowCastRenderer.js";import{ShadowMap as R}from"./ShadowMap.js";import{S as y}from"../../../../chunks/ShadowCastAccumulate.glsl.js";import{ShadowCastAccumulateTechnique as C}from"../shaders/ShadowCastAccumulateTechnique.js";import{TaskPriority as F}from"../../../support/Scheduler.js";import{PixelFormat as j,PixelType as S,SizedPixelFormat as x,TextureWrapMode as P,ClearBufferBit as T}from"../../../webgl/enums.js";import{FramebufferObject as D}from"../../../webgl/FramebufferObject.js";import{TextureDescriptor as q}from"../../../webgl/TextureDescriptor.js";import{vertexCount as E}from"../../../webgl/Util.js";let M=class extends t{constructor(e,t,i,r,s,o){super({}),this.fbos=e,this._stage=i,this._prepareForShadowMapPass=r,this._renderToShadowMap=s,this._requestRender=o,this._progress=0,this._sampleCount=0,this._passParameters=new d,this._cachedLightDirections=[],this._depthRange=g,this._previewing=!1,this._cameraForcedForScreenshot=!1,this._shadowAccumulatorKey="shadowAccumulator",this._rctx=e.rctx,this._bindParameters=new p(new R(e,i.viewingMode),null),this._bindParameters.shadowMap.enabled=!0,this._vao=f(this._rctx),this._accumulationRenderer=new b(t,this._rctx,this,o);const c=this._stage.view.resourceController.scheduler;this.addHandles([c.registerTask(F.SHADOW_ACCUMULATOR,this),a((()=>i.renderView),(e=>{this.removeHandles(L),null!=e&&this.addHandles(e.events.on("force-camera-for-screenshot",(()=>this._cameraForcedForScreenshot=!0)),L)}),n),a((()=>this._previewing),(()=>this._requestRenderIfEnabled()),h)],this._shadowAccumulatorKey)}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),this._accumulationTechniqueCached=o(this._accumulationTechniqueCached),this._cachedLightDirections.length=0,this._sampleCount=0}get computedSamples(){return this._progress}get shadowCastTexture(){return this._fbo?.colorTexture}get isAccumulating(){return this._isPreviewing||this._isRefining}get _accumulationTechnique(){if(null==this._accumulationTechniqueCached){const e={rctx:this._rctx,viewingMode:this._stage.viewingMode};this._accumulationTechniqueCached=new C(e)}return this._accumulationTechniqueCached}get _isRefining(){return this._isActive&&!this._isDoneAccumulating&&!this._previewing}get _isPreviewing(){return this._isActive&&this._previewing}get _isActive(){return null!=this._fbo&&this._sampleCount>0}get canAccumulate(){return null!=this._bindParameters.depth&&this._depthRange!==g&&this._opacityFromElevation>w}get _isDoneAccumulating(){return this._progress>=this._sampleCount}get _lightDirections(){return this._cachedLightDirections}set _lightDirections(e){const t=this._cachedLightDirections;if(i(t,e,u))return;const r=Math.min(y,e.length);t.length=r,this._sampleCount=r;for(let i=0;i<r;++i)t[i]=l(t[i]??m(),e[i]);this._invalidate()}get _opacityFromElevation(){return this._accumulationRenderer.opacityFromElevation}set _opacityFromElevation(e){this._accumulationRenderer.opacityFromElevation=e}get running(){return this._isRefining&&this.canAccumulate&&this._progress>0}runTask(e){for(this._prepareForShadowMapPass(this._bindParameters);!e.done&&!this._isDoneAccumulating;)this._accumulateShadow(),e.madeProgress();this._requestRender()}renderAccumulation(e,t,i,r){if(this._depthRange=t,this._updateCamera(i),this._bindParameters.contentCamera=r,this._bindParameters.depth=e,this._passParameters.origin=this._bindParameters.camera.center,this.notifyChange("canAccumulate"),!this.isAccumulating||!this.canAccumulate)return!1;(this._previewing||0===this._progress||this._cameraForcedForScreenshot)&&this._clear();const s=this._cameraForcedForScreenshot?this._sampleCount:Math.min(U,this._sampleCount-this._progress);for(let o=0;o<s;++o)this._accumulateShadow();return this._cameraForcedForScreenshot=!1,this._requestRender(),s>0}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._isActive||!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,j.RGBA,S.UNSIGNED_BYTE,O),O[0]/this._progress)}_enable(){this._progress=0;const e=new q;e.pixelFormat=j.RED,e.internalFormat=x.R8,e.wrapMode=P.CLAMP_TO_EDGE,this._fbo=new D(this._rctx,e),this._requestRender()}_disable(){this._fbo=s(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(T.COLOR_BUFFER_BIT),this._progress=0}_accumulateShadow(){this._renderToShadowMap(this._bindParameters,this._lightDirections[this._progress++],this._depthRange);const e=this._accumulationTechnique;this._rctx.bindFramebuffer(this._fbo),this._rctx.bindTechnique(e,this._bindParameters,this._passParameters),this._rctx.bindVAO(this._vao),this._rctx.drawArrays(e.primitiveType,0,E(this._vao,"geometry"))}_updateCamera(e){const t=this._fbo;if(null==t)return;const i=this._bindParameters.camera;e.equals(i)||i.copyFrom(e),t.resize(e.fullWidth,e.fullHeight),this._opacityFromElevation=1-r(A,v,e.relativeElevation)}_requestRenderIfEnabled(){this._fbo&&this._requestRender()}get test(){}};e([c()],M.prototype,"_progress",void 0),e([c()],M.prototype,"_sampleCount",void 0),e([c()],M.prototype,"_fbo",void 0),e([c()],M.prototype,"_depthRange",void 0),e([c()],M.prototype,"_previewing",void 0),e([c()],M.prototype,"_accumulationRenderer",void 0),e([c()],M.prototype,"_isRefining",null),e([c()],M.prototype,"_isActive",null),e([c()],M.prototype,"canAccumulate",null),e([c()],M.prototype,"_isDoneAccumulating",null),e([c()],M.prototype,"_opacityFromElevation",null),e([c()],M.prototype,"running",null),M=e([_("esri.views.3d.webgl-engine.lib.ShadowAccumulator")],M);const U=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 i}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{smoothstep as r}from"../../../../core/mathUtils.js";import{disposeMaybe as s,releaseMaybe as o}from"../../../../core/maybe.js";import{watch as a,syncAndInitial as n,sync as h}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import{subclass as _}from"../../../../core/accessorSupport/decorators/subclass.js";import{G as u,c as l}from"../../../../chunks/vec32.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ReadShadowMapPassParameters as d}from"../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{BindParameters as p}from"./BindParameters.js";import{zero as g}from"./depthRange.js";import{createQuadVAO as f}from"./glUtil3D.js";import{ShadowCastRenderer as b,shadowCastDisabledElevationThreshold as w,shadowCastDisableElevationMax as v,shadowCastDisableElevationMin as A}from"./ShadowCastRenderer.js";import{ShadowMap as R}from"./ShadowMap.js";import{S as y}from"../../../../chunks/ShadowCastAccumulate.glsl.js";import{ShadowCastAccumulateTechnique as C}from"../shaders/ShadowCastAccumulateTechnique.js";import{TaskPriority as j}from"../../../support/Scheduler.js";import{PixelFormat as S,PixelType as F,SizedPixelFormat as x,TextureWrapMode as P,FramebufferBit as D}from"../../../webgl/enums.js";import{FramebufferObject as T}from"../../../webgl/FramebufferObject.js";import{TextureDescriptor as q}from"../../../webgl/TextureDescriptor.js";import{vertexCount as E}from"../../../webgl/Util.js";let M=class extends t{constructor(e,t,i,r,s,o){super({}),this.fbos=e,this._stage=i,this._prepareForShadowMapPass=r,this._renderToShadowMap=s,this._requestRender=o,this._progress=0,this._sampleCount=0,this._passParameters=new d,this._cachedLightDirections=[],this._depthRange=g,this._previewing=!1,this._cameraForcedForScreenshot=!1,this._shadowAccumulatorKey="shadowAccumulator",this._rctx=e.rctx,this._bindParameters=new p(new R(e,i.viewingMode),null),this._bindParameters.shadowMap.enabled=!0,this._vao=f(this._rctx),this._accumulationRenderer=new b(t,this._rctx,this,o);const c=this._stage.view.resourceController.scheduler;this.addHandles([c.registerTask(j.SHADOW_ACCUMULATOR,this),a((()=>i.renderView),(e=>{this.removeHandles(O),null!=e&&this.addHandles(e.events.on("force-camera-for-screenshot",(()=>this._cameraForcedForScreenshot=!0)),O)}),n),a((()=>this._previewing),(()=>this._requestRenderIfEnabled()),h)],this._shadowAccumulatorKey)}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),this._accumulationTechniqueCached=o(this._accumulationTechniqueCached),this._cachedLightDirections.length=0,this._sampleCount=0}get computedSamples(){return this._progress}get shadowCastTexture(){return this._fbo?.colorTexture}get isAccumulating(){return this._isPreviewing||this._isRefining}get _accumulationTechnique(){if(null==this._accumulationTechniqueCached){const e={rctx:this._rctx,viewingMode:this._stage.viewingMode};this._accumulationTechniqueCached=new C(e)}return this._accumulationTechniqueCached}get _isRefining(){return this._isActive&&!this._isDoneAccumulating&&!this._previewing}get _isPreviewing(){return this._isActive&&this._previewing}get _isActive(){return null!=this._fbo&&this._sampleCount>0}get canAccumulate(){return null!=this._bindParameters.depth&&this._depthRange!==g&&this._opacityFromElevation>w}get _isDoneAccumulating(){return this._progress>=this._sampleCount}get _lightDirections(){return this._cachedLightDirections}set _lightDirections(e){const t=this._cachedLightDirections;if(i(t,e,u))return;const r=Math.min(y,e.length);t.length=r,this._sampleCount=r;for(let i=0;i<r;++i)t[i]=l(t[i]??m(),e[i]);this._invalidate()}get _opacityFromElevation(){return this._accumulationRenderer.opacityFromElevation}set _opacityFromElevation(e){this._accumulationRenderer.opacityFromElevation=e}get running(){return this._isRefining&&this.canAccumulate&&this._progress>0}runTask(e){for(this._prepareForShadowMapPass(this._bindParameters);!e.done&&!this._isDoneAccumulating;)this._accumulateShadow(),e.madeProgress();this._requestRender()}renderAccumulation(e,t,i,r){if(this._depthRange=t,this._updateCamera(i),this._bindParameters.contentCamera=r,this._bindParameters.depth=e,this._passParameters.origin=this._bindParameters.camera.center,this.notifyChange("canAccumulate"),!this.isAccumulating||!this.canAccumulate)return!1;(this._previewing||0===this._progress||this._cameraForcedForScreenshot)&&this._clear();const s=this._cameraForcedForScreenshot?this._sampleCount:Math.min(L,this._sampleCount-this._progress);for(let o=0;o<s;++o)this._accumulateShadow();return this._cameraForcedForScreenshot=!1,this._requestRender(),s>0}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._isActive||!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,U),U[0]/this._progress)}_enable(){this._progress=0;const e=new q;e.pixelFormat=S.RED,e.internalFormat=x.R8,e.wrapMode=P.CLAMP_TO_EDGE,this._fbo=new T(this._rctx,e),this._requestRender()}_disable(){this._fbo=s(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(D.COLOR),this._progress=0}_accumulateShadow(){this._renderToShadowMap(this._bindParameters,this._lightDirections[this._progress++],this._depthRange);const e=this._accumulationTechnique;this._rctx.bindFramebuffer(this._fbo),this._rctx.bindTechnique(e,this._bindParameters,this._passParameters),this._rctx.bindVAO(this._vao),this._rctx.drawArrays(e.primitiveType,0,E(this._vao,"geometry"))}_updateCamera(e){const t=this._fbo;if(null==t)return;const i=this._bindParameters.camera;e.equals(i)||i.copyFrom(e),t.resize(e.fullWidth,e.fullHeight),this._opacityFromElevation=1-r(A,v,e.relativeElevation)}_requestRenderIfEnabled(){this._fbo&&this._requestRender()}get test(){}};e([c()],M.prototype,"_progress",void 0),e([c()],M.prototype,"_sampleCount",void 0),e([c()],M.prototype,"_fbo",void 0),e([c()],M.prototype,"_depthRange",void 0),e([c()],M.prototype,"_previewing",void 0),e([c()],M.prototype,"_accumulationRenderer",void 0),e([c()],M.prototype,"_isRefining",null),e([c()],M.prototype,"_isActive",null),e([c()],M.prototype,"canAccumulate",null),e([c()],M.prototype,"_isDoneAccumulating",null),e([c()],M.prototype,"_opacityFromElevation",null),e([c()],M.prototype,"running",null),M=e([_("esri.views.3d.webgl-engine.lib.ShadowAccumulator")],M);const L=6,O="renderView",U=new Uint8Array(4);export{M 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.31/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 u,scale as _,lerp as m,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{e as C,c as T,k as j,h as y,s 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{ColorFormat as F,DepthFormat as O}from"../../webgl/formats.js";import{CascadeCamera as U}from"./CascadeCamera.js";import{applyTextureResizeModulo as B,applyTextureResizeFloorModulo as L}from"./textureUtils.js";import{assert as Q,logWithBase as V,verify as I,rayRay2D as N}from"./Util.js";import{TextureType as A,ClearBufferBit as W}from"../../../webgl/enums.js";import{Texture as z}from"../../../webgl/Texture.js";var P;!function(t){t[t.Highlight=0]="Highlight",t[t.ExcludeHighlight=1]="ExcludeHighlight"}(P||(P={}));class q{constructor(){this.camera=new U,this.lightMat=l()}}class k{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 k,this._projectionView=l(),this._projectionViewInverse=l(),this._modelViewLight=l(),this._cascadeDistances=[0,0,0,0,0],this._usedCascadeDistances=R(),this._cascades=[new q,new q,new q,new q],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)it[t]=this._cascades[t];return it.length=this._numCascades,it}start(t,s,e,i,a){Q(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(){Q(this.enabled),this._handle?.detachDepth()}getShadowMapMatrices(t){if(!this._lastOrigin||!C(t,this._lastOrigin)){this._lastOrigin=this._lastOrigin||H(),T(this._lastOrigin,t);for(let s=0;s<this._numCascades;++s){r(at,this._cascades[s].lightMat,t);for(let t=0;t<16;++t)rt[16*s+t]=at[t]}}return rt}moveSnapshot(t){Q(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===P.Highlight?"shadow highlight snapshot":"shadow no highlight snapshot";this._snapshots[t]=this._fbos.acquire(e,i,a,F.RGBA4);const r=this._fbos.rctx;this._bindFbo();const h=r.bindTexture(this._snapshots[t]?.getTexture(),z.TEXTURE_UNIT_FOR_UPDATES);r.gl.copyTexSubImage2D(A.TEXTURE_2D,0,0,0,0,0,e,i),r.bindTexture(h,z.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(W.COLOR_BUFFER_BIT|W.DEPTH_BUFFER_BIT)}_computeTextureHeight(t,s,e){const i=Math.min(window.devicePixelRatio,s)/t.pixelRatio,a=e?this.settings.textureSizeModHighQuality:this.settings.textureSizeModLowQuality,r=B(Math.floor(Math.max(t.fullWidth,t.fullHeight)*i*a)),h=Math.min(this._maxTextureWidth,this._numCascades*r);return L(h/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",F.RGBA4)),this._handle?.acquireDepth(O.DEPTH16_BUFFER)}_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(){const t=this._fbos.rctx;t.unbindTexture(this.depthTexture),t.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]);Q(c<l);for(let r=0;r<8;++r){v(J,r%4==0||r%4==3?-1:1,r%4==0||r%4==1?-1:1,r<4?c:l,1);const t=K[r];S(t,J,this._projectionViewInverse),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3]}j(et,K[0]),a.camera.viewMatrix=r(X,this._modelViewLight,et);for(let r=0;r<8;++r)y(K[r],K[r],a.camera.viewMatrix);let d=K[0][2],u=K[0][2];for(let r=1;r<8;++r)d=Math.min(d,K[r][2]),u=Math.max(u,K[r][2]);d-=200,u+=200,a.camera.near=-u,a.camera.far=-d,Tt(e,i,d,u,a.camera),h(a.lightMat,a.camera.projectionMatrix,a.camera.viewMatrix);const _=this._textureHeight;a.camera.viewport=[t*_,0,_,_]}_setupMatrices(t,s){h(this._projectionView,t.projectionMatrix,t.viewMatrix),o(this._projectionViewInverse,this._projectionView);const e=this._viewingMode===E.Global?t.eye:D(et,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(V(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(),J=R(),K=[];for(let yt=0;yt<8;++yt)K.push(R());const Y=M(),Z=M(),$=M(),tt=M(),st=M(),et=H(),it=[],at=l(),rt=c.concat(c,c,c,c),ht=M(),ot=M(),nt=[M(),M(),M(),M()],ct=M(),lt=M(),dt=M(),ut=M(),_t=M(),mt=M(),ft=M();function gt(t,s,e,i,a,r,h,o){d(ht,0,0);for(let d=0;d<4;++d)u(ht,ht,t[d]);_(ht,ht,.25),d(ot,0,0);for(let d=4;d<8;++d)u(ot,ot,t[d]);_(ot,ot,.25),m(nt[0],t[4],t[5],.5),m(nt[1],t[5],t[6],.5),m(nt[2],t[6],t[7],.5),m(nt[3],t[7],t[4],.5);let n=0,c=f(nt[0],ht);for(let d=1;d<4;++d){const t=f(nt[d],ht);t<c&&(c=t,n=d)}g(ct,nt[n],t[n+4]);const l=ct[0];let M,C;ct[0]=-ct[1],ct[1]=l,g(lt,ot,ht),p(lt,ct)<0&&x(ct,ct),m(ct,ct,lt,e),b(ct,ct),M=C=p(g(dt,t[0],ht),ct);for(let d=1;d<8;++d){const s=p(g(dt,t[d],ht),ct);s<M?M=s:s>C&&(C=s)}w(i,ht),_(dt,ct,M-s),u(i,i,dt);let T=-1,j=1,y=0,D=0;for(let d=0;d<8;++d){g(ut,t[d],i),b(ut,ut);const s=ct[0]*ut[1]-ct[1]*ut[0];s>0?s>T&&(T=s,y=d):s<j&&(j=s,D=d)}I(T>0,"leftArea"),I(j<0,"rightArea"),_(_t,ct,M),u(_t,_t,ht),_(mt,ct,C),u(mt,mt,ht),ft[0]=-ct[1],ft[1]=ct[0];const H=N(i,t[D],mt,u(dt,mt,ft),1,a),v=N(i,t[y],mt,dt,1,r),S=N(i,t[y],_t,u(dt,_t,ft),1,h),R=N(i,t[D],_t,dt,1,o);I(H,"rayRay"),I(v,"rayRay"),I(S,"rayRay"),I(R,"rayRay")}function pt(t,s){return 3*s+t}const xt=M();function bt(t,s){return d(xt,t[s],t[s+3]),xt}const wt=M(),Mt=a();function Ct(t,s,e,i,a){g(wt,e,i),_(wt,wt,.5),Mt[0]=wt[0],Mt[1]=wt[1],Mt[2]=0,Mt[3]=wt[1],Mt[4]=-wt[0],Mt[5]=0,Mt[6]=wt[0]*wt[0]+wt[1]*wt[1],Mt[7]=wt[0]*wt[1]-wt[1]*wt[0],Mt[8]=1,Mt[pt(0,2)]=-p(bt(Mt,0),t),Mt[pt(1,2)]=-p(bt(Mt,1),t);let r=p(bt(Mt,0),e)+Mt[pt(0,2)],h=p(bt(Mt,1),e)+Mt[pt(1,2)],o=p(bt(Mt,0),i)+Mt[pt(0,2)],n=p(bt(Mt,1),i)+Mt[pt(1,2)];r=-(r+o)/(h+n),Mt[pt(0,0)]+=Mt[pt(1,0)]*r,Mt[pt(0,1)]+=Mt[pt(1,1)]*r,Mt[pt(0,2)]+=Mt[pt(1,2)]*r,r=1/(p(bt(Mt,0),e)+Mt[pt(0,2)]),h=1/(p(bt(Mt,1),e)+Mt[pt(1,2)]),Mt[pt(0,0)]*=r,Mt[pt(0,1)]*=r,Mt[pt(0,2)]*=r,Mt[pt(1,0)]*=h,Mt[pt(1,1)]*=h,Mt[pt(1,2)]*=h,Mt[pt(2,0)]=Mt[pt(1,0)],Mt[pt(2,1)]=Mt[pt(1,1)],Mt[pt(2,2)]=Mt[pt(1,2)],Mt[pt(1,2)]+=1,r=p(bt(Mt,1),s)+Mt[pt(1,2)],h=p(bt(Mt,2),s)+Mt[pt(2,2)],o=p(bt(Mt,1),e)+Mt[pt(1,2)],n=p(bt(Mt,2),e)+Mt[pt(2,2)],r=-.5*(r/h+o/n),Mt[pt(1,0)]+=Mt[pt(2,0)]*r,Mt[pt(1,1)]+=Mt[pt(2,1)]*r,Mt[pt(1,2)]+=Mt[pt(2,2)]*r,r=p(bt(Mt,1),s)+Mt[pt(1,2)],h=p(bt(Mt,2),s)+Mt[pt(2,2)],o=-h/r,Mt[pt(1,0)]*=o,Mt[pt(1,1)]*=o,Mt[pt(1,2)]*=o,a[0]=Mt[0],a[1]=Mt[1],a[2]=0,a[3]=Mt[2],a[4]=Mt[3],a[5]=Mt[4],a[6]=0,a[7]=Mt[5],a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=Mt[6],a[13]=Mt[7],a[14]=0,a[15]=Mt[8]}function Tt(t,s,i,a,r){const h=1/K[0][3],o=1/K[4][3];Q(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,gt(K,n,c,Y,Z,$,tt,st),Ct(Y,Z,tt,st,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,P 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 u,scale as m,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{e as C,c as j,k as T,h as y,s 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 O}from"../../../ViewingMode.js";import{ColorFormat as E,DepthFormat as U}from"../../webgl/formats.js";import{CascadeCamera as F}from"./CascadeCamera.js";import{applyTextureResizeModulo as L,applyTextureResizeFloorModulo as Q}from"./textureUtils.js";import{assert as V,logWithBase as N,verify as A,rayRay2D as B}from"./Util.js";import{TextureType as I,FramebufferBit as W}from"../../../webgl/enums.js";import{Texture as z}from"../../../webgl/Texture.js";var P;!function(t){t[t.Highlight=0]="Highlight",t[t.ExcludeHighlight=1]="ExcludeHighlight"}(P||(P={}));class q{constructor(){this.camera=new F,this.lightMat=l()}}class k{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 k,this._projectionView=l(),this._projectionViewInverse=l(),this._modelViewLight=l(),this._cascadeDistances=[0,0,0,0,0],this._usedCascadeDistances=R(),this._cascades=[new q,new q,new q,new q],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)it[t]=this._cascades[t];return it.length=this._numCascades,it}start(t,s,e,i,a){V(this.enabled);const{near:r,far:h}=Tt(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(){V(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(at,this._cascades[s].lightMat,t);for(let t=0;t<16;++t)rt[16*s+t]=at[t]}}return rt}moveSnapshot(t){V(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===P.Highlight?"shadow highlight snapshot":"shadow no highlight snapshot";this._snapshots[t]=this._fbos.acquire(e,i,a,E.RGBA4);const r=this._fbos.rctx;this._bindFbo();const h=r.bindTexture(this._snapshots[t]?.getTexture(),z.TEXTURE_UNIT_FOR_UPDATES);r.gl.copyTexSubImage2D(I.TEXTURE_2D,0,0,0,0,0,e,i),r.bindTexture(h,z.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(W.COLOR|W.DEPTH)}_computeTextureHeight(t,s,e){const i=Math.min(window.devicePixelRatio,s)/t.pixelRatio,a=e?this.settings.textureSizeModHighQuality:this.settings.textureSizeModLowQuality,r=L(Math.floor(Math.max(t.fullWidth,t.fullHeight)*i*a)),h=Math.min(this._maxTextureWidth,this._numCascades*r);return Q(h/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.RGBA4)),this._handle?.acquireDepth(U.DEPTH16_BUFFER)}_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(){const t=this._fbos.rctx;t.unbindTexture(this.depthTexture),t.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]);V(c<l);for(let r=0;r<8;++r){v(J,r%4==0||r%4==3?-1:1,r%4==0||r%4==1?-1:1,r<4?c:l,1);const t=K[r];S(t,J,this._projectionViewInverse),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3]}T(et,K[0]),a.camera.viewMatrix=r(X,this._modelViewLight,et);for(let r=0;r<8;++r)y(K[r],K[r],a.camera.viewMatrix);let d=K[0][2],u=K[0][2];for(let r=1;r<8;++r)d=Math.min(d,K[r][2]),u=Math.max(u,K[r][2]);d-=200,u+=200,a.camera.near=-u,a.camera.far=-d,jt(e,i,d,u,a.camera),h(a.lightMat,a.camera.projectionMatrix,a.camera.viewMatrix);const m=this._textureHeight;a.camera.viewport=[t*m,0,m,m]}_setupMatrices(t,s){h(this._projectionView,t.projectionMatrix,t.viewMatrix),o(this._projectionViewInverse,this._projectionView);const e=this._viewingMode===O.Global?t.eye:D(et,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(N(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(),J=R(),K=[];for(let yt=0;yt<8;++yt)K.push(R());const Y=M(),Z=M(),$=M(),tt=M(),st=M(),et=H(),it=[],at=l(),rt=c.concat(c,c,c,c),ht=M(),ot=M(),nt=[M(),M(),M(),M()],ct=M(),lt=M(),dt=M(),ut=M(),mt=M(),_t=M(),ft=M();function gt(t,s,e,i,a,r,h,o){d(ht,0,0);for(let d=0;d<4;++d)u(ht,ht,t[d]);m(ht,ht,.25),d(ot,0,0);for(let d=4;d<8;++d)u(ot,ot,t[d]);m(ot,ot,.25),_(nt[0],t[4],t[5],.5),_(nt[1],t[5],t[6],.5),_(nt[2],t[6],t[7],.5),_(nt[3],t[7],t[4],.5);let n=0,c=f(nt[0],ht);for(let d=1;d<4;++d){const t=f(nt[d],ht);t<c&&(c=t,n=d)}g(ct,nt[n],t[n+4]);const l=ct[0];let M,C;ct[0]=-ct[1],ct[1]=l,g(lt,ot,ht),p(lt,ct)<0&&x(ct,ct),_(ct,ct,lt,e),b(ct,ct),M=C=p(g(dt,t[0],ht),ct);for(let d=1;d<8;++d){const s=p(g(dt,t[d],ht),ct);s<M?M=s:s>C&&(C=s)}w(i,ht),m(dt,ct,M-s),u(i,i,dt);let j=-1,T=1,y=0,D=0;for(let d=0;d<8;++d){g(ut,t[d],i),b(ut,ut);const s=ct[0]*ut[1]-ct[1]*ut[0];s>0?s>j&&(j=s,y=d):s<T&&(T=s,D=d)}A(j>0,"leftArea"),A(T<0,"rightArea"),m(mt,ct,M),u(mt,mt,ht),m(_t,ct,C),u(_t,_t,ht),ft[0]=-ct[1],ft[1]=ct[0];const H=B(i,t[D],_t,u(dt,_t,ft),1,a),v=B(i,t[y],_t,dt,1,r),S=B(i,t[y],mt,u(dt,mt,ft),1,h),R=B(i,t[D],mt,dt,1,o);A(H,"rayRay"),A(v,"rayRay"),A(S,"rayRay"),A(R,"rayRay")}function pt(t,s){return 3*s+t}const xt=M();function bt(t,s){return d(xt,t[s],t[s+3]),xt}const wt=M(),Mt=a();function Ct(t,s,e,i,a){g(wt,e,i),m(wt,wt,.5),Mt[0]=wt[0],Mt[1]=wt[1],Mt[2]=0,Mt[3]=wt[1],Mt[4]=-wt[0],Mt[5]=0,Mt[6]=wt[0]*wt[0]+wt[1]*wt[1],Mt[7]=wt[0]*wt[1]-wt[1]*wt[0],Mt[8]=1,Mt[pt(0,2)]=-p(bt(Mt,0),t),Mt[pt(1,2)]=-p(bt(Mt,1),t);let r=p(bt(Mt,0),e)+Mt[pt(0,2)],h=p(bt(Mt,1),e)+Mt[pt(1,2)],o=p(bt(Mt,0),i)+Mt[pt(0,2)],n=p(bt(Mt,1),i)+Mt[pt(1,2)];r=-(r+o)/(h+n),Mt[pt(0,0)]+=Mt[pt(1,0)]*r,Mt[pt(0,1)]+=Mt[pt(1,1)]*r,Mt[pt(0,2)]+=Mt[pt(1,2)]*r,r=1/(p(bt(Mt,0),e)+Mt[pt(0,2)]),h=1/(p(bt(Mt,1),e)+Mt[pt(1,2)]),Mt[pt(0,0)]*=r,Mt[pt(0,1)]*=r,Mt[pt(0,2)]*=r,Mt[pt(1,0)]*=h,Mt[pt(1,1)]*=h,Mt[pt(1,2)]*=h,Mt[pt(2,0)]=Mt[pt(1,0)],Mt[pt(2,1)]=Mt[pt(1,1)],Mt[pt(2,2)]=Mt[pt(1,2)],Mt[pt(1,2)]+=1,r=p(bt(Mt,1),s)+Mt[pt(1,2)],h=p(bt(Mt,2),s)+Mt[pt(2,2)],o=p(bt(Mt,1),e)+Mt[pt(1,2)],n=p(bt(Mt,2),e)+Mt[pt(2,2)],r=-.5*(r/h+o/n),Mt[pt(1,0)]+=Mt[pt(2,0)]*r,Mt[pt(1,1)]+=Mt[pt(2,1)]*r,Mt[pt(1,2)]+=Mt[pt(2,2)]*r,r=p(bt(Mt,1),s)+Mt[pt(1,2)],h=p(bt(Mt,2),s)+Mt[pt(2,2)],o=-h/r,Mt[pt(1,0)]*=o,Mt[pt(1,1)]*=o,Mt[pt(1,2)]*=o,a[0]=Mt[0],a[1]=Mt[1],a[2]=0,a[3]=Mt[2],a[4]=Mt[3],a[5]=Mt[4],a[6]=0,a[7]=Mt[5],a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=Mt[6],a[13]=Mt[7],a[14]=0,a[15]=Mt[8]}function jt(t,s,i,a,r){const h=1/K[0][3],o=1/K[4][3];V(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,gt(K,n,c,Y,Z,$,tt,st),Ct(Y,Z,tt,st,r.projectionMatrix),r.projectionMatrix[10]=2/(i-a),r.projectionMatrix[14]=-(i+a)/(i-a)}function Tt(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,P 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.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Collection.js";import{deg2rad as s}from"../../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../../core/maybe.js";import{watch as r,initial as o}from"../../../../core/reactiveUtils.js";import{property as n}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{translate as h,fromTranslation as c,scale as l,mul as d}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{z as p,p as m}from"../../../../chunks/vec32.js";import{create as f,fromValues as w}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ShaderOutput as _}from"../core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as g,ConsumesDepth as v,ConsumesNone as x}from"../effects/RenderPlugin.js";import{RenderSlot as b}from"./RenderSlot.js";import{ViewshedShadowMap as M}from"./ViewshedShadowMap.js";import{V as j}from"../../../../chunks/Viewshed.glsl.js";import{ViewshedTechnique as C}from"../shaders/ViewshedTechnique.js";import{ViewshedTechniqueConfiguration as S}from"../shaders/ViewshedTechniqueConfiguration.js";let y=class extends g{get shadowMap(){return this._shadowMap}get enabled(){return this._viewsheds.length>0}get _contentPixelRatio(){return this.view.state.contentPixelRatio}constructor(e,s){super(e),this._pluginContext=null,this.renderHighQuality=!1,this._passParameters=new j,this._configuration=new S,this._viewsheds=new t,this.produces=new Map([[b.VIEWSHED,()=>!0]]),this._renderShadowMap=s}initialize(){this.addHandles([r((()=>this.view.resolutionScale),(e=>{const t=this._shadowMap;null!=t&&(t.settings.textureSizeQuality=e)}),o)])}destroy(){this.uninitializeRenderContext()}consumes(){return this.enabled?v:x}initializeRenderContext(e){this._pluginContext=e,this._shadowMap=new M(this.fboCache),this._shadowMap.enabled=!0}renderNode(e,t,s){const{bindParameters:i,rctx:r}=e;if(!this.enabled||!i.depth||null==s||null==this._pluginContext)return;const o=this._setupNormals(s),n=this._ensureTechnique(o,this._pluginContext.techniques);if(!n.compiled)return void this._pluginContext.requestRender();const a=e.rctx.getBoundFramebufferObject();for(const h of this._viewsheds){const t=this._renderViewshedShadowCubeMap(i,h),s=this._shadowMap;t&&null!=s?.depthTexture&&!s.isTextureZero&&(this._setPassParameters(h,i.camera),e.rctx.bindFramebuffer(a),r.bindTechnique(n,i,this._passParameters),r.screen.draw())}}uninitializeRenderContext(){this._shadowMap=i(this._shadowMap),this._pluginContext?.techniques.release(this._technique),this._technique=this._pluginContext=null}updateViewsheds(e){const s=this._viewsheds,{removes:i,adds:r}=e;if(null!=i&&(t.isCollection(i)?s.removeMany(i):s.remove(i)),null!=r)if(t.isCollection(r)){const e=r.filter((e=>!s.includes(e)));s.addMany(e)}else s.includes(r)||s.add(r)}_ensureTechnique(e,t){return null!=this._technique&&this._configuration.hasNormals===e||(this._configuration.hasNormals=e,this._technique=t.releaseAndAcquire(C,this._configuration,this._technique)),this._technique}_renderViewshedShadowCubeMap(e,t){const s=this._shadowMap;if(!s?.enabled)return!1;const i=s.start(e.camera,t,this.renderHighQuality,this._contentPixelRatio);if(i)for(const r of s.faces)this._renderShadowMap(e,r,_.ViewshedShadow);return s.finish(),i}_setPassParameters(e,t){const i=this._shadowMap;if(null==i)return;const r=this._passParameters,o=e.observerRenderSpace;r.localOrigin=o,r.fovs=[s(e.horizontalFieldOfView),s(e.verticalFieldOfView)],r.headingAndTilt=[s(e.heading),s(e.tiltParallelToSurface)],r.upVector=e.tiltedUpVector;const n=V(e.targetRenderSpace,o);r.targetVector=n,r.shadowMap=i;const a=new Array,c=new Array;for(let s=0;s<i.numActiveFaces;s++)h(R,i.viewshedViewMatrices[s],o),a.push(...R),P(i.viewshedProjectionMatrices[s],R,T),c.push(...T);r.viewMatrices=a,r.projectionMatrices=c,r.volumeOffset=q(e,this.view,t.eye)}_setupNormals(e){const t=e.get("normals"),s=t?.getTexture();return this._passParameters.normals=s,null!=s}get test(){return{viewsheds:this._viewsheds,shadowMap:this.shadowMap}}};function V(e,t){const s=f();return p(s,e,t)}function P(e,t,s){const i=w(.5,.5,.5);return c(s,i),l(s,s,i),d(s,s,e),d(s,s,t),s}function q(e,t,s){if(null==e)return 0;const{observerRenderSpace:i,targetRenderSpace:r}=e,o=m(s,i)>m(s,r)?e.observer:e.target;return t.pixelSizeAt(o)}e([n()],y.prototype,"_pluginContext",void 0),e([n()],y.prototype,"fboCache",void 0),e([n()],y.prototype,"view",void 0),e([n()],y.prototype,"shadowMap",null),e([n()],y.prototype,"_contentPixelRatio",null),y=e([a("esri.views.3d.webgl-engine.lib.Viewshed")],y);const R=u(),T=u();export{y as Viewshed,q as computeOffsetScale};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Collection.js";import{deg2rad as s}from"../../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../../core/maybe.js";import{watch as r,initial as o}from"../../../../core/reactiveUtils.js";import{property as n}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{translate as h,fromTranslation as c,scale as l,mul as d}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{z as p,p as m}from"../../../../chunks/vec32.js";import{create as f,fromValues as w}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ShaderOutput as _}from"../core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as g,ConsumesDepth as v,ConsumesNone as x}from"../effects/RenderPlugin.js";import{RenderSlot as M}from"./RenderSlot.js";import{ViewshedShadowMap as b}from"./ViewshedShadowMap.js";import{V as j}from"../../../../chunks/Viewshed.glsl.js";import{ViewshedTechnique as P}from"../shaders/ViewshedTechnique.js";import{ViewshedTechniqueConfiguration as C}from"../shaders/ViewshedTechniqueConfiguration.js";let S=class extends g{get shadowMap(){return this._shadowMap}get enabled(){return this._viewsheds.length>0}get _contentPixelRatio(){return this.view.state.contentPixelRatio}constructor(e,s){super(e),this._pluginContext=null,this.renderHighQuality=!1,this._passParameters=new j,this._configuration=new C,this._viewsheds=new t,this.produces=new Map([[M.VIEWSHED,()=>!0]]),this._renderShadowMap=s}initialize(){this.addHandles([r((()=>this.view.resolutionScale),(e=>{const t=this._shadowMap;null!=t&&(t.settings.textureSizeQuality=e)}),o)])}destroy(){this.uninitializeRenderContext()}consumes(){return this.enabled?v:x}initializeRenderContext(e){this._pluginContext=e,this._shadowMap=new b(this.fboCache),this._shadowMap.enabled=!0}renderNode(e,t,s){const{bindParameters:i,rctx:r}=e;if(!this.enabled||!i.depth||null==s||null==this._pluginContext)return;const o=this._setupPassParameters(s),n=this._ensureTechnique(o,this._pluginContext.techniques);if(!n.compiled)return void this._pluginContext.requestRender();const a=e.rctx.getBoundFramebufferObject();for(const h of this._viewsheds){const t=this._renderViewshedShadowCubeMap(i,h),s=this._shadowMap;if(!t||null==s?.depthTexture||s.isTextureZero)continue;const o=this._setupViewshedParameters(h,i.camera);r.bindTechnique(n,i,o),e.rctx.bindFramebuffer(a),r.screen.draw()}}uninitializeRenderContext(){this._shadowMap=i(this._shadowMap),this._pluginContext?.techniques.release(this._technique),this._technique=this._pluginContext=null}updateViewsheds(e){const s=this._viewsheds,{removes:i,adds:r}=e;if(null!=i&&(t.isCollection(i)?s.removeMany(i):s.remove(i)),null!=r)if(t.isCollection(r)){const e=r.filter((e=>!s.includes(e)));s.addMany(e)}else s.includes(r)||s.add(r)}_ensureTechnique(e,t){return null!=this._technique&&this._configuration.hasNormals===e||(this._configuration.hasNormals=e,this._technique=t.releaseAndAcquire(P,this._configuration,this._technique)),this._technique}_renderViewshedShadowCubeMap(e,t){const s=this._shadowMap;if(!s?.enabled)return!1;const i=s.start(e.camera,t,this.renderHighQuality,this._contentPixelRatio);if(i)for(const r of s.faces)this._renderShadowMap(e,r,_.ViewshedShadow);return s.finish(),i}_setupPassParameters(e){return this._passParameters.shadowMap=this._shadowMap??this._passParameters.shadowMap,this._passParameters.normals=e.get("normals")?.getTexture(),null!=this._passParameters.normals}_setupViewshedParameters(e,t){const i=this._shadowMap;if(null==i)return this._passParameters;const r=this._passParameters,o=e.observerRenderSpace;r.localOrigin=o,r.fovs=[s(e.horizontalFieldOfView),s(e.verticalFieldOfView)],r.headingAndTilt=[s(e.heading),s(e.tiltParallelToSurface)],r.upVector=e.tiltedUpVector;const n=V(e.targetRenderSpace,o);r.targetVector=n;const a=new Array,c=new Array;for(let s=0;s<i.numActiveFaces;s++)h(R,i.viewshedViewMatrices[s],o),a.push(...R),y(i.viewshedProjectionMatrices[s],R,T),c.push(...T);return r.viewMatrices=a,r.projectionMatrices=c,r.volumeOffset=q(e,this.view,t.eye),r}get test(){return{viewsheds:this._viewsheds,shadowMap:this.shadowMap}}};function V(e,t){const s=f();return p(s,e,t)}function y(e,t,s){const i=w(.5,.5,.5);return c(s,i),l(s,s,i),d(s,s,e),d(s,s,t),s}function q(e,t,s){if(null==e)return 0;const{observerRenderSpace:i,targetRenderSpace:r}=e,o=m(s,i)>m(s,r)?e.observer:e.target;return t.pixelSizeAt(o)}e([n()],S.prototype,"_pluginContext",void 0),e([n()],S.prototype,"fboCache",void 0),e([n()],S.prototype,"view",void 0),e([n()],S.prototype,"shadowMap",null),e([n()],S.prototype,"_contentPixelRatio",null),S=e([a("esri.views.3d.webgl-engine.lib.Viewshed")],S);const R=u(),T=u();export{S as Viewshed,q as computeOffsetScale};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import{clamp as t}from"../../../../core/mathUtils.js";import{releaseMaybe as e}from"../../../../core/maybe.js";import{fromRotation as s}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{z as r,g as a,k as o,h}from"../../../../chunks/vec32.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ColorFormat as c,DepthFormat as u}from"../../webgl/formats.js";import{applyTextureResizeFloorModulo as l,applyTextureResizeModulo as f}from"./textureUtils.js";import{ViewshedFaceCamera as d}from"./ViewshedFaceCamera.js";import{ClearBufferBit as m}from"../../../webgl/enums.js";class x{constructor(){this.textureSizeQuality=1,this.textureSizeModHighQuality=1.3,this.textureSizeModLowQuality=.9,this.textureSizeMultiple=128,this.toleranceSides=5,this.toleranceBottomTop=10}textureSizeModifier(t){const e=t?this.textureSizeModHighQuality:this.textureSizeModLowQuality;return this.textureSizeQuality*e}textureResizeModulo(t){return Math.ceil(t/this.textureSizeMultiple)*this.textureSizeMultiple}}const p=["front","left","right","back","top","bottom"];function _(t){return!["top","bottom"].includes(t)}class g{constructor(t){this._fbos=t,this._enabled=!1,this._faces={},this._textureWidth=0,this._textureHeight=0,this.settings=new x,this._maxTextureSize=Math.min(has("esri-mobile")?4096:16384,t.rctx.parameters.maxTextureSize)}get depthTexture(){return this._handle?.getTexture()}get enabled(){return this._enabled}set enabled(t){this._enabled=t,t||this.disposeOffscreenBuffers()}get isTextureZero(){return 0===this._textureWidth||0===this._textureHeight}get nearFar(){const t=this.faces;return 0===t.length?null:t[0].nearFar}get numActiveFaces(){const t=this._faces;let e=0;return Object.keys(t).forEach((s=>{t[s]&&(e+=1)})),e}get faces(){const t=this._faces,e=[];for(const s of p){const i=t[s];i&&e.push(i)}return e}get atlasRegions(){return this.faces.map((t=>[t.x/this._textureWidth,(t.x+t.width)/this._textureWidth,t.y/this._textureHeight,(t.y+t.height)/this._textureHeight]))}get viewshedProjectionMatrices(){return this.faces.map((t=>t.projectionMatrix))}get viewshedViewMatrices(){return this.faces.map((t=>t.viewMatrix))}_setupFaceCamera(e,c,u,l){const{observerRenderSpace:f,tiltedUpVector:m,targetRenderSpace:x,farDistanceRenderSpace:p,horizontalFieldOfView:g,verticalFieldOfView:b}=c,M=n();r(M,x,f);const F=n(),S=n(),w=(t,e)=>{const r=n(),o=i();return s(o,t,e),h(r,M,o),a(r,f,r),r};let z,B=m;const T=Math.min(90,g),O=Math.min(90,Math.max(0,(g-90)/2));let j=-45,v=45,y=-45,R=45;if(_(e)){const e=e=>t(e,-45,45);y=e(-b/2)-this.settings.toleranceBottomTop,R=e(+b/2)+this.settings.toleranceBottomTop}switch(e){case"front":z=x,j=-T/2,v=T/2;break;case"left":z=w(Math.PI/2,m),j=45-O;break;case"right":z=w(-Math.PI/2,m),v=-45+O;break;case"top":z=a(F,f,m),B=o(S,M);break;case"bottom":z=r(F,f,m),B=M;break;case"back":z=w(Math.PI,m)}const k=new d({center:z,eye:f,up:B,far:p});k.sectionAnglesDeg=[j-this.settings.toleranceSides,v+this.settings.toleranceSides,y,R],k.fovY=Math.PI/2;const H=k.setViewport(u,l);return this._faces[e]=k,H}_bindFBO(){const t=this._fbos.rctx;t.unbindTexture(this.depthTexture),t.bindFramebuffer(this._handle?.fbo)}_computeActiveFaces(t){const e=new Set,{horizontalFieldOfView:s,verticalFieldOfView:i}=t,r=-i/2,a=i/2;return 0===s||0===i||(r<=45&&a>=-45&&e.add("front"),s>90&&(e.add("left"),e.add("right")),s>270&&e.add("back"),a>45-this.settings.toleranceBottomTop&&e.add("top"),r<-45+this.settings.toleranceBottomTop&&e.add("bottom")),e}_computeBaseTextureSize(t,e,s,i){const r=e/t.pixelRatio,a=this.settings.textureSizeModifier(s),o=Math.max(t.fullWidth,t.fullHeight),h=f(Math.floor(o*r*a)),n=Math.floor(this._maxTextureSize/i),c=Math.min(n,h);return l(c)}_ensureFBO(){const t=this._textureWidth,e=this._textureHeight;this._handle?.fbo?.width===t&&this._handle?.fbo?.height===e||(this._handle?.release(),this._handle=this._fbos.acquire(t,e,"viewshed shadow map",c.RGBA4)),this._handle.acquireDepth(u.DEPTH16_BUFFER)}clearFBO(){const t=this._fbos.rctx;this._ensureFBO(),this._bindFBO(),t.setClearColor(1,1,1,1),t.clear(m.COLOR_BUFFER_BIT|m.DEPTH_BUFFER_BIT)}dispose(){this.enabled=!1,this.disposeOffscreenBuffers()}disposeOffscreenBuffers(){this._handle=e(this._handle)}start(t,e,s,i){if(this._faces={},!this.enabled)return!1;const r=this._computeActiveFaces(e),a=r.size;if(0===a)return!1;const o=this._computeBaseTextureSize(t,i,s,a);if(0===o)return!1;let h=0,n=0,c=0;return p.filter((t=>r.has(t))).forEach((t=>{const s=b(t,a);s>n&&(c=Math.max(c,h),h=0),n=s;const i=s*o;h+=this._setupFaceCamera(t,e,[h,i],o)})),c=Math.max(c,h),this._textureWidth=this.settings.textureResizeModulo(c),this._textureHeight=M(a)*o,this.clearFBO(),!0}finish(){this._handle?.detachDepth()}get test(){return{faces:this._faces,faceTypes:p}}}function b(t,e){if(e<4)return 0;const s="front"===t||"left"===t;return 4===e?s?0:1:s||"right"===t?0:1}function M(t){return t<4?1:2}export{g as ViewshedShadowMap};
5
+ import has from"../../../../core/has.js";import{clamp as t}from"../../../../core/mathUtils.js";import{releaseMaybe as e}from"../../../../core/maybe.js";import{fromRotation as s}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{z as r,g as a,k as o,h}from"../../../../chunks/vec32.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ColorFormat as c,DepthFormat as u}from"../../webgl/formats.js";import{applyTextureResizeFloorModulo as l,applyTextureResizeModulo as f}from"./textureUtils.js";import{ViewshedFaceCamera as d}from"./ViewshedFaceCamera.js";import{FramebufferBit as m}from"../../../webgl/enums.js";class x{constructor(){this.textureSizeQuality=1,this.textureSizeModHighQuality=1.3,this.textureSizeModLowQuality=.9,this.textureSizeMultiple=128,this.toleranceSides=5,this.toleranceBottomTop=10}textureSizeModifier(t){const e=t?this.textureSizeModHighQuality:this.textureSizeModLowQuality;return this.textureSizeQuality*e}textureResizeModulo(t){return Math.ceil(t/this.textureSizeMultiple)*this.textureSizeMultiple}}const p=["front","left","right","back","top","bottom"];function _(t){return!["top","bottom"].includes(t)}class g{constructor(t){this._fbos=t,this._enabled=!1,this._faces={},this._textureWidth=0,this._textureHeight=0,this.settings=new x,this._maxTextureSize=Math.min(has("esri-mobile")?4096:16384,t.rctx.parameters.maxTextureSize)}get depthTexture(){return this._handle?.getTexture()}get enabled(){return this._enabled}set enabled(t){this._enabled=t,t||this.disposeOffscreenBuffers()}get isTextureZero(){return 0===this._textureWidth||0===this._textureHeight}get nearFar(){const t=this.faces;return 0===t.length?null:t[0].nearFar}get numActiveFaces(){const t=this._faces;let e=0;return Object.keys(t).forEach((s=>{t[s]&&(e+=1)})),e}get faces(){const t=this._faces,e=[];for(const s of p){const i=t[s];i&&e.push(i)}return e}get atlasRegions(){return this.faces.map((t=>[t.x/this._textureWidth,(t.x+t.width)/this._textureWidth,t.y/this._textureHeight,(t.y+t.height)/this._textureHeight]))}get viewshedProjectionMatrices(){return this.faces.map((t=>t.projectionMatrix))}get viewshedViewMatrices(){return this.faces.map((t=>t.viewMatrix))}_setupFaceCamera(e,c,u,l){const{observerRenderSpace:f,tiltedUpVector:m,targetRenderSpace:x,farDistanceRenderSpace:p,horizontalFieldOfView:g,verticalFieldOfView:b}=c,M=n();r(M,x,f);const S=n(),w=n(),z=(t,e)=>{const r=n(),o=i();return s(o,t,e),h(r,M,o),a(r,f,r),r};let F,B=m;const T=Math.min(90,g),O=Math.min(90,Math.max(0,(g-90)/2));let j=-45,v=45,y=-45,k=45;if(_(e)){const e=e=>t(e,-45,45);y=e(-b/2)-this.settings.toleranceBottomTop,k=e(+b/2)+this.settings.toleranceBottomTop}switch(e){case"front":F=x,j=-T/2,v=T/2;break;case"left":F=z(Math.PI/2,m),j=45-O;break;case"right":F=z(-Math.PI/2,m),v=-45+O;break;case"top":F=a(S,f,m),B=o(w,M);break;case"bottom":F=r(S,f,m),B=M;break;case"back":F=z(Math.PI,m)}const H=new d({center:F,eye:f,up:B,far:p});H.sectionAnglesDeg=[j-this.settings.toleranceSides,v+this.settings.toleranceSides,y,k],H.fovY=Math.PI/2;const R=H.setViewport(u,l);return this._faces[e]=H,R}_bindFBO(){const t=this._fbos.rctx;t.unbindTexture(this.depthTexture),t.bindFramebuffer(this._handle?.fbo)}_computeActiveFaces(t){const e=new Set,{horizontalFieldOfView:s,verticalFieldOfView:i}=t,r=-i/2,a=i/2;return 0===s||0===i||(r<=45&&a>=-45&&e.add("front"),s>90&&(e.add("left"),e.add("right")),s>270&&e.add("back"),a>45-this.settings.toleranceBottomTop&&e.add("top"),r<-45+this.settings.toleranceBottomTop&&e.add("bottom")),e}_computeBaseTextureSize(t,e,s,i){const r=e/t.pixelRatio,a=this.settings.textureSizeModifier(s),o=Math.max(t.fullWidth,t.fullHeight),h=f(Math.floor(o*r*a)),n=Math.floor(this._maxTextureSize/i),c=Math.min(n,h);return l(c)}_ensureFBO(){const t=this._textureWidth,e=this._textureHeight;this._handle?.fbo?.width===t&&this._handle?.fbo?.height===e||(this._handle?.release(),this._handle=this._fbos.acquire(t,e,"viewshed shadow map",c.RGBA4)),this._handle.acquireDepth(u.DEPTH16_BUFFER)}clearFBO(){const t=this._fbos.rctx;this._ensureFBO(),this._bindFBO(),t.setClearColor(1,1,1,1),t.clear(m.COLOR|m.DEPTH)}dispose(){this.enabled=!1,this.disposeOffscreenBuffers()}disposeOffscreenBuffers(){this._handle=e(this._handle)}start(t,e,s,i){if(this._faces={},!this.enabled)return!1;const r=this._computeActiveFaces(e),a=r.size;if(0===a)return!1;const o=this._computeBaseTextureSize(t,i,s,a);if(0===o)return!1;let h=0,n=0,c=0;return p.filter((t=>r.has(t))).forEach((t=>{const s=b(t,a);s>n&&(c=Math.max(c,h),h=0),n=s;const i=s*o;h+=this._setupFaceCamera(t,e,[h,i],o)})),c=Math.max(c,h),this._textureWidth=this.settings.textureResizeModulo(c),this._textureHeight=M(a)*o,this.clearFBO(),!0}finish(){this._handle?.detachDepth()}get test(){return{faces:this._faces,faceTypes:p}}}function b(t,e){if(e<4)return 0;const s="front"===t||"left"===t;return 4===e?s?0:1:s||"right"===t?0:1}function M(t){return t<4?1:2}export{g as ViewshedShadowMap};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{releaseMaybe as e}from"../../../../../core/maybe.js";import r from"../../../../../core/PooledArray.js";import{transpose as t,invert as s}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{s as n}from"../../../../../chunks/vec32.js";import{debugFlags as o}from"../../../support/debugFlags.js";import{TwoVectorPosition as a}from"../../core/util/TwoVectorPosition.js";import{EdgeDrawParameters as d}from"./EdgeShaderParameters.js";import{EdgeShaderTechnique as l}from"./EdgeShaderTechnique.js";import{EdgeShaderTechniqueConfiguration as h}from"./EdgeShaderTechniqueConfiguration.js";import{Transparency as c}from"./interfaces.js";import{EdgeType as u}from"../../shaders/sources/edgeRenderer/EdgeUtil.glsl.js";import{PrimitiveType as _}from"../../../../webgl/enums.js";const m=8,g=128,f={type:u.Solid,hasSlicePlane:!1,strokesTexture:null,legacy:!0,spherical:!0};class b{constructor(e,t,s){this._rctx=e,this._techniques=t,this._configuration=new h,this.refCount=0,this._renderables=new Set,this._sortedRenderables={[c.TRANSPARENT]:{[c.TRANSPARENT]:new r,[c.OPAQUE]:new r},[c.OPAQUE]:{[c.TRANSPARENT]:new r,[c.OPAQUE]:new r}},this._renderablesDirty=!1,this._drawParameters=new d,this._settings={...f,...s},this.key=b.getKey(this._settings.type,this._settings.hasSlicePlane,this._settings.legacy);const i=this._settings.strokesTexture.variants;this.writerSettings={variants:i,reducedPrecision:o.TESTS_DISABLE_OPTIMIZATIONS},this._configuration.legacy=this._settings.legacy,this._configuration.type=this._settings.type,this._configuration.silhouette=!1,this._configuration.hasSlicePlane=this._settings.hasSlicePlane,this._configuration.doublePrecisionRequiresObfuscation=e.driverTest.doublePrecisionRequiresObfuscation.result,this._configuration.spherical=s.spherical}dispose(){this._technique=e(this._technique)}addRenderable(e){this._renderables.add(e),this._renderablesDirty=!0}removeRenderable(e){this._renderables.delete(e),this._renderablesDirty=!0}setRenderablesDirty(){this._renderablesDirty=!0}forEachRenderable(e,r){this._renderablesDirty&&this._sortRenderables();const t=this._sortedRenderables[r];t[c.TRANSPARENT].forAll(e),t[c.OPAQUE].forAll(e)}updateTechnique(e,r){return this._configuration.multipassEnabled=!!e.multipassEnabled,this._configuration.cullAboveGround=!!e.multipassTerrain.cullAboveGround,this._configuration.silhouette=r,this._technique=this._techniques.releaseAndAcquire(l,this._configuration,this._technique),this._technique}bindRegularEdges(e,r){return this._lastOriginId=null,this._rctx.bindTechnique(this.updateTechnique(r,!1),r,e)}bindSilhouetteEdges(e,r){return this._lastOriginId=null,this._rctx.bindTechnique(this.updateTechnique(r,!0),r,e)}renderRegularEdges(e,r,t,s,i){this._render(e,r,r.regular.vao,t,s,i)}renderSilhouetteEdges(e,r,t,s,i){this._render(e,r,r.silhouette.vao,t,s,i)}_render(e,r,t,s,i,n){n>0&&(this._bindDraw(e,r,s,i),this._rctx.bindVAO(t),this._rctx.drawArraysInstanced(_.TRIANGLE_FAN,0,4,n))}_bindDraw(e,r,i,o){this._drawParameters.componentDataTexture=r.components.buffer.textureBuffer.texture,this._drawParameters.strokesTexture=this._settings.strokesTexture;const d=r.transform.origin;if(d){const t=d.origin.id;this._lastOriginId!==t&&(e.setUniformMatrix4fv("localView",d.viewMatrix),this._lastOriginId=t),e.setUniformMatrix4fv("model",r.transform.modelMatrix),this._drawParameters.slicePlaneLocalOrigin=d.origin.vec3}else{const e=new a(r.transform.position),i=t(A,s(A,r.transform.rotationScale));this._drawParameters.transformWorldFromModelTL=e.low,this._drawParameters.transformWorldFromModelTH=e.high,this._drawParameters.transformWorldFromModelRS=r.transform.rotationScale,this._drawParameters.transformNormalGlobalFromModel=i;const d=o.camera.viewInverseTransposeMatrix;n(this._drawParameters.slicePlaneLocalOrigin,d[3],d[7],d[11])}e.bindDraw(this._drawParameters,o,i)}_sortRenderables(){this._renderablesDirty=!1,this._sortedRenderables[c.TRANSPARENT][c.TRANSPARENT].clear(),this._sortedRenderables[c.TRANSPARENT][c.OPAQUE].clear(),this._sortedRenderables[c.OPAQUE][c.TRANSPARENT].clear(),this._sortedRenderables[c.OPAQUE][c.OPAQUE].clear(),this._renderables.forEach((e=>this._sortedRenderables[e.objectTransparency][e.edgeTransparency].push(e)));const e=(e,r)=>e.transform.origin?r.transform.origin?e.transform.origin.origin.id<r.transform.origin.origin.id?-1:e.transform.origin.origin.id>r.transform.origin.origin.id?1:0:1:0;this._sortedRenderables[c.TRANSPARENT][c.TRANSPARENT].sort(e),this._sortedRenderables[c.TRANSPARENT][c.OPAQUE].sort(e),this._sortedRenderables[c.OPAQUE][c.TRANSPARENT].sort(e),this._sortedRenderables[c.OPAQUE][c.OPAQUE].sort(e)}static getKey(e,r,t){return`edges-t:${e}:${r}:${t}`}}const A=i();export{b as EdgeRenderer,g as extensionLengthOffset,m as lineWidthFractionFactor};
5
+ import{releaseMaybe as e}from"../../../../../core/maybe.js";import r from"../../../../../core/PooledArray.js";import{transpose as t,invert as s}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{s as n}from"../../../../../chunks/vec32.js";import{debugFlags as o}from"../../../support/debugFlags.js";import{TwoVectorPosition as a}from"../../core/util/TwoVectorPosition.js";import{EdgeDrawParameters as d}from"./EdgeShaderParameters.js";import{EdgeShaderTechnique as l}from"./EdgeShaderTechnique.js";import{EdgeShaderTechniqueConfiguration as h}from"./EdgeShaderTechniqueConfiguration.js";import{Transparency as c}from"./interfaces.js";import{EdgeType as u}from"../../shaders/sources/edgeRenderer/EdgeUtil.glsl.js";import{PrimitiveType as _}from"../../../../webgl/enums.js";const m=8,g=128,f={type:u.Solid,hasSlicePlane:!1,strokesTexture:null,legacy:!0,spherical:!0};class b{constructor(e,t,s){this._rctx=e,this._techniques=t,this._configuration=new h,this.refCount=0,this._renderables=new Set,this._sortedRenderables={[c.TRANSPARENT]:{[c.TRANSPARENT]:new r,[c.OPAQUE]:new r},[c.OPAQUE]:{[c.TRANSPARENT]:new r,[c.OPAQUE]:new r}},this._renderablesDirty=!1,this._drawParameters=new d,this._settings={...f,...s},this.key=b.getKey(this._settings.type,this._settings.hasSlicePlane,this._settings.legacy);const i=this._settings.strokesTexture.variants;this.writerSettings={variants:i,reducedPrecision:o.TESTS_DISABLE_OPTIMIZATIONS},this._configuration.legacy=this._settings.legacy,this._configuration.type=this._settings.type,this._configuration.silhouette=!1,this._configuration.hasSlicePlane=this._settings.hasSlicePlane,this._configuration.doublePrecisionRequiresObfuscation=e.driverTest.doublePrecisionRequiresObfuscation.result,this._configuration.spherical=s.spherical}dispose(){this._technique=e(this._technique)}addRenderable(e){this._renderables.add(e),this._renderablesDirty=!0}removeRenderable(e){this._renderables.delete(e),this._renderablesDirty=!0}setRenderablesDirty(){this._renderablesDirty=!0}forEachRenderable(e,r){this._renderablesDirty&&this._sortRenderables();const t=this._sortedRenderables[r];t[c.TRANSPARENT].forAll(e),t[c.OPAQUE].forAll(e)}updateTechnique(e,r){return this._configuration.multipassEnabled=!!e.multipassEnabled,this._configuration.cullAboveGround=!!e.multipassTerrain.cullAboveGround,this._configuration.silhouette=r,this._technique=this._techniques.releaseAndAcquire(l,this._configuration,this._technique),this._technique}bindRegularEdges(e,r){return this._lastOriginId=null,this._rctx.bindTechnique(this.updateTechnique(r,!1),r,e)}bindSilhouetteEdges(e,r){return this._lastOriginId=null,this._rctx.bindTechnique(this.updateTechnique(r,!0),r,e)}renderRegularEdges(e,r,t,s,i){this._render(e,r,r.regular.vao,t,s,i)}renderSilhouetteEdges(e,r,t,s,i){this._render(e,r,r.silhouette.vao,t,s,i)}_render(e,r,t,s,i,n){n>0&&(this._bindDraw(e,r,s,i),this._rctx.bindVAO(t),this._rctx.drawArraysInstanced(_.TRIANGLE_FAN,0,4,n))}_bindDraw(e,r,i,o){this._drawParameters.componentDataTexture=r.components.buffer.textureBuffer.texture,this._drawParameters.strokesTexture=this._settings.strokesTexture;const d=r.transform.origin;if(d){const t=d.origin.id;this._lastOriginId!==t&&(e.setUniformMatrix4fv("localView",d.viewMatrix),this._lastOriginId=t),e.setUniformMatrix4fv("model",r.transform.modelMatrix),this._drawParameters.slicePlaneLocalOrigin=d.origin.vec3}else{const e=new a(r.transform.position),i=t(A,s(A,r.transform.rotationScale));this._drawParameters.transformWorldFromModelTL=e.low,this._drawParameters.transformWorldFromModelTH=e.high,this._drawParameters.transformWorldFromModelRS=r.transform.rotationScale,this._drawParameters.transformNormalGlobalFromModel=i;const d=o.camera.viewInverseTransposeMatrix;n(this._drawParameters.slicePlaneLocalOrigin,d[3],d[7],d[11])}e.bindDraw(o,i,this._drawParameters)}_sortRenderables(){this._renderablesDirty=!1,this._sortedRenderables[c.TRANSPARENT][c.TRANSPARENT].clear(),this._sortedRenderables[c.TRANSPARENT][c.OPAQUE].clear(),this._sortedRenderables[c.OPAQUE][c.TRANSPARENT].clear(),this._sortedRenderables[c.OPAQUE][c.OPAQUE].clear(),this._renderables.forEach((e=>this._sortedRenderables[e.objectTransparency][e.edgeTransparency].push(e)));const e=(e,r)=>e.transform.origin?r.transform.origin?e.transform.origin.origin.id<r.transform.origin.origin.id?-1:e.transform.origin.origin.id>r.transform.origin.origin.id?1:0:1:0;this._sortedRenderables[c.TRANSPARENT][c.TRANSPARENT].sort(e),this._sortedRenderables[c.TRANSPARENT][c.OPAQUE].sort(e),this._sortedRenderables[c.OPAQUE][c.TRANSPARENT].sort(e),this._sortedRenderables[c.OPAQUE][c.OPAQUE].sort(e)}static getKey(e,r,t){return`edges-t:${e}:${r}:${t}`}}const A=i();export{b as EdgeRenderer,g as extensionLengthOffset,m as lineWidthFractionFactor};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{equals as r,binaryIndexOf as s}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import n from"../../../../../core/Logger.js";import{clamp as o}from"../../../../../core/mathUtils.js";import{disposeMaybe as i,destroyMaybe as a}from"../../../../../core/maybe.js";import{isAbortError as c,onAbortOrThrow as l}from"../../../../../core/promiseUtils.js";import{property as d}from"../../../../../core/accessorSupport/decorators/property.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as u,transpose as m,invert as g}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as f}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as p}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as _,c as b,z as y,m as j}from"../../../../../chunks/vec32.js";import{create as O,clone as w}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as E}from"../../../../../core/support/UpdatingHandles.js";import{g as v,h as x}from"../../../../../chunks/sphere.js";import{c as R}from"../../../../../chunks/vec33.js";import{ViewingMode as M}from"../../../../ViewingMode.js";import{encodeElevationOffset as T}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as A}from"../../core/util/TwoVectorPosition.js";import{Attribute as C}from"../Attribute.js";import{GridLocalOriginFactory as D}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as P}from"../localOriginHelper.js";import{LocalOriginManager as U}from"../LocalOriginManager.js";import{Object3D as L}from"../Object3D.js";import{VertexArrayObject as k}from"../VertexArrayObject.js";import{VertexAttribute as I}from"../VertexAttribute.js";import{VertexLayout as S,EdgeInputBufferLayout as B,EdgeShaderAttributeLocations as V,glVertexLayout as H}from"./bufferLayouts.js";import{RegularEdgeBufferWriter as G,SilhouetteEdgeBufferWriter as N}from"./edgeBufferWriters.js";import{EdgeRenderer as W,lineWidthFractionFactor as q,extensionLengthOffset as z}from"./EdgeRenderer.js";import{EdgePassParameters as F}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as K}from"./EdgeWorkerHandle.js";import"./interfaces.js";import{generateStrokesTexture as J}from"./strokes.js";import{determineRendererType as Q,determineEdgeTransparency as X,determineObjectTransparency as Y,fillComponentBufferIndices as Z}from"./util.js";import{BufferManager as $}from"../TextureBackedBuffer/BufferManager.js";import{EdgeSilhouette as ee}from"../../shaders/sources/edgeRenderer/EdgeUtil.glsl.js";import{BufferObject as te}from"../../../../webgl/BufferObject.js";import{Usage as re}from"../../../../webgl/enums.js";const se=128;let ne=class extends t{constructor(e){super(e),this._updatingHandles=new E,this._objectEntries=new Map,this._pendingDeletions=new Map,this._renderers=new Map,this._gpuMemoryUsage=0,this._workerAbort=new AbortController,this._tmpModelPosition=O(),this._localOrigins=new U(new D(e.renderSR));const t=S.createBuffer(4);for(let r=0;r<4;r++)t.sideness.set(r,0,0===r||3===r?0:1),t.sideness.set(r,1,0===r||1===r?0:1);this._verticesBufferObject=te.createVertex(e.rctx,re.STATIC_DRAW,t.buffer)}initialize(){this._worker=new K(this.schedule),this._componentColorManager=new $(this.rctx,3)}destroy(){this.destroyed||(this._objectEntries.forEach((e=>this._discardObjectEntry(e))),this._objectEntries.clear(),this._pendingDeletions.forEach((e=>this._discardObjectEntry(e))),this._pendingDeletions.clear(),this._strokesTexture=i(this._strokesTexture),this._componentColorManager=a(this._componentColorManager),this._workerAbort.abort(),this._worker.destroy(),this._verticesBufferObject.dispose(),this._renderers.clear(),this._updatingHandles.destroy(),this._set("schedule",we))}get updating(){return this._updatingHandles.updating}get usedMemory(){return this._gpuMemoryUsage}shouldRender(){return this._renderers.size>0}async addComponentObject(e,t,r,s,n,o,i){if(this.hasObject(e))return this._getObjectMemoryUsage(e);let a;const c=new ae(null,new Promise((e=>a=e)),e.obb.center,e.obb.radius);this._objectEntries.set(e,c);const l=await this._updatingHandles.addPromise(this._addComponentGeometry(e.transform,c,t,r,s,n,o,i));return this.setNeedsRender(),a(),l}async addOrUpdateObject3D(e,t,r,s){if(this.destroyed)return void n.getLogger(this).warn("Attempt to add an object to a destroyed instance");const o=new AbortController;let i;const a=e.boundingVolumeWorldSpace.bounds,l=new ae(o,new Promise((e=>i=e)),v(a),x(a)),d=this._objectEntries.get(e);d&&(this._pendingDeletions.has(e)?this._discardObjectEntry(d):this._pendingDeletions.set(e,d)),this._objectEntries.set(e,l);try{const n=new Array;if(e.geometries.length>1&&ie(e))n.push(this._addObjectMergedGeometries(e,l,t,r,s));else for(const o of e.geometries)o.material.supportsEdges&&n.push(this._addGeometry(e,l,o,t,r,s));await this._updatingHandles.addPromise(Promise.all(n)),this._removePendingDeletion(e)}catch(h){c(h)?this._discardObjectEntry(l):this._removePendingDeletion(e)}finally{this.setNeedsRender(),i()}}removeObject(e){const t=this._objectEntries.get(e);this._objectEntries.delete(e),this._discardObjectEntry(t),this._removePendingDeletion(e)}_removePendingDeletion(e){const t=this._pendingDeletions.get(e);this._pendingDeletions.delete(e),this._discardObjectEntry(t)}async _getObjectEntry(e){const t=this._objectEntries.get(e);if(!t)throw new Error("no object");return await t.loaded,null==t.loaded?null:t}fastUpdateObject3DEdgesTransform(e){if(this.destroyed)return!1;const t=this._objectEntries.get(e);if(!t)return!1;const{geometries:r}=e,{renderables:s}=t;if(0===r.length||0===s.length)return!0;if(s.length>1)return!1;const[n]=s,o=n.transform;if(!(o instanceof de))return!1;const[i]=r;if(i.localOrigin!==o.origin.origin)return!1;const a=p(),c=this._computeModelTransformWithLocalOrigin(e,i,a);return n.transform=new de(a,c),this.setNeedsRender(),!0}_discardObjectEntry(e){e&&(e.abort?.abort(),e.renderables.length&&(e.renderables.forEach((e=>this._removeRenderable(e))),this.setNeedsRender()),e.loaded=null)}hasObject(e){return this._objectEntries.has(e)}async updateAllComponentOpacities(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));if(null==r)return;const s=Array.isArray(t)?e=>t[e]:()=>t;r.renderables.forEach((e=>{const t=e.components.meta.length;for(let r=0;r<t;r++){const t=s(r),n=e.components.meta[r],o=n.index;n.material.opacity=t,e.components.buffer.textureBuffer.setDataElement(o,1,3,255*t)}this._updateTransparency(e)})),this.setNeedsRender()}async _getObjectMemoryUsage(e){const t=await this._getObjectEntry(e);return t?t.renderables.reduce(((e,t)=>e+t.statistics.gpuMemoryUsage),0):0}async updateAllComponentMaterials(e,t,r,s){const n=e instanceof L,o=Q(t),i=W.getKey(o,r,n),a=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=a&&(a.renderables.forEach((e=>{if(i!==e.rendererKey){const t=this._renderers.get(e.rendererKey),s=this._acquireRenderer(o,r,n);t.removeRenderable(e),--t.refCount,e.rendererKey=i,s.addRenderable(e)}if(Array.isArray(t))for(let r=0;r<t.length;r++)e.components.meta[r].material=t[r];else e.components.meta[0].material=t;s&&me(e.components),this._updateTransparency(e)})),this.setNeedsRender())}async updateAllVerticalOffsets(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&this._updateAllVerticalOffsets(r,t)}_updateAllVerticalOffsets(e,t){e.renderables.forEach((e=>{const r=e.components.meta;for(let s=0;s<r.length;s++)e.components.meta[s].verticalOffset=t?.[s]??0;me(e.components)})),this.setNeedsRender()}async updateObjectVisibility(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));r&&(r.renderables.forEach((e=>e.visible=t)),this.setNeedsRender())}render(e,t){if(null==this._componentColorManager)return;this._localOrigins.updateViewMatrices(e.camera.viewMatrix);const r=e.camera.viewInverseTransposeMatrix,s=O(),n=new A;let o=0,i=0;if(this._renderers.forEach((r=>{if(0===r.refCount)return this._renderers.delete(r.key),void r.dispose();let s=!0,n=!0;r.forEachRenderable((t=>{t.visible&&(o+=t.statistics.averageEdgeLength,i++,s&&t.regular&&(r.updateTechnique(e,!1),s=!1),n&&t.silhouette&&(r.updateTechnique(e,!0),n=!1))}),t)})),this._componentColorManager.garbageCollect(),this._componentColorManager.updateTextures(),0===i)return;const a=new F(40*o/i,t);_(s,r[3],r[7],r[11]),n.set(s),b(a.transformWorldFromViewTH,n.high),b(a.transformWorldFromViewTL,n.low),u(a.transformViewFromCameraRelativeRS,e.camera.viewMatrix),m(Oe,a.transformViewFromCameraRelativeRS),g(a.transformNormalViewFromGlobal,Oe),a.transformProjFromView=e.camera.projectionMatrix,this._updateObjectCameraDistances(e),this._renderers.forEach((t=>{ge(t,e,a),fe(t,e,a)}))}_updateTransparency(e){const t=X(e.components.meta),r=Y(e.components.meta);t===e.edgeTransparency&&r===e.objectTransparency||(e.edgeTransparency=t,e.objectTransparency=r,this._renderers.get(e.rendererKey).setRenderablesDirty())}_computeModelTransformWithLocalOrigin(e,t,r){e.getCombinedShaderTransformation(t,r);const s=null!=t.localOrigin?this._localOrigins.register(t.localOrigin):this._localOrigins.acquire(_(this._tmpModelPosition,r[12],r[13],r[14]));return t.localOrigin=s.origin,P(s.origin.vec3,r),s}_createComponentBuffers(e){if(null==this._componentColorManager)return null;const t=new Array,r=this._componentColorManager.getBuffer(e.length);for(let n=0;n<e.length;n++){const s=e[n],o=r.acquireIndex();t.push({index:o,verticalOffset:0,material:s})}const s=new ce(r,t);return me(s),s}_extractEdges(e,t,r,s,n,o,i=o.length){return i<se&&(n=!0),this._worker.process({data:r,indices:o,indicesLength:i,writerSettings:t,skipDeduplicate:s},e,n)}_createRenderable(e,t,r,s,n){const o=t=>new le(new k(this.rctx,V,{vertices:H,instances:t===ee.REGULAR?G.glLayout:N.glLayout},{vertices:this._verticesBufferObject,instances:te.createVertex(this.rctx,re.STATIC_DRAW,t===ee.REGULAR?e.regular.instancesData.buffer:e.silhouette.instancesData.buffer)}),t===ee.REGULAR?e.regular.lodInfo:e.silhouette.lodInfo),i=e.regular.lodInfo.lengths.length>0?o(ee.REGULAR):null,a=e.silhouette.lodInfo.lengths.length>0?o(ee.SILHOUETTE):null,c=(i?.vao.usedMemory??0)+(a?.vao.usedMemory??0);return new he(i,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,X(t.meta),Y(t.meta),t,s)}async _addGeometry(e,t,r,s,n,o){if(r.edgeIndicesLength<=0)return;const i=r.attributes.get(I.POSITION),a=p(),c=this._computeModelTransformWithLocalOrigin(e,r,a),l=new je(i,a,c);return this._addPositionData(t,l,r.edgeIndicesLength,s,n,o)}async _addPositionData(e,t,r,s,n,o=!1){if(null==e.loaded)return;const i=this._createComponentBuffers([s]);if(null==i)return;const a=this._acquireRenderer(s.type,n,!0),{modelTransform:c,origin:l}=t,d=t.position.indices,h=t.position,u=h.data.length/h.size,m=B.createBuffer(u);for(let p=0;p<u;p++)m.position.set(p,0,h.data[p*h.size]),m.position.set(p,1,h.data[p*h.size+1]),m.position.set(p,2,h.data[p*h.size+2]);Z(i.meta,[0,m.componentIndex.count],m.componentIndex);const g=await this._updatingHandles.addPromise(this._extractEdges(e.abort?.signal||this._workerAbort.signal,a.writerSettings,m,!1,o,d,r));if(null==e.loaded)return;const f=this._createRenderable(g,i,new de(c,l),a.key,!1);e.renderables.push(f),a.addRenderable(f),this._gpuMemoryUsage+=f.statistics.gpuMemoryUsage}async _addComponentGeometry(e,t,r,s,n,o,i,a){if(null==t.loaded)return 0;const c=this._createComponentBuffers(o);if(null==c)return 0;const l=Q(o),d=this._acquireRenderer(l,i||!1,!1),h=B.createBuffer(r.length/3);R(h.position.typedBuffer,r,h.position.typedBufferStride,3),Z(c.meta,n,h.componentIndex,s);const u=!0,m=d.writerSettings,g=await this._updatingHandles.addPromise(this._extractEdges(this._workerAbort.signal,m,h,u,!1,s));if(null==t.loaded)return 0;const f=this._createRenderable(g,c,e,d.key,!0);return t.renderables.push(f),d.addRenderable(f),this._updateAllVerticalOffsets(t,a),f.statistics.gpuMemoryUsage}async _addObjectMergedGeometries(e,t,r,s,n){const o=new Map;let i=0,a=0,c=null;const l=e.geometries.filter((e=>{if(e.edgeIndicesLength<=0||!e.material.supportsEdges)return!1;!c&&e.localOrigin&&(c=e);const t=e.attributes.get(I.POSITION);return a+=t.data.length/t.size,i+=e.edgeIndicesLength,!0}));if(0===l.length)return;const d=a>=65536?Uint32Array:Uint16Array,h=i?new d(i):null,u=[];let m=0;l.forEach((e=>{const t=e.attributes.get(I.POSITION),r=t.indices;let s=o.get(t.data);if(null==s){s=u.length/3;for(let e=0;e<t.data.length;e+=t.size)u.push(t.data[e]),u.push(t.data[e+1]),u.push(t.data[e+2]);o.set(t.data,s)}for(let n=0;n<e.edgeIndicesLength;n++)h[m++]=s+r[n]}));const g=c||e.geometries[0],f=p(),_=this._computeModelTransformWithLocalOrigin(e,g,f);for(let p=0;p<e.geometries.length;p++)e.geometries[p].localOrigin=_.origin;const b=new je(new C(u,h,3),f,_);await this._updatingHandles.addPromise(this._addPositionData(t,b,h.length,r,s,n))}_acquireRenderer(e,t,r){const s=W.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=J(this.rctx)),n||(n=new W(this.rctx,this.techniques,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:this.viewingMode===M.Global}),this._renderers.set(s,n)),++n.refCount,n}_removeRenderable(e){oe(e.regular),oe(e.silhouette);const t=this._renderers.get(e.rendererKey);if(t){t.removeRenderable(e),--t.refCount,this._localOrigins.release(e.transform.origin),this._gpuMemoryUsage-=e.statistics.externalMemoryUsage?0:e.statistics.gpuMemoryUsage;for(const t of e.components.meta)e.components.buffer.releaseIndex(t.index)}}_updateObjectCameraDistances(e){const t=e.camera.eye,r=e.camera.viewForward,s=O(),n=e=>{y(s,e.center,t);const n=j(s,r),o=e.radius,i=n<-o?1/0:n<o?0:n-o;e.renderables.forEach((e=>e.distanceToCamera=i))};this._objectEntries.forEach(n),this._pendingDeletions.forEach(n)}get test(){}};function oe(e){e?.vao&&(e.vao.vertexBuffers.instances.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function ie(e){let t=null,s=null;for(const n of e.geometries){if(n.material.supportsEdges){if(t){if(!r(t,n.transformation))return!1}else t=n.transformation;if(s||null==n.localOrigin){if(null!=s?.localOrigin&&null!=n.localOrigin&&s.localOrigin.id!==n.localOrigin.id)return!1}else s=n}}return!0}e([d({constructOnly:!0})],ne.prototype,"rctx",void 0),e([d({constructOnly:!0})],ne.prototype,"renderSR",void 0),e([d({constructOnly:!0})],ne.prototype,"viewingMode",void 0),e([d({constructOnly:!0})],ne.prototype,"techniques",void 0),e([d({constructOnly:!0})],ne.prototype,"setNeedsRender",void 0),e([d({constructOnly:!0})],ne.prototype,"schedule",void 0),e([d({readOnly:!0})],ne.prototype,"_updatingHandles",void 0),e([d({readOnly:!0})],ne.prototype,"updating",null),ne=e([h("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],ne);class ae{constructor(e,t,r,s){this.abort=e,this.radius=s,this.renderables=new Array;const n=e?l(e.signal,(()=>e.abort())):null;this.loaded=t,this.loaded.then((()=>{null!=this.loaded&&(this.loaded=!0),this.abort=null,n?.remove()})),this.center=w(r)}}class ce{constructor(e,t){this.buffer=e,this.meta=t}}class le{constructor(e,t){this.vao=e,this.lod=t}}class de{constructor(e,t){this.modelMatrix=e,this.origin=t}}class he{constructor(e,t,r,s,n,o,i,a){this.regular=e,this.silhouette=t,this.statistics=r,this.transform=s,this.edgeTransparency=n,this.objectTransparency=o,this.components=i,this.rendererKey=a,this.distanceToCamera=0,this.visible=!0}}class ue extends he{}function me(e){const{meta:t,buffer:r}=e,s=new Uint8Array(4);for(let n=0;n<t.length;n++){const e=t[n].material,i=t[n].index,a=o(Math.round(e.size*q),0,255),c=o(e.extensionLength,-z,255-z)+z,l=255*e.opacity,d=e.color,h=255*d[0],u=255*d[1],m=255*d[2],g=255*d[3];r.textureBuffer.setData(i,0,h,u,m,g),r.textureBuffer.setData(i,1,a,c,e.type,l),T(t[n].verticalOffset,s),r.textureBuffer.setData(i,2,s[0],s[1],s[2],s[3])}}function ge(e,t,r){const s=e.bindRegularEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!pe(n)||!n.visible)return;const i=ye(n.regular.lod.lengths,n.distanceToCamera,o);e.renderRegularEdges(s,n,r,t,i)}),n)}function fe(e,t,r){const s=e.bindSilhouetteEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!be(n)||!n.visible)return;const i=ye(n.silhouette.lod.lengths,n.distanceToCamera,o);e.renderSilhouetteEdges(s,n,r,t,i)}),n)}function pe(e){return null!=e.regular}class _e extends he{}function be(e){return null!=e.silhouette}function ye(e,t,r){const n=t*r,o=s(e,n,!0);return-1===o?n<e[0]?e.length:0:e.length-o}class je{constructor(e,t,r){this.position=e,this.modelTransform=t,this.origin=r}}const Oe=f(),we=()=>Promise.reject();export{ne as EdgeView,de as LegacyTransform,ue as RegularRenderable,he as Renderable,_e as SilhouetteRenderable};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{equals as r,binaryIndexOf as s}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import n from"../../../../../core/Logger.js";import{clamp as o}from"../../../../../core/mathUtils.js";import{disposeMaybe as i,destroyMaybe as a}from"../../../../../core/maybe.js";import{isAbortError as c,onAbortOrThrow as l}from"../../../../../core/promiseUtils.js";import{property as d}from"../../../../../core/accessorSupport/decorators/property.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as u,transpose as m,invert as g}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as f}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as p}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as _,c as b,z as y,m as j}from"../../../../../chunks/vec32.js";import{create as O,clone as w}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as E}from"../../../../../core/support/UpdatingHandles.js";import{g as v,h as x}from"../../../../../chunks/sphere.js";import{c as M}from"../../../../../chunks/vec33.js";import{ViewingMode as R}from"../../../../ViewingMode.js";import{encodeElevationOffset as T}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as A}from"../../core/util/TwoVectorPosition.js";import{Attribute as C}from"../Attribute.js";import{GridLocalOriginFactory as D}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as P}from"../localOriginHelper.js";import{LocalOriginManager as U}from"../LocalOriginManager.js";import{Object3D as L}from"../Object3D.js";import{VertexArrayObject as k}from"../VertexArrayObject.js";import{VertexAttribute as I}from"../VertexAttribute.js";import{VertexLayout as S,EdgeInputBufferLayout as B,EdgeShaderAttributeLocations as V,glVertexLayout as H}from"./bufferLayouts.js";import{RegularEdgeBufferWriter as G,SilhouetteEdgeBufferWriter as N}from"./edgeBufferWriters.js";import{EdgeRenderer as W,lineWidthFractionFactor as q,extensionLengthOffset as z}from"./EdgeRenderer.js";import{EdgePassParameters as F}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as K}from"./EdgeWorkerHandle.js";import"./interfaces.js";import{generateStrokesTexture as J}from"./strokes.js";import{determineRendererType as Q,determineEdgeTransparency as X,determineObjectTransparency as Y,fillComponentBufferIndices as Z}from"./util.js";import{BufferManager as $}from"../TextureBackedBuffer/BufferManager.js";import{EdgeSilhouette as ee}from"../../shaders/sources/edgeRenderer/EdgeUtil.glsl.js";import{BufferObject as te}from"../../../../webgl/BufferObject.js";import{Usage as re}from"../../../../webgl/enums.js";const se=128;let ne=class extends t{constructor(e){super(e),this._updatingHandles=new E,this._objectEntries=new Map,this._pendingDeletions=new Map,this._renderers=new Map,this._gpuMemoryUsage=0,this._workerAbort=new AbortController,this._tmpModelPosition=O(),this._localOrigins=new U(new D(e.renderSR));const t=S.createBuffer(4);for(let r=0;r<4;r++)t.sideness.set(r,0,0===r||3===r?0:1),t.sideness.set(r,1,0===r||1===r?0:1);this._verticesBufferObject=te.createVertex(e.rctx,re.STATIC_DRAW,t.buffer)}initialize(){this._worker=new K(this.schedule),this._componentColorManager=new $(this.rctx,3)}destroy(){this.destroyed||(this._objectEntries.forEach((e=>this._discardObjectEntry(e))),this._objectEntries.clear(),this._pendingDeletions.forEach((e=>this._discardObjectEntry(e))),this._pendingDeletions.clear(),this._strokesTexture=i(this._strokesTexture),this._componentColorManager=a(this._componentColorManager),this._workerAbort.abort(),this._worker.destroy(),this._verticesBufferObject.dispose(),this._renderers.clear(),this._updatingHandles.destroy(),this._set("schedule",we))}get updating(){return this._updatingHandles.updating}get usedMemory(){return this._gpuMemoryUsage}shouldRender(){return this._renderers.size>0}async addComponentObject(e,t,r,s,n,o,i){if(this.hasObject(e))return this._getObjectMemoryUsage(e);let a;const c=new ae(null,new Promise((e=>a=e)),e.obb.center,e.obb.radius);this._objectEntries.set(e,c);const l=await this._updatingHandles.addPromise(this._addComponentGeometry(e.transform,c,t,r,s,n,o,i));return this.setNeedsRender(),a(),l}async addOrUpdateObject3D(e,t,r,s){if(this.destroyed)return void n.getLogger(this).warn("Attempt to add an object to a destroyed instance");const o=new AbortController;let i;const a=e.boundingVolumeWorldSpace.bounds,l=new ae(o,new Promise((e=>i=e)),v(a),x(a)),d=this._objectEntries.get(e);d&&(this._pendingDeletions.has(e)?this._discardObjectEntry(d):this._pendingDeletions.set(e,d)),this._objectEntries.set(e,l);try{const n=new Array;if(e.geometries.length>1&&ie(e))n.push(this._addObjectMergedGeometries(e,l,t,r,s));else for(const o of e.geometries)o.material.supportsEdges&&n.push(this._addGeometry(e,l,o,t,r,s));await this._updatingHandles.addPromise(Promise.all(n)),this._removePendingDeletion(e)}catch(h){c(h)?this._discardObjectEntry(l):this._removePendingDeletion(e)}finally{this.setNeedsRender(),i()}}removeObject(e){const t=this._objectEntries.get(e);this._objectEntries.delete(e),this._discardObjectEntry(t),this._removePendingDeletion(e)}_removePendingDeletion(e){const t=this._pendingDeletions.get(e);this._pendingDeletions.delete(e),this._discardObjectEntry(t)}async _getObjectEntry(e){const t=this._objectEntries.get(e);if(!t)throw new Error("no object");return await t.loaded,null==t.loaded?null:t}fastUpdateObject3DEdgesTransform(e){if(this.destroyed)return!1;const t=this._objectEntries.get(e);if(!t)return!1;const{geometries:r}=e,{renderables:s}=t;if(0===r.length||0===s.length)return!0;if(s.length>1)return!1;const[n]=s,o=n.transform;if(!(o instanceof de))return!1;const[i]=r;if(i.localOrigin!==o.origin.origin)return!1;const a=p(),c=this._computeModelTransformWithLocalOrigin(e,i,a);return n.transform=new de(a,c),this.setNeedsRender(),!0}_discardObjectEntry(e){e&&(e.abort?.abort(),e.renderables.length&&(e.renderables.forEach((e=>this._removeRenderable(e))),this.setNeedsRender()),e.loaded=null)}hasObject(e){return this._objectEntries.has(e)}async updateAllComponentOpacities(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));if(null==r)return;const s=Array.isArray(t)?e=>t[e]:()=>t;r.renderables.forEach((e=>{const t=e.components.meta.length;for(let r=0;r<t;r++){const t=s(r),n=e.components.meta[r],o=n.index;n.material.opacity=t,e.components.buffer.textureBuffer.setDataElement(o,1,3,255*t)}this._updateTransparency(e)})),this.setNeedsRender()}async _getObjectMemoryUsage(e){const t=await this._getObjectEntry(e);return t?t.renderables.reduce(((e,t)=>e+t.statistics.gpuMemoryUsage),0):0}async updateAllComponentMaterials(e,t,r,s){const n=e instanceof L,o=Q(t),i=W.getKey(o,r,n),a=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=a&&(a.renderables.forEach((e=>{if(i!==e.rendererKey){const t=this._renderers.get(e.rendererKey),s=this._acquireRenderer(o,r,n);t.removeRenderable(e),--t.refCount,e.rendererKey=i,s.addRenderable(e)}if(Array.isArray(t))for(let r=0;r<t.length;r++)e.components.meta[r].material=t[r];else e.components.meta[0].material=t;s&&me(e.components),this._updateTransparency(e)})),this.setNeedsRender())}async updateAllVerticalOffsets(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&this._updateAllVerticalOffsets(r,t)}_updateAllVerticalOffsets(e,t){e.renderables.forEach((e=>{const r=e.components.meta;for(let s=0;s<r.length;s++)e.components.meta[s].verticalOffset=t?.[s]??0;me(e.components)})),this.setNeedsRender()}async updateObjectVisibility(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));r&&(r.renderables.forEach((e=>e.visible=t)),this.setNeedsRender())}render(e,t){if(null==this._componentColorManager)return;this._localOrigins.updateViewMatrices(e.camera.viewMatrix);const r=e.camera.viewInverseTransposeMatrix,s=O(),n=new A;let o=0,i=0;if(this._renderers.forEach((r=>{if(0===r.refCount)return this._renderers.delete(r.key),void r.dispose();let s=!0,n=!0;r.forEachRenderable((t=>{t.visible&&(o+=t.statistics.averageEdgeLength,i++,s&&t.regular&&(r.updateTechnique(e,!1),s=!1),n&&t.silhouette&&(r.updateTechnique(e,!0),n=!1))}),t)})),this._componentColorManager.garbageCollect(),this._componentColorManager.updateTextures(),0===i)return;const a=new F(40*o/i,t);_(s,r[3],r[7],r[11]),n.set(s),b(a.transformWorldFromViewTH,n.high),b(a.transformWorldFromViewTL,n.low),u(a.transformViewFromCameraRelativeRS,e.camera.viewMatrix),m(Oe,a.transformViewFromCameraRelativeRS),g(a.transformNormalViewFromGlobal,Oe),a.transformProjFromView=e.camera.projectionMatrix,this._updateObjectCameraDistances(e),this._renderers.forEach((t=>{ge(t,e,a),fe(t,e,a)}))}_updateTransparency(e){const t=X(e.components.meta),r=Y(e.components.meta);t===e.edgeTransparency&&r===e.objectTransparency||(e.edgeTransparency=t,e.objectTransparency=r,this._renderers.get(e.rendererKey).setRenderablesDirty())}_computeModelTransformWithLocalOrigin(e,t,r){e.getCombinedShaderTransformation(t,r);const s=null!=t.localOrigin?this._localOrigins.register(t.localOrigin):this._localOrigins.acquire(_(this._tmpModelPosition,r[12],r[13],r[14]));return t.localOrigin=s.origin,P(s.origin.vec3,r),s}_createComponentBuffers(e){if(null==this._componentColorManager)return null;const t=new Array,r=this._componentColorManager.getBuffer(e.length);for(let n=0;n<e.length;n++){const s=e[n],o=r.acquireIndex();t.push({index:o,verticalOffset:0,material:s})}const s=new ce(r,t);return me(s),s}_extractEdges(e,t,r,s,n,o,i=o.length){return i<se&&(n=!0),this._worker.process({data:r,indices:o,indicesLength:i,writerSettings:t,skipDeduplicate:s},e,n)}_createRenderable(e,t,r,s,n){const o=t=>new le(new k(this.rctx,V,new Map([["vertices",H],["instances",t===ee.REGULAR?G.glLayout:N.glLayout]]),new Map([["vertices",this._verticesBufferObject],["instances",te.createVertex(this.rctx,re.STATIC_DRAW,t===ee.REGULAR?e.regular.instancesData.buffer:e.silhouette.instancesData.buffer)]])),t===ee.REGULAR?e.regular.lodInfo:e.silhouette.lodInfo),i=e.regular.lodInfo.lengths.length>0?o(ee.REGULAR):null,a=e.silhouette.lodInfo.lengths.length>0?o(ee.SILHOUETTE):null,c=(i?.vao.usedMemory??0)+(a?.vao.usedMemory??0);return new he(i,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,X(t.meta),Y(t.meta),t,s)}async _addGeometry(e,t,r,s,n,o){if(r.edgeIndicesLength<=0)return;const i=r.attributes.get(I.POSITION),a=p(),c=this._computeModelTransformWithLocalOrigin(e,r,a),l=new je(i,a,c);return this._addPositionData(t,l,r.edgeIndicesLength,s,n,o)}async _addPositionData(e,t,r,s,n,o=!1){if(null==e.loaded)return;const i=this._createComponentBuffers([s]);if(null==i)return;const a=this._acquireRenderer(s.type,n,!0),{modelTransform:c,origin:l}=t,d=t.position.indices,h=t.position,u=h.data.length/h.size,m=B.createBuffer(u);for(let p=0;p<u;p++)m.position.set(p,0,h.data[p*h.size]),m.position.set(p,1,h.data[p*h.size+1]),m.position.set(p,2,h.data[p*h.size+2]);Z(i.meta,[0,m.componentIndex.count],m.componentIndex);const g=await this._updatingHandles.addPromise(this._extractEdges(e.abort?.signal||this._workerAbort.signal,a.writerSettings,m,!1,o,d,r));if(null==e.loaded)return;const f=this._createRenderable(g,i,new de(c,l),a.key,!1);e.renderables.push(f),a.addRenderable(f),this._gpuMemoryUsage+=f.statistics.gpuMemoryUsage}async _addComponentGeometry(e,t,r,s,n,o,i,a){if(null==t.loaded)return 0;const c=this._createComponentBuffers(o);if(null==c)return 0;const l=Q(o),d=this._acquireRenderer(l,i||!1,!1),h=B.createBuffer(r.length/3);M(h.position.typedBuffer,r,h.position.typedBufferStride,3),Z(c.meta,n,h.componentIndex,s);const u=!0,m=d.writerSettings,g=await this._updatingHandles.addPromise(this._extractEdges(this._workerAbort.signal,m,h,u,!1,s));if(null==t.loaded)return 0;const f=this._createRenderable(g,c,e,d.key,!0);return t.renderables.push(f),d.addRenderable(f),this._updateAllVerticalOffsets(t,a),f.statistics.gpuMemoryUsage}async _addObjectMergedGeometries(e,t,r,s,n){const o=new Map;let i=0,a=0,c=null;const l=e.geometries.filter((e=>{if(e.edgeIndicesLength<=0||!e.material.supportsEdges)return!1;!c&&e.localOrigin&&(c=e);const t=e.attributes.get(I.POSITION);return a+=t.data.length/t.size,i+=e.edgeIndicesLength,!0}));if(0===l.length)return;const d=a>=65536?Uint32Array:Uint16Array,h=i?new d(i):null,u=[];let m=0;l.forEach((e=>{const t=e.attributes.get(I.POSITION),r=t.indices;let s=o.get(t.data);if(null==s){s=u.length/3;for(let e=0;e<t.data.length;e+=t.size)u.push(t.data[e]),u.push(t.data[e+1]),u.push(t.data[e+2]);o.set(t.data,s)}for(let n=0;n<e.edgeIndicesLength;n++)h[m++]=s+r[n]}));const g=c||e.geometries[0],f=p(),_=this._computeModelTransformWithLocalOrigin(e,g,f);for(let p=0;p<e.geometries.length;p++)e.geometries[p].localOrigin=_.origin;const b=new je(new C(u,h,3),f,_);await this._updatingHandles.addPromise(this._addPositionData(t,b,h.length,r,s,n))}_acquireRenderer(e,t,r){const s=W.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=J(this.rctx)),n||(n=new W(this.rctx,this.techniques,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:this.viewingMode===R.Global}),this._renderers.set(s,n)),++n.refCount,n}_removeRenderable(e){oe(e.regular),oe(e.silhouette);const t=this._renderers.get(e.rendererKey);if(t){t.removeRenderable(e),--t.refCount,this._localOrigins.release(e.transform.origin),this._gpuMemoryUsage-=e.statistics.externalMemoryUsage?0:e.statistics.gpuMemoryUsage;for(const t of e.components.meta)e.components.buffer.releaseIndex(t.index)}}_updateObjectCameraDistances(e){const t=e.camera.eye,r=e.camera.viewForward,s=O(),n=e=>{y(s,e.center,t);const n=j(s,r),o=e.radius,i=n<-o?1/0:n<o?0:n-o;e.renderables.forEach((e=>e.distanceToCamera=i))};this._objectEntries.forEach(n),this._pendingDeletions.forEach(n)}get test(){}};function oe(e){e?.vao&&(e.vao.vertexBuffers.get("instances")?.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function ie(e){let t=null,s=null;for(const n of e.geometries){if(n.material.supportsEdges){if(t){if(!r(t,n.transformation))return!1}else t=n.transformation;if(s||null==n.localOrigin){if(null!=s?.localOrigin&&null!=n.localOrigin&&s.localOrigin.id!==n.localOrigin.id)return!1}else s=n}}return!0}e([d({constructOnly:!0})],ne.prototype,"rctx",void 0),e([d({constructOnly:!0})],ne.prototype,"renderSR",void 0),e([d({constructOnly:!0})],ne.prototype,"viewingMode",void 0),e([d({constructOnly:!0})],ne.prototype,"techniques",void 0),e([d({constructOnly:!0})],ne.prototype,"setNeedsRender",void 0),e([d({constructOnly:!0})],ne.prototype,"schedule",void 0),e([d({readOnly:!0})],ne.prototype,"_updatingHandles",void 0),e([d({readOnly:!0})],ne.prototype,"updating",null),ne=e([h("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],ne);class ae{constructor(e,t,r,s){this.abort=e,this.radius=s,this.renderables=new Array;const n=e?l(e.signal,(()=>e.abort())):null;this.loaded=t,this.loaded.then((()=>{null!=this.loaded&&(this.loaded=!0),this.abort=null,n?.remove()})),this.center=w(r)}}class ce{constructor(e,t){this.buffer=e,this.meta=t}}class le{constructor(e,t){this.vao=e,this.lod=t}}class de{constructor(e,t){this.modelMatrix=e,this.origin=t}}class he{constructor(e,t,r,s,n,o,i,a){this.regular=e,this.silhouette=t,this.statistics=r,this.transform=s,this.edgeTransparency=n,this.objectTransparency=o,this.components=i,this.rendererKey=a,this.distanceToCamera=0,this.visible=!0}}class ue extends he{}function me(e){const{meta:t,buffer:r}=e,s=new Uint8Array(4);for(let n=0;n<t.length;n++){const e=t[n].material,i=t[n].index,a=o(Math.round(e.size*q),0,255),c=o(e.extensionLength,-z,255-z)+z,l=255*e.opacity,d=e.color,h=255*d[0],u=255*d[1],m=255*d[2],g=255*d[3];r.textureBuffer.setData(i,0,h,u,m,g),r.textureBuffer.setData(i,1,a,c,e.type,l),T(t[n].verticalOffset,s),r.textureBuffer.setData(i,2,s[0],s[1],s[2],s[3])}}function ge(e,t,r){const s=e.bindRegularEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!pe(n)||!n.visible)return;const i=ye(n.regular.lod.lengths,n.distanceToCamera,o);e.renderRegularEdges(s,n,r,t,i)}),n)}function fe(e,t,r){const s=e.bindSilhouetteEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!be(n)||!n.visible)return;const i=ye(n.silhouette.lod.lengths,n.distanceToCamera,o);e.renderSilhouetteEdges(s,n,r,t,i)}),n)}function pe(e){return null!=e.regular}class _e extends he{}function be(e){return null!=e.silhouette}function ye(e,t,r){const n=t*r,o=s(e,n,!0);return-1===o?n<e[0]?e.length:0:e.length-o}class je{constructor(e,t,r){this.position=e,this.modelTransform=t,this.origin=r}}const Oe=f(),we=()=>Promise.reject();export{ne as EdgeView,de as LegacyTransform,ue as RegularRenderable,he as Renderable,_e as SilhouetteRenderable};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{Default3D as e}from"./DefaultVertexAttributeLocations.js";import{Pos2 as r,Pos2Tex as t}from"./DefaultVertexBufferLayouts.js";import{VertexArrayObject as o}from"./VertexArrayObject.js";import{BufferObject as m}from"../../../webgl/BufferObject.js";import{Usage as n,TextureSamplingMode as f}from"../../../webgl/enums.js";import{Texture as s}from"../../../webgl/Texture.js";import{TextureDescriptor as u}from"../../../webgl/TextureDescriptor.js";function i(f,s=r,u=e,i=-1,l=1){let a=null;if(s===t)a=new Float32Array([i,i,0,0,l,i,1,0,i,l,0,1,l,l,1,1]);else a=new Float32Array([i,i,l,i,i,l,l,l]);return new o(f,u,{geometry:s},{geometry:m.createVertex(f,n.STATIC_DRAW,a)})}const l=4;function a(e){const r=new u(l);return r.samplingMode=f.NEAREST,new s(e,r)}export{a as createEmptyTexture,i as createQuadVAO};
5
+ import{Default3D as e}from"./DefaultVertexAttributeLocations.js";import{Pos2 as r,Pos2Tex as t}from"./DefaultVertexBufferLayouts.js";import{VertexArrayObject as o}from"./VertexArrayObject.js";import{BufferObject as s}from"../../../webgl/BufferObject.js";import{Usage as n,TextureSamplingMode as m}from"../../../webgl/enums.js";import{Texture as a}from"../../../webgl/Texture.js";import{TextureDescriptor as f}from"../../../webgl/TextureDescriptor.js";function u(r,t=c.Pos2,m=e,a=-1,f=1){const u=t===c.Pos2?new Float32Array([a,a,f,a,a,f,f,f]):new Float32Array([a,a,0,0,f,a,1,0,a,f,0,1,f,f,1,1]);return new o(r,m,new Map([["geometry",w.get(t)]]),new Map([["geometry",s.createVertex(r,n.STATIC_DRAW,u)]]))}const i=4;function p(e){const r=new f(i);return r.samplingMode=m.NEAREST,new a(e,r)}var c;!function(e){e[e.Pos2=0]="Pos2",e[e.Pos2Tex=1]="Pos2Tex"}(c||(c={}));const w=new Map([[c.Pos2,r],[c.Pos2Tex,t]]);export{c as Layout,p as createEmptyTexture,u as createQuadVAO};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{glLayout as r}from"../../../support/buffer/glUtil.js";import{Default3D as t}from"../DefaultVertexAttributeLocations.js";import{GLMaterials as e}from"../GLMaterials.js";import{newIntersectorResult as s}from"../Intersector.js";import{IntersectorType as i,StoreResults as o}from"../IntersectorInterfaces.js";import{VertexArrayObject as a}from"../VertexArrayObject.js";import{LodTarget as n}from"./Intersector.js";import{BufferObject as m}from"../../../../webgl/BufferObject.js";import{Usage as l}from"../../../../webgl/enums.js";class u{constructor(s,i){const o=s.renderContext.rctx,n=i.geometry;this._materials=s.materials,n.material.setParameters({instancedDoublePrecision:!0});const u=n.material.createBufferWriter(),f=u.vertexBufferLayout,d=u.elementCount(n),c=f.createBuffer(d);u.write(null,null,n,c,0),this.geometry=n,this.material=n.material,this.glMaterials=new e(n.material,this._materials),this.vertexBufferLayout=f,this.vbo=m.createVertex(o,l.STATIC_DRAW,c.buffer),this.vao=new a(o,t,{geometry:r(f)},{geometry:this.vbo}),this.vertexCount=d}destroy(){this.glMaterials.dispose(),this.vbo.dispose(),this.vao.dispose()}get boundingInfo(){return this.geometry.boundingInfo}get triangleCount(){return this.vertexCount/3}intersect(r,t,e,a,m,l,u,f){const d=this.geometry.id;this.material.intersect(this.geometry,r.transform.transform,r,e,a,((e,a,c,p,h)=>{if(e>=0){if(null!=t&&!t(r.rayBegin,r.rayEnd,e))return;const p=new n(l.layerUid,l.graphicUid(m),d,c,u,f);if((null==r.results.min.drapedLayerOrder||h>=r.results.min.drapedLayerOrder)&&(null==r.results.min.dist||e<r.results.min.dist)&&r.results.min.set(i.LOD,p,e,a,r.transform.transform,h),r.options.store!==o.MIN&&(null==r.results.max.drapedLayerOrder||h>=r.results.max.drapedLayerOrder)&&(null==r.results.max.dist||e>r.results.max.dist)&&r.results.max.set(i.LOD,p,e,a,r.transform.transform,h),r.options.store===o.ALL){const t=s(r.results.min.ray);t.set(i.LOD,p,e,a,r.transform.transform,h),r.results.all.push(t)}}}))}}export{u as LodComponentData};
5
+ import{glLayout as r}from"../../../support/buffer/glUtil.js";import{Default3D as t}from"../DefaultVertexAttributeLocations.js";import{GLMaterials as e}from"../GLMaterials.js";import{newIntersectorResult as s}from"../Intersector.js";import{IntersectorType as i,StoreResults as o}from"../IntersectorInterfaces.js";import{VertexArrayObject as a}from"../VertexArrayObject.js";import{LodTarget as n}from"./Intersector.js";import{BufferObject as m}from"../../../../webgl/BufferObject.js";import{Usage as l}from"../../../../webgl/enums.js";class u{constructor(s,i){const o=s.renderContext.rctx,n=i.geometry;this._materials=s.materials,n.material.setParameters({instancedDoublePrecision:!0});const u=n.material.createBufferWriter(),f=u.vertexBufferLayout,d=u.elementCount(n),p=f.createBuffer(d);u.write(null,null,n,p,0),this.geometry=n,this.material=n.material,this.glMaterials=new e(n.material,this._materials),this.vertexBufferLayout=f,this.vbo=m.createVertex(o,l.STATIC_DRAW,p.buffer),this.vao=new a(o,t,new Map([["geometry",r(f)]]),new Map([["geometry",this.vbo]])),this.vertexCount=d}destroy(){this.glMaterials.dispose(),this.vbo.dispose(),this.vao.dispose()}get boundingInfo(){return this.geometry.boundingInfo}get triangleCount(){return this.vertexCount/3}intersect(r,t,e,a,m,l,u,f){const d=this.geometry.id;this.material.intersect(this.geometry,r.transform.transform,r,e,a,((e,a,p,c,h)=>{if(e>=0){if(null!=t&&!t(r.rayBegin,r.rayEnd,e))return;const c=new n(l.layerUid,l.graphicUid(m),d,p,u,f);if((null==r.results.min.drapedLayerOrder||h>=r.results.min.drapedLayerOrder)&&(null==r.results.min.dist||e<r.results.min.dist)&&r.results.min.set(i.LOD,c,e,a,r.transform.transform,h),r.options.store!==o.MIN&&(null==r.results.max.drapedLayerOrder||h>=r.results.max.drapedLayerOrder)&&(null==r.results.max.dist||e>r.results.max.dist)&&r.results.max.set(i.LOD,c,e,a,r.transform.transform,h),r.options.store===o.ALL){const t=s(r.results.min.ray);t.set(i.LOD,c,e,a,r.transform.transform,h),r.results.all.push(t)}}}))}}export{u as LodComponentData};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{VertexNormalDrawParameters as i}from"../core/shaderLibrary/attributes/VertexNormal.glsl.js";class s extends i{constructor(i=r()){super(),this.origin=i,this.slicePlaneLocalOrigin=this.origin}}export{s as DrawParameters};
5
+ import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{VertexNormalDrawParameters as e}from"../core/shaderLibrary/attributes/VertexNormal.glsl.js";class i extends e{constructor(e=r()){super(),this.origin=e}get slicePlaneLocalOrigin(){return this.origin}}export{i as DrawParameters};