@arcgis/core 4.31.0-next.20240705 → 4.31.0-next.20240708

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 (82) hide show
  1. package/arcade/functions/geomasync.js +1 -1
  2. package/arcade/functions/geomsync.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/{734844c5bef28f609a8c.js → 17c37078ab65f8d4046b.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{3edc527a24cb9a4868e5.js → 20d0390504e4cc9f93f4.js} +1 -1
  6. package/assets/esri/core/workers/chunks/291bdab5737152bc1825.js +1 -0
  7. package/assets/esri/core/workers/chunks/{ef8ba10380053ea4c4dd.js → 34ea46659c8cebec3ffa.js} +1 -1
  8. package/assets/esri/core/workers/chunks/3de4fe7458b7844e2aae.js +1 -0
  9. package/assets/esri/core/workers/chunks/413609b0aa85f2052154.js +1 -0
  10. package/assets/esri/core/workers/chunks/5089a12084a8a8fb93d8.js +1 -0
  11. package/assets/esri/core/workers/chunks/527932bf4c31cec46922.js +1 -0
  12. package/assets/esri/core/workers/chunks/65d34a9d408c678de2ca.js +1 -0
  13. package/assets/esri/core/workers/chunks/{5d0761c14d6ee53dd653.js → 7447883bb4a981e6d759.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{86f3ef84cc27de6d8540.js → 87f33a60768801ca1ce8.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{a734359619e3eb955399.js → b4d850e82a8ae902d684.js} +1 -1
  16. package/assets/esri/core/workers/chunks/d85c51abde781660b1f5.js +1 -0
  17. package/assets/esri/core/workers/chunks/{5afc1562bb5c20127ef1.js → e840e54455eb500b501d.js} +18 -18
  18. package/assets/esri/themes/base/widgets/_Tooltip.scss +4 -0
  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/ChapmanAtmosphere.glsl.js +1 -1
  23. package/chunks/ComponentShader.glsl.js +3 -3
  24. package/chunks/DefaultMaterial.glsl.js +1 -1
  25. package/chunks/EdgeShader.glsl.js +5 -6
  26. package/chunks/Heatmap.glsl.js +4 -4
  27. package/chunks/HighlightApply.glsl.js +172 -135
  28. package/chunks/LineCallout.glsl.js +4 -4
  29. package/chunks/MeasurementArrow.glsl.js +5 -5
  30. package/chunks/RealisticTree.glsl.js +2 -2
  31. package/chunks/Terrain.glsl.js +39 -39
  32. package/geometry/Polyline.js +1 -1
  33. package/geometry/SpatialReference.js +1 -1
  34. package/geometry/geometryEngine.js +1 -1
  35. package/geometry/support/geodesicUtils.js +1 -1
  36. package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
  37. package/layers/LinkChartLayer.js +1 -1
  38. package/layers/support/ElevationQuery.js +1 -1
  39. package/layers/video/videoUtils.js +1 -1
  40. package/package.json +1 -1
  41. package/rest/knowledgeGraph/wasmInterface/wasmToGeometryFactories.js +1 -1
  42. package/support/revision.js +1 -1
  43. package/views/2d/interactive/SnappingVisualizer2D.js +1 -1
  44. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  45. package/views/3d/environment/Fog.js +1 -1
  46. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  47. package/views/3d/terrain/TerrainRenderer.js +1 -1
  48. package/views/3d/terrain/TerrainSurface.js +1 -1
  49. package/views/3d/terrain/TransparencyMode.js +1 -1
  50. package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentShader.glsl.js +1 -1
  51. package/views/3d/webgl-engine/core/shaderLibrary/Laserline.glsl.js +1 -1
  52. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +1 -1
  53. package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +11 -11
  54. package/views/3d/webgl-engine/core/shaderLibrary/terrain/Terrain.glsl.js +1 -1
  55. package/views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js +9 -0
  56. package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
  57. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  58. package/views/3d/webgl-engine/lib/MainFramebuffer.js +5 -0
  59. package/views/3d/webgl-engine/lib/RenderContext.js +1 -1
  60. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  61. package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
  62. package/views/3d/webgl-engine/shaders/Heatmap.glsl.js +1 -1
  63. package/views/3d/webgl-engine/shaders/HighlightApply.glsl.js +1 -1
  64. package/views/3d/webgl-engine/shaders/LineCallout.glsl.js +1 -1
  65. package/views/3d/webgl-engine/shaders/MeasurementArrow.glsl.js +1 -1
  66. package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
  67. package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeShader.glsl.js +1 -1
  68. package/views/draw/support/Box.js +1 -1
  69. package/views/draw/support/Reshape.js +1 -1
  70. package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
  71. package/widgets/UtilityNetworkTrace/support/GeometryHandler.js +1 -1
  72. package/assets/esri/core/workers/chunks/164debfd5eac01ce3121.js +0 -1
  73. package/assets/esri/core/workers/chunks/1972e6be738a3b9289e8.js +0 -1
  74. package/assets/esri/core/workers/chunks/2e62e34c85d8505c98f4.js +0 -1
  75. package/assets/esri/core/workers/chunks/4ef2ce12499fae8b85c4.js +0 -1
  76. package/assets/esri/core/workers/chunks/5bf51ad34e2d729f9048.js +0 -1
  77. package/assets/esri/core/workers/chunks/9a9abefa8099aa1ebc3d.js +0 -1
  78. package/assets/esri/core/workers/chunks/da3af488df83bd8e153b.js +0 -1
  79. package/views/3d/webgl-engine/core/shaderLibrary/util/AlphaDiscard.glsl.js +0 -7
  80. package/views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlphaBlend.glsl.js +0 -7
  81. package/views/3d/webgl-engine/lib/MainColor.js +0 -5
  82. package/views/3d/webgl-engine/shaders/sources/edgeRenderer/DiscardByCoverage.glsl.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import"../../../core/has.js";import n from"../../../core/Logger.js";import{clamp as l}from"../../../core/mathUtils.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{MemCachePool as h}from"../../../core/MemCachePool.js";import d from"../../../core/ObjectPool.js";import p from"../../../core/PooledArray.js";import{throwIfAborted as u,isAbortError as c,isAborted as g}from"../../../core/promiseUtils.js";import{watch as _,syncAndInitial as m,sync as f,initial as T}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import{subclass as v}from"../../../core/accessorSupport/decorators/subclass.js";import{s as E,c as S}from"../../../chunks/vec32.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as P}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as L}from"../../../geometry/ellipsoidUtils.js";import C from"../../../geometry/SpatialReference.js";import{createEmptyProjectorCache as b,getProjector as M}from"../../../geometry/projection/projectors.js";import{projectPointToVector as D}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as U}from"../../../geometry/projection/projectVectorToVector.js";import{create as x,equals as R,intersection as j,intersectsSphere as A,empty as I,expand as B}from"../../../geometry/support/aaBoundingRect.js";import{create as V,copy as k}from"../../../geometry/support/frustum.js";import{isPlateCarree as O}from"../../../geometry/support/spatialReferenceUtils.js";import{d as N,g as G,c as q}from"../../../chunks/sphere.js";import{ElevationQueryTileCache as F}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as W}from"../../../layers/support/layerUtils.js";import{debugFlags as $}from"../support/debugFlags.js";import{ElevationRange as H}from"../support/ElevationRange.js";import{ElevationUpdateEvent as Q}from"../support/ElevationUpdateEvent.js";import{toBoundingRect as z}from"../support/extentUtils.js";import{ClientType as X}from"../support/index.js";import{updatingProgress as Y}from"../support/updatingProperties.js";import{ElevationBounds as K}from"./ElevationBounds.js";import{ElevationData as J,sampleElevation as Z}from"./ElevationData.js";import{create as ee}from"./ExtentHelper.js";import{LODSnapping as te,TextureUpdate as ie}from"./interfaces.js";import{LayerClass as re,LayerClasses as se}from"./LayerClass.js";import{OverlayManager as ae}from"./OverlayManager.js";import{PlanarPatch as ne}from"./PlanarPatch.js";import{RenderOrder as le}from"./RenderOrder.js";import{ScaleRangeQueries as oe}from"./ScaleRangeQueries.js";import{SphericalPatch as he}from"./SphericalPatch.js";import{SplitLimits as de}from"./SplitLimits.js";import{maxRootTiles as pe,tooManyRootTilesAfterChangeError as ue,tooManyRootTilesForLayerError as ce,maxTileNeighborLevelDelta as ge,maxMemoryLodBias as _e}from"./TerrainConst.js";import{TerrainRenderer as me}from"./TerrainRenderer.js";import fe from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as Te,isVectorTileLayerView as ye,neighborEdgeIndices as ve,internalAssert as Ee,oppositeEdge as Se,isSurfaceLayerView as we,isGroupLayerView as Pe,isMapTileLayerView as Le,isBlendableLayerView as Ce,isElevationLayerView as be,releaseTerrainData as Me,enableTerrainInternalChecks as De,neighborCornerIndices as Ue,oppositeCorner as xe,enableWaterproofTests as Re,enableInternalTerrainChecks as je,enableTerrainWaterproofChecks as Ae}from"./terrainUtils.js";import{Tile as Ie,lijEquals as Be}from"./Tile.js";import{printAllocations as Ve}from"./TilePerLayerInfo.js";import{TileUpdate as ke}from"./TileUpdate.js";import{IteratorPreorder as Oe,IteratorPostorder as Ne,compareTilesByLij as Ge,hasLoadableSiblings as qe,sortTilesByPOI as Fe}from"./tileUtils.js";import{TilingSchemeLogic as We}from"./TilingSchemeLogic.js";import{TransparencyMode as $e}from"./TransparencyMode.js";import{UpsampleInfo as He}from"./UpsampleInfo.js";import{isCompositeBlendMode as Qe,blendModeFromString as ze}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{PBRMode as Xe}from"../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{RenderRequestType as Ye}from"../webgl-engine/lib/basicInterfaces.js";import{RenderState as Ke}from"../../support/RenderState.js";import{ImmediateTask as Je,TaskPriority as Ze,noBudget as et}from"../../support/Scheduler.js";import{Yield as tt}from"../../support/Yield.js";var it;let rt=it=class extends(a.EventedMixin(i)){constructor(e){super(e),this._scaleRangeQueries=new oe,this._iteratorPool=new d(Oe,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new Ne,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._usedMemory=null,this._performanceInfo=new fe,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=w(),this._eyePosSurfaceSR=w(),this._splitLimits=new de,this._frustum=V(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new P,this._frameTask=Je,this._allTiles=new p,this._upsampleInfoPool=new d(He),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=x(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=C.WebMercator,this._elevationProjectorCache=new Map,this.visibleElevationBounds=new K(1/0,-1/0),this.rootTileElevationBounds=new K(1/0,-1/0),this._sebProjectorMap=new Map,this._sebProjectorCache=b(),this._tilingSchemeSpatialReference=null,this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1,this.overlayManager=new ae({...e,surface:this}),this._isGlobal=!e.view?.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?he:ne}initialize(){const e=this.view,t=e.resourceController,i=t.memoryController;this._tileCache=new h(((e,t)=>i.newCache(e,t)),"terrain-tile"),this._upsampleMapCache=i.newCache("terrain-upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new F(i.newCache("elevation-query"));const r=this.overlayManager;this._renderer=new me(r.renderer,e._stage,this._allTiles,L(e.spatialReference).radius,i),this.addHandles([_((()=>r.renderer.isEmpty),(()=>this._evaluateTransparency())),_((()=>this.renderer.visible),(e=>this.suspended=!e)),_((()=>this.heading),(e=>{this._renderer.updateHeading(e),this._updateTileTextures(ie.FADING)})),_((()=>({heading:e.camera?.heading,state:e.state?.mode})),(({heading:e,state:t})=>{if(null==e)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree)return void(this.heading=90*Math.round(e/90)%360);const i=Math.round(e)%360,r=Math.abs(i-this.heading);(t===Ke.IDLE||Math.min(r,360-r)>=30)&&(this.heading=i)}))],"overlayManager"),this.addHandles([_((()=>this.baseOpacity),(()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?ie.UNFADED:ie.IMMEDIATE)}),m),_((()=>this.hasCompositeBlendMode),(()=>this._updateTileTextures(this._evaluateTransparency()?ie.UNFADED:ie.IMMEDIATE)),m),_((()=>this.backgroundColor),((e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))}),f),_((()=>this.snapLevel),(()=>this._viewChanged=!0),f),_((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>this._allTilesSorted=!1))})),_((()=>$.TERRAIN_TILE_TREE_SHOW_TILES),(t=>{t&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&$.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))})):t||(this._treeDebugger=o(this._treeDebugger))}),T)]);const{spatialReference:a}=e;this._extentHelper=ee(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});const n=new s({getCollections:()=>e.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),l=new We({layers:n,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set("tilingSchemeLogic",l),this._updateTilingScheme(),this._elevationDataRequester=t.createStreamDataRequester(X.ELEVATION),this._mapDataRequester=t.createStreamDataRequester(X.BASEMAP);const d=t.scheduler;this._frameTask=d.registerTask(Ze.TERRAIN_SURFACE,this),this.addHandles([_((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),T),_((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),f),_((()=>this.extent),(()=>this._updateRootTiles()),T),e.on("resize",(()=>this._viewChangeUpdate())),_((()=>{const t=e.state;return[this._lodBias,this.lodSnapping,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),m),_((()=>e.qualitySettings?.fadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),T),_((()=>e.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._renderer.pbrMode=e?Xe.Simplified:Xe.Disabled),T),_((()=>e.qualitySettings?.tiledSurface.elevationLevelDelta),(()=>this._updateAllTileGeometries())),_((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),f)]),this.addHandles(e.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}destroy(){this._frameTask.remove(),this._watchUpdatingTracking.destroy(),this._removeAllTiles(),this._set("tilingSchemeLogic",o(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",o(this.overlayManager)),this._tileCache=o(this._tileCache),Ie.prune(),this._treeDebugger=o(this._treeDebugger),this._renderer=o(this._renderer),this._iteratorPool=o(this._iteratorPool),this._upsampleMapCache=o(this._upsampleMapCache),this._elevationQueryCache=o(this._elevationQueryCache),this._set("view",null),this._extentHelper=o(this._extentHelper),this._upsampleInfoPool=o(this._upsampleInfoPool),Ve()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){if(this.lodSnapping===te.ON){const{view:e,tilingScheme:t}=this,i=e.terrainScale;if(t&&i){const r=t.levelAtScale(i)+e.qualitySettings.tiledSurface.lodBias,s=t.getMaxLod();return Math.min(r,s||1/0)}}return null}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?te.ON:te.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(null==t||null==e)return null;const i=x(),r=z(t,i,e)?i:null,s=this._get("extent");return R(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=j(this.groundExtent,this._userClippingExtent,x()),t=this._get("extent");return R(e,t)?t:e}get groundExtent(){return null!=this._tilingSchemeExtent?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this.running||this._watchUpdatingTracking?.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager?.updating)}get running(){return(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries.updating||this._frameTask.updating)&&this.ready&&!this.suspended}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return null!=this._rootTiles}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===$e.Opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}getElevation(e,t,i,r){const s=this._rootTiles;if(!s?.length)return null;if(0===s[0].layerInfo[re.ELEVATION].length)return null;let a=this._elevationProjectorCache.get(r);if(void 0===a&&(a=M(r,this._spatialReference)??null,this._elevationProjectorCache.set(r,a)),null==a)return n.getLogger(this).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;const l=E(at,e,t,i);a(l,0,l,0);return dt(s,l[0],l[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[re.ELEVATION].length:0;if(r?.length&&0!==s)for(let a=0;a<t;++a){const t=3*a;i(a,dt(r,e[t],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getScale(e){if(!this.tilingScheme)return null;if(!D(e,at,this.spatialReference))return n.getLogger(this).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(null!=t)for(const i of t)if(i?.containsPoint(at)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;at[0]>t[2]&&(i+=1),at[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}_ensureSEBProject(e){const t=this._sebProjectorMap.get(e);if(t)return t;const i=M(e,this._tilingSchemeSpatialReference,this._sebProjectorCache)??null;return this._sebProjectorMap.set(e,i),i}getSphereElevationBounds(e,t){const i=this._ensureSEBProject(t);if(null==i)return n.getLogger(this).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;N(e,nt);const r=G(nt);i(r,0,r,0);const s=new H,a=this._rootTiles;if(null!=a){const e=[];for(const i of a)e.push(i);let t=0;for(;t<e.length;){const i=e[t];if(++t,!A(i.extent,nt))continue;const r=i.children;if(null==r[0]||i.rendered)s.expandElevationRangeValues(i.elevationBoundsMin,i.elevationBoundsMax);else for(const t of r)e.push(t)}}return s}getRootElevationBounds(){return new H(this.rootTileElevationBounds.min,this.rootTileElevationBounds.max)}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!D(e,G(nt),this.spatialReference))return n.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;nt[3]=t;let i=null;const r=e=>{if(e&&A(e.extent,nt)){const t=e.children;if(t[0]&&!e.rendered)for(const e of t)r(e);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}}},s=this._rootTiles;if(null!=s)for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._allSurfaceLayersTransparent()?t?$e.Empty:$e.TransparentWithDraped:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?$e.Opaque:$e.Semitransparent,s=i!==r;return s&&(this._renderer.transparency=r,this.view?._stage?.renderer.setParameters({terrainTransparency:this._renderer.transparency})),s}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;if(!(e!==this.tilingScheme))return;Te(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??C.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&O(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,this._set("tilingScheme",e),this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference,this._sebProjectorMap.clear(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles())}_acquireTile(e,t,i,r){const s=this._tileCache.pop(it._tileMemcacheKey);return s?(s.init(e,t,i,r,this),s):new this._tileConstructor(e,t,i,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=lt;let s=t.rootTilesInExtent(e,i,5*pe);if(null!=this._rootTiles){if(s.length>pe)return void n.getLogger(this).warn(ue);const e=this._rootTiles.map((e=>e.lij)),t=r(e,s,Be);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter((e=>!(t.removed.findIndex((t=>Be(t,e.lij)))>-1)||(this._purgeTile(e),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>pe&&(n.getLogger(this).warn(ce),s=t.rootTilesInExtent(e,i,pe)),this._setRootTiles(s.map((e=>this._newRootTile(e))));R(i,this._rootTilesExtent)||(this._rootTilesExtent=x(i)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter((e=>e.loaded&&e.intersectsClippingArea));e.sort(Ge),e.forEach((e=>this._renderer.updateTileGeometryState(e))),e.forEach((e=>e.renderData.updateNeighborData())),this._updateTilesGeometries(e),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){if(0===e.length)return;e.sort(Ge);const t=this.renderer;e.forEach((e=>t.updateGeometryIfNeeded(e))),e.forEach((e=>this._pendingTilesForElevationUpdateEvent.add(e)))}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===ke.SPLIT}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(ke.SPLIT),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),null!=e){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(ke.GEOMETRY)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(null==e)return;const t=qe(e),i=this.visibleElevationBounds;let r=t?i.min:1/0,s=t?i.max:-1/0;const a=this.extent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(ke.GEOMETRY)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBoundsMin,r),s=Math.max(e.elevationBoundsMax,s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new K(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;null!=i&&i.forEach((({elevationBoundsMin:i,elevationBoundsMax:r})=>{e=Math.min(e,i),t=Math.max(t,r)}));const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new K(e,t))}_updateViewDependentParameters(){const{camera:e,contentCamera:t}=this.view.state,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=k(this._splitLimits.frustum??V(),t.frustum):this._splitLimits.frustum=null,k(this._frustum,e.frustum),S(this._eyePosRenderSR,t.eye),U(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this._usedMemory=null}_markAllTileNeighborsForUpdate(e){e.forEachLoadedNeighbor((e=>{this._layerViews[re.MAP].some(ye)&&e.setPendingUpdate(ke.TEXTURE_FADING),this._pendingTilesToUpdate.add(e)}))}_updateTileTexture(e,t){const i=e.resetPendingUpdate(ke.TEXTURE_FADING)?ke.TEXTURE_FADING:!!e.resetPendingUpdate(ke.TEXTURE_NOFADING)&&ke.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;const e=ot.extent;I(e),this._pendingTilesForElevationUpdateEvent.forEach((t=>B(e,t.extent,e))),this._pendingTilesForElevationUpdateEvent.clear(),ot.spatialReference=this.spatialReference,this.emit("elevation-change",ot),this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;if(this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed&&this.requestUpdate(),this.notifyChange("updatingProgressValue"),De&&this._checkTileInvariant(),!e.hasProgressed)return tt}_checkTileInvariant(){const e=new Map;this._allTiles.forAll((t=>e.set(t,new Set))),this._allTiles.forAll((t=>{if(Te(t.rendered===t.leaf,` rendered ${t.rendered} != ${t.leaf} leaf`),!t.leaf){const e=e=>0===e.unmergableChildCount&&0===e.maxLevelDeltaNeighborCount,i=t.children.reduce(((t,i)=>t+(e(i)?0:1)),0);if(Te(t.unmergableChildCount===i,` Tile[${t.lij.toString()}] unmergeable child count mismatch: actual ${t.unmergableChildCount} vs ${i}`),t.hasPendingUpdate(ke.MERGE)){Te(!t.hasPendingUpdate(ke.SPLIT),"Tile can be both split and merge at the same time");for(const e of t.children)Te(e.leaf||e.hasPendingUpdate(ke.MERGE),"Child of tile to merge must also merge")}}for(let i=0;i<4;++i){if(t.rendered){const e=t.renderData?.geometryState.edgePeerNeighbors[i];if(null!=e){{const r=t.level-e.level<=ge;r||(console.log(`tile level delta [${t.lij.toString()}] vs [${e.lij.toString()}] > ${ge} (edge[${i}])`),Te(r,`tile level delta [${t.level}] vs [${e.level}] > ${ge}`))}Te(t.level-e.level<=ge,`Max tile lod delta exceeded: [${t.lij.toString()}] vs [${e.lij.toString()}]`)}}const r=t.level-ge,s=e=>e.leaf||e.level===t.level,a=t.findNeighborTile(ve[i],s);if(null!=a){if(t.leaf&&t.level>=ge){let i=a;for(;t.level-i.level<ge;)i=i.parent;const s=[r,t.lij[1]>>ge,t.lij[2]>>ge];if(!Be(s,i.lij)){const r=e.get(i);Te(!r.has(t),"Cannot already have neighbor"),r.add(t)}}Te(a.rendered||a.level===t.level,"Non-same-level-neighbor of rendered must be rendered"),Te(t.level-a.level<=ge,`Tile level delta [${t.level}] vs [${a.level}] > ${ge}`)}}})),this._allTiles.forAll((t=>{const i=t.maxLevelDeltaNeighborCount,r=e.get(t);Te(i===r.size,`Tile[${t.lij.toString()}] merge-blocker mismatch: actual ${i} vs ${r.size}`)}))}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=new pt(this._allTiles.length);t.pushAll(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;this._allTiles.forAll((e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0}));const a=this.view.state.contentCamera.viewProjectionMatrix;for(;!t.empty;){const e=t.pop(),n=e.parent,l=null!=n&&n.hasPendingUpdate(ke.MERGE),o=l?ke.MERGE:e.shouldSplit(r,s,i),h=o===ke.SPLIT;e.leaf?ut(e,h):t.pushAll(e.children),l?(e.resetPendingUpdate(ke.SPLIT),e.leaf||e.setPendingUpdate(ke.MERGE),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(a)):h?(e.resetPendingUpdate(ke.MERGE),e.leaf&&e.setPendingUpdate(ke.SPLIT)):(e.resetPendingUpdate(ke.SPLIT)&&e.updateAgentSuspension(),o===ke.ELEVATION&&e.updateAgents(re.ELEVATION),e.leaf||(e.setPendingUpdate(ke.MERGE),e.resetPendingUpdate(ke.SPLIT)))}this.requestUpdate(),(this._shortBatches||!this._oneBatchPerFrameTask)&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Fe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_markTileToUpdate(e){Ee(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_updatePendingTileGeometries(){const e=this._pendingTilesToUpdate,t=Array.from(e.keys()).filter((e=>e.loaded&&e.intersectsClippingArea));if(0===t.length)return void e.clear();const i=(i,r)=>{!r?.loaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(Ge);const r=t.length;for(let s=0;s<r;++s){const r=t[s];Ee(r.loaded),Ee(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a.dirtyEdgeResolutions,l=a.geometryState,o=e=>{const t=Ue[e];i(r,l.cornerPeerNeighbors[e]?.findCorner(xe(t),(e=>e.loaded)))};for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(Se(ve[t]),(t=>!(!t.loaded||!t.intersectsClippingArea)&&(Ee(e.has(t)||Ge(r,t)<0),i(r,t),!0))),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,De&&Re&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1;const r=this.view.state.fixedContentCamera;let s=!1;for(;!e.done;){s=!0;let a=!1;const n=!this._allTiles.some((s=>{if(!i&&!r&&!s.visible)return e.done;let n=s;if(s.hasPendingUpdate(ke.MERGE)){if(!t||s.unmergableChildCount>0)return e.done;for(s.resetPendingUpdate(ke.MERGE);null!=n.parent&&0===n.parent.unmergableChildCount&&n.parent.resetPendingUpdate(ke.MERGE);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else if(s.resetPendingUpdate(ke.SPLIT)){let t=!0;const i=s.level;if(i>=ge){const e=e=>e.leaf||i-e.level<ge;for(let r=0;r<4;++r){const a=s.findNeighborTile(ve[r],e);null!=a&&i-a.level===ge&&(t=!1,De&&(Ee(a.leaf),Ee(a.hasPendingUpdate(ke.SPLIT))))}}t?(this._splitTile(s),e.madeProgress(),a=!0):s.setPendingUpdate(ke.SPLIT)}return e.done}));if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries()),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some((t=>(t.resetPendingUpdate(ke.GEOMETRY)&&(this._updateTileGeometryState(t),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()),e.done))),!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done)))}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(Ye.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.quality;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*_e}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=l(e-this._lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){null!=this._rootTiles&&(this._rootTiles.forEach((e=>this._purgeTile(e))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.renderer.visible=!1}_purgeSubtree(e){const t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?gt(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(it._tileMemcacheKey,e)}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload(this._renderer)}_splitTile(e){Te(e.leaf,"Tile that is already split should not be split again!"),Te(e.rendered,"Tile marked to split is not rendered"),gt(e);const t=e.createChildren();this._allTiles.pushArray(t),e.updateAgentSuspension(),Te(e.rendered,"parent should be rendered"),this._unloadTile(e),t.forEach((e=>this._loadTile(e))),t.forEach((e=>this._pendingTilesToUpdate.add(e))),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach((e=>ut(e,e.hasPendingUpdate(ke.SPLIT)))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){ht.spatialReference=this.spatialReference,ht.extent=e.extent,ht.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",ht)}createTile(e,t,i,r){Te(!!r,"createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(ke.SPLIT),s}get _shortBatches(){return this.view.state.mode!==Ke.IDLE}_mergeTile(e){Te(!e.hasPendingUpdate(ke.SPLIT),"_mergeTile sanity check"),Te(!e.leaf,"Cannot merge a leaf"),e.leaf||(this._purgeSubtree(e),Te(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),ut(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e)}_handleLayerViewChanges(e=et){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(let s=this.view.allLayerViews.length-1;s>=0;s--){const e=this.view.allLayerViews.items[s];if(i.add(e.uid),we(e)||Pe(e))if(this._basemapLayerViewHandles.has(e.uid)&&!Pe(e)){const i=this._layerClassFromLayerView(e),s=this._getLayerIdxByUID(i,e.uid);null!=s&&((s<r||null==r)&&(t=!0),r=s)}else this._registerTiledLayerView(e),e.layer.loaded&&(t=!0)}this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(Le(t)&&!W(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((Ce(e)||Pe(e))&&Qe(ze[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return be(e)?re.ELEVATION:re.MAP}_registerTiledLayerView(e){const t=[];if((Ce(e)||Pe(e))&&t.push(_((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(ie.UNFADED)}))),!Pe(e)){const i=this._layerClassFromLayerView(e);t.push(_((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(_((()=>e.fullOpacity),(()=>this._updateTileTextures(ie.UNFADED)))),t.push(_((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),t.push(e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);null!=t&&this._invalidateLayerData(t,i)})))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(const e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!we(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===re.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of se){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this._rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&(this._viewChangeUpdate(),this.notifyChange("tilingScheme"))}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===re.ELEVATION&&i.computeElevationBounds()}this._updateRootTileElevationBounds()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(re.MAP),e===ie.IMMEDIATE?this.renderer.updateTileTexture(t,ke.TEXTURE_NOFADING):t.updateRenderData(re.MAP,e)})),this._evaluateTransparency()}_invalidateLayerData(e,t){this._allTiles.forAll((i=>i.removeLayerAgent(e,t))),this._allTiles.forAll((i=>i.invalidateLayerData(e,t)))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=Ye.UPDATE){this.renderer.setNeedsRender(e)}requestUpdate(){1==++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||ye(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.lij[0],e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,u(r),c(t)||this._dataMissing(e,i,s),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){const s=t===re.ELEVATION;return r.requester??=s?this._elevationDataRequester:this._mapDataRequester,s?be(i)?this._requestElevationTileData(e,i,r):Promise.reject():Le(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{!g(i)&&r&&(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,t,r))},s=i=>{c(i)||(n.getLogger(this).error(`Tile ${e.lij.toString()} layer ${re.ELEVATION}/${t.uid} error ${i}`),this._dataMissing(e,re.ELEVATION,t),this.requestUpdate())};return t.fetchTile(e.lij,i).then((e=>this._frameTask.schedule((()=>r(e)))),s).finally((()=>--this._asyncWorkItems))}_elevationDataArrived(e,t,i){const r=this._layerIndexByUid[re.ELEVATION].get(t.uid);if(null==r)return void n.getLogger(this).warn("TerrainSurface: received data from unknown layer %d %s",re.ELEVATION,e.lij.toString());const s=new J(e.lij,e.extent,i);e.dataArrived(r,re.ELEVATION,s);const a=[e],l=e.level,o=this._iteratorPool.acquire();for(o.reset(a);!o.done;){const e=o.next();e.findElevationBoundsForLayer(r,l),e.computeElevationBounds()}0===l&&this._updateRootTileElevationBounds(),o.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{Me(s),g(i)||(console.error(`Tile ${e.lij.toString()} layer ${re.MAP}/${t.uid} error ${r}`),this._dataMissing(e,re.MAP,t),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{this.requestUpdate(),g(i)?Me(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));return t.fetchTile(e.lij,i).then(a,n).finally((()=>--this._asyncWorkItems))}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(re.MAP,t.uid);if(null==r)return Me(i),void n.getLogger(this).warn("TerrainSurface: received data from unknown layer");e.dataArrived(r,re.MAP,i)}_getLayerIdxByUID(e,t){return this._layerIndexByUid[e].get(t)}_dataMissing(e,t,i){const r=this._getLayerIdxByUID(t,i.uid);null!=r?e.dataMissing(r,t):n.getLogger(this).warn("TerrainSurface: received data from unknown layer")}updateTileOverlayParams(e){this._rootTiles&&this.overlayManager&&(this._allTiles.forAll((e=>{e.renderData&&this.overlayManager.setTileParameters(e)})),this._renderer.setNeedsRender(e))}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.leaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}get usedMemory(){return this.tilingScheme?(null==this._usedMemory&&(this._usedMemory=this._recalculateUsedMemory()),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce(((e,t)=>e+t.usedMemory),0)):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return null!=r&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(null==e||null==this._rootTiles)return null;const t=e.split("/").map((e=>+e));if(0===t[0])return this._rootTiles.find((e=>e.lij[1]===t[1]&&e.lij[2]===t[2]));const i=t[0],r=t[1]>>i,s=t[2]>>i;let a;if(this._rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return Te(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get visualizeNormals(){return this._renderer.visualizeNormals}set visualizeNormals(e){this._renderer.visualizeNormals=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(){if(!Re)return;const e=this._rootTiles;if(null==e)return;const t=e=>e?.renderData?.geometry?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometry&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometry||(e.renderData.geometry.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometry),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.leaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.leaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&0===e[2]}lijEastEnd(e){return 1<<e+(this._isGeographic?1:0)}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this._isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){je(e)}enableWaterproofnessChecks(e){Ae(e)}};rt._tileMemcacheKey="TerrainTileMemcache",e([y()],rt.prototype,"_renderer",void 0),e([y({constructOnly:!0})],rt.prototype,"_scaleRangeQueries",void 0),e([y({constructOnly:!0})],rt.prototype,"view",void 0),e([y({constructOnly:!0})],rt.prototype,"overlayManager",void 0),e([y()],rt.prototype,"_hasPendingUpdates",void 0),e([y()],rt.prototype,"_asyncWorkItems",void 0),e([y()],rt.prototype,"_allTilesDirty",void 0),e([y()],rt.prototype,"_allTilesSorted",void 0),e([y()],rt.prototype,"_viewChanged",void 0),e([y({type:Number})],rt.prototype,"heading",void 0),e([y()],rt.prototype,"_splitLimits",void 0),e([y({readOnly:!0})],rt.prototype,"_watchUpdatingTracking",void 0),e([y()],rt.prototype,"_frameTask",void 0),e([y({readOnly:!0})],rt.prototype,"snapLevel",null),e([y({readOnly:!0})],rt.prototype,"lodSnapping",null),e([y()],rt.prototype,"_userClippingExtent",null),e([y()],rt.prototype,"_rootTilesExtent",void 0),e([y({readOnly:!0})],rt.prototype,"extent",null),e([y({readOnly:!0})],rt.prototype,"groundExtent",null),e([y({readOnly:!0})],rt.prototype,"_tilingSchemeExtent",null),e([y({readOnly:!0})],rt.prototype,"updating",null),e([y({readOnly:!0})],rt.prototype,"running",null),e([y(Y)],rt.prototype,"updatingProgress",void 0),e([y({readOnly:!0})],rt.prototype,"updatingProgressValue",null),e([y()],rt.prototype,"_maxNumUpdating",void 0),e([y()],rt.prototype,"baseOpacity",null),e([y()],rt.prototype,"hasCompositeBlendMode",void 0),e([y({readOnly:!0})],rt.prototype,"viewingMode",null),e([y()],rt.prototype,"maxTextureScale",void 0),e([y({readOnly:!0})],rt.prototype,"ready",null),e([y({value:le.FRONT_TO_BACK})],rt.prototype,"renderOrder",null),e([y({readOnly:!0})],rt.prototype,"rootTiles",null),e([y()],rt.prototype,"_rootTiles",void 0),e([y({readOnly:!0})],rt.prototype,"spatialReference",null),e([y({type:t})],rt.prototype,"backgroundColor",null),e([y({value:!1})],rt.prototype,"slicePlaneEnabled",null),e([y({readOnly:!0})],rt.prototype,"tilingScheme",void 0),e([y({readOnly:!0})],rt.prototype,"tilingSchemeLocked",null),e([y({readOnly:!0})],rt.prototype,"tilingSchemeLogic",void 0),e([y()],rt.prototype,"wireframe",null),e([y({value:!1})],rt.prototype,"suspended",null),e([y()],rt.prototype,"fadeDuration",null),e([y()],rt.prototype,"visibleElevationBounds",void 0),e([y()],rt.prototype,"rootTileElevationBounds",void 0),e([y()],rt.prototype,"_layerViewsDirty",void 0),e([y()],rt.prototype,"renderPatchBorders",null),e([y()],rt.prototype,"visualizeNormals",null),e([y()],rt.prototype,"renderingDisabled",null),rt=it=e([v("esri.views.3d.terrain.TerrainSurface")],rt);const st=rt,at=w(),nt=q(),lt=x();new p;const ot=new Q("ground"),ht={spatialReference:null,extent:null,scale:0};function dt(e,t,i){for(const r of e){if(!r.containsPointXY(t,i))continue;let e=r;for(;e&&!e.renderData;){const r=(t>e.extentMidX?1:0)+(i<e.extentMidY?2:0);e=e.children[r]}const s=e?.renderData?.geometryState.samplerData??null;return Z(t,i,s)}return null}class pt{constructor(e){this.capacity=e,this._head=0,this._tail=0,this._data=new Array(e)}push(e){const t=this._tail;if(!(t<this.capacity))throw new Error("Queue full");this._data[t]=e,this._tail=t+1}pushAll(e){const t=e.length;if(0===t)return;const i=this._tail;if(!(i+t<=this.capacity))throw new Error("Queue full");for(let r=0;r<t;++r)this._data[i+r]=e[r];this._tail=i+t}pop(){const e=this._head;if(e<this._tail){const t=this._data[e];return this._head=e+1,t}}get empty(){return this._head>=this._tail}get full(){return this._tail>=this._data.length}}function ut(e,t){!e.leaf||e.level<ge||mt(e,(e=>{t&&ct(e);const i=_t(e);if(e.maxLevelDeltaNeighborCount++,i){let t=e.parent;for(;t;){const e=_t(t);if(t.unmergableChildCount++,!e)break;t=t.parent}}}))}function ct(e){if(e.hasPendingUpdate(ke.SPLIT))return;let t=e.parent;for(;t?.resetPendingUpdate(ke.MERGE);)t=t.parent;e.resetPendingUpdate(ke.MERGE),e.leaf&&e.setPendingUpdate(ke.SPLIT),e.level<ge||mt(e,(e=>{ct(e)}))}function gt(e){e.level<ge||mt(e,(e=>{if(e.maxLevelDeltaNeighborCount--,0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount){let t=e.parent;for(;t&&(t.unmergableChildCount--,_t(t));)t=t.parent}}))}function _t(e){return 0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount}function mt(e,t){if(e.level<ge)return;const i=e.level-ge,r=e.lij[1]>>ge,s=e.lij[2]>>ge,a=e=>e.leaf||e.level===i;for(let n=0;n<4;++n){const l=e.findNeighborTile(ve[n],a);if(!l||l.level!==i)continue;const o=l.lij;o[1]===r&&o[2]===s||t(l)}}export{st as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import"../../../core/has.js";import n from"../../../core/Logger.js";import{clamp as l}from"../../../core/mathUtils.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{MemCachePool as h}from"../../../core/MemCachePool.js";import d from"../../../core/ObjectPool.js";import p from"../../../core/PooledArray.js";import{throwIfAborted as u,isAbortError as c,isAborted as g}from"../../../core/promiseUtils.js";import{watch as _,syncAndInitial as m,sync as f,initial as T}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import{subclass as v}from"../../../core/accessorSupport/decorators/subclass.js";import{s as E,c as S}from"../../../chunks/vec32.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as P}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as L}from"../../../geometry/ellipsoidUtils.js";import C from"../../../geometry/SpatialReference.js";import{createEmptyProjectorCache as b,getProjector as M}from"../../../geometry/projection/projectors.js";import{projectPointToVector as D}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as U}from"../../../geometry/projection/projectVectorToVector.js";import{create as x,equals as R,intersection as j,intersectsSphere as A,empty as I,expand as B}from"../../../geometry/support/aaBoundingRect.js";import{create as V,copy as k}from"../../../geometry/support/frustum.js";import{isPlateCarree as O}from"../../../geometry/support/spatialReferenceUtils.js";import{d as N,g as G,c as q}from"../../../chunks/sphere.js";import{ElevationQueryTileCache as F}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as W}from"../../../layers/support/layerUtils.js";import{debugFlags as $}from"../support/debugFlags.js";import{ElevationRange as H}from"../support/ElevationRange.js";import{ElevationUpdateEvent as Q}from"../support/ElevationUpdateEvent.js";import{toBoundingRect as z}from"../support/extentUtils.js";import{ClientType as X}from"../support/index.js";import{updatingProgress as Y}from"../support/updatingProperties.js";import{ElevationBounds as K}from"./ElevationBounds.js";import{ElevationData as J,sampleElevation as Z}from"./ElevationData.js";import{create as ee}from"./ExtentHelper.js";import{LODSnapping as te,TextureUpdate as ie}from"./interfaces.js";import{LayerClass as re,LayerClasses as se}from"./LayerClass.js";import{OverlayManager as ae}from"./OverlayManager.js";import{PlanarPatch as ne}from"./PlanarPatch.js";import{RenderOrder as le}from"./RenderOrder.js";import{ScaleRangeQueries as oe}from"./ScaleRangeQueries.js";import{SphericalPatch as he}from"./SphericalPatch.js";import{SplitLimits as de}from"./SplitLimits.js";import{maxRootTiles as pe,tooManyRootTilesAfterChangeError as ue,tooManyRootTilesForLayerError as ce,maxTileNeighborLevelDelta as ge,maxMemoryLodBias as _e}from"./TerrainConst.js";import{TerrainRenderer as me}from"./TerrainRenderer.js";import fe from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as Te,isVectorTileLayerView as ye,neighborEdgeIndices as ve,internalAssert as Ee,oppositeEdge as Se,isSurfaceLayerView as we,isGroupLayerView as Pe,isMapTileLayerView as Le,isBlendableLayerView as Ce,isElevationLayerView as be,releaseTerrainData as Me,enableTerrainInternalChecks as De,neighborCornerIndices as Ue,oppositeCorner as xe,enableWaterproofTests as Re,enableInternalTerrainChecks as je,enableTerrainWaterproofChecks as Ae}from"./terrainUtils.js";import{Tile as Ie,lijEquals as Be}from"./Tile.js";import{printAllocations as Ve}from"./TilePerLayerInfo.js";import{TileUpdate as ke}from"./TileUpdate.js";import{IteratorPreorder as Oe,IteratorPostorder as Ne,compareTilesByLij as Ge,hasLoadableSiblings as qe,sortTilesByPOI as Fe}from"./tileUtils.js";import{TilingSchemeLogic as We}from"./TilingSchemeLogic.js";import{TransparencyMode as $e}from"./TransparencyMode.js";import{UpsampleInfo as He}from"./UpsampleInfo.js";import{isCompositeBlendMode as Qe,blendModeFromString as ze}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{PBRMode as Xe}from"../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{RenderRequestType as Ye}from"../webgl-engine/lib/basicInterfaces.js";import{RenderState as Ke}from"../../support/RenderState.js";import{ImmediateTask as Je,TaskPriority as Ze,noBudget as et}from"../../support/Scheduler.js";import{Yield as tt}from"../../support/Yield.js";var it;let rt=it=class extends(a.EventedMixin(i)){constructor(e){super(e),this._scaleRangeQueries=new oe,this._iteratorPool=new d(Oe,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new Ne,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._usedMemory=null,this._performanceInfo=new fe,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=w(),this._eyePosSurfaceSR=w(),this._splitLimits=new de,this._frustum=V(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new P,this._frameTask=Je,this._allTiles=new p,this._upsampleInfoPool=new d(He),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=x(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=C.WebMercator,this._elevationProjectorCache=new Map,this.visibleElevationBounds=new K(1/0,-1/0),this.rootTileElevationBounds=new K(1/0,-1/0),this._sebProjectorMap=new Map,this._sebProjectorCache=b(),this._tilingSchemeSpatialReference=null,this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1,this.overlayManager=new ae({...e,surface:this}),this._isGlobal=!e.view?.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?he:ne}initialize(){const e=this.view,t=e.resourceController,i=t.memoryController;this._tileCache=new h(((e,t)=>i.newCache(e,t)),"terrain-tile"),this._upsampleMapCache=i.newCache("terrain-upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new F(i.newCache("elevation-query"));const r=this.overlayManager;this._renderer=new me(r.renderer,e._stage,this._allTiles,L(e.spatialReference).radius,i),this.addHandles([_((()=>r.renderer.isEmpty),(()=>this._evaluateTransparency())),_((()=>this.renderer.visible),(e=>this.suspended=!e)),_((()=>this.heading),(e=>{this._renderer.updateHeading(e),this._updateTileTextures(ie.FADING)})),_((()=>({heading:e.camera?.heading,state:e.state?.mode})),(({heading:e,state:t})=>{if(null==e)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree)return void(this.heading=90*Math.round(e/90)%360);const i=Math.round(e)%360,r=Math.abs(i-this.heading);(t===Ke.IDLE||Math.min(r,360-r)>=30)&&(this.heading=i)}))],"overlayManager"),this.addHandles([_((()=>this.baseOpacity),(()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?ie.UNFADED:ie.IMMEDIATE)}),m),_((()=>this.hasCompositeBlendMode),(()=>this._updateTileTextures(this._evaluateTransparency()?ie.UNFADED:ie.IMMEDIATE)),m),_((()=>this.backgroundColor),((e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))}),f),_((()=>this.snapLevel),(()=>this._viewChanged=!0),f),_((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>this._allTilesSorted=!1))})),_((()=>$.TERRAIN_TILE_TREE_SHOW_TILES),(t=>{t&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&$.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))})):t||(this._treeDebugger=o(this._treeDebugger))}),T)]);const{spatialReference:a}=e;this._extentHelper=ee(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});const n=new s({getCollections:()=>e.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),l=new We({layers:n,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set("tilingSchemeLogic",l),this._updateTilingScheme(),this._elevationDataRequester=t.createStreamDataRequester(X.ELEVATION),this._mapDataRequester=t.createStreamDataRequester(X.BASEMAP);const d=t.scheduler;this._frameTask=d.registerTask(Ze.TERRAIN_SURFACE,this),this.addHandles([_((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),T),_((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),f),_((()=>this.extent),(()=>this._updateRootTiles()),T),e.on("resize",(()=>this._viewChangeUpdate())),_((()=>{const t=e.state;return[this._lodBias,this.lodSnapping,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),m),_((()=>e.qualitySettings?.fadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),T),_((()=>e.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._renderer.pbrMode=e?Xe.Simplified:Xe.Disabled),T),_((()=>e.qualitySettings?.tiledSurface.elevationLevelDelta),(()=>this._updateAllTileGeometries())),_((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),f)]),this.addHandles(e.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}destroy(){this._frameTask.remove(),this._watchUpdatingTracking.destroy(),this._removeAllTiles(),this._set("tilingSchemeLogic",o(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",o(this.overlayManager)),this._tileCache=o(this._tileCache),Ie.prune(),this._treeDebugger=o(this._treeDebugger),this._renderer=o(this._renderer),this._iteratorPool=o(this._iteratorPool),this._upsampleMapCache=o(this._upsampleMapCache),this._elevationQueryCache=o(this._elevationQueryCache),this._set("view",null),this._extentHelper=o(this._extentHelper),this._upsampleInfoPool=o(this._upsampleInfoPool),Ve()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){if(this.lodSnapping===te.ON){const{view:e,tilingScheme:t}=this,i=e.terrainScale;if(t&&i){const r=t.levelAtScale(i)+e.qualitySettings.tiledSurface.lodBias,s=t.getMaxLod();return Math.min(r,s||1/0)}}return null}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?te.ON:te.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(null==t||null==e)return null;const i=x(),r=z(t,i,e)?i:null,s=this._get("extent");return R(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=j(this.groundExtent,this._userClippingExtent,x()),t=this._get("extent");return R(e,t)?t:e}get groundExtent(){return null!=this._tilingSchemeExtent?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this.running||this._watchUpdatingTracking?.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager?.updating)}get running(){return(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries.updating||this._frameTask.updating)&&this.ready&&!this.suspended}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return null!=this._rootTiles}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===$e.Opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}getElevation(e,t,i,r){const s=this._rootTiles;if(!s?.length)return null;if(0===s[0].layerInfo[re.ELEVATION].length)return null;let a=this._elevationProjectorCache.get(r);if(void 0===a&&(a=M(r,this._spatialReference)??null,this._elevationProjectorCache.set(r,a)),null==a)return n.getLogger(this).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;const l=E(at,e,t,i);a(l,0,l,0);return dt(s,l[0],l[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[re.ELEVATION].length:0;if(r?.length&&0!==s)for(let a=0;a<t;++a){const t=3*a;i(a,dt(r,e[t],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getScale(e){if(!this.tilingScheme)return null;if(!D(e,at,this.spatialReference))return n.getLogger(this).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(null!=t)for(const i of t)if(i?.containsPoint(at)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;at[0]>t[2]&&(i+=1),at[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}_ensureSEBProject(e){const t=this._sebProjectorMap.get(e);if(t)return t;const i=M(e,this._tilingSchemeSpatialReference,this._sebProjectorCache)??null;return this._sebProjectorMap.set(e,i),i}getSphereElevationBounds(e,t){const i=this._ensureSEBProject(t);if(null==i)return n.getLogger(this).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;N(e,nt);const r=G(nt);i(r,0,r,0);const s=new H,a=this._rootTiles;if(null!=a){const e=[];for(const i of a)e.push(i);let t=0;for(;t<e.length;){const i=e[t];if(++t,!A(i.extent,nt))continue;const r=i.children;if(null==r[0]||i.rendered)s.expandElevationRangeValues(i.elevationBoundsMin,i.elevationBoundsMax);else for(const t of r)e.push(t)}}return s}getRootElevationBounds(){return new H(this.rootTileElevationBounds.min,this.rootTileElevationBounds.max)}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!D(e,G(nt),this.spatialReference))return n.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;nt[3]=t;let i=null;const r=e=>{if(e&&A(e.extent,nt)){const t=e.children;if(t[0]&&!e.rendered)for(const e of t)r(e);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}}},s=this._rootTiles;if(null!=s)for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._allSurfaceLayersTransparent()?t?$e.Invisible:$e.InvisibleWithDraped:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?$e.Opaque:$e.Transparent,s=i!==r;return s&&(this._renderer.transparency=r,this.view?._stage?.renderer.setParameters({terrainTransparency:this._renderer.transparency})),s}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;if(!(e!==this.tilingScheme))return;Te(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??C.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&O(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,this._set("tilingScheme",e),this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference,this._sebProjectorMap.clear(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles())}_acquireTile(e,t,i,r){const s=this._tileCache.pop(it._tileMemcacheKey);return s?(s.init(e,t,i,r,this),s):new this._tileConstructor(e,t,i,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=lt;let s=t.rootTilesInExtent(e,i,5*pe);if(null!=this._rootTiles){if(s.length>pe)return void n.getLogger(this).warn(ue);const e=this._rootTiles.map((e=>e.lij)),t=r(e,s,Be);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter((e=>!(t.removed.findIndex((t=>Be(t,e.lij)))>-1)||(this._purgeTile(e),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>pe&&(n.getLogger(this).warn(ce),s=t.rootTilesInExtent(e,i,pe)),this._setRootTiles(s.map((e=>this._newRootTile(e))));R(i,this._rootTilesExtent)||(this._rootTilesExtent=x(i)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter((e=>e.loaded&&e.intersectsClippingArea));e.sort(Ge),e.forEach((e=>this._renderer.updateTileGeometryState(e))),e.forEach((e=>e.renderData.updateNeighborData())),this._updateTilesGeometries(e),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){if(0===e.length)return;e.sort(Ge);const t=this.renderer;e.forEach((e=>t.updateGeometryIfNeeded(e))),e.forEach((e=>this._pendingTilesForElevationUpdateEvent.add(e)))}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===ke.SPLIT}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(ke.SPLIT),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),null!=e){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(ke.GEOMETRY)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(null==e)return;const t=qe(e),i=this.visibleElevationBounds;let r=t?i.min:1/0,s=t?i.max:-1/0;const a=this.extent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(ke.GEOMETRY)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBoundsMin,r),s=Math.max(e.elevationBoundsMax,s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new K(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;null!=i&&i.forEach((({elevationBoundsMin:i,elevationBoundsMax:r})=>{e=Math.min(e,i),t=Math.max(t,r)}));const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new K(e,t))}_updateViewDependentParameters(){const{camera:e,contentCamera:t}=this.view.state,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=k(this._splitLimits.frustum??V(),t.frustum):this._splitLimits.frustum=null,k(this._frustum,e.frustum),S(this._eyePosRenderSR,t.eye),U(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this._usedMemory=null}_markAllTileNeighborsForUpdate(e){e.forEachLoadedNeighbor((e=>{this._layerViews[re.MAP].some(ye)&&e.setPendingUpdate(ke.TEXTURE_FADING),this._pendingTilesToUpdate.add(e)}))}_updateTileTexture(e,t){const i=e.resetPendingUpdate(ke.TEXTURE_FADING)?ke.TEXTURE_FADING:!!e.resetPendingUpdate(ke.TEXTURE_NOFADING)&&ke.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;const e=ot.extent;I(e),this._pendingTilesForElevationUpdateEvent.forEach((t=>B(e,t.extent,e))),this._pendingTilesForElevationUpdateEvent.clear(),ot.spatialReference=this.spatialReference,this.emit("elevation-change",ot),this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;if(this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed&&this.requestUpdate(),this.notifyChange("updatingProgressValue"),De&&this._checkTileInvariant(),!e.hasProgressed)return tt}_checkTileInvariant(){const e=new Map;this._allTiles.forAll((t=>e.set(t,new Set))),this._allTiles.forAll((t=>{if(Te(t.rendered===t.leaf,` rendered ${t.rendered} != ${t.leaf} leaf`),!t.leaf){const e=e=>0===e.unmergableChildCount&&0===e.maxLevelDeltaNeighborCount,i=t.children.reduce(((t,i)=>t+(e(i)?0:1)),0);if(Te(t.unmergableChildCount===i,` Tile[${t.lij.toString()}] unmergeable child count mismatch: actual ${t.unmergableChildCount} vs ${i}`),t.hasPendingUpdate(ke.MERGE)){Te(!t.hasPendingUpdate(ke.SPLIT),"Tile can be both split and merge at the same time");for(const e of t.children)Te(e.leaf||e.hasPendingUpdate(ke.MERGE),"Child of tile to merge must also merge")}}for(let i=0;i<4;++i){if(t.rendered){const e=t.renderData?.geometryState.edgePeerNeighbors[i];if(null!=e){{const r=t.level-e.level<=ge;r||(console.log(`tile level delta [${t.lij.toString()}] vs [${e.lij.toString()}] > ${ge} (edge[${i}])`),Te(r,`tile level delta [${t.level}] vs [${e.level}] > ${ge}`))}Te(t.level-e.level<=ge,`Max tile lod delta exceeded: [${t.lij.toString()}] vs [${e.lij.toString()}]`)}}const r=t.level-ge,s=e=>e.leaf||e.level===t.level,a=t.findNeighborTile(ve[i],s);if(null!=a){if(t.leaf&&t.level>=ge){let i=a;for(;t.level-i.level<ge;)i=i.parent;const s=[r,t.lij[1]>>ge,t.lij[2]>>ge];if(!Be(s,i.lij)){const r=e.get(i);Te(!r.has(t),"Cannot already have neighbor"),r.add(t)}}Te(a.rendered||a.level===t.level,"Non-same-level-neighbor of rendered must be rendered"),Te(t.level-a.level<=ge,`Tile level delta [${t.level}] vs [${a.level}] > ${ge}`)}}})),this._allTiles.forAll((t=>{const i=t.maxLevelDeltaNeighborCount,r=e.get(t);Te(i===r.size,`Tile[${t.lij.toString()}] merge-blocker mismatch: actual ${i} vs ${r.size}`)}))}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=new pt(this._allTiles.length);t.pushAll(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;this._allTiles.forAll((e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0}));const a=this.view.state.contentCamera.viewProjectionMatrix;for(;!t.empty;){const e=t.pop(),n=e.parent,l=null!=n&&n.hasPendingUpdate(ke.MERGE),o=l?ke.MERGE:e.shouldSplit(r,s,i),h=o===ke.SPLIT;e.leaf?ut(e,h):t.pushAll(e.children),l?(e.resetPendingUpdate(ke.SPLIT),e.leaf||e.setPendingUpdate(ke.MERGE),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(a)):h?(e.resetPendingUpdate(ke.MERGE),e.leaf&&e.setPendingUpdate(ke.SPLIT)):(e.resetPendingUpdate(ke.SPLIT)&&e.updateAgentSuspension(),o===ke.ELEVATION&&e.updateAgents(re.ELEVATION),e.leaf||(e.setPendingUpdate(ke.MERGE),e.resetPendingUpdate(ke.SPLIT)))}this.requestUpdate(),(this._shortBatches||!this._oneBatchPerFrameTask)&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Fe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_markTileToUpdate(e){Ee(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_updatePendingTileGeometries(){const e=this._pendingTilesToUpdate,t=Array.from(e.keys()).filter((e=>e.loaded&&e.intersectsClippingArea));if(0===t.length)return void e.clear();const i=(i,r)=>{!r?.loaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(Ge);const r=t.length;for(let s=0;s<r;++s){const r=t[s];Ee(r.loaded),Ee(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a.dirtyEdgeResolutions,l=a.geometryState,o=e=>{const t=Ue[e];i(r,l.cornerPeerNeighbors[e]?.findCorner(xe(t),(e=>e.loaded)))};for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(Se(ve[t]),(t=>!(!t.loaded||!t.intersectsClippingArea)&&(Ee(e.has(t)||Ge(r,t)<0),i(r,t),!0))),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,De&&Re&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1;const r=this.view.state.fixedContentCamera;let s=!1;for(;!e.done;){s=!0;let a=!1;const n=!this._allTiles.some((s=>{if(!i&&!r&&!s.visible)return e.done;let n=s;if(s.hasPendingUpdate(ke.MERGE)){if(!t||s.unmergableChildCount>0)return e.done;for(s.resetPendingUpdate(ke.MERGE);null!=n.parent&&0===n.parent.unmergableChildCount&&n.parent.resetPendingUpdate(ke.MERGE);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else if(s.resetPendingUpdate(ke.SPLIT)){let t=!0;const i=s.level;if(i>=ge){const e=e=>e.leaf||i-e.level<ge;for(let r=0;r<4;++r){const a=s.findNeighborTile(ve[r],e);null!=a&&i-a.level===ge&&(t=!1,De&&(Ee(a.leaf),Ee(a.hasPendingUpdate(ke.SPLIT))))}}t?(this._splitTile(s),e.madeProgress(),a=!0):s.setPendingUpdate(ke.SPLIT)}return e.done}));if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries()),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some((t=>(t.resetPendingUpdate(ke.GEOMETRY)&&(this._updateTileGeometryState(t),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()),e.done))),!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done)))}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(Ye.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.quality;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*_e}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=l(e-this._lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){null!=this._rootTiles&&(this._rootTiles.forEach((e=>this._purgeTile(e))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.renderer.visible=!1}_purgeSubtree(e){const t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?gt(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(it._tileMemcacheKey,e)}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload(this._renderer)}_splitTile(e){Te(e.leaf,"Tile that is already split should not be split again!"),Te(e.rendered,"Tile marked to split is not rendered"),gt(e);const t=e.createChildren();this._allTiles.pushArray(t),e.updateAgentSuspension(),Te(e.rendered,"parent should be rendered"),this._unloadTile(e),t.forEach((e=>this._loadTile(e))),t.forEach((e=>this._pendingTilesToUpdate.add(e))),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach((e=>ut(e,e.hasPendingUpdate(ke.SPLIT)))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){ht.spatialReference=this.spatialReference,ht.extent=e.extent,ht.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",ht)}createTile(e,t,i,r){Te(!!r,"createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(ke.SPLIT),s}get _shortBatches(){return this.view.state.mode!==Ke.IDLE}_mergeTile(e){Te(!e.hasPendingUpdate(ke.SPLIT),"_mergeTile sanity check"),Te(!e.leaf,"Cannot merge a leaf"),e.leaf||(this._purgeSubtree(e),Te(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),ut(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e)}_handleLayerViewChanges(e=et){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(let s=this.view.allLayerViews.length-1;s>=0;s--){const e=this.view.allLayerViews.items[s];if(i.add(e.uid),we(e)||Pe(e))if(this._basemapLayerViewHandles.has(e.uid)&&!Pe(e)){const i=this._layerClassFromLayerView(e),s=this._getLayerIdxByUID(i,e.uid);null!=s&&((s<r||null==r)&&(t=!0),r=s)}else this._registerTiledLayerView(e),e.layer.loaded&&(t=!0)}this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(Le(t)&&!W(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((Ce(e)||Pe(e))&&Qe(ze[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return be(e)?re.ELEVATION:re.MAP}_registerTiledLayerView(e){const t=[];if((Ce(e)||Pe(e))&&t.push(_((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(ie.UNFADED)}))),!Pe(e)){const i=this._layerClassFromLayerView(e);t.push(_((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(_((()=>e.fullOpacity),(()=>this._updateTileTextures(ie.UNFADED)))),t.push(_((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),t.push(e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);null!=t&&this._invalidateLayerData(t,i)})))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(const e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!we(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===re.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of se){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this._rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&(this._viewChangeUpdate(),this.notifyChange("tilingScheme"))}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===re.ELEVATION&&i.computeElevationBounds()}this._updateRootTileElevationBounds()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(re.MAP),e===ie.IMMEDIATE?this.renderer.updateTileTexture(t,ke.TEXTURE_NOFADING):t.updateRenderData(re.MAP,e)})),this._evaluateTransparency()}_invalidateLayerData(e,t){this._allTiles.forAll((i=>i.removeLayerAgent(e,t))),this._allTiles.forAll((i=>i.invalidateLayerData(e,t)))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=Ye.UPDATE){this.renderer.setNeedsRender(e)}requestUpdate(){1==++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||ye(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.lij[0],e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,u(r),c(t)||this._dataMissing(e,i,s),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){const s=t===re.ELEVATION;return r.requester??=s?this._elevationDataRequester:this._mapDataRequester,s?be(i)?this._requestElevationTileData(e,i,r):Promise.reject():Le(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{!g(i)&&r&&(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,t,r))},s=i=>{c(i)||(n.getLogger(this).error(`Tile ${e.lij.toString()} layer ${re.ELEVATION}/${t.uid} error ${i}`),this._dataMissing(e,re.ELEVATION,t),this.requestUpdate())};return t.fetchTile(e.lij,i).then((e=>this._frameTask.schedule((()=>r(e)))),s).finally((()=>--this._asyncWorkItems))}_elevationDataArrived(e,t,i){const r=this._layerIndexByUid[re.ELEVATION].get(t.uid);if(null==r)return void n.getLogger(this).warn("TerrainSurface: received data from unknown layer %d %s",re.ELEVATION,e.lij.toString());const s=new J(e.lij,e.extent,i);e.dataArrived(r,re.ELEVATION,s);const a=[e],l=e.level,o=this._iteratorPool.acquire();for(o.reset(a);!o.done;){const e=o.next();e.findElevationBoundsForLayer(r,l),e.computeElevationBounds()}0===l&&this._updateRootTileElevationBounds(),o.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{Me(s),g(i)||(console.error(`Tile ${e.lij.toString()} layer ${re.MAP}/${t.uid} error ${r}`),this._dataMissing(e,re.MAP,t),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{this.requestUpdate(),g(i)?Me(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));return t.fetchTile(e.lij,i).then(a,n).finally((()=>--this._asyncWorkItems))}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(re.MAP,t.uid);if(null==r)return Me(i),void n.getLogger(this).warn("TerrainSurface: received data from unknown layer");e.dataArrived(r,re.MAP,i)}_getLayerIdxByUID(e,t){return this._layerIndexByUid[e].get(t)}_dataMissing(e,t,i){const r=this._getLayerIdxByUID(t,i.uid);null!=r?e.dataMissing(r,t):n.getLogger(this).warn("TerrainSurface: received data from unknown layer")}updateTileOverlayParams(e){this._rootTiles&&this.overlayManager&&(this._allTiles.forAll((e=>{e.renderData&&this.overlayManager.setTileParameters(e)})),this._renderer.setNeedsRender(e))}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.leaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}get usedMemory(){return this.tilingScheme?(null==this._usedMemory&&(this._usedMemory=this._recalculateUsedMemory()),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce(((e,t)=>e+t.usedMemory),0)):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return null!=r&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(null==e||null==this._rootTiles)return null;const t=e.split("/").map((e=>+e));if(0===t[0])return this._rootTiles.find((e=>e.lij[1]===t[1]&&e.lij[2]===t[2]));const i=t[0],r=t[1]>>i,s=t[2]>>i;let a;if(this._rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return Te(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get visualizeNormals(){return this._renderer.visualizeNormals}set visualizeNormals(e){this._renderer.visualizeNormals=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(){if(!Re)return;const e=this._rootTiles;if(null==e)return;const t=e=>e?.renderData?.geometry?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometry&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometry||(e.renderData.geometry.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometry),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.leaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.leaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&0===e[2]}lijEastEnd(e){return 1<<e+(this._isGeographic?1:0)}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this._isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){je(e)}enableWaterproofnessChecks(e){Ae(e)}};rt._tileMemcacheKey="TerrainTileMemcache",e([y()],rt.prototype,"_renderer",void 0),e([y({constructOnly:!0})],rt.prototype,"_scaleRangeQueries",void 0),e([y({constructOnly:!0})],rt.prototype,"view",void 0),e([y({constructOnly:!0})],rt.prototype,"overlayManager",void 0),e([y()],rt.prototype,"_hasPendingUpdates",void 0),e([y()],rt.prototype,"_asyncWorkItems",void 0),e([y()],rt.prototype,"_allTilesDirty",void 0),e([y()],rt.prototype,"_allTilesSorted",void 0),e([y()],rt.prototype,"_viewChanged",void 0),e([y({type:Number})],rt.prototype,"heading",void 0),e([y()],rt.prototype,"_splitLimits",void 0),e([y({readOnly:!0})],rt.prototype,"_watchUpdatingTracking",void 0),e([y()],rt.prototype,"_frameTask",void 0),e([y({readOnly:!0})],rt.prototype,"snapLevel",null),e([y({readOnly:!0})],rt.prototype,"lodSnapping",null),e([y()],rt.prototype,"_userClippingExtent",null),e([y()],rt.prototype,"_rootTilesExtent",void 0),e([y({readOnly:!0})],rt.prototype,"extent",null),e([y({readOnly:!0})],rt.prototype,"groundExtent",null),e([y({readOnly:!0})],rt.prototype,"_tilingSchemeExtent",null),e([y({readOnly:!0})],rt.prototype,"updating",null),e([y({readOnly:!0})],rt.prototype,"running",null),e([y(Y)],rt.prototype,"updatingProgress",void 0),e([y({readOnly:!0})],rt.prototype,"updatingProgressValue",null),e([y()],rt.prototype,"_maxNumUpdating",void 0),e([y()],rt.prototype,"baseOpacity",null),e([y()],rt.prototype,"hasCompositeBlendMode",void 0),e([y({readOnly:!0})],rt.prototype,"viewingMode",null),e([y()],rt.prototype,"maxTextureScale",void 0),e([y({readOnly:!0})],rt.prototype,"ready",null),e([y({value:le.FRONT_TO_BACK})],rt.prototype,"renderOrder",null),e([y({readOnly:!0})],rt.prototype,"rootTiles",null),e([y()],rt.prototype,"_rootTiles",void 0),e([y({readOnly:!0})],rt.prototype,"spatialReference",null),e([y({type:t})],rt.prototype,"backgroundColor",null),e([y({value:!1})],rt.prototype,"slicePlaneEnabled",null),e([y({readOnly:!0})],rt.prototype,"tilingScheme",void 0),e([y({readOnly:!0})],rt.prototype,"tilingSchemeLocked",null),e([y({readOnly:!0})],rt.prototype,"tilingSchemeLogic",void 0),e([y()],rt.prototype,"wireframe",null),e([y({value:!1})],rt.prototype,"suspended",null),e([y()],rt.prototype,"fadeDuration",null),e([y()],rt.prototype,"visibleElevationBounds",void 0),e([y()],rt.prototype,"rootTileElevationBounds",void 0),e([y()],rt.prototype,"_layerViewsDirty",void 0),e([y()],rt.prototype,"renderPatchBorders",null),e([y()],rt.prototype,"visualizeNormals",null),e([y()],rt.prototype,"renderingDisabled",null),rt=it=e([v("esri.views.3d.terrain.TerrainSurface")],rt);const st=rt,at=w(),nt=q(),lt=x();new p;const ot=new Q("ground"),ht={spatialReference:null,extent:null,scale:0};function dt(e,t,i){for(const r of e){if(!r.containsPointXY(t,i))continue;let e=r;for(;e&&!e.renderData;){const r=(t>e.extentMidX?1:0)+(i<e.extentMidY?2:0);e=e.children[r]}const s=e?.renderData?.geometryState.samplerData??null;return Z(t,i,s)}return null}class pt{constructor(e){this.capacity=e,this._head=0,this._tail=0,this._data=new Array(e)}push(e){const t=this._tail;if(!(t<this.capacity))throw new Error("Queue full");this._data[t]=e,this._tail=t+1}pushAll(e){const t=e.length;if(0===t)return;const i=this._tail;if(!(i+t<=this.capacity))throw new Error("Queue full");for(let r=0;r<t;++r)this._data[i+r]=e[r];this._tail=i+t}pop(){const e=this._head;if(e<this._tail){const t=this._data[e];return this._head=e+1,t}}get empty(){return this._head>=this._tail}get full(){return this._tail>=this._data.length}}function ut(e,t){!e.leaf||e.level<ge||mt(e,(e=>{t&&ct(e);const i=_t(e);if(e.maxLevelDeltaNeighborCount++,i){let t=e.parent;for(;t;){const e=_t(t);if(t.unmergableChildCount++,!e)break;t=t.parent}}}))}function ct(e){if(e.hasPendingUpdate(ke.SPLIT))return;let t=e.parent;for(;t?.resetPendingUpdate(ke.MERGE);)t=t.parent;e.resetPendingUpdate(ke.MERGE),e.leaf&&e.setPendingUpdate(ke.SPLIT),e.level<ge||mt(e,(e=>{ct(e)}))}function gt(e){e.level<ge||mt(e,(e=>{if(e.maxLevelDeltaNeighborCount--,0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount){let t=e.parent;for(;t&&(t.unmergableChildCount--,_t(t));)t=t.parent}}))}function _t(e){return 0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount}function mt(e,t){if(e.level<ge)return;const i=e.level-ge,r=e.lij[1]>>ge,s=e.lij[2]>>ge,a=e=>e.leaf||e.level===i;for(let n=0;n<4;++n){const l=e.findNeighborTile(ve[n],a);if(!l||l.level!==i)continue;const o=l.lij;o[1]===r&&o[2]===s||t(l)}}export{st 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.31/esri/copyright.txt for details.
4
4
  */
5
- var a;!function(a){a[a.Opaque=0]="Opaque",a[a.Semitransparent=1]="Semitransparent",a[a.TransparentWithDraped=2]="TransparentWithDraped",a[a.Empty=3]="Empty",a[a.COUNT=4]="COUNT"}(a||(a={}));export{a as TransparencyMode};
5
+ var e;!function(e){e[e.Opaque=0]="Opaque",e[e.Transparent=1]="Transparent",e[e.InvisibleWithDraped=2]="InvisibleWithDraped",e[e.Invisible=3]="Invisible",e[e.COUNT=4]="COUNT"}(e||(e={}));export{e as TransparencyMode};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../../../../geometry/support/Ellipsoid.js";import"../../../../../terrain/OverlayContent.js";import"../ComponentTechniqueConfiguration.js";import"./ComponentData.glsl.js";import"./VertexDiscardByOpacity.glsl.js";import"../../../../core/shaderLibrary/ForwardLinearDepth.glsl.js";import"../../../../core/shaderLibrary/ShaderOutput.js";import"../../../../core/shaderLibrary/Slice.glsl.js";import"../../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import"../../../../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import"../../../../core/shaderLibrary/attributes/VertexColor.glsl.js";import"../../../../core/shaderLibrary/attributes/VertexNormal.glsl.js";import"../../../../core/shaderLibrary/attributes/VertexPosition.glsl.js";import"../../../../core/shaderLibrary/output/OutputDepth.glsl.js";import"../../../../core/shaderLibrary/output/OutputHighlight.glsl.js";import"../../../../core/shaderLibrary/output/ReadDepth.glsl.js";import"../../../../core/shaderLibrary/shading/ComputeMaterialColor.glsl.js";import"../../../../core/shaderLibrary/shading/ComputeNormalTexture.glsl.js";import"../../../../core/shaderLibrary/shading/ComputeShadingNormal.glsl.js";import"../../../../core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import"../../../../core/shaderLibrary/shading/MainLighting.glsl.js";import"../../../../core/shaderLibrary/shading/MultipassTerrainTest.glsl.js";import"../../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import"../../../../core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js";import"../../../../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import"../../../../core/shaderLibrary/terrain/Overlay.glsl.js";import"../../../../core/shaderLibrary/util/AlphaCutoff.js";import"../../../../core/shaderLibrary/util/AlphaDiscard.glsl.js";import"../../../../core/shaderLibrary/util/EllipsoidMode.js";import"../../../../core/shaderModules/interfaces.js";import"../../../../core/shaderModules/ShaderBuilder.js";import"../../../../core/shaderModules/Texture2DPassUniform.js";import"../../../../lib/TransparencyPassType.js";import"../../../../shaders/OutputColorHighlightOID.glsl.js";export{b as build}from"../../../../../../../chunks/ComponentShader.glsl.js";
5
+ import"../../../../../../../geometry/support/Ellipsoid.js";import"../../../../../terrain/OverlayContent.js";import"../ComponentTechniqueConfiguration.js";import"./ComponentData.glsl.js";import"./VertexDiscardByOpacity.glsl.js";import"../../../../core/shaderLibrary/ForwardLinearDepth.glsl.js";import"../../../../core/shaderLibrary/ShaderOutput.js";import"../../../../core/shaderLibrary/Slice.glsl.js";import"../../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import"../../../../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import"../../../../core/shaderLibrary/attributes/VertexColor.glsl.js";import"../../../../core/shaderLibrary/attributes/VertexNormal.glsl.js";import"../../../../core/shaderLibrary/attributes/VertexPosition.glsl.js";import"../../../../core/shaderLibrary/output/OutputDepth.glsl.js";import"../../../../core/shaderLibrary/output/OutputHighlight.glsl.js";import"../../../../core/shaderLibrary/output/ReadDepth.glsl.js";import"../../../../core/shaderLibrary/shading/ComputeMaterialColor.glsl.js";import"../../../../core/shaderLibrary/shading/ComputeNormalTexture.glsl.js";import"../../../../core/shaderLibrary/shading/ComputeShadingNormal.glsl.js";import"../../../../core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import"../../../../core/shaderLibrary/shading/MainLighting.glsl.js";import"../../../../core/shaderLibrary/shading/MultipassTerrainTest.glsl.js";import"../../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import"../../../../core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js";import"../../../../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import"../../../../core/shaderLibrary/terrain/Overlay.glsl.js";import"../../../../core/shaderLibrary/util/AlphaCutoff.js";import"../../../../core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js";import"../../../../core/shaderLibrary/util/EllipsoidMode.js";import"../../../../core/shaderModules/interfaces.js";import"../../../../core/shaderModules/ShaderBuilder.js";import"../../../../core/shaderModules/Texture2DPassUniform.js";import"../../../../lib/TransparencyPassType.js";import"../../../../shaders/OutputColorHighlightOID.glsl.js";export{b as build}from"../../../../../../../chunks/ComponentShader.glsl.js";
@@ -41,7 +41,7 @@ angleCutoffAdjust = 0.0;
41
41
  float ddepth = fwidth(linearDepth);
42
42
  depthDiscontinuityAlpha = 1.0 - smoothstep(0.0, 0.01, -ddepth / linearDepth);
43
43
  return true;
44
- }`),p.contrastControlEnabled?(i.uniforms.add(new a("frameColor",((o,e)=>o.frameColor)),new t("globalAlphaContrastBoost",(o=>null!=o.globalAlphaContrastBoost?o.globalAlphaContrastBoost:1))),i.code.add(r`float rgbToLuminance(vec3 color) {
44
+ }`),p.contrastControlEnabled?(i.uniforms.add(new a("frameColor",((o,e)=>o.colors)),new t("globalAlphaContrastBoost",(o=>null!=o.globalAlphaContrastBoost?o.globalAlphaContrastBoost:1))),i.code.add(r`float rgbToLuminance(vec3 color) {
45
45
  return dot(vec3(0.2126, 0.7152, 0.0722), color);
46
46
  }
47
47
  vec4 laserlineOutput(vec4 color) {
@@ -2,7 +2,7 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{addNearFar as o}from"../ForwardLinearDepth.glsl.js";import{ShaderOutput as e}from"../ShaderOutput.js";import{SliceDraw as r}from"../Slice.glsl.js";import{Transform as i}from"../Transform.glsl.js";import{NormalAttribute as t,NormalType as a}from"../attributes/NormalAttribute.glsl.js";import{ObjectAndLayerIdColor as s}from"../attributes/ObjectAndLayerIdColor.glsl.js";import{TextureCoordinateAttribute as d}from"../attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormal as l}from"../attributes/VertexNormal.glsl.js";import{OutputDepth as n}from"../output/OutputDepth.glsl.js";import{OutputHighlight as c}from"../output/OutputHighlight.glsl.js";import{VisualVariables as u}from"../shading/VisualVariables.glsl.js";import{DiscardOrAdjustAlphaPass as p}from"../util/AlphaDiscard.glsl.js";import{addProjViewLocalOrigin as v}from"../util/View.glsl.js";import{glsl as m}from"../../shaderModules/interfaces.js";import{Texture2DPassUniform as f}from"../../shaderModules/Texture2DPassUniform.js";import{AlphaDiscardMode as g}from"../../../lib/basicInterfaces.js";function x(x,h){const{vertex:j,fragment:O}=x,w=h.hasColorTexture&&h.alphaDiscardMode!==g.Opaque;switch(h.output){case e.Depth:v(j,h),x.include(i,h),x.include(r,h),x.include(d,h),w&&O.uniforms.add(new f("tex",(o=>o.texture))),j.code.add(m`void main(void) {
5
+ import{addNearFar as o}from"../ForwardLinearDepth.glsl.js";import{ShaderOutput as e}from"../ShaderOutput.js";import{SliceDraw as r}from"../Slice.glsl.js";import{Transform as i}from"../Transform.glsl.js";import{NormalAttribute as t,NormalType as a}from"../attributes/NormalAttribute.glsl.js";import{ObjectAndLayerIdColor as s}from"../attributes/ObjectAndLayerIdColor.glsl.js";import{TextureCoordinateAttribute as d}from"../attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormal as l}from"../attributes/VertexNormal.glsl.js";import{OutputDepth as n}from"../output/OutputDepth.glsl.js";import{OutputHighlight as c}from"../output/OutputHighlight.glsl.js";import{VisualVariables as u}from"../shading/VisualVariables.glsl.js";import{DiscardOrAdjustAlphaPass as p}from"../util/DiscardOrAdjustAlpha.glsl.js";import{addProjViewLocalOrigin as v}from"../util/View.glsl.js";import{glsl as m}from"../../shaderModules/interfaces.js";import{Texture2DPassUniform as f}from"../../shaderModules/Texture2DPassUniform.js";import{AlphaDiscardMode as g}from"../../../lib/basicInterfaces.js";function x(x,h){const{vertex:j,fragment:O}=x,w=h.hasColorTexture&&h.alphaDiscardMode!==g.Opaque;switch(h.output){case e.Depth:v(j,h),x.include(i,h),x.include(r,h),x.include(d,h),w&&O.uniforms.add(new f("tex",(o=>o.texture))),j.code.add(m`void main(void) {
6
6
  vpos = getVertexInLocalOriginSpace();
7
7
  vpos = subtractOrigin(vpos);
8
8
  vpos = addVerticalOffset(vpos, localOrigin);
@@ -2,21 +2,21 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{RgbaFloatEncoding as e}from"../util/RgbaFloatEncoding.glsl.js";import{addCameraPosition as t,addPixelRatio as o}from"../util/View.glsl.js";import{Float4PassUniform as i}from"../../shaderModules/Float4PassUniform.js";import{FloatPassUniform as r}from"../../shaderModules/FloatPassUniform.js";import{glsl as l}from"../../shaderModules/interfaces.js";import{Texture2DPassUniform as a}from"../../shaderModules/Texture2DPassUniform.js";import{computeLongestPattern as p,computeTextureSize as n}from"../../../materials/stippleTextureRepository.js";import{ensureColor4 as s}from"../../../shaders/ensureColor4.js";function d(e,t){e.constants.add("stippleAlphaColorDiscard","float",.001),e.constants.add("stippleAlphaHighlightDiscard","float",.5),t.stippleEnabled?c(e,t):f(e)}function c(p,n){const d=!(n.draped&&n.stipplePreferContinuous),{vertex:c,fragment:f}=p;f.include(e),n.draped||(t(c,n),c.uniforms.add(new r("worldToScreenPerDistanceRatio",((e,t)=>1/t.camera.perScreenPixelRatio))),c.code.add(l`float computeWorldToScreenRatio(vec3 segmentCenter) {
5
+ import{alphaCutoff as e}from"../util/AlphaCutoff.js";import{RgbaFloatEncoding as t}from"../util/RgbaFloatEncoding.glsl.js";import{addCameraPosition as o,addPixelRatio as i}from"../util/View.glsl.js";import{Float4PassUniform as r}from"../../shaderModules/Float4PassUniform.js";import{FloatPassUniform as l}from"../../shaderModules/FloatPassUniform.js";import{glsl as a}from"../../shaderModules/interfaces.js";import{Texture2DPassUniform as p}from"../../shaderModules/Texture2DPassUniform.js";import{computeLongestPattern as s,computeTextureSize as n}from"../../../materials/stippleTextureRepository.js";import{ensureColor4 as d}from"../../../shaders/ensureColor4.js";function c(t,o){t.constants.add("stippleAlphaColorDiscard","float",e),t.constants.add("stippleAlphaHighlightDiscard","float",.5),o.stippleEnabled?f(t,o):m(t)}function f(e,s){const n=!(s.draped&&s.stipplePreferContinuous),{vertex:c,fragment:f}=e;f.include(t),s.draped||(o(c,s),c.uniforms.add(new l("worldToScreenPerDistanceRatio",((e,t)=>1/t.camera.perScreenPixelRatio))),c.code.add(a`float computeWorldToScreenRatio(vec3 segmentCenter) {
6
6
  float segmentDistanceToCamera = length(segmentCenter - cameraPosition);
7
7
  return worldToScreenPerDistanceRatio / segmentDistanceToCamera;
8
- }`)),p.varyings.add("vStippleDistance","float"),p.varyings.add("vStippleDistanceLimits","vec2"),p.varyings.add("vStipplePatternStretch","float"),c.code.add(l`
8
+ }`)),e.varyings.add("vStippleDistance","float"),e.varyings.add("vStippleDistanceLimits","vec2"),e.varyings.add("vStipplePatternStretch","float"),c.code.add(a`
9
9
  float discretizeWorldToScreenRatio(float worldToScreenRatio) {
10
- float step = ${u};
10
+ float step = ${h};
11
11
 
12
12
  float discreteWorldToScreenRatio = log(worldToScreenRatio);
13
13
  discreteWorldToScreenRatio = ceil(discreteWorldToScreenRatio / step) * step;
14
14
  discreteWorldToScreenRatio = exp(discreteWorldToScreenRatio);
15
15
  return discreteWorldToScreenRatio;
16
16
  }
17
- `),c.code.add(l`vec2 computeStippleDistanceLimits(float startPseudoScreen, float segmentLengthPseudoScreen, float segmentLengthScreen, float patternLength) {`),c.code.add(l`
18
- if (segmentLengthPseudoScreen >= ${d?"patternLength":"1e4"}) {
19
- `),o(c),c.code.add(l`float repetitions = segmentLengthScreen / (patternLength * pixelRatio);
17
+ `),c.code.add(a`vec2 computeStippleDistanceLimits(float startPseudoScreen, float segmentLengthPseudoScreen, float segmentLengthScreen, float patternLength) {`),c.code.add(a`
18
+ if (segmentLengthPseudoScreen >= ${n?"patternLength":"1e4"}) {
19
+ `),i(c),c.code.add(a`float repetitions = segmentLengthScreen / (patternLength * pixelRatio);
20
20
  float flooredRepetitions = max(1.0, floor(repetitions + 0.5));
21
21
  float segmentLengthScreenRounded = flooredRepetitions * patternLength;
22
22
  float stretch = repetitions / flooredRepetitions;
@@ -24,7 +24,7 @@ vStipplePatternStretch = max(0.75, stretch);
24
24
  return vec2(0.0, segmentLengthScreenRounded);
25
25
  }
26
26
  return vec2(startPseudoScreen, startPseudoScreen + segmentLengthPseudoScreen);
27
- }`),f.uniforms.add(new a("stipplePatternTexture",(e=>e.stippleTexture)),new r("stipplePatternSDFNormalizer",(e=>m(e.stipplePattern))),new r("stipplePatternPixelSizeInv",(e=>1/S(e)))),f.code.add(l`float getStippleSDF(out bool isClamped) {
27
+ }`),f.uniforms.add(new p("stipplePatternTexture",(e=>e.stippleTexture)),new l("stipplePatternSDFNormalizer",(e=>S(e.stipplePattern))),new l("stipplePatternPixelSizeInv",(e=>1/u(e)))),f.code.add(a`float getStippleSDF(out bool isClamped) {
28
28
  float stippleDistanceClamped = clamp(vStippleDistance, vStippleDistanceLimits.x, vStippleDistanceLimits.y);
29
29
  vec2 aaCorrectedLimits = vStippleDistanceLimits + vec2(1.0, -1.0) / gl_FragCoord.w;
30
30
  isClamped = vStippleDistance < aaCorrectedLimits.x || vStippleDistance > aaCorrectedLimits.y;
@@ -43,8 +43,8 @@ bool isClamped;
43
43
  float stippleSDF = getStippleSDF(isClamped);
44
44
  float antiAliasedResult = clamp(stippleSDF * vLineWidth + 0.5, 0.0, 1.0);
45
45
  return isClamped ? floor(antiAliasedResult + 0.5) : antiAliasedResult;
46
- }`),n.stippleOffColorEnabled?(f.uniforms.add(new i("stippleOffColor",(e=>s(e.stippleOffColor)))),f.code.add(l`#define discardByStippleAlpha(stippleAlpha, threshold) {}
47
- #define blendStipple(color, stippleAlpha) mix(color, stippleOffColor, stippleAlpha)`)):f.code.add(l`#define discardByStippleAlpha(stippleAlpha, threshold) if (stippleAlpha < threshold) { discard; }
48
- #define blendStipple(color, stippleAlpha) vec4(color.rgb, color.a * stippleAlpha)`)}function f(e){e.fragment.code.add(l`float getStippleAlpha() { return 1.0; }
46
+ }`),s.stippleOffColorEnabled?(f.uniforms.add(new r("stippleOffColor",(e=>d(e.stippleOffColor)))),f.code.add(a`#define discardByStippleAlpha(stippleAlpha, threshold) {}
47
+ #define blendStipple(color, stippleAlpha) mix(color, stippleOffColor, stippleAlpha)`)):f.code.add(a`#define discardByStippleAlpha(stippleAlpha, threshold) if (stippleAlpha < threshold) { discard; }
48
+ #define blendStipple(color, stippleAlpha) vec4(color.rgb, color.a * stippleAlpha)`)}function m(e){e.fragment.code.add(a`float getStippleAlpha() { return 1.0; }
49
49
  #define discardByStippleAlpha(_stippleAlpha_, _threshold_) {}
50
- #define blendStipple(color, _stippleAlpha_) color`)}function m(e){return e?(Math.floor(.5*(p(e)-1))+.5)/e.pixelRatio:1}function S(e){const t=e.stipplePattern;return t?n(e.stipplePattern)/t.pixelRatio:1}const u=l.float(.4);export{d as LineStipple,S as computePixelSize};
50
+ #define blendStipple(color, _stippleAlpha_) color`)}function S(e){return e?(Math.floor(.5*(s(e)-1))+.5)/e.pixelRatio:1}function u(e){const t=e.stipplePattern;return t?n(e.stipplePattern)/t.pixelRatio:1}const h=a.float(.4);export{c as LineStipple,u as computePixelSize};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../../../core/libs/gl-matrix-2/math/mat4.js";import"../../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import"../../../../../../chunks/vec32.js";import"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import"../../../../terrain/OverlayContent.js";import"../../../../terrain/TransparencyMode.js";import"../ForwardLinearDepth.glsl.js";import"../ShaderOutput.js";import"../Slice.glsl.js";import"../Transform.glsl.js";import"../attributes/NormalAttribute.glsl.js";import"../attributes/PositionAttribute.glsl.js";import"../attributes/TextureCoordinateAttribute.glsl.js";import"../attributes/VertexTangent.glsl.js";import"../output/OutputDepth.glsl.js";import"../output/OutputHighlight.glsl.js";import"../shading/EvaluateAmbientOcclusion.glsl.js";import"../shading/EvaluateSceneLighting.glsl.js";import"../shading/MainLighting.glsl.js";import"../shading/NormalUtils.glsl.js";import"../shading/PhysicallyBasedRenderingParameters.glsl.js";import"../shading/ReadShadowMap.glsl.js";import"./Overlay.glsl.js";import"./TerrainTexture.glsl.js";import"../util/View.glsl.js";import"../../shaderModules/Float3PassUniform.js";import"../../shaderModules/interfaces.js";import"../../shaderModules/Matrix4DrawUniform.js";import"../../shaderModules/ShaderBuilder.js";import"../../shaderModules/Texture2DPassUniform.js";export{T as TerrainPassParameters,b as build}from"../../../../../../chunks/Terrain.glsl.js";
5
+ import"../../../../../../core/libs/gl-matrix-2/math/mat4.js";import"../../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import"../../../../../../chunks/vec32.js";import"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import"../../../../terrain/OverlayContent.js";import"../../../../terrain/TransparencyMode.js";import"../ForwardLinearDepth.glsl.js";import"../ShaderOutput.js";import"../Slice.glsl.js";import"../Transform.glsl.js";import"../attributes/NormalAttribute.glsl.js";import"../attributes/PositionAttribute.glsl.js";import"../attributes/TextureCoordinateAttribute.glsl.js";import"../attributes/VertexTangent.glsl.js";import"../output/OutputDepth.glsl.js";import"../output/OutputHighlight.glsl.js";import"../shading/EvaluateAmbientOcclusion.glsl.js";import"../shading/EvaluateSceneLighting.glsl.js";import"../shading/MainLighting.glsl.js";import"../shading/NormalUtils.glsl.js";import"../shading/PhysicallyBasedRenderingParameters.glsl.js";import"../shading/ReadShadowMap.glsl.js";import"./Overlay.glsl.js";import"./TerrainTexture.glsl.js";import"../util/AlphaCutoff.js";import"../util/View.glsl.js";import"../../shaderModules/Float3PassUniform.js";import"../../shaderModules/interfaces.js";import"../../shaderModules/Matrix4DrawUniform.js";import"../../shaderModules/ShaderBuilder.js";import"../../shaderModules/Texture2DPassUniform.js";export{T as TerrainPassParameters,b as build}from"../../../../../../chunks/Terrain.glsl.js";
@@ -0,0 +1,9 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
+ */
5
+ import{alphaCutoff as o}from"./AlphaCutoff.js";import{FloatDrawUniform as a}from"../../shaderModules/FloatDrawUniform.js";import{FloatPassUniform as r}from"../../shaderModules/FloatPassUniform.js";import{glsl as e}from"../../shaderModules/interfaces.js";import{AlphaDiscardMode as d}from"../../../lib/basicInterfaces.js";function t(o,a){f(o,a,new r("textureAlphaCutoff",(o=>o.textureAlphaCutoff)))}function s(o,r){f(o,r,new a("textureAlphaCutoff",(o=>o.textureAlphaCutoff)))}function f(a,r,t){const s=a.fragment;switch(r.alphaDiscardMode){case d.Blend:a.fragment.code.add(e`
6
+ #define discardOrAdjustAlpha(color) { if (color.a < ${e.float(o)}) { discard; } }
7
+ `);break;case d.Opaque:s.code.add(e`void discardOrAdjustAlpha(inout vec4 color) {
8
+ color.a = 1.0;
9
+ }`);break;case d.Mask:s.uniforms.add(t).code.add(e`#define discardOrAdjustAlpha(color) { if (color.a < textureAlphaCutoff) { discard; } else { color.a = 1.0; } }`);break;case d.MaskBlend:s.uniforms.add(t).code.add(e`#define discardOrAdjustAlpha(color) { if (color.a < textureAlphaCutoff) { discard; } }`)}}export{s as DiscardOrAdjustAlphaDraw,t as DiscardOrAdjustAlphaPass};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/has.js";import{releaseMaybe as t,disposeMaybe as i,destroyMaybe as s}from"../../../../../core/maybe.js";import{property as n}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import{c as a,g as h}from"../../../../../chunks/vec32.js";import{create as l,fromRay as o,getStart as c,getEnd as d}from"../../../../../geometry/support/clipRay.js";import{intersectClipRay as p}from"../../../../../geometry/support/frustum.js";import{copy as m}from"../../../../../geometry/support/lineSegment.js";import{wrap as u}from"../../../../../geometry/support/ray.js";import{ViewingMode as _}from"../../../../ViewingMode.js";import P from"../../../webgl/RenderNode.js";import{Blit as g}from"../blit/Blit.js";import{LaserlinePathData as b}from"./LaserlinePathData.js";import{LaserlinePathTechnique as f}from"./LaserlinePathTechnique.js";import{LaserlinePathTechniqueConfiguration as E}from"./LaserlinePathTechniqueConfiguration.js";import{LaserlinePassParameters as q,LaserlineTechnique as D}from"./LaserlineTechnique.js";import{LaserlineTechniqueConfiguration as T}from"./LaserlineTechniqueConfiguration.js";import{RenderRequestType as L,Decorations as V}from"../../lib/basicInterfaces.js";import{updateParameters as C}from"../../materials/internal/MaterialUtil.js";import{AlphaMode as R}from"../../shaders/CompositingTechniqueConfiguration.js";import{ClearBufferBit as A}from"../../../../webgl/enums.js";let j=class extends P{constructor(e){super(e),this.produces="laserline-color",this.consumes={required:["laserline-color","normals"]},this.requireGeometryDepth=!0,this._technique=null,this._pathTechnique=null,this._blit=null,this._heightManifoldEnabled=!1,this._pointDistanceEnabled=!1,this._lineVerticalPlaneEnabled=!1,this._intersectsLineEnabled=!1,this._intersectsLineInfinite=!1,this._pathVerticalPlaneEnabled=!1,this._pathVerticalPlaneData=null,this._passParameters=new q}initialize(){this._techniques=this.view._stage.renderView.techniques,this._passParameters.renderCoordsHelper=this.view.renderCoordsHelper,this._techniqueConfig=new T;const e=new E;e.contrastControlEnabled=this.contrastControlEnabled,this._pathTechnique=this._techniques.acquire(f,e)}destroy(){this._technique=t(this._technique),this._pathVerticalPlaneData=i(this._pathVerticalPlaneData),this._pathTechnique?.release(),this._blit=s(this._blit)}get heightManifoldEnabled(){return this._heightManifoldEnabled}set heightManifoldEnabled(e){this._heightManifoldEnabled!==e&&(this._heightManifoldEnabled=e,this.requestRender(L.UPDATE))}get heightManifoldTarget(){return this._passParameters.heightManifoldTarget}set heightManifoldTarget(e){a(this._passParameters.heightManifoldTarget,e),this.requestRender(L.UPDATE)}get pointDistanceEnabled(){return this._pointDistanceEnabled}set pointDistanceEnabled(e){e!==this._pointDistanceEnabled&&(this._pointDistanceEnabled=e,this.requestRender(L.UPDATE))}get pointDistanceTarget(){return this._passParameters.pointDistanceTarget}set pointDistanceTarget(e){a(this._passParameters.pointDistanceTarget,e),this.requestRender(L.UPDATE)}get pointDistanceOrigin(){return this._passParameters.pointDistanceOrigin}set pointDistanceOrigin(e){a(this._passParameters.pointDistanceOrigin,e),this.requestRender(L.UPDATE)}get lineVerticalPlaneEnabled(){return this._lineVerticalPlaneEnabled}set lineVerticalPlaneEnabled(e){e!==this._lineVerticalPlaneEnabled&&(this._lineVerticalPlaneEnabled=e,this.requestRender(L.UPDATE))}get lineVerticalPlaneSegment(){return this._passParameters.lineVerticalPlaneSegment}set lineVerticalPlaneSegment(e){m(e,this._passParameters.lineVerticalPlaneSegment),this.requestRender(L.UPDATE)}get intersectsLineEnabled(){return this._intersectsLineEnabled}set intersectsLineEnabled(e){e!==this._intersectsLineEnabled&&(this._intersectsLineEnabled=e,this.requestRender(L.UPDATE))}get intersectsLineSegment(){return this._passParameters.intersectsLineSegment}set intersectsLineSegment(e){m(e,this._passParameters.intersectsLineSegment),this.requestRender(L.UPDATE)}get intersectsLineRadius(){return this._passParameters.intersectsLineRadius}set intersectsLineRadius(e){e!==this._passParameters.intersectsLineRadius&&(this._passParameters.intersectsLineRadius=e,this.requestRender(L.UPDATE))}get intersectsLineInfinite(){return this._intersectsLineInfinite}set intersectsLineInfinite(e){e!==this._intersectsLineInfinite&&(this._intersectsLineInfinite=e,this.requestRender(L.UPDATE))}get pathVerticalPlaneEnabled(){return this._pathVerticalPlaneEnabled}set pathVerticalPlaneEnabled(e){e!==this._pathVerticalPlaneEnabled&&(this._pathVerticalPlaneEnabled=e,null!=this._pathVerticalPlaneData&&this.requestRender(L.UPDATE))}set pathVerticalPlaneVertices(e){null==this._pathVerticalPlaneData&&(this._pathVerticalPlaneData=new b(this._passParameters.renderCoordsHelper)),this._pathVerticalPlaneData.vertices=e,this.pathVerticalPlaneEnabled&&this.requestRender(L.UPDATE)}set pathVerticalPlaneBuffers(e){null==this._pathVerticalPlaneData&&(this._pathVerticalPlaneData=new b(this._passParameters.renderCoordsHelper)),this._pathVerticalPlaneData.buffers=e,this.pathVerticalPlaneEnabled&&this.requestRender(L.UPDATE)}setParameters(e){C(this._passParameters,e)&&this.requestRender(L.UPDATE)}render(e){const t=e.find((({name:e})=>"laserline-color"===e));if(this.bindParameters.decorations===V.OFF)return t;const i=e.find((({name:e})=>"normals"===e)),s=this.renderingContext;this._passParameters.normals=i.getTexture();const n=()=>{(this.heightManifoldEnabled||this.pointDistanceEnabled||this.lineVerticalPlaneSegment||this.intersectsLineEnabled)&&this._renderUnified(),this.pathVerticalPlaneEnabled&&this._renderPath()};if(!this.contrastControlEnabled)return s.bindFramebuffer(t.fbo),n(),t;this._passParameters.frameColor=t.getTexture();const r=this.fboCache.acquire(t.fbo.width,t.fbo.height,"laser lines");s.unbindTexture(r.fbo?.colorTexture),s.bindFramebuffer(r.fbo),s.setClearColor(0,0,0,0),s.clear(A.COLOR_BUFFER_BIT|A.DEPTH_BUFFER_BIT),n(),this._blit??=new g(this._techniques,R.PremultipliedAlpha);const a=this._blit.blend(s,r,t,this.bindParameters,(()=>this.requestRender));return a.attachDepth(t.getAttachment(this.gl.DEPTH_STENCIL_ATTACHMENT)),r.release(),a}_renderUnified(){if(this._techniqueConfig.heightManifoldEnabled=this.heightManifoldEnabled,this._techniqueConfig.lineVerticalPlaneEnabled=this.lineVerticalPlaneEnabled,this._techniqueConfig.pointDistanceEnabled=this.pointDistanceEnabled,this._techniqueConfig.intersectsLineEnabled=this.intersectsLineEnabled,this._techniqueConfig.contrastControlEnabled=this.contrastControlEnabled,this._techniqueConfig.spherical=this.view.state.viewingMode===_.Global,this._technique=this._techniques.releaseAndAcquire(D,this._techniqueConfig,this._technique),!this._technique?.compiled)return void this.requestRender(L.UPDATE);const e=this.renderingContext;this._updatePassParameters(),e.bindTechnique(this._technique,this.bindParameters,this._passParameters),e.screen.draw()}_renderPath(){if(null==this._pathVerticalPlaneData)return;if(this._pathTechnique&&!this._pathTechnique.compiled)return void this.requestRender(L.UPDATE);const e=this.renderingContext;e.bindTechnique(this._pathTechnique,this.bindParameters,{...this._passParameters,origin:this._pathVerticalPlaneData.origin}),this._pathVerticalPlaneData.draw(e)}_updatePassParameters(){if(!this._intersectsLineEnabled)return;const e=this.bindParameters.camera;if(this._intersectsLineInfinite){if(o(u(this._passParameters.intersectsLineSegment.origin,this._passParameters.intersectsLineSegment.vector),U),U.c0=-Number.MAX_VALUE,!p(e.frustum,U))return;c(U,this._passParameters.lineStartWorld),d(U,this._passParameters.lineEndWorld)}else a(this._passParameters.lineStartWorld,this._passParameters.intersectsLineSegment.origin),h(this._passParameters.lineEndWorld,this._passParameters.intersectsLineSegment.origin,this._passParameters.intersectsLineSegment.vector)}get test(){}};e([n({constructOnly:!0})],j.prototype,"contrastControlEnabled",void 0),e([n({constructOnly:!0})],j.prototype,"isDecoration",void 0),e([n()],j.prototype,"produces",void 0),e([n()],j.prototype,"consumes",void 0),j=e([r("esri.views.3d.webgl-engine.effects.laserlines.LaserLineRenderer")],j);const U=l();export{j as LaserLineRenderer};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/has.js";import{releaseMaybe as t,disposeMaybe as i,destroyMaybe as s}from"../../../../../core/maybe.js";import{property as n}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import{c as a,g as h}from"../../../../../chunks/vec32.js";import{create as l,fromRay as o,getStart as c,getEnd as d}from"../../../../../geometry/support/clipRay.js";import{intersectClipRay as p}from"../../../../../geometry/support/frustum.js";import{copy as u}from"../../../../../geometry/support/lineSegment.js";import{wrap as m}from"../../../../../geometry/support/ray.js";import{ViewingMode as _}from"../../../../ViewingMode.js";import P from"../../../webgl/RenderNode.js";import{Blit as g}from"../blit/Blit.js";import{LaserlinePathData as b}from"./LaserlinePathData.js";import{LaserlinePathTechnique as f}from"./LaserlinePathTechnique.js";import{LaserlinePathTechniqueConfiguration as E}from"./LaserlinePathTechniqueConfiguration.js";import{LaserlinePassParameters as q,LaserlineTechnique as D}from"./LaserlineTechnique.js";import{LaserlineTechniqueConfiguration as T}from"./LaserlineTechniqueConfiguration.js";import{RenderRequestType as L,Decorations as V}from"../../lib/basicInterfaces.js";import{updateParameters as C}from"../../materials/internal/MaterialUtil.js";import{AlphaMode as R}from"../../shaders/CompositingTechniqueConfiguration.js";import{ClearBufferBit as A}from"../../../../webgl/enums.js";let j=class extends P{constructor(e){super(e),this.produces="laserline-color",this.consumes={required:["laserline-color","normals"]},this.requireGeometryDepth=!0,this._technique=null,this._pathTechnique=null,this._blit=null,this._heightManifoldEnabled=!1,this._pointDistanceEnabled=!1,this._lineVerticalPlaneEnabled=!1,this._intersectsLineEnabled=!1,this._intersectsLineInfinite=!1,this._pathVerticalPlaneEnabled=!1,this._pathVerticalPlaneData=null,this._passParameters=new q}initialize(){this._techniques=this.view._stage.renderView.techniques,this._passParameters.renderCoordsHelper=this.view.renderCoordsHelper,this._techniqueConfig=new T;const e=new E;e.contrastControlEnabled=this.contrastControlEnabled,this._pathTechnique=this._techniques.acquire(f,e)}destroy(){this._technique=t(this._technique),this._pathVerticalPlaneData=i(this._pathVerticalPlaneData),this._pathTechnique?.release(),this._blit=s(this._blit)}get heightManifoldEnabled(){return this._heightManifoldEnabled}set heightManifoldEnabled(e){this._heightManifoldEnabled!==e&&(this._heightManifoldEnabled=e,this.requestRender(L.UPDATE))}get heightManifoldTarget(){return this._passParameters.heightManifoldTarget}set heightManifoldTarget(e){a(this._passParameters.heightManifoldTarget,e),this.requestRender(L.UPDATE)}get pointDistanceEnabled(){return this._pointDistanceEnabled}set pointDistanceEnabled(e){e!==this._pointDistanceEnabled&&(this._pointDistanceEnabled=e,this.requestRender(L.UPDATE))}get pointDistanceTarget(){return this._passParameters.pointDistanceTarget}set pointDistanceTarget(e){a(this._passParameters.pointDistanceTarget,e),this.requestRender(L.UPDATE)}get pointDistanceOrigin(){return this._passParameters.pointDistanceOrigin}set pointDistanceOrigin(e){a(this._passParameters.pointDistanceOrigin,e),this.requestRender(L.UPDATE)}get lineVerticalPlaneEnabled(){return this._lineVerticalPlaneEnabled}set lineVerticalPlaneEnabled(e){e!==this._lineVerticalPlaneEnabled&&(this._lineVerticalPlaneEnabled=e,this.requestRender(L.UPDATE))}get lineVerticalPlaneSegment(){return this._passParameters.lineVerticalPlaneSegment}set lineVerticalPlaneSegment(e){u(e,this._passParameters.lineVerticalPlaneSegment),this.requestRender(L.UPDATE)}get intersectsLineEnabled(){return this._intersectsLineEnabled}set intersectsLineEnabled(e){e!==this._intersectsLineEnabled&&(this._intersectsLineEnabled=e,this.requestRender(L.UPDATE))}get intersectsLineSegment(){return this._passParameters.intersectsLineSegment}set intersectsLineSegment(e){u(e,this._passParameters.intersectsLineSegment),this.requestRender(L.UPDATE)}get intersectsLineRadius(){return this._passParameters.intersectsLineRadius}set intersectsLineRadius(e){e!==this._passParameters.intersectsLineRadius&&(this._passParameters.intersectsLineRadius=e,this.requestRender(L.UPDATE))}get intersectsLineInfinite(){return this._intersectsLineInfinite}set intersectsLineInfinite(e){e!==this._intersectsLineInfinite&&(this._intersectsLineInfinite=e,this.requestRender(L.UPDATE))}get pathVerticalPlaneEnabled(){return this._pathVerticalPlaneEnabled}set pathVerticalPlaneEnabled(e){e!==this._pathVerticalPlaneEnabled&&(this._pathVerticalPlaneEnabled=e,null!=this._pathVerticalPlaneData&&this.requestRender(L.UPDATE))}set pathVerticalPlaneVertices(e){null==this._pathVerticalPlaneData&&(this._pathVerticalPlaneData=new b(this._passParameters.renderCoordsHelper)),this._pathVerticalPlaneData.vertices=e,this.pathVerticalPlaneEnabled&&this.requestRender(L.UPDATE)}set pathVerticalPlaneBuffers(e){null==this._pathVerticalPlaneData&&(this._pathVerticalPlaneData=new b(this._passParameters.renderCoordsHelper)),this._pathVerticalPlaneData.buffers=e,this.pathVerticalPlaneEnabled&&this.requestRender(L.UPDATE)}setParameters(e){C(this._passParameters,e)&&this.requestRender(L.UPDATE)}render(e){const t=e.find((({name:e})=>"laserline-color"===e));if(this.bindParameters.decorations===V.OFF)return t;const i=e.find((({name:e})=>"normals"===e)),s=this.renderingContext;this._passParameters.normals=i.getTexture();const n=()=>{(this.heightManifoldEnabled||this.pointDistanceEnabled||this.lineVerticalPlaneSegment||this.intersectsLineEnabled)&&this._renderUnified(),this.pathVerticalPlaneEnabled&&this._renderPath()};if(!this.contrastControlEnabled)return s.bindFramebuffer(t.fbo),n(),t;this._passParameters.colors=t.getTexture();const r=this.fboCache.acquire(t.fbo.width,t.fbo.height,"laser lines");s.unbindTexture(r.fbo?.colorTexture),s.bindFramebuffer(r.fbo),s.setClearColor(0,0,0,0),s.clear(A.COLOR_BUFFER_BIT|A.DEPTH_BUFFER_BIT),n(),this._blit??=new g(this._techniques,R.PremultipliedAlpha);const a=this._blit.blend(s,r,t,this.bindParameters,(()=>this.requestRender));return a.attachDepth(t.getAttachment(this.gl.DEPTH_STENCIL_ATTACHMENT)),r.release(),a}_renderUnified(){if(this._techniqueConfig.heightManifoldEnabled=this.heightManifoldEnabled,this._techniqueConfig.lineVerticalPlaneEnabled=this.lineVerticalPlaneEnabled,this._techniqueConfig.pointDistanceEnabled=this.pointDistanceEnabled,this._techniqueConfig.intersectsLineEnabled=this.intersectsLineEnabled,this._techniqueConfig.contrastControlEnabled=this.contrastControlEnabled,this._techniqueConfig.spherical=this.view.state.viewingMode===_.Global,this._technique=this._techniques.releaseAndAcquire(D,this._techniqueConfig,this._technique),!this._technique?.compiled)return void this.requestRender(L.UPDATE);const e=this.renderingContext;this._updatePassParameters(),e.bindTechnique(this._technique,this.bindParameters,this._passParameters),e.screen.draw()}_renderPath(){if(null==this._pathVerticalPlaneData)return;if(this._pathTechnique&&!this._pathTechnique.compiled)return void this.requestRender(L.UPDATE);const e=this.renderingContext;e.bindTechnique(this._pathTechnique,this.bindParameters,{...this._passParameters,origin:this._pathVerticalPlaneData.origin}),this._pathVerticalPlaneData.draw(e)}_updatePassParameters(){if(!this._intersectsLineEnabled)return;const e=this.bindParameters.camera;if(this._intersectsLineInfinite){if(o(m(this._passParameters.intersectsLineSegment.origin,this._passParameters.intersectsLineSegment.vector),U),U.c0=-Number.MAX_VALUE,!p(e.frustum,U))return;c(U,this._passParameters.lineStartWorld),d(U,this._passParameters.lineEndWorld)}else a(this._passParameters.lineStartWorld,this._passParameters.intersectsLineSegment.origin),h(this._passParameters.lineEndWorld,this._passParameters.intersectsLineSegment.origin,this._passParameters.intersectsLineSegment.vector)}get test(){}};e([n({constructOnly:!0})],j.prototype,"contrastControlEnabled",void 0),e([n({constructOnly:!0})],j.prototype,"isDecoration",void 0),e([n()],j.prototype,"produces",void 0),e([n()],j.prototype,"consumes",void 0),j=e([r("esri.views.3d.webgl-engine.effects.laserlines.LaserLineRenderer")],j);const U=l();export{j as LaserLineRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{CloudsParameters as e}from"../../environment/CloudsParameters.js";import s from"../../webgl/RenderCamera.js";import{HUDRenderStyle as r}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{MultipassGeometryUniforms as h}from"../core/shaderLibrary/shading/MultipassGeometryTest.glsl.js";import{MultipassTerrainUniforms as n}from"../core/shaderLibrary/shading/MultipassTerrainTest.glsl.js";import{Decorations as a}from"./basicInterfaces.js";import{RenderSlot as g}from"./RenderSlot.js";import{TransparencyPassType as o}from"./TransparencyPassType.js";import{Update as l}from"./Update.js";import{SceneLighting as d}from"../lighting/SceneLighting.js";class c{constructor(i,t){this.width=i,this.height=t}}class m{constructor(i,l){this.shadowMap=i,this.slicePlane=l,this.slot=g.OPAQUE_MATERIAL,this.ensuredScreenSize=new c(4,4),this.hasOccludees=!1,this.enableFillLights=!0,this.transparencyPassType=o.NONE,this.alignPixelEnabled=!1,this.decorations=a.ON,this.overlayStretch=1,this.viewshedEnabled=!1,this._camera=new s,this._inverseViewport=t(),this._oldLighting=new d,this._newLighting=new d,this._fadedLighting=new d,this._lighting=this._newLighting,this.ssr=new p,this.multipassEnabled=!1,this.multipassTerrain=new n,this.multipassGeometry=new h,this.highlightTexture=null,this.highlightGroup=null,this.highlightGroupMap=new Map,this.highlightLevel=0,this.hudRenderStyle=r.Occluded,this.cloudsFade=new e,this.shadowHighlightsVisible=!1}get camera(){return this._camera}set camera(i){this._camera=i,this._inverseViewport[0]=1/i.fullViewport[2],this._inverseViewport[1]=1/i.fullViewport[3]}get inverseViewport(){return this._inverseViewport}get lighting(){return this._lighting}get weatherFading(){return this._lighting===this._fadedLighting}fadeLighting(i){const{_oldLighting:t,_newLighting:e}=this;i>=1?this._lighting=e:(this._fadedLighting.lerpLighting(t,e,i),this._lighting=this._fadedLighting)}updateLighting(i,t,e,s){this._oldLighting.copyFrom(this.lighting),this._newLighting.noonFactor=t,this._newLighting.globalFactor=e,this._newLighting.set(i);const r=this.weatherFading?this.cloudsFade.fadeFactor:s===l.Faded?0:1;this.fadeLighting(r)}}class p{constructor(){this.fadeFactor=1,this.reprojectionMatrix=i()}}export{m as BindParameters,c as ViewportSize};
5
+ import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{CloudsParameters as e}from"../../environment/CloudsParameters.js";import s from"../../webgl/RenderCamera.js";import{HUDRenderStyle as r}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{MultipassGeometryUniforms as h}from"../core/shaderLibrary/shading/MultipassGeometryTest.glsl.js";import{MultipassTerrainUniforms as n}from"../core/shaderLibrary/shading/MultipassTerrainTest.glsl.js";import{Decorations as a}from"./basicInterfaces.js";import{RenderSlot as g}from"./RenderSlot.js";import{TransparencyPassType as o}from"./TransparencyPassType.js";import{Update as l}from"./Update.js";import{SceneLighting as d}from"../lighting/SceneLighting.js";class c{constructor(i,t){this.width=i,this.height=t}}class m{constructor(i,l){this.shadowMap=i,this.slicePlane=l,this.slot=g.OPAQUE_MATERIAL,this.hasOccludees=!1,this.enableFillLights=!0,this.transparencyPassType=o.NONE,this.alignPixelEnabled=!1,this.decorations=a.ON,this.overlayStretch=1,this.viewshedEnabled=!1,this._camera=new s,this._inverseViewport=t(),this._oldLighting=new d,this._newLighting=new d,this._fadedLighting=new d,this._lighting=this._newLighting,this.ssr=new p,this.multipassEnabled=!1,this.multipassTerrain=new n,this.multipassGeometry=new h,this.highlightTexture=null,this.highlightGroup=null,this.highlightGroupMap=new Map,this.highlightLevel=0,this.hudRenderStyle=r.Occluded,this.cloudsFade=new e,this.shadowHighlightsVisible=!1}get camera(){return this._camera}set camera(i){this._camera=i,this._inverseViewport[0]=1/i.fullViewport[2],this._inverseViewport[1]=1/i.fullViewport[3]}get inverseViewport(){return this._inverseViewport}get lighting(){return this._lighting}get weatherFading(){return this._lighting===this._fadedLighting}fadeLighting(i){const{_oldLighting:t,_newLighting:e}=this;i>=1?this._lighting=e:(this._fadedLighting.lerpLighting(t,e,i),this._lighting=this._fadedLighting)}updateLighting(i,t,e,s){this._oldLighting.copyFrom(this.lighting),this._newLighting.noonFactor=t,this._newLighting.globalFactor=e,this._newLighting.set(i);const r=this.weatherFading?this.cloudsFade.fadeFactor:s===l.Faded?0:1;this.fadeLighting(r)}}class p{constructor(){this.fadeFactor=1,this.reprojectionMatrix=i()}}export{m as BindParameters,c as ViewportSize};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
+ */
5
+ 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{DepthFormat as i}from"../../webgl/formats.js";import{ViewportSize as s}from"./BindParameters.js";import{ClearBufferBit as o}from"../../../webgl/enums.js";import{ensureAttachmentMaxSize as h}from"../../../webgl/FramebufferObject.js";class _{constructor(t){this._fbos=t,this._size=new s(0,0),this._clearColor=r()}dispose(){this._color=t(this._color),this.release()}initialize(t,r,i){this._size.width=t,this._size.height=r,h(this._size,this._fbos.rctx.parameters.maxTextureSize);const s=this._color;return this._color=null,this.release(),e(this._clearColor,i),s}release(){this._color?.detachDepth(),this._depth=t(this._depth)}renderWithoutDepth(t){this._bindTarget(this.color),t(),this._bindTarget(this.color,this.depth)}update(t){const e=this._ensureColor();e.attachDepth(this.depth),this._color=t(e)}bind(){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.clear(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT|o.STENCIL_BUFFER_BIT)}}_bindTarget(t,e){t.attachDepth(e),this._fbos.rctx.bindFramebuffer(t.fbo)}_acquireColor(){return this._fbos.acquire(this._size.width,this._size.height,"composite-color")}_acquireDepth(){return this._fbos.acquireDepth(i.DEPTH_STENCIL_TEXTURE,this._size.width,this._size.height,"depth")}get size(){return this._size}get color(){return this._ensureColor()}get depth(){return this._depth??=this._acquireDepth(),this._depth}_ensureColor(){return this._color??=this._acquireColor(),this._color}}export{_ as MainFramebuffer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{Milliseconds as r}from"../../../../core/time.js";import e from"../../webgl/RenderCamera.js";import{ShaderOutput as t}from"../core/shaderLibrary/ShaderOutput.js";import{BindParameters as s}from"./BindParameters.js";import{RenderOccludedFlag as a}from"./Material.js";class i{constructor(r,a,i=null){this.rctx=r,this.sliceHelper=i,this.lastFrameCamera=new e,this.output=t.Color,this.renderOccludedMask=n,this.bindParameters=new s(a,null!=i?i.plane:null),this.bindParameters.alignPixelEnabled=!0}}class l extends i{constructor(e,t,s,a){super(e,s,a),this.mainColor=t,this.sliceHelper=a,this.time=r(0)}}const n=a.Occlude|a.OccludeAndTransparent|a.OccludeAndTransparentStencil;export{i as OverlayRenderContext,l as RenderContext,n as defaultRenderOccludedMask};
5
+ import{Milliseconds as e}from"../../../../core/time.js";import r from"../../webgl/RenderCamera.js";import{ShaderOutput as t}from"../core/shaderLibrary/ShaderOutput.js";import{BindParameters as s}from"./BindParameters.js";import{RenderOccludedFlag as a}from"./Material.js";class i{constructor(e,a,i=null){this.rctx=e,this.sliceHelper=i,this.lastFrameCamera=new r,this.output=t.Color,this.renderOccludedMask=n,this.bindParameters=new s(a,null!=i?i.plane:null),this.bindParameters.alignPixelEnabled=!0}}class l extends i{constructor(r,t,s,a){super(r,t,s),this.sliceHelper=s,this.framebuffer=a,this.time=e(0)}}const n=a.Occlude|a.OccludeAndTransparent|a.OccludeAndTransparentStencil;export{i as OverlayRenderContext,l as RenderContext,n as defaultRenderOccludedMask};