@arcgis/core 4.28.0-next.20230621 → 4.28.0-next.20230622

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 (123) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/05c0fdbfc82538f2f68d.js +1 -0
  3. package/assets/esri/core/workers/chunks/0bd95f46a0a9005a19f9.js +1 -0
  4. package/assets/esri/core/workers/chunks/19b4f02fb2392d964582.js +1 -0
  5. package/assets/esri/core/workers/chunks/26212a08ea383547335b.js +1 -0
  6. package/assets/esri/core/workers/chunks/{2420ec029236ab31d908.js → 2882a55a971af1f7858b.js} +1 -1
  7. package/assets/esri/core/workers/chunks/303238fc2fcdbb277981.js +1 -0
  8. package/assets/esri/core/workers/chunks/42dfebbe964f2b44ffab.js +1 -0
  9. package/assets/esri/core/workers/chunks/{4b235d1b6a72773cd4f4.js → 57bb8516fa998a0fba78.js} +1 -1
  10. package/assets/esri/core/workers/chunks/6208f2dfa9dfd3bca000.js +1 -0
  11. package/assets/esri/core/workers/chunks/64008bde5d3ffd9f2499.js +1 -0
  12. package/assets/esri/core/workers/chunks/{c1dfbda75abc748a6ca4.js → 6aa42f510969014db3f4.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{cfe379a78a983373b3ac.js → 7304f45f5622a68253e4.js} +1 -1
  14. package/assets/esri/core/workers/chunks/733b70d6e5c466a67e9c.js +1 -0
  15. package/assets/esri/core/workers/chunks/7694521b44681d52b713.js +1 -0
  16. package/assets/esri/core/workers/chunks/80aa79040c0a7d039c3d.js +1 -0
  17. package/assets/esri/core/workers/chunks/91f957cd49a95a8a95f5.js +1 -0
  18. package/assets/esri/core/workers/chunks/{42b6315e21c4c1345ba5.js → 9f5337a80963e0b3c009.js} +1 -1
  19. package/assets/esri/core/workers/chunks/a16458b4653b284b4b80.js +1 -0
  20. package/assets/esri/core/workers/chunks/a54f361506012be46fdb.js +1 -0
  21. package/assets/esri/core/workers/chunks/{cfc3dcca2b69d20d5375.js → c0b9cc091efd5db827de.js} +1 -1
  22. package/assets/esri/core/workers/chunks/ce7f575a6c2053c7ca17.js +1 -0
  23. package/assets/esri/core/workers/chunks/d24f7ef6eca8c91b90b4.js +1 -0
  24. package/assets/esri/core/workers/chunks/dbd86e4b7983873cbe7c.js +1 -0
  25. package/assets/esri/core/workers/chunks/{3c3f65913006b84b2289.js → de20572d334abd4a7d82.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{c8702e53a8ad6cf6ab85.js → dede2b4948f1f07a9859.js} +1 -1
  27. package/assets/esri/core/workers/chunks/e3f7d464f6d74523fc13.js +1 -0
  28. package/assets/esri/core/workers/chunks/f6040205c50e2795a1a0.js +1 -0
  29. package/assets/esri/core/workers/chunks/{915734255a79bff3ef0f.js → fcd54e9e64c2864f183c.js} +1 -1
  30. package/assets/esri/t9n/common.json +1 -1
  31. package/assets/esri/t9n/common_en.json +1 -1
  32. package/assets/esri/themes/base/_core.scss +6 -2
  33. package/assets/esri/themes/base/_mixins.scss +0 -147
  34. package/assets/esri/themes/base/widgets/_AreaMeasurement2D.scss +0 -8
  35. package/assets/esri/themes/base/widgets/_AreaMeasurement3D.scss +0 -8
  36. package/assets/esri/themes/base/widgets/_DirectLineMeasurement3D.scss +0 -1
  37. package/assets/esri/themes/base/widgets/_DistanceMeasurement2D.scss +0 -1
  38. package/assets/esri/themes/base/widgets/_MeasurementWidgetContent.scss +58 -0
  39. package/assets/esri/themes/base/widgets/_UnitSelect.scss +14 -0
  40. package/assets/esri/themes/dark/main.css +1 -1
  41. package/assets/esri/themes/light/main.css +1 -1
  42. package/assets/esri/themes/light/view.css +1 -1
  43. package/assets/esri/widgets/AreaMeasurement2D/t9n/AreaMeasurement2D.json +1 -1
  44. package/assets/esri/widgets/AreaMeasurement2D/t9n/AreaMeasurement2D_en.json +1 -1
  45. package/assets/esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D.json +1 -1
  46. package/assets/esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D_en.json +1 -1
  47. package/assets/esri/widgets/DirectLineMeasurement3D/t9n/DirectLineMeasurement3D.json +1 -1
  48. package/assets/esri/widgets/DirectLineMeasurement3D/t9n/DirectLineMeasurement3D_en.json +1 -1
  49. package/assets/esri/widgets/DistanceMeasurement2D/t9n/DistanceMeasurement2D.json +1 -1
  50. package/assets/esri/widgets/DistanceMeasurement2D/t9n/DistanceMeasurement2D_en.json +1 -1
  51. package/core/promiseUtils.js +1 -1
  52. package/geometry/projection.js +1 -1
  53. package/interfaces.d.ts +270 -5
  54. package/layers/LinkChartLayer.d.ts +4 -0
  55. package/layers/LinkChartLayer.js +1 -1
  56. package/layers/support/TileInfoTilemapCache.js +1 -1
  57. package/package.json +1 -1
  58. package/support/revision.js +1 -1
  59. package/symbols/cim/cimAnalyzer.js +1 -1
  60. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  61. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  62. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  63. package/views/3d/environment/CloudsGenerator.js +1 -1
  64. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  65. package/views/3d/environment/SceneViewEnvironmentManager.js +1 -1
  66. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  67. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  68. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  69. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  70. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  71. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  72. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  73. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  74. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  75. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  76. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  77. package/views/3d/layers/graphics/Labeler.js +1 -1
  78. package/views/3d/layers/graphics/labelPlacement.js +1 -1
  79. package/views/3d/state/ViewState.js +1 -1
  80. package/views/3d/state/ViewStateManager.js +1 -1
  81. package/views/3d/support/DisplayQualityProfile.js +1 -1
  82. package/views/3d/support/MemoryController.js +1 -1
  83. package/views/3d/support/SceneViewPerformanceInfo.js +1 -1
  84. package/views/3d/support/cameraUtils.js +1 -1
  85. package/views/3d/support/viewpointUtils.js +1 -1
  86. package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
  87. package/views/3d/terrain/OverlayRenderer.js +1 -1
  88. package/views/3d/webgl-engine/Stage.js +1 -1
  89. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  90. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUDOcclusionPass.glsl.js +0 -1
  91. package/views/3d/webgl-engine/lib/Highlight.js +1 -1
  92. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  93. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  94. package/views/3d/webgl-engine/lib/SSAOHelper.js +1 -1
  95. package/views/3d/webgl-engine/lib/SmaaRenderPass.js +1 -1
  96. package/views/webgl/Texture.js +1 -1
  97. package/widgets/AreaMeasurement2D.js +1 -1
  98. package/widgets/AreaMeasurement3D.js +1 -1
  99. package/widgets/DirectLineMeasurement3D.js +1 -1
  100. package/widgets/DistanceMeasurement2D.js +1 -1
  101. package/widgets/FeatureForm/FieldInput.js +1 -1
  102. package/widgets/support/MeasurementWidgetContent.js +5 -0
  103. package/widgets/support/UnitSelect.js +5 -0
  104. package/assets/esri/core/workers/chunks/07f16ea775b39a1a4a7b.js +0 -1
  105. package/assets/esri/core/workers/chunks/1bbc868d2430103951eb.js +0 -1
  106. package/assets/esri/core/workers/chunks/1d2ef88a8d028adef102.js +0 -1
  107. package/assets/esri/core/workers/chunks/39ae4b9b766f674bc6f2.js +0 -1
  108. package/assets/esri/core/workers/chunks/3b3d676b609c47a77164.js +0 -1
  109. package/assets/esri/core/workers/chunks/3d9a8cb638cf9b8ca4b3.js +0 -1
  110. package/assets/esri/core/workers/chunks/45629ff775e77234b227.js +0 -1
  111. package/assets/esri/core/workers/chunks/642510b0371311ff8e16.js +0 -1
  112. package/assets/esri/core/workers/chunks/7e4013f8c31c9a9438c6.js +0 -1
  113. package/assets/esri/core/workers/chunks/82939ead43848a13f765.js +0 -1
  114. package/assets/esri/core/workers/chunks/8b6b963230df56850580.js +0 -1
  115. package/assets/esri/core/workers/chunks/a9e9297267614c4c4f3b.js +0 -1
  116. package/assets/esri/core/workers/chunks/b31974524932e638df8c.js +0 -1
  117. package/assets/esri/core/workers/chunks/b75b4b132dbd9cb9d372.js +0 -1
  118. package/assets/esri/core/workers/chunks/cad7a2092ea7f51dbd8b.js +0 -1
  119. package/assets/esri/core/workers/chunks/d2a127f7bb0e2ba14a13.js +0 -1
  120. package/assets/esri/core/workers/chunks/e097f41bbfac00250477.js +0 -1
  121. package/assets/esri/core/workers/chunks/e55f80b774e090a0aa04.js +0 -1
  122. package/assets/esri/core/workers/chunks/e668c7e2e61aae6ca6e0.js +0 -1
  123. package/assets/esri/core/workers/chunks/f0299d93a95f40ea7cf7.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.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import t from"../../../core/Evented.js";import{someMap as s}from"../../../core/MapUtils.js";import{releaseMaybe as i,disposeMaybe as o,destroyMaybe as a}from"../../../core/maybe.js";import n from"../../../core/PooledArray.js";import{watch as h,syncAndInitial as d,on as l}from"../../../core/reactiveUtils.js";import{someSet as c}from"../../../core/SetUtils.js";import{property as u}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import{x as m,f as _}from"../../../chunks/mat4.js";import{s as g}from"../../../chunks/vec3.js";import{f as y}from"../../../chunks/vec3f64.js";import{ViewingMode as R}from"../../ViewingMode.js";import{DrapeTargetType as f,DrapeSourceType as T,DrapedRenderGroup as w}from"../layers/interfaces.js";import b from"../support/debugFlags.js";import{OverlayIndex as v,RenderTargetType as x}from"./interfaces.js";import{Overlay as S,OverlayStretch as D}from"./Overlay.js";import{OverlayRenderTarget as O}from"./OverlayRenderTarget.js";import{ColorFormat as P}from"../webgl-engine/core/FBOCache.js";import{ShaderOutput as j}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{T as E}from"../../../chunks/TextureOnly.glsl.js";import{ShaderTechniqueRepository as C}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{Camera as A}from"../webgl-engine/lib/Camera.js";import{GLMaterialRepository as q}from"../webgl-engine/lib/GLMaterialRepository.js";import{createEmptyDepthTexture as V,createQuadVAO as M}from"../webgl-engine/lib/glUtil3D.js";import{GridLocalOriginFactory as W}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as H}from"../webgl-engine/lib/Material.js";import{OverlayRenderContext as L}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as F}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as U}from"../webgl-engine/lib/ShadowMap.js";import{SortedRenderGeometryRenderer as I}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{SSAOHelper as k}from"../webgl-engine/lib/SSAOHelper.js";import{TextureTechnique as N}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as G}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{TransparencyPassType as B}from"../webgl-engine/lib/TransparencyPassType.js";import{UpdatePolicy as z}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as Y}from"../webgl-engine/lighting/Lightsources.js";import{TaskPriority as X,noBudget as J}from"../../support/Scheduler.js";import{ClearBufferBit as K,PrimitiveType as Q,TextureSamplingMode as Z}from"../../webgl/enums.js";import{Texture as $}from"../../webgl/Texture.js";import{TextureDescriptor as ee}from"../../webgl/TextureDescriptor.js";import{vertexCount as re}from"../../webgl/Util.js";let te=class extends r{get _bindParameters(){return this._renderContext.bindParameters}get _rctx(){return this.view._stage.renderView.renderingContext}get rctx(){return this._rctx}get materialRepository(){return this._materialRepository}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}constructor(e){super(e),this._overlays=null,this._overlayRenderTarget=null,this._hasHighlights=!1,this._rendersOccluded=!1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new n,this._passParameters=new E,this._materialRepository=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this._camera=new A,this.worldToPCSRatio=1,this.events=new t,this.longitudeCyclical=null}initialize(){const e=this.view._stage.renderer.fboCache,r=this.view._stage.renderView,{waterTextureRepository:t,stippleTextureRepository:s,markerTextureRepository:i}=r;this._shaderTechniqueRepository=new C({rctx:this._rctx,viewingMode:R.Local,stippleTextureRepository:s,markerTextureRepository:i,waterTextureRepository:t}),this._renderContext=new L(this._rctx,new U(e,this.view.state.viewingMode),new k(this.view,e,this._shaderTechniqueRepository,(()=>{}))),this.addHandles([h((()=>t.updating),(()=>this.events.emit("content-changed")),d),h((()=>this.spatialReference),(e=>this._localOriginFactory=new W(e)),d),l((()=>this.view.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0))]),this._materialRepository=new q(r.textureRepository,this._shaderTechniqueRepository,(e=>{(e.renderOccluded&ae)>0!==this._rendersOccluded&&this._updateRendersOccluded(),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed"))),this._bindParameters.slot=F.DRAPED_MATERIAL,this._bindParameters.mainDepth=V(this._rctx),this._camera.near=1,this._camera.far=1e4,this._camera.relativeElevation=null,this._bindParameters.camera=this._camera,this._bindParameters.transparencyPassType=B.NONE,this._bindParameters.newLighting.noonFactor=0,this._bindParameters.newLighting.globalFactor=0,this._bindParameters.newLighting.set([new Y(y(1,1,1))]),this.addHandles(this.view.resourceController.scheduler.registerTask(X.STAGE,this))}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._debugTextureTechnique=i(this._debugTextureTechnique),this._passParameters.texture=o(this._passParameters.texture),this._bindParameters.mainDepth=o(this._bindParameters.mainDepth),this._shaderTechniqueRepository=a(this._shaderTechniqueRepository),this._quadVAO=o(this._quadVAO),this.disposeOverlays()}get updating(){return this._sortedDrapeSourceRenderersDirty||s(this._renderers,(e=>e.updating))}get hasOverlays(){return null!=this._overlays&&null!=this._overlayRenderTarget}get gpuMemoryUsage(){return null!=this._overlayRenderTarget?this._overlayRenderTarget.gpuMemoryUsage:0}createGeometryDrapeSourceRenderer(e){return this.createDrapeSourceRenderer(e,I)}createDrapeSourceRenderer(e,r,t){const s=this._renderers.get(e);null!=s&&s.destroy();const i=new r({...t,rendererContext:this,drapeSource:e});return this._renderers.set(e,i),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(h((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e),i}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._overlayRenderTarget?.computeValidity()??0}releaseRenderTargets(){this._overlayRenderTarget?.dispose()}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){null!=this._overlays&&this._overlays.forEach((r=>r.hasTargetWithoutRasterImage=c(e,(e=>e.drapeTargetType===f.WithoutRasterImage))))}ensureDrapeSources(e){null!=this._overlays&&this._overlays.forEach((r=>{r.hasDrapedFeatureSource=c(e,(e=>e.drapeSourceType===T.Features)),r.hasDrapedRasterSource=c(e,(e=>e.drapeSourceType===T.RasterImage))}))}ensureOverlays(e,r){null==this._overlays&&(this._overlayRenderTarget=new O(this.view._stage.renderer.fboCache),this._overlays=[new S(v.INNER,this._overlayRenderTarget),new S(v.OUTER,this._overlayRenderTarget)]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r)}disposeOverlays(){this._overlays=null,this._overlayRenderTarget=o(this._overlayRenderTarget),this.events.emit("textures-disposed")}get running(){return this.updating}runTask(e){this._processDrapeSources(e,(()=>!0))}_processDrapeSources(e,r){let t=!1;for(const[s,i]of this._renderers){if(e.done)break;(s.destroyed||r(s))&&(i.commitChanges()&&(t=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,t=!0,this._updateSortedDrapeSourceRenderers()),t&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this.events.emit("content-changed"),this._updateHasHighlights(),this._updateRendersOccluded(),this._updateHasWater())}processSyncDrapeSources(){this._processDrapeSources(J,(e=>e.updatePolicy===z.SYNC))}get isEmpty(){return!b.OVERLAY_DRAW_DEBUG_TEXTURE&&!s(this._renderers,(e=>!e.isEmpty))}get hasHighlights(){return this._hasHighlights}get hasWater(){return this._hasWater}get rendersOccluded(){return this._rendersOccluded}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}drawTarget(e,r,t){const s=e.canvasGeometries;if(0===s.numViews)return;const{alignPixelEnabled:i,contentPixelRatio:o}=t;this._screenToWorldRatio=o*e.mapUnitsPerPixel/D;const a=r.output;if(this.isEmpty||a===j.Highlight&&!this.hasHighlights||a===j.Normal&&!this.hasWater||!e.hasSomeSizedView())return;const n=this._rctx;this._camera.pixelRatio=e.pixelRatio*o,this._renderContext.output=a,this._bindParameters.alignPixelEnabled=i,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=a===j.Normal?F.DRAPED_WATER:F.DRAPED_MATERIAL,e.applyViewport(this._rctx);const h=2*e.resolution,d=e.resolution,l=r.fbo;if(l.bind(n,h,d),e.index===v.INNER&&(n.setClearColor(0,0,0,0),n.clearSafe(K.COLOR_BUFFER_BIT)),r.type===x.Occluded&&(this._renderContext.renderOccludedMask=ae),b.OVERLAY_DRAW_DEBUG_TEXTURE&&r.type!==x.Occluded)for(let c=0;c<s.numViews;c++)this._setViewParameters(s.extents[c],e),this._drawDebugTexture(e.resolution,ie[e.index]);this._sortedRenderers.forAll((({drapeSource:t,renderer:i})=>{if(r.type===x.ColorNoRasterImage&&t.drapeSourceType===T.RasterImage)return;const{fullOpacity:o}=t,c=null!=o&&o<1&&a===j.Color?this.bindTemporaryFramebuffer(h,d):null;for(let r=0;r<s.numViews;r++)this._setViewParameters(s.extents[r],e),i.render(this._renderContext);c&&(l.bind(n,h,d),this.view._stage.renderView.compositingHelper.compositeOverlay(this._renderContext.bindParameters,c.colorTexture,o,e.index),c.release())})),n.bindFramebuffer(null),l.generateMipMap(),this._renderContext.resetRenderOccludedMask()}bindTemporaryFramebuffer(e,r){const t=this.view._stage.renderer.fboCache,s=t.acquire(P.RGBA_CLAMPED,e,r);return t.rctx.bindFramebuffer(s.fbo),t.rctx.clearSafe(K.COLOR_BUFFER_BIT),s}async reloadShaders(){await this._shaderTechniqueRepository.reloadAll()}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){let i=0;for(const o of this._renderers.values())i=o.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this.view.map.allLayers;this._renderers.forEach(((r,t)=>{const s=e.indexOf(t.layer),i=s>=0,o=this._renderers.size*(t.renderGroup??(i?w.MapLayer:w.ViewLayer))+(i?s:0);this._sortedRenderers.push(new se(t,r,o))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],m(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),_(t.viewMatrix,[-e[0],-e[1],0])}_updateHasWater(){const e=s(this._renderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_updateHasHighlights(){const e=s(this._renderers,(e=>e.hasHighlights));e!==this._hasHighlights&&(this._hasHighlights=e,this.events.emit("has-highlights",e))}_updateRendersOccluded(){const e=s(this._renderers,(e=>e.rendersOccluded));e!==this._rendersOccluded&&(this._rendersOccluded=e,this.events.emit("renders-occluded",e))}_drawDebugTexture(e,r){this._ensureDebugPatternResources(e,r);const t=this._rctx;t.bindTechnique(this._debugTextureTechnique,this._passParameters,null),t.bindVAO(this._quadVAO),t.drawArrays(Q.TRIANGLE_STRIP,0,re(this._quadVAO,"geometry"))}_ensureDebugPatternResources(e,r){if(g(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let a=0;a<e;a++)for(let r=0;r<e;r++){const i=Math.floor(r/10),o=Math.floor(a/10);i<2||o<2||10*i>e-20||10*o>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&o?1&r^1&a?0:255:1&i^1&o?0:128)}const i=new ee(e);i.samplingMode=Z.NEAREST,this._passParameters.texture=new $(this._rctx,i,t);const o=new G;o.hasAlpha=!0,this._debugTextureTechnique=this._shaderTechniqueRepository.acquire(N,o),this._quadVAO=M(this._rctx)}get test(){return{drapedRenderers:Array.from(this._renderers.values()),getDrapeSourceRenderer:e=>this._renderers.get(e)}}};e([u()],te.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([u({autoDestroy:!0})],te.prototype,"_shaderTechniqueRepository",void 0),e([u({constructOnly:!0})],te.prototype,"view",void 0),e([u()],te.prototype,"worldToPCSRatio",void 0),e([u()],te.prototype,"spatialReference",void 0),e([u({type:Boolean,readOnly:!0})],te.prototype,"updating",null),e([u()],te.prototype,"isEmpty",null),te=e([p("esri.views.3d.terrain.OverlayRenderer")],te);class se{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const ie=[[1,.5,.5],[.5,.5,1]],oe=-2,ae=H.OccludeAndTransparent;export{oe as DRAPED_Z,te as OverlayRenderer,ae as overlayRenderOccludedFlag};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import t from"../../../core/Evented.js";import{someMap as s}from"../../../core/MapUtils.js";import{releaseMaybe as i,disposeMaybe as o,destroyMaybe as a}from"../../../core/maybe.js";import n from"../../../core/PooledArray.js";import{watch as h,syncAndInitial as d,on as l}from"../../../core/reactiveUtils.js";import{someSet as c}from"../../../core/SetUtils.js";import{property as u}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import{x as m,f as _}from"../../../chunks/mat4.js";import{s as g}from"../../../chunks/vec3.js";import{f as y}from"../../../chunks/vec3f64.js";import{ViewingMode as R}from"../../ViewingMode.js";import{DrapeTargetType as f,DrapeSourceType as T,DrapedRenderGroup as w}from"../layers/interfaces.js";import b from"../support/debugFlags.js";import{OverlayIndex as v,RenderTargetType as x}from"./interfaces.js";import{Overlay as S,OverlayStretch as D}from"./Overlay.js";import{OverlayRenderTarget as O}from"./OverlayRenderTarget.js";import{ColorFormat as j}from"../webgl-engine/core/FBOCache.js";import{ShaderOutput as P}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{T as E}from"../../../chunks/TextureOnly.glsl.js";import{ShaderTechniqueRepository as C}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{Camera as A}from"../webgl-engine/lib/Camera.js";import{GLMaterialRepository as q}from"../webgl-engine/lib/GLMaterialRepository.js";import{createEmptyDepthTexture as V,createQuadVAO as M}from"../webgl-engine/lib/glUtil3D.js";import{GridLocalOriginFactory as W}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as H}from"../webgl-engine/lib/Material.js";import{OverlayRenderContext as F}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as L}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as U}from"../webgl-engine/lib/ShadowMap.js";import{SortedRenderGeometryRenderer as I}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{SSAOHelper as k}from"../webgl-engine/lib/SSAOHelper.js";import{TextureTechnique as N}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as G}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{TransparencyPassType as B}from"../webgl-engine/lib/TransparencyPassType.js";import{UpdatePolicy as z}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as Y}from"../webgl-engine/lighting/Lightsources.js";import{TaskPriority as X,noBudget as J}from"../../support/Scheduler.js";import{ClearBufferBit as K,PrimitiveType as Q,TextureSamplingMode as Z}from"../../webgl/enums.js";import{Texture as $}from"../../webgl/Texture.js";import{TextureDescriptor as ee}from"../../webgl/TextureDescriptor.js";import{vertexCount as re}from"../../webgl/Util.js";let te=class extends r{get _bindParameters(){return this._renderContext.bindParameters}get _rctx(){return this.view._stage.renderView.renderingContext}get rctx(){return this._rctx}get materialRepository(){return this._materialRepository}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}constructor(e){super(e),this._overlays=null,this._overlayRenderTarget=null,this._hasHighlights=!1,this._rendersOccluded=!1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new n,this._passParameters=new E,this._materialRepository=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this._camera=new A,this.worldToPCSRatio=1,this.events=new t,this.longitudeCyclical=null}initialize(){const e=this.view._stage.renderer.fboCache,r=this.view._stage.renderView,{waterTextureRepository:t,stippleTextureRepository:s,markerTextureRepository:i}=r;this._shaderTechniqueRepository=new C({rctx:this._rctx,viewingMode:R.Local,stippleTextureRepository:s,markerTextureRepository:i,waterTextureRepository:t}),this._renderContext=new F(this._rctx,new U(e,this.view.state.viewingMode),new k(this.view,e,this._shaderTechniqueRepository,(()=>{}))),this.addHandles([h((()=>t.updating),(()=>this.events.emit("content-changed")),d),h((()=>this.spatialReference),(e=>this._localOriginFactory=new W(e)),d),l((()=>this.view.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0))]),this._materialRepository=new q(r.textureRepository,this._shaderTechniqueRepository,(e=>{(e.renderOccluded&ae)>0!==this._rendersOccluded&&this._updateRendersOccluded(),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed"))),this._bindParameters.slot=L.DRAPED_MATERIAL,this._bindParameters.mainDepth=V(this._rctx),this._camera.near=1,this._camera.far=1e4,this._camera.relativeElevation=null,this._bindParameters.camera=this._camera,this._bindParameters.transparencyPassType=B.NONE,this._bindParameters.newLighting.noonFactor=0,this._bindParameters.newLighting.globalFactor=0,this._bindParameters.newLighting.set([new Y(y(1,1,1))]),this.addHandles(this.view.resourceController.scheduler.registerTask(X.STAGE,this))}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._debugTextureTechnique=i(this._debugTextureTechnique),this._passParameters.texture=o(this._passParameters.texture),this._bindParameters.mainDepth=o(this._bindParameters.mainDepth),this._shaderTechniqueRepository=a(this._shaderTechniqueRepository),this._quadVAO=o(this._quadVAO),this.disposeOverlays()}get updating(){return this._sortedDrapeSourceRenderersDirty||s(this._renderers,(e=>e.updating))}get hasOverlays(){return null!=this._overlays&&null!=this._overlayRenderTarget}get gpuMemoryUsage(){return null!=this._overlayRenderTarget?this._overlayRenderTarget.gpuMemoryUsage:0}createGeometryDrapeSourceRenderer(e){return this.createDrapeSourceRenderer(e,I)}createDrapeSourceRenderer(e,r,t){const s=this._renderers.get(e);null!=s&&s.destroy();const i=new r({...t,rendererContext:this,drapeSource:e});return this._renderers.set(e,i),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(h((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e),i}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._overlayRenderTarget?.computeValidity()??0}releaseRenderTargets(){this._overlayRenderTarget?.dispose()}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){null!=this._overlays&&this._overlays.forEach((r=>r.hasTargetWithoutRasterImage=c(e,(e=>e.drapeTargetType===f.WithoutRasterImage))))}ensureDrapeSources(e){null!=this._overlays&&this._overlays.forEach((r=>{r.hasDrapedFeatureSource=c(e,(e=>e.drapeSourceType===T.Features)),r.hasDrapedRasterSource=c(e,(e=>e.drapeSourceType===T.RasterImage))}))}ensureOverlays(e,r){null==this._overlays&&(this._overlayRenderTarget=new O(this.view._stage.renderer.fboCache),this._overlays=[new S(v.INNER,this._overlayRenderTarget),new S(v.OUTER,this._overlayRenderTarget)]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r)}disposeOverlays(){this._overlays=null,this._overlayRenderTarget=o(this._overlayRenderTarget),this.events.emit("textures-disposed")}get running(){return this.updating}runTask(e){this._processDrapeSources(e,(()=>!0))}_processDrapeSources(e,r){let t=!1;for(const[s,i]of this._renderers){if(e.done)break;(s.destroyed||r(s))&&(i.commitChanges()&&(t=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,t=!0,this._updateSortedDrapeSourceRenderers()),t&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this.events.emit("content-changed"),this._updateHasHighlights(),this._updateRendersOccluded(),this._updateHasWater())}processSyncDrapeSources(){this._processDrapeSources(J,(e=>e.updatePolicy===z.SYNC))}get isEmpty(){return!b.OVERLAY_DRAW_DEBUG_TEXTURE&&!s(this._renderers,(e=>!e.isEmpty))}get hasHighlights(){return this._hasHighlights}get hasWater(){return this._hasWater}get rendersOccluded(){return this._rendersOccluded}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}drawTarget(e,r,t){const s=e.canvasGeometries;if(0===s.numViews)return;const{alignPixelEnabled:i,contentPixelRatio:o}=t;this._screenToWorldRatio=o*e.mapUnitsPerPixel/D;const a=r.output;if(this.isEmpty||a===P.Highlight&&!this.hasHighlights||a===P.Normal&&!this.hasWater||!e.hasSomeSizedView())return;const n=this._rctx;this._camera.pixelRatio=e.pixelRatio*o,this._renderContext.output=a,this._bindParameters.alignPixelEnabled=i,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=a===P.Normal?L.DRAPED_WATER:L.DRAPED_MATERIAL,e.applyViewport(this._rctx);const h=2*e.resolution,d=e.resolution,l=r.fbo;if(l.bind(n,h,d),e.index===v.INNER&&(n.setClearColor(0,0,0,0),n.clearSafe(K.COLOR_BUFFER_BIT)),r.type===x.Occluded&&(this._renderContext.renderOccludedMask=ae),b.OVERLAY_DRAW_DEBUG_TEXTURE&&r.type!==x.Occluded)for(let c=0;c<s.numViews;c++)this._setViewParameters(s.extents[c],e),this._drawDebugTexture(e.resolution,ie[e.index]);this._sortedRenderers.forAll((({drapeSource:t,renderer:i})=>{if(r.type===x.ColorNoRasterImage&&t.drapeSourceType===T.RasterImage)return;const{fullOpacity:o}=t,c=null!=o&&o<1&&a===P.Color?this.bindTemporaryFramebuffer(h,d):null;for(let r=0;r<s.numViews;r++)this._setViewParameters(s.extents[r],e),i.render(this._renderContext);c&&(l.bind(n,h,d),this.view._stage.renderView.compositingHelper.compositeOverlay(this._renderContext.bindParameters,c.colorTexture,o,e.index),c.release())})),n.bindFramebuffer(null),l.generateMipMap(),this._renderContext.resetRenderOccludedMask()}bindTemporaryFramebuffer(e,r){const t=this.view._stage.renderer.fboCache,s=t.acquire(j.RGBA,e,r);return t.rctx.bindFramebuffer(s.fbo),t.rctx.clearSafe(K.COLOR_BUFFER_BIT),s}async reloadShaders(){await this._shaderTechniqueRepository.reloadAll()}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){let i=0;for(const o of this._renderers.values())i=o.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this.view.map.allLayers;this._renderers.forEach(((r,t)=>{const s=e.indexOf(t.layer),i=s>=0,o=this._renderers.size*(t.renderGroup??(i?w.MapLayer:w.ViewLayer))+(i?s:0);this._sortedRenderers.push(new se(t,r,o))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],m(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),_(t.viewMatrix,[-e[0],-e[1],0])}_updateHasWater(){const e=s(this._renderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_updateHasHighlights(){const e=s(this._renderers,(e=>e.hasHighlights));e!==this._hasHighlights&&(this._hasHighlights=e,this.events.emit("has-highlights",e))}_updateRendersOccluded(){const e=s(this._renderers,(e=>e.rendersOccluded));e!==this._rendersOccluded&&(this._rendersOccluded=e,this.events.emit("renders-occluded",e))}_drawDebugTexture(e,r){this._ensureDebugPatternResources(e,r);const t=this._rctx;t.bindTechnique(this._debugTextureTechnique,this._passParameters,null),t.bindVAO(this._quadVAO),t.drawArrays(Q.TRIANGLE_STRIP,0,re(this._quadVAO,"geometry"))}_ensureDebugPatternResources(e,r){if(g(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let a=0;a<e;a++)for(let r=0;r<e;r++){const i=Math.floor(r/10),o=Math.floor(a/10);i<2||o<2||10*i>e-20||10*o>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&o?1&r^1&a?0:255:1&i^1&o?0:128)}const i=new ee(e);i.samplingMode=Z.NEAREST,this._passParameters.texture=new $(this._rctx,i,t);const o=new G;o.hasAlpha=!0,this._debugTextureTechnique=this._shaderTechniqueRepository.acquire(N,o),this._quadVAO=M(this._rctx)}get test(){return{drapedRenderers:Array.from(this._renderers.values()),getDrapeSourceRenderer:e=>this._renderers.get(e)}}};e([u()],te.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([u({autoDestroy:!0})],te.prototype,"_shaderTechniqueRepository",void 0),e([u({constructOnly:!0})],te.prototype,"view",void 0),e([u()],te.prototype,"worldToPCSRatio",void 0),e([u()],te.prototype,"spatialReference",void 0),e([u({type:Boolean,readOnly:!0})],te.prototype,"updating",null),e([u()],te.prototype,"isEmpty",null),te=e([p("esri.views.3d.terrain.OverlayRenderer")],te);class se{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const ie=[[1,.5,.5],[.5,.5,1]],oe=-2,ae=H.OccludeAndTransparent;export{oe as DRAPED_Z,te as OverlayRenderer,ae as overlayRenderOccludedFlag};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import t from"../../../core/PooledArray.js";import{isPromiseLike as s}from"../../../core/promiseUtils.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{isIntersectionHandler as o}from"../state/helpers/SceneIntersectionHelper.js";import{ChangeSet as d}from"./lib/ChangeSet.js";import{UpdatePolicy as a}from"./lib/UpdatePolicy.js";import{isWebGLLayer as h}from"./lib/WebGLLayer.js";import{Model as l}from"./parts/Model.js";import{RenderView as y}from"./parts/RenderView.js";import{TaskPriority as c,noBudget as m}from"../../support/Scheduler.js";let u=class extends r{constructor(e){super(e),this._model=new l,this._layers=new t,this._asyncChangeSet=new d,this._syncChangeSet=new d,this._layerSyncSet=new Set}initialize(){this._set("renderView",new y(this)),this._frameTask=this.view.resourceController.scheduler.registerTask(c.STAGE,this),this.addHandles(this._frameTask)}destroy(){this.removeAllHandles()}get viewingMode(){return this.view.state.viewingMode}get updating(){return this.running||this.renderView.updating||this._frameTask.updating}get renderer(){return this.renderView?.renderer}add(e){this._model.add(e),h(e)&&this._addLayer(e),this.renderView.requestRender()}remove(e){null==e||this.destroyed||(this._model.remove(e),h(e)&&this._removeLayer(e),this.renderView.requestRender())}addMany(e){null!=e&&(this._model.addMany(e),this.renderView.requestRender())}removeMany(e){null!=e&&(this._model?.removeMany(e),this.renderView?.requestRender())}async load(e,r){null!=e&&(Array.isArray(e)||(e=[e]),await Promise.all(e.filter((e=>null==e.glTexture)).map((e=>this.schedule((()=>this._model.has(e)?e.load(this.renderView.renderingContext):null))),r)))}loadImmediate(e){return e.load(this.renderView.renderingContext)}forEachOfType(e,r){this._model.forEachOfType(e,r)}handleEvent(e,r){this.destroyed||(this._model.dirtySet[e](r),this.renderView.requestRender())}get running(){return this._model.dirtySet.dirty||!this._asyncChangeSet.empty}runTask(e){this._frameTask.processQueue(e),this._commit(e)}_commit(e){const r=this._model.dirtySet;this._asyncChangeSet.empty||e.done||(this.renderer.modify(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()),this._layers.forAll((t=>{if(e.done)return;const s=this._layerSyncSet.has(t.id)||t.updatePolicy===a.SYNC,i=s?this._syncChangeSet:this._asyncChangeSet;r.commitLayer(t.id,i),this._layerSyncSet.delete(t.id),i.empty||(this.renderer.modify(i,s?m:e),this.renderView.requestRender(),e.madeProgress())})),this._syncChangeSet.empty||(this.renderer.modify(this._syncChangeSet,m),this.renderView.requestRender(),e.madeProgress()),this._layers.forAll((t=>{e.done||this._layerSyncSet.has(t.id)||t.updatePolicy!==a.ASYNC||(r.commitLayer(t.id,this._asyncChangeSet),this._asyncChangeSet.empty||(this.renderer.modify(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()))})),this._layerSyncSet.clear(),this.notifyChange("running")}commitSyncLayers(){const e=this._model.dirtySet;this._layers.forAll((r=>{(this._layerSyncSet.has(r.id)||r.updatePolicy===a.SYNC)&&(e.commitLayer(r.id,this._syncChangeSet),this._layerSyncSet.delete(r.id))}));for(const r of this._layerSyncSet)e.commitLayer(r,this._syncChangeSet);this._layerSyncSet.clear(),this._syncChangeSet.empty||(this.renderer.modify(this._syncChangeSet,m),this.renderView.requestRender())}_commitLayer(e){this._model.dirtySet.commitLayer(e.id,this._syncChangeSet),this._layerSyncSet.delete(e.id),this._syncChangeSet.empty||(this.renderer.modify(this._syncChangeSet,m),this.renderView.requestRender())}schedule(e,r){return this._frameTask.schedule(e,r)}reschedule(e,r){return this._frameTask.reschedule(e,r)}syncLayer(e){this._layerSyncSet.add(e),this.renderView.requestRender()}getObject(e){return this._model.getObject(e)}get layers(){return this._layers}_addLayer(e){this._layers.includes(e)||this._layers.push(e)}_removeLayer(e){this._commitLayer(e),null!=this._layers.removeUnordered(e)&&(this._model.dirtySet.getResidentRenderGeometries(e.id,this._syncChangeSet.removes),this.renderer.modify(this._syncChangeSet,m))}addRenderPlugin(e,r,t){const i=this.renderer.renderPlugins.add(e,r,t),n=()=>{o(r)&&this.view.sceneIntersectionHelper.addIntersectionHandler(r)};if(s(i))return i.then(n);n()}removeRenderPlugin(e){this.destroyed||(o(e)&&this.view.sceneIntersectionHelper.removeIntersectionHandler(e),this.renderer.renderPlugins.remove(e))}get performanceInfo(){return{renderer:this.renderer.performanceInfo,model:this._model.getStats()}}get test(){const e=this;return{getCount:r=>e._model.test.content.filter((e=>e.type===r)).length,model:e._model}}};u.DebugSettings={endFrameContentValidation:!1},e([i({constructOnly:!0})],u.prototype,"view",void 0),e([i({constructOnly:!0})],u.prototype,"options",void 0),e([i({readOnly:!0})],u.prototype,"viewingMode",null),e([i({constructOnly:!0})],u.prototype,"container",void 0),e([i({readOnly:!0})],u.prototype,"updating",null),e([i({constructOnly:!0})],u.prototype,"_model",void 0),e([i({autoDestroy:!0})],u.prototype,"renderView",void 0),e([i({readOnly:!0})],u.prototype,"renderer",null),e([i({readOnly:!0})],u.prototype,"running",null),u=e([n("esri.views.3d.webgl-engine.Stage")],u);export{u as Stage};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import r from"../../../core/PooledArray.js";import{isPromiseLike as s}from"../../../core/promiseUtils.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{isIntersectionHandler as o}from"../state/helpers/SceneIntersectionHelper.js";import{ChangeSet as d}from"./lib/ChangeSet.js";import{UpdatePolicy as a}from"./lib/UpdatePolicy.js";import{isWebGLLayer as h}from"./lib/WebGLLayer.js";import{Model as l}from"./parts/Model.js";import{RenderView as y}from"./parts/RenderView.js";import{TaskPriority as c,noBudget as m}from"../../support/Scheduler.js";let u=class extends t{constructor(e){super(e),this._model=new l,this._layers=new r,this._asyncChangeSet=new d,this._syncChangeSet=new d,this._layerSyncSet=new Set}initialize(){this._set("renderView",new y(this)),this._frameTask=this.view.resourceController.scheduler.registerTask(c.STAGE,this),this.addHandles(this._frameTask)}destroy(){this.removeAllHandles()}get viewingMode(){return this.view.state.viewingMode}get updating(){return this.running||this.renderView.updating||this._frameTask.updating}get renderer(){return this.renderView?.renderer}add(e){this._model.add(e),h(e)&&this._addLayer(e),this.renderView.requestRender()}remove(e){null==e||this.destroyed||(this._model.remove(e),h(e)&&this._removeLayer(e),this.renderView.requestRender())}addMany(e){null!=e&&(this._model.addMany(e),this.renderView.requestRender())}removeMany(e){null!=e&&(this._model?.removeMany(e),this.renderView?.requestRender())}async load(e,t){null!=e&&(Array.isArray(e)||(e=[e]),await Promise.all(e.filter((e=>null==e.glTexture)).map((e=>this.schedule((()=>this._model.has(e)?e.load(this.renderView.renderingContext):null))),t)))}loadImmediate(e){return e.load(this.renderView.renderingContext)}forEachOfType(e,t){this._model.forEachOfType(e,t)}handleEvent(e,t){this.destroyed||(this._model.dirtySet[e](t),this.renderView.requestRender())}get running(){return this._model.dirtySet.dirty||!this._asyncChangeSet.empty}runTask(e){this._frameTask.processQueue(e),this._commit(e)}_commit(e){const t=this._model.dirtySet;this._asyncChangeSet.empty||e.done||(this.renderer.modify(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()),this._layers.forAll((r=>{if(e.done)return;const s=this._layerSyncSet.has(r.id)||r.updatePolicy===a.SYNC,i=s?this._syncChangeSet:this._asyncChangeSet;t.commitLayer(r.id,i),this._layerSyncSet.delete(r.id),i.empty||(this.renderer.modify(i,s?m:e),this.renderView.requestRender(),e.madeProgress())})),this._syncChangeSet.empty||(this.renderer.modify(this._syncChangeSet,m),this.renderView.requestRender(),e.madeProgress()),this._layers.forAll((r=>{e.done||this._layerSyncSet.has(r.id)||r.updatePolicy!==a.ASYNC||(t.commitLayer(r.id,this._asyncChangeSet),this._asyncChangeSet.empty||(this.renderer.modify(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()))})),this._layerSyncSet.clear(),this.notifyChange("running")}commitSyncLayers(){const e=this._model.dirtySet;this._layers.forAll((t=>{(this._layerSyncSet.has(t.id)||t.updatePolicy===a.SYNC)&&(e.commitLayer(t.id,this._syncChangeSet),this._layerSyncSet.delete(t.id))}));for(const t of this._layerSyncSet)e.commitLayer(t,this._syncChangeSet);this._layerSyncSet.clear(),this._syncChangeSet.empty||(this.renderer.modify(this._syncChangeSet,m),this.renderView.requestRender())}_commitLayer(e){this._model.dirtySet.commitLayer(e.id,this._syncChangeSet),this._layerSyncSet.delete(e.id),this._syncChangeSet.empty||(this.renderer.modify(this._syncChangeSet,m),this.renderView.requestRender())}schedule(e,t){return this._frameTask.schedule(e,t)}reschedule(e,t){return this._frameTask.reschedule(e,t)}syncLayer(e){this._layerSyncSet.add(e),this.renderView.requestRender()}getObject(e){return this._model.getObject(e)}get layers(){return this._layers}_addLayer(e){this._layers.includes(e)||this._layers.push(e)}_removeLayer(e){this._commitLayer(e),null!=this._layers.removeUnordered(e)&&(this._model.dirtySet.getResidentRenderGeometries(e.id,this._syncChangeSet.removes),this.renderer.modify(this._syncChangeSet,m))}addRenderPlugin(e,t,r){const i=this.renderer.renderPlugins.add(e,t,r),n=()=>{o(t)&&this.view.sceneIntersectionHelper.addIntersectionHandler(t)};if(s(i))return i.then(n);n()}removeRenderPlugin(e){this.destroyed||(o(e)&&this.view.sceneIntersectionHelper.removeIntersectionHandler(e),this.renderer.renderPlugins.remove(e))}get performanceInfo(){return this._model.getStats()}get test(){const e=this;return{getCount:t=>e._model.test.content.filter((e=>e.type===t)).length,model:e._model}}};u.DebugSettings={endFrameContentValidation:!1},e([i({constructOnly:!0})],u.prototype,"view",void 0),e([i({constructOnly:!0})],u.prototype,"options",void 0),e([i({readOnly:!0})],u.prototype,"viewingMode",null),e([i({constructOnly:!0})],u.prototype,"container",void 0),e([i({readOnly:!0})],u.prototype,"updating",null),e([i({constructOnly:!0})],u.prototype,"_model",void 0),e([i({autoDestroy:!0})],u.prototype,"renderView",void 0),e([i({readOnly:!0})],u.prototype,"renderer",null),e([i({readOnly:!0})],u.prototype,"running",null),u=e([n("esri.views.3d.webgl-engine.Stage")],u);export{u as Stage};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{releaseMaybe as e}from"../../../../core/maybe.js";import{MemCachePool as t}from"../../../../core/MemCachePool.js";import{PixelFormat as r,SizedPixelFormat as a,TextureWrapMode as s,TextureSamplingMode as h,PixelType as o,RenderbufferFormat as i}from"../../../webgl/enums.js";import{FramebufferObject as c}from"../../../webgl/FramebufferObject.js";import{Renderbuffer as n}from"../../../webgl/Renderbuffer.js";import{RenderbufferDescriptor as p}from"../../../webgl/RenderbufferDescriptor.js";import{Texture as _}from"../../../webgl/Texture.js";import{TextureDescriptor as d}from"../../../webgl/TextureDescriptor.js";class m{constructor(e){this.rctx=e,this._peakMemoryUsage=0,this._allocatedMemory=new Set,this._cache=new t(e.newCache,"FBOCache"),this._depthCache=new t(e.newCache,"DepthTextureCache")}destroy(){this._cache.destroy(),this._depthCache.destroy()}resetPeakMemoryUsage(){this._peakMemoryUsage=0}get peakMemoryUsage(){return this._peakMemoryUsage}acquire(e,t,r){const a=E(e,t,r),s=this._cache.pop(a);if(s)return this.rctx.unbindTexture(s.fbo.colorTexture),this._trackHandle(s);const h=new l(new c(this.rctx,{...w[e],width:t,height:r}),(()=>{this._allocatedMemory.delete(h),h.releaseDepth(),this._cache.put(a,h)}),(e=>(h.releaseDepth(),h.depth=this._acquireDepth(e,h.fbo.width,h.fbo.height),h.fbo.attachDepthStencil(h.depth.attachment),h)));return this.rctx.unbindTexture(h.fbo.colorTexture),this._trackHandle(h)}acquireDepth(e,t,r){return this._acquireDepth(e,t,r)}_acquireDepth(e,t,r){const a=E(e,t,r),s=this._depthCache.pop(a);if(s)return this._trackHandle(s);const h=e===P.DEPTH_STENCIL_TEXTURE?new u(new _(this.rctx,{...C[e],width:t,height:r}),(()=>{this._allocatedMemory.delete(h),this._depthCache.put(a,h)})):new u(new n(this.rctx,{...C[e],width:t,height:r}),(()=>{this._allocatedMemory.delete(h),this._depthCache.put(a,h)}));return this._trackHandle(h)}_trackHandle(e){return this._allocatedMemory.add(e),this._peakMemoryUsage=Math.max(this._peakMemoryUsage,Array.from(this._allocatedMemory.values()).reduce(((e,t)=>e+("colorTexture"in t?t.colorTexture?.gpuMemoryUsage??0:t.memoryUsage)),0)),e}}class l{constructor(e,t,r){this.fbo=e,this.release=t,this.acquireDepth=r}dispose(){this.fbo.dispose()}releaseDepth(){this.fbo.detachDepthStencilTexture(),this.fbo.detachDepthStencilBuffer(),this.depth=e(this.depth)}detachDepth(){const e=this.depth;return this.depth=void 0,this.fbo.detachDepthStencilTexture(),this.fbo.detachDepthStencilBuffer(),e}attachDepth(e){return this.releaseDepth(),e&&(this.fbo.attachDepthStencil(e.attachment),this.depth=e),this}get colorTexture(){return this.fbo?.colorTexture}get memoryUsage(){return this.fbo.gpuMemoryUsage}}class u{constructor(e,t){this.attachment=e,this.release=t}dispose(){this.attachment.dispose()}get memoryUsage(){return this.attachment.gpuMemoryUsage}}function E(e,t,r){return`${e}x${t}x${r}`}var T;!function(e){e[e.RG_CLAMPED=0]="RG_CLAMPED",e[e.RGBA_CLAMPED=1]="RGBA_CLAMPED",e[e.RGBA_CLAMPED_MIPMAP=2]="RGBA_CLAMPED_MIPMAP",e[e.R16F=3]="R16F",e[e.RGBA16F=4]="RGBA16F",e[e.RGBA4=5]="RGBA4"}(T||(T={}));const M=new d;M.pixelFormat=r.RG,M.internalFormat=a.RG8,M.wrapMode=s.CLAMP_TO_EDGE;const D=new d;D.wrapMode=s.CLAMP_TO_EDGE;const A=new d;A.wrapMode=s.CLAMP_TO_EDGE,A.samplingMode=h.LINEAR_MIPMAP_LINEAR,A.hasMipmap=!0,A.maxAnisotropy=8;const R=new d;R.pixelFormat=r.RED,R.dataType=o.HALF_FLOAT,R.internalFormat=a.R16F,R.samplingMode=h.NEAREST;const f=new d;f.dataType=o.HALF_FLOAT,f.internalFormat=a.RGBA16F,f.samplingMode=h.NEAREST;const g=new d;g.internalFormat=a.RGBA4,g.dataType=o.UNSIGNED_SHORT_4_4_4_4;const w={[T.RG_CLAMPED]:M,[T.RGBA_CLAMPED]:D,[T.RGBA_CLAMPED_MIPMAP]:A,[T.R16F]:R,[T.RGBA16F]:f,[T.RGBA4]:g};var P;!function(e){e[e.DEPTH_STENCIL_TEXTURE=0]="DEPTH_STENCIL_TEXTURE",e[e.DEPTH16_BUFFER=1]="DEPTH16_BUFFER"}(P||(P={}));const y=new d;y.pixelFormat=r.DEPTH_STENCIL,y.dataType=o.UNSIGNED_INT_24_8,y.samplingMode=h.NEAREST,y.wrapMode=s.CLAMP_TO_EDGE;const C={[P.DEPTH_STENCIL_TEXTURE]:y,[P.DEPTH16_BUFFER]:new p(i.DEPTH_COMPONENT16,4)};export{T as ColorFormat,P as DepthFormat,m as FBOCache};
5
+ import{releaseMaybe as e}from"../../../../core/maybe.js";import{MemCachePool as t}from"../../../../core/MemCachePool.js";import{PixelFormat as r,SizedPixelFormat as a,TextureWrapMode as s,PixelType as o,TextureSamplingMode as h,RenderbufferFormat as i}from"../../../webgl/enums.js";import{FramebufferObject as c}from"../../../webgl/FramebufferObject.js";import{Renderbuffer as n}from"../../../webgl/Renderbuffer.js";import{RenderbufferDescriptor as p}from"../../../webgl/RenderbufferDescriptor.js";import{Texture as _}from"../../../webgl/Texture.js";import{TextureDescriptor as d}from"../../../webgl/TextureDescriptor.js";class m{constructor(e){this.rctx=e,this._peakMemoryUsage=0,this._allocatedMemory=new Set,this._cache=new t(e.newCache,"FBOCache"),this._depthCache=new t(e.newCache,"DepthTextureCache")}destroy(){this._cache.destroy(),this._depthCache.destroy()}resetPeakMemoryUsage(){this._peakMemoryUsage=0}get peakMemoryUsage(){return this._peakMemoryUsage}acquire(e,t,r){const a=T(e,t,r),s=this._cache.pop(a);if(s)return this.rctx.unbindTexture(s.fbo.colorTexture),this._trackHandle(s);const o=new l(new c(this.rctx,{...A[e],width:t,height:r}),(()=>{this._allocatedMemory.delete(o),o.releaseDepth(),this._cache.put(a,o)}),(e=>(o.releaseDepth(),o.depth=this._acquireDepth(e,o.fbo.width,o.fbo.height),o.fbo.attachDepthStencil(o.depth.attachment),o)));return this.rctx.unbindTexture(o.fbo.colorTexture),this._trackHandle(o)}acquireDepth(e,t,r){return this._acquireDepth(e,t,r)}_acquireDepth(e,t,r){const a=T(e,t,r),s=this._depthCache.pop(a);if(s)return this._trackHandle(s);const o=e===y.DEPTH_STENCIL_TEXTURE?new u(new _(this.rctx,{...b[e],width:t,height:r}),(()=>{this._allocatedMemory.delete(o),this._depthCache.put(a,o)})):new u(new n(this.rctx,{...b[e],width:t,height:r}),(()=>{this._allocatedMemory.delete(o),this._depthCache.put(a,o)}));return this._trackHandle(o)}_trackHandle(e){return this._allocatedMemory.add(e),this._peakMemoryUsage=Math.max(this._peakMemoryUsage,Array.from(this._allocatedMemory.values()).reduce(((e,t)=>e+("colorTexture"in t?t.colorTexture?.gpuMemoryUsage??0:t.memoryUsage)),0)),e}}class l{constructor(e,t,r){this.fbo=e,this.release=t,this.acquireDepth=r}dispose(){this.fbo.dispose()}releaseDepth(){this.fbo.detachDepthStencilTexture(),this.fbo.detachDepthStencilBuffer(),this.depth=e(this.depth)}detachDepth(){const e=this.depth;return this.depth=void 0,this.fbo.detachDepthStencilTexture(),this.fbo.detachDepthStencilBuffer(),e}attachDepth(e){return this.releaseDepth(),e&&(this.fbo.attachDepthStencil(e.attachment),this.depth=e),this}get colorTexture(){return this.fbo?.colorTexture}get memoryUsage(){return this.fbo.gpuMemoryUsage}}class u{constructor(e,t){this.attachment=e,this.release=t}dispose(){this.attachment.dispose()}get memoryUsage(){return this.attachment.gpuMemoryUsage}}function T(e,t,r){return`${e}x${t}x${r}`}var E;!function(e){e[e.RG=0]="RG",e[e.RGBA4=1]="RGBA4",e[e.RGBA=2]="RGBA",e[e.RGBA_MIPMAP=3]="RGBA_MIPMAP",e[e.R16F=4]="R16F",e[e.RGBA16F=5]="RGBA16F"}(E||(E={}));const M=new d;M.pixelFormat=r.RG,M.internalFormat=a.RG8,M.wrapMode=s.CLAMP_TO_EDGE;const R=new d;R.internalFormat=a.RGBA4,R.dataType=o.UNSIGNED_SHORT_4_4_4_4,R.wrapMode=s.CLAMP_TO_EDGE;const f=new d;f.wrapMode=s.CLAMP_TO_EDGE;const D=new d;D.wrapMode=s.CLAMP_TO_EDGE,D.samplingMode=h.LINEAR_MIPMAP_LINEAR,D.hasMipmap=!0,D.maxAnisotropy=8;const g=new d;g.pixelFormat=r.RED,g.dataType=o.HALF_FLOAT,g.internalFormat=a.R16F,g.samplingMode=h.NEAREST;const w=new d;w.dataType=o.HALF_FLOAT,w.internalFormat=a.RGBA16F,w.samplingMode=h.NEAREST;const A={[E.RG]:M,[E.RGBA4]:R,[E.RGBA]:f,[E.RGBA_MIPMAP]:D,[E.R16F]:g,[E.RGBA16F]:w};var y;!function(e){e[e.DEPTH_STENCIL_TEXTURE=0]="DEPTH_STENCIL_TEXTURE",e[e.DEPTH16_BUFFER=1]="DEPTH16_BUFFER"}(y||(y={}));const x=new d;x.pixelFormat=r.DEPTH_STENCIL,x.dataType=o.UNSIGNED_INT_24_8,x.samplingMode=h.NEAREST,x.wrapMode=s.CLAMP_TO_EDGE;const b={[y.DEPTH_STENCIL_TEXTURE]:x,[y.DEPTH16_BUFFER]:new p(i.DEPTH_COMPONENT16,4)};export{E as ColorFormat,y as DepthFormat,m as FBOCache};
@@ -39,7 +39,6 @@ import{AlignPixel as e}from"./AlignPixel.glsl.js";import{ReadLinearDepth as t}fr
39
39
  ${s.multipassEnabled?i`
40
40
  // Read the rgba data from the texture linear depth
41
41
  vec4 terrainDepthData = texelFetch(terrainDepthTexture, ivec2(gl_FragCoord.xy), 0);
42
-
43
42
  float terrainDepth = linearDepthFromRGBA(terrainDepthData, nearFar);
44
43
 
45
44
  // If HUD vertex is behind terrain and the terrain depth is not the initialize value (e.g. we are not looking at the sky)
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{releaseMaybe as e}from"../../../../core/maybe.js";import{s as r}from"../../../../chunks/vec2.js";import{c as i}from"../../../../chunks/vec4.js";import{c as t}from"../../../../chunks/vec4f64.js";import{ColorFormat as s}from"../core/FBOCache.js";import{Default3D as a}from"./DefaultVertexAttributeLocations.js";import{Pos2Tex as o}from"./DefaultVertexBufferLayouts.js";import{createQuadVAO as h}from"./glUtil3D.js";import{VertexArrayObject as p}from"./VertexArrayObject.js";import{HighlightApplyTechnique as l}from"../shaders/HighlightApplyTechnique.js";import{H as m}from"../../../../chunks/HighlightBlur.glsl.js";import{HighlightBlurTechnique as u}from"../shaders/HighlightBlurTechnique.js";import{H as c}from"../../../../chunks/HighlightDownsample.glsl.js";import{HighlightDownsampleTechnique as n}from"../shaders/HighlightDownsampleTechnique.js";import{HighlightPassParameters as _}from"../shaders/HighlightPassParameters.js";import{BufferObject as g}from"../../../webgl/BufferObject.js";import{ClearBufferBit as d,PixelFormat as w,PixelType as f,TextureWrapMode as b,Usage as v,PrimitiveType as T}from"../../../webgl/enums.js";import{FramebufferObject as q}from"../../../webgl/FramebufferObject.js";import{TextureDescriptor as M}from"../../../webgl/TextureDescriptor.js";import{vertexCount as P}from"../../../webgl/Util.js";const x=32;class A{constructor(e,r){this._techniqueRep=e,this._fbos=r,this._viewportToRestore=t(),this._passParameters=new _,this._downsampleDrawParameters=new c,this._blurDrawParameters=new m,this._grid={coverageMipmap:null,vao:null,verticalCellCount:0,horizontalCellCount:0,cellPixelSize:0,mipmapLevels:0,viewportWidth:0,viewportHeight:0}}_ensureResources(){this._quadVAO||(this._quadVAO=h(this._fbos.rctx),this._blurTechnique=this._techniqueRep.acquire(u),this._downsampleTechnique=this._techniqueRep.acquire(n),this._applyTechnique=this._techniqueRep.acquire(l))}dispose(){if(this._blurTechnique=e(this._blurTechnique),this._downsampleTechnique=e(this._downsampleTechnique),this._applyTechnique=e(this._applyTechnique),this._grid.coverageMipmap)for(let e=1;e<this._grid.coverageMipmap.length;e++)this._grid.coverageMipmap[e].dispose();this._grid.vao&&this._grid.vao.dispose(),this._quadVAO&&(this._quadVAO.dispose(),this._quadVAO=null)}setDefaultOptions(e){this._passParameters={...new _,...e}}render(e,t,a){this._ensureResources();const o=e.camera;i(this._viewportToRestore,o.fullViewport);const h=o.fullWidth,p=o.fullHeight,l=o.pixelRatio,m=Math.ceil(h/l),u=Math.ceil(p/l),c=this._fbos.rctx;c.bindVAO(this._quadVAO),this._gridUpdateResources(t,x),this._gridComputeMipmap(e),this._passParameters.highlightTexture=t.colorTexture,this._passParameters.coverageTexture=this._grid.coverageMipmap[this._grid.mipmapLevels].colorTexture;const n=c.bindTechnique(this._blurTechnique,this._passParameters,e),_=this._grid.vao;c.bindVAO(_);const g=this._fbos.acquire(s.RGBA_CLAMPED,m,u);c.bindFramebuffer(g.fbo),c.setViewport(0,0,m,u),c.setClearColor(0,0,0,0),c.clear(d.COLOR_BUFFER_BIT),this._blurDrawParameters.blurInputTexture=t.colorTexture,r(this._blurDrawParameters.blurSize,1/m,0),n.bindDraw(this._blurDrawParameters,e,this._passParameters),c.drawArrays(this._blurTechnique.primitiveType,0,P(_,"geometry"));const w=this._fbos.acquire(s.RGBA_CLAMPED,m,u);c.bindFramebuffer(w.fbo),c.clear(d.COLOR_BUFFER_BIT),this._blurDrawParameters.blurInputTexture=g.colorTexture,r(this._blurDrawParameters.blurSize,0,1/u),n.bindDraw(this._blurDrawParameters,e,this._passParameters),c.drawArrays(this._blurTechnique.primitiveType,0,P(_,"geometry")),c.bindFramebuffer(a),c.setViewport(this._viewportToRestore[0],this._viewportToRestore[1],this._viewportToRestore[2],this._viewportToRestore[3]),this._passParameters.blurTexture=w.colorTexture,c.bindTechnique(this._applyTechnique,this._passParameters,e),c.drawArrays(this._applyTechnique.primitiveType,0,P(_,"geometry")),w.release(),g.release(),c.bindVAO(null)}_gridUpdateResources(e,r){const i=this._fbos.rctx,t=this._grid;let s=!1;if(null===t.coverageMipmap&&(t.coverageMipmap=[e],s=!0),t.viewportWidth===e.width&&t.viewportHeight===e.height||(s=!0,t.viewportWidth=e.width,t.viewportHeight=e.height),t.coverageMipmap[0]=e,t.cellPixelSize!==r&&(t.cellPixelSize=r,s=!0),s){for(let e=1;e<t.coverageMipmap.length;e++)t.coverageMipmap[e].dispose();t.mipmapLevels=Math.ceil(Math.log(t.cellPixelSize)*Math.LOG2E),t.coverageMipmap.length=t.mipmapLevels+1;for(let e=0;e<t.mipmapLevels;e++){const r=t.coverageMipmap[e],s=new M(Math.ceil(r.width/2),Math.ceil(r.height/2));s.pixelFormat=w.RGB,s.dataType=f.UNSIGNED_SHORT_5_6_5,s.wrapMode=b.CLAMP_TO_EDGE,t.coverageMipmap[e+1]=new q(i,s)}}const h=Math.ceil(e.height/t.cellPixelSize),l=Math.ceil(e.width/t.cellPixelSize);if(!t.vao||t.verticalCellCount!==h||t.horizontalCellCount!==l){t.verticalCellCount=h,t.horizontalCellCount=l;const e=h+1,r=l+1,s=1/h,m=1/l,u=6,c=4,n=new Float32Array(u*c*e*r);let _=0;for(let i=0;i<e;i++)for(let e=0;e<r;e++)n[_]=(e-.5)*m*2-1,n[_+1]=(i-.5)*s*2-1,n[_+2]=e*m,n[_+3]=i*s,n[_+4]=(e+.5)*m*2-1,n[_+5]=(i-.5)*s*2-1,n[_+6]=e*m,n[_+7]=i*s,n[_+8]=(e-.5)*m*2-1,n[_+9]=(i+.5)*s*2-1,n[_+10]=e*m,n[_+11]=i*s,n[_+12]=(e-.5)*m*2-1,n[_+13]=(i+.5)*s*2-1,n[_+14]=e*m,n[_+15]=i*s,n[_+16]=(e+.5)*m*2-1,n[_+17]=(i-.5)*s*2-1,n[_+18]=e*m,n[_+19]=i*s,n[_+20]=(e+.5)*m*2-1,n[_+21]=(i+.5)*s*2-1,n[_+22]=e*m,n[_+23]=i*s,_+=u*c;t.vao&&t.vao.dispose(),t.vao=new p(i,a,{geometry:o},{geometry:g.createVertex(i,v.STATIC_DRAW,n)})}}_gridComputeMipmap(e){const i=this._fbos.rctx,t=this._grid,s=i.bindTechnique(this._downsampleTechnique,this._passParameters,e);i.bindVAO(this._quadVAO);for(let a=0;a<t.mipmapLevels;a++){i.bindFramebuffer(t.coverageMipmap[a+1]);const o=t.coverageMipmap[a+1].width,h=t.coverageMipmap[a+1].height;this._downsampleDrawParameters.inputTexture=t.coverageMipmap[a].colorTexture,r(this._downsampleDrawParameters.invFramebufferDim,1/o,1/h),s.bindDraw(this._downsampleDrawParameters,e,this._passParameters),i.setViewport(0,0,o,h),i.drawArrays(T.TRIANGLE_STRIP,0,P(this._quadVAO,"geometry"))}}get gpuMemoryUsage(){return this._grid.coverageMipmap?.reduce(((e,r)=>e+r.gpuMemoryUsage),0)??0}get test(){return{coverage:this._grid.coverageMipmap}}}export{A as Highlight};
5
+ import{releaseMaybe as e}from"../../../../core/maybe.js";import{s as r}from"../../../../chunks/vec2.js";import{c as i}from"../../../../chunks/vec4.js";import{c as t}from"../../../../chunks/vec4f64.js";import{ColorFormat as s}from"../core/FBOCache.js";import{Default3D as a}from"./DefaultVertexAttributeLocations.js";import{Pos2Tex as o}from"./DefaultVertexBufferLayouts.js";import{createQuadVAO as h}from"./glUtil3D.js";import{VertexArrayObject as p}from"./VertexArrayObject.js";import{HighlightApplyTechnique as l}from"../shaders/HighlightApplyTechnique.js";import{H as m}from"../../../../chunks/HighlightBlur.glsl.js";import{HighlightBlurTechnique as u}from"../shaders/HighlightBlurTechnique.js";import{H as c}from"../../../../chunks/HighlightDownsample.glsl.js";import{HighlightDownsampleTechnique as n}from"../shaders/HighlightDownsampleTechnique.js";import{HighlightPassParameters as _}from"../shaders/HighlightPassParameters.js";import{BufferObject as g}from"../../../webgl/BufferObject.js";import{ClearBufferBit as d,PixelFormat as w,PixelType as f,TextureWrapMode as b,Usage as v,PrimitiveType as T}from"../../../webgl/enums.js";import{FramebufferObject as q}from"../../../webgl/FramebufferObject.js";import{TextureDescriptor as M}from"../../../webgl/TextureDescriptor.js";import{vertexCount as P}from"../../../webgl/Util.js";const x=32;class y{constructor(e,r){this._techniqueRep=e,this._fbos=r,this._viewportToRestore=t(),this._passParameters=new _,this._downsampleDrawParameters=new c,this._blurDrawParameters=new m,this._grid={coverageMipmap:null,vao:null,verticalCellCount:0,horizontalCellCount:0,cellPixelSize:0,mipmapLevels:0,viewportWidth:0,viewportHeight:0}}_ensureResources(){this._quadVAO||(this._quadVAO=h(this._fbos.rctx),this._blurTechnique=this._techniqueRep.acquire(u),this._downsampleTechnique=this._techniqueRep.acquire(n),this._applyTechnique=this._techniqueRep.acquire(l))}dispose(){if(this._blurTechnique=e(this._blurTechnique),this._downsampleTechnique=e(this._downsampleTechnique),this._applyTechnique=e(this._applyTechnique),this._grid.coverageMipmap)for(let e=1;e<this._grid.coverageMipmap.length;e++)this._grid.coverageMipmap[e].dispose();this._grid.vao&&this._grid.vao.dispose(),this._quadVAO&&(this._quadVAO.dispose(),this._quadVAO=null)}setDefaultOptions(e){this._passParameters={...new _,...e}}render(e,t,a){this._ensureResources();const o=e.camera;i(this._viewportToRestore,o.fullViewport);const h=o.fullWidth,p=o.fullHeight,l=o.pixelRatio,m=Math.ceil(h/l),u=Math.ceil(p/l),c=this._fbos.rctx;c.bindVAO(this._quadVAO),this._gridUpdateResources(t,x),this._gridComputeMipmap(e),this._passParameters.highlightTexture=t.colorTexture,this._passParameters.coverageTexture=this._grid.coverageMipmap[this._grid.mipmapLevels].colorTexture;const n=c.bindTechnique(this._blurTechnique,this._passParameters,e),_=this._grid.vao;c.bindVAO(_);const g=this._fbos.acquire(s.RGBA4,m,u);c.bindFramebuffer(g.fbo),c.setViewport(0,0,m,u),c.setClearColor(0,0,0,0),c.clear(d.COLOR_BUFFER_BIT),this._blurDrawParameters.blurInputTexture=t.colorTexture,r(this._blurDrawParameters.blurSize,1/m,0),n.bindDraw(this._blurDrawParameters,e,this._passParameters),c.drawArrays(this._blurTechnique.primitiveType,0,P(_,"geometry"));const w=this._fbos.acquire(s.RGBA4,m,u);c.bindFramebuffer(w.fbo),c.clear(d.COLOR_BUFFER_BIT),this._blurDrawParameters.blurInputTexture=g.colorTexture,r(this._blurDrawParameters.blurSize,0,1/u),n.bindDraw(this._blurDrawParameters,e,this._passParameters),c.drawArrays(this._blurTechnique.primitiveType,0,P(_,"geometry")),c.bindFramebuffer(a),c.setViewport(this._viewportToRestore[0],this._viewportToRestore[1],this._viewportToRestore[2],this._viewportToRestore[3]),this._passParameters.blurTexture=w.colorTexture,c.bindTechnique(this._applyTechnique,this._passParameters,e),c.drawArrays(this._applyTechnique.primitiveType,0,P(_,"geometry")),w.release(),g.release(),c.bindVAO(null)}_gridUpdateResources(e,r){const i=this._fbos.rctx,t=this._grid;let s=!1;if(null===t.coverageMipmap&&(t.coverageMipmap=[e],s=!0),t.viewportWidth===e.width&&t.viewportHeight===e.height||(s=!0,t.viewportWidth=e.width,t.viewportHeight=e.height),t.coverageMipmap[0]=e,t.cellPixelSize!==r&&(t.cellPixelSize=r,s=!0),s){for(let e=1;e<t.coverageMipmap.length;e++)t.coverageMipmap[e].dispose();t.mipmapLevels=Math.ceil(Math.log(t.cellPixelSize)*Math.LOG2E),t.coverageMipmap.length=t.mipmapLevels+1;for(let e=0;e<t.mipmapLevels;e++){const r=t.coverageMipmap[e],s=new M(Math.ceil(r.width/2),Math.ceil(r.height/2));s.pixelFormat=w.RGB,s.dataType=f.UNSIGNED_SHORT_5_6_5,s.wrapMode=b.CLAMP_TO_EDGE,t.coverageMipmap[e+1]=new q(i,s)}}const h=Math.ceil(e.height/t.cellPixelSize),l=Math.ceil(e.width/t.cellPixelSize);if(!t.vao||t.verticalCellCount!==h||t.horizontalCellCount!==l){t.verticalCellCount=h,t.horizontalCellCount=l;const e=h+1,r=l+1,s=1/h,m=1/l,u=6,c=4,n=new Float32Array(u*c*e*r);let _=0;for(let i=0;i<e;i++)for(let e=0;e<r;e++)n[_]=(e-.5)*m*2-1,n[_+1]=(i-.5)*s*2-1,n[_+2]=e*m,n[_+3]=i*s,n[_+4]=(e+.5)*m*2-1,n[_+5]=(i-.5)*s*2-1,n[_+6]=e*m,n[_+7]=i*s,n[_+8]=(e-.5)*m*2-1,n[_+9]=(i+.5)*s*2-1,n[_+10]=e*m,n[_+11]=i*s,n[_+12]=(e-.5)*m*2-1,n[_+13]=(i+.5)*s*2-1,n[_+14]=e*m,n[_+15]=i*s,n[_+16]=(e+.5)*m*2-1,n[_+17]=(i-.5)*s*2-1,n[_+18]=e*m,n[_+19]=i*s,n[_+20]=(e+.5)*m*2-1,n[_+21]=(i+.5)*s*2-1,n[_+22]=e*m,n[_+23]=i*s,_+=u*c;t.vao&&t.vao.dispose(),t.vao=new p(i,a,{geometry:o},{geometry:g.createVertex(i,v.STATIC_DRAW,n)})}}_gridComputeMipmap(e){const i=this._fbos.rctx,t=this._grid,s=i.bindTechnique(this._downsampleTechnique,this._passParameters,e);i.bindVAO(this._quadVAO);for(let a=0;a<t.mipmapLevels;a++){i.bindFramebuffer(t.coverageMipmap[a+1]);const o=t.coverageMipmap[a+1].width,h=t.coverageMipmap[a+1].height;this._downsampleDrawParameters.inputTexture=t.coverageMipmap[a].colorTexture,r(this._downsampleDrawParameters.invFramebufferDim,1/o,1/h),s.bindDraw(this._downsampleDrawParameters,e,this._passParameters),i.setViewport(0,0,o,h),i.drawArrays(T.TRIANGLE_STRIP,0,P(this._quadVAO,"geometry"))}}get gpuMemoryUsage(){return this._grid.coverageMipmap?.reduce(((e,r)=>e+r.gpuMemoryUsage),0)??0}get test(){return{coverage:this._grid.coverageMipmap}}}export{y as Highlight};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import{releaseMaybe as t}from"../../../../core/maybe.js";import{c as e}from"../../../../chunks/vec4.js";import{f as r}from"../../../../chunks/vec4f64.js";import{ColorFormat as i,DepthFormat as h}from"../core/FBOCache.js";import{TransparencyPassType as s}from"./TransparencyPassType.js";import{ClearBufferBit as o}from"../../../webgl/enums.js";import{ensureAttachmentMaxSize as c}from"../../../webgl/FramebufferObject.js";class a{constructor(t,e){this._fbos=t,this._compositingHelper=e,this.width=4,this.height=4,this._backgroundColor=r(0,0,0,1)}dispose(){this.releaseBuffers()}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){e(this._backgroundColor,t)}get framebuffer(){return this.color.detachDepth(),this.color.attachDepth(this.depth),this.color.fbo}get colorTexture(){return this.color.colorTexture}get depthTexture(){return this.depth.attachment}swapColorBuffer(){const t=this.color;return this._color=null,t}initializeFrame(t){const e=this._fbos.rctx;this.width=t.fullWidth,this.height=t.fullHeight,c(this,e.parameters.maxTextureSize),this.releaseBuffers(),this.bindFbo(),e.setClearStencil(0);const r=this._backgroundColor;e.setClearColor(r[0]*r[3],r[1]*r[3],r[2]*r[3],r[3]),e.clearSafe(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT|o.STENCIL_BUFFER_BIT)}releaseBuffers(){this._color?.detachDepth(),this._color=t(this._color),this._depth=t(this._depth)}compositeAtmosphereToMain(t,e,r,i){this._bindTarget(this.color),this._compositingHelper.compositeAtmosphere(t,r,i,e),this._bindTarget(this.color,this.depth)}renderHUDVisibility(t,e,r){return t?.fbo.width===this.width&&t?.fbo.height===this.height||(t?.release(),t=this._fbos.acquire(i.RGBA_CLAMPED,this.width,this.height)),t.attachDepth(r||this.depth),this._fbos.rctx.bindFramebuffer(t.fbo),this.renderToFBO(e,b),t.detachDepth(),t}compositeToHUDVisibility(t,e){this._fbos.rctx.bindFramebuffer(t.hudVisibility?.fbo),this._compositingHelper.compositeHUD(t,e)}renderOITPass(t,e,r){let o,c;switch(e){case s.Color:o=this._fbos.acquire(i.RGBA16F,this.width,this.height),c=[0,0,0,0];break;case s.Alpha:o=this._fbos.acquire(i.R16F,this.width,this.height),c=[1,1,1,1];break;case s.FrontFace:o=this._fbos.acquire(i.RGBA_CLAMPED,this.width,this.height),c=[0,0,0,0]}return r?(o.acquireDepth(h.DEPTH16_BUFFER),this._fbos.rctx.bindFramebuffer(o.fbo),this.renderToFBO(t,c,!0,!0),o.releaseDepth()):(o.attachDepth(this.depth),this._fbos.rctx.bindFramebuffer(o.fbo),this.renderToFBO(t,c),o.detachDepth()),o}compositeToFramebuffer(t,e,r,i){this.bindFbo(),this._compositingHelper.composite(t,e,r,i)}compositeTransparentOntoOpaque(t,e,r,i,h){h?(this._fbos.rctx.bindFramebuffer(h.fbo),this._fbos.rctx.setClearColor(0,0,0,1e-13),this._fbos.rctx.clearSafe(o.COLOR_BUFFER_BIT)):this.bindFbo(),this._compositingHelper.compositeOIT(t,e.colorTexture,r.colorTexture,i.colorTexture)}renderDepthDetached(t){this._bindTarget(this.color),t(),this._bindTarget(this.color,this.depth)}renderToCachedFBO(e,r,s,o=h.DEPTH16_BUFFER,c=this.width,a=this.height){return e?.fbo.width===c&&e?.fbo.height===a||(e=t(e)),e=e??this._fbos.acquire(i.RGBA_CLAMPED,c,a),null!=o&&e.acquireDepth(o),this._fbos.rctx.bindFramebuffer(e.fbo),this.renderToFBO(r,s,!0,!0),e}renderToFBO(t,e,r=!1,i=!1){const h=this._fbos.rctx;let s=0;if(e){const t=1e-13,r=Math.max(t,e[3]);h.setClearColor(e[0],e[1],e[2],r),s|=o.COLOR_BUFFER_BIT}r&&(s|=o.DEPTH_BUFFER_BIT),!1===i?i=0:(!0===i&&(i=255),s|=o.STENCIL_BUFFER_BIT),s&&h.clearSafe(s,i),t(),h.gl.flush()}renderToTargets(t,e,r,i,h=!1,s=!1){this._bindTarget(e,r),this.renderToFBO(t,i,h,s),e.detachDepth()}bindFbo(){this._bindTarget(this.color,this.depth)}_bindTarget(t,e){t.detachDepth(),t.attachDepth(e),this._fbos.rctx.bindFramebuffer(t.fbo)}get gpuMemoryUsage(){return(this._color?.colorTexture?.gpuMemoryUsage??0)+(this._depth?.memoryUsage??0)}get color(){return this._color||(this._color=this._fbos.acquire(i.RGBA_CLAMPED,this.width,this.height)),this._color}get depth(){return this._depth||(this._depth=this._fbos.acquireDepth(h.DEPTH_STENCIL_TEXTURE,this.width,this.height)),this._depth}}const b=[0,1,0,1];export{a as OffscreenRendering};
5
+ import"../../../../core/has.js";import{releaseMaybe as t}from"../../../../core/maybe.js";import{c as e}from"../../../../chunks/vec4.js";import{f as r}from"../../../../chunks/vec4f64.js";import{ColorFormat as i,DepthFormat as h}from"../core/FBOCache.js";import{TransparencyPassType as s}from"./TransparencyPassType.js";import{ClearBufferBit as o}from"../../../webgl/enums.js";import{ensureAttachmentMaxSize as c}from"../../../webgl/FramebufferObject.js";class a{constructor(t,e){this._fbos=t,this._compositingHelper=e,this.width=4,this.height=4,this._backgroundColor=r(0,0,0,1)}dispose(){this.releaseBuffers()}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){e(this._backgroundColor,t)}get framebuffer(){return this.color.detachDepth(),this.color.attachDepth(this.depth),this.color.fbo}get colorTexture(){return this.color.colorTexture}get depthTexture(){return this.depth.attachment}swapColorBuffer(){const t=this.color;return this._color=null,t}initializeFrame(t){const e=this._fbos.rctx;this.width=t.fullWidth,this.height=t.fullHeight,c(this,e.parameters.maxTextureSize),this.releaseBuffers(),this.bindFbo(),e.setClearStencil(0);const r=this._backgroundColor;e.setClearColor(r[0]*r[3],r[1]*r[3],r[2]*r[3],r[3]),e.clearSafe(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT|o.STENCIL_BUFFER_BIT)}releaseBuffers(){this._color?.detachDepth(),this._color=t(this._color),this._depth=t(this._depth)}compositeAtmosphereToMain(t,e,r,i){this._bindTarget(this.color),this._compositingHelper.compositeAtmosphere(t,r,i,e),this._bindTarget(this.color,this.depth)}renderHUDVisibility(t,e,r){return t?.fbo.width===this.width&&t?.fbo.height===this.height||(t?.release(),t=this._fbos.acquire(i.RGBA4,this.width,this.height)),t.attachDepth(r||this.depth),this._fbos.rctx.bindFramebuffer(t.fbo),this.renderToFBO(e,b),t.detachDepth(),t}compositeToHUDVisibility(t,e){this._fbos.rctx.bindFramebuffer(t.hudVisibility?.fbo),this._compositingHelper.compositeHUD(t,e)}renderOITPass(t,e,r){let o,c;switch(e){case s.Color:o=this._fbos.acquire(i.RGBA16F,this.width,this.height),c=[0,0,0,0];break;case s.Alpha:o=this._fbos.acquire(i.R16F,this.width,this.height),c=[1,1,1,1];break;case s.FrontFace:o=this._fbos.acquire(i.RGBA,this.width,this.height),c=[0,0,0,0]}return r?(o.acquireDepth(h.DEPTH16_BUFFER),this._fbos.rctx.bindFramebuffer(o.fbo),this.renderToFBO(t,c,!0,!0),o.releaseDepth()):(o.attachDepth(this.depth),this._fbos.rctx.bindFramebuffer(o.fbo),this.renderToFBO(t,c),o.detachDepth()),o}compositeToFramebuffer(t,e,r,i){this.bindFbo(),this._compositingHelper.composite(t,e,r,i)}compositeTransparentOntoOpaque(t,e,r,i,h){h?(this._fbos.rctx.bindFramebuffer(h.fbo),this._fbos.rctx.setClearColor(0,0,0,1e-13),this._fbos.rctx.clearSafe(o.COLOR_BUFFER_BIT)):this.bindFbo(),this._compositingHelper.compositeOIT(t,e.colorTexture,r.colorTexture,i.colorTexture)}renderDepthDetached(t){this._bindTarget(this.color),t(),this._bindTarget(this.color,this.depth)}renderToCachedFBO(e,r,s,o=i.RGBA,c=h.DEPTH16_BUFFER,a=this.width,b=this.height){return e?.fbo.width===a&&e?.fbo.height===b||(e=t(e)),e=e??this._fbos.acquire(o,a,b),null!=c&&e.acquireDepth(c),this._fbos.rctx.bindFramebuffer(e.fbo),this.renderToFBO(r,s,!0,!0),e}renderToFBO(t,e,r=!1,i=!1){const h=this._fbos.rctx;let s=0;if(e){const t=1e-13,r=Math.max(t,e[3]);h.setClearColor(e[0],e[1],e[2],r),s|=o.COLOR_BUFFER_BIT}r&&(s|=o.DEPTH_BUFFER_BIT),!1===i?i=0:(!0===i&&(i=255),s|=o.STENCIL_BUFFER_BIT),s&&h.clearSafe(s,i),t(),h.gl.flush()}renderToTargets(t,e,r,i,h=!1,s=!1){this._bindTarget(e,r),this.renderToFBO(t,i,h,s),e.detachDepth()}bindFbo(){this._bindTarget(this.color,this.depth)}_bindTarget(t,e){t.detachDepth(),t.attachDepth(e),this._fbos.rctx.bindFramebuffer(t.fbo)}get gpuMemoryUsage(){return(this._color?.colorTexture?.gpuMemoryUsage??0)+(this._depth?.memoryUsage??0)}get color(){return this._color||(this._color=this._fbos.acquire(i.RGBA,this.width,this.height)),this._color}get depth(){return this._depth||(this._depth=this._fbos.acquireDepth(h.DEPTH_STENCIL_TEXTURE,this.width,this.height)),this._depth}}const b=[0,1,0,1];export{a as OffscreenRendering};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{update as t}from"../../../../core/arrayUtils.js";import has from"../../../../core/has.js";import{removeMaybe as s,disposeMaybe as i,destroyMaybe as a,releaseMaybe as n}from"../../../../core/maybe.js";import h from"../../../../core/PooledArray.js";import{watch as o,syncAndInitial as d,initial as l,sync as _}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{j as m,a as u,m as f}from"../../../../chunks/mat4.js";import{I as g,c as T}from"../../../../chunks/mat4f64.js";import{h as E}from"../../../../chunks/vec4.js";import{a as R}from"../../../../chunks/boundedPlane.js";import A from"../../support/debugFlags.js";import{TransparencyMode as P}from"../../terrain/TerrainRenderer.js";import{FBOCache as b,ColorFormat as S,DepthFormat as y}from"../core/FBOCache.js";import{RenderPassManager as C}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as I}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as O}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{AnimationTimeStep as w}from"./AnimationTimeStep.js";import{Decorations as D,RenderRequestType as N,StencilBits as L}from"./basicInterfaces.js";import{BoundingInfo as M}from"./BoundingInfo.js";import{ZERO as H,union as x}from"./depthRange.js";import{depthRangeFromScene as v}from"./depthRangeUtils.js";import{Highlight as F}from"./Highlight.js";import{RenderOccludedFlag as U}from"./Material.js";import{OffscreenRendering as q}from"./OffscreenRendering.js";import{RenderContext as G}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as B}from"./rendererUtils.js";import{setupFeatureDefaults as j,RenderFeature as V}from"./RenderFeature.js";import{RenderPluginManager as Q}from"./RenderPluginManager.js";import{RenderSlot as k}from"./RenderSlot.js";import{ShadowAccumulator as W}from"./ShadowAccumulator.js";import{ShadowHighlight as Y}from"./ShadowHighlight.js";import{ShadowMap as X,SnapshotSlot as z}from"./ShadowMap.js";import J from"./SliceHelper.js";import{SmaaRenderPass as K}from"./SmaaRenderPass.js";import{SSAOHelper as Z}from"./SSAOHelper.js";import{TransparencyPassType as $}from"./TransparencyPassType.js";import{EdgeView as ee}from"./edgeRendering/EdgeView.js";import{Transparency as re}from"./edgeRendering/interfaces.js";import{MergedRenderer as te}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as se}from"../shaders/CompositingTechniqueConfiguration.js";import{RendererPerformanceInfo as ie,PerformanceCategory as ae}from"../statistics/RendererPerformanceInfo.js";import{RenderState as ne}from"../../../support/RenderState.js";import{PixelFormat as he,PixelType as oe,ClearBufferBit as de}from"../../../webgl/enums.js";let le=class extends r{get _bindParameters(){return this._renderContext.bindParameters}updateRenderFeatures(e=null,r=!has("disable-feature:high-quality-idle")){this._renderStateFeatures=j(r,e),this.notifyChange("_renderStateFeatures"),this._requestRender()}isFeatureEnabled(e,r=this._state){return this._renderStateFeatures.get(r,e)??!1}setFeatureEnabled(e,r,t){this._renderStateFeatures.set(r,e,t),this.notifyChange("_renderStateFeatures"),this._requestRender()}get _antialiasing(){return this._antialiasingEnabled||this.isFeatureEnabled(V.Antialiasing)}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(V.HighQualityTransparency)}get hasReflections(){return this.hasWater&&(this._ssrEnabled||this.isFeatureEnabled(V.WaterReflection))}get hasDecorations(){return this._materialRenderersHas.decorations||this._renderPlugins.hasDecorations}get hasHighlights(){return this._materialRenderersHas.highlights||this._renderPlugins.needsHighlight}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(V.HighResolutionAtmosphere)}get hasWater(){return this._materialRenderersHas.water||this._hasOverlayWater}constructor(e,r,t,s,i,a,n,_){super({}),this._stage=e,this._materialRepository=r,this._techniqueRepository=s,this._rctx=i,this._compositingHelper=a,this._magnifierHelper=n,this._requestRender=_,this._materialRenderers=new h,this._needsTransparentPass=!1,this._materialRenderersHas={hudElements:!1,highlights:!1,water:!1,decorations:!1,occludees:!1},this._hasOverlayWater=!1,this._renderOverlay=e=>{},this._isRendering=!1,this._fallbackDepthStencilTexture=null,this._sliceHelper=new J,this._state=ne.IDLE,this._antialiasingEnabled=!0,this._highQualityTransparencyEnabled=!0,this._terrainRenderingEnabled=!0,this._terrainTransparency=P.Opaque,this._ssrEnabled=!1,this._ssaoEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new w,this._renderHiddenTransparentEdges=()=>{},this.fboCache=new b(i),this._renderStateFeatures=j(!has("disable-feature:high-quality-idle"),e.view.qualityProfile),this._smaaPass=new K(this.fboCache,s),_(),this._offscreen=new q(this.fboCache,this._compositingHelper),this.performanceInfo=new ie(this._rctx),this._shadowMap=new X(this.fboCache,e.viewingMode),this._ssaoHelper=new Z(e.view,this.fboCache,s,_),this._highlight=new F(s,this.fboCache),this._shadowHighlight=new Y(this._rctx,e.viewingMode),this._shadowAccumulator=new W(this.fboCache,s,e,(e=>{const r=this.shadowsEnabled;this._shadowMap.enabled=!0,this._prepare(e.camera,e.contentCamera),this._renderPlugins.prepareRender(),this._shadowMap.enabled=r}),((e,r,t)=>{e.shadowMap.start(e.camera,r,t,!0,this._stage.view.qualitySettings.maximumPixelRatio),this._renderShadowCascades(I.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._prepare(e.camera,e.contentCamera)}),_),this._renderContext=new G(this._rctx,this._offscreen,this._shadowMap,this._ssaoHelper,this._sliceHelper),this._renderPlugins=new Q({renderContext:this._renderContext,techniqueRepository:s,textureRepository:t,materialRepository:this._materialRepository,requestRender:_,controller:e}),this.renderPassManager=new C(this._rctx,this._techniqueRepository),this._renderPlugins.add(this.renderPassManager.slots(),this.renderPassManager),this.own([o((()=>this._stage.view.state.camera),(()=>_()),d),o((()=>A.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(re.TRANSPARENT):()=>{},_()}),l),o((()=>this._ssaoEnabled||this.isFeatureEnabled(V.SSAO)),(e=>this._ssaoHelper.enabled=e),d)])}normalizeCtorArgs(){return{}}destroy(){this._smaaPass.dispose(),this._gpuTimerHandle=s(this._gpuTimerHandle),this._materialRenderers.forAll((e=>e.dispose())),this._materialRenderers.clear(),this._offscreen.dispose(),this._fallbackDepthStencilTexture=i(this._fallbackDepthStencilTexture),this._shadowMap.dispose(),this._ssaoHelper.destroy(),this._highlight.dispose(),this._shadowHighlight.dispose(),this._shadowAccumulator.dispose(),this._edgeView=a(this._edgeView),this.renderPassManager.destroy(),this._releaseFBOs(),this._bindParameters.linearDepth=n(this._bindParameters.linearDepth),this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility),this.fboCache.destroy(),M.prune()}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth),this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth)}disposeOffscreenBuffers(){this._releaseFBOs(),this._offscreen.dispose(),this._shadowMap.disposeOffscreenBuffers(),this._smaaPass.disable(),this._ssaoHelper.disposeOffscreenBuffers()}get updating(){return this._antialiasing&&this._smaaPass.updating||null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._renderPlugins.updating||!this.isCameraFinal}ensureEdgeView(){if(null==this._edgeView){const e=this._stage.view.resourceController;this._edgeView=new ee({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniqueRepository:this._techniqueRepository,setNeedsRender:()=>this._requestRender(),schedule:Te(e)}),this.addHandles(o((()=>this._edgeView?.updating),(()=>this._requestRender()),_)),this._requestRender()}return this._edgeView}get edgeView(){return this._edgeView}get isCameraFinal(){return m(this._bindParameters.ssr.reprojectionMatrix,g)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this.notifyChange("isCameraFinal")}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:r,_bindParameters:t}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.qualitySettings?.ambientOcclusion&&this._ssaoEnabled!==e.qualitySettings.ambientOcclusion&&(this._ssaoEnabled=e.qualitySettings.ambientOcclusion,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&r.maxCascades!==e.shadowMapMaxCascades&&(r.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const r="virtual"!==e.environment.lighting.type;t.enableFillLights!==r&&(t.enableFillLights=r,this._requestRender())}e.backgroundColor&&!E(this._offscreen.backgroundColor,e.backgroundColor)&&(this._offscreen.backgroundColor=e.backgroundColor,this._requestRender()),void 0!==e.antialiasingEnabled&&this._antialiasingEnabled!==e.antialiasingEnabled&&(this._antialiasingEnabled=e.antialiasingEnabled,this._requestRender()),void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.defaultHighlightOptions&&(this._highlight.setDefaultOptions(e.defaultHighlightOptions),this._shadowHighlight.setDefaultOptions(e.defaultHighlightOptions),this._requestRender()),void 0!==e.overlays&&this._bindParameters.overlays!==e.overlays&&(this._bindParameters.overlays=e.overlays,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.renderOverlay&&this._renderOverlay!==e.renderOverlay&&(this._renderOverlay=e.renderOverlay,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=e.slicePlane,this._requestRender()),void 0!==e.terrainRenderingEnabled&&this._terrainRenderingEnabled!==e.terrainRenderingEnabled&&(this._terrainRenderingEnabled=e.terrainRenderingEnabled,this._requestRender()),void 0!==e.terrainTransparency&&this._terrainTransparency!==e.terrainTransparency&&(this._terrainTransparency=e.terrainTransparency,this._requestRender()),void 0!==e.shadowCastOptions&&this._shadowAccumulator.setOptions(e.shadowCastOptions)}get hasSlicePlane(){return!!this._sliceHelper.plane}get renderPlugins(){return this._renderPlugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,r){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:t,removes:s,updates:i}=e;if(0===t.length&&0===s.length&&0===i.length)return;const a=B(e);let n=!1;a.forEach(((t,s)=>{if(r.done)return;let i=this._materialRenderers.find((e=>e.material===s));null==i&&t.adds.length>0&&(i=new te(this._rctx,this._materialRepository,s),this._materialRenderers.push(i)),i&&(i.modify(t),i.isEmpty&&(n=!0)),t.removes.forEach((r=>e.removes.removeUnordered(r))),t.adds.forEach((r=>e.adds.removeUnordered(r))),t.updates.forEach((r=>e.updates.removeUnordered(r))),r.madeProgress()})),n&&this._materialRenderers.filterInPlace((e=>!e.isEmpty||(e.dispose(),!1))),this._updateHasFlags(),this._requestRender()}_updateHasFlags(){const has=this._materialRenderersHas;has.decorations=!1,has.highlights=!1,has.hudElements=!1,has.water=!1,has.occludees=!1,this._materialRenderers.forAll((e=>{has.highlights||=e.hasHighlights,has.occludees||=e.hasOccludees,has.water||=e.hasWater,has.decorations||=e.isDecoration,has.hudElements||=e.requiresSlot(k.LINE_CALLOUTS_HUD_DEPTH,I.Color)||e.requiresSlot(k.HUD_MATERIAL,I.Color)||e.requiresSlot(k.LABEL_MATERIAL,I.Color)})),this._bindParameters.hasOccludees=has.occludees}updateAnimation(e){const r=this._hasAnimations;return this._hasAnimations=!1,this._materialRenderers.forAll((r=>this._hasAnimations=r.updateAnimation(e)||this._hasAnimations)),this._hasAnimations=this._renderPlugins.updateAnimation(e)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?s(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}render(e,r,t,s,i){this._isRendering=!0,this.performanceInfo.startFrame(),this.fboCache.resetPeakMemoryUsage();const a=this._offscreen,{camera:h,contentCamera:o,mode:d,alignPixelEnabled:l}=t;this._state=d,this._renderOverlay(i),this.performanceInfo.advance(ae.OVERLAY),this._renderContext.time=i,this._bindParameters.transparencyPassType=$.NONE,this._bindParameters.alignPixelEnabled=l,this._bindParameters.decorations=s,this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this.hasReflections?this._bindParameters.ssr.lastFrameColor=a.swapColorBuffer():a.swapColorBuffer().release();const _=R(this._sliceHelper.plane);s===D.OFF&&(this._sliceHelper.plane=null),this._rctx.bindFramebuffer(e),h.setGLViewport(this._rctx),this._prepare(h,o),this._renderPlugins.prepareRender(),this.performanceInfo.advance(ae.PREPARE);const p=this._computeDepthRange(h);this._renderShadowMap(e,h,this._bindParameters.lighting.mainLight.direction,p),this.performanceInfo.advance(ae.SHADOW_MAP),a.initializeFrame(h),this._ensureBindParameters(h,o);const c=this._terrainRenderingEnabled&&(this._terrainTransparency===P.Semitransparent||this._terrainTransparency===P.TransparentWithDraped),m=this._highQualityTransparency&&c,u=this._needsTransparentPass||this._renderPlugins.needsTransparentPass;this._prepareShaders(m,u),this._renderLinearDepth(),this.performanceInfo.advance(ae.LINEAR_DEPTH),this._accumulateShadows(p,h,o),this.performanceInfo.advance(ae.ACCUMULATED_SHADOWS),this._ensureBindParametersSSR(i),this._renderSSAO(i),this.performanceInfo.advance(ae.SSAO),this._renderContext.output=I.Color,a.bindFbo(),this._renderOpaqueGeometry(),this.performanceInfo.advance(ae.OPAQUE),this._renderTerrainLinearDepth(m),this._setMultipassTerrain(m),this._renderEdges(re.OPAQUE),this.performanceInfo.advance(ae.OPAQUE_EDGES),a.bindFbo(),this._renderSlot(k.VOXEL),this.performanceInfo.advance(ae.VOXEL),this._renderHiddenTransparentEdges(),u&&(this._oitEnabled?this._renderOITPass(_e.Geometry):this._renderTransparentGeometry()),this.performanceInfo.advance(ae.TRANSPARENT);const f=this._renderGeometryLinearDepth(m);this._renderHUDVisibility(f),m||this._renderInternalSlot(k.LINE_CALLOUTS),this.performanceInfo.advance(ae.HUD_VISIBILITY),this._renderObjectAndLayerIdColor(r),this.performanceInfo.advance(ae.OBJECT_AND_LAYER_ID_COLOR),this._renderEdges(re.TRANSPARENT,f),f?.release(),this.performanceInfo.advance(ae.TRANSPARENT_EDGES);const g=c?this._renderTransparentTerrain():null;if(g&&this._bindParameters.hudVisibility&&(m?this._renderLineCallouts(O.Occluded):a.compositeToHUDVisibility(this._bindParameters,g.colorTexture),this._renderHUD(O.Occluded,a.framebuffer),this.performanceInfo.advance(ae.HUD_OCCLUDED)),this.performanceInfo.advance(ae.TRANSPARENT_TERRAIN),this._setTerrainCulling(!1),g&&(a.compositeToFramebuffer(this._bindParameters,g.colorTexture,se.PremultipliedAlpha,1),g.release(),m&&(this._renderEdges(re.OPAQUE),this.performanceInfo.advance(ae.OPAQUE_EDGES),u&&(this._oitEnabled?this._renderOITPass(_e.Geometry):this._renderTransparentGeometry()),this.performanceInfo.advance(ae.TRANSPARENT),this._renderEdges(re.TRANSPARENT),this.performanceInfo.advance(ae.TRANSPARENT_EDGES))),m&&this._renderLineCallouts(O.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),a.bindFbo(),this._renderInternalSlot(k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderSlot(k.POSTPROCESSING_ENVIRONMENT_TRANSPARENT),this._renderSlot(k.LASERLINES),this.performanceInfo.advance(ae.ENVIRONMENT),this._renderPlugins.needsLaserlineWithContrastControl){const e=()=>this._renderSlot(k.LASERLINES_CONTRAST_CONTROL),{width:r,height:t,depth:s}=a,i=this.fboCache.acquire(S.RGBA_CLAMPED,r,t);a.renderToTargets(e,i,s,ce),a.compositeToFramebuffer(this._bindParameters,i.colorTexture,se.PremultipliedAlpha,1),i.release()}this.performanceInfo.advance(ae.LASER_LINE),this._renderOccluded(),this.performanceInfo.advance(ae.OCCLUDED);const T=s===D.ON&&this._magnifierHelper.enabled,E=T&&null==e?this.fboCache.acquire(S.RGBA_CLAMPED,a.width,a.height).acquireDepth(y.DEPTH16_BUFFER):null,A=E?.fbo??e;this._rctx.bindFramebuffer(A);const b=this._offscreen.colorTexture;this._renderAntiAliasing(b,A)||null==b||this._compositingHelper.composite(this._bindParameters,b,se.None),this.performanceInfo.advance(ae.ANTIALIASING),this._renderHUD(O.NotOccluded,A),this.performanceInfo.advance(ae.HUD),this._renderHighlights(A,this._bindParameters),this.performanceInfo.advance(ae.HIGHLIGHTS),T&&this._magnifierHelper.render(this._rctx,this._bindParameters),A!==e&&(this._rctx.bindFramebuffer(e),this._compositingHelper.composite(this._bindParameters,E?.colorTexture,se.None)),E?.release(),this._releaseFBOs(),this._offscreen.releaseBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=_,this._isRendering=!1,this.onPostRender&&this.onPostRender(),this.performanceInfo.finishFrame()}_prepareShaders(e,r){this._renderContext.output=I.Color,this._prepareOpaqueGeometrySlots(),this._setMultipassTerrain(e),this._prepareSlots(k.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._prepareInternalSlots(this._materialRenderers,k.LINE_CALLOUTS),r&&this._prepareTransparencySlots(),this._prepareInternalSlots(this._materialRenderers,k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._prepareSlots(k.POSTPROCESSING_ENVIRONMENT_TRANSPARENT,k.LASERLINES),this._rctx.gl.flush()}_renderObjectAndLayerIdColor(e){if(null==e||!has("enable-feature:objectAndLayerId-rendering"))return;const r=this._renderContext.output;this._rctx.bindFramebuffer(e),this._offscreen.renderToFBO((()=>this._renderGeometryAndTransparentTerrainPass(I.ObjectAndLayerIdColor)),[0,0,0,0],!0,!0),this._rctx.bindFramebuffer(e),this._offscreen.renderToFBO((()=>{this._bindParameters.hudRenderStyle=O.NotOccluded,this._renderInternalSlot(k.HUD_MATERIAL)}),void 0,!0,!0),this._renderContext.output=r}finish(e){this._hasAnimations||this._animationTimestep.clear();const r=this.performanceInfo.gpuSamplingEnabled,t=e===N.BACKGROUND;if(t||r){const e=t?this.performanceInfo.elapsedTime:0,s=r?this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.getError(),i=Math.max(e,s);this._animationTimestep.frame(i,t)}}readDepthPixels(e,r,t){const s=this._bindParameters.linearDepth?.fbo;if(s?.colorTexture)return void s.readPixels(r[0],r[1],r[2],r[3],he.RGBA,oe.UNSIGNED_BYTE,t);const i=this.fboCache.acquire(S.RGBA_CLAMPED,this._offscreen.width,this._offscreen.height).acquireDepth(y.DEPTH16_BUFFER);this._rctx.bindFramebuffer(i.fbo),this._ensureBindParameters(e,e),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.setClearColor(0,0,0,0);const a=de.COLOR_BUFFER_BIT|de.DEPTH_BUFFER_BIT|de.STENCIL_BUFFER_BIT;this._rctx.clearSafe(a),this._renderGeometryAndTransparentTerrainPass(I.Depth),i.fbo.readPixels(r[0],r[1],r[2],r[3],he.RGBA,oe.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,r,t,s,i){this._bindParameters.hudVisibility?.fbo.readPixels(e,r,t,s,he.RGBA,oe.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_setMultipassTerrain(e){this._setMultipassEnabled(e),this._setTerrainCulling(e)}_setMultipassEnabled(e){this._bindParameters.multipassEnabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_prepareSlots(...e){this._renderPlugins.prepareSlots(e)}_renderSlot(e){this._renderPlugins.render(this._renderPlugins.prepare(e))}_renderEdges(e,r){const t=this._edgeView;if(t?.shouldRender()){const{width:s,height:i,depth:a}=this._offscreen,n=this.fboCache.acquire(S.RGBA_CLAMPED,s,i),h=()=>t.render(this._bindParameters,e);this._offscreen.renderToTargets(h,n,r??a,ce),this._offscreen.compositeToFramebuffer(this._bindParameters,n.colorTexture,se.Alpha,1),n.release()}}_renderShadowMap(e,r,t,s){const i=this._shadowMap;i.enabled&&(i.start(r,t,s,this.isFeatureEnabled(V.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._shadowHighlight.updateParameters(r,t),this._needsShadowHighlight?(this._renderShadowCascades(I.ShadowHighlight,this._shadowMap),i.moveSnapshot(z.Highlight),i.clear(),this._renderShadowCascades(I.ShadowExcludeHighlight,this._shadowMap),i.copySnapshot(z.Default),this._renderShadowCascades(I.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(I.Shadow),i.finish(),this._rctx.bindFramebuffer(e),r.setGLViewport(this._rctx))}_renderShadowCascades(e,r=this._shadowMap){for(const t of r.cascades)t.camera.setGLViewport(this._rctx),this._prepare(t.camera,t.camera),this._renderGeometryAndTransparentTerrainPass(e)}get _needsLinearDepth(){return this._ssaoHelper.active||this._renderPlugins.needsLinearDepth||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast}_renderLinearDepth(){this._needsLinearDepth?(this._bindParameters.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.linearDepth,(()=>this._renderGeometryAndTransparentTerrainPass(I.Depth)),[0,0,0,0]),this._bindParameters.linearDepth.releaseDepth(),this._offscreen.bindFbo()):this._bindParameters.linearDepth=n(this._bindParameters.linearDepth)}_renderTerrainLinearDepth(e){if(e){const e=this._renderContext.output;this._renderContext.output=I.Depth,this._bindParameters.multipassTerrain.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.multipassTerrain.linearDepth,(()=>this._renderTransparentTerrain()),[-1e10,-1e10,-1e10,1]),this._bindParameters.multipassTerrain.linearDepth.releaseDepth(),this._renderContext.output=e}else this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth)}_renderGeometryLinearDepth(e){if(!e)return void(this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth));const r=this._renderContext.output;return this._bindParameters.multipassGeometry.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.multipassGeometry.linearDepth,(()=>this._renderGeometryPass(I.Depth)),[1,1,1,1]),this._renderContext.output=r,this._bindParameters.multipassGeometry.linearDepth.detachDepth()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return H;const r=v(e,this._materialRenderers,this._stage.layers);return x(r,this.renderPlugins.queryDepthRange(e)),r.near=Math.max(e.near,r.near),r.far=Math.min(e.far,r.far),r}_renderGeometryAndTransparentTerrainPass(e){this._renderContext.output=e,this._prepareSlots(k.TRANSPARENT_TERRAIN),this._renderGeometryPass(e),this._renderTransparentTerrain()}_renderGeometryPass(e){this._renderContext.output=e,this._prepareSlots(k.TRANSPARENT_MATERIAL),this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderSSAO(e){if(!this._ssaoHelper.active)return;const r=this._offscreen.renderToCachedFBO(null,(()=>this._renderGeometryAndTransparentTerrainPass(I.Normal)),[0,0,0,0]);r.releaseDepth(),this._offscreen.bindFbo(),this._ssaoHelper.render(this._bindParameters,e,r.colorTexture),r.release()}_prepareOpaqueGeometrySlots(){this._prepareSlots(k.INTEGRATED_MESH,k.OPAQUE_TERRAIN,k.OPAQUE_MATERIAL,k.POSTPROCESSING_ENVIRONMENT_OPAQUE),this._prepareInternalSlots(this._materialRenderers,k.OPAQUE_MATERIAL)}_renderOpaqueGeometry(){this._renderSlot(k.INTEGRATED_MESH),this._renderSlot(k.OPAQUE_TERRAIN),this._renderInternalSlot(k.OPAQUE_MATERIAL),this._renderSlot(k.OPAQUE_MATERIAL),this._renderSlot(k.POSTPROCESSING_ENVIRONMENT_OPAQUE)}_renderTransparentGeometry(){this._renderInternalSlot(k.TRANSPARENT_MATERIAL),this._renderSlot(k.TRANSPARENT_MATERIAL)}_renderTransparentTerrain(){const e=this._renderPlugins.prepare(k.TRANSPARENT_TERRAIN);if(0===e.size)return;const r=()=>this._renderPlugins.render(e);if(this._renderContext.output!==I.Color)return void r();const{width:t,height:s,depth:i}=this._offscreen,a=this.fboCache.acquire(S.RGBA_CLAMPED,t,s);return this._offscreen.renderToTargets(r,a,i,[0,0,0,0]),a}_renderHUDVisibility(e){let r=!1;const t=this._renderContext.offscreenRenderingHelper;this._bindParameters.hudVisibility=t.renderHUDVisibility(this._bindParameters.hudVisibility,(()=>r=this._renderInternalSlot(k.OCCLUSION_PIXELS)),e),t.bindFbo(),r||(this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility))}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===O.Occluded){const e=()=>this._renderInternalSlot(k.LINE_CALLOUTS),{width:r,height:t,color:s}=this._offscreen,i=this.fboCache.acquireDepth(y.DEPTH16_BUFFER,r,t);this._offscreen.renderToTargets(e,s,i,void 0,!0,!0),i.release()}else this._renderInternalSlot(k.LINE_CALLOUTS)}_renderHUD(e,r){if(this._materialRenderersHas.hudElements)if(this._oitEnabled){const t=this._renderOITPass(_e.HUD,e);this._rctx.bindFramebuffer(r),this._compositingHelper.composite(this._bindParameters,t.colorTexture,se.PremultipliedAlpha),t.release()}else if(e===O.Occluded){const e=()=>this._renderHUDElements(O.Occluded),{width:r,height:t,color:s}=this._offscreen,i=this.fboCache.acquireDepth(y.DEPTH16_BUFFER,r,t);this._offscreen.renderToTargets(e,s,i,void 0,!0,!0),i.release()}else this._renderHUDElements(e)}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._prepareInternalSlots(this._materialRenderers,k.LINE_CALLOUTS_HUD_DEPTH,k.HUD_MATERIAL,k.LABEL_MATERIAL),this._renderInternalSlot(k.LINE_CALLOUTS_HUD_DEPTH),this._renderInternalSlot(k.HUD_MATERIAL),this._renderInternalSlot(k.LABEL_MATERIAL)}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._shadowHighlight.isVisible&&this.hasHighlights}_renderHighlights(e,r){if(!this.hasHighlights||r.decorations===D.OFF)return;const t=this._offscreen.renderToCachedFBO(null,(()=>{this._renderGeometryAndTransparentTerrainPass(I.Highlight),this._rctx.clearSafe(de.DEPTH_BUFFER_BIT),this._renderHUDElements(O.Both)}),[0,0,0,0],y.DEPTH_STENCIL_TEXTURE);this._needsShadowHighlight&&this._shadowHighlight.render(r,t.fbo.colorTexture,e),t.releaseDepth(),this._highlight.render(this._bindParameters,t.fbo,e),t.release()}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_accumulateShadows(e,r,t){this._needsShadowCast&&this._bindParameters.linearDepth?.colorTexture&&this._shadowAccumulator.renderAccumulation(this._bindParameters.linearDepth,e,r,t)}_prepareTransparencySlots(){this._renderContext.output=I.Alpha,this._bindParameters.transparencyPassType=$.Alpha,this._prepareInternalSlots(this._materialRenderers,k.TRANSPARENT_MATERIAL),this._prepareSlots(k.TRANSPARENT_MATERIAL),this._renderContext.output=I.Color,this._bindParameters.transparencyPassType=$.Color,this._prepareInternalSlots(this._materialRenderers,k.TRANSPARENT_MATERIAL),this._prepareSlots(k.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=$.FrontFace,this._prepareInternalSlots(this._materialRenderers,k.TRANSPARENT_MATERIAL),this._prepareSlots(k.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=$.NONE}_renderOITPass(e,r=O.Both){const t=e===_e.HUD,s=t?this.fboCache.acquire(S.RGBA_CLAMPED,this._offscreen.width,this._offscreen.height):null,i=t?()=>this._renderHUDElements(r):()=>this._renderTransparentGeometry(),a=this._renderContext.output;this._renderContext.output=I.Alpha,this._bindParameters.transparencyPassType=$.Alpha;const n=this._offscreen.renderOITPass(i,$.Alpha,t);this._renderContext.output=I.Color,this._bindParameters.transparencyPassType=$.Color;const h=this._offscreen.renderOITPass(i,$.Color,t);this._bindParameters.transparencyPassType=$.FrontFace;const o=this._offscreen.renderOITPass(i,$.FrontFace,t);return this._offscreen.compositeTransparentOntoOpaque(this._bindParameters,h,n,o,s),s?.releaseDepth(),o.release(),h.release(),n.release(),this._bindParameters.transparencyPassType=$.NONE,this._renderContext.output=a,s}_renderOccluded(){let e=0;me.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&r.material.renderOccluded===U.OccludeAndTransparentStencil&&(e|=r.material.renderOccluded,me.push(r))}));const r=this._offscreen,t=(t,s,i,a,n)=>{if(0==(e&s))return;const{width:h,height:o,depth:d}=r,l=this.fboCache.acquire(S.RGBA_CLAMPED,h,o);r.renderToTargets(i,l,d,[0,0,0,0],a,n),r.compositeToFramebuffer(this._bindParameters,l.colorTexture,se.PremultipliedAlpha,t),l.release()};0!==me.length&&(this._prepareInternalSlots(me,k.OCCLUDER_MATERIAL,k.TRANSPARENT_OCCLUDER_MATERIAL),this._renderInternalSlot(k.OCCLUDER_MATERIAL,me),t(.5,U.OccludeAndTransparentStencil,(()=>this._renderInternalSlot(k.TRANSPARENT_OCCLUDER_MATERIAL,me)),!1,!1)),me.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&(r.material.renderOccluded===U.OccludeAndTransparent||r.material.renderOccluded===U.Transparent||r.material.renderOccluded===U.Opaque)&&(e|=r.material.renderOccluded,me.push(r))}));const s=this._renderPlugins.renderOccludedFlags;if(e|=s,!e)return;const i=e=>{this._renderContext.renderOccludedMask=e,this._prepareInternalSlots(me,k.OPAQUE_MATERIAL,k.TRANSPARENT_MATERIAL,k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),s>U.Occlude&&this._renderSlot(k.OCCLUDED_TERRAIN),this._renderInternalSlot(k.OPAQUE_MATERIAL,me),this._renderInternalSlot(k.TRANSPARENT_MATERIAL,me),this._renderInternalSlot(k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,me),this._renderContext.resetRenderOccludedMask()};this._renderContext.output=I.Color,t(.5,U.OccludeAndTransparent,(()=>i(U.OccludeAndTransparent)),!0,L.OutlineVisualElementMask),t(.5,U.Transparent,(()=>i(U.Transparent)),!0,L.OutlineVisualElementMask),t(1,U.Opaque,(()=>i(U.Opaque)),!0,L.OutlineVisualElementMask),me.clear()}_renderAntiAliasing(e,r){if(this._antialiasing){if(this._smaaPass.enable((()=>this._requestRender()))&&null!=e)return this._smaaPass.render(e,r),!0}else this._smaaPass.disable();return!1}_prepare(e,r){this._needsTransparentPass=this._materialRenderers.some((e=>e.requiresSlot(k.TRANSPARENT_MATERIAL,I.Color))),this._bindParameters.camera=e,this._bindParameters.contentCamera=r}_ensureBindParameters(e,r){this._bindParameters.camera=e,this._bindParameters.contentCamera=r;const t=this._renderContext.offscreenRenderingHelper;this._bindParameters.mainColor=t.colorTexture,this._bindParameters.mainDepth=t.depthTexture}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=g:(u(fe,this._bindParameters.camera.viewMatrix),u(ue,this._bindParameters.camera.projectionMatrix),f(ge,fe,ue),f(ge,this._renderContext.lastFrameCamera.viewMatrix,ge),f(ge,this._renderContext.lastFrameCamera.projectionMatrix,ge),this._reprojectionMatrix=ge);const r=this._stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=r>0?Math.min(r,e-this._ssrEnableTime)/r:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=g,this._ssrEnableTime=null}_prepareInternalSlots(e,...r){for(const t of r)this._bindParameters.slot=t,e.forAll((e=>{e.material.shouldRender(this._renderContext)&&e.prepareTechnique(this._renderContext)}))}_renderInternalSlot(e,r=this._materialRenderers){let t=!1;return this._bindParameters.slot=e,r.forAll((e=>{if(e.material.shouldRender(this._renderContext)){const r=e.prepareTechnique(this._renderContext);null!=r&&(e.render(this._renderContext,r),t=!0)}})),t}get gpuMemoryUsage(){return{fbo:(this._offscreen?.gpuMemoryUsage??0)+(this._bindParameters.ssr.lastFrameColor?.memoryUsage??0)+(this._bindParameters.linearDepth?.memoryUsage??0)+(this._bindParameters.hudVisibility?.memoryUsage??0)+this.fboCache.peakMemoryUsage,highlights:this._highlight?.gpuMemoryUsage??0,shadows:this._shadowMap?.gpuMemoryUsage??0,ssao:this._ssaoHelper?.gpuMemoryUsage??0}}get test(){const e=this;return{offscreen:this._offscreen,shadowMap:this._shadowMap,ssao:this._ssaoHelper,highlight:this._highlight,lighting:this._bindParameters.lighting,materialRenderers:this._materialRenderers,shadowAccumulator:this._shadowAccumulator,weatherIsFading:this._bindParameters.cloudsFade.isFading,resetRenderStateFeatures:()=>{e._renderStateFeatures=j()},getFramebufferTexture:r=>{switch(r){case pe.Color:return e._offscreen.colorTexture;case pe.LinearDepth:return e._bindParameters.linearDepth?.colorTexture;case pe.ShadowMap:return e._shadowMap.depthTexture;case pe.HudVisibility:return e._bindParameters.hudVisibility?.colorTexture}}}}};var _e,pe;e([p()],le.prototype,"_renderPlugins",void 0),e([p()],le.prototype,"_shadowAccumulator",void 0),e([p()],le.prototype,"_state",void 0),e([p()],le.prototype,"_renderStateFeatures",void 0),e([p()],le.prototype,"_antialiasingEnabled",void 0),e([p({readOnly:!0})],le.prototype,"_antialiasing",null),e([p()],le.prototype,"_ssaoEnabled",void 0),e([p({readOnly:!0})],le.prototype,"fullResolutionAtmosphere",null),e([p()],le.prototype,"_smaaPass",void 0),e([p({autoDestroy:!0})],le.prototype,"_edgeView",void 0),e([p()],le.prototype,"updating",null),e([p()],le.prototype,"isCameraFinal",null),le=e([c("esri.views.3d.webgl-engine.lib.Renderer")],le),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(_e||(_e={})),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.ShadowMap=2]="ShadowMap",e[e.HudVisibility=3]="HudVisibility"}(pe||(pe={}));const ce=[0,0,0,0],me=new h,ue=T(),fe=T(),ge=T();function Te(e){return r=>e.immediate.schedule(r)}export{pe as FramebufferId,le as Renderer};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{update as t}from"../../../../core/arrayUtils.js";import has from"../../../../core/has.js";import{removeMaybe as s,disposeMaybe as i,destroyMaybe as a,releaseMaybe as n}from"../../../../core/maybe.js";import h from"../../../../core/PooledArray.js";import{watch as o,syncAndInitial as d,initial as l,sync as _}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as m}from"../../../../core/accessorSupport/decorators/subclass.js";import{j as c,a as u,m as f}from"../../../../chunks/mat4.js";import{I as g,c as T}from"../../../../chunks/mat4f64.js";import{h as R}from"../../../../chunks/vec4.js";import{a as b}from"../../../../chunks/boundedPlane.js";import E from"../../support/debugFlags.js";import{TransparencyMode as A}from"../../terrain/TerrainRenderer.js";import{FBOCache as P,ColorFormat as S,DepthFormat as y}from"../core/FBOCache.js";import{RenderPassManager as C}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as I}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as O}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{AnimationTimeStep as w}from"./AnimationTimeStep.js";import{Decorations as D,RenderRequestType as N,StencilBits as M}from"./basicInterfaces.js";import{BoundingInfo as H}from"./BoundingInfo.js";import{ZERO as L,union as x}from"./depthRange.js";import{depthRangeFromScene as v}from"./depthRangeUtils.js";import{Highlight as F}from"./Highlight.js";import{RenderOccludedFlag as U}from"./Material.js";import{OffscreenRendering as q}from"./OffscreenRendering.js";import{RenderContext as G}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as B}from"./rendererUtils.js";import{setupFeatureDefaults as j,RenderFeature as V}from"./RenderFeature.js";import{RenderPluginManager as Q}from"./RenderPluginManager.js";import{RenderSlot as k}from"./RenderSlot.js";import{ShadowAccumulator as W}from"./ShadowAccumulator.js";import{ShadowHighlight as Y}from"./ShadowHighlight.js";import{ShadowMap as X,SnapshotSlot as z}from"./ShadowMap.js";import J from"./SliceHelper.js";import{SmaaRenderPass as K}from"./SmaaRenderPass.js";import{SSAOHelper as Z}from"./SSAOHelper.js";import{TransparencyPassType as $}from"./TransparencyPassType.js";import{EdgeView as ee}from"./edgeRendering/EdgeView.js";import{Transparency as re}from"./edgeRendering/interfaces.js";import{MergedRenderer as te}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as se}from"../shaders/CompositingTechniqueConfiguration.js";import{RendererPerformanceInfo as ie,PerformanceCategory as ae}from"../statistics/RendererPerformanceInfo.js";import{RenderState as ne}from"../../../support/RenderState.js";import{PixelFormat as he,PixelType as oe,ClearBufferBit as de}from"../../../webgl/enums.js";let le=class extends r{get _bindParameters(){return this._renderContext.bindParameters}updateRenderFeatures(e=null,r=!has("disable-feature:high-quality-idle")){this._renderStateFeatures=j(r,e),this.notifyChange("_renderStateFeatures"),this._requestRender()}isFeatureEnabled(e,r=this._state){return this._renderStateFeatures.get(r,e)??!1}setFeatureEnabled(e,r,t){this._renderStateFeatures.set(r,e,t),this.notifyChange("_renderStateFeatures"),this._requestRender()}get _antialiasing(){return this._antialiasingEnabled||this.isFeatureEnabled(V.Antialiasing)}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(V.HighQualityTransparency)}get hasReflections(){return this.hasWater&&(this._ssrEnabled||this.isFeatureEnabled(V.WaterReflection))}get hasDecorations(){return this._materialRenderersHas.decorations||this._renderPlugins.hasDecorations}get hasHighlights(){return this._materialRenderersHas.highlights||this._renderPlugins.needsHighlight}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(V.HighResolutionAtmosphere)}get hasWater(){return this._materialRenderersHas.water||this._hasOverlayWater}constructor(e,r,t,s,i,a,n,_){super({}),this._stage=e,this._materialRepository=r,this._techniqueRepository=s,this._rctx=i,this._compositingHelper=a,this._magnifierHelper=n,this._requestRender=_,this._materialRenderers=new h,this._needsTransparentPass=!1,this._materialRenderersHas={hudElements:!1,highlights:!1,water:!1,decorations:!1,occludees:!1},this._hasOverlayWater=!1,this._renderOverlay=e=>{},this._isRendering=!1,this._fallbackDepthStencilTexture=null,this._sliceHelper=new J,this._state=ne.IDLE,this._antialiasingEnabled=!0,this._highQualityTransparencyEnabled=!0,this._terrainRenderingEnabled=!0,this._terrainTransparency=A.Opaque,this._ssrEnabled=!1,this._ssaoEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new w,this._renderHiddenTransparentEdges=()=>{},this.fboCache=new P(i),this._renderStateFeatures=j(!has("disable-feature:high-quality-idle"),e.view.qualityProfile),this._smaaPass=new K(this.fboCache,s),_(),this._offscreen=new q(this.fboCache,this._compositingHelper),this.performanceInfo=new ie(this._rctx),this._shadowMap=new X(this.fboCache,e.viewingMode),this._ssaoHelper=new Z(e.view,this.fboCache,s,_),this._highlight=new F(s,this.fboCache),this._shadowHighlight=new Y(this._rctx,e.viewingMode),this._shadowAccumulator=new W(this.fboCache,s,e,(e=>{const r=this.shadowsEnabled;this._shadowMap.enabled=!0,this._prepare(e.camera,e.contentCamera),this._renderPlugins.prepareRender(),this._shadowMap.enabled=r}),((e,r,t)=>{e.shadowMap.start(e.camera,r,t,!0,this._stage.view.qualitySettings.maximumPixelRatio),this._renderShadowCascades(I.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._prepare(e.camera,e.contentCamera)}),_),this._renderContext=new G(this._rctx,this._offscreen,this._shadowMap,this._ssaoHelper,this._sliceHelper),this._renderPlugins=new Q({renderContext:this._renderContext,techniqueRepository:s,textureRepository:t,materialRepository:this._materialRepository,requestRender:_,controller:e}),this.renderPassManager=new C(this._rctx,this._techniqueRepository),this._renderPlugins.add(this.renderPassManager.slots(),this.renderPassManager),this.own([o((()=>this._stage.view.state.camera),(()=>_()),d),o((()=>E.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(re.TRANSPARENT):()=>{},_()}),l),o((()=>this._ssaoEnabled||this.isFeatureEnabled(V.SSAO)),(e=>this._ssaoHelper.enabled=e),d)])}normalizeCtorArgs(){return{}}destroy(){this._smaaPass.dispose(),this._gpuTimerHandle=s(this._gpuTimerHandle),this._materialRenderers.forAll((e=>e.dispose())),this._materialRenderers.clear(),this._offscreen.dispose(),this._fallbackDepthStencilTexture=i(this._fallbackDepthStencilTexture),this._shadowMap.dispose(),this._ssaoHelper.destroy(),this._highlight.dispose(),this._shadowHighlight.dispose(),this._shadowAccumulator.dispose(),this._edgeView=a(this._edgeView),this.renderPassManager.destroy(),this._releaseFBOs(),this._bindParameters.linearDepth=n(this._bindParameters.linearDepth),this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility),this.fboCache.destroy(),H.prune()}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth),this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth)}disposeOffscreenBuffers(){this._releaseFBOs(),this._offscreen.dispose(),this._shadowMap.disposeOffscreenBuffers(),this._smaaPass.disable(),this._ssaoHelper.disposeOffscreenBuffers()}get updating(){return this._antialiasing&&this._smaaPass.updating||null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._renderPlugins.updating||!this.isCameraFinal}ensureEdgeView(){if(null==this._edgeView){const e=this._stage.view.resourceController;this._edgeView=new ee({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniqueRepository:this._techniqueRepository,setNeedsRender:()=>this._requestRender(),schedule:Te(e)}),this.addHandles(o((()=>this._edgeView?.updating),(()=>this._requestRender()),_)),this._requestRender()}return this._edgeView}get edgeView(){return this._edgeView}get isCameraFinal(){return c(this._bindParameters.ssr.reprojectionMatrix,g)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this.notifyChange("isCameraFinal")}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:r,_bindParameters:t}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.qualitySettings?.ambientOcclusion&&this._ssaoEnabled!==e.qualitySettings.ambientOcclusion&&(this._ssaoEnabled=e.qualitySettings.ambientOcclusion,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&r.maxCascades!==e.shadowMapMaxCascades&&(r.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const r="virtual"!==e.environment.lighting.type;t.enableFillLights!==r&&(t.enableFillLights=r,this._requestRender())}e.backgroundColor&&!R(this._offscreen.backgroundColor,e.backgroundColor)&&(this._offscreen.backgroundColor=e.backgroundColor,this._requestRender()),void 0!==e.antialiasingEnabled&&this._antialiasingEnabled!==e.antialiasingEnabled&&(this._antialiasingEnabled=e.antialiasingEnabled,this._requestRender()),void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.defaultHighlightOptions&&(this._highlight.setDefaultOptions(e.defaultHighlightOptions),this._shadowHighlight.setDefaultOptions(e.defaultHighlightOptions),this._requestRender()),void 0!==e.overlays&&this._bindParameters.overlays!==e.overlays&&(this._bindParameters.overlays=e.overlays,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.renderOverlay&&this._renderOverlay!==e.renderOverlay&&(this._renderOverlay=e.renderOverlay,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=e.slicePlane,this._requestRender()),void 0!==e.terrainRenderingEnabled&&this._terrainRenderingEnabled!==e.terrainRenderingEnabled&&(this._terrainRenderingEnabled=e.terrainRenderingEnabled,this._requestRender()),void 0!==e.terrainTransparency&&this._terrainTransparency!==e.terrainTransparency&&(this._terrainTransparency=e.terrainTransparency,this._requestRender()),void 0!==e.shadowCastOptions&&this._shadowAccumulator.setOptions(e.shadowCastOptions)}get hasSlicePlane(){return!!this._sliceHelper.plane}get renderPlugins(){return this._renderPlugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,r){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:t,removes:s,updates:i}=e;if(0===t.length&&0===s.length&&0===i.length)return;const a=B(e);let n=!1;a.forEach(((t,s)=>{if(r.done)return;let i=this._materialRenderers.find((e=>e.material===s));null==i&&t.adds.length>0&&(i=new te(this._rctx,this._materialRepository,s),this._materialRenderers.push(i)),i&&(i.modify(t),i.isEmpty&&(n=!0)),t.removes.forEach((r=>e.removes.removeUnordered(r))),t.adds.forEach((r=>e.adds.removeUnordered(r))),t.updates.forEach((r=>e.updates.removeUnordered(r))),r.madeProgress()})),n&&this._materialRenderers.filterInPlace((e=>!e.isEmpty||(e.dispose(),!1))),this._updateHasFlags(),this._requestRender()}_updateHasFlags(){const has=this._materialRenderersHas;has.decorations=!1,has.highlights=!1,has.hudElements=!1,has.water=!1,has.occludees=!1,this._materialRenderers.forAll((e=>{has.highlights||=e.hasHighlights,has.occludees||=e.hasOccludees,has.water||=e.hasWater,has.decorations||=e.isDecoration,has.hudElements||=e.requiresSlot(k.LINE_CALLOUTS_HUD_DEPTH,I.Color)||e.requiresSlot(k.HUD_MATERIAL,I.Color)||e.requiresSlot(k.LABEL_MATERIAL,I.Color)})),this._bindParameters.hasOccludees=has.occludees}updateAnimation(e){const r=this._hasAnimations;return this._hasAnimations=!1,this._materialRenderers.forAll((r=>this._hasAnimations=r.updateAnimation(e)||this._hasAnimations)),this._hasAnimations=this._renderPlugins.updateAnimation(e)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?s(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}render(e,r,t,s,i){this._isRendering=!0,this.performanceInfo.startFrame(),this.fboCache.resetPeakMemoryUsage();const a=this._offscreen,{camera:h,contentCamera:o,mode:d,alignPixelEnabled:l}=t;this._state=d,this._renderOverlay(i),this.performanceInfo.advance(ae.OVERLAY),this._renderContext.time=i,this._bindParameters.transparencyPassType=$.NONE,this._bindParameters.alignPixelEnabled=l,this._bindParameters.decorations=s,this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this.hasReflections?this._bindParameters.ssr.lastFrameColor=a.swapColorBuffer():a.swapColorBuffer().release();const _=b(this._sliceHelper.plane);s===D.OFF&&(this._sliceHelper.plane=null),this._rctx.bindFramebuffer(e),h.setGLViewport(this._rctx),this._prepare(h,o),this._renderPlugins.prepareRender(),this.performanceInfo.advance(ae.PREPARE);const p=this._computeDepthRange(h);this._renderShadowMap(e,h,this._bindParameters.lighting.mainLight.direction,p),this.performanceInfo.advance(ae.SHADOW_MAP),a.initializeFrame(h),this._ensureBindParameters(h,o);const m=this._terrainRenderingEnabled&&(this._terrainTransparency===A.Semitransparent||this._terrainTransparency===A.TransparentWithDraped),c=this._highQualityTransparency&&m,u=this._needsTransparentPass||this._renderPlugins.needsTransparentPass;this._prepareShaders(c,u),this._renderLinearDepth(),this.performanceInfo.advance(ae.LINEAR_DEPTH),this._accumulateShadows(p,h,o),this.performanceInfo.advance(ae.ACCUMULATED_SHADOWS),this._ensureBindParametersSSR(i),this._renderSSAO(i),this.performanceInfo.advance(ae.SSAO),this._renderContext.output=I.Color,a.bindFbo(),this._renderOpaqueGeometry(),this.performanceInfo.advance(ae.OPAQUE),this._renderTerrainLinearDepth(c),this._setMultipassTerrain(c),this._renderEdges(re.OPAQUE),this.performanceInfo.advance(ae.OPAQUE_EDGES),a.bindFbo(),this._renderSlot(k.VOXEL),this.performanceInfo.advance(ae.VOXEL),this._renderHiddenTransparentEdges(),u&&(this._oitEnabled?this._renderOITPass(_e.Geometry):this._renderTransparentGeometry()),this.performanceInfo.advance(ae.TRANSPARENT);const f=this._renderGeometryLinearDepth(c);this._renderHUDVisibility(f),c||this._renderInternalSlot(k.LINE_CALLOUTS),this.performanceInfo.advance(ae.HUD_VISIBILITY),this._renderObjectAndLayerIdColor(r),this.performanceInfo.advance(ae.OBJECT_AND_LAYER_ID_COLOR),this._renderEdges(re.TRANSPARENT,f),f?.release(),this.performanceInfo.advance(ae.TRANSPARENT_EDGES);const g=m?this._renderTransparentTerrain():null;if(g&&this._bindParameters.hudVisibility&&(c?this._renderLineCallouts(O.Occluded):a.compositeToHUDVisibility(this._bindParameters,g.colorTexture),this._renderHUD(O.Occluded,a.framebuffer),this.performanceInfo.advance(ae.HUD_OCCLUDED)),this.performanceInfo.advance(ae.TRANSPARENT_TERRAIN),this._setTerrainCulling(!1),g&&(a.compositeToFramebuffer(this._bindParameters,g.colorTexture,se.PremultipliedAlpha,1),g.release(),c&&(this._renderEdges(re.OPAQUE),this.performanceInfo.advance(ae.OPAQUE_EDGES),u&&(this._oitEnabled?this._renderOITPass(_e.Geometry):this._renderTransparentGeometry()),this.performanceInfo.advance(ae.TRANSPARENT),this._renderEdges(re.TRANSPARENT),this.performanceInfo.advance(ae.TRANSPARENT_EDGES))),c&&this._renderLineCallouts(O.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),a.bindFbo(),this._renderInternalSlot(k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderSlot(k.POSTPROCESSING_ENVIRONMENT_TRANSPARENT),this._renderSlot(k.LASERLINES),this.performanceInfo.advance(ae.ENVIRONMENT),this._renderPlugins.needsLaserlineWithContrastControl){const e=()=>this._renderSlot(k.LASERLINES_CONTRAST_CONTROL),{width:r,height:t,depth:s}=a,i=this.fboCache.acquire(S.RGBA,r,t);a.renderToTargets(e,i,s,me),a.compositeToFramebuffer(this._bindParameters,i.colorTexture,se.PremultipliedAlpha,1),i.release()}this.performanceInfo.advance(ae.LASER_LINE),this._renderOccluded(),this.performanceInfo.advance(ae.OCCLUDED);const T=s===D.ON&&this._magnifierHelper.enabled,R=T&&null==e?this.fboCache.acquire(S.RGBA,a.width,a.height).acquireDepth(y.DEPTH16_BUFFER):null,E=R?.fbo??e;this._rctx.bindFramebuffer(E);const P=this._offscreen.colorTexture;this._renderAntiAliasing(P,E)||null==P||this._compositingHelper.composite(this._bindParameters,P,se.None),this.performanceInfo.advance(ae.ANTIALIASING),this._renderHUD(O.NotOccluded,E),this.performanceInfo.advance(ae.HUD),this._renderHighlights(E,this._bindParameters),this.performanceInfo.advance(ae.HIGHLIGHTS),T&&this._magnifierHelper.render(this._rctx,this._bindParameters),E!==e&&(this._rctx.bindFramebuffer(e),this._compositingHelper.composite(this._bindParameters,R?.colorTexture,se.None)),R?.release(),this._releaseFBOs(),this._offscreen.releaseBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=_,this._isRendering=!1,this.onPostRender&&this.onPostRender(),this.performanceInfo.finishFrame()}_prepareShaders(e,r){this._renderContext.output=I.Color,this._prepareOpaqueGeometrySlots(),this._setMultipassTerrain(e),this._prepareSlots(k.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._prepareInternalSlots(this._materialRenderers,k.LINE_CALLOUTS),r&&this._prepareTransparencySlots(),this._prepareInternalSlots(this._materialRenderers,k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._prepareSlots(k.POSTPROCESSING_ENVIRONMENT_TRANSPARENT,k.LASERLINES),this._rctx.gl.flush()}_renderObjectAndLayerIdColor(e){if(null==e||!has("enable-feature:objectAndLayerId-rendering"))return;const r=this._renderContext.output;this._rctx.bindFramebuffer(e),this._offscreen.renderToFBO((()=>this._renderGeometryAndTransparentTerrainPass(I.ObjectAndLayerIdColor)),[0,0,0,0],!0,!0),this._rctx.bindFramebuffer(e),this._offscreen.renderToFBO((()=>{this._bindParameters.hudRenderStyle=O.NotOccluded,this._renderInternalSlot(k.HUD_MATERIAL)}),void 0,!0,!0),this._renderContext.output=r}finish(e){this._hasAnimations||this._animationTimestep.clear();const r=this.performanceInfo.gpuSamplingEnabled,t=e===N.BACKGROUND;if(t||r){const e=t?this.performanceInfo.elapsedTime:0,s=r?this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.getError(),i=Math.max(e,s);this._animationTimestep.frame(i,t)}}readDepthPixels(e,r,t){const s=this._bindParameters.linearDepth?.fbo;if(s?.colorTexture)return void s.readPixels(r[0],r[1],r[2],r[3],he.RGBA,oe.UNSIGNED_BYTE,t);const i=this.fboCache.acquire(S.RGBA,this._offscreen.width,this._offscreen.height).acquireDepth(y.DEPTH16_BUFFER);this._rctx.bindFramebuffer(i.fbo),this._ensureBindParameters(e,e),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.setClearColor(0,0,0,0);const a=de.COLOR_BUFFER_BIT|de.DEPTH_BUFFER_BIT|de.STENCIL_BUFFER_BIT;this._rctx.clearSafe(a),this._renderGeometryAndTransparentTerrainPass(I.Depth),i.fbo.readPixels(r[0],r[1],r[2],r[3],he.RGBA,oe.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,r,t,s,i){this._bindParameters.hudVisibility?.fbo.readPixels(e,r,t,s,he.RGBA,oe.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_setMultipassTerrain(e){this._setMultipassEnabled(e),this._setTerrainCulling(e)}_setMultipassEnabled(e){this._bindParameters.multipassEnabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_prepareSlots(...e){this._renderPlugins.prepareSlots(e)}_renderSlot(e){this._renderPlugins.render(this._renderPlugins.prepare(e))}_renderEdges(e,r){const t=this._edgeView;if(t?.shouldRender()){const{width:s,height:i,depth:a}=this._offscreen,n=this.fboCache.acquire(S.RGBA,s,i),h=()=>t.render(this._bindParameters,e);this._offscreen.renderToTargets(h,n,r??a,me),this._offscreen.compositeToFramebuffer(this._bindParameters,n.colorTexture,se.Alpha,1),n.release()}}_renderShadowMap(e,r,t,s){const i=this._shadowMap;i.enabled&&(i.start(r,t,s,this.isFeatureEnabled(V.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._shadowHighlight.updateParameters(r,t),this._needsShadowHighlight?(this._renderShadowCascades(I.ShadowHighlight,this._shadowMap),i.moveSnapshot(z.Highlight),i.clear(),this._renderShadowCascades(I.ShadowExcludeHighlight,this._shadowMap),i.copySnapshot(z.Default),this._renderShadowCascades(I.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(I.Shadow),i.finish(),this._rctx.bindFramebuffer(e),r.setGLViewport(this._rctx))}_renderShadowCascades(e,r=this._shadowMap){for(const t of r.cascades)t.camera.setGLViewport(this._rctx),this._prepare(t.camera,t.camera),this._renderGeometryAndTransparentTerrainPass(e)}get _needsLinearDepth(){return this._ssaoHelper.active||this._renderPlugins.needsLinearDepth||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast}_renderLinearDepth(){this._needsLinearDepth?(this._bindParameters.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.linearDepth,(()=>this._renderGeometryAndTransparentTerrainPass(I.Depth)),[0,0,0,0]),this._bindParameters.linearDepth.releaseDepth(),this._offscreen.bindFbo()):this._bindParameters.linearDepth=n(this._bindParameters.linearDepth)}_renderTerrainLinearDepth(e){if(e){const e=this._renderContext.output;this._renderContext.output=I.Depth,this._bindParameters.multipassTerrain.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.multipassTerrain.linearDepth,(()=>this._renderTransparentTerrain()),[-1e10,-1e10,-1e10,1]),this._bindParameters.multipassTerrain.linearDepth.releaseDepth(),this._renderContext.output=e}else this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth)}_renderGeometryLinearDepth(e){if(!e)return void(this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth));const r=this._renderContext.output;return this._bindParameters.multipassGeometry.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.multipassGeometry.linearDepth,(()=>this._renderGeometryPass(I.Depth)),[1,1,1,1]),this._renderContext.output=r,this._bindParameters.multipassGeometry.linearDepth.detachDepth()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return L;const r=v(e,this._materialRenderers,this._stage.layers);return x(r,this.renderPlugins.queryDepthRange(e)),r.near=Math.max(e.near,r.near),r.far=Math.min(e.far,r.far),r}_renderGeometryAndTransparentTerrainPass(e){this._renderContext.output=e,this._prepareSlots(k.TRANSPARENT_TERRAIN),this._renderGeometryPass(e),this._renderTransparentTerrain()}_renderGeometryPass(e){this._renderContext.output=e,this._prepareSlots(k.TRANSPARENT_MATERIAL),this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderSSAO(e){if(!this._ssaoHelper.active)return;const r=this._offscreen.renderToCachedFBO(null,(()=>this._renderGeometryAndTransparentTerrainPass(I.Normal)),[0,0,0,0],S.RGBA4);r.releaseDepth(),this._offscreen.bindFbo(),this._ssaoHelper.render(this._bindParameters,e,r.colorTexture),r.release()}_prepareOpaqueGeometrySlots(){this._prepareSlots(k.INTEGRATED_MESH,k.OPAQUE_TERRAIN,k.OPAQUE_MATERIAL,k.POSTPROCESSING_ENVIRONMENT_OPAQUE),this._prepareInternalSlots(this._materialRenderers,k.OPAQUE_MATERIAL)}_renderOpaqueGeometry(){this._renderSlot(k.INTEGRATED_MESH),this._renderSlot(k.OPAQUE_TERRAIN),this._renderInternalSlot(k.OPAQUE_MATERIAL),this._renderSlot(k.OPAQUE_MATERIAL),this._renderSlot(k.POSTPROCESSING_ENVIRONMENT_OPAQUE)}_renderTransparentGeometry(){this._renderInternalSlot(k.TRANSPARENT_MATERIAL),this._renderSlot(k.TRANSPARENT_MATERIAL)}_renderTransparentTerrain(){const e=this._renderPlugins.prepare(k.TRANSPARENT_TERRAIN);if(0===e.size)return;const r=()=>this._renderPlugins.render(e);if(this._renderContext.output!==I.Color)return void r();const{width:t,height:s,depth:i}=this._offscreen,a=this.fboCache.acquire(S.RGBA,t,s);return this._offscreen.renderToTargets(r,a,i,[0,0,0,0]),a}_renderHUDVisibility(e){let r=!1;const t=this._renderContext.offscreenRenderingHelper;this._bindParameters.hudVisibility=t.renderHUDVisibility(this._bindParameters.hudVisibility,(()=>r=this._renderInternalSlot(k.OCCLUSION_PIXELS)),e),t.bindFbo(),r||(this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility))}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===O.Occluded){const e=()=>this._renderInternalSlot(k.LINE_CALLOUTS),{width:r,height:t,color:s}=this._offscreen,i=this.fboCache.acquireDepth(y.DEPTH16_BUFFER,r,t);this._offscreen.renderToTargets(e,s,i,void 0,!0,!0),i.release()}else this._renderInternalSlot(k.LINE_CALLOUTS)}_renderHUD(e,r){if(this._materialRenderersHas.hudElements)if(this._oitEnabled){const t=this._renderOITPass(_e.HUD,e);this._rctx.bindFramebuffer(r),this._compositingHelper.composite(this._bindParameters,t.colorTexture,se.PremultipliedAlpha),t.release()}else if(e===O.Occluded){const e=()=>this._renderHUDElements(O.Occluded),{width:r,height:t,color:s}=this._offscreen,i=this.fboCache.acquireDepth(y.DEPTH16_BUFFER,r,t);this._offscreen.renderToTargets(e,s,i,void 0,!0,!0),i.release()}else this._renderHUDElements(e)}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._prepareInternalSlots(this._materialRenderers,k.LINE_CALLOUTS_HUD_DEPTH,k.HUD_MATERIAL,k.LABEL_MATERIAL),this._renderInternalSlot(k.LINE_CALLOUTS_HUD_DEPTH),this._renderInternalSlot(k.HUD_MATERIAL),this._renderInternalSlot(k.LABEL_MATERIAL)}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._shadowHighlight.isVisible&&this.hasHighlights}_renderHighlights(e,r){if(!this.hasHighlights||r.decorations===D.OFF)return;const t=()=>{this._renderGeometryAndTransparentTerrainPass(I.Highlight),this._rctx.clearSafe(de.DEPTH_BUFFER_BIT),this._renderHUDElements(O.Both)},s=this._offscreen.renderToCachedFBO(null,t,[0,0,0,0],S.RGBA4,y.DEPTH_STENCIL_TEXTURE);this._needsShadowHighlight&&this._shadowHighlight.render(r,s.fbo.colorTexture,e),s.releaseDepth(),this._highlight.render(this._bindParameters,s.fbo,e),s.release()}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_accumulateShadows(e,r,t){this._needsShadowCast&&this._bindParameters.linearDepth?.colorTexture&&this._shadowAccumulator.renderAccumulation(this._bindParameters.linearDepth,e,r,t)}_prepareTransparencySlots(){this._renderContext.output=I.Alpha,this._bindParameters.transparencyPassType=$.Alpha,this._prepareInternalSlots(this._materialRenderers,k.TRANSPARENT_MATERIAL),this._prepareSlots(k.TRANSPARENT_MATERIAL),this._renderContext.output=I.Color,this._bindParameters.transparencyPassType=$.Color,this._prepareInternalSlots(this._materialRenderers,k.TRANSPARENT_MATERIAL),this._prepareSlots(k.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=$.FrontFace,this._prepareInternalSlots(this._materialRenderers,k.TRANSPARENT_MATERIAL),this._prepareSlots(k.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=$.NONE}_renderOITPass(e,r=O.Both){const t=e===_e.HUD,s=t?this.fboCache.acquire(S.RGBA,this._offscreen.width,this._offscreen.height):null,i=t?()=>this._renderHUDElements(r):()=>this._renderTransparentGeometry(),a=this._renderContext.output;this._renderContext.output=I.Alpha,this._bindParameters.transparencyPassType=$.Alpha;const n=this._offscreen.renderOITPass(i,$.Alpha,t);this._renderContext.output=I.Color,this._bindParameters.transparencyPassType=$.Color;const h=this._offscreen.renderOITPass(i,$.Color,t);this._bindParameters.transparencyPassType=$.FrontFace;const o=this._offscreen.renderOITPass(i,$.FrontFace,t);return this._offscreen.compositeTransparentOntoOpaque(this._bindParameters,h,n,o,s),s?.releaseDepth(),o.release(),h.release(),n.release(),this._bindParameters.transparencyPassType=$.NONE,this._renderContext.output=a,s}_renderOccluded(){let e=0;ce.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&r.material.renderOccluded===U.OccludeAndTransparentStencil&&(e|=r.material.renderOccluded,ce.push(r))}));const r=this._offscreen,t=(t,s,i,a,n)=>{if(0==(e&s))return;const{width:h,height:o,depth:d}=r,l=this.fboCache.acquire(S.RGBA,h,o);r.renderToTargets(i,l,d,[0,0,0,0],a,n),r.compositeToFramebuffer(this._bindParameters,l.colorTexture,se.PremultipliedAlpha,t),l.release()};0!==ce.length&&(this._prepareInternalSlots(ce,k.OCCLUDER_MATERIAL,k.TRANSPARENT_OCCLUDER_MATERIAL),this._renderInternalSlot(k.OCCLUDER_MATERIAL,ce),t(.5,U.OccludeAndTransparentStencil,(()=>this._renderInternalSlot(k.TRANSPARENT_OCCLUDER_MATERIAL,ce)),!1,!1)),ce.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&(r.material.renderOccluded===U.OccludeAndTransparent||r.material.renderOccluded===U.Transparent||r.material.renderOccluded===U.Opaque)&&(e|=r.material.renderOccluded,ce.push(r))}));const s=this._renderPlugins.renderOccludedFlags;if(e|=s,!e)return;const i=e=>{this._renderContext.renderOccludedMask=e,this._prepareInternalSlots(ce,k.OPAQUE_MATERIAL,k.TRANSPARENT_MATERIAL,k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),s>U.Occlude&&this._renderSlot(k.OCCLUDED_TERRAIN),this._renderInternalSlot(k.OPAQUE_MATERIAL,ce),this._renderInternalSlot(k.TRANSPARENT_MATERIAL,ce),this._renderInternalSlot(k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,ce),this._renderContext.resetRenderOccludedMask()};this._renderContext.output=I.Color,t(.5,U.OccludeAndTransparent,(()=>i(U.OccludeAndTransparent)),!0,M.OutlineVisualElementMask),t(.5,U.Transparent,(()=>i(U.Transparent)),!0,M.OutlineVisualElementMask),t(1,U.Opaque,(()=>i(U.Opaque)),!0,M.OutlineVisualElementMask),ce.clear()}_renderAntiAliasing(e,r){if(this._antialiasing){if(this._smaaPass.enable((()=>this._requestRender()))&&null!=e)return this._smaaPass.render(e,r),!0}else this._smaaPass.disable();return!1}_prepare(e,r){this._needsTransparentPass=this._materialRenderers.some((e=>e.requiresSlot(k.TRANSPARENT_MATERIAL,I.Color))),this._bindParameters.camera=e,this._bindParameters.contentCamera=r}_ensureBindParameters(e,r){this._bindParameters.camera=e,this._bindParameters.contentCamera=r;const t=this._renderContext.offscreenRenderingHelper;this._bindParameters.mainColor=t.colorTexture,this._bindParameters.mainDepth=t.depthTexture}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=g:(u(fe,this._bindParameters.camera.viewMatrix),u(ue,this._bindParameters.camera.projectionMatrix),f(ge,fe,ue),f(ge,this._renderContext.lastFrameCamera.viewMatrix,ge),f(ge,this._renderContext.lastFrameCamera.projectionMatrix,ge),this._reprojectionMatrix=ge);const r=this._stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=r>0?Math.min(r,e-this._ssrEnableTime)/r:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=g,this._ssrEnableTime=null}_prepareInternalSlots(e,...r){for(const t of r)this._bindParameters.slot=t,e.forAll((e=>{e.material.shouldRender(this._renderContext)&&e.prepareTechnique(this._renderContext)}))}_renderInternalSlot(e,r=this._materialRenderers){let t=!1;return this._bindParameters.slot=e,r.forAll((e=>{if(e.material.shouldRender(this._renderContext)){const r=e.prepareTechnique(this._renderContext);null!=r&&(e.render(this._renderContext,r),t=!0)}})),t}get memoryInfo(){return{fbo:(this._offscreen?.gpuMemoryUsage??0)+(this._bindParameters.ssr.lastFrameColor?.memoryUsage??0)+(this._bindParameters.linearDepth?.memoryUsage??0)+(this._bindParameters.hudVisibility?.memoryUsage??0)+this.fboCache.peakMemoryUsage,highlights:this._highlight?.gpuMemoryUsage??0,shadows:this._shadowMap?.gpuMemoryUsage??0,ssao:this._ssaoHelper?.gpuMemoryUsage??0}}get usedMemory(){return this.fboCache.peakMemoryUsage+(this._offscreen?.gpuMemoryUsage??0)+(this._bindParameters.linearDepth?.memoryUsage??0)+(this._bindParameters.hudVisibility?.memoryUsage??0)+(this._highlight?.gpuMemoryUsage??0)+(this._shadowMap?.gpuMemoryUsage??0)+(this._ssaoHelper?.gpuMemoryUsage??0)+(this.edgeView?.usedMemory??0)}get test(){const e=this;return{offscreen:this._offscreen,shadowMap:this._shadowMap,ssao:this._ssaoHelper,highlight:this._highlight,lighting:this._bindParameters.lighting,materialRenderers:this._materialRenderers,shadowAccumulator:this._shadowAccumulator,weatherIsFading:this._bindParameters.cloudsFade.isFading,resetRenderStateFeatures:()=>{e._renderStateFeatures=j()},getFramebufferTexture:r=>{switch(r){case pe.Color:return e._offscreen.colorTexture;case pe.LinearDepth:return e._bindParameters.linearDepth?.colorTexture;case pe.ShadowMap:return e._shadowMap.depthTexture;case pe.HudVisibility:return e._bindParameters.hudVisibility?.colorTexture}}}}};var _e,pe;e([p()],le.prototype,"_renderPlugins",void 0),e([p()],le.prototype,"_shadowAccumulator",void 0),e([p()],le.prototype,"_state",void 0),e([p()],le.prototype,"_renderStateFeatures",void 0),e([p()],le.prototype,"_antialiasingEnabled",void 0),e([p({readOnly:!0})],le.prototype,"_antialiasing",null),e([p()],le.prototype,"_ssaoEnabled",void 0),e([p({readOnly:!0})],le.prototype,"fullResolutionAtmosphere",null),e([p()],le.prototype,"_smaaPass",void 0),e([p({autoDestroy:!0})],le.prototype,"_edgeView",void 0),e([p()],le.prototype,"updating",null),e([p()],le.prototype,"isCameraFinal",null),le=e([m("esri.views.3d.webgl-engine.lib.Renderer")],le),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(_e||(_e={})),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.ShadowMap=2]="ShadowMap",e[e.HudVisibility=3]="HudVisibility"}(pe||(pe={}));const me=[0,0,0,0],ce=new h,ue=T(),fe=T(),ge=T();function Te(e){return r=>e.immediate.schedule(r)}export{pe as FramebufferId,le 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.28/esri/copyright.txt for details.
4
4
  */
5
- import{disposeMaybe as e,releaseMaybe as s}from"../../../../core/maybe.js";import{Milliseconds as t}from"../../../../core/time.js";import{s as r}from"../../../../chunks/vec2.js";import{ColorFormat as i}from"../core/FBOCache.js";import{createQuadVAO as a}from"./glUtil3D.js";import{SSAOBlurTechnique as o}from"./SSAOBlurTechnique.js";import{noiseData as h}from"./SSAONoiseData.js";import{SSAOTechnique as n}from"./SSAOTechnique.js";import{g as u}from"../../../../chunks/SSAO.glsl.js";import{SSAOPassParameters as _,BlurDrawParameters as l}from"../shaders/SSAOParameters.js";import{PrimitiveType as m,ClearBufferBit as c,TextureWrapMode as d,PixelFormat as p}from"../../../webgl/enums.js";import{Texture as b}from"../../../webgl/Texture.js";import{TextureDescriptor as T}from"../../../webgl/TextureDescriptor.js";import{vertexCount as f}from"../../../webgl/Util.js";const w=2;class q{constructor(e,s,t,r){this._view=e,this._fbos=s,this._techniques=t,this._requestRender=r,this._quadVAO=null,this._passParameters=new _,this._drawParameters=new l}dispose(){this.enabled=!1,this._quadVAO=e(this._quadVAO)}destroy(){this.dispose()}disposeOffscreenBuffers(){this._ssaoFBO=s(this._ssaoFBO)}set enabled(e){e?this._enable():this._disable()}get enabled(){return null!=this._enableTime}get active(){return this.enabled&&this._ssaoTechnique.compiled&&this._blurTechnique.compiled}get colorTexture(){return this._ssaoFBO?.colorTexture}render(e,t,o){if(null==this._enableTime||null==e.linearDepth?.colorTexture||null==o)return;if(!this.active)return this._enableTime=t,void this._requestRender();0===this._enableTime&&(this._enableTime=t),this._ssaoFBO=s(this._ssaoFBO);const h=this._fbos.rctx,n=e.camera,_=this._view.qualitySettings.fadeDuration,l=_>0?Math.min(_,t-this._enableTime)/_:1;this._passParameters.normalTexture=o,this._passParameters.depthTexture=e.linearDepth?.colorTexture,this._passParameters.projScale=1/n.computeRenderPixelSizeAtDist(1),this._passParameters.intensity=4*P/u(n)**6*l;const d=n.fullViewport,p=d[2],b=d[3],T=p/w,q=b/w,A=this._fbos.acquire(i.RGBA_CLAMPED,p,b);null==this._quadVAO&&(this._quadVAO=a(this._fbos.rctx)),h.bindFramebuffer(A.fbo),h.setViewport(0,0,p,b);h.bindTechnique(this._ssaoTechnique,this._passParameters,e).bindDraw(this._drawParameters,e,this._passParameters),h.bindVAO(this._quadVAO);const O=f(this._quadVAO,"geometry");h.drawArrays(m.TRIANGLE_STRIP,0,O);const x=h.bindTechnique(this._blurTechnique,this._passParameters,e);h.setViewport(0,0,T,q);const B=this._fbos.acquire(i.RGBA_CLAMPED,T,q);h.bindFramebuffer(B.fbo),this._drawParameters.colorTexture=A.colorTexture,r(this._drawParameters.blurSize,0,w/b),x.bindDraw(this._drawParameters,e,this._passParameters),h.setViewport(0,0,T,q),h.drawArrays(m.TRIANGLE_STRIP,0,O),A.release(),this._ssaoFBO=this._fbos.acquire(i.RGBA_CLAMPED,T,q),h.bindFramebuffer(this._ssaoFBO.fbo),h.setViewport(0,0,p,b),h.setClearColor(1,1,1,0),h.clear(c.COLOR_BUFFER_BIT),h.setViewport(0,0,T,q),this._drawParameters.colorTexture=B.colorTexture,r(this._drawParameters.blurSize,w/p,0),x.bindDraw(this._drawParameters,e,this._passParameters),h.drawArrays(m.TRIANGLE_STRIP,0,O),h.setViewport(d[0],d[1],d[2],d[3]),B.release(),l<1&&this._requestRender()}_enable(){if(null!=this._enableTime)return;const e=Uint8Array.from(atob(h),(e=>e.charCodeAt(0))),s=new T;s.wrapMode=d.CLAMP_TO_EDGE,s.pixelFormat=p.RGB,s.wrapMode=d.REPEAT,s.hasMipmap=!0,s.width=32,s.height=32,this._passParameters.noiseTexture=new b(this._fbos.rctx,s,e),null==this._ssaoTechnique&&(this._ssaoTechnique=this._techniques.acquire(n)),null==this._blurTechnique&&(this._blurTechnique=this._techniques.acquire(o)),this._enableTime=t(0),this._requestRender()}_disable(){this._enableTime=null,this._passParameters.noiseTexture=e(this._passParameters.noiseTexture),this._ssaoFBO=s(this._ssaoFBO)}get gpuMemoryUsage(){return this._ssaoFBO?.fbo.gpuMemoryUsage??0}}const P=.5;export{q as SSAOHelper,w as blurSizePixels};
5
+ import{disposeMaybe as e,releaseMaybe as s}from"../../../../core/maybe.js";import{Milliseconds as t}from"../../../../core/time.js";import{s as r}from"../../../../chunks/vec2.js";import{ColorFormat as i}from"../core/FBOCache.js";import{createQuadVAO as a}from"./glUtil3D.js";import{SSAOBlurTechnique as o}from"./SSAOBlurTechnique.js";import{noiseData as h}from"./SSAONoiseData.js";import{SSAOTechnique as n}from"./SSAOTechnique.js";import{g as u}from"../../../../chunks/SSAO.glsl.js";import{SSAOPassParameters as _,BlurDrawParameters as l}from"../shaders/SSAOParameters.js";import{PrimitiveType as m,ClearBufferBit as c,TextureWrapMode as d,PixelFormat as p}from"../../../webgl/enums.js";import{Texture as b}from"../../../webgl/Texture.js";import{TextureDescriptor as T}from"../../../webgl/TextureDescriptor.js";import{vertexCount as f}from"../../../webgl/Util.js";const w=2;class q{constructor(e,s,t,r){this._view=e,this._fbos=s,this._techniques=t,this._requestRender=r,this._quadVAO=null,this._passParameters=new _,this._drawParameters=new l}dispose(){this.enabled=!1,this._quadVAO=e(this._quadVAO)}destroy(){this.dispose()}disposeOffscreenBuffers(){this._ssaoFBO=s(this._ssaoFBO)}set enabled(e){e?this._enable():this._disable()}get enabled(){return null!=this._enableTime}get active(){return this.enabled&&this._ssaoTechnique.compiled&&this._blurTechnique.compiled}get colorTexture(){return this._ssaoFBO?.colorTexture}render(e,t,o){if(null==this._enableTime||null==e.linearDepth?.colorTexture||null==o)return;if(!this.active)return this._enableTime=t,void this._requestRender();0===this._enableTime&&(this._enableTime=t),this._ssaoFBO=s(this._ssaoFBO);const h=this._fbos.rctx,n=e.camera,_=this._view.qualitySettings.fadeDuration,l=_>0?Math.min(_,t-this._enableTime)/_:1;this._passParameters.normalTexture=o,this._passParameters.depthTexture=e.linearDepth?.colorTexture,this._passParameters.projScale=1/n.computeRenderPixelSizeAtDist(1),this._passParameters.intensity=4*O/u(n)**6*l;const d=n.fullViewport,p=d[2],b=d[3],T=p/w,q=b/w,P=this._fbos.acquire(i.RGBA,p,b);null==this._quadVAO&&(this._quadVAO=a(this._fbos.rctx)),h.bindFramebuffer(P.fbo),h.setViewport(0,0,p,b);h.bindTechnique(this._ssaoTechnique,this._passParameters,e).bindDraw(this._drawParameters,e,this._passParameters),h.bindVAO(this._quadVAO);const A=f(this._quadVAO,"geometry");h.drawArrays(m.TRIANGLE_STRIP,0,A);const x=h.bindTechnique(this._blurTechnique,this._passParameters,e);h.setViewport(0,0,T,q);const B=this._fbos.acquire(i.RGBA,T,q);h.bindFramebuffer(B.fbo),this._drawParameters.colorTexture=P.colorTexture,r(this._drawParameters.blurSize,0,w/b),x.bindDraw(this._drawParameters,e,this._passParameters),h.setViewport(0,0,T,q),h.drawArrays(m.TRIANGLE_STRIP,0,A),P.release(),this._ssaoFBO=this._fbos.acquire(i.RGBA,T,q),h.bindFramebuffer(this._ssaoFBO.fbo),h.setViewport(0,0,p,b),h.setClearColor(1,1,1,0),h.clear(c.COLOR_BUFFER_BIT),h.setViewport(0,0,T,q),this._drawParameters.colorTexture=B.colorTexture,r(this._drawParameters.blurSize,w/p,0),x.bindDraw(this._drawParameters,e,this._passParameters),h.drawArrays(m.TRIANGLE_STRIP,0,A),h.setViewport(d[0],d[1],d[2],d[3]),B.release(),l<1&&this._requestRender()}_enable(){if(null!=this._enableTime)return;const e=Uint8Array.from(atob(h),(e=>e.charCodeAt(0))),s=new T;s.wrapMode=d.CLAMP_TO_EDGE,s.pixelFormat=p.RGB,s.wrapMode=d.REPEAT,s.hasMipmap=!0,s.width=32,s.height=32,this._passParameters.noiseTexture=new b(this._fbos.rctx,s,e),null==this._ssaoTechnique&&(this._ssaoTechnique=this._techniques.acquire(n)),null==this._blurTechnique&&(this._blurTechnique=this._techniques.acquire(o)),this._enableTime=t(0),this._requestRender()}_disable(){this._enableTime=null,this._passParameters.noiseTexture=e(this._passParameters.noiseTexture),this._ssaoFBO=s(this._ssaoFBO)}get gpuMemoryUsage(){return this._ssaoFBO?.fbo.gpuMemoryUsage??0}}const O=.5;export{q as SSAOHelper,w 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.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{abortMaybe as s,disposeMaybe as t}from"../../../../core/maybe.js";import{throwIfAborted as i,isAborted as o}from"../../../../core/promiseUtils.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as h}from"../../../../support/requestImageUtils.js";import{ColorFormat as l}from"../core/FBOCache.js";import{ShaderTechniqueConfiguration as u}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{BlendWeightsTechnique as c}from"./BlendWeightsTechnique.js";import{BlurTechnique as _}from"./BlurTechnique.js";import{EdgeDetectTechnique as m}from"./EdgeDetectTechnique.js";import{createScreenSizeTriangleVAO as d}from"./glUtil3D.js";import{SMAAPassParameters as p}from"../shaders/SMAAPassParameters.js";import{TextureSamplingMode as b,PixelFormat as T,ClearBufferBit as f,PrimitiveType as q,TextureWrapMode as g}from"../../../webgl/enums.js";import{Texture as x}from"../../../webgl/Texture.js";import{TextureDescriptor as A}from"../../../webgl/TextureDescriptor.js";let C=class extends r{constructor(e,r){super({}),this._fbos=e,this._techniques=r,this._passParameters=new p,this._isEnabled=!1}normalizeCtorArgs(){return{}}dispose(){this._abortController=s(this._abortController),this.disable()}_loadResources(e){if(this._abortController)return!1;if(this._passParameters.searchTexture)return!0;this._abortController=new AbortController;const r=this._abortController.signal;return import("./SmaaRenderPassData.js").then((e=>this._loadTextures(e,r))).then((()=>e())).finally((()=>this._abortController=null)),!1}_loadTextures(e,r){return i(r),Promise.all([this._loadTextureFromBase64(e.areaTexture,b.LINEAR,T.RGB),this._loadTextureFromBase64(e.searchTexure,b.NEAREST,T.LUMINANCE)]).then((([e,s])=>{o(r)?(e.dispose(),s.dispose(),i(r)):(this._passParameters.areaTexture=e,this._passParameters.searchTexture=s)}))}get updating(){return null!=this._abortController}enable(e){if(this._isEnabled)return!0;if(!this._edgeDetectTechnique||!this._blendWeightsTechnique||!this._blurTechnique){const e=new u;this._edgeDetectTechnique=this._techniques.releaseAndAcquire(m,e,this._edgeDetectTechnique),this._blendWeightsTechnique=this._techniques.releaseAndAcquire(c,e,this._blendWeightsTechnique),this._blurTechnique=this._techniques.releaseAndAcquire(_,e,this._blurTechnique)}return!!this._loadResources(e)&&(this._vao=d(this._fbos.rctx),this._isEnabled=!0,!0)}disable(){this._isEnabled&&(this._vao=t(this._vao),this._passParameters.areaTexture=t(this._passParameters.areaTexture),this._passParameters.searchTexture=t(this._passParameters.searchTexture),this._isEnabled=!1)}render(e,r){const s=e.descriptor.width,t=e.descriptor.height;if(!this._isEnabled)return;const i=this._passParameters;i.color=e;const o=this._fbos.rctx;o.bindVAO(this._vao),o.setViewport(0,0,s,t);const a=this._fbos.acquire(l.RG_CLAMPED,s,t);o.bindFramebuffer(a.fbo),o.setClearColor(0,0,0,1),o.clear(f.COLOR_BUFFER_BIT),o.bindTechnique(this._edgeDetectTechnique,i,null),o.drawArrays(q.TRIANGLES,0,3);const n=this._fbos.acquire(l.RGBA_CLAMPED,s,t);o.bindFramebuffer(n.fbo),i.inputTexture=a.colorTexture,o.setClearColor(0,0,1,1),o.clear(f.COLOR_BUFFER_BIT),o.bindTechnique(this._blendWeightsTechnique,i,null),o.drawArrays(q.TRIANGLES,0,3),o.bindFramebuffer(r),i.inputTexture=n.colorTexture,a.release(),o.setClearColor(0,1,0,1),o.clear(f.COLOR_BUFFER_BIT),o.bindTechnique(this._blurTechnique,i,null),o.drawArrays(q.TRIANGLES,0,3),n.release()}_loadTextureFromBase64(e,r,s){return h(e).then((e=>{const t=new A;return t.pixelFormat=s,t.wrapMode=g.CLAMP_TO_EDGE,t.width=e.width,t.height=e.height,t.samplingMode=r,new x(this._fbos.rctx,t,e)}))}};e([a()],C.prototype,"_abortController",void 0),e([a({readOnly:!0})],C.prototype,"updating",null),C=e([n("esri.views.3d.webgl-engine.lib.SmaaRenderPass")],C);export{C as SmaaRenderPass};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{abortMaybe as s,disposeMaybe as t}from"../../../../core/maybe.js";import{throwIfAborted as i,isAborted as o}from"../../../../core/promiseUtils.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as h}from"../../../../support/requestImageUtils.js";import{ColorFormat as l}from"../core/FBOCache.js";import{ShaderTechniqueConfiguration as u}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{BlendWeightsTechnique as c}from"./BlendWeightsTechnique.js";import{BlurTechnique as _}from"./BlurTechnique.js";import{EdgeDetectTechnique as m}from"./EdgeDetectTechnique.js";import{createScreenSizeTriangleVAO as d}from"./glUtil3D.js";import{SMAAPassParameters as p}from"../shaders/SMAAPassParameters.js";import{TextureSamplingMode as b,PixelFormat as T,ClearBufferBit as f,PrimitiveType as q,TextureWrapMode as g}from"../../../webgl/enums.js";import{Texture as x}from"../../../webgl/Texture.js";import{TextureDescriptor as A}from"../../../webgl/TextureDescriptor.js";let C=class extends r{constructor(e,r){super({}),this._fbos=e,this._techniques=r,this._passParameters=new p,this._isEnabled=!1}normalizeCtorArgs(){return{}}dispose(){this._abortController=s(this._abortController),this.disable()}_loadResources(e){if(this._abortController)return!1;if(this._passParameters.searchTexture)return!0;this._abortController=new AbortController;const r=this._abortController.signal;return import("./SmaaRenderPassData.js").then((e=>this._loadTextures(e,r))).then((()=>e())).finally((()=>this._abortController=null)),!1}_loadTextures(e,r){return i(r),Promise.all([this._loadTextureFromBase64(e.areaTexture,b.LINEAR,T.RGB),this._loadTextureFromBase64(e.searchTexure,b.NEAREST,T.LUMINANCE)]).then((([e,s])=>{o(r)?(e.dispose(),s.dispose(),i(r)):(this._passParameters.areaTexture=e,this._passParameters.searchTexture=s)}))}get updating(){return null!=this._abortController}enable(e){if(this._isEnabled)return!0;if(!this._edgeDetectTechnique||!this._blendWeightsTechnique||!this._blurTechnique){const e=new u;this._edgeDetectTechnique=this._techniques.releaseAndAcquire(m,e,this._edgeDetectTechnique),this._blendWeightsTechnique=this._techniques.releaseAndAcquire(c,e,this._blendWeightsTechnique),this._blurTechnique=this._techniques.releaseAndAcquire(_,e,this._blurTechnique)}return!!this._loadResources(e)&&(this._vao=d(this._fbos.rctx),this._isEnabled=!0,!0)}disable(){this._isEnabled&&(this._vao=t(this._vao),this._passParameters.areaTexture=t(this._passParameters.areaTexture),this._passParameters.searchTexture=t(this._passParameters.searchTexture),this._isEnabled=!1)}render(e,r){const s=e.descriptor.width,t=e.descriptor.height;if(!this._isEnabled)return;const i=this._passParameters;i.color=e;const o=this._fbos.rctx;o.bindVAO(this._vao),o.setViewport(0,0,s,t);const a=this._fbos.acquire(l.RG,s,t);o.bindFramebuffer(a.fbo),o.setClearColor(0,0,0,1),o.clear(f.COLOR_BUFFER_BIT),o.bindTechnique(this._edgeDetectTechnique,i,null),o.drawArrays(q.TRIANGLES,0,3);const n=this._fbos.acquire(l.RGBA,s,t);o.bindFramebuffer(n.fbo),i.inputTexture=a.colorTexture,o.setClearColor(0,0,1,1),o.clear(f.COLOR_BUFFER_BIT),o.bindTechnique(this._blendWeightsTechnique,i,null),o.drawArrays(q.TRIANGLES,0,3),o.bindFramebuffer(r),i.inputTexture=n.colorTexture,a.release(),o.setClearColor(0,1,0,1),o.clear(f.COLOR_BUFFER_BIT),o.bindTechnique(this._blurTechnique,i,null),o.drawArrays(q.TRIANGLES,0,3),n.release()}_loadTextureFromBase64(e,r,s){return h(e).then((e=>{const t=new A;return t.pixelFormat=s,t.wrapMode=g.CLAMP_TO_EDGE,t.width=e.width,t.height=e.height,t.samplingMode=r,new x(this._fbos.rctx,t,e)}))}};e([a()],C.prototype,"_abortController",void 0),e([a({readOnly:!0})],C.prototype,"updating",null),C=e([n("esri.views.3d.webgl-engine.lib.SmaaRenderPass")],C);export{C as SmaaRenderPass};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../core/Error.js";import"../../core/has.js";import{isPowerOfTwo as e}from"../../core/mathUtils.js";import{checkWebGLError as i}from"./checkWebGLError.js";import{ContextType as r}from"./contextUtils.js";import{ResourceType as s,TextureType as o,TextureSamplingMode as a,PixelFormat as n,PixelType as h,SizedPixelFormat as p,TextureWrapMode as l,CompressedTextureFormat as d}from"./enums.js";import{GLObjectType as c}from"./GLObjectType.js";import{estimateMemory as _}from"./TextureDescriptor.js";import{ValidatedTextureDescriptor as m}from"./ValidatedTextureDescriptor.js";const u=4;let T=class{constructor(e,i=null,a=null){if(this.type=c.Texture,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._wasImmutablyAllocated=!1,"context"in e)this._descriptor=e,a=i;else{const r=m.validate(e,i);if(!r)throw new t("Texture descriptor invalid");this._descriptor=r}if(this._descriptor.context.instanceCounter.increment(s.Texture,this),this._descriptor.context.type!==r.WEBGL2&&(this._descriptor.isImmutable&&(this._descriptor.isImmutable=!1),R(this._descriptor.target)))throw new t("3D and array textures are not supported in WebGL1");this._descriptor.target===o.TEXTURE_CUBE_MAP?this._setDataCubeMap(a):this.setData(a)}get glName(){return this._glName}get descriptor(){return this._descriptor}get gpuMemoryUsage(){return P.delete(this),_(this._descriptor)}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty}dispose(){this._descriptor.context.gl&&this._glName&&(this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null,this._descriptor.context.instanceCounter.decrement(s.Texture,this))}release(){this.dispose()}resize(e,i){const r=this._descriptor;if(r.width!==e||r.height!==i){if(this._wasImmutablyAllocated)throw new t("Immutable textures can't be resized!");r.width=e,r.height=i,this._descriptor.target===o.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}_setDataCubeMap(t=null){for(let e=o.TEXTURE_CUBE_MAP_POSITIVE_X;e<=o.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}setData(t){this._setData(t)}_setData(e,r){if(!this._descriptor.context||!this._descriptor.context.gl)return;const s=this._descriptor.context.gl;i(s),this._glName||(this._glName=s.createTexture()),void 0===e&&(e=null);const o=this._descriptor,a=r??o.target,n=R(a);null===e&&(o.width=o.width||u,o.height=o.height||u,n&&(o.depth=o.depth??1));const h=this._descriptor.context.bindTexture(this,T.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(T.TEXTURE_UNIT_FOR_UPDATES),g(this._descriptor.context,o),this._configurePixelStorage(),i(s);const p=this._deriveInternalFormat();if(D(e)){let t="width"in e?e.width:e.codedWidth,r="height"in e?e.height:e.codedHeight;const h=1;e instanceof HTMLVideoElement&&(t=e.videoWidth,r=e.videoHeight),o.width&&o.height,n&&o.depth,o.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(a,p,o.hasMipmap,t,r,h),this._texImage(a,0,p,t,r,h,e),i(s),o.hasMipmap&&this.generateMipmap(),o.width||(o.width=t),o.height||(o.height=r),n&&!o.depth&&(o.depth=h)}else{const{width:r,height:h,depth:l}=o;if(null==r||null==h)throw new t("Width and height must be specified!");if(n&&null==l)throw new t("Depth must be specified!");if(o.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(a,p,o.hasMipmap,r,h,l),A(e)){const i=e.levels,n=b(a,r,h,l),d=Math.min(n-1,i.length-1);null!=this._descriptor.context.gl2?s.texParameteri(o.target,this._descriptor.context.gl2.TEXTURE_MAX_LEVEL,d):o.hasMipmap=o.hasMipmap&&n===i.length;const c=p;if(!w(c))throw new t("Attempting to use compressed data with an uncompressed format!");this._forEachMipmapLevel(((t,e,r,s)=>{const o=i[Math.min(t,i.length-1)];this._compressedTexImage(a,t,c,e,r,s,o)}),d)}else this._texImage(a,0,p,r,h,l,e),i(s),o.hasMipmap&&this.generateMipmap()}x(s,this._descriptor),E(s,this._descriptor),f(this._descriptor.context,this._descriptor),i(s),this._descriptor.context.bindTexture(h,T.TEXTURE_UNIT_FOR_UPDATES)}updateData(e,i,r,s,o,a,n=0){a||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const h=this._descriptor.context.gl,p=this._descriptor.context.gl2,l=this._descriptor,d=this._deriveInternalFormat(),{pixelFormat:c,dataType:_,target:m,isImmutable:u}=l;if(u&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");const g=this._descriptor.context.bindTexture(this,T.TEXTURE_UNIT_FOR_UPDATES,!0);if((i<0||r<0||s>l.width||o>l.height||i+s>l.width||r+o>l.height)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage(),n){if(!p)return void console.error("Webgl2 must be enabled to use dataRowOffset!");h.pixelStorei(p.UNPACK_SKIP_ROWS,n)}if(D(a)?p?p.texSubImage2D(m,e,i,r,s,o,c,_,a):h.texSubImage2D(m,e,i,r,c,_,a):A(a)?h.compressedTexSubImage2D(m,e,i,r,s,o,d,a.levels[e]):h.texSubImage2D(m,e,i,r,s,o,c,_,a),n){if(!p)return void console.error("Webgl2 must be enabled to use dataRowOffset!");h.pixelStorei(p.UNPACK_SKIP_ROWS,0)}this._descriptor.context.bindTexture(g,T.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(e,i,r,s,o,a,n,h){h||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const p=this._descriptor.context.gl2;if(null==p)throw new t("3D textures are not supported in WebGL1");const l=this._descriptor,d=this._deriveInternalFormat(),{pixelFormat:c,dataType:_,isImmutable:m,target:u}=l;if(m&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");R(u)||console.warn("Attempting to set 3D texture data on a non-3D texture");const g=this._descriptor.context.bindTexture(this,T.TEXTURE_UNIT_FOR_UPDATES);if(this._descriptor.context.setActiveTexture(T.TEXTURE_UNIT_FOR_UPDATES),(i<0||r<0||s<0||o>l.width||a>l.height||n>l.depth||i+o>l.width||r+a>l.height||s+n>l.depth)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage(),A(h))h=h.levels[e],p.compressedTexSubImage3D(u,e,i,r,s,o,a,n,d,h);else{const t=h;p.texSubImage3D(u,e,i,r,s,o,a,n,c,_,t)}this._descriptor.context.bindTexture(g,T.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const e=this._descriptor;if(!e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("Cannot add mipmaps to immutable texture after allocation");e.hasMipmap=!0,this._samplingModeDirty=!0,g(this._descriptor.context,e)}e.samplingMode===a.LINEAR?(this._samplingModeDirty=!0,e.samplingMode=a.LINEAR_MIPMAP_NEAREST):e.samplingMode===a.NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=a.NEAREST_MIPMAP_NEAREST);const i=this._descriptor.context.bindTexture(this,T.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(T.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.gl.generateMipmap(e.target),this._descriptor.context.bindTexture(i,T.TEXTURE_UNIT_FOR_UPDATES)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,g(this._descriptor.context,this._descriptor),this._wrapModeDirty=!0)}applyChanges(){const t=this._descriptor.context.gl,e=this._descriptor;this._samplingModeDirty&&(x(t,e),this._samplingModeDirty=!1),this._wrapModeDirty&&(E(t,e),this._wrapModeDirty=!1)}_deriveInternalFormat(){if(this._descriptor.context.type===r.WEBGL1)return this._descriptor.internalFormat=this._descriptor.pixelFormat;if(null!=this._descriptor.internalFormat)return this._descriptor.internalFormat===n.DEPTH_STENCIL&&(this._descriptor.internalFormat=n.DEPTH24_STENCIL8),this._descriptor.internalFormat;switch(this._descriptor.dataType){case h.FLOAT:switch(this._descriptor.pixelFormat){case n.RGBA:return this._descriptor.internalFormat=p.RGBA32F;case n.RGB:return this._descriptor.internalFormat=p.RGB32F;default:throw new t("Unable to derive format")}case h.UNSIGNED_BYTE:switch(this._descriptor.pixelFormat){case n.RGBA:return this._descriptor.internalFormat=p.RGBA8;case n.RGB:return this._descriptor.internalFormat=p.RGB8}}return this._descriptor.internalFormat=this._descriptor.pixelFormat===n.DEPTH_STENCIL?n.DEPTH24_STENCIL8:this._descriptor.pixelFormat}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_texStorage(e,i,r,s,o,a){const n=this._descriptor.context.gl2;if(null==n)throw new t("Immutable textures are not supported in WebGL1");if(!M(i))throw new t("Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const h=r?b(e,s,o,a):1;if(R(e)){if(null==a)throw new t("Missing depth dimension for 3D texture upload");n.texStorage3D(e,h,i,s,o,a)}else n.texStorage2D(e,h,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,s,o,a,n,h){const p=this._descriptor.context.gl,l=R(e),{isImmutable:d,pixelFormat:c,dataType:_}=this._descriptor,m=this._descriptor.context.type===r.WEBGL2,u=m?p:null;if(m||!D(h))if(d){if(null!=h){const r=h;if(l){if(null==n)throw new t("Missing depth dimension for 3D texture upload");u.texSubImage3D(e,i,0,0,0,o,a,n,c,_,r)}else p.texSubImage2D(e,i,0,0,o,a,c,_,r)}}else{const r=h;if(l){if(null==n)throw new t("Missing depth dimension for 3D texture upload");u.texImage3D(e,i,s,o,a,n,0,c,_,r)}else p.texImage2D(e,i,s,o,a,0,c,_,r)}else p.texImage2D(e,0,s,c,_,h)}_compressedTexImage(e,i,s,o,a,n,h){const p=this._descriptor.context.gl;let l=null;const d=R(e),c=this._descriptor.isImmutable;if(d){if(this._descriptor.context.type!==r.WEBGL2)throw new t("3D textures are not supported in WebGL1");l=p}if(c){if(null!=h)if(d){if(null==n)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexSubImage3D(e,i,0,0,0,o,a,n,s,h)}else p.compressedTexSubImage2D(e,i,0,0,o,a,s,h)}else if(d){if(null==n)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexImage3D(e,i,s,o,a,n,0,h)}else p.compressedTexImage2D(e,i,s,o,a,0,h)}_forEachMipmapLevel(e,i=1/0){let{width:r,height:s,depth:a,hasMipmap:n,target:h}=this._descriptor;const p=h===o.TEXTURE_3D;if(null==r||null==s||p&&null==a)throw new t("Missing texture dimensions for mipmap calculation");for(let t=0;e(t,r,s,a),n&&(1!==r||1!==s||p&&1!==a)&&!(t>=i);++t)r=Math.max(1,r>>1),s=Math.max(1,s>>1),p&&(a=Math.max(1,a>>1))}};function g(t,i){(null!=i.width&&i.width<0||null!=i.height&&i.height<0||null!=i.depth&&i.depth<0)&&console.error("Negative dimension parameters are not allowed!");const s=t.type===r.WEBGL2;if(s||!i.isImmutable&&!R(i.target)||console.error("Immutable and 3D-like textures are not supported in WebGL1!"),s)return;null!=i.width&&e(i.width)&&null!=i.height&&e(i.height)||("number"==typeof i.wrapMode?i.wrapMode!==l.CLAMP_TO_EDGE&&console.error("Non-power-of-two textures must have a wrap mode of CLAMP_TO_EDGE!"):i.wrapMode.s===l.CLAMP_TO_EDGE&&i.wrapMode.t===l.CLAMP_TO_EDGE||console.error("Non-power-of-two textures must have a wrap mode of CLAMP_TO_EDGE!"),i.hasMipmap&&console.error("Mipmapping requires power-of-two textures!"))}function x(t,e){let i=e.samplingMode,r=e.samplingMode;i===a.LINEAR_MIPMAP_NEAREST||i===a.LINEAR_MIPMAP_LINEAR?(i=a.LINEAR,e.hasMipmap||(r=a.LINEAR)):i!==a.NEAREST_MIPMAP_NEAREST&&i!==a.NEAREST_MIPMAP_LINEAR||(i=a.NEAREST,e.hasMipmap||(r=a.NEAREST)),t.texParameteri(e.target,t.TEXTURE_MAG_FILTER,i),t.texParameteri(e.target,t.TEXTURE_MIN_FILTER,r)}function E(t,e){"number"==typeof e.wrapMode?(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode)):(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode.s),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode.t))}function f(t,e){const i=t.capabilities.textureFilterAnisotropic;if(!i)return;t.gl.texParameterf(e.target,i.TEXTURE_MAX_ANISOTROPY,e.maxAnisotropy??1)}function M(t){return t in p}function w(t){return t in d}function A(t){return null!=t&&"type"in t&&"compressed"===t.type}function I(t){return null!=t&&"byteLength"in t}function D(t){return null!=t&&!A(t)&&!I(t)}function R(t){return t===o.TEXTURE_3D||t===o.TEXTURE_2D_ARRAY}function b(t,e,i,r=1){let s=Math.max(e,i);return t===o.TEXTURE_3D&&(s=Math.max(s,r)),Math.round(Math.log(s)/Math.LN2)+1}function U(){const t=new Array;return P.forEach(((e,i)=>t.push([i.gpuMemoryUsage,e]))),P.clear(),t.sort(((t,e)=>e[0]-t[0])),t.reduce(((t,e)=>`${t}\n\n${Math.round(e[0]/1024)}KB: ${e[1]}`),"")}T.TEXTURE_UNIT_FOR_UPDATES=0;const P=new Map;export{T as Texture,U as clearUnestimatedTextures};
5
+ import t from"../../core/Error.js";import"../../core/has.js";import{isPowerOfTwo as e}from"../../core/mathUtils.js";import{checkWebGLError as i}from"./checkWebGLError.js";import{ContextType as r}from"./contextUtils.js";import{ResourceType as s,TextureType as o,TextureSamplingMode as a,PixelFormat as n,PixelType as h,SizedPixelFormat as p,TextureWrapMode as l,CompressedTextureFormat as d}from"./enums.js";import{GLObjectType as c}from"./GLObjectType.js";import{estimateMemory as _}from"./TextureDescriptor.js";import{ValidatedTextureDescriptor as m}from"./ValidatedTextureDescriptor.js";const u=4;let T=class{constructor(e,i=null,a=null){if(this.type=c.Texture,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._wasImmutablyAllocated=!1,"context"in e)this._descriptor=e,a=i;else{const r=m.validate(e,i);if(!r)throw new t("Texture descriptor invalid");this._descriptor=r}if(this._descriptor.context.instanceCounter.increment(s.Texture,this),this._descriptor.context.type!==r.WEBGL2&&(this._descriptor.isImmutable&&(this._descriptor.isImmutable=!1),R(this._descriptor.target)))throw new t("3D and array textures are not supported in WebGL1");this._descriptor.target===o.TEXTURE_CUBE_MAP?this._setDataCubeMap(a):this.setData(a)}get glName(){return this._glName}get descriptor(){return this._descriptor}get gpuMemoryUsage(){return P.delete(this),_(this._descriptor)}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty}dispose(){this._descriptor.context.gl&&this._glName&&(this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null,this._descriptor.context.instanceCounter.decrement(s.Texture,this))}release(){this.dispose()}resize(e,i){const r=this._descriptor;if(r.width!==e||r.height!==i){if(this._wasImmutablyAllocated)throw new t("Immutable textures can't be resized!");r.width=e,r.height=i,this._descriptor.target===o.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}_setDataCubeMap(t=null){for(let e=o.TEXTURE_CUBE_MAP_POSITIVE_X;e<=o.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}setData(t){this._setData(t)}_setData(e,r){if(!this._descriptor.context||!this._descriptor.context.gl)return;const s=this._descriptor.context.gl;i(s),this._glName||(this._glName=s.createTexture()),void 0===e&&(e=null);const o=this._descriptor,a=r??o.target,n=R(a);null===e&&(o.width=o.width||u,o.height=o.height||u,n&&(o.depth=o.depth??1));const h=this._descriptor.context.bindTexture(this,T.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(T.TEXTURE_UNIT_FOR_UPDATES),g(this._descriptor.context,o),this._configurePixelStorage(),i(s);const p=this._deriveInternalFormat();if(D(e)){let t="width"in e?e.width:e.codedWidth,r="height"in e?e.height:e.codedHeight;const h=1;e instanceof HTMLVideoElement&&(t=e.videoWidth,r=e.videoHeight),o.width&&o.height,n&&o.depth,o.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(a,p,o.hasMipmap,t,r,h),this._texImage(a,0,p,t,r,h,e),i(s),o.hasMipmap&&this.generateMipmap(),o.width||(o.width=t),o.height||(o.height=r),n&&!o.depth&&(o.depth=h)}else{const{width:r,height:h,depth:l}=o;if(null==r||null==h)throw new t("Width and height must be specified!");if(n&&null==l)throw new t("Depth must be specified!");if(o.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(a,p,o.hasMipmap,r,h,l),A(e)){const i=e.levels,n=b(a,r,h,l),d=Math.min(n-1,i.length-1);null!=this._descriptor.context.gl2?s.texParameteri(o.target,this._descriptor.context.gl2.TEXTURE_MAX_LEVEL,d):o.hasMipmap=o.hasMipmap&&n===i.length;const c=p;if(!w(c))throw new t("Attempting to use compressed data with an uncompressed format!");this._forEachMipmapLevel(((t,e,r,s)=>{const o=i[Math.min(t,i.length-1)];this._compressedTexImage(a,t,c,e,r,s,o)}),d)}else this._texImage(a,0,p,r,h,l,e),i(s),o.hasMipmap&&this.generateMipmap()}x(s,this._descriptor),E(s,this._descriptor),f(this._descriptor.context,this._descriptor),i(s),this._descriptor.context.bindTexture(h,T.TEXTURE_UNIT_FOR_UPDATES)}updateData(e,i,r,s,o,a,n=0){a||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const h=this._descriptor.context.gl,p=this._descriptor.context.gl2,l=this._descriptor,d=this._deriveInternalFormat(),{pixelFormat:c,dataType:_,target:m,isImmutable:u}=l;if(u&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");const g=this._descriptor.context.bindTexture(this,T.TEXTURE_UNIT_FOR_UPDATES,!0);if((i<0||r<0||s>l.width||o>l.height||i+s>l.width||r+o>l.height)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage(),n){if(!p)return void console.error("Webgl2 must be enabled to use dataRowOffset!");h.pixelStorei(p.UNPACK_SKIP_ROWS,n)}if(D(a)?p?p.texSubImage2D(m,e,i,r,s,o,c,_,a):h.texSubImage2D(m,e,i,r,c,_,a):A(a)?h.compressedTexSubImage2D(m,e,i,r,s,o,d,a.levels[e]):h.texSubImage2D(m,e,i,r,s,o,c,_,a),n){if(!p)return void console.error("Webgl2 must be enabled to use dataRowOffset!");h.pixelStorei(p.UNPACK_SKIP_ROWS,0)}this._descriptor.context.bindTexture(g,T.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(e,i,r,s,o,a,n,h){h||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const p=this._descriptor.context.gl2;if(null==p)throw new t("3D textures are not supported in WebGL1");const l=this._descriptor,d=this._deriveInternalFormat(),{pixelFormat:c,dataType:_,isImmutable:m,target:u}=l;if(m&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");R(u)||console.warn("Attempting to set 3D texture data on a non-3D texture");const g=this._descriptor.context.bindTexture(this,T.TEXTURE_UNIT_FOR_UPDATES);if(this._descriptor.context.setActiveTexture(T.TEXTURE_UNIT_FOR_UPDATES),(i<0||r<0||s<0||o>l.width||a>l.height||n>l.depth||i+o>l.width||r+a>l.height||s+n>l.depth)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage(),A(h))h=h.levels[e],p.compressedTexSubImage3D(u,e,i,r,s,o,a,n,d,h);else{const t=h;p.texSubImage3D(u,e,i,r,s,o,a,n,c,_,t)}this._descriptor.context.bindTexture(g,T.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const e=this._descriptor;if(!e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("Cannot add mipmaps to immutable texture after allocation");e.hasMipmap=!0,this._samplingModeDirty=!0,g(this._descriptor.context,e)}e.samplingMode===a.LINEAR?(this._samplingModeDirty=!0,e.samplingMode=a.LINEAR_MIPMAP_NEAREST):e.samplingMode===a.NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=a.NEAREST_MIPMAP_NEAREST);const i=this._descriptor.context.bindTexture(this,T.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(T.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.gl.generateMipmap(e.target),this._descriptor.context.bindTexture(i,T.TEXTURE_UNIT_FOR_UPDATES)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,g(this._descriptor.context,this._descriptor),this._wrapModeDirty=!0)}applyChanges(){const t=this._descriptor.context.gl,e=this._descriptor;this._samplingModeDirty&&(x(t,e),this._samplingModeDirty=!1),this._wrapModeDirty&&(E(t,e),this._wrapModeDirty=!1)}_deriveInternalFormat(){if(this._descriptor.context.type===r.WEBGL1)return this._descriptor.internalFormat=this._descriptor.pixelFormat;if(null!=this._descriptor.internalFormat)return this._descriptor.internalFormat===n.DEPTH_STENCIL&&(this._descriptor.internalFormat=n.DEPTH24_STENCIL8),this._descriptor.internalFormat;switch(this._descriptor.dataType){case h.FLOAT:switch(this._descriptor.pixelFormat){case n.RGBA:return this._descriptor.internalFormat=p.RGBA32F;case n.RGB:return this._descriptor.internalFormat=p.RGB32F;default:throw new t("Unable to derive format")}case h.UNSIGNED_BYTE:switch(this._descriptor.pixelFormat){case n.RGBA:return this._descriptor.internalFormat=p.RGBA8;case n.RGB:return this._descriptor.internalFormat=p.RGB8}}return this._descriptor.internalFormat=this._descriptor.pixelFormat===n.DEPTH_STENCIL?n.DEPTH24_STENCIL8:this._descriptor.pixelFormat}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_texStorage(e,i,r,s,o,a){const n=this._descriptor.context.gl2;if(null==n)throw new t("Immutable textures are not supported in WebGL1");if(!M(i))throw new t("Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const h=r?b(e,s,o,a):1;if(R(e)){if(null==a)throw new t("Missing depth dimension for 3D texture upload");n.texStorage3D(e,h,i,s,o,a)}else n.texStorage2D(e,h,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,s,o,a,n,h){const p=this._descriptor.context.gl,l=R(e),{isImmutable:d,pixelFormat:c,dataType:_}=this._descriptor,m=this._descriptor.context.type===r.WEBGL2,u=m?p:null;if(m||!D(h))if(d){if(null!=h){const r=h;if(l){if(null==n)throw new t("Missing depth dimension for 3D texture upload");u.texSubImage3D(e,i,0,0,0,o,a,n,c,_,r)}else p.texSubImage2D(e,i,0,0,o,a,c,_,r)}}else{const r=h;if(l){if(null==n)throw new t("Missing depth dimension for 3D texture upload");u.texImage3D(e,i,s,o,a,n,0,c,_,r)}else p.texImage2D(e,i,s,o,a,0,c,_,r)}else p.texImage2D(e,0,s,c,_,h)}_compressedTexImage(e,i,s,o,a,n,h){const p=this._descriptor.context.gl;let l=null;const d=R(e),c=this._descriptor.isImmutable;if(d){if(this._descriptor.context.type!==r.WEBGL2)throw new t("3D textures are not supported in WebGL1");l=p}if(c){if(null!=h)if(d){if(null==n)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexSubImage3D(e,i,0,0,0,o,a,n,s,h)}else p.compressedTexSubImage2D(e,i,0,0,o,a,s,h)}else if(d){if(null==n)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexImage3D(e,i,s,o,a,n,0,h)}else p.compressedTexImage2D(e,i,s,o,a,0,h)}_forEachMipmapLevel(e,i=1/0){let{width:r,height:s,depth:a,hasMipmap:n,target:h}=this._descriptor;const p=h===o.TEXTURE_3D;if(null==r||null==s||p&&null==a)throw new t("Missing texture dimensions for mipmap calculation");for(let t=0;e(t,r,s,a),n&&(1!==r||1!==s||p&&1!==a)&&!(t>=i);++t)r=Math.max(1,r>>1),s=Math.max(1,s>>1),p&&(a=Math.max(1,a>>1))}};function g(t,i){(null!=i.width&&i.width<0||null!=i.height&&i.height<0||null!=i.depth&&i.depth<0)&&console.error("Negative dimension parameters are not allowed!");const s=t.type===r.WEBGL2;if(s||!i.isImmutable&&!R(i.target)||console.error("Immutable and 3D-like textures are not supported in WebGL1!"),s)return;null!=i.width&&e(i.width)&&null!=i.height&&e(i.height)||("number"==typeof i.wrapMode?i.wrapMode!==l.CLAMP_TO_EDGE&&console.error("Non-power-of-two textures must have a wrap mode of CLAMP_TO_EDGE!"):i.wrapMode.s===l.CLAMP_TO_EDGE&&i.wrapMode.t===l.CLAMP_TO_EDGE||console.error("Non-power-of-two textures must have a wrap mode of CLAMP_TO_EDGE!"),i.hasMipmap&&console.error("Mipmapping requires power-of-two textures!"))}function x(t,e){let i=e.samplingMode,r=e.samplingMode;i===a.LINEAR_MIPMAP_NEAREST||i===a.LINEAR_MIPMAP_LINEAR?(i=a.LINEAR,e.hasMipmap||(r=a.LINEAR)):i!==a.NEAREST_MIPMAP_NEAREST&&i!==a.NEAREST_MIPMAP_LINEAR||(i=a.NEAREST,e.hasMipmap||(r=a.NEAREST)),t.texParameteri(e.target,t.TEXTURE_MAG_FILTER,i),t.texParameteri(e.target,t.TEXTURE_MIN_FILTER,r)}function E(t,e){"number"==typeof e.wrapMode?(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode)):(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode.s),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode.t))}function f(t,e){const i=t.capabilities.textureFilterAnisotropic;if(!i)return;t.gl.texParameterf(e.target,i.TEXTURE_MAX_ANISOTROPY,e.maxAnisotropy??1)}function M(t){return t in p}function w(t){return t in d}function A(t){return null!=t&&"type"in t&&"compressed"===t.type}function I(t){return null!=t&&"byteLength"in t}function D(t){return null!=t&&!A(t)&&!I(t)}function R(t){return t===o.TEXTURE_3D||t===o.TEXTURE_2D_ARRAY}function b(t,e,i,r=1){let s=Math.max(e,i);return t===o.TEXTURE_3D&&(s=Math.max(s,r)),Math.round(Math.log(s)/Math.LN2)+1}function U(){const t=new Array;return P.forEach(((e,i)=>t.push([i.gpuMemoryUsage,e]))),P.clear(),t.sort(((t,e)=>e[0]-t[0])),t.reduce(((t,e)=>`${t}\n\n${Math.round(e[0]/1024)}KB: ${e[1]}`),`Total: ${Math.round(t.reduce(((t,e)=>t+e[0]),0)/1024)}KB`)}T.TEXTURE_UNIT_FOR_UPDATES=0;const P=new Map;export{T as Texture,U as clearUnestimatedTextures};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{ignoreAbortErrors as t}from"../core/promiseUtils.js";import{isMeasurementSystem as s}from"../core/unitUtils.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import n from"./Widget.js";import a from"./AreaMeasurement2D/AreaMeasurement2DViewModel.js";import{accessibleHandler as o}from"./support/decorators/accessibleHandler.js";import{messageBundle as l}from"./support/decorators/messageBundle.js";import{tsx as u}from"./support/jsxFactory.js";import"./support/widgetUtils.js";const m="esri-area-measurement-2d",p=`${m}__units`,c=`${m}__measurement`,d={buttonDisabled:"esri-button--disabled",widgetIcon:"esri-icon-measure-area",base:`${m} esri-widget esri-widget--panel`,container:`${m}__container`,hint:`${m}__hint`,hintText:`${m}__hint-text`,panelError:`${m}__panel--error`,measurement:c,measurementItem:`${c}-item`,measurementItemDisabled:`${c}-item--disabled`,measurementItemTitle:`${c}-item-title`,measurementItemValue:`${c}-item-value`,settings:`${m}__settings`,units:p,unitsLabel:`${p}-label`,unitsSelect:`${p}-select esri-select`,unitsSelectWrapper:`${p}-select-wrapper`,actionSection:`${m}__actions`,newMeasurementButton:`${m}__clear-button esri-button esri-button--primary`};let v=class extends n{constructor(e,t){super(e,t),this.iconClass=d.widgetIcon,this.icon=null,this.messages=null,this.messagesUnits=null,this.viewModel=new a}get active(){return this.viewModel.active}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get unit(){return this.viewModel.unit}set unit(e){this.viewModel.unit=e}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(e){this.viewModel.unitOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}render(){const{id:e,viewModel:t,visible:i}=this,{active:r,supported:n,measurementLabel:a,state:o,unit:l,unitOptions:m}=t,p="disabled"===o,c="ready"===o,v="measuring"===o||"measured"===o,{messages:b,messagesUnits:h}=this,w=r&&c?u("section",{key:"hint",class:d.hint},u("p",{class:d.hintText},b.hint)):null,g=n?null:u("section",{key:"unsupported",class:d.panelError},u("p",null,b.unsupported)),y=(e,t,s)=>t?u("div",{key:`${s}-enabled`,class:d.measurementItem},u("span",{class:d.measurementItemTitle},e),u("span",{"aria-live":"polite",class:d.measurementItemValue},t)):u("div",{key:`${s}-disabled`,class:this.classes(d.measurementItem,d.measurementItemDisabled),"aria-disabled":"true"},u("span",{class:d.measurementItemTitle},e)),M=v?u("section",{key:"measurement",class:d.measurement},y(b.area,a?.area,"area"),y(b.perimeter,a?.perimeter,"perimeter")):null,_=`${e}__units`,$=u("section",{key:"units",class:d.units},u("label",{class:d.unitsLabel,for:_},b.unit),u("div",{class:d.unitsSelectWrapper},u("select",{class:d.unitsSelect,id:_,onchange:this._changeUnit,bind:this,value:l},m.map((e=>u("option",{key:e,value:e},s(e)?h.systems[e]:h.units[e]?.pluralCapitalized)))))),j=v?u("div",{key:"settings",class:d.settings},$):null,I=!n||r&&!v?null:u("div",{class:d.actionSection},u("button",{"aria-label":b.newMeasurement,bind:this,class:this.classes(d.newMeasurementButton,p&&d.buttonDisabled),disabled:p,onclick:this._newMeasurement,title:b.newMeasurement,type:"button"},b.newMeasurement)),f=i?u("div",{class:d.container},g,w,j,M,I):null;return u("div",{"aria-label":b.widgetLabel,class:d.base,role:"region"},f)}_newMeasurement(){t(this.viewModel.start())}_changeUnit(e){const t=e.target,s=t.options[t.selectedIndex];s&&(this.viewModel.unit=s.value)}};e([i({readOnly:!0})],v.prototype,"active",null),e([i()],v.prototype,"iconClass",void 0),e([i()],v.prototype,"icon",void 0),e([i()],v.prototype,"label",null),e([i(),l("esri/widgets/AreaMeasurement2D/t9n/AreaMeasurement2D")],v.prototype,"messages",void 0),e([i(),l("esri/core/t9n/Units")],v.prototype,"messagesUnits",void 0),e([i()],v.prototype,"uiStrings",void 0),e([i()],v.prototype,"unit",null),e([i()],v.prototype,"unitOptions",null),e([i()],v.prototype,"view",null),e([i({type:a})],v.prototype,"viewModel",void 0),e([i({type:Boolean})],v.prototype,"visible",null),e([o()],v.prototype,"_newMeasurement",null),e([o()],v.prototype,"_changeUnit",null),v=e([r("esri.widgets.AreaMeasurement2D")],v);const b=v;export{b as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{ignoreAbortErrors as t}from"../core/promiseUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import o from"./Widget.js";import r from"./AreaMeasurement2D/AreaMeasurement2DViewModel.js";import{MeasurementWidgetContent as n}from"./support/MeasurementWidgetContent.js";import"./support/widgetUtils.js";import{messageBundle as a}from"./support/decorators/messageBundle.js";import{tsx as l}from"./support/jsxFactory.js";const p="esri-area-measurement-2d",u={base:`${p} esri-widget esri-widget--panel`,newMeasurementButton:`${p}__clear-button`,widgetIcon:"esri-icon-measure-area"};let m=class extends o{constructor(e,t){super(e,t),this.iconClass=u.widgetIcon,this.icon=null,this.messages=null,this.messagesUnits=null,this.messagesCommon=null,this.viewModel=new r}get active(){return this.viewModel.active}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get unit(){return this.viewModel.unit}set unit(e){this.viewModel.unit=e}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(e){this.viewModel.unitOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}render(){const{messages:e,messagesCommon:s,messagesUnits:i,unit:o,unitOptions:r,viewModel:a,visible:p}=this,{active:m,measurementLabel:d,state:c,supported:v}=a;return l("div",{"aria-label":e.widgetLabel,key:this,class:u.base,role:"presentation"},p?l(n,{active:m,measurementItems:[{key:"area",title:i?.measures.area,value:d?.area},{key:"perimeter",title:e.perimeter,value:d?.perimeter}],messages:{...e,notApplicable:s.notApplicable},newMeasurementButtonClass:u.newMeasurementButton,onNewMeasurementClick:()=>{t(a.start())},onUnitChange:e=>{this.unit=e},state:c,supported:v,unit:o,unitOptions:r}):null)}};e([s({readOnly:!0})],m.prototype,"active",null),e([s()],m.prototype,"iconClass",void 0),e([s()],m.prototype,"icon",void 0),e([s()],m.prototype,"label",null),e([s(),a("esri/widgets/AreaMeasurement2D/t9n/AreaMeasurement2D")],m.prototype,"messages",void 0),e([s(),a("esri/core/t9n/Units")],m.prototype,"messagesUnits",void 0),e([s(),a("esri/t9n/common")],m.prototype,"messagesCommon",void 0),e([s()],m.prototype,"uiStrings",void 0),e([s()],m.prototype,"unit",null),e([s()],m.prototype,"unitOptions",null),e([s()],m.prototype,"view",null),e([s({type:r})],m.prototype,"viewModel",void 0),e([s({type:Boolean})],m.prototype,"visible",null),m=e([i("esri.widgets.AreaMeasurement2D")],m);const d=m;export{d as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{ignoreAbortErrors as t}from"../core/promiseUtils.js";import{isMeasurementSystem as s}from"../core/unitUtils.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import r from"./Widget.js";import a from"./AreaMeasurement3D/AreaMeasurement3DViewModel.js";import{accessibleHandler as l}from"./support/decorators/accessibleHandler.js";import{messageBundle as o}from"./support/decorators/messageBundle.js";import{tsx as u}from"./support/jsxFactory.js";import"./support/widgetUtils.js";const m="esri-area-measurement-3d",p=`${m}__measurement`,c=`${m}__units`,d={buttonDisabled:"esri-button--disabled",base:`${m} esri-widget esri-widget--panel`,container:`${m}__container`,hint:`${m}__hint`,hintText:`${m}__hint-text`,panelError:`${m}__panel--error`,measurement:p,measurementItem:`${p}-item`,measurementItemDisabled:`${p}-item--disabled`,measurementItemTitle:`${p}-item-title`,measurementItemValue:`${p}-item-value`,settings:`${m}__settings`,units:c,unitsLabel:`${c}-label`,unitsSelect:`${c}-select esri-select`,unitsSelectWrapper:`${c}-select-wrapper`,actionSection:`${m}__actions`,newMeasurementButton:`${m}__clear-button esri-button esri-button--primary`,widgetIcon:"esri-icon-measure-area"};let v=class extends r{constructor(e,t){super(e,t),this.iconClass=d.widgetIcon,this.icon=null,this.viewModel=new a}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}get active(){return this.viewModel.active}get analysis(){return this.viewModel.analysis}set analysis(e){this.viewModel.analysis=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(e){this.viewModel.unitOptions=e}get unit(){return this.viewModel.unit}set unit(e){this.viewModel.unit=e}render(){const{messages:e,messagesUnits:t}=this,{supported:i,active:n,measurement:r,state:a,unit:l}=this.viewModel,o="disabled"===a,m="measuring"===a||"measured"===a,p=n&&"ready"===a?u("section",{key:"esri-area-measurement-3d__hint",class:d.hint},u("p",{class:d.hintText},e.hint),u("p",{class:d.hintText},e.snappingDisablePromptAlternate)):null,c=i?null:u("section",{key:"esri-area-measurement-3d__unsupported",class:d.panelError},u("p",null,e.unsupported)),v=(t,s,i)=>{switch(s.state){case"available":return u("div",{key:`${i}-enabled`,class:d.measurementItem},u("span",{class:d.measurementItemTitle},t),u("span",{"aria-live":"polite",class:d.measurementItemValue},s.text));case"unavailable":return u("div",{key:`${i}-disabled`,class:this.classes(d.measurementItem,d.measurementItemDisabled)},u("span",{class:d.measurementItemTitle},t));case"invalid":return u("div",{key:`${i}-enabled`,class:d.measurementItem},u("span",{class:d.measurementItemTitle},t),u("span",{class:d.measurementItemValue},e.notApplicable))}},h=m&&r?u("section",{key:"esri-area-measurement-3d__measurement",class:d.measurement},v(e.area,r.area,"area"),v(e.perimeterLength,r.perimeterLength,"perimeter-length")):null,b=`${this.id}__units`,w=u("label",{class:d.unitsLabel,for:b},e.unit),y=u("div",{class:d.unitsSelectWrapper},u("select",{class:d.unitsSelect,id:b,onchange:this._changeUnit,bind:this,value:l},this.viewModel.unitOptions.map((e=>u("option",{key:e,value:e},s(e)?t.systems[e]:t.units[e]?.pluralCapitalized))))),g=m?u("section",{key:"esri-area-measurement-3d__units",class:d.units},w,y):null,_=m?u("div",{key:"settings",class:d.settings},g):null,M=!i||n&&!m?null:u("div",{class:d.actionSection},u("button",{bind:this,class:this.classes(d.newMeasurementButton,o&&d.buttonDisabled),disabled:o,onclick:this._newMeasurement,type:"button"},e.newMeasurement)),$=this.visible?u("div",{class:d.container},c,p,_,h,M):null;return u("div",{"aria-label":e.widgetLabel,key:this,class:d.base,role:"presentation"},$)}_newMeasurement(){t(this.viewModel.start())}_changeUnit(e){const t=e.target,s=t.options[t.selectedIndex];s&&(this.unit=s.value)}};e([i()],v.prototype,"view",null),e([i()],v.prototype,"visible",null),e([i()],v.prototype,"active",null),e([i({constructOnly:!0,nonNullable:!0})],v.prototype,"analysis",null),e([i()],v.prototype,"iconClass",void 0),e([i()],v.prototype,"icon",void 0),e([i()],v.prototype,"label",null),e([i(),o("esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D")],v.prototype,"messages",void 0),e([i(),o("esri/core/t9n/Units")],v.prototype,"messagesUnits",void 0),e([i()],v.prototype,"uiStrings",void 0),e([i({type:a})],v.prototype,"viewModel",void 0),e([i()],v.prototype,"unitOptions",null),e([i()],v.prototype,"unit",null),e([l()],v.prototype,"_newMeasurement",null),e([l()],v.prototype,"_changeUnit",null),v=e([n("esri.widgets.AreaMeasurement3D")],v);const h=v;export{h as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{ignoreAbortErrors as t}from"../core/promiseUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import o from"./Widget.js";import r from"./AreaMeasurement3D/AreaMeasurement3DViewModel.js";import{MeasurementWidgetContent as n}from"./support/MeasurementWidgetContent.js";import"./support/widgetUtils.js";import{messageBundle as a}from"./support/decorators/messageBundle.js";import{tsx as l}from"./support/jsxFactory.js";const p="esri-area-measurement-3d",u={base:`${p} esri-widget esri-widget--panel`,newMeasurementButton:`${p}__clear-button`,widgetIcon:"esri-icon-measure-area"};let m=class extends o{constructor(e,t){super(e,t),this.iconClass=u.widgetIcon,this.icon=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.viewModel=new r}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}get active(){return this.viewModel.active}get analysis(){return this.viewModel.analysis}set analysis(e){this.viewModel.analysis=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(e){this.viewModel.unitOptions=e}get unit(){return this.viewModel.unit}set unit(e){this.viewModel.unit=e}render(){const{messages:e,messagesCommon:s,messagesUnits:i,unit:o,unitOptions:r,viewModel:a}=this,{active:p,measurement:m,state:d,supported:v}=a;return l("div",{"aria-label":this.messages.widgetLabel,key:this,class:u.base,role:"presentation"},this.visible?l(n,{active:p,measurementItems:[{key:"direct",title:i.measures.area,value:c(m?.area)},{key:"perimeter",title:e.perimeterLength,value:c(m?.perimeterLength)}],messages:{...e,notApplicable:s.notApplicable},newMeasurementButtonClass:u.newMeasurementButton,onNewMeasurementClick:()=>{t(this.viewModel.start())},onUnitChange:e=>{this.unit=e},state:d,supported:v,unit:o,unitOptions:r}):null)}};function c(e){return"available"===e?.state?e.text:null}e([s()],m.prototype,"view",null),e([s()],m.prototype,"visible",null),e([s()],m.prototype,"active",null),e([s({constructOnly:!0,nonNullable:!0})],m.prototype,"analysis",null),e([s()],m.prototype,"iconClass",void 0),e([s()],m.prototype,"icon",void 0),e([s()],m.prototype,"label",null),e([s(),a("esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D")],m.prototype,"messages",void 0),e([s(),a("esri/t9n/common")],m.prototype,"messagesCommon",void 0),e([s(),a("esri/core/t9n/Units")],m.prototype,"messagesUnits",void 0),e([s()],m.prototype,"uiStrings",void 0),e([s({type:r})],m.prototype,"viewModel",void 0),e([s()],m.prototype,"unitOptions",null),e([s()],m.prototype,"unit",null),m=e([i("esri.widgets.AreaMeasurement3D")],m);const d=m;export{d as default};