@arcgis/core 5.0.0-next.35 → 5.0.0-next.36

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 (169) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/06462b267ff8d5984882.js +1 -0
  3. package/assets/esri/core/workers/chunks/{b48bb38e5d60fc7a9097.js → 08ef90e3fcfd4eda4301.js} +1 -1
  4. package/assets/esri/core/workers/chunks/0a58b57e1777a8b0ea23.js +1 -0
  5. package/assets/esri/core/workers/chunks/{7115c52e22b7becff8de.js → 103153951ba312dc5e9e.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{f55328aabf84770c8e6a.js → 1817cf11e85afca947d3.js} +1 -1
  7. package/assets/esri/core/workers/chunks/20e4243ea563d05a5256.js +1 -0
  8. package/assets/esri/core/workers/chunks/24a3c6f0154787968724.js +1 -0
  9. package/assets/esri/core/workers/chunks/{fafbacf2467e6883b6c9.js → 28db329528def851efd7.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{2367bd1cb34799a3f08a.js → 30184e39129d9c66ea54.js} +1 -1
  11. package/assets/esri/core/workers/chunks/3f03165487c1c2340fff.js +1 -0
  12. package/assets/esri/core/workers/chunks/48e2737182c75005fb8f.js +1 -0
  13. package/assets/esri/core/workers/chunks/{05e55118dc0023d500fc.js → 5000a37fba27464d10ca.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{fa01d1813fa78034526e.js → 51355866a0dcf41cfded.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{a372d9af43ade7c6314c.js → 52c8687b473c9953c2f2.js} +1 -1
  16. package/assets/esri/core/workers/chunks/640085b5ade5c7f16228.js +1 -0
  17. package/assets/esri/core/workers/chunks/727804cf901094b1d620.js +1 -0
  18. package/assets/esri/core/workers/chunks/{0446562aee0639c61485.js → 7420fa18ba12014b22ea.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{c9c2e00fed979c21e2f0.js → 8a946cbc816f373c136b.js} +1 -1
  20. package/assets/esri/core/workers/chunks/8c271e9272e4eaf1325a.js +1 -0
  21. package/assets/esri/core/workers/chunks/{2a0fe1aede5c68374ccf.js → 8ec238b5b59ef18a1713.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{f1dfb1323d50247e80f9.js → 9110287f272141f60c35.js} +1 -1
  23. package/assets/esri/core/workers/chunks/951a3442d4342539f2ea.js +1 -0
  24. package/assets/esri/core/workers/chunks/9664d9e679abc41f6c42.js +1 -0
  25. package/assets/esri/core/workers/chunks/{2921f05a40fda12f9f81.js → a00bba1c7cbf8cd7892c.js} +1 -1
  26. package/assets/esri/core/workers/chunks/a716b8fdeda4e16f03ab.js +1 -0
  27. package/assets/esri/core/workers/chunks/aead7c9830fa310e5b53.js +1 -0
  28. package/assets/esri/core/workers/chunks/{483dc4ee5d73cdfe6229.js → b075d3714fab0591d67c.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{82cc758bddd9f8397b9f.js → b451dc416eebd0931ef8.js} +4 -4
  30. package/assets/esri/core/workers/chunks/b59be95949445ff5afab.js +1 -0
  31. package/assets/esri/core/workers/chunks/b6dec5dfdeca54bae88d.js +1 -0
  32. package/assets/esri/core/workers/chunks/{4356274cfa477eb6d749.js → bfb9cbe59d36d18f9157.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{6afd59412bfc134bdf75.js → c052fb8c952cda0b5d13.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{f2ebd6471e1259a6eac0.js → c9e7cc5d853908ab5b2f.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{97650ee3d0eecb69ccbb.js → d8623f5f13a084e439c2.js} +5 -5
  36. package/assets/esri/core/workers/chunks/dd105d6e0fcedee32644.js +1 -0
  37. package/assets/esri/core/workers/chunks/e1148067ceae7d9eaaf8.js +1 -0
  38. package/assets/esri/core/workers/chunks/{b536fdb655ad293d9024.js → eb6218634a492667506a.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{7804be2f5b3d86188a24.js → edc3d98f33d7bf959154.js} +1 -1
  40. package/assets/esri/core/workers/chunks/eefad79be500667af96e.js +1 -0
  41. package/assets/esri/core/workers/chunks/{63933cbcb5c12df09715.js → f1ac1c8b1331ec79e898.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{2b7f9a57a2cfbc108673.js → f1b99529e2055873b65a.js} +1 -1
  43. package/assets/esri/core/workers/chunks/f693a4d97b2762d0e6ff.js +1 -0
  44. package/assets/esri/core/workers/chunks/f8caceeaa14d99c35526.js +1 -0
  45. package/assets/esri/core/workers/chunks/febce0d80f019dc2a427.js +1 -0
  46. package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core-simd.wasm +0 -0
  47. package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core.wasm +0 -0
  48. package/assets/esri/themes/base/widgets/_Attribution.scss +1 -0
  49. package/assets/esri/themes/dark/main.css +1 -1
  50. package/assets/esri/themes/light/main.css +1 -1
  51. package/assets/esri/themes/light/view.css +1 -1
  52. package/chunks/Magnifier.glsl.js +1 -1
  53. package/chunks/arcgis-knowledge-client-core-simd.js +1 -1
  54. package/chunks/arcgis-knowledge-client-core.js +1 -1
  55. package/chunks/cameraUtilsSpherical.js +1 -1
  56. package/chunks/vec42.js +1 -1
  57. package/config.js +1 -1
  58. package/core/libs/gl-matrix-2/math/quat.js +1 -1
  59. package/core/libs/gl-matrix-2/math/vec4.js +1 -1
  60. package/geometry/support/aaBoundingRect.js +1 -1
  61. package/geometry/support/buffer/BufferView.js +1 -1
  62. package/geometry/support/buffer/internals/Vec4.js +1 -1
  63. package/interfaces.d.ts +108 -0
  64. package/kernel.js +1 -1
  65. package/layers/GaussianSplatLayer.js +1 -1
  66. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  67. package/layers/IntegratedMeshLayer.js +1 -1
  68. package/package.json +1 -1
  69. package/rest/knowledgeGraph/DataModel.js +1 -1
  70. package/rest/knowledgeGraph/GraphDataModelSingletonOperationResult.d.ts +4 -0
  71. package/rest/knowledgeGraph/GraphDataModelSingletonOperationResult.js +5 -0
  72. package/rest/knowledgeGraph/GraphProperty.js +1 -1
  73. package/rest/knowledgeGraph/wasmInterface/WasmDataModelWrapperInterfaces.js +1 -1
  74. package/rest/knowledgeGraph/wasmInterface/updateToWasmEncodedFactories.js +1 -1
  75. package/rest/knowledgeGraph/wasmInterface/wasmToDataModelChangeResponseFactories.js +1 -1
  76. package/rest/knowledgeGraph/wasmInterface/wasmToDataModelFactories.js +1 -1
  77. package/rest/knowledgeGraphService.d.ts +3 -0
  78. package/rest/knowledgeGraphService.js +1 -1
  79. package/support/revision.js +1 -1
  80. package/views/3d/GroundView3D.js +1 -1
  81. package/views/3d/analysis/ElevationProfile/ElevationProfileLineSceneComputation.js +1 -1
  82. package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
  83. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  84. package/views/3d/environment/Fog.js +1 -1
  85. package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
  86. package/views/3d/interactive/visualElements/MeasurementAreaVisualElement.js +1 -1
  87. package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
  88. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  89. package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
  90. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  91. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  92. package/views/3d/interactive/visualElements/SlicePlaneVisualElement.js +1 -1
  93. package/views/3d/interactive/visualElements/VerticesVisualElement.js +1 -1
  94. package/views/3d/layers/DrapedSubView3D.js +1 -1
  95. package/views/3d/layers/I3SMeshView3D.js +1 -1
  96. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  97. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  98. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  99. package/views/3d/layers/graphics/Graphics3DFrustumVisibility.js +1 -1
  100. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  101. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  102. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  103. package/views/3d/layers/graphics/graphicUtils.js +1 -1
  104. package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
  105. package/views/3d/layers/support/FastSymbolUpdates.js +1 -1
  106. package/views/3d/layers/support/Tiles3DIntersectionHandler.js +1 -1
  107. package/views/3d/state/ConstraintsManager.js +1 -1
  108. package/views/3d/state/ViewStateManager.js +1 -1
  109. package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
  110. package/views/3d/support/gaussianSplatting/GaussianSplatFadeTexture.js +1 -1
  111. package/views/3d/support/gaussianSplatting/GaussianSplatOrderTexture.js +1 -1
  112. package/views/3d/support/gaussianSplatting/GaussianSplatTextureAtlas.js +1 -1
  113. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  114. package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
  115. package/views/3d/support/pointsOfInterest/StableSurfaceCenter.js +1 -1
  116. package/views/3d/terrain/Overlay.js +1 -1
  117. package/views/3d/terrain/OverlayManager.js +1 -1
  118. package/views/3d/terrain/PatchRenderData.js +1 -1
  119. package/views/3d/terrain/ScaleRangeQueries.js +1 -1
  120. package/views/3d/terrain/TerrainSurface.js +1 -1
  121. package/views/3d/terrain/TextureFader.js +1 -1
  122. package/views/3d/terrain/TextureReference.js +1 -1
  123. package/views/3d/terrain/Tile.js +1 -1
  124. package/views/3d/webgl/RenderCamera.js +1 -1
  125. package/views/3d/webgl-engine/collections/Component/Material/ComponentData.glsl.js +1 -1
  126. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js +1 -1
  127. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateAmbientLighting.glsl.js +1 -1
  128. package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterDistortion.glsl.js +1 -1
  129. package/views/3d/webgl-engine/core/shaderLibrary/util/CameraSpace.glsl.js +2 -2
  130. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  131. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  132. package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
  133. package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
  134. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  135. package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
  136. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  137. package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
  138. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBuffer.js +1 -1
  139. package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
  140. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  141. package/views/3d/webgl-engine/shaders/AnimatedLine.glsl.js +1 -1
  142. package/views/3d/webgl-engine/shaders/ensureColor4.js +1 -1
  143. package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +5 -5
  144. package/views/SceneView.js +1 -1
  145. package/views/interactive/coordinateHelper.js +1 -1
  146. package/views/interactive/sketch/constraints.js +1 -1
  147. package/views/support/GroundElevationSampler.js +1 -1
  148. package/widgets/support/SelectionList.js +1 -1
  149. package/assets/esri/core/workers/chunks/032444974011118127d7.js +0 -1
  150. package/assets/esri/core/workers/chunks/089221bac1f019692f48.js +0 -1
  151. package/assets/esri/core/workers/chunks/1bfe0b2bf38d4dee7fd6.js +0 -1
  152. package/assets/esri/core/workers/chunks/27bd88e1101873d4ce12.js +0 -1
  153. package/assets/esri/core/workers/chunks/53d95ba86d010231fc4e.js +0 -1
  154. package/assets/esri/core/workers/chunks/7d3e665613927904ba4f.js +0 -1
  155. package/assets/esri/core/workers/chunks/a5f2da24497349239648.js +0 -1
  156. package/assets/esri/core/workers/chunks/a7b1b42bdb9cb9ecac45.js +0 -1
  157. package/assets/esri/core/workers/chunks/acaaefd4997316d319b8.js +0 -1
  158. package/assets/esri/core/workers/chunks/ad138b989c2c7a1168ac.js +0 -1
  159. package/assets/esri/core/workers/chunks/cc7c37f9ed3f831fd25c.js +0 -1
  160. package/assets/esri/core/workers/chunks/d14bd320f72d8e8a0ad8.js +0 -1
  161. package/assets/esri/core/workers/chunks/d86e59da76eea888ba86.js +0 -1
  162. package/assets/esri/core/workers/chunks/de99c4fd1582a8e610cf.js +0 -1
  163. package/assets/esri/core/workers/chunks/ded3ef385d5a3a2ec8ca.js +0 -1
  164. package/assets/esri/core/workers/chunks/e3a994587f9b2e88db85.js +0 -1
  165. package/assets/esri/core/workers/chunks/eab0938d4ad7d7cc7309.js +0 -1
  166. package/assets/esri/core/workers/chunks/ed1dabed10ff9f4e0369.js +0 -1
  167. package/assets/esri/core/workers/chunks/ef5b13ee3362763c1096.js +0 -1
  168. package/assets/esri/core/workers/chunks/effbc4d240752e8ba0ab.js +0 -1
  169. package/assets/esri/core/workers/chunks/f403d8e414766fab2936.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{unitRGBAFromColor as i}from"../../../../core/colorUtils.js";import"../../../../core/has.js";import{clamp as s,lerp as a}from"../../../../core/mathUtils.js";import{removeMaybe as n,abortMaybe as h,destroyMaybe as o,releaseMaybe as d}from"../../../../core/maybe.js";import{throwIfAborted as _}from"../../../../core/promiseUtils.js";import{watch as l,syncAndInitial as u,initial as p,sync as m}from"../../../../core/reactiveUtils.js";import{signal as c}from"../../../../core/signal.js";import{Milliseconds as f}from"../../../../core/time.js";import{property as g,subclass as b}from"../../../../core/accessorSupport/decorators.js";import{equals as P,invert as C,multiply as w}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as T,create as S}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as x}from"../../../../chunks/vec42.js";import{ZEROS as E}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{fromValues as A,ZEROS as D}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as I}from"../../../../geometry/support/Indices.js";import{RenderCategory as R,InternalRenderCategory as y}from"../../webgl.js";import{innerAtmosphereFadeStart as O}from"../../environment/atmosphereUtils.js";import{minNearDistanceInMeters as F}from"../../state/NearFarHeuristic.js";import{debugFlags as v}from"../../support/debugFlags.js";import{FBOCache as H,defaultWebGLFBO as M}from"../core/FBOCache.js";import{RenderPassManager as N}from"../core/renderPasses/RenderPassManager.js";import{isColor as q}from"../core/shaderLibrary/ShaderOutput.js";import{distanceFadeEnd as G}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as L}from"../effects/RenderNodes.js";import{RenderPluginManager as U}from"../effects/RenderPluginManager.js";import{Blit as V}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as j,renderHighlightBuffer as B}from"../effects/highlight/Highlight.js";import{OITBlend as k}from"../effects/transparency/OITBlend.js";import{AnimationTimer as z}from"./AnimationTimer.js";import{AnimationTimeStep as W}from"./AnimationTimeStep.js";import{BoundingInfo as Q}from"./BoundingInfo.js";import{DepthRange as Y}from"./DepthRange.js";import{depthRangeFromScene as Z}from"./depthRangeUtils.js";import{hudFragmentOpacityParameters as J}from"./hudFragmentOpacityParameters.js";import{MainFramebuffer as K}from"./MainFramebuffer.js";import{RenderContext as X,defaultRenderOccludedMask as $}from"./RenderContext.js";import{RendererBase as ee}from"./RendererBase.js";import{setupFeatureDefaults as te}from"./RenderFeature.js";import{RenderPluginInput as re}from"./RenderPluginInput.js";import{ShadowAccumulator as ie}from"./ShadowAccumulator.js";import{ShadowMap as se}from"./ShadowMap.js";import ae from"./SliceHelper.js";import{MergedRenderer as ne}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as he}from"../parts/renderUtils.js";import{RendererPerformanceInfo as oe,PerformanceCategory as de}from"../statistics/RendererPerformanceInfo.js";import{PixelType as _e,ColorAttachment1 as le,ColorAttachment2 as ue}from"../../../webgl/enums.js";let pe=class extends ee{constructor(e,t,r,s,a,n){super({stage:e}),this._techniques=r,this._rctx=s,this._compositingHelper=a,this._requestRender=n,this._pluginsHas={hudElements:!1,water:!1},this.renderPassManager=new N,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=A(0,0,0,1),this._sliceHelper=new ae,this._blit=null,this._oitblend=null,this.sceneDepthRange=c(Y.Infinite),this._state=c(2),this._hasAnimations=!1,this._animationTimestep=new W,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=c(0),this._lastFrameTime=f(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new re,this._releaseNormals=e=>{e.some(({name:e})=>"normals"===e)&&this._pluginInput.release("normals")},this._debugNeedsDepth=!1,this._fboCache=new H(s),this._renderStateFeatures=c(te(e.view.qualityProfile)),this._framebuffer=new K(this.fboCache),this._performanceInfo=new oe(this._rctx),this._shadowMap=new se(this.fboCache,e.viewingMode),this._shadowAccumulator=new ie(this.fboCache,r,e,e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t},(t,r,i)=>{const s=e.view.qualitySettings.maximumPixelRatio;t.shadowMap.start(t.camera,r,i,!0,s),this._renderShadowCascades(3,t.shadowMap),t.shadowMap.finish(),t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.contentCamera)},n),this._renderContext=new X(this._rctx,this._shadowMap,r),this._nodes=new L(this._renderContext),this._plugins=new U({renderContext:this._renderContext,techniques:r,materials:t,requestRender:n,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this.addHandles([l(()=>e.view.state.camera,()=>n(),u),l(()=>v.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES,e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(0):()=>{},n()},p),l(()=>e.view.environment.background?.color,e=>{const t=e?i(e):D;x(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()},u),l(()=>e.view.state.camera.relativeElevation,e=>this._inGlobeView=(e??1/0)>=G,u),l(()=>this._bindParameters.clouds.fadeFactor,()=>{this._bindParameters.fadeLighting(),this._requestRender(2)},m),l(()=>this._bindParameters.clouds.data?.state,()=>n(),m),l(()=>e.view.state.highlights,e=>{this._bindParameters.highlights=e,n()},p)])}destroy(){this._gpuTimerHandle=n(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.destroy(),this._shadowAccumulator=null,this._loadEdgeViewTask=h(this._loadEdgeViewTask),this._edgeView=o(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._blit=null,this._oitblend=null,this._compositingHelper=null,this._nodes=null,this._framebuffer=null,this._shadowMap=null,this._renderContext=null,this._performanceInfo=null,Q.prune(),ne.prune(),I()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _framebufferSize(){return this._framebuffer.size}get performanceInfo(){return this._performanceInfo}updateRenderFeatures(e){this._renderStateFeatures.value=te(e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate(i=>i.set(t,e,r)),this._requestRender()}get _highQualityTransparency(){return this.isFeatureEnabled(1)}get hasReflections(){return this._pluginsHas.water&&this.isFeatureEnabled(5)}get _hasHighlights(){return this._plugins.produces(8,2,4,18,13,14)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(8,13,14)}get hasSSAO(){return this.isFeatureEnabled(4)&&!this._inGlobeView}get hasSMAA(){return this.isFeatureEnabled(0)}get hasEmitters(){return this._plugins.hasEmitters&&this.stage.view.qualitySettings.physicallyBasedRenderingEnabled}get highResolutionAtmosphere(){return this.isFeatureEnabled(3)}get fboCache(){return this._fboCache}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=d(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.depth=d(this._bindParameters.depth),this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility)}get updating(){return this._loadEdgeViewTask&&!this._loadEdgeViewTask.finished||this._edgeView?.updating||this._shadowAccumulator.readyToRun||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=r(async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");_(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this.stage.view.renderSpatialReference,viewingMode:this.stage.view.stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:xe(this.stage.view.resourceController)});return this.addHandles(l(()=>r.updating,()=>this._requestRender(),m)),this._requestRender(),this._edgeViewCallbacks.forEach(e=>e(r)),this._edgeViewCallbacks.length=0,r})),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&P(this._bindParameters.ssr.reprojectionMatrix,T)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:r}=this;if(void 0!==e.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())}void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}set slice(e){this._sliceHelper.update(e)&&this._requestRender()}get plugins(){return this._plugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}commit(e,t){return this._isRendering&&console.warn("Renderer.modify called while rendering"),!!super.commit(e,t,this._plugins.context)&&(this.updateHasFlags(),!0)}rendererAdded(e){this._plugins.add(e)}rendererRemoved(e){this._plugins.remove(e)}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,9)}updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(0,...Pe),has.water=this._plugins.produces(2,19),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new z(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const r=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?n(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,r,i=!1){try{return this._isRendering=!0,this._render(e,t,r,i)}catch(s){console.error(`Exception during rendering: ${s}`)}finally{this._isRendering=!1}return new he(this._pluginInput.get(R.FINAL),null)}_updateHUDOccludedFragmentOpacity(e,t){const{idleOpacity:r,navigatingOpacity:i,maxDelta:n,tiltFadeStart:h,tiltFadeEnd:o,altitudeStart:d,altitudeEnd:_}=J,l=this.stage.view,u=l.stateManager.camera,p=l.qualitySettings.fadeDuration,m=2===e?r:i,c=s((u.tilt-h)/(o-h),0,1),f=s(((u.position.z??0)-d)/(_-d),0,1),g=a(a(1,m,c),1,f),b=this._bindParameters.hudOccludedFragmentOpacity;if(p<=0||b===g||0===this._lastFrameTime||this._lastFrameTime>t)return this._bindParameters.hudOccludedFragmentOpacity=g,void(this._lastFrameTime=t);const P=t-this._lastFrameTime;this._lastFrameTime=t;const C=Math.max(1-r,Math.abs(r-i)),w=Math.min(C*P/p,n);w>=Math.abs(g-b)?this._bindParameters.hudOccludedFragmentOpacity=g:(this._bindParameters.hudOccludedFragmentOpacity=b+Math.sign(g-b)*w,this._requestRender())}_render(e,t,r,i){const s=0===r;this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=s,this._disposeBindBuffers();const{camera:a,contentCamera:n,mode:h,alignPixelEnabled:o}=e;this._state.value=h;const d=this._nodes.produces("magnifier-color"),_=this._nodes.produces(R.FINAL);this._renderContext.time=t,this._renderContext.output=0,this._bindParameters.hasEmission=this.hasEmitters,this._bindParameters.oitPass=0,this._bindParameters.alignPixelEnabled=o,this._bindParameters.decorations=!i,this._bindParameters.mainDepth=null;const l=!i||!this._sliceHelper.isDecoration;this._bindParameters.slicePlane=l?this._sliceHelper.plane:null,this._bindParameters.viewshedEnabled=this._nodes.produces(y.VIEWSHED),this._bindParameters.cutFillEnabled=this._nodes.produces(y.CUTFILL_DEPTH),this._renderOverlay(),a.setGLViewport(this._rctx);const u=this._framebuffer,p=u.initialize(a.fullWidth,a.fullHeight,this._backgroundColor,this._bindParameters.hasEmission);this.hasReflections?(p?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=p):p?.release(),this._ensureBindParametersCamera(a,n),this._updateHUDOccludedFragmentOpacity(h,t),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!i;const m=this._highQualityTransparency&&this._hasTransparentTerrain,c=this._plugins.produces(0,...ge);this._precompilePrepasses(),this.performanceInfo.advance(de.PREPARE);const f=this._computeShadowDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,f),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(f,a,n,!s),this._ensureBindParametersSSR(t),this._precompileShaders(m,c),this._renderContext.output=0,u.bind(),this._bindParameters.mainDepth=u.depth.attachment,this._renderOpaque(m),this._renderTransparent(c,m),this._shadowMap.disposeMainBuffer(),this._pluginInput.set(y.FOCUSAREA,this._renderFocusAreaGeometry()),this._pluginInput.set(y.CUTFILL_DEPTH,this._renderCutFillDepth()),u.update(e=>this._renderNodes(y.TRANSPARENT_ENVIRONMENT,e)),u.update(e=>this._renderNodes(y.VIEWSHED,e)),u.update(e=>this._renderNodes(y.LASERLINES,e)),u.update(e=>this._renderNodes(y.FOCUSAREA_COLOR,e)),this._pluginInput.release(y.FOCUSAREA),this._pluginInput.release(y.CUTFILL_DEPTH),u.update(e=>this._renderNodes(y.OCCLUDED,e)),this._pluginInput.set("highlights",this._renderHighlightPrepass()),this._renderHighlightShadowMap(a,this._bindParameters.lighting.mainLight.direction,f);const g=2===r?this._renderObjectAndLayerIdColor():null;u.update(e=>this._renderNodes(R.COMPOSITE,e)),this._shadowMap.disposeOffscreenBuffers();const b=s&&!_&&!(d&&!i),P=this._pluginInput.get(R.COMPOSITE),C=b?M:this.fboCache.acquire(P.fbo.width,P.fbo.height,y.ANTIALIASING),w=this._nodes.produces(y.ANTIALIASING)?this._renderNodes(y.ANTIALIASING,C):this.blitFBO(P,C,!1);let T;this._pluginInput.set(y.ANTIALIASING,w),this._hasHUDHighlights?(this._renderHUD(1,w),T=this._renderNodes(y.HIGHLIGHTS,w)):(T=this._renderNodes(y.HIGHLIGHTS,w),this._renderHUD(1,T));const S=this._renderNodes(y.MAGNIFIER,T);return s&&d&&!i&&!_&&this.blitFBO(S),_?(S.attachDepth(u.depth),this.blitFBO(this._renderNodes(R.FINAL,S)),S.detachDepth()):this._pluginInput.set(R.FINAL,S),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),u.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),s||(this._releaseFBOs(),this._disposeOffscreenBuffers()),new he(this._pluginInput.get(R.FINAL),g)}_precompileShaders(e,t){++this._plugins.context.techniques.precompiling,this._renderContext.output=0,this._precompileOpaqueGeometry(),this._nodes.precompile(y.OPAQUE_ENVIRONMENT),this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,this._renderContext.output=1,this._plugins.precompile(6),this._plugins.precompile(7),e&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._renderContext.output=0,this._plugins.precompile(6),this._plugins.precompile(7),t&&(this._precompileTransparentGeometry(),this._hasTransparentTerrain&&(this._bindParameters.cullAboveTerrain=!1,this._precompileTransparentGeometry(),this._bindParameters.cullAboveTerrain=e)),this._nodes.precompile(y.FOCUSAREA),this._needsHUDVisibility&&this._plugins.precompile(12),this._plugins.precompile(15),this._precompileHUD(0),this._bindParameters.terrainDepthTest=!1,this._bindParameters.cullAboveTerrain=!1,this._nodes.precompile(y.VIEWSHED,y.CUTFILL_DEPTH,y.CUTFILL_COLOR,y.LASERLINES,y.FOCUSAREA_COLOR,y.OCCLUDED,y.ANTIALIASING,y.HIGHLIGHTS);const r=this._bindParameters;r.highlightMixTexture=r.highlights.length>1?this._rctx.emptyTexture:null,this._precompileHUD(1),this._hasHighlights&&(r.highlights.forEach((e,t)=>{r.highlightLevel=t,this._precompileAllGeometry(8)}),r.highlightLevel=null),r.highlightMixTexture=null,this._nodes.precompile(R.COMPOSITE,y.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(8),--this._plugins.context.techniques.precompiling}_renderFocusAreaGeometry(){const e=this._nodes.produce(y.FOCUSAREA,this._pluginInput);return e&&this.performanceInfo.advance(de.FOCUS_AREA_MASK),e}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._renderContext.output;++this._techniques.precompiling;const t=this._framebufferSize;let r=this.fboCache.acquire(t.width,t.height,"olid");return r.acquireDepth(13),r=this._nodes.render(r,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(de.OBJECT_AND_LAYER_ID_COLOR),this._renderContext.output=e,r}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 i=0;t?i=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const s=Math.max(e,i);this._animationTimestep.frame(s,r)}}readMainDepth(e,t){const{mainDepth:r,camera:i}=this._bindParameters;if(!r)return;const s=this.fboCache.acquire(this._framebufferSize.width,this._framebufferSize.height,"linear depth");this._rctx.bindFramebuffer(s.fbo),i.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(D),this._compositingHelper.blitDepthToLinearDepth(this._bindParameters,r),this._rctx.setScissorTestEnabled(!1),this._rctx.setScissorRect(0,0,this._rctx.gl.canvas.width,this._rctx.gl.canvas.width),s.fbo?.readPixels(e[0],e[1],e[2],e[3],6408,_e.UNSIGNED_BYTE,t),s.release()}readHUDVisibility(e,t,r,i,s){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,i,6408,_e.UNSIGNED_BYTE,s)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"edges"),s=this._bindParameters.geometryDepth,a=()=>t.render(this._bindParameters,e);this.renderToTargets(a,i,s??this._framebuffer.depth,D),this._framebuffer.bind(),this._compositingHelper.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(1===e?de.OPAQUE_EDGES:de.TRANSPARENT_EDGES)}_renderOverlay(){this._bindParameters.overlay=this.overlay?.render(),this._bindParameters.overlay&&this.performanceInfo.advance(de.OVERLAY)}_renderShadowMap(e,t,r){if(!this.shadowsEnabled)return;const i=this._shadowMap;i.start(e,t,r,this.isFeatureEnabled(6),this.stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(5,this._shadowMap),i.copySnapshot(1),this._renderShadowCascades(4,this._shadowMap)):this._renderShadowCascades(3),i.finish(),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,this._bindParameters.contentCamera),this.performanceInfo.advance(de.SHADOW_MAP)}_renderHighlightShadowMap(e,t,r){if(!this.shadowsEnabled||!this._needsShadowHighlight)return;const i=this._shadowMap;i.start(e,t,r,this.isFeatureEnabled(6),this.stage.view.qualitySettings.maximumPixelRatio),this._renderShadowCascades(4,this._shadowMap),i.moveSnapshot(0),i.finish(),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,this._bindParameters.contentCamera),this.performanceInfo.advance(de.SHADOW_MAP)}_renderCutFillDepth(){return this._nodes.produce(y.CUTFILL_DEPTH,this._pluginInput)}_precompileShadowCascades(e){0!==this._shadowMap.cascades.length&&this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){t.bindFbo();for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e)}get _needsDepth(){return this._plugins.consumes(1)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._shadowAccumulator.active||this._debugNeedsDepth}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");e?(this._pluginInput.set(y.SSAO,this._renderSSAO()),this._needsDepth?(this._rctx.bindFramebuffer(e.fbo),this._rctx.clear(1024),this._renderGeometryWithoutNormals(1),d(this._bindParameters.depth),this._bindParameters.depth=e.obtainDepthTexture(),this.performanceInfo.advance(de.DEPTH)):(e.detachDepth(),this._bindParameters.depth=d(this._bindParameters.depth)),this.hasSSAO&&this._pluginInput.release("normals")):this._renderAllGeometryDepth()}_renderAllGeometryDepth(){if(!this._needsDepth)return void(this._bindParameters.depth=d(this._bindParameters.depth));const e=this._framebufferSize,t=this.fboCache.acquire(e.width,e.height,"geometry depth",13);this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(1280),this.renderAllGeometry(1),d(this._bindParameters.depth),this._bindParameters.depth=t.obtainDepthTexture(),t.release(),this.performanceInfo.advance(de.DEPTH)}_renderTerrainDepth(e){if(this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth),this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,!e)return;const t=this._renderContext.output;this._renderContext.output=1;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"terrain depth",13);this._rctx.bindFramebuffer(i.fbo),this._rctx.clear(1280),this._renderTransparentTerrain(),this._bindParameters.terrainDepth=i.obtainDepthTexture(),i.release(),this._renderContext.output=t}_renderGeometryDepth(e){if(!e)return void(this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth));const t=this._renderContext.output,{width:r,height:i}=this._framebufferSize,s=this.fboCache.acquire(r,i,"geometry depth",13);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(1280),this._renderOpaqueAndTransparentGeometry(1),this._renderContext.output=t,d(this._bindParameters.geometryDepth),this._bindParameters.geometryDepth=s.obtainDepthTexture(),s.release()}get _needsShadowDepthRange(){return this._shadowMap.enabled||this._shadowAccumulator.active}_computeShadowDepthRange(e){if(!this._needsShadowDepthRange)return Y.Zero;const t=Z(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=Y.Infinite);if((this.stage.view.renderCoordsHelper?.getAltitude(e.eye)??0)<O)return void(this.sceneDepthRange.value=Y.Infinite);const t=e.clone();t.near=F,t.far=1e10;const r=Z(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",R.FINAL,R.COMPOSITE,R.OPAQUE,R.TRANSPARENT,y.VIEWSHED,y.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)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"normals",5);r.acquireDepth(13),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(D,!0,!0),this._renderGeometryWithNormals(2);const i=this._nodes.optional("normals",R.FINAL,R.COMPOSITE,R.OPAQUE,R.TRANSPARENT,y.VIEWSHED);return r.retain(e+i-1),this.performanceInfo.advance(de.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return;const t=this._nodes.produce(y.SSAO,this._pluginInput);return this._bindParameters.ssao=t,t&&this.performanceInfo.advance(de.SSAO),t}_precompileAllGeometry(e){const t=this._renderContext.output;this._renderContext.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(6),this._plugins.precompile(7),this._renderContext.output=t}renderAllGeometry(e){this._renderContext.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentTerrain()}precompileSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const r of t)this._renderContext.renderOccludedMask=r,this.precompileSlots(e,...be);this._renderContext.renderOccludedMask=$}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(9),this.renderSlots(e,...be),this._renderContext.renderOccludedMask=$}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(13)}precompileViewshedShadowMap(){this._precompileAllGeometry(6)}precompileCutFill(){const e=7,t=this._renderContext.output;this._renderContext.output=e,this._plugins.precompile(0,1,6),this._renderContext.output=t}renderViewshedShadowMap(e){const{camera:t,contentCamera:r}=this._bindParameters,i=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=i}renderCutFillReferenceDepth(e){const{camera:t,contentCamera:r}=this._bindParameters,i=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this._renderContext.output=7,this._plugins.render(0,1),this._plugins.render(6),this._ensureBindParametersCamera(t,r),t.setGLViewport(this._rctx),this._renderContext.output=i}_renderOpaqueAndTransparentGeometry(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithNormals(e){this._renderContext.output=e,this._plugins.render(...me),this._renderTransparentTerrain()}_renderGeometryWithoutNormals(e){this._renderContext.output=e,this._plugins.render(...ce)}_precompileOpaqueGeometry(){this._plugins.precompile(...fe),this._nodes.precompile("opaque-color")}_renderOpaqueGeometry(){this._plugins.render(...fe)}_renderTransparentGeometry(){this._plugins.render(...ge)}get _hasTransparentTerrain(){return this._plugins.produces(0,6)}get _hasTransparentIntegratedMesh(){return this._plugins.produces(this._renderContext.output,7)}_renderTransparentTerrain(){const e=()=>this._plugins.render(6);if(!q(this._renderContext.output))return void e();const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"transparent terrain");return this.renderToTargets(e,r,this._framebuffer.depth,D),r}_renderTransparentIntegratedMesh(){const e=()=>this._plugins.render(7);if(!q(this._renderContext.output))return void e();const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"transparent integrated mesh");return this.renderToTargets(e,r,this._framebuffer.depth,D),r}get _needsHUDVisibility(){return this._plugins.produces(this._renderContext.output,12)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility));const{width:e,height:t}=this._framebufferSize;let r=this._bindParameters.hudVisibility;r?.fbo?.width===e&&r?.fbo?.height===t||(r?.release(),r=this.fboCache.acquire(e,t,"hud visibility",4),this._bindParameters.hudVisibility=r);const i=this._bindParameters.geometryDepth;r.attachDepth(i||this._framebuffer.depth),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(12),r.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(de.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,0===e){const e=()=>this._plugins.render(15),t=this._framebufferSize,r=this.fboCache.acquireDepth(12,t.width,t.height,"line callouts");this.renderToTargets(e,this._framebuffer.color,r,void 0,!0,!0),r.release()}else this._plugins.render(15)}_precompileHUD(e){if(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&&q(this._renderContext.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...Pe),this._bindParameters.oitPass=2,this._plugins.precompile(...Pe),this._bindParameters.oitPass=0):this._plugins.precompile(...Pe),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t){if(this._pluginsHas.hudElements){if(this._oitEnabled){const r=this._renderOIT(1,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,r.getTexture(),!1),r.release()}else if(this._renderContext.output=0,0===e){const t=()=>this._renderHUDElements(e),r=this._framebufferSize,i=this.fboCache.acquireDepth(12,r.width,r.height,"hud");this.renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(12),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(0===e?de.HUD_OCCLUDED:de.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(...Pe)}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(4,2)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:r}=this,i=this._framebufferSize,{highlights:s}=r,a=e.acquire(i.width,i.height,"highlights",s.length>j?3:1);a.acquireDepth(13);const n=this._plugins.produces(8,0);return n&&this._framebuffer.color.fbo&&a.fbo&&t.blitFramebuffer(this._framebuffer.color.fbo,a.fbo,1024),t.bindFramebuffer(a.fbo),t.gl.clearBufferuiv(6144,0,[0,0,0,0]),n||t.clear(1024),this._renderContext.output=8,t.bindFramebuffer(a.fbo),B(t,e,i,r,()=>this._renderHighlightGeometries()),a.detachDepth(),this.performanceInfo.advance(de.HIGHLIGHTS),a}_renderHighlightGeometries(){this._plugins.render(...Ce),this._rctx.clear(256),this._renderHUDElements(2)}_renderShadowAccumulation(e,t,r,i){this._shadowAccumulator.updateDepthRange(e),this._shadowAccumulator.accumulating&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,t,r,i)&&this.performanceInfo.advance(de.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this._oitEnabled&&q(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)}_renderOIT(e,t=2){const r=1===e,i=this._framebufferSize,s=r?()=>this._renderHUDElements(t):()=>this._renderTransparentGeometry(),a=this._bindParameters,n=this._renderContext.output;this._renderContext.output=0,a.oitPass=1;const h=r?"oit hud":"oit",o=this.fboCache.acquire(i.width,i.height,h,8),d=this._bindParameters.hasEmission;d&&o.acquireColor(le,8,"oit emissive"),o.acquireColor(d?ue:le,7,"oit alpha"),r||o.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(o.fbo),this._rctx.clearFramebuffer([0,0,0,1]),d&&this._rctx.clearBuffer(1,E),s(),o.detachDepth(),a.oitPass=2;const _=this.fboCache.acquire(i.width,i.height,r?"oit hud front":"oit front");let l;return d&&_.acquireColor(le,8,"oit emissive front"),r?_.acquireDepth(12):_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer(D,r),s(),_.detachDepth(),a.oitPass=0,r?(l=this.fboCache.acquire(i.width,i.height,"oit hud composite"),this._rctx.bindFramebuffer(l.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(16384)):this._framebuffer.bind(),this._oitblend??=new k(this._techniques),this._oitblend.blend(this._rctx,o,_,a,d,!r),l?.detachDepth(),_.release(),o.release(),this._renderContext.output=n,l}_renderOpaque(e){const t=this.plugins.produces(0,...fe);if(t){this._plugins.render(0,1);const e=this._framebuffer;e.update(e=>this._renderNodes(y.CUTFILL_COLOR,e)),e.update(e=>this._renderNodes(y.OPAQUE_TERRAIN,e)),e.bind(),this._plugins.render(2,3)}const r=this._framebuffer;this._renderTerrainDepth(e),r.update(e=>this._renderNodes(R.OPAQUE,e,t)),this.fboCache.debugCallback?.(R.OPAQUE,r.color.fbo),r.update(e=>this._renderNodes(y.OPAQUE_ENVIRONMENT,e)),this.fboCache.debugCallback?.(y.OPAQUE_ENVIRONMENT,r.color.fbo),this._renderEdges(1)}_renderTransparent(e,t){const r=this._framebuffer;r.bind(),this._renderPlugins(20,de.VOXEL),this._renderHiddenTransparentEdges(),e&&(this._oitEnabled?this._renderOIT(0):this._renderTransparentGeometry()),r.update(t=>this._renderNodes(R.TRANSPARENT,t,e)),this.fboCache.debugCallback?.(R.TRANSPARENT,r.color.fbo),this._renderGeometryDepth(t),this._renderHUDVisibility(),t||this._plugins.render(15),this._renderEdges(0);const i=this._hasTransparentTerrain?this._renderTransparentTerrain():null;i&&(this.performanceInfo.advance(de.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(t?this._renderLineCallouts(0):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositingHelper.compositeHUD(this._bindParameters,i.getTexture())),this._renderHUD(0,r.color))),this._bindParameters.cullAboveTerrain=!1,i&&(r.bind(),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,i.getTexture()),i.release(),t&&(this._renderEdges(1),e&&(this._oitEnabled?this._renderOIT(0):this._renderTransparentGeometry(),this.performanceInfo.advance(de.TRANSPARENT)),this._renderEdges(0)));const s=this._hasTransparentIntegratedMesh?this._renderTransparentIntegratedMesh():null;s&&(r.bind(),this._compositingHelper.composite(this._bindParameters,s.getTexture()),s.release()),this._bindParameters.ssao=d(this._bindParameters.ssao),t&&this._renderLineCallouts(1),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(de.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(8),this.performanceInfo.advance(de.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){if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;const i=this._nodes.render(t,this._pluginInput,this._releaseNormals);return this.performanceInfo.advance(e),i}blitFBO(e,t=M,r=!0){return this._blit??=new V(this._techniques),this._blit.blit(this._rctx,e,t,this._bindParameters),this._pluginInput.set(e.name,t),r&&e.release(),t}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=T:(C(Te,this._bindParameters.camera.viewMatrix),C(we,this._bindParameters.camera.projectionMatrix),w(Se,Te,we),w(Se,this._renderContext.lastFrameCamera.viewMatrix,Se),w(Se,this._renderContext.lastFrameCamera.projectionMatrix,Se),this._reprojectionMatrix=Se);const t=this.stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=T,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,r,i){this._bindParameters.updateLighting(e,t,r,i),this._requestRender(1)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}renderToTargets(e,t,r,i,s=!1,a=!1){t.attachDepth(r),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(i,s,a),e(),t.detachDepth()}get test(){}};e([g({readOnly:!0})],pe.prototype,"highResolutionAtmosphere",null),e([g()],pe.prototype,"_edgeView",void 0),e([g()],pe.prototype,"updating",null),pe=e([b("esri.views.3d.webgl-engine.lib.Renderer")],pe);const me=[0,1,2,4],ce=[3,5],fe=[0,1,2,3],ge=[4,5],be=[2,4,8],Pe=[16,13,14],Ce=[4,5,2,3,6,0,1],we=S(),Te=S(),Se=S();function xe(e){return t=>e.immediate.schedule(t)}export{pe as Renderer};
5
+ import{__decorate as e}from"tslib";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{unitRGBAFromColor as i}from"../../../../core/colorUtils.js";import"../../../../core/has.js";import{clamp as s,lerp as a}from"../../../../core/mathUtils.js";import{removeMaybe as n,abortMaybe as h,destroyMaybe as o,releaseMaybe as d}from"../../../../core/maybe.js";import{throwIfAborted as _}from"../../../../core/promiseUtils.js";import{watch as l,syncAndInitial as u,initial as p,sync as m}from"../../../../core/reactiveUtils.js";import{signal as c}from"../../../../core/signal.js";import{Milliseconds as f}from"../../../../core/time.js";import{property as g,subclass as b}from"../../../../core/accessorSupport/decorators.js";import{equals as P,invert as C,multiply as w}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as T,create as S}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{c as x}from"../../../../chunks/vec42.js";import{ZEROS as E}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{fromValues as A,ZEROS as D}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as I}from"../../../../geometry/support/Indices.js";import{RenderCategory as R,InternalRenderCategory as y}from"../../webgl.js";import{innerAtmosphereFadeStart as O}from"../../environment/atmosphereUtils.js";import{minNearDistanceInMeters as F}from"../../state/NearFarHeuristic.js";import{debugFlags as v}from"../../support/debugFlags.js";import{FBOCache as H,defaultWebGLFBO as M}from"../core/FBOCache.js";import{RenderPassManager as N}from"../core/renderPasses/RenderPassManager.js";import{isColor as q}from"../core/shaderLibrary/ShaderOutput.js";import{distanceFadeEnd as G}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as L}from"../effects/RenderNodes.js";import{RenderPluginManager as U}from"../effects/RenderPluginManager.js";import{Blit as V}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as j,renderHighlightBuffer as B}from"../effects/highlight/Highlight.js";import{OITBlend as k}from"../effects/transparency/OITBlend.js";import{AnimationTimer as z}from"./AnimationTimer.js";import{AnimationTimeStep as W}from"./AnimationTimeStep.js";import{BoundingInfo as Q}from"./BoundingInfo.js";import{DepthRange as Y}from"./DepthRange.js";import{depthRangeFromScene as Z}from"./depthRangeUtils.js";import{hudFragmentOpacityParameters as J}from"./hudFragmentOpacityParameters.js";import{MainFramebuffer as K}from"./MainFramebuffer.js";import{RenderContext as X,defaultRenderOccludedMask as $}from"./RenderContext.js";import{RendererBase as ee}from"./RendererBase.js";import{setupFeatureDefaults as te}from"./RenderFeature.js";import{RenderPluginInput as re}from"./RenderPluginInput.js";import{ShadowAccumulator as ie}from"./ShadowAccumulator.js";import{ShadowMap as se}from"./ShadowMap.js";import ae from"./SliceHelper.js";import{MergedRenderer as ne}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as he}from"../parts/renderUtils.js";import{RendererPerformanceInfo as oe,PerformanceCategory as de}from"../statistics/RendererPerformanceInfo.js";import{PixelType as _e,ColorAttachment1 as le,ColorAttachment2 as ue}from"../../../webgl/enums.js";let pe=class extends ee{constructor(e,t,r,s,a,n){super({stage:e}),this._techniques=r,this._rctx=s,this._compositingHelper=a,this._requestRender=n,this._pluginsHas={hudElements:!1,water:!1},this.renderPassManager=new N,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=A(0,0,0,1),this._sliceHelper=new ae,this._blit=null,this._oitblend=null,this.sceneDepthRange=c(Y.Infinite),this._state=c(2),this._hasAnimations=!1,this._animationTimestep=new W,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=c(0),this._lastFrameTime=f(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new re,this._releaseNormals=e=>{e.some(({name:e})=>"normals"===e)&&this._pluginInput.release("normals")},this._debugNeedsDepth=!1,this._fboCache=new H(s),this._renderStateFeatures=c(te(e.view.qualityProfile)),this._framebuffer=new K(this.fboCache),this._performanceInfo=new oe(this._rctx),this._shadowMap=new se(this.fboCache,e.viewingMode),this._shadowAccumulator=new ie(this.fboCache,r,e,e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t},(t,r,i)=>{const s=e.view.qualitySettings.maximumPixelRatio;t.shadowMap.start(t.camera,r,i,!0,s),this._renderShadowCascades(3,t.shadowMap),t.shadowMap.finish(),t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.contentCamera)},n),this._renderContext=new X(this._rctx,this._shadowMap,r),this._nodes=new L(this._renderContext),this._plugins=new U({renderContext:this._renderContext,techniques:r,materials:t,requestRender:n,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this.addHandles([l(()=>e.view.state.camera,()=>n(),u),l(()=>v.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES,e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(0):()=>{},n()},p),l(()=>e.view.environment.background?.color,e=>{const t=e?i(e):D;x(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()},u),l(()=>e.view.state.camera.relativeElevation,e=>this._inGlobeView=(e??1/0)>=G,u),l(()=>this._bindParameters.clouds.fadeFactor,()=>{this._bindParameters.fadeLighting(),this._requestRender(2)},m),l(()=>this._bindParameters.clouds.data?.state,()=>n(),m),l(()=>e.view.state.highlights,e=>{this._bindParameters.highlights=e,n()},p)])}destroy(){this._gpuTimerHandle=n(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.destroy(),this._shadowAccumulator=null,this._loadEdgeViewTask=h(this._loadEdgeViewTask),this._edgeView=o(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._blit=null,this._oitblend=null,this._compositingHelper=null,this._nodes=null,this._framebuffer=null,this._shadowMap=null,this._renderContext=null,this._performanceInfo=null,Q.prune(),ne.prune(),I()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _framebufferSize(){return this._framebuffer.size}get performanceInfo(){return this._performanceInfo}updateRenderFeatures(e){this._renderStateFeatures.value=te(e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate(i=>i.set(t,e,r)),this._requestRender()}get _highQualityTransparency(){return this.isFeatureEnabled(1)}get hasReflections(){return this._pluginsHas.water&&this.isFeatureEnabled(5)}get _hasHighlights(){return this._plugins.produces(8,2,4,18,13,14)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(8,13,14)}get hasSSAO(){return this.isFeatureEnabled(4)&&!this._inGlobeView}get hasSMAA(){return this.isFeatureEnabled(0)}get hasEmitters(){return this._plugins.hasEmitters&&this.stage.view.qualitySettings.physicallyBasedRenderingEnabled}get highResolutionAtmosphere(){return this.isFeatureEnabled(3)}get fboCache(){return this._fboCache}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=d(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.depth=d(this._bindParameters.depth),this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility)}get updating(){return this._loadEdgeViewTask&&!this._loadEdgeViewTask.finished||this._edgeView?.updating||this._shadowAccumulator.readyToRun||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=r(async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");_(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this.stage.view.renderSpatialReference,viewingMode:this.stage.view.stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:xe(this.stage.view.resourceController)});return this.addHandles(l(()=>r.updating,()=>this._requestRender(),m)),this._requestRender(),this._edgeViewCallbacks.forEach(e=>e(r)),this._edgeViewCallbacks.length=0,r})),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&P(this._bindParameters.ssr.reprojectionMatrix,T)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:r}=this;if(void 0!==e.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())}void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}set slice(e){this._sliceHelper.update(e)&&this._requestRender()}get plugins(){return this._plugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}commit(e,t){return this._isRendering&&console.warn("Renderer.modify called while rendering"),!!super.commit(e,t,this._plugins.context)&&(this.updateHasFlags(),!0)}rendererAdded(e){this._plugins.add(e)}rendererRemoved(e){this._plugins.remove(e)}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,9)}updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(0,...Pe),has.water=this._plugins.produces(2,19),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new z(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const r=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?n(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,r,i=!1){try{return this._isRendering=!0,this._render(e,t,r,i)}catch(s){console.error(`Exception during rendering: ${s}`)}finally{this._isRendering=!1}return new he(this._pluginInput.get(R.FINAL),null)}_updateHUDOccludedFragmentOpacity(e,t){const{idleOpacity:r,navigatingOpacity:i,maxDelta:n,tiltFadeStart:h,tiltFadeEnd:o,altitudeStart:d,altitudeEnd:_}=J,l=this.stage.view,u=l.stateManager.camera,p=l.qualitySettings.fadeDuration,m=2===e?r:i,c=s((u.tilt-h)/(o-h),0,1),f=s(((u.position.z??0)-d)/(_-d),0,1),g=a(a(1,m,c),1,f),b=this._bindParameters.hudOccludedFragmentOpacity;if(p<=0||b===g||0===this._lastFrameTime||this._lastFrameTime>t)return this._bindParameters.hudOccludedFragmentOpacity=g,void(this._lastFrameTime=t);const P=t-this._lastFrameTime;this._lastFrameTime=t;const C=Math.max(1-r,Math.abs(r-i)),w=Math.min(C*P/p,n);w>=Math.abs(g-b)?this._bindParameters.hudOccludedFragmentOpacity=g:(this._bindParameters.hudOccludedFragmentOpacity=b+Math.sign(g-b)*w,this._requestRender())}_render(e,t,r,i){const s=0===r;this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=s,this._disposeBindBuffers();const{camera:a,contentCamera:n,mode:h,alignPixelEnabled:o}=e;this._state.value=h;const d=this._nodes.produces("magnifier-color"),_=this._nodes.produces(R.FINAL);this._renderContext.time=t,this._renderContext.output=0,this._bindParameters.hasEmission=this.hasEmitters,this._bindParameters.oitPass=0,this._bindParameters.alignPixelEnabled=o,this._bindParameters.decorations=!i,this._bindParameters.mainDepth=null;const l=!i||!this._sliceHelper.isDecoration;this._bindParameters.slicePlane=l?this._sliceHelper.plane:null,this._bindParameters.viewshedEnabled=this._nodes.produces(y.VIEWSHED),this._bindParameters.cutFillEnabled=this._nodes.produces(y.CUTFILL_DEPTH),this._renderOverlay(),a.setGLViewport(this._rctx);const u=this._framebuffer,p=u.initialize(a.fullWidth,a.fullHeight,this._backgroundColor,this._bindParameters.hasEmission);this.hasReflections?(p?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=p):p?.release(),this._ensureBindParametersCamera(a,n),this._updateHUDOccludedFragmentOpacity(h,t),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!i;const m=this._highQualityTransparency&&this._hasTransparentTerrain,c=this._plugins.produces(0,...ge);this._precompilePrepasses(),this.performanceInfo.advance(de.PREPARE);const f=this._computeShadowDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,f),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(f,a,n,!s),this._ensureBindParametersSSR(t),this._precompileShaders(m,c),this._renderContext.output=0,u.bind(),this._bindParameters.mainDepth=u.depth.attachment,this._renderOpaque(m),this._renderTransparent(c,m),this._shadowMap.disposeMainBuffer(),this._pluginInput.set(y.FOCUSAREA,this._renderFocusAreaGeometry()),this._pluginInput.set(y.CUTFILL_DEPTH,this._renderCutFillDepth()),u.update(e=>this._renderNodes(y.TRANSPARENT_ENVIRONMENT,e)),u.update(e=>this._renderNodes(y.VIEWSHED,e)),u.update(e=>this._renderNodes(y.LASERLINES,e)),u.update(e=>this._renderNodes(y.FOCUSAREA_COLOR,e)),this._pluginInput.release(y.FOCUSAREA),this._pluginInput.release(y.CUTFILL_DEPTH),u.update(e=>this._renderNodes(y.OCCLUDED,e)),this._pluginInput.set("highlights",this._renderHighlightPrepass()),this._renderHighlightShadowMap(a,this._bindParameters.lighting.mainLight.direction,f);const g=2===r?this._renderObjectAndLayerIdColor():null;u.update(e=>this._renderNodes(R.COMPOSITE,e)),this._shadowMap.disposeOffscreenBuffers();const b=s&&!_&&!(d&&!i),P=this._pluginInput.get(R.COMPOSITE),C=b?M:this.fboCache.acquire(P.fbo.width,P.fbo.height,y.ANTIALIASING),w=this._nodes.produces(y.ANTIALIASING)?this._renderNodes(y.ANTIALIASING,C):this.blitFBO(P,C,!1);let T;this._pluginInput.set(y.ANTIALIASING,w),this._hasHUDHighlights?(this._renderHUD(1,w),T=this._renderNodes(y.HIGHLIGHTS,w)):(T=this._renderNodes(y.HIGHLIGHTS,w),this._renderHUD(1,T));const S=this._renderNodes(y.MAGNIFIER,T);return s&&d&&!i&&!_&&this.blitFBO(S),_?(S.attachDepth(u.depth),this.blitFBO(this._renderNodes(R.FINAL,S)),S.detachDepth()):this._pluginInput.set(R.FINAL,S),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),u.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),s||(this._releaseFBOs(),this._disposeOffscreenBuffers()),new he(this._pluginInput.get(R.FINAL),g)}_precompileShaders(e,t){++this._plugins.context.techniques.precompiling,this._renderContext.output=0,this._precompileOpaqueGeometry(),this._nodes.precompile(y.OPAQUE_ENVIRONMENT),this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,this._renderContext.output=1,this._plugins.precompile(6),this._plugins.precompile(7),e&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._renderContext.output=0,this._plugins.precompile(6),this._plugins.precompile(7),t&&(this._precompileTransparentGeometry(),this._hasTransparentTerrain&&(this._bindParameters.cullAboveTerrain=!1,this._precompileTransparentGeometry(),this._bindParameters.cullAboveTerrain=e)),this._nodes.precompile(y.FOCUSAREA),this._needsHUDVisibility&&this._plugins.precompile(12),this._plugins.precompile(15),this._precompileHUD(0),this._bindParameters.terrainDepthTest=!1,this._bindParameters.cullAboveTerrain=!1,this._nodes.precompile(y.VIEWSHED,y.CUTFILL_DEPTH,y.CUTFILL_COLOR,y.LASERLINES,y.FOCUSAREA_COLOR,y.OCCLUDED,y.ANTIALIASING,y.HIGHLIGHTS);const r=this._bindParameters;r.highlightMixTexture=r.highlights.length>1?this._rctx.emptyTexture:null,this._precompileHUD(1),this._hasHighlights&&(r.highlights.forEach((e,t)=>{r.highlightLevel=t,this._precompileAllGeometry(8)}),r.highlightLevel=null),r.highlightMixTexture=null,this._nodes.precompile(R.COMPOSITE,y.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(8),--this._plugins.context.techniques.precompiling}_renderFocusAreaGeometry(){const e=this._nodes.produce(y.FOCUSAREA,this._pluginInput);return e&&this.performanceInfo.advance(de.FOCUS_AREA_MASK),e}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._renderContext.output;++this._techniques.precompiling;const t=this._framebufferSize;let r=this.fboCache.acquire(t.width,t.height,"olid");return r.acquireDepth(13),r=this._nodes.render(r,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(de.OBJECT_AND_LAYER_ID_COLOR),this._renderContext.output=e,r}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 i=0;t?i=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const s=Math.max(e,i);this._animationTimestep.frame(s,r)}}readMainDepth(e,t){const{mainDepth:r,camera:i}=this._bindParameters;if(!r)return;const s=this.fboCache.acquire(this._framebufferSize.width,this._framebufferSize.height,"linear depth");this._rctx.bindFramebuffer(s.fbo),i.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(D),this._compositingHelper.blitDepthToLinearDepth(this._bindParameters,r),this._rctx.setScissorTestEnabled(!1),this._rctx.setScissorRect(0,0,this._rctx.gl.canvas.width,this._rctx.gl.canvas.width),s.fbo?.readPixels(e[0],e[1],e[2],e[3],6408,_e.UNSIGNED_BYTE,t),s.release()}readHUDVisibility(e,t,r,i,s){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,i,6408,_e.UNSIGNED_BYTE,s)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"edges"),s=this._bindParameters.geometryDepth,a=()=>t.render(this._bindParameters,e);this.renderToTargets(a,i,s??this._framebuffer.depth,D),this._framebuffer.bind(),this._compositingHelper.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(1===e?de.OPAQUE_EDGES:de.TRANSPARENT_EDGES)}_renderOverlay(){this._bindParameters.overlay=this.overlay?.render(),this._bindParameters.overlay&&this.performanceInfo.advance(de.OVERLAY)}_renderShadowMap(e,t,r){if(!this.shadowsEnabled)return;const i=this._shadowMap;i.start(e,t,r,this.isFeatureEnabled(6),this.stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(5,this._shadowMap),i.copySnapshot(1),this._renderShadowCascades(4,this._shadowMap)):this._renderShadowCascades(3),i.finish(),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,this._bindParameters.contentCamera),this.performanceInfo.advance(de.SHADOW_MAP)}_renderHighlightShadowMap(e,t,r){if(!this.shadowsEnabled||!this._needsShadowHighlight)return;const i=this._shadowMap;i.start(e,t,r,this.isFeatureEnabled(6),this.stage.view.qualitySettings.maximumPixelRatio),this._renderShadowCascades(4,this._shadowMap),i.moveSnapshot(0),i.finish(),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,this._bindParameters.contentCamera),this.performanceInfo.advance(de.SHADOW_MAP)}_renderCutFillDepth(){return this._nodes.produce(y.CUTFILL_DEPTH,this._pluginInput)}_precompileShadowCascades(e){0!==this._shadowMap.cascades.length&&this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){t.bindFbo();for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e)}get _needsDepth(){return this._plugins.consumes(1)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._shadowAccumulator.active||this._debugNeedsDepth}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");e?(this._pluginInput.set(y.SSAO,this._renderSSAO()),this._needsDepth?(this._rctx.bindFramebuffer(e.fbo),this._rctx.clear(1024),this._renderGeometryWithoutNormals(1),d(this._bindParameters.depth),this._bindParameters.depth=e.obtainDepthTexture(),this.performanceInfo.advance(de.DEPTH)):(e.detachDepth(),this._bindParameters.depth=d(this._bindParameters.depth)),this.hasSSAO&&this._pluginInput.release("normals")):this._renderAllGeometryDepth()}_renderAllGeometryDepth(){if(!this._needsDepth)return void(this._bindParameters.depth=d(this._bindParameters.depth));const e=this._framebufferSize,t=this.fboCache.acquire(e.width,e.height,"geometry depth",13);this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(1280),this.renderAllGeometry(1),d(this._bindParameters.depth),this._bindParameters.depth=t.obtainDepthTexture(),t.release(),this.performanceInfo.advance(de.DEPTH)}_renderTerrainDepth(e){if(this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth),this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,!e)return;const t=this._renderContext.output;this._renderContext.output=1;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"terrain depth",13);this._rctx.bindFramebuffer(i.fbo),this._rctx.clear(1280),this._renderTransparentTerrain(),this._bindParameters.terrainDepth=i.obtainDepthTexture(),i.release(),this._renderContext.output=t}_renderGeometryDepth(e){if(!e)return void(this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth));const t=this._renderContext.output,{width:r,height:i}=this._framebufferSize,s=this.fboCache.acquire(r,i,"geometry depth",13);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(1280),this._renderOpaqueAndTransparentGeometry(1),this._renderContext.output=t,d(this._bindParameters.geometryDepth),this._bindParameters.geometryDepth=s.obtainDepthTexture(),s.release()}get _needsShadowDepthRange(){return this._shadowMap.enabled||this._shadowAccumulator.active}_computeShadowDepthRange(e){if(!this._needsShadowDepthRange)return Y.Zero;const t=Z(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=Y.Infinite);if((this.stage.view.renderCoordsHelper?.getAltitude(e.eye)??0)<O)return void(this.sceneDepthRange.value=Y.Infinite);const t=e.clone();t.near=F,t.far=1e10;const r=Z(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",R.FINAL,R.COMPOSITE,R.OPAQUE,R.TRANSPARENT,y.VIEWSHED,y.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)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"normals",5);r.acquireDepth(13),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(D,!0,!0),this._renderGeometryWithNormals(2);const i=this._nodes.optional("normals",R.FINAL,R.COMPOSITE,R.OPAQUE,R.TRANSPARENT,y.VIEWSHED);return r.retain(e+i-1),this.performanceInfo.advance(de.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return;const t=this._nodes.produce(y.SSAO,this._pluginInput);return this._bindParameters.ssao=t,t&&this.performanceInfo.advance(de.SSAO),t}_precompileAllGeometry(e){const t=this._renderContext.output;this._renderContext.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(6),this._plugins.precompile(7),this._renderContext.output=t}renderAllGeometry(e){this._renderContext.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentTerrain()}precompileSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const r of t)this._renderContext.renderOccludedMask=r,this.precompileSlots(e,...be);this._renderContext.renderOccludedMask=$}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(9),this.renderSlots(e,...be),this._renderContext.renderOccludedMask=$}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(13)}precompileViewshedShadowMap(){this._precompileAllGeometry(6)}precompileCutFill(){const e=7,t=this._renderContext.output;this._renderContext.output=e,this._plugins.precompile(0,1,6),this._renderContext.output=t}renderViewshedShadowMap(e){const{camera:t,contentCamera:r}=this._bindParameters,i=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=i}renderCutFillReferenceDepth(e){const{camera:t,contentCamera:r}=this._bindParameters,i=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this._renderContext.output=7,this._plugins.render(0,1),this._plugins.render(6),this._ensureBindParametersCamera(t,r),t.setGLViewport(this._rctx),this._renderContext.output=i}_renderOpaqueAndTransparentGeometry(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithNormals(e){this._renderContext.output=e,this._plugins.render(...me),this._renderTransparentTerrain()}_renderGeometryWithoutNormals(e){this._renderContext.output=e,this._plugins.render(...ce)}_precompileOpaqueGeometry(){this._plugins.precompile(...fe),this._nodes.precompile("opaque-color")}_renderOpaqueGeometry(){this._plugins.render(...fe)}_renderTransparentGeometry(){this._plugins.render(...ge)}get _hasTransparentTerrain(){return this._plugins.produces(0,6)}get _hasTransparentIntegratedMesh(){return this._plugins.produces(this._renderContext.output,7)}_renderTransparentTerrain(){const e=()=>this._plugins.render(6);if(!q(this._renderContext.output))return void e();const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"transparent terrain");return this.renderToTargets(e,r,this._framebuffer.depth,D),r}_renderTransparentIntegratedMesh(){const e=()=>this._plugins.render(7);if(!q(this._renderContext.output))return void e();const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"transparent integrated mesh");return this.renderToTargets(e,r,this._framebuffer.depth,D),r}get _needsHUDVisibility(){return this._plugins.produces(this._renderContext.output,12)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility));const{width:e,height:t}=this._framebufferSize;let r=this._bindParameters.hudVisibility;r?.fbo?.width===e&&r?.fbo?.height===t||(r?.release(),r=this.fboCache.acquire(e,t,"hud visibility",4),this._bindParameters.hudVisibility=r);const i=this._bindParameters.geometryDepth;r.attachDepth(i||this._framebuffer.depth),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(12),r.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(de.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,0===e){const e=()=>this._plugins.render(15),t=this._framebufferSize,r=this.fboCache.acquireDepth(12,t.width,t.height,"line callouts");this.renderToTargets(e,this._framebuffer.color,r,void 0,!0,!0),r.release()}else this._plugins.render(15)}_precompileHUD(e){if(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&&q(this._renderContext.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...Pe),this._bindParameters.oitPass=2,this._plugins.precompile(...Pe),this._bindParameters.oitPass=0):this._plugins.precompile(...Pe),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t){if(this._pluginsHas.hudElements){if(this._oitEnabled){const r=this._renderOIT(1,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,r.getTexture(),!1),r.release()}else if(this._renderContext.output=0,0===e){const t=()=>this._renderHUDElements(e),r=this._framebufferSize,i=this.fboCache.acquireDepth(12,r.width,r.height,"hud");this.renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(12),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(0===e?de.HUD_OCCLUDED:de.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(...Pe)}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(4,2)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:r}=this,i=this._framebufferSize,{highlights:s}=r,a=e.acquire(i.width,i.height,"highlights",s.length>j?3:1);a.acquireDepth(13);const n=this._plugins.produces(8,0);return n&&this._framebuffer.color.fbo&&a.fbo&&t.blitFramebuffer(this._framebuffer.color.fbo,a.fbo,1024),t.bindFramebuffer(a.fbo),t.gl.clearBufferuiv(6144,0,[0,0,0,0]),n||t.clear(1024),this._renderContext.output=8,t.bindFramebuffer(a.fbo),B(t,e,i,r,()=>this._renderHighlightGeometries()),a.detachDepth(),this.performanceInfo.advance(de.HIGHLIGHTS),a}_renderHighlightGeometries(){this._plugins.render(...Ce),this._rctx.clear(256),this._renderHUDElements(2)}_renderShadowAccumulation(e,t,r,i){this._shadowAccumulator.updateDepthRange(e),this._shadowAccumulator.accumulating&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,t,r,i)&&this.performanceInfo.advance(de.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this._oitEnabled&&q(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)}_renderOIT(e,t=2){const r=1===e,i=this._framebufferSize,s=r?()=>this._renderHUDElements(t):()=>this._renderTransparentGeometry(),a=this._bindParameters,n=this._renderContext.output;this._renderContext.output=0,a.oitPass=1;const h=r?"oit hud":"oit",o=this.fboCache.acquire(i.width,i.height,h,8),d=this._bindParameters.hasEmission;d&&o.acquireColor(le,8,"oit emissive"),o.acquireColor(d?ue:le,7,"oit alpha"),r||o.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(o.fbo),this._rctx.clearFramebuffer([0,0,0,1]),d&&this._rctx.clearBuffer(1,E),s(),o.detachDepth(),a.oitPass=2;const _=this.fboCache.acquire(i.width,i.height,r?"oit hud front":"oit front");let l;return d&&_.acquireColor(le,8,"oit emissive front"),r?_.acquireDepth(12):_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer(D,r),s(),_.detachDepth(),a.oitPass=0,r?(l=this.fboCache.acquire(i.width,i.height,"oit hud composite"),this._rctx.bindFramebuffer(l.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(16384)):this._framebuffer.bind(),this._oitblend??=new k(this._techniques),this._oitblend.blend(this._rctx,o,_,a,d,!r),l?.detachDepth(),_.release(),o.release(),this._renderContext.output=n,l}_renderOpaque(e){const t=this.plugins.produces(0,...fe);if(t){this._plugins.render(0,1);const e=this._framebuffer;e.update(e=>this._renderNodes(y.CUTFILL_COLOR,e)),e.update(e=>this._renderNodes(y.OPAQUE_TERRAIN,e)),e.bind(),this._plugins.render(2,3)}const r=this._framebuffer;this._renderTerrainDepth(e),r.update(e=>this._renderNodes(R.OPAQUE,e,t)),this.fboCache.debugCallback?.(R.OPAQUE,r.color.fbo),r.update(e=>this._renderNodes(y.OPAQUE_ENVIRONMENT,e)),this.fboCache.debugCallback?.(y.OPAQUE_ENVIRONMENT,r.color.fbo),this._renderEdges(1)}_renderTransparent(e,t){const r=this._framebuffer;r.bind(),this._renderPlugins(20,de.VOXEL),this._renderHiddenTransparentEdges(),e&&(this._oitEnabled?this._renderOIT(0):this._renderTransparentGeometry()),r.update(t=>this._renderNodes(R.TRANSPARENT,t,e)),this.fboCache.debugCallback?.(R.TRANSPARENT,r.color.fbo),this._renderGeometryDepth(t),this._renderHUDVisibility(),t||this._plugins.render(15),this._renderEdges(0);const i=this._hasTransparentTerrain?this._renderTransparentTerrain():null;i&&(this.performanceInfo.advance(de.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(t?this._renderLineCallouts(0):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositingHelper.compositeHUD(this._bindParameters,i.getTexture())),this._renderHUD(0,r.color))),this._bindParameters.cullAboveTerrain=!1,i&&(r.bind(),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,i.getTexture()),i.release(),t&&(this._renderEdges(1),e&&(this._oitEnabled?this._renderOIT(0):this._renderTransparentGeometry(),this.performanceInfo.advance(de.TRANSPARENT)),this._renderEdges(0)));const s=this._hasTransparentIntegratedMesh?this._renderTransparentIntegratedMesh():null;s&&(r.bind(),this._compositingHelper.composite(this._bindParameters,s.getTexture()),s.release()),this._bindParameters.ssao=d(this._bindParameters.ssao),t&&this._renderLineCallouts(1),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(de.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(8),this.performanceInfo.advance(de.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){if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;const i=this._nodes.render(t,this._pluginInput,this._releaseNormals);return this.performanceInfo.advance(e),i}blitFBO(e,t=M,r=!0){return this._blit??=new V(this._techniques),this._blit.blit(this._rctx,e,t,this._bindParameters),this._pluginInput.set(e.name,t),r&&e.release(),t}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=T:(C(Te,this._bindParameters.camera.viewMatrix),C(we,this._bindParameters.camera.projectionMatrix),w(Se,Te,we),w(Se,this._renderContext.lastFrameCamera.viewMatrix,Se),w(Se,this._renderContext.lastFrameCamera.projectionMatrix,Se),this._reprojectionMatrix=Se);const t=this.stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=T,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,r,i){this._bindParameters.updateLighting(e,t,r,i),this._requestRender(1)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}renderToTargets(e,t,r,i,s=!1,a=!1){t.attachDepth(r),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(i,s,a),e(),t.detachDepth()}get test(){}};e([g({readOnly:!0})],pe.prototype,"highResolutionAtmosphere",null),e([g()],pe.prototype,"_edgeView",void 0),e([g()],pe.prototype,"updating",null),pe=e([b("esri.views.3d.webgl-engine.lib.Renderer")],pe);const me=[0,1,2,4],ce=[3,5],fe=[0,1,2,3],ge=[4,5],be=[2,4,8],Pe=[16,13,14],Ce=[4,5,2,3,6,0,1],we=S(),Te=S(),Se=S();function xe(e){return t=>e.immediate.schedule(t)}export{pe as Renderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{disposeMaybe as s}from"../../../../core/maybe.js";import{property as i,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{a as r,d as o}from"../../../../chunks/vec42.js";import{createQuadVAO as n}from"./glUtil3D.js";import{S as h}from"../../../../chunks/ShadowCastVisualize.glsl.js";import{ShadowCastVisualizeTechnique as d}from"../shaders/ShadowCastVisualizeTechnique.js";import{ShadowCastVisualizeTechniqueConfiguration as l}from"../shaders/ShadowCastVisualizeTechniqueConfiguration.js";const _=4e4,p=5e4,m=1/512;let u=class extends t{constructor(e,t,s,i){super({}),this._techniques=e,this._rctx=t,this._data=s,this._requestRender=i,this._passParameters=new h(this._data),this._configuration=new l,this._enabled=!1,this._vao=n(t)}dispose(){this._stop(),this._vao=s(this._vao)}precompile(){this._showVisualization&&this._techniques.precompile(d,this._configuration)}render(e){if(!this._showVisualization)return;const[t,s]=this._data.computedSamples;this._passParameters.sampleScale=[t?1/t:0,s?1/s:0];const i=this._techniques.get(d,this._configuration);this._rctx.bindVAO(this._vao),this._rctx.bindTechnique(i,e,this._passParameters),this._rctx.drawArrays(i.primitiveType,0,this._vao.vertexCount("geometry"))}setOptions(e){void 0!==e.enabled&&this._setEnabled(e.enabled),void 0!==e.thresholdColor&&this._setThresholdColor(e.thresholdColor),void 0!==e.gradientColor&&this._setGradientColor(e.gradientColor),void 0!==e.bandedGradientColor&&this._setBandedGradientColor(e.bandedGradientColor),void 0!==e.threshold&&(this._threshold=e.threshold),void 0!==e.visualization&&(this._visualization=e.visualization),void 0!==e.bandSize&&(this._bandSize=e.bandSize)}get opacityFromElevation(){return this._passParameters.opacityFromElevation}set opacityFromElevation(e){this._passParameters.opacityFromElevation!==e&&(this._passParameters.opacityFromElevation=e,this.notifyChange("opacityFromElevation"))}get _showVisualization(){return this._enabled&&(this._data.computedSamples[0]>0||this._data.computedSamples[1]>0)&&this.opacityFromElevation>m}get _threshold(){return this._passParameters.threshold}set _threshold(e){this._threshold!==e&&(this._passParameters.threshold=e,this._requestRenderIfEnabled())}get _visualization(){return this._configuration.visualization}set _visualization(e){e!==this._visualization&&(this._configuration.visualization=e,this._requestRenderIfEnabled())}get _bandSize(){return this._passParameters.bandSize}set _bandSize(e){e!==this._bandSize&&(this._passParameters.bandSize=e,this._requestRenderIfEnabled())}_setThresholdColor(e){const t=this._passParameters.thresholdColor;r(e,t)||(o(this._passParameters.thresholdColor,e),this._requestRenderIfEnabled())}_setGradientColor(e){const t=this._passParameters.gradientColor;r(e,t)||(o(this._passParameters.gradientColor,e),this._requestRenderIfEnabled())}_setBandedGradientColor(e){const t=this._passParameters.bandedGradientColor;r(e,t)||(o(this._passParameters.bandedGradientColor,e),this._requestRenderIfEnabled())}_setEnabled(e){e!==this._enabled&&(e?this._start():this._stop())}_requestRenderIfEnabled(){this._enabled&&this._requestRender()}_start(){this._enabled=!0,this._requestRender()}_stop(){this._enabled=!1,this._requestRender()}};e([i()],u.prototype,"opacityFromElevation",null),u=e([a("esri.views.3d.webgl-engine.lib.ShadowCastRenderer")],u);export{u as ShadowCastRenderer,p as shadowCastDisableElevationMax,_ as shadowCastDisableElevationMin,m as shadowCastDisabledElevationThreshold};
5
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{disposeMaybe as s}from"../../../../core/maybe.js";import{property as i,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{a as r,f as o}from"../../../../chunks/vec42.js";import{createQuadVAO as n}from"./glUtil3D.js";import{S as h}from"../../../../chunks/ShadowCastVisualize.glsl.js";import{ShadowCastVisualizeTechnique as d}from"../shaders/ShadowCastVisualizeTechnique.js";import{ShadowCastVisualizeTechniqueConfiguration as l}from"../shaders/ShadowCastVisualizeTechniqueConfiguration.js";const _=4e4,p=5e4,m=1/512;let u=class extends t{constructor(e,t,s,i){super({}),this._techniques=e,this._rctx=t,this._data=s,this._requestRender=i,this._passParameters=new h(this._data),this._configuration=new l,this._enabled=!1,this._vao=n(t)}dispose(){this._stop(),this._vao=s(this._vao)}precompile(){this._showVisualization&&this._techniques.precompile(d,this._configuration)}render(e){if(!this._showVisualization)return;const[t,s]=this._data.computedSamples;this._passParameters.sampleScale=[t?1/t:0,s?1/s:0];const i=this._techniques.get(d,this._configuration);this._rctx.bindVAO(this._vao),this._rctx.bindTechnique(i,e,this._passParameters),this._rctx.drawArrays(i.primitiveType,0,this._vao.vertexCount("geometry"))}setOptions(e){void 0!==e.enabled&&this._setEnabled(e.enabled),void 0!==e.thresholdColor&&this._setThresholdColor(e.thresholdColor),void 0!==e.gradientColor&&this._setGradientColor(e.gradientColor),void 0!==e.bandedGradientColor&&this._setBandedGradientColor(e.bandedGradientColor),void 0!==e.threshold&&(this._threshold=e.threshold),void 0!==e.visualization&&(this._visualization=e.visualization),void 0!==e.bandSize&&(this._bandSize=e.bandSize)}get opacityFromElevation(){return this._passParameters.opacityFromElevation}set opacityFromElevation(e){this._passParameters.opacityFromElevation!==e&&(this._passParameters.opacityFromElevation=e,this.notifyChange("opacityFromElevation"))}get _showVisualization(){return this._enabled&&(this._data.computedSamples[0]>0||this._data.computedSamples[1]>0)&&this.opacityFromElevation>m}get _threshold(){return this._passParameters.threshold}set _threshold(e){this._threshold!==e&&(this._passParameters.threshold=e,this._requestRenderIfEnabled())}get _visualization(){return this._configuration.visualization}set _visualization(e){e!==this._visualization&&(this._configuration.visualization=e,this._requestRenderIfEnabled())}get _bandSize(){return this._passParameters.bandSize}set _bandSize(e){e!==this._bandSize&&(this._passParameters.bandSize=e,this._requestRenderIfEnabled())}_setThresholdColor(e){const t=this._passParameters.thresholdColor;r(e,t)||(o(this._passParameters.thresholdColor,e),this._requestRenderIfEnabled())}_setGradientColor(e){const t=this._passParameters.gradientColor;r(e,t)||(o(this._passParameters.gradientColor,e),this._requestRenderIfEnabled())}_setBandedGradientColor(e){const t=this._passParameters.bandedGradientColor;r(e,t)||(o(this._passParameters.bandedGradientColor,e),this._requestRenderIfEnabled())}_setEnabled(e){e!==this._enabled&&(e?this._start():this._stop())}_requestRenderIfEnabled(){this._enabled&&this._requestRender()}_start(){this._enabled=!0,this._requestRender()}_stop(){this._enabled=!1,this._requestRender()}};e([i()],u.prototype,"opacityFromElevation",null),u=e([a("esri.views.3d.webgl-engine.lib.ShadowCastRenderer")],u);export{u as ShadowCastRenderer,p as shadowCastDisableElevationMax,_ as shadowCastDisableElevationMin,m as shadowCastDisabledElevationThreshold};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import{clamp as t,lerp as s,acosClamped as e}from"../../../../core/mathUtils.js";import{releaseMaybe as i}from"../../../../core/maybe.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as r,multiply as h,invert as n,lookAt as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as c,create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as d,add as u,scale as m,lerp as _,squaredDistance as f,subtract as g,dot as p,negate as x,normalize as b,copy as w}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as M}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{m as C,d as j,q as y,p as v,h as S}from"../../../../chunks/vec32.js";import{create as H}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as O,t as D}from"../../../../chunks/vec42.js";import{create as F}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 q}from"../../../webgl/enums.js";class R{constructor(){this.camera=new T,this.lightMat=l()}}class W{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 W,this._projectionView=l(),this._projectionViewInverse=l(),this._modelViewLight=l(),this._cascadeDistances=[0,0,0,0,0],this._usedCascadeDistances=F(),this._cascades=[new R,new R,new R,new R],this._lastOrigin=null,this._enabled=!1,this._maxTextureWidth=Math.min(has("esri-mobile")?4096:16384,t.rctx.parameters.maxTextureSize)}dispose(){this.enabled=!1,this.disposeOffscreenBuffers()}get depthTexture(){return this._handle?.getTexture(q)}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)}disposeMainBuffer(){this._handle=i(this._handle)}disposeOffscreenBuffers(){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.disposeOffscreenBuffers()}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:n,projectionMatrix:o}=t;for(let c=0;c<this._numCascades;++c)this._constructCascade(c,o,n,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(q)?.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(q):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(q)?.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],n=-this._cascadeDistances[t],o=-this._cascadeDistances[t+1],c=(s[10]*n+s[14])/Math.abs(s[11]*n+s[15]),l=(s[10]*o+s[14])/Math.abs(s[11]*o+s[15]);B(c<l);for(let r=0;r<8;++r){O(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];D(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],u=U[0][2];for(let r=1;r<8;++r)d=Math.min(d,U[r][2]),u=Math.max(u,U[r][2]);d-=200,u+=200,a.camera.near=-u,a.camera.far=-d,pt(e,i,d,u,a.camera),h(a.lightMat,a.camera.projectionMatrix,a.camera.viewMatrix);const m=this._textureHeight;a.camera.viewport=[t*m,0,m,m]}_setupMatrices(t,s){h(this._projectionView,t.projectionMatrix,t.viewMatrix),n(this._projectionViewInverse,this._projectionView);const e=1===this._viewingMode?t.eye:S(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(L(e/t,4)),a);const r=(e-t)/this._numCascades,h=(e/t)**(1/this._numCascades);let n=t,o=t;for(let c=0;c<this._numCascades+1;++c)this._cascadeDistances[c]=s(n,o,this.settings.splitSchemeLambda),n*=h,o+=r}get test(){}}const A=l(),I=F(),U=[];for(let bt=0;bt<8;++bt)U.push(F());const k=M(),P=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(),nt=M(),ot=M(),ct=M();function lt(t,s,e,i,a,r,h,n){d(tt,0,0);for(let d=0;d<4;++d)u(tt,tt,t[d]);m(tt,tt,.25),d(st,0,0);for(let d=4;d<8;++d)u(st,st,t[d]);m(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,c=f(et[0],tt);for(let d=1;d<4;++d){const t=f(et[d],tt);t<c&&(c=t,o=d)}g(it,et[o],t[o+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),m(rt,it,M-s),u(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"),m(nt,it,M),u(nt,nt,tt),m(ot,it,C),u(ot,ot,tt),ct[0]=-it[1],ct[1]=it[0];const H=N(i,t[S],ot,u(rt,ot,ct),1,a),O=N(i,t[v],ot,rt,1,r),D=N(i,t[v],nt,u(rt,nt,ct),1,h),F=N(i,t[S],nt,rt,1,n);V(H,"rayRay"),V(O,"rayRay"),V(D,"rayRay"),V(F,"rayRay")}function dt(t,s){return 3*s+t}const ut=M();function mt(t,s){return d(ut,t[s],t[s+3]),ut}const _t=M(),ft=a();function gt(t,s,e,i,a){g(_t,e,i),m(_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(mt(ft,0),t),ft[dt(1,2)]=-p(mt(ft,1),t);let r=p(mt(ft,0),e)+ft[dt(0,2)],h=p(mt(ft,1),e)+ft[dt(1,2)],n=p(mt(ft,0),i)+ft[dt(0,2)],o=p(mt(ft,1),i)+ft[dt(1,2)];r=-(r+n)/(h+o),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(mt(ft,0),e)+ft[dt(0,2)]),h=1/(p(mt(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(mt(ft,1),s)+ft[dt(1,2)],h=p(mt(ft,2),s)+ft[dt(2,2)],n=p(mt(ft,1),e)+ft[dt(1,2)],o=p(mt(ft,2),e)+ft[dt(2,2)],r=-.5*(r/h+n/o),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(mt(ft,1),s)+ft[dt(1,2)],h=p(mt(ft,2),s)+ft[dt(2,2)],n=-h/r,ft[dt(1,0)]*=n,ft[dt(1,1)]*=n,ft[dt(1,2)]*=n,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],n=1/U[4][3];B(h<n);let o=h+Math.sqrt(h*n);const c=Math.sin(e(t[2]*s[0]+t[6]*s[1]+t[10]*s[2]));o/=c,lt(U,o,c,k,P,E,G,J),gt(k,P,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};
5
+ import has from"../../../../core/has.js";import{clamp as t,lerp as s,acosClamped as e}from"../../../../core/mathUtils.js";import{releaseMaybe as i}from"../../../../core/maybe.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as r,multiply as h,invert as n,lookAt as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as c,create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as d,add as u,scale as m,lerp as _,squaredDistance as f,subtract as g,dot as p,negate as x,normalize as b,copy as w}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as M}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{m as C,d as j,q as y,p as v,h as S}from"../../../../chunks/vec32.js";import{create as H}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as O,t as D}from"../../../../chunks/vec42.js";import{create as F}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 q}from"../../../webgl/enums.js";class R{constructor(){this.camera=new T,this.lightMat=l()}}class W{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 W,this._projectionView=l(),this._projectionViewInverse=l(),this._modelViewLight=l(),this._cascadeDistances=[0,0,0,0,0],this._usedCascadeDistances=F(),this._cascades=[new R,new R,new R,new R],this._lastOrigin=null,this._enabled=!1,this._maxTextureWidth=Math.min(has("esri-mobile")?4096:16384,t.rctx.parameters.maxTextureSize)}dispose(){this.enabled=!1,this.disposeOffscreenBuffers()}get depthTexture(){return this._handle?.getTexture(q)}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)}disposeMainBuffer(){this._handle=i(this._handle)}disposeOffscreenBuffers(){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.disposeOffscreenBuffers()}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:n,projectionMatrix:o}=t;for(let c=0;c<this._numCascades;++c)this._constructCascade(c,o,n,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(q)?.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(q):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(q)?.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],n=-this._cascadeDistances[t],o=-this._cascadeDistances[t+1],c=(s[10]*n+s[14])/Math.abs(s[11]*n+s[15]),l=(s[10]*o+s[14])/Math.abs(s[11]*o+s[15]);B(c<l);for(let r=0;r<8;++r){O(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];D(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],u=U[0][2];for(let r=1;r<8;++r)d=Math.min(d,U[r][2]),u=Math.max(u,U[r][2]);d-=200,u+=200,a.camera.near=-u,a.camera.far=-d,pt(e,i,d,u,a.camera),h(a.lightMat,a.camera.projectionMatrix,a.camera.viewMatrix);const m=this._textureHeight;a.camera.viewport=[t*m,0,m,m]}_setupMatrices(t,s){h(this._projectionView,t.projectionMatrix,t.viewMatrix),n(this._projectionViewInverse,this._projectionView);const e=1===this._viewingMode?t.eye:S(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(L(e/t,4)),a);const r=(e-t)/this._numCascades,h=(e/t)**(1/this._numCascades);let n=t,o=t;for(let c=0;c<this._numCascades+1;++c)this._cascadeDistances[c]=s(n,o,this.settings.splitSchemeLambda),n*=h,o+=r}get test(){}}const A=l(),I=F(),U=[];for(let bt=0;bt<8;++bt)U.push(F());const k=M(),P=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(),nt=M(),ot=M(),ct=M();function lt(t,s,e,i,a,r,h,n){d(tt,0,0);for(let d=0;d<4;++d)u(tt,tt,t[d]);m(tt,tt,.25),d(st,0,0);for(let d=4;d<8;++d)u(st,st,t[d]);m(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,c=f(et[0],tt);for(let d=1;d<4;++d){const t=f(et[d],tt);t<c&&(c=t,o=d)}g(it,et[o],t[o+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),m(rt,it,M-s),u(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"),m(nt,it,M),u(nt,nt,tt),m(ot,it,C),u(ot,ot,tt),ct[0]=-it[1],ct[1]=it[0];const H=N(i,t[S],ot,u(rt,ot,ct),1,a),O=N(i,t[v],ot,rt,1,r),D=N(i,t[v],nt,u(rt,nt,ct),1,h),F=N(i,t[S],nt,rt,1,n);V(H,"rayRay"),V(O,"rayRay"),V(D,"rayRay"),V(F,"rayRay")}function dt(t,s){return 3*s+t}const ut=M();function mt(t,s){return d(ut,t[s],t[s+3]),ut}const _t=M(),ft=a();function gt(t,s,e,i,a){g(_t,e,i),m(_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(mt(ft,0),t),ft[dt(1,2)]=-p(mt(ft,1),t);let r=p(mt(ft,0),e)+ft[dt(0,2)],h=p(mt(ft,1),e)+ft[dt(1,2)],n=p(mt(ft,0),i)+ft[dt(0,2)],o=p(mt(ft,1),i)+ft[dt(1,2)];r=-(r+n)/(h+o),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(mt(ft,0),e)+ft[dt(0,2)]),h=1/(p(mt(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(mt(ft,1),s)+ft[dt(1,2)],h=p(mt(ft,2),s)+ft[dt(2,2)],n=p(mt(ft,1),e)+ft[dt(1,2)],o=p(mt(ft,2),e)+ft[dt(2,2)],r=-.5*(r/h+n/o),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(mt(ft,1),s)+ft[dt(1,2)],h=p(mt(ft,2),s)+ft[dt(2,2)],n=-h/r,ft[dt(1,0)]*=n,ft[dt(1,1)]*=n,ft[dt(1,2)]*=n,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],n=1/U[4][3];B(h<n);let o=h+Math.sqrt(h*n);const c=Math.sin(e(t[2]*s[0]+t[6]*s[1]+t[10]*s[2]));o/=c,lt(U,o,c,k,P,E,G,J),gt(k,P,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,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{EventEmitter as s}from"../../../../core/Evented.js";import"../../../../core/has.js";import{disposeMaybe as i,removeMaybe as r}from"../../../../core/maybe.js";import{generateUID as h}from"../../../../core/uid.js";import{property as n,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{a as o,s as l}from"../../../../chunks/vec42.js";import{ZEROS as _,create as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{textTextureAtlas as d}from"./testUtils.js";import{applyTextureResizeModuloCeil as u}from"./textureUtils.js";import{TaskPriority as m}from"../../../support/Scheduler.js";import{Yield as f}from"../../../support/Yield.js";import{Texture as p}from"../../../webgl/Texture.js";import{TextureDescriptor as x}from"../../../webgl/TextureDescriptor.js";const g=4096;let v=class extends t{constructor(e){super(e),this.id=h(),this.events=new s,this._texture=null,this._atlas=new R(256,256),this._needsRepack=!1,this._canRepack=!0,this._elementsToRender=new Map,this._elements=new Map,this._uvCallbacks=new Map,this.updating=!1}initialize(){this._canvas=document.createElement("canvas"),this._canvas.setAttribute("id","textAtlasCanvas"),this._canvas.setAttribute("style","display:none"),this._ctx=this._canvas.getContext("2d"),this._stage=this.view.stage,this._stage.addTexture(this),this._updateCanvasElementSize(this._atlas),this._reset()}unload(){this._texture=i(this._texture),this._frameWorker=r(this._frameWorker),this.updating=!1,this.events.emit("unloaded")}get loaded(){return null!=this._texture}get texture(){return this._texture}static get maxSize(){return b=d.stableRendering?w:0,[g-w-b,g-w-b-k]}load(e){if(this._texture)return this._texture;const t=new x;return t.wrapMode=33071,t.samplingMode=9987,t.hasMipmap=!0,t.preMultiplyAlpha=!0,t.maxAnisotropy=e.parameters.maxMaxAnisotropy,this._texture=new p(e,t,this._canvas),this._frameWorker=this.view.resourceController.scheduler.registerTask(m.TEXT_TEXTURE_ATLAS,this),this.setDirty(),this._texture}dispose(){this._elements.clear(),this._elementsToRender.clear(),this._frameWorker=r(this._frameWorker),this._texture&&(this._stage.removeTexture(this),this._texture=i(this._texture)),this._canvas.width=0,this._canvas.height=0,this._canvas=null,this._ctx=null}_updateCanvasElementSize(e){this._canvas.width=e.width,this._canvas.height=e.height}_resizeAtlas(e,t){const{width:s,height:i}=this._atlas;s===e&&i===t||(this._atlas.width=e,this._atlas.height=t,this._texture?.resize(e,t),this._texture?.updateData(0,0,0,s,i,this._canvas),this._updateCanvasElementSize(this._atlas),this._elements.forEach(e=>this._uvCallbacks.get(e.textRenderer.key)?.forEach(t=>t(e.uv))),this._reset())}_reset(){this._elementsToRender.clear(),this._atlas.reset(),this._needsRepack=!0,this.setDirty()}_addAtlasElement(e,t,s,i){const r=this._atlas;if(r.width<s||r.height<i)return!1;let h=r.cursors.get(i);if(!h){if(r.height<r.nextY+i)return!1;h=[new T(r.nextY)],r.cursors.set(i,h),r.nextY+=i}let n=h.find(e=>r.width>=e.x+s);if(null==n){if(r.height<r.nextY+i)return!1;n=new T(r.nextY),r.nextY+=i,h.push(n)}return e.setNewPosition(n),this._elements.set(t,e),this._elementsToRender.set(t,e),n.x+=s,!0}_ensureCallbacks(e){const t=this._uvCallbacks.get(e);if(t)return t;const s=new Set;return this._uvCallbacks.set(e,s),s}_addCallback(e,t){this._ensureCallbacks(e).add(t)}_removeCallback(e,t){const s=this._uvCallbacks.get(e);return!(!s?.delete(t)||0!==s.size)&&(this._uvCallbacks.delete(e),!0)}_processAddition(e){const t=e.textRenderer.key;if(this._needsRepack)return void this._elements.set(t,e);const s=this._atlas,i=e.textRenderer.renderedWidth,r=e.textRenderer.renderedHeight,h=i+w,n=r+w+k;if(!this._addAtlasElement(e,t,h,n)){if(this._canRepack)this._reset();else if(s.width<h){const e=u(Math.max(h,1.5*s.width),g);this._resizeAtlas(e,s.height)}else{const e=s.nextY+n,t=u(Math.max(e,1.5*s.height),g);if(t>s.height)this._resizeAtlas(s.width,t);else if(s.width<g){const e=u(1.5*s.width,g);this._resizeAtlas(e,s.height)}}this._elements.set(t,e)}}_renderElement(e){const t=e.commitNewPosition(),s=e.textRenderer;this._ctx.clearRect(t[0]-w,t[1]-w,s.renderedWidth+2*w,s.renderedHeight+2*w),s.render(this._ctx,t[0],t[1]),this._uvCallbacks.get(s.key)?.forEach(t=>t(e.uv))}get readyToRun(){return this.updating}runTask(e){if(null==this._texture)return f;for(;this._needsRepack&&(this._canRepack||this._atlas.height<g&&this._atlas.height<g);){this._canRepack=this._needsRepack=!1;const t=this._elements;this._elements=new Map,t.forEach(e=>this._processAddition(e)),e.madeProgress()}if(this._elementsToRender.size>0){for(const[t,s]of this._elementsToRender){if(e.done)break;this._renderElement(s),this._elementsToRender.delete(t),e.madeProgress()}this._texture.setData(this._canvas)}this.updating=this._elementsToRender.size>0}addText(e,t){const s=e.key;this._addCallback(s,t);let i=this._elements.get(s);return i?o(i.uv,_)||t(i.uv):(i=new y(e),this._processAddition(i),this.setDirty()),{remove:()=>this._removeText(e,t)}}_removeText(e,t){const s=e.key;this._elements.get(s)&&this._removeCallback(s,t)&&(this._elements.delete(s),this._elementsToRender.delete(s),this._canRepack=!0)}setDirty(){this._texture&&(this.updating=!0)}get test(){}get usedMemory(){return(this._texture?.usedMemory??0)+(this._canvas?.width??0)*(this._canvas?.height??0)*4}};e([n({constructOnly:!0})],v.prototype,"view",void 0),e([n({type:Boolean})],v.prototype,"updating",void 0),v=e([a("esri.views.3d.webgl-engine.lib.TextTextureAtlas")],v);const w=2,k=2;class y{constructor(e){this.textRenderer=e,this._uv=c(),this._newPosition=[0,0]}get uv(){if(null==this._xOffset||null==this._yOffset)return _;const{renderedWidth:e,renderedHeight:t}=this.textRenderer;return l(this._uv,this._xOffset,this._yOffset+t,this._xOffset+e,this._yOffset)}setNewPosition(e){this._newPosition[0]=e.x,this._newPosition[1]=e.y}commitNewPosition(){return this._xOffset=this._newPosition[0],this._yOffset=this._newPosition[1],this._newPosition}get xOffset(){return this._xOffset}get yOffset(){return this._yOffset}}class R{constructor(e,t){this.width=e,this.height=t,this.cursors=new Map,this.nextY=0}reset(){this.cursors.clear(),this.nextY=b}}class T{constructor(e){this.y=e,this.x=b}}let b=0;export{v as TextTextureAtlas};
5
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{EventEmitter as s}from"../../../../core/Evented.js";import"../../../../core/has.js";import{disposeMaybe as i,removeMaybe as r}from"../../../../core/maybe.js";import{generateUID as h}from"../../../../core/uid.js";import{property as n,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{a as o,c as l}from"../../../../chunks/vec42.js";import{ZEROS as _,create as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{textTextureAtlas as d}from"./testUtils.js";import{applyTextureResizeModuloCeil as u}from"./textureUtils.js";import{TaskPriority as m}from"../../../support/Scheduler.js";import{Yield as f}from"../../../support/Yield.js";import{Texture as p}from"../../../webgl/Texture.js";import{TextureDescriptor as x}from"../../../webgl/TextureDescriptor.js";const g=4096;let v=class extends t{constructor(e){super(e),this.id=h(),this.events=new s,this._texture=null,this._atlas=new R(256,256),this._needsRepack=!1,this._canRepack=!0,this._elementsToRender=new Map,this._elements=new Map,this._uvCallbacks=new Map,this.updating=!1}initialize(){this._canvas=document.createElement("canvas"),this._canvas.setAttribute("id","textAtlasCanvas"),this._canvas.setAttribute("style","display:none"),this._ctx=this._canvas.getContext("2d"),this._stage=this.view.stage,this._stage.addTexture(this),this._updateCanvasElementSize(this._atlas),this._reset()}unload(){this._texture=i(this._texture),this._frameWorker=r(this._frameWorker),this.updating=!1,this.events.emit("unloaded")}get loaded(){return null!=this._texture}get texture(){return this._texture}static get maxSize(){return b=d.stableRendering?w:0,[g-w-b,g-w-b-k]}load(e){if(this._texture)return this._texture;const t=new x;return t.wrapMode=33071,t.samplingMode=9987,t.hasMipmap=!0,t.preMultiplyAlpha=!0,t.maxAnisotropy=e.parameters.maxMaxAnisotropy,this._texture=new p(e,t,this._canvas),this._frameWorker=this.view.resourceController.scheduler.registerTask(m.TEXT_TEXTURE_ATLAS,this),this.setDirty(),this._texture}dispose(){this._elements.clear(),this._elementsToRender.clear(),this._frameWorker=r(this._frameWorker),this._texture&&(this._stage.removeTexture(this),this._texture=i(this._texture)),this._canvas.width=0,this._canvas.height=0,this._canvas=null,this._ctx=null}_updateCanvasElementSize(e){this._canvas.width=e.width,this._canvas.height=e.height}_resizeAtlas(e,t){const{width:s,height:i}=this._atlas;s===e&&i===t||(this._atlas.width=e,this._atlas.height=t,this._texture?.resize(e,t),this._texture?.updateData(0,0,0,s,i,this._canvas),this._updateCanvasElementSize(this._atlas),this._elements.forEach(e=>this._uvCallbacks.get(e.textRenderer.key)?.forEach(t=>t(e.uv))),this._reset())}_reset(){this._elementsToRender.clear(),this._atlas.reset(),this._needsRepack=!0,this.setDirty()}_addAtlasElement(e,t,s,i){const r=this._atlas;if(r.width<s||r.height<i)return!1;let h=r.cursors.get(i);if(!h){if(r.height<r.nextY+i)return!1;h=[new T(r.nextY)],r.cursors.set(i,h),r.nextY+=i}let n=h.find(e=>r.width>=e.x+s);if(null==n){if(r.height<r.nextY+i)return!1;n=new T(r.nextY),r.nextY+=i,h.push(n)}return e.setNewPosition(n),this._elements.set(t,e),this._elementsToRender.set(t,e),n.x+=s,!0}_ensureCallbacks(e){const t=this._uvCallbacks.get(e);if(t)return t;const s=new Set;return this._uvCallbacks.set(e,s),s}_addCallback(e,t){this._ensureCallbacks(e).add(t)}_removeCallback(e,t){const s=this._uvCallbacks.get(e);return!(!s?.delete(t)||0!==s.size)&&(this._uvCallbacks.delete(e),!0)}_processAddition(e){const t=e.textRenderer.key;if(this._needsRepack)return void this._elements.set(t,e);const s=this._atlas,i=e.textRenderer.renderedWidth,r=e.textRenderer.renderedHeight,h=i+w,n=r+w+k;if(!this._addAtlasElement(e,t,h,n)){if(this._canRepack)this._reset();else if(s.width<h){const e=u(Math.max(h,1.5*s.width),g);this._resizeAtlas(e,s.height)}else{const e=s.nextY+n,t=u(Math.max(e,1.5*s.height),g);if(t>s.height)this._resizeAtlas(s.width,t);else if(s.width<g){const e=u(1.5*s.width,g);this._resizeAtlas(e,s.height)}}this._elements.set(t,e)}}_renderElement(e){const t=e.commitNewPosition(),s=e.textRenderer;this._ctx.clearRect(t[0]-w,t[1]-w,s.renderedWidth+2*w,s.renderedHeight+2*w),s.render(this._ctx,t[0],t[1]),this._uvCallbacks.get(s.key)?.forEach(t=>t(e.uv))}get readyToRun(){return this.updating}runTask(e){if(null==this._texture)return f;for(;this._needsRepack&&(this._canRepack||this._atlas.height<g&&this._atlas.height<g);){this._canRepack=this._needsRepack=!1;const t=this._elements;this._elements=new Map,t.forEach(e=>this._processAddition(e)),e.madeProgress()}if(this._elementsToRender.size>0){for(const[t,s]of this._elementsToRender){if(e.done)break;this._renderElement(s),this._elementsToRender.delete(t),e.madeProgress()}this._texture.setData(this._canvas)}this.updating=this._elementsToRender.size>0}addText(e,t){const s=e.key;this._addCallback(s,t);let i=this._elements.get(s);return i?o(i.uv,_)||t(i.uv):(i=new y(e),this._processAddition(i),this.setDirty()),{remove:()=>this._removeText(e,t)}}_removeText(e,t){const s=e.key;this._elements.get(s)&&this._removeCallback(s,t)&&(this._elements.delete(s),this._elementsToRender.delete(s),this._canRepack=!0)}setDirty(){this._texture&&(this.updating=!0)}get test(){}get usedMemory(){return(this._texture?.usedMemory??0)+(this._canvas?.width??0)*(this._canvas?.height??0)*4}};e([n({constructOnly:!0})],v.prototype,"view",void 0),e([n({type:Boolean})],v.prototype,"updating",void 0),v=e([a("esri.views.3d.webgl-engine.lib.TextTextureAtlas")],v);const w=2,k=2;class y{constructor(e){this.textRenderer=e,this._uv=c(),this._newPosition=[0,0]}get uv(){if(null==this._xOffset||null==this._yOffset)return _;const{renderedWidth:e,renderedHeight:t}=this.textRenderer;return l(this._uv,this._xOffset,this._yOffset+t,this._xOffset+e,this._yOffset)}setNewPosition(e){this._newPosition[0]=e.x,this._newPosition[1]=e.y}commitNewPosition(){return this._xOffset=this._newPosition[0],this._yOffset=this._newPosition[1],this._newPosition}get xOffset(){return this._xOffset}get yOffset(){return this._yOffset}}class R{constructor(e,t){this.width=e,this.height=t,this.cursors=new Map,this.nextY=0}reset(){this.cursors.clear(),this.nextY=b}}class T{constructor(e){this.y=e,this.x=b}}let b=0;export{v as TextTextureAtlas};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{SizedPixelFormat as t,PixelType as e}from"../../../../webgl/enums.js";import{Texture as i}from"../../../../webgl/Texture.js";import{TextureDescriptor as r}from"../../../../webgl/TextureDescriptor.js";class s{constructor(s,h){this._rctx=s,this._fields=[],this._nameToFieldMap=new Map,this._textureData=new Uint8Array(new ArrayBuffer),this._textureWidth=1,this._textureHeight=1,this._dirty=!0,this._layout=h,this._setupFields(h);const a=new r(this._textureWidth,this._textureHeight);a.samplingMode=9728,a.wrapMode=33071,a.internalFormat=t.RGBA8UI,a.pixelFormat=36249,a.dataType=e.UNSIGNED_BYTE,this._texture=new i(this._rctx,a)}get layout(){return this._layout}dispose(){this._texture.dispose(),this._texture=void 0,this._textureData=void 0}get test(){return{data:this._textureData,fields:this._fields}}getScalarField(t){const e=this._nameToFieldMap.get(t);return 1===e?.elementCount?e:null}getVec4Field(t){const e=this._nameToFieldMap.get(t);return 4===e?.elementCount?e:null}resizeToFit(t){const e=t+1;e>this._textureData.length/this._layout.byteStride&&this._resize(e)}updateTexture(){if(!this._dirty)return;const t=this._texture.descriptor.width,e=this._texture.descriptor.height;t===this._textureWidth&&e===this._textureHeight||this._texture.resize(this._textureWidth,this._textureHeight),this._texture.setData(this._textureData),this._dirty=!1}get texture(){return this._texture}_resize(t){const{_fields:e,_layout:i}=this,r=i.byteStride;if(0===t){const t=new ArrayBuffer;this._textureData=new Uint8Array(t);for(const i of e)i.updateBuffer(t);return void(this._dirty=!0)}const s=Math.ceil(Math.sqrt(t)),h=Math.ceil(t/s),a=s*r,u=Math.ceil(a/4),_=new ArrayBuffer(a*h);for(const o of e)o.updateBuffer(_);const n=new Uint8Array(_);n.set(this._textureData),this._textureData=n,this._textureWidth=u,this._textureHeight=h,this._dirty=!0}_setupFields(t){const e=this._textureData.buffer;this._fields=t.fields.map(t=>{const i=t.createField(()=>this._dirty=!0);return i.updateBuffer(e),this._nameToFieldMap.set(i.name,i),i})}}export{s as TextureBackedBuffer};
5
+ import{disposeMaybe as t}from"../../../../../core/maybe.js";import{SizedPixelFormat as e,PixelType as i}from"../../../../webgl/enums.js";import{Texture as r}from"../../../../webgl/Texture.js";import{TextureDescriptor as s}from"../../../../webgl/TextureDescriptor.js";class u{constructor(t,e){this._rctx=t,this._fields=[],this._nameToFieldMap=new Map,this._textureData=new Uint8Array(new ArrayBuffer),this._textureWidth=0,this._textureHeight=0,this._texture=null,this._dirty=!0,this._layout=e,this._setupFields(e)}get layout(){return this._layout}dispose(){this._texture=t(this._texture),this._texture=void 0,this._textureData=void 0}get test(){return{data:this._textureData,fields:this._fields}}getScalarField(t){const e=this._nameToFieldMap.get(t);return 1===e?.elementCount?e:null}getVec4Field(t){const e=this._nameToFieldMap.get(t);return 4===e?.elementCount?e:null}resizeToFit(t){const e=t+1;e>this._textureData.length/this._layout.byteStride&&this._resize(e)}updateTexture(){if(!this._dirty)return;const{_textureWidth:e,_textureHeight:i}=this;if(0===i||0===i)return this._texture=t(this._texture),void(this._dirty=!1);const r=this._texture?.descriptor.width,s=this._texture?.descriptor.height;null!=this._texture&&r===e&&s===i||(this._texture=t(this.texture),this._texture=this._allocateTexture()),this._texture.setData(this._textureData),this._dirty=!1}get texture(){return this._texture}_resize(t){const{_fields:e,_layout:i}=this,r=i.byteStride;if(0===t){const t=new ArrayBuffer;this._textureData=new Uint8Array(t);for(const i of e)i.updateBuffer(t);return void(this._dirty=!0)}const s=Math.ceil(Math.sqrt(t)),u=Math.ceil(t/s),a=s*r,h=Math.ceil(a/4),_=new ArrayBuffer(a*u);for(const n of e)n.updateBuffer(_);const o=new Uint8Array(_);o.set(this._textureData),this._textureData=o,this._textureWidth=h,this._textureHeight=u,this._dirty=!0}_setupFields(t){const e=this._textureData.buffer;this._fields=t.fields.map(t=>{const i=t.createField(()=>this._dirty=!0);return i.updateBuffer(e),this._nameToFieldMap.set(i.name,i),i})}_allocateTexture(){const t=new s(this._textureWidth,this._textureHeight);return t.samplingMode=9728,t.wrapMode=33071,t.internalFormat=e.RGBA8UI,t.pixelFormat=36249,t.dataType=i.UNSIGNED_BYTE,t.isImmutable=!0,t.hasMipmap=!1,new r(this._rctx,t)}}export{u as TextureBackedBuffer};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../core/PooledArray.js";import{transpose as r,invert as t}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{h as i}from"../../../../../chunks/vec32.js";import{debugFlags as a}from"../../../support/debugFlags.js";import{TwoVectorPosition as o}from"../../core/util/TwoVectorPosition.js";import{EdgeDrawParameters as n}from"./EdgeShaderParameters.js";import{EdgeShaderTechnique as l}from"./EdgeShaderTechnique.js";import{EdgeShaderTechniqueConfiguration as d}from"./EdgeShaderTechniqueConfiguration.js";import{PrimitiveType as h}from"../../../../webgl/enums.js";const c=8,m=128,_={type:0,hasSlicePlane:!1,strokesTexture:null,legacy:!0,spherical:!0};class g{constructor(r,t,s){this.rctx=r,this._techniques=t,this._configuration=new d,this.refCount=0,this._renderables=new Set,this._sortedRenderables={0:{0:new e,1:new e},1:{0:new e,1:new e}},this._renderablesDirty=!1,this._drawParameters=new n,this._settings={..._,...s},this.key=g.getKey(this._settings.type,this._settings.hasSlicePlane,this._settings.legacy);const i=this._settings.strokesTexture.variants;this.writerSettings={variants:i,reducedPrecision:a.TESTS_DISABLE_OPTIMIZATIONS},this._configuration.legacy=this._settings.legacy,this._configuration.type=this._settings.type,this._configuration.silhouette=!1,this._configuration.hasSlicePlane=this._settings.hasSlicePlane,this._configuration.spherical=s.spherical}addRenderable(e){this._renderables.add(e),this._renderablesDirty=!0}removeRenderable(e){this._renderables.delete(e),this._renderablesDirty=!0}setRenderablesDirty(){this._renderablesDirty=!0}forEachRenderable(e,r){this._renderablesDirty&&this._sortRenderables();const t=this._sortedRenderables[r];t[0].forAll(e),t[1].forAll(e)}acquireTechnique(e,r){return this._lastOriginId=null,this._configuration.terrainDepthTest=e.terrainDepthTest,this._configuration.cullAboveTerrain=e.cullAboveTerrain,this._configuration.silhouette=r,this._techniques.get(l,this._configuration)}renderRegularEdges(e,r,t,s,i){this._render(e,r,r.regular.vao,t,s,i)}renderSilhouetteEdges(e,r,t,s,i){this._render(e,r,r.silhouette.vao,t,s,i)}_render(e,r,t,s,i,a){a>0&&(this._bindDraw(e,r,s,i),this.rctx.bindVAO(t),this.rctx.drawArraysInstanced(h.TRIANGLE_FAN,0,4,a))}_bindDraw(e,s,a,n){this._drawParameters.componentDataTexture=s.components.buffer.textureBuffer.texture,this._drawParameters.strokesTexture=this._settings.strokesTexture;const l=s.transform.origin;if(l){const r=l.origin.id;this._lastOriginId!==r&&(e.setUniformMatrix4fv("localView",l.viewMatrix),this._lastOriginId=r),e.setUniformMatrix4fv("model",s.transform.modelMatrix),this._drawParameters.slicePlaneLocalOrigin=l.origin.vec3}else{const e=new o(s.transform.position),a=r(f,t(f,s.transform.rotationScale));this._drawParameters.transformWorldFromModelTL=e.low,this._drawParameters.transformWorldFromModelTH=e.high,this._drawParameters.transformWorldFromModelRS=s.transform.rotationScale,this._drawParameters.transformNormalGlobalFromModel=a;const l=n.camera.viewInverseTransposeMatrix;i(this._drawParameters.slicePlaneLocalOrigin,l[3],l[7],l[11])}e.bindDraw(n,a,this._drawParameters)}_sortRenderables(){this._renderablesDirty=!1,this._sortedRenderables[0][0].clear(),this._sortedRenderables[0][1].clear(),this._sortedRenderables[1][0].clear(),this._sortedRenderables[1][1].clear(),this._renderables.forEach(e=>this._sortedRenderables[e.objectTransparency][e.edgeTransparency].push(e));const e=(e,r)=>e.transform.origin?r.transform.origin?e.transform.origin.origin.id<r.transform.origin.origin.id?-1:e.transform.origin.origin.id>r.transform.origin.origin.id?1:0:1:0;this._sortedRenderables[0][0].sort(e),this._sortedRenderables[0][1].sort(e),this._sortedRenderables[1][0].sort(e),this._sortedRenderables[1][1].sort(e)}static getKey(e,r,t){return`edges-t:${e}:${r}:${t}`}}const f=s();export{g as EdgeRenderer,m as extensionLengthOffset,c as lineWidthFractionFactor};
5
+ import e from"../../../../../core/PooledArray.js";import{transpose as r,invert as t}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{h as i}from"../../../../../chunks/vec32.js";import{debugFlags as a}from"../../../support/debugFlags.js";import{TwoVectorPosition as o}from"../../core/util/TwoVectorPosition.js";import{EdgeDrawParameters as n}from"./EdgeShaderParameters.js";import{EdgeShaderTechnique as l}from"./EdgeShaderTechnique.js";import{EdgeShaderTechniqueConfiguration as d}from"./EdgeShaderTechniqueConfiguration.js";import{PrimitiveType as h}from"../../../../webgl/enums.js";const c=8,m=128,_={type:0,hasSlicePlane:!1,strokesTexture:null,legacy:!0,spherical:!0};class g{constructor(r,t,s){this.rctx=r,this._techniques=t,this._configuration=new d,this.refCount=0,this._renderables=new Set,this._sortedRenderables={0:{0:new e,1:new e},1:{0:new e,1:new e}},this._renderablesDirty=!1,this._drawParameters=new n,this._settings={..._,...s},this.key=g.getKey(this._settings.type,this._settings.hasSlicePlane,this._settings.legacy);const i=this._settings.strokesTexture.variants;this.writerSettings={variants:i,reducedPrecision:a.TESTS_DISABLE_OPTIMIZATIONS},this._configuration.legacy=this._settings.legacy,this._configuration.type=this._settings.type,this._configuration.silhouette=!1,this._configuration.hasSlicePlane=this._settings.hasSlicePlane,this._configuration.spherical=s.spherical}addRenderable(e){this._renderables.add(e),this._renderablesDirty=!0}removeRenderable(e){this._renderables.delete(e),this._renderablesDirty=!0}setRenderablesDirty(){this._renderablesDirty=!0}forEachRenderable(e,r){this._renderablesDirty&&this._sortRenderables();const t=this._sortedRenderables[r];t[0].forAll(e),t[1].forAll(e)}acquireTechnique(e,r){return this._lastOriginId=null,this._configuration.terrainDepthTest=e.terrainDepthTest,this._configuration.cullAboveTerrain=e.cullAboveTerrain,this._configuration.silhouette=r,this._techniques.get(l,this._configuration)}renderRegularEdges(e,r,t,s,i){this._render(e,r,r.regular.vao,t,s,i)}renderSilhouetteEdges(e,r,t,s,i){this._render(e,r,r.silhouette.vao,t,s,i)}_render(e,r,t,s,i,a){a>0&&(this._bindDraw(e,r,s,i),this.rctx.bindVAO(t),this.rctx.drawArraysInstanced(h.TRIANGLE_FAN,0,4,a))}_bindDraw(e,s,a,n){this._drawParameters.componentDataTextureBuffer=s.components.buffer.textureBuffer,this._drawParameters.strokesTexture=this._settings.strokesTexture;const l=s.transform.origin;if(l){const r=l.origin.id;this._lastOriginId!==r&&(e.setUniformMatrix4fv("localView",l.viewMatrix),this._lastOriginId=r),e.setUniformMatrix4fv("model",s.transform.modelMatrix),this._drawParameters.slicePlaneLocalOrigin=l.origin.vec3}else{const e=new o(s.transform.position),a=r(f,t(f,s.transform.rotationScale));this._drawParameters.transformWorldFromModelTL=e.low,this._drawParameters.transformWorldFromModelTH=e.high,this._drawParameters.transformWorldFromModelRS=s.transform.rotationScale,this._drawParameters.transformNormalGlobalFromModel=a;const l=n.camera.viewInverseTransposeMatrix;i(this._drawParameters.slicePlaneLocalOrigin,l[3],l[7],l[11])}e.bindDraw(n,a,this._drawParameters)}_sortRenderables(){this._renderablesDirty=!1,this._sortedRenderables[0][0].clear(),this._sortedRenderables[0][1].clear(),this._sortedRenderables[1][0].clear(),this._sortedRenderables[1][1].clear(),this._renderables.forEach(e=>this._sortedRenderables[e.objectTransparency][e.edgeTransparency].push(e));const e=(e,r)=>e.transform.origin?r.transform.origin?e.transform.origin.origin.id<r.transform.origin.origin.id?-1:e.transform.origin.origin.id>r.transform.origin.origin.id?1:0:1:0;this._sortedRenderables[0][0].sort(e),this._sortedRenderables[0][1].sort(e),this._sortedRenderables[1][0].sort(e),this._sortedRenderables[1][1].sort(e)}static getKey(e,r,t){return`edges-t:${e}:${r}:${t}`}}const f=s();export{g as EdgeRenderer,m as extensionLengthOffset,c as lineWidthFractionFactor};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../../core/Logger.js";import{clamp as e}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as i}from"../../../../core/screenUtils.js";import{secondsFromMilliseconds as r}from"../../../../core/time.js";import{copy as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{h as a,e as n,g as o,j as l,i as h,d as c,b as m,D as p,p as u}from"../../../../chunks/vec32.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as d}from"../../../../chunks/vec42.js";import{ONES as g,create as b}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{makeFloat16Array as _}from"../../../../geometry/support/float16.js";import{distance2 as S,fromPoints as v,create as P,closestLineSegmentPoint as j}from"../../../../geometry/support/lineSegment.js";import{fromPoints as E,create as w,signedDistance as y,getNormal as T}from"../../../../geometry/support/plane.js";import{isHighlightOrOID as z,isColor as A,isDepth as C,isColorHighlightOIDOrDepth as O,is2DGeometryOutput as L}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as M}from"../effects/geometry/olidUtils.js";import V from"../lib/GLMaterial.js";import{Material as R}from"../lib/Material.js";import{isTranslationMatrix as x}from"../lib/Util.js";import{VisualVariablePassParameters as F}from"./VisualVariablePassParameters.js";import{writeDeltaF16Vector as k}from"./internal/bufferWriterUtils.js";import{r as N}from"../../../../chunks/RibbonLine.glsl.js";import{getLayout as U,RibbonLineTechnique as D}from"../shaders/RibbonLineTechnique.js";import{RibbonLineTechniqueConfiguration as B}from"../shaders/RibbonLineTechniqueConfiguration.js";import{alphaCutoff as W}from"../../../../webscene/support/AlphaCutoff.js";class J extends R{constructor(t,e){super(t,q),this.produces=new Map([[2,t=>z(t)||A(t)&&8===this.parameters.renderOccluded],[3,t=>C(t)],[10,t=>O(t)&&8===this.parameters.renderOccluded],[11,t=>O(t)&&8===this.parameters.renderOccluded],[4,t=>A(t)&&this.parameters.writeDepth&&8!==this.parameters.renderOccluded],[8,t=>A(t)&&!this.parameters.writeDepth&&8!==this.parameters.renderOccluded],[18,t=>L(t)]]),this._configuration=new B(e)}getConfiguration(t,e){super.getConfiguration(t,e,this._configuration),this._configuration.oitPass=e.oitPass,this._configuration.draped=18===e.slot;const i=null!=this.parameters.stipplePattern&&8!==t;return this._configuration.stippleEnabled=i,this._configuration.stippleOffColorEnabled=i&&null!=this.parameters.stippleOffColor,this._configuration.stipplePreferContinuous=i&&this.parameters.stipplePreferContinuous,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.roundJoins="round"===this.parameters.join,this._configuration.capType=this.parameters.cap,this._configuration.applyMarkerOffset=null!=this.parameters.markerParameters&&H(this.parameters.markerParameters),this._configuration.hasPolygonOffset=this.parameters.hasPolygonOffset,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.hasVVSize=this.parameters.hasVVSize,this._configuration.hasVVColor=this.parameters.hasVVColor,this._configuration.hasVVOpacity=this.parameters.hasVVOpacity,this._configuration.innerColorEnabled=this.parameters.innerWidth>0&&null!=this.parameters.innerColor,this._configuration.falloffEnabled=this.parameters.falloff>0,this._configuration.hasOccludees=e.hasOccludees,this._configuration.occluder=8===this.parameters.renderOccluded,this._configuration.terrainDepthTest=e.terrainDepthTest&&A(t),this._configuration.cullAboveTerrain=e.cullAboveTerrain,this._configuration.wireframe=this.parameters.wireframe,this._configuration.animation=this.parameters.animation,this._configuration.emissionSource=this.hasEmissions?1:0,this._configuration.hasScreenSizePerspective=!!this.parameters.screenSizePerspective,this._configuration}get visible(){return this.parameters.color[3]>=W||null!=this.parameters.stipplePattern&&(this.parameters.stippleOffColor?.[3]??0)>W}setParameters(t,e){t.animation=this.parameters.animation,super.setParameters(t,e)}intersectDraped({attributes:t,screenToWorldRatio:i},r,s,a,n){if(!r.options.selectionMode)return;const o=t.get("size");let l=this.parameters.width;if(this.parameters.vvSize){const i=t.get("sizeFeatureAttribute").data[0];Number.isNaN(i)?l*=this.parameters.vvSize.fallback[0]:l*=e(this.parameters.vvSize.offset[0]+i*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else o&&(l*=o.data[0]);const h=s[0],c=s[1],m=(l/2+4)*i;let p=Number.MAX_VALUE,u=0;const f=t.get("position").data,d=I(this.parameters,t)?f.length-2:f.length-5;for(let g=0;g<d;g+=3){const t=f[g],i=f[g+1],r=(g+3)%f.length,s=h-t,a=c-i,n=f[r]-t,o=f[r+1]-i,l=e((n*s+o*a)/(n*n+o*o),0,1),m=n*l-s,d=o*l-a,b=m*m+d*d;b<p&&(p=b,u=g/3)}p<m*m&&a(n.distance,n.normal,u)}intersect(i,r,u,f,d,g){const{options:b,camera:_,rayBegin:P,rayEnd:w}=u;if(!b.selectionMode||!i.visible||!_)return;if(!x(r))return void t.getLogger("esri.views.3d.webgl-engine.materials.RibbonLineMaterial").error("intersection assumes a translation-only matrix");const z=i.attributes,A=z.get("position").data;let C=this.parameters.width;if(this.parameters.vvSize){const t=z.get("sizeFeatureAttribute").data[0];Number.isNaN(t)||(C*=e(this.parameters.vvSize.offset[0]+t*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0]))}else z.has("size")&&(C*=z.get("size").data[0]);const O=tt;s(O,u.point);const L=C*_.pixelRatio/2+4*_.pixelRatio;a(mt[0],O[0]-L,O[1]+L,0),a(mt[1],O[0]+L,O[1]+L,0),a(mt[2],O[0]+L,O[1]-L,0),a(mt[3],O[0]-L,O[1]-L,0);for(let t=0;t<4;t++)if(!_.unprojectFromRenderScreen(mt[t],pt[t]))return;E(_.eye,pt[0],pt[1],ut),E(_.eye,pt[1],pt[2],ft),E(_.eye,pt[2],pt[3],dt),E(_.eye,pt[3],pt[0],gt);let M=Number.MAX_VALUE,V=0;const R=I(this.parameters,z)?A.length-2:A.length-5;for(let t=0;t<R;t+=3){K[0]=A[t]+r[12],K[1]=A[t+1]+r[13],K[2]=A[t+2]+r[14];const e=(t+3)%A.length;if(Q[0]=A[e]+r[12],Q[1]=A[e+1]+r[13],Q[2]=A[e+2]+r[14],y(ut,K)<0&&y(ut,Q)<0||y(ft,K)<0&&y(ft,Q)<0||y(dt,K)<0&&y(dt,Q)<0||y(gt,K)<0&&y(gt,Q)<0)continue;const i=_.projectToRenderScreen(K,et),s=_.projectToRenderScreen(Q,it);if(null==i||null==s)continue;if(i[2]<0&&s[2]>0){n(Z,K,Q);const t=_.frustum,e=-y(t[4],K)/o(Z,T(t[4]));if(l(Z,Z,e),h(K,K,Z),!_.projectToRenderScreen(K,i))continue}else if(i[2]>0&&s[2]<0){n(Z,Q,K);const t=_.frustum,e=-y(t[4],Q)/o(Z,T(t[4]));if(l(Z,Z,e),h(Q,Q,Z),!_.projectToRenderScreen(Q,s))continue}else if(i[2]<0&&s[2]<0)continue;i[2]=0,s[2]=0;const a=S(v(i,s,at),O);a<M&&(M=a,c(rt,K),c(st,Q),V=t/3)}if(M<L*L){let t=Number.MAX_VALUE;if(j(v(rt,st,at),v(P,w,nt),$)){n($,$,P);const e=m($);l($,$,1/e),t=e/p(P,w)}g(t,$,V)}}get hasEmissions(){return this.parameters.emissiveStrength>0}createBufferWriter(){return new X(U(this.parameters),this.parameters)}createGLMaterial(t){return new Y(t)}validateParameters(t){"miter"!==t.join&&(t.miterLimit=0),null!=t.markerParameters&&(t.markerScale=t.markerParameters.width/t.width)}update(t){return!!this.parameters.hasAnimation&&(this.setParameters({timeElapsed:r(t.time)},!1),0!==t.dt)}}class Y extends V{constructor(){super(...arguments),this._stipplePattern=null}dispose(){super.dispose(),this._stippleTextures?.release(this._stipplePattern),this._stipplePattern=null}beginSlot(t){const e=this._material.parameters.stipplePattern;return this._stipplePattern!==e&&(this._material.setParameters({stippleTexture:this._stippleTextures.swap(e,this._stipplePattern)}),this._stipplePattern=e),this.getTechnique(D,t)}}class q extends F{constructor(){super(...arguments),this.width=0,this.color=g,this.join="miter",this.cap=0,this.miterLimit=5,this.writeDepth=!0,this.hasPolygonOffset=!1,this.stippleTexture=null,this.stipplePreferContinuous=!0,this.markerParameters=null,this.markerScale=1,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.isClosed=!1,this.falloff=0,this.innerWidth=0,this.wireframe=!1,this.timeElapsed=0,this.animation=0,this.animationSpeed=1,this.trailLength=1,this.startTime=0,this.endTime=1/0,this.fadeInTime=0,this.fadeOutTime=1/0,this.emissiveStrength=0}get transparent(){return this.color[3]<1||this.hasAnimation||null!=this.stipplePattern&&(this.stippleOffColor?.[3]??0)<1}get hasAnimation(){return 0!==this.animation}}class X{constructor(t,e){this.layout=t,this._parameters=e;const i=e.stipplePattern?1:0;switch(this._parameters.join){case"miter":case"bevel":this.numJoinSubdivisions=i;break;case"round":this.numJoinSubdivisions=N+i}}_isClosed(t){return I(this._parameters,t)}allocate(t){return this.layout.createBuffer(t)}elementCount(t){const e=2,i=t.get("position").indices.length/2+1,r=this._isClosed(t);let s=r?2:2*e;return s+=((r?i:i-1)-(r?0:1))*(2*this.numJoinSubdivisions+4),s+=2,this._parameters.wireframe&&(s=2+4*(s-2)),s}write(t,e,i,r,s,n){const o=this.layout,l=i.get("position"),h=l.indices,m=l.data.length/3,f=i.get("distanceToStart")?.data;h&&h.length!==2*(m-1)&&console.warn("RibbonLineMaterial does not support indices");const g=o.fields.has("sizeFeatureAttribute");let b=1,S=null;if(g){const t=i.get("sizeFeatureAttribute");1===t.data.length?b=t.data[0]:S=t.data}else b=i.get("size")?.data[0]??1;let v=[1,1,1,1],P=0,j=null;const E=o.fields.has("colorFeatureAttribute");if(E){const t=i.get("colorFeatureAttribute");1===t.data.length?P=t.data[0]:j=t.data}else v=i.get("color")?.data??v;const w=i.get("timeStamps")?.data,y=w&&o.fields.has("timeStamps"),T=o.fields.has("opacityFeatureAttribute");let z=0,A=null;if(T){const t=i.get("opacityFeatureAttribute");1===t.data.length?z=t.data[0]:A=t.data}const C=new Float32Array(s.buffer),O=_(s.buffer),L=new Uint8Array(s.buffer),V=o.stride/4;let R=n*V;const x=R;let F=0;const N=f?(t,e,i)=>F=f[i]:(t,e,i)=>F+=p(t,e),U=C.BYTES_PER_ELEMENT/O.BYTES_PER_ELEMENT,D=4/U,B=M(),W=(t,e,i,s,a,n,o,l)=>{C[R++]=e[0],C[R++]=e[1],C[R++]=e[2],k(t,e,O,R*U),R+=D,k(i,e,O,R*U),R+=D,C[R++]=l;let h=R*U;if(O[h++]=a,O[h++]=n,R=Math.ceil(h/U),E)C[R]=j?.[o]??P;else{const t=Math.min(4*o,v.length-4),e=4*R;L[e]=255*v[t],L[e+1]=255*v[t+1],L[e+2]=255*v[t+2],L[e+3]=255*v[t+3]}if(R++,C[R++]=S?.[o]??b,T&&(C[R++]=A?.[o]??z),B){let t=4*R;r?(L[t++]=r[0],L[t++]=r[1],L[t++]=r[2],L[t++]=r[3]):(L[t++]=0,L[t++]=0,L[t++]=0,L[t++]=0),R=Math.ceil(.25*t)}y&&(h=R*U,O[h++]=s[0],O[h++]=s[1],O[h++]=s[2],O[h++]=s[3],R=Math.ceil(h/U))};R+=V,a(lt,l.data[0],l.data[1],l.data[2]),y&&d(ct,w[0],w[1],w[2],w[3]),t&&u(lt,lt,t);const J=this._isClosed(i);if(J){const e=l.data.length-3;a(ot,l.data[e],l.data[e+1],l.data[e+2]),t&&u(ot,ot,t)}else a(ht,l.data[3],l.data[4],l.data[5]),t&&u(ht,ht,t),W(lt,lt,ht,ct,1,-4,0,0),W(lt,lt,ht,ct,1,4,0,0),c(ot,lt),c(lt,ht),y&&d(ct,w[4],w[5],w[6],w[7]);const Y=J?0:1,q=J?m:m-1;for(let p=Y;p<q;p++){const e=(p+1)%m*3;a(ht,l.data[e],l.data[e+1],l.data[e+2]),t&&u(ht,ht,t),N(ot,lt,p),W(ot,lt,ht,ct,0,-1,p,F),W(ot,lt,ht,ct,0,1,p,F);const i=this.numJoinSubdivisions;for(let t=0;t<i;++t){const e=(t+1)/(i+1);W(ot,lt,ht,ct,e,-1,p,F),W(ot,lt,ht,ct,e,1,p,F)}if(W(ot,lt,ht,ct,1,-2,p,F),W(ot,lt,ht,ct,1,2,p,F),c(ot,lt),c(lt,ht),y){const t=(p+1)%m*4;d(ct,w[t],w[t+1],w[t+2],w[t+3])}}J?(a(ht,l.data[3],l.data[4],l.data[5]),t&&u(ht,ht,t),F=N(ot,lt,q),W(ot,lt,ht,ct,0,-1,Y,F),W(ot,lt,ht,ct,0,1,Y,F)):(F=N(ot,lt,q),W(ot,lt,lt,ct,0,-5,q,F),W(ot,lt,lt,ct,0,5,q,F)),G(C,x+V,C,x,V);return R=G(C,R-V,C,R,V),this._parameters.wireframe&&this._addWireframeVertices(s,x,R,V),null}_addWireframeVertices(t,e,i,r){const s=new Float32Array(t.buffer,i*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(t.buffer,e*Float32Array.BYTES_PER_ELEMENT,i-e);let n=0;const o=t=>n=G(a,t,s,n,r);for(let l=0;l<a.length-1;l+=2*r)o(l),o(l+2*r),o(l+1*r),o(l+2*r),o(l+1*r),o(l+3*r)}}function G(t,e,i,r,s){for(let a=0;a<s;a++)i[r++]=t[e++];return r}function I(t,e){if(!t.isClosed)return!1;return e.get("position").indices.length>2}function H(t){return 1===t.anchor&&t.hideOnShortSegments&&"begin-end"===t.placement&&t.worldSpace}const K=f(),Q=f(),Z=f(),$=f(),tt=f(),et=i(),it=i(),rt=f(),st=f(),at=P(),nt=P(),ot=f(),lt=f(),ht=f(),ct=b(),mt=[i(),i(),i(),i()],pt=[f(),f(),f(),f()],ut=w(),ft=w(),dt=w(),gt=w();export{q as Parameters,J as RibbonLineMaterial};
5
+ import t from"../../../../core/Logger.js";import{clamp as e}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as i}from"../../../../core/screenUtils.js";import{secondsFromMilliseconds as r}from"../../../../core/time.js";import{copy as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{h as a,e as n,g as o,j as l,i as h,d as c,b as m,D as p,p as u}from"../../../../chunks/vec32.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as d}from"../../../../chunks/vec42.js";import{ONES as g,create as b}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{makeFloat16Array as _}from"../../../../geometry/support/float16.js";import{distance2 as S,fromPoints as v,create as P,closestLineSegmentPoint as j}from"../../../../geometry/support/lineSegment.js";import{fromPoints as E,create as w,signedDistance as y,getNormal as T}from"../../../../geometry/support/plane.js";import{isHighlightOrOID as z,isColor as A,isDepth as C,isColorHighlightOIDOrDepth as O,is2DGeometryOutput as L}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as M}from"../effects/geometry/olidUtils.js";import V from"../lib/GLMaterial.js";import{Material as R}from"../lib/Material.js";import{isTranslationMatrix as x}from"../lib/Util.js";import{VisualVariablePassParameters as F}from"./VisualVariablePassParameters.js";import{writeDeltaF16Vector as k}from"./internal/bufferWriterUtils.js";import{r as N}from"../../../../chunks/RibbonLine.glsl.js";import{getLayout as U,RibbonLineTechnique as D}from"../shaders/RibbonLineTechnique.js";import{RibbonLineTechniqueConfiguration as B}from"../shaders/RibbonLineTechniqueConfiguration.js";import{alphaCutoff as W}from"../../../../webscene/support/AlphaCutoff.js";class J extends R{constructor(t,e){super(t,q),this.produces=new Map([[2,t=>z(t)||A(t)&&8===this.parameters.renderOccluded],[3,t=>C(t)],[10,t=>O(t)&&8===this.parameters.renderOccluded],[11,t=>O(t)&&8===this.parameters.renderOccluded],[4,t=>A(t)&&this.parameters.writeDepth&&8!==this.parameters.renderOccluded],[8,t=>A(t)&&!this.parameters.writeDepth&&8!==this.parameters.renderOccluded],[18,t=>L(t)]]),this._configuration=new B(e)}getConfiguration(t,e){super.getConfiguration(t,e,this._configuration),this._configuration.oitPass=e.oitPass,this._configuration.draped=18===e.slot;const i=null!=this.parameters.stipplePattern&&8!==t;return this._configuration.stippleEnabled=i,this._configuration.stippleOffColorEnabled=i&&null!=this.parameters.stippleOffColor,this._configuration.stipplePreferContinuous=i&&this.parameters.stipplePreferContinuous,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.roundJoins="round"===this.parameters.join,this._configuration.capType=this.parameters.cap,this._configuration.applyMarkerOffset=null!=this.parameters.markerParameters&&H(this.parameters.markerParameters),this._configuration.hasPolygonOffset=this.parameters.hasPolygonOffset,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.hasVVSize=this.parameters.hasVVSize,this._configuration.hasVVColor=this.parameters.hasVVColor,this._configuration.hasVVOpacity=this.parameters.hasVVOpacity,this._configuration.innerColorEnabled=this.parameters.innerWidth>0&&null!=this.parameters.innerColor,this._configuration.falloffEnabled=this.parameters.falloff>0,this._configuration.hasOccludees=e.hasOccludees,this._configuration.occluder=8===this.parameters.renderOccluded,this._configuration.terrainDepthTest=e.terrainDepthTest&&A(t),this._configuration.cullAboveTerrain=e.cullAboveTerrain,this._configuration.wireframe=this.parameters.wireframe,this._configuration.animation=this.parameters.animation,this._configuration.emissionSource=this.hasEmissions?1:0,this._configuration.hasScreenSizePerspective=!!this.parameters.screenSizePerspective,this._configuration}get visible(){return this.parameters.color[3]>=W||null!=this.parameters.stipplePattern&&(this.parameters.stippleOffColor?.[3]??0)>W}setParameters(t,e){t.animation=this.parameters.animation,super.setParameters(t,e)}intersectDraped({attributes:t,screenToWorldRatio:i},r,s,a,n){if(!r.options.selectionMode)return;const o=t.get("size");let l=this.parameters.width;if(this.parameters.vvSize){const i=t.get("sizeFeatureAttribute").data[0];Number.isNaN(i)?l*=this.parameters.vvSize.fallback[0]:l*=e(this.parameters.vvSize.offset[0]+i*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else o&&(l*=o.data[0]);const h=s[0],c=s[1],m=(l/2+4)*i;let p=Number.MAX_VALUE,u=0;const f=t.get("position").data,d=I(this.parameters,t)?f.length-2:f.length-5;for(let g=0;g<d;g+=3){const t=f[g],i=f[g+1],r=(g+3)%f.length,s=h-t,a=c-i,n=f[r]-t,o=f[r+1]-i,l=e((n*s+o*a)/(n*n+o*o),0,1),m=n*l-s,d=o*l-a,b=m*m+d*d;b<p&&(p=b,u=g/3)}p<m*m&&a(n.distance,n.normal,u)}intersect(i,r,u,f,d,g){const{options:b,camera:_,rayBegin:P,rayEnd:w}=u;if(!b.selectionMode||!i.visible||!_)return;if(!x(r))return void t.getLogger("esri.views.3d.webgl-engine.materials.RibbonLineMaterial").error("intersection assumes a translation-only matrix");const z=i.attributes,A=z.get("position").data;let C=this.parameters.width;if(this.parameters.vvSize){const t=z.get("sizeFeatureAttribute").data[0];Number.isNaN(t)||(C*=e(this.parameters.vvSize.offset[0]+t*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0]))}else z.has("size")&&(C*=z.get("size").data[0]);const O=tt;s(O,u.point);const L=C*_.pixelRatio/2+4*_.pixelRatio;a(mt[0],O[0]-L,O[1]+L,0),a(mt[1],O[0]+L,O[1]+L,0),a(mt[2],O[0]+L,O[1]-L,0),a(mt[3],O[0]-L,O[1]-L,0);for(let t=0;t<4;t++)if(!_.unprojectFromRenderScreen(mt[t],pt[t]))return;E(_.eye,pt[0],pt[1],ut),E(_.eye,pt[1],pt[2],ft),E(_.eye,pt[2],pt[3],dt),E(_.eye,pt[3],pt[0],gt);let M=Number.MAX_VALUE,V=0;const R=I(this.parameters,z)?A.length-2:A.length-5;for(let t=0;t<R;t+=3){K[0]=A[t]+r[12],K[1]=A[t+1]+r[13],K[2]=A[t+2]+r[14];const e=(t+3)%A.length;if(Q[0]=A[e]+r[12],Q[1]=A[e+1]+r[13],Q[2]=A[e+2]+r[14],y(ut,K)<0&&y(ut,Q)<0||y(ft,K)<0&&y(ft,Q)<0||y(dt,K)<0&&y(dt,Q)<0||y(gt,K)<0&&y(gt,Q)<0)continue;const i=_.projectToRenderScreen(K,et),s=_.projectToRenderScreen(Q,it);if(null==i||null==s)continue;if(i[2]<0&&s[2]>0){n(Z,K,Q);const t=_.frustum,e=-y(t[4],K)/o(Z,T(t[4]));if(l(Z,Z,e),h(K,K,Z),!_.projectToRenderScreen(K,i))continue}else if(i[2]>0&&s[2]<0){n(Z,Q,K);const t=_.frustum,e=-y(t[4],Q)/o(Z,T(t[4]));if(l(Z,Z,e),h(Q,Q,Z),!_.projectToRenderScreen(Q,s))continue}else if(i[2]<0&&s[2]<0)continue;i[2]=0,s[2]=0;const a=S(v(i,s,at),O);a<M&&(M=a,c(rt,K),c(st,Q),V=t/3)}if(M<L*L){let t=Number.MAX_VALUE;if(j(v(rt,st,at),v(P,w,nt),$)){n($,$,P);const e=m($);l($,$,1/e),t=e/p(P,w)}g(t,$,V)}}get hasEmissions(){return this.parameters.emissiveStrength>0}createBufferWriter(){return new X(U(this.parameters),this.parameters)}createGLMaterial(t){return new Y(t)}validateParameters(t){"miter"!==t.join&&(t.miterLimit=0),null!=t.markerParameters&&(t.markerScale=t.markerParameters.width/t.width)}update(t){return!!this.parameters.hasAnimation&&(this.setParameters({timeElapsed:r(t.time)},!1),0!==t.dt)}}class Y extends V{constructor(){super(...arguments),this._stipplePattern=null}dispose(){super.dispose(),this._stippleTextures?.release(this._stipplePattern),this._stipplePattern=null}beginSlot(t){const e=this._material.parameters.stipplePattern;return this._stipplePattern!==e&&(this._material.setParameters({stippleTexture:this._stippleTextures.swap(e,this._stipplePattern)}),this._stipplePattern=e),this.getTechnique(D,t)}}class q extends F{constructor(){super(...arguments),this.width=0,this.color=g,this.join="miter",this.cap=0,this.miterLimit=5,this.writeDepth=!0,this.hasPolygonOffset=!1,this.stippleTexture=null,this.stipplePreferContinuous=!0,this.markerParameters=null,this.markerScale=1,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.isClosed=!1,this.falloff=0,this.innerWidth=0,this.wireframe=!1,this.timeElapsed=0,this.animation=0,this.animationSpeed=1,this.trailLength=1,this.startTime=0,this.endTime=1/0,this.fadeInTime=0,this.fadeOutTime=1/0,this.emissiveStrength=0}get transparent(){return this.color[3]<1||this.hasAnimation||null!=this.stipplePattern&&(this.stippleOffColor?.[3]??0)<1}get hasAnimation(){return 0!==this.animation}}class X{constructor(t,e){this.layout=t,this._parameters=e;const i=e.stipplePattern?1:0;switch(this._parameters.join){case"miter":case"bevel":this.numJoinSubdivisions=i;break;case"round":this.numJoinSubdivisions=N+i}}_isClosed(t){return I(this._parameters,t)}allocate(t){return this.layout.createBuffer(t)}elementCount(t){const e=2,i=t.get("position").indices.length/2+1,r=this._isClosed(t);let s=r?2:2*e;return s+=((r?i:i-1)-(r?0:1))*(2*this.numJoinSubdivisions+4),s+=2,this._parameters.wireframe&&(s=2+4*(s-2)),s}write(t,e,i,r,s,n){const o=this.layout,l=i.get("position"),h=l.indices,m=l.data.length/3,f=i.get("distanceToStart")?.data;h&&h.length!==2*(m-1)&&console.warn("RibbonLineMaterial does not support indices");const g=o.fields.has("sizeFeatureAttribute");let b=1,S=null;if(g){const t=i.get("sizeFeatureAttribute");1===t.data.length?b=t.data[0]:S=t.data}else b=i.get("size")?.data[0]??1;let v=[1,1,1,1],P=0,j=null;const E=o.fields.has("colorFeatureAttribute");if(E){const t=i.get("colorFeatureAttribute");1===t.data.length?P=t.data[0]:j=t.data}else v=i.get("color")?.data??v;const w=i.get("timeStamps")?.data,y=w&&o.fields.has("timeStamps"),T=o.fields.has("opacityFeatureAttribute");let z=0,A=null;if(T){const t=i.get("opacityFeatureAttribute");1===t.data.length?z=t.data[0]:A=t.data}const C=new Float32Array(s.buffer),O=_(s.buffer),L=new Uint8Array(s.buffer),V=o.stride/4;let R=n*V;const x=R;let F=0;const N=f?(t,e,i)=>F=f[i]:(t,e,i)=>F+=p(t,e),U=C.BYTES_PER_ELEMENT/O.BYTES_PER_ELEMENT,D=4/U,B=M(),W=(t,e,i,s,a,n,o,l)=>{C[R++]=e[0],C[R++]=e[1],C[R++]=e[2],k(t,e,O,R*U),R+=D,k(i,e,O,R*U),R+=D,C[R++]=l;let h=R*U;if(O[h++]=a,O[h++]=n,R=Math.ceil(h/U),E)C[R]=j?.[o]??P;else{const t=Math.min(4*o,v.length-4),e=4*R;L[e]=255*v[t],L[e+1]=255*v[t+1],L[e+2]=255*v[t+2],L[e+3]=255*v[t+3]}if(R++,C[R++]=S?.[o]??b,T&&(C[R++]=A?.[o]??z),B){let t=4*R;r?(L[t++]=r[0],L[t++]=r[1],L[t++]=r[2],L[t++]=r[3]):(L[t++]=0,L[t++]=0,L[t++]=0,L[t++]=0),R=Math.ceil(.25*t)}y&&(h=R*U,O[h++]=s[0],O[h++]=s[1],O[h++]=s[2],O[h++]=s[3],R=Math.ceil(h/U))};R+=V,a(lt,l.data[0],l.data[1],l.data[2]),y&&d(ct,w[0],w[1],w[2],w[3]),t&&u(lt,lt,t);const J=this._isClosed(i);if(J){const e=l.data.length-3;a(ot,l.data[e],l.data[e+1],l.data[e+2]),t&&u(ot,ot,t)}else a(ht,l.data[3],l.data[4],l.data[5]),t&&u(ht,ht,t),W(lt,lt,ht,ct,1,-4,0,0),W(lt,lt,ht,ct,1,4,0,0),c(ot,lt),c(lt,ht),y&&d(ct,w[4],w[5],w[6],w[7]);const Y=J?0:1,q=J?m:m-1;for(let p=Y;p<q;p++){const e=(p+1)%m*3;a(ht,l.data[e],l.data[e+1],l.data[e+2]),t&&u(ht,ht,t),N(ot,lt,p),W(ot,lt,ht,ct,0,-1,p,F),W(ot,lt,ht,ct,0,1,p,F);const i=this.numJoinSubdivisions;for(let t=0;t<i;++t){const e=(t+1)/(i+1);W(ot,lt,ht,ct,e,-1,p,F),W(ot,lt,ht,ct,e,1,p,F)}if(W(ot,lt,ht,ct,1,-2,p,F),W(ot,lt,ht,ct,1,2,p,F),c(ot,lt),c(lt,ht),y){const t=(p+1)%m*4;d(ct,w[t],w[t+1],w[t+2],w[t+3])}}J?(a(ht,l.data[3],l.data[4],l.data[5]),t&&u(ht,ht,t),F=N(ot,lt,q),W(ot,lt,ht,ct,0,-1,Y,F),W(ot,lt,ht,ct,0,1,Y,F)):(F=N(ot,lt,q),W(ot,lt,lt,ct,0,-5,q,F),W(ot,lt,lt,ct,0,5,q,F)),G(C,x+V,C,x,V);return R=G(C,R-V,C,R,V),this._parameters.wireframe&&this._addWireframeVertices(s,x,R,V),null}_addWireframeVertices(t,e,i,r){const s=new Float32Array(t.buffer,i*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(t.buffer,e*Float32Array.BYTES_PER_ELEMENT,i-e);let n=0;const o=t=>n=G(a,t,s,n,r);for(let l=0;l<a.length-1;l+=2*r)o(l),o(l+2*r),o(l+1*r),o(l+2*r),o(l+1*r),o(l+3*r)}}function G(t,e,i,r,s){for(let a=0;a<s;a++)i[r++]=t[e++];return r}function I(t,e){if(!t.isClosed)return!1;return e.get("position").indices.length>2}function H(t){return 1===t.anchor&&t.hideOnShortSegments&&"begin-end"===t.placement&&t.worldSpace}const K=f(),Q=f(),Z=f(),$=f(),tt=f(),et=i(),it=i(),rt=f(),st=f(),at=P(),nt=P(),ot=f(),lt=f(),ht=f(),ct=b(),mt=[i(),i(),i(),i()],pt=[f(),f(),f(),f()],ut=w(),ft=w(),dt=w(),gt=w();export{q as Parameters,J as RibbonLineMaterial};
@@ -2,7 +2,7 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{s as e}from"../../../../chunks/vec42.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{Float4PassUniform as a}from"../core/shaderModules/Float4PassUniform.js";import{FloatPassUniform as i}from"../core/shaderModules/FloatPassUniform.js";import{glsl as o}from"../core/shaderModules/glsl.js";function m(t,m){if(!m.hasAnimation)return;const{attributes:r,varyings:d,vertex:l,fragment:T}=t;r.add("timeStamps","vec4"),d.add("vTimeStamp","float"),d.add("vFirstTime","float"),d.add("vLastTime","float"),d.add("vTransitionType","float"),l.main.add(o`vTimeStamp = timeStamps.x;
5
+ import{c as e}from"../../../../chunks/vec42.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{Float4PassUniform as a}from"../core/shaderModules/Float4PassUniform.js";import{FloatPassUniform as i}from"../core/shaderModules/FloatPassUniform.js";import{glsl as o}from"../core/shaderModules/glsl.js";function m(t,m){if(!m.hasAnimation)return;const{attributes:r,varyings:d,vertex:l,fragment:T}=t;r.add("timeStamps","vec4"),d.add("vTimeStamp","float"),d.add("vFirstTime","float"),d.add("vLastTime","float"),d.add("vTransitionType","float"),l.main.add(o`vTimeStamp = timeStamps.x;
6
6
  vFirstTime = timeStamps.y;
7
7
  vLastTime = timeStamps.z;
8
8
  vTransitionType = timeStamps.w;`);const{animation:v}=m;3===v&&T.constants.add("decayRate","float",2.3),T.code.add(o`
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{s as r}from"../../../../chunks/vec42.js";import{ZEROS as o,create as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";function s(t){return null==t?o:4===t.length?t:r(c,t[0],t[1],t[2],1)}const c=t();export{s as ensureColor4};
5
+ import{c as r}from"../../../../chunks/vec42.js";import{ZEROS as o,create as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";function c(t){return null==t?o:4===t.length?t:r(e,t[0],t[1],t[2],1)}const e=t();export{c as ensureColor4};
@@ -2,7 +2,7 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{TextureBackedBufferModule as o}from"../../../core/shaderLibrary/TextureBackedBuffer.glsl.js";import{NormalAttribute as e}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{DoublePrecision as r}from"../../../core/shaderLibrary/util/DoublePrecision.glsl.js";import{Float3DrawUniform as t}from"../../../core/shaderModules/Float3DrawUniform.js";import{Float3PassUniform as a}from"../../../core/shaderModules/Float3PassUniform.js";import{glsl as l}from"../../../core/shaderModules/glsl.js";import{Matrix3DrawUniform as n}from"../../../core/shaderModules/Matrix3DrawUniform.js";import{Matrix3PassUniform as d}from"../../../core/shaderModules/Matrix3PassUniform.js";import{Matrix4BindUniform as m}from"../../../core/shaderModules/Matrix4BindUniform.js";import{Texture2DUintDrawUniform as s}from"../../../core/shaderModules/Texture2DUintDrawUniform.js";import{edgeViewTextureLayout as i}from"../../../lib/edgeRendering/bufferLayouts.js";const c=new o(i,"componentIndex",new s("componentTextureBuffer",o=>o.componentDataTexture));function f(o,s){const{vertex:i}=o;o.include(e,s);const{silhouette:f,legacy:v,spherical:u}=s;o.attributes.add("componentIndex","float");const{getTextureAttribute:w,TextureBackedBufferModule:p}=c;o.include(p);const F=8,M=128;i.constants.add("lineWidthFractionFactor","float",F),i.constants.add("extensionLengthOffset","float",M),i.code.add(l`
5
+ import{TextureBackedBufferModule as o}from"../../../core/shaderLibrary/TextureBackedBuffer.glsl.js";import{NormalAttribute as e}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{DoublePrecision as r}from"../../../core/shaderLibrary/util/DoublePrecision.glsl.js";import{Float3DrawUniform as t}from"../../../core/shaderModules/Float3DrawUniform.js";import{Float3PassUniform as a}from"../../../core/shaderModules/Float3PassUniform.js";import{glsl as l}from"../../../core/shaderModules/glsl.js";import{Matrix3DrawUniform as n}from"../../../core/shaderModules/Matrix3DrawUniform.js";import{Matrix3PassUniform as d}from"../../../core/shaderModules/Matrix3PassUniform.js";import{Matrix4BindUniform as m}from"../../../core/shaderModules/Matrix4BindUniform.js";import{Texture2DUintDrawUniform as s}from"../../../core/shaderModules/Texture2DUintDrawUniform.js";import{edgeViewTextureLayout as i}from"../../../lib/edgeRendering/bufferLayouts.js";const c=new o(i,"componentIndex",new s("componentTextureBuffer",o=>o.componentDataTextureBuffer?.texture));function f(o,s){const{vertex:i}=o;o.include(e,s);const{silhouette:f,legacy:u,spherical:v}=s;o.attributes.add("componentIndex","float");const{getTextureAttribute:w,TextureBackedBufferModule:p}=c;o.include(p);const F=8,M=128;i.constants.add("lineWidthFractionFactor","float",F),i.constants.add("extensionLengthOffset","float",M),i.code.add(l`
6
6
  struct ComponentData {
7
7
  vec4 color;
8
8
  vec3 normal;
@@ -35,7 +35,7 @@ import{TextureBackedBufferModule as o}from"../../../core/shaderLibrary/TextureBa
35
35
  verticalOffset
36
36
  );
37
37
  }
38
- `),v?i.code.add(l`vec3 _modelToWorldNormal(vec3 normal) {
38
+ `),u?i.code.add(l`vec3 _modelToWorldNormal(vec3 normal) {
39
39
  return (model * vec4(normal, 0.0)).xyz;
40
40
  }
41
41
  vec3 _modelToViewNormal(vec3 normal) {
@@ -46,7 +46,7 @@ return transformNormalGlobalFromModel * normal;
46
46
  return _modelToWorldNormal(normalize(data.normal + data.normal2));
47
47
  }`)):i.code.add(l`vec3 worldNormal(ComponentData data) {
48
48
  return _modelToWorldNormal(data.normal);
49
- }`),v?i.code.add(l`void worldAndViewFromModelPosition(vec3 modelPos, float verticalOffset, out vec3 worldPos, out vec3 viewPos) {
49
+ }`),u?i.code.add(l`void worldAndViewFromModelPosition(vec3 modelPos, float verticalOffset, out vec3 worldPos, out vec3 viewPos) {
50
50
  worldPos = (model * vec4(modelPos, 1.0)).xyz;
51
51
  viewPos = (localView * vec4(worldPos, 1.0)).xyz;
52
52
  }`):(i.include(r,s),i.uniforms.add(new d("transformViewFromCameraRelativeRS",o=>o.transformViewFromCameraRelativeRS),new n("transformWorldFromModelRS",o=>o.transformWorldFromModelRS),new t("transformWorldFromModelTL",o=>o.transformWorldFromModelTL),new t("transformWorldFromModelTH",o=>o.transformWorldFromModelTH),new a("transformWorldFromViewTL",o=>o.transformWorldFromViewTL),new a("transformWorldFromViewTH",o=>o.transformWorldFromViewTH)),i.code.add(l`
@@ -63,7 +63,7 @@ viewPos = (localView * vec4(worldPos, 1.0)).xyz;
63
63
  worldPos = transformCameraRelativeFromModel + rotatedModelPosition;
64
64
 
65
65
  if (verticalOffset != 0.0) {
66
- vec3 vUp = ${u?"normalize(transformWorldFromModelTL + rotatedModelPosition);":"vec3(0.0, 0.0, 1.0);"}
66
+ vec3 vUp = ${v?"normalize(transformWorldFromModelTL + rotatedModelPosition);":"vec3(0.0, 0.0, 1.0);"}
67
67
  worldPos += verticalOffset * vUp;
68
68
  }
69
69
 
@@ -73,4 +73,4 @@ viewPos = (localView * vec4(worldPos, 1.0)).xyz;
73
73
  return transformProjFromView * vec4(position, 1.0);
74
74
  }`),i.code.add(l`float calculateExtensionLength(float extensionLength, float lineLength) {
75
75
  return extensionLength / (log2(max(1.0, 256.0 / lineLength)) * 0.2 + 1.0);
76
- }`)}function v(o){return 1===o||2===o}export{f as EdgeUtil,v as usesSketchLogic};
76
+ }`)}function u(o){return 1===o||2===o}export{f as EdgeUtil,u as usesSketchLogic};