@arcgis/core 4.29.0-next.20231220 → 4.29.0-next.20231221

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 (99) hide show
  1. package/analysis/Analysis.js +1 -1
  2. package/applications/WebEditor/sketchUtils.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/00b340b4495bfabd4ca2.js +1 -0
  5. package/assets/esri/core/workers/chunks/{4301736368af52b94ee2.js → 02d6e2f0b1003534a077.js} +1 -1
  6. package/assets/esri/core/workers/chunks/0e315452f11b112523f0.js +1 -0
  7. package/assets/esri/core/workers/chunks/{37faadfa58a2f72d11bd.js → 1254a544d369d99ccf59.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{0be38fd63e870341c660.js → 220fcc25578b2ef316da.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{c9f8354d51f701cd69e5.js → 321dcff84c31c739ed93.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{f350378a0d93dda39425.js → 7205c1680afee0cc0aac.js} +1 -1
  11. package/assets/esri/core/workers/chunks/831283ac6653d7af90b6.js +1 -0
  12. package/assets/esri/core/workers/chunks/8485562b452686c6c3f2.js +1 -0
  13. package/assets/esri/core/workers/chunks/{ff582d31932d72912c33.js → b7c2244c27790ccaca92.js} +1 -1
  14. package/assets/esri/core/workers/chunks/dbded06d7a944dd97b01.js +1 -0
  15. package/assets/esri/core/workers/chunks/dcfc48bf5c27774fa05c.js +1 -0
  16. package/assets/esri/core/workers/chunks/e4049e498b3eaa9c8596.js +1 -0
  17. package/assets/esri/themes/base/widgets/_Directions.scss +4 -0
  18. package/assets/esri/themes/base/widgets/_Grid.scss +8 -2
  19. package/assets/esri/themes/dark/main.css +1 -1
  20. package/assets/esri/themes/light/main.css +1 -1
  21. package/assets/esri/themes/light/view.css +1 -1
  22. package/chunks/vec32.js +1 -1
  23. package/core/PooledArray.js +1 -1
  24. package/core/libs/gl-matrix-2/math/vec3.js +1 -1
  25. package/geometry/ellipsoidUtils.js +1 -1
  26. package/interfaces.d.ts +298 -30
  27. package/layers/GeoJSONLayer.js +1 -1
  28. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  29. package/layers/support/rasterFunctions/BandArithmeticFunction.js +1 -1
  30. package/layers/support/rasterFunctions/bandIndexUtils.js +1 -1
  31. package/package.json +1 -1
  32. package/support/revision.js +1 -1
  33. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  34. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  35. package/views/2d/layers/support/DebugOverlay.js +1 -1
  36. package/views/3d/analysis/AnalysisView3D.js +1 -1
  37. package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
  38. package/views/3d/layers/I3SMeshView3D.js +1 -1
  39. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  40. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  41. package/views/3d/layers/IntegratedMesh3DTilesViewPerformanceInfo.js +5 -0
  42. package/views/3d/layers/TiledLayerView3D.js +1 -1
  43. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  44. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  45. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  46. package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
  47. package/views/3d/layers/i3s/PagedNodeIndex.js +1 -1
  48. package/views/3d/layers/support/DefinitionExpressionSceneLayerView.js +1 -1
  49. package/views/3d/layers/support/TemporalSceneLayerView.js +1 -1
  50. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  51. package/views/3d/support/RenderCoordsHelper.js +1 -1
  52. package/views/3d/support/orientedBoundingBox.js +1 -1
  53. package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
  54. package/views/3d/terrain/OverlayManager.js +1 -1
  55. package/views/3d/terrain/OverlayRenderer.js +1 -1
  56. package/views/3d/terrain/PatchRenderData.js +1 -1
  57. package/views/3d/terrain/SphericalPatch.js +1 -1
  58. package/views/3d/terrain/TerrainSurface.js +1 -1
  59. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  60. package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
  61. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  62. package/views/3d/webgl-engine/effects/RenderNodeCollection.js +1 -1
  63. package/views/3d/webgl-engine/effects/ScreenSpaceGeometry.js +1 -1
  64. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  65. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  66. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  67. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  68. package/views/3d/webgl-engine/lib/Camera.js +1 -1
  69. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  70. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  71. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  72. package/views/3d/webgl-engine/lib/glUtil3D.js +1 -1
  73. package/views/draw/DrawGraphicTool.js +1 -1
  74. package/views/interactive/AnalysisToolBase.js +1 -1
  75. package/views/interactive/tooltip/Tooltip.js +1 -1
  76. package/views/interactive/tooltip/content/TooltipContent.js +1 -1
  77. package/views/layers/DimensionLayerView.js +1 -1
  78. package/views/webgl/Program.js +1 -1
  79. package/widgets/BasemapLayerList.js +1 -1
  80. package/widgets/DirectionalPad/DirectionalPadViewModel.d.ts +4 -0
  81. package/widgets/DirectionalPad.d.ts +4 -0
  82. package/widgets/Directions/css.js +1 -1
  83. package/widgets/Directions.js +1 -1
  84. package/widgets/ElevationProfile/ElevationProfileLineView.js +1 -1
  85. package/widgets/FeatureTable/FieldColumn.js +1 -1
  86. package/widgets/FeatureTable/Grid/Column.js +1 -1
  87. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  88. package/widgets/Features/FeaturesViewModel.js +1 -1
  89. package/widgets/LayerList/support/layerListUtils.js +1 -1
  90. package/widgets/LayerList.js +1 -1
  91. package/widgets/TableList.js +1 -1
  92. package/widgets/support/AnchorElementViewModel.js +1 -1
  93. package/assets/esri/core/workers/chunks/4051e70c2d25c5bea933.js +0 -1
  94. package/assets/esri/core/workers/chunks/5730e14c706a1e4e57d3.js +0 -1
  95. package/assets/esri/core/workers/chunks/5db76bdc4916d11cbcfe.js +0 -1
  96. package/assets/esri/core/workers/chunks/642e652bf21a7fa463c9.js +0 -1
  97. package/assets/esri/core/workers/chunks/67e4bec7950f09ffe4a7.js +0 -1
  98. package/assets/esri/core/workers/chunks/8407cf549c0c59a206f1.js +0 -1
  99. package/assets/esri/core/workers/chunks/f11896da4989806a66ce.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../../core/has.js";import e from"../../../../../core/Logger.js";import t from"../../../../../core/PooledArray.js";import{isArray as o}from"../../../../../core/typedArrayUtil.js";import{invert as r,transpose as n}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{a as s,x as a,t as l}from"../../../../../chunks/vec32.js";import{clone as m,create as c}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{compactIndices as f}from"../../../../../geometry/support/Indices.js";import{b as p}from"../../../../../chunks/vec3.js";import{c as h}from"../../../../../chunks/vec33.js";import{ViewingMode as u}from"../../../../ViewingMode.js";import{ColorMixModeEnum as d,encodeSymbolColor as g}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as b}from"../../../support/orientedBoundingBox.js";import{glLayout as y}from"../../../support/buffer/glUtil.js";import{newLayout as C}from"../../../support/buffer/InterleavedLayout.js";import j from"./ComponentData.js";import{ComponentObject as v}from"./ComponentObject.js";import _ from"./IntersectionGeometry.js";import{Renderable as w}from"./Renderable.js";import{RenderGeometry as M}from"./RenderGeometry.js";import{RenderSubmitSystem as x}from"./RenderSubmitSystem.js";import{createVertexBufferLayout as O}from"./SourceGeometry.js";import{UniformComponentParameters as A}from"./UniformComponentParameters.js";import{ComponentParametersVarying as D,ComponentParametersUniform as S,ComponentParameterSummary as I,ComponentMaterial as P}from"./Material/ComponentMaterial.js";import{attributeLocations as U}from"./Material/ComponentTechnique.js";import{encodeElevationOffset as E}from"./Material/shader/ComponentData.glsl.js";import{getVisibility as R,updateVisibilityWithCount as B}from"../../lib/ComponentUtils.js";import{assert as T}from"../../lib/Util.js";import{VertexAttribute as L}from"../../lib/VertexAttribute.js";import{getVerticalOffsetI3S as V}from"../../lib/verticalOffsetUtils.js";import{EdgeInputBufferLayout as G}from"../../lib/edgeRendering/bufferLayouts.js";import{extractComponentsEdgeLocationsLayout as k}from"../../lib/edgeRendering/edgeProcessing.js";import{BufferManager as N}from"../../lib/TextureBackedBuffer/BufferManager.js";import{BufferObject as q}from"../../../../webgl/BufferObject.js";import{Usage as H,PrimitiveType as W}from"../../../../webgl/enums.js";import{VertexArrayObject as X}from"../../../../webgl/VertexArrayObject.js";const Y=()=>e.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");class z{constructor(e,o){this._renderManager=e,this._viewingMode=o,this._visible=new t,this._hidden=new t,this._renderSubmit=new x(this),this._renderManager.register(this._renderSubmit),this._hasObjectAndLayerId=has("enable-feature:objectAndLayerId-rendering"),this._componentBufferManager=new N(e.rctx,2+(this._hasObjectAndLayerId?1:0))}destroy(){T(0===this._hidden.length&&0===this._visible.length,"ObjectCollection should be empty upon disposal"),this._componentBufferManager.destroy(),this._visible.forAll((e=>e.destroy())),this._hidden.forAll((e=>e.destroy())),this._visible.clear(),this._hidden.clear()}createObject(e){const t=new v;t.toMapSpace=e.toMapSpace,t.transform=e.transform,t.obb=e.obb.clone(),t.components=new j(this._componentBufferManager,f(e.geometry.componentOffsets)),t.renderable=this._createRenderable(e,t.components),t.intersectionGeometry=new _(e.geometry.positionData,t.components);return(t.visible?this._visible:this._hidden).push(t),t}destroyObject(e){const t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._notifyDirty()}setObjectVisibility(e,t){const o=e;t!==o.visible&&(t?(this._hidden.removeUnordered(o),this._visible.push(o)):(this._visible.removeUnordered(o),this._hidden.push(o)),o.visible=t,this._notifyDirty())}preSubmit(e){const t=e.camera.eye;this.visibleObjects.forAll((e=>e.renderable.meta.cameraDepthSquared=s(t,e.obb.center)))}getMaterial(e){return e.renderable.material}updateMaterial(e,t){const o=e.renderable.material;t(o),o.dirty&&this._notifyDirty()}setAllComponentVisibilities(e,t){const o=e;o.components.visibility.reset(t),o.components.visibilityDirty(),this._notifyDirty()}forEachVisibleComponent(e,t){return e.components.visibility.forEachComponent(t)}getComponentCount(e){const t=e,o=t.components.visibility.componentCount();return{visible:o,invisible:t.components.count-o}}setComponentData(e,t){const o=e,r=o.renderable.material,n=o.components,i=n.materialDataBuffer,s=n.materialDataIndices,a=new A,l=i.textureBuffer,m=new Uint8Array(4),c=new Uint32Array(m.buffer);let f=0,p=0,h=0,u=n.verticalOffsets,y=1/0,C=-1/0,j=!1,v=!1,_=0;for(let b=0;b<n.count;b++){t(b,a),f+=+(a.externalColor[3]<1),p+=+(a.externalColorMixMode===d.Replace&&1===a.externalColor[3]),h+=+a.castShadows,g(a.externalColor,a.externalColorMixMode,m),m[2]=254&m[2]|+a.castShadows,l.setData(s[b],0,m[0],m[1],m[2],m[3]),j||=b>0&&_!==c[0],_=c[0],v||=0!==a.elevationOffset,v&&null==u&&(u=new Array(b).fill(0)),null!=u&&(u[b]=a.elevationOffset),y=Math.min(y,a.elevationOffset),C=Math.max(C,a.elevationOffset),E(a.elevationOffset,m),l.setData(s[b],1,m[0],m[1],m[2],m[3]);const e=a.objectAndLayerIdColor;null!=e&&l.setData(s[b],2,e[0],e[1],e[2],e[3]),a.pickable!==R(n.pickability,b)&&(n.pickability=B(n.pickability,n.count,b,a.pickable))}n.verticalOffsets=v?u:null,o.offsetObb=v?b(o.obb,y,C,this._viewingMode,o.offsetObb??o.obb.clone()):null,j||v||this._hasObjectAndLayerId?(r.componentParameters=new D,r.componentParameters.castShadows=J(h,n.count),r.componentParameters.transparent=J(f,n.count),r.componentParameters.opaqueOverride=J(p,n.count),r.componentParameters.texture=l,l.updateTexture()):(r.componentParameters=new S,r.componentParameters.castShadows=a.castShadows?I.All:I.None,r.componentParameters.externalColor=a.externalColor,r.componentParameters.externalColorMixMode=a.externalColorMixMode),this._notifyDirty()}getComponentAabb(e,t,o,r=!1){e.intersectionGeometry.getComponentAabb(t,o);const n=e,i=n.components.verticalOffsets;if(r||null==i)return o;const s=i[t];if(this._viewingMode===u.Local||0===s)return o[2]+=s,o[5]+=s,o;const a=V(s);return a.localOrigin=n.transform.position,a.applyToAabb(o)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,o){return e.intersectionGeometry.getComponentPositions(t,o)}intersect(e,t,o,i,s,m){const c=e;null!=s&&(s.localOrigin=c.transform.position);const f=r(K,c.transform.rotationScale);a(Q,t,c.transform.position),a(Z,o,c.transform.position),l(Q,Q,f),l(Z,Z,f);const p=n(K,f);return c.intersectionGeometry.intersect(Q,Z,i,p,s,c.components.verticalOffsets,m)}addEdges(e,t,o,r){const n=e,{indices:i,positions:s}=n.intersectionGeometry,a=n.components.offsets;return t.addComponentObject(n,s,i,a,o,r)}async extractEdgeInformation(e,t,o){const r=e,n=r.components.visibility;if(n.allInvisible())return{buffer:k.createBuffer(0),origin:[0,0,0]};const{indices:i,positions:s}=r.intersectionGeometry,a=r.components.offsets,l=G.createBuffer(s.length/3);h(l.position.typedBuffer,s,l.position.typedBufferStride,3),p(l.position,l.position,r.transform.rotationScale),this._setComponentIndices(l.componentIndex,i,a);const c=l.count,f=this._computeVisibilityIndices(i,n,a,c);return{origin:m(r.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:f,indicesLength:f.length,skipDeduplicate:!0,data:l,writerSettings:{reducedPrecision:!1,variants:0}},o)}}_setComponentIndices(e,t,o){let r=0;for(let n=0;n<o.length-1;n++){const i=o[n],s=o[n+1];for(let o=i;o<s;o++){const n=t?t[o]:o;e.set(n,r)}r++}}_computeVisibilityIndices(e,t,r,n){if(e&&t.allVisible())return e;let i=0;t.forEachComponentRange(((e,t)=>(i+=r[t]-r[e],!0)));const s=o(e)?new Array(i):2===e?.BYTES_PER_ELEMENT||n<=65536?new Uint16Array(i):new Uint32Array(i);let a=0;return t.forEachComponentRange(((t,o)=>{const n=r[t],i=r[o];for(let r=n;r<i;r++)s[a++]=e?e[r]:r;return!0})),s}addComponentHighlight(e,t){const o=e.components;null==o.highlightCounts&&(o.highlightCounts=new Uint32Array(o.count+1));0===o.highlightCounts[t]++&&(o.highlightsDirty(),this._notifyDirty()),o.highlightCounts[o.count]++}removeComponentHighlight(e,t){const o=e.components;if(null==o.highlightCounts)return void Y().warn("Removing non-existing highlight.");const r=o.highlightCounts[t],n=o.highlightCounts[o.count];if(0!==r){if(r>1)return o.highlightCounts[t]=r-1,void(o.highlightCounts[o.count]=n-1);o.highlightCounts[t]=0,o.highlightsDirty(),this._notifyDirty(),1===n?o.highlightCounts=null:o.highlightCounts[o.count]=n-1}else Y().warn("Removing non-existing highlight.")}clearHighlights(e){const t=e.components;null!=t.highlightCounts&&(t.highlightCounts=null,t.highlightsDirty(),this._notifyDirty())}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t){const o=this._renderManager.rctx,r=e.geometry,n=r.vertices.layoutParameters,i=q.createVertex(o,H.STATIC_DRAW,r.vertices.data),s=r.indices?q.createIndex(o,H.STATIC_DRAW,r.indices):null,a=y(O(n)),l=new Uint16Array(r.vertices.count);for(let u=0;u<t.count;u++){const e=t.offsets[u],o=t.offsets[u+1],n=t.materialDataIndices[u];if(null!=r.indices)for(let t=e;t<o;t++){l[r.indices[t]]=n}else for(let t=e;t<o;t++)l[t]=n}const m=q.createVertex(o,H.STATIC_DRAW,l.buffer),c=new P(e.transform,e.toMapSpace),f=new X(o,U,{data:a,componentIndices:F},{data:i,componentIndices:m},s),p=new M(f,W.TRIANGLES,n,null!=s),h={cameraDepthSquared:.5,gpuMemoryEstimate:i.usedMemory+m.usedMemory+(null!=s?s.usedMemory:0)};return new w(c,p,h)}_notifyDirty(){this._renderManager.notifyDirty()}}const F=y(C().u16(L.COMPONENTINDEX));function J(e,t){return e===t?I.All:0===e?I.None:I.Some}const K=i(),Q=c(),Z=c();export{z as ComponentObjectCollection};
5
+ import has from"../../../../../core/has.js";import e from"../../../../../core/Logger.js";import t from"../../../../../core/PooledArray.js";import{isArray as o}from"../../../../../core/typedArrayUtil.js";import{invert as r,transpose as n}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{a as s,x as a,t as l}from"../../../../../chunks/vec32.js";import{clone as m,create as c}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{compactIndices as f}from"../../../../../geometry/support/Indices.js";import{b as p}from"../../../../../chunks/vec3.js";import{c as h}from"../../../../../chunks/vec33.js";import{ViewingMode as u}from"../../../../ViewingMode.js";import{ColorMixModeEnum as d,encodeSymbolColor as g}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as b}from"../../../support/orientedBoundingBox.js";import{glLayout as y}from"../../../support/buffer/glUtil.js";import{newLayout as C}from"../../../support/buffer/InterleavedLayout.js";import j from"./ComponentData.js";import{ComponentObject as v}from"./ComponentObject.js";import _ from"./IntersectionGeometry.js";import{Renderable as w}from"./Renderable.js";import{RenderGeometry as M}from"./RenderGeometry.js";import{RenderSubmitSystem as x}from"./RenderSubmitSystem.js";import{createVertexBufferLayout as O}from"./SourceGeometry.js";import{UniformComponentParameters as A}from"./UniformComponentParameters.js";import{ComponentParametersVarying as D,ComponentParametersUniform as S,ComponentParameterSummary as I,ComponentMaterial as P}from"./Material/ComponentMaterial.js";import{attributeLocations as U}from"./Material/ComponentTechnique.js";import{encodeElevationOffset as E}from"./Material/shader/ComponentData.glsl.js";import{getVisibility as R,updateVisibilityWithCount as B}from"../../lib/ComponentUtils.js";import{assert as T}from"../../lib/Util.js";import{VertexAttribute as L}from"../../lib/VertexAttribute.js";import{getVerticalOffsetI3S as V}from"../../lib/verticalOffsetUtils.js";import{EdgeInputBufferLayout as G}from"../../lib/edgeRendering/bufferLayouts.js";import{extractComponentsEdgeLocationsLayout as k}from"../../lib/edgeRendering/edgeProcessing.js";import{BufferManager as N}from"../../lib/TextureBackedBuffer/BufferManager.js";import{BufferObject as q}from"../../../../webgl/BufferObject.js";import{Usage as H,PrimitiveType as W}from"../../../../webgl/enums.js";import{VertexArrayObject as X}from"../../../../webgl/VertexArrayObject.js";const Y=()=>e.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");class z{constructor(e,o){this._renderManager=e,this._viewingMode=o,this._visible=new t,this._hidden=new t,this._renderSubmit=new x(this),this._renderManager.register(this._renderSubmit),this._hasObjectAndLayerId=has("enable-feature:objectAndLayerId-rendering"),this._componentBufferManager=new N(e.rctx,2+(this._hasObjectAndLayerId?1:0))}destroy(){T(0===this._hidden.length&&0===this._visible.length,"ObjectCollection should be empty upon disposal"),this._componentBufferManager.destroy(),this._visible.forAll((e=>e.destroy())),this._hidden.forAll((e=>e.destroy())),this._visible.clear(),this._hidden.clear()}createObject(e){const t=new v;t.toMapSpace=e.toMapSpace,t.transform=e.transform,t.obb=e.obb.clone(),t.components=new j(this._componentBufferManager,f(e.geometry.componentOffsets)),t.renderable=this._createRenderable(e,t.components),t.intersectionGeometry=new _(e.geometry.positionData,t.components);return(t.visible?this._visible:this._hidden).push(t),t}destroyObject(e){const t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._notifyDirty()}setObjectVisibility(e,t){const o=e;t!==o.visible&&(t?(this._hidden.removeUnordered(o),this._visible.push(o)):(this._visible.removeUnordered(o),this._hidden.push(o)),o.visible=t,this._notifyDirty())}preSubmit(e){const t=e.camera.eye;this.visibleObjects.forAll((e=>e.renderable.meta.cameraDepthSquared=s(t,e.obb.center)))}getMaterial(e){return e.renderable.material}updateMaterial(e,t){const o=e.renderable.material;t(o),o.dirty&&this._notifyDirty()}setAllComponentVisibilities(e,t){const o=e;o.components.visibility.reset(t),o.components.visibilityDirty(),this._notifyDirty()}forEachVisibleComponent(e,t){return e.components.visibility.forEachComponent(t)}getComponentCount(e){const t=e,o=t.components.visibility.componentCount();return{visible:o,invisible:t.components.count-o}}setComponentData(e,t){const o=e,r=o.renderable.material,n=o.components,i=n.materialDataBuffer,s=n.materialDataIndices,a=new A,l=i.textureBuffer,m=new Uint8Array(4),c=new Uint32Array(m.buffer);let f=0,p=0,h=0,u=n.verticalOffsets,y=1/0,C=-1/0,j=!1,v=!1,_=0;for(let b=0;b<n.count;b++){t(b,a),f+=+(a.externalColor[3]<1),p+=+(a.externalColorMixMode===d.Replace&&1===a.externalColor[3]),h+=+a.castShadows,g(a.externalColor,a.externalColorMixMode,m),m[2]=254&m[2]|+a.castShadows,l.setData(s[b],0,m[0],m[1],m[2],m[3]),j||=b>0&&_!==c[0],_=c[0],v||=0!==a.elevationOffset,v&&null==u&&(u=new Array(b).fill(0)),null!=u&&(u[b]=a.elevationOffset),y=Math.min(y,a.elevationOffset),C=Math.max(C,a.elevationOffset),E(a.elevationOffset,m),l.setData(s[b],1,m[0],m[1],m[2],m[3]);const e=a.objectAndLayerIdColor;null!=e&&l.setData(s[b],2,e[0],e[1],e[2],e[3]),a.pickable!==R(n.pickability,b)&&(n.pickability=B(n.pickability,n.count,b,a.pickable))}n.verticalOffsets=v?u:null,o.offsetObb=v?b(o.obb,y,C,this._viewingMode,o.offsetObb??o.obb.clone()):null,j||v||this._hasObjectAndLayerId?(r.componentParameters=new D,r.componentParameters.castShadows=J(h,n.count),r.componentParameters.transparent=J(f,n.count),r.componentParameters.opaqueOverride=J(p,n.count),r.componentParameters.texture=l,l.updateTexture()):(r.componentParameters=new S,r.componentParameters.castShadows=a.castShadows?I.All:I.None,r.componentParameters.externalColor=a.externalColor,r.componentParameters.externalColorMixMode=a.externalColorMixMode),this._notifyDirty()}getComponentAabb(e,t,o,r=!1){e.intersectionGeometry.getComponentAabb(t,o);const n=e,i=n.components.verticalOffsets;if(r||null==i)return o;const s=i[t];if(this._viewingMode===u.Local||0===s)return o[2]+=s,o[5]+=s,o;const a=V(s);return a.localOrigin=n.transform.position,a.applyToAabb(o)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,o){return e.intersectionGeometry.getComponentPositions(t,o)}intersect(e,t,o,i,s,m,c){const f=e;null!=s&&(s.localOrigin=f.transform.position);const p=r(K,f.transform.rotationScale);a(Q,t,f.transform.position),a(Z,o,f.transform.position),l(Q,Q,p),l(Z,Z,p);const h=n(K,p);return f.intersectionGeometry.intersect(Q,Z,i,h,s,f.components.verticalOffsets,m,c)}addEdges(e,t,o,r){const n=e,{indices:i,positions:s}=n.intersectionGeometry,a=n.components.offsets;return t.addComponentObject(n,s,i,a,o,r)}async extractEdgeInformation(e,t,o){const r=e,n=r.components.visibility;if(n.allInvisible())return{buffer:k.createBuffer(0),origin:[0,0,0]};const{indices:i,positions:s}=r.intersectionGeometry,a=r.components.offsets,l=G.createBuffer(s.length/3);h(l.position.typedBuffer,s,l.position.typedBufferStride,3),p(l.position,l.position,r.transform.rotationScale),this._setComponentIndices(l.componentIndex,i,a);const c=l.count,f=this._computeVisibilityIndices(i,n,a,c);return{origin:m(r.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:f,indicesLength:f.length,skipDeduplicate:!0,data:l,writerSettings:{reducedPrecision:!1,variants:0}},o)}}_setComponentIndices(e,t,o){let r=0;for(let n=0;n<o.length-1;n++){const i=o[n],s=o[n+1];for(let o=i;o<s;o++){const n=t?t[o]:o;e.set(n,r)}r++}}_computeVisibilityIndices(e,t,r,n){if(e&&t.allVisible())return e;let i=0;t.forEachComponentRange(((e,t)=>(i+=r[t]-r[e],!0)));const s=o(e)?new Array(i):2===e?.BYTES_PER_ELEMENT||n<=65536?new Uint16Array(i):new Uint32Array(i);let a=0;return t.forEachComponentRange(((t,o)=>{const n=r[t],i=r[o];for(let r=n;r<i;r++)s[a++]=e?e[r]:r;return!0})),s}addComponentHighlight(e,t){const o=e.components;null==o.highlightCounts&&(o.highlightCounts=new Uint32Array(o.count+1));0===o.highlightCounts[t]++&&(o.highlightsDirty(),this._notifyDirty()),o.highlightCounts[o.count]++}removeComponentHighlight(e,t){const o=e.components;if(null==o.highlightCounts)return void Y().warn("Removing non-existing highlight.");const r=o.highlightCounts[t],n=o.highlightCounts[o.count];if(0!==r){if(r>1)return o.highlightCounts[t]=r-1,void(o.highlightCounts[o.count]=n-1);o.highlightCounts[t]=0,o.highlightsDirty(),this._notifyDirty(),1===n?o.highlightCounts=null:o.highlightCounts[o.count]=n-1}else Y().warn("Removing non-existing highlight.")}clearHighlights(e){const t=e.components;null!=t.highlightCounts&&(t.highlightCounts=null,t.highlightsDirty(),this._notifyDirty())}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t){const o=this._renderManager.rctx,r=e.geometry,n=r.vertices.layoutParameters,i=q.createVertex(o,H.STATIC_DRAW,r.vertices.data),s=r.indices?q.createIndex(o,H.STATIC_DRAW,r.indices):null,a=y(O(n)),l=new Uint16Array(r.vertices.count);for(let u=0;u<t.count;u++){const e=t.offsets[u],o=t.offsets[u+1],n=t.materialDataIndices[u];if(null!=r.indices)for(let t=e;t<o;t++){l[r.indices[t]]=n}else for(let t=e;t<o;t++)l[t]=n}const m=q.createVertex(o,H.STATIC_DRAW,l.buffer),c=new P(e.transform,e.toMapSpace),f=new X(o,U,{data:a,componentIndices:F},{data:i,componentIndices:m},s),p=new M(f,W.TRIANGLES,n,null!=s),h={cameraDepthSquared:.5,gpuMemoryEstimate:i.usedMemory+m.usedMemory+(null!=s?s.usedMemory:0)};return new w(c,p,h)}_notifyDirty(){this._renderManager.notifyDirty()}}const F=y(C().u16(L.COMPONENTINDEX));function J(e,t){return e===t?I.All:0===e?I.None:I.Some}const K=i(),Q=c(),Z=c();export{z as ComponentObjectCollection};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{t}from"../../../../../chunks/vec32.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as n}from"../../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as s}from"../../../../../geometry/support/FloatArray.js";import{compactIndices as i,getContinuousIndexArray as e}from"../../../../../geometry/support/Indices.js";import{componentMinimalSizeForIntersectionData as r,ComponentIntersectionData as p}from"./ComponentIntersectionData.js";import{Vertices as c}from"../../lib/Attribute.js";import{getVisibility as m}from"../../lib/ComponentUtils.js";import{computeInvDir as a,intersectAabbInvDir as h,intersectTriangles as l}from"../../materials/internal/MaterialUtil.js";class _{constructor(t,o){this._components=o,this._indices=t.indices?i(t.indices):e(t.positions.length/3),this._positions=t.positions,this._componentIntersectionData=new Array(o.count)}destroy(){this._positions=null,this._indices=null,this._componentIntersectionData.length=0,this._perComponentAabbs=null}getComponentAabb(t,o){this._perComponentAabbs||(this._perComponentAabbs=this._computePerComponentAabbs());for(let n=0;n<6;n++)o[n]=this._perComponentAabbs[6*t+n];return o}getComponentPositions(t,o){o.indices=this._indices,o.data=this._positions,o.stride=3,o.startIndex=this._components.offsets[t],o.endIndex=this._components.offsets[t+1]}intersect(o,n,s,i,e,_,b){const d=new c(this._positions,3),g=this._indices,A=this._components.offsets,C=a(o,n,f),y=o[2],j=n[2];this._components.visibility.forEachComponent((c=>{if(!m(this._components.pickability,c))return!0;const a=this.getComponentAabb(c,u);if(null!=_){const t=_[c];null!=e?e.componentOffset=t:(o[2]=y-t,n[2]=j-t)}if(null!=e&&e.applyToAabb(a),!h(a,o,C,s))return!0;const f=A[c]/3,I=A[c+1]/3,x=(o,n,s)=>b(c,o,t(n,n,i),s);return null==e&&I-f>r?(null==this._componentIntersectionData[c]&&(this._componentIntersectionData[c]=new p(this._indices,f,I,d)),this._componentIntersectionData[c].intersectRay({r0:o,r1:n},x)):l(o,n,f,I,g,d,void 0,e,x),!0}))}_computePerComponentAabbs(){const t=this._components.count,o=s(6*t),n=this._indices,i=this._positions,e=this._components.offsets;let r=0;for(let s=0;s<t;s++){const t=e[s],p=e[s+1];let c=1/0,m=1/0,a=1/0,h=-1/0,l=-1/0,_=-1/0;for(let o=t;o<p;o++){const t=3*n[o],s=i[t],e=i[t+1],r=i[t+2];c=Math.min(c,s),m=Math.min(m,e),a=Math.min(a,r),h=Math.max(h,s),l=Math.max(l,e),_=Math.max(_,r)}o[r++]=c,o[r++]=m,o[r++]=a,o[r++]=h,o[r++]=l,o[r++]=_}return o}get positions(){return this._positions}get indices(){return this._indices}}const f=o(),u=n();export{_ as default};
5
+ import{t}from"../../../../../chunks/vec32.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as n}from"../../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as s}from"../../../../../geometry/support/FloatArray.js";import{compactIndices as i,getContinuousIndexArray as e}from"../../../../../geometry/support/Indices.js";import{componentMinimalSizeForIntersectionData as r,ComponentIntersectionData as p}from"./ComponentIntersectionData.js";import{Vertices as c}from"../../lib/Attribute.js";import{getVisibility as m}from"../../lib/ComponentUtils.js";import{computeInvDir as a,intersectAabbInvDir as h,intersectTriangles as l}from"../../materials/internal/MaterialUtil.js";class _{constructor(t,o){this._components=o,this._indices=t.indices?i(t.indices):e(t.positions.length/3),this._positions=t.positions,this._componentIntersectionData=new Array(o.count)}destroy(){this._positions=null,this._indices=null,this._componentIntersectionData.length=0,this._perComponentAabbs=null}getComponentAabb(t,o){this._perComponentAabbs||(this._perComponentAabbs=this._computePerComponentAabbs());for(let n=0;n<6;n++)o[n]=this._perComponentAabbs[6*t+n];return o}getComponentPositions(t,o){o.indices=this._indices,o.data=this._positions,o.stride=3,o.startIndex=this._components.offsets[t],o.endIndex=this._components.offsets[t+1]}intersect(o,n,s,i,e,_,b,d){const g=new c(this._positions,3),A=this._indices,C=this._components.offsets,y=a(o,n,f),j=o[2],I=n[2];this._components.visibility.forEachComponent((c=>{if(!m(this._components.pickability,c))return!0;const a=this.getComponentAabb(c,u);if(null!=_){const t=_[c];null==e||d?(o[2]=j-t,n[2]=I-t):e.componentOffset=t}if(null==e||d||e.applyToAabb(a),!h(a,o,y,s))return!0;const f=C[c]/3,x=C[c+1]/3,M=(o,n,s)=>b(c,o,t(n,n,i),s);return(null==e||d)&&x-f>r?(null==this._componentIntersectionData[c]&&(this._componentIntersectionData[c]=new p(this._indices,f,x,g)),this._componentIntersectionData[c].intersectRay({r0:o,r1:n},M)):l(o,n,f,x,A,g,void 0,e,M),!0}))}_computePerComponentAabbs(){const t=this._components.count,o=s(6*t),n=this._indices,i=this._positions,e=this._components.offsets;let r=0;for(let s=0;s<t;s++){const t=e[s],p=e[s+1];let c=1/0,m=1/0,a=1/0,h=-1/0,l=-1/0,_=-1/0;for(let o=t;o<p;o++){const t=3*n[o],s=i[t],e=i[t+1],r=i[t+2];c=Math.min(c,s),m=Math.min(m,e),a=Math.min(a,r),h=Math.max(h,s),l=Math.max(l,e),_=Math.max(_,r)}o[r++]=c,o[r++]=m,o[r++]=a,o[r++]=h,o[r++]=l,o[r++]=_}return o}get positions(){return this._positions}get indices(){return this._indices}}const f=o(),u=n();export{_ as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{releaseMaybe as e}from"../../../../core/maybe.js";import{FBOPool as t}from"./FBOPool.js";import{PixelFormat as r,SizedPixelFormat as h,TextureWrapMode as s,PixelType as a,TextureSamplingMode as o,RenderbufferFormat as i,ColorAttachment as c,DepthStencilAttachment as n}from"../../../webgl/enums.js";import{FramebufferObject as l}from"../../../webgl/FramebufferObject.js";import{Renderbuffer as d}from"../../../webgl/Renderbuffer.js";import{RenderbufferDescriptor as u}from"../../../webgl/RenderbufferDescriptor.js";import{Texture as _}from"../../../webgl/Texture.js";import{TextureDescriptor as p}from"../../../webgl/TextureDescriptor.js";class m{constructor(e){this.rctx=e,this._acquired=new Set,this._cache=new t(e.newCache,"FBOCache"),this._depthCache=new t(e.newCache,"DepthAttachmentCache"),this._colorCache=new t(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.debugCallback()}frameEnd(){const e=this.debugCallback;e&&this._acquired.forEach((t=>t.type===T.FBO&&e(t.name,t.fbo)))}get usedMemory(){return Array.from(this._acquired.values()).reduce(((e,t)=>e+("colorTexture"in t?t.colorTexture?.usedMemory??0:t.usedMemory)),this._cache.usedMemory+this._colorCache.usedMemory+this._depthCache.usedMemory)}set interactive(e){this._cache.interactive=this._colorCache.interactive=this._depthCache.interactive=e}acquire(e,t,r,h){const s=D(e,t,r);let a=this._cache.pop(s);return a?a.retain():a=new E(s,h,new l(this.rctx,{...P[e],width:t,height:r}),(e=>(a.releaseDepth(),a.depth=this._acquireDepth(e,a.fbo.width,a.fbo.height,`${a.name} depth`),a.fbo.attachDepthStencil(a.depth.attachment),a)),((e,h)=>{const s=this._acquireColor(e,t,r,`${a.name} color ${h}`);return a.colors??=new Map,a.colors.set(h,s),a.fbo.attachColorTexture(s.attachment,h),a})),a.name=h,a.release=()=>{a.dereference((()=>{this.debugCallback&&this.debugCallback(a.name,a.fbo),this._acquired.delete(a),a.releaseDepth(),this._cache.put(a),a.release=()=>console.log(`Double FBO release in ${(new Error).stack}`)}))},this.rctx.unbindTexture(a.fbo.colorTexture),this.rctx.bindFramebuffer(a.fbo),this._trackHandle(a)}acquireDepth(e,t,r,h){return this._acquireDepth(e,t,r,h)}_acquireDepth(e,t,r,h){const s=D(e,t,r),a=this._depthCache.pop(s);if(a)return a.name=h,this._trackHandle(a);const o=e===y.DEPTH_STENCIL_TEXTURE?new R(s,new _(this.rctx,{...B[e],width:t,height:r}),(()=>{this._acquired.delete(o),this._depthCache.put(o)})):new R(s,new d(this.rctx,{...B[e],width:t,height:r}),(()=>{this._acquired.delete(o),this._depthCache.put(o)}));return o.name=h,this._trackHandle(o)}_acquireColor(e,t,r,h){const s=D(e,t,r),a=this._colorCache.pop(s);if(a)return a.name=h,this._trackHandle(a);const o=new b(s,new _(this.rctx,{...P[e],width:t,height:r}),(()=>{this._acquired.delete(o),this._colorCache.put(o)}));return o.name=h,this._trackHandle(o)}_trackHandle(e){return this._acquired.add(e),e}}var T,C;!function(e){e[e.FBO=0]="FBO",e[e.DEPTH=1]="DEPTH",e[e.COLOR=2]="COLOR"}(T||(T={}));class E{constructor(e,t,r,h,s){this.key=e,this.name=t,this.fbo=r,this.acquireDepth=h,this.acquireColor=s,this.type=T.FBO,this._refCount=1,this.release=()=>{},this.incarnation=0}dispose(){this.fbo.dispose()}retain(){++this._refCount}dereference(e){--this._refCount,0===this._refCount&&e()}releaseDepth(){this.fbo.detachDepthStencilTexture(),this.fbo.detachDepthStencilBuffer(),this.depth=e(this.depth)}detachDepth(){const e=this.depth;return this.depth=void 0,this.fbo.detachDepthStencilTexture(),this.fbo.detachDepthStencilBuffer(),e}attachDepth(e){return this.releaseDepth(),e&&(this.fbo.attachDepthStencil(e.attachment),this.depth=e),this}releaseColor(t){this.fbo.detachColorTexture(t);const r=this.colors?.get(t);this.colors?.delete(t),e(r)}get colorTexture(){return this.fbo?.colorTexture}getColorTexture(e=c.COLOR_ATTACHMENT0){return this.fbo?.getColorTexture(e)}getTexture(e=c.COLOR_ATTACHMENT0){return e===n?this.fbo?.depthStencilTexture:this.fbo?.getColorTexture(e)}get usedMemory(){return this.fbo.usedMemory}}class f{constructor(e,t,r){this.key=e,this.attachment=t,this.release=r,this.incarnation=0,this.name=""}dispose(){this.attachment.dispose()}get usedMemory(){return this.attachment.usedMemory}}class R extends f{constructor(){super(...arguments),this.type=T.DEPTH}}class b extends f{constructor(e,t,r){super(e,t,r),this.attachment=t,this.release=r,this.type=T.COLOR}}function D(e,t,r){return`${e}x${t}x${r}`}!function(e){e[e.RED=0]="RED",e[e.RG=1]="RG",e[e.RGBA4=2]="RGBA4",e[e.RGBA=3]="RGBA",e[e.RGBA_MIPMAP=4]="RGBA_MIPMAP",e[e.R16F=5]="R16F",e[e.RGBA16F=6]="RGBA16F"}(C||(C={}));const w=new p;w.pixelFormat=r.RED,w.internalFormat=h.R8,w.wrapMode=s.CLAMP_TO_EDGE;const A=new p;A.pixelFormat=r.RG,A.internalFormat=h.RG8,A.wrapMode=s.CLAMP_TO_EDGE;const M=new p;M.internalFormat=h.RGBA4,M.dataType=a.UNSIGNED_SHORT_4_4_4_4,M.wrapMode=s.CLAMP_TO_EDGE;const F=new p;F.wrapMode=s.CLAMP_TO_EDGE;const x=new p;x.wrapMode=s.CLAMP_TO_EDGE,x.samplingMode=o.LINEAR_MIPMAP_LINEAR,x.hasMipmap=!0,x.maxAnisotropy=8;const g=new p;g.pixelFormat=r.RED,g.dataType=a.HALF_FLOAT,g.internalFormat=h.R16F,g.samplingMode=o.NEAREST;const O=new p;O.dataType=a.HALF_FLOAT,O.internalFormat=h.RGBA16F,O.samplingMode=o.NEAREST;const P={[C.RED]:w,[C.RG]:A,[C.RGBA4]:M,[C.RGBA]:F,[C.RGBA_MIPMAP]:x,[C.R16F]:g,[C.RGBA16F]:O};var y;!function(e){e[e.DEPTH_STENCIL_TEXTURE=0]="DEPTH_STENCIL_TEXTURE",e[e.DEPTH16_BUFFER=1]="DEPTH16_BUFFER"}(y||(y={}));const G=new p;G.pixelFormat=r.DEPTH_STENCIL,G.dataType=a.UNSIGNED_INT_24_8,G.samplingMode=o.NEAREST,G.wrapMode=s.CLAMP_TO_EDGE;const B={[y.DEPTH_STENCIL_TEXTURE]:G,[y.DEPTH16_BUFFER]:new u(i.DEPTH_COMPONENT16,4)};export{C as ColorFormat,y as DepthFormat,m as FBOCache};
5
+ import{releaseMaybe as e}from"../../../../core/maybe.js";import{FBOPool as t}from"./FBOPool.js";import{PixelFormat as r,SizedPixelFormat as h,TextureWrapMode as s,PixelType as a,TextureSamplingMode as o,RenderbufferFormat as i,ColorAttachment as c,DepthStencilAttachment as n}from"../../../webgl/enums.js";import{FramebufferObject as l}from"../../../webgl/FramebufferObject.js";import{Renderbuffer as d}from"../../../webgl/Renderbuffer.js";import{RenderbufferDescriptor as u}from"../../../webgl/RenderbufferDescriptor.js";import{Texture as _}from"../../../webgl/Texture.js";import{TextureDescriptor as p}from"../../../webgl/TextureDescriptor.js";class m{constructor(e){this.rctx=e,this._acquired=new Set,this._cache=new t(e.newCache,"FBOCache"),this._depthCache=new t(e.newCache,"DepthAttachmentCache"),this._colorCache=new t(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.debugCallback()}frameEnd(){const e=this.debugCallback;e&&this._acquired.forEach((t=>t.type===T.FBO&&e(t.name,t.fbo)))}get usedMemory(){return Array.from(this._acquired.values()).reduce(((e,t)=>e+("colorTexture"in t?t.colorTexture?.usedMemory??0:t.usedMemory)),this._cache.usedMemory+this._colorCache.usedMemory+this._depthCache.usedMemory)}set interactive(e){this._cache.interactive=this._colorCache.interactive=this._depthCache.interactive=e}acquire(e,t,r,h=C.RGBA){const s=D(h,e,t);let a=this._cache.pop(s);return a?a.retain():a=new E(s,r,new l(this.rctx,{...G[h],width:e,height:t}),(e=>(a.releaseDepth(),a.depth=this._acquireDepth(e,a.fbo.width,a.fbo.height,`${a.name} depth`),a.fbo.attachDepthStencil(a.depth.attachment),a)),((r,h)=>{const s=this._acquireColor(r,e,t,`${a.name} color ${h}`);return a.colors??=new Map,a.colors.set(h,s),a.fbo.attachColorTexture(s.attachment,h),a})),a.name=r,a.release=()=>{a.dereference((()=>{this.debugCallback&&this.debugCallback(a.name,a.fbo),this._acquired.delete(a),a.releaseDepth(),a.colors?.forEach(((e,t)=>a.releaseColor(t))),this._cache.put(a),a.release=()=>console.log(`Double FBO release in ${(new Error).stack}`)}))},this.rctx.unbindTexture(a.fbo.colorTexture),this.rctx.bindFramebuffer(a.fbo),this._trackHandle(a)}acquireDepth(e,t,r,h){return this._acquireDepth(e,t,r,h)}_acquireDepth(e,t,r,h){const s=D(e,t,r),a=this._depthCache.pop(s);if(a)return a.name=h,this._trackHandle(a);const o=e===P.DEPTH_STENCIL_TEXTURE?new R(s,new _(this.rctx,{...B[e],width:t,height:r}),(()=>{this._acquired.delete(o),this._depthCache.put(o)})):new R(s,new d(this.rctx,{...B[e],width:t,height:r}),(()=>{this._acquired.delete(o),this._depthCache.put(o)}));return o.name=h,this._trackHandle(o)}_acquireColor(e,t,r,h){const s=D(e,t,r),a=this._colorCache.pop(s);if(a)return a.name=h,this._trackHandle(a);const o=new b(s,new _(this.rctx,{...G[e],width:t,height:r}),(()=>{this._acquired.delete(o),this._colorCache.put(o)}));return o.name=h,this._trackHandle(o)}_trackHandle(e){return this._acquired.add(e),e}}var T,C;!function(e){e[e.FBO=0]="FBO",e[e.DEPTH=1]="DEPTH",e[e.COLOR=2]="COLOR"}(T||(T={}));class E{constructor(e,t,r,h,s){this.key=e,this.name=t,this.fbo=r,this.acquireDepth=h,this.acquireColor=s,this.type=T.FBO,this._refCount=1,this.release=()=>{},this.incarnation=0}dispose(){this.fbo.dispose()}retain(){++this._refCount}dereference(e){--this._refCount,0===this._refCount&&e()}releaseDepth(){this.fbo.detachDepthStencilTexture(),this.fbo.detachDepthStencilBuffer(),this.depth=e(this.depth)}detachDepth(){const e=this.depth;return this.depth=void 0,this.fbo.detachDepthStencilTexture(),this.fbo.detachDepthStencilBuffer(),e}attachDepth(e){return this.releaseDepth(),e&&(this.fbo.attachDepthStencil(e.attachment),this.depth=e),this}releaseColor(t){this.fbo.detachColorTexture(t);const r=this.colors?.get(t);this.colors?.delete(t),e(r)}get colorTexture(){return this.fbo?.colorTexture}getColorTexture(e=c.COLOR_ATTACHMENT0){return this.fbo?.getColorTexture(e)}getTexture(e=c.COLOR_ATTACHMENT0){return e===n?this.fbo?.depthStencilTexture:this.fbo?.getColorTexture(e)}get usedMemory(){return this.fbo.usedMemory}}class f{constructor(e,t,r){this.key=e,this.attachment=t,this.release=r,this.incarnation=0,this.name=""}dispose(){this.attachment.dispose()}get usedMemory(){return this.attachment.usedMemory}}class R extends f{constructor(){super(...arguments),this.type=T.DEPTH}}class b extends f{constructor(e,t,r){super(e,t,r),this.attachment=t,this.release=r,this.type=T.COLOR}}function D(e,t,r){return`${e}x${t}x${r}`}!function(e){e[e.RED=0]="RED",e[e.RG=1]="RG",e[e.RGBA4=2]="RGBA4",e[e.RGBA=3]="RGBA",e[e.RGBA_MIPMAP=4]="RGBA_MIPMAP",e[e.R16F=5]="R16F",e[e.RGBA16F=6]="RGBA16F"}(C||(C={}));const w=new p;w.pixelFormat=r.RED,w.internalFormat=h.R8,w.wrapMode=s.CLAMP_TO_EDGE;const A=new p;A.pixelFormat=r.RG,A.internalFormat=h.RG8,A.wrapMode=s.CLAMP_TO_EDGE;const M=new p;M.internalFormat=h.RGBA4,M.dataType=a.UNSIGNED_SHORT_4_4_4_4,M.wrapMode=s.CLAMP_TO_EDGE;const F=new p;F.wrapMode=s.CLAMP_TO_EDGE;const x=new p;x.wrapMode=s.CLAMP_TO_EDGE,x.samplingMode=o.LINEAR_MIPMAP_LINEAR,x.hasMipmap=!0,x.maxAnisotropy=8;const g=new p;g.pixelFormat=r.RED,g.dataType=a.HALF_FLOAT,g.internalFormat=h.R16F,g.samplingMode=o.NEAREST;const O=new p;O.dataType=a.HALF_FLOAT,O.internalFormat=h.RGBA16F,O.samplingMode=o.NEAREST;const G={[C.RED]:w,[C.RG]:A,[C.RGBA4]:M,[C.RGBA]:F,[C.RGBA_MIPMAP]:x,[C.R16F]:g,[C.RGBA16F]:O};var P;!function(e){e[e.DEPTH_STENCIL_TEXTURE=0]="DEPTH_STENCIL_TEXTURE",e[e.DEPTH16_BUFFER=1]="DEPTH16_BUFFER"}(P||(P={}));const y=new p;y.pixelFormat=r.DEPTH_STENCIL,y.dataType=a.UNSIGNED_INT_24_8,y.samplingMode=o.NEAREST,y.wrapMode=s.CLAMP_TO_EDGE;const B={[P.DEPTH_STENCIL_TEXTURE]:y,[P.DEPTH16_BUFFER]:new u(i.DEPTH_COMPONENT16,4)};export{C as ColorFormat,P as DepthFormat,m as FBOCache};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Collection.js";class r{constructor(){this._renderNodes=new e}add(e){this._renderNodes.push(e)}remove(e){const r=this._renderNodes.indexOf(e);this._renderNodes.removeAt(r)?.destroy()}produces(e){return this._renderNodes.some((r=>r.produces.includes(e)))}consumes(e){return this._renderNodes.some((r=>r.consumes.required.includes(e)))}render(e,r){if(!e.composite)return;let s,o=e.composite;return this._renderNodes.filter((e=>e.produces.includes(r))).forEach((n=>{const t=new Array;for(const r of n.consumes.required)switch(r){case"composite-color":t.push(o);break;case"linear-depth":if(!e.linearDepth)return;t.push(e.linearDepth);break;case"normals":if(!e.normals)return;t.push(e.normals);break;case"highlight":if(!e.highlight)return;t.push(e.highlight)}o=n.render(t,r),s?.release(),s=o})),s}}export{r as RenderNodeCollection};
5
+ import e from"../../../../core/Collection.js";class s{constructor(){this._nodes=new e}add(e){this._nodes.push(e)}remove(e){const s=this._nodes.indexOf(e);this._nodes.removeAt(s)?.destroy()}produces(e){return this._nodes.some((s=>s.produces.includes(e)))}consumes(e){return this._nodes.some((s=>s.consumes.required.includes(e)))}render(e,s){if(!e.composite)return;let r,o=e.composite;return this._nodes.filter((e=>e.produces.includes(s))).forEach((n=>{const t=new Array;for(const s of n.consumes.required)switch(s){case"composite-color":t.push(o);break;case"linear-depth":if(!e.linearDepth)return;t.push(e.linearDepth);break;case"normals":if(!e.normals)return;t.push(e.normals);break;case"highlight":if(!e.highlight)return;t.push(e.highlight)}o=n.render(t,s),r?.release(),r=o})),r}}export{s as RenderNodeCollection};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{disposeMaybe as t}from"../../../../core/maybe.js";import{createScreenSizeTriangleVAO as r}from"../lib/glUtil3D.js";import{PrimitiveType as s}from"../../../webgl/enums.js";class e{constructor(t){this._rctx=t,this._vao=r(t)}destroy(){this._vao=t(this._vao)}draw(){null!=this._vao&&(this._rctx.bindVAO(this._vao),this._rctx.drawArrays(s.TRIANGLES,0,3))}get test(){return{cachedWebGLObjects:o(this._vao?.glName)+o(this._vao?.indexBuffer?.glName)+o(this._vao?.vertexBuffers.geometry)}}}function o(t){return null!=t?1:0}export{e as ScreenSpaceGeometry};
5
+ import{disposeMaybe as e}from"../../../../core/maybe.js";import{Default3D as t}from"../lib/DefaultVertexAttributeLocations.js";import{Pos2 as r}from"../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as o}from"../lib/VertexArrayObject.js";import{BufferObject as i}from"../../../webgl/BufferObject.js";import{PrimitiveType as s,Usage as a}from"../../../webgl/enums.js";class c{constructor(e){this._rctx=e,this._vao=this.createScreenSizeTriangleVAO(e)}destroy(){this._vao=e(this._vao)}draw(){null!=this._vao&&(this._rctx.bindVAO(this._vao),this._rctx.drawArrays(s.TRIANGLES,0,3))}get test(){return{cachedWebGLObjects:m(this._vao?.glName)+m(this._vao?.indexBuffer?.glName)+m(this._vao?.vertexBuffers.geometry)}}createScreenSizeTriangleVAO(e,s=r,c=t){const m=new Float32Array([-1,-1,3,-1,-1,3]);return new o(e,c,{geometry:s},{geometry:i.createVertex(e,a.STATIC_DRAW,m)})}}function m(e){return null!=e?1:0}export{c as ScreenSpaceGeometry};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/Logger.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import"../../../../../core/Error.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import o from"../../../effects/RenderNode.js";import{ColorFormat as t}from"../../core/FBOCache.js";import{getProjectionInfo as n,getZScale as i}from"../../core/shaderLibrary/util/CameraSpace.glsl.js";import{Default3D as s}from"../../lib/DefaultVertexAttributeLocations.js";import{ClearBufferBit as a,ColorAttachment as c,BlendFactor as l,SizedPixelFormat as u,PixelFormat as p,DataType as f}from"../../../../webgl/enums.js";var d;!function(e){e[e.ON=0]="ON",e[e.OFF=1]="OFF"}(d||(d={}));let h=class extends o{constructor(){super(...arguments),this.consumes={required:["composite-color"]},this.produces=["composite-color"],this._focusedFBO=null,this._program=new Array}destroy(){this._program.forEach((e=>e.dispose())),this._program.length=0}render(e,r){const o=e.find((({name:e})=>"composite-color"===e))?.getTexture(),n=this.renderCamera,i=this.renderingContext,s=n.fullWidth,c=n.fullHeight,l=this.fboCache.acquire(t.RGBA,s,c,"fbo visualizer");i.setClearColor(0,0,0,0),i.clearSafe(a.COLOR_BUFFER_BIT);const u=this._ensureShader(i,!1);return i.useProgram(u),this.bindTexture(this._focusedFBO?this._focusedFBO.colorTexture:o,0),u.setUniform1i("colorTex",0),u.setUniform1i("inputType",0),i.screen.draw(),l}getReplacingFBO(e,r,o,s,p){r===d.ON&&(s=e.width,p=e.height);const f=this.renderingContext,h=e.depthStencilTexture,m=this._ensureShader(f,null!=h),v=this.fboCache.acquire(t.RGBA,s,p,"fbo visualizer");f.useProgram(m),h&&(v.acquireColor(t.RGBA,c.COLOR_ATTACHMENT1),f.bindFramebuffer(v.fbo),f.capabilities.drawBuffers?.drawBuffers([c.COLOR_ATTACHMENT0,c.COLOR_ATTACHMENT1]),f.bindTexture(h,1),m.setUniform1i("depthTex",1));const T=f.getViewport();f.setViewport(0,0,s,p),f.setClearColor(0,0,0,0),f.clearSafe(a.COLOR_BUFFER_BIT),f.setBlendingEnabled(!0),f.setBlendFunction(l.ONE,l.ONE_MINUS_SRC_ALPHA),f.bindTexture(e.colorTexture,0),m.setUniform1i("colorTex",0);const g=e.colorTexture?.descriptor.internalFormat,F=o.includes("depth")||o.includes("shadow")?3:g===u.R16F||g===u.R32F||g===u.R8?1:g===u.RG8?2:g===u.RGBA16F?4:0;if(m.setUniform1i("inputType",F),o.includes("depth")){const e=this.renderCamera;m.setUniform2fv("nearFar",e.nearFar);const r=n(e);m.setUniform4fv("projInfo",r);const o=i(e);m.setUniform2fv("zScale",o)}return f.screen.draw(),f.capabilities.drawBuffers?.drawBuffers([c.COLOR_ATTACHMENT0]),f.bindFramebuffer(null),f.setViewport(T.x,T.y,T.width,T.height),r===d.ON&&(this._focusedFBO=v),v}clearFocusedFBO(){this._focusedFBO=null}getPreviewContent(e,r,o,n){if(!o)return null;const i=this.renderingContext,s=this.fboCache.acquire(t.RGBA,e,r,"fbo visualizer");i.setClearColor(0,0,0,0),i.clearSafe(a.COLOR_BUFFER_BIT),i.setBlendingEnabled(!0),i.setBlendFunction(l.ONE,l.ONE_MINUS_SRC_ALPHA),i.setViewport(0,0,e,r);const c=this._ensureShader(i,!1);i.useProgram(c),i.bindTexture(o.getColorTexture(n),0),c.setUniform1i("colorTex",0),c.setUniform1i("inputType",0),i.screen.draw();const u=new ImageData(new Uint8ClampedArray(e*r*4),e,r);return i.gl.readPixels(0,0,e,r,p.RGBA,f.UNSIGNED_BYTE,new Uint8Array(u.data.buffer)),i.bindFramebuffer(null),s?.release(),u}_ensureShader(e,r){const o=r?1:0;if(this._program[o])return this._program[o];const t="#version 300 es\n in vec2 position;\n out vec2 uv;\n\n void main() {\n gl_Position = vec4(position, 0.0, 1.0);\n uv = position * 0.5 + vec2(0.5);\n }",n=`#version 300 es\n precision highp float;\n\n in vec2 uv;\n uniform sampler2D colorTex;\n layout(location = 0) out vec4 fragColor;\n ${r?"\n layout(location = 1) out vec4 fragDepth;\n uniform sampler2D depthTex;\n ":""}\n uniform int inputType;\n uniform vec2 nearFar;\n uniform vec4 projInfo;\n uniform vec2 zScale;\n\n // Factors to convert rgba back to float\n const vec4 RGBA_2_FLOAT_FACTORS = vec4(\n 255.0 / (256.0),\n 255.0 / (256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0 * 256.0)\n );\n\n\n float rgba2float(vec4 rgba) {\n // Convert components from 0->1 back to 0->255 and then add the components together with their corresponding\n // fixed point factors, i.e. (256^1, 256^2, 256^3, 256^4)\n return dot(rgba, RGBA_2_FLOAT_FACTORS);\n }\n\n float linearDepthFromFloat(float depth) {\n depth = pow(depth, 0.2);\n return -(depth * (nearFar[1] - nearFar[0]) + nearFar[0]);\n }\n\n float linearDepthFromRGBA(vec4 depth) {\n return linearDepthFromFloat(rgba2float(depth));\n }\n\n float linearDepthFromTexture(sampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(texelFetch(depthTex, iuv, 0));\n }\n\n void main() {\n vec4 color;\n if(inputType == 1) {\n color = vec4(vec3(texture(colorTex, uv).r), 1.0);\n } else if(inputType == 2) {\n color = vec4(texture(colorTex, uv).rg, 0.0, 1.0);\n } else if(inputType == 3) {\n float depth = 1.0 - (-linearDepthFromTexture(colorTex, uv) / (nearFar[1] - nearFar[0]));\n color = vec4(vec3(depth), depth >= 0.999 ? 0.0 : 1.0);\n } else if(inputType == 4) {\n color = texture(colorTex, uv);\n color = vec4(color.rgb / color.a, color.a);\n } else {\n color = texture(colorTex, uv);\n }\n\n\n if(color.a < 0.000001)\n discard;\n else {\n fragColor = color;\n ${r?"\n float depth = 1.0 - pow(texture(depthTex, uv).r, 10.0);\n fragDepth = vec4(vec3(depth), depth < 0.000001 ? 0.0 : 1.0);\n ":""}\n }\n }`;return this._program[o]=e.programCache.acquire(t,n,s),this._program[o]}};h=e([r("esri.views.3d.webgl-engine.effects.debug.RenderNodeVisualizerNode")],h);export{d as FocusState,h as RenderNodeVisualizerNode};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/Logger.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import"../../../../../core/Error.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import o from"../../../effects/RenderNode.js";import{ColorFormat as t}from"../../core/FBOCache.js";import{getProjectionInfo as n,getZScale as i}from"../../core/shaderLibrary/util/CameraSpace.glsl.js";import{Default3D as s}from"../../lib/DefaultVertexAttributeLocations.js";import{ClearBufferBit as a,ColorAttachment as c,BlendFactor as l,SizedPixelFormat as u,PixelFormat as p,DataType as f}from"../../../../webgl/enums.js";var d;!function(e){e[e.ON=0]="ON",e[e.OFF=1]="OFF"}(d||(d={}));let h=class extends o{constructor(){super(...arguments),this.consumes={required:["composite-color"]},this.produces=["composite-color"],this._focusedFBO=null,this._program=new Array}destroy(){this._program.forEach((e=>e.dispose())),this._program.length=0}render(e,r){const o=e.find((({name:e})=>"composite-color"===e))?.getTexture(),t=this.renderCamera,n=this.renderingContext,i=t.fullWidth,s=t.fullHeight,c=this.fboCache.acquire(i,s,"fbo visualizer");n.setClearColor(0,0,0,0),n.clearSafe(a.COLOR_BUFFER_BIT);const l=this._ensureShader(n,!1);return n.useProgram(l),this.bindTexture(this._focusedFBO?this._focusedFBO.colorTexture:o,0),l.setUniform1i("colorTex",0),l.setUniform1i("inputType",0),n.screen.draw(),c}getReplacingFBO(e,r,o,s,p){r===d.ON&&(s=e.width,p=e.height);const f=this.renderingContext,h=e.depthStencilTexture,m=this._ensureShader(f,null!=h),v=this.fboCache.acquire(s,p,"fbo visualizer");f.useProgram(m),h&&(v.acquireColor(t.RGBA,c.COLOR_ATTACHMENT1),f.bindFramebuffer(v.fbo),f.capabilities.drawBuffers?.drawBuffers([c.COLOR_ATTACHMENT0,c.COLOR_ATTACHMENT1]),f.bindTexture(h,1),m.setUniform1i("depthTex",1));const T=f.getViewport();f.setViewport(0,0,s,p),f.setClearColor(0,0,0,0),f.clearSafe(a.COLOR_BUFFER_BIT),f.setBlendingEnabled(!0),f.setBlendFunction(l.ONE,l.ONE_MINUS_SRC_ALPHA),f.bindTexture(e.colorTexture,0),m.setUniform1i("colorTex",0);const g=e.colorTexture?.descriptor.internalFormat,F=o.includes("depth")||o.includes("shadow")?3:g===u.R16F||g===u.R32F||g===u.R8?1:g===u.RG8?2:g===u.RGBA16F?4:0;if(m.setUniform1i("inputType",F),o.includes("depth")){const e=this.renderCamera;m.setUniform2fv("nearFar",e.nearFar);const r=n(e);m.setUniform4fv("projInfo",r);const o=i(e);m.setUniform2fv("zScale",o)}return f.screen.draw(),f.capabilities.drawBuffers?.drawBuffers([c.COLOR_ATTACHMENT0]),f.bindFramebuffer(null),f.setViewport(T.x,T.y,T.width,T.height),r===d.ON&&(this._focusedFBO=v),v}clearFocusedFBO(){this._focusedFBO=null}getPreviewContent(e,r,o,t){if(!o)return null;const n=this.renderingContext,i=this.fboCache.acquire(e,r,"fbo visualizer");n.setClearColor(0,0,0,0),n.clearSafe(a.COLOR_BUFFER_BIT),n.setBlendingEnabled(!0),n.setBlendFunction(l.ONE,l.ONE_MINUS_SRC_ALPHA),n.setViewport(0,0,e,r);const s=this._ensureShader(n,!1);n.useProgram(s),n.bindTexture(o.getColorTexture(t),0),s.setUniform1i("colorTex",0),s.setUniform1i("inputType",0),n.screen.draw();const c=new ImageData(new Uint8ClampedArray(e*r*4),e,r);return n.gl.readPixels(0,0,e,r,p.RGBA,f.UNSIGNED_BYTE,new Uint8Array(c.data.buffer)),n.bindFramebuffer(null),i?.release(),c}_ensureShader(e,r){const o=r?1:0;if(this._program[o])return this._program[o];const t="#version 300 es\n in vec2 position;\n out vec2 uv;\n\n void main() {\n gl_Position = vec4(position, 0.0, 1.0);\n uv = position * 0.5 + vec2(0.5);\n }",n=`#version 300 es\n precision highp float;\n\n in vec2 uv;\n uniform sampler2D colorTex;\n layout(location = 0) out vec4 fragColor;\n ${r?"\n layout(location = 1) out vec4 fragDepth;\n uniform sampler2D depthTex;\n ":""}\n uniform int inputType;\n uniform vec2 nearFar;\n uniform vec4 projInfo;\n uniform vec2 zScale;\n\n // Factors to convert rgba back to float\n const vec4 RGBA_2_FLOAT_FACTORS = vec4(\n 255.0 / (256.0),\n 255.0 / (256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0 * 256.0)\n );\n\n\n float rgba2float(vec4 rgba) {\n // Convert components from 0->1 back to 0->255 and then add the components together with their corresponding\n // fixed point factors, i.e. (256^1, 256^2, 256^3, 256^4)\n return dot(rgba, RGBA_2_FLOAT_FACTORS);\n }\n\n float linearDepthFromFloat(float depth) {\n depth = pow(depth, 0.2);\n return -(depth * (nearFar[1] - nearFar[0]) + nearFar[0]);\n }\n\n float linearDepthFromRGBA(vec4 depth) {\n return linearDepthFromFloat(rgba2float(depth));\n }\n\n float linearDepthFromTexture(sampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(texelFetch(depthTex, iuv, 0));\n }\n\n void main() {\n vec4 color;\n if(inputType == 1) {\n color = vec4(vec3(texture(colorTex, uv).r), 1.0);\n } else if(inputType == 2) {\n color = vec4(texture(colorTex, uv).rg, 0.0, 1.0);\n } else if(inputType == 3) {\n float depth = 1.0 - (-linearDepthFromTexture(colorTex, uv) / (nearFar[1] - nearFar[0]));\n color = vec4(vec3(depth), depth >= 0.999 ? 0.0 : 1.0);\n } else if(inputType == 4) {\n color = texture(colorTex, uv);\n color = vec4(color.rgb / color.a, color.a);\n } else {\n color = texture(colorTex, uv);\n }\n\n\n if(color.a < 0.000001)\n discard;\n else {\n fragColor = color;\n ${r?"\n float depth = 1.0 - pow(texture(depthTex, uv).r, 10.0);\n fragDepth = vec4(vec3(depth), depth < 0.000001 ? 0.0 : 1.0);\n ":""}\n }\n }`;return this._program[o]=e.programCache.acquire(t,n,s),this._program[o]}};h=e([r("esri.views.3d.webgl-engine.effects.debug.RenderNodeVisualizerNode")],h);export{d as FocusState,h as RenderNodeVisualizerNode};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{unitRGBAFromColor as t}from"../../../../../core/colorUtils.js";import has from"../../../../../core/has.js";import{releaseMaybe as r,disposeMaybe as i}from"../../../../../core/maybe.js";import{watch as s,syncAndInitial as o}from"../../../../../core/reactiveUtils.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as l}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{ColorFormat as c}from"../../core/FBOCache.js";import{SyncRenderPlugin as n,ConsumesHighlight as p}from"../RenderPlugin.js";import{HighlightApplyTechnique as u}from"./HighlightApplyTechnique.js";import{HighlightBlurTechnique as m}from"./HighlightBlurTechnique.js";import{defaultColor as _,defaultHaloOpacity as g,defaultFillOpacity as d}from"./HighlightDefaults.js";import{HighlightDownsampleTechnique as b}from"./HighlightDownsampleTechnique.js";import{HighlightPassParameters as f}from"./HighlightPassParameters.js";import{Default3D as w}from"../../lib/DefaultVertexAttributeLocations.js";import{Pos2Tex as T}from"../../lib/DefaultVertexBufferLayouts.js";import{RenderSlot as q}from"../../lib/RenderSlot.js";import{VertexArrayObject as v}from"../../lib/VertexArrayObject.js";import{H as x}from"../../../../../chunks/HighlightBlur.glsl.js";import{H as P,g as y}from"../../../../../chunks/HighlightDownsample.glsl.js";import{BufferObject as C}from"../../../../webgl/BufferObject.js";import{ClearBufferBit as j,Usage as R}from"../../../../webgl/enums.js";import{vertexCount as O}from"../../../../webgl/Util.js";let D=class extends n{constructor(e){super(e),this._context=null,this._passParameters=new f,this._downsampleDrawParameters=new P,this._blurDrawParameters=new x,this._blurColorFormat=has("mac")?c.RGBA:c.RGBA4,this._grid={coverage:null,vao:null,verticalCellCount:0,horizontalCellCount:0,viewportWidth:0,viewportHeight:0},this.produces=new Map([[q.HIGHLIGHT,()=>!0]])}consumes(){return p}initializeRenderContext(e){this._context=e,null==this._blurTechnique&&(this._blurTechnique=this._context.techniqueRepository.acquire(m)),null==this._downsampleTechnique&&(this._downsampleTechnique=this._context.techniqueRepository.acquire(b)),null==this._applyTechnique&&(this._applyTechnique=this._context.techniqueRepository.acquire(u)),this.addHandles([s((()=>this.view.highlightOptions.color),(e=>{this._passParameters.color=t(e??_),this.view.highlightOptions.haloColor||(this._passParameters.haloColor=this._passParameters.color),this._context.requestRender()}),o),s((()=>this.view.highlightOptions.haloColor),(e=>{this._passParameters.haloColor=null!=e?t(e):this._passParameters.color,this._context.requestRender()}),o),s((()=>this.view.highlightOptions.haloOpacity),(e=>{this._passParameters.haloOpacity=e??g,this._passParameters.haloOpacityOccluded=.25*this._passParameters.haloOpacity,this._context.requestRender()}),o),s((()=>this.view.highlightOptions.fillOpacity),(e=>{this._passParameters.fillOpacity=e??d,this._passParameters.fillOpacityOccluded=.25*this._passParameters.fillOpacity,this._context.requestRender()}),o)])}uninitializeRenderContext(){this._context=null}dispose(){this._blurTechnique=r(this._blurTechnique),this._downsampleTechnique=r(this._downsampleTechnique),this._applyTechnique=r(this._applyTechnique),this._grid.coverage=r(this._grid.coverage),this._grid.vao=i(this._grid.vao)}renderNode(e,t,r,i){const s=r?.highlight?.colorTexture;if(!this._context||!s)return;if(!(this._blurTechnique.compiled&&this._downsampleTechnique.compiled&&this._applyTechnique.compiled))return void this._context.requestRender();const o=e.bindParameters.camera,a=o.fullWidth,h=o.fullHeight,c=o.pixelRatio,n=Math.ceil(a/c),p=Math.ceil(h/c),u=this._context.fbos,m=u.rctx;this._gridUpdateResources(s),this._gridComputeCoverage(s,e.bindParameters),this._passParameters.highlightTexture=s,this._passParameters.coverageTexture=this._grid.coverage?.colorTexture;const{width:_,height:g}=s.descriptor;l(this._passParameters.coverageRounding,_/(Math.ceil(_/y)*y),g/(Math.ceil(g/y)*y));const d=this._grid.vao;m.bindVAO(d);const b=u.acquire(this._blurColorFormat,n,p,"highlight blur");m.setClearColor(0,0,0,0),m.clearSafe(j.COLOR_BUFFER_BIT),m.setViewport(0,0,n,p),this._blurDrawParameters.blurInputTexture=s,l(this._blurDrawParameters.blurSize,1/n,0);const f=m.bindTechnique(this._blurTechnique,e.bindParameters,this._passParameters,this._blurDrawParameters);m.drawArrays(this._blurTechnique.primitiveType,0,O(d,"geometry"));const w=u.acquire(this._blurColorFormat,n,p,"highlight blur");m.setClearColor(0,0,0,0),m.clearSafe(j.COLOR_BUFFER_BIT),this._blurDrawParameters.blurInputTexture=b.colorTexture,l(this._blurDrawParameters.blurSize,0,1/p),f.bindDraw(this._blurDrawParameters,e.bindParameters,this._passParameters),m.drawArrays(this._blurTechnique.primitiveType,0,O(d,"geometry")),m.bindFramebuffer(i?.fbo),m.setViewport4fv(o.fullViewport),this._passParameters.blurTexture=w.colorTexture,m.bindTechnique(this._applyTechnique,e.bindParameters,this._passParameters),m.drawArrays(this._applyTechnique.primitiveType,0,O(d,"geometry")),b.release(),w.release()}_gridUpdateResources(e){if(!this._context)return;const t=this._context.fbos.rctx,r=this._grid,i=Math.ceil(e.descriptor.height/y),s=Math.ceil(e.descriptor.width/y);if(r.vao&&r.verticalCellCount===i&&r.horizontalCellCount===s)return;r.verticalCellCount=i,r.horizontalCellCount=s;const o=i+1,a=s+1,h=1/i,l=1/s,c=new Float32Array(6*4*o*a);let n=0;for(let p=0;p<o;p++)for(let e=0;e<a;e++)c[n++]=(e-.5)*l*2-1,c[n++]=(p-.5)*h*2-1,c[n++]=e*l,c[n++]=p*h,c[n++]=(e+.5)*l*2-1,c[n++]=(p-.5)*h*2-1,c[n++]=e*l,c[n++]=p*h,c[n++]=(e-.5)*l*2-1,c[n++]=(p+.5)*h*2-1,c[n++]=e*l,c[n++]=p*h,c[n++]=(e-.5)*l*2-1,c[n++]=(p+.5)*h*2-1,c[n++]=e*l,c[n++]=p*h,c[n++]=(e+.5)*l*2-1,c[n++]=(p-.5)*h*2-1,c[n++]=e*l,c[n++]=p*h,c[n++]=(e+.5)*l*2-1,c[n++]=(p+.5)*h*2-1,c[n++]=e*l,c[n++]=p*h;r.vao?.dispose(),r.vao=new v(t,w,{geometry:T},{geometry:C.createVertex(t,R.STATIC_DRAW,c)})}_gridComputeCoverage(e,t){if(!this._context)return;const r=this._context.fbos.rctx,i=this._grid,s=e.descriptor,o=Math.ceil(s.width/y),a=Math.ceil(s.height/y);this._downsampleDrawParameters.input=e,i.coverage?.release(),i.coverage=this._context.fbos.acquire(c.RG,o,a,"highlight coverage"),r.bindTechnique(this._downsampleTechnique,t,this._passParameters,this._downsampleDrawParameters),r.setViewport(0,0,o,a),r.screen.draw()}get test(){return{coverage:this._grid.coverage}}};e([a()],D.prototype,"_context",void 0),e([a()],D.prototype,"view",void 0),D=e([h("esri.views.3d.webgl-engine.effects.highlight.Highlight")],D);export{D as Highlight};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{unitRGBAFromColor as t}from"../../../../../core/colorUtils.js";import has from"../../../../../core/has.js";import{releaseMaybe as r,disposeMaybe as i}from"../../../../../core/maybe.js";import{watch as s,syncAndInitial as o}from"../../../../../core/reactiveUtils.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as l}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{ColorFormat as c}from"../../core/FBOCache.js";import{SyncRenderPlugin as n,ConsumesHighlight as p}from"../RenderPlugin.js";import{HighlightApplyTechnique as u}from"./HighlightApplyTechnique.js";import{HighlightBlurTechnique as m}from"./HighlightBlurTechnique.js";import{defaultColor as _,defaultHaloOpacity as g,defaultFillOpacity as d}from"./HighlightDefaults.js";import{HighlightDownsampleTechnique as b}from"./HighlightDownsampleTechnique.js";import{HighlightPassParameters as f}from"./HighlightPassParameters.js";import{Default3D as w}from"../../lib/DefaultVertexAttributeLocations.js";import{Pos2Tex as T}from"../../lib/DefaultVertexBufferLayouts.js";import{RenderSlot as q}from"../../lib/RenderSlot.js";import{VertexArrayObject as v}from"../../lib/VertexArrayObject.js";import{H as x}from"../../../../../chunks/HighlightBlur.glsl.js";import{H as P,g as y}from"../../../../../chunks/HighlightDownsample.glsl.js";import{BufferObject as C}from"../../../../webgl/BufferObject.js";import{ClearBufferBit as j,Usage as R}from"../../../../webgl/enums.js";import{vertexCount as O}from"../../../../webgl/Util.js";let D=class extends n{constructor(e){super(e),this._context=null,this._passParameters=new f,this._downsampleDrawParameters=new P,this._blurDrawParameters=new x,this._blurColorFormat=has("mac")?c.RGBA:c.RGBA4,this._grid={coverage:null,vao:null,verticalCellCount:0,horizontalCellCount:0,viewportWidth:0,viewportHeight:0},this.produces=new Map([[q.HIGHLIGHT,()=>!0]])}consumes(){return p}initializeRenderContext(e){this._context=e,null==this._blurTechnique&&(this._blurTechnique=this._context.techniqueRepository.acquire(m)),null==this._downsampleTechnique&&(this._downsampleTechnique=this._context.techniqueRepository.acquire(b)),null==this._applyTechnique&&(this._applyTechnique=this._context.techniqueRepository.acquire(u)),this.addHandles([s((()=>this.view.highlightOptions.color),(e=>{this._passParameters.color=t(e??_),this.view.highlightOptions.haloColor||(this._passParameters.haloColor=this._passParameters.color),this._context.requestRender()}),o),s((()=>this.view.highlightOptions.haloColor),(e=>{this._passParameters.haloColor=null!=e?t(e):this._passParameters.color,this._context.requestRender()}),o),s((()=>this.view.highlightOptions.haloOpacity),(e=>{this._passParameters.haloOpacity=e??g,this._passParameters.haloOpacityOccluded=.25*this._passParameters.haloOpacity,this._context.requestRender()}),o),s((()=>this.view.highlightOptions.fillOpacity),(e=>{this._passParameters.fillOpacity=e??d,this._passParameters.fillOpacityOccluded=.25*this._passParameters.fillOpacity,this._context.requestRender()}),o)])}uninitializeRenderContext(){this._context=null}dispose(){this._blurTechnique=r(this._blurTechnique),this._downsampleTechnique=r(this._downsampleTechnique),this._applyTechnique=r(this._applyTechnique),this._grid.coverage=r(this._grid.coverage),this._grid.vao=i(this._grid.vao)}renderNode(e,t,r,i){const s=r?.highlight?.colorTexture;if(!this._context||!s)return;if(!(this._blurTechnique.compiled&&this._downsampleTechnique.compiled&&this._applyTechnique.compiled))return void this._context.requestRender();const o=e.bindParameters.camera,a=o.fullWidth,h=o.fullHeight,c=o.pixelRatio,n=Math.ceil(a/c),p=Math.ceil(h/c),u=this._context.fbos,m=u.rctx;this._gridUpdateResources(s),this._gridComputeCoverage(s,e.bindParameters),this._passParameters.highlightTexture=s,this._passParameters.coverageTexture=this._grid.coverage?.colorTexture;const{width:_,height:g}=s.descriptor;l(this._passParameters.coverageRounding,_/(Math.ceil(_/y)*y),g/(Math.ceil(g/y)*y));const d=this._grid.vao;m.bindVAO(d);const b=u.acquire(n,p,"highlight blur",this._blurColorFormat);m.setClearColor(0,0,0,0),m.clearSafe(j.COLOR_BUFFER_BIT),m.setViewport(0,0,n,p),this._blurDrawParameters.blurInputTexture=s,l(this._blurDrawParameters.blurSize,1/n,0);const f=m.bindTechnique(this._blurTechnique,e.bindParameters,this._passParameters,this._blurDrawParameters);m.drawArrays(this._blurTechnique.primitiveType,0,O(d,"geometry"));const w=u.acquire(n,p,"highlight blur",this._blurColorFormat);m.setClearColor(0,0,0,0),m.clearSafe(j.COLOR_BUFFER_BIT),this._blurDrawParameters.blurInputTexture=b.colorTexture,l(this._blurDrawParameters.blurSize,0,1/p),f.bindDraw(this._blurDrawParameters,e.bindParameters,this._passParameters),m.drawArrays(this._blurTechnique.primitiveType,0,O(d,"geometry")),m.bindFramebuffer(i?.fbo),m.setViewport4fv(o.fullViewport),this._passParameters.blurTexture=w.colorTexture,m.bindTechnique(this._applyTechnique,e.bindParameters,this._passParameters),m.drawArrays(this._applyTechnique.primitiveType,0,O(d,"geometry")),b.release(),w.release()}_gridUpdateResources(e){if(!this._context)return;const t=this._context.fbos.rctx,r=this._grid,i=Math.ceil(e.descriptor.height/y),s=Math.ceil(e.descriptor.width/y);if(r.vao&&r.verticalCellCount===i&&r.horizontalCellCount===s)return;r.verticalCellCount=i,r.horizontalCellCount=s;const o=i+1,a=s+1,h=1/i,l=1/s,c=new Float32Array(6*4*o*a);let n=0;for(let p=0;p<o;p++)for(let e=0;e<a;e++)c[n++]=(e-.5)*l*2-1,c[n++]=(p-.5)*h*2-1,c[n++]=e*l,c[n++]=p*h,c[n++]=(e+.5)*l*2-1,c[n++]=(p-.5)*h*2-1,c[n++]=e*l,c[n++]=p*h,c[n++]=(e-.5)*l*2-1,c[n++]=(p+.5)*h*2-1,c[n++]=e*l,c[n++]=p*h,c[n++]=(e-.5)*l*2-1,c[n++]=(p+.5)*h*2-1,c[n++]=e*l,c[n++]=p*h,c[n++]=(e+.5)*l*2-1,c[n++]=(p-.5)*h*2-1,c[n++]=e*l,c[n++]=p*h,c[n++]=(e+.5)*l*2-1,c[n++]=(p+.5)*h*2-1,c[n++]=e*l,c[n++]=p*h;r.vao?.dispose(),r.vao=new v(t,w,{geometry:T},{geometry:C.createVertex(t,R.STATIC_DRAW,c)})}_gridComputeCoverage(e,t){if(!this._context)return;const r=this._context.fbos.rctx,i=this._grid,s=e.descriptor,o=Math.ceil(s.width/y),a=Math.ceil(s.height/y);this._downsampleDrawParameters.input=e,i.coverage?.release(),i.coverage=this._context.fbos.acquire(o,a,"highlight coverage",c.RG),r.bindTechnique(this._downsampleTechnique,t,this._passParameters,this._downsampleDrawParameters),r.setViewport(0,0,o,a),r.screen.draw()}get test(){return{coverage:this._grid.coverage}}};e([a()],D.prototype,"_context",void 0),e([a()],D.prototype,"view",void 0),D=e([h("esri.views.3d.webgl-engine.effects.highlight.Highlight")],D);export{D as Highlight};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{disposeMaybe as t,abortMaybe as r}from"../../../../../core/maybe.js";import{throwIfAborted as s,createAbortError as i}from"../../../../../core/promiseUtils.js";import{watch as o,syncAndInitial as a}from"../../../../../core/reactiveUtils.js";import{property as n}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as h}from"../../../../../support/requestImageUtils.js";import{ColorFormat as u}from"../../core/FBOCache.js";import{SyncRenderPlugin as c,ConsumesCompositeColor as d}from"../RenderPlugin.js";import{SMAABlendWeightsTechnique as m}from"./SMAABlendWeightsTechnique.js";import{SMAABlurTechnique as _}from"./SMAABlurTechnique.js";import{SMAAEdgeDetectTechnique as p}from"./SMAAEdgeDetectTechnique.js";import{SMAAPassParameters as x}from"./SMAAPassParameters.js";import{RenderFeature as b}from"../../lib/RenderFeature.js";import{RenderSlot as T}from"../../lib/RenderSlot.js";import{PixelFormat as f,TextureSamplingMode as g,ClearBufferBit as q,TextureWrapMode as C}from"../../../../webgl/enums.js";import{Texture as w}from"../../../../webgl/Texture.js";import{TextureDescriptor as j}from"../../../../webgl/TextureDescriptor.js";let A=class extends c{constructor(e){super(e),this._context=null,this._areaTexture=null,this._searchTexture=null,this._isEnabled=!1,this._smaaParameters=new x,this.produces=new Map([[T.ANTIALIASING,()=>this._isEnabled&&null!=this._context]])}consumes(){return d}get updating(){return null!=this._abortController}initializeRenderContext(e){this._context=e,this.addHandles([o((()=>this.view.qualitySettings.antialiasingEnabled),(()=>this.renderFeatureChanged()),a)])}renderFeatureChanged(){this.view.qualitySettings.antialiasingEnabled||this._context?.isFeatureEnabled(b.Antialiasing)?this.enable():this.disable()}uninitializeRenderContext(){this.disable(),this._context=null}async enable(){if(this._isEnabled||!this._context||this._abortController)return;if(this._edgeTechnique??=this._context.techniqueRepository.acquire(p),this._blendTechnique??=this._context.techniqueRepository.acquire(m),this._blurTechnique??=this._context.techniqueRepository.acquire(_),this._areaTexture&&this._searchTexture)return void(this._isEnabled=!0);this._abortController=new AbortController;const e=this._abortController.signal;try{const t=await import("./SMAAData.js");await this._loadTextures(this._context,t,e),this._context?.requestRender()}catch{}this._abortController=null}async _loadTextures(e,t,r){if(s(r),!e)throw i();const[o,a]=await Promise.allSettled([h(t.areaTexture,{signal:r}),h(t.searchTexure,{signal:r})]);s(r),"fulfilled"===o.status&&"fulfilled"===a.status&&(this._areaTexture=R(e.fbos.rctx,g.LINEAR,f.RGB,o.value),this._searchTexture=R(e.fbos.rctx,g.NEAREST,f.LUMINANCE,a.value),this._isEnabled=!0)}_disposeTextures(){this._areaTexture=t(this._areaTexture),this._searchTexture=t(this._searchTexture)}disable(){this._abortController=r(this._abortController),this._isEnabled=!1}destroy(){this.disable(),this._disposeTextures()}renderNode(e,t,r,s){const i=r?.composite?.colorTexture;if(!(this._isEnabled&&this._context&&r&&i))return s;if(!(this._edgeTechnique?.compiled&&this._blendTechnique?.compiled&&this._blurTechnique?.compiled))return this._context.requestRender(),s;const o=i.descriptor.width,a=i.descriptor.height,n=this._context.fbos,l=e.rctx;l.setViewport(0,0,o,a);const h=n.acquire(u.RG,o,a,"smaa edges");l.setClearColor(0,0,0,1),l.clear(q.COLOR_BUFFER_BIT),this._smaaParameters.color=i,l.bindTechnique(this._edgeTechnique,null,this._smaaParameters),l.screen.draw();const c=n.acquire(u.RGBA,o,a,"smaa blend");return l.setClearColor(0,0,1,1),l.clear(q.COLOR_BUFFER_BIT),this._smaaParameters.inputTexture=h.colorTexture,this._smaaParameters.areaTexture=this._areaTexture,this._smaaParameters.searchTexture=this._searchTexture,l.bindTechnique(this._blendTechnique,null,this._smaaParameters),l.screen.draw(),l.bindFramebuffer(s?.fbo),h.release(),l.setClearColor(0,1,0,1),l.clear(q.COLOR_BUFFER_BIT),this._smaaParameters.inputTexture=c.colorTexture,l.bindTechnique(this._blurTechnique,null,this._smaaParameters),l.screen.draw(),c.release(),s}};function R(e,t,r,s){const i=new j;return i.pixelFormat=r,i.wrapMode=C.CLAMP_TO_EDGE,i.width=s.width,i.height=s.height,i.samplingMode=t,new w(e,i,s)}e([n()],A.prototype,"view",void 0),e([n()],A.prototype,"_context",void 0),e([n()],A.prototype,"_abortController",void 0),e([n({readOnly:!0})],A.prototype,"updating",null),A=e([l("esri.views.3d.webgl-engine.effects.smaa.SMAA")],A);export{A as SMAA};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{disposeMaybe as t,abortMaybe as r}from"../../../../../core/maybe.js";import{throwIfAborted as s,createAbortError as i}from"../../../../../core/promiseUtils.js";import{watch as o,syncAndInitial as a}from"../../../../../core/reactiveUtils.js";import{property as n}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as h}from"../../../../../support/requestImageUtils.js";import{ColorFormat as u}from"../../core/FBOCache.js";import{SyncRenderPlugin as c,ConsumesCompositeColor as d}from"../RenderPlugin.js";import{SMAABlendWeightsTechnique as m}from"./SMAABlendWeightsTechnique.js";import{SMAABlurTechnique as _}from"./SMAABlurTechnique.js";import{SMAAEdgeDetectTechnique as p}from"./SMAAEdgeDetectTechnique.js";import{SMAAPassParameters as x}from"./SMAAPassParameters.js";import{RenderFeature as b}from"../../lib/RenderFeature.js";import{RenderSlot as T}from"../../lib/RenderSlot.js";import{PixelFormat as f,TextureSamplingMode as g,ClearBufferBit as q,TextureWrapMode as C}from"../../../../webgl/enums.js";import{Texture as w}from"../../../../webgl/Texture.js";import{TextureDescriptor as j}from"../../../../webgl/TextureDescriptor.js";let A=class extends c{constructor(e){super(e),this._context=null,this._areaTexture=null,this._searchTexture=null,this._isEnabled=!1,this._smaaParameters=new x,this.produces=new Map([[T.ANTIALIASING,()=>this._isEnabled&&null!=this._context]])}consumes(){return d}get updating(){return null!=this._abortController}initializeRenderContext(e){this._context=e,this.addHandles([o((()=>this.view.qualitySettings.antialiasingEnabled),(()=>this.renderFeatureChanged()),a)])}renderFeatureChanged(){this.view.qualitySettings.antialiasingEnabled||this._context?.isFeatureEnabled(b.Antialiasing)?this.enable():this.disable()}uninitializeRenderContext(){this.disable(),this._context=null}async enable(){if(this._isEnabled||!this._context||this._abortController)return;if(this._edgeTechnique??=this._context.techniqueRepository.acquire(p),this._blendTechnique??=this._context.techniqueRepository.acquire(m),this._blurTechnique??=this._context.techniqueRepository.acquire(_),this._areaTexture&&this._searchTexture)return void(this._isEnabled=!0);this._abortController=new AbortController;const e=this._abortController.signal;try{const t=await import("./SMAAData.js");await this._loadTextures(this._context,t,e),this._context?.requestRender()}catch{}this._abortController=null}async _loadTextures(e,t,r){if(s(r),!e)throw i();const[o,a]=await Promise.allSettled([h(t.areaTexture,{signal:r}),h(t.searchTexure,{signal:r})]);s(r),"fulfilled"===o.status&&"fulfilled"===a.status&&(this._areaTexture=R(e.fbos.rctx,g.LINEAR,f.RGB,o.value),this._searchTexture=R(e.fbos.rctx,g.NEAREST,f.LUMINANCE,a.value),this._isEnabled=!0)}_disposeTextures(){this._areaTexture=t(this._areaTexture),this._searchTexture=t(this._searchTexture)}disable(){this._abortController=r(this._abortController),this._isEnabled=!1}destroy(){this.disable(),this._disposeTextures()}renderNode(e,t,r,s){const i=r?.composite?.colorTexture;if(!(this._isEnabled&&this._context&&r&&i))return s;if(!(this._edgeTechnique?.compiled&&this._blendTechnique?.compiled&&this._blurTechnique?.compiled))return this._context.requestRender(),s;const o=i.descriptor.width,a=i.descriptor.height,n=this._context.fbos,l=e.rctx;l.setViewport(0,0,o,a);const h=n.acquire(o,a,"smaa edges",u.RG);l.setClearColor(0,0,0,1),l.clear(q.COLOR_BUFFER_BIT),this._smaaParameters.color=i,l.bindTechnique(this._edgeTechnique,null,this._smaaParameters),l.screen.draw();const c=n.acquire(o,a,"smaa blend");return l.setClearColor(0,0,1,1),l.clear(q.COLOR_BUFFER_BIT),this._smaaParameters.inputTexture=h.colorTexture,this._smaaParameters.areaTexture=this._areaTexture,this._smaaParameters.searchTexture=this._searchTexture,l.bindTechnique(this._blendTechnique,null,this._smaaParameters),l.screen.draw(),l.bindFramebuffer(s?.fbo),h.release(),l.setClearColor(0,1,0,1),l.clear(q.COLOR_BUFFER_BIT),this._smaaParameters.inputTexture=c.colorTexture,l.bindTechnique(this._blurTechnique,null,this._smaaParameters),l.screen.draw(),c.release(),s}};function R(e,t,r,s){const i=new j;return i.pixelFormat=r,i.wrapMode=C.CLAMP_TO_EDGE,i.width=s.width,i.height=s.height,i.samplingMode=t,new w(e,i,s)}e([n()],A.prototype,"view",void 0),e([n()],A.prototype,"_context",void 0),e([n()],A.prototype,"_abortController",void 0),e([n({readOnly:!0})],A.prototype,"updating",null),A=e([l("esri.views.3d.webgl-engine.effects.smaa.SMAA")],A);export{A 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.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{disposeMaybe as t}from"../../../../../core/maybe.js";import{watch as r,syncAndInitial as s}from"../../../../../core/reactiveUtils.js";import{Milliseconds as i}from"../../../../../core/time.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as n}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{ColorFormat as c}from"../../core/FBOCache.js";import{SyncRenderPlugin as l,ConsumesDepthNormal as m,ConsumesNone as u}from"../RenderPlugin.js";import{SSAOBlurTechnique as h}from"./SSAOBlurTechnique.js";import{noiseData as p}from"./SSAONoiseData.js";import{SSAOPassParameters as _,BlurDrawParameters as d}from"./SSAOParameters.js";import{SSAOTechnique as b}from"./SSAOTechnique.js";import{RenderFeature as x}from"../../lib/RenderFeature.js";import{RenderSlot as T}from"../../lib/RenderSlot.js";import{g as w}from"../../../../../chunks/SSAO.glsl.js";import{TextureWrapMode as f,PixelFormat as S,ClearBufferBit as P}from"../../../../webgl/enums.js";import{Texture as q}from"../../../../webgl/Texture.js";import{TextureDescriptor as j}from"../../../../webgl/TextureDescriptor.js";const R=2;let g=class extends l{constructor(e){super(e),this._context=null,this._passParameters=new _,this._drawParameters=new d,this.produces=new Map([[T.SSAO,()=>this._produces()]])}_produces(){return null!=this._enableTime&&null!=this._context}consumes(){return this._produces()?m:u}initializeRenderContext(e){this._context=e,this.addHandles([r((()=>this.view.qualitySettings.ambientOcclusion||this._context?.isFeatureEnabled(x.SSAO)),(e=>e?this._enable():this._disable()),s)])}uninitializeRenderContext(){this._disable(),this._context=null}_disable(){this._passParameters.noiseTexture=t(this._passParameters.noiseTexture),this._enableTime=null}destroy(){this._disable()}_enable(){if(null!=this._enableTime||!this._context)return;const e=Uint8Array.from(atob(p),(e=>e.charCodeAt(0))),t=new j;t.wrapMode=f.CLAMP_TO_EDGE,t.pixelFormat=S.RGB,t.wrapMode=f.REPEAT,t.hasMipmap=!0,t.width=32,t.height=32,this._passParameters.noiseTexture=new q(this._context.renderContext.rctx,t,e),null==this._ssaoTechnique&&(this._ssaoTechnique=this._context.techniqueRepository.acquire(b)),null==this._blurTechnique&&(this._blurTechnique=this._context.techniqueRepository.acquire(h)),this._enableTime=i(0),this._context?.requestRender()}renderNode(e,t,r){const s=e.bindParameters,i=s.linearDepth?.colorTexture,o=r?.normals?.colorTexture;if(null==this._enableTime||null==this._context||null==i||!o)return;if(!this._ssaoTechnique.compiled||!this._blurTechnique.compiled)return this._enableTime=e.time,void this._context.requestRender();0===this._enableTime&&(this._enableTime=e.time);const a=e.rctx,l=s.camera,m=this.view.qualitySettings.fadeDuration,u=m>0?Math.min(m,e.time-this._enableTime)/m:1;this._passParameters.normalTexture=o,this._passParameters.depthTexture=i,this._passParameters.projScale=1/l.computeScreenPixelSizeAtDist(1),this._passParameters.intensity=4*O/w(l)**6*u;const h=l.fullViewport[2],p=l.fullViewport[3],_=Math.round(h/R),d=Math.round(p/R),b=this._context.fbos,x=b.acquire(c.RG,h,p,"ssao input");a.setViewport(0,0,h,p),a.bindTechnique(this._ssaoTechnique,s,this._passParameters,this._drawParameters),a.screen.draw(),a.setViewport(0,0,_,d);const T=b.acquire(c.RED,_,d,"ssao blur");this._drawParameters.colorTexture=x.colorTexture,n(this._drawParameters.blurSize,0,R/p);const f=a.bindTechnique(this._blurTechnique,s,this._passParameters,this._drawParameters);a.setViewport(0,0,_,d),a.screen.draw(),x.release();const S=b.acquire(c.RED,_,d,"ssao");return a.setViewport(0,0,h,p),a.setClearColor(1,1,1,0),a.clear(P.COLOR_BUFFER_BIT),a.setViewport(0,0,_,d),this._drawParameters.colorTexture=T.colorTexture,n(this._drawParameters.blurSize,R/h,0),f.bindDraw(this._drawParameters,s,this._passParameters),a.screen.draw(),a.setViewport4fv(l.fullViewport),T.release(),u<1&&this._context.requestRender(),S}};e([o({constructOnly:!0})],g.prototype,"view",void 0),e([o()],g.prototype,"_context",void 0),g=e([a("esri.views.3d.webgl-engine.effects.ssao.SSAO")],g);const O=.5;export{g as SSAO,R as blurSizePixels};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{disposeMaybe as t}from"../../../../../core/maybe.js";import{watch as r,syncAndInitial as s}from"../../../../../core/reactiveUtils.js";import{Milliseconds as i}from"../../../../../core/time.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as n}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{ColorFormat as c}from"../../core/FBOCache.js";import{SyncRenderPlugin as l,ConsumesDepthNormal as m,ConsumesNone as u}from"../RenderPlugin.js";import{SSAOBlurTechnique as h}from"./SSAOBlurTechnique.js";import{noiseData as p}from"./SSAONoiseData.js";import{SSAOPassParameters as _,BlurDrawParameters as d}from"./SSAOParameters.js";import{SSAOTechnique as b}from"./SSAOTechnique.js";import{RenderFeature as x}from"../../lib/RenderFeature.js";import{RenderSlot as T}from"../../lib/RenderSlot.js";import{g as w}from"../../../../../chunks/SSAO.glsl.js";import{TextureWrapMode as f,PixelFormat as S,ClearBufferBit as P}from"../../../../webgl/enums.js";import{Texture as q}from"../../../../webgl/Texture.js";import{TextureDescriptor as j}from"../../../../webgl/TextureDescriptor.js";const R=2;let g=class extends l{constructor(e){super(e),this._context=null,this._passParameters=new _,this._drawParameters=new d,this.produces=new Map([[T.SSAO,()=>this._produces()]])}_produces(){return null!=this._enableTime&&null!=this._context}consumes(){return this._produces()?m:u}initializeRenderContext(e){this._context=e,this.addHandles([r((()=>this.view.qualitySettings.ambientOcclusion||this._context?.isFeatureEnabled(x.SSAO)),(e=>e?this._enable():this._disable()),s)])}uninitializeRenderContext(){this._disable(),this._context=null}_disable(){this._passParameters.noiseTexture=t(this._passParameters.noiseTexture),this._enableTime=null}destroy(){this._disable()}_enable(){if(null!=this._enableTime||!this._context)return;const e=Uint8Array.from(atob(p),(e=>e.charCodeAt(0))),t=new j;t.wrapMode=f.CLAMP_TO_EDGE,t.pixelFormat=S.RGB,t.wrapMode=f.REPEAT,t.hasMipmap=!0,t.width=32,t.height=32,this._passParameters.noiseTexture=new q(this._context.renderContext.rctx,t,e),null==this._ssaoTechnique&&(this._ssaoTechnique=this._context.techniqueRepository.acquire(b)),null==this._blurTechnique&&(this._blurTechnique=this._context.techniqueRepository.acquire(h)),this._enableTime=i(0),this._context?.requestRender()}renderNode(e,t,r){const s=e.bindParameters,i=s.linearDepth?.colorTexture,o=r?.normals?.colorTexture;if(null==this._enableTime||null==this._context||null==i||!o)return;if(!this._ssaoTechnique.compiled||!this._blurTechnique.compiled)return this._enableTime=e.time,void this._context.requestRender();0===this._enableTime&&(this._enableTime=e.time);const a=e.rctx,l=s.camera,m=this.view.qualitySettings.fadeDuration,u=m>0?Math.min(m,e.time-this._enableTime)/m:1;this._passParameters.normalTexture=o,this._passParameters.depthTexture=i,this._passParameters.projScale=1/l.computeScreenPixelSizeAtDist(1),this._passParameters.intensity=4*O/w(l)**6*u;const h=l.fullViewport[2],p=l.fullViewport[3],_=Math.round(h/R),d=Math.round(p/R),b=this._context.fbos,x=b.acquire(h,p,"ssao input",c.RG);a.setViewport(0,0,h,p),a.bindTechnique(this._ssaoTechnique,s,this._passParameters,this._drawParameters),a.screen.draw(),a.setViewport(0,0,_,d);const T=b.acquire(_,d,"ssao blur",c.RED);this._drawParameters.colorTexture=x.colorTexture,n(this._drawParameters.blurSize,0,R/p);const f=a.bindTechnique(this._blurTechnique,s,this._passParameters,this._drawParameters);a.setViewport(0,0,_,d),a.screen.draw(),x.release();const S=b.acquire(_,d,"ssao",c.RED);return a.setViewport(0,0,h,p),a.setClearColor(1,1,1,0),a.clear(P.COLOR_BUFFER_BIT),a.setViewport(0,0,_,d),this._drawParameters.colorTexture=T.colorTexture,n(this._drawParameters.blurSize,R/h,0),f.bindDraw(this._drawParameters,s,this._passParameters),a.screen.draw(),a.setViewport4fv(l.fullViewport),T.release(),u<1&&this._context.requestRender(),S}};e([o({constructOnly:!0})],g.prototype,"view",void 0),e([o()],g.prototype,"_context",void 0),g=e([a("esri.views.3d.webgl-engine.effects.ssao.SSAO")],g);const O=.5;export{g as SSAO,R as blurSizePixels};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../chunks/tslib.es6.js";import i from"../../../../core/Accessor.js";import e from"../../../../core/Logger.js";import{lerp as r}from"../../../../core/mathUtils.js";import{createScreenPointArray as s,createRenderScreenPointArray3 as o}from"../../../../core/screenUtils.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{copy as a,multiply as p,frustum as u,equals as _,invert as l,transpose as c,lookAt as v}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as w}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{copy as d,exactEquals as y}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as g}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{f as m,s as f,k as x,c as M,h as T,x as D,j,F as R,w as P,i as F,l as O,b as V,n as C,B as b}from"../../../../chunks/vec32.js";import{create as S}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{b as I,e as E,a as L,c as H,d as B,t as G}from"../../../../chunks/vec42.js";import{fromValues as A,create as k}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as U,copy as z,fromMatrix as W}from"../../../../geometry/support/frustum.js";import{create as X}from"../../../../geometry/support/ray.js";import{projectPointSignedLength as Y}from"../../../../geometry/support/vector.js";import{ViewingMode as q}from"../../../ViewingMode.js";import{fovd2fovx as N,fovx2fovd as J,fovd2fovy as K,fovy2fovd as Q}from"./fov.js";var Z;let $=Z=class extends i{constructor(t){super(t),this._ray=X(),this._viewport=A(0,0,1,1),this._padding=A(0,0,0,0),this._fov=55/180*Math.PI,this._nearFar=g(1,1e3),this._viewDirty=!0,this._viewMatrix=w(),this._viewProjectionDirty=!0,this._viewProjectionMatrix=w(),this._viewInverseTransposeMatrixDirty=!0,this._viewInverseTransposeMatrix=w(),this._frustumDirty=!0,this._frustum=U(),this._fullViewport=k(),this._pixelRatio=1,this.row=0,this.column=0,this._rows=1,this._columns=1,this._center=S(),this._up=S(),this.relativeElevation=0}get pixelRatio(){return this._pixelRatio}set pixelRatio(t){this._pixelRatio=t>0?t:1}get rows(){return this._rows}set rows(t){this._rows=Math.max(1,t)}get columns(){return this._columns}set columns(t){this._columns=Math.max(1,t)}get eye(){return this._ray.origin}set eye(t){this._compareAndSetView(t,this._ray.origin)}get center(){return this._center}set center(t){this._compareAndSetView(t,this._center,"_center")}get ray(){return m(this._ray.direction,this.center,this.eye),this._ray}get up(){return this._up}set up(t){this._compareAndSetView(t,this._up,"_up")}get viewMatrix(){return this._ensureViewClean(),this._viewMatrix}set viewMatrix(t){a(this._viewMatrix,t),this.notifyChange("_viewMatrix"),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0,this._viewProjectionDirty=!0,this._frustumDirty=!0}get viewForward(){return this._ensureViewClean(),f(S(),-this._viewMatrix[2],-this._viewMatrix[6],-this._viewMatrix[10])}get viewUp(){return this._ensureViewClean(),f(S(),this._viewMatrix[1],this._viewMatrix[5],this._viewMatrix[9])}get viewRight(){return this._ensureViewClean(),f(S(),this._viewMatrix[0],this._viewMatrix[4],this._viewMatrix[8])}get nearFar(){return this._nearFar}get near(){return this._nearFar[0]}set near(t){this._nearFar[0]!==t&&(this._nearFar[0]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_nearFar"))}get far(){return this._nearFar[1]}set far(t){this._nearFar[1]!==t&&(this._nearFar[1]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_nearFar"))}get viewport(){return this._viewport}set viewport(t){this.x=t[0],this.y=t[1],this.width=t[2],this.height=t[3]}get screenViewport(){if(1===this.pixelRatio)return this._viewport;const t=I(k(),this._viewport,1/this.pixelRatio),i=this._get("screenViewport");return i&&E(t,i)?i:t}get screenPadding(){if(1===this.pixelRatio)return this._padding;const t=I(k(),this._padding,1/this.pixelRatio),i=this._get("screenPadding");return i&&E(t,i)?i:t}get x(){return this._viewport[0]}set x(t){t+=this._padding[ot.LEFT],this._viewport[0]!==t&&(this._viewport[0]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get y(){return this._viewport[1]}set y(t){t+=this._padding[ot.BOTTOM],this._viewport[1]!==t&&(this._viewport[1]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get width(){return this._viewport[2]}set width(t){this._viewport[2]!==t&&(this._viewport[2]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get height(){return this._viewport[3]}set height(t){this._viewport[3]!==t&&(this._viewport[3]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get fullWidth(){return this._viewport[2]+this._padding[ot.RIGHT]+this._padding[ot.LEFT]}set fullWidth(t){this.width=t-(this._padding[ot.RIGHT]+this._padding[ot.LEFT])}get fullHeight(){return this._viewport[3]+this._padding[ot.TOP]+this._padding[ot.BOTTOM]}set fullHeight(t){this.height=t-(this._padding[ot.TOP]+this._padding[ot.BOTTOM])}get fullViewport(){return this._fullViewport[0]=this._viewport[0]-this._padding[ot.LEFT],this._fullViewport[1]=this._viewport[1]-this._padding[ot.BOTTOM],this._fullViewport[2]=this.fullWidth,this._fullViewport[3]=this.fullHeight,this._fullViewport}get _aspect(){return this.width/this.height}get padding(){return this._padding}set padding(t){L(this._padding,t)||(this._viewport[0]+=t[ot.LEFT]-this._padding[ot.LEFT],this._viewport[1]+=t[ot.BOTTOM]-this._padding[ot.BOTTOM],this._viewport[2]-=t[ot.RIGHT]+t[ot.LEFT]-(this._padding[ot.RIGHT]+this._padding[ot.LEFT]),this._viewport[3]-=t[ot.TOP]+t[ot.BOTTOM]-(this._padding[ot.TOP]+this._padding[ot.BOTTOM]),H(this._padding,t),this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_padding"),this.notifyChange("_viewport"))}get viewProjectionMatrix(){return this._viewProjectionDirty&&(p(this._viewProjectionMatrix,this.projectionMatrix,this.viewMatrix),this._viewProjectionDirty=!1),this._viewProjectionMatrix}get projectionMatrix(){const t=this.width,i=this.height,e=this.near*Math.tan(this.fovY/2)*2,r=e*this._aspect,s=e/this.rows,o=r/this.columns,n=-r/2+this.column*o,h=n+o,a=-e/2+this.row*s,p=a+s,l=u(w(),n*(1+2*this._padding[ot.LEFT]/t),h*(1+2*this._padding[ot.RIGHT]/t),a*(1+2*this._padding[ot.BOTTOM]/i),p*(1+2*this._padding[ot.TOP]/i),this.near,this.far),c=this._get("projectionMatrix");return c&&_(c,l)?c:l}get inverseProjectionMatrix(){return l(w(),this.projectionMatrix)||this._get("inverseProjectionMatrix")||w()}get fov(){return this._fov}set fov(t){this._fov=t,this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovX(){return N(this._fov,this.width,this.height)}set fovX(t){this._fov=J(t,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovY(){return K(this._fov,this.width,this.height)}set fovY(t){this._fov=Q(t,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get distance(){return x(this.center,this.eye)}get frustum(){return this._recomputeFrustum(),this._frustum}get viewInverseTransposeMatrix(){return(this._viewInverseTransposeMatrixDirty||this._viewDirty)&&(l(this._viewInverseTransposeMatrix,this.viewMatrix),c(this._viewInverseTransposeMatrix,this._viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),this._viewInverseTransposeMatrix}depthNDCToWorld(t){const i=2*t-1;return 2*this.near*this.far/(this.far+this.near-i*(this.far-this.near))}get perRenderPixelRatio(){return Math.tan(this.fovX/2)/(this.width/2)}get perScreenPixelRatio(){return this.perRenderPixelRatio*this.pixelRatio}get aboveGround(){return null!=this.relativeElevation&&this.relativeElevation>=0}copyFrom(t){M(this._ray.origin,t.eye),this.center=t.center,this.up=t.up,H(this._viewport,t.viewport),this.notifyChange("_viewport"),H(this._padding,t.padding),this.notifyChange("_padding"),d(this._nearFar,t.nearFar),this.notifyChange("_nearFar"),this._fov=t.fov,this.row=t.row,this.column=t.column,this.rows=t.rows,this.columns=t.columns,this.relativeElevation=t.relativeElevation;const i=t;return this._viewDirty=i._viewDirty,this._viewDirty||(a(this._viewMatrix,t.viewMatrix),this.notifyChange("_viewMatrix")),this._viewProjectionDirty=!0,this._frustumDirty=i._frustumDirty,this._frustumDirty||(z(this._frustum,t.frustum),this._frustumDirty=!1),i._viewInverseTransposeMatrixDirty?this._viewInverseTransposeMatrixDirty=!0:(a(this._viewInverseTransposeMatrix,t.viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),H(this._fullViewport,t.fullViewport),this.pixelRatio=t.pixelRatio,this}copyViewFrom(t){this.eye=t.eye,this.center=t.center,this.up=t.up}clone(){return(new Z).copyFrom(this)}equals(t){return T(this.eye,t.eye)&&T(this.center,t.center)&&T(this.up,t.up)&&L(this._viewport,t.viewport)&&L(this._padding,t.padding)&&y(this.nearFar,t.nearFar)&&this._fov===t.fov&&this.pixelRatio===t.pixelRatio&&this.relativeElevation===t.relativeElevation&&this.row===t.row&&this.column===t.column&&this.rows===t.rows&&this.columns===t.columns}almostEquals(t){const i=Math.max(1,1/this.pixelRatio,1/t.pixelRatio);if(Math.abs(t.fov-this._fov)>=.001||B(t.screenPadding,this.screenPadding)>=i||B(this.screenViewport,t.screenViewport)>=i||this.row!==t.row||this.column!==t.column||this.rows!==t.rows||this.columns!==t.columns)return!1;D(et,t.eye,t.center),D(rt,this.eye,this.center);const e=j(et,rt),r=R(et),s=R(rt),o=5e-4;return e*e>=(1-1e-10)*r*s&&P(t.eye,this.eye)<Math.max(r,s)*o*o}computeRenderPixelSizeAt(t){return this.computeRenderPixelSizeAtDist(this._viewDirectionDistance(t))}computeRenderPixelSizeAtDist(t){return t*this.perRenderPixelRatio}computeScreenPixelSizeAt(t){return this.computeScreenPixelSizeAtDist(this._viewDirectionDistance(t))}_viewDirectionDistance(t){return Math.abs(Y(this.viewForward,m(et,t,this.eye)))}computeScreenPixelSizeAtDist(t){return t*this.perScreenPixelRatio}computeDistanceFromRadius(t,i){return t/Math.tan(Math.min(this.fovX,this.fovY)/(2*(i||1)))}getScreenCenter(t=s()){return t[0]=(this.padding[ot.LEFT]+this.width/2)/this.pixelRatio,t[1]=(this.padding[ot.TOP]+this.height/2)/this.pixelRatio,t}getRenderCenter(t,i=.5,e=.5){return t[0]=this.padding[ot.LEFT]+this.width*i,t[1]=this.padding[ot.BOTTOM]+this.height*e,t[2]=.5,t}setGLViewport(t){const i=this.viewport,e=this.padding;t.setViewport(i[0]-e[3],i[1]-e[2],i[2]+e[1]+e[3],i[3]+e[0]+e[2])}applyProjection(t,i){t!==tt&&M(tt,t),tt[3]=1,G(tt,tt,this.projectionMatrix);const e=Math.abs(tt[3]);F(tt,tt,1/e);const s=this.fullViewport;i[0]=r(0,s[0]+s[2],.5+.5*tt[0]),i[1]=r(0,s[1]+s[3],.5+.5*tt[1]),i[2]=.5*(tt[2]+1),i[3]=e}unapplyProjection(t,i){const e=this.fullViewport;tt[0]=(t[0]/(e[0]+e[2])*2-1)*t[3],tt[1]=(t[1]/(e[1]+e[3])*2-1)*t[3],tt[2]=(2*t[2]-1)*t[3],tt[3]=t[3],null!=this.inverseProjectionMatrix&&(G(tt,tt,this.inverseProjectionMatrix),i[0]=tt[0],i[1]=tt[1],i[2]=tt[2])}projectToScreen(t,i){return this.projectToRenderScreen(t,st),this.renderToScreen(st,i),i}projectToRenderScreen(t,i){if(tt[0]=t[0],tt[1]=t[1],tt[2]=t[2],tt[3]=1,G(tt,tt,this.viewProjectionMatrix),0===tt[3])return null;const e=tt;F(e,e,1/Math.abs(tt[3]));const s=this.fullViewport,o=r(0,s[0]+s[2],.5+.5*e[0]),n=r(0,s[1]+s[3],.5+.5*e[1]);return"x"in i?(i.x=o,i.y=n):(i[0]=o,i[1]=n,i.length>2&&(i[2]=.5*(e[2]+1))),i}unprojectFromScreen(t,i){return this.unprojectFromRenderScreen(this.screenToRender(t,st),i)}unprojectFromRenderScreen(t,i){if(p(it,this.projectionMatrix,this.viewMatrix),!l(it,it))return null;const e=this.fullViewport;return tt[0]=2*(t[0]-e[0])/e[2]-1,tt[1]=2*(t[1]-e[1])/e[3]-1,tt[2]=2*t[2]-1,tt[3]=1,G(tt,tt,it),0===tt[3]?null:(i[0]=tt[0]/tt[3],i[1]=tt[1]/tt[3],i[2]=tt[2]/tt[3],i)}constrainWindowSize(t,i,e,r){const s=t*this.pixelRatio,o=i*this.pixelRatio,n=Math.max(s-e/2,0),h=Math.max(this.fullHeight-o-r/2,0),a=-Math.min(s-e/2,0),p=-Math.min(this.fullHeight-o-r/2,0),u=e-a- -Math.min(this.fullWidth-s-e/2,0),_=r-p- -Math.min(o-r/2,0);return[Math.round(n),Math.round(h),Math.round(u),Math.round(_)]}computeUp(t){t===q.Global?this._computeUpGlobal():this._computeUpLocal()}screenToRender(t,i){const e=t[0]*this.pixelRatio,r=this.fullHeight-t[1]*this.pixelRatio;return i[0]=e,i[1]=r,i}renderToScreen(t,i){const e=t[0]/this.pixelRatio,r=(this.fullHeight-t[1])/this.pixelRatio;i[0]=e,i[1]=r}_computeUpGlobal(){m(et,this.center,this.eye);const t=O(this.center);t<1?(f(this._up,0,0,1),this._markViewDirty(),this.notifyChange("_up")):Math.abs(j(et,this.center))>.9999*O(et)*t||(V(this._up,et,this.center),V(this._up,this._up,et),C(this._up,this._up),this.notifyChange("_up"),this._markViewDirty())}_computeUpLocal(){b(et,this.eye,this.center),Math.abs(et[2])<=.9999&&(F(et,et,et[2]),f(this._up,-et[0],-et[1],1-et[2]),C(this._up,this._up),this.notifyChange("_up"),this._markViewDirty())}_compareAndSetView(t,i,r=""){"number"==typeof t[0]&&isFinite(t[0])&&"number"==typeof t[1]&&isFinite(t[1])&&"number"==typeof t[2]&&isFinite(t[2])?T(t,i)||(M(i,t),this._markViewDirty(),r.length&&this.notifyChange(r)):e.getLogger("esri.views.3d.webgl-engine.lib.Camera").warn("Camera vector contains invalid number, ignoring value")}_markViewDirty(){this._viewDirty=!0,this._frustumDirty=!0,this._viewProjectionDirty=!0}_recomputeFrustum(){this._frustumDirty&&(W(this.viewMatrix,this.projectionMatrix,this._frustum),this._frustumDirty=!1)}_ensureViewClean(){this._viewDirty&&(v(this._viewMatrix,this.eye,this.center,this.up),this.notifyChange("_viewMatrix"),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0)}};t([n()],$.prototype,"_viewport",void 0),t([n()],$.prototype,"_padding",void 0),t([n()],$.prototype,"_fov",void 0),t([n()],$.prototype,"_nearFar",void 0),t([n()],$.prototype,"_viewDirty",void 0),t([n()],$.prototype,"_viewMatrix",void 0),t([n()],$.prototype,"_pixelRatio",void 0),t([n()],$.prototype,"pixelRatio",null),t([n()],$.prototype,"row",void 0),t([n()],$.prototype,"column",void 0),t([n()],$.prototype,"_rows",void 0),t([n()],$.prototype,"rows",null),t([n()],$.prototype,"_columns",void 0),t([n()],$.prototype,"columns",null),t([n()],$.prototype,"eye",null),t([n()],$.prototype,"center",null),t([n()],$.prototype,"_center",void 0),t([n()],$.prototype,"up",null),t([n()],$.prototype,"_up",void 0),t([n({readOnly:!0})],$.prototype,"viewForward",null),t([n({readOnly:!0})],$.prototype,"viewUp",null),t([n({readOnly:!0})],$.prototype,"viewRight",null),t([n({readOnly:!0})],$.prototype,"nearFar",null),t([n()],$.prototype,"near",null),t([n()],$.prototype,"far",null),t([n()],$.prototype,"viewport",null),t([n({readOnly:!0})],$.prototype,"screenViewport",null),t([n({readOnly:!0})],$.prototype,"screenPadding",null),t([n()],$.prototype,"x",null),t([n()],$.prototype,"y",null),t([n()],$.prototype,"width",null),t([n()],$.prototype,"height",null),t([n()],$.prototype,"fullWidth",null),t([n()],$.prototype,"fullHeight",null),t([n({readOnly:!0})],$.prototype,"_aspect",null),t([n()],$.prototype,"padding",null),t([n({readOnly:!0})],$.prototype,"projectionMatrix",null),t([n({readOnly:!0})],$.prototype,"inverseProjectionMatrix",null),t([n()],$.prototype,"fov",null),t([n()],$.prototype,"fovX",null),t([n()],$.prototype,"fovY",null),$=Z=t([h("esri.views.3d.webgl-engine.lib.Camera")],$);const tt=k(),it=w(),et=S(),rt=S(),st=o();var ot;!function(t){t[t.TOP=0]="TOP",t[t.RIGHT=1]="RIGHT",t[t.BOTTOM=2]="BOTTOM",t[t.LEFT=3]="LEFT"}(ot||(ot={}));export{$ as Camera,ot as PaddingSide};
5
+ import{_ as t}from"../../../../chunks/tslib.es6.js";import i from"../../../../core/Accessor.js";import e from"../../../../core/Logger.js";import{lerp as r}from"../../../../core/mathUtils.js";import{createScreenPointArray as s,createRenderScreenPointArray3 as o}from"../../../../core/screenUtils.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{copy as a,multiply as p,frustum as u,equals as _,invert as l,transpose as c,lookAt as v}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as w}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{copy as d,exactEquals as y}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as g}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{f as m,s as f,k as x,c as M,h as T,x as D,j,F as R,v as P,i as F,l as O,b as V,n as C,B as b}from"../../../../chunks/vec32.js";import{create as S}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{b as I,e as E,a as L,c as H,d as B,t as G}from"../../../../chunks/vec42.js";import{fromValues as A,create as k}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as U,copy as z,fromMatrix as W}from"../../../../geometry/support/frustum.js";import{create as X}from"../../../../geometry/support/ray.js";import{projectPointSignedLength as Y}from"../../../../geometry/support/vector.js";import{ViewingMode as q}from"../../../ViewingMode.js";import{fovd2fovx as N,fovx2fovd as J,fovd2fovy as K,fovy2fovd as Q}from"./fov.js";var Z;let $=Z=class extends i{constructor(t){super(t),this._ray=X(),this._viewport=A(0,0,1,1),this._padding=A(0,0,0,0),this._fov=55/180*Math.PI,this._nearFar=g(1,1e3),this._viewDirty=!0,this._viewMatrix=w(),this._viewProjectionDirty=!0,this._viewProjectionMatrix=w(),this._viewInverseTransposeMatrixDirty=!0,this._viewInverseTransposeMatrix=w(),this._frustumDirty=!0,this._frustum=U(),this._fullViewport=k(),this._pixelRatio=1,this.row=0,this.column=0,this._rows=1,this._columns=1,this._center=S(),this._up=S(),this.relativeElevation=0}get pixelRatio(){return this._pixelRatio}set pixelRatio(t){this._pixelRatio=t>0?t:1}get rows(){return this._rows}set rows(t){this._rows=Math.max(1,t)}get columns(){return this._columns}set columns(t){this._columns=Math.max(1,t)}get eye(){return this._ray.origin}set eye(t){this._compareAndSetView(t,this._ray.origin)}get center(){return this._center}set center(t){this._compareAndSetView(t,this._center,"_center")}get ray(){return m(this._ray.direction,this.center,this.eye),this._ray}get up(){return this._up}set up(t){this._compareAndSetView(t,this._up,"_up")}get viewMatrix(){return this._ensureViewClean(),this._viewMatrix}set viewMatrix(t){a(this._viewMatrix,t),this.notifyChange("_viewMatrix"),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0,this._viewProjectionDirty=!0,this._frustumDirty=!0}get viewForward(){return this._ensureViewClean(),f(S(),-this._viewMatrix[2],-this._viewMatrix[6],-this._viewMatrix[10])}get viewUp(){return this._ensureViewClean(),f(S(),this._viewMatrix[1],this._viewMatrix[5],this._viewMatrix[9])}get viewRight(){return this._ensureViewClean(),f(S(),this._viewMatrix[0],this._viewMatrix[4],this._viewMatrix[8])}get nearFar(){return this._nearFar}get near(){return this._nearFar[0]}set near(t){this._nearFar[0]!==t&&(this._nearFar[0]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_nearFar"))}get far(){return this._nearFar[1]}set far(t){this._nearFar[1]!==t&&(this._nearFar[1]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_nearFar"))}get viewport(){return this._viewport}set viewport(t){this.x=t[0],this.y=t[1],this.width=t[2],this.height=t[3]}get screenViewport(){if(1===this.pixelRatio)return this._viewport;const t=I(k(),this._viewport,1/this.pixelRatio),i=this._get("screenViewport");return i&&E(t,i)?i:t}get screenPadding(){if(1===this.pixelRatio)return this._padding;const t=I(k(),this._padding,1/this.pixelRatio),i=this._get("screenPadding");return i&&E(t,i)?i:t}get x(){return this._viewport[0]}set x(t){t+=this._padding[ot.LEFT],this._viewport[0]!==t&&(this._viewport[0]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get y(){return this._viewport[1]}set y(t){t+=this._padding[ot.BOTTOM],this._viewport[1]!==t&&(this._viewport[1]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get width(){return this._viewport[2]}set width(t){this._viewport[2]!==t&&(this._viewport[2]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get height(){return this._viewport[3]}set height(t){this._viewport[3]!==t&&(this._viewport[3]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get fullWidth(){return this._viewport[2]+this._padding[ot.RIGHT]+this._padding[ot.LEFT]}set fullWidth(t){this.width=t-(this._padding[ot.RIGHT]+this._padding[ot.LEFT])}get fullHeight(){return this._viewport[3]+this._padding[ot.TOP]+this._padding[ot.BOTTOM]}set fullHeight(t){this.height=t-(this._padding[ot.TOP]+this._padding[ot.BOTTOM])}get fullViewport(){return this._fullViewport[0]=this._viewport[0]-this._padding[ot.LEFT],this._fullViewport[1]=this._viewport[1]-this._padding[ot.BOTTOM],this._fullViewport[2]=this.fullWidth,this._fullViewport[3]=this.fullHeight,this._fullViewport}get _aspect(){return this.width/this.height}get padding(){return this._padding}set padding(t){L(this._padding,t)||(this._viewport[0]+=t[ot.LEFT]-this._padding[ot.LEFT],this._viewport[1]+=t[ot.BOTTOM]-this._padding[ot.BOTTOM],this._viewport[2]-=t[ot.RIGHT]+t[ot.LEFT]-(this._padding[ot.RIGHT]+this._padding[ot.LEFT]),this._viewport[3]-=t[ot.TOP]+t[ot.BOTTOM]-(this._padding[ot.TOP]+this._padding[ot.BOTTOM]),H(this._padding,t),this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_padding"),this.notifyChange("_viewport"))}get viewProjectionMatrix(){return this._viewProjectionDirty&&(p(this._viewProjectionMatrix,this.projectionMatrix,this.viewMatrix),this._viewProjectionDirty=!1),this._viewProjectionMatrix}get projectionMatrix(){const t=this.width,i=this.height,e=this.near*Math.tan(this.fovY/2)*2,r=e*this._aspect,s=e/this.rows,o=r/this.columns,n=-r/2+this.column*o,h=n+o,a=-e/2+this.row*s,p=a+s,l=u(w(),n*(1+2*this._padding[ot.LEFT]/t),h*(1+2*this._padding[ot.RIGHT]/t),a*(1+2*this._padding[ot.BOTTOM]/i),p*(1+2*this._padding[ot.TOP]/i),this.near,this.far),c=this._get("projectionMatrix");return c&&_(c,l)?c:l}get inverseProjectionMatrix(){return l(w(),this.projectionMatrix)||this._get("inverseProjectionMatrix")||w()}get fov(){return this._fov}set fov(t){this._fov=t,this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovX(){return N(this._fov,this.width,this.height)}set fovX(t){this._fov=J(t,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovY(){return K(this._fov,this.width,this.height)}set fovY(t){this._fov=Q(t,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get distance(){return x(this.center,this.eye)}get frustum(){return this._recomputeFrustum(),this._frustum}get viewInverseTransposeMatrix(){return(this._viewInverseTransposeMatrixDirty||this._viewDirty)&&(l(this._viewInverseTransposeMatrix,this.viewMatrix),c(this._viewInverseTransposeMatrix,this._viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),this._viewInverseTransposeMatrix}depthNDCToWorld(t){const i=2*t-1;return 2*this.near*this.far/(this.far+this.near-i*(this.far-this.near))}get perRenderPixelRatio(){return Math.tan(this.fovX/2)/(this.width/2)}get perScreenPixelRatio(){return this.perRenderPixelRatio*this.pixelRatio}get aboveGround(){return null!=this.relativeElevation&&this.relativeElevation>=0}copyFrom(t){M(this._ray.origin,t.eye),this.center=t.center,this.up=t.up,H(this._viewport,t.viewport),this.notifyChange("_viewport"),H(this._padding,t.padding),this.notifyChange("_padding"),d(this._nearFar,t.nearFar),this.notifyChange("_nearFar"),this._fov=t.fov,this.row=t.row,this.column=t.column,this.rows=t.rows,this.columns=t.columns,this.relativeElevation=t.relativeElevation;const i=t;return this._viewDirty=i._viewDirty,this._viewDirty||(a(this._viewMatrix,t.viewMatrix),this.notifyChange("_viewMatrix")),this._viewProjectionDirty=!0,this._frustumDirty=i._frustumDirty,this._frustumDirty||(z(this._frustum,t.frustum),this._frustumDirty=!1),i._viewInverseTransposeMatrixDirty?this._viewInverseTransposeMatrixDirty=!0:(a(this._viewInverseTransposeMatrix,t.viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),H(this._fullViewport,t.fullViewport),this.pixelRatio=t.pixelRatio,this}copyViewFrom(t){this.eye=t.eye,this.center=t.center,this.up=t.up}clone(){return(new Z).copyFrom(this)}equals(t){return T(this.eye,t.eye)&&T(this.center,t.center)&&T(this.up,t.up)&&L(this._viewport,t.viewport)&&L(this._padding,t.padding)&&y(this.nearFar,t.nearFar)&&this._fov===t.fov&&this.pixelRatio===t.pixelRatio&&this.relativeElevation===t.relativeElevation&&this.row===t.row&&this.column===t.column&&this.rows===t.rows&&this.columns===t.columns}almostEquals(t){const i=Math.max(1,1/this.pixelRatio,1/t.pixelRatio);if(Math.abs(t.fov-this._fov)>=.001||B(t.screenPadding,this.screenPadding)>=i||B(this.screenViewport,t.screenViewport)>=i||this.row!==t.row||this.column!==t.column||this.rows!==t.rows||this.columns!==t.columns)return!1;D(et,t.eye,t.center),D(rt,this.eye,this.center);const e=j(et,rt),r=R(et),s=R(rt),o=5e-4;return e*e>=(1-1e-10)*r*s&&P(t.eye,this.eye)<Math.max(r,s)*o*o}computeRenderPixelSizeAt(t){return this.computeRenderPixelSizeAtDist(this._viewDirectionDistance(t))}computeRenderPixelSizeAtDist(t){return t*this.perRenderPixelRatio}computeScreenPixelSizeAt(t){return this.computeScreenPixelSizeAtDist(this._viewDirectionDistance(t))}_viewDirectionDistance(t){return Math.abs(Y(this.viewForward,m(et,t,this.eye)))}computeScreenPixelSizeAtDist(t){return t*this.perScreenPixelRatio}computeDistanceFromRadius(t,i){return t/Math.tan(Math.min(this.fovX,this.fovY)/(2*(i||1)))}getScreenCenter(t=s()){return t[0]=(this.padding[ot.LEFT]+this.width/2)/this.pixelRatio,t[1]=(this.padding[ot.TOP]+this.height/2)/this.pixelRatio,t}getRenderCenter(t,i=.5,e=.5){return t[0]=this.padding[ot.LEFT]+this.width*i,t[1]=this.padding[ot.BOTTOM]+this.height*e,t[2]=.5,t}setGLViewport(t){const i=this.viewport,e=this.padding;t.setViewport(i[0]-e[3],i[1]-e[2],i[2]+e[1]+e[3],i[3]+e[0]+e[2])}applyProjection(t,i){t!==tt&&M(tt,t),tt[3]=1,G(tt,tt,this.projectionMatrix);const e=Math.abs(tt[3]);F(tt,tt,1/e);const s=this.fullViewport;i[0]=r(0,s[0]+s[2],.5+.5*tt[0]),i[1]=r(0,s[1]+s[3],.5+.5*tt[1]),i[2]=.5*(tt[2]+1),i[3]=e}unapplyProjection(t,i){const e=this.fullViewport;tt[0]=(t[0]/(e[0]+e[2])*2-1)*t[3],tt[1]=(t[1]/(e[1]+e[3])*2-1)*t[3],tt[2]=(2*t[2]-1)*t[3],tt[3]=t[3],null!=this.inverseProjectionMatrix&&(G(tt,tt,this.inverseProjectionMatrix),i[0]=tt[0],i[1]=tt[1],i[2]=tt[2])}projectToScreen(t,i){return this.projectToRenderScreen(t,st),this.renderToScreen(st,i),i}projectToRenderScreen(t,i){if(tt[0]=t[0],tt[1]=t[1],tt[2]=t[2],tt[3]=1,G(tt,tt,this.viewProjectionMatrix),0===tt[3])return null;const e=tt;F(e,e,1/Math.abs(tt[3]));const s=this.fullViewport,o=r(0,s[0]+s[2],.5+.5*e[0]),n=r(0,s[1]+s[3],.5+.5*e[1]);return"x"in i?(i.x=o,i.y=n):(i[0]=o,i[1]=n,i.length>2&&(i[2]=.5*(e[2]+1))),i}unprojectFromScreen(t,i){return this.unprojectFromRenderScreen(this.screenToRender(t,st),i)}unprojectFromRenderScreen(t,i){if(p(it,this.projectionMatrix,this.viewMatrix),!l(it,it))return null;const e=this.fullViewport;return tt[0]=2*(t[0]-e[0])/e[2]-1,tt[1]=2*(t[1]-e[1])/e[3]-1,tt[2]=2*t[2]-1,tt[3]=1,G(tt,tt,it),0===tt[3]?null:(i[0]=tt[0]/tt[3],i[1]=tt[1]/tt[3],i[2]=tt[2]/tt[3],i)}constrainWindowSize(t,i,e,r){const s=t*this.pixelRatio,o=i*this.pixelRatio,n=Math.max(s-e/2,0),h=Math.max(this.fullHeight-o-r/2,0),a=-Math.min(s-e/2,0),p=-Math.min(this.fullHeight-o-r/2,0),u=e-a- -Math.min(this.fullWidth-s-e/2,0),_=r-p- -Math.min(o-r/2,0);return[Math.round(n),Math.round(h),Math.round(u),Math.round(_)]}computeUp(t){t===q.Global?this._computeUpGlobal():this._computeUpLocal()}screenToRender(t,i){const e=t[0]*this.pixelRatio,r=this.fullHeight-t[1]*this.pixelRatio;return i[0]=e,i[1]=r,i}renderToScreen(t,i){const e=t[0]/this.pixelRatio,r=(this.fullHeight-t[1])/this.pixelRatio;i[0]=e,i[1]=r}_computeUpGlobal(){m(et,this.center,this.eye);const t=O(this.center);t<1?(f(this._up,0,0,1),this._markViewDirty(),this.notifyChange("_up")):Math.abs(j(et,this.center))>.9999*O(et)*t||(V(this._up,et,this.center),V(this._up,this._up,et),C(this._up,this._up),this.notifyChange("_up"),this._markViewDirty())}_computeUpLocal(){b(et,this.eye,this.center),Math.abs(et[2])<=.9999&&(F(et,et,et[2]),f(this._up,-et[0],-et[1],1-et[2]),C(this._up,this._up),this.notifyChange("_up"),this._markViewDirty())}_compareAndSetView(t,i,r=""){"number"==typeof t[0]&&isFinite(t[0])&&"number"==typeof t[1]&&isFinite(t[1])&&"number"==typeof t[2]&&isFinite(t[2])?T(t,i)||(M(i,t),this._markViewDirty(),r.length&&this.notifyChange(r)):e.getLogger("esri.views.3d.webgl-engine.lib.Camera").warn("Camera vector contains invalid number, ignoring value")}_markViewDirty(){this._viewDirty=!0,this._frustumDirty=!0,this._viewProjectionDirty=!0}_recomputeFrustum(){this._frustumDirty&&(W(this.viewMatrix,this.projectionMatrix,this._frustum),this._frustumDirty=!1)}_ensureViewClean(){this._viewDirty&&(v(this._viewMatrix,this.eye,this.center,this.up),this.notifyChange("_viewMatrix"),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0)}};t([n()],$.prototype,"_viewport",void 0),t([n()],$.prototype,"_padding",void 0),t([n()],$.prototype,"_fov",void 0),t([n()],$.prototype,"_nearFar",void 0),t([n()],$.prototype,"_viewDirty",void 0),t([n()],$.prototype,"_viewMatrix",void 0),t([n()],$.prototype,"_pixelRatio",void 0),t([n()],$.prototype,"pixelRatio",null),t([n()],$.prototype,"row",void 0),t([n()],$.prototype,"column",void 0),t([n()],$.prototype,"_rows",void 0),t([n()],$.prototype,"rows",null),t([n()],$.prototype,"_columns",void 0),t([n()],$.prototype,"columns",null),t([n()],$.prototype,"eye",null),t([n()],$.prototype,"center",null),t([n()],$.prototype,"_center",void 0),t([n()],$.prototype,"up",null),t([n()],$.prototype,"_up",void 0),t([n({readOnly:!0})],$.prototype,"viewForward",null),t([n({readOnly:!0})],$.prototype,"viewUp",null),t([n({readOnly:!0})],$.prototype,"viewRight",null),t([n({readOnly:!0})],$.prototype,"nearFar",null),t([n()],$.prototype,"near",null),t([n()],$.prototype,"far",null),t([n()],$.prototype,"viewport",null),t([n({readOnly:!0})],$.prototype,"screenViewport",null),t([n({readOnly:!0})],$.prototype,"screenPadding",null),t([n()],$.prototype,"x",null),t([n()],$.prototype,"y",null),t([n()],$.prototype,"width",null),t([n()],$.prototype,"height",null),t([n()],$.prototype,"fullWidth",null),t([n()],$.prototype,"fullHeight",null),t([n({readOnly:!0})],$.prototype,"_aspect",null),t([n()],$.prototype,"padding",null),t([n({readOnly:!0})],$.prototype,"projectionMatrix",null),t([n({readOnly:!0})],$.prototype,"inverseProjectionMatrix",null),t([n()],$.prototype,"fov",null),t([n()],$.prototype,"fovX",null),t([n()],$.prototype,"fovY",null),$=Z=t([h("esri.views.3d.webgl-engine.lib.Camera")],$);const tt=k(),it=w(),et=S(),rt=S(),st=o();var ot;!function(t){t[t.TOP=0]="TOP",t[t.RIGHT=1]="RIGHT",t[t.BOTTOM=2]="BOTTOM",t[t.LEFT=3]="LEFT"}(ot||(ot={}));export{$ as Camera,ot as PaddingSide};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import{releaseMaybe as t}from"../../../../core/maybe.js";import{c as e}from"../../../../chunks/vec42.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ColorFormat as i,DepthFormat as o}from"../core/FBOCache.js";import{RendererTarget as h}from"./rendererUtils.js";import{TransparencyPassType as s}from"./TransparencyPassType.js";import{ClearBufferBit as c}from"../../../webgl/enums.js";import{ensureAttachmentMaxSize as a}from"../../../webgl/FramebufferObject.js";class l{constructor(t,e){this._fbos=t,this.compositingHelper=e,this._width=4,this._height=4,this._clearColor=r()}dispose(){this._color=t(this._color),this.releaseBuffers()}get framebuffer(){return this.color.detachDepth(),this.color.attachDepth(this.depth),this.color.fbo}get colorTexture(){return this.color.colorTexture}get depthTexture(){return this.depth.attachment}initializeFrame(t,r,i){this._fbos.interactive=i===h.Default;const o=this._fbos.rctx;this._width=t.fullWidth,this._height=t.fullHeight,a(this,o.parameters.maxTextureSize);const s=this._color;return this._color=null,this.releaseBuffers(),e(this._clearColor,r),s}releaseBuffers(){this._color?.detachDepth(),this._depth=t(this._depth)}renderHUDVisibility(t,e,r){return t?.fbo.width===this._width&&t?.fbo.height===this._height||(t?.release(),t=this._fbos.acquire(i.RGBA4,this._width,this._height,"hud visibility")),t.attachDepth(r||this.depth),this._fbos.rctx.bindFramebuffer(t.fbo),this.renderToFBO(e,f),t.detachDepth(),t}compositeToHUDVisibility(t,e){this._fbos.rctx.bindFramebuffer(t.hudVisibility?.fbo),this.compositingHelper.compositeHUD(t,e)}renderOITPass(t,e,r){let h,c;const{_width:a,_height:l}=this;switch(e){case s.Color:h=this._fbos.acquire(i.RGBA16F,a,l,r?"oit hud color":"oit color"),c=[0,0,0,0];break;case s.Alpha:h=this._fbos.acquire(i.R16F,a,l,r?"oit hud alpha":"oit alpha"),c=[1,1,1,1];break;case s.FrontFace:h=this._fbos.acquire(i.RGBA,a,l,r?"oit hud front":"oit front"),c=[0,0,0,0]}return r?(h.acquireDepth(o.DEPTH16_BUFFER),this._fbos.rctx.bindFramebuffer(h.fbo),this.renderToFBO(t,c,!0,!0),h.releaseDepth()):(h.attachDepth(this.depth),this._fbos.rctx.bindFramebuffer(h.fbo),this.renderToFBO(t,c),h.detachDepth()),h}compositeToFramebuffer(t,e,r,i){this.bindFbo(),this.compositingHelper.composite(t,e,r,i)}compositeTransparentOntoOpaque(t,e,r,i,o){o?(this._fbos.rctx.bindFramebuffer(o.fbo),this._fbos.rctx.setClearColor(0,0,0,1e-13),this._fbos.rctx.clearSafe(c.COLOR_BUFFER_BIT)):this.bindFbo(),this.compositingHelper.compositeOIT(t,e.colorTexture,r.colorTexture,i.colorTexture)}renderDepthDetached(t){this._bindTarget(this.color),t(),this._bindTarget(this.color,this.depth)}renderToCachedFBO(e,r,h,s,c=i.RGBA,a=o.DEPTH16_BUFFER,l=this._width,f=this._height,_=null){return e?.fbo.width===l&&e?.fbo.height===f||(e=t(e)),e=e??this._fbos.acquire(c,l,f,r),null!=a&&e.acquireDepth(a),_?.forEach((t=>{e.acquireColor(t.format,t.attachment)})),this._fbos.rctx.bindFramebuffer(e.fbo),this.renderToFBO(h,s,!0,!0),e}renderToFBO(t,e,r=!1,i=!1){const o=this._fbos.rctx;let h=0;if(e){const t=1e-13,r=Math.max(t,e[3]);o.setClearColor(e[0],e[1],e[2],r),h|=c.COLOR_BUFFER_BIT}r&&(h|=c.DEPTH_BUFFER_BIT),!1===i?i=0:(!0===i&&(i=255),h|=c.STENCIL_BUFFER_BIT),h&&o.clearSafe(h,i),t(),o.gl.flush()}renderToTargets(t,e,r,i,o=!1,h=!1){this._bindTarget(e,r),this.renderToFBO(t,i,o,h),e.detachDepth()}bindFbo(){const t=null==this._color;if(this._bindTarget(this.color,this.depth),t){const t=this._fbos.rctx;t.setClearStencil(0),t.setClearColor(this._clearColor[0],this._clearColor[1],this._clearColor[2],this._clearColor[3]),t.clearSafe(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT|c.STENCIL_BUFFER_BIT)}}_bindTarget(t,e){t.detachDepth(),t.attachDepth(e),this._fbos.rctx.bindFramebuffer(t.fbo)}get width(){return this._width}get height(){return this._height}get color(){return this._color||(this._color=this._fbos.acquire(i.RGBA,this._width,this._height,"composite-color")),this._color}get depth(){return this._depth||(this._depth=this._fbos.acquireDepth(o.DEPTH_STENCIL_TEXTURE,this._width,this._height,"depth")),this._depth}}const f=[0,1,0,1];export{l as OffscreenRendering};
5
+ import"../../../../core/has.js";import{releaseMaybe as t}from"../../../../core/maybe.js";import{c as e}from"../../../../chunks/vec42.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ColorFormat as i,DepthFormat as o}from"../core/FBOCache.js";import{RendererTarget as h}from"./rendererUtils.js";import{TransparencyPassType as s}from"./TransparencyPassType.js";import{ClearBufferBit as c}from"../../../webgl/enums.js";import{ensureAttachmentMaxSize as a}from"../../../webgl/FramebufferObject.js";class l{constructor(t,e){this._fbos=t,this.compositingHelper=e,this._width=4,this._height=4,this._clearColor=r()}dispose(){this._color=t(this._color),this.releaseBuffers()}get framebuffer(){return this.color.detachDepth(),this.color.attachDepth(this.depth),this.color.fbo}get colorTexture(){return this.color.colorTexture}get depthTexture(){return this.depth.attachment}initializeFrame(t,r,i){this._fbos.interactive=i===h.Default;const o=this._fbos.rctx;this._width=t.fullWidth,this._height=t.fullHeight,a(this,o.parameters.maxTextureSize);const s=this._color;return this._color=null,this.releaseBuffers(),e(this._clearColor,r),s}releaseBuffers(){this._color?.detachDepth(),this._depth=t(this._depth)}renderHUDVisibility(t,e,r){return t?.fbo.width===this._width&&t?.fbo.height===this._height||(t?.release(),t=this._fbos.acquire(this._width,this._height,"hud visibility",i.RGBA4)),t.attachDepth(r||this.depth),this._fbos.rctx.bindFramebuffer(t.fbo),this.renderToFBO(e,f),t.detachDepth(),t}compositeToHUDVisibility(t,e){this._fbos.rctx.bindFramebuffer(t.hudVisibility?.fbo),this.compositingHelper.compositeHUD(t,e)}renderOITPass(t,e,r){let h,c;const{_width:a,_height:l}=this;switch(e){case s.Color:h=this._fbos.acquire(a,l,r?"oit hud color":"oit color",i.RGBA16F),c=[0,0,0,0];break;case s.Alpha:h=this._fbos.acquire(a,l,r?"oit hud alpha":"oit alpha",i.R16F),c=[1,1,1,1];break;case s.FrontFace:h=this._fbos.acquire(a,l,r?"oit hud front":"oit front"),c=[0,0,0,0]}return r?(h.acquireDepth(o.DEPTH16_BUFFER),this._fbos.rctx.bindFramebuffer(h.fbo),this.renderToFBO(t,c,!0,!0),h.releaseDepth()):(h.attachDepth(this.depth),this._fbos.rctx.bindFramebuffer(h.fbo),this.renderToFBO(t,c),h.detachDepth()),h}compositeToFramebuffer(t,e,r,i){this.bindFbo(),this.compositingHelper.composite(t,e,r,i)}compositeTransparentOntoOpaque(t,e,r,i,o){o?(this._fbos.rctx.bindFramebuffer(o.fbo),this._fbos.rctx.setClearColor(0,0,0,1e-13),this._fbos.rctx.clearSafe(c.COLOR_BUFFER_BIT)):this.bindFbo(),this.compositingHelper.compositeOIT(t,e.colorTexture,r.colorTexture,i.colorTexture)}renderDepthDetached(t){this._bindTarget(this.color),t(),this._bindTarget(this.color,this.depth)}renderToCachedFBO(e,r,h,s,c=i.RGBA,a=o.DEPTH16_BUFFER,l=this._width,f=this._height,_=null){return e?.fbo.width===l&&e?.fbo.height===f||(e=t(e)),e=e??this._fbos.acquire(l,f,r,c),null!=a&&e.acquireDepth(a),_?.forEach((t=>{e.acquireColor(t.format,t.attachment)})),this._fbos.rctx.bindFramebuffer(e.fbo),this.renderToFBO(h,s,!0,!0),e}renderToFBO(t,e,r=!1,i=!1){const o=this._fbos.rctx;let h=0;if(e){const t=1e-13,r=Math.max(t,e[3]);o.setClearColor(e[0],e[1],e[2],r),h|=c.COLOR_BUFFER_BIT}r&&(h|=c.DEPTH_BUFFER_BIT),!1===i?i=0:(!0===i&&(i=255),h|=c.STENCIL_BUFFER_BIT),h&&o.clearSafe(h,i),t(),o.gl.flush()}renderToTargets(t,e,r,i,o=!1,h=!1){this._bindTarget(e,r),this.renderToFBO(t,i,o,h),e.detachDepth()}bindFbo(){const t=null==this._color;if(this._bindTarget(this.color,this.depth),t){const t=this._fbos.rctx;t.setClearStencil(0),t.setClearColor(this._clearColor[0],this._clearColor[1],this._clearColor[2],this._clearColor[3]),t.clearSafe(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT|c.STENCIL_BUFFER_BIT)}}_bindTarget(t,e){t.detachDepth(),t.attachDepth(e),this._fbos.rctx.bindFramebuffer(t.fbo)}get width(){return this._width}get height(){return this._height}get color(){return this._color||(this._color=this._fbos.acquire(this._width,this._height,"composite-color")),this._color}get depth(){return this._depth||(this._depth=this._fbos.acquireDepth(o.DEPTH_STENCIL_TEXTURE,this._width,this._height,"depth")),this._depth}}const f=[0,1,0,1];export{l as OffscreenRendering};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{update as t}from"../../../../core/arrayUtils.js";import{unitRGBAFromColor as s}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{removeMaybe as i,destroyMaybe as a,releaseMaybe as n}from"../../../../core/maybe.js";import h from"../../../../core/PooledArray.js";import{watch as o,syncAndInitial as d,initial as l,sync as _}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{equals as c,invert as m,multiply as f}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as g,create as T}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as A}from"../../../../chunks/vec42.js";import{fromValues as E,ZEROS as b}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{a as R}from"../../../../chunks/boundedPlane.js";import{debugFlags as P}from"../../support/debugFlags.js";import{TransparencyMode as S}from"../../terrain/TerrainRenderer.js";import{DepthFormat as D,FBOCache as O,ColorFormat as y}from"../core/FBOCache.js";import{RenderPassManager as C}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as I}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as w}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{RenderNodeCollection as N}from"../effects/RenderNodeCollection.js";import{isPrepareRenderPlugin as L}from"../effects/RenderPlugin.js";import{RenderPluginInput as H}from"../effects/RenderPluginInput.js";import{RenderPluginManager as M}from"../effects/RenderPluginManager.js";import{Blit as F}from"../effects/blit/Blit.js";import{Highlight as x}from"../effects/highlight/Highlight.js";import{ShadowHighlight as v}from"../effects/highlight/ShadowHighlight.js";import{SMAA as U}from"../effects/smaa/SMAA.js";import{SSAO as G}from"../effects/ssao/SSAO.js";import{AnimationTimeStep as B}from"./AnimationTimeStep.js";import{Decorations as q,RenderRequestType as j,StencilBits as V}from"./basicInterfaces.js";import{BoundingInfo as Q}from"./BoundingInfo.js";import{zero as W,union as k}from"./depthRange.js";import{depthRangeFromScene as X}from"./depthRangeUtils.js";import{RenderOccludedFlag as Y}from"./Material.js";import{OffscreenRendering as z}from"./OffscreenRendering.js";import{RenderContext as J,defaultRenderOccludedMask as K}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as Z,RendererTarget as $}from"./rendererUtils.js";import{setupFeatureDefaults as ee,RenderFeature as re}from"./RenderFeature.js";import{RenderSlot as te}from"./RenderSlot.js";import{ShadowAccumulator as se}from"./ShadowAccumulator.js";import{ShadowMap as ie,SnapshotSlot as ae}from"./ShadowMap.js";import ne from"./SliceHelper.js";import{TransparencyPassType as he}from"./TransparencyPassType.js";import{EdgeView as oe}from"./edgeRendering/EdgeView.js";import{Transparency as de}from"./edgeRendering/interfaces.js";import{MergedRenderer as le}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as _e}from"../shaders/CompositingTechniqueConfiguration.js";import{RendererPerformanceInfo as pe,PerformanceCategory as ue}from"../statistics/RendererPerformanceInfo.js";import{RenderState as ce}from"../../../support/RenderState.js";import{PixelFormat as me,PixelType as fe,ClearBufferBit as ge}from"../../../webgl/enums.js";let Te=class extends r{get _bindParameters(){return this._renderContext.bindParameters}updateRenderFeatures(e=null,r=!has("disable-feature:high-quality-idle")){this._renderStateFeatures=ee(r,e),this.notifyChange("_renderStateFeatures"),this._plugins.renderFeatureChanged(),this._requestRender()}isFeatureEnabled(e,r=this._state){return this._renderStateFeatures.get(r,e)??!1}setFeatureEnabled(e,r,t){this._renderStateFeatures.set(r,e,t),this.notifyChange("_renderStateFeatures"),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(re.HighQualityTransparency)}get hasReflections(){return(this._pluginsHas.water||this._hasOverlayWater)&&(this._ssrEnabled||this.isFeatureEnabled(re.WaterReflection))}get hasDecorations(){return this._plugins.hasDecorations}get hasHighlights(){return this._plugins.produces(te.OPAQUE_MATERIAL,I.Highlight)||this._plugins.produces(te.DRAPED_MATERIAL,I.Highlight)}get _magnifierEnabled(){return this._bindParameters.decorations===q.ON&&this._magnifierHelper.enabled}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(re.HighResolutionAtmosphere)}constructor(e,r,t,i,a,n,h,_){super({}),this._stage=e,this._techniqueRepository=i,this._rctx=a,this._compositingHelper=n,this._magnifierHelper=h,this._requestRender=_,this._needsTransparentPass=!1,this._pluginsHas={hudElements:!1,water:!1},this._hasOverlayWater=!1,this.renderOverlay=e=>{},this._isRendering=!1,this._backgroundColor=E(0,0,0,1),this._sliceHelper=new ne,this._renderNodes=new N,this._state=ce.IDLE,this._highQualityTransparencyEnabled=!0,this._terrainTransparency=S.Opaque,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new B,this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new H,this._releaseGeometryLinearDepth=e=>e?.release(),this._geometryLinearDepthFormat=D.DEPTH16_BUFFER,this.fboCache=new O(a),this._renderStateFeatures=ee(!has("disable-feature:high-quality-idle"),e.view.qualityProfile),this._offscreen=new z(this.fboCache,this._compositingHelper),this.performanceInfo=new pe(this._rctx),this._shadowMap=new ie(this.fboCache,e.viewingMode),this._highlight=new x({view:e.view}),this._shadowHighlight=new v({view:e.view,viewingMode:e.viewingMode}),this._shadowAccumulator=new se(this.fboCache,i,e,(e=>{const r=this.shadowsEnabled;this._shadowMap.enabled=!0,this._prepare(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=r}),((e,r,t)=>{const s=this._stage.view.qualitySettings.maximumPixelRatio;e.shadowMap.start(e.camera,r,t,!0,s),this._renderShadowCascades(I.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._prepare(e.camera,e.contentCamera)}),_),this._ssao=new G({view:this._stage.view}),this._renderContext=new J(this._rctx,this._offscreen,this._shadowMap,this._sliceHelper),this._plugins=new M({renderContext:this._renderContext,techniqueRepository:i,textureRepository:t,materialRepository:r,requestRender:_,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this.renderPassManager=new C,this._plugins.add(this.renderPassManager),this._smaa=new U({view:this._stage.view}),this._plugins.add(this._smaa),this._blit=new F({opacity:1,alphaMode:_e.None}),this._plugins.add(this._blit),this._plugins.add(this._ssao),this._plugins.add(this._highlight),this._plugins.add(this._shadowHighlight),this.addHandles([o((()=>this._stage.view.state.camera),(()=>_()),d),o((()=>P.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(de.TRANSPARENT):()=>{},_()}),l),o((()=>this._stage.view.environment.background?.color),(e=>{const r=e?s(e):b;A(this._backgroundColor,r[0]*r[3],r[1]*r[3],r[2]*r[3],r[3]),_()}),d)])}normalizeCtorArgs(){return{}}destroy(){this._gpuTimerHandle=i(this._gpuTimerHandle),this._offscreen.dispose(),this._shadowMap.dispose(),this._highlight.dispose(),this._shadowAccumulator.dispose(),this._edgeView=a(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),this._plugins.destroy(),Q.prune()}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth),this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth)}_disposeOffscreenBuffers(){this._offscreen.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.linearDepth=n(this._bindParameters.linearDepth),this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility)}get updating(){return this._smaa.updating||null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._plugins.updating||!this.isCameraFinal}ensureEdgeView(){if(null==this._edgeView){const e=this._stage.view.resourceController;this._edgeView=new oe({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniqueRepository:this._techniqueRepository,setNeedsRender:()=>this._requestRender(),schedule:Oe(e)}),this.addHandles(o((()=>this._edgeView?.updating),(()=>this._requestRender()),_)),this._requestRender()}return this._edgeView}get edgeView(){return this._edgeView}get isCameraFinal(){return c(this._bindParameters.ssr.reprojectionMatrix,g)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this.notifyChange("isCameraFinal")}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:r,_bindParameters:t}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&r.maxCascades!==e.shadowMapMaxCascades&&(r.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const r="virtual"!==e.environment.lighting.type;t.enableFillLights!==r&&(t.enableFillLights=r,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=e.slicePlane,this._requestRender()),void 0!==e.terrainTransparency&&this._terrainTransparency!==e.terrainTransparency&&(this._terrainTransparency=e.terrainTransparency,this._requestRender()),void 0!==e.shadowCastOptions&&this._shadowAccumulator.setOptions(e.shadowCastOptions)}get hasSlicePlane(){return!!this._sliceHelper.plane}get plugins(){return this._plugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,r){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:t,removes:s,updates:i}=e;if(0===t.length&&0===s.length&&0===i.length)return;const a=Z(e);let n=!1;a.forEach(((t,s)=>{if(r.done)return;let i=this._plugins.getMaterialRenderer(s);if(null==i&&t.adds.length>0){const e=new le({material:s});e.initializeRenderContext(this._plugins._context),i=e,this._plugins.add(i)}i&&(i.modify(t),0===i.numGeometries&&(n=!0)),t.removes.forEach((r=>e.removes.removeUnordered(r))),t.adds.forEach((r=>e.adds.removeUnordered(r))),t.updates.forEach((r=>e.updates.removeUnordered(r))),r.madeProgress()})),n&&this._plugins.removeEmptyMaterialRenderers(),this._updateHasFlags(),this._requestRender()}_updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(te.LINE_CALLOUTS_HUD_DEPTH)||this._plugins.produces(te.HUD_MATERIAL)||this._plugins.produces(te.LABEL_MATERIAL),has.water=this._plugins.produces(te.DRAPED_WATER,I.Normal),this._bindParameters.hasOccludees=this._plugins.hasOccludees}updateAnimation(e){const r=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(e)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?i(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,r,t=$.Default,s=q.ON){this._isRendering=!0,this.performanceInfo.startFrame(),this.fboCache.frameStart(),this._disposeBindBuffers();const i=this._offscreen,{camera:a,contentCamera:h,mode:o,alignPixelEnabled:d}=e;this._state=o,this._bindParameters.overlay=this.renderOverlay(r),this.performanceInfo.advance(ue.OVERLAY),this._renderContext.time=r,this._bindParameters.transparencyPassType=he.NONE,this._bindParameters.alignPixelEnabled=d,this._bindParameters.decorations=s,this._bindParameters.mainColor=this._bindParameters.mainDepth=null;const l=R(this._sliceHelper.plane);s===q.OFF&&(this._sliceHelper.plane=null),a.setGLViewport(this._rctx);const _=i.initializeFrame(a,this._backgroundColor,t);this.hasReflections?this._bindParameters.ssr.lastFrameColor=_:_?.release(),this._prepare(a,h),this._plugins.prepareRender(),this.performanceInfo.advance(ue.PREPARE);const p=this._computeDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,p),this.performanceInfo.advance(ue.SHADOW_MAP),this._ensureBindParameters(a,h);const u=this._plugins.produces(te.OPAQUE_TERRAIN)&&(this._terrainTransparency===S.Semitransparent||this._terrainTransparency===S.TransparentWithDraped),c=this._highQualityTransparency&&u;this._prepareShaders(c,this._needsTransparentPass),this._renderLinearDepthForSSAO(),this.performanceInfo.advance(ue.LINEAR_DEPTH_SSAO);let m=this._renderNormals();this.performanceInfo.advance(ue.NORMALS);let f=m?.detachDepth();this._renderSSAO(m),m&&!this._renderNodes.consumes("normals")&&(m.release(),m=null),this.performanceInfo.advance(ue.SSAO),this._renderLinearDepth(f),f=n(f),this.performanceInfo.advance(ue.LINEAR_DEPTH),this._renderShadowAccumulation(p,a,h),this.performanceInfo.advance(ue.ACCUMULATED_SHADOWS),this._ensureBindParametersSSR(r),this._renderContext.output=I.Color,i.bindFbo(),this._bindParameters.mainColor=i.colorTexture,this._bindParameters.mainDepth=i.depthTexture,this._renderOpaqueGeometry(),this._plugins.render(te.ENVIRONMENT_OPAQUE),this.performanceInfo.advance(ue.OPAQUE),this.fboCache.debugCallback&&this.fboCache.debugCallback("opaque color",this._offscreen.color.fbo),this._renderTerrainLinearDepth(c),this._setMultipassTerrain(c),this._renderEdges(de.OPAQUE),this.performanceInfo.advance(ue.OPAQUE_EDGES),i.bindFbo(),this._plugins.render(te.VOXEL),this.performanceInfo.advance(ue.VOXEL),this._renderHiddenTransparentEdges(),this._needsTransparentPass&&(this._oitEnabled?this._renderOITPass(Ae.Geometry):this._renderTransparentMaterial()),this.performanceInfo.advance(ue.TRANSPARENT);const g=this._renderGeometryLinearDepth(c);this._renderHUDVisibility(g),c||this._plugins.render(te.LINE_CALLOUTS),this.performanceInfo.advance(ue.HUD_VISIBILITY);const T=t===$.ObjectAndLayerID?this._renderObjectAndLayerIdColor():null;this.performanceInfo.advance(ue.OBJECT_AND_LAYER_ID_COLOR),this._renderEdges(de.TRANSPARENT,g),this._releaseGeometryLinearDepth(g),this.performanceInfo.advance(ue.TRANSPARENT_EDGES);const A=u?this._renderTransparentTerrain():null;A&&this._bindParameters.hudVisibility&&(c?this._renderLineCallouts(w.Occluded):i.compositeToHUDVisibility(this._bindParameters,A.colorTexture),this._renderHUD(w.Occluded,i.color),this.performanceInfo.advance(ue.HUD_OCCLUDED)),this.performanceInfo.advance(ue.TRANSPARENT_TERRAIN),this._setTerrainCulling(!1),A&&(i.compositeToFramebuffer(this._bindParameters,A.colorTexture,_e.PremultipliedAlpha,1),A.release(),c&&(this._renderEdges(de.OPAQUE),this.performanceInfo.advance(ue.OPAQUE_EDGES),this._needsTransparentPass&&(this._oitEnabled?this._renderOITPass(Ae.Geometry):this._renderTransparentMaterial()),this.performanceInfo.advance(ue.TRANSPARENT),this._renderEdges(de.TRANSPARENT),this.performanceInfo.advance(ue.TRANSPARENT_EDGES))),this._bindParameters.ssao=n(this._bindParameters.ssao),c&&this._renderLineCallouts(w.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),i.bindFbo(),this._plugins.render(te.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._plugins.render(te.ENVIRONMENT_TRANSPARENT),this.performanceInfo.advance(ue.ENVIRONMENT),this._renderLaserlines(),this.performanceInfo.advance(ue.LASER_LINES),this._renderOccluded(),this.performanceInfo.advance(ue.OCCLUDED);const E=this._renderHighlightPrepass(),b=this._magnifierEnabled&&t===$.Default?this.fboCache.acquire(y.RGBA,this._offscreen.width,this._offscreen.height,"magnifier"):null,P=t!==$.Default?this.fboCache.acquire(y.RGBA,this._offscreen.width,this._offscreen.height,"screenshot"):null,D=this._renderComposite(b??P,this._offscreen.color,m,E)??P;return m?.release(),this.performanceInfo.advance(ue.ANTIALIASING),this._renderHUD(w.NotOccluded,D),this.performanceInfo.advance(ue.HUD),this._renderHighlights(D,E,this._bindParameters),E?.release(),this.performanceInfo.advance(ue.HIGHLIGHTS),this._magnifierEnabled&&this._magnifierHelper.render(this._rctx,this._bindParameters),D!==P&&(this._rctx.bindFramebuffer(P?.fbo),this._compositingHelper.composite(this._bindParameters,b?.colorTexture,_e.None)),t===$.Default&&b?.release(),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),this._offscreen.releaseBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=l,this._isRendering=!1,this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),t!==$.Default&&(this._releaseFBOs(),this._disposeOffscreenBuffers()),{screen:P,oid:T}}_prepareShaders(e,r){this._renderContext.output=I.Color,this._prepareOpaqueGeometry(),this._setMultipassTerrain(e),this._plugins.prepare(te.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._plugins.prepare(te.LINE_CALLOUTS),r&&this._prepareTransparencySlots(),this._plugins.prepare(te.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._plugins.prepare(te.ENVIRONMENT_TRANSPARENT),this._plugins.prepare(te.LASERLINES),this._rctx.gl.flush()}_renderObjectAndLayerIdColor(){if(!has("enable-feature:objectAndLayerId-rendering"))return;const e=this._renderContext.output,r=this.fboCache.acquire(y.RGBA,this._offscreen.width,this._offscreen.height,"oid");return r.acquireDepth(D.DEPTH_STENCIL_TEXTURE),this._rctx.bindFramebuffer(r.fbo),this._offscreen.renderToFBO((()=>this._renderAllGeometry(I.ObjectAndLayerIdColor)),[0,0,0,0],!0,!0),this._rctx.bindFramebuffer(r.fbo),this._offscreen.renderToFBO((()=>{this._bindParameters.hudRenderStyle=w.NotOccluded,this._plugins.render(te.HUD_MATERIAL)}),void 0,!0,!0),this._renderContext.output=e,r}finish(e){this._hasAnimations||this._animationTimestep.clear();const r=this.performanceInfo.gpuSamplingEnabled,t=e===j.BACKGROUND;if(t||r){const e=t?this.performanceInfo.elapsedTime:0,s=r?this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.getError(),i=Math.max(e,s);this._animationTimestep.frame(i,t)}}readDepthPixels(e,r,t){const s=this._bindParameters.linearDepth?.fbo;if(s?.colorTexture)return void s.readPixels(r[0],r[1],r[2],r[3],me.RGBA,fe.UNSIGNED_BYTE,t);const i=this.fboCache.acquire(y.RGBA,this._offscreen.width,this._offscreen.height,"depth").acquireDepth(D.DEPTH16_BUFFER);this._rctx.bindFramebuffer(i.fbo),this._ensureBindParameters(e,e),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.setClearColor(0,0,0,0);const a=ge.COLOR_BUFFER_BIT|ge.DEPTH_BUFFER_BIT|ge.STENCIL_BUFFER_BIT;this._rctx.clearSafe(a),this._renderAllGeometry(I.Depth),i.fbo.readPixels(r[0],r[1],r[2],r[3],me.RGBA,fe.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,r,t,s,i){this._bindParameters.hudVisibility?.fbo.readPixels(e,r,t,s,me.RGBA,fe.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_setMultipassTerrain(e){this._setMultipassEnabled(e),this._setTerrainCulling(e)}_setMultipassEnabled(e){this._bindParameters.multipassEnabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_renderEdges(e,r){const t=this._edgeView;if(t?.shouldRender()){const{width:s,height:i,depth:a}=this._offscreen,n=this.fboCache.acquire(y.RGBA,s,i,"edges"),h=()=>t.render(this._bindParameters,e);this._offscreen.renderToTargets(h,n,r??a,be),this._offscreen.compositeToFramebuffer(this._bindParameters,n.colorTexture,_e.Alpha,1),n.release()}}_renderShadowMap(e,r,t){const s=this._shadowMap;s.enabled&&(s.start(e,r,t,this.isFeatureEnabled(re.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._shadowHighlight.updateParameters(e,r),this._needsShadowHighlight?(this._renderShadowCascades(I.ShadowHighlight,this._shadowMap),s.moveSnapshot(ae.Highlight),this._renderShadowCascades(I.ShadowExcludeHighlight,this._shadowMap),s.copySnapshot(ae.ExcludeHighlight),this._renderShadowCascades(I.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(I.Shadow),s.finish(),e.setGLViewport(this._rctx))}_renderShadowCascades(e,r=this._shadowMap){for(const t of r.cascades)t.camera.setGLViewport(this._rctx),this._prepare(t.camera,t.camera),this._renderAllGeometry(e)}get _needsLinearDepth(){return this._plugins.consumes(I.Depth)||this._renderNodes.consumes("linear-depth")||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast}_renderLinearDepthForSSAO(){this._plugins.produces(te.SSAO)&&(this._bindParameters.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.linearDepth,"linear-depth",(()=>this._renderGeometryForSSAO(I.Depth)),[0,0,0,0],y.RGBA,D.DEPTH_STENCIL_TEXTURE),this._bindParameters.linearDepth.releaseDepth())}_renderLinearDepth(e){if(this._needsLinearDepth){if(this._plugins.produces(te.SSAO)&&e&&this._bindParameters.linearDepth)return this._bindParameters.linearDepth.attachDepth(e),this._rctx.bindFramebuffer(this._bindParameters.linearDepth.fbo),this._offscreen.renderToFBO((()=>this._renderGeometryExcludedFromSSAO(I.Depth))),void this._bindParameters.linearDepth.detachDepth();this._bindParameters.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.linearDepth,"linear-depth",(()=>this._renderAllGeometry(I.Depth)),[0,0,0,0],y.RGBA,D.DEPTH_STENCIL_TEXTURE),this._bindParameters.linearDepth.releaseDepth()}else this._bindParameters.linearDepth=n(this._bindParameters.linearDepth)}_renderTerrainLinearDepth(e){if(e){const e=this._renderContext.output;this._renderContext.output=I.Depth,this._bindParameters.multipassTerrain.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.multipassTerrain.linearDepth,"terrain depth",(()=>this._renderTransparentTerrain()),[-1e10,-1e10,-1e10,1]),this._bindParameters.multipassTerrain.linearDepth.releaseDepth(),this._renderContext.output=e}else this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth)}_renderGeometryLinearDepth(e){if(!e)return void(this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth));const r=this._renderContext.output;return this._bindParameters.multipassGeometry.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.multipassGeometry.linearDepth,"geometry depth",(()=>this._renderOpaqueGeometryAndTransparentMaterial(I.Depth)),[1,1,1,1],y.RGBA,this._geometryLinearDepthFormat),this._renderContext.output=r,this._bindParameters.multipassGeometry.linearDepth.detachDepth()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return W;const r=X(e,this._plugins.plugins,this._stage.layers);return k(r,this._plugins.queryDepthRange(e)),r.near=Math.max(e.near,r.near),r.far=Math.min(e.far,r.far),r}_renderNormals(){if(!this._renderNodes.consumes("normals")&&!this._plugins.produces(te.SSAO))return;return this._offscreen.renderToCachedFBO(null,"normals",(()=>this._renderGeometryForSSAO(I.Normal)),[0,0,0,0],y.RGBA,D.DEPTH_STENCIL_TEXTURE)}_renderSSAO(e){this._plugins.produces(te.SSAO)&&(this._pluginInput.normals=e,this._bindParameters.ssao=this._plugins.render(te.SSAO,this._pluginInput))}_renderAllGeometry(e){this._renderContext.output=e,this._plugins.prepare(te.TRANSPARENT_TERRAIN),this._renderOpaqueGeometryAndTransparentMaterial(e),this._renderTransparentTerrain()}_renderOpaqueGeometryAndTransparentMaterial(e){this._renderContext.output=e,this._plugins.prepare(te.TRANSPARENT_MATERIAL),this._plugins.prepare(te.TRANSPARENT_NO_SSAO_DEPTH),this._renderOpaqueGeometry(),this._renderTransparentMaterial()}_renderGeometryForSSAO(e){this._renderContext.output=e,this._plugins.render(te.INTEGRATED_MESH),this._plugins.render(te.OPAQUE_TERRAIN),this._plugins.render(te.OPAQUE_MATERIAL),this._plugins.render(te.TRANSPARENT_MATERIAL),this._renderTransparentTerrain()}_renderGeometryExcludedFromSSAO(e){this._renderContext.output=e,this._plugins.render(te.OPAQUE_NO_SSAO_DEPTH),this._plugins.render(te.TRANSPARENT_NO_SSAO_DEPTH)}_prepareOpaqueGeometry(){this._plugins.prepare(te.INTEGRATED_MESH),this._plugins.prepare(te.OPAQUE_TERRAIN),this._plugins.prepare(te.OPAQUE_MATERIAL),this._plugins.prepare(te.OPAQUE_NO_SSAO_DEPTH),this._plugins.prepare(te.ENVIRONMENT_OPAQUE)}_renderOpaqueGeometry(){this._plugins.render(te.INTEGRATED_MESH),this._plugins.render(te.OPAQUE_TERRAIN),this._plugins.render(te.OPAQUE_MATERIAL),this._plugins.render(te.OPAQUE_NO_SSAO_DEPTH)}_renderTransparentMaterial(){this._plugins.render(te.TRANSPARENT_MATERIAL),this._plugins.render(te.TRANSPARENT_NO_SSAO_DEPTH)}_renderTransparentTerrain(){if(!this._plugins.produces(te.TRANSPARENT_TERRAIN))return;const e=()=>this._plugins.render(te.TRANSPARENT_TERRAIN,null);if(this._renderContext.output!==I.Color)return void e();const{width:r,height:t,depth:s}=this._offscreen,i=this.fboCache.acquire(y.RGBA,r,t,"transparent terrain");return this._offscreen.renderToTargets(e,i,s,[0,0,0,0]),i}_renderHUDVisibility(e){this._plugins.produces(te.OCCLUSION_PIXELS)?(this._bindParameters.hudVisibility=this._offscreen.renderHUDVisibility(this._bindParameters.hudVisibility,(()=>this._plugins.render(te.OCCLUSION_PIXELS)),e),this._offscreen.bindFbo()):this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===w.Occluded){const e=()=>{this._plugins.render(te.LINE_CALLOUTS)},{width:r,height:t,color:s}=this._offscreen,i=this.fboCache.acquireDepth(D.DEPTH16_BUFFER,r,t,"line callouts");this._offscreen.renderToTargets(e,s,i,void 0,!0,!0),i.release()}else this._plugins.render(te.LINE_CALLOUTS)}_renderLaserlines(){if(this._plugins.render(te.LASERLINES),this._plugins.produces(te.LASERLINES_CONTRAST_CONTROL)){const e=this._offscreen,{width:r,height:t,depth:s}=e,i=this.fboCache.acquire(y.RGBA,r,t,"laser lines"),a=()=>this._plugins.render(te.LASERLINES_CONTRAST_CONTROL);e.renderToTargets(a,i,s,be),e.compositeToFramebuffer(this._bindParameters,i.colorTexture,_e.PremultipliedAlpha,1),i.release()}}_renderHUD(e,r){if(this._pluginsHas.hudElements)if(this._oitEnabled){const t=this._renderOITPass(Ae.HUD,e);this._rctx.bindFramebuffer(r?.fbo),this._compositingHelper.composite(this._bindParameters,t.colorTexture,_e.PremultipliedAlpha),t.release()}else if(e===w.Occluded){const r=()=>this._renderHUDElements(e),{width:t,height:s,color:i}=this._offscreen,a=this.fboCache.acquireDepth(D.DEPTH16_BUFFER,t,s,"hud");this._offscreen.renderToTargets(r,i,a,void 0,!0,!0),a.release()}else this._rctx.bindFramebuffer(null),r?.acquireDepth(D.DEPTH16_BUFFER),this._rctx.bindFramebuffer(r?.fbo),this._renderHUDElements(e),r?.releaseDepth()}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.prepare(te.LINE_CALLOUTS_HUD_DEPTH),this._plugins.prepare(te.HUD_MATERIAL),this._plugins.prepare(te.LABEL_MATERIAL),this._plugins.render(te.LINE_CALLOUTS_HUD_DEPTH),this._plugins.render(te.HUD_MATERIAL),this._plugins.render(te.LABEL_MATERIAL)}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._plugins.produces(te.SHADOW_HIGHLIGHT)&&this._plugins.produces(te.OPAQUE_MATERIAL,I.ShadowHighlight)}_renderHighlightPrepass(){if(!this.hasHighlights&&!this._renderNodes.consumes("highlight"))return;const e=()=>{this._renderAllGeometry(I.Highlight),this._rctx.clearSafe(ge.DEPTH_BUFFER_BIT),this._renderHUDElements(w.Both)},r=this._offscreen.renderToCachedFBO(null,"highlight",e,[0,0,0,0],y.RGBA4,D.DEPTH_STENCIL_TEXTURE);return r.releaseDepth(),r}_renderHighlights(e,r,t){this.hasHighlights&&t.decorations!==q.OFF&&(this._needsShadowHighlight&&(this._pluginInput.highlight=r,this._plugins.render(te.SHADOW_HIGHLIGHT,this._pluginInput,e)),this._plugins.produces(te.HIGHLIGHT)&&(this._pluginInput.composite=null,this._pluginInput.normals=null,this._pluginInput.highlight=r,this._plugins.render(te.HIGHLIGHT,this._pluginInput,e)))}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_renderShadowAccumulation(e,r,t){this._needsShadowCast&&this._bindParameters.linearDepth?.colorTexture&&this._shadowAccumulator.renderAccumulation(this._bindParameters.linearDepth,e,r,t)}_prepareTransparencySlots(){this._renderContext.output=I.Alpha,this._bindParameters.transparencyPassType=he.Alpha,this._plugins.prepare(te.TRANSPARENT_MATERIAL),this._renderContext.output=I.Color,this._bindParameters.transparencyPassType=he.Color,this._plugins.prepare(te.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=he.FrontFace,this._plugins.prepare(te.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=he.NONE}_renderOITPass(e,r=w.Both){const t=e===Ae.HUD,s=t?this.fboCache.acquire(y.RGBA,this._offscreen.width,this._offscreen.height,"oit hud composite"):null,i=t?()=>this._renderHUDElements(r):()=>this._renderTransparentMaterial(),a=this._renderContext.output;this._renderContext.output=I.Alpha,this._bindParameters.transparencyPassType=he.Alpha;const n=this._offscreen.renderOITPass(i,he.Alpha,t);this._renderContext.output=I.Color,this._bindParameters.transparencyPassType=he.Color;const h=this._offscreen.renderOITPass(i,he.Color,t);this._bindParameters.transparencyPassType=he.FrontFace;const o=this._offscreen.renderOITPass(i,he.FrontFace,t);return this._offscreen.compositeTransparentOntoOpaque(this._bindParameters,h,n,o,s),s?.releaseDepth(),o.release(),h.release(),n.release(),this._bindParameters.transparencyPassType=he.NONE,this._renderContext.output=a,s}_renderOccluded(){let e=0;Re.clear(),this._plugins.plugins.forAll((r=>{if(!r.materialReference)return;r.queryRenderOccludedState(Y.OccludeAndTransparentStencil)&&(e|=Y.OccludeAndTransparentStencil,Re.push(r))}));const r=this._offscreen,t=(t,s,i,a,n)=>{if(0==(e&s))return;const{width:h,height:o,depth:d}=r,l=this.fboCache.acquire(y.RGBA,h,o,"tmp color");r.renderToTargets(i,l,d,[0,0,0,0],a,n),r.compositeToFramebuffer(this._bindParameters,l.colorTexture,_e.PremultipliedAlpha,t),l.release()},s=(e,r)=>{this._bindParameters.slot=e,r.forAll((e=>{if(L(e)){const r=e.prepareTechnique(this._renderContext);r&&e.renderNode(this._renderContext,r)}}))};0!==Re.length&&(s(te.OCCLUDER_MATERIAL,Re),t(.5,Y.OccludeAndTransparentStencil,(()=>s(te.TRANSPARENT_OCCLUDER_MATERIAL,Re)),!1,!1)),Re.clear(),this._plugins.plugins.forAll((r=>{if(!r.materialReference)return;const t=r.queryRenderOccludedState(Y.OccludeAndTransparent),s=r.queryRenderOccludedState(Y.Transparent),i=r.queryRenderOccludedState(Y.Opaque);(t||s||i)&&(e|=t?Y.OccludeAndTransparent:s?Y.Transparent:Y.Opaque,Re.push(r))}));const i=this._plugins.renderOccludedFlags;if(e|=i,!e)return;const a=e=>{this._renderContext.renderOccludedMask=e,i>Y.Occlude&&this._plugins.render(te.OCCLUDED_TERRAIN),s(te.OPAQUE_MATERIAL,Re),s(te.TRANSPARENT_MATERIAL,Re),s(te.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,Re),this._renderContext.renderOccludedMask=K};this._renderContext.output=I.Color,t(.5,Y.OccludeAndTransparent,(()=>a(Y.OccludeAndTransparent)),!0,V.OutlineVisualElementMask),t(.5,Y.Transparent,(()=>a(Y.Transparent)),!0,V.OutlineVisualElementMask),t(1,Y.Opaque,(()=>a(Y.Opaque)),!0,V.OutlineVisualElementMask),Re.clear()}_renderComposite(e,r,t,s){this._pluginInput.composite=r;let i=null;const a=this._renderNodes.produces("composite-color");a&&(this._pluginInput.linearDepth=this._bindParameters.linearDepth,this._pluginInput.normals=t,this._pluginInput.highlight=s,i=this._renderNodes.render(this._pluginInput,"composite-color"),this._pluginInput.composite=i);const n=this._plugins.produces(te.ANTIALIASING),h=this._plugins.render(n?te.ANTIALIASING:te.BLIT,this._pluginInput,e);return a&&i?.release(),h}_prepare(e,r){this._needsTransparentPass=this._plugins.produces(te.TRANSPARENT_MATERIAL,I.Color),this._bindParameters.camera=e,this._bindParameters.contentCamera=r}_ensureBindParameters(e,r){this._bindParameters.camera=e,this._bindParameters.contentCamera=r}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=g:(m(Se,this._bindParameters.camera.viewMatrix),m(Pe,this._bindParameters.camera.projectionMatrix),f(De,Se,Pe),f(De,this._renderContext.lastFrameCamera.viewMatrix,De),f(De,this._renderContext.lastFrameCamera.projectionMatrix,De),this._reprojectionMatrix=De);const r=this._stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=r>0?Math.min(r,e-this._ssrEnableTime)/r:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=g,this._ssrEnableTime=null}addRenderNode(e){this._renderNodes.add(e),this._requestRender()}removeRenderNode(e){this._renderNodes.remove(e),this._requestRender()}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}get test(){const e=this;return{offscreen:this._offscreen,shadowMap:this._shadowMap,highlight:this._highlight,lighting:this._bindParameters.lighting,renderPlugins:this._plugins,shadowAccumulator:this._shadowAccumulator,weatherIsFading:this._bindParameters.cloudsFade.isFading,resetRenderStateFeatures:()=>{e._renderStateFeatures=ee(),this._plugins.renderFeatureChanged(),this._requestRender()},releaseGeometryLinearDepth(r){e._releaseGeometryLinearDepth=r??(e=>e?.release()),e._geometryLinearDepthFormat=r?D.DEPTH_STENCIL_TEXTURE:D.DEPTH16_BUFFER},getFramebufferTexture:r=>{switch(r){case Ee.Color:return e._offscreen.colorTexture;case Ee.LinearDepth:return e._bindParameters.linearDepth?.colorTexture;case Ee.ShadowMap:return e._shadowMap.depthTexture;case Ee.HudVisibility:return e._bindParameters.hudVisibility?.colorTexture}}}}};var Ae,Ee;e([p()],Te.prototype,"_plugins",void 0),e([p()],Te.prototype,"_shadowAccumulator",void 0),e([p()],Te.prototype,"_state",void 0),e([p()],Te.prototype,"_renderStateFeatures",void 0),e([p({readOnly:!0})],Te.prototype,"fullResolutionAtmosphere",null),e([p()],Te.prototype,"_smaa",void 0),e([p()],Te.prototype,"_blit",void 0),e([p({autoDestroy:!0})],Te.prototype,"_edgeView",void 0),e([p()],Te.prototype,"updating",null),e([p()],Te.prototype,"isCameraFinal",null),Te=e([u("esri.views.3d.webgl-engine.lib.Renderer")],Te),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(Ae||(Ae={})),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.ShadowMap=2]="ShadowMap",e[e.HudVisibility=3]="HudVisibility"}(Ee||(Ee={}));const be=[0,0,0,0],Re=new h,Pe=T(),Se=T(),De=T();function Oe(e){return r=>e.immediate.schedule(r)}export{Ee as FramebufferId,Te as Renderer};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{update as t}from"../../../../core/arrayUtils.js";import{unitRGBAFromColor as s}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{removeMaybe as i,destroyMaybe as a,releaseMaybe as n}from"../../../../core/maybe.js";import h from"../../../../core/PooledArray.js";import{watch as o,syncAndInitial as d,initial as l,sync as _}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{equals as c,invert as m,multiply as f}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as g,create as T}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as E}from"../../../../chunks/vec42.js";import{fromValues as A,ZEROS as b}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{a as R}from"../../../../chunks/boundedPlane.js";import{debugFlags as P}from"../../support/debugFlags.js";import{TransparencyMode as S}from"../../terrain/TerrainRenderer.js";import{DepthFormat as D,FBOCache as O,ColorFormat as y}from"../core/FBOCache.js";import{RenderPassManager as C}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as I}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as w}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{RenderNodeCollection as N}from"../effects/RenderNodeCollection.js";import{isPrepareRenderPlugin as L}from"../effects/RenderPlugin.js";import{RenderPluginInput as H}from"../effects/RenderPluginInput.js";import{RenderPluginManager as M}from"../effects/RenderPluginManager.js";import{Blit as F}from"../effects/blit/Blit.js";import{Highlight as x}from"../effects/highlight/Highlight.js";import{ShadowHighlight as v}from"../effects/highlight/ShadowHighlight.js";import{SMAA as U}from"../effects/smaa/SMAA.js";import{SSAO as G}from"../effects/ssao/SSAO.js";import{AnimationTimeStep as q}from"./AnimationTimeStep.js";import{Decorations as B,RenderRequestType as j,StencilBits as V}from"./basicInterfaces.js";import{BoundingInfo as Q}from"./BoundingInfo.js";import{zero as W,union as k}from"./depthRange.js";import{depthRangeFromScene as X}from"./depthRangeUtils.js";import{RenderOccludedFlag as Y}from"./Material.js";import{OffscreenRendering as z}from"./OffscreenRendering.js";import{RenderContext as J,defaultRenderOccludedMask as K}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as Z,RendererTarget as $}from"./rendererUtils.js";import{setupFeatureDefaults as ee,RenderFeature as re}from"./RenderFeature.js";import{RenderSlot as te}from"./RenderSlot.js";import{ShadowAccumulator as se}from"./ShadowAccumulator.js";import{ShadowMap as ie,SnapshotSlot as ae}from"./ShadowMap.js";import ne from"./SliceHelper.js";import{TransparencyPassType as he}from"./TransparencyPassType.js";import{EdgeView as oe}from"./edgeRendering/EdgeView.js";import{Transparency as de}from"./edgeRendering/interfaces.js";import{MergedRenderer as le}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as _e}from"../shaders/CompositingTechniqueConfiguration.js";import{RendererPerformanceInfo as pe,PerformanceCategory as ue}from"../statistics/RendererPerformanceInfo.js";import{RenderState as ce}from"../../../support/RenderState.js";import{PixelFormat as me,PixelType as fe,ClearBufferBit as ge}from"../../../webgl/enums.js";let Te=class extends r{get _bindParameters(){return this._renderContext.bindParameters}updateRenderFeatures(e=null,r=!has("disable-feature:high-quality-idle")){this._renderStateFeatures=ee(r,e),this.notifyChange("_renderStateFeatures"),this._plugins.renderFeatureChanged(),this._requestRender()}isFeatureEnabled(e,r=this._state){return this._renderStateFeatures.get(r,e)??!1}setFeatureEnabled(e,r,t){this._renderStateFeatures.set(r,e,t),this.notifyChange("_renderStateFeatures"),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(re.HighQualityTransparency)}get hasReflections(){return(this._pluginsHas.water||this._hasOverlayWater)&&(this._ssrEnabled||this.isFeatureEnabled(re.WaterReflection))}get hasDecorations(){return this._plugins.hasDecorations}get hasHighlights(){return this._plugins.produces(te.OPAQUE_MATERIAL,I.Highlight)||this._plugins.produces(te.DRAPED_MATERIAL,I.Highlight)}get _magnifierEnabled(){return this._bindParameters.decorations===B.ON&&this._magnifierHelper.enabled}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(re.HighResolutionAtmosphere)}constructor(e,r,t,i,a,n,h,_){super({}),this._stage=e,this._techniqueRepository=i,this._rctx=a,this._compositingHelper=n,this._magnifierHelper=h,this._requestRender=_,this._needsTransparentPass=!1,this._pluginsHas={hudElements:!1,water:!1},this._hasOverlayWater=!1,this.renderOverlay=e=>{},this._isRendering=!1,this._backgroundColor=A(0,0,0,1),this._sliceHelper=new ne,this._renderNodes=new N,this._state=ce.IDLE,this._highQualityTransparencyEnabled=!0,this._terrainTransparency=S.Opaque,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new q,this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new H,this._releaseGeometryLinearDepth=e=>e?.release(),this._geometryLinearDepthFormat=D.DEPTH16_BUFFER,this.fboCache=new O(a),this._renderStateFeatures=ee(!has("disable-feature:high-quality-idle"),e.view.qualityProfile),this._offscreen=new z(this.fboCache,this._compositingHelper),this.performanceInfo=new pe(this._rctx),this._shadowMap=new ie(this.fboCache,e.viewingMode),this._highlight=new x({view:e.view}),this._shadowHighlight=new v({view:e.view,viewingMode:e.viewingMode}),this._shadowAccumulator=new se(this.fboCache,i,e,(e=>{const r=this.shadowsEnabled;this._shadowMap.enabled=!0,this._prepare(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=r}),((e,r,t)=>{const s=this._stage.view.qualitySettings.maximumPixelRatio;e.shadowMap.start(e.camera,r,t,!0,s),this._renderShadowCascades(I.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._prepare(e.camera,e.contentCamera)}),_),this._ssao=new G({view:this._stage.view}),this._renderContext=new J(this._rctx,this._offscreen,this._shadowMap,this._sliceHelper),this._plugins=new M({renderContext:this._renderContext,techniqueRepository:i,textureRepository:t,materialRepository:r,requestRender:_,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this.renderPassManager=new C,this._plugins.add(this.renderPassManager),this._smaa=new U({view:this._stage.view}),this._plugins.add(this._smaa),this._blit=new F({opacity:1,alphaMode:_e.None}),this._plugins.add(this._blit),this._plugins.add(this._ssao),this._plugins.add(this._highlight),this._plugins.add(this._shadowHighlight),this.addHandles([o((()=>this._stage.view.state.camera),(()=>_()),d),o((()=>P.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(de.TRANSPARENT):()=>{},_()}),l),o((()=>this._stage.view.environment.background?.color),(e=>{const r=e?s(e):b;E(this._backgroundColor,r[0]*r[3],r[1]*r[3],r[2]*r[3],r[3]),_()}),d)])}normalizeCtorArgs(){return{}}destroy(){this._gpuTimerHandle=i(this._gpuTimerHandle),this._offscreen.dispose(),this._shadowMap.dispose(),this._highlight.dispose(),this._shadowAccumulator.dispose(),this._edgeView=a(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),this._plugins.destroy(),Q.prune()}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth),this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth)}_disposeOffscreenBuffers(){this._offscreen.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.linearDepth=n(this._bindParameters.linearDepth),this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility)}get updating(){return this._smaa.updating||null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._plugins.updating||!this.isCameraFinal}ensureEdgeView(){if(null==this._edgeView){const e=this._stage.view.resourceController;this._edgeView=new oe({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniqueRepository:this._techniqueRepository,setNeedsRender:()=>this._requestRender(),schedule:Oe(e)}),this.addHandles(o((()=>this._edgeView?.updating),(()=>this._requestRender()),_)),this._requestRender()}return this._edgeView}get edgeView(){return this._edgeView}get isCameraFinal(){return c(this._bindParameters.ssr.reprojectionMatrix,g)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this.notifyChange("isCameraFinal")}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:r,_bindParameters:t}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&r.maxCascades!==e.shadowMapMaxCascades&&(r.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const r="virtual"!==e.environment.lighting.type;t.enableFillLights!==r&&(t.enableFillLights=r,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=e.slicePlane,this._requestRender()),void 0!==e.terrainTransparency&&this._terrainTransparency!==e.terrainTransparency&&(this._terrainTransparency=e.terrainTransparency,this._requestRender()),void 0!==e.shadowCastOptions&&this._shadowAccumulator.setOptions(e.shadowCastOptions)}get hasSlicePlane(){return!!this._sliceHelper.plane}get plugins(){return this._plugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,r){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:t,removes:s,updates:i}=e;if(0===t.length&&0===s.length&&0===i.length)return;const a=Z(e);let n=!1;a.forEach(((t,s)=>{if(r.done)return;let i=this._plugins.getMaterialRenderer(s);if(null==i&&t.adds.length>0){const e=new le({material:s});e.initializeRenderContext(this._plugins._context),i=e,this._plugins.add(i)}i&&(i.modify(t),0===i.numGeometries&&(n=!0)),t.removes.forEach((r=>e.removes.removeUnordered(r))),t.adds.forEach((r=>e.adds.removeUnordered(r))),t.updates.forEach((r=>e.updates.removeUnordered(r))),r.madeProgress()})),n&&this._plugins.removeEmptyMaterialRenderers(),this._updateHasFlags(),this._requestRender()}_updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(te.LINE_CALLOUTS_HUD_DEPTH)||this._plugins.produces(te.HUD_MATERIAL)||this._plugins.produces(te.LABEL_MATERIAL),has.water=this._plugins.produces(te.DRAPED_WATER,I.Normal),this._bindParameters.hasOccludees=this._plugins.hasOccludees}updateAnimation(e){const r=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(e)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?i(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,r,t=$.Default,s=B.ON){this._isRendering=!0,this.performanceInfo.startFrame(),this.fboCache.frameStart(),this._disposeBindBuffers();const i=this._offscreen,{camera:a,contentCamera:h,mode:o,alignPixelEnabled:d}=e;this._state=o,this._bindParameters.overlay=this.renderOverlay(r),this.performanceInfo.advance(ue.OVERLAY),this._renderContext.time=r,this._bindParameters.transparencyPassType=he.NONE,this._bindParameters.alignPixelEnabled=d,this._bindParameters.decorations=s,this._bindParameters.mainColor=this._bindParameters.mainDepth=null;const l=R(this._sliceHelper.plane);s===B.OFF&&(this._sliceHelper.plane=null),a.setGLViewport(this._rctx);const _=i.initializeFrame(a,this._backgroundColor,t);this.hasReflections?this._bindParameters.ssr.lastFrameColor=_:_?.release(),this._prepare(a,h),this._plugins.prepareRender(),this.performanceInfo.advance(ue.PREPARE);const p=this._computeDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,p),this.performanceInfo.advance(ue.SHADOW_MAP),this._ensureBindParameters(a,h);const u=this._plugins.produces(te.OPAQUE_TERRAIN)&&(this._terrainTransparency===S.Semitransparent||this._terrainTransparency===S.TransparentWithDraped),c=this._highQualityTransparency&&u;this._prepareShaders(c,this._needsTransparentPass),this._renderLinearDepthForSSAO(),this.performanceInfo.advance(ue.LINEAR_DEPTH_SSAO);let m=this._renderNormals();this.performanceInfo.advance(ue.NORMALS);let f=m?.detachDepth();this._renderSSAO(m),m&&!this._renderNodes.consumes("normals")&&(m.release(),m=null),this.performanceInfo.advance(ue.SSAO),this._renderLinearDepth(f),f=n(f),this.performanceInfo.advance(ue.LINEAR_DEPTH),this._renderShadowAccumulation(p,a,h),this.performanceInfo.advance(ue.ACCUMULATED_SHADOWS),this._ensureBindParametersSSR(r),this._renderContext.output=I.Color,i.bindFbo(),this._bindParameters.mainColor=i.colorTexture,this._bindParameters.mainDepth=i.depthTexture,this._renderOpaqueGeometry(),this._plugins.render(te.ENVIRONMENT_OPAQUE),this.performanceInfo.advance(ue.OPAQUE),this.fboCache.debugCallback&&this.fboCache.debugCallback("opaque color",this._offscreen.color.fbo),this._renderTerrainLinearDepth(c),this._setMultipassTerrain(c),this._renderEdges(de.OPAQUE),this.performanceInfo.advance(ue.OPAQUE_EDGES),i.bindFbo(),this._plugins.render(te.VOXEL),this.performanceInfo.advance(ue.VOXEL),this._renderHiddenTransparentEdges(),this._needsTransparentPass&&(this._oitEnabled?this._renderOITPass(Ee.Geometry):this._renderTransparentMaterial()),this.performanceInfo.advance(ue.TRANSPARENT);const g=this._renderGeometryLinearDepth(c);this._renderHUDVisibility(g),c||this._plugins.render(te.LINE_CALLOUTS),this.performanceInfo.advance(ue.HUD_VISIBILITY);const T=t===$.ObjectAndLayerID?this._renderObjectAndLayerIdColor():null;this.performanceInfo.advance(ue.OBJECT_AND_LAYER_ID_COLOR),this._renderEdges(de.TRANSPARENT,g),this._releaseGeometryLinearDepth(g),this.performanceInfo.advance(ue.TRANSPARENT_EDGES);const E=u?this._renderTransparentTerrain():null;E&&this._bindParameters.hudVisibility&&(c?this._renderLineCallouts(w.Occluded):i.compositeToHUDVisibility(this._bindParameters,E.colorTexture),this._renderHUD(w.Occluded,i.color),this.performanceInfo.advance(ue.HUD_OCCLUDED)),this.performanceInfo.advance(ue.TRANSPARENT_TERRAIN),this._setTerrainCulling(!1),E&&(i.compositeToFramebuffer(this._bindParameters,E.colorTexture,_e.PremultipliedAlpha,1),E.release(),c&&(this._renderEdges(de.OPAQUE),this.performanceInfo.advance(ue.OPAQUE_EDGES),this._needsTransparentPass&&(this._oitEnabled?this._renderOITPass(Ee.Geometry):this._renderTransparentMaterial()),this.performanceInfo.advance(ue.TRANSPARENT),this._renderEdges(de.TRANSPARENT),this.performanceInfo.advance(ue.TRANSPARENT_EDGES))),this._bindParameters.ssao=n(this._bindParameters.ssao),c&&this._renderLineCallouts(w.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),i.bindFbo(),this._plugins.render(te.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._plugins.render(te.ENVIRONMENT_TRANSPARENT),this.performanceInfo.advance(ue.ENVIRONMENT),this._renderLaserlines(),this.performanceInfo.advance(ue.LASER_LINES),this._renderOccluded(),this.performanceInfo.advance(ue.OCCLUDED);const A=this._renderHighlightPrepass(),b=this._magnifierEnabled&&t===$.Default?this.fboCache.acquire(this._offscreen.width,this._offscreen.height,"magnifier"):null,P=t!==$.Default?this.fboCache.acquire(this._offscreen.width,this._offscreen.height,"screenshot"):null,D=this._renderComposite(b??P,this._offscreen.color,m,A)??P;return m?.release(),this.performanceInfo.advance(ue.ANTIALIASING),this._renderHUD(w.NotOccluded,D),this.performanceInfo.advance(ue.HUD),this._renderHighlights(D,A,this._bindParameters),A?.release(),this.performanceInfo.advance(ue.HIGHLIGHTS),this._magnifierEnabled&&this._magnifierHelper.render(this._rctx,this._bindParameters),D!==P&&(this._rctx.bindFramebuffer(P?.fbo),this._compositingHelper.composite(this._bindParameters,b?.colorTexture,_e.None)),t===$.Default&&b?.release(),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),this._offscreen.releaseBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=l,this._isRendering=!1,this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),t!==$.Default&&(this._releaseFBOs(),this._disposeOffscreenBuffers()),{screen:P,oid:T}}_prepareShaders(e,r){this._renderContext.output=I.Color,this._prepareOpaqueGeometry(),this._setMultipassTerrain(e),this._plugins.prepare(te.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._plugins.prepare(te.LINE_CALLOUTS),r&&this._prepareTransparencySlots(),this._plugins.prepare(te.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._plugins.prepare(te.ENVIRONMENT_TRANSPARENT),this._plugins.prepare(te.LASERLINES),this._rctx.gl.flush()}_renderObjectAndLayerIdColor(){if(!has("enable-feature:objectAndLayerId-rendering"))return;const e=this._renderContext.output,r=this.fboCache.acquire(this._offscreen.width,this._offscreen.height,"oid");return r.acquireDepth(D.DEPTH_STENCIL_TEXTURE),this._rctx.bindFramebuffer(r.fbo),this._offscreen.renderToFBO((()=>this._renderAllGeometry(I.ObjectAndLayerIdColor)),[0,0,0,0],!0,!0),this._rctx.bindFramebuffer(r.fbo),this._offscreen.renderToFBO((()=>{this._bindParameters.hudRenderStyle=w.NotOccluded,this._plugins.render(te.HUD_MATERIAL)}),void 0,!0,!0),this._renderContext.output=e,r}finish(e){this._hasAnimations||this._animationTimestep.clear();const r=this.performanceInfo.gpuSamplingEnabled,t=e===j.BACKGROUND;if(t||r){const e=t?this.performanceInfo.elapsedTime:0,s=r?this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.getError(),i=Math.max(e,s);this._animationTimestep.frame(i,t)}}readDepthPixels(e,r,t){const s=this._bindParameters.linearDepth?.fbo;if(s?.colorTexture)return void s.readPixels(r[0],r[1],r[2],r[3],me.RGBA,fe.UNSIGNED_BYTE,t);const i=this.fboCache.acquire(this._offscreen.width,this._offscreen.height,"depth").acquireDepth(D.DEPTH16_BUFFER);this._rctx.bindFramebuffer(i.fbo),this._ensureBindParameters(e,e),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.setClearColor(0,0,0,0);const a=ge.COLOR_BUFFER_BIT|ge.DEPTH_BUFFER_BIT|ge.STENCIL_BUFFER_BIT;this._rctx.clearSafe(a),this._renderAllGeometry(I.Depth),i.fbo.readPixels(r[0],r[1],r[2],r[3],me.RGBA,fe.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,r,t,s,i){this._bindParameters.hudVisibility?.fbo.readPixels(e,r,t,s,me.RGBA,fe.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_setMultipassTerrain(e){this._setMultipassEnabled(e),this._setTerrainCulling(e)}_setMultipassEnabled(e){this._bindParameters.multipassEnabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_renderEdges(e,r){const t=this._edgeView;if(t?.shouldRender()){const{width:s,height:i,depth:a}=this._offscreen,n=this.fboCache.acquire(s,i,"edges"),h=()=>t.render(this._bindParameters,e);this._offscreen.renderToTargets(h,n,r??a,be),this._offscreen.compositeToFramebuffer(this._bindParameters,n.colorTexture,_e.Alpha,1),n.release()}}_renderShadowMap(e,r,t){const s=this._shadowMap;s.enabled&&(s.start(e,r,t,this.isFeatureEnabled(re.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._shadowHighlight.updateParameters(e,r),this._needsShadowHighlight?(this._renderShadowCascades(I.ShadowHighlight,this._shadowMap),s.moveSnapshot(ae.Highlight),this._renderShadowCascades(I.ShadowExcludeHighlight,this._shadowMap),s.copySnapshot(ae.ExcludeHighlight),this._renderShadowCascades(I.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(I.Shadow),s.finish(),e.setGLViewport(this._rctx))}_renderShadowCascades(e,r=this._shadowMap){for(const t of r.cascades)t.camera.setGLViewport(this._rctx),this._prepare(t.camera,t.camera),this._renderAllGeometry(e)}get _needsLinearDepth(){return this._plugins.consumes(I.Depth)||this._renderNodes.consumes("linear-depth")||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast}_renderLinearDepthForSSAO(){this._plugins.produces(te.SSAO)&&(this._bindParameters.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.linearDepth,"linear-depth",(()=>this._renderGeometryForSSAO(I.Depth)),[0,0,0,0],y.RGBA,D.DEPTH_STENCIL_TEXTURE),this._bindParameters.linearDepth.releaseDepth())}_renderLinearDepth(e){if(this._needsLinearDepth){if(this._plugins.produces(te.SSAO)&&e&&this._bindParameters.linearDepth)return this._bindParameters.linearDepth.attachDepth(e),this._rctx.bindFramebuffer(this._bindParameters.linearDepth.fbo),this._offscreen.renderToFBO((()=>this._renderGeometryExcludedFromSSAO(I.Depth))),void this._bindParameters.linearDepth.detachDepth();this._bindParameters.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.linearDepth,"linear-depth",(()=>this._renderAllGeometry(I.Depth)),[0,0,0,0],y.RGBA,D.DEPTH_STENCIL_TEXTURE),this._bindParameters.linearDepth.releaseDepth()}else this._bindParameters.linearDepth=n(this._bindParameters.linearDepth)}_renderTerrainLinearDepth(e){if(e){const e=this._renderContext.output;this._renderContext.output=I.Depth,this._bindParameters.multipassTerrain.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.multipassTerrain.linearDepth,"terrain depth",(()=>this._renderTransparentTerrain()),[-1e10,-1e10,-1e10,1]),this._bindParameters.multipassTerrain.linearDepth.releaseDepth(),this._renderContext.output=e}else this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth)}_renderGeometryLinearDepth(e){if(!e)return void(this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth));const r=this._renderContext.output;return this._bindParameters.multipassGeometry.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.multipassGeometry.linearDepth,"geometry depth",(()=>this._renderOpaqueGeometryAndTransparentMaterial(I.Depth)),[1,1,1,1],y.RGBA,this._geometryLinearDepthFormat),this._renderContext.output=r,this._bindParameters.multipassGeometry.linearDepth.detachDepth()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return W;const r=X(e,this._plugins.plugins,this._stage.layers);return k(r,this._plugins.queryDepthRange(e)),r.near=Math.max(e.near,r.near),r.far=Math.min(e.far,r.far),r}_renderNormals(){if(!this._renderNodes.consumes("normals")&&!this._plugins.produces(te.SSAO))return;return this._offscreen.renderToCachedFBO(null,"normals",(()=>this._renderGeometryForSSAO(I.Normal)),[0,0,0,0],y.RGBA,D.DEPTH_STENCIL_TEXTURE)}_renderSSAO(e){this._plugins.produces(te.SSAO)&&(this._pluginInput.normals=e,this._bindParameters.ssao=this._plugins.render(te.SSAO,this._pluginInput))}_renderAllGeometry(e){this._renderContext.output=e,this._plugins.prepare(te.TRANSPARENT_TERRAIN),this._renderOpaqueGeometryAndTransparentMaterial(e),this._renderTransparentTerrain()}_renderOpaqueGeometryAndTransparentMaterial(e){this._renderContext.output=e,this._plugins.prepare(te.TRANSPARENT_MATERIAL),this._plugins.prepare(te.TRANSPARENT_NO_SSAO_DEPTH),this._renderOpaqueGeometry(),this._renderTransparentMaterial()}_renderGeometryForSSAO(e){this._renderContext.output=e,this._plugins.render(te.INTEGRATED_MESH),this._plugins.render(te.OPAQUE_TERRAIN),this._plugins.render(te.OPAQUE_MATERIAL),this._plugins.render(te.TRANSPARENT_MATERIAL),this._renderTransparentTerrain()}_renderGeometryExcludedFromSSAO(e){this._renderContext.output=e,this._plugins.render(te.OPAQUE_NO_SSAO_DEPTH),this._plugins.render(te.TRANSPARENT_NO_SSAO_DEPTH)}_prepareOpaqueGeometry(){this._plugins.prepare(te.INTEGRATED_MESH),this._plugins.prepare(te.OPAQUE_TERRAIN),this._plugins.prepare(te.OPAQUE_MATERIAL),this._plugins.prepare(te.OPAQUE_NO_SSAO_DEPTH),this._plugins.prepare(te.ENVIRONMENT_OPAQUE)}_renderOpaqueGeometry(){this._plugins.render(te.INTEGRATED_MESH),this._plugins.render(te.OPAQUE_TERRAIN),this._plugins.render(te.OPAQUE_MATERIAL),this._plugins.render(te.OPAQUE_NO_SSAO_DEPTH)}_renderTransparentMaterial(){this._plugins.render(te.TRANSPARENT_MATERIAL),this._plugins.render(te.TRANSPARENT_NO_SSAO_DEPTH)}_renderTransparentTerrain(){if(!this._plugins.produces(te.TRANSPARENT_TERRAIN))return;const e=()=>this._plugins.render(te.TRANSPARENT_TERRAIN,null);if(this._renderContext.output!==I.Color)return void e();const{width:r,height:t,depth:s}=this._offscreen,i=this.fboCache.acquire(r,t,"transparent terrain");return this._offscreen.renderToTargets(e,i,s,[0,0,0,0]),i}_renderHUDVisibility(e){this._plugins.produces(te.OCCLUSION_PIXELS)?(this._bindParameters.hudVisibility=this._offscreen.renderHUDVisibility(this._bindParameters.hudVisibility,(()=>this._plugins.render(te.OCCLUSION_PIXELS)),e),this._offscreen.bindFbo()):this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===w.Occluded){const e=()=>{this._plugins.render(te.LINE_CALLOUTS)},{width:r,height:t,color:s}=this._offscreen,i=this.fboCache.acquireDepth(D.DEPTH16_BUFFER,r,t,"line callouts");this._offscreen.renderToTargets(e,s,i,void 0,!0,!0),i.release()}else this._plugins.render(te.LINE_CALLOUTS)}_renderLaserlines(){if(this._plugins.render(te.LASERLINES),this._plugins.produces(te.LASERLINES_CONTRAST_CONTROL)){const e=this._offscreen,{width:r,height:t,depth:s}=e,i=this.fboCache.acquire(r,t,"laser lines"),a=()=>this._plugins.render(te.LASERLINES_CONTRAST_CONTROL);e.renderToTargets(a,i,s,be),e.compositeToFramebuffer(this._bindParameters,i.colorTexture,_e.PremultipliedAlpha,1),i.release()}}_renderHUD(e,r){if(this._pluginsHas.hudElements)if(this._oitEnabled){const t=this._renderOITPass(Ee.HUD,e);this._rctx.bindFramebuffer(r?.fbo),this._compositingHelper.composite(this._bindParameters,t.colorTexture,_e.PremultipliedAlpha),t.release()}else if(e===w.Occluded){const r=()=>this._renderHUDElements(e),{width:t,height:s,color:i}=this._offscreen,a=this.fboCache.acquireDepth(D.DEPTH16_BUFFER,t,s,"hud");this._offscreen.renderToTargets(r,i,a,void 0,!0,!0),a.release()}else this._rctx.bindFramebuffer(null),r?.acquireDepth(D.DEPTH16_BUFFER),this._rctx.bindFramebuffer(r?.fbo),this._renderHUDElements(e),r?.releaseDepth()}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.prepare(te.LINE_CALLOUTS_HUD_DEPTH),this._plugins.prepare(te.HUD_MATERIAL),this._plugins.prepare(te.LABEL_MATERIAL),this._plugins.render(te.LINE_CALLOUTS_HUD_DEPTH),this._plugins.render(te.HUD_MATERIAL),this._plugins.render(te.LABEL_MATERIAL)}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._plugins.produces(te.SHADOW_HIGHLIGHT)&&this._plugins.produces(te.OPAQUE_MATERIAL,I.ShadowHighlight)}_renderHighlightPrepass(){if(!this.hasHighlights&&!this._renderNodes.consumes("highlight"))return;const e=()=>{this._renderAllGeometry(I.Highlight),this._rctx.clearSafe(ge.DEPTH_BUFFER_BIT),this._renderHUDElements(w.Both)},r=this._offscreen.renderToCachedFBO(null,"highlight",e,[0,0,0,0],y.RGBA4,D.DEPTH_STENCIL_TEXTURE);return r.releaseDepth(),r}_renderHighlights(e,r,t){this.hasHighlights&&t.decorations!==B.OFF&&(this._needsShadowHighlight&&(this._pluginInput.highlight=r,this._plugins.render(te.SHADOW_HIGHLIGHT,this._pluginInput,e)),this._plugins.produces(te.HIGHLIGHT)&&(this._pluginInput.composite=null,this._pluginInput.normals=null,this._pluginInput.highlight=r,this._plugins.render(te.HIGHLIGHT,this._pluginInput,e)))}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_renderShadowAccumulation(e,r,t){this._needsShadowCast&&this._bindParameters.linearDepth?.colorTexture&&this._shadowAccumulator.renderAccumulation(this._bindParameters.linearDepth,e,r,t)}_prepareTransparencySlots(){this._renderContext.output=I.Alpha,this._bindParameters.transparencyPassType=he.Alpha,this._plugins.prepare(te.TRANSPARENT_MATERIAL),this._renderContext.output=I.Color,this._bindParameters.transparencyPassType=he.Color,this._plugins.prepare(te.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=he.FrontFace,this._plugins.prepare(te.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=he.NONE}_renderOITPass(e,r=w.Both){const t=e===Ee.HUD,s=t?this.fboCache.acquire(this._offscreen.width,this._offscreen.height,"oit hud composite"):null,i=t?()=>this._renderHUDElements(r):()=>this._renderTransparentMaterial(),a=this._renderContext.output;this._renderContext.output=I.Alpha,this._bindParameters.transparencyPassType=he.Alpha;const n=this._offscreen.renderOITPass(i,he.Alpha,t);this._renderContext.output=I.Color,this._bindParameters.transparencyPassType=he.Color;const h=this._offscreen.renderOITPass(i,he.Color,t);this._bindParameters.transparencyPassType=he.FrontFace;const o=this._offscreen.renderOITPass(i,he.FrontFace,t);return this._offscreen.compositeTransparentOntoOpaque(this._bindParameters,h,n,o,s),s?.releaseDepth(),o.release(),h.release(),n.release(),this._bindParameters.transparencyPassType=he.NONE,this._renderContext.output=a,s}_renderOccluded(){let e=0;Re.clear(),this._plugins.plugins.forAll((r=>{if(!r.materialReference)return;r.queryRenderOccludedState(Y.OccludeAndTransparentStencil)&&(e|=Y.OccludeAndTransparentStencil,Re.push(r))}));const r=this._offscreen,t=(t,s,i,a,n)=>{if(0==(e&s))return;const{width:h,height:o,depth:d}=r,l=this.fboCache.acquire(h,o,"tmp color");r.renderToTargets(i,l,d,[0,0,0,0],a,n),r.compositeToFramebuffer(this._bindParameters,l.colorTexture,_e.PremultipliedAlpha,t),l.release()},s=(e,r)=>{this._bindParameters.slot=e,r.forAll((e=>{if(L(e)){const r=e.prepareTechnique(this._renderContext);r&&e.renderNode(this._renderContext,r)}}))};0!==Re.length&&(s(te.OCCLUDER_MATERIAL,Re),t(.5,Y.OccludeAndTransparentStencil,(()=>s(te.TRANSPARENT_OCCLUDER_MATERIAL,Re)),!1,!1)),Re.clear(),this._plugins.plugins.forAll((r=>{if(!r.materialReference)return;const t=r.queryRenderOccludedState(Y.OccludeAndTransparent),s=r.queryRenderOccludedState(Y.Transparent),i=r.queryRenderOccludedState(Y.Opaque);(t||s||i)&&(e|=t?Y.OccludeAndTransparent:s?Y.Transparent:Y.Opaque,Re.push(r))}));const i=this._plugins.renderOccludedFlags;if(e|=i,!e)return;const a=e=>{this._renderContext.renderOccludedMask=e,i>Y.Occlude&&this._plugins.render(te.OCCLUDED_TERRAIN),s(te.OPAQUE_MATERIAL,Re),s(te.TRANSPARENT_MATERIAL,Re),s(te.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,Re),this._renderContext.renderOccludedMask=K};this._renderContext.output=I.Color,t(.5,Y.OccludeAndTransparent,(()=>a(Y.OccludeAndTransparent)),!0,V.OutlineVisualElementMask),t(.5,Y.Transparent,(()=>a(Y.Transparent)),!0,V.OutlineVisualElementMask),t(1,Y.Opaque,(()=>a(Y.Opaque)),!0,V.OutlineVisualElementMask),Re.clear()}_renderComposite(e,r,t,s){this._pluginInput.composite=r;let i=null;const a=this._renderNodes.produces("composite-color");a&&(this._pluginInput.linearDepth=this._bindParameters.linearDepth,this._pluginInput.normals=t,this._pluginInput.highlight=s,i=this._renderNodes.render(this._pluginInput,"composite-color"),this._pluginInput.composite=i);const n=this._plugins.produces(te.ANTIALIASING),h=this._plugins.render(n?te.ANTIALIASING:te.BLIT,this._pluginInput,e);return a&&i?.release(),h}_prepare(e,r){this._needsTransparentPass=this._plugins.produces(te.TRANSPARENT_MATERIAL,I.Color),this._bindParameters.camera=e,this._bindParameters.contentCamera=r}_ensureBindParameters(e,r){this._bindParameters.camera=e,this._bindParameters.contentCamera=r}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=g:(m(Se,this._bindParameters.camera.viewMatrix),m(Pe,this._bindParameters.camera.projectionMatrix),f(De,Se,Pe),f(De,this._renderContext.lastFrameCamera.viewMatrix,De),f(De,this._renderContext.lastFrameCamera.projectionMatrix,De),this._reprojectionMatrix=De);const r=this._stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=r>0?Math.min(r,e-this._ssrEnableTime)/r:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=g,this._ssrEnableTime=null}addRenderNode(e){this._renderNodes.add(e),this._requestRender()}removeRenderNode(e){this._renderNodes.remove(e),this._requestRender()}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}get test(){const e=this;return{offscreen:this._offscreen,shadowMap:this._shadowMap,highlight:this._highlight,lighting:this._bindParameters.lighting,renderPlugins:this._plugins,shadowAccumulator:this._shadowAccumulator,weatherIsFading:this._bindParameters.cloudsFade.isFading,resetRenderStateFeatures:()=>{e._renderStateFeatures=ee(),this._plugins.renderFeatureChanged(),this._requestRender()},releaseGeometryLinearDepth(r){e._releaseGeometryLinearDepth=r??(e=>e?.release()),e._geometryLinearDepthFormat=r?D.DEPTH_STENCIL_TEXTURE:D.DEPTH16_BUFFER},getFramebufferTexture:r=>{switch(r){case Ae.Color:return e._offscreen.colorTexture;case Ae.LinearDepth:return e._bindParameters.linearDepth?.colorTexture;case Ae.ShadowMap:return e._shadowMap.depthTexture;case Ae.HudVisibility:return e._bindParameters.hudVisibility?.colorTexture}}}}};var Ee,Ae;e([p()],Te.prototype,"_plugins",void 0),e([p()],Te.prototype,"_shadowAccumulator",void 0),e([p()],Te.prototype,"_state",void 0),e([p()],Te.prototype,"_renderStateFeatures",void 0),e([p({readOnly:!0})],Te.prototype,"fullResolutionAtmosphere",null),e([p()],Te.prototype,"_smaa",void 0),e([p()],Te.prototype,"_blit",void 0),e([p({autoDestroy:!0})],Te.prototype,"_edgeView",void 0),e([p()],Te.prototype,"updating",null),e([p()],Te.prototype,"isCameraFinal",null),Te=e([u("esri.views.3d.webgl-engine.lib.Renderer")],Te),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(Ee||(Ee={})),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.ShadowMap=2]="ShadowMap",e[e.HudVisibility=3]="HudVisibility"}(Ae||(Ae={}));const be=[0,0,0,0],Re=new h,Pe=T(),Se=T(),De=T();function Oe(e){return r=>e.immediate.schedule(r)}export{Ae as FramebufferId,Te as Renderer};