@arcgis/core 4.34.0-next.67 → 4.34.0-next.69

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 (181) hide show
  1. package/applications/Components/analysisUtils.d.ts +1 -0
  2. package/applications/Components/analysisUtils.js +1 -1
  3. package/applications/MapViewer/mediaUtils.d.ts +1 -0
  4. package/applications/MapViewer/mediaUtils.js +1 -1
  5. package/arcade/Feature.js +1 -1
  6. package/arcade/functions/measures.js +1 -1
  7. package/assets/esri/core/workers/RemoteClient.js +1 -1
  8. package/assets/esri/core/workers/chunks/097a5c333de28ec5e16f.js +1 -0
  9. package/assets/esri/core/workers/chunks/2f44848916051f5501eb.js +1 -0
  10. package/assets/esri/core/workers/chunks/{2cd27b06226e30aec5da.js → 3cef77453623bbb37ad2.js} +1 -1
  11. package/assets/esri/core/workers/chunks/3d2629357242492afcfa.js +1 -0
  12. package/assets/esri/core/workers/chunks/49486c2e12e768b347ed.js +1 -0
  13. package/assets/esri/core/workers/chunks/{cad03967e132a28512c2.js → 4aa98309081e6889ccbb.js} +1 -1
  14. package/assets/esri/core/workers/chunks/570b17a1a4ab405bbdcb.js +1 -0
  15. package/assets/esri/core/workers/chunks/5a6b487b70ca85a45f57.js +1 -0
  16. package/assets/esri/core/workers/chunks/5a95688651d7e8b7101d.js +1 -0
  17. package/assets/esri/core/workers/chunks/6433116597021a9af680.js +1 -0
  18. package/assets/esri/core/workers/chunks/{5d8c64693830506c8776.js → 643acb12ec6a1d4b4fbb.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{90491262b6d6a126c32f.js → 7944c18b270c85ff2e41.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{35df19d1eab3a694c3fa.js → 978fab0f0b10edde4ff8.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{27027493a8dba8305693.js → a07321a901d6847d1a6b.js} +1 -1
  22. package/assets/esri/core/workers/chunks/a6f66492651646c18f10.js +1 -0
  23. package/assets/esri/core/workers/chunks/{a44f17397d8589433dae.js → b683b0fa7fc430b4d9c5.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{2f7e192ee2066f863e1d.js → c908184d747d33366881.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{997a2a1a51039ce7e4e3.js → dd84f630466a26722d57.js} +1 -1
  26. package/assets/esri/core/workers/chunks/e2486bf5546443408c85.js +1 -0
  27. package/assets/esri/core/workers/chunks/{96102a9296afd1bfe1a9.js → e956d437c0c2ea81db93.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{d6f5297f7b323c340727.js → f060a52a9b69eb250d63.js} +1 -1
  29. package/assets/esri/core/workers/chunks/f1865b28f0f75cadd716.js +1 -0
  30. package/assets/esri/core/workers/chunks/{06ff5f34ad9bdf9705de.js → f47a0b9e500af2b9453b.js} +8 -2
  31. package/assets/esri/core/workers/chunks/f8adac87e48ea86bec21.js +1 -0
  32. package/assets/esri/core/workers/chunks/fe475b1ecdefecfcd541.js +1 -0
  33. package/assets/esri/themes/base/widgets/_Expand.scss +1 -1
  34. package/assets/esri/themes/dark/main.css +1 -1
  35. package/assets/esri/themes/light/main.css +1 -1
  36. package/assets/esri/themes/light/view.css +1 -1
  37. package/chunks/ComponentShader.glsl.js +42 -36
  38. package/chunks/LineSeries.js +1 -1
  39. package/config.js +1 -1
  40. package/core/MemCache.js +1 -1
  41. package/core/MemCachePool.js +1 -1
  42. package/editing/geometry/lineUtils.js +1 -1
  43. package/geometry/ellipsoidUtils.js +1 -1
  44. package/geometry/support/curves/bezierCurveUtils.js +1 -1
  45. package/geometry/support/curves/circleUtils.js +1 -1
  46. package/geometry/support/curves/curveLength.js +1 -1
  47. package/geometry/support/curves/ellipticArc7Utils.js +1 -1
  48. package/interfaces.d.ts +72 -527
  49. package/kernel.js +1 -1
  50. package/layers/support/ElevationTileData.js +1 -1
  51. package/layers/support/gaussianSplatUtils.js +1 -1
  52. package/package.json +1 -1
  53. package/support/elevationInfoUtils.js +1 -1
  54. package/support/revision.js +1 -1
  55. package/views/2d/engine/vectorTiles/RenderBucket.js +1 -1
  56. package/views/2d/engine/vectorTiles/TileHandler3D.js +1 -1
  57. package/views/2d/engine/vectorTiles/VectorTile.js +1 -1
  58. package/views/2d/interactive/editingTools/MediaTransformToolsWrapper.js +5 -0
  59. package/views/3d/analysis/ElevationProfile/ElevationProfileSceneLineComputation.js +1 -1
  60. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementShiftTool.js +5 -0
  61. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementTool.js +1 -1
  62. package/views/3d/glTF/loader.js +1 -1
  63. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  64. package/views/3d/interactive/editingTools/isSupportedObjectUtils.js +1 -1
  65. package/views/3d/interactive/editingTools/move/isSupportedObject.js +1 -1
  66. package/views/3d/interactive/editingTools/reshape/isSupportedObject.js +1 -1
  67. package/views/3d/interactive/editingTools/transform/isSupportedGraphic.js +1 -1
  68. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  69. package/views/3d/layers/I3SMeshView3D.js +1 -1
  70. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  71. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  72. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  73. package/views/3d/layers/graphics/ElevationContext.js +1 -1
  74. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  75. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  76. package/views/3d/layers/graphics/Graphics3DGraphic.js +1 -1
  77. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  78. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  79. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  80. package/views/3d/layers/graphics/Graphics3DLodInstanceGraphicLayer.js +1 -1
  81. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  82. package/views/3d/layers/graphics/Graphics3DMeshObject3DGraphicLayer.js +1 -1
  83. package/views/3d/layers/graphics/Graphics3DObject3DGraphicLayer.js +1 -1
  84. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  85. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  86. package/views/3d/layers/graphics/Graphics3DPointSymbol.js +1 -1
  87. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  88. package/views/3d/layers/graphics/Graphics3DSymbol.js +1 -1
  89. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  90. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  91. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  92. package/views/3d/layers/graphics/Graphics3DWebStyleSymbol.js +1 -1
  93. package/views/3d/layers/graphics/Labeler.js +1 -1
  94. package/views/3d/layers/graphics/ObjectResourceCache.js +1 -1
  95. package/views/3d/layers/graphics/QueryEngineCache.js +1 -1
  96. package/views/3d/layers/graphics/elevationAlignPointsInFeatures.js +1 -1
  97. package/views/3d/layers/graphics/wosrLoader.js +1 -1
  98. package/views/3d/layers/i3s/CachedMeshData.js +1 -1
  99. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  100. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  101. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  102. package/views/3d/layers/i3s/PointCloudRendererNode.js +1 -1
  103. package/views/3d/layers/support/FeatureTile.js +1 -1
  104. package/views/3d/layers/support/Tiles3DIntersectionHandler.js +1 -1
  105. package/views/3d/support/CombinedElevationProvider.js +1 -1
  106. package/views/3d/support/buffer/InterleavedLayout.js +1 -1
  107. package/views/3d/terrain/MapDataCacheItem.js +5 -0
  108. package/views/3d/terrain/OverlayManager.js +1 -1
  109. package/views/3d/terrain/OverlayRenderer.js +1 -1
  110. package/views/3d/terrain/TerrainSurface.js +1 -1
  111. package/views/3d/terrain/Tile.js +1 -1
  112. package/views/3d/terrain/TileTexture.js +1 -1
  113. package/views/3d/webgl/ManagedFBO.js +1 -1
  114. package/views/3d/webgl/ManagedFBOAttachment.js +1 -1
  115. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  116. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  117. package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentShader.glsl.js +1 -1
  118. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  119. package/views/3d/webgl-engine/core/FBOPool.js +1 -1
  120. package/views/3d/webgl-engine/core/shaderLibrary/output/ReadDepth.glsl.js +8 -2
  121. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorNode.js +1 -1
  122. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
  123. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  124. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  125. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  126. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  127. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  128. package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
  129. package/views/3d/webgl-engine/shaders/SphereDepthInterpolate.glsl.js +17 -0
  130. package/views/GroundView.js +1 -1
  131. package/views/analysis/ElevationProfile/ElevationProfileChart.js +5 -0
  132. package/views/analysis/ElevationProfile/constants.js +1 -1
  133. package/views/analysis/ElevationProfile/elevationProfileChartBoundsUtils.js +5 -0
  134. package/views/analysis/ElevationProfile/elevationProfileChartTheme.js +5 -0
  135. package/views/analysis/ElevationProfile/elevationProfileGeometryUtils.js +1 -1
  136. package/views/webgl/Texture.js +1 -1
  137. package/views/webgl/VertexArrayObject.js +1 -1
  138. package/widgets/Bookmarks.js +1 -1
  139. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  140. package/widgets/Editor/UpdateFeaturesWorkflow.js +1 -1
  141. package/widgets/Editor/support/EditorItem.js +1 -1
  142. package/widgets/Editor/support/splitFeatureUtils.js +1 -1
  143. package/widgets/ElevationProfile/support/chartUtils.js +1 -1
  144. package/widgets/Expand.js +1 -1
  145. package/widgets/Feature/FeatureMedia/xyChart.js +1 -1
  146. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  147. package/widgets/support/SelectionList.js +1 -1
  148. package/assets/esri/core/workers/chunks/047d6f7b1677cc7ab271.js +0 -1
  149. package/assets/esri/core/workers/chunks/0f20c0eec850a39620a1.js +0 -1
  150. package/assets/esri/core/workers/chunks/3212a476184be25d17f8.js +0 -1
  151. package/assets/esri/core/workers/chunks/39d69afc9da9db0c75ab.js +0 -1
  152. package/assets/esri/core/workers/chunks/548818df658b607a364e.js +0 -1
  153. package/assets/esri/core/workers/chunks/70dc7ec6474f0801bc04.js +0 -1
  154. package/assets/esri/core/workers/chunks/7597ef10d1699e7088e5.js +0 -1
  155. package/assets/esri/core/workers/chunks/8a104b35708a492bd614.js +0 -1
  156. package/assets/esri/core/workers/chunks/a634764dec5404f4a1d7.js +0 -1
  157. package/assets/esri/core/workers/chunks/bafd9b0f6e817252cb31.js +0 -1
  158. package/assets/esri/core/workers/chunks/bc9f54a6b577c43189fd.js +0 -1
  159. package/assets/esri/core/workers/chunks/de4da985c398c8bcf2e7.js +0 -1
  160. package/assets/esri/core/workers/chunks/f4d4c1f13522f20b00d1.js +0 -1
  161. package/graphic/BuildingGraphicOrigin.d.ts +0 -4
  162. package/graphic/CSVGraphicOrigin.d.ts +0 -4
  163. package/graphic/CatalogGraphicOrigin.d.ts +0 -4
  164. package/graphic/FeatureGraphicOrigin.d.ts +0 -4
  165. package/graphic/GeoJSONGraphicOrigin.d.ts +0 -4
  166. package/graphic/GeoRSSGraphicOrigin.d.ts +0 -4
  167. package/graphic/KnowledgeGraphGraphicOrigin.d.ts +0 -4
  168. package/graphic/MapImageGraphicOrigin.d.ts +0 -4
  169. package/graphic/MapNotesGraphicOrigin.d.ts +0 -4
  170. package/graphic/OGCFeatureGraphicOrigin.d.ts +0 -4
  171. package/graphic/OrientedImageryGraphicOrigin.d.ts +0 -4
  172. package/graphic/ParquetGraphicOrigin.d.ts +0 -4
  173. package/graphic/PointCloudGraphicOrigin.d.ts +0 -4
  174. package/graphic/SceneGraphicOrigin.d.ts +0 -4
  175. package/graphic/StreamGraphicOrigin.d.ts +0 -4
  176. package/graphic/SubtypeGroupGraphicOrigin.d.ts +0 -4
  177. package/graphic/TileGraphicOrigin.d.ts +0 -4
  178. package/graphic/VoxelGraphicOrigin.d.ts +0 -4
  179. package/graphic/WCSGraphicOrigin.d.ts +0 -4
  180. package/graphic/WFSGraphicOrigin.d.ts +0 -4
  181. package/graphic/graphicOrigins.d.ts +0 -22
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Error.js";import{ManagedColorAttachment as t}from"../../webgl/ManagedColorAttachment.js";import{ManagedDepthTexture as a}from"../../webgl/ManagedDepthTexture.js";import r from"../../webgl/ManagedFBO.js";import{isDepthFormat as c,formatString as h,DepthTextureFormats as s,ColorFormats as i}from"./FBOCacheFormats.js";import{FBOPool as n}from"./FBOPool.js";import{DepthStencilAttachment as o,ColorAttachment0 as l}from"../../../webgl/enums.js";import{FramebufferObject as u}from"../../../webgl/FramebufferObject.js";import{Texture as m}from"../../../webgl/Texture.js";class d{constructor(e){this.rctx=e,this._interactive=!1,this._usage=new Map,this._acquired=new Set,this._cache=new n(e.newCache,"FBOCache"),this._depthCache=new n(e.newCache,"DepthAttachmentCache"),this._colorCache=new n(e.newCache,"ColorAttachmentCache")}destroy(){this._cache.destroy(),this._depthCache.destroy(),this._colorCache.destroy()}clean(){this._cache.clean(),this._colorCache.clean(),this._depthCache.clean()}frameStart(){this._cache.frame(),this._colorCache.frame(),this._depthCache.frame(),this.debugCallback?.(),this._usage.clear()}frameEnd(){const{debugCallback:e}=this;e&&this._acquired.forEach(t=>e(t.name,t.fbo,this._usage))}get usedMemory(){return Array.from(this._acquired.values()).reduce((e,t)=>e+t.cachedMemory,this._cache.usedMemory+this._colorCache.usedMemory+this._depthCache.usedMemory)}set interactive(e){this._cache.interactive=this._colorCache.interactive=this._depthCache.interactive=e,this._interactive=e}get interactive(){return this._interactive}acquire(t,a,s,i=5){const n=C(i,t,a);let m=this._cache.pop(n);const{rctx:d}=this;if(m){m.retain(),m.setName(s);const t=m.getAttachment(o);t&&(t.name=f(s));const a=m.getAttachment(l);a&&(a.name=_(s,0));const{fbo:r}=m;if(!r)throw new e("renderer","attempt to use a none existing framebuffer");d.temporaryBindFramebufferObject(r,()=>{d.setDrawBuffers([l]),d.unbindTexture(r.colorTexture)})}else{const e=new u(d),h=(e,r,c)=>{r??=5;const h=this._acquireColor(r,t,a,c??_(m.name,e-l));return this.rctx.unbindTexture(h.attachment),m.attachColor(h,e),h.release(),m},p=e=>{e??=12;const r=this.acquireDepth(e,t,a,f(m.name));return m.attachDepth(r),r.release(),m},C=()=>{if(!m)return;this.debugCallback?.(m.name,m.fbo),this._acquired.delete(m);const e=c(i);e&&null!=m.getAttachment(o)||!e&&null!=m.getAttachment(l)?(e?(m.fbo?.invalidateAttachments([o]),m.detachAllColors()):(m.fbo?.invalidateAttachments([l]),m.detachAllButColor0()),this._cache.put(m)):m.dispose()};m=new r(n,s,e,h,p,C),c(i)?m.acquireDepth(i):m.acquireColor(l,i,s)}return this._trackUsage(m,"fbo "+h(i),t,a),this._trackHandle(m)}acquireDepth(e,t,r,c){const i=C(e,t,r);let n=this._depthCache.pop(i);if(n)n.retain(),n.attachment.setShadowFiltering(!1);else{const c=new m(this.rctx,{...s[e],width:t,height:r});n=new a(i,c,()=>this._depthCache.put(n))}return n.name=c,this._trackUsage(n,"depth "+h(e),t,r),n}_acquireColor(e,a,r,c){const s=C(e,a,r);let n=this._colorCache.pop(s);if(n)n.retain();else{const c=new m(this.rctx,{...i[e],width:a,height:r});n=new t(s,c,()=>this._colorCache.put(n))}return n.name=c,this._trackUsage(n,"color "+h(e),a,r),n}_trackHandle(e){return this._acquired.add(e),e}_trackUsage(e,t,a,r){this.debugCallback&&(this._usage.has(e)?this._usage.get(e)[2].push(e.name):this._usage.set(e,[t,`${a}x${r}`,[e.name]]))}}function _(e,t=0){return`${e}.color${t}`}function f(e){return`${e}.depth`}const p=new r("default","default",null,()=>p,()=>p,()=>{});function C(e,t,a){return`${t}x${a}:${e}`}p.release=()=>!1;export{d as FBOCache,p as defaultWebGLFBO};
5
+ import e from"../../../../core/Logger.js";import{ManagedColorAttachment as t}from"../../webgl/ManagedColorAttachment.js";import{ManagedDepthTexture as a}from"../../webgl/ManagedDepthTexture.js";import r from"../../webgl/ManagedFBO.js";import{isDepthFormat as c,formatString as h,DepthTextureFormats as s,ColorFormats as i}from"./FBOCacheFormats.js";import{FBOPool as n}from"./FBOPool.js";import{DepthStencilAttachment as o,ColorAttachment0 as l}from"../../../webgl/enums.js";import{FramebufferObject as u}from"../../../webgl/FramebufferObject.js";import{Texture as m}from"../../../webgl/Texture.js";class d{constructor(e){this.rctx=e,this._interactive=!1,this._usage=new Map,this._acquired=new Set,this._cache=new n(e.newCache,"FBOCache"),this._depthCache=new n(e.newCache,"DepthAttachmentCache"),this._colorCache=new n(e.newCache,"ColorAttachmentCache")}destroy(){this._cache.destroy(),this._depthCache.destroy(),this._colorCache.destroy()}clean(){this._cache.clean(),this._colorCache.clean(),this._depthCache.clean()}frameStart(){this._cache.frame(),this._colorCache.frame(),this._depthCache.frame(),this.debugCallback?.(),this._usage.clear()}frameEnd(){const{debugCallback:e}=this;e&&this._acquired.forEach(t=>e(t.name,t.fbo,this._usage))}get usedMemory(){return Array.from(this._acquired.values()).reduce((e,t)=>e+t.usedMemory,this._cache.usedMemory+this._colorCache.usedMemory+this._depthCache.usedMemory)}set interactive(e){this._cache.interactive=this._colorCache.interactive=this._depthCache.interactive=e,this._interactive=e}get interactive(){return this._interactive}acquire(t,a,s,i=5){const n=p(i,t,a);let m=this._cache.pop(n);const{rctx:d}=this;if(m){m.retain(),m.setName(s);const t=m.getAttachment(o);t&&(t.name=f(s));const a=m.getAttachment(l);a&&(a.name=_(s,0));const r=m.fbo;r?d.temporaryBindFramebufferObject(r,()=>{d.setDrawBuffers([l]),d.unbindTexture(r.colorTexture)}):e.getLogger("esri.views.3d.webgl-engine.core.FBOCache").errorOnce("Encountered an invalid cached framebuffer")}else{const e=new u(d),h=(e,r,c)=>{r??=5;const h=this._acquireColor(r,t,a,c??_(m.name,e-l));return this.rctx.unbindTexture(h.attachment),m.attachColor(h,e),h.release(),m},g=e=>{e??=12;const r=this.acquireDepth(e,t,a,f(m.name));return m.attachDepth(r),r.release(),m},p=()=>{if(!m)return;this.debugCallback?.(m.name,m.fbo),this._acquired.delete(m);const e=c(i);e&&null!=m.getAttachment(o)||!e&&null!=m.getAttachment(l)?(e?(m.fbo?.invalidateAttachments([o]),m.detachAllColors()):(m.fbo?.invalidateAttachments([l]),m.detachAllButColor0()),this._cache.put(m)):m.dispose()};m=new r(n,s,e,h,g,p),c(i)?m.acquireDepth(i):m.acquireColor(l,i,s)}return this._trackUsage(m,"fbo "+h(i),t,a),this._trackHandle(m)}acquireDepth(e,t,r,c){const i=p(e,t,r);let n=this._depthCache.pop(i);if(n)n.retain(),n.attachment.setShadowFiltering(!1);else{const c=new m(this.rctx,{...s[e],width:t,height:r});n=new a(i,c,()=>this._depthCache.put(n))}return n.name=c,this._trackUsage(n,"depth "+h(e),t,r),n}_acquireColor(e,a,r,c){const s=p(e,a,r);let n=this._colorCache.pop(s);if(n)n.retain();else{const c=new m(this.rctx,{...i[e],width:a,height:r});n=new t(s,c,()=>this._colorCache.put(n))}return n.name=c,this._trackUsage(n,"color "+h(e),a,r),n}_trackHandle(e){return this._acquired.add(e),e}_trackUsage(e,t,a,r){this.debugCallback&&(this._usage.has(e)?this._usage.get(e)[2].push(e.name):this._usage.set(e,[t,`${a}x${r}`,[e.name]]))}}function _(e,t=0){return`${e}.color${t}`}function f(e){return`${e}.depth`}const g=new r("default","default",null,()=>g,()=>g,()=>{});function p(e,t,a){return`${t}x${a}:${e}`}g.release=()=>!1;export{d as FBOCache,g as defaultWebGLFBO};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{MemCachePool as t}from"../../../../core/MemCachePool.js";import s from"../../../../core/PooledArray.js";class i{constructor(i,e){this._last=new s,this._incarnation=0,this._cache=new t(i,e)}destroy(){this._last?.forAll(t=>t.dispose()),this._last?.prune(),this._last=null,this._cache.destroy()}set interactive(t){t&&!this._last?this._last=new s:t||(this._last?.forAll(t=>t.dispose()),this._last=null)}clean(){this._last?.filterInPlace(t=>!(t.incarnation<this._incarnation)||(this._cache.put(t.key,t),!1))}frame(){++this._incarnation}pop(t){if(this._last){const s=this._last.find(s=>s.key===t);if(s)return this._last.removeUnordered(s),s}return this._cache.pop(t)}put(t){t.incarnation=this._incarnation,this._last?this._last.push(t):this._cache.put(t.key,t)}get usedMemory(){return this._last?.reduce((t,s)=>t+s.cachedMemory,0)??0}}export{i as FBOPool};
5
+ import{MemCachePool as t}from"../../../../core/MemCachePool.js";import s from"../../../../core/PooledArray.js";class i{constructor(i,e){this._last=new s,this._incarnation=0,this._cache=new t(i,e)}destroy(){this._last?.forAll(t=>t.dispose()),this._last?.prune(),this._last=null,this._cache.destroy()}set interactive(t){t&&!this._last?this._last=new s:t||(this._last?.forAll(t=>t.dispose()),this._last=null)}clean(){this._last?.filterInPlace(t=>!(t.incarnation<this._incarnation)||(this._cache.put(t.key,t),!1))}frame(){++this._incarnation}pop(t){if(this._last){const s=this._last.find(s=>s.key===t);if(s)return this._last.removeUnordered(s),s}return this._cache.pop(t)}put(t){t.incarnation=this._incarnation,this._last?this._last.push(t):this._cache.put(t.key,t)}get usedMemory(){return this._last?.reduce((t,s)=>t+s.usedMemory,0)??0}}export{i as FBOPool};
@@ -2,15 +2,21 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{set as e}from"../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as t}from"../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{Float2BindUniform as r}from"../../shaderModules/Float2BindUniform.js";import{glsl as o}from"../../shaderModules/glsl.js";function d(e){e.uniforms.add(new r("zProjectionMap",e=>a(e.camera))),e.code.add(o`float linearizeDepth(float depth) {
5
+ import{set as e}from"../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as t}from"../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{Float2BindUniform as r}from"../../shaderModules/Float2BindUniform.js";import{glsl as o}from"../../shaderModules/glsl.js";function a(e){e.uniforms.add(new r("zProjectionMap",e=>d(e.camera))),e.code.add(o`float linearizeDepth(float depth) {
6
6
  float depthNdc = depth * 2.0 - 1.0;
7
7
  float c1 = zProjectionMap[0];
8
8
  float c2 = zProjectionMap[1];
9
9
  return -(c1 / (depthNdc + c2 + 1e-7));
10
+ }`),e.code.add(o`float delinearizeDepth(float linearDepth) {
11
+ float c1 = zProjectionMap[0];
12
+ float c2 = zProjectionMap[1];
13
+ float depthNdc = (-c1/linearDepth) - c2 - 1e-7;
14
+ float depthNonlinear01 = (depthNdc + 1.0 ) / 2.0;
15
+ return depthNonlinear01;
10
16
  }`),e.code.add(o`float depthFromTexture(sampler2D depthTexture, vec2 uv) {
11
17
  ivec2 iuv = ivec2(uv * vec2(textureSize(depthTexture, 0)));
12
18
  float depth = texelFetch(depthTexture, iuv, 0).r;
13
19
  return depth;
14
20
  }`),e.code.add(o`float linearDepthFromTexture(sampler2D depthTexture, vec2 uv) {
15
21
  return linearizeDepth(depthFromTexture(depthTexture, uv));
16
- }`)}function a(t){const r=t.projectionMatrix;return e(c,r[14],r[10])}const c=t();export{d as ReadDepth};
22
+ }`)}function d(t){const r=t.projectionMatrix;return e(c,r[14],r[10])}const c=t();export{a as ReadDepth};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{property as r}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as s}from"../../../../../core/accessorSupport/decorators/subclass.js";import{InternalRenderCategory as o}from"../../../webgl.js";import t from"../../../webgl/RenderNode.js";import{F as i}from"../../../../../chunks/FocusAreaColor.glsl.js";import{FocusAreaColorTechnique as c}from"./FocusAreaColorTechnique.js";import{DepthStencilAttachment as a}from"../../../../webgl/enums.js";let p=class extends t{constructor(e){super({...e,view:e.focusAreasView.view}),this.consumes={required:[o.FOCUSAREA_COLOR,o.FOCUSAREA]},this.produces=o.FOCUSAREA_COLOR,this._passParameters=new i}precompile(){this.techniques.precompile(c)}render(e){const r=this.techniques.get(c),s=e.find(({name:e})=>e===this.produces);if(!r.compiled)return this.requestRender(),s;const t=this.focusAreasView.style,i=this.bindParameters,p=i.camera,n=p.fullViewport[2],u=p.fullViewport[3],d=e.find(({name:e})=>e===o.FOCUSAREA),h=this.fboCache.acquire(n,u,this.produces),f=this.renderingContext;return f.bindFramebuffer(h.fbo),this._passParameters.color=s.getTexture(),this._passParameters.focusArea=d.getTexture(),this._passParameters.effect=m[t],f.bindTechnique(r,i,this._passParameters),f.screen.draw(),h.attachDepth(s.getAttachment(a)),h}};e([r()],p.prototype,"consumes",void 0),e([r()],p.prototype,"produces",void 0),e([r({constructOnly:!0})],p.prototype,"focusAreasView",void 0),p=e([s("esri.views.3d.webgl-engine.effects.focusArea.FocusAreaColorNode")],p);const m={bright:0,dark:1};export{p as FocusAreaColorNode};
5
+ import{__decorate as e}from"tslib";import{property as r}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as s}from"../../../../../core/accessorSupport/decorators/subclass.js";import{InternalRenderCategory as o}from"../../../webgl.js";import t from"../../../webgl/RenderNode.js";import{F as i}from"../../../../../chunks/FocusAreaColor.glsl.js";import{FocusAreaColorTechnique as c}from"./FocusAreaColorTechnique.js";import{DepthStencilAttachment as a}from"../../../../webgl/enums.js";let p=class extends t{constructor(e){super({...e,view:e.focusAreasView.view}),this.consumes={required:[o.FOCUSAREA_COLOR,o.FOCUSAREA]},this.produces=o.FOCUSAREA_COLOR,this._passParameters=new i}precompile(){this.techniques.precompile(c)}render(e){const r=this.techniques.get(c),s=e.find(({name:e})=>e===this.produces);if(!r.compiled)return this.requestRender(1),s;const t=this.focusAreasView.style,i=this.bindParameters,p=i.camera,n=p.fullViewport[2],u=p.fullViewport[3],d=e.find(({name:e})=>e===o.FOCUSAREA),h=this.fboCache.acquire(n,u,this.produces),f=this.renderingContext;return f.bindFramebuffer(h.fbo),this._passParameters.color=s.getTexture(),this._passParameters.focusArea=d.getTexture(),this._passParameters.effect=m[t],f.bindTechnique(r,i,this._passParameters),f.screen.draw(),h.attachDepth(s.getAttachment(a)),h}};e([r()],p.prototype,"consumes",void 0),e([r()],p.prototype,"produces",void 0),e([r({constructOnly:!0})],p.prototype,"focusAreasView",void 0),p=e([s("esri.views.3d.webgl-engine.effects.focusArea.FocusAreaColorNode")],p);const m={bright:0,dark:1};export{p as FocusAreaColorNode};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{property as s}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as t}from"../../../../../core/accessorSupport/decorators/subclass.js";import{RenderCategory as r,InternalRenderCategory as o}from"../../../webgl.js";import i from"../../../webgl/RenderNode.js";import{F as n}from"../../../../../chunks/FocusAreaMask.glsl.js";import{FocusAreaMaskTechnique as a}from"./FocusAreaMaskTechnique.js";import{Pos3 as c}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as h}from"../../lib/VertexArrayObject.js";import{DepthStencilAttachment as p,PrimitiveType as l}from"../../../../webgl/enums.js";import{noParameters as u}from"../../../../webgl/NoParameters.js";import{VertexBuffer as m}from"../../../../webgl/VertexBuffer.js";let d=class extends i{constructor(e){super({...e,view:e.focusAreasView.view}),this.consumes={required:[r.TRANSPARENT]},this.produces=o.FOCUSAREA,this._vaos=new Array,this._counts=new Array,this._origins=new Array,this._maskParameters=new n}initialize(){this.updateGeometries()}destroy(){this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0}precompile(){this.techniques.precompile(a)}render(e){const s=this.techniques.get(a),t=this.bindParameters,i=t.camera,n=i.fullViewport[2],c=i.fullViewport[3];if(!s.compiled||!this._vaos)return void this.requestRender();const h=e.find(({name:e})=>e===r.TRANSPARENT),m=this.renderingContext,d=this.fboCache.acquire(n,c,o.FOCUSAREA,2);this.view.stage.renderer.occludedRequiresStencil?(d.acquireDepth(12),m.blitFramebuffer(h.fbo,d.fbo,256)):d.attachDepth(h.getAttachment(p)),m.bindFramebuffer(d.fbo),m.setClearColor(0,0,0,1),m.clear(17408),m.setViewport(0,0,n,c);const f=m.bindTechnique(s,t);m.setFaceCullingEnabled(!1),m.setStencilTestEnabled(!0),m.setStencilOpSeparate(1028,7680,34055,7680),m.setStencilOpSeparate(1029,7680,34056,7680),m.setDepthWriteEnabled(!1);for(let r=0;r<this._vaos.length;r++){const e=this._vaos[r],s=this._counts[r];this._maskParameters.origin=this._origins[r],f.bindDraw(t,u,this._maskParameters),m.bindVAO(e),m.setDepthTestEnabled(!0),m.setStencilWriteMask(255),m.setStencilFunction(519,0,255),m.setColorMask(!1,!1,!1,!1),m.drawArrays(l.TRIANGLES,0,s),m.setDepthTestEnabled(!1),m.setStencilWriteMask(0),m.setStencilFunction(517,0,255),m.setColorMask(!0,!0,!0,!0),m.drawArrays(l.TRIANGLES,0,s)}return d}updateGeometries(){if(!this.view.stage)return;this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0;this.focusAreasView.volumes.forEach(e=>{const s=new Array;let t=0,r=0;e.geometryVolumes.forEach(e=>{const o=e.indicesBottom;t+=o.length;for(let t=0;t<o.length;t++)s.push(e.positions[3*(o[t]-1)]),s.push(e.positions[3*(o[t]-1)+1]),s.push(e.positions[3*(o[t]-1)+2]);const i=e.indicesExtruded;r+=i.length;for(let t=0;t<i.length;t++)s.push(e.positions[3*i[t]]),s.push(e.positions[3*i[t]+1]),s.push(e.positions[3*i[t]+2])});const o=new h(this.renderingContext,new m(this.renderingContext,c,new Float32Array(s)));this._vaos.push(o),this._counts.push(t+r),this._origins.push(e.origin)}),this.requestRender()}};e([s()],d.prototype,"consumes",void 0),e([s()],d.prototype,"produces",void 0),e([s({constructOnly:!0})],d.prototype,"focusAreasView",void 0),d=e([t("esri.views.3d.webgl-engine.effects.focusArea.FocusAreaMaskNode")],d);export{d as FocusAreaMaskNode};
5
+ import{__decorate as e}from"tslib";import{property as s}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as t}from"../../../../../core/accessorSupport/decorators/subclass.js";import{RenderCategory as r,InternalRenderCategory as o}from"../../../webgl.js";import i from"../../../webgl/RenderNode.js";import{F as n}from"../../../../../chunks/FocusAreaMask.glsl.js";import{FocusAreaMaskTechnique as a}from"./FocusAreaMaskTechnique.js";import{Pos3 as c}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as h}from"../../lib/VertexArrayObject.js";import{DepthStencilAttachment as p,PrimitiveType as l}from"../../../../webgl/enums.js";import{noParameters as u}from"../../../../webgl/NoParameters.js";import{VertexBuffer as m}from"../../../../webgl/VertexBuffer.js";let d=class extends i{constructor(e){super({...e,view:e.focusAreasView.view}),this.consumes={required:[r.TRANSPARENT]},this.produces=o.FOCUSAREA,this._vaos=new Array,this._counts=new Array,this._origins=new Array,this._maskParameters=new n}initialize(){this.updateGeometries()}destroy(){this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0}precompile(){this.techniques.precompile(a)}render(e){const s=this.techniques.get(a),t=this.bindParameters,i=t.camera,n=i.fullViewport[2],c=i.fullViewport[3];if(!s.compiled||!this._vaos)return void this.requestRender(1);const h=e.find(({name:e})=>e===r.TRANSPARENT),m=this.renderingContext,d=this.fboCache.acquire(n,c,o.FOCUSAREA,2);this.view.stage.renderer.occludedRequiresStencil?(d.acquireDepth(12),m.blitFramebuffer(h.fbo,d.fbo,256)):d.attachDepth(h.getAttachment(p)),m.bindFramebuffer(d.fbo),m.setClearColor(0,0,0,1),m.clear(17408),m.setViewport(0,0,n,c);const f=m.bindTechnique(s,t);m.setFaceCullingEnabled(!1),m.setStencilTestEnabled(!0),m.setStencilOpSeparate(1028,7680,34055,7680),m.setStencilOpSeparate(1029,7680,34056,7680),m.setDepthWriteEnabled(!1);for(let r=0;r<this._vaos.length;r++){const e=this._vaos[r],s=this._counts[r];this._maskParameters.origin=this._origins[r],f.bindDraw(t,u,this._maskParameters),m.bindVAO(e),m.setDepthTestEnabled(!0),m.setStencilWriteMask(255),m.setStencilFunction(519,0,255),m.setColorMask(!1,!1,!1,!1),m.drawArrays(l.TRIANGLES,0,s),m.setDepthTestEnabled(!1),m.setStencilWriteMask(0),m.setStencilFunction(517,0,255),m.setColorMask(!0,!0,!0,!0),m.drawArrays(l.TRIANGLES,0,s)}return d}updateGeometries(){if(!this.view.stage)return;this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0;this.focusAreasView.volumes.forEach(e=>{const s=new Array;let t=0,r=0;e.geometryVolumes.forEach(e=>{const o=e.indicesBottom;t+=o.length;for(let t=0;t<o.length;t++)s.push(e.positions[3*(o[t]-1)]),s.push(e.positions[3*(o[t]-1)+1]),s.push(e.positions[3*(o[t]-1)+2]);const i=e.indicesExtruded;r+=i.length;for(let t=0;t<i.length;t++)s.push(e.positions[3*i[t]]),s.push(e.positions[3*i[t]+1]),s.push(e.positions[3*i[t]+2])});const o=new h(this.renderingContext,new m(this.renderingContext,c,new Float32Array(s)));this._vaos.push(o),this._counts.push(t+r),this._origins.push(e.origin)}),this.requestRender(1)}};e([s()],d.prototype,"consumes",void 0),e([s()],d.prototype,"produces",void 0),e([s({constructOnly:!0})],d.prototype,"focusAreasView",void 0),d=e([t("esri.views.3d.webgl-engine.effects.focusArea.FocusAreaMaskNode")],d);export{d as FocusAreaMaskNode};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{disposeMaybe as r}from"../../../../../core/maybe.js";import{throwIfAborted as t}from"../../../../../core/promiseUtils.js";import{watch as s,syncAndInitial as i}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as n}from"../../../../../support/requestImageUtils.js";import{RenderCategory as c,InternalRenderCategory as h}from"../../../webgl.js";import u from"../../../webgl/RenderNode.js";import{SMAABlendWeightsTechnique as l}from"./SMAABlendWeightsTechnique.js";import{SMAABlurTechnique as m}from"./SMAABlurTechnique.js";import{SMAAEdgeDetectTechnique as d}from"./SMAAEdgeDetectTechnique.js";import{SMAAPassParameters as p}from"./SMAAPassParameters.js";import{Texture as f}from"../../../../webgl/Texture.js";import{TextureDescriptor as b}from"../../../../webgl/TextureDescriptor.js";let T=class extends u{constructor(e){super(e),this.produces="disabled",this.consumes={required:[h.ANTIALIASING],optional:[c.COMPOSITE]},this._areaTexture=null,this._searchTexture=null,this._smaaParameters=new p}initialize(){this.addHandles([s(()=>this.isEnabled(),e=>e?this.enable():this.disable(),i)])}async enable(){if(this.produces=h.ANTIALIASING,this.destroyed||this._abortController||this._areaTexture&&this._searchTexture)return;this._abortController=new AbortController;const e=this._abortController.signal;try{const r=await import("./SMAAData.js");if(this.destroyed)return;if(await this._loadTextures(r,e),this.destroyed)return;this.requestRender(1)}catch(r){console.error("SMAA err:",r)}this.destroyed||(this._abortController=null)}async _loadTextures(e,r){t(r);const[s,i]=await Promise.allSettled([n(e.areaTexture,{signal:r}),n(e.searchTexure,{signal:r})]);if(t(r),"fulfilled"!==s.status||"fulfilled"!==i.status)return;const o=this.renderingContext;this._areaTexture=x(o,9729,6407,s.value),this._searchTexture=x(o,9728,6409,i.value)}disable(){this.produces="disabled"}destroy(){this._searchTexture=r(this._searchTexture),this._areaTexture=r(this._areaTexture)}precompile(){this.techniques.precompile(d),this.techniques.precompile(l),this.techniques.precompile(m)}render(e){const r=e.find(({name:e})=>e===h.ANTIALIASING);if(!this._areaTexture||!this._searchTexture)return this.requestRender(1),r;const t=this.techniques.get(d),s=this.techniques.get(l),i=this.techniques.get(m);if(!t.compiled||!s.compiled||!i.compiled)return this.requestRender(1),r;const o=e.find(({name:e})=>e===c.COMPOSITE);if(!o)return r;const a=o.fbo.width,n=o.fbo.height,u=this.renderingContext;u.setViewport(0,0,a,n);const p=this.fboCache.acquire(a,n,"smaa edges",2);u.bindFramebuffer(p.fbo),u.setClearColor(0,0,0,1),u.clear(16384),this._smaaParameters.color=o.getTexture();const f=this.bindParameters;u.bindTechnique(t,f,this._smaaParameters),u.screen.draw();const b=this.fboCache.acquire(a,n,"smaa blend");return u.bindFramebuffer(b.fbo),u.setClearColor(0,0,1,1),u.clear(16384),this._smaaParameters.inputTexture=p.getTexture(),this._smaaParameters.areaTexture=this._areaTexture,this._smaaParameters.searchTexture=this._searchTexture,u.bindTechnique(s,f,this._smaaParameters),u.screen.draw(),p.release(),u.bindFramebuffer(r.fbo),u.setClearColor(0,1,0,1),u.clear(16384),this._smaaParameters.inputTexture=b.getTexture(),u.bindTechnique(i,f,this._smaaParameters),u.screen.draw(),b.release(),r}};function x(e,r,t,s){const i=new b(s.width,s.height);return i.pixelFormat=t,i.wrapMode=33071,i.samplingMode=r,new f(e,i,s)}e([o()],T.prototype,"produces",void 0),e([o()],T.prototype,"consumes",void 0),e([o({constructOnly:!0})],T.prototype,"isEnabled",void 0),e([o()],T.prototype,"_abortController",void 0),T=e([a("esri.views.3d.webgl-engine.effects.smaa.SMAA")],T);export{T as SMAA};
5
+ import{__decorate as e}from"tslib";import r from"../../../../../core/Logger.js";import{disposeMaybe as t}from"../../../../../core/maybe.js";import{throwIfAborted as s}from"../../../../../core/promiseUtils.js";import{watch as i,syncAndInitial as o}from"../../../../../core/reactiveUtils.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import{subclass as n}from"../../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as h}from"../../../../../support/requestImageUtils.js";import{RenderCategory as u,InternalRenderCategory as c}from"../../../webgl.js";import l from"../../../webgl/RenderNode.js";import{SMAABlendWeightsTechnique as m}from"./SMAABlendWeightsTechnique.js";import{SMAABlurTechnique as d}from"./SMAABlurTechnique.js";import{SMAAEdgeDetectTechnique as p}from"./SMAAEdgeDetectTechnique.js";import{SMAAPassParameters as f}from"./SMAAPassParameters.js";import{Texture as b}from"../../../../webgl/Texture.js";import{TextureDescriptor as T}from"../../../../webgl/TextureDescriptor.js";let x=class extends l{constructor(e){super(e),this.produces="disabled",this.consumes={required:[c.ANTIALIASING],optional:[u.COMPOSITE]},this._areaTexture=null,this._searchTexture=null,this._smaaParameters=new f}initialize(){this.addHandles([i(()=>this.isEnabled(),e=>e?this.enable():this.disable(),o)])}async enable(){if(this.destroyed)return;if(this.produces=c.ANTIALIASING,this.requestRender(1),this._abortController||this._areaTexture&&this._searchTexture)return;this._abortController=new AbortController;const e=this._abortController.signal;try{const r=await import("./SMAAData.js");if(this.destroyed)return;if(await this._loadTextures(r,e),this.destroyed)return;this.requestRender(1)}catch(t){r.getLogger(this).errorOnce(t)}this.destroyed||(this._abortController=null)}async _loadTextures(e,r){s(r);const[t,i]=await Promise.allSettled([h(e.areaTexture,{signal:r}),h(e.searchTexure,{signal:r})]);if(s(r),"fulfilled"!==t.status||"fulfilled"!==i.status)return;const o=this.renderingContext;this._areaTexture=g(o,9729,6407,t.value),this._searchTexture=g(o,9728,6409,i.value)}disable(){this.produces="disabled",this.requestRender(1)}destroy(){this._searchTexture=t(this._searchTexture),this._areaTexture=t(this._areaTexture)}precompile(){this.techniques.precompile(p),this.techniques.precompile(m),this.techniques.precompile(d)}render(e){const r=e.find(({name:e})=>e===c.ANTIALIASING),t=e.find(({name:e})=>e===u.COMPOSITE);if(!t)return r;if(!this._areaTexture||!this._searchTexture)return this.view.stage.renderer.blitFBO(t,r,!1),this.requestRender(1),r;const s=this.techniques.get(p),i=this.techniques.get(m),o=this.techniques.get(d);if(!s.compiled||!i.compiled||!o.compiled)return this.view.stage.renderer.blitFBO(t,r,!1),this.requestRender(1),r;const a=t.fbo.width,n=t.fbo.height,h=this.renderingContext;h.setViewport(0,0,a,n);const l=this.fboCache.acquire(a,n,"smaa edges",2);h.bindFramebuffer(l.fbo),h.setClearColor(0,0,0,1),h.clear(16384),this._smaaParameters.color=t.getTexture();const f=this.bindParameters;h.bindTechnique(s,f,this._smaaParameters),h.screen.draw();const b=this.fboCache.acquire(a,n,"smaa blend");return h.bindFramebuffer(b.fbo),h.setClearColor(0,0,1,1),h.clear(16384),this._smaaParameters.inputTexture=l.getTexture(),this._smaaParameters.areaTexture=this._areaTexture,this._smaaParameters.searchTexture=this._searchTexture,h.bindTechnique(i,f,this._smaaParameters),h.screen.draw(),l.release(),h.bindFramebuffer(r.fbo),h.setClearColor(0,1,0,1),h.clear(16384),this._smaaParameters.inputTexture=b.getTexture(),h.bindTechnique(o,f,this._smaaParameters),h.screen.draw(),b.release(),r}};function g(e,r,t,s){const i=new T(s.width,s.height);return i.pixelFormat=t,i.wrapMode=33071,i.samplingMode=r,new b(e,i,s)}e([a()],x.prototype,"produces",void 0),e([a()],x.prototype,"consumes",void 0),e([a({constructOnly:!0})],x.prototype,"isEnabled",void 0),e([a()],x.prototype,"_abortController",void 0),x=e([n("esri.views.3d.webgl-engine.effects.smaa.SMAA")],x);export{x as SMAA};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import{watch as s}from"../../../../core/reactiveUtils.js";import"../../../../core/Logger.js";import"../../../../core/has.js";import"../../../../core/Error.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{set as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{g as o,J as n,c as h,d as l}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{elementsPerSplatPage as u,splatAtlasTextureSize as c}from"../../../../layers/support/GaussianSplatAtlasPageAllocator.js";import{evalTextureSize as m,maxAllowedVisibleGaussians as _}from"../../../../layers/support/gaussianSplatUtils.js";import{RenderCategory as d}from"../../webgl.js";import{makeScheduleFunction as f}from"../../layers/support/makeScheduleFunction.js";import{GaussianSplatSortWorkerHandle as g}from"../../support/GaussianSplatWorkerHandle.js";import b from"../../webgl/RenderNode.js";import{G as S}from"../../../../chunks/GaussianSplat.glsl.js";import{G as C}from"../../../../chunks/GaussianSplatComposition.glsl.js";import{GaussianSplatCompositionTechnique as T}from"../shaders/GaussianSplatCompositionTechnique.js";import{G as w}from"../../../../chunks/GaussianSplatDepthComposition.glsl.js";import{GaussianSplatDepthCompositionTechnique as P}from"../shaders/GaussianSplatDepthCompositionTechnique.js";import{GaussianSplatDepthTechnique as y}from"../shaders/GaussianSplatDepthTechnique.js";import{GaussianSplatTechnique as G}from"../shaders/GaussianSplatTechnique.js";import{GaussianSplatTechniqueConfiguration as q}from"../shaders/GaussianSplatTechniqueConfiguration.js";import{DepthStencilAttachment as x,PrimitiveType as v,PixelType as A,SizedPixelFormat as j}from"../../../webgl/enums.js";import{Texture as D}from"../../../webgl/Texture.js";import{TextureDescriptor as I}from"../../../webgl/TextureDescriptor.js";var k;let F=class extends b{static{k=this}static{this.tileSize=2.048}constructor(t){super(t),this.produces=d.OPAQUE,this._gaussianSplatParameters=new S,this._gaussianSplatCompositionParameters=new C,this._gaussianSplatDepthCompositionParameters=new w,this._splatDepthTechniqueConfiguration=new q(!0),this._totalVisibleGaussians=0,this._orderTexture=null,this._textureAtlas=null,this._visibleGaussianTiles=new Array,this._workerHandle=null,this._isSorting=!1,this._pendingSortTask=!1,this._bufferCapacity=0,this._previousCameraPosition=p(),this._previousCameraDirection=p(),this._tanFov=r(),this._tempVec=p(),this._cameraDelta=p(),this._coarseCameraPosition=p()}async initialize(){this._initializeTextures(),this.addHandles([s(()=>this.view.state.camera,()=>this._onCameraChange())]);const{resourceController:t}=this.view;this._workerHandle=new g(f(t))}precompile(){this.techniques.precompile(G),this.techniques.precompile(y,this._splatDepthTechniqueConfiguration),this.techniques.precompile(T),this.techniques.precompile(P)}render(t){const e=t.find(({name:t})=>t===d.OPAQUE),s=this.techniques.get(G),i=this.techniques.get(y,this._splatDepthTechniqueConfiguration),r=this.techniques.get(T),o=this.techniques.get(P);if(!(s.compiled&&i.compiled&&o.compiled&&r.compiled))return this.requestRender(1),e;const{fullWidth:n,fullHeight:h}=this.bindParameters.camera,l=this.fboCache,p=l.acquire(n,h,"gaussianColorOutput");p.attachDepth(e.getAttachment(x));const u=this.renderingContext;u.bindFramebuffer(p.fbo),u.setClearColor(0,0,0,0),u.clear(16384),this._gaussianSplatParameters.totalGaussians=this._totalVisibleGaussians,this._gaussianSplatParameters.splatOrder=this._orderTexture,this._gaussianSplatParameters.splatAtlas=this._textureAtlas;const c=Math.tan(.5*this.camera.fovY),m=c/h*n;a(this._tanFov,m,c);const _=h/(2*c);this._gaussianSplatParameters.focalLength=_,this._gaussianSplatParameters.tanFov=this._tanFov,this.prepareHighPrecisionCameraPosition(),this.renderingContext.bindTechnique(s,this.bindParameters,this._gaussianSplatParameters),this.renderingContext.drawArraysInstanced(v.TRIANGLE_STRIP,0,4,this._totalVisibleGaussians);const f=l.acquire(n,h,"splat depth",8);f.attachDepth(e.getAttachment(x)),u.bindFramebuffer(f.fbo),u.setClearColor(0,0,0,0),u.clear(16384),this.renderingContext.bindTechnique(i,this.bindParameters,this._gaussianSplatParameters),this.renderingContext.drawArraysInstanced(v.TRIANGLE_STRIP,0,4,this._totalVisibleGaussians);const g=l.acquire(n,h,this.produces);return this._gaussianSplatDepthCompositionParameters.splatDepth=f.getTexture(),g.attachDepth(e.getAttachment(x)),u.bindFramebuffer(g.fbo),u.bindTechnique(o,this.bindParameters,this._gaussianSplatDepthCompositionParameters),u.screen.draw(),this._gaussianSplatCompositionParameters.color=e.getTexture(),this._gaussianSplatCompositionParameters.splatColor=p.getTexture(),u.bindFramebuffer(g.fbo),u.bindTechnique(r,this.bindParameters,this._gaussianSplatCompositionParameters),u.screen.draw(),p.release(),f.release(),g}updateGaussianVisibility(t){this._visibleGaussianTiles=t,this._requestSort()}destroy(){this._workerHandle?.destroyWorkerAndSelf(),super.destroy()}updateTextureAtlas(t,e,s){this._textureAtlas?.updateData(0,t,e,u,1,s)}_ensureBufferCapacity(t){if(this._bufferCapacity<t){const s=Math.ceil(t*e);this._atlasIndicesBuffer=new Uint32Array(s),this._sortedAtlasIndicesBuffer=new Uint32Array(s),this._bufferCapacity=s}}_initializeTextures(){const t=new I;t.height=c,t.width=c,t.pixelFormat=36249,t.dataType=A.UNSIGNED_INT,t.internalFormat=j.RGBA32UI,t.samplingMode=9728,t.wrapMode=33071,this._textureAtlas=new D(this.renderingContext,t);const e=m(_);this._orderBuffer=new Uint32Array(e[0]*e[1]);const s=new I;s.height=e[0],s.width=e[1],s.pixelFormat=36244,s.dataType=A.UNSIGNED_INT,s.internalFormat=j.R32UI,s.wrapMode=33071,s.samplingMode=9728,this._orderTexture=new D(this.renderingContext,s)}_onCameraChange(){const t=this.view.state.camera.eye,e=this.view.state.camera.ray.direction,s=.001;(Math.abs(t[0]-this._previousCameraPosition[0])>s||Math.abs(t[1]-this._previousCameraPosition[1])>s||Math.abs(t[2]-this._previousCameraPosition[2])>s||Math.abs(e[0]-this._previousCameraDirection[0])>s||Math.abs(e[1]-this._previousCameraDirection[1])>s||Math.abs(e[2]-this._previousCameraDirection[2])>s)&&this._requestSort()}prepareHighPrecisionCameraPosition(){o(this._tempVec,this.camera.eye,1/k.tileSize),n(this._tempVec,this._tempVec),h(this._coarseCameraPosition,this._tempVec),this._gaussianSplatParameters.cameraPos8k=this._coarseCameraPosition,o(this._tempVec,this._tempVec,k.tileSize),l(this._cameraDelta,this.camera.eye,this._tempVec),this._gaussianSplatParameters.cameraDelta=this._cameraDelta}_requestSort(){this._isSorting?this._pendingSortTask=!0:(this._isSorting=!0,this._pendingSortTask=!1,this._sortOnWorker().then(()=>{this._isSorting=!1,this._pendingSortTask&&this._requestSort()}).catch(()=>{this._isSorting=!1,this._pendingSortTask&&this._requestSort()}))}async _sortOnWorker(){let t=0;for(let _=0;_<this._visibleGaussianTiles.length;_++)t+=this._visibleGaussianTiles[_].gaussianAtlasIndices.length;if(0===t||t>_)return;this._ensureBufferCapacity(t);const e=this.camera.ray.direction,s=e[0],i=e[1],a=e[2],r=1/Math.sqrt(s*s+i*i+a*a),o=s*r,n=i*r,h=a*r,l=this._atlasIndicesBuffer.subarray(0,t),p=new Float64Array(t);let u=0;for(let _=0;_<this._visibleGaussianTiles.length;_++){const t=this._visibleGaussianTiles[_],e=t.gaussianAtlasIndices,s=t.positions;for(let i=0;i<e.length;i++){l[u]=e[i];const t=3*i,a=s[t],r=s[t+1],c=s[t+2];p[u]=a*o+r*n+c*h,u++}}const c=new Uint32Array(t);for(let _=0;_<t;_++)c[_]=_;const m={distances:p,sortOrderIndices:c};await(this._workerHandle?.sort(m).then(e=>{const s=this._sortedAtlasIndicesBuffer.subarray(0,t);for(let i=0;i<t;i++)s[i]=l[e.sortedOrderIndices[i]];this._orderBuffer.set(s),this._orderTexture?.setData(this._orderBuffer),this._totalVisibleGaussians=t,this.requestRender(1)}))}};F=k=t([i("esri.views.3d.webgl-engine.lib.GaussianSplatRenderNode")],F);export{F as GaussianSplatRenderNode};
5
+ import{__decorate as t}from"tslib";import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import{watch as s}from"../../../../core/reactiveUtils.js";import"../../../../core/Logger.js";import"../../../../core/has.js";import"../../../../core/Error.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{set as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as r,fromValues as o}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{g as n,J as h,c as l,d as p}from"../../../../chunks/vec32.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{elementsPerSplatPage as c,splatAtlasTextureSize as m}from"../../../../layers/support/GaussianSplatAtlasPageAllocator.js";import{maxAllowedVisibleGaussians as _}from"../../../../layers/support/gaussianSplatUtils.js";import{RenderCategory as d}from"../../webgl.js";import{makeScheduleFunction as f}from"../../layers/support/makeScheduleFunction.js";import{GaussianSplatSortWorkerHandle as g}from"../../support/GaussianSplatWorkerHandle.js";import b from"../../webgl/RenderNode.js";import{G as S}from"../../../../chunks/GaussianSplat.glsl.js";import{G as C}from"../../../../chunks/GaussianSplatComposition.glsl.js";import{GaussianSplatCompositionTechnique as T}from"../shaders/GaussianSplatCompositionTechnique.js";import{G as w}from"../../../../chunks/GaussianSplatDepthComposition.glsl.js";import{GaussianSplatDepthCompositionTechnique as P}from"../shaders/GaussianSplatDepthCompositionTechnique.js";import{GaussianSplatDepthTechnique as q}from"../shaders/GaussianSplatDepthTechnique.js";import{GaussianSplatTechnique as G}from"../shaders/GaussianSplatTechnique.js";import{GaussianSplatTechniqueConfiguration as y}from"../shaders/GaussianSplatTechniqueConfiguration.js";import{DepthStencilAttachment as v,PrimitiveType as x,PixelType as A,SizedPixelFormat as j}from"../../../webgl/enums.js";import{Texture as D}from"../../../webgl/Texture.js";import{TextureDescriptor as I}from"../../../webgl/TextureDescriptor.js";var k;let M=class extends b{static{k=this}static{this.tileSize=2.048}constructor(t){super(t),this.produces=d.OPAQUE,this._gaussianSplatParameters=new S,this._gaussianSplatCompositionParameters=new C,this._gaussianSplatDepthCompositionParameters=new w,this._splatDepthTechniqueConfiguration=new y(!0),this._totalVisibleGaussians=0,this._orderTexture=null,this._textureAtlas=null,this._visibleGaussianTiles=new Array,this._workerHandle=null,this._isSorting=!1,this._pendingSortTask=!1,this._bufferCapacity=0,this._previousCameraPosition=u(),this._previousCameraDirection=u(),this._tanFov=r(),this._tempVec=u(),this._cameraDelta=u(),this._coarseCameraPosition=u()}async initialize(){this._initializeTextures(),this.addHandles([s(()=>this.view.state.camera,()=>this._onCameraChange())]);const{resourceController:t}=this.view;this._workerHandle=new g(f(t))}precompile(){this.techniques.precompile(G),this.techniques.precompile(q,this._splatDepthTechniqueConfiguration),this.techniques.precompile(T),this.techniques.precompile(P)}render(t){const e=t.find(({name:t})=>t===d.OPAQUE),s=this.techniques.get(G),i=this.techniques.get(q,this._splatDepthTechniqueConfiguration),r=this.techniques.get(T),o=this.techniques.get(P);if(!(s.compiled&&i.compiled&&o.compiled&&r.compiled))return this.requestRender(1),e;const{fullWidth:n,fullHeight:h}=this.bindParameters.camera,l=this.fboCache,p=l.acquire(n,h,"gaussianColorOutput");p.attachDepth(e.getAttachment(v));const u=this.renderingContext;u.bindFramebuffer(p.fbo),u.setClearColor(0,0,0,0),u.clear(16384),this._gaussianSplatParameters.totalGaussians=this._totalVisibleGaussians,this._gaussianSplatParameters.splatOrder=this._orderTexture,this._gaussianSplatParameters.splatAtlas=this._textureAtlas;const c=Math.tan(.5*this.camera.fovY),m=c/h*n;a(this._tanFov,m,c);const _=h/(2*c);this._gaussianSplatParameters.focalLength=_,this._gaussianSplatParameters.tanFov=this._tanFov,this._prepareHighPrecisionCameraPosition(),this.renderingContext.bindTechnique(s,this.bindParameters,this._gaussianSplatParameters),this.renderingContext.drawArraysInstanced(x.TRIANGLE_STRIP,0,4,this._totalVisibleGaussians);const f=l.acquire(n,h,"splat depth",8);f.attachDepth(e.getAttachment(v)),u.bindFramebuffer(f.fbo),u.setClearColor(0,0,0,0),u.clear(16384),this.renderingContext.bindTechnique(i,this.bindParameters,this._gaussianSplatParameters),this.renderingContext.drawArraysInstanced(x.TRIANGLE_STRIP,0,4,this._totalVisibleGaussians);const g=l.acquire(n,h,this.produces);return this._gaussianSplatDepthCompositionParameters.splatDepth=f.getTexture(),g.attachDepth(e.getAttachment(v)),u.bindFramebuffer(g.fbo),u.bindTechnique(o,this.bindParameters,this._gaussianSplatDepthCompositionParameters),u.screen.draw(),this._gaussianSplatCompositionParameters.color=e.getTexture(),this._gaussianSplatCompositionParameters.splatColor=p.getTexture(),u.bindFramebuffer(g.fbo),u.bindTechnique(r,this.bindParameters,this._gaussianSplatCompositionParameters),u.screen.draw(),p.release(),f.release(),g}updateGaussianVisibility(t){this._visibleGaussianTiles=t,this._requestSort()}destroy(){this._workerHandle?.destroyWorkerAndSelf(),super.destroy()}updateTextureAtlas(t,e,s){this._textureAtlas?.updateData(0,t,e,c,1,s)}_ensureBufferCapacity(t){if(this._bufferCapacity<t){const s=Math.ceil(t*e);this._atlasIndicesBuffer=new Uint32Array(s),this._sortedAtlasIndicesBuffer=new Uint32Array(s),this._bufferCapacity=s}}_initializeTextures(){const t=new I;t.height=m,t.width=m,t.pixelFormat=36249,t.dataType=A.UNSIGNED_INT,t.internalFormat=j.RGBA32UI,t.samplingMode=9728,t.wrapMode=33071,this._textureAtlas=new D(this.renderingContext,t);const e=V(_);this._orderBuffer=new Uint32Array(e[0]*e[1]);const s=new I;s.height=e[0],s.width=e[1],s.pixelFormat=36244,s.dataType=A.UNSIGNED_INT,s.internalFormat=j.R32UI,s.wrapMode=33071,s.samplingMode=9728,this._orderTexture=new D(this.renderingContext,s)}_onCameraChange(){const t=this.view.state.camera.eye,e=this.view.state.camera.ray.direction,s=.001;(Math.abs(t[0]-this._previousCameraPosition[0])>s||Math.abs(t[1]-this._previousCameraPosition[1])>s||Math.abs(t[2]-this._previousCameraPosition[2])>s||Math.abs(e[0]-this._previousCameraDirection[0])>s||Math.abs(e[1]-this._previousCameraDirection[1])>s||Math.abs(e[2]-this._previousCameraDirection[2])>s)&&this._requestSort()}_prepareHighPrecisionCameraPosition(){n(this._tempVec,this.camera.eye,1/k.tileSize),h(this._tempVec,this._tempVec),l(this._coarseCameraPosition,this._tempVec),this._gaussianSplatParameters.cameraPos8k=this._coarseCameraPosition,n(this._tempVec,this._tempVec,k.tileSize),p(this._cameraDelta,this.camera.eye,this._tempVec),this._gaussianSplatParameters.cameraDelta=this._cameraDelta}_requestSort(){this._isSorting?this._pendingSortTask=!0:(this._isSorting=!0,this._pendingSortTask=!1,this._sortOnWorker().then(()=>{this._isSorting=!1,this._pendingSortTask&&this._requestSort()}).catch(()=>{this._isSorting=!1,this._pendingSortTask&&this._requestSort()}))}async _sortOnWorker(){let t=0;for(let _=0;_<this._visibleGaussianTiles.length;_++)t+=this._visibleGaussianTiles[_].gaussianAtlasIndices.length;if(0===t||t>_)return this._totalVisibleGaussians=0,void this.requestRender(1);this._ensureBufferCapacity(t);const e=this.camera.ray.direction,s=e[0],i=e[1],a=e[2],r=1/Math.sqrt(s*s+i*i+a*a),o=s*r,n=i*r,h=a*r,l=this._atlasIndicesBuffer.subarray(0,t),p=new Float64Array(t);let u=0;for(let _=0;_<this._visibleGaussianTiles.length;_++){const t=this._visibleGaussianTiles[_],e=t.gaussianAtlasIndices,s=t.positions;for(let i=0;i<e.length;i++){l[u]=e[i];const t=3*i,a=s[t],r=s[t+1],c=s[t+2];p[u]=a*o+r*n+c*h,u++}}const c=new Uint32Array(t);for(let _=0;_<t;_++)c[_]=_;const m={distances:p,sortOrderIndices:c};await(this._workerHandle?.sort(m).then(e=>{const s=this._sortedAtlasIndicesBuffer.subarray(0,t);for(let i=0;i<t;i++)s[i]=l[e.sortedOrderIndices[i]];this._orderBuffer.set(s),this._orderTexture?.setData(this._orderBuffer),this._totalVisibleGaussians=t,this.requestRender(1)}))}};function V(t){const e=Math.ceil(Math.sqrt(t)),s=Math.ceil(t/e);return o(e,s)}M=k=t([i("esri.views.3d.webgl-engine.lib.GaussianSplatRenderNode")],M);export{M as GaussianSplatRenderNode};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{unitRGBAFromColor as i}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{clamp as s,lerp as a}from"../../../../core/mathUtils.js";import{removeMaybe as n,abortMaybe as h,destroyMaybe as o,releaseMaybe as d}from"../../../../core/maybe.js";import{throwIfAborted as l}from"../../../../core/promiseUtils.js";import{watch as _,syncAndInitial as u,initial as p,sync as m}from"../../../../core/reactiveUtils.js";import{signal as c}from"../../../../core/signal.js";import{Milliseconds as f}from"../../../../core/time.js";import{property as g}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import{subclass as b}from"../../../../core/accessorSupport/decorators/subclass.js";import{equals as P,invert as w,multiply as C}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as T,create as S}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as E}from"../../../../chunks/vec42.js";import{ZEROS as x}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{fromValues as A,ZEROS as y}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as D}from"../../../../geometry/support/Indices.js";import{RenderCategory as I,InternalRenderCategory as R}from"../../webgl.js";import{innerAtmosphereFadeStart as O}from"../../environment/atmosphereUtils.js";import{minNearDistanceInMeters as v}from"../../state/NearFarHeuristic.js";import{debugFlags as F}from"../../support/debugFlags.js";import{FBOCache as H,defaultWebGLFBO as M}from"../core/FBOCache.js";import{RenderPassManager as N}from"../core/renderPasses/RenderPassManager.js";import{isColorOrColorEmission as q}from"../core/shaderLibrary/ShaderOutput.js";import{distanceFadeEnd as G}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as L}from"../effects/RenderNodes.js";import{RenderPluginManager as V}from"../effects/RenderPluginManager.js";import{Blit as U}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as j,renderHighlightBuffer as B}from"../effects/highlight/Highlight.js";import{OITBlend as k}from"../effects/transparency/OITBlend.js";import{AnimationTimer as z}from"./AnimationTimer.js";import{AnimationTimeStep as Q}from"./AnimationTimeStep.js";import{BoundingInfo as W}from"./BoundingInfo.js";import{DepthRange as Y}from"./DepthRange.js";import{depthRangeFromScene as J}from"./depthRangeUtils.js";import{hudFragmentOpacityParameters as K}from"./hudFragmentOpacityParameters.js";import{MainFramebuffer as X}from"./MainFramebuffer.js";import{RenderContext as Z,defaultRenderOccludedMask as $}from"./RenderContext.js";import{RendererBase as ee}from"./RendererBase.js";import{setupFeatureDefaults as te}from"./RenderFeature.js";import{RenderPluginInput as re}from"./RenderPluginInput.js";import{ShadowAccumulator as ie}from"./ShadowAccumulator.js";import{ShadowMap as se}from"./ShadowMap.js";import ae from"./SliceHelper.js";import{MergedRenderer as ne}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as he}from"../parts/renderUtils.js";import{RendererPerformanceInfo as oe,PerformanceCategory as de}from"../statistics/RendererPerformanceInfo.js";import{PixelType as le,ColorAttachment1 as _e,ColorAttachment2 as ue}from"../../../webgl/enums.js";let pe=class extends ee{constructor(e,t,r,s,a,n){super({stage:e}),this._techniques=r,this._rctx=s,this._compositingHelper=a,this._requestRender=n,this._pluginsHas={hudElements:!1,water:!1},this.renderPassManager=new N,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=A(0,0,0,1),this._sliceHelper=new ae,this._blit=null,this._oitblend=null,this.sceneDepthRange=c(Y.infinite),this._state=c(2),this._highQualityTransparencyEnabled=!0,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new Q,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=c(0),this._lastFrameTime=f(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new re,this._releaseNormals=e=>{e.some(({name:e})=>"normals"===e)&&this._pluginInput.release("normals")},this._debugNeedsDepth=!1,this._fboCache=new H(s),this._renderStateFeatures=c(te(!has("disable-feature:high-quality-idle"),e.view.qualityProfile)),this._framebuffer=new X(this.fboCache),this._performanceInfo=new oe(this._rctx),this._shadowMap=new se(this.fboCache,e.viewingMode),this._shadowAccumulator=new ie(this.fboCache,r,e,e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t},(t,r,i)=>{const s=e.view.qualitySettings.maximumPixelRatio;t.shadowMap.start(t.camera,r,i,!0,s),this._renderShadowCascades(4,t.shadowMap),t.shadowMap.finish(),t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.contentCamera)},n),this._renderContext=new Z(this._rctx,this._shadowMap,r),this._nodes=new L(this._renderContext),this._plugins=new V({renderContext:this._renderContext,techniques:r,materials:t,requestRender:n,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this.addHandles([_(()=>e.view.state.camera,()=>n(),u),_(()=>F.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES,e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(0):()=>{},n()},p),_(()=>e.view.environment.background?.color,e=>{const t=e?i(e):y;E(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()},u),_(()=>e.view.state.camera.relativeElevation,e=>this._inGlobeView=(e??1/0)>=G,u),_(()=>this._bindParameters.clouds.fadeFactor,()=>this._bindParameters.fadeLighting(),m),_(()=>this._bindParameters.clouds.data?.state,()=>n(),m),_(()=>e.view.state.highlights,e=>{this._bindParameters.highlights=e,n()},p)])}destroy(){this._gpuTimerHandle=n(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.destroy(),this._shadowAccumulator=null,this._loadEdgeViewTask=h(this._loadEdgeViewTask),this._edgeView=o(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this._fboCache.destroy(),this._fboCache=null,this._plugins.destroy(),this._plugins=null,this._pluginInput=null,this._blit=null,this._oitblend=null,this._compositingHelper=null,this._nodes=null,this._framebuffer=null,this._shadowMap=null,this._renderContext=null,this._performanceInfo=null,W.prune(),ne.prune(),D()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _framebufferSize(){return this._framebuffer.size}get performanceInfo(){return this._performanceInfo}updateRenderFeatures(e=null,t=!has("disable-feature:high-quality-idle")){this._renderStateFeatures.value=te(t,e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate(i=>i.set(t,e,r)),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(1)}get hasReflections(){return this._pluginsHas.water&&(this._ssrEnabled||this.isFeatureEnabled(5))}get _hasHighlights(){return this._plugins.produces(9,2,4,18,13,14)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(9,13,14)}get hasSSAO(){return(this.stage.view.qualitySettings.ambientOcclusion||this.isFeatureEnabled(4))&&!this._inGlobeView}get hasSMAA(){return this.stage.view.qualitySettings.antialiasingEnabled||this.isFeatureEnabled(0)}get fullResolutionAtmosphere(){return this.stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(3)}get fboCache(){return this._fboCache}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=d(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.depth=d(this._bindParameters.depth),this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility)}get updating(){return this._loadEdgeViewTask&&!this._loadEdgeViewTask.finished||this._edgeView?.updating||this._shadowAccumulator.readyToRun||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=r(async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");l(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this.stage.view.renderSpatialReference,viewingMode:this.stage.view.stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:Ee(this.stage.view.resourceController)});return this.addHandles(_(()=>r.updating,()=>this._requestRender(),m)),this._requestRender(),this._edgeViewCallbacks.forEach(e=>e(r)),this._edgeViewCallbacks.length=0,r})),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&P(this._bindParameters.ssr.reprojectionMatrix,T)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:r}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&t.maxCascades!==e.shadowMapMaxCascades&&(t.maxCascades=e.shadowMapMaxCascades,this._requestRender()),e.environment){void 0!==e.environment.weather&&(this._bindParameters.weather=e.environment.weather);const t="virtual"!==e.environment.lighting.type;r.enableFillLights!==t&&(r.enableFillLights=t,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}set slice(e){this._sliceHelper.update(e)&&this._requestRender()}get plugins(){return this._plugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}commit(e,t){return this._isRendering&&console.warn("Renderer.modify called while rendering"),!!super.commit(e,t,this._plugins.context)&&(this.updateHasFlags(),!0)}rendererAdded(e){this._plugins.add(e)}rendererRemoved(e){this._plugins.remove(e)}get occludedRequiresStencil(){return this.occludedRequiresOccludeeStencil||this.occludedRequiresIntegratedMeshStencil}get occludedRequiresOccludeeStencil(){return this._bindParameters.hasOccludees&&!!(8&this.plugins.renderOccludedFlags)}get occludedRequiresIntegratedMeshStencil(){return this._plugins.produces(0,0)&&this._plugins.produces(0,9)}updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(0,...Pe),has.water=this._plugins.produces(3,19),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new z(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const r=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?n(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,r,i=!1){try{return this._isRendering=!0,this._render(e,t,r,i)}catch(s){console.error(`Exception during rendering: ${s}`)}finally{this._isRendering=!1}return new he(this._pluginInput.get(I.FINAL),null)}_updateHUDOccludedFragmentOpacity(e,t){const{idleOpacity:r,navigatingOpacity:i,maxDelta:n,tiltFadeStart:h,tiltFadeEnd:o,altitudeStart:d,altitudeEnd:l}=K,_=this.stage.view,u=_.stateManager.camera,p=_.qualitySettings.fadeDuration,m=2===e?r:i,c=s((u.tilt-h)/(o-h),0,1),f=s(((u.position.z??0)-d)/(l-d),0,1),g=a(a(1,m,c),1,f),b=this._bindParameters.hudOccludedFragmentOpacity;if(p<=0||b===g||0===this._lastFrameTime||this._lastFrameTime>t)return this._bindParameters.hudOccludedFragmentOpacity=g,void(this._lastFrameTime=t);const P=t-this._lastFrameTime;this._lastFrameTime=t;const w=Math.max(1-r,Math.abs(r-i)),C=Math.min(w*P/p,n);C>=Math.abs(g-b)?this._bindParameters.hudOccludedFragmentOpacity=g:(this._bindParameters.hudOccludedFragmentOpacity=b+Math.sign(g-b)*C,this._requestRender())}_render(e,t,r,i){const s=0===r;this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=s,this._disposeBindBuffers();const{camera:a,contentCamera:n,mode:h,alignPixelEnabled:o}=e;this._state.value=h;const d=this._nodes.produces("magnifier-color"),l=this._nodes.produces(I.FINAL),_=this._plugins.hasEmitters,u=_?1:0;this._renderContext.time=t,this._renderContext.output=u,this._bindParameters.oitPass=0,this._bindParameters.alignPixelEnabled=o,this._bindParameters.decorations=!i,this._bindParameters.mainDepth=null;const p=!i||!this._sliceHelper.isDecoration;this._bindParameters.slicePlane=p?this._sliceHelper.plane:null,this._bindParameters.viewshedEnabled=this._nodes.produces(R.VIEWSHED),this._bindParameters.cutFillEnabled=this._nodes.produces(R.CUTFILL_DEPTH),this._renderOverlay(),a.setGLViewport(this._rctx);const m=this._framebuffer,c=m.initialize(a.fullWidth,a.fullHeight,this._backgroundColor,_);this.hasReflections?(c?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=c):c?.release(),this._ensureBindParametersCamera(a,n),this._updateHUDOccludedFragmentOpacity(h,t),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!i;const f=this._highQualityTransparency&&this._hasTransparentTerrain,g=this._plugins.produces(0,...ge);this._precompilePrepasses(),this.performanceInfo.advance(de.PREPARE);const b=this._computeShadowDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,b),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(b,a,n,!s),this._ensureBindParametersSSR(t),this._precompileShaders(f,g,u),this._renderContext.output=u,m.bind(),this._bindParameters.mainDepth=m.depth.attachment,this._renderOpaque(f),this._renderTransparent(g,f,u),this._shadowMap.disposeMainBuffer(),this._pluginInput.set(R.FOCUSAREA,this._renderFocusAreaGeometry()),this._pluginInput.set(R.CUTFILL_DEPTH,this._renderCutFillDepth()),m.update(e=>this._renderNodes(R.TRANSPARENT_ENVIRONMENT,e)),m.update(e=>this._renderNodes(R.VIEWSHED,e)),m.update(e=>this._renderNodes(R.LASERLINES,e)),m.update(e=>this._renderNodes(R.FOCUSAREA_COLOR,e)),this._pluginInput.release(R.FOCUSAREA),this._pluginInput.release(R.CUTFILL_DEPTH),m.update(e=>this._renderNodes(R.OCCLUDED,e)),this._pluginInput.set("highlights",this._renderHighlightPrepass()),this._renderHighlightShadowMap(a,this._bindParameters.lighting.mainLight.direction,b);const P=2===r?this._renderObjectAndLayerIdColor():null;m.update(e=>this._renderNodes(I.COMPOSITE,e)),this._shadowMap.disposeOffscreenBuffers();const w=s&&!l&&!(d&&!i),C=this._pluginInput.get(I.COMPOSITE),T=w?M:this.fboCache.acquire(C.fbo.width,C.fbo.height,R.ANTIALIASING),S=this._nodes.produces(R.ANTIALIASING)?this._renderNodes(R.ANTIALIASING,T):this._blitFBO(C,T,!1);let E;this._pluginInput.set(R.ANTIALIASING,S),this._hasHUDHighlights?(this._renderHUD(1,S,u),E=this._renderNodes(R.HIGHLIGHTS,S)):(E=this._renderNodes(R.HIGHLIGHTS,S),this._renderHUD(1,E,u));const x=this._renderNodes(R.MAGNIFIER,E);return s&&d&&!i&&!l&&this._blitFBO(x),l?(x.attachDepth(m.depth),this._blitFBO(this._renderNodes(I.FINAL,x)),x.detachDepth()):this._pluginInput.set(I.FINAL,x),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),m.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),s||(this._releaseFBOs(),this._disposeOffscreenBuffers()),new he(this._pluginInput.get(I.FINAL),P)}_precompileShaders(e,t,r){++this._plugins.context.techniques.precompiling,this._renderContext.output=r,this._precompileOpaqueGeometry(),this._nodes.precompile(R.OPAQUE_ENVIRONMENT),this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,this._renderContext.output=2,this._plugins.precompile(6),this._plugins.precompile(7),e&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._renderContext.output=r,this._plugins.precompile(6),this._plugins.precompile(7),t&&(this._precompileTransparentGeometry(),this._hasTransparentTerrain&&(this._bindParameters.cullAboveTerrain=!1,this._precompileTransparentGeometry(),this._bindParameters.cullAboveTerrain=e)),this._nodes.precompile(R.FOCUSAREA),this._needsHUDVisibility&&this._plugins.precompile(12),this._plugins.precompile(15),this._precompileHUD(0),this._bindParameters.terrainDepthTest=!1,this._bindParameters.cullAboveTerrain=!1,this._nodes.precompile(R.VIEWSHED,R.CUTFILL_DEPTH,R.LASERLINES,R.FOCUSAREA_COLOR,R.OCCLUDED,R.ANTIALIASING,R.HIGHLIGHTS);const i=this._bindParameters;i.highlightMixTexture=i.highlights.length>1?this._rctx.emptyTexture:null,this._precompileHUD(1),this._hasHighlights&&(i.highlights.forEach((e,t)=>{i.highlightLevel=t,this._precompileAllGeometry(9)}),i.highlightLevel=null),i.highlightMixTexture=null,this._nodes.precompile(I.COMPOSITE,R.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(8),--this._plugins.context.techniques.precompiling}_renderFocusAreaGeometry(){const e=this._nodes.produce(R.FOCUSAREA,this._pluginInput);return e&&this.performanceInfo.advance(de.FOCUS_AREA_MASK),e}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._renderContext.output;++this._techniques.precompiling;const t=this._framebufferSize;let r=this.fboCache.acquire(t.width,t.height,"olid");return r.acquireDepth(12),r=this._nodes.render(r,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(de.OBJECT_AND_LAYER_ID_COLOR),this._renderContext.output=e,r}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=0===e;if(r||t){const e=r?this.performanceInfo.elapsedTime:0;let i=0;t?i=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const s=Math.max(e,i);this._animationTimestep.frame(s,r)}}readMainDepth(e,t){const{mainDepth:r,camera:i}=this._bindParameters;if(!r)return;const s=this.fboCache.acquire(this._framebufferSize.width,this._framebufferSize.height,"linear depth");this._rctx.bindFramebuffer(s.fbo),i.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(y),this._compositingHelper.blitDepthToLinearDepth(this._bindParameters,r),this._rctx.setScissorTestEnabled(!1),this._rctx.setScissorRect(0,0,this._rctx.gl.canvas.width,this._rctx.gl.canvas.width),s.fbo?.readPixels(e[0],e[1],e[2],e[3],6408,le.UNSIGNED_BYTE,t),s.release()}readHUDVisibility(e,t,r,i,s){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,i,6408,le.UNSIGNED_BYTE,s)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"edges"),s=()=>t.render(this._bindParameters,e),a=this._bindParameters.geometryDepth;this.renderToTargets(s,i,a??this._framebuffer.depth,y),this._framebuffer.bind(),this._compositingHelper.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(1===e?de.OPAQUE_EDGES:de.TRANSPARENT_EDGES)}_renderOverlay(){this._bindParameters.overlay=this.overlay?.render(),this._bindParameters.overlay&&this.performanceInfo.advance(de.OVERLAY)}_renderShadowMap(e,t,r){if(!this.shadowsEnabled)return;const{contentCamera:i}=this._bindParameters,s=this._shadowMap;s.start(e,t,r,this.isFeatureEnabled(6),this.stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(6,this._shadowMap),s.copySnapshot(1),this._renderShadowCascades(5,this._shadowMap)):this._renderShadowCascades(4),s.finish(),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,i),this.performanceInfo.advance(de.SHADOW_MAP)}_renderHighlightShadowMap(e,t,r){if(!this.shadowsEnabled||!this._needsShadowHighlight)return;const{contentCamera:i}=this._bindParameters,s=this._shadowMap;s.start(e,t,r,this.isFeatureEnabled(6),this.stage.view.qualitySettings.maximumPixelRatio),this._renderShadowCascades(5,this._shadowMap),s.moveSnapshot(0),s.finish(),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,i),this.performanceInfo.advance(de.SHADOW_MAP)}_renderCutFillDepth(){return this._nodes.produce(R.CUTFILL_DEPTH,this._pluginInput)}_precompileShadowCascades(e){for(const t of this._shadowMap.cascades)t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.camera),this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){t.bindFbo();for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e)}get _needsDepth(){return this._plugins.consumes(2)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._shadowAccumulator.active||this._debugNeedsDepth}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");e?(this._pluginInput.set(R.SSAO,this._renderSSAO()),this._needsDepth?(this._rctx.bindFramebuffer(e.fbo),this._rctx.clear(1024),this._renderGeometryWithoutNormals(2),d(this._bindParameters.depth),this._bindParameters.depth=e.obtainDepthTexture(),this.performanceInfo.advance(de.DEPTH)):(e.detachDepth(),this._bindParameters.depth=d(this._bindParameters.depth)),this.hasSSAO&&this._pluginInput.release("normals")):this._renderAllGeometryDepth()}_renderAllGeometryDepth(){if(!this._needsDepth)return void(this._bindParameters.depth=d(this._bindParameters.depth));const e=this._framebufferSize,t=this.fboCache.acquire(e.width,e.height,"geometry depth",12);this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(1280),this.renderAllGeometry(2),d(this._bindParameters.depth),this._bindParameters.depth=t.obtainDepthTexture(),t.release(),this.performanceInfo.advance(de.DEPTH)}_renderTerrainDepth(e){if(this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,!e)return void(this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth));const t=this._renderContext.output;this._renderContext.output=2;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"terrain depth",12);this._rctx.bindFramebuffer(i.fbo),this._rctx.clear(1280),this._renderTransparentTerrain(),d(this._bindParameters.terrainDepth),this._bindParameters.terrainDepth=i.obtainDepthTexture(),this._renderContext.output=t,i.release()}_renderGeometryDepth(e){if(!e)return void(this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth));const t=this._renderContext.output,{width:r,height:i}=this._framebufferSize,s=this.fboCache.acquire(r,i,"geometry depth",12);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(1280),this._renderOpaqueAndTransparentGeometry(2),this._renderContext.output=t,d(this._bindParameters.geometryDepth),this._bindParameters.geometryDepth=s.obtainDepthTexture(),s.release()}get _needsShadowDepthRange(){return this._shadowMap.enabled||this._shadowAccumulator.active}_computeShadowDepthRange(e){if(!this._needsShadowDepthRange)return Y.zero;const t=J(e,this._plugins.plugins,this.stage.layers,0);return t.union(this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}updateSceneDepthRange(e){if(!this.stage.view.state.isGlobal)return void(this.sceneDepthRange.value=Y.infinite);if((this.stage.view.renderCoordsHelper?.getAltitude(e.eye)??0)<O)return void(this.sceneDepthRange.value=Y.infinite);const t=e.clone();t.near=v,t.far=1e10;const r=J(t,this._plugins.plugins,this.stage.layers,1);r.union(this._plugins.queryDepthRange(t)),this.sceneDepthRange.value.far===r.far&&this.sceneDepthRange.value.near===r.near||(this.sceneDepthRange.value=r)}get _normalsRequired(){const e=this._nodes.require("normals",I.FINAL,I.COMPOSITE,I.OPAQUE,I.TRANSPARENT,R.VIEWSHED,R.LASERLINES);return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(3),this._needsDepth&&this._precompileAllGeometry(2),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(5),this._precompileShadowCascades(6),this._precompileShadowCascades(5)):this._precompileShadowCascades(4)),this._shadowAccumulator.active&&this._precompileAllGeometry(4)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"normals",5);r.acquireDepth(12),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(y,!0,!0),this._renderGeometryWithNormals(3);const i=this._nodes.optional("normals",I.FINAL,I.COMPOSITE,I.OPAQUE,I.TRANSPARENT,R.VIEWSHED);return r.retain(e+i-1),this.performanceInfo.advance(de.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return;const t=this._nodes.produce(R.SSAO,this._pluginInput);return this._bindParameters.ssao=t,t&&this.performanceInfo.advance(de.SSAO),t}_precompileAllGeometry(e){const t=this._renderContext.output;this._renderContext.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(6),this._plugins.precompile(7),this._renderContext.output=t}renderAllGeometry(e){this._renderContext.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentTerrain()}precompileSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const r of t)this._renderContext.renderOccludedMask=r,this.precompileSlots(e,...be);this._renderContext.renderOccludedMask=$}renderSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.forAll(e=>{const t=e.acquireTechniques(this._renderContext);t&&e.render(this._renderContext,t)})}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>1&&this._plugins.render(9),this.renderSlots(e,...be),this._renderContext.renderOccludedMask=$}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(13)}precompileViewshedShadowMap(){this._precompileAllGeometry(7)}precompileCutFill(){const e=8,t=this._renderContext.output;this._renderContext.output=e,this._plugins.precompile(0,1,6),this._renderContext.output=t}renderViewshedShadowMap(e){const{camera:t,contentCamera:r}=this._bindParameters,i=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(7),this._ensureBindParametersCamera(t,r),this._bindParameters.camera.setGLViewport(this._rctx),this._renderContext.output=i}renderCutFillReferenceDepth(e){const{camera:t,contentCamera:r}=this._bindParameters,i=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this._renderContext.output=8,this._plugins.render(0,1),this._plugins.render(6),this._ensureBindParametersCamera(t,r),t.setGLViewport(this._rctx),this._renderContext.output=i}_renderOpaqueAndTransparentGeometry(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithNormals(e){this._renderContext.output=e,this._plugins.render(...me),this._renderTransparentTerrain()}_renderGeometryWithoutNormals(e){this._renderContext.output=e,this._plugins.render(...ce)}_precompileOpaqueGeometry(){this._plugins.precompile(...fe)}_renderOpaqueGeometry(){this._plugins.render(...fe)}_renderTransparentGeometry(){this._plugins.render(...ge)}get _hasTransparentTerrain(){return this._plugins.produces(0,6)}get _hasTransparentIntegratedMesh(){return this._plugins.produces(this._renderContext.output,7)}_renderTransparentTerrain(){const e=()=>this._plugins.render(6);if(!q(this._renderContext.output))return void e();const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"transparent terrain");return this.renderToTargets(e,r,this._framebuffer.depth,y),r}_renderTransparentIntegratedMesh(){const e=()=>this._plugins.render(7);if(!q(this._renderContext.output))return void e();const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"transparent integrated mesh");return this.renderToTargets(e,r,this._framebuffer.depth,y),r}get _needsHUDVisibility(){return this._plugins.produces(this._renderContext.output,12)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility));const{width:e,height:t}=this._framebufferSize;let r=this._bindParameters.hudVisibility;r?.fbo?.width===e&&r?.fbo?.height===t||(r?.release(),r=this.fboCache.acquire(e,t,"hud visibility",4),this._bindParameters.hudVisibility=r);const i=this._bindParameters.geometryDepth;r.attachDepth(i||this._framebuffer.depth),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(12),r.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(de.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,0===e){const e=()=>this._plugins.render(15),t=this._framebufferSize,r=this.fboCache.acquireDepth(11,t.width,t.height,"line callouts");this.renderToTargets(e,this._framebuffer.color,r,void 0,!0,!0),r.release()}else this._plugins.render(15)}_precompileHUD(e){if(this._precompileHUDOutput(e),this._hasHighlights){const t=this._renderContext.output;this._renderContext.output=9,this._precompileHUDOutput(e),this._renderContext.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this._oitEnabled&&q(this._renderContext.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...Pe),this._bindParameters.oitPass=2,this._plugins.precompile(...Pe),this._bindParameters.oitPass=0):this._plugins.precompile(...Pe),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t,r){if(this._pluginsHas.hudElements){if(this._oitEnabled){const i=this._renderOIT(1,r,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,i.getTexture()),i.release()}else if(this._renderContext.output=r,0===e){const t=()=>this._renderHUDElements(e),r=this._framebufferSize,i=this.fboCache.acquireDepth(11,r.width,r.height,"hud");this.renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(11),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(0===e?de.HUD_OCCLUDED:de.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(...Pe)}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(5,2)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:r}=this,i=this._framebufferSize,{highlights:s}=r,a=e.acquire(i.width,i.height,"highlights",s.length>j?3:1);a.acquireDepth(12),t.bindFramebuffer(a.fbo);const{gl:n}=t;return n.clearBufferuiv(n.COLOR,0,[0,0,0,0]),this._renderContext.output=9,t.bindFramebuffer(a.fbo),B(t,e,i,r,()=>this._renderHighlightGeometries()),this.performanceInfo.advance(de.HIGHLIGHTS),a}_renderHighlightGeometries(){this._plugins.render(...we),this._rctx.clear(256),this._renderHUDElements(2)}_renderShadowAccumulation(e,t,r,i){this._shadowAccumulator.updateDepthRange(e),this._shadowAccumulator.accumulating&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,t,r,i)&&this.performanceInfo.advance(de.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this._oitEnabled&&q(this._renderContext.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...ge),this._bindParameters.oitPass=2,this._plugins.precompile(...ge),this._bindParameters.oitPass=0):this._plugins.precompile(...ge)}_renderOIT(e,t,r=2){const i=1===e,s=this._framebufferSize,a=i?this.fboCache.acquire(s.width,s.height,"oit hud composite"):null,n=i?()=>this._renderHUDElements(r):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._renderContext.output;this._renderContext.output=t,h.oitPass=1;const d=a?"oit hud color+alpha":"oit color+alpha",l=this.fboCache.acquire(s.width,s.height,d,8),_=1===t;_&&l.acquireColor(_e,8,"oit emissive"),l.acquireColor(_?ue:_e,7),a||l.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(l.fbo),this._rctx.clearFramebuffer([0,0,0,1]),_&&this._rctx.clearBuffer(1,x),n(),l.detachDepth(),h.oitPass=2;const u=this.fboCache.acquire(s.width,s.height,a?"oit hud front":"oit front");return _&&u.acquireColor(_e,8,"oit emissive front"),a?u.acquireDepth(11):u.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(u.fbo),this._rctx.clearFramebuffer(y,!!a),n(),u.detachDepth(),h.oitPass=0,a?(this._rctx.bindFramebuffer(a.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(16384)):this._framebuffer.bind(),this._oitblend??=new k(this._techniques),this._oitblend.blend(this._rctx,l,u,h,_),a?.detachDepth(),u.release(),l.release(),this._renderContext.output=o,a}_renderOpaque(e){const t=this.plugins.produces(0,...fe);if(t){this._plugins.render(0,1);const e=this._framebuffer;e.update(e=>this._renderNodes(R.OPAQUE_TERRAIN,e)),e.bind(),this._plugins.render(2,3)}const r=this._framebuffer;r.update(e=>this._renderNodes(I.OPAQUE,e,t)),this.fboCache.debugCallback?.(I.OPAQUE,r.color.fbo),r.update(e=>this._renderNodes(R.OPAQUE_ENVIRONMENT,e)),this.fboCache.debugCallback?.(R.OPAQUE_ENVIRONMENT,r.color.fbo),this._renderTerrainDepth(e),this._renderEdges(1)}_renderTransparent(e,t,r){const i=this._framebuffer;i.bind(),this._renderPlugins(20,de.VOXEL),this._renderHiddenTransparentEdges(),e&&(this._oitEnabled?this._renderOIT(0,r):this._renderTransparentGeometry()),i.update(t=>this._renderNodes(I.TRANSPARENT,t,e)),this.fboCache.debugCallback?.(I.TRANSPARENT,i.color.fbo),this._renderGeometryDepth(t),this._renderHUDVisibility(),t||this._plugins.render(15),this._renderEdges(0);const s=this._hasTransparentTerrain?this._renderTransparentTerrain():null;s&&(this.performanceInfo.advance(de.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(t?this._renderLineCallouts(0):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositingHelper.compositeHUD(this._bindParameters,s.getTexture())),this._renderHUD(0,i.color,r))),this._bindParameters.cullAboveTerrain=!1,s&&(i.bind(),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,s.getTexture()),s.release(),t&&(this._renderEdges(1),e&&(this._oitEnabled?this._renderOIT(0,r):this._renderTransparentGeometry(),this.performanceInfo.advance(de.TRANSPARENT)),this._renderEdges(0)));const a=this._hasTransparentIntegratedMesh?this._renderTransparentIntegratedMesh():null;a&&(i.bind(),this._compositingHelper.composite(this._bindParameters,a.getTexture()),a.release()),this._bindParameters.ssao=d(this._bindParameters.ssao),t&&this._renderLineCallouts(1),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(de.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(8),this.performanceInfo.advance(de.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderPlugins(e,t){this._plugins.produces(this._renderContext.output,e)&&(this._plugins.render(e),this.performanceInfo.advance(t))}_renderNodes(e,t,r=!1){if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;const i=this._nodes.render(t,this._pluginInput,this._releaseNormals);return this.performanceInfo.advance(e),i}_blitFBO(e,t=M,r=!0){return this._blit??=new U(this._techniques),this._blit.blit(this._rctx,e,t,this._bindParameters),this._pluginInput.set(e.name,t),r&&e.release(),t}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=T:(w(Te,this._bindParameters.camera.viewMatrix),w(Ce,this._bindParameters.camera.projectionMatrix),C(Se,Te,Ce),C(Se,this._renderContext.lastFrameCamera.viewMatrix,Se),C(Se,this._renderContext.lastFrameCamera.projectionMatrix,Se),this._reprojectionMatrix=Se);const t=this.stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=T,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,r,i){this._bindParameters.updateLighting(e,t,r,i),this._requestRender(1)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}renderToTargets(e,t,r,i,s=!1,a=!1){t.attachDepth(r),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(i,s,a),e(),t.detachDepth()}get test(){}};e([g({readOnly:!0})],pe.prototype,"fullResolutionAtmosphere",null),e([g()],pe.prototype,"_edgeView",void 0),e([g()],pe.prototype,"updating",null),pe=e([b("esri.views.3d.webgl-engine.lib.Renderer")],pe);const me=[0,1,2,4],ce=[3,5],fe=[0,1,2,3],ge=[4,5],be=[2,4,8],Pe=[16,13,14],we=[4,5,2,3,6,0,1],Ce=S(),Te=S(),Se=S();function Ee(e){return t=>e.immediate.schedule(t)}export{pe as Renderer};
5
+ import{__decorate as e}from"tslib";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{unitRGBAFromColor as i}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{clamp as s,lerp as a}from"../../../../core/mathUtils.js";import{removeMaybe as n,abortMaybe as h,destroyMaybe as o,releaseMaybe as d}from"../../../../core/maybe.js";import{throwIfAborted as l}from"../../../../core/promiseUtils.js";import{watch as _,syncAndInitial as u,initial as p,sync as m}from"../../../../core/reactiveUtils.js";import{signal as c}from"../../../../core/signal.js";import{Milliseconds as f}from"../../../../core/time.js";import{property as g}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import{subclass as b}from"../../../../core/accessorSupport/decorators/subclass.js";import{equals as P,invert as w,multiply as C}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as T,create as S}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as E}from"../../../../chunks/vec42.js";import{ZEROS as x}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{fromValues as A,ZEROS as y}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as D}from"../../../../geometry/support/Indices.js";import{RenderCategory as I,InternalRenderCategory as R}from"../../webgl.js";import{innerAtmosphereFadeStart as O}from"../../environment/atmosphereUtils.js";import{minNearDistanceInMeters as v}from"../../state/NearFarHeuristic.js";import{debugFlags as F}from"../../support/debugFlags.js";import{FBOCache as H,defaultWebGLFBO as M}from"../core/FBOCache.js";import{RenderPassManager as N}from"../core/renderPasses/RenderPassManager.js";import{isColorOrColorEmission as q}from"../core/shaderLibrary/ShaderOutput.js";import{distanceFadeEnd as G}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as L}from"../effects/RenderNodes.js";import{RenderPluginManager as V}from"../effects/RenderPluginManager.js";import{Blit as U}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as j,renderHighlightBuffer as B}from"../effects/highlight/Highlight.js";import{OITBlend as k}from"../effects/transparency/OITBlend.js";import{AnimationTimer as z}from"./AnimationTimer.js";import{AnimationTimeStep as Q}from"./AnimationTimeStep.js";import{BoundingInfo as W}from"./BoundingInfo.js";import{DepthRange as Y}from"./DepthRange.js";import{depthRangeFromScene as J}from"./depthRangeUtils.js";import{hudFragmentOpacityParameters as K}from"./hudFragmentOpacityParameters.js";import{MainFramebuffer as X}from"./MainFramebuffer.js";import{RenderContext as Z,defaultRenderOccludedMask as $}from"./RenderContext.js";import{RendererBase as ee}from"./RendererBase.js";import{setupFeatureDefaults as te}from"./RenderFeature.js";import{RenderPluginInput as re}from"./RenderPluginInput.js";import{ShadowAccumulator as ie}from"./ShadowAccumulator.js";import{ShadowMap as se}from"./ShadowMap.js";import ae from"./SliceHelper.js";import{MergedRenderer as ne}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as he}from"../parts/renderUtils.js";import{RendererPerformanceInfo as oe,PerformanceCategory as de}from"../statistics/RendererPerformanceInfo.js";import{PixelType as le,ColorAttachment1 as _e,ColorAttachment2 as ue}from"../../../webgl/enums.js";let pe=class extends ee{constructor(e,t,r,s,a,n){super({stage:e}),this._techniques=r,this._rctx=s,this._compositingHelper=a,this._requestRender=n,this._pluginsHas={hudElements:!1,water:!1},this.renderPassManager=new N,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=A(0,0,0,1),this._sliceHelper=new ae,this._blit=null,this._oitblend=null,this.sceneDepthRange=c(Y.infinite),this._state=c(2),this._highQualityTransparencyEnabled=!0,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new Q,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=c(0),this._lastFrameTime=f(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new re,this._releaseNormals=e=>{e.some(({name:e})=>"normals"===e)&&this._pluginInput.release("normals")},this._debugNeedsDepth=!1,this._fboCache=new H(s),this._renderStateFeatures=c(te(!has("disable-feature:high-quality-idle"),e.view.qualityProfile)),this._framebuffer=new X(this.fboCache),this._performanceInfo=new oe(this._rctx),this._shadowMap=new se(this.fboCache,e.viewingMode),this._shadowAccumulator=new ie(this.fboCache,r,e,e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t},(t,r,i)=>{const s=e.view.qualitySettings.maximumPixelRatio;t.shadowMap.start(t.camera,r,i,!0,s),this._renderShadowCascades(4,t.shadowMap),t.shadowMap.finish(),t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.contentCamera)},n),this._renderContext=new Z(this._rctx,this._shadowMap,r),this._nodes=new L(this._renderContext),this._plugins=new V({renderContext:this._renderContext,techniques:r,materials:t,requestRender:n,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this.addHandles([_(()=>e.view.state.camera,()=>n(),u),_(()=>F.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES,e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(0):()=>{},n()},p),_(()=>e.view.environment.background?.color,e=>{const t=e?i(e):y;E(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()},u),_(()=>e.view.state.camera.relativeElevation,e=>this._inGlobeView=(e??1/0)>=G,u),_(()=>this._bindParameters.clouds.fadeFactor,()=>this._bindParameters.fadeLighting(),m),_(()=>this._bindParameters.clouds.data?.state,()=>n(),m),_(()=>e.view.state.highlights,e=>{this._bindParameters.highlights=e,n()},p)])}destroy(){this._gpuTimerHandle=n(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.destroy(),this._shadowAccumulator=null,this._loadEdgeViewTask=h(this._loadEdgeViewTask),this._edgeView=o(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this._fboCache.destroy(),this._fboCache=null,this._plugins.destroy(),this._plugins=null,this._pluginInput=null,this._blit=null,this._oitblend=null,this._compositingHelper=null,this._nodes=null,this._framebuffer=null,this._shadowMap=null,this._renderContext=null,this._performanceInfo=null,W.prune(),ne.prune(),D()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _framebufferSize(){return this._framebuffer.size}get performanceInfo(){return this._performanceInfo}updateRenderFeatures(e=null,t=!has("disable-feature:high-quality-idle")){this._renderStateFeatures.value=te(t,e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate(i=>i.set(t,e,r)),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(1)}get hasReflections(){return this._pluginsHas.water&&(this._ssrEnabled||this.isFeatureEnabled(5))}get _hasHighlights(){return this._plugins.produces(9,2,4,18,13,14)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(9,13,14)}get hasSSAO(){return(this.stage.view.qualitySettings.ambientOcclusion||this.isFeatureEnabled(4))&&!this._inGlobeView}get hasSMAA(){return this.stage.view.qualitySettings.antialiasingEnabled||this.isFeatureEnabled(0)}get fullResolutionAtmosphere(){return this.stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(3)}get fboCache(){return this._fboCache}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=d(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.depth=d(this._bindParameters.depth),this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility)}get updating(){return this._loadEdgeViewTask&&!this._loadEdgeViewTask.finished||this._edgeView?.updating||this._shadowAccumulator.readyToRun||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=r(async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");l(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this.stage.view.renderSpatialReference,viewingMode:this.stage.view.stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:Ee(this.stage.view.resourceController)});return this.addHandles(_(()=>r.updating,()=>this._requestRender(),m)),this._requestRender(),this._edgeViewCallbacks.forEach(e=>e(r)),this._edgeViewCallbacks.length=0,r})),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&P(this._bindParameters.ssr.reprojectionMatrix,T)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:r}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&t.maxCascades!==e.shadowMapMaxCascades&&(t.maxCascades=e.shadowMapMaxCascades,this._requestRender()),e.environment){void 0!==e.environment.weather&&(this._bindParameters.weather=e.environment.weather);const t="virtual"!==e.environment.lighting.type;r.enableFillLights!==t&&(r.enableFillLights=t,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}set slice(e){this._sliceHelper.update(e)&&this._requestRender()}get plugins(){return this._plugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}commit(e,t){return this._isRendering&&console.warn("Renderer.modify called while rendering"),!!super.commit(e,t,this._plugins.context)&&(this.updateHasFlags(),!0)}rendererAdded(e){this._plugins.add(e)}rendererRemoved(e){this._plugins.remove(e)}get occludedRequiresStencil(){return this.occludedRequiresOccludeeStencil||this.occludedRequiresIntegratedMeshStencil}get occludedRequiresOccludeeStencil(){return this._bindParameters.hasOccludees&&!!(8&this.plugins.renderOccludedFlags)}get occludedRequiresIntegratedMeshStencil(){return this._plugins.produces(0,0)&&this._plugins.produces(0,9)}updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(0,...Pe),has.water=this._plugins.produces(3,19),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new z(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const r=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?n(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,r,i=!1){try{return this._isRendering=!0,this._render(e,t,r,i)}catch(s){console.error(`Exception during rendering: ${s}`)}finally{this._isRendering=!1}return new he(this._pluginInput.get(I.FINAL),null)}_updateHUDOccludedFragmentOpacity(e,t){const{idleOpacity:r,navigatingOpacity:i,maxDelta:n,tiltFadeStart:h,tiltFadeEnd:o,altitudeStart:d,altitudeEnd:l}=K,_=this.stage.view,u=_.stateManager.camera,p=_.qualitySettings.fadeDuration,m=2===e?r:i,c=s((u.tilt-h)/(o-h),0,1),f=s(((u.position.z??0)-d)/(l-d),0,1),g=a(a(1,m,c),1,f),b=this._bindParameters.hudOccludedFragmentOpacity;if(p<=0||b===g||0===this._lastFrameTime||this._lastFrameTime>t)return this._bindParameters.hudOccludedFragmentOpacity=g,void(this._lastFrameTime=t);const P=t-this._lastFrameTime;this._lastFrameTime=t;const w=Math.max(1-r,Math.abs(r-i)),C=Math.min(w*P/p,n);C>=Math.abs(g-b)?this._bindParameters.hudOccludedFragmentOpacity=g:(this._bindParameters.hudOccludedFragmentOpacity=b+Math.sign(g-b)*C,this._requestRender())}_render(e,t,r,i){const s=0===r;this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=s,this._disposeBindBuffers();const{camera:a,contentCamera:n,mode:h,alignPixelEnabled:o}=e;this._state.value=h;const d=this._nodes.produces("magnifier-color"),l=this._nodes.produces(I.FINAL),_=this._plugins.hasEmitters,u=_?1:0;this._renderContext.time=t,this._renderContext.output=u,this._bindParameters.oitPass=0,this._bindParameters.alignPixelEnabled=o,this._bindParameters.decorations=!i,this._bindParameters.mainDepth=null;const p=!i||!this._sliceHelper.isDecoration;this._bindParameters.slicePlane=p?this._sliceHelper.plane:null,this._bindParameters.viewshedEnabled=this._nodes.produces(R.VIEWSHED),this._bindParameters.cutFillEnabled=this._nodes.produces(R.CUTFILL_DEPTH),this._renderOverlay(),a.setGLViewport(this._rctx);const m=this._framebuffer,c=m.initialize(a.fullWidth,a.fullHeight,this._backgroundColor,_);this.hasReflections?(c?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=c):c?.release(),this._ensureBindParametersCamera(a,n),this._updateHUDOccludedFragmentOpacity(h,t),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!i;const f=this._highQualityTransparency&&this._hasTransparentTerrain,g=this._plugins.produces(0,...ge);this._precompilePrepasses(),this.performanceInfo.advance(de.PREPARE);const b=this._computeShadowDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,b),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(b,a,n,!s),this._ensureBindParametersSSR(t),this._precompileShaders(f,g,u),this._renderContext.output=u,m.bind(),this._bindParameters.mainDepth=m.depth.attachment,this._renderOpaque(f),this._renderTransparent(g,f,u),this._shadowMap.disposeMainBuffer(),this._pluginInput.set(R.FOCUSAREA,this._renderFocusAreaGeometry()),this._pluginInput.set(R.CUTFILL_DEPTH,this._renderCutFillDepth()),m.update(e=>this._renderNodes(R.TRANSPARENT_ENVIRONMENT,e)),m.update(e=>this._renderNodes(R.VIEWSHED,e)),m.update(e=>this._renderNodes(R.LASERLINES,e)),m.update(e=>this._renderNodes(R.FOCUSAREA_COLOR,e)),this._pluginInput.release(R.FOCUSAREA),this._pluginInput.release(R.CUTFILL_DEPTH),m.update(e=>this._renderNodes(R.OCCLUDED,e)),this._pluginInput.set("highlights",this._renderHighlightPrepass()),this._renderHighlightShadowMap(a,this._bindParameters.lighting.mainLight.direction,b);const P=2===r?this._renderObjectAndLayerIdColor():null;m.update(e=>this._renderNodes(I.COMPOSITE,e)),this._shadowMap.disposeOffscreenBuffers();const w=s&&!l&&!(d&&!i),C=this._pluginInput.get(I.COMPOSITE),T=w?M:this.fboCache.acquire(C.fbo.width,C.fbo.height,R.ANTIALIASING),S=this._nodes.produces(R.ANTIALIASING)?this._renderNodes(R.ANTIALIASING,T):this.blitFBO(C,T,!1);let E;this._pluginInput.set(R.ANTIALIASING,S),this._hasHUDHighlights?(this._renderHUD(1,S,u),E=this._renderNodes(R.HIGHLIGHTS,S)):(E=this._renderNodes(R.HIGHLIGHTS,S),this._renderHUD(1,E,u));const x=this._renderNodes(R.MAGNIFIER,E);return s&&d&&!i&&!l&&this.blitFBO(x),l?(x.attachDepth(m.depth),this.blitFBO(this._renderNodes(I.FINAL,x)),x.detachDepth()):this._pluginInput.set(I.FINAL,x),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),m.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),s||(this._releaseFBOs(),this._disposeOffscreenBuffers()),new he(this._pluginInput.get(I.FINAL),P)}_precompileShaders(e,t,r){++this._plugins.context.techniques.precompiling,this._renderContext.output=r,this._precompileOpaqueGeometry(),this._nodes.precompile(R.OPAQUE_ENVIRONMENT),this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,this._renderContext.output=2,this._plugins.precompile(6),this._plugins.precompile(7),e&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._renderContext.output=r,this._plugins.precompile(6),this._plugins.precompile(7),t&&(this._precompileTransparentGeometry(),this._hasTransparentTerrain&&(this._bindParameters.cullAboveTerrain=!1,this._precompileTransparentGeometry(),this._bindParameters.cullAboveTerrain=e)),this._nodes.precompile(R.FOCUSAREA),this._needsHUDVisibility&&this._plugins.precompile(12),this._plugins.precompile(15),this._precompileHUD(0),this._bindParameters.terrainDepthTest=!1,this._bindParameters.cullAboveTerrain=!1,this._nodes.precompile(R.VIEWSHED,R.CUTFILL_DEPTH,R.LASERLINES,R.FOCUSAREA_COLOR,R.OCCLUDED,R.ANTIALIASING,R.HIGHLIGHTS);const i=this._bindParameters;i.highlightMixTexture=i.highlights.length>1?this._rctx.emptyTexture:null,this._precompileHUD(1),this._hasHighlights&&(i.highlights.forEach((e,t)=>{i.highlightLevel=t,this._precompileAllGeometry(9)}),i.highlightLevel=null),i.highlightMixTexture=null,this._nodes.precompile(I.COMPOSITE,R.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(8),--this._plugins.context.techniques.precompiling}_renderFocusAreaGeometry(){const e=this._nodes.produce(R.FOCUSAREA,this._pluginInput);return e&&this.performanceInfo.advance(de.FOCUS_AREA_MASK),e}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._renderContext.output;++this._techniques.precompiling;const t=this._framebufferSize;let r=this.fboCache.acquire(t.width,t.height,"olid");return r.acquireDepth(12),r=this._nodes.render(r,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(de.OBJECT_AND_LAYER_ID_COLOR),this._renderContext.output=e,r}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=0===e;if(r||t){const e=r?this.performanceInfo.elapsedTime:0;let i=0;t?i=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const s=Math.max(e,i);this._animationTimestep.frame(s,r)}}readMainDepth(e,t){const{mainDepth:r,camera:i}=this._bindParameters;if(!r)return;const s=this.fboCache.acquire(this._framebufferSize.width,this._framebufferSize.height,"linear depth");this._rctx.bindFramebuffer(s.fbo),i.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(y),this._compositingHelper.blitDepthToLinearDepth(this._bindParameters,r),this._rctx.setScissorTestEnabled(!1),this._rctx.setScissorRect(0,0,this._rctx.gl.canvas.width,this._rctx.gl.canvas.width),s.fbo?.readPixels(e[0],e[1],e[2],e[3],6408,le.UNSIGNED_BYTE,t),s.release()}readHUDVisibility(e,t,r,i,s){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,i,6408,le.UNSIGNED_BYTE,s)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"edges"),s=()=>t.render(this._bindParameters,e),a=this._bindParameters.geometryDepth;this.renderToTargets(s,i,a??this._framebuffer.depth,y),this._framebuffer.bind(),this._compositingHelper.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(1===e?de.OPAQUE_EDGES:de.TRANSPARENT_EDGES)}_renderOverlay(){this._bindParameters.overlay=this.overlay?.render(),this._bindParameters.overlay&&this.performanceInfo.advance(de.OVERLAY)}_renderShadowMap(e,t,r){if(!this.shadowsEnabled)return;const{contentCamera:i}=this._bindParameters,s=this._shadowMap;s.start(e,t,r,this.isFeatureEnabled(6),this.stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(6,this._shadowMap),s.copySnapshot(1),this._renderShadowCascades(5,this._shadowMap)):this._renderShadowCascades(4),s.finish(),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,i),this.performanceInfo.advance(de.SHADOW_MAP)}_renderHighlightShadowMap(e,t,r){if(!this.shadowsEnabled||!this._needsShadowHighlight)return;const{contentCamera:i}=this._bindParameters,s=this._shadowMap;s.start(e,t,r,this.isFeatureEnabled(6),this.stage.view.qualitySettings.maximumPixelRatio),this._renderShadowCascades(5,this._shadowMap),s.moveSnapshot(0),s.finish(),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,i),this.performanceInfo.advance(de.SHADOW_MAP)}_renderCutFillDepth(){return this._nodes.produce(R.CUTFILL_DEPTH,this._pluginInput)}_precompileShadowCascades(e){for(const t of this._shadowMap.cascades)t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.camera),this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){t.bindFbo();for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e)}get _needsDepth(){return this._plugins.consumes(2)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._shadowAccumulator.active||this._debugNeedsDepth}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");e?(this._pluginInput.set(R.SSAO,this._renderSSAO()),this._needsDepth?(this._rctx.bindFramebuffer(e.fbo),this._rctx.clear(1024),this._renderGeometryWithoutNormals(2),d(this._bindParameters.depth),this._bindParameters.depth=e.obtainDepthTexture(),this.performanceInfo.advance(de.DEPTH)):(e.detachDepth(),this._bindParameters.depth=d(this._bindParameters.depth)),this.hasSSAO&&this._pluginInput.release("normals")):this._renderAllGeometryDepth()}_renderAllGeometryDepth(){if(!this._needsDepth)return void(this._bindParameters.depth=d(this._bindParameters.depth));const e=this._framebufferSize,t=this.fboCache.acquire(e.width,e.height,"geometry depth",12);this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(1280),this.renderAllGeometry(2),d(this._bindParameters.depth),this._bindParameters.depth=t.obtainDepthTexture(),t.release(),this.performanceInfo.advance(de.DEPTH)}_renderTerrainDepth(e){if(this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,!e)return void(this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth));const t=this._renderContext.output;this._renderContext.output=2;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"terrain depth",12);this._rctx.bindFramebuffer(i.fbo),this._rctx.clear(1280),this._renderTransparentTerrain(),d(this._bindParameters.terrainDepth),this._bindParameters.terrainDepth=i.obtainDepthTexture(),this._renderContext.output=t,i.release()}_renderGeometryDepth(e){if(!e)return void(this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth));const t=this._renderContext.output,{width:r,height:i}=this._framebufferSize,s=this.fboCache.acquire(r,i,"geometry depth",12);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(1280),this._renderOpaqueAndTransparentGeometry(2),this._renderContext.output=t,d(this._bindParameters.geometryDepth),this._bindParameters.geometryDepth=s.obtainDepthTexture(),s.release()}get _needsShadowDepthRange(){return this._shadowMap.enabled||this._shadowAccumulator.active}_computeShadowDepthRange(e){if(!this._needsShadowDepthRange)return Y.zero;const t=J(e,this._plugins.plugins,this.stage.layers,0);return t.union(this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}updateSceneDepthRange(e){if(!this.stage.view.state.isGlobal)return void(this.sceneDepthRange.value=Y.infinite);if((this.stage.view.renderCoordsHelper?.getAltitude(e.eye)??0)<O)return void(this.sceneDepthRange.value=Y.infinite);const t=e.clone();t.near=v,t.far=1e10;const r=J(t,this._plugins.plugins,this.stage.layers,1);r.union(this._plugins.queryDepthRange(t)),this.sceneDepthRange.value.far===r.far&&this.sceneDepthRange.value.near===r.near||(this.sceneDepthRange.value=r)}get _normalsRequired(){const e=this._nodes.require("normals",I.FINAL,I.COMPOSITE,I.OPAQUE,I.TRANSPARENT,R.VIEWSHED,R.LASERLINES);return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(3),this._needsDepth&&this._precompileAllGeometry(2),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(5),this._precompileShadowCascades(6),this._precompileShadowCascades(5)):this._precompileShadowCascades(4)),this._shadowAccumulator.active&&this._precompileAllGeometry(4)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"normals",5);r.acquireDepth(12),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(y,!0,!0),this._renderGeometryWithNormals(3);const i=this._nodes.optional("normals",I.FINAL,I.COMPOSITE,I.OPAQUE,I.TRANSPARENT,R.VIEWSHED);return r.retain(e+i-1),this.performanceInfo.advance(de.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return;const t=this._nodes.produce(R.SSAO,this._pluginInput);return this._bindParameters.ssao=t,t&&this.performanceInfo.advance(de.SSAO),t}_precompileAllGeometry(e){const t=this._renderContext.output;this._renderContext.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(6),this._plugins.precompile(7),this._renderContext.output=t}renderAllGeometry(e){this._renderContext.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentTerrain()}precompileSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const r of t)this._renderContext.renderOccludedMask=r,this.precompileSlots(e,...be);this._renderContext.renderOccludedMask=$}renderSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.forAll(e=>{const t=e.acquireTechniques(this._renderContext);t&&e.render(this._renderContext,t)})}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>1&&this._plugins.render(9),this.renderSlots(e,...be),this._renderContext.renderOccludedMask=$}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(13)}precompileViewshedShadowMap(){this._precompileAllGeometry(7)}precompileCutFill(){const e=8,t=this._renderContext.output;this._renderContext.output=e,this._plugins.precompile(0,1,6),this._renderContext.output=t}renderViewshedShadowMap(e){const{camera:t,contentCamera:r}=this._bindParameters,i=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(7),this._ensureBindParametersCamera(t,r),this._bindParameters.camera.setGLViewport(this._rctx),this._renderContext.output=i}renderCutFillReferenceDepth(e){const{camera:t,contentCamera:r}=this._bindParameters,i=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this._renderContext.output=8,this._plugins.render(0,1),this._plugins.render(6),this._ensureBindParametersCamera(t,r),t.setGLViewport(this._rctx),this._renderContext.output=i}_renderOpaqueAndTransparentGeometry(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithNormals(e){this._renderContext.output=e,this._plugins.render(...me),this._renderTransparentTerrain()}_renderGeometryWithoutNormals(e){this._renderContext.output=e,this._plugins.render(...ce)}_precompileOpaqueGeometry(){this._plugins.precompile(...fe)}_renderOpaqueGeometry(){this._plugins.render(...fe)}_renderTransparentGeometry(){this._plugins.render(...ge)}get _hasTransparentTerrain(){return this._plugins.produces(0,6)}get _hasTransparentIntegratedMesh(){return this._plugins.produces(this._renderContext.output,7)}_renderTransparentTerrain(){const e=()=>this._plugins.render(6);if(!q(this._renderContext.output))return void e();const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"transparent terrain");return this.renderToTargets(e,r,this._framebuffer.depth,y),r}_renderTransparentIntegratedMesh(){const e=()=>this._plugins.render(7);if(!q(this._renderContext.output))return void e();const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"transparent integrated mesh");return this.renderToTargets(e,r,this._framebuffer.depth,y),r}get _needsHUDVisibility(){return this._plugins.produces(this._renderContext.output,12)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility));const{width:e,height:t}=this._framebufferSize;let r=this._bindParameters.hudVisibility;r?.fbo?.width===e&&r?.fbo?.height===t||(r?.release(),r=this.fboCache.acquire(e,t,"hud visibility",4),this._bindParameters.hudVisibility=r);const i=this._bindParameters.geometryDepth;r.attachDepth(i||this._framebuffer.depth),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(12),r.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(de.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,0===e){const e=()=>this._plugins.render(15),t=this._framebufferSize,r=this.fboCache.acquireDepth(11,t.width,t.height,"line callouts");this.renderToTargets(e,this._framebuffer.color,r,void 0,!0,!0),r.release()}else this._plugins.render(15)}_precompileHUD(e){if(this._precompileHUDOutput(e),this._hasHighlights){const t=this._renderContext.output;this._renderContext.output=9,this._precompileHUDOutput(e),this._renderContext.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this._oitEnabled&&q(this._renderContext.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...Pe),this._bindParameters.oitPass=2,this._plugins.precompile(...Pe),this._bindParameters.oitPass=0):this._plugins.precompile(...Pe),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t,r){if(this._pluginsHas.hudElements){if(this._oitEnabled){const i=this._renderOIT(1,r,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,i.getTexture()),i.release()}else if(this._renderContext.output=r,0===e){const t=()=>this._renderHUDElements(e),r=this._framebufferSize,i=this.fboCache.acquireDepth(11,r.width,r.height,"hud");this.renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(11),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(0===e?de.HUD_OCCLUDED:de.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(...Pe)}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(5,2)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:r}=this,i=this._framebufferSize,{highlights:s}=r,a=e.acquire(i.width,i.height,"highlights",s.length>j?3:1);a.acquireDepth(12),t.bindFramebuffer(a.fbo);const{gl:n}=t;return n.clearBufferuiv(n.COLOR,0,[0,0,0,0]),this._renderContext.output=9,t.bindFramebuffer(a.fbo),B(t,e,i,r,()=>this._renderHighlightGeometries()),this.performanceInfo.advance(de.HIGHLIGHTS),a}_renderHighlightGeometries(){this._plugins.render(...we),this._rctx.clear(256),this._renderHUDElements(2)}_renderShadowAccumulation(e,t,r,i){this._shadowAccumulator.updateDepthRange(e),this._shadowAccumulator.accumulating&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,t,r,i)&&this.performanceInfo.advance(de.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this._oitEnabled&&q(this._renderContext.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...ge),this._bindParameters.oitPass=2,this._plugins.precompile(...ge),this._bindParameters.oitPass=0):this._plugins.precompile(...ge)}_renderOIT(e,t,r=2){const i=1===e,s=this._framebufferSize,a=i?this.fboCache.acquire(s.width,s.height,"oit hud composite"):null,n=i?()=>this._renderHUDElements(r):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._renderContext.output;this._renderContext.output=t,h.oitPass=1;const d=a?"oit hud color+alpha":"oit color+alpha",l=this.fboCache.acquire(s.width,s.height,d,8),_=1===t;_&&l.acquireColor(_e,8,"oit emissive"),l.acquireColor(_?ue:_e,7),a||l.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(l.fbo),this._rctx.clearFramebuffer([0,0,0,1]),_&&this._rctx.clearBuffer(1,x),n(),l.detachDepth(),h.oitPass=2;const u=this.fboCache.acquire(s.width,s.height,a?"oit hud front":"oit front");return _&&u.acquireColor(_e,8,"oit emissive front"),a?u.acquireDepth(11):u.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(u.fbo),this._rctx.clearFramebuffer(y,!!a),n(),u.detachDepth(),h.oitPass=0,a?(this._rctx.bindFramebuffer(a.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(16384)):this._framebuffer.bind(),this._oitblend??=new k(this._techniques),this._oitblend.blend(this._rctx,l,u,h,_),a?.detachDepth(),u.release(),l.release(),this._renderContext.output=o,a}_renderOpaque(e){const t=this.plugins.produces(0,...fe);if(t){this._plugins.render(0,1);const e=this._framebuffer;e.update(e=>this._renderNodes(R.OPAQUE_TERRAIN,e)),e.bind(),this._plugins.render(2,3)}const r=this._framebuffer;r.update(e=>this._renderNodes(I.OPAQUE,e,t)),this.fboCache.debugCallback?.(I.OPAQUE,r.color.fbo),r.update(e=>this._renderNodes(R.OPAQUE_ENVIRONMENT,e)),this.fboCache.debugCallback?.(R.OPAQUE_ENVIRONMENT,r.color.fbo),this._renderTerrainDepth(e),this._renderEdges(1)}_renderTransparent(e,t,r){const i=this._framebuffer;i.bind(),this._renderPlugins(20,de.VOXEL),this._renderHiddenTransparentEdges(),e&&(this._oitEnabled?this._renderOIT(0,r):this._renderTransparentGeometry()),i.update(t=>this._renderNodes(I.TRANSPARENT,t,e)),this.fboCache.debugCallback?.(I.TRANSPARENT,i.color.fbo),this._renderGeometryDepth(t),this._renderHUDVisibility(),t||this._plugins.render(15),this._renderEdges(0);const s=this._hasTransparentTerrain?this._renderTransparentTerrain():null;s&&(this.performanceInfo.advance(de.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(t?this._renderLineCallouts(0):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositingHelper.compositeHUD(this._bindParameters,s.getTexture())),this._renderHUD(0,i.color,r))),this._bindParameters.cullAboveTerrain=!1,s&&(i.bind(),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,s.getTexture()),s.release(),t&&(this._renderEdges(1),e&&(this._oitEnabled?this._renderOIT(0,r):this._renderTransparentGeometry(),this.performanceInfo.advance(de.TRANSPARENT)),this._renderEdges(0)));const a=this._hasTransparentIntegratedMesh?this._renderTransparentIntegratedMesh():null;a&&(i.bind(),this._compositingHelper.composite(this._bindParameters,a.getTexture()),a.release()),this._bindParameters.ssao=d(this._bindParameters.ssao),t&&this._renderLineCallouts(1),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(de.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(8),this.performanceInfo.advance(de.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderPlugins(e,t){this._plugins.produces(this._renderContext.output,e)&&(this._plugins.render(e),this.performanceInfo.advance(t))}_renderNodes(e,t,r=!1){if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;const i=this._nodes.render(t,this._pluginInput,this._releaseNormals);return this.performanceInfo.advance(e),i}blitFBO(e,t=M,r=!0){return this._blit??=new U(this._techniques),this._blit.blit(this._rctx,e,t,this._bindParameters),this._pluginInput.set(e.name,t),r&&e.release(),t}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=T:(w(Te,this._bindParameters.camera.viewMatrix),w(Ce,this._bindParameters.camera.projectionMatrix),C(Se,Te,Ce),C(Se,this._renderContext.lastFrameCamera.viewMatrix,Se),C(Se,this._renderContext.lastFrameCamera.projectionMatrix,Se),this._reprojectionMatrix=Se);const t=this.stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=T,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,r,i){this._bindParameters.updateLighting(e,t,r,i),this._requestRender(1)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}renderToTargets(e,t,r,i,s=!1,a=!1){t.attachDepth(r),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(i,s,a),e(),t.detachDepth()}get test(){}};e([g({readOnly:!0})],pe.prototype,"fullResolutionAtmosphere",null),e([g()],pe.prototype,"_edgeView",void 0),e([g()],pe.prototype,"updating",null),pe=e([b("esri.views.3d.webgl-engine.lib.Renderer")],pe);const me=[0,1,2,4],ce=[3,5],fe=[0,1,2,3],ge=[4,5],be=[2,4,8],Pe=[16,13,14],we=[4,5,2,3,6,0,1],Ce=S(),Te=S(),Se=S();function Ee(e){return t=>e.immediate.schedule(t)}export{pe as Renderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{equals as r,binaryIndexOf as s}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import n from"../../../../../core/Logger.js";import{clamp as i}from"../../../../../core/mathUtils.js";import{disposeMaybe as o,destroyMaybe as a}from"../../../../../core/maybe.js";import{isAbortError as c,onAbortOrThrow as l}from"../../../../../core/promiseUtils.js";import{property as d}from"../../../../../core/accessorSupport/decorators/property.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as u,transpose as m,invert as g}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as p}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as f}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i as _,c as b,a as y,e as j}from"../../../../../chunks/vec32.js";import{create as w,clone as O}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as E}from"../../../../../core/support/UpdatingHandles.js";import{n as x,g as v}from"../../../../../chunks/sphere.js";import{c as M}from"../../../../../chunks/vec33.js";import{encodeElevationOffset as R}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as T}from"../../core/util/TwoVectorPosition.js";import{Attribute as C}from"../Attribute.js";import{GridLocalOriginFactory as D}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as P}from"../localOriginHelper.js";import{LocalOriginManager as A}from"../LocalOriginManager.js";import{Object3D as k}from"../Object3D.js";import{VertexArrayObject as U}from"../VertexArrayObject.js";import{VertexLayout as q,glVertexLayout as B,EdgeInputBufferLayout as H,RegularEdgeInstancesGLLayout as L,SilhouetteEdgeInstancesGLLayout as V}from"./bufferLayouts.js";import{EdgeRenderer as S,lineWidthFractionFactor as I,extensionLengthOffset as N}from"./EdgeRenderer.js";import{EdgePassParameters as z}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as F}from"./EdgeWorkerHandle.js";import{generateStrokesTexture as G}from"./strokes.js";import{determineRendererType as K,determineEdgeTransparency as W,determineObjectTransparency as J,fillComponentBufferIndices as Q}from"./util.js";import{BufferManager as X}from"../TextureBackedBuffer/BufferManager.js";import{VertexBuffer as Y}from"../../../../webgl/VertexBuffer.js";const Z=128;let $=class extends t{constructor(e){super(e),this._updatingHandles=new E,this._objectEntries=new Map,this._pendingDeletions=new Map,this._renderers=new Map,this._gpuMemoryUsage=0,this._workerAbort=new AbortController,this._tmpModelPosition=w(),this._localOrigins=new A(new D(e.renderSR));const t=q.createBuffer(4);for(let r=0;r<4;r++)t.sideness.set(r,0,0===r||3===r?0:1),t.sideness.set(r,1,0===r||1===r?0:1);this._vertexBuffer=new Y(e.rctx,B,t.buffer)}initialize(){this._workerHandle=new F(this.schedule),this._componentColorManager=new X(this.rctx,3)}destroy(){this.destroyed||(this._objectEntries.forEach(e=>this._discardObjectEntry(e)),this._objectEntries.clear(),this._pendingDeletions.forEach(e=>this._discardObjectEntry(e)),this._pendingDeletions.clear(),this._strokesTexture=o(this._strokesTexture),this._componentColorManager=a(this._componentColorManager),this._workerAbort.abort(),this._workerHandle.destroy(),this._vertexBuffer.dispose(),this._renderers.clear(),this._updatingHandles.destroy(),this._set("schedule",_e))}get updating(){return this._updatingHandles.updating}get usedMemory(){return this._gpuMemoryUsage}shouldRender(){return this._renderers.size>0}async addComponentObject(e,t,r,s,n,i,o){if(this.hasObject(e))return this._getObjectMemoryUsage(e);let a;const c=new re(null,new Promise(e=>a=e),e.obb.center,e.obb.radius);this._objectEntries.set(e,c);const l=await this._updatingHandles.addPromise(this._addComponentGeometry(e.transform,c,t,r,s,n,i,o));return this.setNeedsRender(),a(),l}async addOrUpdateObject3D(e,t,r,s){if(this.destroyed)return void n.getLogger(this).warn("Attempt to add an object to a destroyed instance");const i=new AbortController;let o;const a=e.boundingVolumeWorldSpace.bounds,l=new re(i,new Promise(e=>o=e),x(a,w()),v(a)),d=this._objectEntries.get(e);d&&(this._pendingDeletions.has(e)?this._discardObjectEntry(d):this._pendingDeletions.set(e,d)),this._objectEntries.set(e,l);try{const n=new Array;if(e.geometries.length>1&&te(e))n.push(this._addObjectMergedGeometries(e,l,t,r,s));else for(const i of e.geometries)i.material.supportsEdges&&n.push(this._addGeometry(e,l,i,t,r,s));await this._updatingHandles.addPromise(Promise.all(n)),this._removePendingDeletion(e)}catch(h){c(h)?this._discardObjectEntry(l):this._removePendingDeletion(e)}finally{this.setNeedsRender(),o()}}removeObject(e){const t=this._objectEntries.get(e);this._objectEntries.delete(e),this._discardObjectEntry(t),this._removePendingDeletion(e)}_removePendingDeletion(e){const t=this._pendingDeletions.get(e);this._pendingDeletions.delete(e),this._discardObjectEntry(t)}async _getObjectEntry(e){const t=this._objectEntries.get(e);if(!t)throw new Error("no object");return await t.loaded,null==t.loaded?null:t}fastUpdateObject3DEdgesTransform(e){if(this.destroyed)return!1;const t=this._objectEntries.get(e);if(!t)return!1;const{geometries:r}=e,{renderables:s}=t;if(0===r.length||0===s.length)return!0;if(s.length>1)return!1;const[n]=s,i=n.transform;if(!(i instanceof ie))return!1;const[o]=r;if(o.localOrigin!==i.origin.origin)return!1;const a=f(),c=this._computeModelTransformWithLocalOrigin(e,o,a);return n.transform=new ie(a,c),this.setNeedsRender(),!0}_discardObjectEntry(e){e&&(e.abort?.abort(),e.renderables.length&&(e.renderables.forEach(e=>this._removeRenderable(e)),this.setNeedsRender()),e.loaded=null)}hasObject(e){return this._objectEntries.has(e)}async updateAllComponentOpacities(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));if(null==r)return;const s=Array.isArray(t)?e=>t[e]:()=>t;r.renderables.forEach(e=>{const t=e.components.meta.length;for(let r=0;r<t;r++){const t=s(r),n=e.components.meta[r],i=n.index;n.material.opacity=t,e.components.buffer.textureBuffer.setDataElement(i,1,3,255*t)}this._updateTransparency(e)}),this.setNeedsRender()}async _getObjectMemoryUsage(e){const t=await this._getObjectEntry(e);return t?t.renderables.reduce((e,t)=>e+t.statistics.gpuMemoryUsage,0):0}async updateAllComponentMaterials(e,t,r,s){const n=e instanceof k,i=K(t),o=S.getKey(i,r,n),a=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=a&&(a.renderables.forEach(e=>{if(o!==e.rendererKey){const t=this._renderers.get(e.rendererKey),s=this._acquireRenderer(i,r,n);t.removeRenderable(e),--t.refCount,e.rendererKey=o,s.addRenderable(e)}if(Array.isArray(t))for(let r=0;r<t.length;r++)e.components.meta[r].material=t[r];else e.components.meta[0].material=t;s&&ce(e.components),this._updateTransparency(e)}),this.setNeedsRender())}async updateAllVerticalOffsets(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&this._updateAllVerticalOffsets(r,t)}_updateAllVerticalOffsets(e,t){e.renderables.forEach(e=>{const r=e.components.meta;for(let s=0;s<r.length;s++)e.components.meta[s].verticalOffset=t?.[s]??0;ce(e.components)}),this.setNeedsRender()}async updateObjectVisibility(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));r&&(r.renderables.forEach(e=>e.visible=t),this.setNeedsRender())}render(e,t){if(null==this._componentColorManager)return;this._localOrigins.updateViewMatrices(e.camera.viewMatrix);const r=e.camera.viewInverseTransposeMatrix,s=w(),n=new T;let i=0,o=0;if(this._renderers.forEach(r=>{0!==r.refCount?(++this.techniques.precompiling,r.forEachRenderable(t=>{t.visible&&(i+=t.statistics.averageEdgeLength,o++,t.regular&&r.acquireTechnique(e,!1),t.silhouette&&r.acquireTechnique(e,!0))},t),--this.techniques.precompiling):this._renderers.delete(r.key)}),this._componentColorManager.garbageCollect(),this._componentColorManager.updateTextures(),0===o)return;const a=new z(40*i/o,t);_(s,r[3],r[7],r[11]),n.set(s),b(a.transformWorldFromViewTH,n.high),b(a.transformWorldFromViewTL,n.low),u(a.transformViewFromCameraRelativeRS,e.camera.viewMatrix),m(fe,a.transformViewFromCameraRelativeRS),g(a.transformNormalViewFromGlobal,fe),a.transformProjFromView=e.camera.projectionMatrix,this._updateObjectCameraDistances(e),this._renderers.forEach(t=>{le(t,e,a),de(t,e,a)})}_updateTransparency(e){const t=W(e.components.meta),r=J(e.components.meta);t===e.edgeTransparency&&r===e.objectTransparency||(e.edgeTransparency=t,e.objectTransparency=r,this._renderers.get(e.rendererKey).setRenderablesDirty())}_computeModelTransformWithLocalOrigin(e,t,r){e.getCombinedShaderTransformation(t,r);const s=null!=t.localOrigin?this._localOrigins.register(t.localOrigin):this._localOrigins.acquire(_(this._tmpModelPosition,r[12],r[13],r[14]));return t.localOrigin=s.origin,P(s.origin.vec3,r),s}_createComponentBuffers(e){if(null==this._componentColorManager)return null;const t=new Array,r=this._componentColorManager.getBuffer(e.length);for(let n=0;n<e.length;n++){const s=e[n],i=r.acquireIndex();t.push({index:i,verticalOffset:0,material:s})}const s=new se(r,t);return ce(s),s}_extractEdges(e,t,r,s,n,i,o=i.length){return o<Z&&(n=!0),this._workerHandle.process({data:r,indices:i,indicesLength:o,writerSettings:t,skipDeduplicate:s},e,n)}_createRenderable(e,t,r,s,n){const i=t=>new ne(new U(this.rctx,new Map([["vertices",this._vertexBuffer],["instances",0===t?new Y(this.rctx,L,e.regular.instancesData.buffer):new Y(this.rctx,V,e.silhouette.instancesData.buffer)]])),0===t?e.regular.lodInfo:e.silhouette.lodInfo),o=e.regular.lodInfo.lengths.length>0?i(0):null,a=e.silhouette.lodInfo.lengths.length>0?i(1):null,c=(o?.vao.cachedMemory??0)+(a?.vao.cachedMemory??0);return new oe(o,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,W(t.meta),J(t.meta),t,s)}async _addGeometry(e,t,r,s,n,i){if(r.edgeIndicesLength<=0)return;const o=r.attributes.get("position"),a=f(),c=this._computeModelTransformWithLocalOrigin(e,r,a),l=new pe(o,a,c);return this._addPositionData(t,l,r.edgeIndicesLength,s,n,i)}async _addPositionData(e,t,r,s,n,i=!1){if(null==e.loaded)return;const o=this._createComponentBuffers([s]);if(null==o)return;const a=this._acquireRenderer(s.type,n,!0),{modelTransform:c,origin:l}=t,d=t.position.indices,h=t.position,u=h.data.length/h.size,m=H.createBuffer(u);for(let f=0;f<u;f++)m.position.set(f,0,h.data[f*h.size]),m.position.set(f,1,h.data[f*h.size+1]),m.position.set(f,2,h.data[f*h.size+2]);Q(o.meta,[0,m.componentIndex.count],m.componentIndex);const g=await this._updatingHandles.addPromise(this._extractEdges(e.abort?.signal||this._workerAbort.signal,a.writerSettings,m,!1,i,d,r));if(null==e.loaded)return;const p=this._createRenderable(g,o,new ie(c,l),a.key,!1);e.renderables.push(p),a.addRenderable(p),this._gpuMemoryUsage+=p.statistics.gpuMemoryUsage}async _addComponentGeometry(e,t,r,s,n,i,o,a){if(null==t.loaded)return 0;const c=this._createComponentBuffers(i);if(null==c)return 0;const l=K(i),d=this._acquireRenderer(l,o||!1,!1),h=H.createBuffer(r.length/3);M(h.position.typedBuffer,r,h.position.typedBufferStride,3),Q(c.meta,n,h.componentIndex,s);const u=!0,m=d.writerSettings,g=await this._updatingHandles.addPromise(this._extractEdges(this._workerAbort.signal,m,h,u,!1,s));if(null==t.loaded)return 0;const p=this._createRenderable(g,c,e,d.key,!0);return t.renderables.push(p),d.addRenderable(p),this._updateAllVerticalOffsets(t,a),p.statistics.gpuMemoryUsage}async _addObjectMergedGeometries(e,t,r,s,n){const i=new Map;let o=0,a=0,c=null;const l=e.geometries.filter(e=>{if(e.edgeIndicesLength<=0||!e.material.supportsEdges)return!1;!c&&e.localOrigin&&(c=e);const t=e.attributes.get("position");return a+=t.data.length/t.size,o+=e.edgeIndicesLength,!0});if(0===l.length)return;const d=a>=65536?Uint32Array:Uint16Array,h=o?new d(o):null,u=[];let m=0;l.forEach(e=>{const t=e.attributes.get("position"),r=t.indices;let s=i.get(t.data);if(null==s){s=u.length/3;for(let e=0;e<t.data.length;e+=t.size)u.push(t.data[e]),u.push(t.data[e+1]),u.push(t.data[e+2]);i.set(t.data,s)}for(let n=0;n<e.edgeIndicesLength;n++)h[m++]=s+r[n]});const g=c||e.geometries[0],p=f(),_=this._computeModelTransformWithLocalOrigin(e,g,p);for(let f=0;f<e.geometries.length;f++)e.geometries[f].localOrigin=_.origin;const b=new pe(new C(u,h,3),p,_);await this._updatingHandles.addPromise(this._addPositionData(t,b,h.length,r,s,n))}_acquireRenderer(e,t,r){const s=S.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=G(this.rctx)),n||(n=new S(this.rctx,this.techniques,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:1===this.viewingMode}),this._renderers.set(s,n)),++n.refCount,n}_removeRenderable(e){ee(e.regular),ee(e.silhouette);const t=this._renderers.get(e.rendererKey);if(t){t.removeRenderable(e),--t.refCount,this._localOrigins.release(e.transform.origin),this._gpuMemoryUsage-=e.statistics.externalMemoryUsage?0:e.statistics.gpuMemoryUsage;for(const t of e.components.meta)e.components.buffer.releaseIndex(t.index)}}_updateObjectCameraDistances(e){const t=e.camera.eye,r=e.camera.viewForward,s=w(),n=e=>{y(s,e.center,t);const n=j(s,r),i=e.radius,o=n<-i?1/0:n<i?0:n-i;e.renderables.forEach(e=>e.distanceToCamera=o)};this._objectEntries.forEach(n),this._pendingDeletions.forEach(n)}get test(){}};function ee(e){e?.vao&&(e.vao.buffer("instances")?.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function te(e){let t=null,s=null;for(const n of e.geometries){if(n.material.supportsEdges){if(t){if(!r(t,n.transformation))return!1}else t=n.transformation;if(s||null==n.localOrigin){if(null!=s?.localOrigin&&null!=n.localOrigin&&s.localOrigin.id!==n.localOrigin.id)return!1}else s=n}}return!0}e([d({constructOnly:!0})],$.prototype,"rctx",void 0),e([d({constructOnly:!0})],$.prototype,"renderSR",void 0),e([d({constructOnly:!0})],$.prototype,"viewingMode",void 0),e([d({constructOnly:!0})],$.prototype,"techniques",void 0),e([d({constructOnly:!0})],$.prototype,"setNeedsRender",void 0),e([d({constructOnly:!0})],$.prototype,"schedule",void 0),e([d({readOnly:!0})],$.prototype,"_updatingHandles",void 0),e([d({readOnly:!0})],$.prototype,"updating",null),$=e([h("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],$);class re{constructor(e,t,r,s){this.abort=e,this.radius=s,this.renderables=new Array;const n=e?l(e.signal,()=>e.abort()):null;this.loaded=t,this.loaded.then(()=>{null!=this.loaded&&(this.loaded=!0),this.abort=null,n?.remove()}),this.center=O(r)}}class se{constructor(e,t){this.buffer=e,this.meta=t}}class ne{constructor(e,t){this.vao=e,this.lod=t}}class ie{constructor(e,t){this.modelMatrix=e,this.origin=t}}class oe{constructor(e,t,r,s,n,i,o,a){this.regular=e,this.silhouette=t,this.statistics=r,this.transform=s,this.edgeTransparency=n,this.objectTransparency=i,this.components=o,this.rendererKey=a,this.distanceToCamera=0,this.visible=!0}}class ae extends oe{}function ce(e){const{meta:t,buffer:r}=e,s=new Uint8Array(4);for(let n=0;n<t.length;n++){const e=t[n].material,o=t[n].index,a=i(Math.round(e.size*I),0,255),c=i(e.extensionLength,-N,255-N)+N,l=255*e.opacity,d=e.color,h=255*d[0],u=255*d[1],m=255*d[2],g=255*d[3];r.textureBuffer.setData(o,0,h,u,m,g),r.textureBuffer.setData(o,1,a,c,e.type,l),R(t[n].verticalOffset,s),r.textureBuffer.setData(o,2,s[0],s[1],s[2],s[3])}}function le(e,t,r){let s,n;const i=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable(i=>{if(!he(i)||!i.visible)return;s??=e.acquireTechnique(t,!1),n??=e.rctx.bindTechnique(s,t,r);const a=ge(i.regular.lod.lengths,i.distanceToCamera,o);e.renderRegularEdges(n,i,r,t,a)},i)}function de(e,t,r){let s,n;const i=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable(i=>{if(!me(i)||!i.visible)return;s??=e.acquireTechnique(t,!0),n??=e.rctx.bindTechnique(s,t,r);const a=ge(i.silhouette.lod.lengths,i.distanceToCamera,o);e.renderSilhouetteEdges(n,i,r,t,a)},i)}function he(e){return null!=e.regular}class ue extends oe{}function me(e){return null!=e.silhouette}function ge(e,t,r){const n=t*r,i=s(e,n,!0);return-1===i?n<e[0]?e.length:0:e.length-i}class pe{constructor(e,t,r){this.position=e,this.modelTransform=t,this.origin=r}}const fe=p(),_e=()=>Promise.reject();export{$ as EdgeView,ie as LegacyTransform,ae as RegularRenderable,oe as Renderable,ue as SilhouetteRenderable};
5
+ import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{equals as r,binaryIndexOf as s}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import n from"../../../../../core/Logger.js";import{clamp as i}from"../../../../../core/mathUtils.js";import{disposeMaybe as o,destroyMaybe as a}from"../../../../../core/maybe.js";import{isAbortError as c,onAbortOrThrow as l}from"../../../../../core/promiseUtils.js";import{property as d}from"../../../../../core/accessorSupport/decorators/property.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as u,transpose as m,invert as g}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as p}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as f}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i as _,c as b,a as y,e as j}from"../../../../../chunks/vec32.js";import{create as w,clone as O}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as E}from"../../../../../core/support/UpdatingHandles.js";import{n as x,g as v}from"../../../../../chunks/sphere.js";import{c as M}from"../../../../../chunks/vec33.js";import{encodeElevationOffset as R}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as T}from"../../core/util/TwoVectorPosition.js";import{Attribute as C}from"../Attribute.js";import{GridLocalOriginFactory as D}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as P}from"../localOriginHelper.js";import{LocalOriginManager as A}from"../LocalOriginManager.js";import{Object3D as k}from"../Object3D.js";import{VertexArrayObject as U}from"../VertexArrayObject.js";import{VertexLayout as q,glVertexLayout as B,EdgeInputBufferLayout as H,RegularEdgeInstancesGLLayout as L,SilhouetteEdgeInstancesGLLayout as V}from"./bufferLayouts.js";import{EdgeRenderer as S,lineWidthFractionFactor as I,extensionLengthOffset as N}from"./EdgeRenderer.js";import{EdgePassParameters as z}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as F}from"./EdgeWorkerHandle.js";import{generateStrokesTexture as G}from"./strokes.js";import{determineRendererType as K,determineEdgeTransparency as W,determineObjectTransparency as J,fillComponentBufferIndices as Q}from"./util.js";import{BufferManager as X}from"../TextureBackedBuffer/BufferManager.js";import{VertexBuffer as Y}from"../../../../webgl/VertexBuffer.js";const Z=128;let $=class extends t{constructor(e){super(e),this._updatingHandles=new E,this._objectEntries=new Map,this._pendingDeletions=new Map,this._renderers=new Map,this._gpuMemoryUsage=0,this._workerAbort=new AbortController,this._tmpModelPosition=w(),this._localOrigins=new A(new D(e.renderSR));const t=q.createBuffer(4);for(let r=0;r<4;r++)t.sideness.set(r,0,0===r||3===r?0:1),t.sideness.set(r,1,0===r||1===r?0:1);this._vertexBuffer=new Y(e.rctx,B,t.buffer)}initialize(){this._workerHandle=new F(this.schedule),this._componentColorManager=new X(this.rctx,3)}destroy(){this.destroyed||(this._objectEntries.forEach(e=>this._discardObjectEntry(e)),this._objectEntries.clear(),this._pendingDeletions.forEach(e=>this._discardObjectEntry(e)),this._pendingDeletions.clear(),this._strokesTexture=o(this._strokesTexture),this._componentColorManager=a(this._componentColorManager),this._workerAbort.abort(),this._workerHandle.destroy(),this._vertexBuffer.dispose(),this._renderers.clear(),this._updatingHandles.destroy(),this._set("schedule",_e))}get updating(){return this._updatingHandles.updating}get usedMemory(){return this._gpuMemoryUsage}shouldRender(){return this._renderers.size>0}async addComponentObject(e,t,r,s,n,i,o){if(this.hasObject(e))return this._getObjectMemoryUsage(e);let a;const c=new re(null,new Promise(e=>a=e),e.obb.center,e.obb.radius);this._objectEntries.set(e,c);const l=await this._updatingHandles.addPromise(this._addComponentGeometry(e.transform,c,t,r,s,n,i,o));return this.setNeedsRender(),a(),l}async addOrUpdateObject3D(e,t,r,s){if(this.destroyed)return void n.getLogger(this).warn("Attempt to add an object to a destroyed instance");const i=new AbortController;let o;const a=e.boundingVolumeWorldSpace.bounds,l=new re(i,new Promise(e=>o=e),x(a,w()),v(a)),d=this._objectEntries.get(e);d&&(this._pendingDeletions.has(e)?this._discardObjectEntry(d):this._pendingDeletions.set(e,d)),this._objectEntries.set(e,l);try{const n=new Array;if(e.geometries.length>1&&te(e))n.push(this._addObjectMergedGeometries(e,l,t,r,s));else for(const i of e.geometries)i.material.supportsEdges&&n.push(this._addGeometry(e,l,i,t,r,s));await this._updatingHandles.addPromise(Promise.all(n)),this._removePendingDeletion(e)}catch(h){c(h)?this._discardObjectEntry(l):this._removePendingDeletion(e)}finally{this.setNeedsRender(),o()}}removeObject(e){const t=this._objectEntries.get(e);this._objectEntries.delete(e),this._discardObjectEntry(t),this._removePendingDeletion(e)}_removePendingDeletion(e){const t=this._pendingDeletions.get(e);this._pendingDeletions.delete(e),this._discardObjectEntry(t)}async _getObjectEntry(e){const t=this._objectEntries.get(e);if(!t)throw new Error("no object");return await t.loaded,null==t.loaded?null:t}fastUpdateObject3DEdgesTransform(e){if(this.destroyed)return!1;const t=this._objectEntries.get(e);if(!t)return!1;const{geometries:r}=e,{renderables:s}=t;if(0===r.length||0===s.length)return!0;if(s.length>1)return!1;const[n]=s,i=n.transform;if(!(i instanceof ie))return!1;const[o]=r;if(o.localOrigin!==i.origin.origin)return!1;const a=f(),c=this._computeModelTransformWithLocalOrigin(e,o,a);return n.transform=new ie(a,c),this.setNeedsRender(),!0}_discardObjectEntry(e){e&&(e.abort?.abort(),e.renderables.length&&(e.renderables.forEach(e=>this._removeRenderable(e)),this.setNeedsRender()),e.loaded=null)}hasObject(e){return this._objectEntries.has(e)}async updateAllComponentOpacities(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));if(null==r)return;const s=Array.isArray(t)?e=>t[e]:()=>t;r.renderables.forEach(e=>{const t=e.components.meta.length;for(let r=0;r<t;r++){const t=s(r),n=e.components.meta[r],i=n.index;n.material.opacity=t,e.components.buffer.textureBuffer.setDataElement(i,1,3,255*t)}this._updateTransparency(e)}),this.setNeedsRender()}async _getObjectMemoryUsage(e){const t=await this._getObjectEntry(e);return t?t.renderables.reduce((e,t)=>e+t.statistics.gpuMemoryUsage,0):0}async updateAllComponentMaterials(e,t,r,s){const n=e instanceof k,i=K(t),o=S.getKey(i,r,n),a=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=a&&(a.renderables.forEach(e=>{if(o!==e.rendererKey){const t=this._renderers.get(e.rendererKey),s=this._acquireRenderer(i,r,n);t.removeRenderable(e),--t.refCount,e.rendererKey=o,s.addRenderable(e)}if(Array.isArray(t))for(let r=0;r<t.length;r++)e.components.meta[r].material=t[r];else e.components.meta[0].material=t;s&&ce(e.components),this._updateTransparency(e)}),this.setNeedsRender())}async updateAllVerticalOffsets(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&this._updateAllVerticalOffsets(r,t)}_updateAllVerticalOffsets(e,t){e.renderables.forEach(e=>{const r=e.components.meta;for(let s=0;s<r.length;s++)e.components.meta[s].verticalOffset=t?.[s]??0;ce(e.components)}),this.setNeedsRender()}async updateObjectVisibility(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));r&&(r.renderables.forEach(e=>e.visible=t),this.setNeedsRender())}render(e,t){if(null==this._componentColorManager)return;this._localOrigins.updateViewMatrices(e.camera.viewMatrix);const r=e.camera.viewInverseTransposeMatrix,s=w(),n=new T;let i=0,o=0;if(this._renderers.forEach(r=>{0!==r.refCount?(++this.techniques.precompiling,r.forEachRenderable(t=>{t.visible&&(i+=t.statistics.averageEdgeLength,o++,t.regular&&r.acquireTechnique(e,!1),t.silhouette&&r.acquireTechnique(e,!0))},t),--this.techniques.precompiling):this._renderers.delete(r.key)}),this._componentColorManager.garbageCollect(),this._componentColorManager.updateTextures(),0===o)return;const a=new z(40*i/o,t);_(s,r[3],r[7],r[11]),n.set(s),b(a.transformWorldFromViewTH,n.high),b(a.transformWorldFromViewTL,n.low),u(a.transformViewFromCameraRelativeRS,e.camera.viewMatrix),m(fe,a.transformViewFromCameraRelativeRS),g(a.transformNormalViewFromGlobal,fe),a.transformProjFromView=e.camera.projectionMatrix,this._updateObjectCameraDistances(e),this._renderers.forEach(t=>{le(t,e,a),de(t,e,a)})}_updateTransparency(e){const t=W(e.components.meta),r=J(e.components.meta);t===e.edgeTransparency&&r===e.objectTransparency||(e.edgeTransparency=t,e.objectTransparency=r,this._renderers.get(e.rendererKey).setRenderablesDirty())}_computeModelTransformWithLocalOrigin(e,t,r){e.getCombinedShaderTransformation(t,r);const s=null!=t.localOrigin?this._localOrigins.register(t.localOrigin):this._localOrigins.acquire(_(this._tmpModelPosition,r[12],r[13],r[14]));return t.localOrigin=s.origin,P(s.origin.vec3,r),s}_createComponentBuffers(e){if(null==this._componentColorManager)return null;const t=new Array,r=this._componentColorManager.getBuffer(e.length);for(let n=0;n<e.length;n++){const s=e[n],i=r.acquireIndex();t.push({index:i,verticalOffset:0,material:s})}const s=new se(r,t);return ce(s),s}_extractEdges(e,t,r,s,n,i,o=i.length){return o<Z&&(n=!0),this._workerHandle.process({data:r,indices:i,indicesLength:o,writerSettings:t,skipDeduplicate:s},e,n)}_createRenderable(e,t,r,s,n){const i=t=>new ne(new U(this.rctx,new Map([["vertices",this._vertexBuffer],["instances",0===t?new Y(this.rctx,L,e.regular.instancesData.buffer):new Y(this.rctx,V,e.silhouette.instancesData.buffer)]])),0===t?e.regular.lodInfo:e.silhouette.lodInfo),o=e.regular.lodInfo.lengths.length>0?i(0):null,a=e.silhouette.lodInfo.lengths.length>0?i(1):null,c=(o?.vao.usedMemory??0)+(a?.vao.usedMemory??0);return new oe(o,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,W(t.meta),J(t.meta),t,s)}async _addGeometry(e,t,r,s,n,i){if(r.edgeIndicesLength<=0)return;const o=r.attributes.get("position"),a=f(),c=this._computeModelTransformWithLocalOrigin(e,r,a),l=new pe(o,a,c);return this._addPositionData(t,l,r.edgeIndicesLength,s,n,i)}async _addPositionData(e,t,r,s,n,i=!1){if(null==e.loaded)return;const o=this._createComponentBuffers([s]);if(null==o)return;const a=this._acquireRenderer(s.type,n,!0),{modelTransform:c,origin:l}=t,d=t.position.indices,h=t.position,u=h.data.length/h.size,m=H.createBuffer(u);for(let f=0;f<u;f++)m.position.set(f,0,h.data[f*h.size]),m.position.set(f,1,h.data[f*h.size+1]),m.position.set(f,2,h.data[f*h.size+2]);Q(o.meta,[0,m.componentIndex.count],m.componentIndex);const g=await this._updatingHandles.addPromise(this._extractEdges(e.abort?.signal||this._workerAbort.signal,a.writerSettings,m,!1,i,d,r));if(null==e.loaded)return;const p=this._createRenderable(g,o,new ie(c,l),a.key,!1);e.renderables.push(p),a.addRenderable(p),this._gpuMemoryUsage+=p.statistics.gpuMemoryUsage}async _addComponentGeometry(e,t,r,s,n,i,o,a){if(null==t.loaded)return 0;const c=this._createComponentBuffers(i);if(null==c)return 0;const l=K(i),d=this._acquireRenderer(l,o||!1,!1),h=H.createBuffer(r.length/3);M(h.position.typedBuffer,r,h.position.typedBufferStride,3),Q(c.meta,n,h.componentIndex,s);const u=!0,m=d.writerSettings,g=await this._updatingHandles.addPromise(this._extractEdges(this._workerAbort.signal,m,h,u,!1,s));if(null==t.loaded)return 0;const p=this._createRenderable(g,c,e,d.key,!0);return t.renderables.push(p),d.addRenderable(p),this._updateAllVerticalOffsets(t,a),p.statistics.gpuMemoryUsage}async _addObjectMergedGeometries(e,t,r,s,n){const i=new Map;let o=0,a=0,c=null;const l=e.geometries.filter(e=>{if(e.edgeIndicesLength<=0||!e.material.supportsEdges)return!1;!c&&e.localOrigin&&(c=e);const t=e.attributes.get("position");return a+=t.data.length/t.size,o+=e.edgeIndicesLength,!0});if(0===l.length)return;const d=a>=65536?Uint32Array:Uint16Array,h=o?new d(o):null,u=[];let m=0;l.forEach(e=>{const t=e.attributes.get("position"),r=t.indices;let s=i.get(t.data);if(null==s){s=u.length/3;for(let e=0;e<t.data.length;e+=t.size)u.push(t.data[e]),u.push(t.data[e+1]),u.push(t.data[e+2]);i.set(t.data,s)}for(let n=0;n<e.edgeIndicesLength;n++)h[m++]=s+r[n]});const g=c||e.geometries[0],p=f(),_=this._computeModelTransformWithLocalOrigin(e,g,p);for(let f=0;f<e.geometries.length;f++)e.geometries[f].localOrigin=_.origin;const b=new pe(new C(u,h,3),p,_);await this._updatingHandles.addPromise(this._addPositionData(t,b,h.length,r,s,n))}_acquireRenderer(e,t,r){const s=S.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=G(this.rctx)),n||(n=new S(this.rctx,this.techniques,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:1===this.viewingMode}),this._renderers.set(s,n)),++n.refCount,n}_removeRenderable(e){ee(e.regular),ee(e.silhouette);const t=this._renderers.get(e.rendererKey);if(t){t.removeRenderable(e),--t.refCount,this._localOrigins.release(e.transform.origin),this._gpuMemoryUsage-=e.statistics.externalMemoryUsage?0:e.statistics.gpuMemoryUsage;for(const t of e.components.meta)e.components.buffer.releaseIndex(t.index)}}_updateObjectCameraDistances(e){const t=e.camera.eye,r=e.camera.viewForward,s=w(),n=e=>{y(s,e.center,t);const n=j(s,r),i=e.radius,o=n<-i?1/0:n<i?0:n-i;e.renderables.forEach(e=>e.distanceToCamera=o)};this._objectEntries.forEach(n),this._pendingDeletions.forEach(n)}get test(){}};function ee(e){e?.vao&&(e.vao.buffer("instances")?.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function te(e){let t=null,s=null;for(const n of e.geometries){if(n.material.supportsEdges){if(t){if(!r(t,n.transformation))return!1}else t=n.transformation;if(s||null==n.localOrigin){if(null!=s?.localOrigin&&null!=n.localOrigin&&s.localOrigin.id!==n.localOrigin.id)return!1}else s=n}}return!0}e([d({constructOnly:!0})],$.prototype,"rctx",void 0),e([d({constructOnly:!0})],$.prototype,"renderSR",void 0),e([d({constructOnly:!0})],$.prototype,"viewingMode",void 0),e([d({constructOnly:!0})],$.prototype,"techniques",void 0),e([d({constructOnly:!0})],$.prototype,"setNeedsRender",void 0),e([d({constructOnly:!0})],$.prototype,"schedule",void 0),e([d({readOnly:!0})],$.prototype,"_updatingHandles",void 0),e([d({readOnly:!0})],$.prototype,"updating",null),$=e([h("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],$);class re{constructor(e,t,r,s){this.abort=e,this.radius=s,this.renderables=new Array;const n=e?l(e.signal,()=>e.abort()):null;this.loaded=t,this.loaded.then(()=>{null!=this.loaded&&(this.loaded=!0),this.abort=null,n?.remove()}),this.center=O(r)}}class se{constructor(e,t){this.buffer=e,this.meta=t}}class ne{constructor(e,t){this.vao=e,this.lod=t}}class ie{constructor(e,t){this.modelMatrix=e,this.origin=t}}class oe{constructor(e,t,r,s,n,i,o,a){this.regular=e,this.silhouette=t,this.statistics=r,this.transform=s,this.edgeTransparency=n,this.objectTransparency=i,this.components=o,this.rendererKey=a,this.distanceToCamera=0,this.visible=!0}}class ae extends oe{}function ce(e){const{meta:t,buffer:r}=e,s=new Uint8Array(4);for(let n=0;n<t.length;n++){const e=t[n].material,o=t[n].index,a=i(Math.round(e.size*I),0,255),c=i(e.extensionLength,-N,255-N)+N,l=255*e.opacity,d=e.color,h=255*d[0],u=255*d[1],m=255*d[2],g=255*d[3];r.textureBuffer.setData(o,0,h,u,m,g),r.textureBuffer.setData(o,1,a,c,e.type,l),R(t[n].verticalOffset,s),r.textureBuffer.setData(o,2,s[0],s[1],s[2],s[3])}}function le(e,t,r){let s,n;const i=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable(i=>{if(!he(i)||!i.visible)return;s??=e.acquireTechnique(t,!1),n??=e.rctx.bindTechnique(s,t,r);const a=ge(i.regular.lod.lengths,i.distanceToCamera,o);e.renderRegularEdges(n,i,r,t,a)},i)}function de(e,t,r){let s,n;const i=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable(i=>{if(!me(i)||!i.visible)return;s??=e.acquireTechnique(t,!0),n??=e.rctx.bindTechnique(s,t,r);const a=ge(i.silhouette.lod.lengths,i.distanceToCamera,o);e.renderSilhouetteEdges(n,i,r,t,a)},i)}function he(e){return null!=e.regular}class ue extends oe{}function me(e){return null!=e.silhouette}function ge(e,t,r){const n=t*r,i=s(e,n,!0);return-1===i?n<e[0]?e.length:0:e.length-i}class pe{constructor(e,t,r){this.position=e,this.modelTransform=t,this.origin=r}}const fe=p(),_e=()=>Promise.reject();export{$ as EdgeView,ie as LegacyTransform,ae as RegularRenderable,oe as Renderable,ue as SilhouetteRenderable};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import"../../../../../core/has.js";import{property as r}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as t}from"../../../../../core/accessorSupport/decorators/subclass.js";import{SyncRenderPlugin as i}from"../../effects/RenderPlugin.js";import{MergedBuffer as s}from"./MergedBuffer.js";import{VaoRenderer as a}from"./VaoRenderer.js";let n=class extends i{constructor(e){super(e),this._dataByOrigin=new Map,this._buffer=null,this._renderer=null,this.drapedPriority=0}initialize(){this._buffer=new s({material:this.material,dataByOrigin:this._dataByOrigin,highlightOrderMap:this.highlightOrderMap}),this._renderer=new a({material:this.material,dataByOrigin:this._dataByOrigin})}destroy(){for(const e of this._dataByOrigin.values())e.dispose();this._dataByOrigin.clear(),this._buffer.destroy(),this._renderer.destroy()}hasHighlight(e){return this._renderer.hasHighlight(e)}initializeRenderContext(e){this._buffer.initializeRenderContext(e),this._renderer.initializeRenderContext(e)}uninitializeRenderContext(){this._buffer.uninitializeRenderContext(),this._renderer.uninitializeRenderContext()}get produces(){return this._renderer.produces}get hasOccludees(){return this._buffer.hasOccludees}get hasOnlyOccluders(){return!!(-2&this.renderOccludedFlags)}get hasEmitters(){return this.material.hasEmissions}get isDecoration(){return this.material.parameters.isDecoration}get renderOccludedFlags(){return this.material.renderOccludedFlags}get numGeometries(){let e=0;return this._dataByOrigin.forEach(r=>e+=r.buffers.reduce((e,r)=>e+r.instances.size,0)),e}get usedMemory(){let e=0;return this._dataByOrigin.forEach(r=>e+=r.buffers.reduce((e,r)=>e+r.vao.cachedMemory,0)),e}forEachGeometry(e){this._dataByOrigin.forEach(r=>r.buffers.forEach(r=>r.instances.forEach(({geometry:r})=>e(r))))}modify(e,r){this._buffer.modify(e,r),this._renderer.updateHighlights()}get canCompact(){return this._buffer.canCompact}compact(e){return this._buffer.compact(e)}updateHighlights(e){this.highlightOrderMap=e,this._buffer.updateHighlights(e),this._renderer.updateHighlights()}updateAnimation(e){return this.material.update(e)}acquireTechniques(e){return this._renderer.acquireTechniques(e)}render(e,r){return this._renderer.render(e,r)}static prune(){s.prune()}get test(){}};e([r({constructOnly:!0})],n.prototype,"material",void 0),e([r()],n.prototype,"highlightOrderMap",void 0),n=e([t("esri.views.3d.webgl-engine.materials.renderers.MergedRenderer")],n);export{n as MergedRenderer};
5
+ import{__decorate as e}from"tslib";import"../../../../../core/has.js";import{property as r}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as t}from"../../../../../core/accessorSupport/decorators/subclass.js";import{SyncRenderPlugin as i}from"../../effects/RenderPlugin.js";import{MergedBuffer as s}from"./MergedBuffer.js";import{VaoRenderer as a}from"./VaoRenderer.js";let n=class extends i{constructor(e){super(e),this._dataByOrigin=new Map,this._buffer=null,this._renderer=null,this.drapedPriority=0}initialize(){this._buffer=new s({material:this.material,dataByOrigin:this._dataByOrigin,highlightOrderMap:this.highlightOrderMap}),this._renderer=new a({material:this.material,dataByOrigin:this._dataByOrigin})}destroy(){for(const e of this._dataByOrigin.values())e.dispose();this._dataByOrigin.clear(),this._buffer.destroy(),this._renderer.destroy()}hasHighlight(e){return this._renderer.hasHighlight(e)}initializeRenderContext(e){this._buffer.initializeRenderContext(e),this._renderer.initializeRenderContext(e)}uninitializeRenderContext(){this._buffer.uninitializeRenderContext(),this._renderer.uninitializeRenderContext()}get produces(){return this._renderer.produces}get hasOccludees(){return this._buffer.hasOccludees}get hasOnlyOccluders(){return!!(-2&this.renderOccludedFlags)}get hasEmitters(){return this.material.hasEmissions}get isDecoration(){return this.material.parameters.isDecoration}get renderOccludedFlags(){return this.material.renderOccludedFlags}get numGeometries(){let e=0;return this._dataByOrigin.forEach(r=>e+=r.buffers.reduce((e,r)=>e+r.instances.size,0)),e}get usedMemory(){let e=0;return this._dataByOrigin.forEach(r=>e+=r.buffers.reduce((e,r)=>e+r.vao.usedMemory,0)),e}forEachGeometry(e){this._dataByOrigin.forEach(r=>r.buffers.forEach(r=>r.instances.forEach(({geometry:r})=>e(r))))}modify(e,r){this._buffer.modify(e,r),this._renderer.updateHighlights()}get canCompact(){return this._buffer.canCompact}compact(e){return this._buffer.compact(e)}updateHighlights(e){this.highlightOrderMap=e,this._buffer.updateHighlights(e),this._renderer.updateHighlights()}updateAnimation(e){return this.material.update(e)}acquireTechniques(e){return this._renderer.acquireTechniques(e)}render(e,r){return this._renderer.render(e,r)}static prune(){s.prune()}get test(){}};e([r({constructOnly:!0})],n.prototype,"material",void 0),e([r()],n.prototype,"highlightOrderMap",void 0),n=e([t("esri.views.3d.webgl-engine.materials.renderers.MergedRenderer")],n);export{n as MergedRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{nextHighestPowerOfTwo as t}from"../../../../../core/mathUtils.js";import{copy as e,invert as r,transpose as o}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{glLayout as i}from"../../../support/buffer/glUtil.js";class a{constructor(t,e){this._bufferWriter=t.createBufferWriter(),this._vaoCache=e.getVaoCache(i(this._bufferWriter.layout))}get maxElements(){return Math.floor(h/this._strideFloats)}get _strideBytes(){return this._bufferWriter.layout.stride}get _strideFloats(){return this._strideBytes/4}vaoEndElement(t){return Math.floor(t.getByteLength("geometry")/this._strideBytes)}evaluateBufferAllocation(t,e,r,o){const s=this._strideFloats,i=e.reduce((t,e)=>t+this.elementCount(e),0),a=r.reduce((t,e)=>t+this.elementCount(e),0),n=Math.min((t+i-a)*s,h),f=o.getByteLength("geometry")/4;return n>l&&n<f/2?0:n>f?1:2}deleteBuffer(t){this._vaoCache.deleteVao(t)}reallocateBuffer(t,e){this.deleteBuffer(t);const r=e*this._strideFloats;return this._vaoCache.newVao(g(r))}elementCount(t){return this._bufferWriter.elementCount(t.geometry.attributes)}canGrow(t,e){const r=4*(e*this._strideFloats);return t.getByteLength("geometry")<g(h-l)&&r>t.getByteLength("geometry")}clearHoles(t,e){const{_strideFloats:r}=this,o=t.reduce((t,e)=>Math.max(t,e.numElements),0)*r,s=b(o);s.fill(0,0,o);const i=e.buffer();for(const a of t)i?.setSubData(s,a.from*r,0,a.numElements*r)}clearHolesMetal(t,e,r,o){const{_bufferWriter:s,_strideFloats:i}=this,a=(r-e)*i,n=b(a),f=s.layout.createView(n.buffer);n.fill(0,0,a);for(const l of t){if(!(l.from>=e&&l.to<=r))continue;const t=l.from-e;this._writeGeometry(l.geometry,f,t)}o.buffer()?.setSubData(n,e*i,0,a)}writeRandomInstances(t,e,r){const{_bufferWriter:o,_strideFloats:s}=this,i=b(t*s),a=o.layout.createView(i.buffer);let n=0,f=0,l=0;const u=r.buffer();for(const m of e){if(!(l===m.from)){const t=l-f;t>0&&u?.setSubData(i,f*s,0,t*s),f=m.from,n=0}this._writeGeometry(m.geometry,a,n),n=m.to,l=m.to}const c=l-f;c>0&&u?.setSubData(i,f*s,0,c*s)}writeInstanceRangeMetal(t,e,r,o){const{_bufferWriter:s,_strideFloats:i}=this,a=t-e,n=a*i,f=b(n),l=s.layout.createView(f.buffer);f.fill(0,0,n);for(const u of r){if(!(u.from>=e&&u.to<=t))continue;const r=u.from-e;this._writeGeometry(u.geometry,l,r)}a>0&&o.buffer()?.setSubData(f,e*i,0,n)}rebuildInstances(t,e,r){const{_bufferWriter:o,_strideFloats:s}=this,i=b(t*s),a=o.layout.createView(i.buffer);let n=0;for(const f of e){this._writeGeometry(f.geometry,a,n);const t=n;n+=this.elementCount(f.geometry),f.from=t,f.to=n}return r.buffer()?.setSubData(i,0,0,n*s),n}updateInstance(t,e){const{_bufferWriter:r,_strideFloats:o}=this,s=b(r.elementCount(t.geometry.geometry.attributes)*o),i=r.layout.createView(s.buffer);this._writeGeometry(t.geometry,i,0),e.buffer()?.setSubData(s,t.from*o,0,t.numElements*o)}_writeGeometry(t,s,i){const{_bufferWriter:a}=this;null!=a&&(e(n,t.transformation),n[12]-=t.localOrigin.vec3[0],n[13]-=t.localOrigin.vec3[1],n[14]-=t.localOrigin.vec3[2],r(f,n),o(f,f),a.write(n,f,t.geometry.attributes,t.geometry.olidColor,s,i))}static prune(){y=new Float32Array(l)}}const n=s(),f=s(),l=65536,u=4*l,c=1024,m=16777216,h=m/4;let y=new Float32Array(l);function b(t){return y.length<t&&(y=new Float32Array(t)),y}function g(e){const r=4*e;return r<=c?c:r<u?t(r):Math.max(Math.min(Math.ceil(1.5*r/u)*u,m),r)}export{a as VaoWriter};
5
+ import{nextHighestPowerOfTwo as t}from"../../../../../core/mathUtils.js";import{copy as e,invert as r,transpose as o}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{glLayout as i}from"../../../support/buffer/glUtil.js";class a{constructor(t,e){this._bufferWriter=t.createBufferWriter(),this._vaoCache=e.getVaoCache(i(this._bufferWriter.layout))}get maxElements(){return Math.floor(h/this._strideFloats)}get _strideBytes(){return this._bufferWriter.layout.stride}get _strideFloats(){return this._strideBytes/4}vaoEndElement(t){return Math.floor(t.getByteLength("geometry")/this._strideBytes)}evaluateBufferAllocation(t,e,r,o){const s=this._strideFloats,i=e.reduce((t,e)=>t+this.elementCount(e),0),a=r.reduce((t,e)=>t+this.elementCount(e),0),n=Math.min((t+i-a)*s,h),f=o.getByteLength("geometry")/4;return n>l&&n<f/2?0:n>f?1:2}deleteBuffer(t){this._vaoCache.deleteVao(t)}reallocateBuffer(t,e){this.deleteBuffer(t);const r=e*this._strideFloats;return this._vaoCache.newVao(g(r))}elementCount(t){return this._bufferWriter.elementCount(t.geometry.attributes)}canGrow(t,e){const r=4*(e*this._strideFloats);return t.getByteLength("geometry")<g(h-l)&&r>t.getByteLength("geometry")}clearHoles(t,e){const{_strideFloats:r}=this,o=t.reduce((t,e)=>Math.max(t,e.numElements),0)*r,s=b(o);s.fill(0,0,o);const i=e.buffer();for(const a of t)i?.setSubData(s,a.from*r,0,a.numElements*r)}clearHolesMetal(t,e,r,o){const{_bufferWriter:s,_strideFloats:i}=this,a=(r-e)*i,n=b(a),f=s.layout.createView(n.buffer);n.fill(0,0,a);for(const l of t){if(!(l.from>=e&&l.to<=r))continue;const t=l.from-e;this._writeGeometry(l.geometry,f,t)}o.buffer()?.setSubData(n,e*i,0,a)}writeRandomInstances(t,e,r){const{_bufferWriter:o,_strideFloats:s}=this,i=b(t*s),a=o.layout.createView(i.buffer);let n=0,f=0,l=0;const u=r.buffer();for(const c of e){if(!(l===c.from)){const t=l-f;t>0&&u?.setSubData(i,f*s,0,t*s),f=c.from,n=0}this._writeGeometry(c.geometry,a,n),n+=c.numElements,l=c.to}const m=l-f;m>0&&u?.setSubData(i,f*s,0,m*s)}writeInstanceRangeMetal(t,e,r,o){const{_bufferWriter:s,_strideFloats:i}=this,a=t-e,n=a*i,f=b(n),l=s.layout.createView(f.buffer);f.fill(0,0,n);for(const u of r){if(!(u.from>=e&&u.to<=t))continue;const r=u.from-e;this._writeGeometry(u.geometry,l,r)}a>0&&o.buffer()?.setSubData(f,e*i,0,n)}rebuildInstances(t,e,r){const{_bufferWriter:o,_strideFloats:s}=this,i=b(t*s),a=o.layout.createView(i.buffer);let n=0;for(const f of e){this._writeGeometry(f.geometry,a,n);const t=n;n+=this.elementCount(f.geometry),f.from=t,f.to=n}return r.buffer()?.setSubData(i,0,0,n*s),n}updateInstance(t,e){const{_bufferWriter:r,_strideFloats:o}=this,s=b(r.elementCount(t.geometry.geometry.attributes)*o),i=r.layout.createView(s.buffer);this._writeGeometry(t.geometry,i,0),e.buffer()?.setSubData(s,t.from*o,0,t.numElements*o)}_writeGeometry(t,s,i){const{_bufferWriter:a}=this;null!=a&&(e(n,t.transformation),n[12]-=t.localOrigin.vec3[0],n[13]-=t.localOrigin.vec3[1],n[14]-=t.localOrigin.vec3[2],r(f,n),o(f,f),a.write(n,f,t.geometry.attributes,t.geometry.olidColor,s,i))}static prune(){y=new Float32Array(l)}}const n=s(),f=s(),l=65536,u=4*l,m=1024,c=16777216,h=c/4;let y=new Float32Array(l);function b(t){return y.length<t&&(y=new Float32Array(t)),y}function g(e){const r=4*e;return r<=m?m:r<u?t(r):Math.max(Math.min(Math.ceil(1.5*r/u)*u,c),r)}export{a as VaoWriter};
@@ -0,0 +1,17 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
+ */
5
+ import{smoothstep as e}from"../../../../core/mathUtils.js";import{k as r}from"../../../../chunks/vec32.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{Float3BindUniform as a}from"../core/shaderModules/Float3BindUniform.js";import{Float4BindUniform as o}from"../core/shaderModules/Float4BindUniform.js";import{glsl as s}from"../core/shaderModules/glsl.js";import{SphereIntersect as n}from"./SphereIntersect.glsl.js";function i(i,h){i.fragment.uniforms.add(new o("heightParameters",a=>{const o=a.camera,s=r(o.eye),n=Math.sqrt(s),i=h.radius,l=s-i*i;let m=e(4e6,5e6,n-i);return m=Math.min(m,.98),t(m,l,0,0)}),new a("cameraPosition",e=>e.camera.eye)),i.fragment.include(n),i.fragment.code.add(s`float sphereFade() {return heightParameters[0];}
6
+ float sphereDepthInterpolate(vec3 worldRay, vec3 viewRay, float currentLinearDepth) {
7
+ vec2 rayPlanetIntersect = sphereIntersect(cameraPosition, worldRay, heightParameters[1]);
8
+ bool hitsPlanet = (rayPlanetIntersect.x <= rayPlanetIntersect.y) && rayPlanetIntersect.x > 0.0;
9
+ if (hitsPlanet) {
10
+ float sphereDepth = rayPlanetIntersect.x;
11
+ viewRay *= viewRay.z*sphereDepth;
12
+ float linearDepth = length(viewRay);
13
+ float sphereFade = heightParameters[0];
14
+ return (-linearDepth)*sphereFade + currentLinearDepth*(1.0-sphereFade);
15
+ }
16
+ return currentLinearDepth;
17
+ }`)}export{i as sphereDepthInterpolate};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import r from"../core/Accessor.js";import t from"../core/Collection.js";import{when as s}from"../core/reactiveUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import{isLayerGroundReplacement as a}from"../layers/GroundLayer.js";import{toExtent as n}from"./3d/support/cameraUtils.js";import p from"./support/GroundViewElevationSampler.js";let d=class extends r{constructor(e){super(e),this.view=null,this.layerViews=new t}initialize(){this.addHandles(s(()=>this.view?.map?.ground,async e=>e.load())),"3d"===this.view.type&&this.addHandles([s(()=>this.view.map?.basemap,e=>{e.groundLayers.on("after-changes",()=>this._groundLayersChanged())},{initial:!0}),s(()=>"3d"===this.view.type&&(this.view?.basemapTerrain??!1),async()=>{this._groundLayersChanged()})])}_groundLayersChanged(){const{view:e}=this;if(null!=e&&"3d"===e.type){const r=e.basemapTerrain;if(r){const t=e.map?.basemap?.groundLayers.some(a);r.enable(!t)}}}get ground(){return this.view?.map?.ground}destroy(){this._set("view",null);for(const e of this.layerViews)e.destroy();this.layerViews.length=0}get elevationSampler(){return"2d"!==this.view?.type&&this.view?.ready&&this.view?.basemapTerrain?.ready?new p({view:this.view}):null}get extent(){const e=this.view;return e&&"2d"!==e.type&&e.ready?n(e,e.state.camera,e.pointsOfInterest.centerOnSurfaceFrequent.renderLocation):null}get updating(){return!this.suspended&&this.layerViews.some(e=>e.updating)}get suspended(){return this.view?.suspended??!0}};e([o({readOnly:!0})],d.prototype,"elevationSampler",null),e([o({readOnly:!0})],d.prototype,"extent",null),e([o({type:Boolean,readOnly:!0})],d.prototype,"updating",null),e([o({constructOnly:!0})],d.prototype,"view",void 0),e([o({type:t,readOnly:!0})],d.prototype,"layerViews",void 0),e([o({readOnly:!0})],d.prototype,"suspended",null),d=e([i("esri.views.GroundView")],d);const l=d;export{l as default};
5
+ import{__decorate as e}from"tslib";import r from"../core/Accessor.js";import t from"../core/Collection.js";import{when as s,watch as o}from"../core/reactiveUtils.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import{isLayerGroundReplacement as n}from"../layers/GroundLayer.js";import{toExtent as p}from"./3d/support/cameraUtils.js";import d from"./support/GroundViewElevationSampler.js";let l=class extends r{constructor(e){super(e),this.view=null,this.layerViews=new t}initialize(){this.addHandles(s(()=>this.view?.map?.ground,async e=>e.load())),"3d"===this.view.type&&this.addHandles([o(()=>this.view.map?.basemap,()=>this._groundLayersChanged(),{initial:!0}),o(()=>this.view.map?.basemap?.groundLayers,e=>{this._groundLayersChanged(),e?.on("after-changes",()=>this._groundLayersChanged())},{initial:!0}),s(()=>"3d"===this.view.type&&(this.view?.basemapTerrain??!1),async()=>{this._groundLayersChanged()})])}_groundLayersChanged(){const{view:e}=this;if(null!=e&&"3d"===e.type){const r=e.basemapTerrain;if(r){const t=e.map?.basemap?.groundLayers.some(n);r.enable(!t)}}}get ground(){return this.view?.map?.ground}destroy(){this._set("view",null);for(const e of this.layerViews)e.destroy();this.layerViews.length=0}get elevationSampler(){return"2d"!==this.view?.type&&this.view?.ready&&this.view?.basemapTerrain?.ready?new d({view:this.view}):null}get extent(){const e=this.view;return e&&"2d"!==e.type&&e.ready?p(e,e.state.camera,e.pointsOfInterest.centerOnSurfaceFrequent.renderLocation):null}get updating(){return!this.suspended&&this.layerViews.some(e=>e.updating)}get suspended(){return this.view?.suspended??!0}};e([i({readOnly:!0})],l.prototype,"elevationSampler",null),e([i({readOnly:!0})],l.prototype,"extent",null),e([i({type:Boolean,readOnly:!0})],l.prototype,"updating",null),e([i({constructOnly:!0})],l.prototype,"view",void 0),e([i({type:t,readOnly:!0})],l.prototype,"layerViews",void 0),e([i({readOnly:!0})],l.prototype,"suspended",null),l=e([a("esri.views.GroundView")],l);const u=l;export{u as default};