@arcgis/core 5.1.0-next.25 → 5.1.0-next.27

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 (161) hide show
  1. package/PopupTemplate.d.ts +12 -8
  2. package/README.md +4 -5
  3. package/applications/Components/testUtils.js +1 -1
  4. package/applications/Components/viewUtils.js +1 -1
  5. package/assets/esri/core/workers/RemoteClient.js +1 -1
  6. package/assets/esri/core/workers/chunks/{7a2e9626d0853a6d1547.js → 01e4cc34be6265843258.js} +1 -1
  7. package/assets/esri/core/workers/chunks/0389ebb63510dd7024de.js +2 -0
  8. package/assets/esri/core/workers/chunks/03e20ac54d6f141b5001.js +1 -0
  9. package/assets/esri/core/workers/chunks/049ec6dcb5d9519029fe.js +1 -0
  10. package/assets/esri/core/workers/chunks/{54794b18edc584fd7515.js → 07528211e59740c47aaa.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{6e32e7b2ea2ea1a1fc04.js → 1069b92c2c5fe5f0398b.js} +1 -1
  12. package/assets/esri/core/workers/chunks/17078f4ab1b3e33c80b4.js +1 -0
  13. package/assets/esri/core/workers/chunks/23079a2e584fca0bdb66.js +1 -0
  14. package/assets/esri/core/workers/chunks/{6fde745f3a62e7f5a97d.js → 36fd18a05ba503e6f3b5.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{a78ac951c00f090d9024.js → 3a018c78859b5edec4fd.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{abc2471cfa9430ca5645.js → 3a8f2f6ac3c3e7e71c00.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{7189e03cc24f5c10865a.js → 4490f8eeeb2ee04daa9d.js} +2 -2
  18. package/assets/esri/core/workers/chunks/{593e9c8ac3b3b02deeb9.js → 4b4cf6efde26dd80f4ad.js} +1 -1
  19. package/assets/esri/core/workers/chunks/4e9b3b4b3dcce94c99a5.js +1 -0
  20. package/assets/esri/core/workers/chunks/{14792047c5519dd89828.js → 541619f434b643f0526d.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{4fc6dd1423075e145b29.js → 5fff383615ba93adbf36.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{25bc7c7bc2793d209640.js → 776c0c38b9179dda00b3.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{e6f51f66b71e0d6525ec.js → 8dcc8df5925f66e45b8c.js} +1 -1
  24. package/assets/esri/core/workers/chunks/8eae33c4d8932b7a6bc1.js +1 -0
  25. package/assets/esri/core/workers/chunks/{f5c5a9e771074f780fc8.js → 94563b007647a9c4ad76.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{0140dc583e20b031eac9.js → 952ff668d202e80b43b0.js} +1 -1
  27. package/assets/esri/core/workers/chunks/a061a17b62686f945e81.js +1 -0
  28. package/assets/esri/core/workers/chunks/{835d6dd8c5a00682d879.js → a1eb8c6fd9a885cbaec9.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{9e7eea56e96f012f9ff4.js → a7d06c1553dfb6e83fe6.js} +1 -1
  30. package/assets/esri/core/workers/chunks/b1ddc837a6805a09d0da.js +1 -0
  31. package/assets/esri/core/workers/chunks/b9d68a5dcb50999d3a90.js +1 -0
  32. package/assets/esri/core/workers/chunks/{f12f96770a45ce6d1ed7.js → c3a0b38abf0a12a466fa.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{e2661d39c48376163adf.js → c55c70dde682084867a2.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{2de299ff3a902d380be6.js → c814abf3e67d9eadbc6b.js} +1 -1
  35. package/assets/esri/core/workers/chunks/c9bfe3d8416856c4a657.js +1 -0
  36. package/assets/esri/core/workers/chunks/e4faccd48060349b8da1.js +1 -0
  37. package/assets/esri/core/workers/chunks/{f1c1f7583fa13dff9b5c.js → e611f37bc22f75ce8a06.js} +44 -38
  38. package/assets/esri/core/workers/chunks/{deee88e3f1641c6ef5db.js → ee6f7c5d3c2f187645ff.js} +1 -1
  39. package/assets/esri/core/workers/chunks/ef29e9e575091ef3adbb.js +1 -0
  40. package/assets/esri/core/workers/chunks/{ef267b938327c41727c1.js → f89b7b0ccfbd1e5f9a0f.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{c794f7be868e53ca4a8c.js → fb05f27710fb50691d7a.js} +1 -1
  42. package/assets/esri/themes/base/widgets/_OrientedImageryViewerNavigationUI.scss +4 -1
  43. package/assets/esri/themes/dark/main.css +1 -1
  44. package/assets/esri/themes/light/main.css +1 -1
  45. package/assets/esri/themes/light/view.css +1 -1
  46. package/chunks/ImageMaterial.glsl.js +7 -7
  47. package/chunks/MeasurementArrow.glsl.js +5 -8
  48. package/chunks/ShadowCastAccumulate.glsl.js +5 -10
  49. package/chunks/ShadowHighlight.glsl.js +1 -1
  50. package/chunks/vec3.js +1 -1
  51. package/chunks/vec4.js +1 -1
  52. package/config.d.ts +2 -2
  53. package/config.js +1 -1
  54. package/editing/templateUtils.js +1 -1
  55. package/geometry/support/buffer/math/common.js +1 -1
  56. package/geometry/support/buffer/math/vec3.js +1 -1
  57. package/kernel.js +1 -1
  58. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  59. package/layers/support/FeatureReductionBinning.d.ts +3 -4
  60. package/layers/support/FeatureReductionBinning.js +1 -1
  61. package/layers/support/FeatureReductionCluster.d.ts +3 -4
  62. package/layers/support/FeatureReductionCluster.js +1 -1
  63. package/layers/support/featureReductionProperties.js +1 -1
  64. package/package.json +3 -3
  65. package/renderers/FlowRenderer.d.ts +6 -2
  66. package/support/actions/ActionBase.d.ts +5 -3
  67. package/support/actions/ActionBase.js +1 -1
  68. package/support/basemapDefinitions.js +1 -1
  69. package/support/revision.js +1 -1
  70. package/symbols/Font.d.ts +1 -1
  71. package/symbols/TextSymbol.d.ts +1 -1
  72. package/symbols/cim/CIMSymbolRasterizer.js +1 -1
  73. package/symbols/support/densifyForPreview.js +2 -0
  74. package/symbols/support/previewSymbol2D.js +1 -1
  75. package/views/2d/analysis/AreaMeasurement/AreaMeasurementTool.js +1 -1
  76. package/views/2d/analysis/DistanceMeasurement/DistanceMeasurementTool.js +1 -1
  77. package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
  78. package/views/2d/engine/vectorTiles/expression/expression.js +1 -1
  79. package/views/2d/engine/vectorTiles/shaders/VTLMaterial.js +1 -1
  80. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/vector-tiles/VTLShaderFill.js +1 -1
  81. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/vector-tiles/VTLShaderLine.js +1 -1
  82. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  83. package/views/2d/layers/MediaLayerView2D.js +1 -1
  84. package/views/2d/layers/imagery/VectorFieldView2D.js +1 -1
  85. package/views/3d/GroundView3D.js +1 -1
  86. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  87. package/views/3d/environment/CloudsComposition.js +1 -1
  88. package/views/3d/environment/CloudsRenderer.js +1 -1
  89. package/views/3d/environment/Fog.js +1 -1
  90. package/views/3d/environment/LocalAtmosphere.js +1 -1
  91. package/views/3d/environment/MarsAtmosphere.js +1 -1
  92. package/views/3d/environment/NoiseTextureAtlas.js +1 -1
  93. package/views/3d/environment/Precipitation.js +1 -1
  94. package/views/3d/environment/PrecipitationTechnique.js +1 -1
  95. package/views/3d/layers/MediaLayerView3D.js +1 -1
  96. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  97. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +12 -6
  98. package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js +1 -1
  99. package/views/3d/webgl-engine/effects/RenderNodes.js +1 -1
  100. package/views/3d/webgl-engine/effects/blit/Blit.js +1 -1
  101. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorNode.js +1 -1
  102. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorTechnique.js +1 -1
  103. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
  104. package/views/3d/webgl-engine/effects/glow/GlowBlurTechnique.js +1 -1
  105. package/views/3d/webgl-engine/effects/glow/GlowCompositionTechnique.js +1 -1
  106. package/views/3d/webgl-engine/effects/glow/GlowRenderNode.js +1 -1
  107. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  108. package/views/3d/webgl-engine/effects/haze/HazeCompositingTechnique.js +1 -1
  109. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  110. package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
  111. package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
  112. package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
  113. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  114. package/views/3d/webgl-engine/effects/smaa/SMAABlendWeightsTechnique.js +1 -1
  115. package/views/3d/webgl-engine/effects/smaa/SMAABlurTechnique.js +1 -1
  116. package/views/3d/webgl-engine/effects/smaa/SMAAEdgeDetectTechnique.js +1 -1
  117. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  118. package/views/3d/webgl-engine/effects/stars/Stars.js +1 -1
  119. package/views/3d/webgl-engine/lib/BasisUtil.js +1 -1
  120. package/views/3d/webgl-engine/lib/CutFillColor.js +1 -1
  121. package/views/3d/webgl-engine/lib/CutFillDepth.js +1 -1
  122. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  123. package/views/3d/webgl-engine/lib/Program.js +1 -1
  124. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  125. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  126. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  127. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  128. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  129. package/views/3d/webgl-engine/shaders/ImageMaterial.glsl.js +1 -1
  130. package/views/3d/webgl-engine/shaders/MeasurementArrow.glsl.js +1 -1
  131. package/views/3d/webgl-engine/shaders/MeasurementArrowTechnique.js +1 -1
  132. package/views/3d/webgl-engine/shaders/MeasurementArrowTechniqueConfiguration.js +1 -1
  133. package/views/3d/webgl-engine/shaders/ShadowCastAccumulate.glsl.js +1 -1
  134. package/views/layers/MediaLayerView.d.ts +90 -4
  135. package/views/layers/MediaLayerView.js +1 -1
  136. package/views/support/waitForResources.js +1 -1
  137. package/widgets/Features/FeaturesViewModel.d.ts +14 -19
  138. package/widgets/Features.d.ts +1 -1
  139. package/widgets/Measurement.d.ts +1 -1
  140. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  141. package/widgets/OrientedImageryViewer/components/Arrow.js +1 -1
  142. package/widgets/Popup.d.ts +1 -1
  143. package/widgets/ValuePicker.d.ts +1 -1
  144. package/widgets/support/legacyIcon.js +1 -1
  145. package/assets/esri/core/workers/chunks/1be4e308280149eae4fb.js +0 -1
  146. package/assets/esri/core/workers/chunks/1dcd057695f8db79eca2.js +0 -1
  147. package/assets/esri/core/workers/chunks/1df8330823841b5bb6a5.js +0 -1
  148. package/assets/esri/core/workers/chunks/2063b49607a03f7718ee.js +0 -1
  149. package/assets/esri/core/workers/chunks/2b76a8897ad7ba284d33.js +0 -1
  150. package/assets/esri/core/workers/chunks/36da644678e6acf3bdb5.js +0 -1
  151. package/assets/esri/core/workers/chunks/4754610760f3f634adf9.js +0 -2
  152. package/assets/esri/core/workers/chunks/551fee27bf3abf0c41fd.js +0 -1
  153. package/assets/esri/core/workers/chunks/57b620d7e029747adca3.js +0 -1
  154. package/assets/esri/core/workers/chunks/74e3c224e879edb37812.js +0 -1
  155. package/assets/esri/core/workers/chunks/868c8a152cb1452b9a94.js +0 -1
  156. package/assets/esri/core/workers/chunks/e839c5f3a0213091a399.js +0 -1
  157. package/assets/esri/core/workers/chunks/feececf6809231f72c5a.js +0 -1
  158. package/views/layers/MediaLayerViewMixin.d.ts +0 -109
  159. package/views/layers/MediaLayerViewMixin.js +0 -2
  160. /package/assets/esri/core/workers/chunks/{4754610760f3f634adf9.js.LICENSE.txt → 0389ebb63510dd7024de.js.LICENSE.txt} +0 -0
  161. /package/assets/esri/core/workers/chunks/{7189e03cc24f5c10865a.js.LICENSE.txt → 4490f8eeeb2ee04daa9d.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as s}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import{removeMaybe as r,abortMaybe as i,destroyMaybe as n,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAborted as h}from"../../../../core/promiseUtils.js";import{watch as o,syncAndInitial as d,initial as _,sync as l}from"../../../../core/reactiveUtils.js";import{signal as u}from"../../../../core/signal.js";import{property as p,subclass as m}from"../../../../core/accessorSupport/decorators.js";import{equals as c,invert as f,multiply as g}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as b,create as P}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as C}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as w,ZEROS as E}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as T}from"../../../../geometry/support/Indices.js";import{RenderNodeOutput as x,InternalRenderCategory as A,AllRenderNodeOutputs as S,AllInternalRenderNodeOutputs as D}from"../../webgl.js";import{innerAtmosphereFadeStart as R}from"../../environment/atmosphereUtils.js";import{minNearDistanceInMeters as I}from"../../state/NearFarHeuristic.js";import{debugFlags as y}from"../../support/debugFlags.js";import{FBOCache as H}from"../core/FBOCache.js";import{RenderPassManager as O}from"../core/renderPasses/RenderPassManager.js";import{isColor as v}from"../core/shaderLibrary/ShaderOutput.js";import{distanceFadeEnd as F}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as M}from"../effects/RenderNodes.js";import{RenderPluginManager as N}from"../effects/RenderPluginManager.js";import{Blit as q}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as G,renderHighlightBuffer as L}from"../effects/highlight/Highlight.js";import{OITBlend as U}from"../effects/transparency/OITBlend.js";import{AnimationTimer as V}from"./AnimationTimer.js";import{AnimationTimeStep as B}from"./AnimationTimeStep.js";import{BoundingInfo as j}from"./BoundingInfo.js";import{Compositor as k}from"./Compositor.js";import{DepthRange as z}from"./DepthRange.js";import{depthRangeFromScene as W}from"./depthRangeUtils.js";import{MainFramebuffer as Q}from"./MainFramebuffer.js";import{RenderContext as Y,defaultRenderOccludedMask as J}from"./RenderContext.js";import{RendererBase as K}from"./RendererBase.js";import{setupFeatureDefaults as X}from"./RenderFeature.js";import{RenderPluginInput as Z}from"./RenderPluginInput.js";import{ShadowAccumulator as $}from"./ShadowAccumulator.js";import{ShadowMap as ee}from"./ShadowMap.js";import te from"./SliceHelper.js";import{MergedRenderer as se}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as re}from"../parts/renderUtils.js";import{RendererPerformanceInfo as ie,PerformanceCategory as ne}from"../statistics/RendererPerformanceInfo.js";import{PixelType as ae,ColorAttachment1 as he,ColorAttachment2 as oe,ColorAttachment0 as de}from"../../../webgl/enums.js";let _e=class extends K{constructor(e,t,s,r,i){super({stage:e}),this._techniques=s,this._rctx=r,this._requestRender=i,this._pluginsHas={occludedHudElements:!1,hudElements:!1,water:!1},this.renderPassManager=new O,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=w(0,0,0,1),this._sliceHelper=new te,this.sceneDepthRange=u(z.Infinite),this._state=u(2),this._hasAnimations=!1,this._animationTimestep=new B,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=u(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new Z,this._oitCallouts=!1,this._releaseNodeInputs=e=>{for(const t of we)e.some(({name:e})=>e===t)&&this._pluginInput.release(t)},this._debugNeedsDepth=!1,this._fboCache=new H(r),this._compositor=new k(r,s),this._renderStateFeatures=u(X(e.view.qualityProfile)),this._framebuffer=new Q(this.fboCache),this._performanceInfo=new ie(this._rctx),this._shadowMap=new ee(this.fboCache,e.viewingMode),this._blit=new q(s),this._shadowAccumulator=new $(this.fboCache,s,e,e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t},(t,s,r)=>{const i=e.view.qualitySettings.maximumPixelRatio;t.shadowMap.start(t.camera,s,r,!0,i),this._renderShadowCascades(3,t.shadowMap),t.shadowMap.finish(),t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.contentCamera)},i),this._renderContext=new Y(this._rctx,this._shadowMap,s),this._nodes=new M(this._renderContext),this._plugins=new N({renderContext:this._renderContext,techniques:s,materials:t,requestRender:i,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this.addHandles([o(()=>e.view.state.camera,()=>i(),d),o(()=>y.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES,e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(0):()=>{},i()},_),o(()=>e.view.environment.background?.color,e=>{const t=e?e.toUnitRGBA():E;C(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),i()},d),o(()=>e.view.state.camera.relativeElevation,e=>this._inGlobeView=(e??1/0)>=F,d),o(()=>this._bindParameters.clouds.fadeFactor,()=>{this._bindParameters.fadeLighting(),this._requestRender(2)},l),o(()=>this._bindParameters.clouds.data?.state,()=>i(),l),o(()=>e.view.state.highlights,e=>{this._bindParameters.highlights=e,i()},_)])}destroy(){this._gpuTimerHandle=r(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.destroy(),this._shadowAccumulator=null,this._loadEdgeViewTask=i(this._loadEdgeViewTask),this._edgeView=n(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this._fboCache.destroy(),this._fboCache=null,this._plugins.destroy(),this._plugins=null,this._pluginInput=null,this._oitBlendOrNil=null,this._nodes=null,this._framebuffer=null,this._shadowMap=null,this._renderContext=null,this._performanceInfo=null,j.prune(),se.prune(),T()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _oitBlend(){return this._oitBlendOrNil??=new U(this._techniques),this._oitBlendOrNil}get performanceInfo(){return this._performanceInfo}updateRenderFeatures(e){this._renderStateFeatures.value=X(e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,s){this._renderStateFeatures.mutate(r=>r.set(t,e,s)),this._requestRender()}get _highQualityTransparency(){return this.isFeatureEnabled(1)}get hasReflections(){return this._pluginsHas.water&&this.isFeatureEnabled(6)}get _hasHighlights(){return this._plugins.produces(8,2,4,20,14,15,16)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(8,14,15,16)}get hasSSAO(){return this.isFeatureEnabled(5)&&!this._inGlobeView}get hasSMAA(){return this.isFeatureEnabled(0)}get _hasEmission(){return this._plugins.hasEmitters&&this._hasFloatBufferBlendSupport}get highResolutionAtmosphere(){return this.isFeatureEnabled(4)}get fboCache(){return this._fboCache}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=a(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=a(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=a(this._bindParameters.geometryDepth),this._bindParameters.hudOcclusion=a(this._bindParameters.hudOcclusion)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeBuffers(),this._bindParameters.depth=a(this._bindParameters.depth),this._bindParameters.hudVisibility=a(this._bindParameters.hudVisibility)}get updating(){return this._loadEdgeViewTask&&!this._loadEdgeViewTask.finished||this._edgeView?.updating||this._shadowAccumulator.readyToRun||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=s(async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");h(e);const s=this._edgeView=new t({rctx:this._rctx,renderSR:this.stage.view.renderSpatialReference,viewingMode:this.stage.view.stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:Ae(this.stage.view.resourceController)});return this.addHandles(o(()=>s.updating,()=>this._requestRender(),l)),this._requestRender(),this._edgeViewCallbacks.forEach(e=>e(s)),this._edgeViewCallbacks.length=0,s})),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&&c(this._bindParameters.ssr.reprojectionMatrix,b)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:s}=this;if(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()),e.environment){void 0!==e.environment.weather&&(this._bindParameters.weather=e.environment.weather);const t="virtual"!==e.environment.lighting.type;s.enableFillLights!==t&&(s.enableFillLights=t,this._requestRender())}void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}set slice(e){this._sliceHelper.update(e)&&this._requestRender()}get plugins(){return this._plugins}get _hasFloatBufferBlendSupport(){return this._rctx.driverTest.floatBufferBlend.result}get oitEnabled(){return this.isFeatureEnabled(2)&&this._hasFloatBufferBlendSupport}commit(e,t){return this._isRendering&&console.warn("Renderer.modify called while rendering"),!!super.commit(e,t,this._plugins.context)&&(this.updateHasFlags(),!0)}rendererAdded(e){this._plugins.add(e)}rendererRemoved(e){this._plugins.remove(e)}get occludedRequiresStencil(){return this.occludedRequiresOccludeeStencil||this.occludedRequiresIntegratedMeshStencil}get occludedRequiresOccludeeStencil(){return this._bindParameters.hasOccludees&&!!(8&this.plugins.renderOccludedFlags)}get occludedRequiresIntegratedMeshStencil(){return this._plugins.produces(0,0)&&this._plugins.produces(0,10)}updateHasFlags(){const has=this._pluginsHas;has.occludedHudElements=this._plugins.produces(0,15),has.hudElements=has.occludedHudElements||this._plugins.produces(0,...ge),has.water=this._plugins.produces(2,21),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new V(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const s=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==s&&(this._gpuTimerHandle=s?r(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,s,r=!1){try{return this._isRendering=!0,this._render(e,t,s,r)}catch(i){console.error(`Exception during rendering: ${i}`)}finally{this._isRendering=!1}return new re(this._pluginInput.get(x.FINAL),null)}_render(e,t,s,r){const i=0===s;this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=i,this._disposeBindBuffers();const{camera:n,contentCamera:a,mode:h,alignPixelEnabled:o}=e;this._state.value=h,this._renderContext.time=t,this._renderContext.output=0,this._bindParameters.hasEmission=this._hasEmission,this._bindParameters.oitPass=0,this._bindParameters.alignPixelEnabled=o,this._bindParameters.decorations=!r,this._bindParameters.mainDepth=null;const d=!r||!this._sliceHelper.isDecoration;this._bindParameters.slicePlane=d?this._sliceHelper.plane:null,this._bindParameters.viewshedEnabled=this._nodes.produces(A.VIEWSHED),this._bindParameters.cutFillEnabled=this._nodes.produces(A.CUTFILL_DEPTH),this._renderOverlay(),n.setGLViewport(this._rctx);const _=this._framebuffer,l=_.initialize(n.fullWidth,n.fullHeight,this._backgroundColor,this._bindParameters.hasEmission);this.hasReflections?(l?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=l):l?.release(),this._ensureBindParametersCamera(n,a),this._plugins.sortTestsTransparentOrderedSlots(Pe),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!r;const u=this._plugins.produces(0,...ue);this._precompilePrepasses(),this.performanceInfo.advance(ne.PREPARE);const p=this._computeShadowDepthRange(n);this._renderShadowMap(n,this._bindParameters.lighting.mainLight.direction,p),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(p,n,a,!i),this._oitCallouts=u&&this.oitEnabled,this._ensureBindParametersSSR(t),this._precompileShaders(u),this._renderContext.output=0,_.bind(),this._bindParameters.mainDepth=_.depth.attachment,this._renderOpaque(),this._renderTransparent(u),this._shadowMap.disposeMainBuffer(),this._pluginInput.set(A.FOCUSAREA,this._renderFocusAreaGeometry()),this._pluginInput.set(A.CUTFILL_DEPTH,this._renderCutFillDepth()),_.update(e=>this._renderNodes(A.TRANSPARENT_ENVIRONMENT,e)),_.update(e=>this._renderNodes(A.VIEWSHED,e)),_.update(e=>this._renderNodes(A.LASERLINES,e)),_.update(e=>this._renderNodes(A.FOCUSAREA_COLOR,e)),this._pluginInput.release(A.FOCUSAREA),this._pluginInput.release(A.CUTFILL_DEPTH),_.update(e=>this._renderNodes(A.OCCLUDED,e)),this._pluginInput.set("highlights",this._renderHighlightPrepass()),this._renderHighlightShadowMap(n,this._bindParameters.lighting.mainLight.direction,p);const m=2===s?this._renderObjectAndLayerIdColor():null;_.update(e=>this._renderNodes(x.COMPOSITE,e)),this._shadowMap.disposeBuffers(),_.update(e=>this._renderNodes(A.ANTIALIASING,e));const c=this._hasPhotoshopTerrain||!u?1:2;let f;return this._bindParameters.hasEmission=!1,this._hasHUDHighlights&&_.update(e=>this._renderHUD(c,e)),_.update(e=>this._renderNodes(A.HIGHLIGHT_COLOR,e)),this._hasHUDHighlights||_.update(e=>this._renderHUD(c,e)),this._bindParameters.hasEmission=this._hasEmission,_.update(e=>this._renderNodes(A.MAGNIFIER,e)),_.update(e=>this._renderNodes(x.FINAL,e)),i&&this._blit.toFramebuffer(this._rctx,_.color,this._bindParameters),this.onPostRender?.(),this._releaseFBOs(),_.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),i||(f=_.color,f.retain(),this._releaseFBOs(),this._disposeOffscreenBuffers()),this.performanceInfo.finishFrame(),new re(f,m)}_precompileShaders(e){++this._plugins.context.techniques.precompiling,this._renderContext.output=0,this._precompileOpaqueGeometry(),this._nodes.precompile(A.OPAQUE_ENVIRONMENT),this._nodes.precompile(A.GAUSSIAN_SPLAT);const t=this._bindParameters;t.terrainDepthTest=t.cullAboveTerrain=this._needsTerrainDepth,this._renderContext.output=1,this._plugins.precompile(...pe),this._needsTerrainDepth&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._renderContext.output=0,this._plugins.precompile(...pe);const s=this._pluginsHas.hudElements&&this.oitEnabled,r=this._pluginsHas.occludedHudElements,i=this._bindParameters.hasEmission;this._oitBlend.precompile(i,r,s),s&&this._oitBlend.precompile(!1,r,s),e&&(this._precompileTransparentGeometry(),this._hasPhotoshopTerrain&&(t.cullAboveTerrain=!1,this._precompileTransparentGeometry(),t.cullAboveTerrain=this._needsTerrainDepth)),this._nodes.precompile(A.FOCUSAREA);const n=this._hasPhotoshopTerrain&&!this._needsTerrainDepth;this._compositor.precompile(this._usesPremultipliedAlphaBlit,!!this._needsEdges,n,i),this._needsHUDVisibility&&this._plugins.precompile(13),this._oitCallouts||this._plugins.precompile(17),this._precompileHUD(0),t.terrainDepthTest=t.cullAboveTerrain=!1,this._nodes.precompile(A.TRANSPARENT_ENVIRONMENT,A.VIEWSHED,A.CUTFILL_DEPTH,A.CUTFILL_COLOR,A.LASERLINES,A.FOCUSAREA_COLOR,A.OCCLUDED,A.ANTIALIASING,A.HIGHLIGHT_COLOR),t.highlightMixTexture=t.highlights.length>1?this._rctx.emptyTexture:null,t.hasEmission=!1,this._precompileHUD(1),this.oitEnabled&&this._precompileHUD(0),t.hasEmission=this._hasEmission,this._hasHighlights&&(t.highlights.forEach((e,s)=>{t.highlightLevel=s,this._precompileAllGeometry(8),this._hasHUDHighlights&&this._plugins.precompile(15,14)}),t.highlightLevel=null,this._nodes.precompile(A.HIGHLIGHT_COLOR)),t.highlightMixTexture=null,this._nodes.precompile(x.COMPOSITE,A.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(9),--this._plugins.context.techniques.precompiling}_renderFocusAreaGeometry(){const e=this._nodes.produce(A.FOCUSAREA,this._pluginInput);return e&&this.performanceInfo.advance(ne.FOCUS_AREA_MASK),e}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._renderContext.output;++this._techniques.precompiling;const{width:t,height:s}=this._framebuffer.size;let r=this.fboCache.acquire(t,s,"olid");return r.acquireDepth(13),r=this._nodes.render(r,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(ne.OBJECT_AND_LAYER_ID_COLOR),this._renderContext.output=e,r}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,s=0===e;if(s||t){const e=s?this.performanceInfo.elapsedTime:0;let r=0;t?r=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const i=Math.max(e,r);this._animationTimestep.frame(i,s)}}readMainDepth(e,t){const{mainDepth:s,camera:r}=this._bindParameters;if(!s)return;const i=this.fboCache.acquire(this._framebuffer.size.width,this._framebuffer.size.height,"linear depth");this._rctx.bindFramebuffer(i.fbo),r.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(E),this._compositor.blitDepthToLinearDepth(this._bindParameters,s),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],6408,ae.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,t,s,r,i){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,s,r,6408,ae.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}get _needsEdges(){return this._edgeView?.shouldRender()?this._edgeView:null}_renderEdges(e){const t=this._needsEdges;if(!t)return;const{width:s,height:r}=this._framebuffer.size,i=this.fboCache.acquire(s,r,"edges"),n=this._bindParameters.geometryDepth,a=()=>t.render(this._bindParameters,e);this._renderToTargets(a,i,n??this._framebuffer.depth,E),this._framebuffer.bind(),this._compositor.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(1===e?ne.OPAQUE_EDGES:ne.TRANSPARENT_EDGES)}_renderOverlay(){this._bindParameters.overlay=this.overlay?.render(this._renderContext.time),this._bindParameters.overlay&&this.performanceInfo.advance(ne.OVERLAY)}_renderShadowMap(e,t,s){if(!this.shadowsEnabled)return;const r=this._shadowMap;r.start(e,t,s,this.isFeatureEnabled(7),this.stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(5,this._shadowMap),r.copySnapshot(1),this._renderShadowCascades(4,this._shadowMap)):this._renderShadowCascades(3),r.finish(),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,this._bindParameters.contentCamera),this.performanceInfo.advance(ne.SHADOW_MAP)}_renderHighlightShadowMap(e,t,s){if(!this.shadowsEnabled||!this._needsShadowHighlight)return;const r=this._shadowMap;r.start(e,t,s,this.isFeatureEnabled(7),this.stage.view.qualitySettings.maximumPixelRatio),this._renderShadowCascades(4,this._shadowMap),r.moveSnapshot(0),r.finish(),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,this._bindParameters.contentCamera),this.performanceInfo.advance(ne.SHADOW_MAP)}_renderCutFillDepth(){return this._nodes.produce(A.CUTFILL_DEPTH,this._pluginInput)}_precompileShadowCascades(e){0!==this._shadowMap.cascades.length&&this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){t.bindFbo();for(const s of t.cascades)s.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(s.camera,s.camera),this.renderAllGeometry(e)}get _needsDepth(){return this._plugins.consumes(1)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._shadowAccumulator.active||this._debugNeedsDepth}get _usesPremultipliedAlphaBlit(){return this._pluginsHas.hudElements&&this.oitEnabled||this._hasPhotoshopTerrain}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");e?(this._pluginInput.set(A.SSAO,this._renderSSAO()),this._needsDepth?(this._rctx.bindFramebuffer(e.fbo),this._rctx.clear(1024),this._renderGeometryWithoutNormals(1),this._bindParameters.depth?.release(),this._bindParameters.depth=e.obtainDepthTexture(),this.performanceInfo.advance(ne.DEPTH)):(e.detachDepth(),this._bindParameters.depth=a(this._bindParameters.depth)),this.hasSSAO&&this._pluginInput.release("normals")):this._renderAllGeometryDepth()}_renderAllGeometryDepth(){if(this._bindParameters.depth=a(this._bindParameters.depth),!this._needsDepth)return;const{width:e,height:t}=this._framebuffer.size,s=this.fboCache.acquire(e,t,"geometry depth",13);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(1280),this.renderAllGeometry(1),this._bindParameters.depth=s.obtainDepthTexture(),s.release(),this.performanceInfo.advance(ne.DEPTH)}_renderTerrainDepth(){if(this._bindParameters.terrainDepth=a(this._bindParameters.terrainDepth),this._bindParameters.terrainDepthTest=this._bindParameters.cullAboveTerrain=this._needsTerrainDepth,!this._needsTerrainDepth)return;const e=this._renderContext.output;this._renderContext.output=1;const{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquire(t,s,"terrain depth",13);this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(1280),this._renderTransparentGround(),this._bindParameters.terrainDepth=r.obtainDepthTexture(),r.release(),this._renderContext.output=e}_renderGeometryDepth(){if(this._bindParameters.geometryDepth=a(this._bindParameters.geometryDepth),!this._needsTerrainDepth)return;const e=this._renderContext.output,{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquire(t,s,"geometry depth",13);this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(1280),this._renderOpaqueAndTransparentGeometry(1),this._renderContext.output=e,this._bindParameters.geometryDepth=r.obtainDepthTexture(),r.release()}get _needsShadowDepthRange(){return this._shadowMap.enabled||this._shadowAccumulator.active}_computeShadowDepthRange(e){if(!this._needsShadowDepthRange)return z.Zero;const t=W(e,this._plugins.plugins,this.stage.layers,0);return t.union(this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}updateSceneDepthRange(e){if(!this.stage.view.state.isGlobal)return void(this.sceneDepthRange.value=z.Infinite);if((this.stage.view.renderCoordsHelper?.getAltitude(e.eye)??0)<R)return void(this.sceneDepthRange.value=z.Infinite);const t=e.clone();t.near=I,t.far=1e10;const s=W(t,this._plugins.plugins,this.stage.layers,1);s.union(this._plugins.queryDepthRange(t)),this.sceneDepthRange.value.equals(s)||(this.sceneDepthRange.value=s)}get _normalsRequired(){const e=this._nodes.require("normals",...S,A.VIEWSHED,A.LASERLINES);return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(2),this._needsDepth&&this._precompileAllGeometry(1),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(4),this._precompileShadowCascades(5)):this._precompileShadowCascades(3)),this._shadowAccumulator.active&&this._precompileAllGeometry(3),this.hasSSAO&&this._normalsRequired&&this._nodes.precompile(A.SSAO)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquire(t,s,"normals",5);r.acquireDepth(13),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(E,!0,!0),this._renderContext.output=2,this._plugins.render(...me);const i=this._nodes.optional("normals",...S,A.VIEWSHED);return r.retain(e+i-1),this.performanceInfo.advance(ne.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(this.hasSSAO&&e)return this._bindParameters.ssao=this._nodes.produce(A.SSAO,this._pluginInput),this._bindParameters.ssao&&this.performanceInfo.advance(ne.SSAO),this._bindParameters.ssao}_precompileAllGeometry(e){const t=this._renderContext.output;this._renderContext.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(...pe),this._renderContext.output=t}renderAllGeometry(e){this._renderContext.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentGround()}precompileSlots(e,...t){for(const s of t)this._bindParameters.slot=s,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const s of t)this._renderContext.renderOccludedMask=s,this.precompileSlots(e,...fe);this._renderContext.renderOccludedMask=J}renderSlots(e,...t){for(const s of t)this._bindParameters.slot=s,e.forAll(e=>{const t=e.acquireTechniques(this._renderContext);t&&e.render(this._renderContext,t)})}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>1&&this._plugins.render(10),this.renderSlots(e,...fe),this._renderContext.renderOccludedMask=J}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(...Ce[e])}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(18),this.renderHUD(e),this._bindParameters.hudRenderStyle=e,this._plugins.render(16)}precompileViewshedShadowMap(){this._precompileAllGeometry(6)}precompileCutFill(){const e=7,t=this._renderContext.output;this._renderContext.output=e,this._plugins.precompile(0,1,...pe),this._renderContext.output=t}renderViewshedShadowMap(e){const{camera:t,contentCamera:s}=this._bindParameters,r=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(6),this._ensureBindParametersCamera(t,s),this._bindParameters.camera.setGLViewport(this._rctx),this._renderContext.output=r}renderCutFillReferenceDepth(e){const{camera:t,contentCamera:s}=this._bindParameters,r=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this._renderContext.output=7,this._plugins.render(0,1,...pe),this._ensureBindParametersCamera(t,s),t.setGLViewport(this._rctx),this._renderContext.output=r}_renderOpaqueAndTransparentGeometry(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithoutNormals(e){this._renderContext.output=e,this._plugins.render(...ce)}_precompileOpaqueGeometry(){this._plugins.precompile(...le),this._nodes.precompile("opaque-color")}_renderOpaqueGeometry(){this._plugins.render(...le)}_renderTransparentGeometry(){this._plugins.render(...ue),this._oitCallouts&&this._plugins.render(17)}get _hasPhotoshopTerrain(){return this._plugins.produces(0,6)}get _needsTerrainDepth(){return this._highQualityTransparency&&this._hasPhotoshopTerrain}_renderPhotoshopTerrain(){if(!this._hasPhotoshopTerrain)return null;const{width:e,height:t}=this._framebuffer.size,s=this.fboCache.acquire(e,t,"transparent terrain"),r=()=>this._plugins.render(6);return this._renderToTargets(r,s,this._framebuffer.depth,E),this.performanceInfo.advance(ne.TRANSPARENT_TERRAIN),s}_renderTransparentGround(){this._plugins.render(...pe)}get _needsHUDVisibility(){return this._plugins.produces(this._renderContext.output,13)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=a(this._bindParameters.hudVisibility));const{width:e,height:t}=this._framebuffer.size;let s=this._bindParameters.hudVisibility;s?.fbo?.width===e&&s?.fbo?.height===t||(s?.release(),s=this.fboCache.acquire(e,t,"hud visibility",4),this._bindParameters.hudVisibility=s);const r=this._bindParameters.geometryDepth;s.attachDepth(r||this._framebuffer.depth),this._rctx.bindFramebuffer(s.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(13),s.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(ne.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,0===e){const e=()=>this._plugins.render(17),{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquireDepth(12,t,s,"line callouts");this._renderToTargets(e,this._framebuffer.color,r,void 0,!0,!0),r.release()}else this._plugins.render(17)}_precompileHUD(e){if(this._pluginsHas.hudElements&&(this._precompileHUDOutput(e),this._hasHighlights)){const t=this._renderContext.output;this._renderContext.output=8,this._precompileHUDOutput(e),this._renderContext.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this.oitEnabled&&v(this._renderContext.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...ge),this._bindParameters.oitPass=2,this._plugins.precompile(...ge),this._bindParameters.oitPass=0):this._plugins.precompile(...ge),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t){if(!this._pluginsHas.hudElements)return t;if(this.oitEnabled){const s=this._renderOIT(1,e);this._rctx.bindFramebuffer(t.fbo),this._compositor.compositePreMultipliedAlpha(this._bindParameters,s.getTexture(),!1),s.release()}else if(this._renderContext.output=0,0===e){const t=()=>this._renderHUDElements(e),{width:s,height:r}=this._framebuffer.size,i=this.fboCache.acquireDepth(12,s,r,"hud");this._renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(12),this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(256),this._renderHUDElements(e),t.detachDepth();return this.performanceInfo.advance(0===e?ne.HUD_OCCLUDED:ne.HUD),t}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(4,2)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:s}=this,{width:r,height:i}=this._framebuffer.size,{highlights:n}=s,a=n.length>G?3:1,h=e.acquire(r,i,"highlights",a);h.acquireDepth(13);const o=this._plugins.produces(8,0);return o&&this._framebuffer.color.fbo&&h.fbo&&t.blitFramebuffer(this._framebuffer.color.fbo,h.fbo,1024),t.bindFramebuffer(h.fbo),t.gl.clearBufferuiv(6144,0,[0,0,0,0]),o||t.clear(1024),this._renderContext.output=8,t.bindFramebuffer(h.fbo),L(t,e,r,i,s,()=>this._renderHighlightGeometries()),h.detachDepth(),this.performanceInfo.advance(ne.HIGHLIGHTS),h.retain(this._nodes.require("highlights",...D)+this._nodes.optional("highlights",...D)-1),h}_renderHighlightGeometries(){this._plugins.render(...be),this._rctx.clear(256),this._renderHUDElements(2)}_renderShadowAccumulation(e,t,s,r){this._shadowAccumulator.updateDepthRange(e),this._shadowAccumulator.accumulating&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,t,s,r)&&this.performanceInfo.advance(ne.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this.oitEnabled&&v(this._renderContext.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...ue),this._oitCallouts&&this._plugins.precompile(17),this._bindParameters.oitPass=2,this._plugins.precompile(...ue),this._oitCallouts&&this._plugins.precompile(17),this._bindParameters.oitPass=0):this._plugins.precompile(...ue)}_renderOIT(e,t=2){const s=1===e,{width:r,height:i}=this._framebuffer.size,n=s?()=>this._renderHUDElements(t):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._renderContext.output;this._renderContext.output=0,h.oitPass=1;const d=s?"oit hud":"oit",_=this.fboCache.acquire(r,i,d,8),l=this._bindParameters.hasEmission&&(0===e||1!==t);l&&_.acquireColor(he,8,"oit emissive");const u=l?oe:he;_.acquireColor(u,7,"oit alpha"),s||_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer([0,0,0,1]),l&&this._rctx.clearBuffer(1,E),n(),_.detachDepth(),h.oitPass=2;const p=this.fboCache.acquire(r,i,s?"oit hud front":"oit front");l&&p.acquireColor(he,8,"oit emissive front"),s?p.acquireDepth(12):p.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(p.fbo),this._rctx.clearFramebuffer(E,s),n(),p.detachDepth();const m=this._pluginsHas.occludedHudElements&&!s;let c;return this._bindParameters.hudOcclusion=a(this._bindParameters.hudOcclusion),h.oitPass=0,s?(c=this.fboCache.acquire(r,i,"oit hud composite"),this._rctx.bindFramebuffer(c.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(16384)):(m&&(this._framebuffer.color.acquireColor(u,0,"hud occlusion"),this._rctx.clearBuffer(u-de,E)),this._framebuffer.bind()),this._oitBlend.blend(this._rctx,_,p,h,l,m,e),c?.detachDepth(),s||(this._rctx.bindFramebuffer(p.fbo),this._framebuffer.bind(),m&&(this._bindParameters.hudOcclusion=this._framebuffer.color.obtainAttachment(u))),p.release(),_.release(),this._renderContext.output=o,c}_renderOpaque(){const e=this.plugins.produces(0,...le);if(e){this._plugins.render(0,1);const e=this._framebuffer;e.update(e=>this._renderNodes(A.CUTFILL_COLOR,e)),e.update(e=>this._renderNodes(A.OPAQUE_TERRAIN,e)),e.bind(),this._plugins.render(2,3)}const t=this._framebuffer;this._renderTerrainDepth(),t.update(t=>this._renderNodes(x.OPAQUE,t,e)),this.fboCache.debugCallback?.(x.OPAQUE,t.color.fbo),t.update(e=>this._renderNodes(A.OPAQUE_ENVIRONMENT,e)),this.fboCache.debugCallback?.(A.OPAQUE_ENVIRONMENT,t.color.fbo),this._renderEdges(1)}_renderTransparent(e){const t=this._framebuffer;t.bind(),this._renderPlugins(22,ne.VOXEL),t.update(e=>this._renderNodes(A.GAUSSIAN_SPLAT,e)),this.fboCache.debugCallback?.(A.GAUSSIAN_SPLAT,t.color.fbo),this._renderHiddenTransparentEdges(),e&&(this.oitEnabled?this._renderOIT(0):this._renderTransparentGeometry()),t.update(t=>this._renderNodes(x.TRANSPARENT,t,e)),this.fboCache.debugCallback?.(x.TRANSPARENT,t.color.fbo),this._renderGeometryDepth(),this._renderHUDVisibility(),this._needsTerrainDepth||this._oitCallouts||this._plugins.render(17),this._renderEdges(0);const s=this._renderPhotoshopTerrain(),r=s?.getTexture();r&&(this._bindParameters.hudVisibility&&(this._needsTerrainDepth?this._renderLineCallouts(0):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositor.compositeHUD(this._bindParameters,r))),this._renderHUD(0,t.color)),this._bindParameters.cullAboveTerrain=!1,r&&(t.bind(),this._compositor.compositePreMultipliedAlpha(this._bindParameters,r),s?.release(),this._needsTerrainDepth&&(this._renderEdges(1),e&&(this.oitEnabled?this._renderOIT(0):this._renderTransparentGeometry(),this.performanceInfo.advance(ne.TRANSPARENT)),this._renderEdges(0))),this._bindParameters.ssao=a(this._bindParameters.ssao),this._needsTerrainDepth&&this._renderLineCallouts(1),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(ne.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(9),this.performanceInfo.advance(ne.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderPlugins(e,t){this._plugins.produces(this._renderContext.output,e)&&(this._plugins.render(e),this.performanceInfo.advance(t))}_renderNodes(e,t,s=!1){const r=t.name;if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return s&&this.performanceInfo.advance(e),t;this._fboCache.debugCallback?.(r,t.fbo);const i=this._nodes.render(t,this._pluginInput,this._releaseNodeInputs);return this.performanceInfo.advance(e),i}_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=b:(f(Te,this._bindParameters.camera.viewMatrix),f(Ee,this._bindParameters.camera.projectionMatrix),g(xe,Te,Ee),g(xe,this._renderContext.lastFrameCamera.viewMatrix,xe),g(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=b,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,s,r){this._bindParameters.updateLighting(e,t,s,r),this._requestRender(1)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}_renderToTargets(e,t,s,r,i=!1,n=!1){t.attachDepth(s),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(r,i,n),e(),t.detachDepth()}get test(){}};e([p({readOnly:!0})],_e.prototype,"highResolutionAtmosphere",null),e([p()],_e.prototype,"_edgeView",void 0),e([p()],_e.prototype,"updating",null),_e=e([m("esri.views.3d.webgl-engine.lib.Renderer")],_e);const le=[0,1,2,3],ue=[7,8,4,5],pe=[6,7,8],me=[0,1,2,4,...pe],ce=[3,5],fe=[2,4,9],ge=[18,14,16,15],be=[4,5,2,3,0,1,...pe],Pe=[4,9,5,12],Ce={0:[15],1:[14],2:[15,14],3:[15,14]},we=["normals","highlights"],Ee=P(),Te=P(),xe=P();function Ae(e){return t=>e.immediate.schedule(t)}export{_e as Renderer};
2
+ import{__decorate as e}from"tslib";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import{removeMaybe as s,abortMaybe as i,destroyMaybe as n,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAborted as h}from"../../../../core/promiseUtils.js";import{watch as o,syncAndInitial as d,initial as _,sync as l}from"../../../../core/reactiveUtils.js";import{signal as u}from"../../../../core/signal.js";import{property as p,subclass as m}from"../../../../core/accessorSupport/decorators.js";import{equals as c,invert as f,multiply as g}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as b,create as P}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as C}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as w,ZEROS as E}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as T}from"../../../../geometry/support/Indices.js";import{RenderNodeOutput as x,InternalRenderCategory as A,AllRenderNodeOutputs as D,AllInternalRenderNodeOutputs as S}from"../../webgl.js";import{innerAtmosphereFadeStart as R}from"../../environment/atmosphereUtils.js";import{minNearDistanceInMeters as I}from"../../state/NearFarHeuristic.js";import{debugFlags as y}from"../../support/debugFlags.js";import{FBOCache as O}from"../core/FBOCache.js";import{RenderPassManager as H}from"../core/renderPasses/RenderPassManager.js";import{isColor as v}from"../core/shaderLibrary/ShaderOutput.js";import{distanceFadeEnd as F}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as M}from"../effects/RenderNodes.js";import{RenderPluginManager as N}from"../effects/RenderPluginManager.js";import{Blit as q}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as G,renderHighlightBuffer as L}from"../effects/highlight/Highlight.js";import{OITBlend as U}from"../effects/transparency/OITBlend.js";import{AnimationTimer as V}from"./AnimationTimer.js";import{AnimationTimeStep as j}from"./AnimationTimeStep.js";import{BoundingInfo as B}from"./BoundingInfo.js";import{Compositor as k}from"./Compositor.js";import{DepthRange as z}from"./DepthRange.js";import{depthRangeFromScene as W}from"./depthRangeUtils.js";import{MainFramebuffer as Q}from"./MainFramebuffer.js";import{RenderContext as Y,defaultRenderOccludedMask as J}from"./RenderContext.js";import{RendererBase as K}from"./RendererBase.js";import{setupFeatureDefaults as X}from"./RenderFeature.js";import{RenderPluginInput as Z}from"./RenderPluginInput.js";import{ShadowAccumulator as $}from"./ShadowAccumulator.js";import{ShadowMap as ee}from"./ShadowMap.js";import te from"./SliceHelper.js";import{MergedRenderer as re}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as se}from"../parts/renderUtils.js";import{RendererPerformanceInfo as ie,PerformanceCategory as ne}from"../statistics/RendererPerformanceInfo.js";import{PixelType as ae,ColorAttachment1 as he,ColorAttachment2 as oe,ColorAttachment0 as de}from"../../../webgl/enums.js";let _e=class extends K{constructor(e,t,r,s,i){super({stage:e}),this._techniques=r,this._rctx=s,this._requestRender=i,this._pluginsHas={occludedHudElements:!1,hudElements:!1,water:!1},this.renderPassManager=new H,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=w(0,0,0,1),this._sliceHelper=new te,this.sceneDepthRange=u(z.Infinite),this._state=u(2),this._hasAnimations=!1,this._animationTimestep=new j,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=u(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new Z,this._oitCallouts=!1,this._releaseNodeInputs=e=>{for(const t of we)e.some(({name:e})=>e===t)&&this._pluginInput.release(t)},this._debugNeedsDepth=!1,this._fboCache=new O(s),this._compositor=new k(s,r),this._renderStateFeatures=u(X(e.view.qualityProfile)),this._framebuffer=new Q(this.fboCache),this._performanceInfo=new ie(this._rctx),this._shadowMap=new ee(this.fboCache,e.viewingMode),this._blit=new q(r),this._shadowAccumulator=new $(this.fboCache,r,e,e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t},(t,r,s)=>{const i=e.view.qualitySettings.maximumPixelRatio;t.shadowMap.start(t.camera,r,s,!0,i),this._renderShadowCascades(3,t.shadowMap),t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.contentCamera)},i),this._renderContext=new Y(this._rctx,this._shadowMap,r),this._nodes=new M(this._renderContext),this._plugins=new N({renderContext:this._renderContext,techniques:r,materials:t,requestRender:i,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this.addHandles([o(()=>e.view.state.camera,()=>i(),d),o(()=>y.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES,e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(0):()=>{},i()},_),o(()=>e.view.environment.background?.color,e=>{const t=e?e.toUnitRGBA():E;C(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),i()},d),o(()=>e.view.state.camera.relativeElevation,e=>this._inGlobeView=(e??1/0)>=F,d),o(()=>this._bindParameters.clouds.fadeFactor,()=>{this._bindParameters.fadeLighting(),this._requestRender(2)},l),o(()=>this._bindParameters.clouds.data?.state,()=>i(),l),o(()=>e.view.state.highlights,e=>{this._bindParameters.highlights=e,i()},_)])}destroy(){this._gpuTimerHandle=s(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.destroy(),this._shadowAccumulator=null,this._loadEdgeViewTask=i(this._loadEdgeViewTask),this._edgeView=n(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this._fboCache.destroy(),this._fboCache=null,this._plugins.destroy(),this._plugins=null,this._pluginInput=null,this._oitBlendOrNil=null,this._nodes=null,this._framebuffer=null,this._shadowMap=null,this._renderContext=null,this._performanceInfo=null,B.prune(),re.prune(),T()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _oitBlend(){return this._oitBlendOrNil??=new U(this._techniques),this._oitBlendOrNil}get performanceInfo(){return this._performanceInfo}updateRenderFeatures(e){this._renderStateFeatures.value=X(e),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.isFeatureEnabled(1)}get hasReflections(){return this._pluginsHas.water&&this.isFeatureEnabled(6)}get _hasHighlights(){return this._plugins.produces(8,2,4,20,14,15,16)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(8,14,15,16)}get hasSSAO(){return this.isFeatureEnabled(5)&&!this._inGlobeView}get hasSMAA(){return this.isFeatureEnabled(0)}get _hasEmission(){return this._plugins.hasEmitters&&this._hasFloatBufferBlendSupport}get highResolutionAtmosphere(){return this.isFeatureEnabled(4)}get fboCache(){return this._fboCache}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=a(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=a(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=a(this._bindParameters.geometryDepth),this._bindParameters.hudOcclusion=a(this._bindParameters.hudOcclusion)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOutputs(),this._bindParameters.depth=a(this._bindParameters.depth),this._bindParameters.hudVisibility=a(this._bindParameters.hudVisibility)}get updating(){return this._loadEdgeViewTask&&!this._loadEdgeViewTask.finished||this._edgeView?.updating||this._shadowAccumulator.readyToRun||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=r(async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");h(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this.stage.view.renderSpatialReference,viewingMode:this.stage.view.stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:Ae(this.stage.view.resourceController)});return this.addHandles(o(()=>r.updating,()=>this._requestRender(),l)),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&&c(this._bindParameters.ssr.reprojectionMatrix,b)}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.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()),e.environment){void 0!==e.environment.weather&&(this._bindParameters.weather=e.environment.weather);const t="virtual"!==e.environment.lighting.type;r.enableFillLights!==t&&(r.enableFillLights=t,this._requestRender())}e.shadowCast&&this._shadowAccumulator.setParameters(e.shadowCast)}set slice(e){this._sliceHelper.update(e)&&this._requestRender()}get plugins(){return this._plugins}get _hasFloatBufferBlendSupport(){return this._rctx.driverTest.floatBufferBlend.result}get oitEnabled(){return this.isFeatureEnabled(2)&&this._hasFloatBufferBlendSupport}commit(e,t){return this._isRendering&&console.warn("Renderer.modify called while rendering"),!!super.commit(e,t,this._plugins.context)&&(this.updateHasFlags(),!0)}rendererAdded(e){this._plugins.add(e)}rendererRemoved(e){this._plugins.remove(e)}get occludedRequiresStencil(){return this.occludedRequiresOccludeeStencil||this.occludedRequiresIntegratedMeshStencil}get occludedRequiresOccludeeStencil(){return this._bindParameters.hasOccludees&&!!(8&this.plugins.renderOccludedFlags)}get occludedRequiresIntegratedMeshStencil(){return this._plugins.produces(0,0)&&this._plugins.produces(0,10)}updateHasFlags(){const has=this._pluginsHas;has.occludedHudElements=this._plugins.produces(0,15),has.hudElements=has.occludedHudElements||this._plugins.produces(0,...ge),has.water=this._plugins.produces(2,21),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new V(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const r=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?s(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,s=!1){try{return this._isRendering=!0,this._render(e,t,r,s)}catch(i){console.error(`Exception during rendering: ${i}`)}finally{this._isRendering=!1}return new se(this._pluginInput.get(x.FINAL),null)}_render(e,t,r,s){const i=0===r;this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=i,this._disposeBindBuffers();const{camera:n,contentCamera:a,mode:h,alignPixelEnabled:o}=e;this._state.value=h,this._renderContext.time=t,this._renderContext.output=0,this._bindParameters.hasEmission=this._hasEmission,this._bindParameters.oitPass=0,this._bindParameters.alignPixelEnabled=o,this._bindParameters.decorations=!s,this._bindParameters.mainDepth=null;const d=!s||!this._sliceHelper.isDecoration;this._bindParameters.slicePlane=d?this._sliceHelper.plane:null,this._bindParameters.viewshedEnabled=this._nodes.produces(A.VIEWSHED),this._bindParameters.cutFillEnabled=this._nodes.produces(A.CUTFILL_DEPTH),this._renderOverlay(),n.setGLViewport(this._rctx);const _=this._framebuffer,l=_.initialize(n.fullWidth,n.fullHeight,this._backgroundColor,this._bindParameters.hasEmission);this.hasReflections?(l?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=l):l?.release(),this._ensureBindParametersCamera(n,a),this._plugins.sortTestsTransparentOrderedSlots(Pe),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!s;const u=this._plugins.produces(0,...ue);this._precompilePrepasses(),this.performanceInfo.advance(ne.PREPARE);const p=this._computeShadowDepthRange(n);this._renderShadowMap(n,this._bindParameters.lighting.mainLight.direction,p),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(p,!i),this._oitCallouts=u&&this.oitEnabled,this._ensureBindParametersSSR(t),this._precompileShaders(u),this._renderContext.output=0,_.bind(),this._bindParameters.mainDepth=_.depth.attachment,this._renderOpaque(),this._renderTransparent(u),this._shadowMap.disposeOutput(3),this._pluginInput.set(A.FOCUSAREA,this._renderFocusAreaGeometry()),this._pluginInput.set(A.CUTFILL_DEPTH,this._renderCutFillDepth()),_.update(e=>this._renderNodes(A.TRANSPARENT_ENVIRONMENT,e)),_.update(e=>this._renderNodes(A.VIEWSHED,e)),_.update(e=>this._renderNodes(A.LASERLINES,e)),_.update(e=>this._renderNodes(A.FOCUSAREA_COLOR,e)),this._pluginInput.release(A.FOCUSAREA),this._pluginInput.release(A.CUTFILL_DEPTH),_.update(e=>this._renderNodes(A.OCCLUDED,e)),this._pluginInput.set("highlights",this._renderHighlightPrepass());const m=2===r?this._renderObjectAndLayerIdColor():null;_.update(e=>this._renderNodes(x.COMPOSITE,e)),this._shadowMap.disposeOutputs(),_.update(e=>this._renderNodes(A.ANTIALIASING,e));const c=this._hasPhotoshopTerrain||!u?1:2;let f;return this._bindParameters.hasEmission=!1,this._hasHUDHighlights&&_.update(e=>this._renderHUD(c,e)),_.update(e=>this._renderNodes(A.HIGHLIGHT_COLOR,e)),this._hasHUDHighlights||_.update(e=>this._renderHUD(c,e)),this._bindParameters.hasEmission=this._hasEmission,_.update(e=>this._renderNodes(A.MAGNIFIER,e)),_.update(e=>this._renderNodes(x.FINAL,e)),i&&this._blit.toFramebuffer(this._rctx,_.color,this._bindParameters),this.onPostRender?.(),this._releaseFBOs(),_.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),i||(f=_.color,f.retain(),this._releaseFBOs(),this._disposeOffscreenBuffers()),this.performanceInfo.finishFrame(),new se(f,m)}_precompileShaders(e){++this._plugins.context.techniques.precompiling,this._renderContext.output=0;const t=this._bindParameters.hasEmission;this._precompileOpaqueGeometry(),this._nodes.precompile(t,A.OPAQUE_ENVIRONMENT),this._nodes.precompile(t,A.GAUSSIAN_SPLAT);const r=this._bindParameters;r.terrainDepthTest=r.cullAboveTerrain=this._needsTerrainDepth,this._renderContext.output=1,this._plugins.precompile(...pe),this._needsTerrainDepth&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._renderContext.output=0,this._plugins.precompile(...pe);const s=this._pluginsHas.hudElements&&this.oitEnabled,i=this._pluginsHas.occludedHudElements;this._oitBlend.precompile(t,i,s),s&&this._oitBlend.precompile(!1,i,s),e&&(this._precompileTransparentGeometry(),this._hasPhotoshopTerrain&&(r.cullAboveTerrain=!1,this._precompileTransparentGeometry(),r.cullAboveTerrain=this._needsTerrainDepth)),this._nodes.precompile(t,A.FOCUSAREA);const n=this._hasPhotoshopTerrain&&!this._needsTerrainDepth;this._compositor.precompile(this._usesPremultipliedAlphaBlit,!!this._needsEdges,n,t),this._needsHUDVisibility&&this._plugins.precompile(13),this._oitCallouts||this._plugins.precompile(17),this._precompileHUD(0),r.terrainDepthTest=r.cullAboveTerrain=!1,this._nodes.precompile(t,A.TRANSPARENT_ENVIRONMENT,A.VIEWSHED,A.CUTFILL_DEPTH,A.CUTFILL_COLOR,A.LASERLINES,A.FOCUSAREA_COLOR,A.OCCLUDED,A.ANTIALIASING,A.HIGHLIGHT_COLOR),r.highlightMixTexture=r.highlights.length>1?this._rctx.emptyTexture:null,r.hasEmission=!1,this._precompileHUD(1),this.oitEnabled&&this._precompileHUD(0),r.hasEmission=this._hasEmission,this._hasHighlights&&(r.highlights.forEach((e,t)=>{r.highlightLevel=t,this._precompileAllGeometry(8),this._hasHUDHighlights&&this._plugins.precompile(15,14)}),r.highlightLevel=null,this._nodes.precompile(t,A.HIGHLIGHT_COLOR)),r.highlightMixTexture=null,this._nodes.precompile(t,x.COMPOSITE,A.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(9),--this._plugins.context.techniques.precompiling}_renderFocusAreaGeometry(){const e=this._nodes.produce(A.FOCUSAREA,this._pluginInput);return e&&this.performanceInfo.advance(ne.FOCUS_AREA_MASK),e}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._renderContext.output;++this._techniques.precompiling;const{width:t,height:r}=this._framebuffer.size;let s=this.fboCache.acquire(t,r,"olid");return s.acquireDepth(13),s=this._nodes.render(s,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(ne.OBJECT_AND_LAYER_ID_COLOR),this._renderContext.output=e,s}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=0===e;if(r||t){const e=r?this.performanceInfo.elapsedTime:0;let s=0;t?s=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const i=Math.max(e,s);this._animationTimestep.frame(i,r)}}readMainDepth(e,t){const{mainDepth:r,camera:s}=this._bindParameters;if(!r)return;const i=this.fboCache.acquire(this._framebuffer.size.width,this._framebuffer.size.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(E),this._compositor.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],6408,ae.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,t,r,s,i){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,s,6408,ae.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}get _needsEdges(){return this._edgeView?.shouldRender()?this._edgeView:null}_renderEdges(e){const t=this._needsEdges;if(!t)return;const{width:r,height:s}=this._framebuffer.size,i=this.fboCache.acquire(r,s,"edges"),n=this._bindParameters.geometryDepth,a=()=>t.render(this._bindParameters,e);this._renderToTargets(a,i,n??this._framebuffer.depth,E),this._framebuffer.bind(),this._compositor.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(1===e?ne.OPAQUE_EDGES:ne.TRANSPARENT_EDGES)}_renderOverlay(){this._bindParameters.overlay=this.overlay?.render(this._renderContext.time),this._bindParameters.overlay&&this.performanceInfo.advance(ne.OVERLAY)}_renderShadowMap(e,t,r){if(!this.shadowsEnabled)return;const s=this._shadowMap;s.start(e,t,r,this.isFeatureEnabled(7),this.stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(5,this._shadowMap),s.clear(),this._renderShadowCascades(4,this._shadowMap)):this._renderShadowCascades(3),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,this._bindParameters.contentCamera),this.performanceInfo.advance(ne.SHADOW_MAP)}_renderCutFillDepth(){return this._nodes.produce(A.CUTFILL_DEPTH,this._pluginInput)}_precompileShadowCascades(e){0!==this._shadowMap.cascades.length&&this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){t.bindFramebuffer();for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e);t.finish(e)}get _needsDepth(){return this._plugins.consumes(1)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._shadowAccumulator.active||this._debugNeedsDepth}get _usesPremultipliedAlphaBlit(){return this._pluginsHas.hudElements&&this.oitEnabled||this._hasPhotoshopTerrain}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");e?(this._pluginInput.set(A.SSAO,this._renderSSAO()),this._needsDepth?(this._rctx.bindFramebuffer(e.fbo),this._rctx.clear(1024),this._renderGeometryWithoutNormals(1),this._bindParameters.depth?.release(),this._bindParameters.depth=e.obtainDepthTexture(),this.performanceInfo.advance(ne.DEPTH)):(e.detachDepth(),this._bindParameters.depth=a(this._bindParameters.depth)),this.hasSSAO&&this._pluginInput.release("normals")):this._renderAllGeometryDepth()}_renderAllGeometryDepth(){if(this._bindParameters.depth=a(this._bindParameters.depth),!this._needsDepth)return;const{width:e,height:t}=this._framebuffer.size,r=this.fboCache.acquire(e,t,"geometry depth",13);this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(1280),this.renderAllGeometry(1),this._bindParameters.depth=r.obtainDepthTexture(),r.release(),this.performanceInfo.advance(ne.DEPTH)}_renderTerrainDepth(){if(this._bindParameters.terrainDepth=a(this._bindParameters.terrainDepth),this._bindParameters.terrainDepthTest=this._bindParameters.cullAboveTerrain=this._needsTerrainDepth,!this._needsTerrainDepth)return;const e=this._renderContext.output;this._renderContext.output=1;const{width:t,height:r}=this._framebuffer.size,s=this.fboCache.acquire(t,r,"terrain depth",13);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(1280),this._renderTransparentGround(),this._bindParameters.terrainDepth=s.obtainDepthTexture(),s.release(),this._renderContext.output=e}_renderGeometryDepth(){if(this._bindParameters.geometryDepth=a(this._bindParameters.geometryDepth),!this._needsTerrainDepth)return;const e=this._renderContext.output,{width:t,height:r}=this._framebuffer.size,s=this.fboCache.acquire(t,r,"geometry depth",13);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(1280),this._renderOpaqueAndTransparentGeometry(1),this._renderContext.output=e,this._bindParameters.geometryDepth=s.obtainDepthTexture(),s.release()}get _needsShadowDepthRange(){return this._shadowMap.enabled||this._shadowAccumulator.active}_computeShadowDepthRange(e){if(!this._needsShadowDepthRange)return z.Zero;const t=W(e,this._plugins.plugins,this.stage.layers,0);return t.union(this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}updateSceneDepthRange(e){if(!this.stage.view.state.isGlobal)return void(this.sceneDepthRange.value=z.Infinite);if((this.stage.view.renderCoordsHelper?.getAltitude(e.eye)??0)<R)return void(this.sceneDepthRange.value=z.Infinite);const t=e.clone();t.near=I,t.far=1e10;const r=W(t,this._plugins.plugins,this.stage.layers,1);r.union(this._plugins.queryDepthRange(t)),this.sceneDepthRange.value.equals(r)||(this.sceneDepthRange.value=r)}get _normalsRequired(){const e=this._nodes.require("normals",...D,A.VIEWSHED,A.LASERLINES);return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(2),this._needsDepth&&this._precompileAllGeometry(1),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(4),this._precompileShadowCascades(5)):this._precompileShadowCascades(3)),this._shadowAccumulator.active&&this._precompileAllGeometry(3),this.hasSSAO&&this._normalsRequired&&this._nodes.precompile(this._bindParameters.hasEmission,A.SSAO)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const{width:t,height:r}=this._framebuffer.size,s=this.fboCache.acquire(t,r,"normals",5);s.acquireDepth(13),this._rctx.bindFramebuffer(s.fbo),this._rctx.clearFramebuffer(E,!0,!0),this._renderContext.output=2,this._plugins.render(...me);const i=this._nodes.optional("normals",...D,A.VIEWSHED);return s.retain(e+i-1),this.performanceInfo.advance(ne.NORMALS),s}_renderSSAO(){const e=this._pluginInput.get("normals");if(this.hasSSAO&&e)return this._bindParameters.ssao=this._nodes.produce(A.SSAO,this._pluginInput),this._bindParameters.ssao&&this.performanceInfo.advance(ne.SSAO),this._bindParameters.ssao}_precompileAllGeometry(e){const t=this._renderContext.output;this._renderContext.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(...pe),this._renderContext.output=t}renderAllGeometry(e){this._renderContext.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentGround()}precompileSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const r of t)this._renderContext.renderOccludedMask=r,this.precompileSlots(e,...fe);this._renderContext.renderOccludedMask=J}renderSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.forAll(e=>{const t=e.acquireTechniques(this._renderContext);t&&e.render(this._renderContext,t)})}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>1&&this._plugins.render(10),this.renderSlots(e,...fe),this._renderContext.renderOccludedMask=J}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(...Ce[e])}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(18),this.renderHUD(e),this._bindParameters.hudRenderStyle=e,this._plugins.render(16)}precompileViewshedShadowMap(){this._precompileAllGeometry(6)}precompileCutFill(){const e=7,t=this._renderContext.output;this._renderContext.output=e,this._plugins.precompile(0,1,...pe),this._renderContext.output=t}renderViewshedShadowMap(e){const{camera:t,contentCamera:r}=this._bindParameters,s=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(6),this._ensureBindParametersCamera(t,r),this._bindParameters.camera.setGLViewport(this._rctx),this._renderContext.output=s}renderCutFillReferenceDepth(e){const{camera:t,contentCamera:r}=this._bindParameters,s=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this._renderContext.output=7,this._plugins.render(0,1,...pe),this._ensureBindParametersCamera(t,r),t.setGLViewport(this._rctx),this._renderContext.output=s}_renderOpaqueAndTransparentGeometry(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithoutNormals(e){this._renderContext.output=e,this._plugins.render(...ce)}_precompileOpaqueGeometry(){this._plugins.precompile(...le),this._nodes.precompile(this._bindParameters.hasEmission,"opaque-color")}_renderOpaqueGeometry(){this._plugins.render(...le)}_renderTransparentGeometry(){this._plugins.render(...ue),this._oitCallouts&&this._plugins.render(17)}get _hasPhotoshopTerrain(){return this._plugins.produces(0,6)}get _needsTerrainDepth(){return this._highQualityTransparency&&this._hasPhotoshopTerrain}_renderPhotoshopTerrain(){if(!this._hasPhotoshopTerrain)return null;const{width:e,height:t}=this._framebuffer.size,r=this.fboCache.acquire(e,t,"transparent terrain"),s=()=>this._plugins.render(6);return this._renderToTargets(s,r,this._framebuffer.depth,E),this.performanceInfo.advance(ne.TRANSPARENT_TERRAIN),r}_renderTransparentGround(){this._plugins.render(...pe)}get _needsHUDVisibility(){return this._plugins.produces(this._renderContext.output,13)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=a(this._bindParameters.hudVisibility));const{width:e,height:t}=this._framebuffer.size;let r=this._bindParameters.hudVisibility;r?.fbo?.width===e&&r?.fbo?.height===t||(r?.release(),r=this.fboCache.acquire(e,t,"hud visibility",4),this._bindParameters.hudVisibility=r);const s=this._bindParameters.geometryDepth;r.attachDepth(s||this._framebuffer.depth),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(13),r.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(ne.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,0===e){const e=()=>this._plugins.render(17),{width:t,height:r}=this._framebuffer.size,s=this.fboCache.acquireDepth(12,t,r,"line callouts");this._renderToTargets(e,this._framebuffer.color,s,void 0,!0,!0),s.release()}else this._plugins.render(17)}_precompileHUD(e){if(this._pluginsHas.hudElements&&(this._precompileHUDOutput(e),this._hasHighlights)){const t=this._renderContext.output;this._renderContext.output=8,this._precompileHUDOutput(e),this._renderContext.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this.oitEnabled&&v(this._renderContext.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...ge),this._bindParameters.oitPass=2,this._plugins.precompile(...ge),this._bindParameters.oitPass=0):this._plugins.precompile(...ge),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t){if(!this._pluginsHas.hudElements)return t;if(this.oitEnabled){const r=this._renderOIT(1,e);this._rctx.bindFramebuffer(t.fbo),this._compositor.compositePreMultipliedAlpha(this._bindParameters,r.getTexture(),!1),r.release()}else if(this._renderContext.output=0,0===e){const t=()=>this._renderHUDElements(e),{width:r,height:s}=this._framebuffer.size,i=this.fboCache.acquireDepth(12,r,s,"hud");this._renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(12),this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(256),this._renderHUDElements(e),t.detachDepth();return this.performanceInfo.advance(0===e?ne.HUD_OCCLUDED:ne.HUD),t}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(4,2)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:r}=this,{width:s,height:i}=this._framebuffer.size,{highlights:n}=r,a=n.length>G?3:1,h=e.acquire(s,i,"highlights",a);h.acquireDepth(13);const o=this._plugins.produces(8,0);return o&&this._framebuffer.color.fbo&&h.fbo&&t.blitFramebuffer(this._framebuffer.color.fbo,h.fbo,1024),t.bindFramebuffer(h.fbo),t.gl.clearBufferuiv(6144,0,[0,0,0,0]),o||t.clear(1024),this._renderContext.output=8,t.bindFramebuffer(h.fbo),L(t,e,s,i,r,()=>this._renderHighlightGeometries()),h.detachDepth(),this.performanceInfo.advance(ne.HIGHLIGHTS),h.retain(this._nodes.require("highlights",...S)+this._nodes.optional("highlights",...S)-1),h}_renderHighlightGeometries(){this._plugins.render(...be),this._rctx.clear(256),this._renderHUDElements(2)}_renderShadowAccumulation(e,t){this._shadowAccumulator.updateDepthRange(e);const{depth:r,camera:s,contentCamera:i}=this._bindParameters;this._shadowAccumulator.accumulating&&r&&this._shadowAccumulator.renderAccumulation(r,s,i,t)&&this.performanceInfo.advance(ne.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this.oitEnabled&&v(this._renderContext.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...ue),this._oitCallouts&&this._plugins.precompile(17),this._bindParameters.oitPass=2,this._plugins.precompile(...ue),this._oitCallouts&&this._plugins.precompile(17),this._bindParameters.oitPass=0):this._plugins.precompile(...ue)}_renderOIT(e,t=2){const r=1===e,{width:s,height:i}=this._framebuffer.size,n=r?()=>this._renderHUDElements(t):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._renderContext.output;this._renderContext.output=0,h.oitPass=1;const d=r?"oit hud":"oit",_=this.fboCache.acquire(s,i,d,8),l=this._bindParameters.hasEmission&&(0===e||1!==t);l&&_.acquireColor(he,8,"oit emissive");const u=l?oe:he;_.acquireColor(u,7,"oit alpha"),r||_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer([0,0,0,1]),l&&this._rctx.clearBuffer(1,E),n(),_.detachDepth(),h.oitPass=2;const p=this.fboCache.acquire(s,i,r?"oit hud front":"oit front");l&&p.acquireColor(he,8,"oit emissive front"),r?p.acquireDepth(12):p.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(p.fbo),this._rctx.clearFramebuffer(E,r),n(),p.detachDepth();const m=this._pluginsHas.occludedHudElements&&!r;let c;return this._bindParameters.hudOcclusion=a(this._bindParameters.hudOcclusion),h.oitPass=0,r?(c=this.fboCache.acquire(s,i,"oit hud composite"),this._rctx.bindFramebuffer(c.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(16384)):(m&&(this._framebuffer.color.acquireColor(u,0,"hud occlusion"),this._rctx.clearBuffer(u-de,E)),this._framebuffer.bind()),this._oitBlend.blend(this._rctx,_,p,h,l,m,e),c?.detachDepth(),r||(this._rctx.bindFramebuffer(p.fbo),this._framebuffer.bind(),m&&(this._bindParameters.hudOcclusion=this._framebuffer.color.obtainAttachment(u))),p.release(),_.release(),this._renderContext.output=o,c}_renderOpaque(){const e=this.plugins.produces(0,...le);if(e){this._plugins.render(0,1);const e=this._framebuffer;e.update(e=>this._renderNodes(A.CUTFILL_COLOR,e)),e.update(e=>this._renderNodes(A.OPAQUE_TERRAIN,e)),e.bind(),this._plugins.render(2,3)}const t=this._framebuffer;this._renderTerrainDepth(),t.update(t=>this._renderNodes(x.OPAQUE,t,e)),this.fboCache.debugCallback?.(x.OPAQUE,t.color.fbo),t.update(e=>this._renderNodes(A.OPAQUE_ENVIRONMENT,e)),this.fboCache.debugCallback?.(A.OPAQUE_ENVIRONMENT,t.color.fbo),this._renderEdges(1)}_renderTransparent(e){const t=this._framebuffer;t.bind(),this._renderPlugins(22,ne.VOXEL),t.update(e=>this._renderNodes(A.GAUSSIAN_SPLAT,e)),this.fboCache.debugCallback?.(A.GAUSSIAN_SPLAT,t.color.fbo),this._renderHiddenTransparentEdges(),e&&(this.oitEnabled?this._renderOIT(0):this._renderTransparentGeometry()),t.update(t=>this._renderNodes(x.TRANSPARENT,t,e)),this.fboCache.debugCallback?.(x.TRANSPARENT,t.color.fbo),this._renderGeometryDepth(),this._renderHUDVisibility(),this._needsTerrainDepth||this._oitCallouts||this._plugins.render(17),this._renderEdges(0);const r=this._renderPhotoshopTerrain(),s=r?.getTexture();s&&(this._bindParameters.hudVisibility&&(this._needsTerrainDepth?this._renderLineCallouts(0):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositor.compositeHUD(this._bindParameters,s))),this._renderHUD(0,t.color)),this._bindParameters.cullAboveTerrain=!1,s&&(t.bind(),this._compositor.compositePreMultipliedAlpha(this._bindParameters,s),r?.release(),this._needsTerrainDepth&&(this._renderEdges(1),e&&(this.oitEnabled?this._renderOIT(0):this._renderTransparentGeometry(),this.performanceInfo.advance(ne.TRANSPARENT)),this._renderEdges(0))),this._bindParameters.ssao=a(this._bindParameters.ssao),this._needsTerrainDepth&&this._renderLineCallouts(1),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(ne.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(9),this.performanceInfo.advance(ne.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderPlugins(e,t){this._plugins.produces(this._renderContext.output,e)&&(this._plugins.render(e),this.performanceInfo.advance(t))}_renderNodes(e,t,r=!1){const s=t.name;if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;this._fboCache.debugCallback?.(s,t.fbo);const i=this._nodes.render(t,this._pluginInput,this._releaseNodeInputs);return this.performanceInfo.advance(e),i}_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=b:(f(Te,this._bindParameters.camera.viewMatrix),f(Ee,this._bindParameters.camera.projectionMatrix),g(xe,Te,Ee),g(xe,this._renderContext.lastFrameCamera.viewMatrix,xe),g(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=b,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,r,s){this._bindParameters.updateLighting(e,t,r,s),this._requestRender(1)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}_renderToTargets(e,t,r,s,i=!1,n=!1){t.attachDepth(r),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(s,i,n),e(),t.detachDepth()}get test(){}};e([p({readOnly:!0})],_e.prototype,"highResolutionAtmosphere",null),e([p()],_e.prototype,"_edgeView",void 0),e([p()],_e.prototype,"updating",null),_e=e([m("esri.views.3d.webgl-engine.lib.Renderer")],_e);const le=[0,1,2,3],ue=[7,8,4,5],pe=[6,7,8],me=[0,1,2,4,...pe],ce=[3,5],fe=[2,4,9],ge=[18,14,16,15],be=[4,5,2,3,0,1,...pe],Pe=[4,9,5,12],Ce={0:[15],1:[14],2:[15,14],3:[15,14]},we=["normals","highlights"],Ee=P(),Te=P(),xe=P();function Ae(e){return t=>e.immediate.schedule(t)}export{_e as Renderer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../../../../core/Accessor.js";import{sliceEquals as i}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{smoothstep as r}from"../../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../../core/maybe.js";import{watch as o,sync as a}from"../../../../core/reactiveUtils.js";import{signal as n}from"../../../../core/signal.js";import{property as h,subclass as c}from"../../../../core/accessorSupport/decorators.js";import{copy as u,equals as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ReadShadowMapPassParameters as _}from"../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{BindParameters as p}from"./BindParameters.js";import{DepthRange as d}from"./DepthRange.js";import{createQuadVAO as f}from"./glUtil3D.js";import{ShadowCastRenderer as g,shadowCastDisabledElevationThreshold as b,shadowCastDisableElevationMax as v,shadowCastDisableElevationMin as S}from"./ShadowCastRenderer.js";import{ShadowMap as w}from"./ShadowMap.js";import{S as y}from"../../../../chunks/ShadowCastAccumulate.glsl.js";import{ShadowCastAccumulateTechnique as F}from"../shaders/ShadowCastAccumulateTechnique.js";import{ShadowCastAccumulateTechniqueConfiguration as A}from"../shaders/ShadowCastAccumulateTechniqueConfiguration.js";import{ShadowCastClearTechnique as x}from"../shaders/ShadowCastClearTechnique.js";import{TaskPriority as R}from"../../../support/Scheduler.js";import{SizedPixelFormat as C,PixelType as j}from"../../../webgl/enums.js";import{FramebufferObject as q}from"../../../webgl/FramebufferObject.js";import{TextureDescriptor as P}from"../../../webgl/TextureDescriptor.js";let T=class extends e{updateDepthRange(t){this._depthRange.equals(t)||(this._depthRange=t)}constructor(t,e,i,r,s,n){super({}),this.fbos=t,this._techniques=e,this._stage=i,this._prepareForShadowMapPass=r,this._renderToShadowMap=s,this._requestRender=n,this._primarySet=new M(new A(0),()=>this._requestRenderIfEnabled()),this._contextSet=new M(new A(1),()=>this._requestRenderIfEnabled()),this._passParameters=new _,this._depthRange=d.Zero,this._previewing=!1,this._shadowAccumulatorKey=Symbol("shadowAccumulator"),this._rctx=t.rctx,this._bindParameters=new p(this._rctx.emptyTexture,new w(t,i.viewingMode)),this._bindParameters.shadowMap.enabled=!0,this._vao=f(this._rctx),this._accumulationRenderer=new g(e,this._rctx,this,n);const h=this._stage.view.resourceController.scheduler;this.addHandles([h.registerTask(R.SHADOW_ACCUMULATOR,this),o(()=>this._previewing,t=>{t?this._invalidateAccumulationSets():this._requestRenderIfEnabled()},a),o(()=>2===this._numActive,()=>this._numActiveChanged(),a),o(()=>this._depthRange,()=>this._invalidateAccumulationSets(),a),o(()=>this.accumulating&&this.canAccumulate,()=>this._precompile(),{sync:!0,once:!0})],this._shadowAccumulatorKey)}normalizeCtorArgs(){return{}}destroy(){this._disable(),this.removeHandles(this._shadowAccumulatorKey),this._accumulationRenderer=s(this._accumulationRenderer),this._bindParameters.shadowMap.dispose(),this._fbo=s(this._fbo),this._vao=s(this._vao);for(const t of this._accumulationSets())t.destroy();this._contextSet=null,this._primarySet=null,this._bindParameters.destroy()}*_accumulationSets(){yield this._primarySet,yield this._contextSet}get computedSamples(){return[this._primarySet.progress,this._contextSet.progress]}get shadowCastTexture(){return this._fbo?.colorTexture}get accumulating(){return this.active&&this._previewing||this._refining}get _refining(){return this.active&&!this._doneAccumulating&&!this._previewing}get active(){return null!=this._fbo&&[...this._accumulationSets()].some(t=>t.active)}get canAccumulate(){return null!=this._bindParameters.depth&&this._depthRange!==d.Zero&&this._opacityFromElevation>b}get _doneAccumulating(){return[...this._accumulationSets()].every(t=>t.doneAccumulating)}get _opacityFromElevation(){return this._accumulationRenderer.opacityFromElevation}set _opacityFromElevation(t){this._accumulationRenderer.opacityFromElevation=t}get _numActive(){return[...this._accumulationSets()].reduce((t,e)=>t+(e.active?1:0),0)}get _pixelFormat(){return 2===this._numActive?{pixelFormat:33319,internalFormat:C.RG8}:{pixelFormat:6403,internalFormat:C.R8}}get readyToRun(){return this._refining&&this.canAccumulate&&[...this._accumulationSets()].some(t=>t.running)}_precompile(){for(const t of this._accumulationSets())this._techniques.precompile(F,t.configuration),this._techniques.precompile(x,t.configuration)}runTask(t){this._clearBuffersOnAccumulationStart(),this._prepareForShadowMapPass(this._bindParameters);let e=!1;for(const i of this._accumulationSets())this._runTaskForSet(i,t)&&(e=!0);e&&this._requestRender()}_runTaskForSet(t,e){let i=!1;for(;!e.done&&!t.doneAccumulating;)this._accumulateShadow(t),e.madeProgress(),i=!0;return i}renderAccumulation(t,e,i,r){return this._updateCamera(e),this._bindParameters.contentCamera=i,this._bindParameters.depth=t,this._passParameters.origin=this._bindParameters.camera.center,this.notifyChange("canAccumulate"),!(!this.accumulating||!this.canAccumulate)&&(this._previewing||r?(this._clearFramebuffer(),this._reset()):this._clearBuffersOnAccumulationStart(),this._accumulateSetsForRenderFrame(r))}_clearBuffersOnAccumulationStart(){if([...this._accumulationSets()].every(t=>0===t.progress))this._clearFramebuffer();else for(const t of this._accumulationSets())0===t.progress&&this._clearFramebufferForSet(this._fbo,t)}_accumulateSetsForRenderFrame(t){let e=!1;for(const i of this._accumulationSets())this._accumulateSetForRenderFrame(i,t)&&(e=!0);return e&&this._requestRender(),e}_accumulateSetForRenderFrame(t,e){let i=e?t.sampleCount:Math.min(D,t.sampleCount);i-=t.progress;for(let r=0;r<i;++r)this._accumulateShadow(t);return i>0}precompile(){this._accumulationRenderer.precompile()}render(t){this._accumulationRenderer.render(t)}setOptions(t){void 0!==t.previewing&&(this._previewing=t.previewing),void 0!==t.lightDirections&&(this._primarySet.lightDirections=t.lightDirections),void 0!==t.lightDirectionsContext&&(this._contextSet.lightDirections=t.lightDirectionsContext),!0===t.enabled?this._enable():!1===t.enabled&&this._disable(),this._accumulationRenderer.setOptions(t)}readAccumulatedShadow(t,e){const i=this._primarySet.progress;return!this.active||!this._fbo||i<1||t<0||t>=this._fbo.width||e<0||e>=this._fbo.height?0:(this._fbo.readPixels(t,e,1,1,6408,j.UNSIGNED_BYTE,E),E[0]/i)}_numActiveChanged(){if(!this._fbo)return;const t=2===this._numActive,e=this._createFBO();e.resize(this._fbo.width,this._fbo.height),t&&(this._clearFramebuffer(e),this._contextSet.reset()),this._fbo.width&&this._fbo.height&&this._rctx.blitFramebuffer(this._fbo,e),this._fbo.dispose(),this._fbo=e,this._requestRender()}_enable(){this._fbo||(this._fbo=this._createFBO(),this._invalidateAccumulationSets())}_createFBO(){const{pixelFormat:t,internalFormat:e}=this._pixelFormat,i=new P;return i.pixelFormat=t,i.internalFormat=e,i.wrapMode=33071,new q(this._rctx,i)}_invalidateAccumulationSets(){for(const t of this._accumulationSets())t.reset();this._requestRenderIfEnabled()}_disable(){this._fbo&&(this._fbo=s(this._fbo),this._requestRender())}_reset(){for(const t of this._accumulationSets())t.reset()}_clearFramebuffer(t=this._fbo){t&&t.width&&t.height&&(this._rctx.bindFramebuffer(t),this._rctx.setClearColor(0,0,0,0),this._rctx.clear(16384))}_clearFramebufferForSet(t,e){if(!t)return;const i=this._techniques.get(x,e.configuration);this._rctx.bindFramebuffer(t),this._rctx.bindTechnique(i,this._bindParameters,this._passParameters),this._rctx.bindVAO(this._vao),this._rctx.drawArrays(i.primitiveType,0,this._vao.vertexCount("geometry"))}_accumulateShadow(t){this._renderToShadowMap(this._bindParameters,t.lightDirections[t.progress++],this._depthRange);const e=this._techniques.get(F,t.configuration);this._rctx.bindFramebuffer(this._fbo),this._rctx.bindTechnique(e,this._bindParameters,this._passParameters),this._rctx.bindVAO(this._vao),this._rctx.drawArrays(e.primitiveType,0,this._vao.vertexCount("geometry"))}_updateCamera(t){const e=this._fbo;if(null==e)return;const i=this._bindParameters.camera;t.equals(i)||i.copyFrom(t),e.resize(t.fullWidth,t.fullHeight),this._opacityFromElevation=1-r(S,v,t.relativeElevation)}_requestRenderIfEnabled(){this._fbo&&this._requestRender()}get test(){}};t([h()],T.prototype,"_fbo",void 0),t([h()],T.prototype,"_depthRange",void 0),t([h()],T.prototype,"_previewing",void 0),t([h()],T.prototype,"_accumulationRenderer",void 0),t([h()],T.prototype,"_refining",null),t([h()],T.prototype,"active",null),t([h()],T.prototype,"canAccumulate",null),t([h()],T.prototype,"_doneAccumulating",null),t([h()],T.prototype,"_opacityFromElevation",null),t([h()],T.prototype,"_numActive",null),t([h()],T.prototype,"_pixelFormat",null),t([h()],T.prototype,"readyToRun",null),T=t([c("esri.views.3d.webgl-engine.lib.ShadowAccumulator")],T);const D=6,E=new Uint8Array(4);class M{constructor(t,e){this.configuration=t,this._notifyChange=e,this._cachedLightDirections=[],this._progress=n(0),this._sampleCount=n(0)}get progress(){return this._progress.value}set progress(t){this._progress.value=t}get sampleCount(){return this._sampleCount.value}get doneAccumulating(){return this.progress>=this.sampleCount}get running(){return this.progress>0}get active(){return this.sampleCount>0}get lightDirections(){return this._cachedLightDirections}set lightDirections(t){const e=this._cachedLightDirections,r=Math.min(y,t.length);if(!i(e,0,e.length,t,0,r,l)){e.length=r,this._sampleCount.value=r;for(let i=0;i<r;++i)e[i]=u(e[i]??m(),t[i]);this.reset(),this._notifyChange()}}destroy(){this._cachedLightDirections.length=0,this._sampleCount.value=0}reset(){this.progress=0}precompile(t){t.precompile(F,this.configuration),t.precompile(x,this.configuration)}}export{T as ShadowAccumulator};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{sliceEquals as i}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{smoothstep as r}from"../../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../../core/maybe.js";import{watch as a,sync as o}from"../../../../core/reactiveUtils.js";import{signal as n}from"../../../../core/signal.js";import{property as h,subclass as c}from"../../../../core/accessorSupport/decorators.js";import{copy as u,equals as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ReadShadowMapPassParameters as m}from"../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{BindParameters as d}from"./BindParameters.js";import{DepthRange as p}from"./DepthRange.js";import{createQuadVAO as f}from"./glUtil3D.js";import{ShadowCastRenderer as g,shadowCastDisabledElevationThreshold as b,shadowCastDisableElevationMax as v,shadowCastDisableElevationMin as S}from"./ShadowCastRenderer.js";import{ShadowMap as y}from"./ShadowMap.js";import{S as w}from"../../../../chunks/ShadowCastAccumulate.glsl.js";import{ShadowCastAccumulateTechnique as A}from"../shaders/ShadowCastAccumulateTechnique.js";import{ShadowCastAccumulateTechniqueConfiguration as F}from"../shaders/ShadowCastAccumulateTechniqueConfiguration.js";import{ShadowCastClearTechnique as R}from"../shaders/ShadowCastClearTechnique.js";import{TaskPriority as x}from"../../../support/Scheduler.js";import{PixelType as C}from"../../../webgl/enums.js";let H=class extends t{constructor(e,t,i,r,s,n){super({}),this._fbos=e,this._techniques=t,this._stage=i,this._prepareForShadowMapPass=r,this._renderToShadowMap=s,this._requestRender=n,this._primarySet=new j(new F(0),()=>this._requestRenderIfEnabled()),this._contextSet=new j(new F(1),()=>this._requestRenderIfEnabled()),this._passParameters=new m,this._depthRange=p.Zero,this._enabled=!1,this._previewing=!1,this._shadowAccumulatorKey=Symbol("shadowAccumulator"),this._bindParameters=new d(e.rctx.emptyTexture,new y(e,i.viewingMode)),this._bindParameters.shadowMap.enabled=!0,this._vao=f(e.rctx),this._accumulationRenderer=new g(t,e.rctx,this,n);const h=this._stage.view.resourceController.scheduler;this.addHandles([h.registerTask(x.SHADOW_ACCUMULATOR,this),a(()=>this._previewing,e=>{e?this._invalidateAccumulationSets():this._requestRenderIfEnabled()},o),a(()=>this._numActive,()=>this._numActiveChanged(),o),a(()=>this._depthRange,()=>this._invalidateAccumulationSets(),o),a(()=>this.accumulating&&this.canAccumulate,()=>this._precompile(),{sync:!0,once:!0})],this._shadowAccumulatorKey)}destroy(){this._disable(),this.removeHandles(this._shadowAccumulatorKey),this._accumulationRenderer=s(this._accumulationRenderer),this._bindParameters.shadowMap.dispose(),this._fboHandle=s(this._fboHandle),this._vao=s(this._vao);for(const e of this._accumulationSets())e.destroy();this._contextSet=null,this._primarySet=null,this._bindParameters.destroy()}*_accumulationSets(){yield this._primarySet,yield this._contextSet}get computedSamples(){return[this._primarySet.progress,this._contextSet.progress]}get shadowCastTexture(){return this._fboHandle?.getTexture()}get accumulating(){return this.active&&this._previewing||this._refining}get _refining(){return this.active&&!this._doneAccumulating&&!this._previewing}get active(){return this._enabled&&[...this._accumulationSets()].some(e=>e.active)}get canAccumulate(){return null!=this._bindParameters.depth&&this._depthRange!==p.Zero&&this._opacityFromElevation>b}get _doneAccumulating(){return[...this._accumulationSets()].every(e=>e.doneAccumulating)}get _opacityFromElevation(){return this._accumulationRenderer.opacityFromElevation}set _opacityFromElevation(e){this._accumulationRenderer.opacityFromElevation=e}get _numActive(){return[...this._accumulationSets()].reduce((e,t)=>e+(t.active?1:0),0)}get _colorFormat(){return 2===this._numActive?2:0}get readyToRun(){return this._refining&&this.canAccumulate&&[...this._accumulationSets()].some(e=>e.running)}_precompile(){for(const e of this._accumulationSets())this._techniques.precompile(A,e.configuration),this._techniques.precompile(R,e.configuration)}runTask(e){this._clearBuffersOnAccumulationStart(),this._prepareForShadowMapPass(this._bindParameters);let t=!1;for(const i of this._accumulationSets())this._runTaskForSet(i,e)&&(t=!0);t&&this._requestRender()}_runTaskForSet(e,t){let i=!1;for(;!t.done&&!e.doneAccumulating;)this._accumulateShadow(e),t.madeProgress(),i=!0;return i}renderAccumulation(e,t,i,r){return this._updateCamera(t),this._bindParameters.contentCamera=i,this._bindParameters.depth=e,this._passParameters.origin=this._bindParameters.camera.center,this.notifyChange("canAccumulate"),!(!this.accumulating||!this.canAccumulate)&&(this._previewing||r?(this._clearFramebuffer(),this._reset()):this._clearBuffersOnAccumulationStart(),this._accumulateSetsForRenderFrame(r))}_clearBuffersOnAccumulationStart(){if([...this._accumulationSets()].every(e=>0===e.progress))this._clearFramebuffer();else for(const e of this._accumulationSets())0===e.progress&&this._clearFramebufferForSet(this._fboHandle,e)}_accumulateSetsForRenderFrame(e){let t=!1;for(const i of this._accumulationSets())this._accumulateSetForRenderFrame(i,e)&&(t=!0);return t&&this._requestRender(),t}_accumulateSetForRenderFrame(e,t){let i=t?e.sampleCount:Math.min(q,e.sampleCount);i-=e.progress;for(let r=0;r<i;++r)this._accumulateShadow(e);return i>0}precompile(){this._accumulationRenderer.precompile()}render(e){this._accumulationRenderer.render(e)}setParameters(e){void 0!==e.previewing&&(this._previewing=e.previewing),void 0!==e.lightDirections&&(this._primarySet.lightDirections=e.lightDirections),void 0!==e.lightDirectionsContext&&(this._contextSet.lightDirections=e.lightDirectionsContext),!0===e.enabled?this._enable():!1===e.enabled&&this._disable(),this._accumulationRenderer.setOptions(e)}readAccumulatedShadow(e,t){const i=this._primarySet.progress;return!this.active||!this._fboHandle||i<1||e<0||e>=this._fboHandle.fbo.width||t<0||t>=this._fboHandle.fbo.height?0:(this._fboHandle.fbo.readPixels(e,t,1,1,6408,C.UNSIGNED_BYTE,P),P[0]/i)}_numActiveChanged(){if(!this._enabled||!this._fboHandle)return;const e=2===this._numActive,{width:t,height:i}=this._fboHandle.fbo,r=this._createFBO(t,i);e&&(this._clearFramebuffer(r),this._contextSet.reset()),this._rctx.blitFramebuffer(this._fboHandle.fbo,r.fbo),this._fboHandle.dispose(),this._fboHandle=r,this._requestRender()}_enable(){this._enabled||(this._enabled=!0,this._invalidateAccumulationSets())}_disable(){this._enabled&&(this._fboHandle=s(this._fboHandle),this._enabled=!1,this._requestRender())}_createFBO(e,t){return this._fbos.acquire(e,t,"shadow accumulation",this._colorFormat)}_invalidateAccumulationSets(){for(const e of this._accumulationSets())e.reset();this._requestRenderIfEnabled()}_reset(){for(const e of this._accumulationSets())e.reset()}_clearFramebuffer(e=this._fboHandle){e&&(this._rctx.bindFramebuffer(e.fbo),this._rctx.setClearColor(0,0,0,0),this._rctx.clear(16384))}_clearFramebufferForSet(e,t){if(!e)return;const i=this._techniques.get(R,t.configuration);this._rctx.bindFramebuffer(e.fbo),this._rctx.bindTechnique(i,this._bindParameters,this._passParameters),this._rctx.bindVAO(this._vao),this._rctx.drawArrays(i.primitiveType,0,this._vao.vertexCount("geometry"))}_accumulateShadow(e){this._renderToShadowMap(this._bindParameters,e.lightDirections[e.progress++],this._depthRange);const t=this._techniques.get(A,e.configuration);this._rctx.bindFramebuffer(this._fboHandle?.fbo),this._rctx.bindTechnique(t,this._bindParameters,this._passParameters),this._rctx.bindVAO(this._vao),this._rctx.drawArrays(t.primitiveType,0,this._vao.vertexCount("geometry"))}_updateCamera(e){if(!this._enabled)return;const t=this._bindParameters.camera;e.equals(t)||t.copyFrom(e),this._fboHandle?.fbo.width===e.fullWidth&&this._fboHandle?.fbo.height===e.fullHeight||(this._fboHandle?.release(),this._fboHandle=this._createFBO(e.fullWidth,e.fullHeight)),this._opacityFromElevation=1-r(S,v,e.relativeElevation)}_requestRenderIfEnabled(){this._enabled&&this._requestRender()}get _rctx(){return this._fbos.rctx}updateDepthRange(e){this._depthRange.equals(e)||(this._depthRange=e)}get test(){}};e([h()],H.prototype,"_refining",null),e([h()],H.prototype,"active",null),e([h()],H.prototype,"canAccumulate",null),e([h()],H.prototype,"_doneAccumulating",null),e([h()],H.prototype,"_opacityFromElevation",null),e([h()],H.prototype,"_numActive",null),e([h()],H.prototype,"_colorFormat",null),e([h()],H.prototype,"readyToRun",null),e([h()],H.prototype,"_depthRange",void 0),e([h()],H.prototype,"_enabled",void 0),e([h()],H.prototype,"_previewing",void 0),e([h()],H.prototype,"_accumulationRenderer",void 0),H=e([c("esri.views.3d.webgl-engine.lib.ShadowAccumulator")],H);const q=6,P=new Uint8Array(4);class j{constructor(e,t){this.configuration=e,this._notifyChange=t,this._cachedLightDirections=[],this._progress=n(0),this._sampleCount=n(0)}get progress(){return this._progress.value}set progress(e){this._progress.value=e}get sampleCount(){return this._sampleCount.value}get doneAccumulating(){return this.progress>=this.sampleCount}get running(){return this.progress>0}get active(){return this.sampleCount>0}get lightDirections(){return this._cachedLightDirections}set lightDirections(e){const t=this._cachedLightDirections,r=Math.min(w,e.length);if(!i(t,0,t.length,e,0,r,l)){t.length=r,this._sampleCount.value=r;for(let i=0;i<r;++i)t[i]=u(t[i]??_(),e[i]);this.reset(),this._notifyChange()}}destroy(){this._cachedLightDirections.length=0,this._sampleCount.value=0}reset(){this.progress=0}precompile(e){e.precompile(A,this.configuration),e.precompile(R,this.configuration)}}export{H as ShadowAccumulator};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import has from"../../../../core/has.js";import{clamp as t,lerp as s,acosClamped as e}from"../../../../core/mathUtils.js";import{releaseMaybe as i}from"../../../../core/maybe.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as r,multiply as h,invert as o,lookAt as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as c,create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as d,add as m,scale as u,lerp as _,squaredDistance as f,subtract as g,dot as p,negate as x,normalize as b,copy as w}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as M}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{exactEquals as C,copy as j,negate as y,transformMat4 as v,set as S}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as H}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as D,transformMat4 as F}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as O}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{CascadeCamera as T}from"./CascadeCamera.js";import{applyTextureResizeModulo as Q}from"./textureUtils.js";import{assert as B,logWithBase as L,verify as V,rayRay2D as N}from"./Util.js";import{DepthStencilAttachment as R}from"../../../webgl/enums.js";class W{constructor(){this.camera=new T,this.lightMat=l()}}class q{constructor(){this.maxNumCascadesHighQuality=4,this.maxNumCascadesLowQuality=4,this.textureSizeModHighQuality=1.3,this.textureSizeModLowQuality=.9,this.splitSchemeLambda=0}}class z{constructor(t,s){this._fbos=t,this._viewingMode=s,this._snapshots=new Array,this._textureHeight=0,this._numCascades=1,this.settings=new q,this._projectionView=l(),this._projectionViewInverse=l(),this._modelViewLight=l(),this._cascadeDistances=[0,0,0,0,0],this._usedCascadeDistances=O(),this._cascades=[new W,new W,new W,new W],this._lastOrigin=null,this._enabled=!1,this._maxTextureWidth=Math.min(has("esri-mobile")?4096:16384,t.rctx.parameters.maxTextureSize)}dispose(){this.enabled=!1,this.disposeBuffers()}get depthTexture(){return this._handle?.getTexture(R)}get _textureWidth(){return this._textureHeight*this._numCascades}get numCascades(){return this._numCascades}get cascadeDistances(){return D(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)}disposeMainBuffer(){this._handle=i(this._handle)}disposeBuffers(){this.disposeMainBuffer(),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.disposeBuffers()}get enabled(){return this._enabled}get ready(){return this._enabled&&null!=this.depthTexture}get cascades(){for(let t=0;t<this._numCascades;++t)X[t]=this._cascades[t];return X.length=this._numCascades,X}start(t,s,e,i,a){B(this.enabled);const{near:r,far:h}=xt(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(){B(this.enabled)}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(Z,this._cascades[s].lightMat,t);for(let t=0;t<16;++t)$[16*s+t]=Z[t]}}return $}moveSnapshot(t){B(this.enabled),this._snapshots[t]?.release(),this._snapshots[t]=this._handle,this._handle?.setName(0===t?"shadow map highlight":"shadow map excluding highlight"),this._handle=null}copySnapshot(t){if(!this.enabled)return;const s=this._handle?.getTexture(R)?.descriptor;if(!s)return;this._snapshots[t]?.release();const e=0===t?"shadow map highlight":"shadow map excluding highlight",i=this._acquireFBO(e);this._snapshots[t]=i;const a=this._handle?.fbo;if(!a||!i?.fbo)return void console.error("No FBO");const{rctx:r}=this._fbos;r.blitFramebuffer(a,i.fbo,256)}getSnapshot(t){return this.enabled?this._snapshots[t]?.getTexture(R):null}clear(){this._ensureFbo(),this.bindFbo(),this._fbos.rctx.clear(256)}_computeTextureHeight({pixelRatio:t,fullWidth:s,fullHeight:e},i,a){const r=Math.min(window.devicePixelRatio,i)/t,h=a?this.settings.textureSizeModHighQuality:this.settings.textureSizeModLowQuality;return Q(Math.max(s,e)*r*h,this._maxTextureWidth/this._numCascades)}_ensureFbo(){this._handle?.fbo?.width===this._textureWidth&&this._handle?.fbo.height===this._textureHeight||(this._handle?.release(),this._handle=this._acquireFBO("shadow map"))}_acquireFBO(t){const s=this._fbos.acquire(this._textureWidth,this._textureHeight,t,12);return s.getTexture(R)?.setShadowFiltering(!0),s}_discardSnapshot(t){this._snapshots[t]=i(this._snapshots[t])}_discardSnapshots(){for(let t=0;t<this._snapshots.length;++t)this._discardSnapshot(t);this._snapshots.length=0}bindFbo(){this._fbos.rctx.bindFramebuffer(this._handle?.fbo)}_constructCascade(t,s,e,i){const a=this._cascades[t],o=-this._cascadeDistances[t],n=-this._cascadeDistances[t+1],c=(s[10]*o+s[14])/Math.abs(s[11]*o+s[15]),l=(s[10]*n+s[14])/Math.abs(s[11]*n+s[15]);B(c<l);for(let r=0;r<8;++r){D(I,r%4==0||r%4==3?-1:1,r%4==0||r%4==1?-1:1,r<4?c:l,1);const t=U[r];F(t,I,this._projectionViewInverse),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3]}y(K,U[0]),a.camera.viewMatrix=r(A,this._modelViewLight,K);for(let r=0;r<8;++r)v(U[r],U[r],a.camera.viewMatrix);let d=U[0][2],m=U[0][2];for(let r=1;r<8;++r)d=Math.min(d,U[r][2]),m=Math.max(m,U[r][2]);d-=200,m+=200,a.camera.near=-m,a.camera.far=-d,pt(e,i,d,m,a.camera),h(a.lightMat,a.camera.projectionMatrix,a.camera.viewMatrix);const u=this._textureHeight;a.camera.viewport=[t*u,0,u,u]}_setupMatrices(t,s){h(this._projectionView,t.projectionMatrix,t.viewMatrix),o(this._projectionViewInverse,this._projectionView);const e=1===this._viewingMode?t.eye:S(K,0,0,1);n(this._modelViewLight,[0,0,0],[-s[0],-s[1],-s[2]],e)}_computeCascadeDistances(t,e,i){const a=i?this.settings.maxNumCascadesHighQuality:this.settings.maxNumCascadesLowQuality;this._numCascades=Math.min(1+Math.floor(L(e/t,4)),a);const r=(e-t)/this._numCascades,h=(e/t)**(1/this._numCascades);let o=t,n=t;for(let c=0;c<this._numCascades+1;++c)this._cascadeDistances[c]=s(o,n,this.settings.splitSchemeLambda),o*=h,n+=r}get test(){}}const A=l(),I=O(),U=[];for(let bt=0;bt<8;++bt)U.push(O());const P=M(),k=M(),E=M(),G=M(),J=M(),K=H(),X=[];function Y(){X.length=0}const Z=l(),$=c.concat(c,c,c),tt=M(),st=M(),et=[M(),M(),M(),M()],it=M(),at=M(),rt=M(),ht=M(),ot=M(),nt=M(),ct=M();function lt(t,s,e,i,a,r,h,o){d(tt,0,0);for(let d=0;d<4;++d)m(tt,tt,t[d]);u(tt,tt,.25),d(st,0,0);for(let d=4;d<8;++d)m(st,st,t[d]);u(st,st,.25),_(et[0],t[4],t[5],.5),_(et[1],t[5],t[6],.5),_(et[2],t[6],t[7],.5),_(et[3],t[7],t[4],.5);let n=0,c=f(et[0],tt);for(let d=1;d<4;++d){const t=f(et[d],tt);t<c&&(c=t,n=d)}g(it,et[n],t[n+4]);const l=it[0];let M,C;it[0]=-it[1],it[1]=l,g(at,st,tt),p(at,it)<0&&x(it,it),_(it,it,at,e),b(it,it),M=C=p(g(rt,t[0],tt),it);for(let d=1;d<8;++d){const s=p(g(rt,t[d],tt),it);s<M?M=s:s>C&&(C=s)}w(i,tt),u(rt,it,M-s),m(i,i,rt);let j=-1,y=1,v=0,S=0;for(let d=0;d<8;++d){g(ht,t[d],i),b(ht,ht);const s=it[0]*ht[1]-it[1]*ht[0];s>0?s>j&&(j=s,v=d):s<y&&(y=s,S=d)}V(j>0,"leftArea"),V(y<0,"rightArea"),u(ot,it,M),m(ot,ot,tt),u(nt,it,C),m(nt,nt,tt),ct[0]=-it[1],ct[1]=it[0];const H=N(i,t[S],nt,m(rt,nt,ct),1,a),D=N(i,t[v],nt,rt,1,r),F=N(i,t[v],ot,m(rt,ot,ct),1,h),O=N(i,t[S],ot,rt,1,o);V(H,"rayRay"),V(D,"rayRay"),V(F,"rayRay"),V(O,"rayRay")}function dt(t,s){return 3*s+t}const mt=M();function ut(t,s){return d(mt,t[s],t[s+3]),mt}const _t=M(),ft=a();function gt(t,s,e,i,a){g(_t,e,i),u(_t,_t,.5),ft[0]=_t[0],ft[1]=_t[1],ft[2]=0,ft[3]=_t[1],ft[4]=-_t[0],ft[5]=0,ft[6]=_t[0]*_t[0]+_t[1]*_t[1],ft[7]=_t[0]*_t[1]-_t[1]*_t[0],ft[8]=1,ft[dt(0,2)]=-p(ut(ft,0),t),ft[dt(1,2)]=-p(ut(ft,1),t);let r=p(ut(ft,0),e)+ft[dt(0,2)],h=p(ut(ft,1),e)+ft[dt(1,2)],o=p(ut(ft,0),i)+ft[dt(0,2)],n=p(ut(ft,1),i)+ft[dt(1,2)];r=-(r+o)/(h+n),ft[dt(0,0)]+=ft[dt(1,0)]*r,ft[dt(0,1)]+=ft[dt(1,1)]*r,ft[dt(0,2)]+=ft[dt(1,2)]*r,r=1/(p(ut(ft,0),e)+ft[dt(0,2)]),h=1/(p(ut(ft,1),e)+ft[dt(1,2)]),ft[dt(0,0)]*=r,ft[dt(0,1)]*=r,ft[dt(0,2)]*=r,ft[dt(1,0)]*=h,ft[dt(1,1)]*=h,ft[dt(1,2)]*=h,ft[dt(2,0)]=ft[dt(1,0)],ft[dt(2,1)]=ft[dt(1,1)],ft[dt(2,2)]=ft[dt(1,2)],ft[dt(1,2)]+=1,r=p(ut(ft,1),s)+ft[dt(1,2)],h=p(ut(ft,2),s)+ft[dt(2,2)],o=p(ut(ft,1),e)+ft[dt(1,2)],n=p(ut(ft,2),e)+ft[dt(2,2)],r=-.5*(r/h+o/n),ft[dt(1,0)]+=ft[dt(2,0)]*r,ft[dt(1,1)]+=ft[dt(2,1)]*r,ft[dt(1,2)]+=ft[dt(2,2)]*r,r=p(ut(ft,1),s)+ft[dt(1,2)],h=p(ut(ft,2),s)+ft[dt(2,2)],o=-h/r,ft[dt(1,0)]*=o,ft[dt(1,1)]*=o,ft[dt(1,2)]*=o,a[0]=ft[0],a[1]=ft[1],a[2]=0,a[3]=ft[2],a[4]=ft[3],a[5]=ft[4],a[6]=0,a[7]=ft[5],a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=ft[6],a[13]=ft[7],a[14]=0,a[15]=ft[8]}function pt(t,s,i,a,r){const h=1/U[0][3],o=1/U[4][3];B(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,lt(U,n,c,P,k,E,G,J),gt(P,k,G,J,r.projectionMatrix),r.projectionMatrix[10]=2/(i-a),r.projectionMatrix[14]=-(i+a)/(i-a)}function xt(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{z as ShadowMap,Y as cleanupShadowmap};
2
+ 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 c,lookAt as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as n,create as u}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as l,add as m,scale as d,lerp as _,squaredDistance as g,subtract as f,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{exactEquals as C,copy as j,negate as y,transformMat4 as v,set as H}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as D}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as O,transformMat4 as Q}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as L}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{CascadeCamera as S}from"./CascadeCamera.js";import{applyTextureResizeModulo as V}from"./textureUtils.js";import{assert as N,logWithBase as T,verify as F,rayRay2D as R}from"./Util.js";import{DepthStencilAttachment as W}from"../../../webgl/enums.js";class z{constructor(){this.camera=new S,this.lightMat=u()}}class A{constructor(){this.maxNumCascadesHighQuality=4,this.maxNumCascadesLowQuality=4,this.textureSizeModHighQuality=1.3,this.textureSizeModLowQuality=.9,this.splitSchemeLambda=0}}class I{constructor(t,s){this._fbos=t,this._viewingMode=s,this._enabled=!1,this._outputs=new Array,this._textureHeight=0,this._numCascades=1,this.settings=new A,this._projectionView=u(),this._projectionViewInverse=u(),this._modelViewLight=u(),this._cascadeDistances=[0,0,0,0,0],this._usedCascadeDistances=L(),this._cascades=[new z,new z,new z,new z],this._lastOrigin=null,this._maxTextureWidth=Math.min(has("esri-mobile")?4096:16384,t.rctx.parameters.maxTextureSize)}dispose(){this.enabled=!1}disposeOutputs(){this._handle=i(this._handle),this._outputs.forEach(t=>t?.release()),this._outputs.length=0}disposeOutput(t){this._outputs[t]=i(this._outputs[t])}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.disposeOutputs()}get enabled(){return this._enabled}get ready(){return!!this.getOutput(3)||!!this.getOutput(5)}get cascades(){for(let t=0;t<this._numCascades;++t)X[t]=this._cascades[t];return X.length=this._numCascades,X}start(t,s,e,i,a){N(this.enabled);const{near:r,far:h}=xt(e);this._computeCascadeDistances(r,h,i),this._textureHeight=this._computeTextureHeight(t,a,i),this._setupMatrices(t,s);const{viewMatrix:c,projectionMatrix:o}=t;for(let n=0;n<this._numCascades;++n)this._constructCascade(n,o,c,s);this._lastOrigin=null,this.clear()}getShadowMapMatrices(t){if(!this._lastOrigin||!C(t,this._lastOrigin)){this._lastOrigin=this._lastOrigin||D(),j(this._lastOrigin,t);for(let s=0;s<this._numCascades;++s){r(Z,this._cascades[s].lightMat,t);for(let t=0;t<16;++t)$[16*s+t]=Z[t]}}return $}finish(t){N(this.enabled),this._outputs[t]?.release(),this._outputs[t]=this._handle,this._handle?.setName(4===t?"shadow map highlight":"shadow map excluding highlight"),this._handle=null}getOutput(t){return this.enabled?this._outputs[t]?.getTexture(W):null}clear(){this._ensureFbo(),this.bindFramebuffer(),this._fbos.rctx.clear(256)}_computeTextureHeight({pixelRatio:t,fullWidth:s,fullHeight:e},i,a){const r=Math.min(window.devicePixelRatio,i)/t,h=a?this.settings.textureSizeModHighQuality:this.settings.textureSizeModLowQuality;return V(Math.max(s,e)*r*h,this._maxTextureWidth/this._numCascades)}_ensureFbo(){this._handle?.fbo?.width===this._textureWidth&&this._handle?.fbo.height===this._textureHeight||(this._handle?.release(),this._handle=this._fbos.acquire(this._textureWidth,this._textureHeight,"shadow map",12),this._handle.getTexture(W)?.setShadowFiltering(!0))}bindFramebuffer(){this._fbos.rctx.bindFramebuffer(this._handle?.fbo)}_constructCascade(t,s,e,i){const a=this._cascades[t],c=-this._cascadeDistances[t],o=-this._cascadeDistances[t+1],n=(s[10]*c+s[14])/Math.abs(s[11]*c+s[15]),u=(s[10]*o+s[14])/Math.abs(s[11]*o+s[15]);N(n<u);for(let r=0;r<8;++r){O(q,r%4==0||r%4==3?-1:1,r%4==0||r%4==1?-1:1,r<4?n:u,1);const t=E[r];Q(t,q,this._projectionViewInverse),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3]}y(K,E[0]),a.camera.viewMatrix=r(U,this._modelViewLight,K);for(let r=0;r<8;++r)v(E[r],E[r],a.camera.viewMatrix);let l=E[0][2],m=E[0][2];for(let r=1;r<8;++r)l=Math.min(l,E[r][2]),m=Math.max(m,E[r][2]);l-=200,m+=200,a.camera.near=-m,a.camera.far=-l,pt(e,i,l,m,a.camera),h(a.lightMat,a.camera.projectionMatrix,a.camera.viewMatrix);const d=this._textureHeight;a.camera.viewport=[t*d,0,d,d]}_setupMatrices(t,s){h(this._projectionView,t.projectionMatrix,t.viewMatrix),c(this._projectionViewInverse,this._projectionView);const e=1===this._viewingMode?t.eye:H(K,0,0,1);o(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(T(e/t,4)),a);const r=(e-t)/this._numCascades,h=(e/t)**(1/this._numCascades);let c=t,o=t;for(let n=0;n<this._numCascades+1;++n)this._cascadeDistances[n]=s(c,o,this.settings.splitSchemeLambda),c*=h,o+=r}get _textureWidth(){return this._textureHeight*this._numCascades}get numCascades(){return this._numCascades}get cascadeDistances(){return O(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)}get test(){}}const U=u(),q=L(),E=[];for(let bt=0;bt<8;++bt)E.push(L());const P=M(),k=M(),B=M(),G=M(),J=M(),K=D(),X=[];function Y(){X.length=0}const Z=u(),$=n.concat(n,n,n),tt=M(),st=M(),et=[M(),M(),M(),M()],it=M(),at=M(),rt=M(),ht=M(),ct=M(),ot=M(),nt=M();function ut(t,s,e,i,a,r,h,c){l(tt,0,0);for(let l=0;l<4;++l)m(tt,tt,t[l]);d(tt,tt,.25),l(st,0,0);for(let l=4;l<8;++l)m(st,st,t[l]);d(st,st,.25),_(et[0],t[4],t[5],.5),_(et[1],t[5],t[6],.5),_(et[2],t[6],t[7],.5),_(et[3],t[7],t[4],.5);let o=0,n=g(et[0],tt);for(let l=1;l<4;++l){const t=g(et[l],tt);t<n&&(n=t,o=l)}f(it,et[o],t[o+4]);const u=it[0];let M,C;it[0]=-it[1],it[1]=u,f(at,st,tt),p(at,it)<0&&x(it,it),_(it,it,at,e),b(it,it),M=C=p(f(rt,t[0],tt),it);for(let l=1;l<8;++l){const s=p(f(rt,t[l],tt),it);s<M?M=s:s>C&&(C=s)}w(i,tt),d(rt,it,M-s),m(i,i,rt);let j=-1,y=1,v=0,H=0;for(let l=0;l<8;++l){f(ht,t[l],i),b(ht,ht);const s=it[0]*ht[1]-it[1]*ht[0];s>0?s>j&&(j=s,v=l):s<y&&(y=s,H=l)}F(j>0,"leftArea"),F(y<0,"rightArea"),d(ct,it,M),m(ct,ct,tt),d(ot,it,C),m(ot,ot,tt),nt[0]=-it[1],nt[1]=it[0];const D=R(i,t[H],ot,m(rt,ot,nt),1,a),O=R(i,t[v],ot,rt,1,r),Q=R(i,t[v],ct,m(rt,ct,nt),1,h),L=R(i,t[H],ct,rt,1,c);F(D,"rayRay"),F(O,"rayRay"),F(Q,"rayRay"),F(L,"rayRay")}function lt(t,s){return 3*s+t}const mt=M();function dt(t,s){return l(mt,t[s],t[s+3]),mt}const _t=M(),gt=a();function ft(t,s,e,i,a){f(_t,e,i),d(_t,_t,.5),gt[0]=_t[0],gt[1]=_t[1],gt[2]=0,gt[3]=_t[1],gt[4]=-_t[0],gt[5]=0,gt[6]=_t[0]*_t[0]+_t[1]*_t[1],gt[7]=_t[0]*_t[1]-_t[1]*_t[0],gt[8]=1,gt[lt(0,2)]=-p(dt(gt,0),t),gt[lt(1,2)]=-p(dt(gt,1),t);let r=p(dt(gt,0),e)+gt[lt(0,2)],h=p(dt(gt,1),e)+gt[lt(1,2)],c=p(dt(gt,0),i)+gt[lt(0,2)],o=p(dt(gt,1),i)+gt[lt(1,2)];r=-(r+c)/(h+o),gt[lt(0,0)]+=gt[lt(1,0)]*r,gt[lt(0,1)]+=gt[lt(1,1)]*r,gt[lt(0,2)]+=gt[lt(1,2)]*r,r=1/(p(dt(gt,0),e)+gt[lt(0,2)]),h=1/(p(dt(gt,1),e)+gt[lt(1,2)]),gt[lt(0,0)]*=r,gt[lt(0,1)]*=r,gt[lt(0,2)]*=r,gt[lt(1,0)]*=h,gt[lt(1,1)]*=h,gt[lt(1,2)]*=h,gt[lt(2,0)]=gt[lt(1,0)],gt[lt(2,1)]=gt[lt(1,1)],gt[lt(2,2)]=gt[lt(1,2)],gt[lt(1,2)]+=1,r=p(dt(gt,1),s)+gt[lt(1,2)],h=p(dt(gt,2),s)+gt[lt(2,2)],c=p(dt(gt,1),e)+gt[lt(1,2)],o=p(dt(gt,2),e)+gt[lt(2,2)],r=-.5*(r/h+c/o),gt[lt(1,0)]+=gt[lt(2,0)]*r,gt[lt(1,1)]+=gt[lt(2,1)]*r,gt[lt(1,2)]+=gt[lt(2,2)]*r,r=p(dt(gt,1),s)+gt[lt(1,2)],h=p(dt(gt,2),s)+gt[lt(2,2)],c=-h/r,gt[lt(1,0)]*=c,gt[lt(1,1)]*=c,gt[lt(1,2)]*=c,a[0]=gt[0],a[1]=gt[1],a[2]=0,a[3]=gt[2],a[4]=gt[3],a[5]=gt[4],a[6]=0,a[7]=gt[5],a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=gt[6],a[13]=gt[7],a[14]=0,a[15]=gt[8]}function pt(t,s,i,a,r){const h=1/E[0][3],c=1/E[4][3];N(h<c);let o=h+Math.sqrt(h*c);const n=Math.sin(e(t[2]*s[0]+t[6]*s[1]+t[10]*s[2]));o/=n,ut(E,o,n,P,k,B,G,J),ft(P,k,G,J,r.projectionMatrix),r.projectionMatrix[10]=2/(i-a),r.projectionMatrix[14]=-(i+a)/(i-a)}function xt(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{I as ShadowMap,Y as cleanupShadowmap};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import s from"../../../../core/Collection.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../../core/maybe.js";import{watch as i,initial as o,when as a,sync as n}from"../../../../core/reactiveUtils.js";import{property as h,subclass as d}from"../../../../core/accessorSupport/decorators.js";import{translate as c,fromTranslation as p,scale as w,mul as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{sub as f,distance as u}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as v,fromValues as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Sphere as V}from"../../../../geometry/support/sphere.js";import{InternalRenderCategory as g}from"../../webgl.js";import M from"../../webgl/RenderNode.js";import{ViewshedShadowMap as b}from"./ViewshedShadowMap.js";import{V as y}from"../../../../chunks/Viewshed.glsl.js";import{ViewshedTechnique as S}from"../shaders/ViewshedTechnique.js";let j=class extends M{get shadowMap(){return this._shadowMap}get hasViewsheds(){return this._viewsheds.length>0}get _contentPixelRatio(){return this.view.state.contentPixelRatio}get _viewshedsInView(){return this._viewsheds.items.filter(e=>P(this.view,e))}constructor(e){super(e),this.isDecoration=!1,this._passParameters=new y,this._viewsheds=new s,this._shadowMap=null,this.consumes={required:[g.VIEWSHED,"normals"]},this.produces=g.VIEWSHED,this.requireGeometryDepth=!0}initialize(){this._shadowMap=new b(this.fboCache),this.addHandles([i(()=>this.view.resolutionScale,e=>{const s=this._shadowMap;s&&(s.settings.textureSizeQuality=e)},o),a(()=>!this.hasViewsheds,()=>this._shadowMap?.dispose()),i(()=>this._viewshedsInView.map(e=>[e.observerRenderSpace,e.heading,e.tilt,e.farDistance,e.horizontalFieldOfView,e.verticalFieldOfView]),()=>this.requestRender(1),n)])}destroy(){this._shadowMap=r(this._shadowMap)}precompile(){if(this.hasViewsheds){this.techniques.precompile(S);for(const e of this._viewshedsInView)if(this._shadowMap?.isActive(e))return void this.view.stage.renderer.precompileViewshedShadowMap()}}render(e){const s=this.bindParameters,t=this.renderingContext,r=e.find(({name:e})=>e===g.VIEWSHED);if(!this.hasViewsheds||!s.depth||this.isDecoration&&!s.decorations)return r;this._passParameters.shadowMap=this._shadowMap??this._passParameters.shadowMap,this._passParameters.normals=e.find(({name:e})=>"normals"===e)?.getTexture();const i=this.techniques.get(S);if(!i?.compiled)return this.requestRender(1),r;const o=this.view.stage.renderer.isFeatureEnabled(8);for(const a of this._viewshedsInView){if(!this._renderShadowCubeMap(s,a,o)||!this._shadowMap?.ready)continue;const e=this._setupViewshedParameters(a,s.camera);t.bindFramebuffer(r.fbo),t.bindTechnique(i,s,e),t.screen.draw()}return this.shadowMap?.dispose(),r}updateViewsheds(e){const s=this._viewsheds,{removes:t,adds:r}=e;if(t&&(Array.isArray(t)?s.removeMany(t):s.remove(t)),r)if(Array.isArray(r)){const e=r.filter(e=>!s.includes(e));s.addMany(e)}else s.includes(r)||s.add(r)}_renderShadowCubeMap(e,s,t){const r=this._shadowMap;if(!r)return!1;const i=this.view.basemapTerrain.hasStencilEnabledExtents,o=r.start(e.camera,s,t,this._contentPixelRatio,i);return o&&r.faces.forEach(e=>this.view.stage.renderer.renderViewshedShadowMap(e)),r.finish(),o}_setupViewshedParameters(e,s){const r=this._shadowMap;if(!r)return this._passParameters;const i=this._passParameters,o=e.effectiveObserverRenderSpace;i.localOrigin=o,i.observerOffset=f(E,e.observerRenderSpace,e.effectiveObserverRenderSpace),i.fovs=[t(e.horizontalFieldOfView),t(e.verticalFieldOfView)],i.headingAndTilt=[t(e.heading),t(e.tiltParallelToSurface)],i.upVector=e.tiltedUpVector;const a=R(e.targetRenderSpace,o);i.targetVector=a;const n=new Array,h=new Array;for(let t=0;t<r.numActiveFaces;t++)c(I,r.viewshedViewMatrices[t],o),n.push(...I),x(r.viewshedProjectionMatrices[t],I,D),h.push(...D);return i.viewMatrices=n,i.projectionMatrices=h,i.volumeOffset=this.selectedViewshed?.()===e.viewshed?A(e,this.view,s.eye):0,i}get test(){return{viewsheds:this._viewsheds,shadowMap:this._shadowMap,viewshedsInView:this._viewshedsInView}}};function R(e,s){const t=v();return f(t,e,s)}function x(e,s,t){const r=_(.5,.5,.5);return p(t,r),w(t,t,r),l(t,t,e),l(t,t,s),t}function P(e,s){const t=new V(s.observerRenderSpace,s.farDistanceRenderSpace);return!!e.ready&&e.frustum.intersectsSphere(t)}function A(e,s,t){if(null==e)return 0;const{observerRenderSpace:r,targetRenderSpace:i}=e,o=u(t,r)>u(t,i)?e.observer:e.target;return s.pixelSizeAt(o)}e([h()],j.prototype,"selectedViewshed",void 0),e([h()],j.prototype,"isDecoration",void 0),e([h()],j.prototype,"shadowMap",null),e([h()],j.prototype,"hasViewsheds",null),e([h()],j.prototype,"_contentPixelRatio",null),e([h()],j.prototype,"_viewshedsInView",null),e([h()],j.prototype,"consumes",void 0),e([h()],j.prototype,"produces",void 0),j=e([d("esri.views.3d.webgl-engine.lib.Viewshed")],j);const E=v(),I=m(),D=m();export{j as Viewshed,A as computeOffsetScale};
2
+ import{__decorate as e}from"tslib";import s from"../../../../core/Collection.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../../core/maybe.js";import{watch as i,initial as o,when as a,sync as n}from"../../../../core/reactiveUtils.js";import{property as h,subclass as d}from"../../../../core/accessorSupport/decorators.js";import{translate as c,fromTranslation as p,scale as w,mul as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{sub as f,distance as u}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as v,fromValues as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Sphere as V}from"../../../../geometry/support/sphere.js";import{InternalRenderCategory as g}from"../../webgl.js";import M from"../../webgl/RenderNode.js";import{ViewshedShadowMap as b}from"./ViewshedShadowMap.js";import{V as y}from"../../../../chunks/Viewshed.glsl.js";import{ViewshedTechnique as S}from"../shaders/ViewshedTechnique.js";let j=class extends M{get shadowMap(){return this._shadowMap}get hasViewsheds(){return this._viewsheds.length>0}get _contentPixelRatio(){return this.view.state.contentPixelRatio}get _viewshedsInView(){return this._viewsheds.items.filter(e=>P(this.view,e))}constructor(e){super(e),this.isDecoration=!1,this._passParameters=new y,this._viewsheds=new s,this._shadowMap=null,this.consumes={required:[g.VIEWSHED,"normals"]},this.produces=g.VIEWSHED,this.requireGeometryDepth=!0}initialize(){this._shadowMap=new b(this.fboCache),this.addHandles([i(()=>this.view.resolutionScale,e=>{const s=this._shadowMap;s&&(s.settings.textureSizeQuality=e)},o),a(()=>!this.hasViewsheds,()=>this._shadowMap?.dispose()),i(()=>this._viewshedsInView.map(e=>[e.observerRenderSpace,e.heading,e.tilt,e.farDistance,e.horizontalFieldOfView,e.verticalFieldOfView]),()=>this.requestRender(1),n)])}destroy(){this._shadowMap=r(this._shadowMap)}precompile(){if(this.hasViewsheds){this.techniques.precompile(S);for(const e of this._viewshedsInView)if(this._shadowMap?.isActive(e))return void this.view.stage.renderer.precompileViewshedShadowMap()}}render(e){const s=this.bindParameters,t=this.renderingContext,r=e.find(({name:e})=>e===g.VIEWSHED);if(!this.hasViewsheds||!s.depth||this.isDecoration&&!s.decorations)return r;const i=this.techniques.getCompiled(S);if(!i)return this.requestRender(1),r;const o=this.view.stage.renderer.isFeatureEnabled(8);this._passParameters.shadowMap=this._shadowMap??this._passParameters.shadowMap,this._passParameters.normals=e.find(({name:e})=>"normals"===e)?.getTexture();for(const a of this._viewshedsInView){if(!this._renderShadowCubeMap(s,a,o)||!this._shadowMap?.ready)continue;const e=this._setupViewshedParameters(a,s.camera);t.bindFramebuffer(r.fbo),t.bindTechnique(i,s,e),t.screen.draw()}return this.shadowMap?.dispose(),r}updateViewsheds(e){const s=this._viewsheds,{removes:t,adds:r}=e;if(t&&(Array.isArray(t)?s.removeMany(t):s.remove(t)),r)if(Array.isArray(r)){const e=r.filter(e=>!s.includes(e));s.addMany(e)}else s.includes(r)||s.add(r)}_renderShadowCubeMap(e,s,t){const r=this._shadowMap;if(!r)return!1;const i=this.view.basemapTerrain.hasStencilEnabledExtents,o=r.start(e.camera,s,t,this._contentPixelRatio,i);return o&&r.faces.forEach(e=>this.view.stage.renderer.renderViewshedShadowMap(e)),r.finish(),o}_setupViewshedParameters(e,s){const r=this._shadowMap;if(!r)return this._passParameters;const i=this._passParameters,o=e.effectiveObserverRenderSpace;i.localOrigin=o,i.observerOffset=f(E,e.observerRenderSpace,e.effectiveObserverRenderSpace),i.fovs=[t(e.horizontalFieldOfView),t(e.verticalFieldOfView)],i.headingAndTilt=[t(e.heading),t(e.tiltParallelToSurface)],i.upVector=e.tiltedUpVector;const a=R(e.targetRenderSpace,o);i.targetVector=a;const n=new Array,h=new Array;for(let t=0;t<r.numActiveFaces;t++)c(I,r.viewshedViewMatrices[t],o),n.push(...I),x(r.viewshedProjectionMatrices[t],I,D),h.push(...D);return i.viewMatrices=n,i.projectionMatrices=h,i.volumeOffset=this.selectedViewshed?.()===e.viewshed?A(e,this.view,s.eye):0,i}get test(){return{viewsheds:this._viewsheds,shadowMap:this._shadowMap,viewshedsInView:this._viewshedsInView}}};function R(e,s){const t=v();return f(t,e,s)}function x(e,s,t){const r=_(.5,.5,.5);return p(t,r),w(t,t,r),l(t,t,e),l(t,t,s),t}function P(e,s){const t=new V(s.observerRenderSpace,s.farDistanceRenderSpace);return!!e.ready&&e.frustum.intersectsSphere(t)}function A(e,s,t){if(null==e)return 0;const{observerRenderSpace:r,targetRenderSpace:i}=e,o=u(t,r)>u(t,i)?e.observer:e.target;return s.pixelSizeAt(o)}e([h()],j.prototype,"selectedViewshed",void 0),e([h()],j.prototype,"isDecoration",void 0),e([h()],j.prototype,"shadowMap",null),e([h()],j.prototype,"hasViewsheds",null),e([h()],j.prototype,"_contentPixelRatio",null),e([h()],j.prototype,"_viewshedsInView",null),e([h()],j.prototype,"consumes",void 0),e([h()],j.prototype,"produces",void 0),j=e([d("esri.views.3d.webgl-engine.lib.Viewshed")],j);const E=v(),I=m(),D=m();export{j as Viewshed,A as computeOffsetScale};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import e from"../../../../core/PooledArray.js";import{multiply as t}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{transformMat4 as n}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{lerp as i}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{intersectsSphere as s}from"../../../../geometry/support/frustum.js";import{Sphere as o}from"../../../../geometry/support/sphere.js";import{maxScale as f}from"../../support/mathUtils.js";import{DepthRange as h}from"./DepthRange.js";import{assert as c}from"./Util.js";const u=1e4,l=100,d=500,m=500,_=.1;function g(e,t,r,n){let i=0;if(!t.some(e=>!!e.material&&(i+=e.numGeometries,i>=u)))return F.compute(e,t,n);const a=new h;return r.forEach(t=>a.union(p(e,t))),a}function p(e,t){if(!t.visible)return;const r=new h,n=t.getSpatialQueryAccelerator();return n?b(r,e,n):w(r,e,t.objects),r}function b(e,t,r){const{eye:n,viewForward:i,frustum:a}=t,s=e=>e.visible,o=r.objectCount;if(o<d)E.set(t.near,Math.min(e.near,t.far)),r.forEachInDepthRange(n,i,1,E,(r,n)=>{M(e,t,r),E.far=e.near,n.setRange(E)},a,s),E.set(Math.max(e.far,t.near),t.far),r.forEachInDepthRange(n,i,-1,E,(r,n)=>{M(e,t,r),E.near=e.far,n.setRange(E)},a,s);else{const n=Math.max(Math.min(o,m),Math.ceil(o*_)),f=r.findClosest(i,1,a,s,n),h=r.findClosest(i,-1,a,s,n);f&&h&&(x(e,t,f.boundingVolumeWorldSpace.bounds),x(e,t,h.boundingVolumeWorldSpace.bounds))}}function w(e,t,r){S.clear(),r.forEach(e=>{e.visible&&0!==e.geometries.length&&S.add(e)}),S.empty||(S.sort(t),E.set(t.near,Math.min(e.near,t.far)),S.forEachInDepthRange(E,1,(r,n)=>{n<e.near&&M(e,t,r)}),E.set(Math.max(e.far,t.near),t.far),S.forEachInDepthRange(E,-1,(t,r,n)=>{e.far=Math.max(e.far,n)}))}function M(e,r,n){if(!n.visible)return;if(!s(r.frustum,n.boundingVolumeWorldSpace.bounds))return;const i=n.transformation,a=D;n.geometries.forEach(n=>{t(a,i,n.transformation);const s=f(a);j(e,r,n.boundingInfo,a,s)})}function j(e,t,r,i,a){if(null==r)return;n(A.center,r.center,i);const{eye:o,viewForward:f}=t,h=f[0]*(A.center[0]-o[0])+f[1]*(A.center[1]-o[1])+f[2]*(A.center[2]-o[2]);if(A.radius=r.radius*a,!(h-A.radius>e.near&&h+A.radius<e.far)&&s(t.frustum,A))if(r.radius>l&&r.getChildren())for(const n of r.getChildren())j(e,t,n,i,a);else W.unionDepthRangeWithAABB(e,t.viewProjectionMatrix,i,r.bbMin,r.bbMax)}function x(e,t,r){const n=t.eye,i=t.viewForward,a=(r.center[0]-n[0])*i[0]+(r.center[1]-n[1])*i[1]+(r.center[2]-n[2])*i[2];e.near=Math.min(e.near,a-r.radius),e.far=Math.max(e.far,a+r.radius)}class R{constructor(){this._items=new e({allocator:e=>e||{object:null,distance:0,near:0,far:0},deallocator:e=>(e.object=null,e.distance=0,e.near=0,e.far=0,e)})}get length(){return this._items.length}get empty(){return 0===this._items.length}clear(){this._items.clear()}add(e){this._items.pushNew().object=e}sort(e){const t=e.eye,r=e.viewForward;this._items.forAll(e=>{const n=e.object.boundingVolumeWorldSpace.bounds,i=(n.center[0]-t[0])*r[0]+(n.center[1]-t[1])*r[1]+(n.center[2]-t[2])*r[2];e.distance=i,e.near=i-n.radius,e.far=i+n.radius}),this._items.sort((e,t)=>e.distance-t.distance)}forEachInDepthRange(e,t,r){if(1===t)for(let n=0;n<this._items.length;++n){const t=this._items.data[n];t.far<e.near||t.near>e.far||r(t.object,t.near,t.far)}else for(let n=this._items.length-1;n>=0;--n){const t=this._items.data[n];t.far<e.near||t.near>e.far||r(t.object,t.near,t.far)}}}class v{constructor(){this._geometries=new Array,this._near=[],this._far=[],this._nearCandidates=[],this._farCandidates=[],this._looseRange=new h(0,0)}compute(e,t,r){this._reset();const{viewMatrix:n}=e;t.forEach(e=>{e.forEachGeometry(e=>{if(!e.visible||0===r&&!e.castShadow)return;const t=e.boundingSphere,i=n[2]*t.center[0]+n[6]*t.center[1]+n[10]*t.center[2]+n[14],a=i-t.radius,s=i+t.radius;this._geometries.push(e),this._near.push(-s),this._far.push(-a)})});const i=new h;if(0===this._geometries.length)return i;for(let f=0;f<this._geometries.length;++f)this._near[f]>i.far&&(i.far=this._near[f]),this._near[f]>2&&this._far[f]<i.near&&(i.near=this._far[f]);const a=this._looseRange;a.near=Math.max(.5*i.near,2),a.far=2*i.far;let s=0,o=0;for(let f=0;f<this._geometries.length;++f)this._near[f]<i.near&&(this._near[f]>=a.near?i.near=this._near[f]:this._nearCandidates[s++]=f),this._far[f]>i.far&&(this._far[f]<=a.far?i.far=this._far[f]:this._farCandidates[o++]=f);if(0===this._nearCandidates.length&&0===this._farCandidates.length)return i;this._nearCandidates.sort((e,t)=>this._near[e]<this._near[t]?-1:this._near[e]>this._near[t]?1:0),this._farCandidates.sort((e,t)=>this._far[e]<this._far[t]?1:this._far[e]>this._far[t]?-1:0);for(let f=0;f<this._nearCandidates.length;++f){const t=this._nearCandidates[f];if(this._near[t]<i.near){const r=this._geometries[t],{boundingInfo:n,shaderTransformation:a}=r;this._includeNearBoundingInfoRec(e,n,a,i)}}for(let f=0;f<this._farCandidates.length;++f){const t=this._farCandidates[f];if(this._far[t]>i.far){const r=this._geometries[t],{boundingInfo:n,shaderTransformation:a}=r;this._includeFarBoundingInfoRec(e,n,a,i)}}return this._reset(),i}_reset(){this._geometries.length=0,this._near.length=0,this._far.length=0,this._nearCandidates.length=0,this._farCandidates.length=0}_isOutsideSidePlanes(e,t){const{center:r,radius:n}=e;return t[0][0]*r[0]+t[0][1]*r[1]+t[0][2]*r[2]+t[0][3]>n||t[1][0]*r[0]+t[1][1]*r[1]+t[1][2]*r[2]+t[1][3]>n||t[2][0]*r[0]+t[2][1]*r[1]+t[2][2]*r[2]+t[2][3]>n||t[3][0]*r[0]+t[3][1]*r[1]+t[3][2]*r[2]+t[3][3]>n}_includeNearBoundingInfoRec(e,t,r,i){if(null==t)return;const a=t.center;n(A.center,a,r),A.radius=t.radius*f(r);const{frustum:s}=e;if(this._isOutsideSidePlanes(A,s))return;const o=A.center[0],h=A.center[1],c=A.center[2],u=A.radius,{viewMatrix:d}=e,m=d[2]*o+d[6]*h+d[10]*c+d[14],_=m+u;if(!(-(m-u)<2||-_>=i.near))if(-_>this._looseRange.near)i.near=-_;else{if(u>l){const n=t.getChildren();if(void 0!==n){for(const t of n)this._includeNearBoundingInfoRec(e,t,r,i);return}}W.unionDepthRangeWithAABB(i,e.viewProjectionMatrix,r,t.bbMin,t.bbMax)}}_includeFarBoundingInfoRec(e,t,r,i){if(null==t)return;const a=t.center;n(A.center,a,r),A.radius=t.radius*f(r);const{frustum:s}=e;if(this._isOutsideSidePlanes(A,s))return;const[o,h,c]=A.center,{viewMatrix:u,viewProjectionMatrix:d}=e,m=u[2]*o+u[6]*h+u[10]*c+u[14]-A.radius;if(!(-m<=i.far))if(-m<this._looseRange.far)i.far=-m;else{if(A.radius>l){const n=t.getChildren();if(void 0!==n){for(const t of n)this._includeFarBoundingInfoRec(e,t,r,i);return}}W.unionDepthRangeWithAABB(i,d,r,t.bbMin,t.bbMax)}}}class C{constructor(){this._modelViewProj=r(),this._clipPosition=[a(),a(),a(),a(),a(),a(),a(),a()]}unionDepthRangeWithAABB(e,r,n,i,a){const s=this._modelViewProj;t(s,r,n);let o=!1;for(let t=0;t<8;++t){const e=this._clipPosition[t],r=0===t||3===t||4===t||7===t?i[0]:a[0],n=0===t||1===t||4===t||5===t?i[1]:a[1],o=t<4?i[2]:a[2];e[0]=s[0]*r+s[4]*n+s[8]*o+s[12],e[1]=s[1]*r+s[5]*n+s[9]*o+s[13],e[2]=s[2]*r+s[6]*n+s[10]*o+s[14],e[3]=s[3]*r+s[7]*n+s[11]*o+s[15]}for(let t=0;t<12;++t){const r=B(this._clipPosition[y[t][0]],this._clipPosition[y[t][1]],this._clipPosition[y[t][2]]);let n=!0;for(let e=0;e<r.length;++e){if(r[e][3]>=2){n=!1;break}}if(!n){o=!0;for(let t=0;t<r.length;++t){const n=r[t][3];Number.isFinite(n)&&(e.near=Math.min(n,e.near),e.far=Math.max(n,e.far))}}}return o}}function B(e,t,r){let n=[e,t,r];for(let i=0;i<4;++i){const e=n;n=[];for(let t=0;t<e.length;++t){const r=e[t],a=e[(t+1)%e.length];I(a,i)?(I(r,i)||n.push(P(r,a,i)),n.push(a)):I(r,i)&&n.push(P(r,a,i))}}return n}function I(e,t){return 0===t?e[0]>=-e[3]:1===t?e[1]>=-e[3]:2===t?e[0]<=e[3]:3===t?e[1]<=e[3]:void c(!1)}function P(e,t,r){let n=0;return 0===r?n=(-e[3]-e[0])/(t[0]-e[0]+t[3]-e[3]):1===r?n=(-e[3]-e[1])/(t[1]-e[1]+t[3]-e[3]):2===r?n=(e[3]-e[0])/(t[0]-e[0]-t[3]+e[3]):3===r&&(n=(e[3]-e[1])/(t[1]-e[1]-t[3]+e[3])),i(a(),e,t,n)}const y=[[0,1,3],[2,3,1],[1,5,2],[6,2,5],[5,4,6],[7,6,4],[4,0,7],[3,7,0],[3,2,7],[6,7,2],[4,5,0],[1,0,5]],A=new o,D=r(),E=new h,S=new R,F=new v,W=new C;export{g as depthRangeFromScene};
2
+ import e from"../../../../core/PooledArray.js";import{multiply as t}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{transformMat4 as n}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{lerp as i}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{intersectsSphere as s}from"../../../../geometry/support/frustum.js";import{Sphere as o}from"../../../../geometry/support/sphere.js";import{maxScale as f}from"../../support/mathUtils.js";import{DepthRange as h}from"./DepthRange.js";import{assert as c}from"./Util.js";const u=1e4,l=100,d=500,m=500,_=.1;function g(e,t,r,n){let i=0;if(!t.some(e=>!!e.material&&(i+=e.numGeometries,i>=u)))return F.compute(e,t,n);const a=new h;return r.forEach(t=>a.union(p(e,t))),a}function p(e,t){if(!t.visible)return;const r=new h,n=t.getSpatialQueryAccelerator();return n?b(r,e,n):w(r,e,t.objects),r}function b(e,t,r){const{eye:n,viewForward:i,frustum:a}=t,s=e=>e.visible,o=r.objectCount;if(o<d)E.set(t.near,Math.min(e.near,t.far)),r.forEachInDepthRange(n,i,1,E,(r,n)=>{M(e,t,r),E.far=e.near,n.setRange(E)},a,s),E.set(Math.max(e.far,t.near),t.far),r.forEachInDepthRange(n,i,-1,E,(r,n)=>{M(e,t,r),E.near=e.far,n.setRange(E)},a,s);else{const n=Math.max(Math.min(o,m),Math.ceil(o*_)),f=r.findClosest(i,1,a,s,n),h=r.findClosest(i,-1,a,s,n);f&&h&&(x(e,t,f.boundingVolumeWorldSpace.bounds),x(e,t,h.boundingVolumeWorldSpace.bounds))}}function w(e,t,r){S.clear(),r.forEach(e=>{e.visible&&0!==e.geometries.length&&S.add(e,t)}),S.empty||(S.sort(),E.set(t.near,Math.min(e.near,t.far)),S.forEachInDepthRange(E,1,(r,n)=>{n<e.near&&M(e,t,r)}),E.set(Math.max(e.far,t.near),t.far),S.forEachInDepthRange(E,-1,(t,r,n)=>{e.far=Math.max(e.far,n)}))}function M(e,r,n){if(!n.visible)return;if(!s(r.frustum,n.boundingVolumeWorldSpace.bounds))return;const i=n.transformation,a=D;n.geometries.forEach(n=>{t(a,i,n.transformation);const s=f(a);j(e,r,n.boundingInfo,a,s)})}function j(e,t,r,i,a){if(null==r)return;n(A.center,r.center,i);const{eye:o,viewForward:f}=t,h=f[0]*(A.center[0]-o[0])+f[1]*(A.center[1]-o[1])+f[2]*(A.center[2]-o[2]);if(A.radius=r.radius*a,!(h-A.radius>e.near&&h+A.radius<e.far)&&s(t.frustum,A))if(r.radius>l&&r.getChildren())for(const n of r.getChildren())j(e,t,n,i,a);else W.unionDepthRangeWithAABB(e,t.viewProjectionMatrix,i,r.bbMin,r.bbMax)}function x(e,t,r){const n=t.eye,i=t.viewForward,a=(r.center[0]-n[0])*i[0]+(r.center[1]-n[1])*i[1]+(r.center[2]-n[2])*i[2];e.near=Math.min(e.near,a-r.radius),e.far=Math.max(e.far,a+r.radius)}class R{constructor(){this._items=new e({allocator:e=>e||{object:null,distance:0,near:0,far:0},deallocator:e=>(e.object=null,e.distance=0,e.near=0,e.far=0,e)})}get length(){return this._items.length}get empty(){return 0===this._items.length}clear(){this._items.clear()}add(e,t){const r=t.eye,n=t.viewForward,i=e.boundingVolumeWorldSpace.bounds,a=(i.center[0]-r[0])*n[0]+(i.center[1]-r[1])*n[1]+(i.center[2]-r[2])*n[2];if(!Number.isFinite(a))return;const s=this._items.pushNew();s.object=e,s.distance=a,s.near=a-i.radius,s.far=a+i.radius}sort(){this._items.sort((e,t)=>e.distance-t.distance)}forEachInDepthRange(e,t,r){if(1===t)for(let n=0;n<this._items.length;++n){const t=this._items.data[n];t.far<e.near||t.near>e.far||r(t.object,t.near,t.far)}else for(let n=this._items.length-1;n>=0;--n){const t=this._items.data[n];t.far<e.near||t.near>e.far||r(t.object,t.near,t.far)}}}class v{constructor(){this._geometries=new Array,this._near=[],this._far=[],this._nearCandidates=[],this._farCandidates=[],this._looseRange=new h(0,0)}compute(e,t,r){this._reset();const{viewMatrix:n}=e;t.forEach(e=>{e.forEachGeometry(e=>{if(!e.visible||0===r&&!e.castShadow)return;const t=e.boundingSphere,i=n[2]*t.center[0]+n[6]*t.center[1]+n[10]*t.center[2]+n[14],a=i-t.radius,s=i+t.radius;this._geometries.push(e),this._near.push(-s),this._far.push(-a)})});const i=new h;if(0===this._geometries.length)return i;for(let f=0;f<this._geometries.length;++f)this._near[f]>i.far&&(i.far=this._near[f]),this._near[f]>2&&this._far[f]<i.near&&(i.near=this._far[f]);const a=this._looseRange;a.near=Math.max(.5*i.near,2),a.far=2*i.far;let s=0,o=0;for(let f=0;f<this._geometries.length;++f)this._near[f]<i.near&&(this._near[f]>=a.near?i.near=this._near[f]:this._nearCandidates[s++]=f),this._far[f]>i.far&&(this._far[f]<=a.far?i.far=this._far[f]:this._farCandidates[o++]=f);if(0===this._nearCandidates.length&&0===this._farCandidates.length)return i;this._nearCandidates.sort((e,t)=>this._near[e]<this._near[t]?-1:this._near[e]>this._near[t]?1:0),this._farCandidates.sort((e,t)=>this._far[e]<this._far[t]?1:this._far[e]>this._far[t]?-1:0);for(let f=0;f<this._nearCandidates.length;++f){const t=this._nearCandidates[f];if(this._near[t]<i.near){const r=this._geometries[t],{boundingInfo:n,shaderTransformation:a}=r;this._includeNearBoundingInfoRec(e,n,a,i)}}for(let f=0;f<this._farCandidates.length;++f){const t=this._farCandidates[f];if(this._far[t]>i.far){const r=this._geometries[t],{boundingInfo:n,shaderTransformation:a}=r;this._includeFarBoundingInfoRec(e,n,a,i)}}return this._reset(),i}_reset(){this._geometries.length=0,this._near.length=0,this._far.length=0,this._nearCandidates.length=0,this._farCandidates.length=0}_isOutsideSidePlanes(e,t){const{center:r,radius:n}=e;return t[0][0]*r[0]+t[0][1]*r[1]+t[0][2]*r[2]+t[0][3]>n||t[1][0]*r[0]+t[1][1]*r[1]+t[1][2]*r[2]+t[1][3]>n||t[2][0]*r[0]+t[2][1]*r[1]+t[2][2]*r[2]+t[2][3]>n||t[3][0]*r[0]+t[3][1]*r[1]+t[3][2]*r[2]+t[3][3]>n}_includeNearBoundingInfoRec(e,t,r,i){if(null==t)return;const a=t.center;n(A.center,a,r),A.radius=t.radius*f(r);const{frustum:s}=e;if(this._isOutsideSidePlanes(A,s))return;const o=A.center[0],h=A.center[1],c=A.center[2],u=A.radius,{viewMatrix:d}=e,m=d[2]*o+d[6]*h+d[10]*c+d[14],_=m+u;if(!(-(m-u)<2||-_>=i.near))if(-_>this._looseRange.near)i.near=-_;else{if(u>l){const n=t.getChildren();if(void 0!==n){for(const t of n)this._includeNearBoundingInfoRec(e,t,r,i);return}}W.unionDepthRangeWithAABB(i,e.viewProjectionMatrix,r,t.bbMin,t.bbMax)}}_includeFarBoundingInfoRec(e,t,r,i){if(null==t)return;const a=t.center;n(A.center,a,r),A.radius=t.radius*f(r);const{frustum:s}=e;if(this._isOutsideSidePlanes(A,s))return;const[o,h,c]=A.center,{viewMatrix:u,viewProjectionMatrix:d}=e,m=u[2]*o+u[6]*h+u[10]*c+u[14]-A.radius;if(!(-m<=i.far))if(-m<this._looseRange.far)i.far=-m;else{if(A.radius>l){const n=t.getChildren();if(void 0!==n){for(const t of n)this._includeFarBoundingInfoRec(e,t,r,i);return}}W.unionDepthRangeWithAABB(i,d,r,t.bbMin,t.bbMax)}}}class C{constructor(){this._modelViewProj=r(),this._clipPosition=[a(),a(),a(),a(),a(),a(),a(),a()]}unionDepthRangeWithAABB(e,r,n,i,a){const s=this._modelViewProj;t(s,r,n);let o=!1;for(let t=0;t<8;++t){const e=this._clipPosition[t],r=0===t||3===t||4===t||7===t?i[0]:a[0],n=0===t||1===t||4===t||5===t?i[1]:a[1],o=t<4?i[2]:a[2];e[0]=s[0]*r+s[4]*n+s[8]*o+s[12],e[1]=s[1]*r+s[5]*n+s[9]*o+s[13],e[2]=s[2]*r+s[6]*n+s[10]*o+s[14],e[3]=s[3]*r+s[7]*n+s[11]*o+s[15]}for(let t=0;t<12;++t){const r=B(this._clipPosition[y[t][0]],this._clipPosition[y[t][1]],this._clipPosition[y[t][2]]);let n=!0;for(let e=0;e<r.length;++e){if(r[e][3]>=2){n=!1;break}}if(!n){o=!0;for(let t=0;t<r.length;++t){const n=r[t][3];Number.isFinite(n)&&(e.near=Math.min(n,e.near),e.far=Math.max(n,e.far))}}}return o}}function B(e,t,r){let n=[e,t,r];for(let i=0;i<4;++i){const e=n;n=[];for(let t=0;t<e.length;++t){const r=e[t],a=e[(t+1)%e.length];I(a,i)?(I(r,i)||n.push(P(r,a,i)),n.push(a)):I(r,i)&&n.push(P(r,a,i))}}return n}function I(e,t){return 0===t?e[0]>=-e[3]:1===t?e[1]>=-e[3]:2===t?e[0]<=e[3]:3===t?e[1]<=e[3]:void c(!1)}function P(e,t,r){let n=0;return 0===r?n=(-e[3]-e[0])/(t[0]-e[0]+t[3]-e[3]):1===r?n=(-e[3]-e[1])/(t[1]-e[1]+t[3]-e[3]):2===r?n=(e[3]-e[0])/(t[0]-e[0]-t[3]+e[3]):3===r&&(n=(e[3]-e[1])/(t[1]-e[1]-t[3]+e[3])),i(a(),e,t,n)}const y=[[0,1,3],[2,3,1],[1,5,2],[6,2,5],[5,4,6],[7,6,4],[4,0,7],[3,7,0],[3,2,7],[6,7,2],[4,5,0],[1,0,5]],A=new o,D=r(),E=new h,S=new R,F=new v,W=new C;export{g as depthRangeFromScene};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import"../core/shaderLibrary/Slice.glsl.js";import"../core/shaderLibrary/Transform.glsl.js";import"../core/shaderLibrary/attributes/ObjectAndLayerIdColor.glsl.js";import"../core/shaderLibrary/shading/TerrainDepthTest.glsl.js";import"../core/shaderLibrary/util/ColorConversion.glsl.js";import"../core/shaderLibrary/util/View.glsl.js";import"../core/shaderModules/FloatPassUniform.js";import"../core/shaderModules/glsl.js";import"../core/shaderModules/Texture2DPassUniform.js";import"./OutputColorHighlightOLID.glsl.js";import"../../../webgl/NoParameters.js";import"../../../webgl/ShaderBuilder.js";export{a as ImageMaterialPassParameters,b as build}from"../../../../chunks/ImageMaterial.glsl.js";
2
+ import"../core/shaderLibrary/Slice.glsl.js";import"../core/shaderLibrary/Transform.glsl.js";import"../core/shaderLibrary/shading/TerrainDepthTest.glsl.js";import"../core/shaderLibrary/util/ColorConversion.glsl.js";import"../core/shaderLibrary/util/View.glsl.js";import"../core/shaderModules/FloatPassUniform.js";import"../core/shaderModules/glsl.js";import"../core/shaderModules/Texture2DPassUniform.js";import"./OutputColorHighlightOLID.glsl.js";import"../../../webgl/NoParameters.js";import"../../../webgl/ShaderBuilder.js";export{a as ImageMaterialPassParameters,b as build}from"../../../../chunks/ImageMaterial.glsl.js";
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import"../core/shaderLibrary/util/View.glsl.js";import"../core/shaderModules/Float4PassUniform.js";import"../core/shaderModules/FloatPassUniform.js";import"../core/shaderModules/glsl.js";import"./alphaCutoff.glsl.js";import"../../../webgl/ShaderBuilder.js";export{b as build}from"../../../../chunks/MeasurementArrow.glsl.js";
2
+ import"../core/shaderLibrary/util/View.glsl.js";import"../core/shaderModules/Float4PassUniform.js";import"../core/shaderModules/FloatPassUniform.js";import"../core/shaderModules/glsl.js";import"./OutputColorHighlightOLID.glsl.js";import"../../../webgl/ShaderBuilder.js";export{b as build}from"../../../../chunks/MeasurementArrow.glsl.js";
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{subclass as r}from"../../../../core/accessorSupport/decorators.js";import{glLayout as o}from"../../support/buffer/glUtil.js";import{newLayout as t}from"../../support/buffer/InterleavedLayout.js";import{ReloadableShader as s}from"../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as i}from"../core/shaderTechnique/ShaderTechnique.js";import{blending as n}from"../lib/OrderIndependentTransparency.js";import{M as p}from"../../../../chunks/MeasurementArrow.glsl.js";import{PrimitiveType as l}from"../../../webgl/enums.js";import{makePipelineState as a,defaultColorWrite as m,defaultDepthWrite as f}from"../../../webgl/renderState.js";let u=class extends i{constructor(e,r){super(e,r,o(c)),this.shader=new s(p,()=>import("./MeasurementArrow.glsl.js")),this.primitiveType=l.TRIANGLE_STRIP}initializePipeline(e){return a({blending:e.transparent?n(e.oitPass):null,polygonOffset:e.polygonOffsetEnabled?{factor:0,units:-4}:null,depthTest:{func:513},depthWrite:f,colorWrite:m})}};u=e([r("esri.views.3d.webgl-engine.shaders.MeasurementArrowTechnique")],u);const c=t().vec3f("position").vec3f("normal").vec2f("uv0").f32("length");export{u as MeasurementArrowTechnique,c as layout};
2
+ import{__decorate as e}from"tslib";import{subclass as r}from"../../../../core/accessorSupport/decorators.js";import{glLayout as s}from"../../support/buffer/glUtil.js";import{newLayout as o}from"../../support/buffer/InterleavedLayout.js";import{ReloadableShader as t}from"../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as i}from"../core/shaderTechnique/ShaderTechnique.js";import{drawBuffers as n,blending as p}from"../lib/OrderIndependentTransparency.js";import{M as a}from"../../../../chunks/MeasurementArrow.glsl.js";import{PrimitiveType as l}from"../../../webgl/enums.js";import{makePipelineState as m,defaultColorWrite as f,defaultDepthWrite as u}from"../../../webgl/renderState.js";let c=class extends i{constructor(e,r){super(e,r,s(d)),this.shader=new t(a,()=>import("./MeasurementArrow.glsl.js")),this.primitiveType=l.TRIANGLE_STRIP}initializePipeline(e){const{transparent:r,oitPass:s,polygonOffsetEnabled:o,hasEmission:t}=e;return m({blending:r?p(s):null,polygonOffset:o?{factor:0,units:-4}:null,depthTest:{func:513},depthWrite:u,drawBuffers:n(s,t),colorWrite:f})}};c=e([r("esri.views.3d.webgl-engine.shaders.MeasurementArrowTechnique")],c);const d=o().vec3f("position").vec3f("normal").vec2f("uv0").f32("length");export{c as MeasurementArrowTechnique,d as layout};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as o}from"tslib";import{parameter as t}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{DefaultTechniqueConfiguration as e}from"../materials/DefaultTechniqueConfiguration.js";class r extends e{constructor(){super(...arguments),this.polygonOffsetEnabled=!1,this.transparent=!1}}o([t()],r.prototype,"polygonOffsetEnabled",void 0),o([t()],r.prototype,"transparent",void 0);export{r as MeasurementArrowTechniqueConfiguration};
2
+ import{__decorate as e}from"tslib";import{parameter as t}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{DefaultTechniqueConfiguration as o}from"../materials/DefaultTechniqueConfiguration.js";class r extends o{constructor(){super(...arguments),this.polygonOffsetEnabled=!1,this.transparent=!1,this.discardInvisibleFragments=!0,this.draped=!1,this.emissionSource=0,this.snowCover=!1,this.textureCoordinateType=0}}e([t()],r.prototype,"polygonOffsetEnabled",void 0),e([t()],r.prototype,"transparent",void 0);export{r as MeasurementArrowTechniqueConfiguration};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import"../core/shaderLibrary/ScreenSpacePass.glsl.js";import"../core/shaderLibrary/shading/calculateUVZShadowFromDepth.glsl.js";import"../core/shaderLibrary/shading/ShadowmapFiltering.glsl.js";import"../core/shaderModules/glsl.js";import"../core/shaderModules/Texture2DBindUniform.js";import"../core/shaderModules/Texture2DShadowBindUniform.js";import"../../../webgl/ShaderBuilder.js";export{S as ShadowCastMaxSamples,b as build}from"../../../../chunks/ShadowCastAccumulate.glsl.js";
2
+ import"../core/shaderLibrary/ScreenSpacePass.glsl.js";import"../core/shaderLibrary/shading/calculateUVZShadowFromDepth.glsl.js";import"../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import"../core/shaderLibrary/shading/ShadowmapFiltering.glsl.js";import"../core/shaderModules/glsl.js";import"../core/shaderModules/Texture2DBindUniform.js";import"../../../webgl/ShaderBuilder.js";export{S as ShadowCastMaxSamples,b as build}from"../../../../chunks/ShadowCastAccumulate.glsl.js";
@@ -1,8 +1,12 @@
1
+ import type MediaLayer from "../../layers/MediaLayer.js";
2
+ import type MediaLayerInteractionOptions from "../3d/layers/support/MediaLayerInteractionOptions.js";
1
3
  import type LayerView from "./LayerView.js";
2
- import type { MediaLayerViewMixin, MediaLayerViewMixinProperties } from "./MediaLayerViewMixin.js";
4
+ import type { ResourceHandle } from "../../core/Handles.js";
5
+ import type { MediaElement } from "../../layers/media/types.js";
6
+ import type { LayerViewHighlightOptions } from "./types.js";
3
7
  import type { LayerViewProperties } from "./LayerView.js";
4
8
 
5
- export interface MediaLayerViewProperties extends LayerViewProperties, MediaLayerViewMixinProperties {}
9
+ export interface MediaLayerViewProperties extends LayerViewProperties, Partial<Pick<MediaLayerView, "interactionOptions" | "interactive" | "selectedElement">> {}
6
10
 
7
11
  /**
8
12
  * Represents the [LayerView](https://developers.arcgis.com/javascript/latest/references/core/views/layers/LayerView/) of a [MediaLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/MediaLayer/)
@@ -27,5 +31,87 @@ export interface MediaLayerViewProperties extends LayerViewProperties, MediaLaye
27
31
  * @since 4.30
28
32
  * @see [MediaLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/MediaLayer/)
29
33
  */
30
- export default abstract class MediaLayerView extends MediaLayerViewSuperclass {}
31
- declare const MediaLayerViewSuperclass: typeof LayerView & typeof MediaLayerViewMixin
34
+ export default abstract class MediaLayerView extends LayerView {
35
+ /**
36
+ * Options for when the layer view is interactive.
37
+ *
38
+ * > [!WARNING]
39
+ * >
40
+ * > Interactivity for 2D [MapViews](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/) was added at version 4.31.
41
+ *
42
+ * @since 4.30
43
+ * @see [interactive](https://developers.arcgis.com/javascript/latest/references/core/views/layers/MediaLayerView/#interactive)
44
+ */
45
+ accessor interactionOptions: MediaLayerInteractionOptions;
46
+ /**
47
+ * Enables interactivity for the [layer](https://developers.arcgis.com/javascript/latest/references/core/views/layers/MediaLayerView/#layer). When set to `true`, any elements in the
48
+ * layer's [MediaLayer.source](https://developers.arcgis.com/javascript/latest/references/core/layers/MediaLayer/#source) become selectable and editable.
49
+ *
50
+ * > [!WARNING]
51
+ * >
52
+ * > Interactivity for 2D [MapViews](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/) was added at version 4.31.
53
+ *
54
+ * @default false
55
+ * @since 4.30
56
+ * @see [selectedElement](https://developers.arcgis.com/javascript/latest/references/core/views/layers/MediaLayerView/#selectedElement)
57
+ * @see [interactionOptions](https://developers.arcgis.com/javascript/latest/references/core/views/layers/MediaLayerView/#interactionOptions)
58
+ * @example
59
+ * view.whenLayerView(mediaLayer).then((mediaLayerView) => {
60
+ * // Enable interactivity and select first element
61
+ * mediaLayerView.interactive = true;
62
+ *
63
+ * mediaLayerView.selectedElement = mediaLayer.source.elements.at(0);
64
+ * });
65
+ */
66
+ accessor interactive: boolean;
67
+ /**
68
+ * The layer being viewed.
69
+ *
70
+ * @since 5.0
71
+ */
72
+ get layer(): MediaLayer;
73
+ /**
74
+ * The selected element. If [interactive](https://developers.arcgis.com/javascript/latest/references/core/views/layers/MediaLayerView/#interactive) is `true`, any element in the
75
+ * [layer](https://developers.arcgis.com/javascript/latest/references/core/views/layers/MediaLayerView/#layer) can be selected by clicking on it in the view. As long as [interactive](https://developers.arcgis.com/javascript/latest/references/core/views/layers/MediaLayerView/#interactive)
76
+ * remains `true`, the properties of the selected element can be edited by interacting with
77
+ * manipulators in the view.
78
+ *
79
+ * > [!WARNING]
80
+ * >
81
+ * > Interactivity for 2D [MapViews](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/) was added at version 4.31.
82
+ *
83
+ * @since 4.30
84
+ * @see [interactive](https://developers.arcgis.com/javascript/latest/references/core/views/layers/MediaLayerView/#interactive)
85
+ * @example
86
+ * view.whenLayerView(mediaLayer).then((mediaLayerView) => {
87
+ * // Enable interactivity and select first element
88
+ * mediaLayerView.interactive = true;
89
+ *
90
+ * mediaLayerView.selectedElement = mediaLayer.source.elements.at(0);
91
+ * });
92
+ */
93
+ accessor selectedElement: MediaElement | null | undefined;
94
+ /**
95
+ * Highlights the given media element(s) in a MediaLayerView. Highlights are only supported in
96
+ * [3D SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/) or [Scene component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-scene/).
97
+ *
98
+ * @param target - The media element(s) to highlight.
99
+ * @param options - An object with the following properties.
100
+ * @returns Returns a highlight handler with a `remove()` method that
101
+ * can be called to remove the highlight.
102
+ * @since 5.0
103
+ * @see [SceneView.highlights](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#highlights)
104
+ * @see [Sample: Highlight SceneLayer](https://developers.arcgis.com/javascript/latest/sample-code/highlight-scenelayer/)
105
+ * @example
106
+ * // Add a new set of highlight options to the highlights collection
107
+ * const highlightName = "mark";
108
+ * view.highlights.push({ name: highlightName, color: "red", fillOpacity: 0.5 });
109
+ *
110
+ * // Highlight a specific media element
111
+ * view.whenLayerView(layer).then((layerView) => {
112
+ * let element = layer.source.elements.getItemAt(0);
113
+ * layerView.highlight(element, { name: highlightName } );
114
+ * });
115
+ */
116
+ highlight(target: MediaElement | Iterable<MediaElement>, options?: LayerViewHighlightOptions): ResourceHandle;
117
+ }
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import e from"./LayerView.js";import{MediaLayerViewMixin as i}from"./MediaLayerViewMixin.js";class r extends(i(e)){}export{r as default};
2
+ import{__decorate as t}from"tslib";import{property as e}from"../../core/accessorSupport/decorators.js";import o from"../3d/layers/support/MediaLayerInteractionOptions.js";import r from"./LayerView.js";class i extends r{constructor(){super(...arguments),this.layer=null,this.interactive=!1,this.interactionOptions=new o,this.selectedElement=null}highlight(t,e){throw new Error("missing implementation")}}t([e()],i.prototype,"layer",void 0),t([e()],i.prototype,"interactive",void 0),t([e({type:o})],i.prototype,"interactionOptions",void 0),t([e()],i.prototype,"selectedElement",void 0);export{i as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{createResolver as e}from"../../core/promiseUtils.js";import{whenOnce as r}from"../../core/reactiveUtils.js";import{debug as t}from"../../core/scheduling.js";import{dispatch as o}from"../../core/accessorSupport/watch.js";function s(e){switch(e.type){case"2d":return i(e);case"3d":if(e)return o(),t.dispatch(),r(()=>!e.updating)}return Promise.resolve()}function i(r){const s=e();let i=performance.now();const n=()=>(o(),t.dispatch(),!r.ready||r.updating||!r.stationary||r.rendering);function c(){if(!r.destroyed&&n())i=null,setTimeout(c,16);else{i||(i=performance.now());performance.now()-i>=100?s():setTimeout(c,16)}}return setTimeout(c,16),s.promise}export{s as default};
2
+ import{createResolver as e}from"../../core/promiseUtils.js";import{whenOnce as r}from"../../core/reactiveUtils.js";import{debug as t}from"../../core/scheduling.js";import{dispatch as o}from"../../core/accessorSupport/watch.js";function n(e){switch(e.type){case"2d":return i(e);case"3d":return o(),t.dispatch(),r(()=>!e.updating).then(()=>s(e));default:return Promise.resolve()}}function s(e){const r="3d"===e.type?e.resourceController?.scheduler?.test?.getRunning()??null:null;if(null!=r)throw new Error(`View is not updating, but scheduler is running:${r} at ${(new Error).stack}`)}function i(r){const n=e();let s=performance.now();const i=()=>(o(),t.dispatch(),!r.ready||r.updating||!r.stationary||r.rendering);function c(){if(!r.destroyed&&i())s=null,setTimeout(c,16);else{s||(s=performance.now());performance.now()-s>=100?n():setTimeout(c,16)}}return setTimeout(c,16),n.promise}export{n as default};