@arcgis/core 4.33.0-next.20250319 → 4.33.0-next.20250321

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 (111) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/1034155c525d2b7baaa1.js +1 -0
  3. package/assets/esri/core/workers/chunks/2b9ce6648823f6962f58.js +1 -0
  4. package/assets/esri/core/workers/chunks/{6a97bdd46715fc12e1b4.js → 9cfce9414b874878d761.js} +4 -4
  5. package/assets/esri/core/workers/chunks/b23d16745674486ddd6c.js +1 -0
  6. package/assets/esri/core/workers/chunks/bfbb118ae3b4a4ce1c74.js +319 -0
  7. package/assets/esri/themes/base/_mixins.scss +4 -0
  8. package/assets/esri/themes/dark/main.css +1 -1
  9. package/assets/esri/themes/light/main.css +1 -1
  10. package/assets/esri/themes/light/view.css +1 -1
  11. package/chunks/BloomBlur.glsl.js +7 -7
  12. package/chunks/BloomComposition.glsl.js +2 -2
  13. package/geometry/support/buffer/BufferView.js +1 -1
  14. package/interfaces.d.ts +8 -7
  15. package/layers/VoxelWasmPerSceneView.js +1 -1
  16. package/package.json +2 -2
  17. package/support/basemapUtils.js +1 -1
  18. package/support/revision.js +1 -1
  19. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  20. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  21. package/views/3d/layers/BuildingSceneLayerView3D.js +1 -1
  22. package/views/3d/layers/BuildingSublayerView3D.js +1 -1
  23. package/views/3d/layers/I3SMeshView3D.js +1 -1
  24. package/views/3d/layers/I3SMeshViewLabeler.js +1 -1
  25. package/views/3d/layers/MediaLayerView3D.js +1 -1
  26. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  27. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  28. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  29. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  30. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  31. package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
  32. package/views/3d/layers/graphics/Graphics3DGraphicsPipeline.js +1 -1
  33. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  34. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  35. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  36. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  37. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  38. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  39. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  40. package/views/3d/layers/graphics/Graphics3DSymbolCreationContext.js +1 -1
  41. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  42. package/views/3d/layers/graphics/GraphicsProcessor.js +1 -1
  43. package/views/3d/layers/graphics/Labeler.js +1 -1
  44. package/views/3d/layers/graphics/deconflictorDebug.js +1 -1
  45. package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +1 -1
  46. package/views/3d/layers/graphics/pipeline/rendering/DirectRenderer.js +1 -1
  47. package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
  48. package/views/3d/layers/graphics/pipeline/rendering/LodRenderer.js +1 -1
  49. package/views/3d/layers/graphics/pointUtils.js +1 -1
  50. package/views/3d/layers/graphics/polygonUtils.js +1 -1
  51. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  52. package/views/3d/layers/i3s/Intersector.js +1 -1
  53. package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
  54. package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
  55. package/views/3d/layers/support/Tiles3DIntersectionHandler.js +1 -1
  56. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  57. package/views/3d/support/buffer/InterleavedLayout.js +1 -1
  58. package/views/3d/support/hitTest.js +1 -1
  59. package/views/3d/terrain/OverlayRenderTargets.js +1 -1
  60. package/views/3d/terrain/TerrainRenderer.js +1 -1
  61. package/views/3d/webgl/ManagedColorAttachment.js +1 -1
  62. package/views/3d/webgl/ManagedDepthAttachment.js +1 -1
  63. package/views/3d/webgl/ManagedFBO.js +1 -1
  64. package/views/3d/webgl/ManagedFBOAttachment.js +1 -1
  65. package/views/3d/webgl/{ManagedFBObject.js → ManagedFBOResource.js} +1 -1
  66. package/views/3d/webgl/formats.js +1 -1
  67. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  68. package/views/3d/webgl-engine/effects/bloom/BloomBlur.glsl.js +1 -1
  69. package/views/3d/webgl-engine/effects/bloom/BloomComposition.glsl.js +1 -1
  70. package/views/3d/webgl-engine/effects/bloom/BloomPresets.glsl.js +5 -0
  71. package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +1 -1
  72. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  73. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorNode.js +1 -1
  74. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
  75. package/views/3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js +1 -1
  76. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  77. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  78. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  79. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  80. package/views/3d/webgl-engine/lib/IntersectorInterfaces.js +1 -1
  81. package/views/3d/webgl-engine/lib/IntersectorTarget.js +1 -1
  82. package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
  83. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  84. package/views/3d/webgl-engine/lib/ObjectAndLayerIdRenderHelper.js +1 -1
  85. package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
  86. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  87. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  88. package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
  89. package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
  90. package/views/3d/webgl-engine/lib/WebGLLayer.js +1 -1
  91. package/views/3d/webgl-engine/lib/intersectorUtilsConversions.js +1 -1
  92. package/views/3d/webgl-engine/lib/lodRendering/Intersector.js +1 -1
  93. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  94. package/views/3d/webgl-engine/lib/lodRendering/LodResources.js +1 -1
  95. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  96. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  97. package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
  98. package/views/3d/webgl.js +1 -1
  99. package/views/SceneView.js +1 -1
  100. package/views/webgl/FramebufferObject.js +1 -1
  101. package/views/webgl/GLObjectType.js +1 -1
  102. package/views/webgl/Renderbuffer.js +1 -1
  103. package/widgets/Daylight.js +1 -1
  104. package/widgets/ElevationProfile/support/visualizationUtils.js +1 -1
  105. package/widgets/ShadowCast.js +1 -1
  106. package/widgets/support/globalCss.js +1 -1
  107. package/widgets/support/timeWidgetUtils.js +1 -1
  108. package/assets/esri/core/workers/chunks/534f3d7e4300b662191a.js +0 -1
  109. package/assets/esri/core/workers/chunks/657ae4a0461d45044b28.js +0 -1
  110. package/assets/esri/core/workers/chunks/8e20ec4e8e2cfc582fe7.js +0 -319
  111. package/assets/esri/core/workers/chunks/c528a2ca3b1b73df5a5d.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{property as t}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as s}from"../../../../../core/accessorSupport/decorators/subclass.js";import{InternalRenderCategory as r,RenderCategory as o}from"../../../webgl.js";import{ColorFormat as i}from"../../../webgl/formats.js";import n from"../../../webgl/RenderNode.js";import{FocusAreaMaskTechnique as a}from"./FocusAreaMaskTechnique.js";import{Default3D as c}from"../../lib/DefaultVertexAttributeLocations.js";import{Pos3 as h}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as p}from"../../lib/VertexArrayObject.js";import{F as u}from"../../../../../chunks/FocusAreaMask.glsl.js";import{BufferObject as l}from"../../../../webgl/BufferObject.js";import{DepthStencilAttachment as m,FramebufferBit as d,Face as f,StencilOperation as g,CompareFunction as A,PrimitiveType as E,Usage as b}from"../../../../webgl/enums.js";import{noParameters as w}from"../../../../webgl/NoParameters.js";let _=class extends n{constructor(e){super({...e,view:e.focusAreas.view}),this.consumes={required:[r.FOCUSAREA,o.TRANSPARENT]},this.produces=r.FOCUSAREA,this._vaos=new Array,this._counts=new Array,this._origins=new Array,this._maskParameters=new u}initialize(){this.updateGeometries()}destroy(){this._vaos.forEach((e=>e.dispose())),this._vaos.length=this._counts.length=this._origins.length=0}precompile(){this.techniques.precompile(a)}render(e){const t=this.techniques.get(a),s=this.bindParameters,n=s.camera,c=n.fullViewport[2],h=n.fullViewport[3],p=this.fboCache.acquire(c,h,r.FOCUSAREA,i.RGBA);if(!t.compiled||!this._vaos)return this.requestRender(),p;const u=e.find((({name:e})=>e===o.TRANSPARENT)),l=this.renderingContext;p.attachDepth(u.getAttachment(m)),l.bindFramebuffer(p.fbo),l.clear(d.COLOR|d.STENCIL),l.setViewport(0,0,c,h),l.clear(d.STENCIL,0);const b=l.bindTechnique(t,s);l.setFaceCullingEnabled(!1),l.setStencilTestEnabled(!0),l.setStencilOpSeparate(f.FRONT,g.KEEP,g.INCR_WRAP,g.KEEP),l.setStencilOpSeparate(f.BACK,g.KEEP,g.DECR_WRAP,g.KEEP),l.setDepthWriteEnabled(!1);for(let r=0;r<this._vaos.length;r++){const e=this._vaos[r],t=this._counts[r];this._maskParameters.origin=this._origins[r],b.bindDraw(s,w,this._maskParameters),l.bindVAO(e),l.setDepthTestEnabled(!0),l.setStencilWriteMask(255),l.setStencilFunction(A.ALWAYS,0,255),l.setColorMask(!1,!1,!1,!1),l.drawArrays(E.TRIANGLES,0,t),l.setDepthTestEnabled(!1),l.setStencilWriteMask(0),l.setStencilFunction(A.NOTEQUAL,0,255),l.setColorMask(!0,!0,!0,!0),l.drawArrays(E.TRIANGLES,0,t)}return p}updateGeometries(){if(!this.view.stage)return;this._vaos.forEach((e=>e.dispose())),this._vaos.length=this._counts.length=this._origins.length=0;const e=this.focusAreas.geometries;for(const t of e){const e=new Array,s=t.indicesBottom;for(let n=0;n<s.length;n++)e.push(t.positions[3*(s[n]-1)]),e.push(t.positions[3*(s[n]-1)+1]),e.push(t.positions[3*(s[n]-1)+2]);const r=t.indicesExtruded;for(let n=0;n<r.length;n++)e.push(t.positions[3*r[n]]),e.push(t.positions[3*r[n]+1]),e.push(t.positions[3*r[n]+2]);const o=new Float32Array(e),i=new p(this.renderingContext,c,new Map([["geometry",h]]),new Map([["geometry",l.createVertex(this.renderingContext,b.STATIC_DRAW,o)]]));this._vaos.push(i),this._counts.push(s.length+r.length),this._origins.push(t.origin)}this.requestRender()}};e([t()],_.prototype,"consumes",void 0),e([t()],_.prototype,"produces",void 0),e([t({constructOnly:!0})],_.prototype,"focusAreas",void 0),_=e([s("esri.views.3d.webgl-engine.effects.focusArea.FocusAreaMaskNode")],_);class R{constructor(e,t,s,r,o,i){this.positions=e,this.indicesBottom=t,this.indicesExtruded=s,this.height=r,this.origin=o,this.color=i}}var S;!function(e){e[e.NONE=0]="NONE",e[e.BRIGHT=1]="BRIGHT",e[e.DARK=2]="DARK"}(S||(S={}));export{S as FocusAreaEffect,R as FocusAreaGeometry,_ as FocusAreaMaskNode};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{property as t}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as s}from"../../../../../core/accessorSupport/decorators/subclass.js";import{InternalRenderCategory as r,RenderCategory as o}from"../../../webgl.js";import{ColorFormat as i}from"../../../webgl/formats.js";import n from"../../../webgl/RenderNode.js";import{FocusAreaMaskTechnique as a}from"./FocusAreaMaskTechnique.js";import{Default3D as c}from"../../lib/DefaultVertexAttributeLocations.js";import{Pos3 as h}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as p}from"../../lib/VertexArrayObject.js";import{F as u}from"../../../../../chunks/FocusAreaMask.glsl.js";import{BufferObject as l}from"../../../../webgl/BufferObject.js";import{DepthStencilAttachment as m,FramebufferBit as d,Face as f,StencilOperation as g,CompareFunction as A,PrimitiveType as E,Usage as b}from"../../../../webgl/enums.js";import{noParameters as w}from"../../../../webgl/NoParameters.js";let _=class extends n{constructor(e){super({...e,view:e.focusAreas.view}),this.consumes={required:[r.FOCUSAREA,o.TRANSPARENT]},this.produces=r.FOCUSAREA,this._vaos=new Array,this._counts=new Array,this._origins=new Array,this._maskParameters=new u}initialize(){this.updateGeometries()}destroy(){this._vaos.forEach((e=>e.dispose())),this._vaos.length=this._counts.length=this._origins.length=0}precompile(){this.techniques.precompile(a)}render(e){const t=this.techniques.get(a),s=this.bindParameters,n=s.camera,c=n.fullViewport[2],h=n.fullViewport[3],p=this.fboCache.acquire(c,h,r.FOCUSAREA,i.RGBA8);if(!t.compiled||!this._vaos)return this.requestRender(),p;const u=e.find((({name:e})=>e===o.TRANSPARENT)),l=this.renderingContext;p.attachDepth(u.getAttachment(m)),l.bindFramebuffer(p.fbo),l.clear(d.COLOR|d.STENCIL),l.setViewport(0,0,c,h),l.clear(d.STENCIL,0);const b=l.bindTechnique(t,s);l.setFaceCullingEnabled(!1),l.setStencilTestEnabled(!0),l.setStencilOpSeparate(f.FRONT,g.KEEP,g.INCR_WRAP,g.KEEP),l.setStencilOpSeparate(f.BACK,g.KEEP,g.DECR_WRAP,g.KEEP),l.setDepthWriteEnabled(!1);for(let r=0;r<this._vaos.length;r++){const e=this._vaos[r],t=this._counts[r];this._maskParameters.origin=this._origins[r],b.bindDraw(s,w,this._maskParameters),l.bindVAO(e),l.setDepthTestEnabled(!0),l.setStencilWriteMask(255),l.setStencilFunction(A.ALWAYS,0,255),l.setColorMask(!1,!1,!1,!1),l.drawArrays(E.TRIANGLES,0,t),l.setDepthTestEnabled(!1),l.setStencilWriteMask(0),l.setStencilFunction(A.NOTEQUAL,0,255),l.setColorMask(!0,!0,!0,!0),l.drawArrays(E.TRIANGLES,0,t)}return p}updateGeometries(){if(!this.view.stage)return;this._vaos.forEach((e=>e.dispose())),this._vaos.length=this._counts.length=this._origins.length=0;const e=this.focusAreas.geometries;for(const t of e){const e=new Array,s=t.indicesBottom;for(let n=0;n<s.length;n++)e.push(t.positions[3*(s[n]-1)]),e.push(t.positions[3*(s[n]-1)+1]),e.push(t.positions[3*(s[n]-1)+2]);const r=t.indicesExtruded;for(let n=0;n<r.length;n++)e.push(t.positions[3*r[n]]),e.push(t.positions[3*r[n]+1]),e.push(t.positions[3*r[n]+2]);const o=new Float32Array(e),i=new p(this.renderingContext,c,new Map([["geometry",h]]),new Map([["geometry",l.createVertex(this.renderingContext,b.STATIC_DRAW,o)]]));this._vaos.push(i),this._counts.push(s.length+r.length),this._origins.push(t.origin)}this.requestRender()}};e([t()],_.prototype,"consumes",void 0),e([t()],_.prototype,"produces",void 0),e([t({constructOnly:!0})],_.prototype,"focusAreas",void 0),_=e([s("esri.views.3d.webgl-engine.effects.focusArea.FocusAreaMaskNode")],_);class R{constructor(e,t,s,r,o,i){this.positions=e,this.indicesBottom=t,this.indicesExtruded=s,this.height=r,this.origin=o,this.color=i}}var S;!function(e){e[e.NONE=0]="NONE",e[e.BRIGHT=1]="BRIGHT",e[e.DARK=2]="DARK"}(S||(S={}));export{S as FocusAreaEffect,R as FocusAreaGeometry,_ as FocusAreaMaskNode};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import r from"../../../../../core/PooledArray.js";import{property as t}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as s}from"../../../../../core/accessorSupport/decorators/subclass.js";import{ZEROS as o}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as n}from"../../../webgl.js";import{DepthFormat as i}from"../../../webgl/formats.js";import c from"../../../webgl/RenderNode.js";import{Blit as l}from"../blit/Blit.js";import{StencilBits as a}from"../../lib/basicInterfaces.js";import{RenderOccludedFlag as d}from"../../lib/Material.js";import{RenderSlot as p}from"../../lib/RenderSlot.js";import{BlitMode as u}from"../../shaders/CompositingTechniqueConfiguration.js";import{DepthStencilAttachment as m}from"../../../../webgl/enums.js";let f=class extends c{constructor(e){super(e),this.consumes={required:[n.OCCLUDED]},this.produces=n.OCCLUDED,this._blit=new l(e.view.stage.renderView.techniques,u.PremultipliedAlpha)}precompile(){const e=this.view.stage.renderer;e.plugins.plugins.forAll((r=>{e.precompileSlots(r,p.OCCLUDED_TERRAIN,p.TRANSPARENT_OCCLUDER_MATERIAL),r.material&&e.precompileOccludedSlots(r,g)}))}render(e){const r=e.find((({name:e})=>e===this.produces)),t=this.view.stage.renderer;let s=0;if(h.clear(),t.plugins.plugins.forAll((e=>{if(!e.material)return;e.queryRenderOccludedState(d.OccludeAndTransparentStencil)&&(s|=d.OccludeAndTransparentStencil,h.push(e))})),h.length>0&&(t.renderSlots(h,p.OCCLUDER_MATERIAL),s&d.OccludeAndTransparentStencil&&this._renderAndComposite(r,.5,(()=>t.renderSlots(h,p.TRANSPARENT_OCCLUDER_MATERIAL)),!1,!1)),h.clear(),t.plugins.plugins.forAll((e=>{if(!e.material)return;const r=e.queryRenderOccludedState(d.OccludeAndTransparent),t=e.queryRenderOccludedState(d.Transparent),o=e.queryRenderOccludedState(d.Opaque);(r||t||o)&&(s|=r?d.OccludeAndTransparent:t?d.Transparent:d.Opaque,h.push(e))})),s|=t.plugins.renderOccludedFlags,!s)return r;for(const o of g)s&o&&this._renderAndComposite(r,o===d.Opaque?1:.5,(()=>t.renderOccludedSlots(h,o)),!0,a.OutlineVisualElementMask);return h.clear(),r}_renderAndComposite(e,r,t,s,n){const c=this.renderingContext,{width:l,height:a}=e.fbo,d=this.fboCache.acquire(l,a,"tmp color"),p=s?this.fboCache.acquireDepth(i.DEPTH_STENCIL_TEXTURE,l,a,"tmp depth"):e.getAttachment(m);d.attachDepth(p),c.bindFramebuffer(d.fbo),c.clearFramebuffer(o,s,n),t(),d.detachDepth(),this._blit.blend(c,d,e,this.bindParameters,r),s&&p.release(),d.release()}};e([t()],f.prototype,"consumes",void 0),e([t()],f.prototype,"produces",void 0),f=e([s("esri.views.3d.webgl-engine.effects.geometry.RenderOccludedRenderNode")],f);const h=new r,g=[d.OccludeAndTransparent,d.Transparent,d.Opaque];export{f as RenderOccludedRenderNode};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import r from"../../../../../core/PooledArray.js";import{property as t}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as s}from"../../../../../core/accessorSupport/decorators/subclass.js";import{ZEROS as o}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as n}from"../../../webgl.js";import i from"../../../webgl/RenderNode.js";import{Blit as c}from"../blit/Blit.js";import{StencilBits as l}from"../../lib/basicInterfaces.js";import{RenderOccludedFlag as a}from"../../lib/Material.js";import{RenderSlot as d}from"../../lib/RenderSlot.js";import{BlitMode as p}from"../../shaders/CompositingTechniqueConfiguration.js";import{DepthStencilAttachment as u}from"../../../../webgl/enums.js";let m=class extends i{constructor(e){super(e),this.consumes={required:[n.OCCLUDED]},this.produces=n.OCCLUDED,this._blit=new c(e.view.stage.renderView.techniques,p.PremultipliedAlpha)}precompile(){const e=this.view.stage.renderer;e.plugins.plugins.forAll((r=>{e.precompileSlots(r,d.OCCLUDED_TERRAIN,d.TRANSPARENT_OCCLUDER_MATERIAL),r.material&&e.precompileOccludedSlots(r,h)}))}render(e){const r=e.find((({name:e})=>e===this.produces)),t=this.view.stage.renderer;let s=0;if(f.clear(),t.plugins.plugins.forAll((e=>{if(!e.material)return;e.queryRenderOccludedState(a.OccludeAndTransparentStencil)&&(s|=a.OccludeAndTransparentStencil,f.push(e))})),f.length>0&&(t.renderSlots(f,d.OCCLUDER_MATERIAL),s&a.OccludeAndTransparentStencil&&this._renderAndComposite(r,.5,(()=>t.renderSlots(f,d.TRANSPARENT_OCCLUDER_MATERIAL)),!1,!1)),f.clear(),t.plugins.plugins.forAll((e=>{if(!e.material)return;const r=e.queryRenderOccludedState(a.OccludeAndTransparent),t=e.queryRenderOccludedState(a.Transparent),o=e.queryRenderOccludedState(a.Opaque);(r||t||o)&&(s|=r?a.OccludeAndTransparent:t?a.Transparent:a.Opaque,f.push(e))})),s|=t.plugins.renderOccludedFlags,!s)return r;for(const o of h)s&o&&this._renderAndComposite(r,o===a.Opaque?1:.5,(()=>t.renderOccludedSlots(f,o)),!0,l.OutlineVisualElementMask);return f.clear(),r}_renderAndComposite(e,r,t,s,n){const i=this.renderingContext,{width:c,height:l}=e.fbo,a=this.fboCache.acquire(c,l,"tmp color"),d=s?this.fboCache.acquireDepth(u,c,l,"tmp depth"):e.getAttachment(u);a.attachDepth(d),i.bindFramebuffer(a.fbo),i.clearFramebuffer(o,s,n),t(),a.detachDepth(),this._blit.blend(i,a,e,this.bindParameters,r),s&&d.release(),a.release()}};e([t()],m.prototype,"consumes",void 0),e([t()],m.prototype,"produces",void 0),m=e([s("esri.views.3d.webgl-engine.effects.geometry.RenderOccludedRenderNode")],m);const f=new r,h=[a.OccludeAndTransparent,a.Transparent,a.Opaque];export{m as RenderOccludedRenderNode};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{lerp as t,clamp as s,smoothstep as r}from"../../../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../../../core/maybe.js";import{watch as o,syncAndInitial as a}from"../../../../../core/reactiveUtils.js";import"../../../../../core/Logger.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import"../../../../../core/Error.js";import{subclass as n}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as m}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{l as h,k as c}from"../../../../../chunks/vec32.js";import{s as p}from"../../../../../chunks/vec42.js";import{earth as u}from"../../../../../geometry/support/Ellipsoid.js";import{InternalRenderCategory as d}from"../../../webgl.js";import{ColorFormat as l}from"../../../webgl/formats.js";import{TransparentEnvironment as f}from"../TransparentEnvironment.js";import{H as _}from"../../../../../chunks/HazeCompositing.glsl.js";import{HazeCompositingTechnique as g}from"./HazeCompositingTechnique.js";import{HazePassParameters as b,HazeTechnique as w}from"./HazeTechnique.js";import{HazeTechniqueConfiguration as P}from"./HazeTechniqueConfiguration.js";import{createQuadVAO as j,Layout as v}from"../../lib/glUtil3D.js";import{applyTextureResizeModulo as A}from"../../lib/textureUtils.js";import{DepthStencilAttachment as T,PrimitiveType as C}from"../../../../webgl/enums.js";let x=class extends f{constructor(e){super(e),this._compositingPassParameters=new _,this._passParameters=new b,this._hazeConfiguration=new P,this._vao=null,this.requireGeometryDepth=!0,this._oldAmount=1,this._newAmount=1,this._amount=this._newAmount;const t=e.view.stage.renderView.techniques;t.precompile(w,new P);const s=new P;s.reduced=!0,t.precompile(w,s),t.precompile(g)}initialize(){this.addHandles([o((()=>this.view.environment.atmosphereEnabled),(e=>e?this._enable():this._disable()),a),o((()=>this.view.stage?.renderer.renderContext.bind.clouds.fadeFactor??1),(e=>this._fade(e)),a),o((()=>this.view.environment.weather.type),(e=>this._newAmount="rainy"===e?0:1),a),o((()=>this.view.stage.renderer?.fullResolutionAtmosphere),(e=>this._hazeConfiguration.reduced=!e),a)])}_fade(e){e>=1?(this._amount=this._newAmount,this._oldAmount=this._newAmount):this._amount=e<=0?this._oldAmount:t(this._oldAmount,this._newAmount,e)}destroy(){this._vao=i(this._vao)}render(e){const s=e.find((({name:e})=>e===d.TRANSPARENT_ENVIRONMENT));if(!this.bindParameters.mainDepth)return s;const r=this.renderingContext;this._vao??=j(r,v.Pos2Tex);const i=this.techniques.get(w,this._hazeConfiguration);if(!i.compiled)return s;const o=s.getAttachment(T);if(this._update(),!this._hazeConfiguration.reduced)return s.detachDepth(),r.bindFramebuffer(s.fbo),r.bindTechnique(i,this.bindParameters,this._passParameters),this._renderCommon(r),s.attachDepth(o),s;const a=this.techniques.get(g);if(!a.compiled)return s;const n=r.getViewport(),m=this.camera,c=h(m.eye)-u.radius;let p;const f=u.atmosphereHeight;if(c<f){const e=Math.min(1,Math.max(0,c/f));p=t(.4,.5,e)}else{const e=Math.min(1,Math.max(0,(c-f)/(15*f)));p=t(.5,1,e)}const _=this.renderingContext.parameters.maxTextureSize,b=A(Math.round(p*m.fullViewport[2]),_),P=A(Math.round(p*m.fullViewport[3]),_);r.setViewport(0,0,b,P);const C=this.fboCache.acquire(b,P,"haze",l.RGBA);return r.bindFramebuffer(C.fbo),r.clearFramebuffer([0,0,0,1],!0,!0),r.bindTechnique(i,this.bindParameters,this._passParameters),this._renderCommon(r),r.setViewport(n.x,n.y,n.width,n.height),this._compositingPassParameters.color=C.getTexture(),s.detachDepth(),r.bindFramebuffer(s.fbo),r.bindTechnique(a,this.bindParameters,this._compositingPassParameters),r.screen.draw(),s.attachDepth(o),C.release(),s}_renderCommon(e){null!=this._vao&&(e.bindVAO(this._vao),e.drawArrays(C.TRIANGLE_STRIP,0,4))}_update(){const e=this.bindParameters.camera,i=c(e.eye),o=Math.sqrt(i),a=i-this._passParameters.radii[1]*this._passParameters.radii[1],n=s((o-this._passParameters.radii[0])/u.atmosphereHeight,0,1);p(this._passParameters.heightParameters,o,i,a,n);const h=this.view.basemapTerrain?.getLowerBoundRadius()??0;m(this._passParameters.radii,h,h+u.atmosphereHeight),this._passParameters.hazeStrength=t(t(.6,1,r(9500,10500,o-u.radius)),1,this._amount)}};x=e([n("esri.views.3d.webgl-engine.effects.haze.Haze")],x);export{x as Haze};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{lerp as t,clamp as s,smoothstep as r}from"../../../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../../../core/maybe.js";import{watch as o,syncAndInitial as a}from"../../../../../core/reactiveUtils.js";import"../../../../../core/Logger.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import"../../../../../core/Error.js";import{subclass as n}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as m}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{l as h,k as c}from"../../../../../chunks/vec32.js";import{s as p}from"../../../../../chunks/vec42.js";import{earth as u}from"../../../../../geometry/support/Ellipsoid.js";import{InternalRenderCategory as d}from"../../../webgl.js";import{ColorFormat as l}from"../../../webgl/formats.js";import{TransparentEnvironment as f}from"../TransparentEnvironment.js";import{H as _}from"../../../../../chunks/HazeCompositing.glsl.js";import{HazeCompositingTechnique as g}from"./HazeCompositingTechnique.js";import{HazePassParameters as b,HazeTechnique as w}from"./HazeTechnique.js";import{HazeTechniqueConfiguration as P}from"./HazeTechniqueConfiguration.js";import{createQuadVAO as j,Layout as v}from"../../lib/glUtil3D.js";import{applyTextureResizeModulo as A}from"../../lib/textureUtils.js";import{DepthStencilAttachment as T,PrimitiveType as C}from"../../../../webgl/enums.js";let x=class extends f{constructor(e){super(e),this._compositingPassParameters=new _,this._passParameters=new b,this._hazeConfiguration=new P,this._vao=null,this.requireGeometryDepth=!0,this._oldAmount=1,this._newAmount=1,this._amount=this._newAmount;const t=e.view.stage.renderView.techniques;t.precompile(w,new P);const s=new P;s.reduced=!0,t.precompile(w,s),t.precompile(g)}initialize(){this.addHandles([o((()=>this.view.environment.atmosphereEnabled),(e=>e?this._enable():this._disable()),a),o((()=>this.view.stage?.renderer.renderContext.bind.clouds.fadeFactor??1),(e=>this._fade(e)),a),o((()=>this.view.environment.weather.type),(e=>this._newAmount="rainy"===e?0:1),a),o((()=>this.view.stage.renderer?.fullResolutionAtmosphere),(e=>this._hazeConfiguration.reduced=!e),a)])}_fade(e){e>=1?(this._amount=this._newAmount,this._oldAmount=this._newAmount):this._amount=e<=0?this._oldAmount:t(this._oldAmount,this._newAmount,e)}destroy(){this._vao=i(this._vao)}render(e){const s=e.find((({name:e})=>e===d.TRANSPARENT_ENVIRONMENT));if(!this.bindParameters.mainDepth)return s;const r=this.renderingContext;this._vao??=j(r,v.Pos2Tex);const i=this.techniques.get(w,this._hazeConfiguration);if(!i.compiled)return s;const o=s.getAttachment(T);if(this._update(),!this._hazeConfiguration.reduced)return s.detachDepth(),r.bindFramebuffer(s.fbo),r.bindTechnique(i,this.bindParameters,this._passParameters),this._renderCommon(r),s.attachDepth(o),s;const a=this.techniques.get(g);if(!a.compiled)return s;const n=r.getViewport(),m=this.camera,c=h(m.eye)-u.radius;let p;const f=u.atmosphereHeight;if(c<f){const e=Math.min(1,Math.max(0,c/f));p=t(.4,.5,e)}else{const e=Math.min(1,Math.max(0,(c-f)/(15*f)));p=t(.5,1,e)}const _=this.renderingContext.parameters.maxTextureSize,b=A(Math.round(p*m.fullViewport[2]),_),P=A(Math.round(p*m.fullViewport[3]),_);r.setViewport(0,0,b,P);const C=this.fboCache.acquire(b,P,"haze",l.RGBA8);return r.bindFramebuffer(C.fbo),r.clearFramebuffer([0,0,0,1],!0,!0),r.bindTechnique(i,this.bindParameters,this._passParameters),this._renderCommon(r),r.setViewport(n.x,n.y,n.width,n.height),this._compositingPassParameters.color=C.getTexture(),s.detachDepth(),r.bindFramebuffer(s.fbo),r.bindTechnique(a,this.bindParameters,this._compositingPassParameters),r.screen.draw(),s.attachDepth(o),C.release(),s}_renderCommon(e){null!=this._vao&&(e.bindVAO(this._vao),e.drawArrays(C.TRIANGLE_STRIP,0,4))}_update(){const e=this.bindParameters.camera,i=c(e.eye),o=Math.sqrt(i),a=i-this._passParameters.radii[1]*this._passParameters.radii[1],n=s((o-this._passParameters.radii[0])/u.atmosphereHeight,0,1);p(this._passParameters.heightParameters,o,i,a,n);const h=this.view.basemapTerrain?.getLowerBoundRadius()??0;m(this._passParameters.radii,h,h+u.atmosphereHeight),this._passParameters.hazeStrength=t(t(.6,1,r(9500,10500,o-u.radius)),1,this._amount)}};x=e([n("esri.views.3d.webgl-engine.effects.haze.Haze")],x);export{x as Haze};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/has.js";import{releaseMaybe as t,disposeMaybe as r}from"../../../../../core/maybe.js";import{watch as i,initial as s}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as n}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{InternalRenderCategory as l}from"../../../webgl.js";import{ColorFormat as a}from"../../../webgl/formats.js";import g from"../../../webgl/RenderNode.js";import{HighlightApplyTechnique as c}from"./HighlightApplyTechnique.js";import{HighlightBlurTechnique as u}from"./HighlightBlurTechnique.js";import{HighlightDownsampleTechnique as m}from"./HighlightDownsampleTechnique.js";import{HighlightPassParameters as p}from"./HighlightPassParameters.js";import{HighlightToSingleTechnique as d}from"./HighlightToSingleTechnique.js";import{RenderRequestType as f}from"../../lib/basicInterfaces.js";import{Default3D as b}from"../../lib/DefaultVertexAttributeLocations.js";import{NoVertex as T}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as w}from"../../lib/VertexArrayObject.js";import{H as x}from"../../../../../chunks/HighlightBlur.glsl.js";import{H as C,g as v}from"../../../../../chunks/HighlightDownsample.glsl.js";import{BufferObject as _}from"../../../../webgl/BufferObject.js";import{PixelFormat as j,TextureSamplingMode as H,FramebufferBit as P,Usage as R,TextureType as O,PrimitiveType as q,DataType as D}from"../../../../webgl/enums.js";import{Texture as I}from"../../../../webgl/Texture.js";import{TextureDescriptor as y}from"../../../../webgl/TextureDescriptor.js";let A=class extends g{constructor(){super(...arguments),this.produces=l.HIGHLIGHTS,this.consumes={required:[l.HIGHLIGHTS,"highlights"]},this._downsampleDrawParameters=new C,this._passParameters=new p,this._highlightBlurDrawParameters=new x,this._grid=new U}initialize(){this.addHandles([i((()=>this._updateOptionsTexture()),(()=>{}),s)])}destroy(){this._grid.coverage=t(this._grid.coverage),this._grid.vao=r(this._grid.vao),this._passParameters.highlightOptionsTexture=t(this._passParameters.highlightOptionsTexture)}_updateOptionsTexture(){if(null==this._passParameters.highlightOptionsTexture){const e=new y(16,2);e.internalFormat=j.RGBA,e.samplingMode=H.NEAREST,this._passParameters.highlightOptionsTexture=new I(this.renderingContext,e,null)}this._passParameters.highlightOptionsTexture.setData(E(this.view.state.highlights)),this.requestRender(f.UPDATE)}precompile(){this.techniques.precompile(m),this.techniques.precompile(d),this.techniques.precompile(u),this.techniques.precompile(c)}render(e){const t=e.find((({name:e})=>e===l.HIGHLIGHTS)),{techniques:r,bindParameters:i,_passParameters:s,renderingContext:o}=this;if(!i.decorations)return t;const h=r.get(m);if(!h.compiled)return this.requestRender(f.UPDATE),t;const n=e.find((({name:e})=>"highlights"===e)).getTexture();s.highlightTexture=n;const a=()=>{this._gridUpdateResources(n);const e=this._gridComputeCoverage(h,n,i),{horizontalCellCount:t,verticalCellCount:r}=e;return s.horizontalCellCount=t,s.verticalCellCount=r,s.coverageTexture=e.coverage?.getTexture(),e},g=e=>{const t=e.verticalCellCount*e.horizontalCellCount;o.bindVAO(e.vao),o.drawElementsInstanced(q.TRIANGLES,6,D.UNSIGNED_BYTE,0,t)},{camera:c}=i,u=()=>{o.bindFramebuffer(t.fbo),o.setViewport4fv(c.fullViewport)};return this._renderHighlightPostprocess(n,a,g,u),s.highlightTexture=null,s.coverageTexture=null,t}_renderHighlightPostprocess(e,t,r,i){const{fboCache:s,techniques:o,bindParameters:h,_passParameters:l,renderingContext:g}=this,m=o.get(d),p=o.get(u),b=o.get(c);if(!b.compiled||!p.compiled||!m.compiled)return void this.requestRender(f.UPDATE);l.highlightTexture=e;const T=t(),{width:w,height:x}=e.descriptor;l.highlightTexture=e;const{camera:C}=h,{fullWidth:v,fullHeight:_,pixelRatio:j}=C,H=Math.ceil(v/j),R=Math.ceil(_/j),{_highlightBlurDrawParameters:O}=this,q=this.view.stage.renderView.renderer,{highlights:D}=h;for(let c=0;c<D.length;++c){const{name:e}=D[c];if(!q.hasHighlight(e))continue;l.highlightLevel=c,g.setClearColor(0,0,0,0);const t=s.acquire(w,x,"single highlight",a.RG);g.bindFramebuffer(t.fbo),g.setViewport(0,0,w,x),g.clear(P.COLOR),g.bindTechnique(m,h,l),r(T),O.blurInput=t.getTexture(),n(O.blurSize,1/H,0);const o=s.acquire(H,R,"single highlight blur h",a.RG);g.unbindTexture(o.fbo?.colorTexture),g.bindFramebuffer(o.fbo),g.setViewport(0,0,H,R),g.clear(P.COLOR),g.bindTechnique(p,h,l,O),r(T),t.release(),n(O.blurSize,0,1/R),l.highlightBlurTexture=o.getTexture(),i(),g.bindTechnique(b,h,l,O),r(T),o.release()}}_gridUpdateResources(e){const t=this._grid,{width:r,height:i}=e.descriptor;if(t.horizontalCellCount=Math.ceil(r/v),t.verticalCellCount=Math.ceil(i/v),t.vao)return;const s=this.renderingContext,o=_.createIndex(s,R.STATIC_DRAW,L);t.vao=new w(s,b,new Map([["geometry",T]]),new Map([["geometry",_.createVertex(s,R.STATIC_DRAW)]]),o)}_gridComputeCoverage(e,t,r){const i=this.renderingContext,s=this._grid,o=t.descriptor,h=Math.ceil(o.width/v),n=Math.ceil(o.height/v);this._downsampleDrawParameters.input=t;const{highlights:l}=r;s.coverage?.release();const g=this.fboCache.acquire(h,n,"highlight coverage",l.length>B?a.RG8UI:a.R8UI);return s.coverage=g,i.bindFramebuffer(g.fbo),i.bindTechnique(e,r,this._passParameters,this._downsampleDrawParameters),i.setViewport(0,0,h,n),i.screen.draw(),s}get test(){}};e([o()],A.prototype,"produces",void 0),e([o()],A.prototype,"consumes",void 0),A=e([h("esri.views.3d.webgl-engine.effects.highlight.Highlight")],A);class U{constructor(){this.coverage=null,this.vao=null,this.verticalCellCount=0,this.horizontalCellCount=0,this.viewportWidth=0,this.viewportHeight=0}}function E(e){const t=new Uint8Array(128);let r=0;for(const i of e){const e=4*r,s=4*r+64;++r;const{color:o}=i,h=i.haloColor??o;t[e+0]=o.r,t[e+1]=o.g,t[e+2]=o.b,t[e+3]=i.fillOpacity*o.a*255,t[s+0]=h.r,t[s+1]=h.g,t[s+2]=h.b,t[s+3]=i.haloOpacity*h.a*255}return t}let S=0;function G(e){let t=0;for(const i of e){const{name:e}=i;t+=e.length;const{color:r,fillOpacity:s,haloColor:o,haloOpacity:h}=i;t+=r.r+r.g+r.b+r.a+s,t+=o?o.r+o.g+o.b+o.a+h:0}const r=e.at(0);if(r){const{shadowOpacity:e,shadowDifference:i,shadowColor:s}=r;t+=e+i+s.r+s.g+s.b+s.a}return S+++(t>=0?0:1)}const L=new Uint8Array([0,1,2,2,1,3]);function M(e,t,r,i,s,o=0){const{highlights:h}=i,l=h.length>1?t.acquire(r.width,r.height,"highlight mix",h.length>B?a.RG8UI:a.R8UI):null,{gl:g}=e;if(l){const t=e.getBoundFramebufferObject();e.bindFramebuffer(l.fbo),g.clearBufferuiv(g.COLOR,0,[0,0,0,0]),e.bindFramebuffer(t)}const c=l?.getTexture();i.highlightMixTexture=c,n(i.highlightMixOrigin,o,0),h.forEach(((t,h)=>{if(h>0){const t=I.TEXTURE_UNIT_FOR_UPDATES;e.bindTexture(c,t),e.setActiveTexture(t),g.copyTexSubImage2D(O.TEXTURE_2D,0,0,0,o,0,r.width,r.height),e.bindTexture(null,t)}e.clear(P.DEPTH),i.highlightLevel=h,s()})),i.highlightLevel=null,i.highlightMixTexture=null,l?.release()}const B=4;export{A as Highlight,B as maxHighlightsPerChannel,M as renderHighlightBuffer,G as trackHighlightOptions};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/has.js";import{releaseMaybe as t,disposeMaybe as r}from"../../../../../core/maybe.js";import{watch as i,initial as s}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as n}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{InternalRenderCategory as l}from"../../../webgl.js";import{ColorFormat as a}from"../../../webgl/formats.js";import g from"../../../webgl/RenderNode.js";import{HighlightApplyTechnique as c}from"./HighlightApplyTechnique.js";import{HighlightBlurTechnique as u}from"./HighlightBlurTechnique.js";import{HighlightDownsampleTechnique as m}from"./HighlightDownsampleTechnique.js";import{HighlightPassParameters as p}from"./HighlightPassParameters.js";import{HighlightToSingleTechnique as d}from"./HighlightToSingleTechnique.js";import{RenderRequestType as f}from"../../lib/basicInterfaces.js";import{Default3D as b}from"../../lib/DefaultVertexAttributeLocations.js";import{NoVertex as T}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as w}from"../../lib/VertexArrayObject.js";import{H as x}from"../../../../../chunks/HighlightBlur.glsl.js";import{H as C,g as v}from"../../../../../chunks/HighlightDownsample.glsl.js";import{BufferObject as _}from"../../../../webgl/BufferObject.js";import{PixelFormat as j,TextureSamplingMode as H,FramebufferBit as P,Usage as R,TextureType as O,PrimitiveType as q,DataType as D}from"../../../../webgl/enums.js";import{Texture as I}from"../../../../webgl/Texture.js";import{TextureDescriptor as y}from"../../../../webgl/TextureDescriptor.js";let A=class extends g{constructor(){super(...arguments),this.produces=l.HIGHLIGHTS,this.consumes={required:[l.HIGHLIGHTS,"highlights"]},this._downsampleDrawParameters=new C,this._passParameters=new p,this._highlightBlurDrawParameters=new x,this._grid=new U}initialize(){this.addHandles([i((()=>this._updateOptionsTexture()),(()=>{}),s)])}destroy(){this._grid.coverage=t(this._grid.coverage),this._grid.vao=r(this._grid.vao),this._passParameters.highlightOptionsTexture=t(this._passParameters.highlightOptionsTexture)}_updateOptionsTexture(){if(null==this._passParameters.highlightOptionsTexture){const e=new y(16,2);e.internalFormat=j.RGBA,e.samplingMode=H.NEAREST,this._passParameters.highlightOptionsTexture=new I(this.renderingContext,e,null)}this._passParameters.highlightOptionsTexture.setData(E(this.view.state.highlights)),this.requestRender(f.UPDATE)}precompile(){this.techniques.precompile(m),this.techniques.precompile(d),this.techniques.precompile(u),this.techniques.precompile(c)}render(e){const t=e.find((({name:e})=>e===l.HIGHLIGHTS)),{techniques:r,bindParameters:i,_passParameters:s,renderingContext:o}=this;if(!i.decorations)return t;const h=r.get(m);if(!h.compiled)return this.requestRender(f.UPDATE),t;const n=e.find((({name:e})=>"highlights"===e)).getTexture();s.highlightTexture=n;const a=()=>{this._gridUpdateResources(n);const e=this._gridComputeCoverage(h,n,i),{horizontalCellCount:t,verticalCellCount:r}=e;return s.horizontalCellCount=t,s.verticalCellCount=r,s.coverageTexture=e.coverage?.getTexture(),e},g=e=>{const t=e.verticalCellCount*e.horizontalCellCount;o.bindVAO(e.vao),o.drawElementsInstanced(q.TRIANGLES,6,D.UNSIGNED_BYTE,0,t)},{camera:c}=i,u=()=>{o.bindFramebuffer(t.fbo),o.setViewport4fv(c.fullViewport)};return this._renderHighlightPostprocess(n,a,g,u),s.highlightTexture=null,s.coverageTexture=null,t}_renderHighlightPostprocess(e,t,r,i){const{fboCache:s,techniques:o,bindParameters:h,_passParameters:l,renderingContext:g}=this,m=o.get(d),p=o.get(u),b=o.get(c);if(!b.compiled||!p.compiled||!m.compiled)return void this.requestRender(f.UPDATE);l.highlightTexture=e;const T=t(),{width:w,height:x}=e.descriptor;l.highlightTexture=e;const{camera:C}=h,{fullWidth:v,fullHeight:_,pixelRatio:j}=C,H=Math.ceil(v/j),R=Math.ceil(_/j),{_highlightBlurDrawParameters:O}=this,q=this.view.stage.renderView.renderer,{highlights:D}=h;for(let c=0;c<D.length;++c){const{name:e}=D[c];if(!q.hasHighlight(e))continue;l.highlightLevel=c,g.setClearColor(0,0,0,0);const t=s.acquire(w,x,"single highlight",a.RG8);g.bindFramebuffer(t.fbo),g.setViewport(0,0,w,x),g.clear(P.COLOR),g.bindTechnique(m,h,l),r(T),O.blurInput=t.getTexture(),n(O.blurSize,1/H,0);const o=s.acquire(H,R,"single highlight blur h",a.RG8);g.unbindTexture(o.fbo?.colorTexture),g.bindFramebuffer(o.fbo),g.setViewport(0,0,H,R),g.clear(P.COLOR),g.bindTechnique(p,h,l,O),r(T),t.release(),n(O.blurSize,0,1/R),l.highlightBlurTexture=o.getTexture(),i(),g.bindTechnique(b,h,l,O),r(T),o.release()}}_gridUpdateResources(e){const t=this._grid,{width:r,height:i}=e.descriptor;if(t.horizontalCellCount=Math.ceil(r/v),t.verticalCellCount=Math.ceil(i/v),t.vao)return;const s=this.renderingContext,o=_.createIndex(s,R.STATIC_DRAW,L);t.vao=new w(s,b,new Map([["geometry",T]]),new Map([["geometry",_.createVertex(s,R.STATIC_DRAW)]]),o)}_gridComputeCoverage(e,t,r){const i=this.renderingContext,s=this._grid,o=t.descriptor,h=Math.ceil(o.width/v),n=Math.ceil(o.height/v);this._downsampleDrawParameters.input=t;const{highlights:l}=r;s.coverage?.release();const g=this.fboCache.acquire(h,n,"highlight coverage",l.length>B?a.RG8UI:a.R8UI);return s.coverage=g,i.bindFramebuffer(g.fbo),i.bindTechnique(e,r,this._passParameters,this._downsampleDrawParameters),i.setViewport(0,0,h,n),i.screen.draw(),s}get test(){}};e([o()],A.prototype,"produces",void 0),e([o()],A.prototype,"consumes",void 0),A=e([h("esri.views.3d.webgl-engine.effects.highlight.Highlight")],A);class U{constructor(){this.coverage=null,this.vao=null,this.verticalCellCount=0,this.horizontalCellCount=0,this.viewportWidth=0,this.viewportHeight=0}}function E(e){const t=new Uint8Array(128);let r=0;for(const i of e){const e=4*r,s=4*r+64;++r;const{color:o}=i,h=i.haloColor??o;t[e+0]=o.r,t[e+1]=o.g,t[e+2]=o.b,t[e+3]=i.fillOpacity*o.a*255,t[s+0]=h.r,t[s+1]=h.g,t[s+2]=h.b,t[s+3]=i.haloOpacity*h.a*255}return t}let S=0;function G(e){let t=0;for(const i of e){const{name:e}=i;t+=e.length;const{color:r,fillOpacity:s,haloColor:o,haloOpacity:h}=i;t+=r.r+r.g+r.b+r.a+s,t+=o?o.r+o.g+o.b+o.a+h:0}const r=e.at(0);if(r){const{shadowOpacity:e,shadowDifference:i,shadowColor:s}=r;t+=e+i+s.r+s.g+s.b+s.a}return S+++(t>=0?0:1)}const L=new Uint8Array([0,1,2,2,1,3]);function M(e,t,r,i,s,o=0){const{highlights:h}=i,l=h.length>1?t.acquire(r.width,r.height,"highlight mix",h.length>B?a.RG8UI:a.R8UI):null,{gl:g}=e;if(l){const t=e.getBoundFramebufferObject();e.bindFramebuffer(l.fbo),g.clearBufferuiv(g.COLOR,0,[0,0,0,0]),e.bindFramebuffer(t)}const c=l?.getTexture();i.highlightMixTexture=c,n(i.highlightMixOrigin,o,0),h.forEach(((t,h)=>{if(h>0){const t=I.TEXTURE_UNIT_FOR_UPDATES;e.bindTexture(c,t),e.setActiveTexture(t),g.copyTexSubImage2D(O.TEXTURE_2D,0,0,0,o,0,r.width,r.height),e.bindTexture(null,t)}e.clear(P.DEPTH),i.highlightLevel=h,s()})),i.highlightLevel=null,i.highlightMixTexture=null,l?.release()}const B=4;export{A as Highlight,B as maxHighlightsPerChannel,M as renderHighlightBuffer,G as trackHighlightOptions};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{disposeMaybe as r}from"../../../../../core/maybe.js";import{throwIfAborted as t}from"../../../../../core/promiseUtils.js";import{watch as s,syncAndInitial as i}from"../../../../../core/reactiveUtils.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as n}from"../../../../../support/requestImageUtils.js";import{InternalRenderCategory as c,RenderCategory as h}from"../../../webgl.js";import{ColorFormat as m}from"../../../webgl/formats.js";import l from"../../../webgl/RenderNode.js";import{SMAABlendWeightsTechnique as u}from"./SMAABlendWeightsTechnique.js";import{SMAABlurTechnique as p}from"./SMAABlurTechnique.js";import{SMAAEdgeDetectTechnique as d}from"./SMAAEdgeDetectTechnique.js";import{SMAAPassParameters as f}from"./SMAAPassParameters.js";import{RenderRequestType as b}from"../../lib/basicInterfaces.js";import{PixelFormat as T,TextureSamplingMode as x,FramebufferBit as _,TextureWrapMode as g}from"../../../../webgl/enums.js";import{Texture as A}from"../../../../webgl/Texture.js";import{TextureDescriptor as C}from"../../../../webgl/TextureDescriptor.js";let w=class extends l{constructor(e){super(e),this.produces="disabled",this.consumes={required:[c.ANTIALIASING],optional:[h.COMPOSITE]},this._areaTexture=null,this._searchTexture=null,this._smaaParameters=new f}initialize(){this.addHandles([s((()=>this.isEnabled()),(e=>e?this.enable():this.disable()),i)])}async enable(){if(this.produces=c.ANTIALIASING,this._abortController||this._areaTexture&&this._searchTexture)return;this._abortController=new AbortController;const e=this._abortController.signal;try{const r=await import("./SMAAData.js");await this._loadTextures(r,e),this.requestRender(b.UPDATE)}catch{}this._abortController=null}async _loadTextures(e,r){t(r);const[s,i]=await Promise.allSettled([n(e.areaTexture,{signal:r}),n(e.searchTexure,{signal:r})]);if(t(r),"fulfilled"!==s.status||"fulfilled"!==i.status)return;const a=this.renderingContext;this._areaTexture=j(a,x.LINEAR,T.RGB,s.value),this._searchTexture=j(a,x.NEAREST,T.LUMINANCE,i.value)}disable(){this.produces="disabled"}destroy(){this._searchTexture=r(this._searchTexture),this._areaTexture=r(this._areaTexture)}precompile(){this.techniques.precompile(d),this.techniques.precompile(u),this.techniques.precompile(p)}render(e){const r=e.find((({name:e})=>e===c.ANTIALIASING));if(!this._areaTexture||!this._searchTexture)return this.requestRender(b.UPDATE),r;const t=this.techniques.get(d),s=this.techniques.get(u),i=this.techniques.get(p);if(!t.compiled||!s.compiled||!i.compiled)return this.requestRender(b.UPDATE),r;const a=e.find((({name:e})=>e===h.COMPOSITE));if(!a)return r;const o=a.fbo.width,n=a.fbo.height,l=this.renderingContext;l.setViewport(0,0,o,n);const f=this.fboCache.acquire(o,n,"smaa edges",m.RG);l.bindFramebuffer(f.fbo),l.setClearColor(0,0,0,1),l.clear(_.COLOR),this._smaaParameters.color=a.getTexture();const T=this.bindParameters;l.bindTechnique(t,T,this._smaaParameters),l.screen.draw();const x=this.fboCache.acquire(o,n,"smaa blend");return l.bindFramebuffer(x.fbo),l.setClearColor(0,0,1,1),l.clear(_.COLOR),this._smaaParameters.inputTexture=f.getTexture(),this._smaaParameters.areaTexture=this._areaTexture,this._smaaParameters.searchTexture=this._searchTexture,l.bindTechnique(s,T,this._smaaParameters),l.screen.draw(),f.release(),l.bindFramebuffer(r.fbo),l.setClearColor(0,1,0,1),l.clear(_.COLOR),this._smaaParameters.inputTexture=x.getTexture(),l.bindTechnique(i,T,this._smaaParameters),l.screen.draw(),x.release(),r}};function j(e,r,t,s){const i=new C;return i.pixelFormat=t,i.wrapMode=g.CLAMP_TO_EDGE,i.width=s.width,i.height=s.height,i.samplingMode=r,new A(e,i,s)}e([a()],w.prototype,"produces",void 0),e([a()],w.prototype,"consumes",void 0),e([a({constructOnly:!0})],w.prototype,"isEnabled",void 0),e([a()],w.prototype,"_abortController",void 0),w=e([o("esri.views.3d.webgl-engine.effects.smaa.SMAA")],w);export{w as SMAA};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{disposeMaybe as r}from"../../../../../core/maybe.js";import{throwIfAborted as t}from"../../../../../core/promiseUtils.js";import{watch as s,syncAndInitial as i}from"../../../../../core/reactiveUtils.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as n}from"../../../../../support/requestImageUtils.js";import{InternalRenderCategory as c,RenderCategory as h}from"../../../webgl.js";import{ColorFormat as m}from"../../../webgl/formats.js";import l from"../../../webgl/RenderNode.js";import{SMAABlendWeightsTechnique as u}from"./SMAABlendWeightsTechnique.js";import{SMAABlurTechnique as p}from"./SMAABlurTechnique.js";import{SMAAEdgeDetectTechnique as d}from"./SMAAEdgeDetectTechnique.js";import{SMAAPassParameters as f}from"./SMAAPassParameters.js";import{RenderRequestType as b}from"../../lib/basicInterfaces.js";import{PixelFormat as T,TextureSamplingMode as x,FramebufferBit as _,TextureWrapMode as g}from"../../../../webgl/enums.js";import{Texture as A}from"../../../../webgl/Texture.js";import{TextureDescriptor as C}from"../../../../webgl/TextureDescriptor.js";let w=class extends l{constructor(e){super(e),this.produces="disabled",this.consumes={required:[c.ANTIALIASING],optional:[h.COMPOSITE]},this._areaTexture=null,this._searchTexture=null,this._smaaParameters=new f}initialize(){this.addHandles([s((()=>this.isEnabled()),(e=>e?this.enable():this.disable()),i)])}async enable(){if(this.produces=c.ANTIALIASING,this._abortController||this._areaTexture&&this._searchTexture)return;this._abortController=new AbortController;const e=this._abortController.signal;try{const r=await import("./SMAAData.js");await this._loadTextures(r,e),this.requestRender(b.UPDATE)}catch{}this._abortController=null}async _loadTextures(e,r){t(r);const[s,i]=await Promise.allSettled([n(e.areaTexture,{signal:r}),n(e.searchTexure,{signal:r})]);if(t(r),"fulfilled"!==s.status||"fulfilled"!==i.status)return;const a=this.renderingContext;this._areaTexture=j(a,x.LINEAR,T.RGB,s.value),this._searchTexture=j(a,x.NEAREST,T.LUMINANCE,i.value)}disable(){this.produces="disabled"}destroy(){this._searchTexture=r(this._searchTexture),this._areaTexture=r(this._areaTexture)}precompile(){this.techniques.precompile(d),this.techniques.precompile(u),this.techniques.precompile(p)}render(e){const r=e.find((({name:e})=>e===c.ANTIALIASING));if(!this._areaTexture||!this._searchTexture)return this.requestRender(b.UPDATE),r;const t=this.techniques.get(d),s=this.techniques.get(u),i=this.techniques.get(p);if(!t.compiled||!s.compiled||!i.compiled)return this.requestRender(b.UPDATE),r;const a=e.find((({name:e})=>e===h.COMPOSITE));if(!a)return r;const o=a.fbo.width,n=a.fbo.height,l=this.renderingContext;l.setViewport(0,0,o,n);const f=this.fboCache.acquire(o,n,"smaa edges",m.RG8);l.bindFramebuffer(f.fbo),l.setClearColor(0,0,0,1),l.clear(_.COLOR),this._smaaParameters.color=a.getTexture();const T=this.bindParameters;l.bindTechnique(t,T,this._smaaParameters),l.screen.draw();const x=this.fboCache.acquire(o,n,"smaa blend");return l.bindFramebuffer(x.fbo),l.setClearColor(0,0,1,1),l.clear(_.COLOR),this._smaaParameters.inputTexture=f.getTexture(),this._smaaParameters.areaTexture=this._areaTexture,this._smaaParameters.searchTexture=this._searchTexture,l.bindTechnique(s,T,this._smaaParameters),l.screen.draw(),f.release(),l.bindFramebuffer(r.fbo),l.setClearColor(0,1,0,1),l.clear(_.COLOR),this._smaaParameters.inputTexture=x.getTexture(),l.bindTechnique(i,T,this._smaaParameters),l.screen.draw(),x.release(),r}};function j(e,r,t,s){const i=new C;return i.pixelFormat=t,i.wrapMode=g.CLAMP_TO_EDGE,i.width=s.width,i.height=s.height,i.samplingMode=r,new A(e,i,s)}e([a()],w.prototype,"produces",void 0),e([a()],w.prototype,"consumes",void 0),e([a({constructOnly:!0})],w.prototype,"isEnabled",void 0),e([a()],w.prototype,"_abortController",void 0),w=e([o("esri.views.3d.webgl-engine.effects.smaa.SMAA")],w);export{w as SMAA};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{clamp as r}from"../../../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../../../core/maybe.js";import{watch as t}from"../../../../../core/reactiveUtils.js";import{Milliseconds as i}from"../../../../../core/time.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as m}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{InternalRenderCategory as n}from"../../../webgl.js";import{ColorFormat as p}from"../../../webgl/formats.js";import c from"../../../webgl/RenderNode.js";import{distanceFadeEnd as h,distanceFadeStart as u}from"../../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{SSAOBlurTechnique as l}from"./SSAOBlurTechnique.js";import{noiseData as d}from"./SSAONoiseData.js";import{SSAOPassParameters as f,BlurDrawParameters as b}from"./SSAOParameters.js";import{SSAOTechnique as w}from"./SSAOTechnique.js";import{RenderRequestType as T}from"../../lib/basicInterfaces.js";import{g as S}from"../../../../../chunks/SSAO.glsl.js";import{TextureWrapMode as _,PixelFormat as P,DepthStencilAttachment as j,FramebufferBit as g}from"../../../../webgl/enums.js";import{Texture as x}from"../../../../webgl/Texture.js";import{TextureDescriptor as q}from"../../../../webgl/TextureDescriptor.js";const A=2;let E=class extends c{constructor(e){super(e),this.consumes={required:["normals"]},this.produces=n.SSAO,this.isEnabled=()=>!1,this._enableTime=i(0),this._passParameters=new f,this._drawParameters=new b}initialize(){const e=Uint8Array.from(atob(d),(e=>e.charCodeAt(0))),r=new q;r.wrapMode=_.CLAMP_TO_EDGE,r.pixelFormat=P.RGB,r.wrapMode=_.REPEAT,r.hasMipmap=!0,r.width=32,r.height=32,this._passParameters.noiseTexture=new x(this.renderingContext,r,e),this.techniques.precompile(w),this.techniques.precompile(l),this.addHandles(t((()=>this.isEnabled()),(()=>this._enableTime=i(0))))}destroy(){this._passParameters.noiseTexture=s(this._passParameters.noiseTexture)}render(e){const s=this.bindParameters,t=e.find((({name:e})=>"normals"===e)),o=t?.getTexture(),a=t?.getTexture(j),c=this.fboCache,d=s.camera,f=d.fullViewport[2],b=d.fullViewport[3],_=Math.round(f/A),P=Math.round(b/A),x=this.techniques.get(w),q=this.techniques.get(l);if(!x.compiled||!q.compiled)return this._enableTime=i(performance.now()),this.requestRender(T.UPDATE),c.acquire(_,P,n.SSAO,p.RED);0===this._enableTime&&(this._enableTime=i(performance.now()));const E=this.renderingContext,y=this.view.qualitySettings.fadeDuration,R=d.relativeElevation,v=r((h-R)/(h-u),0,1),C=y>0?Math.min(y,performance.now()-this._enableTime)/y:1,D=C*v;this._passParameters.normalTexture=o,this._passParameters.depthTexture=a,this._passParameters.projScale=1/d.computeScreenPixelSizeAtDist(1),this._passParameters.intensity=4*O/S(d)**6*D;const V=c.acquire(f,b,"ssao input",p.RG);E.bindFramebuffer(V.fbo),E.setViewport(0,0,f,b),E.bindTechnique(x,s,this._passParameters,this._drawParameters),E.screen.draw();const M=c.acquire(_,P,"ssao blur",p.RED);E.bindFramebuffer(M.fbo),this._drawParameters.colorTexture=V.getTexture(),m(this._drawParameters.blurSize,0,A/b),E.bindTechnique(q,s,this._passParameters,this._drawParameters),E.setViewport(0,0,_,P),E.screen.draw(),V.release();const L=c.acquire(_,P,n.SSAO,p.RED);return E.bindFramebuffer(L.fbo),E.setViewport(0,0,f,b),E.setClearColor(1,1,1,0),E.clear(g.COLOR),this._drawParameters.colorTexture=M.getTexture(),m(this._drawParameters.blurSize,A/f,0),E.bindTechnique(q,s,this._passParameters,this._drawParameters),E.setViewport(0,0,_,P),E.screen.draw(),E.setViewport4fv(d.fullViewport),M.release(),C<1&&this.requestRender(T.UPDATE),L}};e([o()],E.prototype,"consumes",void 0),e([o()],E.prototype,"produces",void 0),e([o({constructOnly:!0})],E.prototype,"isEnabled",void 0),E=e([a("esri.views.3d.webgl-engine.effects.ssao.SSAO")],E);const O=.5;export{E as SSAO,A as blurSizePixels};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{clamp as r}from"../../../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../../../core/maybe.js";import{watch as t}from"../../../../../core/reactiveUtils.js";import{Milliseconds as i}from"../../../../../core/time.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as m}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{InternalRenderCategory as n}from"../../../webgl.js";import{ColorFormat as p}from"../../../webgl/formats.js";import c from"../../../webgl/RenderNode.js";import{distanceFadeEnd as h,distanceFadeStart as u}from"../../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{SSAOBlurTechnique as l}from"./SSAOBlurTechnique.js";import{noiseData as d}from"./SSAONoiseData.js";import{SSAOPassParameters as f,BlurDrawParameters as b}from"./SSAOParameters.js";import{SSAOTechnique as w}from"./SSAOTechnique.js";import{RenderRequestType as T}from"../../lib/basicInterfaces.js";import{g as S}from"../../../../../chunks/SSAO.glsl.js";import{TextureWrapMode as _,PixelFormat as P,DepthStencilAttachment as j,FramebufferBit as g}from"../../../../webgl/enums.js";import{Texture as x}from"../../../../webgl/Texture.js";import{TextureDescriptor as q}from"../../../../webgl/TextureDescriptor.js";const A=2;let O=class extends c{constructor(e){super(e),this.consumes={required:["normals"]},this.produces=n.SSAO,this.isEnabled=()=>!1,this._enableTime=i(0),this._passParameters=new f,this._drawParameters=new b}initialize(){const e=Uint8Array.from(atob(d),(e=>e.charCodeAt(0))),r=new q;r.wrapMode=_.CLAMP_TO_EDGE,r.pixelFormat=P.RGB,r.wrapMode=_.REPEAT,r.hasMipmap=!0,r.width=32,r.height=32,this._passParameters.noiseTexture=new x(this.renderingContext,r,e),this.techniques.precompile(w),this.techniques.precompile(l),this.addHandles(t((()=>this.isEnabled()),(()=>this._enableTime=i(0))))}destroy(){this._passParameters.noiseTexture=s(this._passParameters.noiseTexture)}render(e){const s=this.bindParameters,t=e.find((({name:e})=>"normals"===e)),o=t?.getTexture(),a=t?.getTexture(j),c=this.fboCache,d=s.camera,f=d.fullViewport[2],b=d.fullViewport[3],_=Math.round(f/A),P=Math.round(b/A),x=this.techniques.get(w),q=this.techniques.get(l);if(!x.compiled||!q.compiled)return this._enableTime=i(performance.now()),this.requestRender(T.UPDATE),c.acquire(_,P,n.SSAO,p.R8);0===this._enableTime&&(this._enableTime=i(performance.now()));const O=this.renderingContext,R=this.view.qualitySettings.fadeDuration,v=d.relativeElevation,C=r((h-v)/(h-u),0,1),E=R>0?Math.min(R,performance.now()-this._enableTime)/R:1,V=E*C;this._passParameters.normalTexture=o,this._passParameters.depthTexture=a,this._passParameters.projScale=1/d.computeScreenPixelSizeAtDist(1),this._passParameters.intensity=4*y/S(d)**6*V;const D=c.acquire(f,b,"ssao input",p.RG8);O.bindFramebuffer(D.fbo),O.setViewport(0,0,f,b),O.bindTechnique(x,s,this._passParameters,this._drawParameters),O.screen.draw();const M=c.acquire(_,P,"ssao blur",p.R8);O.bindFramebuffer(M.fbo),this._drawParameters.colorTexture=D.getTexture(),m(this._drawParameters.blurSize,0,A/b),O.bindTechnique(q,s,this._passParameters,this._drawParameters),O.setViewport(0,0,_,P),O.screen.draw(),D.release();const L=c.acquire(_,P,n.SSAO,p.R8);return O.bindFramebuffer(L.fbo),O.setViewport(0,0,f,b),O.setClearColor(1,1,1,0),O.clear(g.COLOR),this._drawParameters.colorTexture=M.getTexture(),m(this._drawParameters.blurSize,A/f,0),O.bindTechnique(q,s,this._passParameters,this._drawParameters),O.setViewport(0,0,_,P),O.screen.draw(),O.setViewport4fv(d.fullViewport),M.release(),E<1&&this.requestRender(T.UPDATE),L}};e([o()],O.prototype,"consumes",void 0),e([o()],O.prototype,"produces",void 0),e([o({constructOnly:!0})],O.prototype,"isEnabled",void 0),O=e([a("esri.views.3d.webgl-engine.effects.ssao.SSAO")],O);const y=.5;export{O as SSAO,A as blurSizePixels};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- var i,e;!function(i){i[i.OBJECT=0]="OBJECT",i[i.HUD=1]="HUD",i[i.TERRAIN=2]="TERRAIN",i[i.OVERLAY=3]="OVERLAY",i[i.I3S=4]="I3S",i[i.PCL=5]="PCL",i[i.LOD=6]="LOD",i[i.VOXEL=7]="VOXEL",i[i.TILES3D=8]="TILES3D"}(i||(i={}));class s{constructor(){this.verticalOffset=0,this.selectionMode=!1,this.hud=!0,this.selectOpaqueTerrainOnly=!0,this.invisibleTerrain=!1,this.backfacesTerrain=!0,this.isFiltered=!1,this.filteredLayerUids=[],this.store=e.ALL,this.normalRequired=!0,this.excludeLabels=!1}}!function(i){i[i.MIN=0]="MIN",i[i.MINMAX=1]="MINMAX",i[i.ALL=2]="ALL"}(e||(e={}));export{s as IntersectorOptions,i as IntersectorType,e as StoreResults};
5
+ var i,e;!function(i){i[i.OBJECT=0]="OBJECT",i[i.HUD=1]="HUD",i[i.TERRAIN=2]="TERRAIN",i[i.OVERLAY=3]="OVERLAY",i[i.I3S=4]="I3S",i[i.PCL=5]="PCL",i[i.LOD=6]="LOD",i[i.VOXEL=7]="VOXEL",i[i.TILES3D=8]="TILES3D"}(i||(i={}));class s{constructor(){this.verticalOffset=0,this.selectionMode=!1,this.hud=!0,this.selectOpaqueTerrainOnly=!0,this.invisibleTerrain=!1,this.backfacesTerrain=!0,this.isFiltered=!1,this.filteredLayerViewUids=[],this.store=e.ALL,this.normalRequired=!0,this.excludeLabels=!1}}!function(i){i[i.MIN=0]="MIN",i[i.MINMAX=1]="MINMAX",i[i.ALL=2]="ALL"}(e||(e={}));export{s as IntersectorOptions,i as IntersectorType,e as StoreResults};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{clone as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";class t{constructor(s,t,r){this.object=s,this.geometryId=t,this.primIndex=r}}class r extends t{constructor(t,r,c,e){super(t,r,c),this.center=null!=e?s(e):null}}class c extends r{}class e{constructor(s){this.layerUid=s}}class o extends e{constructor(s,t){super(s),this.graphicUid=t}}export{o as Graphic3DTarget,r as HudTarget,e as LayerTarget,t as ObjectTarget,c as ValidHudTarget};
5
+ import{clone as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";class t{constructor(s,t,r){this.object=s,this.geometryId=t,this.primIndex=r}}class r extends t{constructor(t,r,e,c){super(t,r,e),this.center=null!=c?s(c):null}}class e extends r{}class c{constructor(s){this.layerViewUid=s}}class i extends c{constructor(s,t){super(s),this.graphicUid=t}}export{i as Graphic3DTarget,r as HudTarget,c as LayerTarget,t as ObjectTarget,e as ValidHudTarget};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{releaseMaybe as e}from"../../../../core/maybe.js";import{c as t}from"../../../../chunks/vec42.js";import{ZEROS as i}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ColorFormat as r,DepthFormat as o}from"../../webgl/formats.js";import{ViewportSize as h}from"./BindParameters.js";import{FramebufferBit as c,ColorAttachment1 as l}from"../../../webgl/enums.js";import{ensureAttachmentMaxSize as _}from"../../../webgl/FramebufferObject.js";class a{constructor(e){this._fbos=e,this._requiresEmission=!1,this._size=new h(0,0),this._clearColor=s()}dispose(){this._color=e(this._color),this.releaseDepth()}initialize(e,i,s,r){this._size.width=e,this._size.height=i,_(this._size,this._fbos.rctx.parameters.maxTextureSize);const o=this._color;return this._color=null,this.releaseDepth(),this._requiresEmission=r,t(this._clearColor,s),o}releaseDepth(){this._color?.detachDepth(),this._depth=e(this._depth)}update(e){const t=this._ensureColor();t.attachDepth(this.depth),this._color=e(t)}bind(){const{rctx:e}=this._fbos,t=null==this._color;this.color.attachDepth(this.depth),e.bindFramebuffer(this.color.fbo),t&&(e.setClearStencil(0),e.setClearColor(this._clearColor[0],this._clearColor[1],this._clearColor[2],this._clearColor[3]),e.clear(c.COLOR|c.DEPTH|c.STENCIL),this._requiresEmission&&e.clearBuffer(1,i))}_acquireColor(){return this._requiresEmission?this._fbos.acquire(this._size.width,this._size.height,"acquired-color").acquireColor(l,r.RGBA16F,"emissive"):this._fbos.acquire(this._size.width,this._size.height,"acquired-color")}_acquireDepth(){return this._fbos.acquireDepth(o.DEPTH_STENCIL_TEXTURE,this._size.width,this._size.height,"depth")}get size(){return this._size}get color(){return this._ensureColor()}get depth(){return this._depth??=this._acquireDepth(),this._depth}_ensureColor(){return this._color??=this._acquireColor(),this._color}}export{a as MainFramebuffer};
5
+ import{releaseMaybe as e}from"../../../../core/maybe.js";import{c as t}from"../../../../chunks/vec42.js";import{ZEROS as i}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ColorFormat as r}from"../../webgl/formats.js";import{ViewportSize as o}from"./BindParameters.js";import{FramebufferBit as h,ColorAttachment1 as c,DepthStencilAttachment as l}from"../../../webgl/enums.js";import{ensureAttachmentMaxSize as _}from"../../../webgl/FramebufferObject.js";class a{constructor(e){this._fbos=e,this._requiresEmission=!1,this._size=new o(0,0),this._clearColor=s()}dispose(){this._color=e(this._color),this.releaseDepth()}initialize(e,i,s,r){this._size.width=e,this._size.height=i,_(this._size,this._fbos.rctx.parameters.maxTextureSize);const o=this._color;return this._color=null,this.releaseDepth(),this._requiresEmission=r,t(this._clearColor,s),o}releaseDepth(){this._color?.detachDepth(),this._depth=e(this._depth)}update(e){const t=this._ensureColor();t.attachDepth(this.depth),this._color=e(t)}bind(){const{rctx:e}=this._fbos,t=null==this._color;this.color.attachDepth(this.depth),e.bindFramebuffer(this.color.fbo),t&&(e.setClearStencil(0),e.setClearColor(this._clearColor[0],this._clearColor[1],this._clearColor[2],this._clearColor[3]),e.clear(h.COLOR|h.DEPTH|h.STENCIL),this._requiresEmission&&e.clearBuffer(1,i))}_acquireColor(){return this._requiresEmission?this._fbos.acquire(this._size.width,this._size.height,"acquired-color").acquireColor(c,r.RGBA16F,"emissive"):this._fbos.acquire(this._size.width,this._size.height,"acquired-color")}_acquireDepth(){return this._fbos.acquireDepth(l,this._size.width,this._size.height,"depth")}get size(){return this._size}get color(){return this._ensureColor()}get depth(){return this._depth??=this._acquireDepth(),this._depth}_ensureColor(){return this._color??=this._acquireColor(),this._color}}export{a as MainFramebuffer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import{copy as t,multiply as e,hasIdentityRotation as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as s,create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{m as o,t as a,j as n,i as h,g as m,p as c,c as l}from"../../../../chunks/vec32.js";import{fromValues as d,create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{a as u,c as f}from"../../../../chunks/sphere.js";import{maxScale as _}from"../../support/mathUtils.js";import{Object3DState as b}from"./basicInterfaces.js";import{ContentObject as p}from"./ContentObject.js";import{ContentObjectType as v}from"./ContentObjectType.js";import{Object3DOccludeeStateID as j,Object3DHighlightStateID as S}from"./Object3DStateID.js";import{assert as y}from"./Util.js";import{affectsGeometry as x}from"./VertexAttribute.js";import{addObject3DStateID as V,removeObject3DStateID as O}from"../materials/renderers/utils.js";class A extends p{get geometries(){return this._geometries}get transformation(){return this._transformation??s}set transformation(e){this._transformation=t(this._transformation??r(),e),this._invalidateBoundingVolume(),this._emit("transformationChanged",this)}get shaderTransformation(){return this._shaderTransformation}set shaderTransformation(e){this._shaderTransformation=e?t(this._shaderTransformation??r(),e):null,this._invalidateBoundingVolume(),this._emit("shaderTransformationChanged",this)}get effectiveTransformation(){return this.shaderTransformation??this.transformation}constructor(t={}){super(),this.type=v.Object,this._shaderTransformation=null,this._parentLayer=null,this._visible=!0,this._highlightIds=new Set,this.castShadow=t.castShadow??!0,this.usesVerticalDistanceToGround=t.usesVerticalDistanceToGround??!1,this.graphicUid=t.graphicUid,this.layerUid=t.layerUid,t.isElevationSource&&(this.lastValidElevationBB=new C),this._geometries=t.geometries?Array.from(t.geometries):new Array}dispose(){this._geometries.length=0}get parentLayer(){return this._parentLayer}set parentLayer(t){y(null==this._parentLayer||null==t,"Object3D can only be added to a single Layer"),this._parentLayer=t}addGeometry(t){t.visible=this._visible,this._geometries.push(t);for(const e of this._highlightIds)t.addHighlight(e);this._emit("geometryAdded",{object:this,geometry:t}),this._highlightIds.size&&this._emit("highlightChanged",this),this._invalidateBoundingVolume()}removeGeometry(t){const e=this._geometries.splice(t,1)[0];if(e){for(const t of this._highlightIds)e.removeHighlight(t);this._emit("geometryRemoved",{object:this,geometry:e}),this._highlightIds.size&&this._emit("highlightChanged",this),this._invalidateBoundingVolume()}}removeAllGeometries(){for(;this._geometries.length>0;)this.removeGeometry(0)}geometryVertexAttributeUpdated(t,e,i=!1){this._emit("attributesChanged",{object:this,geometry:t,attribute:e,sync:i}),x(e)&&this._invalidateBoundingVolume()}get visible(){return this._visible}set visible(t){if(this._visible!==t){this._visible=t;for(const t of this._geometries)t.visible=this._visible;this._emit("visibilityChanged",this)}}maskOccludee(){const t=new j;for(const e of this._geometries)e.occludees=V(e.occludees,t);return this._emit("occlusionChanged",this),t}removeOcclude(t){for(const e of this._geometries)e.occludees=O(e.occludees,t);this._emit("occlusionChanged",this)}highlight(t){const e=new S(t);for(const i of this._geometries)i.addHighlight(e);return this._emit("highlightChanged",this),this._highlightIds.add(e),e}removeHighlight(t){this._highlightIds.delete(t);for(const e of this._geometries)e.removeHighlight(t);this._emit("highlightChanged",this)}removeStateID(t){t.channel===b.Highlight?this.removeHighlight(t):this.removeOcclude(t)}getCombinedStaticTransformation(t,i){return e(i,this.transformation,t.transformation)}getCombinedShaderTransformation(t,i=r()){return e(i,this.effectiveTransformation,t.transformation)}get boundingVolumeWorldSpace(){return this._bvWorldSpace||(this._bvWorldSpace=this._bvWorldSpace||new L,this._validateBoundingVolume(this._bvWorldSpace,W.WorldSpace)),this._bvWorldSpace}get boundingVolumeObjectSpace(){return this._bvObjectSpace||(this._bvObjectSpace=this._bvObjectSpace||new L,this._validateBoundingVolume(this._bvObjectSpace,W.ObjectSpace)),this._bvObjectSpace}_validateBoundingVolume(t,e){const i=e===W.ObjectSpace;for(const s of this._geometries){const e=s.boundingInfo;e&&M(e,t,i?s.transformation:this.getCombinedShaderTransformation(s))}o(u(t.bounds),t.min,t.max,.5);for(const s of this._geometries){const e=s.boundingInfo;if(null==e)continue;const r=i?s.transformation:this.getCombinedShaderTransformation(s),o=_(r);a(I,e.center,r);const h=n(I,u(t.bounds)),m=e.radius*o;t.bounds[3]=Math.max(t.bounds[3],h+m)}}_invalidateBoundingVolume(){const t=this._bvWorldSpace?.bounds;this._bvObjectSpace=this._bvWorldSpace=void 0,this._parentLayer&&t&&this._parentLayer.notifyObjectBBChanged(this,t)}_emit(t,e){this._parentLayer&&this._parentLayer.events.emit(t,e)}get test(){}}class C{constructor(){this.min=d(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this.max=d(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE)}isEmpty(){return this.max[0]<this.min[0]&&this.max[1]<this.min[1]&&this.max[2]<this.min[2]}}class L extends C{constructor(){super(...arguments),this.bounds=f()}}function M(t,e,s){const r=t.bbMin,o=t.bbMax;if(i(s)){const t=h(T,s[12],s[13],s[14]);m(B,r,t),m(U,o,t);for(let i=0;i<3;++i)e.min[i]=Math.min(e.min[i],B[i]),e.max[i]=Math.max(e.max[i],U[i])}else if(a(B,r,s),c(r,o))for(let i=0;i<3;++i)e.min[i]=Math.min(e.min[i],B[i]),e.max[i]=Math.max(e.max[i],B[i]);else{a(U,o,s);for(let t=0;t<3;++t)e.min[t]=Math.min(e.min[t],B[t],U[t]),e.max[t]=Math.max(e.max[t],B[t],U[t]);for(let t=0;t<3;++t){l(B,r),l(U,o),B[t]=o[t],U[t]=r[t],a(B,B,s),a(U,U,s);for(let t=0;t<3;++t)e.min[t]=Math.min(e.min[t],B[t],U[t]),e.max[t]=Math.max(e.max[t],B[t],U[t])}}}const T=g(),B=g(),U=g(),I=g();var W;!function(t){t[t.WorldSpace=0]="WorldSpace",t[t.ObjectSpace=1]="ObjectSpace"}(W||(W={}));export{L as BoundingVolume,A as Object3D};
5
+ import"../../../../core/has.js";import{copy as t,multiply as e,hasIdentityRotation as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as s,create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{m as o,t as a,j as n,i as h,g as m,p as c,c as l}from"../../../../chunks/vec32.js";import{fromValues as d,create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{a as u,c as f}from"../../../../chunks/sphere.js";import{maxScale as _}from"../../support/mathUtils.js";import{Object3DState as b}from"./basicInterfaces.js";import{ContentObject as p}from"./ContentObject.js";import{ContentObjectType as v}from"./ContentObjectType.js";import{Object3DOccludeeStateID as j,Object3DHighlightStateID as S}from"./Object3DStateID.js";import{assert as y}from"./Util.js";import{affectsGeometry as x}from"./VertexAttribute.js";import{addObject3DStateID as V,removeObject3DStateID as O}from"../materials/renderers/utils.js";class A extends p{get geometries(){return this._geometries}get transformation(){return this._transformation??s}set transformation(e){this._transformation=t(this._transformation??r(),e),this._invalidateBoundingVolume(),this._emit("transformationChanged",this)}get shaderTransformation(){return this._shaderTransformation}set shaderTransformation(e){this._shaderTransformation=e?t(this._shaderTransformation??r(),e):null,this._invalidateBoundingVolume(),this._emit("shaderTransformationChanged",this)}get effectiveTransformation(){return this.shaderTransformation??this.transformation}constructor(t={}){super(),this.type=v.Object,this._shaderTransformation=null,this._parentLayer=null,this._visible=!0,this._highlightIds=new Set,this.castShadow=t.castShadow??!0,this.usesVerticalDistanceToGround=t.usesVerticalDistanceToGround??!1,this.graphicUid=t.graphicUid,this.layerViewUid=t.layerViewUid,t.isElevationSource&&(this.lastValidElevationBB=new C),this._geometries=t.geometries?Array.from(t.geometries):new Array}dispose(){this._geometries.length=0}get parentLayer(){return this._parentLayer}set parentLayer(t){y(null==this._parentLayer||null==t,"Object3D can only be added to a single Layer"),this._parentLayer=t}addGeometry(t){t.visible=this._visible,this._geometries.push(t);for(const e of this._highlightIds)t.addHighlight(e);this._emit("geometryAdded",{object:this,geometry:t}),this._highlightIds.size&&this._emit("highlightChanged",this),this._invalidateBoundingVolume()}removeGeometry(t){const e=this._geometries.splice(t,1)[0];if(e){for(const t of this._highlightIds)e.removeHighlight(t);this._emit("geometryRemoved",{object:this,geometry:e}),this._highlightIds.size&&this._emit("highlightChanged",this),this._invalidateBoundingVolume()}}removeAllGeometries(){for(;this._geometries.length>0;)this.removeGeometry(0)}geometryVertexAttributeUpdated(t,e,i=!1){this._emit("attributesChanged",{object:this,geometry:t,attribute:e,sync:i}),x(e)&&this._invalidateBoundingVolume()}get visible(){return this._visible}set visible(t){if(this._visible!==t){this._visible=t;for(const t of this._geometries)t.visible=this._visible;this._emit("visibilityChanged",this)}}maskOccludee(){const t=new j;for(const e of this._geometries)e.occludees=V(e.occludees,t);return this._emit("occlusionChanged",this),t}removeOcclude(t){for(const e of this._geometries)e.occludees=O(e.occludees,t);this._emit("occlusionChanged",this)}highlight(t){const e=new S(t);for(const i of this._geometries)i.addHighlight(e);return this._emit("highlightChanged",this),this._highlightIds.add(e),e}removeHighlight(t){this._highlightIds.delete(t);for(const e of this._geometries)e.removeHighlight(t);this._emit("highlightChanged",this)}removeStateID(t){t.channel===b.Highlight?this.removeHighlight(t):this.removeOcclude(t)}getCombinedStaticTransformation(t,i){return e(i,this.transformation,t.transformation)}getCombinedShaderTransformation(t,i=r()){return e(i,this.effectiveTransformation,t.transformation)}get boundingVolumeWorldSpace(){return this._bvWorldSpace||(this._bvWorldSpace=this._bvWorldSpace||new L,this._validateBoundingVolume(this._bvWorldSpace,w.WorldSpace)),this._bvWorldSpace}get boundingVolumeObjectSpace(){return this._bvObjectSpace||(this._bvObjectSpace=this._bvObjectSpace||new L,this._validateBoundingVolume(this._bvObjectSpace,w.ObjectSpace)),this._bvObjectSpace}_validateBoundingVolume(t,e){const i=e===w.ObjectSpace;for(const s of this._geometries){const e=s.boundingInfo;e&&M(e,t,i?s.transformation:this.getCombinedShaderTransformation(s))}o(u(t.bounds),t.min,t.max,.5);for(const s of this._geometries){const e=s.boundingInfo;if(null==e)continue;const r=i?s.transformation:this.getCombinedShaderTransformation(s),o=_(r);a(I,e.center,r);const h=n(I,u(t.bounds)),m=e.radius*o;t.bounds[3]=Math.max(t.bounds[3],h+m)}}_invalidateBoundingVolume(){const t=this._bvWorldSpace?.bounds;this._bvObjectSpace=this._bvWorldSpace=void 0,this._parentLayer&&t&&this._parentLayer.notifyObjectBBChanged(this,t)}_emit(t,e){this._parentLayer&&this._parentLayer.events.emit(t,e)}get test(){}}class C{constructor(){this.min=d(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this.max=d(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE)}isEmpty(){return this.max[0]<this.min[0]&&this.max[1]<this.min[1]&&this.max[2]<this.min[2]}}class L extends C{constructor(){super(...arguments),this.bounds=f()}}function M(t,e,s){const r=t.bbMin,o=t.bbMax;if(i(s)){const t=h(T,s[12],s[13],s[14]);m(B,r,t),m(U,o,t);for(let i=0;i<3;++i)e.min[i]=Math.min(e.min[i],B[i]),e.max[i]=Math.max(e.max[i],U[i])}else if(a(B,r,s),c(r,o))for(let i=0;i<3;++i)e.min[i]=Math.min(e.min[i],B[i]),e.max[i]=Math.max(e.max[i],B[i]);else{a(U,o,s);for(let t=0;t<3;++t)e.min[t]=Math.min(e.min[t],B[t],U[t]),e.max[t]=Math.max(e.max[t],B[t],U[t]);for(let t=0;t<3;++t){l(B,r),l(U,o),B[t]=o[t],U[t]=r[t],a(B,B,s),a(U,U,s);for(let t=0;t<3;++t)e.min[t]=Math.min(e.min[t],B[t],U[t]),e.max[t]=Math.max(e.max[t],B[t],U[t])}}}const T=g(),B=g(),U=g(),I=g();var w;!function(t){t[t.WorldSpace=0]="WorldSpace",t[t.ObjectSpace=1]="ObjectSpace"}(w||(w={}));export{L as BoundingVolume,A as Object3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import{NestedMap as e}from"../../../../core/NestedMap.js";import{fromValues as r}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{BufferViewVec4u8 as t}from"../../../../geometry/support/buffer/BufferView.js";class o{constructor(){this.declaredClass="esri.views.3d.webgl-engine.lib.ObjectAndLayerIdRenderHelper",this.colorZero=new t(new ArrayBuffer(4)),this._layerToOidToColor=new e,this._colorToUID=new Map,this._layerUidToGraphicsUidToObjectId=new e,this._layerUidToId=new Map,this._layerUidToPopupEnabled=new Map}setUidToObjectAndLayerId(e,r,t,o,i,d=null,a=null,s=null){e&&r&&t&&o&&(this._layerUidToId.set(o,t),this._layerUidToPopupEnabled.set(o,i),i&&this._layerUidToGraphicsUidToObjectId.set(o,r,{objectId:e,attributeNodeId:d,attributeIndex:a,subLayerId:s}))}getObjectAndLayerIdColor(e){const t=this.getObjectAndLayerIdColorArray(e);return r(t.get(0,1),t.get(0,2),t.get(0,3),255)}getObjectAndLayerIdColorArray(e){if(!e.layerUid||!e.graphicUid)return this.colorZero;const r=this._layerUidToPopupEnabled.get(e.layerUid);if(void 0===r)return this.colorZero;if(!1===r)return this.colorZero;const o=this._layerUidToGraphicsUidToObjectId.get(e.layerUid,e.graphicUid)?.objectId;if(!o)return this.colorZero;let i=this._layerToOidToColor.get(e.layerUid,o);if(!i){if(!!has("enable-feature:objectAndLayerId-screenshot-testing"))i=o;else for(;!i;){const e=Math.floor(16777214*Math.random())+1;this._colorToUID.has(e)||(i=e)}if(i>16777215)throw new Error("Object ID Overflow");this._layerToOidToColor.set(e.layerUid,o,i),this._colorToUID.set(i,e)}const d=new ArrayBuffer(4);new DataView(d).setUint32(0,i,!1);return new t(d)}getColorToObjectAndLayerIdMapping(){const e=new Map;for(const[r,t]of this._colorToUID.entries()){const o=this._layerUidToGraphicsUidToObjectId.get(t.layerUid,t.graphicUid),i=this._layerUidToId.get(t.layerUid);o&&i&&e.set(r,o.attributeNodeId?{type:"object-and-layer-and-i3s-id",olid:o.objectId,lid:i,attrId:o.attributeNodeId,attrIdx:o.attributeIndex,subLayerId:o.subLayerId}:{type:"object-and-layer-id",olid:o.objectId,lid:i})}return e}}export{o as ObjectAndLayerIdRenderHelper};
5
+ import has from"../../../../core/has.js";import{NestedMap as e}from"../../../../core/NestedMap.js";import{fromValues as r}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{BufferViewVec4u8 as t}from"../../../../geometry/support/buffer/BufferView.js";class o{constructor(){this.declaredClass="esri.views.3d.webgl-engine.lib.ObjectAndLayerIdRenderHelper",this.colorZero=new t(new ArrayBuffer(4)),this._layerToOidToColor=new e,this._colorToUID=new Map,this._layerViewUidToGraphicsUidToObjectId=new e,this._layerViewUidToLayerId=new Map,this._layerViewUidToPopupEnabled=new Map}setUidToObjectAndLayerId(e,r,t,o,i,d=null,a=null,s=null){e&&r&&t&&o&&(this._layerViewUidToLayerId.set(o,t),this._layerViewUidToPopupEnabled.set(o,i),i&&this._layerViewUidToGraphicsUidToObjectId.set(o,r,{objectId:e,attributeNodeId:d,attributeIndex:a,subLayerId:s}))}getObjectAndLayerIdColor(e){const t=this.getObjectAndLayerIdColorArray(e);return r(t.get(0,1),t.get(0,2),t.get(0,3),255)}getObjectAndLayerIdColorArray(e){if(!e.layerViewUid||!e.graphicUid)return this.colorZero;const r=this._layerViewUidToPopupEnabled.get(e.layerViewUid);if(void 0===r)return this.colorZero;if(!1===r)return this.colorZero;const o=this._layerViewUidToGraphicsUidToObjectId.get(e.layerViewUid,e.graphicUid)?.objectId;if(!o)return this.colorZero;let i=this._layerToOidToColor.get(e.layerViewUid,o);if(!i){if(!!has("enable-feature:objectAndLayerId-screenshot-testing"))i=o;else for(;!i;){const e=Math.floor(16777214*Math.random())+1;this._colorToUID.has(e)||(i=e)}if(i>16777215)throw new Error("Object ID Overflow");this._layerToOidToColor.set(e.layerViewUid,o,i),this._colorToUID.set(i,e)}const d=new ArrayBuffer(4);new DataView(d).setUint32(0,i,!1);return new t(d)}getColorToObjectAndLayerIdMapping(){const e=new Map;for(const[r,t]of this._colorToUID.entries()){const o=this._layerViewUidToGraphicsUidToObjectId.get(t.layerViewUid,t.graphicUid),i=this._layerViewUidToLayerId.get(t.layerViewUid);o&&i&&e.set(r,o.attributeNodeId?{type:"object-and-layer-and-i3s-id",olid:o.objectId,lid:i,attrId:o.attributeNodeId,attrIdx:o.attributeIndex,subLayerId:o.subLayerId}:{type:"object-and-layer-id",olid:o.objectId,lid:i})}return e}}export{o as ObjectAndLayerIdRenderHelper};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{generateUID as t}from"../../../../core/uid.js";import{copy as r,multiply as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as e}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{t as s}from"../../../../chunks/vec32.js";import{N as o,c as n,a as h}from"../../../../chunks/sphere.js";import{maxScale as a}from"../../support/mathUtils.js";class g{constructor(r,i={}){this.geometry=r,this.screenToWorldRatio=1,this._transformation=e(),this._shaderTransformation=null,this._boundingSphere=null,this.id=t(),this.layerUid=i.layerUid,this.graphicUid=i.graphicUid,this.castShadow=i.castShadow??!1,i.objectShaderTransformation&&this.objectShaderTransformationChanged(i.objectShaderTransformation)}get transformation(){return this._transformation}set transformation(t){r(this._transformation,t),this._boundingSphere=null}get boundingInfo(){return this.geometry.boundingInfo}objectShaderTransformationChanged(t){null==t?this._shaderTransformation=null:(this._shaderTransformation??=e(),i(this._shaderTransformation,t,this.geometry.transformation)),this._boundingSphere=null}get boundingSphere(){return this.boundingInfo?(null==this._boundingSphere&&(this._boundingSphere??=n(),s(h(this._boundingSphere),this.boundingInfo.center,this.shaderTransformation),this._boundingSphere[3]=this.boundingInfo.radius*a(this.shaderTransformation)),this._boundingSphere):o}get material(){return this.geometry.material}get type(){return this.geometry.type}get shaderTransformation(){return this._shaderTransformation??this.transformation}get attributes(){return this.geometry.attributes}get highlight(){return this.geometry.highlights}foreachHighlightOptions(t){this.geometry.foreachHighlightOptions(t)}get hasHighlights(){return this.geometry.hasHighlights}get occludees(){return this.geometry.occludees}get visible(){return this.geometry.visible}set visible(t){this.geometry.visible=t}}class m extends g{}export{g as RenderGeometry,m as ValidatedRenderGeometry};
5
+ import{generateUID as t}from"../../../../core/uid.js";import{copy as r,multiply as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as e}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{t as s}from"../../../../chunks/vec32.js";import{N as o,c as n,a as h}from"../../../../chunks/sphere.js";import{maxScale as a}from"../../support/mathUtils.js";class g{constructor(r,i={}){this.geometry=r,this.screenToWorldRatio=1,this._transformation=e(),this._shaderTransformation=null,this._boundingSphere=null,this.id=t(),this.layerViewUid=i.layerViewUid,this.graphicUid=i.graphicUid,this.castShadow=i.castShadow??!1,i.objectShaderTransformation&&this.objectShaderTransformationChanged(i.objectShaderTransformation)}get transformation(){return this._transformation}set transformation(t){r(this._transformation,t),this._boundingSphere=null}get boundingInfo(){return this.geometry.boundingInfo}objectShaderTransformationChanged(t){null==t?this._shaderTransformation=null:(this._shaderTransformation??=e(),i(this._shaderTransformation,t,this.geometry.transformation)),this._boundingSphere=null}get boundingSphere(){return this.boundingInfo?(null==this._boundingSphere&&(this._boundingSphere??=n(),s(h(this._boundingSphere),this.boundingInfo.center,this.shaderTransformation),this._boundingSphere[3]=this.boundingInfo.radius*a(this.shaderTransformation)),this._boundingSphere):o}get material(){return this.geometry.material}get type(){return this.geometry.type}get shaderTransformation(){return this._shaderTransformation??this.transformation}get attributes(){return this.geometry.attributes}get highlight(){return this.geometry.highlights}foreachHighlightOptions(t){this.geometry.foreachHighlightOptions(t)}get hasHighlights(){return this.geometry.hasHighlights}get occludees(){return this.geometry.occludees}get visible(){return this.geometry.visible}set visible(t){this.geometry.visible=t}}class m extends g{}export{g as RenderGeometry,m as ValidatedRenderGeometry};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{unitRGBAFromColor as i}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{clamp as s,lerp as a}from"../../../../core/mathUtils.js";import{removeMaybe as n,abortMaybe as h,destroyMaybe as o,releaseMaybe as d}from"../../../../core/maybe.js";import{throwIfAborted as _}from"../../../../core/promiseUtils.js";import{watch as l,syncAndInitial as p,initial as u,sync as m}from"../../../../core/reactiveUtils.js";import{signal as c}from"../../../../core/signal.js";import{Milliseconds as g}from"../../../../core/time.js";import{property as f}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/accessorSupport/interfaces.js";import"../../../../core/accessorSupport/tracking/Flags.js";import"../../../../core/Warning.js";import"../../../../core/Error.js";import{equals as b,invert as T,multiply as E}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as A,create as P}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as R}from"../../../../chunks/vec42.js";import{ZEROS as S}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{fromValues as I,ZEROS as C}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as w}from"../../../../geometry/support/Indices.js";import{RenderCategory as D,InternalRenderCategory as N}from"../../webgl.js";import{debugFlags as O}from"../../support/debugFlags.js";import{DepthFormat as y,ColorFormat as H}from"../../webgl/formats.js";import{FBOCache as x,defaultWebGLFBO as L}from"../core/FBOCache.js";import{RenderPassManager as M}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as U,isColorOrColorEmission as F}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as v}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{distanceFadeEnd as G}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as q}from"../effects/RenderNodes.js";import{RenderPluginManager as V}from"../effects/RenderPluginManager.js";import{Blit as j}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as B,renderHighlightBuffer as Q}from"../effects/highlight/Highlight.js";import{OITBlend as W}from"../effects/transparency/OITBlend.js";import{AnimationTimer as k}from"./AnimationTimer.js";import{AnimationTimeStep as z}from"./AnimationTimeStep.js";import{RenderRequestType as X}from"./basicInterfaces.js";import{BoundingInfo as Y}from"./BoundingInfo.js";import{DepthRange as K}from"./DepthRange.js";import{depthRangeFromScene as J}from"./depthRangeUtils.js";import{hudFragmentOpacityParameters as Z}from"./hudFragmentOpacityParameters.js";import{MainFramebuffer as $}from"./MainFramebuffer.js";import{RenderOccludedFlag as ee}from"./Material.js";import{OITPass as te}from"./OITPass.js";import{RenderContext as re,defaultRenderOccludedMask as ie}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as se,RendererTarget as ae}from"./rendererUtils.js";import{setupFeatureDefaults as ne,RenderFeature as he}from"./RenderFeature.js";import{RenderPluginInput as oe}from"./RenderPluginInput.js";import{RenderSlot as de}from"./RenderSlot.js";import{ShadowAccumulator as _e}from"./ShadowAccumulator.js";import{ShadowMap as le,SnapshotSlot as pe}from"./ShadowMap.js";import ue from"./SliceHelper.js";import{Transparency as me}from"./edgeRendering/interfaces.js";import{MergedRenderer as ce}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as ge}from"../parts/renderUtils.js";import{RendererPerformanceInfo as fe,PerformanceCategory as be}from"../statistics/RendererPerformanceInfo.js";import{RenderState as Te}from"../../../support/RenderState.js";import{PixelFormat as Ee,PixelType as Ae,DepthStencilAttachment as Pe,FramebufferBit as Re,ColorAttachment1 as Se,ColorAttachment2 as Ie}from"../../../webgl/enums.js";class Ce{constructor(e,t,r,s,a,n){this._stage=e,this._techniques=r,this._rctx=s,this._compositingHelper=a,this._requestRender=n,this._pluginsHas={hudElements:!1,water:!1},this._renderers=new Map,this.renderPassManager=new M,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=I(0,0,0,1),this._sliceHelper=new ue,this._blit=null,this._oitblend=null,this._state=c(Te.IDLE),this._highQualityTransparencyEnabled=!0,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new z,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=c(0),this._lastFrameTime=g(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new oe,this._releaseNormals=e=>{e.some((({name:e})=>"normals"===e))&&this._pluginInput.release("normals")},this._debugNeedsDepth=!1,this.fboCache=new x(s),this._renderStateFeatures=c(ne(!has("disable-feature:high-quality-idle"),e.view.qualityProfile)),this._framebuffer=new $(this.fboCache),this.performanceInfo=new fe(this._rctx),this._shadowMap=new le(this.fboCache,e.viewingMode),this._shadowAccumulator=new _e(this.fboCache,r,e,(e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t}),((e,t,r)=>{const i=this._stage.view.qualitySettings.maximumPixelRatio;e.shadowMap.start(e.camera,t,r,!0,i),this._renderShadowCascades(U.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(e.camera,e.contentCamera)}),n),this._renderContext=new re(this._rctx,this._shadowMap,r),this._nodes=new q(this._renderContext),this._plugins=new V({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._handles=[l((()=>this._stage.view.state.camera),(()=>n()),p),l((()=>O.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(me.TRANSPARENT):()=>{},n()}),u),l((()=>this._stage.view.environment.background?.color),(e=>{const t=e?i(e):C;R(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()}),p),l((()=>this._stage.view.state.camera.relativeElevation),(e=>this._inGlobeView=(e??1/0)>=G),p),l((()=>this._bindParameters.clouds.fadeFactor),(()=>this._bindParameters.fadeLighting()),m),l((()=>this._bindParameters.clouds.data?.state),(()=>n()),m),l((()=>this._stage.view.state.highlights),(e=>{this._bindParameters.highlights=e,this._updateHighlights(),n()}),u)]}destroy(){this._handles.forEach((e=>e.remove())),this._gpuTimerHandle=n(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.dispose(),this._loadEdgeViewTask=h(this._loadEdgeViewTask),this._edgeView=o(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),this._plugins.destroy(),this._renderers.clear(),this._blit=null,this._oitblend=null,Y.prune(),ce.prune(),w()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _framebufferSize(){return this._framebuffer.size}updateRenderFeatures(e=null,t=!has("disable-feature:high-quality-idle")){this._renderStateFeatures.value=ne(t,e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate((i=>i.set(t,e,r))),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(he.HighQualityTransparency)}get hasReflections(){return this._pluginsHas.water&&(this._ssrEnabled||this.isFeatureEnabled(he.WaterReflection))}get _hasHighlights(){return this._plugins.produces(U.Highlight,de.OPAQUE_MATERIAL,de.TRANSPARENT_MATERIAL,de.DRAPED_MATERIAL,de.HUD_MATERIAL,de.LABEL_MATERIAL)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(U.Highlight,de.HUD_MATERIAL,de.LABEL_MATERIAL)}get hasSSAO(){return(this._stage.view.qualitySettings.ambientOcclusion||this.isFeatureEnabled(he.SSAO))&&!this._inGlobeView}get hasSMAA(){return this._stage.view.qualitySettings.antialiasingEnabled||this.isFeatureEnabled(he.Antialiasing)}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(he.HighResolutionAtmosphere)}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=d(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.depth=d(this._bindParameters.depth),this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility)}get updating(){return null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=r((async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");_(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:ve(this._stage.view.resourceController)});return this._handles.push(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&&b(this._bindParameters.ssr.reprojectionMatrix,A)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:r}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&t.maxCascades!==e.shadowMapMaxCascades&&(t.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const t="virtual"!==e.environment.lighting.type;r.enableFillLights!==t&&(r.enableFillLights=t,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}set slicePlane(e){this._sliceHelper.plane!==e&&(this._sliceHelper.plane=e,this._requestRender())}get plugins(){return this._plugins}getMaterialRenderer(e){return this._renderers.get(e)}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,t){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:r,removes:i,updates:s}=e;if(0===r.length&&0===i.length&&0===s.length)return;se(e).forEach(((r,i)=>{if(t.done)return;let s=this._renderers.get(i);null==s&&r.adds.length>0&&(s=new ce({material:i,highlightOrderMap:this._stage.view.state.highlightOrderMap}),s.initializeRenderContext(this._plugins.context),this._plugins.add(s),this._renderers.set(i,s)),s&&(s.modify(r),s.updateHighlights(this._stage.view.state.highlightOrderMap),0===s.numGeometries&&(this._renderers.delete(s.material),this._plugins.remove(s),s.destroy())),r.removes.forEach((t=>e.removes.removeUnordered(t))),r.adds.forEach((t=>e.adds.removeUnordered(t))),r.updates.forEach((t=>e.updates.removeUnordered(t))),t.madeProgress()})),this.updateHasFlags()}updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(U.Color,...xe),has.water=this._plugins.produces(U.Normal,de.DRAPED_WATER),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new k(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const r=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?n(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,r=ae.Default,i=!1){try{return this._isRendering=!0,this._render(e,t,r,i)}catch(s){console.error(`Exception during rendering: ${s}`)}finally{this._isRendering=!1}return new ge(this._pluginInput.get(D.FINAL),null)}_updateHUDOccludedFragmentOpacity(e,t){const{idleOpacity:r,navigatingOpacity:i,maxDelta:n,tiltFadeStart:h,tiltFadeEnd:o,altitudeStart:d,altitudeEnd:_}=Z,l=this._stage.view,p=l.stateManager.camera,u=l.qualitySettings.fadeDuration,m=e===Te.IDLE?r:i,c=s((p.tilt-h)/(o-h),0,1),g=s((p.position.z??0-d)/(_-d),0,1),f=a(a(1,m,c),1,g),b=this._bindParameters.hudOccludedFragmentOpacity;if(u<=0||b===f||0===this._lastFrameTime||this._lastFrameTime>t)return this._bindParameters.hudOccludedFragmentOpacity=f,void(this._lastFrameTime=t);const T=t-this._lastFrameTime;this._lastFrameTime=t;const E=Math.min(Math.abs(r-i)*T/u,n);E>=Math.abs(f-b)?this._bindParameters.hudOccludedFragmentOpacity=f:(this._bindParameters.hudOccludedFragmentOpacity=b+Math.sign(f-b)*E,this._requestRender())}_render(e,t,r=ae.Default,i){this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=r===ae.Default,this._disposeBindBuffers();const{camera:s,contentCamera:a,mode:n,alignPixelEnabled:h}=e;this._state.value=n;const o=this._nodes.produces("magnifier-color"),_=this._nodes.produces(D.FINAL),l=this._nodes.require("emissive",D.FINAL,D.COMPOSITE)>0&&this._plugins.hasEmissions,p=l?U.ColorEmission:U.Color;this._renderContext.time=t,this._renderContext.output=p,this._bindParameters.oitPass=te.NONE,this._bindParameters.alignPixelEnabled=h,this._bindParameters.decorations=!i,this._bindParameters.mainDepth=null,this._bindParameters.slicePlane=this._sliceHelper.plane,this._bindParameters.viewshedEnabled=this._nodes.produces(N.VIEWSHED),this._renderOverlay(t),s.setGLViewport(this._rctx);const u=this._framebuffer,m=u.initialize(s.fullWidth,s.fullHeight,this._backgroundColor,l);this.hasReflections?(m?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=m):m?.release(),this._ensureBindParametersCamera(s,a),this._updateHUDOccludedFragmentOpacity(n,t),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!i;const c=this._highQualityTransparency&&this._hasTransparentTerrain,g=this._plugins.produces(U.Color,...ye);this._precompilePrepasses(),this.performanceInfo.advance(be.PREPARE);const f=this._computeDepthRange(s);this._renderShadowMap(s,this._bindParameters.lighting.mainLight.direction,f),this._ensureBindParametersCamera(s,a),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(f,s,a),this._ensureBindParametersSSR(t),this._precompileShaders(c,g,p),this._renderContext.output=p,u.bind(),this._bindParameters.mainDepth=u.depth.attachment;const b=this.plugins.produces(U.Color,...Oe);b&&this._renderOpaqueGeometry(),u.update((e=>this._renderNodes(D.OPAQUE,e,b))),this.fboCache.debugCallback?.(D.OPAQUE,u.color.fbo),u.update((e=>this._renderNodes(N.OPAQUE_ENVIRONMENT,e))),this.fboCache.debugCallback?.(N.OPAQUE_ENVIRONMENT,u.color.fbo),this._renderTerrainDepth(c),this._renderEdges(me.OPAQUE),u.bind(),this._renderPlugins(de.VOXEL,be.VOXEL),this._renderHiddenTransparentEdges(),g&&(this._oitEnabled?this._renderOIT(we.Geometry,p):this._renderTransparentGeometry()),u.update((e=>this._renderNodes(D.TRANSPARENT,e,g))),this.fboCache.debugCallback?.(D.TRANSPARENT,u.color.fbo),this._renderGeometryDepth(c),this._renderHUDVisibility(),c||this._plugins.render(this._pluginInput,de.LINE_CALLOUTS),this._renderEdges(me.TRANSPARENT);const T=this._hasTransparentTerrain?this._renderTransparentTerrain():null;T&&(this.performanceInfo.advance(be.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(c?this._renderLineCallouts(v.Occluded):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositingHelper.compositeHUD(this._bindParameters,T.getTexture())),this._renderHUD(v.Occluded,u.color,p))),this._bindParameters.cullAboveTerrain=!1,T&&(u.bind(),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,T.getTexture()),T.release(),c&&(this._renderEdges(me.OPAQUE),g&&(this._oitEnabled?this._renderOIT(we.Geometry,p):this._renderTransparentGeometry(),this.performanceInfo.advance(be.TRANSPARENT)),this._renderEdges(me.TRANSPARENT))),this._bindParameters.ssao=d(this._bindParameters.ssao),c&&this._renderLineCallouts(v.NotOccluded),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment(),this._pluginInput.set(N.FOCUSAREA,this._renderFocusAreaGeometry()),u.update((e=>this._renderNodes(N.TRANSPARENT_ENVIRONMENT,e))),u.update((e=>this._renderNodes(N.VIEWSHED,e))),u.update((e=>this._renderNodes(N.LASERLINES,e))),u.update((e=>this._renderNodes(N.OCCLUDED,e))),this._pluginInput.set("highlights",this._renderHighlightPrepass());const E=r===ae.ObjectAndLayerID?this._renderObjectAndLayerIdColor():null;u.update((e=>this._renderNodes(D.COMPOSITE,e))),this._pluginInput.release(N.FOCUSAREA);const A=!(r!==ae.Default||_||o&&!i),P=this._pluginInput.get(D.COMPOSITE),R=A?L:this.fboCache.acquire(P.fbo.width,P.fbo.height,N.ANTIALIASING),S=this._nodes.produces(N.ANTIALIASING)?this._renderNodes(N.ANTIALIASING,R):this._blitFBO(P,R,!1);let I;this._pluginInput.set(N.ANTIALIASING,S),this._hasHUDHighlights?(this._renderHUD(v.NotOccluded,S,p),I=this._renderNodes(N.HIGHLIGHTS,S)):(I=this._renderNodes(N.HIGHLIGHTS,S),this._renderHUD(v.NotOccluded,I,p));const C=this._renderNodes(N.MAGNIFIER,I);return o&&!i&&r===ae.Default&&!_&&this._blitFBO(C),_?(C.attachDepth(u.depth),this._blitFBO(this._renderNodes(D.FINAL,C)),C.detachDepth()):this._pluginInput.set(D.FINAL,C),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),u.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),r!==ae.Default&&(this._releaseFBOs(),this._disposeOffscreenBuffers()),new ge(this._pluginInput.get(D.FINAL),E)}_precompileShaders(e,t,r){if(++this._plugins.context.techniques.precompiling,this._renderContext.output=r,this._precompileOpaqueGeometry(),this._nodes.precompile(N.OPAQUE_ENVIRONMENT),this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,this._renderContext.output=U.Depth,this._plugins.precompile(de.TRANSPARENT_TERRAIN),e&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._renderContext.output=r,this._plugins.precompile(de.TRANSPARENT_TERRAIN),t&&(this._precompileTransparentGeometry(),this._hasTransparentTerrain&&(this._bindParameters.cullAboveTerrain=!1,this._precompileTransparentGeometry(),this._bindParameters.cullAboveTerrain=e)),this._nodes.precompile(N.FOCUSAREA),this._needsHUDVisibility&&this._plugins.precompile(de.OCCLUSION_PIXELS),this._plugins.precompile(de.LINE_CALLOUTS),this._precompileHUD(v.Occluded),this._bindParameters.terrainDepthTest=!1,this._bindParameters.cullAboveTerrain=!1,this._nodes.precompile(N.VIEWSHED,N.LASERLINES,N.OCCLUDED,N.ANTIALIASING,N.HIGHLIGHTS),this._precompileHUD(v.NotOccluded),this._hasHighlights){const e=this._bindParameters;e.highlights.forEach(((t,r)=>{e.highlightLevel=r,this._precompileAllGeometry(U.Highlight)})),e.highlightLevel=null}this._nodes.precompile(D.COMPOSITE,N.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(de.TRANSPARENT_MATERIAL_WITHOUT_DEPTH),--this._plugins.context.techniques.precompiling}_updateHighlights(){const e=this._stage.view.state;this._renderers.forEach((t=>t.updateHighlights(e.highlightOrderMap)))}_renderFocusAreaGeometry(){if(!this._nodes.produces(N.FOCUSAREA))return null;const{width:e,height:t}=this._framebufferSize;let r=this.fboCache.acquire(e,t,N.FOCUSAREA);return r=this._nodes.render(r,this._pluginInput),this.performanceInfo.advance(be.FOCUS_AREA_MASK),r}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._renderContext.output;++this._techniques.precompiling;const t=this._framebufferSize;let r=this.fboCache.acquire(t.width,t.height,"olid");return r.acquireDepth(y.DEPTH_STENCIL_TEXTURE),r=this._nodes.render(r,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(be.OBJECT_AND_LAYER_ID_COLOR),this._renderContext.output=e,r}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=e===X.BACKGROUND;if(r||t){const e=r?this.performanceInfo.elapsedTime:0;let i=0;t?i=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const s=Math.max(e,i);this._animationTimestep.frame(s,r)}}readMainDepth(e,t){const{mainDepth:r,camera:i}=this._bindParameters;if(!r)return;const s=this.fboCache.acquire(this._framebufferSize.width,this._framebufferSize.height,"linear-depth");this._rctx.bindFramebuffer(s.fbo),i.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(C),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],Ee.RGBA,Ae.UNSIGNED_BYTE,t),s.release()}readHUDVisibility(e,t,r,i,s){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,i,Ee.RGBA,Ae.UNSIGNED_BYTE,s)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"edges"),s=()=>t.render(this._bindParameters,e),a=this._bindParameters.geometryDepth;this.renderToTargets(s,i,a??this._framebuffer.depth,C),this._framebuffer.bind(),this._compositingHelper.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(e===me.OPAQUE?be.OPAQUE_EDGES:be.TRANSPARENT_EDGES)}_renderOverlay(e){this._bindParameters.overlay=this.overlay?.render(e),this._bindParameters.overlay&&this.performanceInfo.advance(be.OVERLAY)}_renderShadowMap(e,t,r){if(!this.shadowsEnabled)return;const i=this._shadowMap;i.start(e,t,r,this.isFeatureEnabled(he.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(U.ShadowHighlight,this._shadowMap),i.moveSnapshot(pe.Highlight),this._renderShadowCascades(U.ShadowExcludeHighlight,this._shadowMap),i.copySnapshot(pe.ExcludeHighlight),this._renderShadowCascades(U.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(U.Shadow),i.finish(),e.setGLViewport(this._rctx),this.performanceInfo.advance(be.SHADOW_MAP)}_precompileShadowCascades(e){for(const t of this._shadowMap.cascades)t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.camera),this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e)}get _needsDepth(){return this._plugins.consumes(U.Depth)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._needsShadowAccumulation||this._debugNeedsDepth}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");if(e){const t=this._needsDepth?e.getAttachment(Pe):null;t?.retain(),this._pluginInput.set(N.SSAO,this._renderSSAO()),this._renderGeometryWithoutNormalsDepth(t)}else this._renderAllGeometryDepth()}_renderGeometryWithoutNormalsDepth(e){if(!this._needsDepth||!e)return void(this._bindParameters.depth=d(this._bindParameters.depth));const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"depth");r.attachDepth(e),e.release(),this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(Re.STENCIL),this._renderGeometryWithoutNormals(U.Depth),d(this._bindParameters.depth),this._bindParameters.depth=r.obtainDepthTexture(),r.release(),this.performanceInfo.advance(be.DEPTH)}_renderAllGeometryDepth(){if(!this._needsDepth)return void(this._bindParameters.depth=d(this._bindParameters.depth));const e=this._framebufferSize,t=this.fboCache.acquire(e.width,e.height,"depth").acquireDepth(y.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(Re.DEPTH|Re.STENCIL),this.renderAllGeometry(U.Depth),d(this._bindParameters.depth),this._bindParameters.depth=t.obtainDepthTexture(),t.release(),this.performanceInfo.advance(be.DEPTH)}_renderTerrainDepth(e){if(this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,!e)return void(this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth));const t=this._renderContext.output;this._renderContext.output=U.Depth;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"terrain depth").acquireDepth(y.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(i.fbo),this._rctx.clear(Re.DEPTH|Re.STENCIL),this._renderTransparentTerrain(),d(this._bindParameters.terrainDepth),this._bindParameters.terrainDepth=i.obtainDepthTexture(),this._renderContext.output=t,i.release()}_renderGeometryDepth(e){if(!e)return void(this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth));const t=this._renderContext.output,{width:r,height:i}=this._framebufferSize,s=this.fboCache.acquire(r,i,"geometry depth").acquireDepth(y.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(Re.DEPTH|Re.STENCIL),this._renderOpaqueAndTransparentGeometry(U.Depth),this._renderContext.output=t,d(this._bindParameters.geometryDepth),this._bindParameters.geometryDepth=s.obtainDepthTexture(),s.release()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowAccumulation}_computeDepthRange(e){if(!this._needsDepthRange)return K.zero;const t=J(e,this._plugins.plugins,this._stage.layers);return t.union(this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}get _normalsRequired(){const e=this._nodes.require("normals",D.FINAL,D.COMPOSITE,D.OPAQUE,D.TRANSPARENT,N.VIEWSHED,N.LASERLINES);return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(U.Normal),this._needsDepth&&this._precompileAllGeometry(U.Depth),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(U.ShadowHighlight),this._precompileShadowCascades(U.ShadowExcludeHighlight),this._precompileShadowCascades(U.ShadowHighlight)):this._precompileShadowCascades(U.Shadow)),this._needsShadowAccumulation&&this._precompileAllGeometry(U.Shadow)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"normals",H.RGBA);r.acquireDepth(y.DEPTH_STENCIL_TEXTURE),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(C,!0,!0),this._renderGeometryWithNormals(U.Normal);const i=this._nodes.optional("normals",D.FINAL,D.COMPOSITE,D.OPAQUE,D.TRANSPARENT,N.VIEWSHED);return r.retain(e+i-1),this.performanceInfo.advance(be.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return void e?.detachDepth();L.setName(N.SSAO);const t=this._nodes.render(L,this._pluginInput);return this._bindParameters.ssao=t,e.detachDepth(),this._pluginInput.release("normals"),this.performanceInfo.advance(be.SSAO),t}_precompileAllGeometry(e){const t=this._renderContext.output;this._renderContext.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(de.TRANSPARENT_TERRAIN),this._renderContext.output=t}renderAllGeometry(e){this._renderContext.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentTerrain()}precompileSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const r of t)this._renderContext.renderOccludedMask=r,this.precompileSlots(e,...He);this._renderContext.renderOccludedMask=ie}renderSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.forAll((e=>{const t=e.acquireTechniques(this._renderContext);t&&e.render(this._renderContext,t,this._pluginInput)}))}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>ee.Occlude&&this._plugins.render(this._pluginInput,de.OCCLUDED_TERRAIN),this.renderSlots(e,...He),this._renderContext.renderOccludedMask=ie}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(this._pluginInput,de.HUD_MATERIAL)}precompileViewshedShadowMap(){this._precompileAllGeometry(U.ViewshedShadow)}renderViewshedShadowMap(e){const{camera:t,contentCamera:r}=this._bindParameters,i=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(U.ViewshedShadow),this._ensureBindParametersCamera(t,r),this._bindParameters.camera.setGLViewport(this._rctx),this._renderContext.output=i}_renderOpaqueAndTransparentGeometry(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithNormals(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,...De),this._renderTransparentTerrain()}_renderGeometryWithoutNormals(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,...Ne)}_precompileOpaqueGeometry(){this._plugins.precompile(...Oe)}_renderOpaqueGeometry(){this._plugins.render(this._pluginInput,...Oe)}_renderTransparentGeometry(){this._plugins.render(this._pluginInput,...ye)}get _hasTransparentTerrain(){return this._plugins.produces(U.Color,de.TRANSPARENT_TERRAIN)}_renderTransparentTerrain(){const e=()=>this._plugins.render(this._pluginInput,de.TRANSPARENT_TERRAIN);if(!F(this._renderContext.output))return void e();const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"transparent terrain");return this.renderToTargets(e,r,this._framebuffer.depth,C),r}get _needsHUDVisibility(){return this._plugins.produces(this._renderContext.output,de.OCCLUSION_PIXELS)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility));const{width:e,height:t}=this._framebufferSize;let r=this._bindParameters.hudVisibility;r?.fbo?.width===e&&r?.fbo?.height===t||(r?.release(),r=this.fboCache.acquire(e,t,"hud visibility",H.RGBA4),this._bindParameters.hudVisibility=r);const i=this._bindParameters.geometryDepth;r.attachDepth(i||this._framebuffer.depth),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(this._pluginInput,de.OCCLUSION_PIXELS),r.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(be.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===v.Occluded){const e=()=>this._plugins.render(this._pluginInput,de.LINE_CALLOUTS),t=this._framebufferSize,r=this.fboCache.acquireDepth(y.DEPTH16_BUFFER,t.width,t.height,"line callouts");this.renderToTargets(e,this._framebuffer.color,r,void 0,!0,!0),r.release()}else this._plugins.render(this._pluginInput,de.LINE_CALLOUTS)}_precompileHUD(e){if(this._precompileHUDOutput(e),this._hasHighlights){const t=this._renderContext.output;this._renderContext.output=U.Highlight,this._precompileHUDOutput(e),this._renderContext.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this._oitEnabled&&F(this._renderContext.output)?(this._bindParameters.oitPass=te.ColorAlpha,this._plugins.precompile(...xe),this._bindParameters.oitPass=te.FrontFace,this._plugins.precompile(...xe),this._bindParameters.oitPass=te.NONE):this._plugins.precompile(...xe),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t,r){if(this._pluginsHas.hudElements){if(this._oitEnabled){const i=this._renderOIT(we.HUD,r,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,i.getTexture()),i.release()}else if(this._renderContext.output=r,e===v.Occluded){const t=()=>this._renderHUDElements(e),r=this._framebufferSize,i=this.fboCache.acquireDepth(y.DEPTH16_BUFFER,r.width,r.height,"hud");this.renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(y.DEPTH16_BUFFER),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(e===v.Occluded?be.HUD_OCCLUDED:be.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(this._pluginInput,...xe)}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(U.ShadowHighlight,de.OPAQUE_MATERIAL)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:r}=this,i=this._framebufferSize,{highlights:s}=r,a=e.acquire(i.width,i.height,"highlights",s.length>B?H.RG8UI:H.R8UI);a.acquireDepth(y.DEPTH_STENCIL_TEXTURE),t.bindFramebuffer(a.fbo);const{gl:n}=t;return n.clearBufferuiv(n.COLOR,0,[0,0,0,0]),this._renderContext.output=U.Highlight,t.bindFramebuffer(a.fbo),Q(t,e,i,r,(()=>this._renderHighlightGeometries())),this.performanceInfo.advance(be.HIGHLIGHTS),a}_renderHighlightGeometries(){this._plugins.render(this._pluginInput,...Le),this._rctx.clear(Re.DEPTH),this._renderHUDElements(v.Both)}get _needsShadowAccumulation(){return this._shadowAccumulator.accumulating}_renderShadowAccumulation(e,t,r){this._needsShadowAccumulation&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,e,t,r)&&this.performanceInfo.advance(be.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this._oitEnabled&&F(this._renderContext.output)?(this._bindParameters.oitPass=te.ColorAlpha,this._plugins.precompile(...ye),this._bindParameters.oitPass=te.FrontFace,this._plugins.precompile(...ye),this._bindParameters.oitPass=te.NONE):this._plugins.precompile(...ye)}_renderOIT(e,t,r=v.Both){const i=e===we.HUD,s=this._framebufferSize,a=i?this.fboCache.acquire(s.width,s.height,"oit hud composite"):null,n=i?()=>this._renderHUDElements(r):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._renderContext.output;this._renderContext.output=t,h.oitPass=te.ColorAlpha;const d=a?"oit hud color+alpha":"oit color+alpha",_=this.fboCache.acquire(s.width,s.height,d,H.RGBA16F),l=t===U.ColorEmission;l&&_.acquireColor(Se,H.RGBA16F,"emissive"),_.acquireColor(l?Ie:Se,H.R16F),a||_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer([0,0,0,1]),l&&this._rctx.clearBuffer(1,S),n(),_.detachDepth(),h.oitPass=te.FrontFace;const p=this.fboCache.acquire(s.width,s.height,a?"oit hud front":"oit front");return l&&p.acquireColor(Se,H.RGBA16F,"emissive"),a?p.acquireDepth(y.DEPTH16_BUFFER):p.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(p.fbo),this._rctx.clearFramebuffer(C,!!a),n(),p.detachDepth(),h.oitPass=te.NONE,a?(this._rctx.bindFramebuffer(a.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(Re.COLOR)):this._framebuffer.bind(),this._oitblend??=new W(this._techniques),this._oitblend.blend(this._rctx,_,p,h,l),a?.detachDepth(),p.release(),_.release(),this._renderContext.output=o,a}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(be.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(this._pluginInput,de.TRANSPARENT_MATERIAL_WITHOUT_DEPTH),this.performanceInfo.advance(be.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderPlugins(e,t){this._plugins.produces(this._renderContext.output,e)&&(this._plugins.render(this._pluginInput,e),this.performanceInfo.advance(t))}_renderNodes(e,t,r=!1){if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;const i=this._nodes.render(t,this._pluginInput,this._releaseNormals);return this.performanceInfo.advance(e),i}_blitFBO(e,t=L,r=!0){return this._blit??=new j(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=A:(T(Ue,this._bindParameters.camera.viewMatrix),T(Me,this._bindParameters.camera.projectionMatrix),E(Fe,Ue,Me),E(Fe,this._renderContext.lastFrameCamera.viewMatrix,Fe),E(Fe,this._renderContext.lastFrameCamera.projectionMatrix,Fe),this._reprojectionMatrix=Fe);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=A,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(X.UPDATE)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}renderToTargets(e,t,r,i,s=!1,a=!1){t.attachDepth(r),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(i,s,a),e(),t.detachDepth()}get test(){}}var we;e([f({readOnly:!0})],Ce.prototype,"fullResolutionAtmosphere",null),e([f()],Ce.prototype,"_edgeView",void 0),e([f()],Ce.prototype,"updating",null),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(we||(we={}));const De=[de.INTEGRATED_MESH,de.OPAQUE_TERRAIN,de.OPAQUE_MATERIAL,de.TRANSPARENT_MATERIAL],Ne=[de.OPAQUE_MATERIAL_WITHOUT_NORMALS,de.TRANSPARENT_MATERIAL_WITHOUT_NORMALS],Oe=[de.INTEGRATED_MESH,de.OPAQUE_TERRAIN,de.OPAQUE_MATERIAL,de.OPAQUE_MATERIAL_WITHOUT_NORMALS],ye=[de.TRANSPARENT_MATERIAL,de.TRANSPARENT_MATERIAL_WITHOUT_NORMALS],He=[de.OPAQUE_MATERIAL,de.TRANSPARENT_MATERIAL,de.TRANSPARENT_MATERIAL_WITHOUT_DEPTH],xe=[de.LINE_CALLOUTS_HUD_DEPTH,de.HUD_MATERIAL,de.LABEL_MATERIAL],Le=[de.TRANSPARENT_MATERIAL,de.TRANSPARENT_MATERIAL_WITHOUT_NORMALS,de.OPAQUE_MATERIAL,de.OPAQUE_MATERIAL_WITHOUT_NORMALS,de.TRANSPARENT_TERRAIN,de.INTEGRATED_MESH,de.OPAQUE_TERRAIN],Me=P(),Ue=P(),Fe=P();function ve(e){return t=>e.immediate.schedule(t)}export{Ce as Renderer};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{unitRGBAFromColor as i}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{clamp as s,lerp as a}from"../../../../core/mathUtils.js";import{removeMaybe as n,abortMaybe as h,destroyMaybe as o,releaseMaybe as d}from"../../../../core/maybe.js";import{throwIfAborted as _}from"../../../../core/promiseUtils.js";import{watch as l,syncAndInitial as p,initial as u,sync as m}from"../../../../core/reactiveUtils.js";import{signal as c}from"../../../../core/signal.js";import{Milliseconds as g}from"../../../../core/time.js";import{property as f}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/accessorSupport/interfaces.js";import"../../../../core/accessorSupport/tracking/Flags.js";import"../../../../core/Warning.js";import"../../../../core/Error.js";import{equals as b,invert as A,multiply as T}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as E,create as P}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as R}from"../../../../chunks/vec42.js";import{ZEROS as S}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{fromValues as I,ZEROS as C}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as w}from"../../../../geometry/support/Indices.js";import{RenderCategory as O,InternalRenderCategory as D}from"../../webgl.js";import{debugFlags as N}from"../../support/debugFlags.js";import{ColorFormat as y,DepthRenderbuffer16f as x}from"../../webgl/formats.js";import{FBOCache as H,defaultWebGLFBO as M}from"../core/FBOCache.js";import{RenderPassManager as L}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as v,isColorOrColorEmission as U}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as F}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{distanceFadeEnd as G}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as q}from"../effects/RenderNodes.js";import{RenderPluginManager as V}from"../effects/RenderPluginManager.js";import{Blit as j}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as B,renderHighlightBuffer as Q}from"../effects/highlight/Highlight.js";import{OITBlend as W}from"../effects/transparency/OITBlend.js";import{AnimationTimer as k}from"./AnimationTimer.js";import{AnimationTimeStep as z}from"./AnimationTimeStep.js";import{RenderRequestType as Y}from"./basicInterfaces.js";import{BoundingInfo as X}from"./BoundingInfo.js";import{DepthRange as K}from"./DepthRange.js";import{depthRangeFromScene as J}from"./depthRangeUtils.js";import{hudFragmentOpacityParameters as Z}from"./hudFragmentOpacityParameters.js";import{MainFramebuffer as $}from"./MainFramebuffer.js";import{RenderOccludedFlag as ee}from"./Material.js";import{OITPass as te}from"./OITPass.js";import{RenderContext as re,defaultRenderOccludedMask as ie}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as se,RendererTarget as ae}from"./rendererUtils.js";import{setupFeatureDefaults as ne,RenderFeature as he}from"./RenderFeature.js";import{RenderPluginInput as oe}from"./RenderPluginInput.js";import{RenderSlot as de}from"./RenderSlot.js";import{ShadowAccumulator as _e}from"./ShadowAccumulator.js";import{ShadowMap as le,SnapshotSlot as pe}from"./ShadowMap.js";import ue from"./SliceHelper.js";import{Transparency as me}from"./edgeRendering/interfaces.js";import{MergedRenderer as ce}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as ge}from"../parts/renderUtils.js";import{RendererPerformanceInfo as fe,PerformanceCategory as be}from"../statistics/RendererPerformanceInfo.js";import{RenderState as Ae}from"../../../support/RenderState.js";import{DepthStencilAttachment as Te,PixelFormat as Ee,PixelType as Pe,FramebufferBit as Re,ColorAttachment1 as Se,ColorAttachment2 as Ie}from"../../../webgl/enums.js";class Ce{constructor(e,t,r,s,a,n){this._stage=e,this._techniques=r,this._rctx=s,this._compositingHelper=a,this._requestRender=n,this._pluginsHas={hudElements:!1,water:!1},this._renderers=new Map,this.renderPassManager=new L,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=I(0,0,0,1),this._sliceHelper=new ue,this._blit=null,this._oitblend=null,this._state=c(Ae.IDLE),this._highQualityTransparencyEnabled=!0,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new z,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=c(0),this._lastFrameTime=g(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new oe,this._releaseNormals=e=>{e.some((({name:e})=>"normals"===e))&&this._pluginInput.release("normals")},this._debugNeedsDepth=!1,this.fboCache=new H(s),this._renderStateFeatures=c(ne(!has("disable-feature:high-quality-idle"),e.view.qualityProfile)),this._framebuffer=new $(this.fboCache),this.performanceInfo=new fe(this._rctx),this._shadowMap=new le(this.fboCache,e.viewingMode),this._shadowAccumulator=new _e(this.fboCache,r,e,(e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t}),((e,t,r)=>{const i=this._stage.view.qualitySettings.maximumPixelRatio;e.shadowMap.start(e.camera,t,r,!0,i),this._renderShadowCascades(v.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(e.camera,e.contentCamera)}),n),this._renderContext=new re(this._rctx,this._shadowMap,r),this._nodes=new q(this._renderContext),this._plugins=new V({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._handles=[l((()=>this._stage.view.state.camera),(()=>n()),p),l((()=>N.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(me.TRANSPARENT):()=>{},n()}),u),l((()=>this._stage.view.environment.background?.color),(e=>{const t=e?i(e):C;R(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()}),p),l((()=>this._stage.view.state.camera.relativeElevation),(e=>this._inGlobeView=(e??1/0)>=G),p),l((()=>this._bindParameters.clouds.fadeFactor),(()=>this._bindParameters.fadeLighting()),m),l((()=>this._bindParameters.clouds.data?.state),(()=>n()),m),l((()=>this._stage.view.state.highlights),(e=>{this._bindParameters.highlights=e,this._updateHighlights(),n()}),u)]}destroy(){this._handles.forEach((e=>e.remove())),this._gpuTimerHandle=n(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.dispose(),this._loadEdgeViewTask=h(this._loadEdgeViewTask),this._edgeView=o(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),this._plugins.destroy(),this._renderers.clear(),this._blit=null,this._oitblend=null,X.prune(),ce.prune(),w()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _framebufferSize(){return this._framebuffer.size}updateRenderFeatures(e=null,t=!has("disable-feature:high-quality-idle")){this._renderStateFeatures.value=ne(t,e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate((i=>i.set(t,e,r))),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(he.HighQualityTransparency)}get hasReflections(){return this._pluginsHas.water&&(this._ssrEnabled||this.isFeatureEnabled(he.WaterReflection))}get _hasHighlights(){return this._plugins.produces(v.Highlight,de.OPAQUE_MATERIAL,de.TRANSPARENT_MATERIAL,de.DRAPED_MATERIAL,de.HUD_MATERIAL,de.LABEL_MATERIAL)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(v.Highlight,de.HUD_MATERIAL,de.LABEL_MATERIAL)}get hasSSAO(){return(this._stage.view.qualitySettings.ambientOcclusion||this.isFeatureEnabled(he.SSAO))&&!this._inGlobeView}get hasSMAA(){return this._stage.view.qualitySettings.antialiasingEnabled||this.isFeatureEnabled(he.Antialiasing)}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(he.HighResolutionAtmosphere)}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=d(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.depth=d(this._bindParameters.depth),this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility)}get updating(){return null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=r((async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");_(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:Fe(this._stage.view.resourceController)});return this._handles.push(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&&b(this._bindParameters.ssr.reprojectionMatrix,E)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:r}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&t.maxCascades!==e.shadowMapMaxCascades&&(t.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const t="virtual"!==e.environment.lighting.type;r.enableFillLights!==t&&(r.enableFillLights=t,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}set slicePlane(e){this._sliceHelper.plane!==e&&(this._sliceHelper.plane=e,this._requestRender())}get plugins(){return this._plugins}getMaterialRenderer(e){return this._renderers.get(e)}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,t){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:r,removes:i,updates:s}=e;if(0===r.length&&0===i.length&&0===s.length)return;se(e).forEach(((r,i)=>{if(t.done)return;let s=this._renderers.get(i);null==s&&r.adds.length>0&&(s=new ce({material:i,highlightOrderMap:this._stage.view.state.highlightOrderMap}),s.initializeRenderContext(this._plugins.context),this._plugins.add(s),this._renderers.set(i,s)),s&&(s.modify(r),s.updateHighlights(this._stage.view.state.highlightOrderMap),0===s.numGeometries&&(this._renderers.delete(s.material),this._plugins.remove(s),s.destroy())),r.removes.forEach((t=>e.removes.removeUnordered(t))),r.adds.forEach((t=>e.adds.removeUnordered(t))),r.updates.forEach((t=>e.updates.removeUnordered(t))),t.madeProgress()})),this.updateHasFlags()}updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(v.Color,...He),has.water=this._plugins.produces(v.Normal,de.DRAPED_WATER),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new k(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const r=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?n(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,r=ae.Default,i=!1){try{return this._isRendering=!0,this._render(e,t,r,i)}catch(s){console.error(`Exception during rendering: ${s}`)}finally{this._isRendering=!1}return new ge(this._pluginInput.get(O.FINAL),null)}_updateHUDOccludedFragmentOpacity(e,t){const{idleOpacity:r,navigatingOpacity:i,maxDelta:n,tiltFadeStart:h,tiltFadeEnd:o,altitudeStart:d,altitudeEnd:_}=Z,l=this._stage.view,p=l.stateManager.camera,u=l.qualitySettings.fadeDuration,m=e===Ae.IDLE?r:i,c=s((p.tilt-h)/(o-h),0,1),g=s(((p.position.z??0)-d)/(_-d),0,1),f=a(a(1,m,c),1,g),b=this._bindParameters.hudOccludedFragmentOpacity;if(u<=0||b===f||0===this._lastFrameTime||this._lastFrameTime>t)return this._bindParameters.hudOccludedFragmentOpacity=f,void(this._lastFrameTime=t);const A=t-this._lastFrameTime;this._lastFrameTime=t;const T=Math.max(1-r,Math.abs(r-i)),E=Math.min(T*A/u,n);E>=Math.abs(f-b)?this._bindParameters.hudOccludedFragmentOpacity=f:(this._bindParameters.hudOccludedFragmentOpacity=b+Math.sign(f-b)*E,this._requestRender())}_render(e,t,r=ae.Default,i){this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=r===ae.Default,this._disposeBindBuffers();const{camera:s,contentCamera:a,mode:n,alignPixelEnabled:h}=e;this._state.value=n;const o=this._nodes.produces("magnifier-color"),_=this._nodes.produces(O.FINAL),l=this._nodes.require("emissive",O.FINAL,O.COMPOSITE)>0&&this._plugins.hasEmissions,p=l?v.ColorEmission:v.Color;this._renderContext.time=t,this._renderContext.output=p,this._bindParameters.oitPass=te.NONE,this._bindParameters.alignPixelEnabled=h,this._bindParameters.decorations=!i,this._bindParameters.mainDepth=null,this._bindParameters.slicePlane=this._sliceHelper.plane,this._bindParameters.viewshedEnabled=this._nodes.produces(D.VIEWSHED),this._renderOverlay(t),s.setGLViewport(this._rctx);const u=this._framebuffer,m=u.initialize(s.fullWidth,s.fullHeight,this._backgroundColor,l);this.hasReflections?(m?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=m):m?.release(),this._ensureBindParametersCamera(s,a),this._updateHUDOccludedFragmentOpacity(n,t),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!i;const c=this._highQualityTransparency&&this._hasTransparentTerrain,g=this._plugins.produces(v.Color,...ye);this._precompilePrepasses(),this.performanceInfo.advance(be.PREPARE);const f=this._computeDepthRange(s);this._renderShadowMap(s,this._bindParameters.lighting.mainLight.direction,f),this._ensureBindParametersCamera(s,a),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(f,s,a),this._ensureBindParametersSSR(t),this._precompileShaders(c,g,p),this._renderContext.output=p,u.bind(),this._bindParameters.mainDepth=u.depth.attachment;const b=this.plugins.produces(v.Color,...Ne);b&&this._renderOpaqueGeometry(),u.update((e=>this._renderNodes(O.OPAQUE,e,b))),this.fboCache.debugCallback?.(O.OPAQUE,u.color.fbo),u.update((e=>this._renderNodes(D.OPAQUE_ENVIRONMENT,e))),this.fboCache.debugCallback?.(D.OPAQUE_ENVIRONMENT,u.color.fbo),this._renderTerrainDepth(c),this._renderEdges(me.OPAQUE),u.bind(),this._renderPlugins(de.VOXEL,be.VOXEL),this._renderHiddenTransparentEdges(),g&&(this._oitEnabled?this._renderOIT(we.Geometry,p):this._renderTransparentGeometry()),u.update((e=>this._renderNodes(O.TRANSPARENT,e,g))),this.fboCache.debugCallback?.(O.TRANSPARENT,u.color.fbo),this._renderGeometryDepth(c),this._renderHUDVisibility(),c||this._plugins.render(this._pluginInput,de.LINE_CALLOUTS),this._renderEdges(me.TRANSPARENT);const A=this._hasTransparentTerrain?this._renderTransparentTerrain():null;A&&(this.performanceInfo.advance(be.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(c?this._renderLineCallouts(F.Occluded):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositingHelper.compositeHUD(this._bindParameters,A.getTexture())),this._renderHUD(F.Occluded,u.color,p))),this._bindParameters.cullAboveTerrain=!1,A&&(u.bind(),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,A.getTexture()),A.release(),c&&(this._renderEdges(me.OPAQUE),g&&(this._oitEnabled?this._renderOIT(we.Geometry,p):this._renderTransparentGeometry(),this.performanceInfo.advance(be.TRANSPARENT)),this._renderEdges(me.TRANSPARENT))),this._bindParameters.ssao=d(this._bindParameters.ssao),c&&this._renderLineCallouts(F.NotOccluded),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment(),this._pluginInput.set(D.FOCUSAREA,this._renderFocusAreaGeometry()),u.update((e=>this._renderNodes(D.TRANSPARENT_ENVIRONMENT,e))),u.update((e=>this._renderNodes(D.VIEWSHED,e))),u.update((e=>this._renderNodes(D.LASERLINES,e))),u.update((e=>this._renderNodes(D.FOCUSAREA_COLOR,e))),u.update((e=>this._renderNodes(D.OCCLUDED,e))),this._pluginInput.set("highlights",this._renderHighlightPrepass());const T=r===ae.ObjectAndLayerID?this._renderObjectAndLayerIdColor():null;u.update((e=>this._renderNodes(O.COMPOSITE,e))),this._pluginInput.release(D.FOCUSAREA);const E=!(r!==ae.Default||_||o&&!i),P=this._pluginInput.get(O.COMPOSITE),R=E?M:this.fboCache.acquire(P.fbo.width,P.fbo.height,D.ANTIALIASING),S=this._nodes.produces(D.ANTIALIASING)?this._renderNodes(D.ANTIALIASING,R):this._blitFBO(P,R,!1);let I;this._pluginInput.set(D.ANTIALIASING,S),this._hasHUDHighlights?(this._renderHUD(F.NotOccluded,S,p),I=this._renderNodes(D.HIGHLIGHTS,S)):(I=this._renderNodes(D.HIGHLIGHTS,S),this._renderHUD(F.NotOccluded,I,p));const C=this._renderNodes(D.MAGNIFIER,I);return o&&!i&&r===ae.Default&&!_&&this._blitFBO(C),_?(C.attachDepth(u.depth),this._blitFBO(this._renderNodes(O.FINAL,C)),C.detachDepth()):this._pluginInput.set(O.FINAL,C),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),u.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),r!==ae.Default&&(this._releaseFBOs(),this._disposeOffscreenBuffers()),new ge(this._pluginInput.get(O.FINAL),T)}_precompileShaders(e,t,r){if(++this._plugins.context.techniques.precompiling,this._renderContext.output=r,this._precompileOpaqueGeometry(),this._nodes.precompile(D.OPAQUE_ENVIRONMENT),this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,this._renderContext.output=v.Depth,this._plugins.precompile(de.TRANSPARENT_TERRAIN),e&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._renderContext.output=r,this._plugins.precompile(de.TRANSPARENT_TERRAIN),t&&(this._precompileTransparentGeometry(),this._hasTransparentTerrain&&(this._bindParameters.cullAboveTerrain=!1,this._precompileTransparentGeometry(),this._bindParameters.cullAboveTerrain=e)),this._nodes.precompile(D.FOCUSAREA),this._needsHUDVisibility&&this._plugins.precompile(de.OCCLUSION_PIXELS),this._plugins.precompile(de.LINE_CALLOUTS),this._precompileHUD(F.Occluded),this._bindParameters.terrainDepthTest=!1,this._bindParameters.cullAboveTerrain=!1,this._nodes.precompile(D.VIEWSHED,D.LASERLINES,D.FOCUSAREA_COLOR,D.OCCLUDED,D.ANTIALIASING,D.HIGHLIGHTS),this._precompileHUD(F.NotOccluded),this._hasHighlights){const e=this._bindParameters;e.highlights.forEach(((t,r)=>{e.highlightLevel=r,this._precompileAllGeometry(v.Highlight)})),e.highlightLevel=null}this._nodes.precompile(O.COMPOSITE,D.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(de.TRANSPARENT_MATERIAL_WITHOUT_DEPTH),--this._plugins.context.techniques.precompiling}_updateHighlights(){const e=this._stage.view.state;this._renderers.forEach((t=>t.updateHighlights(e.highlightOrderMap)))}_renderFocusAreaGeometry(){if(!this._nodes.produces(D.FOCUSAREA))return null;const{width:e,height:t}=this._framebufferSize;let r=this.fboCache.acquire(e,t,D.FOCUSAREA);return r=this._nodes.render(r,this._pluginInput),this.performanceInfo.advance(be.FOCUS_AREA_MASK),r}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._renderContext.output;++this._techniques.precompiling;const t=this._framebufferSize;let r=this.fboCache.acquire(t.width,t.height,"olid");return r.acquireDepth(Te),r=this._nodes.render(r,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(be.OBJECT_AND_LAYER_ID_COLOR),this._renderContext.output=e,r}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=e===Y.BACKGROUND;if(r||t){const e=r?this.performanceInfo.elapsedTime:0;let i=0;t?i=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const s=Math.max(e,i);this._animationTimestep.frame(s,r)}}readMainDepth(e,t){const{mainDepth:r,camera:i}=this._bindParameters;if(!r)return;const s=this.fboCache.acquire(this._framebufferSize.width,this._framebufferSize.height,"linear-depth");this._rctx.bindFramebuffer(s.fbo),i.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(C),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],Ee.RGBA,Pe.UNSIGNED_BYTE,t),s.release()}readHUDVisibility(e,t,r,i,s){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,i,Ee.RGBA,Pe.UNSIGNED_BYTE,s)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"edges"),s=()=>t.render(this._bindParameters,e),a=this._bindParameters.geometryDepth;this.renderToTargets(s,i,a??this._framebuffer.depth,C),this._framebuffer.bind(),this._compositingHelper.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(e===me.OPAQUE?be.OPAQUE_EDGES:be.TRANSPARENT_EDGES)}_renderOverlay(e){this._bindParameters.overlay=this.overlay?.render(e),this._bindParameters.overlay&&this.performanceInfo.advance(be.OVERLAY)}_renderShadowMap(e,t,r){if(!this.shadowsEnabled)return;const i=this._shadowMap;i.start(e,t,r,this.isFeatureEnabled(he.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(v.ShadowHighlight,this._shadowMap),i.moveSnapshot(pe.Highlight),this._renderShadowCascades(v.ShadowExcludeHighlight,this._shadowMap),i.copySnapshot(pe.ExcludeHighlight),this._renderShadowCascades(v.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(v.Shadow),i.finish(),e.setGLViewport(this._rctx),this.performanceInfo.advance(be.SHADOW_MAP)}_precompileShadowCascades(e){for(const t of this._shadowMap.cascades)t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.camera),this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e)}get _needsDepth(){return this._plugins.consumes(v.Depth)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._needsShadowAccumulation||this._debugNeedsDepth}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");if(e){const t=this._needsDepth?e.getAttachment(Te):null;t?.retain(),this._pluginInput.set(D.SSAO,this._renderSSAO()),this._renderGeometryWithoutNormalsDepth(t)}else this._renderAllGeometryDepth()}_renderGeometryWithoutNormalsDepth(e){if(!this._needsDepth||!e)return void(this._bindParameters.depth=d(this._bindParameters.depth));const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"depth");r.attachDepth(e),e.release(),this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(Re.STENCIL),this._renderGeometryWithoutNormals(v.Depth),d(this._bindParameters.depth),this._bindParameters.depth=r.obtainDepthTexture(),r.release(),this.performanceInfo.advance(be.DEPTH)}_renderAllGeometryDepth(){if(!this._needsDepth)return void(this._bindParameters.depth=d(this._bindParameters.depth));const e=this._framebufferSize,t=this.fboCache.acquire(e.width,e.height,"depth").acquireDepth(Te);this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(Re.DEPTH|Re.STENCIL),this.renderAllGeometry(v.Depth),d(this._bindParameters.depth),this._bindParameters.depth=t.obtainDepthTexture(),t.release(),this.performanceInfo.advance(be.DEPTH)}_renderTerrainDepth(e){if(this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,!e)return void(this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth));const t=this._renderContext.output;this._renderContext.output=v.Depth;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"terrain depth").acquireDepth(Te);this._rctx.bindFramebuffer(i.fbo),this._rctx.clear(Re.DEPTH|Re.STENCIL),this._renderTransparentTerrain(),d(this._bindParameters.terrainDepth),this._bindParameters.terrainDepth=i.obtainDepthTexture(),this._renderContext.output=t,i.release()}_renderGeometryDepth(e){if(!e)return void(this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth));const t=this._renderContext.output,{width:r,height:i}=this._framebufferSize,s=this.fboCache.acquire(r,i,"geometry depth").acquireDepth(Te);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(Re.DEPTH|Re.STENCIL),this._renderOpaqueAndTransparentGeometry(v.Depth),this._renderContext.output=t,d(this._bindParameters.geometryDepth),this._bindParameters.geometryDepth=s.obtainDepthTexture(),s.release()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowAccumulation}_computeDepthRange(e){if(!this._needsDepthRange)return K.zero;const t=J(e,this._plugins.plugins,this._stage.layers);return t.union(this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}get _normalsRequired(){const e=this._nodes.require("normals",O.FINAL,O.COMPOSITE,O.OPAQUE,O.TRANSPARENT,D.VIEWSHED,D.LASERLINES);return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(v.Normal),this._needsDepth&&this._precompileAllGeometry(v.Depth),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(v.ShadowHighlight),this._precompileShadowCascades(v.ShadowExcludeHighlight),this._precompileShadowCascades(v.ShadowHighlight)):this._precompileShadowCascades(v.Shadow)),this._needsShadowAccumulation&&this._precompileAllGeometry(v.Shadow)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"normals",y.RGBA8);r.acquireDepth(Te),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(C,!0,!0),this._renderGeometryWithNormals(v.Normal);const i=this._nodes.optional("normals",O.FINAL,O.COMPOSITE,O.OPAQUE,O.TRANSPARENT,D.VIEWSHED);return r.retain(e+i-1),this.performanceInfo.advance(be.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return void e?.detachDepth();M.setName(D.SSAO);const t=this._nodes.render(M,this._pluginInput);return this._bindParameters.ssao=t,e.detachDepth(),this._pluginInput.release("normals"),this.performanceInfo.advance(be.SSAO),t}_precompileAllGeometry(e){const t=this._renderContext.output;this._renderContext.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(de.TRANSPARENT_TERRAIN),this._renderContext.output=t}renderAllGeometry(e){this._renderContext.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentTerrain()}precompileSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const r of t)this._renderContext.renderOccludedMask=r,this.precompileSlots(e,...xe);this._renderContext.renderOccludedMask=ie}renderSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.forAll((e=>{const t=e.acquireTechniques(this._renderContext);t&&e.render(this._renderContext,t,this._pluginInput)}))}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>ee.Occlude&&this._plugins.render(this._pluginInput,de.OCCLUDED_TERRAIN),this.renderSlots(e,...xe),this._renderContext.renderOccludedMask=ie}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(this._pluginInput,de.HUD_MATERIAL)}precompileViewshedShadowMap(){this._precompileAllGeometry(v.ViewshedShadow)}renderViewshedShadowMap(e){const{camera:t,contentCamera:r}=this._bindParameters,i=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(v.ViewshedShadow),this._ensureBindParametersCamera(t,r),this._bindParameters.camera.setGLViewport(this._rctx),this._renderContext.output=i}_renderOpaqueAndTransparentGeometry(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithNormals(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,...Oe),this._renderTransparentTerrain()}_renderGeometryWithoutNormals(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,...De)}_precompileOpaqueGeometry(){this._plugins.precompile(...Ne)}_renderOpaqueGeometry(){this._plugins.render(this._pluginInput,...Ne)}_renderTransparentGeometry(){this._plugins.render(this._pluginInput,...ye)}get _hasTransparentTerrain(){return this._plugins.produces(v.Color,de.TRANSPARENT_TERRAIN)}_renderTransparentTerrain(){const e=()=>this._plugins.render(this._pluginInput,de.TRANSPARENT_TERRAIN);if(!U(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,C),r}get _needsHUDVisibility(){return this._plugins.produces(this._renderContext.output,de.OCCLUSION_PIXELS)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility));const{width:e,height:t}=this._framebufferSize;let r=this._bindParameters.hudVisibility;r?.fbo?.width===e&&r?.fbo?.height===t||(r?.release(),r=this.fboCache.acquire(e,t,"hud visibility",y.RGBA4),this._bindParameters.hudVisibility=r);const i=this._bindParameters.geometryDepth;r.attachDepth(i||this._framebuffer.depth),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(this._pluginInput,de.OCCLUSION_PIXELS),r.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(be.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===F.Occluded){const e=()=>this._plugins.render(this._pluginInput,de.LINE_CALLOUTS),t=this._framebufferSize,r=this.fboCache.acquireDepth(x,t.width,t.height,"line callouts");this.renderToTargets(e,this._framebuffer.color,r,void 0,!0,!0),r.release()}else this._plugins.render(this._pluginInput,de.LINE_CALLOUTS)}_precompileHUD(e){if(this._precompileHUDOutput(e),this._hasHighlights){const t=this._renderContext.output;this._renderContext.output=v.Highlight,this._precompileHUDOutput(e),this._renderContext.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this._oitEnabled&&U(this._renderContext.output)?(this._bindParameters.oitPass=te.ColorAlpha,this._plugins.precompile(...He),this._bindParameters.oitPass=te.FrontFace,this._plugins.precompile(...He),this._bindParameters.oitPass=te.NONE):this._plugins.precompile(...He),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t,r){if(this._pluginsHas.hudElements){if(this._oitEnabled){const i=this._renderOIT(we.HUD,r,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,i.getTexture()),i.release()}else if(this._renderContext.output=r,e===F.Occluded){const t=()=>this._renderHUDElements(e),r=this._framebufferSize,i=this.fboCache.acquireDepth(x,r.width,r.height,"hud");this.renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(x),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(e===F.Occluded?be.HUD_OCCLUDED:be.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(this._pluginInput,...He)}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(v.ShadowHighlight,de.OPAQUE_MATERIAL)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:r}=this,i=this._framebufferSize,{highlights:s}=r,a=e.acquire(i.width,i.height,"highlights",s.length>B?y.RG8UI:y.R8UI);a.acquireDepth(Te),t.bindFramebuffer(a.fbo);const{gl:n}=t;return n.clearBufferuiv(n.COLOR,0,[0,0,0,0]),this._renderContext.output=v.Highlight,t.bindFramebuffer(a.fbo),Q(t,e,i,r,(()=>this._renderHighlightGeometries())),this.performanceInfo.advance(be.HIGHLIGHTS),a}_renderHighlightGeometries(){this._plugins.render(this._pluginInput,...Me),this._rctx.clear(Re.DEPTH),this._renderHUDElements(F.Both)}get _needsShadowAccumulation(){return this._shadowAccumulator.accumulating}_renderShadowAccumulation(e,t,r){this._needsShadowAccumulation&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,e,t,r)&&this.performanceInfo.advance(be.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this._oitEnabled&&U(this._renderContext.output)?(this._bindParameters.oitPass=te.ColorAlpha,this._plugins.precompile(...ye),this._bindParameters.oitPass=te.FrontFace,this._plugins.precompile(...ye),this._bindParameters.oitPass=te.NONE):this._plugins.precompile(...ye)}_renderOIT(e,t,r=F.Both){const i=e===we.HUD,s=this._framebufferSize,a=i?this.fboCache.acquire(s.width,s.height,"oit hud composite"):null,n=i?()=>this._renderHUDElements(r):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._renderContext.output;this._renderContext.output=t,h.oitPass=te.ColorAlpha;const d=a?"oit hud color+alpha":"oit color+alpha",_=this.fboCache.acquire(s.width,s.height,d,y.RGBA16F),l=t===v.ColorEmission;l&&_.acquireColor(Se,y.RGBA16F,"emissive"),_.acquireColor(l?Ie:Se,y.R16F),a||_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer([0,0,0,1]),l&&this._rctx.clearBuffer(1,S),n(),_.detachDepth(),h.oitPass=te.FrontFace;const p=this.fboCache.acquire(s.width,s.height,a?"oit hud front":"oit front");return l&&p.acquireColor(Se,y.RGBA16F,"emissive"),a?p.acquireDepth(x):p.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(p.fbo),this._rctx.clearFramebuffer(C,!!a),n(),p.detachDepth(),h.oitPass=te.NONE,a?(this._rctx.bindFramebuffer(a.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(Re.COLOR)):this._framebuffer.bind(),this._oitblend??=new W(this._techniques),this._oitblend.blend(this._rctx,_,p,h,l),a?.detachDepth(),p.release(),_.release(),this._renderContext.output=o,a}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(be.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(this._pluginInput,de.TRANSPARENT_MATERIAL_WITHOUT_DEPTH),this.performanceInfo.advance(be.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderPlugins(e,t){this._plugins.produces(this._renderContext.output,e)&&(this._plugins.render(this._pluginInput,e),this.performanceInfo.advance(t))}_renderNodes(e,t,r=!1){if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;const i=this._nodes.render(t,this._pluginInput,this._releaseNormals);return this.performanceInfo.advance(e),i}_blitFBO(e,t=M,r=!0){return this._blit??=new j(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=E:(A(ve,this._bindParameters.camera.viewMatrix),A(Le,this._bindParameters.camera.projectionMatrix),T(Ue,ve,Le),T(Ue,this._renderContext.lastFrameCamera.viewMatrix,Ue),T(Ue,this._renderContext.lastFrameCamera.projectionMatrix,Ue),this._reprojectionMatrix=Ue);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=E,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(Y.UPDATE)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}renderToTargets(e,t,r,i,s=!1,a=!1){t.attachDepth(r),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(i,s,a),e(),t.detachDepth()}get test(){}}var we;e([f({readOnly:!0})],Ce.prototype,"fullResolutionAtmosphere",null),e([f()],Ce.prototype,"_edgeView",void 0),e([f()],Ce.prototype,"updating",null),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(we||(we={}));const Oe=[de.INTEGRATED_MESH,de.OPAQUE_TERRAIN,de.OPAQUE_MATERIAL,de.TRANSPARENT_MATERIAL],De=[de.OPAQUE_MATERIAL_WITHOUT_NORMALS,de.TRANSPARENT_MATERIAL_WITHOUT_NORMALS],Ne=[de.INTEGRATED_MESH,de.OPAQUE_TERRAIN,de.OPAQUE_MATERIAL,de.OPAQUE_MATERIAL_WITHOUT_NORMALS],ye=[de.TRANSPARENT_MATERIAL,de.TRANSPARENT_MATERIAL_WITHOUT_NORMALS],xe=[de.OPAQUE_MATERIAL,de.TRANSPARENT_MATERIAL,de.TRANSPARENT_MATERIAL_WITHOUT_DEPTH],He=[de.LINE_CALLOUTS_HUD_DEPTH,de.HUD_MATERIAL,de.LABEL_MATERIAL],Me=[de.TRANSPARENT_MATERIAL,de.TRANSPARENT_MATERIAL_WITHOUT_NORMALS,de.OPAQUE_MATERIAL,de.OPAQUE_MATERIAL_WITHOUT_NORMALS,de.TRANSPARENT_TERRAIN,de.INTEGRATED_MESH,de.OPAQUE_TERRAIN],Le=P(),ve=P(),Ue=P();function Fe(e){return t=>e.immediate.schedule(t)}export{Ce as Renderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import{clamp as t,lerp as s,acosClamped as e}from"../../../../core/mathUtils.js";import{releaseMaybe as i}from"../../../../core/maybe.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as r,multiply as h,invert as o,lookAt as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as c,create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as d,add as m,scale as u,lerp as _,squaredDistance as f,subtract as g,dot as p,negate as x,normalize as b,copy as w}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as M}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{p as C,c as j,v as T,t as y,i as D}from"../../../../chunks/vec32.js";import{create as H}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as v,t as S}from"../../../../chunks/vec42.js";import{create as R}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ViewingMode as O}from"../../../ViewingMode.js";import{ColorFormat as E,DepthFormat as U}from"../../webgl/formats.js";import{CascadeCamera as F}from"./CascadeCamera.js";import{applyTextureResizeModulo as L}from"./textureUtils.js";import{assert as Q,logWithBase as V,verify as N,rayRay2D as A}from"./Util.js";import{TextureType as B,FramebufferBit as I}from"../../../webgl/enums.js";import{Texture as W}from"../../../webgl/Texture.js";var z;!function(t){t[t.Highlight=0]="Highlight",t[t.ExcludeHighlight=1]="ExcludeHighlight"}(z||(z={}));class P{constructor(){this.camera=new F,this.lightMat=l()}}class q{constructor(){this.maxNumCascadesHighQuality=4,this.maxNumCascadesLowQuality=4,this.textureSizeModHighQuality=1.3,this.textureSizeModLowQuality=.9,this.splitSchemeLambda=0}}class G{constructor(t,s){this._fbos=t,this._viewingMode=s,this._enabled=!1,this._snapshots=new Array,this._textureHeight=0,this._numCascades=1,this.settings=new q,this._projectionView=l(),this._projectionViewInverse=l(),this._modelViewLight=l(),this._cascadeDistances=[0,0,0,0,0],this._usedCascadeDistances=R(),this._cascades=[new P,new P,new P,new P],this._lastOrigin=null,this._maxTextureWidth=Math.min(has("esri-mobile")?4096:16384,t.rctx.parameters.maxTextureSize)}dispose(){this.enabled=!1,this.disposeOffscreenBuffers()}get depthTexture(){return this._handle?.getTexture()}get _textureWidth(){return this._textureHeight*this._numCascades}get numCascades(){return this._numCascades}get cascadeDistances(){return v(this._usedCascadeDistances,this._cascadeDistances[0],this._numCascades>1?this._cascadeDistances[1]:1/0,this._numCascades>2?this._cascadeDistances[2]:1/0,this._numCascades>3?this._cascadeDistances[3]:1/0)}disposeOffscreenBuffers(){this._handle=i(this._handle),this._discardSnapshots()}set maxCascades(s){this.settings.maxNumCascadesHighQuality=t(Math.floor(s),1,4)}get maxCascades(){return this.settings.maxNumCascadesHighQuality}set enabled(t){this._enabled=t,t||this.disposeOffscreenBuffers()}get enabled(){return this._enabled}get ready(){return this._enabled&&null!=this.depthTexture}get cascades(){for(let t=0;t<this._numCascades;++t)et[t]=this._cascades[t];return et.length=this._numCascades,et}start(t,s,e,i,a){Q(this.enabled);const{near:r,far:h}=jt(e);this._computeCascadeDistances(r,h,i),this._textureHeight=this._computeTextureHeight(t,a,i),this._setupMatrices(t,s);const{viewMatrix:o,projectionMatrix:n}=t;for(let c=0;c<this._numCascades;++c)this._constructCascade(c,n,o,s);this._lastOrigin=null,this.clear()}finish(){Q(this.enabled),this._handle?.detachDepth()}getShadowMapMatrices(t){if(!this._lastOrigin||!C(t,this._lastOrigin)){this._lastOrigin=this._lastOrigin||H(),j(this._lastOrigin,t);for(let s=0;s<this._numCascades;++s){r(it,this._cascades[s].lightMat,t);for(let t=0;t<16;++t)at[16*s+t]=it[t]}}return at}moveSnapshot(t){Q(this.enabled),this._handle?.detachDepth(),this._snapshots[t]?.release(),this._snapshots[t]=this._handle,this._handle=null,this.clear()}copySnapshot(t){const s=this._handle?.getTexture()?.descriptor;if(!this.enabled||!s)return;this._snapshots[t]?.release();const{width:e,height:i}=s,a=t===z.Highlight?"shadow highlight snapshot":"shadow no highlight snapshot";this._snapshots[t]=this._fbos.acquire(e,i,a,E.RGBA4);const r=this._fbos.rctx;this._bindFbo();const h=r.bindTexture(this._snapshots[t]?.getTexture(),W.TEXTURE_UNIT_FOR_UPDATES);r.gl.copyTexSubImage2D(B.TEXTURE_2D,0,0,0,0,0,e,i),r.bindTexture(h,W.TEXTURE_UNIT_FOR_UPDATES)}getSnapshot(t){return this.enabled?this._snapshots[t]?.getTexture():null}clear(){const t=this._fbos.rctx;this._ensureFbo(),this._bindFbo(),t.setClearColor(1,1,1,1),t.clear(I.COLOR|I.DEPTH)}_computeTextureHeight({pixelRatio:t,fullWidth:s,fullHeight:e},i,a){const r=Math.min(window.devicePixelRatio,i)/t,h=a?this.settings.textureSizeModHighQuality:this.settings.textureSizeModLowQuality;return L(Math.max(s,e)*r*h,this._maxTextureWidth/this._numCascades)}_ensureFbo(){this._handle?.fbo?.width===this._textureWidth&&this._handle?.fbo.height===this._textureHeight||(this._handle?.release(),this._handle=this._fbos.acquire(this._textureWidth,this._textureHeight,"shadow map",E.RGBA4)),this._handle?.acquireDepth(U.DEPTH16_BUFFER)}_discardSnapshot(t){this._snapshots[t]=i(this._snapshots[t])}_discardSnapshots(){for(let t=0;t<this._snapshots.length;++t)this._discardSnapshot(t);this._snapshots.length=0}_bindFbo(){this._fbos.rctx.bindFramebuffer(this._handle?.fbo)}_constructCascade(t,s,e,i){const a=this._cascades[t],o=-this._cascadeDistances[t],n=-this._cascadeDistances[t+1],c=(s[10]*o+s[14])/Math.abs(s[11]*o+s[15]),l=(s[10]*n+s[14])/Math.abs(s[11]*n+s[15]);Q(c<l);for(let r=0;r<8;++r){v(k,r%4==0||r%4==3?-1:1,r%4==0||r%4==1?-1:1,r<4?c:l,1);const t=J[r];S(t,k,this._projectionViewInverse),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3]}T(st,J[0]),a.camera.viewMatrix=r(X,this._modelViewLight,st);for(let r=0;r<8;++r)y(J[r],J[r],a.camera.viewMatrix);let d=J[0][2],m=J[0][2];for(let r=1;r<8;++r)d=Math.min(d,J[r][2]),m=Math.max(m,J[r][2]);d-=200,m+=200,a.camera.near=-m,a.camera.far=-d,Ct(e,i,d,m,a.camera),h(a.lightMat,a.camera.projectionMatrix,a.camera.viewMatrix);const u=this._textureHeight;a.camera.viewport=[t*u,0,u,u]}_setupMatrices(t,s){h(this._projectionView,t.projectionMatrix,t.viewMatrix),o(this._projectionViewInverse,this._projectionView);const e=this._viewingMode===O.Global?t.eye:D(st,0,0,1);n(this._modelViewLight,[0,0,0],[-s[0],-s[1],-s[2]],e)}_computeCascadeDistances(t,e,i){const a=i?this.settings.maxNumCascadesHighQuality:this.settings.maxNumCascadesLowQuality;this._numCascades=Math.min(1+Math.floor(V(e/t,4)),a);const r=(e-t)/this._numCascades,h=(e/t)**(1/this._numCascades);let o=t,n=t;for(let c=0;c<this._numCascades+1;++c)this._cascadeDistances[c]=s(o,n,this.settings.splitSchemeLambda),o*=h,n+=r}get test(){}}const X=l(),k=R(),J=[];for(let Tt=0;Tt<8;++Tt)J.push(R());const K=M(),Y=M(),Z=M(),$=M(),tt=M(),st=H(),et=[],it=l(),at=c.concat(c,c,c,c),rt=M(),ht=M(),ot=[M(),M(),M(),M()],nt=M(),ct=M(),lt=M(),dt=M(),mt=M(),ut=M(),_t=M();function ft(t,s,e,i,a,r,h,o){d(rt,0,0);for(let d=0;d<4;++d)m(rt,rt,t[d]);u(rt,rt,.25),d(ht,0,0);for(let d=4;d<8;++d)m(ht,ht,t[d]);u(ht,ht,.25),_(ot[0],t[4],t[5],.5),_(ot[1],t[5],t[6],.5),_(ot[2],t[6],t[7],.5),_(ot[3],t[7],t[4],.5);let n=0,c=f(ot[0],rt);for(let d=1;d<4;++d){const t=f(ot[d],rt);t<c&&(c=t,n=d)}g(nt,ot[n],t[n+4]);const l=nt[0];let M,C;nt[0]=-nt[1],nt[1]=l,g(ct,ht,rt),p(ct,nt)<0&&x(nt,nt),_(nt,nt,ct,e),b(nt,nt),M=C=p(g(lt,t[0],rt),nt);for(let d=1;d<8;++d){const s=p(g(lt,t[d],rt),nt);s<M?M=s:s>C&&(C=s)}w(i,rt),u(lt,nt,M-s),m(i,i,lt);let j=-1,T=1,y=0,D=0;for(let d=0;d<8;++d){g(dt,t[d],i),b(dt,dt);const s=nt[0]*dt[1]-nt[1]*dt[0];s>0?s>j&&(j=s,y=d):s<T&&(T=s,D=d)}N(j>0,"leftArea"),N(T<0,"rightArea"),u(mt,nt,M),m(mt,mt,rt),u(ut,nt,C),m(ut,ut,rt),_t[0]=-nt[1],_t[1]=nt[0];const H=A(i,t[D],ut,m(lt,ut,_t),1,a),v=A(i,t[y],ut,lt,1,r),S=A(i,t[y],mt,m(lt,mt,_t),1,h),R=A(i,t[D],mt,lt,1,o);N(H,"rayRay"),N(v,"rayRay"),N(S,"rayRay"),N(R,"rayRay")}function gt(t,s){return 3*s+t}const pt=M();function xt(t,s){return d(pt,t[s],t[s+3]),pt}const bt=M(),wt=a();function Mt(t,s,e,i,a){g(bt,e,i),u(bt,bt,.5),wt[0]=bt[0],wt[1]=bt[1],wt[2]=0,wt[3]=bt[1],wt[4]=-bt[0],wt[5]=0,wt[6]=bt[0]*bt[0]+bt[1]*bt[1],wt[7]=bt[0]*bt[1]-bt[1]*bt[0],wt[8]=1,wt[gt(0,2)]=-p(xt(wt,0),t),wt[gt(1,2)]=-p(xt(wt,1),t);let r=p(xt(wt,0),e)+wt[gt(0,2)],h=p(xt(wt,1),e)+wt[gt(1,2)],o=p(xt(wt,0),i)+wt[gt(0,2)],n=p(xt(wt,1),i)+wt[gt(1,2)];r=-(r+o)/(h+n),wt[gt(0,0)]+=wt[gt(1,0)]*r,wt[gt(0,1)]+=wt[gt(1,1)]*r,wt[gt(0,2)]+=wt[gt(1,2)]*r,r=1/(p(xt(wt,0),e)+wt[gt(0,2)]),h=1/(p(xt(wt,1),e)+wt[gt(1,2)]),wt[gt(0,0)]*=r,wt[gt(0,1)]*=r,wt[gt(0,2)]*=r,wt[gt(1,0)]*=h,wt[gt(1,1)]*=h,wt[gt(1,2)]*=h,wt[gt(2,0)]=wt[gt(1,0)],wt[gt(2,1)]=wt[gt(1,1)],wt[gt(2,2)]=wt[gt(1,2)],wt[gt(1,2)]+=1,r=p(xt(wt,1),s)+wt[gt(1,2)],h=p(xt(wt,2),s)+wt[gt(2,2)],o=p(xt(wt,1),e)+wt[gt(1,2)],n=p(xt(wt,2),e)+wt[gt(2,2)],r=-.5*(r/h+o/n),wt[gt(1,0)]+=wt[gt(2,0)]*r,wt[gt(1,1)]+=wt[gt(2,1)]*r,wt[gt(1,2)]+=wt[gt(2,2)]*r,r=p(xt(wt,1),s)+wt[gt(1,2)],h=p(xt(wt,2),s)+wt[gt(2,2)],o=-h/r,wt[gt(1,0)]*=o,wt[gt(1,1)]*=o,wt[gt(1,2)]*=o,a[0]=wt[0],a[1]=wt[1],a[2]=0,a[3]=wt[2],a[4]=wt[3],a[5]=wt[4],a[6]=0,a[7]=wt[5],a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=wt[6],a[13]=wt[7],a[14]=0,a[15]=wt[8]}function Ct(t,s,i,a,r){const h=1/J[0][3],o=1/J[4][3];Q(h<o);let n=h+Math.sqrt(h*o);const c=Math.sin(e(t[2]*s[0]+t[6]*s[1]+t[10]*s[2]));n/=c,ft(J,n,c,K,Y,Z,$,tt),Mt(K,Y,$,tt,r.projectionMatrix),r.projectionMatrix[10]=2/(i-a),r.projectionMatrix[14]=-(i+a)/(i-a)}function jt(t){let{near:s,far:e}=t;return s<2&&(s=2),e<2&&(e=2),s>=e&&(s=2,e=4),{near:s,far:e}}export{G as ShadowMap,z as SnapshotSlot};
5
+ import has from"../../../../core/has.js";import{clamp as t,lerp as s,acosClamped as e}from"../../../../core/mathUtils.js";import{releaseMaybe as i}from"../../../../core/maybe.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as r,multiply as h,invert as o,lookAt as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as c,create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as d,add as m,scale as u,lerp as _,squaredDistance as f,subtract as g,dot as p,negate as x,normalize as b,copy as w}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as M}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{p as C,c as j,v as T,t as y,i as v}from"../../../../chunks/vec32.js";import{create as D}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as H,t as S}from"../../../../chunks/vec42.js";import{create as O}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ViewingMode as R}from"../../../ViewingMode.js";import{ColorFormat as E,DepthRenderbuffer16f as L}from"../../webgl/formats.js";import{CascadeCamera as Q}from"./CascadeCamera.js";import{applyTextureResizeModulo as U}from"./textureUtils.js";import{assert as V,logWithBase as F,verify as N,rayRay2D as A}from"./Util.js";import{TextureType as I,FramebufferBit as W}from"../../../webgl/enums.js";import{Texture as z}from"../../../webgl/Texture.js";var B;!function(t){t[t.Highlight=0]="Highlight",t[t.ExcludeHighlight=1]="ExcludeHighlight"}(B||(B={}));class q{constructor(){this.camera=new Q,this.lightMat=l()}}class P{constructor(){this.maxNumCascadesHighQuality=4,this.maxNumCascadesLowQuality=4,this.textureSizeModHighQuality=1.3,this.textureSizeModLowQuality=.9,this.splitSchemeLambda=0}}class G{constructor(t,s){this._fbos=t,this._viewingMode=s,this._enabled=!1,this._snapshots=new Array,this._textureHeight=0,this._numCascades=1,this.settings=new P,this._projectionView=l(),this._projectionViewInverse=l(),this._modelViewLight=l(),this._cascadeDistances=[0,0,0,0,0],this._usedCascadeDistances=O(),this._cascades=[new q,new q,new q,new q],this._lastOrigin=null,this._maxTextureWidth=Math.min(has("esri-mobile")?4096:16384,t.rctx.parameters.maxTextureSize)}dispose(){this.enabled=!1,this.disposeOffscreenBuffers()}get depthTexture(){return this._handle?.getTexture()}get _textureWidth(){return this._textureHeight*this._numCascades}get numCascades(){return this._numCascades}get cascadeDistances(){return H(this._usedCascadeDistances,this._cascadeDistances[0],this._numCascades>1?this._cascadeDistances[1]:1/0,this._numCascades>2?this._cascadeDistances[2]:1/0,this._numCascades>3?this._cascadeDistances[3]:1/0)}disposeOffscreenBuffers(){this._handle=i(this._handle),this._discardSnapshots()}set maxCascades(s){this.settings.maxNumCascadesHighQuality=t(Math.floor(s),1,4)}get maxCascades(){return this.settings.maxNumCascadesHighQuality}set enabled(t){this._enabled=t,t||this.disposeOffscreenBuffers()}get enabled(){return this._enabled}get ready(){return this._enabled&&null!=this.depthTexture}get cascades(){for(let t=0;t<this._numCascades;++t)et[t]=this._cascades[t];return et.length=this._numCascades,et}start(t,s,e,i,a){V(this.enabled);const{near:r,far:h}=jt(e);this._computeCascadeDistances(r,h,i),this._textureHeight=this._computeTextureHeight(t,a,i),this._setupMatrices(t,s);const{viewMatrix:o,projectionMatrix:n}=t;for(let c=0;c<this._numCascades;++c)this._constructCascade(c,n,o,s);this._lastOrigin=null,this.clear()}finish(){V(this.enabled),this._handle?.detachDepth()}getShadowMapMatrices(t){if(!this._lastOrigin||!C(t,this._lastOrigin)){this._lastOrigin=this._lastOrigin||D(),j(this._lastOrigin,t);for(let s=0;s<this._numCascades;++s){r(it,this._cascades[s].lightMat,t);for(let t=0;t<16;++t)at[16*s+t]=it[t]}}return at}moveSnapshot(t){V(this.enabled),this._handle?.detachDepth(),this._snapshots[t]?.release(),this._snapshots[t]=this._handle,this._handle=null,this.clear()}copySnapshot(t){const s=this._handle?.getTexture()?.descriptor;if(!this.enabled||!s)return;this._snapshots[t]?.release();const{width:e,height:i}=s,a=t===B.Highlight?"shadow highlight snapshot":"shadow no highlight snapshot";this._snapshots[t]=this._fbos.acquire(e,i,a,E.RGBA4);const r=this._fbos.rctx;this._bindFbo();const h=r.bindTexture(this._snapshots[t]?.getTexture(),z.TEXTURE_UNIT_FOR_UPDATES);r.gl.copyTexSubImage2D(I.TEXTURE_2D,0,0,0,0,0,e,i),r.bindTexture(h,z.TEXTURE_UNIT_FOR_UPDATES)}getSnapshot(t){return this.enabled?this._snapshots[t]?.getTexture():null}clear(){const t=this._fbos.rctx;this._ensureFbo(),this._bindFbo(),t.setClearColor(1,1,1,1),t.clear(W.COLOR|W.DEPTH)}_computeTextureHeight({pixelRatio:t,fullWidth:s,fullHeight:e},i,a){const r=Math.min(window.devicePixelRatio,i)/t,h=a?this.settings.textureSizeModHighQuality:this.settings.textureSizeModLowQuality;return U(Math.max(s,e)*r*h,this._maxTextureWidth/this._numCascades)}_ensureFbo(){this._handle?.fbo?.width===this._textureWidth&&this._handle?.fbo.height===this._textureHeight||(this._handle?.release(),this._handle=this._fbos.acquire(this._textureWidth,this._textureHeight,"shadow map",E.RGBA4)),this._handle?.acquireDepth(L)}_discardSnapshot(t){this._snapshots[t]=i(this._snapshots[t])}_discardSnapshots(){for(let t=0;t<this._snapshots.length;++t)this._discardSnapshot(t);this._snapshots.length=0}_bindFbo(){this._fbos.rctx.bindFramebuffer(this._handle?.fbo)}_constructCascade(t,s,e,i){const a=this._cascades[t],o=-this._cascadeDistances[t],n=-this._cascadeDistances[t+1],c=(s[10]*o+s[14])/Math.abs(s[11]*o+s[15]),l=(s[10]*n+s[14])/Math.abs(s[11]*n+s[15]);V(c<l);for(let r=0;r<8;++r){H(k,r%4==0||r%4==3?-1:1,r%4==0||r%4==1?-1:1,r<4?c:l,1);const t=J[r];S(t,k,this._projectionViewInverse),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3]}T(st,J[0]),a.camera.viewMatrix=r(X,this._modelViewLight,st);for(let r=0;r<8;++r)y(J[r],J[r],a.camera.viewMatrix);let d=J[0][2],m=J[0][2];for(let r=1;r<8;++r)d=Math.min(d,J[r][2]),m=Math.max(m,J[r][2]);d-=200,m+=200,a.camera.near=-m,a.camera.far=-d,Ct(e,i,d,m,a.camera),h(a.lightMat,a.camera.projectionMatrix,a.camera.viewMatrix);const u=this._textureHeight;a.camera.viewport=[t*u,0,u,u]}_setupMatrices(t,s){h(this._projectionView,t.projectionMatrix,t.viewMatrix),o(this._projectionViewInverse,this._projectionView);const e=this._viewingMode===R.Global?t.eye:v(st,0,0,1);n(this._modelViewLight,[0,0,0],[-s[0],-s[1],-s[2]],e)}_computeCascadeDistances(t,e,i){const a=i?this.settings.maxNumCascadesHighQuality:this.settings.maxNumCascadesLowQuality;this._numCascades=Math.min(1+Math.floor(F(e/t,4)),a);const r=(e-t)/this._numCascades,h=(e/t)**(1/this._numCascades);let o=t,n=t;for(let c=0;c<this._numCascades+1;++c)this._cascadeDistances[c]=s(o,n,this.settings.splitSchemeLambda),o*=h,n+=r}get test(){}}const X=l(),k=O(),J=[];for(let Tt=0;Tt<8;++Tt)J.push(O());const K=M(),Y=M(),Z=M(),$=M(),tt=M(),st=D(),et=[],it=l(),at=c.concat(c,c,c,c),rt=M(),ht=M(),ot=[M(),M(),M(),M()],nt=M(),ct=M(),lt=M(),dt=M(),mt=M(),ut=M(),_t=M();function ft(t,s,e,i,a,r,h,o){d(rt,0,0);for(let d=0;d<4;++d)m(rt,rt,t[d]);u(rt,rt,.25),d(ht,0,0);for(let d=4;d<8;++d)m(ht,ht,t[d]);u(ht,ht,.25),_(ot[0],t[4],t[5],.5),_(ot[1],t[5],t[6],.5),_(ot[2],t[6],t[7],.5),_(ot[3],t[7],t[4],.5);let n=0,c=f(ot[0],rt);for(let d=1;d<4;++d){const t=f(ot[d],rt);t<c&&(c=t,n=d)}g(nt,ot[n],t[n+4]);const l=nt[0];let M,C;nt[0]=-nt[1],nt[1]=l,g(ct,ht,rt),p(ct,nt)<0&&x(nt,nt),_(nt,nt,ct,e),b(nt,nt),M=C=p(g(lt,t[0],rt),nt);for(let d=1;d<8;++d){const s=p(g(lt,t[d],rt),nt);s<M?M=s:s>C&&(C=s)}w(i,rt),u(lt,nt,M-s),m(i,i,lt);let j=-1,T=1,y=0,v=0;for(let d=0;d<8;++d){g(dt,t[d],i),b(dt,dt);const s=nt[0]*dt[1]-nt[1]*dt[0];s>0?s>j&&(j=s,y=d):s<T&&(T=s,v=d)}N(j>0,"leftArea"),N(T<0,"rightArea"),u(mt,nt,M),m(mt,mt,rt),u(ut,nt,C),m(ut,ut,rt),_t[0]=-nt[1],_t[1]=nt[0];const D=A(i,t[v],ut,m(lt,ut,_t),1,a),H=A(i,t[y],ut,lt,1,r),S=A(i,t[y],mt,m(lt,mt,_t),1,h),O=A(i,t[v],mt,lt,1,o);N(D,"rayRay"),N(H,"rayRay"),N(S,"rayRay"),N(O,"rayRay")}function gt(t,s){return 3*s+t}const pt=M();function xt(t,s){return d(pt,t[s],t[s+3]),pt}const bt=M(),wt=a();function Mt(t,s,e,i,a){g(bt,e,i),u(bt,bt,.5),wt[0]=bt[0],wt[1]=bt[1],wt[2]=0,wt[3]=bt[1],wt[4]=-bt[0],wt[5]=0,wt[6]=bt[0]*bt[0]+bt[1]*bt[1],wt[7]=bt[0]*bt[1]-bt[1]*bt[0],wt[8]=1,wt[gt(0,2)]=-p(xt(wt,0),t),wt[gt(1,2)]=-p(xt(wt,1),t);let r=p(xt(wt,0),e)+wt[gt(0,2)],h=p(xt(wt,1),e)+wt[gt(1,2)],o=p(xt(wt,0),i)+wt[gt(0,2)],n=p(xt(wt,1),i)+wt[gt(1,2)];r=-(r+o)/(h+n),wt[gt(0,0)]+=wt[gt(1,0)]*r,wt[gt(0,1)]+=wt[gt(1,1)]*r,wt[gt(0,2)]+=wt[gt(1,2)]*r,r=1/(p(xt(wt,0),e)+wt[gt(0,2)]),h=1/(p(xt(wt,1),e)+wt[gt(1,2)]),wt[gt(0,0)]*=r,wt[gt(0,1)]*=r,wt[gt(0,2)]*=r,wt[gt(1,0)]*=h,wt[gt(1,1)]*=h,wt[gt(1,2)]*=h,wt[gt(2,0)]=wt[gt(1,0)],wt[gt(2,1)]=wt[gt(1,1)],wt[gt(2,2)]=wt[gt(1,2)],wt[gt(1,2)]+=1,r=p(xt(wt,1),s)+wt[gt(1,2)],h=p(xt(wt,2),s)+wt[gt(2,2)],o=p(xt(wt,1),e)+wt[gt(1,2)],n=p(xt(wt,2),e)+wt[gt(2,2)],r=-.5*(r/h+o/n),wt[gt(1,0)]+=wt[gt(2,0)]*r,wt[gt(1,1)]+=wt[gt(2,1)]*r,wt[gt(1,2)]+=wt[gt(2,2)]*r,r=p(xt(wt,1),s)+wt[gt(1,2)],h=p(xt(wt,2),s)+wt[gt(2,2)],o=-h/r,wt[gt(1,0)]*=o,wt[gt(1,1)]*=o,wt[gt(1,2)]*=o,a[0]=wt[0],a[1]=wt[1],a[2]=0,a[3]=wt[2],a[4]=wt[3],a[5]=wt[4],a[6]=0,a[7]=wt[5],a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=wt[6],a[13]=wt[7],a[14]=0,a[15]=wt[8]}function Ct(t,s,i,a,r){const h=1/J[0][3],o=1/J[4][3];V(h<o);let n=h+Math.sqrt(h*o);const c=Math.sin(e(t[2]*s[0]+t[6]*s[1]+t[10]*s[2]));n/=c,ft(J,n,c,K,Y,Z,$,tt),Mt(K,Y,$,tt,r.projectionMatrix),r.projectionMatrix[10]=2/(i-a),r.projectionMatrix[14]=-(i+a)/(i-a)}function jt(t){let{near:s,far:e}=t;return s<2&&(s=2),e<2&&(e=2),s>=e&&(s=2,e=4),{near:s,far:e}}export{G as ShadowMap,B as SnapshotSlot};