@arcgis/core 4.24.0-next.20220331 → 4.24.0-next.20220401

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 (124) hide show
  1. package/WebScene.js +1 -1
  2. package/analysis/LineOfSightAnalysisObserver.js +1 -1
  3. package/analysis/LineOfSightAnalysisTarget.js +1 -1
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/0eb9c9477d36cd212f8b.js +1 -0
  6. package/assets/esri/core/workers/chunks/10779a256841c37f2429.js +1 -0
  7. package/assets/esri/core/workers/chunks/125b14c2ccd96d7c20c2.js +1 -0
  8. package/assets/esri/core/workers/chunks/{19cb7315d403a4cd4f59.js → 2530e8ccf6e12787ce76.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{302c68c5b91d1ab4fd47.js → 560234694f3e53802aff.js} +1 -1
  10. package/assets/esri/core/workers/chunks/5633710daeb3bbb79bcf.js +1 -0
  11. package/assets/esri/core/workers/chunks/6f7917da7166e8c6854b.js +1 -0
  12. package/assets/esri/core/workers/chunks/7388824eac8da01ea03d.js +1 -0
  13. package/assets/esri/core/workers/chunks/794b47764ebb0257ed41.js +1 -0
  14. package/assets/esri/core/workers/chunks/81e9d860a044acec74ce.js +1 -0
  15. package/assets/esri/core/workers/chunks/{9a32f129f0d67547e44c.js → 831dc0187f71e658550c.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{d162d1b7b97a58e97d8c.js → 8958cd555f4887526e8b.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{e57b71ba70f088a3a052.js → 90dcd86cdef90099abfa.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{a5b54e134ae59629d6d1.js → 93067e27eea5844edc6c.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{0b63c9d5d9c004923a97.js → b26bd8fde2fc65bb67fb.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{b81e1df3a47b61421295.js → b34ba22c7a5adce8a7a2.js} +1 -1
  21. package/assets/esri/core/workers/chunks/c28f7ae4756ad1ba94bd.js +1 -0
  22. package/assets/esri/core/workers/chunks/{e1408ff1b8343674e6ef.js → c59b0b58e24e6a60cf3e.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{f4e79769297ad9c1d508.js → c7cee13a962396b23a5e.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{cb38754110b7a0e901f6.js → cd3679fa86129ebabfdf.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{224c0e64160bdc170051.js → d076627bb7dadea89e89.js} +1 -1
  26. package/assets/esri/core/workers/chunks/e06ad3a3d71154fed654.js +1 -0
  27. package/assets/esri/core/workers/chunks/{7a77d4cd27c30f1a5cae.js → ee3387a43dfbb3df23e1.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{fbb7a121a45f8ca7d89c.js → f4fc165420d449e442b8.js} +1 -1
  29. package/assets/esri/themes/base/widgets/_Widget.scss +2 -2
  30. package/assets/esri/themes/dark/main.css +1 -1
  31. package/assets/esri/themes/dark-blue/main.css +1 -1
  32. package/assets/esri/themes/dark-green/main.css +1 -1
  33. package/assets/esri/themes/dark-purple/main.css +1 -1
  34. package/assets/esri/themes/dark-red/main.css +1 -1
  35. package/assets/esri/themes/light/main.css +1 -1
  36. package/assets/esri/themes/light/view.css +1 -1
  37. package/assets/esri/themes/light-blue/main.css +1 -1
  38. package/assets/esri/themes/light-green/main.css +1 -1
  39. package/assets/esri/themes/light-purple/main.css +1 -1
  40. package/assets/esri/themes/light-red/main.css +1 -1
  41. package/core/AsyncUpdate.js +1 -1
  42. package/exports/csv.js +1 -1
  43. package/geometry/support/meshUtils/exporters/gltf/geometry.js +1 -1
  44. package/geometry/support/normalizeUtils.js +1 -1
  45. package/interfaces.d.ts +120 -0
  46. package/layers/MapImageLayer.js +1 -1
  47. package/layers/RouteLayer.js +1 -1
  48. package/layers/VectorTileLayer.js +1 -1
  49. package/layers/graphics/editingSupport.js +1 -1
  50. package/layers/mixins/ArcGISImageService.js +1 -1
  51. package/layers/support/RasterJobHandler.js +1 -1
  52. package/layers/support/SpriteSource.js +1 -1
  53. package/layers/support/Sublayer.js +1 -1
  54. package/layers/support/TilemapCache.js +1 -1
  55. package/layers/support/vectorTileLayerLoader.js +1 -1
  56. package/libs/i3s/I3SModule.js +1 -1
  57. package/libs/vxl/VxlModule.js +1 -1
  58. package/package.json +1 -1
  59. package/portal/support/layersLoader.js +1 -1
  60. package/portal/support/portalLayers.js +1 -1
  61. package/renderers/support/DictionaryLoader.js +1 -1
  62. package/rest/query/operations/query.js +1 -1
  63. package/rest/query/operations/queryTopFeatures.js +1 -1
  64. package/rest/support/DirectionLine.js +1 -1
  65. package/rest/support/DirectionPoint.js +1 -1
  66. package/rest/support/PointBarrier.js +1 -1
  67. package/rest/support/PolygonBarrier.js +1 -1
  68. package/rest/support/PolylineBarrier.js +1 -1
  69. package/rest/support/RouteInfo.js +1 -1
  70. package/rest/support/Stop.js +1 -1
  71. package/smartMapping/labels/clusters.js +1 -1
  72. package/smartMapping/renderers/color.js +1 -1
  73. package/smartMapping/support/adapters/SceneLayerAdapter.js +1 -1
  74. package/support/elevationInfoUtils.js +1 -1
  75. package/support/revision.js +1 -1
  76. package/symbols/support/previewSymbol3D.js +1 -1
  77. package/symbols/support/symbolLayerUtils.js +1 -1
  78. package/views/2d/engine/vectorTiles/TileParser.js +1 -1
  79. package/views/2d/engine/webgl/util/Lock.js +1 -1
  80. package/views/2d/layers/RouteLayerView2D.js +1 -1
  81. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  82. package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
  83. package/views/2d/layers/support/webStyleUtils.js +1 -1
  84. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  85. package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
  86. package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
  87. package/views/3d/interactive/analysisTools/lineOfSight/LineOfSightTool.js +1 -1
  88. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  89. package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
  90. package/views/3d/layers/ImageryLayerView3D.js +1 -1
  91. package/views/3d/layers/RouteLayerView3D.js +1 -1
  92. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  93. package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
  94. package/views/3d/layers/support/PopupSceneLayerView.js +1 -1
  95. package/views/3d/support/debugFlags.js +1 -1
  96. package/views/3d/terrain/TerrainSurface.js +1 -1
  97. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  98. package/views/SceneView.js +1 -1
  99. package/views/layers/ImageryTileLayerView.js +1 -1
  100. package/views/layers/MapImageLayerView.js +1 -1
  101. package/views/layers/TileLayerView.js +1 -1
  102. package/views/support/DefaultsFromMap.js +1 -1
  103. package/widgets/Bookmarks/BookmarksViewModel.js +1 -1
  104. package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
  105. package/widgets/Directions/DirectionsViewModel.js +1 -1
  106. package/widgets/Directions.js +1 -1
  107. package/widgets/Editor.js +1 -1
  108. package/widgets/Feature/support/featureUtils.js +1 -1
  109. package/widgets/FeatureForm/InputField.js +1 -1
  110. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  111. package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
  112. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  113. package/widgets/Popup/actionUtils.js +1 -1
  114. package/widgets/Search/SearchViewModel.js +1 -1
  115. package/assets/esri/core/workers/chunks/113362697da1b69deaed.js +0 -1
  116. package/assets/esri/core/workers/chunks/1e590d63187ada4f5ff7.js +0 -1
  117. package/assets/esri/core/workers/chunks/391a330182c616cfffaf.js +0 -1
  118. package/assets/esri/core/workers/chunks/3a85312fd7d0cda9ce93.js +0 -1
  119. package/assets/esri/core/workers/chunks/3c00e38d3b16f4a53a4f.js +0 -1
  120. package/assets/esri/core/workers/chunks/4a82a6a473b3d540d0be.js +0 -1
  121. package/assets/esri/core/workers/chunks/5b4d9786c010d265346c.js +0 -1
  122. package/assets/esri/core/workers/chunks/bbfc98e33d4630eb9e5c.js +0 -1
  123. package/assets/esri/core/workers/chunks/bd725783b85f308e2c89.js +0 -1
  124. package/assets/esri/core/workers/chunks/d343f05a3366f95e0494.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/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 n from"../../../core/Handles.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{releaseMaybe as h,destroyMaybe as d,isNone as u,isSome as p}from"../../../core/maybe.js";import c from"../../../core/ObjectPool.js";import _ from"../../../core/PooledArray.js";import{isAbortError as m,isAborted as g,createAbortError as y}from"../../../core/promiseUtils.js";import{watch as f,syncAndInitial as T,initial as v,sync as w}from"../../../core/reactiveUtils.js";import{aliasOf as S}from"../../../core/accessorSupport/decorators/aliasOf.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{property as L}from"../../../core/accessorSupport/decorators/property.js";import{subclass as E}from"../../../core/accessorSupport/decorators/subclass.js";import{m as x}from"../../../chunks/mat4.js";import{c as D}from"../../../chunks/mat4f64.js";import{c as P}from"../../../chunks/vec3.js";import{c as C}from"../../../chunks/vec3f64.js";import{c as R}from"../../../chunks/vec4f64.js";import{WatchUpdatingTracking as j}from"../../../core/support/WatchUpdatingTracking.js";import{projectVectorToVector as U,projectPointToVector as M}from"../../../geometry/projection.js";import{getReferenceEllipsoid as b}from"../../../geometry/projectionEllipsoid.js";import{create as I,equals as A,intersection as V,containsPoint as O,empty as k,expand as q,intersectsSphere as B}from"../../../geometry/support/aaBoundingRect.js";import{create as N,copy as F}from"../../../geometry/support/frustum.js";import{isRefreshableLayer as G}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as H}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as W}from"../../../layers/support/layerUtils.js";import{acquireDecoder as Q}from"../../../layers/support/LercDecoder.js";import{printAllocations as X}from"../../2d/engine/vectorTiles/VectorTile.js";import z from"../layers/ElevationLayerView3D.js";import{directionToHeadingTilt as Y,scaleToZoom as $}from"../support/cameraUtils.js";import K from"../support/debugFlags.js";import{toBoundingRect as J}from"../support/extentUtils.js";import{ClientType as Z}from"../support/index.js";import{updatingProgress as ee}from"../support/updatingProperties.js";import{ElevationBounds as te}from"./ElevationBounds.js";import{sampleElevation as ie,ElevationData as re}from"./ElevationData.js";import{create as se}from"./ExtentHelper.js";import{LODSnapping as ae,TextureUpdate as ne}from"./interfaces.js";import{LayerClass as le,LayerClasses as oe}from"./LayerClass.js";import{OverlayManager as he}from"./OverlayManager.js";import{PlanarPatch as de}from"./PlanarPatch.js";import{RenderOrder as ue}from"./RenderOrder.js";import{SphericalPatch as pe}from"./SphericalPatch.js";import{DEFAULT_TILE_BACKGROUND as ce,MAX_ROOT_TILES as _e,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as me,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as ge,MAX_MEMORY_LOD_BIAS as ye,ELEVATION_NODATA_VALUE as fe}from"./TerrainConst.js";import Te from"./TerrainRenderer.js";import ve from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as we,computeSkirtScale as Se,isSurfaceLayerView as Le,isElevationLayerView as Ee,isVectorTileLayerView as xe,useFetchTileForLayer as De,isImageryTileLayerView as Pe,isTileLayerView as Ce,releaseTileData as Re}from"./terrainUtils.js";import{SplitLimits as je,Tile as Ue}from"./Tile.js";import{printAllocations as Me}from"./TilePerLayerInfo.js";import{TileUpdate as be}from"./TileUpdate.js";import{IteratorPreorder as Ie,IteratorPostorder as Ae,hasLoadableSiblings as Ve,sortTilesByPOI as Oe,sortTiles as ke}from"./tileUtils.js";import{TilingSchemeLogic as qe}from"./TilingSchemeLogic.js";import{UpsampleInfo as Be}from"./UpsampleInfo.js";import{RenderRequestType as Ne}from"../webgl-engine/lib/basicInterfaces.js";import{ImmediateTask as Fe,TaskPriority as Ge,noBudget as He}from"../../support/Scheduler.js";const We=l.getLogger("esri.views.3d.terrain.TerrainSurface"),Qe=.25;let Xe=class extends(a.EventedMixin(i)){constructor(e){super(e),this._elevationBounds=new te,this._iteratorPool=new c(Ie,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new Ae,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._visible=!1,this._usedMemory=Je,this._performanceInfo=new ve,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=C(),this._eyePosSurfaceSR=C(),this._splitLimits=new je,this._snapLevel=1/0,this._frustum=N(),this._viewProjectionMatrix=D(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._handles=new n,this._watchUpdatingTracking=new j,this._frameTask=Fe,this._allTiles=new _,this._upsampleInfoPool=new c(Be),this._rootTilesExtent=I(),this._maxNumUpdating=1,this.maxTextureScale=1.2,this.backgroundImage=ce,this.backgroundColor=null,this._layerViewsDirty=!1}initialize(){this._lercDecoder=Q(this.view.resourceController),this._tilePool=this.view.state.isLocal?new c(de):new c(pe);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("esri.views.3d.terrain.upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new H(e.newCache("elevation-query")),this._set("overlayManager",new he({surface:this})),this._handles.add([this.watch("overlayManager.hasHighlights",(e=>this._renderer.setNeedsHighlight(e))),this.watch("overlayManager.rendersOccluded",(e=>this._renderer.setRenderOccludedOverlay(e)))],"overlayManager"),this._renderer=new Te({overlayRenderer:this.overlayManager.renderer,ellipsoidRadius:b(this.view.spatialReference).radius,stage:this.view._stage,allTiles:this._allTiles}),this._handles.add([f((()=>this.baseOpacity),(e=>{this._handleLayerViewChanges(),this._updateBaseOpacity(e)}),T),f((()=>this._background),(()=>{this._handleLayerViewChanges(),this._renderer.setTileBackground(this._background)}),T),f((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>()=>this._allTilesSorted=!1))})),f((()=>K.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&K.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=d(this._treeDebugger))}),v)]),this._extentHelper=se(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:this.view.spatialReference});const t=this.view.defaultsFromMap?new s({getCollections:()=>{var e,t,i;return null==(e=this.view)||null==(t=e.defaultsFromMap)||null==(i=t.mapCollections)?void 0:i.map((({layers:e})=>e))},getChildrenFunction:e=>e&&"layers"in e?e.layers:null}):this.view.map.allLayers,i=new qe({layers:t,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:this.view.spatialReference});this._set("tilingSchemeLogic",i),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester(Z.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester(Z.BASEMAP);const r=this.view.resourceController.scheduler;this._frameTask=r.registerTask(Ge.TERRAIN_SURFACE,this),this._handles.add([f((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),v),f((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),w),f((()=>this.extent),(()=>this._updateRootTiles()),v),this.view.on("resize",(()=>this._viewChangeUpdate())),f((()=>{var e,t;const i=this.view,r=i.state;return[this.lodBias,this.lodSnapping,null==(e=i.resourceController)||null==(t=e.memoryController)?void 0:t.memoryFactor,r.camera,r.contentCamera,r.fixedContentCamera]}),(()=>this._viewChangeUpdate()),T),f((()=>{var e,t;return null==(e=this.view.qualitySettings)||null==(t=e.tiledSurface)?void 0:t.textureFadeDuration}),(e=>this._renderer.textureFadingEnabled=e>0),v),f((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),w)]),this._handles.add(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._handles.destroy(),this._watchUpdatingTracking.destroy(),this._lercDecoder=h(this._lercDecoder),this._removeAllTiles(),this._upsampleMapCache=d(this._upsampleMapCache),this._elevationQueryCache=d(this._elevationQueryCache),this._set("tilingSchemeLogic",d(this.tilingSchemeLogic)),this._extentHelper=d(this._extentHelper),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",d(this.overlayManager)),this._tilePool=d(this._tilePool),Ue.prune(),this._treeDebugger&&(this._treeDebugger.destroy(),this._treeDebugger=null),this._renderer=d(this._renderer),this._iteratorPool=d(this._iteratorPool),this._set("view",null),this._upsampleInfoPool=d(this._upsampleInfoPool),X(),Me()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){var e,t;const i=null==(e=this.view.pointsOfInterest)||null==(t=e.contentCameraOnSurface)?void 0:t.scale;if(i){const e=this.view.state.contentCamera;let t=Y(this.view,e.eye,e.viewForward,e.up).tilt;t>90&&(t=180-t);const r=2*(t/90)**2,s=$(this.view,i)-r;Math.abs(this._snapLevel-s)>Qe&&(Math.round(s)!==Math.round(this._snapLevel)&&(this._viewChanged=!0),this._snapLevel=s)}return Math.round(this._snapLevel)}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?ae.ON:ae.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(u(t)||u(e))return null;const i=I(),r=J(t,i,e)?i:null,s=this._get("extent");return A(r,s)?s:r}get extent(){const e=V(this.groundExtent,this._userClippingExtent,I()),t=this._get("extent");return A(e,t)?t:e}get groundExtent(){return p(this._tilingSchemeExtent)?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){var e;return null==(e=this.tilingSchemeLogic)?void 0:e.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this._watchUpdatingTracking.updating||this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||this._asyncWorkItems>0||!this._allTilesSorted||this._renderer.updating||this._layerViewsDirty)&&this.ready&&!this.suspended||this.overlayManager.updating||this._frameTask.updating)}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get viewingMode(){return this.view.state.viewingMode}get ready(){return p(this.rootTiles)}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}set skirtScale(e){this._renderer.skirtScale=e}get skirtScale(){return this._renderer.skirtScale}get spatialReference(){var e,t;return null!=(e=null==(t=this.tilingScheme)?void 0:t.spatialReference)?e:null}get _background(){return null!=this.backgroundColor?this.backgroundColor:this.backgroundImage}set slicePlaneEnabled(e){var t,i;this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),null==(t=this.view)||null==(i=t._stage)||i.renderView.setRenderParameters({opaqueTerrain:this.opaque})}set velvetOverground(e){e!==this.velvetOverground&&(this._renderer.velvetOverground=e),this._set("velvetOverground",e)}set visible(e){e!==this._visible&&(this._visible=e,this._renderer.setVisibility(e),this.suspended=!e)}get opaque(){return this._renderer.opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this.getTileWithElevation(e,t,i,r,Ze);return u(s)?null:ie(Ze[0],Ze[1],s.renderData.geometryState.samplerData)}getTileWithElevation(e,t,i,r,s=Ze){var a;const n=this.rootTiles;if(u(n)||!n.length)return null;if(0===n[0].layerInfo[le.ELEVATION].length)return null;if(s[0]=e,s[1]=t,s[2]=i,!U(s,r,s,null==(a=this.tilingScheme)?void 0:a.spatialReference))return We.error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;for(let l of n){if(!l.containsPoint(s))continue;for(;l&&!l.rendered&&!l.isLeaf;){let e=0;s[0]>.5*(l.extent[0]+l.extent[2])&&(e+=1),s[1]<.5*(l.extent[1]+l.extent[3])&&(e+=2),l=l.children[e]}const e=l.renderData;return(e?e.geometryState.samplerData:null)?l:null}return null}get elevationBounds(){return this._elevationBounds}getScale(e){if(this.tilingScheme){if(!M(e,Ze,this.spatialReference))return We.error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this.rootTiles;if(p(t))for(let e of t)if(e.containsPoint(Ze)){for(;null!=e.children[0];){let t=0;Ze[0]>e.children[0].extent[2]&&(t+=1),Ze[1]<e.children[0].extent[1]&&(t+=2),e=e.children[t]}return this._getLodBiasCorrectedScale(e.level)}}return 1e100}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!M(e,Ze,this.spatialReference))return We.error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;Ze[3]=t;let i=null;const r=e=>{if(e&&B(e.extent,Ze))if(null!=e.children[0])for(const t of e.children)r(t);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}},s=this.rootTiles;if(p(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._renderer.queryVisibleLevelRange(e,s+n,a+n,r)}_updateBaseOpacity(e){const t=this._renderer.opaque;this._renderer.opaque=e>=1,this._renderer.isTransparent=this._allTransparentSurfaceLayers();const i=t===this._renderer.opaque?ne.UNFADED:ne.IMMEDIATE;var r,s;i===ne.IMMEDIATE&&(null==(r=this.view)||null==(s=r._stage)||s.renderView.setRenderParameters({opaqueTerrain:this.opaque}));this._updateTileTextures(i)}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;e!==this.tilingScheme&&(we(!!e,"tiling scheme cannot be reset to undefined"),this.tilingScheme&&this._removeAllTiles(),this._set("tilingScheme",e),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._tilePool.acquire();return tt[0]=e,tt[1]=t,tt[2]=i,s.init(tt,r,this),s}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=et;let s=t.rootTilesInExtent(e,i,5*_e);if(p(this.rootTiles)){if(s.length>_e)return void We.warn(me);const e=this.rootTiles.map((e=>e.lij)),t=r(e,s,Ye);if(t.removed.length>0||t.added.length>0){const e=this.rootTiles.filter((e=>!(t.removed.findIndex((t=>Ye(t,e.lij)))>-1)||(this._purgeTile(e),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else s.length>_e&&(We.warn(ge),s=t.rootTilesInExtent(e,i,_e)),this._setRootTiles(s.map((e=>this._newRootTile(e))));A(i,this._rootTilesExtent)||(this._rootTilesExtent=I(i)),this.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready")}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return t.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===be.SPLIT&&t.setPendingUpdate(be.SPLIT),this._loadTile(t),t}_setRootTiles(e){if(this._set("rootTiles",e),this._allTiles.clear(),p(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._visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateSkirts(),this._updateTilesVisibility(this.rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(be.GEOMETRY)&&this._updateTileGeometry(e)}_updateTilesVisibility(e){if(u(e))return;const t=Ve(e);let i=t?this._elevationBounds.min:1/0,r=t?this._elevationBounds.max:-1/0;const s=this.view.state.fixedContentCamera,a=this.extent,n=this._viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(be.GEOMETRY)&&this._updateTileGeometry(e),e.setPendingUpdate(be.RENDERDATA);const t=e.computeVisibility();s||t?(e.updateScreenDepth(n),e.renderData&&(i=Math.min(e.elevationBounds[0],i),r=Math.max(e.elevationBounds[1],r))):l.skipSubtree()}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,isFinite(i)&&isFinite(r)&&(this._elevationBounds.min===i&&this._elevationBounds.max===r||(this._elevationBounds.min=i,this._elevationBounds.max=r,this.emit("elevation-bounds-change",null)))}_updateViewDependentParameters(){const e=this.view.state.camera,t=this.view.state.contentCamera,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?(u(this._splitLimits.frustum)&&(this._splitLimits.frustum=N()),F(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,F(this._frustum,e.frustum),x(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),P(this._eyePosRenderSR,t.eye),U(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateSkirts(){const e=this.view.state.camera,t=this.view.state.constraints.collision.enabled?0:1.11*e.near;this.skirtScale=Se(this,this._eyePosSurfaceSR,t)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&($e(e)?this._loadChildren(e):Ke(e)&&this._loadParent(e))}_updateTileGeometry(e){e.updateVisibility(),this._renderer.updateTileGeometry(e),this._elevationUpdate(e),this._usedMemory=Je}_updateTileTexture(e,t){const i=e.resetPendingUpdate(be.TEXTURE_FADING)?be.TEXTURE_FADING:!!e.resetPendingUpdate(be.TEXTURE_NOFADING)&&be.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=Je,t.madeProgress())}_elevationUpdate(e){rt.spatialReference=this.spatialReference,rt.tile=e,rt.extent=e.extent,this.emit("elevation-change",rt),O(e.extent,this._eyePosSurfaceSR)&&this._updateSkirts()}get running(){return this.updating&&this.ready&&!this.suspended}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateTileStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),e.run((()=>this._updateElevation(e))),e.run((()=>this._updateTextures(e))),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),e.done&&this.requestUpdate(),this.notifyChange("updatingProgressValue")}_updateTileStatus(e){if(!this._viewChanged||!this.rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();for(t.reset(this.rootTiles);!t.done;){const e=t.next();if(e.loadable){const i=e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping);if(i===be.SPLIT){e.resetPendingUpdate(be.MERGE),e.isLeaf&&(e.setPendingUpdate(be.SPLIT),t.skipSubtree());continue}e.resetPendingUpdate(be.SPLIT)&&e.updateAgentSuspension(),i===be.VSPLITMERGE&&e.updateAgents(le.ELEVATION)}if(t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(be.MERGE),e.resetPendingUpdate(be.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.loadable&&e.updateScreenDepth(this._viewProjectionMatrix);t.remove()}}t.remove(),this.requestUpdate(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Oe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=0;for(;!e.done;){let r=!1;i=0;const s=!this._allTiles.some((s=>{if(i+=s.usedMemory,s.resetPendingUpdate(be.MERGE)){if(!t)return s.setPendingUpdate(be.MERGE),e.done;this._mergeTile(s),r=!0,e.madeProgress()}else s.resetPendingUpdate(be.SPLIT)&&(this._splitTile(s),r=!0,e.madeProgress());return!e.done&&s.resetPendingUpdate(be.RENDERDATA)&&(this._updateRenderData(s),e.madeProgress()),e.done}));if(r&&(this._allTilesSorted=!1,this._allTilesDirty=!0),s){if(this._usedMemory=i,!r)break;this._updateTilesVisibility(this.rootTiles)}else this._allTilesDirty=!0}0===i&&(this._allTilesDirty=!0),this._sortTiles(e)}_updateElevation(e){return this._allTiles.some((t=>(t.resetPendingUpdate(be.GEOMETRY)&&(this._updateTileGeometry(t),this._updateTileTexture(t,e),e.madeProgress()),e.done))),e.hasProgressed}_updateTextures(e){return this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done))),e.hasProgressed}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(Ne.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get lodBias(){const e=this.view.resourceController.memoryController.memoryFactor;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*ye}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=o(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(){p(this.rootTiles)&&(this.rootTiles.forEach((e=>this._purgeTile(e))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.visible=!1}_purgeChildTiles(e){if(e.isLeaf)return!1;let t=this._purgeTile(e.children[0]);return t=this._purgeTile(e.children[1])||t,t=this._purgeTile(e.children[2])||t,t=this._purgeTile(e.children[3])||t,e.unsetChildren(),t}_purgeTile(e){const t=this._purgeChildTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),e.unload(this._renderer),this._tilePool.release(e),t}_splitTile(e){we(e.isLeaf,"tile that is already split should not be split again!");const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2];e.setChildren(this._createTile(t,i,r,e),this._createTile(t,i,r+1,e),this._createTile(t,i+1,r,e),this._createTile(t,i+1,r+1,e)),e.setPendingUpdate(be.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,this._emitTileScaleChange(e,t),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){st.spatialReference=this.spatialReference,st.extent=e.extent,st.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",st)}_createTile(e,t,i,r){we(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.loadable&&(s.updateScreenDepth(this._viewProjectionMatrix),s.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===be.SPLIT&&s.setPendingUpdate(be.SPLIT)),s}_mergeTile(e){we(!e.hasPendingUpdate(be.SPLIT),"_mergeTile sanity check"),this._purgeChildTiles(e)&&(we(!e.renderData,"_mergeTile sanity check"),this._loadTile(e)),this._allTilesDirty=!0,++this._performanceInfo.numMerged,this._emitTileScaleChange(e)}_loadChildren(e){we(e.rendered,"parent should be rendered"),e.unload(this._renderer),this._loadTile(e.children[0]),this._loadTile(e.children[1]),this._loadTile(e.children[2]),this._loadTile(e.children[3])}_loadParent(e){const t=e.parent;this._unloadChildren(t),this._loadTile(t)}_unloadChildren(e){e.isLeaf||(this._unloadChildren(e.children[0]),e.children[0].unload(this._renderer),this._unloadChildren(e.children[1]),e.children[1].unload(this._renderer),this._unloadChildren(e.children[2]),e.children[2].unload(this._renderer),this._unloadChildren(e.children[3]),e.children[3].unload(this._renderer))}_loadTile(e){e.load(this._renderer),e.setPendingUpdate(be.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e),this._elevationUpdate(e)}_elevationDataArrived(e,t,i){const r=new re(e.lij,e.extent,i);e.dataArrived(t,le.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=He){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(const s of this.view.allLayerViews.items)if(i.add(s.uid),Le(s))if(this._basemapLayerViewHandles.has(s.uid)){const e=this._layerClassFromLayerView(s),i=this._layerIndexByUid[e].get(s.uid);i<r&&(t=!0),r=i}else this._registerTiledLayerView(s),s.layer.loaded&&(t=!0);this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this._renderer.isTransparent=this._allTransparentSurfaceLayers(),e.madeProgress()}_allTransparentSurfaceLayers(){var e,t;let i=0===(null==(e=this.view.map)||null==(t=e.ground)?void 0:t.opacity);for(const r of this.view.allLayerViews.items)if(Le(r)&&!Ee(r)&&!W(r.layer)&&0!==r.fullOpacity)return i=!1,i;return i}_layerClassFromLayerView(e){return Ee(e)?le.ELEVATION:le.MAP}_registerTiledLayerView(e){const t=[],i=this._layerClassFromLayerView(e);t.push(e.watch("suspended",(()=>this._updateTiledLayers()))),t.push(e.watch("fullOpacity",(()=>this._updateTileTextures(ne.UNFADED)))),t.push(e.layer.watch("effectiveScaleRange",(()=>this._restartAllAgents(i)))),e.on("data-changed",(()=>{const t=this._layerIndexByUid[i].get(e.uid);null!=t&&this._invalidateLayerData(t,i)})),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(let e=0;e<t.length;e++)t[e].remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;const r=k();e.forEach((e=>{const s=e.layer;if(!s||e.suspended||!Le(e))return;const a=e.fullExtent;if(!a)return void We.warn("Terrain: Map or elevation layer does not have fullExtent: "+s.id);q(r,a,r);const n=this._layerClassFromLayerView(e);if(n===le.MAP){const t=e.displayLevelRange;t.maxLevel!==1/0&&(null===i||t.maxLevel>i)&&(i=t.maxLevel)}t[n].push(e)}));for(const s of oe){const e=this._layerViews[s],i=t[s];i.reverse();const r=i.length;let a=e.length!==r;const n=new Array(r),l=new Array(e.length);this._layerIndexByUid[s].clear();for(let t=0;t<r;t++){const r=i[t].uid;this._layerIndexByUid[s].set(r,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,s);this._layerViews[s]=i,this._restartAllAgents(s),this._updateTilesVisibility(this.rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&this._viewChangeUpdate()}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this.rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===le.ELEVATION&&i.computeElevationBounds()}}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(le.MAP),e===ne.IMMEDIATE?this.renderer.updateTileTexture(t,be.TEXTURE_NOFADING):t.updateRenderData(le.MAP,e)})),this._renderer.isTransparent=this._allTransparentSurfaceLayers()}_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=Ne.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||xe(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,m(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===le.ELEVATION?this._requestElevationTileData(e,i,r):this._requestMapTileData(e,i,r)}_requestElevationTileData(e,t,i){if(!Ee(t))return void we(!1,"_requestElevationTileData can only be called for elevation layer views");const r=r=>{if(--this._asyncWorkItems,g(i))return;const s=this._layerIndexByUid[le.ELEVATION].get(t.uid);null!=s?(this._usedMemory=Je,this.requestUpdate(),this._elevationDataArrived(e,s,r)):We.warn("TerrainSurface: received data from unknown layer %d %s",le.ELEVATION,e.lij.toString())},s=i=>{--this._asyncWorkItems,m(i)||(this._dataMissing(e,le.ELEVATION,t,i),this.requestUpdate())};if(++this._asyncWorkItems,De(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:fe,signal:i.signal}).then((e=>{if(g(i))return We.warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void s(y());this._frameTask.schedule((()=>r(e)),i.signal,s)}),s);const a=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);return this._elevationDataRequester.request(a,"binary",i).then((e=>this._lercDecoder.decode(e,{noDataValue:fe},i.signal))).then((e=>{r({values:e.pixelData,width:e.width,height:e.height,noDataValue:e.noDataValue,minValue:e.minValue,maxValue:e.maxValue})}),s)}_requestMapTileData(e,t,i){if(t instanceof z)return Promise.reject();++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,Re(s),g(i)||(this._dataMissing(e,le.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),g(i)?Re(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(xe(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,n)}if(Pe(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,n);if(Ce(t)&&De(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(g(i))return We.warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void n(y());a(e)}),n);let l=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);G(t.layer)&&t.layer.refreshTimestamp&&(l+=`${l.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const o=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(l,o,i).then(a,n)}_mapTileDataArrived(e,t,i){const r=this._layerIndexByUid[le.MAP].get(t.uid);null!=r?e.dataArrived(r,le.MAP,i):(Re(i),We.warn("TerrainSurface: received data from unknown layer"))}_dataMissing(e,t,i,r){const s=this._layerIndexByUid[t].get(i.uid);null!=s?e.dataMissing(s,t,r):We.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.isLeaf&&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}getUsedMemory(){return this.tilingScheme?(this._usedMemory===Je&&(this._usedMemory=0,this._allTiles.forAll((e=>this._usedMemory+=e.usedMemory))),this._usedMemory):0}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._layerIndexByUid[i].get(e.uid);return this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(u(e)||u(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=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(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 we(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}get test(){const e=this;return{renderer:e._renderer,lercDecoder:e._lercDecoder,forceReload:()=>{p(e.rootTiles)&&(e._mergeTile(e.rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){it.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&it.push(e)}));const t=it.toArray();return ke(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}get isGlobal(){var e,t;return!(null!=(e=this.view)&&null!=(t=e.state)&&t.isLocal)}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&0===e[2]}lijEastEnd(e){return 2**(e+(this.spatialReference.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]}};e([L()],Xe.prototype,"_renderer",void 0),e([L()],Xe.prototype,"_hasPendingUpdates",void 0),e([L()],Xe.prototype,"_asyncWorkItems",void 0),e([L()],Xe.prototype,"_allTilesDirty",void 0),e([L()],Xe.prototype,"_allTilesSorted",void 0),e([L()],Xe.prototype,"_viewChanged",void 0),e([L({readOnly:!0})],Xe.prototype,"_watchUpdatingTracking",void 0),e([L()],Xe.prototype,"_frameTask",void 0),e([L({readOnly:!0})],Xe.prototype,"snapLevel",null),e([L({readOnly:!0})],Xe.prototype,"lodSnapping",null),e([L({constructOnly:!0})],Xe.prototype,"view",void 0),e([L()],Xe.prototype,"_userClippingExtent",null),e([L()],Xe.prototype,"_rootTilesExtent",void 0),e([L({readOnly:!0})],Xe.prototype,"extent",null),e([L({readOnly:!0})],Xe.prototype,"groundExtent",null),e([L({readOnly:!0})],Xe.prototype,"_tilingSchemeExtent",null),e([L({readOnly:!0})],Xe.prototype,"updating",null),e([L(ee)],Xe.prototype,"updatingProgress",void 0),e([L({readOnly:!0})],Xe.prototype,"updatingProgressValue",null),e([L()],Xe.prototype,"_maxNumUpdating",void 0),e([L({aliasOf:"view.map.ground.opacity"})],Xe.prototype,"baseOpacity",void 0),e([L({readOnly:!0})],Xe.prototype,"overlayManager",void 0),e([L({readOnly:!0})],Xe.prototype,"viewingMode",null),e([L()],Xe.prototype,"maxTextureScale",void 0),e([L({readOnly:!0})],Xe.prototype,"ready",null),e([L({value:ue.FRONT_TO_BACK})],Xe.prototype,"renderOrder",null),e([L({readOnly:!0})],Xe.prototype,"rootTiles",void 0),e([L({readOnly:!0})],Xe.prototype,"spatialReference",null),e([L()],Xe.prototype,"backgroundImage",void 0),e([L({type:t,aliasOf:"view.map.ground.surfaceColor"})],Xe.prototype,"backgroundColor",void 0),e([L()],Xe.prototype,"_background",null),e([L({value:!1})],Xe.prototype,"slicePlaneEnabled",null),e([L({readOnly:!0})],Xe.prototype,"tilingScheme",void 0),e([L({readOnly:!0,aliasOf:"tilingSchemeLogic.tilingSchemeLocked"})],Xe.prototype,"tilingSchemeLocked",void 0),e([L({readOnly:!0})],Xe.prototype,"tilingSchemeLogic",void 0),e([L({value:!0})],Xe.prototype,"velvetOverground",null),e([S("_renderer.wireframe")],Xe.prototype,"wireframe",void 0),e([L({value:!1})],Xe.prototype,"suspended",null),e([L({readOnly:!0,aliasOf:"view.qualitySettings.tiledSurface.textureFadeDuration"})],Xe.prototype,"textureFadeDuration",void 0),e([L()],Xe.prototype,"_layerViewsDirty",void 0),e([S("_renderer.renderPatchBorders")],Xe.prototype,"renderPatchBorders",void 0),e([S("_renderer.renderingDisabled")],Xe.prototype,"renderingDisabled",void 0),Xe=e([E("esri.views.3d.terrain.TerrainSurface")],Xe);const ze=Xe;function Ye(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function $e(e){return!e.isLeaf&&(e.children[0].shouldLoad||e.children[1].shouldLoad||e.children[2].shouldLoad||e.children[3].shouldLoad||$e(e.children[0])||$e(e.children[1])||$e(e.children[2])||$e(e.children[3]))}function Ke(e){return e.isLeaf&&e.parent&&e.parent.shouldLoad}const Je=-1,Ze=R(),et=I(),tt=[0,0,0],it=new _,rt={spatialReference:null,tile:null,extent:null,context:"ground"},st={spatialReference:null,extent:null,scale:0};export{ze 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 n from"../../../core/Handles.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{releaseMaybe as h,destroyMaybe as d,isNone as u,isSome as p}from"../../../core/maybe.js";import c from"../../../core/ObjectPool.js";import _ from"../../../core/PooledArray.js";import{isAbortError as m,isAborted as g,createAbortError as y}from"../../../core/promiseUtils.js";import{watch as T,syncAndInitial as f,sync as v,initial as w}from"../../../core/reactiveUtils.js";import{aliasOf as S}from"../../../core/accessorSupport/decorators/aliasOf.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{property as L}from"../../../core/accessorSupport/decorators/property.js";import{subclass as x}from"../../../core/accessorSupport/decorators/subclass.js";import{m as E}from"../../../chunks/mat4.js";import{c as D}from"../../../chunks/mat4f64.js";import{c as P}from"../../../chunks/vec3.js";import{c as C}from"../../../chunks/vec3f64.js";import{c as R}from"../../../chunks/vec4f64.js";import{WatchUpdatingTracking as j}from"../../../core/support/WatchUpdatingTracking.js";import{projectVectorToVector as U,projectPointToVector as M}from"../../../geometry/projection.js";import{getReferenceEllipsoid as b}from"../../../geometry/projectionEllipsoid.js";import{create as A,equals as I,intersection as V,containsPoint as O,empty as k,expand as q,intersectsSphere as B}from"../../../geometry/support/aaBoundingRect.js";import{create as N,copy as F}from"../../../geometry/support/frustum.js";import{isRefreshableLayer as G}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as H}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as W}from"../../../layers/support/layerUtils.js";import{acquireDecoder as Q}from"../../../layers/support/LercDecoder.js";import{printAllocations as X}from"../../2d/engine/vectorTiles/VectorTile.js";import z from"../layers/ElevationLayerView3D.js";import{directionToHeadingTilt as Y,scaleToZoom as $}from"../support/cameraUtils.js";import K from"../support/debugFlags.js";import{toBoundingRect as J}from"../support/extentUtils.js";import{ClientType as Z}from"../support/index.js";import{updatingProgress as ee}from"../support/updatingProperties.js";import{ElevationBounds as te}from"./ElevationBounds.js";import{sampleElevation as ie,ElevationData as re}from"./ElevationData.js";import{create as se}from"./ExtentHelper.js";import{LODSnapping as ae,TextureUpdate as ne}from"./interfaces.js";import{LayerClass as le,LayerClasses as oe}from"./LayerClass.js";import{OverlayManager as he}from"./OverlayManager.js";import{PlanarPatch as de}from"./PlanarPatch.js";import{RenderOrder as ue}from"./RenderOrder.js";import{SphericalPatch as pe}from"./SphericalPatch.js";import{DEFAULT_TILE_BACKGROUND as ce,MAX_ROOT_TILES as _e,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as me,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as ge,MAX_MEMORY_LOD_BIAS as ye,ELEVATION_NODATA_VALUE as Te}from"./TerrainConst.js";import fe from"./TerrainRenderer.js";import ve from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as we,computeSkirtScale as Se,isSurfaceLayerView as Le,isElevationLayerView as xe,isVectorTileLayerView as Ee,useFetchTileForLayer as De,isImageryTileLayerView as Pe,isTileLayerView as Ce,releaseTileData as Re}from"./terrainUtils.js";import{SplitLimits as je,Tile as Ue}from"./Tile.js";import{printAllocations as Me}from"./TilePerLayerInfo.js";import{TileUpdate as be}from"./TileUpdate.js";import{IteratorPreorder as Ae,IteratorPostorder as Ie,hasLoadableSiblings as Ve,sortTilesByPOI as Oe,sortTiles as ke}from"./tileUtils.js";import{TilingSchemeLogic as qe}from"./TilingSchemeLogic.js";import{UpsampleInfo as Be}from"./UpsampleInfo.js";import{RenderRequestType as Ne}from"../webgl-engine/lib/basicInterfaces.js";import{ImmediateTask as Fe,TaskPriority as Ge,noBudget as He}from"../../support/Scheduler.js";const We=l.getLogger("esri.views.3d.terrain.TerrainSurface"),Qe=.25;let Xe=class extends(a.EventedMixin(i)){constructor(e){super(e),this._elevationBounds=new te,this._iteratorPool=new c(Ae,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new Ie,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._visible=!1,this._usedMemory=Je,this._performanceInfo=new ve,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=C(),this._eyePosSurfaceSR=C(),this._splitLimits=new je,this._snapLevel=1/0,this._frustum=N(),this._viewProjectionMatrix=D(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._handles=new n,this._watchUpdatingTracking=new j,this._frameTask=Fe,this._allTiles=new _,this._upsampleInfoPool=new c(Be),this._rootTilesExtent=A(),this._maxNumUpdating=1,this.maxTextureScale=1.2,this.backgroundImage=ce,this.backgroundColor=null,this._layerViewsDirty=!1}initialize(){this._lercDecoder=Q(this.view.resourceController),this._tilePool=this.view.state.isLocal?new c(de):new c(pe);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("esri.views.3d.terrain.upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new H(e.newCache("elevation-query")),this._set("overlayManager",new he({surface:this})),this._handles.add([this.watch("overlayManager.hasHighlights",(e=>this._renderer.setNeedsHighlight(e))),this.watch("overlayManager.rendersOccluded",(e=>this._renderer.setRenderOccludedOverlay(e)))],"overlayManager"),this._renderer=new fe({overlayRenderer:this.overlayManager.renderer,ellipsoidRadius:b(this.view.spatialReference).radius,stage:this.view._stage,allTiles:this._allTiles}),this._handles.add([T((()=>this.baseOpacity),(e=>{this._handleLayerViewChanges(),this._updateBaseOpacity(e)}),f),T((()=>this.renderingDisabled),(()=>this._updateTransparentTerrain()),v),T((()=>this._background),(()=>{this._handleLayerViewChanges(),this._renderer.setTileBackground(this._background)}),f),T((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>()=>this._allTilesSorted=!1))})),T((()=>K.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&K.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=d(this._treeDebugger))}),w)]),this._extentHelper=se(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:this.view.spatialReference});const t=this.view.defaultsFromMap?new s({getCollections:()=>{var e,t,i;return null==(e=this.view)||null==(t=e.defaultsFromMap)||null==(i=t.mapCollections)?void 0:i.map((({layers:e})=>e))},getChildrenFunction:e=>e&&"layers"in e?e.layers:null}):this.view.map.allLayers,i=new qe({layers:t,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:this.view.spatialReference});this._set("tilingSchemeLogic",i),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester(Z.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester(Z.BASEMAP);const r=this.view.resourceController.scheduler;this._frameTask=r.registerTask(Ge.TERRAIN_SURFACE,this),this._handles.add([T((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),w),T((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),v),T((()=>this.extent),(()=>this._updateRootTiles()),w),this.view.on("resize",(()=>this._viewChangeUpdate())),T((()=>{var e,t;const i=this.view,r=i.state;return[this.lodBias,this.lodSnapping,null==(e=i.resourceController)||null==(t=e.memoryController)?void 0:t.memoryFactor,r.camera,r.contentCamera,r.fixedContentCamera]}),(()=>this._viewChangeUpdate()),f),T((()=>{var e,t;return null==(e=this.view.qualitySettings)||null==(t=e.tiledSurface)?void 0:t.textureFadeDuration}),(e=>this._renderer.textureFadingEnabled=e>0),w),T((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),v)]),this._handles.add(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._handles.destroy(),this._watchUpdatingTracking.destroy(),this._lercDecoder=h(this._lercDecoder),this._removeAllTiles(),this._upsampleMapCache=d(this._upsampleMapCache),this._elevationQueryCache=d(this._elevationQueryCache),this._set("tilingSchemeLogic",d(this.tilingSchemeLogic)),this._extentHelper=d(this._extentHelper),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",d(this.overlayManager)),this._tilePool=d(this._tilePool),Ue.prune(),this._treeDebugger&&(this._treeDebugger.destroy(),this._treeDebugger=null),this._renderer=d(this._renderer),this._iteratorPool=d(this._iteratorPool),this._set("view",null),this._upsampleInfoPool=d(this._upsampleInfoPool),X(),Me()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){var e,t;const i=null==(e=this.view.pointsOfInterest)||null==(t=e.contentCameraOnSurface)?void 0:t.scale;if(i){const e=this.view.state.contentCamera;let t=Y(this.view,e.eye,e.viewForward,e.up).tilt;t>90&&(t=180-t);const r=2*(t/90)**2,s=$(this.view,i)-r;Math.abs(this._snapLevel-s)>Qe&&(Math.round(s)!==Math.round(this._snapLevel)&&(this._viewChanged=!0),this._snapLevel=s)}return Math.round(this._snapLevel)}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?ae.ON:ae.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(u(t)||u(e))return null;const i=A(),r=J(t,i,e)?i:null,s=this._get("extent");return I(r,s)?s:r}get extent(){const e=V(this.groundExtent,this._userClippingExtent,A()),t=this._get("extent");return I(e,t)?t:e}get groundExtent(){return p(this._tilingSchemeExtent)?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){var e;return null==(e=this.tilingSchemeLogic)?void 0:e.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this._watchUpdatingTracking.updating||this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||this._asyncWorkItems>0||!this._allTilesSorted||this._renderer.updating||this._layerViewsDirty)&&this.ready&&!this.suspended||this.overlayManager.updating||this._frameTask.updating)}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get viewingMode(){return this.view.state.viewingMode}get ready(){return p(this.rootTiles)}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}set skirtScale(e){this._renderer.skirtScale=e}get skirtScale(){return this._renderer.skirtScale}get spatialReference(){var e,t;return null!=(e=null==(t=this.tilingScheme)?void 0:t.spatialReference)?e:null}get _background(){return null!=this.backgroundColor?this.backgroundColor:this.backgroundImage}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._updateTransparentTerrain()}_updateTransparentTerrain(){var e,t;const i=!this.renderingDisabled&&!this.opaque;null==(e=this.view)||null==(t=e._stage)||t.renderView.setRenderParameters({transparentTerrain:i})}set velvetOverground(e){e!==this.velvetOverground&&(this._renderer.velvetOverground=e),this._set("velvetOverground",e)}set visible(e){e!==this._visible&&(this._visible=e,this._renderer.setVisibility(e),this.suspended=!e)}get opaque(){return this._renderer.opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this.getTileWithElevation(e,t,i,r,Ze);return u(s)?null:ie(Ze[0],Ze[1],s.renderData.geometryState.samplerData)}getTileWithElevation(e,t,i,r,s=Ze){var a;const n=this.rootTiles;if(u(n)||!n.length)return null;if(0===n[0].layerInfo[le.ELEVATION].length)return null;if(s[0]=e,s[1]=t,s[2]=i,!U(s,r,s,null==(a=this.tilingScheme)?void 0:a.spatialReference))return We.error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;for(let l of n){if(!l.containsPoint(s))continue;for(;l&&!l.rendered&&!l.isLeaf;){let e=0;s[0]>.5*(l.extent[0]+l.extent[2])&&(e+=1),s[1]<.5*(l.extent[1]+l.extent[3])&&(e+=2),l=l.children[e]}const e=l.renderData;return(e?e.geometryState.samplerData:null)?l:null}return null}get elevationBounds(){return this._elevationBounds}getScale(e){if(this.tilingScheme){if(!M(e,Ze,this.spatialReference))return We.error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this.rootTiles;if(p(t))for(let e of t)if(e.containsPoint(Ze)){for(;null!=e.children[0];){let t=0;Ze[0]>e.children[0].extent[2]&&(t+=1),Ze[1]<e.children[0].extent[1]&&(t+=2),e=e.children[t]}return this._getLodBiasCorrectedScale(e.level)}}return 1e100}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!M(e,Ze,this.spatialReference))return We.error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;Ze[3]=t;let i=null;const r=e=>{if(e&&B(e.extent,Ze))if(null!=e.children[0])for(const t of e.children)r(t);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}},s=this.rootTiles;if(p(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._renderer.queryVisibleLevelRange(e,s+n,a+n,r)}_updateBaseOpacity(e){const t=this._renderer.opaque;this._renderer.opaque=e>=1,this._renderer.isTransparent=this._allTransparentSurfaceLayers();const i=t!==this._renderer.opaque;i&&this._updateTransparentTerrain(),this._updateTileTextures(i?ne.UNFADED:ne.IMMEDIATE)}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;e!==this.tilingScheme&&(we(!!e,"tiling scheme cannot be reset to undefined"),this.tilingScheme&&this._removeAllTiles(),this._set("tilingScheme",e),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._tilePool.acquire();return tt[0]=e,tt[1]=t,tt[2]=i,s.init(tt,r,this),s}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=et;let s=t.rootTilesInExtent(e,i,5*_e);if(p(this.rootTiles)){if(s.length>_e)return void We.warn(me);const e=this.rootTiles.map((e=>e.lij)),t=r(e,s,Ye);if(t.removed.length>0||t.added.length>0){const e=this.rootTiles.filter((e=>!(t.removed.findIndex((t=>Ye(t,e.lij)))>-1)||(this._purgeTile(e),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else s.length>_e&&(We.warn(ge),s=t.rootTilesInExtent(e,i,_e)),this._setRootTiles(s.map((e=>this._newRootTile(e))));I(i,this._rootTilesExtent)||(this._rootTilesExtent=A(i)),this.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready")}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return t.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===be.SPLIT&&t.setPendingUpdate(be.SPLIT),this._loadTile(t),t}_setRootTiles(e){if(this._set("rootTiles",e),this._allTiles.clear(),p(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._visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateSkirts(),this._updateTilesVisibility(this.rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(be.GEOMETRY)&&this._updateTileGeometry(e)}_updateTilesVisibility(e){if(u(e))return;const t=Ve(e);let i=t?this._elevationBounds.min:1/0,r=t?this._elevationBounds.max:-1/0;const s=this.view.state.fixedContentCamera,a=this.extent,n=this._viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(be.GEOMETRY)&&this._updateTileGeometry(e),e.setPendingUpdate(be.RENDERDATA);const t=e.computeVisibility();s||t?(e.updateScreenDepth(n),e.renderData&&(i=Math.min(e.elevationBounds[0],i),r=Math.max(e.elevationBounds[1],r))):l.skipSubtree()}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,isFinite(i)&&isFinite(r)&&(this._elevationBounds.min===i&&this._elevationBounds.max===r||(this._elevationBounds.min=i,this._elevationBounds.max=r,this.emit("elevation-bounds-change",null)))}_updateViewDependentParameters(){const e=this.view.state.camera,t=this.view.state.contentCamera,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?(u(this._splitLimits.frustum)&&(this._splitLimits.frustum=N()),F(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,F(this._frustum,e.frustum),E(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),P(this._eyePosRenderSR,t.eye),U(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateSkirts(){const e=this.view.state.camera,t=this.view.state.constraints.collision.enabled?0:1.11*e.near;this.skirtScale=Se(this,this._eyePosSurfaceSR,t)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&($e(e)?this._loadChildren(e):Ke(e)&&this._loadParent(e))}_updateTileGeometry(e){e.updateVisibility(),this._renderer.updateTileGeometry(e),this._elevationUpdate(e),this._usedMemory=Je}_updateTileTexture(e,t){const i=e.resetPendingUpdate(be.TEXTURE_FADING)?be.TEXTURE_FADING:!!e.resetPendingUpdate(be.TEXTURE_NOFADING)&&be.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=Je,t.madeProgress())}_elevationUpdate(e){rt.spatialReference=this.spatialReference,rt.tile=e,rt.extent=e.extent,this.emit("elevation-change",rt),O(e.extent,this._eyePosSurfaceSR)&&this._updateSkirts()}get running(){return this.updating&&this.ready&&!this.suspended}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateTileStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),e.run((()=>this._updateElevation(e))),e.run((()=>this._updateTextures(e))),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),e.done&&this.requestUpdate(),this.notifyChange("updatingProgressValue")}_updateTileStatus(e){if(!this._viewChanged||!this.rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();for(t.reset(this.rootTiles);!t.done;){const e=t.next();if(e.loadable){const i=e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping);if(i===be.SPLIT){e.resetPendingUpdate(be.MERGE),e.isLeaf&&(e.setPendingUpdate(be.SPLIT),t.skipSubtree());continue}e.resetPendingUpdate(be.SPLIT)&&e.updateAgentSuspension(),i===be.VSPLITMERGE&&e.updateAgents(le.ELEVATION)}if(t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(be.MERGE),e.resetPendingUpdate(be.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.loadable&&e.updateScreenDepth(this._viewProjectionMatrix);t.remove()}}t.remove(),this.requestUpdate(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Oe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=0;for(;!e.done;){let r=!1;i=0;const s=!this._allTiles.some((s=>{if(i+=s.usedMemory,s.resetPendingUpdate(be.MERGE)){if(!t)return s.setPendingUpdate(be.MERGE),e.done;this._mergeTile(s),r=!0,e.madeProgress()}else s.resetPendingUpdate(be.SPLIT)&&(this._splitTile(s),r=!0,e.madeProgress());return!e.done&&s.resetPendingUpdate(be.RENDERDATA)&&(this._updateRenderData(s),e.madeProgress()),e.done}));if(r&&(this._allTilesSorted=!1,this._allTilesDirty=!0),s){if(this._usedMemory=i,!r)break;this._updateTilesVisibility(this.rootTiles)}else this._allTilesDirty=!0}0===i&&(this._allTilesDirty=!0),this._sortTiles(e)}_updateElevation(e){return this._allTiles.some((t=>(t.resetPendingUpdate(be.GEOMETRY)&&(this._updateTileGeometry(t),this._updateTileTexture(t,e),e.madeProgress()),e.done))),e.hasProgressed}_updateTextures(e){return this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done))),e.hasProgressed}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(Ne.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get lodBias(){const e=this.view.resourceController.memoryController.memoryFactor;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*ye}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=o(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(){p(this.rootTiles)&&(this.rootTiles.forEach((e=>this._purgeTile(e))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.visible=!1}_purgeChildTiles(e){if(e.isLeaf)return!1;let t=this._purgeTile(e.children[0]);return t=this._purgeTile(e.children[1])||t,t=this._purgeTile(e.children[2])||t,t=this._purgeTile(e.children[3])||t,e.unsetChildren(),t}_purgeTile(e){const t=this._purgeChildTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),e.unload(this._renderer),this._tilePool.release(e),t}_splitTile(e){we(e.isLeaf,"tile that is already split should not be split again!");const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2];e.setChildren(this._createTile(t,i,r,e),this._createTile(t,i,r+1,e),this._createTile(t,i+1,r,e),this._createTile(t,i+1,r+1,e)),e.setPendingUpdate(be.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,this._emitTileScaleChange(e,t),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){st.spatialReference=this.spatialReference,st.extent=e.extent,st.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",st)}_createTile(e,t,i,r){we(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.loadable&&(s.updateScreenDepth(this._viewProjectionMatrix),s.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===be.SPLIT&&s.setPendingUpdate(be.SPLIT)),s}_mergeTile(e){we(!e.hasPendingUpdate(be.SPLIT),"_mergeTile sanity check"),this._purgeChildTiles(e)&&(we(!e.renderData,"_mergeTile sanity check"),this._loadTile(e)),this._allTilesDirty=!0,++this._performanceInfo.numMerged,this._emitTileScaleChange(e)}_loadChildren(e){we(e.rendered,"parent should be rendered"),e.unload(this._renderer),this._loadTile(e.children[0]),this._loadTile(e.children[1]),this._loadTile(e.children[2]),this._loadTile(e.children[3])}_loadParent(e){const t=e.parent;this._unloadChildren(t),this._loadTile(t)}_unloadChildren(e){e.isLeaf||(this._unloadChildren(e.children[0]),e.children[0].unload(this._renderer),this._unloadChildren(e.children[1]),e.children[1].unload(this._renderer),this._unloadChildren(e.children[2]),e.children[2].unload(this._renderer),this._unloadChildren(e.children[3]),e.children[3].unload(this._renderer))}_loadTile(e){e.load(this._renderer),e.setPendingUpdate(be.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e),this._elevationUpdate(e)}_elevationDataArrived(e,t,i){const r=new re(e.lij,e.extent,i);e.dataArrived(t,le.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=He){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(const s of this.view.allLayerViews.items)if(i.add(s.uid),Le(s))if(this._basemapLayerViewHandles.has(s.uid)){const e=this._layerClassFromLayerView(s),i=this._layerIndexByUid[e].get(s.uid);i<r&&(t=!0),r=i}else this._registerTiledLayerView(s),s.layer.loaded&&(t=!0);this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this._renderer.isTransparent=this._allTransparentSurfaceLayers(),e.madeProgress()}_allTransparentSurfaceLayers(){var e,t;let i=0===(null==(e=this.view.map)||null==(t=e.ground)?void 0:t.opacity);for(const r of this.view.allLayerViews.items)if(Le(r)&&!xe(r)&&!W(r.layer)&&0!==r.fullOpacity)return i=!1,i;return i}_layerClassFromLayerView(e){return xe(e)?le.ELEVATION:le.MAP}_registerTiledLayerView(e){const t=[],i=this._layerClassFromLayerView(e);t.push(e.watch("suspended",(()=>this._updateTiledLayers()))),t.push(e.watch("fullOpacity",(()=>this._updateTileTextures(ne.UNFADED)))),t.push(e.layer.watch("effectiveScaleRange",(()=>this._restartAllAgents(i)))),e.on("data-changed",(()=>{const t=this._layerIndexByUid[i].get(e.uid);null!=t&&this._invalidateLayerData(t,i)})),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(let e=0;e<t.length;e++)t[e].remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;const r=k();e.forEach((e=>{const s=e.layer;if(!s||e.suspended||!Le(e))return;const a=e.fullExtent;if(!a)return void We.warn("Terrain: Map or elevation layer does not have fullExtent: "+s.id);q(r,a,r);const n=this._layerClassFromLayerView(e);if(n===le.MAP){const t=e.displayLevelRange;t.maxLevel!==1/0&&(null===i||t.maxLevel>i)&&(i=t.maxLevel)}t[n].push(e)}));for(const s of oe){const e=this._layerViews[s],i=t[s];i.reverse();const r=i.length;let a=e.length!==r;const n=new Array(r),l=new Array(e.length);this._layerIndexByUid[s].clear();for(let t=0;t<r;t++){const r=i[t].uid;this._layerIndexByUid[s].set(r,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,s);this._layerViews[s]=i,this._restartAllAgents(s),this._updateTilesVisibility(this.rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&this._viewChangeUpdate()}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this.rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===le.ELEVATION&&i.computeElevationBounds()}}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(le.MAP),e===ne.IMMEDIATE?this.renderer.updateTileTexture(t,be.TEXTURE_NOFADING):t.updateRenderData(le.MAP,e)})),this._renderer.isTransparent=this._allTransparentSurfaceLayers()}_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=Ne.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||Ee(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,m(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===le.ELEVATION?this._requestElevationTileData(e,i,r):this._requestMapTileData(e,i,r)}_requestElevationTileData(e,t,i){if(!xe(t))return void we(!1,"_requestElevationTileData can only be called for elevation layer views");const r=r=>{if(--this._asyncWorkItems,g(i))return;const s=this._layerIndexByUid[le.ELEVATION].get(t.uid);null!=s?(this._usedMemory=Je,this.requestUpdate(),this._elevationDataArrived(e,s,r)):We.warn("TerrainSurface: received data from unknown layer %d %s",le.ELEVATION,e.lij.toString())},s=i=>{--this._asyncWorkItems,m(i)||(this._dataMissing(e,le.ELEVATION,t,i),this.requestUpdate())};if(++this._asyncWorkItems,De(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:Te,signal:i.signal}).then((e=>{if(g(i))return We.warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void s(y());this._frameTask.schedule((()=>r(e)),i.signal,s)}),s);const a=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);return this._elevationDataRequester.request(a,"binary",i).then((e=>this._lercDecoder.decode(e,{noDataValue:Te},i.signal))).then((e=>{r({values:e.pixelData,width:e.width,height:e.height,noDataValue:e.noDataValue,minValue:e.minValue,maxValue:e.maxValue})}),s)}_requestMapTileData(e,t,i){if(t instanceof z)return Promise.reject();++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,Re(s),g(i)||(this._dataMissing(e,le.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),g(i)?Re(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(Ee(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,n)}if(Pe(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,n);if(Ce(t)&&De(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(g(i))return We.warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void n(y());a(e)}),n);let l=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);G(t.layer)&&t.layer.refreshTimestamp&&(l+=`${l.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const o=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(l,o,i).then(a,n)}_mapTileDataArrived(e,t,i){const r=this._layerIndexByUid[le.MAP].get(t.uid);null!=r?e.dataArrived(r,le.MAP,i):(Re(i),We.warn("TerrainSurface: received data from unknown layer"))}_dataMissing(e,t,i,r){const s=this._layerIndexByUid[t].get(i.uid);null!=s?e.dataMissing(s,t,r):We.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.isLeaf&&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}getUsedMemory(){return this.tilingScheme?(this._usedMemory===Je&&(this._usedMemory=0,this._allTiles.forAll((e=>this._usedMemory+=e.usedMemory))),this._usedMemory):0}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._layerIndexByUid[i].get(e.uid);return this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(u(e)||u(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=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(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 we(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}get test(){const e=this;return{renderer:e._renderer,lercDecoder:e._lercDecoder,forceReload:()=>{p(e.rootTiles)&&(e._mergeTile(e.rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){it.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&it.push(e)}));const t=it.toArray();return ke(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}get isGlobal(){var e,t;return!(null!=(e=this.view)&&null!=(t=e.state)&&t.isLocal)}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&0===e[2]}lijEastEnd(e){return 2**(e+(this.spatialReference.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]}};e([L()],Xe.prototype,"_renderer",void 0),e([L()],Xe.prototype,"_hasPendingUpdates",void 0),e([L()],Xe.prototype,"_asyncWorkItems",void 0),e([L()],Xe.prototype,"_allTilesDirty",void 0),e([L()],Xe.prototype,"_allTilesSorted",void 0),e([L()],Xe.prototype,"_viewChanged",void 0),e([L({readOnly:!0})],Xe.prototype,"_watchUpdatingTracking",void 0),e([L()],Xe.prototype,"_frameTask",void 0),e([L({readOnly:!0})],Xe.prototype,"snapLevel",null),e([L({readOnly:!0})],Xe.prototype,"lodSnapping",null),e([L({constructOnly:!0})],Xe.prototype,"view",void 0),e([L()],Xe.prototype,"_userClippingExtent",null),e([L()],Xe.prototype,"_rootTilesExtent",void 0),e([L({readOnly:!0})],Xe.prototype,"extent",null),e([L({readOnly:!0})],Xe.prototype,"groundExtent",null),e([L({readOnly:!0})],Xe.prototype,"_tilingSchemeExtent",null),e([L({readOnly:!0})],Xe.prototype,"updating",null),e([L(ee)],Xe.prototype,"updatingProgress",void 0),e([L({readOnly:!0})],Xe.prototype,"updatingProgressValue",null),e([L()],Xe.prototype,"_maxNumUpdating",void 0),e([L({aliasOf:"view.map.ground.opacity"})],Xe.prototype,"baseOpacity",void 0),e([L({readOnly:!0})],Xe.prototype,"overlayManager",void 0),e([L({readOnly:!0})],Xe.prototype,"viewingMode",null),e([L()],Xe.prototype,"maxTextureScale",void 0),e([L({readOnly:!0})],Xe.prototype,"ready",null),e([L({value:ue.FRONT_TO_BACK})],Xe.prototype,"renderOrder",null),e([L({readOnly:!0})],Xe.prototype,"rootTiles",void 0),e([L({readOnly:!0})],Xe.prototype,"spatialReference",null),e([L()],Xe.prototype,"backgroundImage",void 0),e([L({type:t,aliasOf:"view.map.ground.surfaceColor"})],Xe.prototype,"backgroundColor",void 0),e([L()],Xe.prototype,"_background",null),e([L({value:!1})],Xe.prototype,"slicePlaneEnabled",null),e([L({readOnly:!0})],Xe.prototype,"tilingScheme",void 0),e([L({readOnly:!0,aliasOf:"tilingSchemeLogic.tilingSchemeLocked"})],Xe.prototype,"tilingSchemeLocked",void 0),e([L({readOnly:!0})],Xe.prototype,"tilingSchemeLogic",void 0),e([L({value:!0})],Xe.prototype,"velvetOverground",null),e([S("_renderer.wireframe")],Xe.prototype,"wireframe",void 0),e([L({value:!1})],Xe.prototype,"suspended",null),e([L({readOnly:!0,aliasOf:"view.qualitySettings.tiledSurface.textureFadeDuration"})],Xe.prototype,"textureFadeDuration",void 0),e([L()],Xe.prototype,"_layerViewsDirty",void 0),e([S("_renderer.renderPatchBorders")],Xe.prototype,"renderPatchBorders",void 0),e([S("_renderer.renderingDisabled")],Xe.prototype,"renderingDisabled",void 0),Xe=e([x("esri.views.3d.terrain.TerrainSurface")],Xe);const ze=Xe;function Ye(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function $e(e){return!e.isLeaf&&(e.children[0].shouldLoad||e.children[1].shouldLoad||e.children[2].shouldLoad||e.children[3].shouldLoad||$e(e.children[0])||$e(e.children[1])||$e(e.children[2])||$e(e.children[3]))}function Ke(e){return e.isLeaf&&e.parent&&e.parent.shouldLoad}const Je=-1,Ze=R(),et=A(),tt=[0,0,0],it=new _,rt={spatialReference:null,tile:null,extent:null,context:"ground"},st={spatialReference:null,extent:null,scale:0};export{ze 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.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{update as t}from"../../../../core/arrayUtils.js";import s from"../../../../core/Handles.js";import{someMap as i}from"../../../../core/MapUtils.js";import{destroyMaybe as n,disposeMaybe as a,isSome as h,isNone as d,unwrap as o}from"../../../../core/maybe.js";import{watch as l,syncAndInitial as _,initial as p}from"../../../../core/reactiveUtils.js";import{Milliseconds as c}from"../../../../core/time.js";import{property as m}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as g}from"../../../../core/accessorSupport/decorators/subclass.js";import{v as u,a as f,m as T}from"../../../../chunks/mat4.js";import{I as R,c as A}from"../../../../chunks/mat4f64.js";import{c as E}from"../../../../chunks/boundedPlane.js";import{MAXIMUM_ANIMATION_LOAD as P,MINIMUM_IDLE_ANIMATION_MS as b}from"../../support/animationUtils.js";import S from"../../support/debugFlags.js";import{RenderPassManager as H}from"../core/renderPasses/RenderPassManager.js";import{HUDTransparentRenderStyle as w}from"../core/shaderLibrary/hud/HUDUniforms.js";import{AntiAliasingMode as x,TransparencyPassType as I,Decorations as M,RenderRequestType as L,StencilBits as O}from"./basicInterfaces.js";import{BoundingInfo as D}from"./BoundingInfo.js";import{ZERO as C,union as y}from"./depthRange.js";import{depthRangeFromScene as N}from"./depthRangeUtils.js";import{createEmptyDepthTexture as v}from"./glUtil3D.js";import U from"./HighlightHelper.js";import{RenderOccludedFlag as q}from"./Material.js";import{OffscreenRendering as F}from"./OffscreenRendering.js";import{RenderContext as j}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as G}from"./rendererUtils.js";import{RenderPass as V}from"./RenderPass.js";import{RenderPluginManager as B}from"./RenderPluginManager.js";import{RenderSlot as W}from"./RenderSlot.js";import{ShadowAccumulator as k}from"./ShadowAccumulator.js";import{ShadowHighlightHelper as Q}from"./ShadowHighlightHelper.js";import z from"./ShadowMap.js";import X from"./SliceHelper.js";import{SmaaRenderPass as Y}from"./SmaaRenderPass.js";import{SSAOHelper as K}from"./SSAOHelper.js";import{EdgeView as J}from"./edgeRendering/EdgeView.js";import{Transparency as Z}from"./edgeRendering/interfaces.js";import{MergedRenderer as $}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as ee}from"../shaders/CompositingTechniqueConfiguration.js";import{HighlightShadowMapSlot as re,DefaultSnapshotSlot as te}from"../shaders/ShadowHighlightTechnique.js";import{RendererPerformanceInfo as se,Statistics as ie}from"../statistics/RendererPerformanceInfo.js";import{ClearBufferBit as ne,PixelFormat as ae,PixelType as he}from"../../../webgl/enums.js";const de=.9;let oe=class extends r{constructor(e,r,t,i,n,a,h,d,o){super({}),this._materialRepository=e,this._shaderTechniqueRepository=t,this._rctx=i,this._compositingHelper=n,this._magnifierHelper=a,this._requestRender=h,this._stage=o,this._materialRenderers=new Map,this._needsTransparentPass=!1,this._hasHUDElements=!1,this._hasHighlights=!1,this._hasWater=!1,this._hasOverlayWater=!1,this._content=new Map,this._isRendering=!1,this._fallbackDepthStencilTexture=null,this.performanceInfo=new se,this._antialiasing=x.SMAA,this._oitEnabled=!1,this._multipassTerrain=!0,this._opaqueTerrain=!0,this._hasAnimations=!1,this._animationTimestep=c(0),this._handles=new s,this._renderHiddenTransparentEdges=()=>{},this._oitUsed=!1,this._smaaPass=new Y(this._rctx,t),this._oitEnabled=this._hasOITSupport,this._requestRender(),this._offscreenRendering=new F(this._rctx,this._compositingHelper),this._sliceHelper=new X,this._shadowMap=new z(this._rctx,o.viewingMode,2),this._ssaoHelper=new K(t,this._rctx,(()=>this._requestRender())),this._highlightHelper=new U(t,this._rctx),this._shadowHighlightHelper=new Q(this._rctx,o.viewingMode),this._shadowAccumulator=new k(this._rctx,t,o,((e,r)=>{const t=this.hasShadowsEnabled;return this._shadowMap.enabled=!0,this._renderPlugins.prepareRender(e,r),this._shadowMap.enabled=t,this._bindParameters}),((e,r,t,s)=>{e.start(t,r,s),this._renderShadowCascades(V.MATERIAL_DEPTH_SHADOWMAP_ALL,e),t.setGLViewport(this._rctx),this._ensureCameraBindParameters(t)}),(()=>this._requestRender())),this._renderContext=new j(this._rctx,this._offscreenRendering,this._shadowMap,this._ssaoHelper,this._sliceHelper),this._renderPlugins=new B({renderContext:this._renderContext,shaderTechniqueRepository:t,textureRep:r,materialRep:this._materialRepository,requestRender:this._requestRender,schedule:d}),this.renderPassManager=new H(this._rctx,this._shaderTechniqueRepository),this._renderPlugins.add(this.renderPassManager.slots(),this.renderPassManager),this._handles.add([l((()=>this._stage.state.camera),(()=>this._requestRender()),_),l((()=>S.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(Z.TRANSPARENT):()=>{},this._requestRender()}),p)])}get _bindParameters(){return this._renderContext.bindParameters}get hasWater(){return this._hasWater||this._hasOverlayWater}get hasWaterReflection(){return this.hasWater&&this._waterReflectionEnabled}normalizeCtorArgs(){return{}}dispose(){this._handles.destroy(),this._smaaPass.dispose(),this._materialRenderers.forEach((e=>e.dispose())),this._materialRenderers.clear(),this._edgeView=n(this._edgeView),this._offscreenRendering.dispose(),this._fallbackDepthStencilTexture=a(this._fallbackDepthStencilTexture),this._shadowMap.enabled=!1,this._shadowMap.dispose(),this._ssaoHelper.enabled=!1,this._ssaoHelper.dispose(),this._highlightHelper.dispose(),this._shadowHighlightHelper.dispose(),this._shadowAccumulator.dispose(),D.prune(),this._content.clear()}disposeOffscreenBuffers(){this._offscreenRendering.dispose(),this._shadowMap.dispose(),this._smaaPass.disable(),this._ssaoHelper.disposeOffscreenBuffers()}get updating(){return this._antialiasing===x.SMAA&&this._smaaPass.updating||h(this._edgeView)&&this._edgeView.updating||this._shadowAccumulator.running||!this.isCameraFinal}ensureEdgeView(){return d(this._edgeView)&&(this._edgeView=new J({rctx:this._rctx,renderSR:this._stage.renderSR,techniqueRepository:this._shaderTechniqueRepository,setNeedsRender:()=>this._requestRender(),schedule:e=>this._stage.resourceController.schedule(e)}),this._handles.add(this._edgeView.watch("updating",(()=>this._requestRender()),!0)),this._requestRender()),this._edgeView}get edgeView(){return this._edgeView}get isCameraFinal(){return u(this._bindParameters.ssr.reprojectionMatrix,R)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this.notifyChange("isCameraFinal")}get hasShadowsEnabled(){var e;return!(null==(e=this._shadowMap)||!e.enabled)}setRenderParameters(e){const{_shadowMap:r,_ssaoHelper:t,_bindParameters:s}=this;void 0!==e.screenSpaceReflectionsEnabled&&s.ssr.enabled!==e.screenSpaceReflectionsEnabled&&(s.ssr.enabled=e.screenSpaceReflectionsEnabled,this._requestRender()),void 0!==e.enableFillLights&&s.enableFillLights!==e.enableFillLights&&(s.enableFillLights=e.enableFillLights,this._requestRender()),void 0!==e.shadowMap&&r.enabled!==e.shadowMap&&(r.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&r.maxCascades!==e.shadowMapMaxCascades&&(r.maxCascades=e.shadowMapMaxCascades,this._requestRender()),void 0!==e.ssao&&t.enabled!==e.ssao&&(t.enabled=e.ssao,this._requestRender()),e.background&&this._offscreenRendering.background!==e.background&&(this._offscreenRendering.background=e.background,this._requestRender());const i=e.antialiasingEnabled?x.SMAA:x.NONE;void 0!==e.antialiasingEnabled&&this._antialiasing!==i&&(this._antialiasing=i,this._requestRender()),void 0!==e.highQualityTransparency&&this._multipassTerrain!==e.highQualityTransparency&&(this._multipassTerrain=e.highQualityTransparency,this._oitEnabled=e.highQualityTransparency&&this._hasOITSupport,this._requestRender()),void 0!==e.defaultHighlightOptions&&(this._highlightHelper.setDefaultOptions(e.defaultHighlightOptions),this._shadowHighlightHelper.setDefaultOptions(e.defaultHighlightOptions),this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=o(e.slicePlane),this._requestRender()),void 0!==e.waterReflectionEnabled&&this._waterReflectionEnabled!==e.waterReflectionEnabled&&(this._waterReflectionEnabled=e.waterReflectionEnabled,this._requestRender()),void 0!==e.enableFillLights&&s.enableFillLights!==e.enableFillLights&&(s.enableFillLights=e.enableFillLights,this._requestRender()),void 0!==e.opaqueTerrain&&this._opaqueTerrain!==e.opaqueTerrain&&(this._opaqueTerrain=e.opaqueTerrain,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.shadowCastOptions&&this._shadowAccumulator.setOptions(e.shadowCastOptions)}get hasSlicePlane(){return!!this._sliceHelper.plane}get renderPlugins(){return this._renderPlugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlendWorking}modify(e){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:r,removes:t,updates:s}=e;if(0===r.length&&0===t.length&&0===s.length)return;t.forAll((({id:e})=>this._content.delete(e))),r.forAll((e=>this._content.set(e.id,e)));const n=G(e);let a=!1;n.forEach(((e,r)=>{let t=this._materialRenderers.get(r);if(!t){if(!(e.adds.length>0))return;t=new $(this._rctx,this._materialRepository,r),this._materialRenderers.set(r,t)}t.modify(e),t.isEmpty&&(a=!0)})),a&&this._materialRenderers.forEach(((e,r)=>{e.isEmpty&&(this._materialRenderers.delete(r),e.dispose())})),this._hasHighlights=i(this._materialRenderers,(e=>e.hasHighlights)),this._bindParameters.hasOccludees=i(this._materialRenderers,(e=>e.hasOccludees)),this._hasWater=i(this._materialRenderers,(e=>e.hasWater)),this._needsTransparentPass=i(this._materialRenderers,(e=>e.requiresSlot(W.TRANSPARENT_MATERIAL,V.MATERIAL))),this._hasHUDElements=i(this._materialRenderers,(e=>e.requiresSlot(W.LINE_CALLOUTS_HUD_DEPTH,V.MATERIAL)||e.requiresSlot(W.HUD_MATERIAL,V.MATERIAL)||e.requiresSlot(W.LABEL_MATERIAL,V.MATERIAL))),this._requestRender()}updateAnimation(e){return this._hasAnimations=!1,this._materialRenderers.forEach((r=>this._hasAnimations=r.updateAnimation(e)||this._hasAnimations)),this._hasAnimations=this._renderPlugins.updateAnimation(e)||this._hasAnimations,this._hasAnimations}get animationTimestep(){return this._animationTimestep}updateLightSources(e,r,t){this._bindParameters.lighting.groundLightingFactor=r,this._bindParameters.lighting.globalFactor=t,this._bindParameters.lighting.set(e)}render(e,r,t,s){this._isRendering=!0,this.performanceInfo.prerender(this._rctx),this._bindParameters.transparencyPassType=I.NONE;const i=this._offscreenRendering;i.needLastFrameColorTexture=this.hasWaterReflection,i.advanceCurrentRenderTarget();const n=E(this._sliceHelper.plane);s===M.OFF&&(this._sliceHelper.plane=null),this._rctx.bindFramebuffer(e),r.setGLViewport(this._rctx),this._renderPlugins.prepareRender(r,t),this.performanceInfo.advance(ie.Prepare);const a=this._computeDepthRange(r);this._renderShadowMap(e,r,this._bindParameters.lighting.lightingMainDirection,a),this.performanceInfo.advance(ie.Shadowmap),i.initializeFrame(r),this._ensureBindParameters(r),this._renderLinearDepth(),this.performanceInfo.advance(ie.Lineardepth),this._accumulateShadows(a,r,t),this._renderNormal(),this.performanceInfo.advance(ie.Normals),this._ensureBindParametersSSR(),this._ssaoHelper.computeSSAO(this._bindParameters,i.linearDepthTexture,i.normalTexture),this.performanceInfo.advance(ie.SSAO),this._renderContext.pass=V.MATERIAL,i.bindFramebuffer(),this._renderOpaqueGeometry(),this.performanceInfo.advance(ie.Opaque);const o=this._multipassTerrain&&!this._opaqueTerrain;this._renderTerrainLinearDepth(o),this._setMultipassEnabled(o),this._setTerrainCulling(o),this._renderEdges(Z.OPAQUE),this.performanceInfo.advance(ie.OpaqueEdges),this._renderHiddenTransparentEdges();const l=this._needsTransparentPass||this._renderPlugins.needsTransparentPass;l&&(this._oitEnabled?this._renderOrderIndependentTransparency((()=>this._renderTransparentGeometry()),!1):this._renderTransparentGeometry()),this.performanceInfo.advance(ie.Transparent),this._renderGeometryLinearDepth(o);const _=this._renderHUDVisibility();o||this._renderInternalSlot(W.LINE_CALLOUTS),this.performanceInfo.advance(ie.Hudvisibility),this._renderEdges(Z.TRANSPARENT,o),this.performanceInfo.advance(ie.TransparentEdges),this._renderSlot(W.VOXEL),this._renderTransparentTerrain(),!this._opaqueTerrain&&_&&(o?this._renderLineCallouts(w.Occluded):i.compositeTransparentTerrainOntoHUDVisibility(),this._renderHUD(w.Occluded,i.framebuffer),this.performanceInfo.advance(ie.HudOccluded)),this.performanceInfo.advance(ie.TransparentTerrain),this._setTerrainCulling(!1),this._opaqueTerrain||(i.compositeTransparentTerrainOntoMain(),o&&(this._renderEdges(Z.OPAQUE),this.performanceInfo.advance(ie.OpaqueEdges),l&&(this._oitEnabled?this._renderOrderIndependentTransparency((()=>this._renderTransparentGeometry()),!1):this._renderTransparentGeometry()),this.performanceInfo.advance(ie.Transparent),this._renderEdges(Z.TRANSPARENT),this.performanceInfo.advance(ie.TransparentEdges))),o&&this._renderLineCallouts(w.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),i.renderToTargets((()=>{this._renderInternalSlot(W.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderSlot(W.POSTPROCESSING_ENVIRONMENT_TRANSPARENT),this._renderSlot(W.LASERLINES)}),i.currentColorTarget,i.mainDepth),this.performanceInfo.advance(ie.Atmosphere),this._renderPlugins.needsLaserlineWithContrastControl&&i.renderTmpAndCompositeToMain((()=>this._renderSlot(W.LASERLINES_CONTRAST_CONTROL)),ee.PremultipliedAlpha),this.performanceInfo.advance(ie.Laserline),this._renderOccluded(),this.performanceInfo.advance(ie.Occluded);const p=s===M.ON&&this._magnifierHelper.enabled,c=p&&d(e)?this._offscreenRendering.getFramebuffer(this._offscreenRendering.tmpColor,this._offscreenRendering.tmpDepth):e;this._rctx.bindFramebuffer(c);const m=this._offscreenRendering.colorTexture;!this._renderAntiAliasing(this._antialiasing,m)&&h(m)&&this._compositingHelper.composite(m,ee.None),this.performanceInfo.advance(ie.Antialiasing),this._renderHUD(w.NotOccluded,c),this.performanceInfo.advance(ie.HudNotoccluded),this._renderHighlights(c,this._bindParameters),this.performanceInfo.advance(ie.Highlights),p&&this._magnifierHelper.render(this._rctx,this._bindParameters),c!==e&&(this._rctx.bindFramebuffer(e),this._compositingHelper.composite(this._offscreenRendering.tmpColorTexture,ee.None)),this._disposeOITBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=n,this._isRendering=!1,this.onPostRender&&this.onPostRender(),this.performanceInfo.postrender()}finish(e){if(this._hasAnimations||(this._animationTimestep=c(0)),e===L.BACKGROUND){this._rctx.gl.getError();const e=this.performanceInfo.elapsedTime/P;this._animationTimestep=c(Math.max(this._animationTimestep*de+e*(1-de),b))}}readDepthPixels(e,r,t,s,i,n){const a=this._offscreenRendering.bindTarget(this._offscreenRendering.linearDepth,this._offscreenRendering.tmpDepth);if(!this._needsLinearDepth){this._ensureBindParameters(e),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.setClearColor(0,0,0,0);const r=ne.COLOR_BUFFER_BIT|ne.DEPTH_BUFFER_BIT|ne.STENCIL_BUFFER_BIT;this._rctx.clearSafe(r),this._renderGeometryAndTransparentTerrainPass(V.MATERIAL_DEPTH)}a.readPixels(r,t,s,i,ae.RGBA,he.UNSIGNED_BYTE,n)}readHUDVisibility(e,r,t,s,i){this._offscreenRendering.bindTarget(this._offscreenRendering.hudVisibility).readPixels(e,r,t,s,ae.RGBA,he.UNSIGNED_BYTE,i)}readAccumulatedShadow(e,r){return this._shadowAccumulator.readAccumulatedShadow(e,r)}_setMultipassEnabled(e){this._bindParameters.multipassTerrain.enabled=this._bindParameters.multipassGeometry.enabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_renderSlot(e){this._bindParameters.slot=e,this._renderPlugins.render()}_renderEdges(e,r=!1){const t=this._edgeView;h(t)&&t.shouldRender()&&this._offscreenRendering.renderTmpAndCompositeToMain((()=>t.render(this._bindParameters,e)),ee.Alpha,r)}_renderShadowMap(e,r,t,s){const i=this._shadowMap;i.enabled&&(i.start(r,t,s),this._shadowHighlightHelper.updateParameters(r,t),this.needsShadowHighlight?(this._renderShadowCascades(V.MATERIAL_DEPTH_SHADOWMAP_HIGHLIGHT,this._shadowMap,(e=>i.takeCascadeSnapshotTo(e,re))),i.clear(),this._renderShadowCascades(V.MATERIAL_DEPTH_SHADOWMAP_DEFAULT,this._shadowMap,(e=>{i.takeCascadeSnapshotTo(e,te),this._renderGeometryAndTransparentTerrainPass(V.MATERIAL_DEPTH_SHADOWMAP_HIGHLIGHT)}))):this._renderShadowCascades(V.MATERIAL_DEPTH_SHADOWMAP_ALL),i.finish(e),r.setGLViewport(this._rctx))}_renderShadowCascades(e,r=this._shadowMap,t=(e=>{})){for(const s of r.getCascades())s.camera.setGLViewport(this._rctx),this._ensureCameraBindParameters(s.camera),this._renderGeometryAndTransparentTerrainPass(e),t(s)}get _needsLinearDepth(){return this._ssaoHelper.enabled||this._renderPlugins.needsLinearDepth||this._hasWater&&this._waterReflectionEnabled||this.needsShadowHighlight||this.needsShadowCast}_renderLinearDepth(){this._needsLinearDepth?this._offscreenRendering.renderToTargets((()=>this._renderGeometryAndTransparentTerrainPass(V.MATERIAL_DEPTH)),this._offscreenRendering.linearDepth,this._offscreenRendering.tmpDepth,[0,0,0,0],!0,!0):this._offscreenRendering.disposeTarget(this._offscreenRendering.linearDepth),this._bindParameters.ssr.linearDepthTexture=this._offscreenRendering.linearDepthTexture}_renderTerrainLinearDepth(e){if(e){const e=this._renderContext.pass;this._renderContext.pass=V.MATERIAL_DEPTH,this._offscreenRendering.renderToTargets((()=>this._renderTransparentTerrain()),this._offscreenRendering.terrainLinearDepth,this._offscreenRendering.tmpDepth,[-1e10,-1e10,-1e10,1],!0,!0),this._renderContext.pass=e}else this._offscreenRendering.disposeTarget(this._offscreenRendering.terrainLinearDepth);this._bindParameters.multipassTerrain.linearDepthTexture=this._offscreenRendering.terrainLinearDepthTexture}_renderGeometryLinearDepth(e){if(e){const e=this._renderContext.pass;this._offscreenRendering.renderToTargets((()=>this._renderGeometryPass(V.MATERIAL_DEPTH)),this._offscreenRendering.geometryLinearDepth,this._offscreenRendering.tmpDepth,[1,1,1,1],!0,!0),this._renderContext.pass=e}else this._offscreenRendering.disposeTarget(this._offscreenRendering.geometryLinearDepth);this._bindParameters.multipassGeometry.linearDepthTexture=this._offscreenRendering.geometryLinearDepthTexture}get needsNormal(){return this._ssaoHelper.enabled}_renderNormal(){this.needsNormal?this._offscreenRendering.renderToTargets((()=>{this._renderGeometryAndTransparentTerrainPass(V.MATERIAL_NORMAL)}),this._offscreenRendering.normal,this._offscreenRendering.tmpDepth,[0,0,0,0],!0,!0):this._offscreenRendering.disposeTarget(this._offscreenRendering.normal)}get needsDepthRange(){return this._shadowMap.enabled||this.needsShadowCast}_computeDepthRange(e){if(!this.needsDepthRange)return C;const r=N(e,this._content,this._stage.layers);return y(r,this.renderPlugins.queryDepthRange(e)),r.near=Math.max(e.near,r.near),r.far=Math.min(e.far,r.far),r}_renderGeometryAndTransparentTerrainPass(e){this._renderContext.pass=e,this._renderGeometryPass(e),this._renderTransparentTerrain()}_renderGeometryPass(e){this._renderContext.pass=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderOpaqueGeometry(){this._renderSlot(W.INTEGRATED_MESH),this._renderSlot(W.OPAQUE_TERRAIN),this._renderInternalSlot(W.OPAQUE_MATERIAL),this._renderSlot(W.OPAQUE_MATERIAL),this._renderSlot(W.POSTPROCESSING_ENVIRONMENT_OPAQUE)}_renderTransparentGeometry(){this._renderInternalSlot(W.TRANSPARENT_MATERIAL),this._renderSlot(W.TRANSPARENT_MATERIAL)}_renderTransparentTerrain(){this._renderSlot(W.TRANSPARENT_TERRAIN)}_renderHUDVisibility(){let e=!1;return this._renderContext.offscreenRenderingHelper&&this._renderContext.offscreenRenderingHelper.renderHUDVisibility((()=>{this._bindParameters.hudVisibilityTexture=this._renderContext.offscreenRenderingHelper.hudVisibilityTexture,e=this._renderInternalSlot(W.OCCLUSION_PIXELS)}),this._multipassTerrain&&!this._opaqueTerrain),e}_renderLineCallouts(e){this._bindParameters.renderTransparentlyOccludedHUD=e,e===w.Occluded?this._offscreenRendering.renderToTargets((()=>this._renderInternalSlot(W.LINE_CALLOUTS)),this._offscreenRendering.currentColorTarget,this._offscreenRendering.tmpDepth,void 0,!0,!0):this._renderInternalSlot(W.LINE_CALLOUTS)}_renderHUD(e,r){this._hasHUDElements&&(this._oitEnabled?(this._renderOrderIndependentTransparency((()=>this._renderHUDElements(e)),!0),this._rctx.bindFramebuffer(r),this._compositingHelper.composite(this._offscreenRendering.hudColorTexture,ee.PremultipliedAlpha)):e===w.Occluded?this._offscreenRendering.renderToTargets((()=>this._renderHUDElements(w.Occluded)),this._offscreenRendering.currentColorTarget,this._offscreenRendering.tmpDepth,void 0,!0,!0):this._renderHUDElements(e))}_renderHUDElements(e){this._bindParameters.renderTransparentlyOccludedHUD=e,this._renderInternalSlot(W.LINE_CALLOUTS_HUD_DEPTH),this._renderInternalSlot(W.HUD_MATERIAL),this._renderInternalSlot(W.LABEL_MATERIAL)}get needsHighlight(){return this._hasHighlights||this._renderPlugins.needsHighlight}get needsShadowHighlight(){return this._shadowMap.enabled&&this._shadowHighlightHelper.isVisible&&this.needsHighlight}_renderHighlights(e,r){if(!this.needsHighlight)return void this._offscreenRendering.disposeTarget(this._offscreenRendering.highlight);const t=this._highlightHelper,s=this._offscreenRendering.renderToTargets((()=>{this._renderGeometryAndTransparentTerrainPass(V.MATERIAL_HIGHLIGHT),this._rctx.clearSafe(ne.DEPTH_BUFFER_BIT),this._renderHUDElements(w.Both)}),this._offscreenRendering.highlight,this._offscreenRendering.tmpDepth,[0,0,0,0],!0,!0);this._bindParameters.highlightColorTexture=s.colorTexture,this.needsShadowHighlight&&this._shadowHighlightHelper.render(r,e),t.render(this._bindParameters,s,e)}get needsShadowCast(){return this._shadowAccumulator.isAccumulating}_accumulateShadows(e,r,t){this.needsShadowCast&&(this._shadowAccumulator.setAccumulationDependencies(this._offscreenRendering.linearDepthTexture,e,r,t),this._shadowAccumulator.accumulateFixedSamples(this._bindParameters))}_renderOrderIndependentTransparency(e,r){const t=t=>{this._bindParameters.transparencyPassType=t,this._offscreenRendering.renderOITPass((()=>e()),t,r)},s=this._renderContext.pass;this._renderContext.pass=V.MATERIAL_ALPHA,t(I.Alpha),this._renderContext.pass=V.MATERIAL,t(I.Color),t(I.FrontFace),this._offscreenRendering.compositeTransparentOntoOpaque(r),this._bindParameters.transparencyPassType=I.NONE,this._renderContext.pass=s,this._oitUsed=!0}_disposeOITBuffers(){this._oitUsed||(this._offscreenRendering.disposeTarget(this._offscreenRendering.alphaFloatTarget),this._offscreenRendering.disposeTarget(this._offscreenRendering.colorFloatTarget),this._offscreenRendering.disposeTarget(this._offscreenRendering.frontFaceTarget)),this._oitUsed=!1}_renderOccluded(){let e=0;this._materialRenderers.forEach(((r,t)=>{t&&t.isVisible()&&t.renderOccluded===q.OccludeAndTransparentStencil&&(e|=t.renderOccluded,pe.push(t))}));const r=this._offscreenRendering,t=(t,s,i,n,a)=>{0!=(e&s)&&(r.renderToTargets(i,r.tmpColor,r.mainDepth,[0,0,0,0],n,a),r.compositeOccludedOntoMain(t))};0!==pe.length&&(this._renderInternalSlot(W.OCCLUDER_MATERIAL,pe),t(.5,q.OccludeAndTransparentStencil,(()=>this._renderInternalSlot(W.TRANSPARENT_OCCLUDER_MATERIAL,pe)),!1,!1),pe.length=0),this._materialRenderers.forEach(((r,t)=>{t&&t.isVisible()&&(t.renderOccluded===q.OccludeAndTransparent||t.renderOccluded===q.Transparent||t.renderOccluded===q.Opaque)&&(e|=t.renderOccluded,_e.push(t))}));const s=this._renderPlugins.renderOccludedFlags;if(e|=s,!e)return;const i=e=>{this._renderContext.renderOccludedMask=e,s>q.Occlude&&this._renderSlot(W.OCCLUDED_TERRAIN),this._renderInternalSlot(W.OPAQUE_MATERIAL,_e),this._renderInternalSlot(W.TRANSPARENT_MATERIAL,_e),this._renderInternalSlot(W.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,_e),this._renderContext.resetRenderOccludedMask()};this._renderContext.pass=V.MATERIAL,t(.5,q.OccludeAndTransparent,(()=>i(q.OccludeAndTransparent)),!0,O.OutlineVisualElementMask),t(.5,q.Transparent,(()=>i(q.Transparent)),!0,O.OutlineVisualElementMask),t(1,q.Opaque,(()=>i(q.Opaque)),!0,O.OutlineVisualElementMask),_e.length=0}_renderAntiAliasing(e,r){if(e===x.SMAA){if(this._smaaPass.enable((()=>this._requestRender()))&&h(r))return this._smaaPass.render(r),!0}else this._smaaPass.disable();return!1}_ensureCameraBindParameters(e){this._bindParameters.camera=e}_ensureBindParameters(e){var r;this._ensureCameraBindParameters(e);const t=this._renderContext.offscreenRenderingHelper;this._bindParameters.hudVisibilityTexture=t.hudVisibilityTexture,this._bindParameters.highlightDepthTexture=null!=(r=t.depthTexture)?r:this._getFallbackDepthTexture()}_ensureBindParametersSSR(){this.hasWaterReflection?(this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=R:(f(me,this._bindParameters.camera.viewMatrix),f(ce,this._bindParameters.camera.projectionMatrix),T(ge,me,ce),T(ge,this._renderContext.lastFrameCamera.viewMatrix,ge),T(ge,this._renderContext.lastFrameCamera.projectionMatrix,ge),this._reprojectionMatrix=ge),this._bindParameters.ssr.lastFrameColorTexture=this._offscreenRendering.lastFrameColorTexture):this._bindParameters.ssr.lastFrameColorTexture=null,this._bindParameters.ssr.enabled=this.hasWaterReflection}_renderInternalSlot(e,r){let t=!1;return this._bindParameters.slot=e,h(r)?r.forEach((e=>{if(!e.shouldRender(this._renderContext))return;const r=this._materialRenderers.get(e);h(r)&&(t=r.render(this._renderContext.pass,this._bindParameters)||t)})):this._materialRenderers.forEach(((e,r)=>{r.shouldRender(this._renderContext)&&e.render(this._renderContext.pass,this._bindParameters)&&(t=!0)})),t}_getFallbackDepthTexture(){return this._fallbackDepthStencilTexture||(this._fallbackDepthStencilTexture=v(this._rctx)),this._fallbackDepthStencilTexture}get gpuMemoryUsage(){var e,r,t,s,i,n,a,h,d,o;return{offscreen:null!=(e=null==(r=this._offscreenRendering)?void 0:r.gpuMemoryUsage)?e:0,highlights:(null!=(t=null==(s=this._highlightHelper)?void 0:s.gpuMemoryUsage)?t:0)+(null!=(i=null==(n=this._shadowHighlightHelper)?void 0:n.gpuMemoryUsage)?i:0),shadows:null!=(a=null==(h=this._shadowMap)?void 0:h.gpuMemoryUsage)?a:0,ssao:null!=(d=null==(o=this._ssaoHelper)?void 0:o.gpuMemoryUsage)?d:0}}get test(){const e=this;return{offscreen:this._offscreenRendering,shadowMap:this._shadowMap,ssao:this._ssaoHelper,highlight:this._highlightHelper,lighting:this._bindParameters.lighting,materialRenderers:this._materialRenderers,shadowAccumulator:this._shadowAccumulator,getFramebufferTexture:r=>{var t;switch(r){case le.Color:return e._offscreenRendering.colorTexture;case le.LinearDepth:return e._offscreenRendering.linearDepthTexture;case le.Normals:return e._offscreenRendering.normalTexture;case le.ShadowMap:return null==(t=e._shadowMap)?void 0:t.test.depthTexture;case le.HudVisibility:return e._offscreenRendering.hudVisibilityTexture;case le.Highlight:return e._offscreenRendering.highlightTexture}}}}};var le;e([m()],oe.prototype,"_shadowAccumulator",void 0),e([m()],oe.prototype,"_smaaPass",void 0),e([m()],oe.prototype,"_antialiasing",void 0),e([m()],oe.prototype,"_edgeView",void 0),e([m()],oe.prototype,"updating",null),e([m()],oe.prototype,"isCameraFinal",null),oe=e([g("esri.views.3d.webgl-engine.lib.Renderer")],oe),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.Normals=2]="Normals",e[e.ShadowMap=3]="ShadowMap",e[e.HudVisibility=4]="HudVisibility",e[e.Highlight=5]="Highlight"}(le||(le={}));const _e=[],pe=[],ce=A(),me=A(),ge=A();export{le as FramebufferId,oe as Renderer};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{update as t}from"../../../../core/arrayUtils.js";import s from"../../../../core/Handles.js";import{someMap as i}from"../../../../core/MapUtils.js";import{destroyMaybe as n,disposeMaybe as a,isSome as h,isNone as d,unwrap as o}from"../../../../core/maybe.js";import{watch as l,syncAndInitial as _,initial as p}from"../../../../core/reactiveUtils.js";import{Milliseconds as c}from"../../../../core/time.js";import{property as m}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as g}from"../../../../core/accessorSupport/decorators/subclass.js";import{v as u,a as f,m as T}from"../../../../chunks/mat4.js";import{I as R,c as A}from"../../../../chunks/mat4f64.js";import{c as E}from"../../../../chunks/boundedPlane.js";import{MAXIMUM_ANIMATION_LOAD as P,MINIMUM_IDLE_ANIMATION_MS as b}from"../../support/animationUtils.js";import S from"../../support/debugFlags.js";import{RenderPassManager as H}from"../core/renderPasses/RenderPassManager.js";import{HUDTransparentRenderStyle as w}from"../core/shaderLibrary/hud/HUDUniforms.js";import{AntiAliasingMode as x,TransparencyPassType as I,Decorations as M,RenderRequestType as L,StencilBits as O}from"./basicInterfaces.js";import{BoundingInfo as D}from"./BoundingInfo.js";import{ZERO as C,union as y}from"./depthRange.js";import{depthRangeFromScene as N}from"./depthRangeUtils.js";import{createEmptyDepthTexture as v}from"./glUtil3D.js";import U from"./HighlightHelper.js";import{RenderOccludedFlag as F}from"./Material.js";import{OffscreenRendering as j}from"./OffscreenRendering.js";import{RenderContext as q}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as G}from"./rendererUtils.js";import{RenderPass as V}from"./RenderPass.js";import{RenderPluginManager as B}from"./RenderPluginManager.js";import{RenderSlot as W}from"./RenderSlot.js";import{ShadowAccumulator as k}from"./ShadowAccumulator.js";import{ShadowHighlightHelper as Q}from"./ShadowHighlightHelper.js";import z from"./ShadowMap.js";import X from"./SliceHelper.js";import{SmaaRenderPass as Y}from"./SmaaRenderPass.js";import{SSAOHelper as K}from"./SSAOHelper.js";import{EdgeView as J}from"./edgeRendering/EdgeView.js";import{Transparency as Z}from"./edgeRendering/interfaces.js";import{MergedRenderer as $}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as ee}from"../shaders/CompositingTechniqueConfiguration.js";import{HighlightShadowMapSlot as re,DefaultSnapshotSlot as te}from"../shaders/ShadowHighlightTechnique.js";import{RendererPerformanceInfo as se,Statistics as ie}from"../statistics/RendererPerformanceInfo.js";import{ClearBufferBit as ne,PixelFormat as ae,PixelType as he}from"../../../webgl/enums.js";const de=.9;let oe=class extends r{constructor(e,r,t,i,n,a,h,d,o){super({}),this._materialRepository=e,this._shaderTechniqueRepository=t,this._rctx=i,this._compositingHelper=n,this._magnifierHelper=a,this._requestRender=h,this._stage=o,this._materialRenderers=new Map,this._needsTransparentPass=!1,this._hasHUDElements=!1,this._hasHighlights=!1,this._hasWater=!1,this._hasOverlayWater=!1,this._content=new Map,this._isRendering=!1,this._fallbackDepthStencilTexture=null,this.performanceInfo=new se,this._antialiasing=x.SMAA,this._oitEnabled=!1,this._multipassTerrain=!0,this._transparentTerrain=!1,this._hasAnimations=!1,this._animationTimestep=c(0),this._handles=new s,this._renderHiddenTransparentEdges=()=>{},this._oitUsed=!1,this._smaaPass=new Y(this._rctx,t),this._oitEnabled=this._hasOITSupport,this._requestRender(),this._offscreenRendering=new j(this._rctx,this._compositingHelper),this._sliceHelper=new X,this._shadowMap=new z(this._rctx,o.viewingMode,2),this._ssaoHelper=new K(t,this._rctx,(()=>this._requestRender())),this._highlightHelper=new U(t,this._rctx),this._shadowHighlightHelper=new Q(this._rctx,o.viewingMode),this._shadowAccumulator=new k(this._rctx,t,o,((e,r)=>{const t=this.hasShadowsEnabled;return this._shadowMap.enabled=!0,this._renderPlugins.prepareRender(e,r),this._shadowMap.enabled=t,this._bindParameters}),((e,r,t,s)=>{e.start(t,r,s),this._renderShadowCascades(V.MATERIAL_DEPTH_SHADOWMAP_ALL,e),t.setGLViewport(this._rctx),this._ensureCameraBindParameters(t)}),(()=>this._requestRender())),this._renderContext=new q(this._rctx,this._offscreenRendering,this._shadowMap,this._ssaoHelper,this._sliceHelper),this._renderPlugins=new B({renderContext:this._renderContext,shaderTechniqueRepository:t,textureRep:r,materialRep:this._materialRepository,requestRender:this._requestRender,schedule:d}),this.renderPassManager=new H(this._rctx,this._shaderTechniqueRepository),this._renderPlugins.add(this.renderPassManager.slots(),this.renderPassManager),this._handles.add([l((()=>this._stage.state.camera),(()=>this._requestRender()),_),l((()=>S.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(Z.TRANSPARENT):()=>{},this._requestRender()}),p)])}get _bindParameters(){return this._renderContext.bindParameters}get hasWater(){return this._hasWater||this._hasOverlayWater}get hasWaterReflection(){return this.hasWater&&this._waterReflectionEnabled}normalizeCtorArgs(){return{}}dispose(){this._handles.destroy(),this._smaaPass.dispose(),this._materialRenderers.forEach((e=>e.dispose())),this._materialRenderers.clear(),this._edgeView=n(this._edgeView),this._offscreenRendering.dispose(),this._fallbackDepthStencilTexture=a(this._fallbackDepthStencilTexture),this._shadowMap.enabled=!1,this._shadowMap.dispose(),this._ssaoHelper.enabled=!1,this._ssaoHelper.dispose(),this._highlightHelper.dispose(),this._shadowHighlightHelper.dispose(),this._shadowAccumulator.dispose(),D.prune(),this._content.clear()}disposeOffscreenBuffers(){this._offscreenRendering.dispose(),this._shadowMap.dispose(),this._smaaPass.disable(),this._ssaoHelper.disposeOffscreenBuffers()}get updating(){return this._antialiasing===x.SMAA&&this._smaaPass.updating||h(this._edgeView)&&this._edgeView.updating||this._shadowAccumulator.running||!this.isCameraFinal}ensureEdgeView(){return d(this._edgeView)&&(this._edgeView=new J({rctx:this._rctx,renderSR:this._stage.renderSR,techniqueRepository:this._shaderTechniqueRepository,setNeedsRender:()=>this._requestRender(),schedule:e=>this._stage.resourceController.schedule(e)}),this._handles.add(this._edgeView.watch("updating",(()=>this._requestRender()),!0)),this._requestRender()),this._edgeView}get edgeView(){return this._edgeView}get isCameraFinal(){return u(this._bindParameters.ssr.reprojectionMatrix,R)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this.notifyChange("isCameraFinal")}get hasShadowsEnabled(){var e;return!(null==(e=this._shadowMap)||!e.enabled)}setRenderParameters(e){const{_shadowMap:r,_ssaoHelper:t,_bindParameters:s}=this;void 0!==e.screenSpaceReflectionsEnabled&&s.ssr.enabled!==e.screenSpaceReflectionsEnabled&&(s.ssr.enabled=e.screenSpaceReflectionsEnabled,this._requestRender()),void 0!==e.enableFillLights&&s.enableFillLights!==e.enableFillLights&&(s.enableFillLights=e.enableFillLights,this._requestRender()),void 0!==e.shadowMap&&r.enabled!==e.shadowMap&&(r.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&r.maxCascades!==e.shadowMapMaxCascades&&(r.maxCascades=e.shadowMapMaxCascades,this._requestRender()),void 0!==e.ssao&&t.enabled!==e.ssao&&(t.enabled=e.ssao,this._requestRender()),e.background&&this._offscreenRendering.background!==e.background&&(this._offscreenRendering.background=e.background,this._requestRender());const i=e.antialiasingEnabled?x.SMAA:x.NONE;void 0!==e.antialiasingEnabled&&this._antialiasing!==i&&(this._antialiasing=i,this._requestRender()),void 0!==e.highQualityTransparency&&this._multipassTerrain!==e.highQualityTransparency&&(this._multipassTerrain=e.highQualityTransparency,this._oitEnabled=e.highQualityTransparency&&this._hasOITSupport,this._requestRender()),void 0!==e.defaultHighlightOptions&&(this._highlightHelper.setDefaultOptions(e.defaultHighlightOptions),this._shadowHighlightHelper.setDefaultOptions(e.defaultHighlightOptions),this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=o(e.slicePlane),this._requestRender()),void 0!==e.waterReflectionEnabled&&this._waterReflectionEnabled!==e.waterReflectionEnabled&&(this._waterReflectionEnabled=e.waterReflectionEnabled,this._requestRender()),void 0!==e.enableFillLights&&s.enableFillLights!==e.enableFillLights&&(s.enableFillLights=e.enableFillLights,this._requestRender()),void 0!==e.transparentTerrain&&this._transparentTerrain!==e.transparentTerrain&&(this._transparentTerrain=e.transparentTerrain,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.shadowCastOptions&&this._shadowAccumulator.setOptions(e.shadowCastOptions)}get hasSlicePlane(){return!!this._sliceHelper.plane}get renderPlugins(){return this._renderPlugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlendWorking}modify(e){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:r,removes:t,updates:s}=e;if(0===r.length&&0===t.length&&0===s.length)return;t.forAll((({id:e})=>this._content.delete(e))),r.forAll((e=>this._content.set(e.id,e)));const n=G(e);let a=!1;n.forEach(((e,r)=>{let t=this._materialRenderers.get(r);if(!t){if(!(e.adds.length>0))return;t=new $(this._rctx,this._materialRepository,r),this._materialRenderers.set(r,t)}t.modify(e),t.isEmpty&&(a=!0)})),a&&this._materialRenderers.forEach(((e,r)=>{e.isEmpty&&(this._materialRenderers.delete(r),e.dispose())})),this._hasHighlights=i(this._materialRenderers,(e=>e.hasHighlights)),this._bindParameters.hasOccludees=i(this._materialRenderers,(e=>e.hasOccludees)),this._hasWater=i(this._materialRenderers,(e=>e.hasWater)),this._needsTransparentPass=i(this._materialRenderers,(e=>e.requiresSlot(W.TRANSPARENT_MATERIAL,V.MATERIAL))),this._hasHUDElements=i(this._materialRenderers,(e=>e.requiresSlot(W.LINE_CALLOUTS_HUD_DEPTH,V.MATERIAL)||e.requiresSlot(W.HUD_MATERIAL,V.MATERIAL)||e.requiresSlot(W.LABEL_MATERIAL,V.MATERIAL))),this._requestRender()}updateAnimation(e){return this._hasAnimations=!1,this._materialRenderers.forEach((r=>this._hasAnimations=r.updateAnimation(e)||this._hasAnimations)),this._hasAnimations=this._renderPlugins.updateAnimation(e)||this._hasAnimations,this._hasAnimations}get animationTimestep(){return this._animationTimestep}updateLightSources(e,r,t){this._bindParameters.lighting.groundLightingFactor=r,this._bindParameters.lighting.globalFactor=t,this._bindParameters.lighting.set(e)}render(e,r,t,s){this._isRendering=!0,this.performanceInfo.prerender(this._rctx),this._bindParameters.transparencyPassType=I.NONE;const i=this._offscreenRendering;i.needLastFrameColorTexture=this.hasWaterReflection,i.advanceCurrentRenderTarget();const n=E(this._sliceHelper.plane);s===M.OFF&&(this._sliceHelper.plane=null),this._rctx.bindFramebuffer(e),r.setGLViewport(this._rctx),this._renderPlugins.prepareRender(r,t),this.performanceInfo.advance(ie.Prepare);const a=this._computeDepthRange(r);this._renderShadowMap(e,r,this._bindParameters.lighting.lightingMainDirection,a),this.performanceInfo.advance(ie.Shadowmap),i.initializeFrame(r),this._ensureBindParameters(r),this._renderLinearDepth(),this.performanceInfo.advance(ie.Lineardepth),this._accumulateShadows(a,r,t),this._renderNormal(),this.performanceInfo.advance(ie.Normals),this._ensureBindParametersSSR(),this._ssaoHelper.computeSSAO(this._bindParameters,i.linearDepthTexture,i.normalTexture),this.performanceInfo.advance(ie.SSAO),this._renderContext.pass=V.MATERIAL,i.bindFramebuffer(),this._renderOpaqueGeometry(),this.performanceInfo.advance(ie.Opaque);const o=this._multipassTerrain&&this._transparentTerrain;this._renderTerrainLinearDepth(o),this._setMultipassEnabled(o),this._setTerrainCulling(o),this._renderEdges(Z.OPAQUE),this.performanceInfo.advance(ie.OpaqueEdges),this._renderHiddenTransparentEdges();const l=this._needsTransparentPass||this._renderPlugins.needsTransparentPass;l&&(this._oitEnabled?this._renderOrderIndependentTransparency((()=>this._renderTransparentGeometry()),!1):this._renderTransparentGeometry()),this.performanceInfo.advance(ie.Transparent),this._renderGeometryLinearDepth(o);const _=this._renderHUDVisibility();o||this._renderInternalSlot(W.LINE_CALLOUTS),this.performanceInfo.advance(ie.Hudvisibility),this._renderEdges(Z.TRANSPARENT,o),this.performanceInfo.advance(ie.TransparentEdges),this._renderSlot(W.VOXEL),this._renderTransparentTerrain(),this._transparentTerrain&&_&&(o?this._renderLineCallouts(w.Occluded):i.compositeTransparentTerrainOntoHUDVisibility(),this._renderHUD(w.Occluded,i.framebuffer),this.performanceInfo.advance(ie.HudOccluded)),this.performanceInfo.advance(ie.TransparentTerrain),this._setTerrainCulling(!1),this._transparentTerrain&&(i.compositeTransparentTerrainOntoMain(),o&&(this._renderEdges(Z.OPAQUE),this.performanceInfo.advance(ie.OpaqueEdges),l&&(this._oitEnabled?this._renderOrderIndependentTransparency((()=>this._renderTransparentGeometry()),!1):this._renderTransparentGeometry()),this.performanceInfo.advance(ie.Transparent),this._renderEdges(Z.TRANSPARENT),this.performanceInfo.advance(ie.TransparentEdges))),o&&this._renderLineCallouts(w.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),i.renderToTargets((()=>{this._renderInternalSlot(W.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderSlot(W.POSTPROCESSING_ENVIRONMENT_TRANSPARENT),this._renderSlot(W.LASERLINES)}),i.currentColorTarget,i.mainDepth),this.performanceInfo.advance(ie.Atmosphere),this._renderPlugins.needsLaserlineWithContrastControl&&i.renderTmpAndCompositeToMain((()=>this._renderSlot(W.LASERLINES_CONTRAST_CONTROL)),ee.PremultipliedAlpha),this.performanceInfo.advance(ie.Laserline),this._renderOccluded(),this.performanceInfo.advance(ie.Occluded);const p=s===M.ON&&this._magnifierHelper.enabled,c=p&&d(e)?this._offscreenRendering.getFramebuffer(this._offscreenRendering.tmpColor,this._offscreenRendering.tmpDepth):e;this._rctx.bindFramebuffer(c);const m=this._offscreenRendering.colorTexture;!this._renderAntiAliasing(this._antialiasing,m)&&h(m)&&this._compositingHelper.composite(m,ee.None),this.performanceInfo.advance(ie.Antialiasing),this._renderHUD(w.NotOccluded,c),this.performanceInfo.advance(ie.HudNotoccluded),this._renderHighlights(c,this._bindParameters),this.performanceInfo.advance(ie.Highlights),p&&this._magnifierHelper.render(this._rctx,this._bindParameters),c!==e&&(this._rctx.bindFramebuffer(e),this._compositingHelper.composite(this._offscreenRendering.tmpColorTexture,ee.None)),this._disposeOITBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=n,this._isRendering=!1,this.onPostRender&&this.onPostRender(),this.performanceInfo.postrender()}finish(e){if(this._hasAnimations||(this._animationTimestep=c(0)),e===L.BACKGROUND){this._rctx.gl.getError();const e=this.performanceInfo.elapsedTime/P;this._animationTimestep=c(Math.max(this._animationTimestep*de+e*(1-de),b))}}readDepthPixels(e,r,t,s,i,n){const a=this._offscreenRendering.bindTarget(this._offscreenRendering.linearDepth,this._offscreenRendering.tmpDepth);if(!this._needsLinearDepth){this._ensureBindParameters(e),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.setClearColor(0,0,0,0);const r=ne.COLOR_BUFFER_BIT|ne.DEPTH_BUFFER_BIT|ne.STENCIL_BUFFER_BIT;this._rctx.clearSafe(r),this._renderGeometryAndTransparentTerrainPass(V.MATERIAL_DEPTH)}a.readPixels(r,t,s,i,ae.RGBA,he.UNSIGNED_BYTE,n)}readHUDVisibility(e,r,t,s,i){this._offscreenRendering.bindTarget(this._offscreenRendering.hudVisibility).readPixels(e,r,t,s,ae.RGBA,he.UNSIGNED_BYTE,i)}readAccumulatedShadow(e,r){return this._shadowAccumulator.readAccumulatedShadow(e,r)}_setMultipassEnabled(e){this._bindParameters.multipassTerrain.enabled=this._bindParameters.multipassGeometry.enabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_renderSlot(e){this._bindParameters.slot=e,this._renderPlugins.render()}_renderEdges(e,r=!1){const t=this._edgeView;h(t)&&t.shouldRender()&&this._offscreenRendering.renderTmpAndCompositeToMain((()=>t.render(this._bindParameters,e)),ee.Alpha,r)}_renderShadowMap(e,r,t,s){const i=this._shadowMap;i.enabled&&(i.start(r,t,s),this._shadowHighlightHelper.updateParameters(r,t),this.needsShadowHighlight?(this._renderShadowCascades(V.MATERIAL_DEPTH_SHADOWMAP_HIGHLIGHT,this._shadowMap,(e=>i.takeCascadeSnapshotTo(e,re))),i.clear(),this._renderShadowCascades(V.MATERIAL_DEPTH_SHADOWMAP_DEFAULT,this._shadowMap,(e=>{i.takeCascadeSnapshotTo(e,te),this._renderGeometryAndTransparentTerrainPass(V.MATERIAL_DEPTH_SHADOWMAP_HIGHLIGHT)}))):this._renderShadowCascades(V.MATERIAL_DEPTH_SHADOWMAP_ALL),i.finish(e),r.setGLViewport(this._rctx))}_renderShadowCascades(e,r=this._shadowMap,t=(e=>{})){for(const s of r.getCascades())s.camera.setGLViewport(this._rctx),this._ensureCameraBindParameters(s.camera),this._renderGeometryAndTransparentTerrainPass(e),t(s)}get _needsLinearDepth(){return this._ssaoHelper.enabled||this._renderPlugins.needsLinearDepth||this._hasWater&&this._waterReflectionEnabled||this.needsShadowHighlight||this.needsShadowCast}_renderLinearDepth(){this._needsLinearDepth?this._offscreenRendering.renderToTargets((()=>this._renderGeometryAndTransparentTerrainPass(V.MATERIAL_DEPTH)),this._offscreenRendering.linearDepth,this._offscreenRendering.tmpDepth,[0,0,0,0],!0,!0):this._offscreenRendering.disposeTarget(this._offscreenRendering.linearDepth),this._bindParameters.ssr.linearDepthTexture=this._offscreenRendering.linearDepthTexture}_renderTerrainLinearDepth(e){if(e){const e=this._renderContext.pass;this._renderContext.pass=V.MATERIAL_DEPTH,this._offscreenRendering.renderToTargets((()=>this._renderTransparentTerrain()),this._offscreenRendering.terrainLinearDepth,this._offscreenRendering.tmpDepth,[-1e10,-1e10,-1e10,1],!0,!0),this._renderContext.pass=e}else this._offscreenRendering.disposeTarget(this._offscreenRendering.terrainLinearDepth);this._bindParameters.multipassTerrain.linearDepthTexture=this._offscreenRendering.terrainLinearDepthTexture}_renderGeometryLinearDepth(e){if(e){const e=this._renderContext.pass;this._offscreenRendering.renderToTargets((()=>this._renderGeometryPass(V.MATERIAL_DEPTH)),this._offscreenRendering.geometryLinearDepth,this._offscreenRendering.tmpDepth,[1,1,1,1],!0,!0),this._renderContext.pass=e}else this._offscreenRendering.disposeTarget(this._offscreenRendering.geometryLinearDepth);this._bindParameters.multipassGeometry.linearDepthTexture=this._offscreenRendering.geometryLinearDepthTexture}get needsNormal(){return this._ssaoHelper.enabled}_renderNormal(){this.needsNormal?this._offscreenRendering.renderToTargets((()=>{this._renderGeometryAndTransparentTerrainPass(V.MATERIAL_NORMAL)}),this._offscreenRendering.normal,this._offscreenRendering.tmpDepth,[0,0,0,0],!0,!0):this._offscreenRendering.disposeTarget(this._offscreenRendering.normal)}get needsDepthRange(){return this._shadowMap.enabled||this.needsShadowCast}_computeDepthRange(e){if(!this.needsDepthRange)return C;const r=N(e,this._content,this._stage.layers);return y(r,this.renderPlugins.queryDepthRange(e)),r.near=Math.max(e.near,r.near),r.far=Math.min(e.far,r.far),r}_renderGeometryAndTransparentTerrainPass(e){this._renderContext.pass=e,this._renderGeometryPass(e),this._renderTransparentTerrain()}_renderGeometryPass(e){this._renderContext.pass=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderOpaqueGeometry(){this._renderSlot(W.INTEGRATED_MESH),this._renderSlot(W.OPAQUE_TERRAIN),this._renderInternalSlot(W.OPAQUE_MATERIAL),this._renderSlot(W.OPAQUE_MATERIAL),this._renderSlot(W.POSTPROCESSING_ENVIRONMENT_OPAQUE)}_renderTransparentGeometry(){this._renderInternalSlot(W.TRANSPARENT_MATERIAL),this._renderSlot(W.TRANSPARENT_MATERIAL)}_renderTransparentTerrain(){this._renderSlot(W.TRANSPARENT_TERRAIN)}_renderHUDVisibility(){let e=!1;return this._renderContext.offscreenRenderingHelper&&this._renderContext.offscreenRenderingHelper.renderHUDVisibility((()=>{this._bindParameters.hudVisibilityTexture=this._renderContext.offscreenRenderingHelper.hudVisibilityTexture,e=this._renderInternalSlot(W.OCCLUSION_PIXELS)}),this._multipassTerrain&&this._transparentTerrain),e}_renderLineCallouts(e){this._bindParameters.renderTransparentlyOccludedHUD=e,e===w.Occluded?this._offscreenRendering.renderToTargets((()=>this._renderInternalSlot(W.LINE_CALLOUTS)),this._offscreenRendering.currentColorTarget,this._offscreenRendering.tmpDepth,void 0,!0,!0):this._renderInternalSlot(W.LINE_CALLOUTS)}_renderHUD(e,r){this._hasHUDElements&&(this._oitEnabled?(this._renderOrderIndependentTransparency((()=>this._renderHUDElements(e)),!0),this._rctx.bindFramebuffer(r),this._compositingHelper.composite(this._offscreenRendering.hudColorTexture,ee.PremultipliedAlpha)):e===w.Occluded?this._offscreenRendering.renderToTargets((()=>this._renderHUDElements(w.Occluded)),this._offscreenRendering.currentColorTarget,this._offscreenRendering.tmpDepth,void 0,!0,!0):this._renderHUDElements(e))}_renderHUDElements(e){this._bindParameters.renderTransparentlyOccludedHUD=e,this._renderInternalSlot(W.LINE_CALLOUTS_HUD_DEPTH),this._renderInternalSlot(W.HUD_MATERIAL),this._renderInternalSlot(W.LABEL_MATERIAL)}get needsHighlight(){return this._hasHighlights||this._renderPlugins.needsHighlight}get needsShadowHighlight(){return this._shadowMap.enabled&&this._shadowHighlightHelper.isVisible&&this.needsHighlight}_renderHighlights(e,r){if(!this.needsHighlight)return void this._offscreenRendering.disposeTarget(this._offscreenRendering.highlight);const t=this._highlightHelper,s=this._offscreenRendering.renderToTargets((()=>{this._renderGeometryAndTransparentTerrainPass(V.MATERIAL_HIGHLIGHT),this._rctx.clearSafe(ne.DEPTH_BUFFER_BIT),this._renderHUDElements(w.Both)}),this._offscreenRendering.highlight,this._offscreenRendering.tmpDepth,[0,0,0,0],!0,!0);this._bindParameters.highlightColorTexture=s.colorTexture,this.needsShadowHighlight&&this._shadowHighlightHelper.render(r,e),t.render(this._bindParameters,s,e)}get needsShadowCast(){return this._shadowAccumulator.isAccumulating}_accumulateShadows(e,r,t){this.needsShadowCast&&(this._shadowAccumulator.setAccumulationDependencies(this._offscreenRendering.linearDepthTexture,e,r,t),this._shadowAccumulator.accumulateFixedSamples(this._bindParameters))}_renderOrderIndependentTransparency(e,r){const t=t=>{this._bindParameters.transparencyPassType=t,this._offscreenRendering.renderOITPass((()=>e()),t,r)},s=this._renderContext.pass;this._renderContext.pass=V.MATERIAL_ALPHA,t(I.Alpha),this._renderContext.pass=V.MATERIAL,t(I.Color),t(I.FrontFace),this._offscreenRendering.compositeTransparentOntoOpaque(r),this._bindParameters.transparencyPassType=I.NONE,this._renderContext.pass=s,this._oitUsed=!0}_disposeOITBuffers(){this._oitUsed||(this._offscreenRendering.disposeTarget(this._offscreenRendering.alphaFloatTarget),this._offscreenRendering.disposeTarget(this._offscreenRendering.colorFloatTarget),this._offscreenRendering.disposeTarget(this._offscreenRendering.frontFaceTarget)),this._oitUsed=!1}_renderOccluded(){let e=0;this._materialRenderers.forEach(((r,t)=>{t&&t.isVisible()&&t.renderOccluded===F.OccludeAndTransparentStencil&&(e|=t.renderOccluded,pe.push(t))}));const r=this._offscreenRendering,t=(t,s,i,n,a)=>{0!=(e&s)&&(r.renderToTargets(i,r.tmpColor,r.mainDepth,[0,0,0,0],n,a),r.compositeOccludedOntoMain(t))};0!==pe.length&&(this._renderInternalSlot(W.OCCLUDER_MATERIAL,pe),t(.5,F.OccludeAndTransparentStencil,(()=>this._renderInternalSlot(W.TRANSPARENT_OCCLUDER_MATERIAL,pe)),!1,!1),pe.length=0),this._materialRenderers.forEach(((r,t)=>{t&&t.isVisible()&&(t.renderOccluded===F.OccludeAndTransparent||t.renderOccluded===F.Transparent||t.renderOccluded===F.Opaque)&&(e|=t.renderOccluded,_e.push(t))}));const s=this._renderPlugins.renderOccludedFlags;if(e|=s,!e)return;const i=e=>{this._renderContext.renderOccludedMask=e,s>F.Occlude&&this._renderSlot(W.OCCLUDED_TERRAIN),this._renderInternalSlot(W.OPAQUE_MATERIAL,_e),this._renderInternalSlot(W.TRANSPARENT_MATERIAL,_e),this._renderInternalSlot(W.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,_e),this._renderContext.resetRenderOccludedMask()};this._renderContext.pass=V.MATERIAL,t(.5,F.OccludeAndTransparent,(()=>i(F.OccludeAndTransparent)),!0,O.OutlineVisualElementMask),t(.5,F.Transparent,(()=>i(F.Transparent)),!0,O.OutlineVisualElementMask),t(1,F.Opaque,(()=>i(F.Opaque)),!0,O.OutlineVisualElementMask),_e.length=0}_renderAntiAliasing(e,r){if(e===x.SMAA){if(this._smaaPass.enable((()=>this._requestRender()))&&h(r))return this._smaaPass.render(r),!0}else this._smaaPass.disable();return!1}_ensureCameraBindParameters(e){this._bindParameters.camera=e}_ensureBindParameters(e){var r;this._ensureCameraBindParameters(e);const t=this._renderContext.offscreenRenderingHelper;this._bindParameters.hudVisibilityTexture=t.hudVisibilityTexture,this._bindParameters.highlightDepthTexture=null!=(r=t.depthTexture)?r:this._getFallbackDepthTexture()}_ensureBindParametersSSR(){this.hasWaterReflection?(this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=R:(f(me,this._bindParameters.camera.viewMatrix),f(ce,this._bindParameters.camera.projectionMatrix),T(ge,me,ce),T(ge,this._renderContext.lastFrameCamera.viewMatrix,ge),T(ge,this._renderContext.lastFrameCamera.projectionMatrix,ge),this._reprojectionMatrix=ge),this._bindParameters.ssr.lastFrameColorTexture=this._offscreenRendering.lastFrameColorTexture):this._bindParameters.ssr.lastFrameColorTexture=null,this._bindParameters.ssr.enabled=this.hasWaterReflection}_renderInternalSlot(e,r){let t=!1;return this._bindParameters.slot=e,h(r)?r.forEach((e=>{if(!e.shouldRender(this._renderContext))return;const r=this._materialRenderers.get(e);h(r)&&(t=r.render(this._renderContext.pass,this._bindParameters)||t)})):this._materialRenderers.forEach(((e,r)=>{r.shouldRender(this._renderContext)&&e.render(this._renderContext.pass,this._bindParameters)&&(t=!0)})),t}_getFallbackDepthTexture(){return this._fallbackDepthStencilTexture||(this._fallbackDepthStencilTexture=v(this._rctx)),this._fallbackDepthStencilTexture}get gpuMemoryUsage(){var e,r,t,s,i,n,a,h,d,o;return{offscreen:null!=(e=null==(r=this._offscreenRendering)?void 0:r.gpuMemoryUsage)?e:0,highlights:(null!=(t=null==(s=this._highlightHelper)?void 0:s.gpuMemoryUsage)?t:0)+(null!=(i=null==(n=this._shadowHighlightHelper)?void 0:n.gpuMemoryUsage)?i:0),shadows:null!=(a=null==(h=this._shadowMap)?void 0:h.gpuMemoryUsage)?a:0,ssao:null!=(d=null==(o=this._ssaoHelper)?void 0:o.gpuMemoryUsage)?d:0}}get test(){const e=this;return{offscreen:this._offscreenRendering,shadowMap:this._shadowMap,ssao:this._ssaoHelper,highlight:this._highlightHelper,lighting:this._bindParameters.lighting,materialRenderers:this._materialRenderers,shadowAccumulator:this._shadowAccumulator,getFramebufferTexture:r=>{var t;switch(r){case le.Color:return e._offscreenRendering.colorTexture;case le.LinearDepth:return e._offscreenRendering.linearDepthTexture;case le.Normals:return e._offscreenRendering.normalTexture;case le.ShadowMap:return null==(t=e._shadowMap)?void 0:t.test.depthTexture;case le.HudVisibility:return e._offscreenRendering.hudVisibilityTexture;case le.Highlight:return e._offscreenRendering.highlightTexture}}}}};var le;e([m()],oe.prototype,"_shadowAccumulator",void 0),e([m()],oe.prototype,"_smaaPass",void 0),e([m()],oe.prototype,"_antialiasing",void 0),e([m()],oe.prototype,"_edgeView",void 0),e([m()],oe.prototype,"updating",null),e([m()],oe.prototype,"isCameraFinal",null),oe=e([g("esri.views.3d.webgl-engine.lib.Renderer")],oe),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.Normals=2]="Normals",e[e.ShadowMap=3]="ShadowMap",e[e.HudVisibility=4]="HudVisibility",e[e.Highlight=5]="Highlight"}(le||(le={}));const _e=[],pe=[],ce=A(),me=A(),ge=A();export{le as FramebufferId,oe as Renderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../Camera.js";import"../geometry.js";import i from"../Graphic.js";import r from"../Ground.js";import s from"../Viewpoint.js";import n from"../core/Collection.js";import{byId as a}from"../core/domUtils.js";import o from"../core/Error.js";import{on as l}from"../core/events.js";import{handlesGroup as p,makeHandle as h}from"../core/handleUtils.js";import d from"../core/has.js";import{isIterable as c}from"../core/iteratorUtils.js";import u from"../core/Logger.js";import{destroyMaybe as g,isNone as m,isSome as f,unwrapOr as y}from"../core/maybe.js";import{ObservableChangesType as w}from"../core/ObservableChangesType.js";import{throwIfAborted as v}from"../core/promiseUtils.js";import{on as _,initial as b,syncAndInitial as M,whenOnce as S,watch as R}from"../core/reactiveUtils.js";import{setFrameDuration as V}from"../core/scheduling.js";import{screenPointObjectToArray as C,createScreenPoint as T,createScreenPointArray as O}from"../core/screenUtils.js";import{initialize as x}from"../core/workers/workers.js";import{property as E}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import{cast as j}from"../core/accessorSupport/decorators/cast.js";import{subclass as I}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as P}from"../core/accessorSupport/ensureType.js";import{c as G}from"../chunks/vec3f64.js";import{owningCollectionProperty as L}from"../core/support/OwningCollection.js";import H from"../geometry/HeightModelInfo.js";import{canProjectWithoutEngine as U,project as A,projectPointToVector as D,projectVectorToVector as F,projectBoundingRect as W}from"../geometry/projection.js";import{create as q,toExtent as z}from"../geometry/support/aaBoundingRect.js";import{B as k,a as N}from"../chunks/boundedPlane.js";import{renderSRFromViewSR as B}from"../geometry/support/coordinateSystem.js";import{getResolutionForScale as Q}from"../geometry/support/scaleUtils.js";import $ from"../layers/VoxelWasmManager.js";import{isImageryTileLayer as X,isTiledLayer as K,isVoxelLayer as Z}from"../layers/support/layerUtils.js";import{AnalysesCollection as J}from"../support/AnalysesCollection.js";import{BreakpointsOwner as Y}from"./BreakpointsOwner.js";import{DOMContainer as ee}from"./DOMContainer.js";import te from"./GroundView.js";import{PopupView as ie}from"./PopupView.js";import re from"./View.js";import se from"./ViewAnimation.js";import{ViewingMode as ne,stringFromViewingMode as ae,viewingModeFromString as oe}from"./ViewingMode.js";import{layerView3DImporter as le}from"./3d/layerViewModuleImportUtils.js";import pe from"./3d/analysis/AnalysisViewManager3D.js";import{Constraints as he}from"./3d/constraints/Constraints.js";import de from"./3d/environment/SceneViewEnvironment.js";import{SceneViewEnvironmentManager as ce}from"./3d/environment/SceneViewEnvironmentManager.js";import ue from"./3d/input/SceneInputManager.js";import{GraphicsDeconflictor as ge}from"./3d/layers/graphics/GraphicsDeconflictor.js";import{Labeler as me}from"./3d/layers/graphics/Labeler.js";import{ObjectResourceCache as fe}from"./3d/layers/graphics/ObjectResourceCache.js";import{FeatureTileTree3D as ye}from"./3d/layers/support/FeatureTileTree3D.js";import we from"./3d/state/ViewState.js";import ve from"./3d/state/ViewStateManager.js";import{SceneIntersectionHelper as _e}from"./3d/state/helpers/SceneIntersectionHelper.js";import{CombinedElevationProvider as be}from"./3d/support/CombinedElevationProvider.js";import Me from"./3d/support/debugFlags.js";import Se from"./3d/support/DisplayQualityProfile.js";import{getElevationAtPoint as Re}from"./3d/support/ElevationProvider.js";import Ve from"./3d/support/HighlightOptions.js";import{MapCoordsHelper as Ce}from"./3d/support/MapCoordsHelper.js";import{PropertiesPool as Te}from"./3d/support/PropertiesPool.js";import Oe from"./3d/support/QualitySettings.js";import{RenderCoordsHelper as xe}from"./3d/support/RenderCoordsHelper.js";import{newResourceController as Ee}from"./3d/support/ResourceController.js";import je from"./3d/support/SceneViewPerformanceInfo.js";import{SharedSymbolResources as Ie}from"./3d/support/SharedSymbolResources.js";import{PointsOfInterest as Pe}from"./3d/support/pointsOfInterest/PointsOfInterest.js";import Ge from"./3d/terrain/TerrainSurface.js";import{isSurfaceLayerView as Le,getTiledLayerInfo as He,checkIfTileInfoSupportedForView as Ue}from"./3d/terrain/terrainUtils.js";import{Stage as Ae}from"./3d/webgl-engine/Stage.js";import{newIntersector as De,DEFAULT_TOLERANCE as Fe}from"./3d/webgl-engine/lib/Intersector.js";import{StoreResults as We,IntersectorType as qe}from"./3d/webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as ze}from"./3d/webgl-engine/lib/intersectorUtils.js";import{toGraphic as ke,toOwner as Ne}from"./3d/webgl-engine/lib/intersectorUtilsConversions.js";import{TERRAIN_ID as Be}from"./3d/webgl-engine/lib/verticalOffsetUtils.js";import{hitTestSelectSimilarDistance as Qe}from"./support/hitTestSelectUtils.js";import{occludeesSupported as $e}from"./support/layerViewUtils.js";import{toRenderSettings as Xe,screenshotSuperSampleSettings as Ke}from"./support/screenshotUtils.js";import{isSupportedScreenPointEvent as Ze,createScreenPointFromSupportedEvent as Je}from"./support/screenUtils.js";import{isSpatialReferenceSupported as Ye}from"./support/spatialReferenceSupport.js";import{check as et}from"./support/WebGLRequirements.js";import tt from"./ui/3d/DefaultUI3D.js";import it from"../webscene/Environment.js";import rt from"../geometry/Extent.js";import st from"../geometry/SpatialReference.js";import nt from"../geometry/Point.js";const at=u.getLogger("esri.views.SceneView");let ot=class extends(Y(ee(ie(re)))){constructor(e){super(e),this._userClippingArea=null,this._clippingArea=null,this._initialDefaultSpatialReference=null,this._defaults={},this._externallySet={environment:!1},this._createGraphicsViewController=null,this._resolveWhenReady=[],this.propertiesPool=new Te({slicePlane:k},this),this._resourceController=Ee(this),this._defaultToMapOptions={include:new Set},this._defaultHitTestOptions={exclude:new Set},this.deconflictor=new ge({view:this}),this.labeler=new me({view:this,deconflictor:this.deconflictor.labels}),this.sharedSymbolResources=null,this.analyses=new J,this.basemapTerrain=null,this.elevationProvider=null,this.camera=null,this.canvas=null,this.center=null,this.constraints=new he,this.environmentManager=new ce,this.extent=null,this.floors=new n,this.fullOpacity=1,this.graphicsView=null,this.analysisViewManager=new pe({view:this}),this.groundView=null,this.navigating=!1,this.map=null,this.screenSizePerspectiveEnabled=!0,this.state=new we,this.scale=null,this.spatialReference=null,this.alphaCompositingEnabled=!1,this.supersampleScreenshotsEnabled=!0,this.type="3d",this.ui=new tt,this._numUpdating=0,this._lastUpdateTime=0,this.updatingProgress=.5,this.viewpoint=null,this.zoom=null,this.highlightOptions=new Ve,x(),e&&e.environment||(this._defaults.environment=new de,this.environment=this._defaults.environment);const t=(e=null)=>{f(e)&&e.type===w.MOVE||(this._updatingChanged(),this.map&&this.map.allLayers.forEach((async e=>{try{await e.when()}catch{}this._updatingChanged()})))};this.handles.add([_((()=>{var e;return null==(e=this.map)?void 0:e.allLayers}),"after-changes",(e=>t(e)),{onListenerAdd:()=>t(),onListenerRemove:()=>t(),sync:!0}),this.allLayerViews.on("after-changes",(e=>this._updateUpdatingMonitors(e))),this.watch("map",(e=>{e&&e.load&&e.load().catch((()=>{}))}))]),this.inputManager=new ue({view:this}),this.stateManager=new ve({view:this})}initialize(){this.groundView=new te({view:this}),this._updateUpdatingMonitors();const e=()=>this._updateDefaultToMapOptions();this.handles.add(_((()=>{var e;return null==(e=this.map)?void 0:e.allLayers}),"after-changes",e,{onListenerAdd:e,onListenerRemove:e})),this.updatingHandles.add((()=>this.qualitySettings.memoryLimit),(e=>{this.resourceController&&(this.resourceController.memoryController.maxMemory=e)}),b),this.updatingHandles.add((()=>this.qualitySettings.additionalCacheMemory),(e=>{this.resourceController&&(this.resourceController.memoryController.additionalCacheMemory=e)}),b),this.updatingHandles.add((()=>this.qualitySettings.frameRate),(e=>V(e>0?1e3/Math.ceil(e):0)),b),this.updatingHandles.add((()=>Me.SCENEVIEW_LOCKING_LOG),(e=>this.defaultsFromMap.logDebugInformation=e),b),this.updatingHandles.add((()=>{var e;return null==(e=this.map)?void 0:e.ground}),e,M),this.updatingHandles.add((()=>{var e,t;return null==(e=this.map)||null==(t=e.ground)?void 0:t.opacity}),(()=>this._updateDefaultHitTestOptions()),M),this.handles.add(this.watch("spatialReference",(()=>this.notifyChange("clippingArea")),!0))}destroy(){this.destroyed||(this.invalidate(),this.activeTool=null,this.layerViewManager.clear(),this._exitSurface(),this._disposeGraphicsView(),this.sharedSymbolResources=g(this.sharedSymbolResources),this.labeler.destroy(),this._set("labeler",null),this.deconflictor.destroy(),this._set("deconflictor",null),this._resourceController=g(this._resourceController),this.stateManager.destroy(),this._set("stateManager",null),this.inputManager.destroy(),this._set("inputManager",null),this.propertiesPool.destroy(),this.handles.remove("updatingMonitors"),this.environmentManager.destroy(),this._set("environmentManager",null),this.groundView=g(this.groundView))}get renderSpatialReference(){return this.renderCoordsHelper&&this.renderCoordsHelper.spatialReference}get basemapSpatialReference(){return this.basemapTerrain&&this.basemapTerrain.spatialReference}installContentCameraReset(e={sticky:!1}){return this.stateManager.installContentCameraReset(e)}get clippingArea(){if("global"===this.viewingMode)return null;let e=this._userClippingArea||this.get("map.clippingArea");return!(!!this._userClippingArea||this.get("map.clippingEnabled"))||m(e)?(this._clippingArea=null,null):e instanceof rt?this.spatialReference&&(e=ht(e,this.spatialReference),m(e))?(at.error("#clippingArea","setting clippingArea with incompatible SpatialReference"),this._clippingArea):(e=e.clone(),m(e.intersection(this.groundAndLayersExtent))&&(e.xmin=e.xmax,e.ymin=e.ymax),e.zmin=void 0,e.zmax=void 0,e.equals(this._clippingArea)||(this._clippingArea=e),this._clippingArea):(at.error("#clippingArea","only clippingArea geometries of type Extent are supported"),this._clippingArea)}set clippingArea(e){this.ready&&"global"===this.viewingMode&&f(e)?at.error("#clippingArea=","Clipping area is only supported in local viewingMode"):this._userClippingArea=e}get renderDataExtent(){if(this.state.viewingMode===ne.Global)return null;const e=this.renderSpatialReference,t=this.dataExtent;return m(t)||m(e)||t.spatialReference.equals(e)?t:ht(t,e)}get dataExtent(){let e=this.groundAndLayersExtent;const t=this.spatialReference||st.WGS84,i=ht(this.clippingArea,t);f(i)&&(e=f(e)?e.intersection(i):i);const r=this._get("dataExtent");return f(e)&&e.equals(r)?r:e}get groundAndLayersExtent(){const e=this.spatialReference||st.WGS84;let t;const i=i=>{const r=ht(i,e);m(r)||(f(t)?t.union(r):t=r.clone())},r=this.basemapTerrain;if(null!=r&&r.spatialReference){const e=r.groundExtent;i(new rt({xmin:e[0],ymin:e[1],zmin:0,xmax:e[2],ymax:e[3],zmax:0,spatialReference:r.spatialReference}))}if(this.map){const e=e=>{!f(e.fullExtent)||"graphics"===e.type&&e.internal||i(e.fullExtent)};this.map.allLayers.forEach((t=>e(t)))}if(m(t))return null;t.hasZ?(t.zmin=Math.min(0,t.zmin),t.zmax=Math.max(0,t.zmax)):(t.zmin=0,t.zmax=0);const s=this._get("groundAndLayersExtent");return t.equals(s)?s:t}set environment(e){e!==this._defaults.environment&&(this._externallySet.environment=!0),this._set("environment",e)}castEnvironment(e){return e?e instanceof de?e:e instanceof it?null!=this.environment?this.environment.cloneWithWebsceneEnvironment(e):de.fromWebsceneEnvironment(e):P(de,e):new de}get initialExtentRequired(){return this.stateManager&&!this.stateManager.hasInitialView}get _defaultsFromMapSettings(){return{required:{tileInfo:!1,heightModelInfo:!0,extent:!1}}}get interacting(){return this.navigating||f(this.activeTool)}get stationary(){return!this.animation&&!this.resizing&&(m(this.state)||this.state.stationary)}set qualityProfile(e){Se.isValidProfile(e)&&(Se.apply(e,this.qualitySettings),this._set("qualityProfile",e))}get qualityProfile(){return this._get("qualityProfile")||Se.getDefaultProfile()}set slicePlane(e){if(f(this._stage)&&this._stage.renderView.setRenderParameters({slicePlane:e}),m(e))return void this._set("slicePlane",null);const t=this.propertiesPool.get("slicePlane");N(e,t),this._set("slicePlane",t)}get typeSpecificPreconditionsReady(){return!!this.viewingMode}get resolution(){return null!=this.spatialReference?Q(this.scale,this.spatialReference):0}get heightModelInfo(){const e=this.getDefaultHeightModelInfo();return null!=e?H.deriveUnitFromSR(e,this.spatialReference):null}get updating(){var e,t,i;if(this.destroyed)return!1;let r=0,s=this.layerViewManager.updating,n=s?this.layerViewManager.updatingRemaining:0;this.allLayerViews.forEach((e=>{if(e.isFulfilled()){if(e.updating){if(s=!0,e.suspended||Le(e))return;++n,r+=e.updatingProgress}}else++n}));for(const a of[this.graphicsView,this.basemapView,this._resourceController,this._stage,this.featureTiles,this.pointsOfInterest,this.environmentManager,this.overlay,this.featureTreeDebugger,this.toolViewManager,this.analysisViewManager])if(f(a)&&a.updating){const e=.1;n+=e,r+=.5*e}for(const a of[this.deconflictor,this.labeler,this.basemapTerrain])f(a)&&a.updating&&(++n,r+=a.updatingProgress);if(s=!!(s||n>0||this.updatingHandles.updating||!this.ready||!this.stationary||this._createGraphicsViewController||null!=(e=this.inputManager)&&e.hasPendingInputs||null!=(t=this.map)&&null!=(i=t.allLayers)&&i.some((e=>!e.isFulfilled()))),s?(this._numUpdating=Math.max(n,this._numUpdating),r+=this._numUpdating-n):this._numUpdating=0,this._numUpdating>0?r/=this._numUpdating:r=s?0:1,this._get("updatingProgress")!==r){const e=this._resourceController.scheduler.now;if(r<1){const t=Math.min((e-this._lastUpdateTime)/2e3,1);r=this.updatingProgress*(1-t)+r*t}this._set("updatingProgress",r),this._lastUpdateTime=s&&r<1?e:0}return s}get viewingMode(){var e;const t=this._predeterminedViewingMode;if(f(t))return ae(t);const i=this.spatialReference;return i?f(null==(e=this.defaultsFromMap)?void 0:e.viewingMode)&&i.equals(this.defaultsFromMap.spatialReference)?ae(this.defaultsFromMap.viewingMode):Ye(i,ne.Global)?"global":"local":"global"}set viewingMode(e){this.ready?at.error("#viewingMode","viewingMode cannot be set once view is ready"):e?this._override("viewingMode",e):void 0===e&&this._clearOverride("viewingMode")}get resourceController(){return this._resourceController}get performanceInfo(){return new je(this)}forceAnimationTime(e){this._stage.renderView.forcedAnimationTime=this.basemapTerrain.overlayManager.forcedAnimationTime=e}on(e,t,i,r){const s=this.viewEvents.on(e,t,i,r);return s||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}toMap(e,t){if(!this.ready)return at.error("#toMap()","Scene view cannot be used before it is ready"),null;const i=t?this.externalToInternalIntersectOptions(t):this._defaultToMapOptions,r=f(i.graphics)&&(f(i.graphics.include)||f(i.graphics.exclude)),s=Ze(e)?Je(this,e):e,n=C(s);i.enableDraped=i.include&&!i.include.has(Be)||i.exclude&&i.exclude.has(Be);const a=this.sceneIntersectionHelper,o=De(this.state.viewingMode);if(o.options.selectionMode=!0,o.options.store=r?We.ALL:We.MIN,a.intersectIntersectorScreen(n,o,i),r){for(const e of o.results.all){const t=ke(e,this);if(m(t))return this._intersectResultToMapPoint(e);if(this._testGraphicUidFilter(i.graphics,t))return this._intersectResultToMapPoint(e)}return null}return this._intersectResultToMapPoint(o.results.min)}toScreen(e){if(!this.ready)return at.error("#toScreen()","Scene view cannot be used before it is ready"),null;const t=y(null==e.z&&Re(this.elevationProvider,e),0);return D(e,ct,this.renderSpatialReference,t),this.state.camera.projectToScreen(ct,ut),T(ut[0],ut[1])}pixelSizeAt(e){return this.ready?e?(D(e,ct,this.renderSpatialReference),this.state.camera.computeScreenPixelSizeAt(ct)):0:(at.error("#pixelSizeAt()","Scene view cannot be used before it is ready"),null)}overlayPixelSizeInMapUnits(e){const t=this.basemapTerrain.overlayManager;return t?t.overlayPixelSizeInMapUnits(e):1}hitTest(e,t){if(!this.ready)return at.error("#hitTest()","Scene view cannot be used before it is ready"),null;const i=Ze(e)?Je(this,e):e,r=O(i.x,i.y),s=t?this.externalToInternalIntersectOptions(t):this._defaultHitTestOptions;s.requiresGroundFeedback=!0,s.enableDraped=!0;const n=De(this.state.viewingMode);n.options.selectionMode=!0,n.options.store=We.ALL,this.sceneIntersectionHelper.intersectIntersectorScreen(r,n,s);const a=this._intersectResultsToHits(n.results.all,s.graphics),o=n.results.ground,l=Ne(o,this),p=f(l)&&"type"in l&&"integrated-mesh"===l.type?l:null,h={screenPoint:i,results:a,ground:{mapPoint:this._intersectResultToMapPoint(o),distance:ze(o)?o.distanceInRenderSpace:0,layer:p}};return Me.SCENEVIEW_HITTEST_RETURN_INTERSECTOR&&(h.intersector=n),Promise.resolve(h)}popupHitTest(e){return Qe(this,e).then((({results:t,ground:i})=>{let r=null;return!(0===t.length||Math.abs(y(t[0].distance,0)-i.distance)<1e-5)||i.layer&&"integrated-mesh"===i.layer.type||(r=i.mapPoint),{results:t,screenPoint:e,mapPoint:r}}))}goTo(e,t){return this.updatingHandles.addPromise(this.stateManager.goTo(e,t))}async whenAnalysisView(e){if(await this.whenReady(),m(e.parent))throw new o("view:no-analysisview-for-analysis","The analysis has not been added to view.analyses",{analysis:e});if("analysis"===e.parent.type){return(await this.whenLayerView(e.parent)).whenAnalysisView(e)}return this.analysisViewManager.whenAnalysisView(e)}whenLayerView(e){return super.whenLayerView(e)}takeScreenshot(e){return this.whenReady().then((()=>{const t=Xe(e,this);return t.pixelRatio/=this.state.pixelRatio,this._stage.renderView.takeScreenshot(Ke(t,this.supersampleScreenshotsEnabled,this.padding))}))}addUpdatingPromise(e){return this.updatingHandles.addPromise(e)}importLayerView(e){return le.importLayerView(e)}hasLayerViewModule(e){return le.hasLayerViewModule(e)}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){var e,t,i,r;return this.map&&"initialViewProperties"in this.map&&(null==(e=this.map)||null==(t=e.initialViewProperties)?void 0:t.spatialReference)||(null==(i=this.defaultsFromMap)?void 0:i.spatialReference)||(null==(r=this.defaultsFromMap)?void 0:r.ready)&&this._initialDefaultSpatialReference||null}async validate(){let e=et(this.type);if(d("safari")&&d("safari")<9&&(e=new o("sceneview:browser-not-supported","This browser is not supported by SceneView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:d("safari")})),f(e))throw at.warn("#validate()",e.message),e}get _predeterminedViewingMode(){var e,t;const i=this._isOverridden("viewingMode")?this._get("viewingMode"):null!=(e=this.map&&"initialViewProperties"in this.map?null==(t=this.map.initialViewProperties)?void 0:t.viewingMode:null)?e:null;return f(i)?oe(i):null}getSpatialReferenceSupport({spatialReference:e,layer:t}){const i=this._predeterminedViewingMode;if(f(i))return this._validateSpatialReferenceForViewingMode(e,t,i)?{constraints:this._makeSpatialReferenceConstraints(e,t,i)}:null;const r=this._validateSpatialReferenceForViewingMode(e,t,ne.Local),s=this._validateSpatialReferenceForViewingMode(e,t,ne.Global);return r||s?r&&s?{constraints:this._makeSpatialReferenceConstraints(e,t,null)}:r?{constraints:this._makeSpatialReferenceConstraints(e,t,ne.Local)}:{constraints:this._makeSpatialReferenceConstraints(e,t,ne.Global)}:null}_validateSpatialReferenceForViewingMode(e,t,i){return!!Ye(e,i)&&(!!m(t)||(!!X(t)||(!K(t)||!m(He(t,e,i)))&&(!Z(t)||i!==ne.Global)))}_makeSpatialReferenceConstraints(e,t,i){if(m(t))return[{spatialReference:e,viewingMode:i}];const r=e.isWebMercator,s=e.isWGS84;if(X(t)&&(r||s)){return!s||i===ne.Local||null===Ue(t.tileInfo,t.fullExtent,e,ne.Global)?[{spatialReference:e,viewingMode:i},{spatialReference:st.WebMercator,viewingMode:i}]:[{spatialReference:r?st.WGS84:st.WebMercator,viewingMode:i}]}return K(t)||Z(t)||!r&&!s?K(t)&&r&&i!==ne.Global?[{spatialReference:e,viewingMode:i},{spatialReference:st.WGS84,viewingMode:ne.Local}]:[{spatialReference:e,viewingMode:i}]:[{spatialReference:e,viewingMode:i},{spatialReference:r?st.WGS84:st.WebMercator,viewingMode:i}]}_validateSpatialReference(e){const t=f(this.getSpatialReferenceSupport({spatialReference:e})),i=this._predeterminedViewingMode;return t||(f(i)?at.warnOnce(`Spatial reference defined on view not supported in ${ae(i)} viewing mode.`):e.isGeographic&&at.warnOnce("Spatial reference is geographic but not supported.")),t}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}computeMapPointFromVec3d(e,t){let i=this.spatialReference||st.WGS84;return F(e,this.renderSpatialReference,e,i)||(i=st.WGS84,F(e,this.renderSpatialReference,e,i)),t?(t.x=e[0],t.y=e[1],t.z=e[2],t.spatialReference=i):t=new nt(e,i),t}trackGraphicState(e){if(!e.graphic)return at.error("trackGraphicState","GraphicState.graphic must not be null or undefined to start tracking"),null;const t=this.getViewForGraphic(e.graphic);let i=null,r=!1;const s=t=>{var s;!r&&f(t)&&"processor"in t&&"graphics-3d"===(null==(s=t.processor)?void 0:s.type)&&t.processor.graphicsCore&&(i=t.processor.graphicsCore.trackGraphicState(e))};return f(t)?s(t):this.whenViewForGraphic(e.graphic,{waitForLayer:!0}).then((e=>s(e)),(()=>{})).catch((()=>{})),{remove:()=>{r=!0,f(i)&&(i.remove(),i=null)}}}highlight(e){if(Array.isArray(e))return p(e.map((e=>this.highlight(e))));if(n.isCollection(e))return p(e.toArray().map((e=>this.highlight(e))));const t=this.getViewForGraphic(e);return t&&"highlight"in t?t.highlight(e):h()}maskOccludee(e){if(!e)return at.error("maskOccludee","GraphicState.graphic must not be null or undefined to mask an occludee"),null;const t=this.getViewForGraphic(e);let i=null,r=!1;const s=t=>{!r&&f(t)&&$e(t)&&(i=t.maskOccludee(e))};return f(t)?s(t):this.whenViewForGraphic(e,{waitForLayer:!0}).then((e=>s(e)),(()=>{})).catch((()=>{})),{remove:()=>{r=!0,f(i)&&(i.remove(),i=null)}}}getViewForGraphic(e){return e.layer===this.graphics?this.graphicsView:e.layer?this.allLayerViews.find((t=>t.layer===e.layer)):null}graphicChanged(e){f(this.graphicsView)&&this.graphicsView.graphicChanged(e)}async whenViewForGraphic(e,t){if(e.layer===this)return await S((()=>this.graphicsView)),this.graphicsView;if(!e.layer||!this.map)throw new o("no-view-for-graphic");return t&&t.waitForLayer&&!this.map.allLayers.includes(e.layer)?new Promise(((t,i)=>{const r=this.map.allLayers.on("change",(s=>{s.added.includes(e.layer)&&(r.remove(),this.whenLayerView(e.layer).then(t,i))}))})):this.whenLayerView(e.layer)}externalToInternalIntersectOptions(e){const t=this._externalToInternalRenderItems(e.include,dt.INCLUDE),i=this._externalToInternalRenderItems(e.exclude,dt.EXCLUDE);return{include:t.layerUids,exclude:i.layerUids,graphics:{include:t.graphicUids,exclude:i.graphicUids}}}_intersectResultToMapPoint(e,t){return e.getIntersectionPoint(ct)?(t=this.computeMapPointFromVec3d(ct,t),e.intersector===qe.TERRAIN&&this.basemapTerrain&&(t.z=y(Re(this.basemapTerrain,t),0)),t):null}_intersectResultsToHits(e,t){const i=new Array;let r=null;for(let s=0;s<e.length;s++){const n=e[s],a=Ne(n,this);if(f(a)&&(a===this.map.ground||"type"in a&&"integrated-mesh"===a.type))break;const o=ke(n,this);if(m(o))continue;if(m(r)&&s!==e.length-1&&(r=new Set),f(r)){const e=this._getGraphicFilterUid(o);if(r.has(e))continue;r.add(e)}if(!this._testGraphicUidFilter(t,o))continue;const l=this._intersectResultToMapPoint(n),p=n.distanceInRenderSpace;i.push({graphic:o,mapPoint:l,distance:p})}return i}_getGraphicFilterUid(e){if(e.layer&&"objectIdField"in e.layer){const t=e.attributes[e.layer.objectIdField];if(t)return`o-${e.layer.id}-${t}`}return`u-${e.uid}`}_testGraphicUidFilter(e,t){const i=this._getGraphicFilterUid(t);return m(e)||(m(e.include)||e.include.has(i))&&(m(e.exclude)||!e.exclude.has(i))}_externalToInternalRenderItems(e,t,s={layerUids:null,graphicUids:null}){if(!e)return s;if(e instanceof i)pt(s,this._getGraphicFilterUid(e)),t===dt.INCLUDE&&(f(this.graphicsView)&&e.layer===this?lt(s,this.graphicsView.processor.layer.id):e.layer&&lt(s,e.layer.uid));else if(c(e))for(const i of e)i===this.graphics&&f(this.graphicsView)?lt(s,this.graphicsView.processor.layer.id):i instanceof r?i===this.map.ground&&lt(s,Be):this._externalToInternalRenderItems(i,t,s);else lt(s,e.uid);return s}_initBasemapTerrain(){this._set("basemapTerrain",new Ge({view:this})),this._set("elevationProvider",new be({view:this})),this.elevationProvider.register("ground",this.basemapTerrain)}_exitBasemapTerrain(){this.basemapTerrain&&(this.elevationProvider.unregister(this.basemapTerrain),this.elevationProvider.destroy(),this._set("elevationProvider",null),this.basemapTerrain.destroy(),this._set("basemapTerrain",null))}_initGlobe(){this._initCoordinateSystem(),this.state.createInitialCamera(),this._initBasemapTerrain(),this._set("pointsOfInterest",new Pe({view:this})),this._set("featureTiles",new ye({renderCoordsHelper:this.renderCoordsHelper,cameraOnSurface:this.pointsOfInterest.contentCameraOnSurface,focus:this.pointsOfInterest.focus,tilingSchemeOwner:this.basemapTerrain,viewState:this.state,scheduler:this._resourceController.scheduler,terrain:this.basemapTerrain}));const e=()=>{const e=this.basemapTerrain&&this.basemapTerrain.extent;if(this.clippingArea||e)if(e&&this.basemapTerrain.spatialReference){const e=f(this.basemapTerrain.extent)?A(z(this.basemapTerrain.extent,this.basemapTerrain.spatialReference),this.spatialReference):null;f(this.clippingArea)?this.featureTiles.filterExtent=this.clippingArea.intersection(e):this.featureTiles.filterExtent=e}else this.featureTiles.filterExtent=this.clippingArea;else this.featureTiles.filterExtent=null};this.handles.add([this.updatingHandles.add((()=>Me.FEATURE_TILE_TREE_SHOW_TILES),(e=>{e&&this.featureTiles&&!this.featureTreeDebugger?this.updatingHandles.addPromise(import("./3d/layers/support/FeatureTileTree3DDebugger.js")).then((({FeatureTileTree3DDebugger:e})=>{!this.featureTreeDebugger&&Me.FEATURE_TILE_TREE_SHOW_TILES&&(this.featureTreeDebugger=new e({view:this}))})):e||!this.featureTreeDebugger||Me.FEATURE_TILE_TREE_SHOW_TILES||(this.featureTreeDebugger.destroy(),this.featureTreeDebugger=null)}),M),this.updatingHandles.add((()=>this.clippingArea),e,M),this.updatingHandles.add((()=>this.basemapTerrain.extent),e,M)],"feature-tiles"),this.stateManager.init()}_exitGlobe(){this.state&&(this.stateManager.deinit(),this.handles.remove("render-coords-helper"),this.handles.remove("feature-tiles"),this.featureTiles.destroy(),this._set("featureTiles",null),this.pointsOfInterest.destroy(),this._set("pointsOfInterest",null),this._exitBasemapTerrain(),this.state.exit(),this._exitCoordinateSystem())}_initCoordinateSystem(){if(this.spatialReference){const e=this.spatialReference;this.mapCoordsHelper&&this.mapCoordsHelper.spatialReference.equals(e)||this._set("mapCoordsHelper",new Ce(this.map,e));const t=this.state.isGlobal,i=B(t,e);i!==this.renderSpatialReference&&(this._set("renderCoordsHelper",xe.create(this.state.viewingMode,i)),t||this.handles.add(this.watch("basemapTerrain.extent",(e=>{const t=this.renderCoordsHelper.spatialReference;0===e[0]&&0===e[1]&&0===e[2]&&0===e[3]||!W(e,this.basemapTerrain.spatialReference,gt,t)||(this.renderCoordsHelper.extent=gt)}),!0),"render-coords-helper"),this.sceneIntersectionHelper&&this.sceneIntersectionHelper.setTolerance(Fe/this.renderCoordsHelper.unitInMeters))}else this._set("mapCoordsHelper",null),this._set("renderCoordsHelper",null)}_exitCoordinateSystem(){this.mapCoordsHelper&&(this.handles.remove("render-coords-helper"),this._set("renderCoordsHelper",null),this._set("mapCoordsHelper",null))}_updatingChanged(){this.notifyChange("updating")}_updateUpdatingMonitors(e=null){f(e)&&e.type===w.MOVE||(this.handles.remove("updatingMonitors"),this.allLayerViews.forEach((e=>{e.destroyed||(this.handles.add([e.watch(["updating","updatingProgress"],(()=>this._updatingChanged()),!0)],"updatingMonitors"),e.when((()=>this._updatingChanged()),(()=>this._updatingChanged())))})),this._updatingChanged())}_renderScreenshotOverlay(e,t){if(!this.overlay||!this.overlay.hasVisibleItems)return t;const i=e.getContext("2d");return i.putImageData(t,0,0),this.overlay.renderCanvas(e),i.getImageData(0,0,t.width,t.height)}_initStage(){const e={deactivatedWebGLExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions,alpha:this.alphaCompositingEnabled,canvas:this.renderCanvas,screenshot:{renderOverlay:(e,t)=>this._renderScreenshotOverlay(e,t)}},t=new _e(this.state.viewingMode,(e=>this._stage.layers.forAll(e)),this);this._set("sceneIntersectionHelper",t);const i=a(this.surface),{resourceController:r,state:s,renderSpatialReference:n}=this;this._stage=new Ae({options:e,container:i,resourceController:r,state:s,sceneIntersectionHelper:t,renderSR:n}),this._stage.renderView.setRenderParameters({slicePlane:this.slicePlane}),this._lostWebGLContextHandle=l(this._stage.renderView.canvas,"webglcontextlost",(()=>this.fatalError=new o("webgl-context-lost"))),this.handles.add([this.updatingHandles.add((()=>this.qualitySettings.antialiasingEnabled),(()=>this._stage.renderView.setRenderParameters({antialiasingEnabled:this.qualitySettings.antialiasingEnabled})),b),this.updatingHandles.add((()=>this.qualitySettings.highQualityTransparency),(()=>this._stage.renderView.setRenderParameters({highQualityTransparency:this.qualitySettings.highQualityTransparency})),b),R((()=>this.magnifier),(e=>this._stage.renderView.magnifier=e),M)],"stage");const p=()=>{this._stage.renderView.setRenderParameters({defaultHighlightOptions:Ve.toEngineOptions(this.highlightOptions)})};this.handles.add(this.updatingHandles.add((()=>[this.highlightOptions.color,this.highlightOptions.haloColor,this.highlightOptions.haloOpacity,this.highlightOptions.fillOpacity,this.highlightOptions.shadowOpacity,this.highlightOptions.shadowColor,this.highlightOptions.shadowDifference]),p),"stage"),p(),this.renderCoordsHelper&&this.sceneIntersectionHelper.setTolerance(Fe/this.renderCoordsHelper.unitInMeters),this._set("canvas",this._stage.renderView.canvas)}_exitStage(){this._set("sceneIntersectionHelper",null),this._stage.destroy(),this._stage=null,this._lostWebGLContextHandle.remove(),this._lostWebGLContextHandle=null,this.handles.remove("stage"),this._set("canvas",null)}_initSurface(e){this._exitSurface(),this.state.init(e,this.spatialReference),this._initStage(),this._initGlobe(),this.sharedSymbolResources=new Ie({view:this,viewingMode:e,resourceController:this._resourceController,pointsOfInterest:this.pointsOfInterest,viewState:this.state,objectResourceCache:new fe})}_exitSurface(){this.sharedSymbolResources&&(this.sharedSymbolResources.objectResourceCache.destroy(),this.sharedSymbolResources.destroy(),this.sharedSymbolResources=null,this._exitGlobe(),this._exitStage())}_createGraphicsViewIfNeeded(){if(this.graphicsView||this._createGraphicsViewController)return;if(0===this.graphics.length)return;this.handles.remove("graphics-view"),this._createGraphicsViewController=new AbortController;const e=()=>{this._createGraphicsViewController=null,this._updatingChanged()};this._createGraphicsViewAsync(this._createGraphicsViewController.signal).then(e,e),this._updatingChanged()}async _createGraphicsViewAsync(e){const t=(await import("./3d/layers/GraphicsView3D.js")).default;v(e),await S((()=>{var e;return!0===(null==(e=this.basemapTerrain)?void 0:e.ready)}),e),this._set("graphicsView",new t({view:this}))}_disposeGraphicsView(){this._createGraphicsViewController&&(this._createGraphicsViewController.abort(),this._createGraphicsViewController=null),this.handles.remove("graphics-view"),f(this.graphicsView)&&(this.handles.remove(this.graphicsView.processor.layer.id),this.graphicsView.destroy(),this._set("graphicsView",null))}_startup(){const e=oe(this.viewingMode);if(e===ne.Global&&(this._clippingArea=null),this._initSurface(e),this._set("ready",!0),this.handles.add(_((()=>this.graphics),"after-changes",(()=>this._createGraphicsViewIfNeeded())),"graphics-view"),this._createGraphicsViewIfNeeded(),!this._externallySet.environment){const e=this.get("map.initialViewProperties.environment");e&&(this.environment=e)}this.labeler.setup(),this.environmentManager.connectView(this),this.inputManager.connect();const t=this._resolveWhenReady;this._resolveWhenReady=[],t.forEach((e=>e(this)))}_teardown(){this._initialDefaultSpatialReference=null,this.inputManager.disconnect(),this.environmentManager.disconnectView(),this.labeler.dispose(),this._disposeGraphicsView(),this.handles.remove("graphics-view"),this._exitSurface(),this._set("ready",!1)}_updateDefaultToMapOptions(){if(this._defaultToMapOptions.include.clear(),this.map){this.map.ground&&this._defaultToMapOptions.include.add(Be);for(const e of this.map.allLayers.items)"integrated-mesh"===e.type&&this._defaultToMapOptions.include.add(e.uid)}}_updateDefaultHitTestOptions(){if(this._defaultHitTestOptions.exclude.clear(),this.map){this.map.ground&&this.map.ground.opacity<1&&this._defaultHitTestOptions.exclude.add(Be);for(const e of this.map.allLayers.items)"integrated-mesh"===e.type&&e.opacity<1&&this._defaultToMapOptions.exclude.add(e.uid)}}getVoxelWasmPerSceneView(){return $.getInstance().getVoxelWasmPerSceneView(this)}};function lt(e,t){e.layerUids||(e.layerUids=new Set),e.layerUids.add(t)}function pt(e,t){e.graphicUids||(e.graphicUids=new Set),e.graphicUids.add(t)}function ht(e,t){return f(e)&&U(e.spatialReference,t)?A(e,t):null}var dt;e([E()],ot.prototype,"_userClippingArea",void 0),e([E()],ot.prototype,"_resourceController",void 0),e([E()],ot.prototype,"_stage",void 0),e([E({readOnly:!0})],ot.prototype,"deconflictor",void 0),e([E({readOnly:!0})],ot.prototype,"labeler",void 0),e([E(L(J,"analyses"))],ot.prototype,"analyses",void 0),e([E({type:se,readOnly:!0,aliasOf:"state.animation"})],ot.prototype,"animation",void 0),e([E({readOnly:!0})],ot.prototype,"basemapTerrain",void 0),e([E({readOnly:!0})],ot.prototype,"elevationProvider",void 0),e([E({type:t,aliasOf:"stateManager.camera"})],ot.prototype,"camera",void 0),e([E({type:t,aliasOf:"stateManager.contentCamera"})],ot.prototype,"contentCamera",void 0),e([E({readOnly:!0})],ot.prototype,"canvas",void 0),e([E({type:nt,aliasOf:"stateManager.center"})],ot.prototype,"center",void 0),e([E({type:rt})],ot.prototype,"clippingArea",null),e([E({type:he})],ot.prototype,"constraints",void 0),e([E({type:rt,readOnly:!0})],ot.prototype,"renderDataExtent",null),e([E({type:rt,readOnly:!0})],ot.prototype,"dataExtent",null),e([E({type:rt,readOnly:!0})],ot.prototype,"groundAndLayersExtent",null),e([E({value:null,type:de})],ot.prototype,"environment",null),e([j("environment")],ot.prototype,"castEnvironment",null),e([E({readOnly:!0})],ot.prototype,"environmentManager",void 0),e([E({type:rt,aliasOf:"stateManager.extent"})],ot.prototype,"extent",void 0),e([E()],ot.prototype,"floors",void 0),e([E({readOnly:!0,aliasOf:"stateManager.screenCenter"})],ot.prototype,"screenCenter",void 0),e([E({aliasOf:"stateManager.frustum"})],ot.prototype,"frustum",void 0),e([E({type:Number,readOnly:!0})],ot.prototype,"fullOpacity",void 0),e([E({readOnly:!0})],ot.prototype,"graphicsView",void 0),e([E({readOnly:!0})],ot.prototype,"analysisViewManager",void 0),e([E()],ot.prototype,"groundView",void 0),e([E({type:Boolean})],ot.prototype,"initialExtentRequired",null),e([E()],ot.prototype,"_defaultsFromMapSettings",null),e([E({type:Boolean,readOnly:!0})],ot.prototype,"interacting",null),e([E()],ot.prototype,"stationary",null),e([E({aliasOf:"state.navigating"})],ot.prototype,"navigating",void 0),e([E()],ot.prototype,"map",void 0),e([E({readOnly:!0})],ot.prototype,"mapCoordsHelper",void 0),e([E({aliasOf:"stateManager.padding"})],ot.prototype,"padding",void 0),e([E({type:Pe,readOnly:!0})],ot.prototype,"pointsOfInterest",void 0),e([E({type:ye,readOnly:!0})],ot.prototype,"featureTiles",void 0),e([E()],ot.prototype,"featureTreeDebugger",void 0),e([E({type:Boolean})],ot.prototype,"screenSizePerspectiveEnabled",void 0),e([E({constructOnly:!0})],ot.prototype,"deactivatedWebGLExtensions",void 0),e([E({constructOnly:!0})],ot.prototype,"debugWebGLExtensions",void 0),e([E({constructOnly:!0})],ot.prototype,"renderCanvas",void 0),e([E({constructOnly:!0})],ot.prototype,"state",void 0),e([E({readOnly:!0})],ot.prototype,"inputManager",void 0),e([E({readOnly:!0})],ot.prototype,"stateManager",void 0),e([E({type:["low","medium","high"]})],ot.prototype,"qualityProfile",null),e([E({type:Oe,get(){let e=this._get("qualitySettings");return e||(e=new Oe,Se.apply(this.qualityProfile,e)),e}})],ot.prototype,"qualitySettings",void 0),e([E()],ot.prototype,"slicePlane",null),e([E({readOnly:!0})],ot.prototype,"typeSpecificPreconditionsReady",null),e([E({readOnly:!0})],ot.prototype,"renderCoordsHelper",void 0),e([E({readOnly:!0})],ot.prototype,"sceneIntersectionHelper",void 0),e([E({type:Number,dependsOn:["scale","spatialReference"],readOnly:!0})],ot.prototype,"resolution",null),e([E({type:Number,aliasOf:"stateManager.scale"})],ot.prototype,"scale",void 0),e([E()],ot.prototype,"heightModelInfo",null),e([E()],ot.prototype,"spatialReference",void 0),e([E({type:Boolean,constructOnly:!0})],ot.prototype,"alphaCompositingEnabled",void 0),e([E({type:Boolean})],ot.prototype,"supersampleScreenshotsEnabled",void 0),e([E({readOnly:!0})],ot.prototype,"type",void 0),e([E({type:tt})],ot.prototype,"ui",void 0),e([E({type:Boolean,readOnly:!0,dependsOn:["graphicsView.updating","basemapView.updating","basemapTerrain.updating","layerViewManager.updating","layerViewManager.updatingRemaining","_resourceController.updating","_stage.updating","featureTiles.updating","pointsOfInterest.updating","environmentManager.updating","overlay.updating","updatingHandles.updating","featureTreeDebugger.updating","labeler.updating","deconflictor.updating","ready","stationary","inputManager.hasPendingInputs","toolViewManager.updating","analysisViewManager.updating"]})],ot.prototype,"updating",null),e([E({type:Number,readOnly:!0,dependsOn:["updating"]})],ot.prototype,"updatingProgress",void 0),e([E({type:["global","local"]})],ot.prototype,"viewingMode",null),e([E({type:s,aliasOf:"stateManager.viewpoint"})],ot.prototype,"viewpoint",void 0),e([E({type:Number,aliasOf:"stateManager.zoom"})],ot.prototype,"zoom",void 0),e([E({type:Ve})],ot.prototype,"highlightOptions",void 0),ot=e([I("esri.views.SceneView")],ot),function(e){e[e.INCLUDE=0]="INCLUDE",e[e.EXCLUDE=1]="EXCLUDE"}(dt||(dt={}));const ct=G(),ut=O(),gt=q(),mt=ot;export{mt as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../Camera.js";import"../geometry.js";import i from"../Graphic.js";import r from"../Ground.js";import s from"../Viewpoint.js";import n from"../core/Collection.js";import{byId as a}from"../core/domUtils.js";import o from"../core/Error.js";import{on as l}from"../core/events.js";import{handlesGroup as p,makeHandle as h}from"../core/handleUtils.js";import d from"../core/has.js";import{isIterable as c}from"../core/iteratorUtils.js";import u from"../core/Logger.js";import{destroyMaybe as g,isNone as m,isSome as f,unwrapOr as y}from"../core/maybe.js";import{ObservableChangesType as w}from"../core/ObservableChangesType.js";import{throwIfAborted as v}from"../core/promiseUtils.js";import{on as _,initial as b,syncAndInitial as M,whenOnce as S,watch as R}from"../core/reactiveUtils.js";import{setFrameDuration as V}from"../core/scheduling.js";import{screenPointObjectToArray as T,createScreenPoint as C,createScreenPointArray as O}from"../core/screenUtils.js";import{initialize as x}from"../core/workers/workers.js";import{property as E}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import{cast as j}from"../core/accessorSupport/decorators/cast.js";import{subclass as P}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as I}from"../core/accessorSupport/ensureType.js";import{c as G}from"../chunks/vec3f64.js";import{owningCollectionProperty as L}from"../core/support/OwningCollection.js";import H from"../geometry/HeightModelInfo.js";import{canProjectWithoutEngine as U,project as A,projectPointToVector as D,projectVectorToVector as F,projectBoundingRect as W}from"../geometry/projection.js";import{create as q,toExtent as z}from"../geometry/support/aaBoundingRect.js";import{B as k,a as N}from"../chunks/boundedPlane.js";import{renderSRFromViewSR as B}from"../geometry/support/coordinateSystem.js";import{getResolutionForScale as Q}from"../geometry/support/scaleUtils.js";import $ from"../layers/VoxelWasmManager.js";import{isImageryTileLayer as X,isTiledLayer as Z,isVoxelLayer as J}from"../layers/support/layerUtils.js";import{AnalysesCollection as K}from"../support/AnalysesCollection.js";import{BreakpointsOwner as Y}from"./BreakpointsOwner.js";import{DOMContainer as ee}from"./DOMContainer.js";import te from"./GroundView.js";import{PopupView as ie}from"./PopupView.js";import re from"./View.js";import se from"./ViewAnimation.js";import{ViewingMode as ne,stringFromViewingMode as ae,viewingModeFromString as oe}from"./ViewingMode.js";import{layerView3DImporter as le}from"./3d/layerViewModuleImportUtils.js";import pe from"./3d/analysis/AnalysisViewManager3D.js";import{Constraints as he}from"./3d/constraints/Constraints.js";import de from"./3d/environment/SceneViewEnvironment.js";import{SceneViewEnvironmentManager as ce}from"./3d/environment/SceneViewEnvironmentManager.js";import ue from"./3d/input/SceneInputManager.js";import{GraphicsDeconflictor as ge}from"./3d/layers/graphics/GraphicsDeconflictor.js";import{Labeler as me}from"./3d/layers/graphics/Labeler.js";import{ObjectResourceCache as fe}from"./3d/layers/graphics/ObjectResourceCache.js";import{FeatureTileTree3D as ye}from"./3d/layers/support/FeatureTileTree3D.js";import we from"./3d/state/ViewState.js";import ve from"./3d/state/ViewStateManager.js";import{SceneIntersectionHelper as _e}from"./3d/state/helpers/SceneIntersectionHelper.js";import{CombinedElevationProvider as be}from"./3d/support/CombinedElevationProvider.js";import Me from"./3d/support/debugFlags.js";import Se from"./3d/support/DisplayQualityProfile.js";import{getElevationAtPoint as Re}from"./3d/support/ElevationProvider.js";import Ve from"./3d/support/HighlightOptions.js";import{MapCoordsHelper as Te}from"./3d/support/MapCoordsHelper.js";import{PropertiesPool as Ce}from"./3d/support/PropertiesPool.js";import Oe from"./3d/support/QualitySettings.js";import{RenderCoordsHelper as xe}from"./3d/support/RenderCoordsHelper.js";import{newResourceController as Ee}from"./3d/support/ResourceController.js";import je from"./3d/support/SceneViewPerformanceInfo.js";import{SharedSymbolResources as Pe}from"./3d/support/SharedSymbolResources.js";import{PointsOfInterest as Ie}from"./3d/support/pointsOfInterest/PointsOfInterest.js";import Ge from"./3d/terrain/TerrainSurface.js";import{isSurfaceLayerView as Le,getTiledLayerInfo as He,checkIfTileInfoSupportedForView as Ue}from"./3d/terrain/terrainUtils.js";import{Stage as Ae}from"./3d/webgl-engine/Stage.js";import{newIntersector as De,DEFAULT_TOLERANCE as Fe}from"./3d/webgl-engine/lib/Intersector.js";import{StoreResults as We,IntersectorType as qe}from"./3d/webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as ze}from"./3d/webgl-engine/lib/intersectorUtils.js";import{toGraphic as ke,toOwner as Ne}from"./3d/webgl-engine/lib/intersectorUtilsConversions.js";import{TERRAIN_ID as Be}from"./3d/webgl-engine/lib/verticalOffsetUtils.js";import{hitTestSelectSimilarDistance as Qe}from"./support/hitTestSelectUtils.js";import{occludeesSupported as $e}from"./support/layerViewUtils.js";import{toRenderSettings as Xe,screenshotSuperSampleSettings as Ze}from"./support/screenshotUtils.js";import{isSupportedScreenPointEvent as Je,createScreenPointFromSupportedEvent as Ke}from"./support/screenUtils.js";import{isSpatialReferenceSupported as Ye}from"./support/spatialReferenceSupport.js";import{check as et}from"./support/WebGLRequirements.js";import tt from"./ui/3d/DefaultUI3D.js";import it from"../webscene/Environment.js";import rt from"../geometry/Extent.js";import st from"../geometry/SpatialReference.js";import nt from"../geometry/Point.js";const at=u.getLogger("esri.views.SceneView");let ot=class extends(Y(ee(ie(re)))){constructor(e){super(e),this._userClippingArea=null,this._clippingArea=null,this._initialDefaultSpatialReference=null,this._defaults={},this._externallySet={environment:!1},this._createGraphicsViewController=null,this._resolveWhenReady=[],this.propertiesPool=new Ce({slicePlane:k},this),this._resourceController=Ee(this),this._defaultToMapOptions={include:new Set},this._defaultHitTestOptions={exclude:new Set},this.deconflictor=new ge({view:this}),this.labeler=new me({view:this,deconflictor:this.deconflictor.labels}),this.sharedSymbolResources=null,this.analyses=new K,this.basemapTerrain=null,this.elevationProvider=null,this.camera=null,this.canvas=null,this.center=null,this.constraints=new he,this.environmentManager=new ce,this.extent=null,this.floors=new n,this.fullOpacity=1,this.graphicsView=null,this.analysisViewManager=new pe({view:this}),this.groundView=null,this.navigating=!1,this.map=null,this.screenSizePerspectiveEnabled=!0,this.state=new we,this.scale=null,this.spatialReference=null,this.alphaCompositingEnabled=!1,this.supersampleScreenshotsEnabled=!0,this.type="3d",this.ui=new tt,this._numUpdating=0,this._lastUpdateTime=0,this.updatingProgress=.5,this.viewpoint=null,this.zoom=null,this.highlightOptions=new Ve,x(),e&&e.environment||(this._defaults.environment=new de,this.environment=this._defaults.environment);const t=(e=null)=>{f(e)&&e.type===w.MOVE||(this._updatingChanged(),this.map&&this.map.allLayers.forEach((async e=>{try{await e.when()}catch{}this._updatingChanged()})))};this.handles.add([_((()=>{var e;return null==(e=this.map)?void 0:e.allLayers}),"after-changes",(e=>t(e)),{onListenerAdd:()=>t(),onListenerRemove:()=>t(),sync:!0}),this.allLayerViews.on("after-changes",(e=>this._updateUpdatingMonitors(e))),this.watch("map",(e=>{e&&e.load&&e.load().catch((()=>{}))}))]),this.inputManager=new ue({view:this}),this.stateManager=new ve({view:this})}initialize(){this.groundView=new te({view:this}),this._updateUpdatingMonitors();const e=()=>this._updateDefaultToMapOptions();this.handles.add(_((()=>{var e;return null==(e=this.map)?void 0:e.allLayers}),"after-changes",e,{onListenerAdd:e,onListenerRemove:e})),this.updatingHandles.add((()=>this.qualitySettings.memoryLimit),(e=>{this.resourceController&&(this.resourceController.memoryController.maxMemory=e)}),b),this.updatingHandles.add((()=>this.qualitySettings.additionalCacheMemory),(e=>{this.resourceController&&(this.resourceController.memoryController.additionalCacheMemory=e)}),b),this.updatingHandles.add((()=>this.qualitySettings.frameRate),(e=>V(e>0?1e3/Math.ceil(e):0)),b),this.updatingHandles.add((()=>{var e;return null==(e=this.map)?void 0:e.ground}),e,M),this.updatingHandles.add((()=>{var e,t;return null==(e=this.map)||null==(t=e.ground)?void 0:t.opacity}),(()=>this._updateDefaultHitTestOptions()),M),this.handles.add(this.watch("spatialReference",(()=>this.notifyChange("clippingArea")),!0))}destroy(){this.destroyed||(this.invalidate(),this.activeTool=null,this.layerViewManager.clear(),this._exitSurface(),this._disposeGraphicsView(),this.sharedSymbolResources=g(this.sharedSymbolResources),this.labeler.destroy(),this._set("labeler",null),this.deconflictor.destroy(),this._set("deconflictor",null),this._resourceController=g(this._resourceController),this.stateManager.destroy(),this._set("stateManager",null),this.inputManager.destroy(),this._set("inputManager",null),this.propertiesPool.destroy(),this.handles.remove("updatingMonitors"),this.environmentManager.destroy(),this._set("environmentManager",null),this.groundView=g(this.groundView))}get renderSpatialReference(){return this.renderCoordsHelper&&this.renderCoordsHelper.spatialReference}get basemapSpatialReference(){return this.basemapTerrain&&this.basemapTerrain.spatialReference}installContentCameraReset(e={sticky:!1}){return this.stateManager.installContentCameraReset(e)}get clippingArea(){if("global"===this.viewingMode)return null;let e=this._userClippingArea||this.get("map.clippingArea");return!(!!this._userClippingArea||this.get("map.clippingEnabled"))||m(e)?(this._clippingArea=null,null):e instanceof rt?this.spatialReference&&(e=ht(e,this.spatialReference),m(e))?(at.error("#clippingArea","setting clippingArea with incompatible SpatialReference"),this._clippingArea):(e=e.clone(),m(e.intersection(this.groundAndLayersExtent))&&(e.xmin=e.xmax,e.ymin=e.ymax),e.zmin=void 0,e.zmax=void 0,e.equals(this._clippingArea)||(this._clippingArea=e),this._clippingArea):(at.error("#clippingArea","only clippingArea geometries of type Extent are supported"),this._clippingArea)}set clippingArea(e){this.ready&&"global"===this.viewingMode&&f(e)?at.error("#clippingArea=","Clipping area is only supported in local viewingMode"):this._userClippingArea=e}get renderDataExtent(){if(this.state.viewingMode===ne.Global)return null;const e=this.renderSpatialReference,t=this.dataExtent;return m(t)||m(e)||t.spatialReference.equals(e)?t:ht(t,e)}get dataExtent(){let e=this.groundAndLayersExtent;const t=this.spatialReference||st.WGS84,i=ht(this.clippingArea,t);f(i)&&(e=f(e)?e.intersection(i):i);const r=this._get("dataExtent");return f(e)&&e.equals(r)?r:e}get groundAndLayersExtent(){const e=this.spatialReference||st.WGS84;let t;const i=i=>{const r=ht(i,e);m(r)||(f(t)?t.union(r):t=r.clone())},r=this.basemapTerrain;if(null!=r&&r.spatialReference){const e=r.groundExtent;i(new rt({xmin:e[0],ymin:e[1],zmin:0,xmax:e[2],ymax:e[3],zmax:0,spatialReference:r.spatialReference}))}if(this.map){const e=e=>{!f(e.fullExtent)||"graphics"===e.type&&e.internal||i(e.fullExtent)};this.map.allLayers.forEach((t=>e(t)))}if(m(t))return null;t.hasZ?(t.zmin=Math.min(0,t.zmin),t.zmax=Math.max(0,t.zmax)):(t.zmin=0,t.zmax=0);const s=this._get("groundAndLayersExtent");return t.equals(s)?s:t}set environment(e){e!==this._defaults.environment&&(this._externallySet.environment=!0),this._set("environment",e)}castEnvironment(e){return e?e instanceof de?e:e instanceof it?null!=this.environment?this.environment.cloneWithWebsceneEnvironment(e):de.fromWebsceneEnvironment(e):I(de,e):new de}get initialExtentRequired(){return this.stateManager&&!this.stateManager.hasInitialView}get _defaultsFromMapSettings(){return{required:{tileInfo:!1,heightModelInfo:!0,extent:!1}}}get interacting(){return this.navigating||f(this.activeTool)}get stationary(){return!this.animation&&!this.resizing&&(m(this.state)||this.state.stationary)}set qualityProfile(e){Se.isValidProfile(e)&&(Se.apply(e,this.qualitySettings),this._set("qualityProfile",e))}get qualityProfile(){return this._get("qualityProfile")||Se.getDefaultProfile()}set slicePlane(e){if(f(this._stage)&&this._stage.renderView.setRenderParameters({slicePlane:e}),m(e))return void this._set("slicePlane",null);const t=this.propertiesPool.get("slicePlane");N(e,t),this._set("slicePlane",t)}get typeSpecificPreconditionsReady(){return!!this.viewingMode}get resolution(){return null!=this.spatialReference?Q(this.scale,this.spatialReference):0}get heightModelInfo(){const e=this.getDefaultHeightModelInfo();return null!=e?H.deriveUnitFromSR(e,this.spatialReference):null}get updating(){var e,t,i;if(this.destroyed)return!1;let r=0,s=this.layerViewManager.updating,n=s?this.layerViewManager.updatingRemaining:0;this.allLayerViews.forEach((e=>{if(e.isFulfilled()){if(e.updating){if(s=!0,e.suspended||Le(e))return;++n,r+=e.updatingProgress}}else++n}));for(const a of[this.graphicsView,this.basemapView,this._resourceController,this._stage,this.featureTiles,this.pointsOfInterest,this.environmentManager,this.overlay,this.featureTreeDebugger,this.toolViewManager,this.analysisViewManager])if(f(a)&&a.updating){const e=.1;n+=e,r+=.5*e}for(const a of[this.deconflictor,this.labeler,this.basemapTerrain])f(a)&&a.updating&&(++n,r+=a.updatingProgress);if(s=!!(s||n>0||this.updatingHandles.updating||!this.ready||!this.stationary||this._createGraphicsViewController||null!=(e=this.inputManager)&&e.hasPendingInputs||null!=(t=this.map)&&null!=(i=t.allLayers)&&i.some((e=>!e.isFulfilled()))),s?(this._numUpdating=Math.max(n,this._numUpdating),r+=this._numUpdating-n):this._numUpdating=0,this._numUpdating>0?r/=this._numUpdating:r=s?0:1,this._get("updatingProgress")!==r){const e=this._resourceController.scheduler.now;if(r<1){const t=Math.min((e-this._lastUpdateTime)/2e3,1);r=this.updatingProgress*(1-t)+r*t}this._set("updatingProgress",r),this._lastUpdateTime=s&&r<1?e:0}return s}get viewingMode(){var e;const t=this._predeterminedViewingMode;if(f(t))return ae(t);const i=this.spatialReference;return i?f(null==(e=this.defaultsFromMap)?void 0:e.viewingMode)&&i.equals(this.defaultsFromMap.spatialReference)?ae(this.defaultsFromMap.viewingMode):Ye(i,ne.Global)?"global":"local":"global"}set viewingMode(e){this.ready?at.error("#viewingMode","viewingMode cannot be set once view is ready"):e?this._override("viewingMode",e):void 0===e&&this._clearOverride("viewingMode")}get resourceController(){return this._resourceController}get performanceInfo(){return new je(this)}forceAnimationTime(e){this._stage.renderView.forcedAnimationTime=this.basemapTerrain.overlayManager.forcedAnimationTime=e}on(e,t,i,r){const s=this.viewEvents.on(e,t,i,r);return s||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}toMap(e,t){if(!this.ready)return at.error("#toMap()","Scene view cannot be used before it is ready"),null;const i=t?this.externalToInternalIntersectOptions(t):this._defaultToMapOptions,r=f(i.graphics)&&(f(i.graphics.include)||f(i.graphics.exclude)),s=Je(e)?Ke(this,e):e,n=T(s);i.enableDraped=i.include&&!i.include.has(Be)||i.exclude&&i.exclude.has(Be);const a=this.sceneIntersectionHelper,o=De(this.state.viewingMode);if(o.options.selectionMode=!0,o.options.store=r?We.ALL:We.MIN,a.intersectIntersectorScreen(n,o,i),r){for(const e of o.results.all){const t=ke(e,this);if(m(t))return this._intersectResultToMapPoint(e);if(this._testGraphicUidFilter(i.graphics,t))return this._intersectResultToMapPoint(e)}return null}return this._intersectResultToMapPoint(o.results.min)}toScreen(e){if(!this.ready)return at.error("#toScreen()","Scene view cannot be used before it is ready"),null;const t=y(null==e.z&&Re(this.elevationProvider,e),0);return D(e,ct,this.renderSpatialReference,t),this.state.camera.projectToScreen(ct,ut),C(ut[0],ut[1])}pixelSizeAt(e){return this.ready?e?(D(e,ct,this.renderSpatialReference),this.state.camera.computeScreenPixelSizeAt(ct)):0:(at.error("#pixelSizeAt()","Scene view cannot be used before it is ready"),null)}overlayPixelSizeInMapUnits(e){const t=this.basemapTerrain.overlayManager;return t?t.overlayPixelSizeInMapUnits(e):1}hitTest(e,t){if(!this.ready)return at.error("#hitTest()","Scene view cannot be used before it is ready"),null;const i=Je(e)?Ke(this,e):e,r=O(i.x,i.y),s=t?this.externalToInternalIntersectOptions(t):this._defaultHitTestOptions;s.requiresGroundFeedback=!0,s.enableDraped=!0;const n=De(this.state.viewingMode);n.options.selectionMode=!0,n.options.store=We.ALL,this.sceneIntersectionHelper.intersectIntersectorScreen(r,n,s);const a=this._intersectResultsToHits(n.results.all,s.graphics),o=n.results.ground,l=Ne(o,this),p=f(l)&&"type"in l&&"integrated-mesh"===l.type?l:null,h={screenPoint:i,results:a,ground:{mapPoint:this._intersectResultToMapPoint(o),distance:ze(o)?o.distanceInRenderSpace:0,layer:p}};return Me.SCENEVIEW_HITTEST_RETURN_INTERSECTOR&&(h.intersector=n),Promise.resolve(h)}popupHitTest(e){return Qe(this,e).then((({results:t,ground:i})=>{let r=null;return!(0===t.length||Math.abs(y(t[0].distance,0)-i.distance)<1e-5)||i.layer&&"integrated-mesh"===i.layer.type||(r=i.mapPoint),{results:t,screenPoint:e,mapPoint:r}}))}goTo(e,t){return this.updatingHandles.addPromise(this.stateManager.goTo(e,t))}async whenAnalysisView(e){if(await this.whenReady(),m(e.parent))throw new o("view:no-analysisview-for-analysis","The analysis has not been added to view.analyses",{analysis:e});if("analysis"===e.parent.type){return(await this.whenLayerView(e.parent)).whenAnalysisView(e)}return this.analysisViewManager.whenAnalysisView(e)}whenLayerView(e){return super.whenLayerView(e)}takeScreenshot(e){return this.whenReady().then((()=>{const t=Xe(e,this);return t.pixelRatio/=this.state.pixelRatio,this._stage.renderView.takeScreenshot(Ze(t,this.supersampleScreenshotsEnabled,this.padding))}))}addUpdatingPromise(e){return this.updatingHandles.addPromise(e)}importLayerView(e){return le.importLayerView(e)}hasLayerViewModule(e){return le.hasLayerViewModule(e)}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){var e,t,i,r;return this.map&&"initialViewProperties"in this.map&&(null==(e=this.map)||null==(t=e.initialViewProperties)?void 0:t.spatialReference)||(null==(i=this.defaultsFromMap)?void 0:i.spatialReference)||(null==(r=this.defaultsFromMap)?void 0:r.ready)&&this._initialDefaultSpatialReference||null}async validate(){let e=et(this.type);if(d("safari")&&d("safari")<9&&(e=new o("sceneview:browser-not-supported","This browser is not supported by SceneView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:d("safari")})),f(e))throw at.warn("#validate()",e.message),e}get _predeterminedViewingMode(){var e,t;const i=this._isOverridden("viewingMode")?this._get("viewingMode"):null!=(e=this.map&&"initialViewProperties"in this.map?null==(t=this.map.initialViewProperties)?void 0:t.viewingMode:null)?e:null;return f(i)?oe(i):null}getSpatialReferenceSupport({spatialReference:e,layer:t}){const i=this._predeterminedViewingMode;if(f(i))return this._validateSpatialReferenceForViewingMode(e,t,i)?{constraints:this._makeSpatialReferenceConstraints(e,t,i)}:null;const r=this._validateSpatialReferenceForViewingMode(e,t,ne.Local),s=this._validateSpatialReferenceForViewingMode(e,t,ne.Global);return r||s?r&&s?{constraints:this._makeSpatialReferenceConstraints(e,t,null)}:r?{constraints:this._makeSpatialReferenceConstraints(e,t,ne.Local)}:{constraints:this._makeSpatialReferenceConstraints(e,t,ne.Global)}:null}_validateSpatialReferenceForViewingMode(e,t,i){return!!Ye(e,i)&&(!!m(t)||(!!X(t)||(!Z(t)||!m(He(t,e,i)))&&(!J(t)||i!==ne.Global)))}_makeSpatialReferenceConstraints(e,t,i){if(m(t))return[{spatialReference:e,viewingMode:i}];const r=e.isWebMercator,s=e.isWGS84;if(X(t)&&(r||s)){return!s||i===ne.Local||null===Ue(t.tileInfo,t.fullExtent,e,ne.Global)?[{spatialReference:e,viewingMode:i},{spatialReference:st.WebMercator,viewingMode:i}]:[{spatialReference:r?st.WGS84:st.WebMercator,viewingMode:i}]}return Z(t)||J(t)||!r&&!s?Z(t)&&r&&i!==ne.Global?[{spatialReference:e,viewingMode:i},{spatialReference:st.WGS84,viewingMode:ne.Local}]:[{spatialReference:e,viewingMode:i}]:[{spatialReference:e,viewingMode:i},{spatialReference:r?st.WGS84:st.WebMercator,viewingMode:i}]}_validateSpatialReference(e){const t=f(this.getSpatialReferenceSupport({spatialReference:e})),i=this._predeterminedViewingMode;return t||(f(i)?at.warnOnce(`Spatial reference defined on view not supported in ${ae(i)} viewing mode.`):e.isGeographic&&at.warnOnce("Spatial reference is geographic but not supported.")),t}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}computeMapPointFromVec3d(e,t){let i=this.spatialReference||st.WGS84;return F(e,this.renderSpatialReference,e,i)||(i=st.WGS84,F(e,this.renderSpatialReference,e,i)),t?(t.x=e[0],t.y=e[1],t.z=e[2],t.spatialReference=i):t=new nt(e,i),t}trackGraphicState(e){if(!e.graphic)return at.error("trackGraphicState","GraphicState.graphic must not be null or undefined to start tracking"),null;const t=this.getViewForGraphic(e.graphic);let i=null,r=!1;const s=t=>{var s;!r&&f(t)&&"processor"in t&&"graphics-3d"===(null==(s=t.processor)?void 0:s.type)&&t.processor.graphicsCore&&(i=t.processor.graphicsCore.trackGraphicState(e))};return f(t)?s(t):this.whenViewForGraphic(e.graphic,{waitForLayer:!0}).then((e=>s(e)),(()=>{})).catch((()=>{})),{remove:()=>{r=!0,f(i)&&(i.remove(),i=null)}}}highlight(e){if(Array.isArray(e))return p(e.map((e=>this.highlight(e))));if(n.isCollection(e))return p(e.toArray().map((e=>this.highlight(e))));const t=this.getViewForGraphic(e);return t&&"highlight"in t?t.highlight(e):h()}maskOccludee(e){if(!e)return at.error("maskOccludee","GraphicState.graphic must not be null or undefined to mask an occludee"),null;const t=this.getViewForGraphic(e);let i=null,r=!1;const s=t=>{!r&&f(t)&&$e(t)&&(i=t.maskOccludee(e))};return f(t)?s(t):this.whenViewForGraphic(e,{waitForLayer:!0}).then((e=>s(e)),(()=>{})).catch((()=>{})),{remove:()=>{r=!0,f(i)&&(i.remove(),i=null)}}}getViewForGraphic(e){return e.layer===this.graphics?this.graphicsView:e.layer?this.allLayerViews.find((t=>t.layer===e.layer)):null}graphicChanged(e){f(this.graphicsView)&&this.graphicsView.graphicChanged(e)}async whenViewForGraphic(e,t){if(e.layer===this)return await S((()=>this.graphicsView)),this.graphicsView;if(!e.layer||!this.map)throw new o("no-view-for-graphic");return t&&t.waitForLayer&&!this.map.allLayers.includes(e.layer)?new Promise(((t,i)=>{const r=this.map.allLayers.on("change",(s=>{s.added.includes(e.layer)&&(r.remove(),this.whenLayerView(e.layer).then(t,i))}))})):this.whenLayerView(e.layer)}externalToInternalIntersectOptions(e){const t=this._externalToInternalRenderItems(e.include,dt.INCLUDE),i=this._externalToInternalRenderItems(e.exclude,dt.EXCLUDE);return{include:t.layerUids,exclude:i.layerUids,graphics:{include:t.graphicUids,exclude:i.graphicUids}}}_intersectResultToMapPoint(e,t){return e.getIntersectionPoint(ct)?(t=this.computeMapPointFromVec3d(ct,t),e.intersector===qe.TERRAIN&&this.basemapTerrain&&(t.z=y(Re(this.basemapTerrain,t),0)),t):null}_intersectResultsToHits(e,t){const i=new Array;let r=null;for(let s=0;s<e.length;s++){const n=e[s],a=Ne(n,this);if(f(a)&&(a===this.map.ground||"type"in a&&"integrated-mesh"===a.type))break;const o=ke(n,this);if(m(o))continue;if(m(r)&&s!==e.length-1&&(r=new Set),f(r)){const e=this._getGraphicFilterUid(o);if(r.has(e))continue;r.add(e)}if(!this._testGraphicUidFilter(t,o))continue;const l=this._intersectResultToMapPoint(n),p=n.distanceInRenderSpace;i.push({graphic:o,mapPoint:l,distance:p})}return i}_getGraphicFilterUid(e){if(e.layer&&"objectIdField"in e.layer){const t=e.attributes[e.layer.objectIdField];if(t)return`o-${e.layer.id}-${t}`}return`u-${e.uid}`}_testGraphicUidFilter(e,t){const i=this._getGraphicFilterUid(t);return m(e)||(m(e.include)||e.include.has(i))&&(m(e.exclude)||!e.exclude.has(i))}_externalToInternalRenderItems(e,t,s={layerUids:null,graphicUids:null}){if(!e)return s;if(e instanceof i)pt(s,this._getGraphicFilterUid(e)),t===dt.INCLUDE&&(f(this.graphicsView)&&e.layer===this?lt(s,this.graphicsView.processor.layer.id):e.layer&&lt(s,e.layer.uid));else if(c(e))for(const i of e)i===this.graphics&&f(this.graphicsView)?lt(s,this.graphicsView.processor.layer.id):i instanceof r?i===this.map.ground&&lt(s,Be):this._externalToInternalRenderItems(i,t,s);else lt(s,e.uid);return s}_initBasemapTerrain(){this._set("basemapTerrain",new Ge({view:this})),this._set("elevationProvider",new be({view:this})),this.elevationProvider.register("ground",this.basemapTerrain)}_exitBasemapTerrain(){this.basemapTerrain&&(this.elevationProvider.unregister(this.basemapTerrain),this.elevationProvider.destroy(),this._set("elevationProvider",null),this.basemapTerrain.destroy(),this._set("basemapTerrain",null))}_initGlobe(){this._initCoordinateSystem(),this.state.createInitialCamera(),this._initBasemapTerrain(),this._set("pointsOfInterest",new Ie({view:this})),this._set("featureTiles",new ye({renderCoordsHelper:this.renderCoordsHelper,cameraOnSurface:this.pointsOfInterest.contentCameraOnSurface,focus:this.pointsOfInterest.focus,tilingSchemeOwner:this.basemapTerrain,viewState:this.state,scheduler:this._resourceController.scheduler,terrain:this.basemapTerrain}));const e=()=>{const e=this.basemapTerrain&&this.basemapTerrain.extent;if(this.clippingArea||e)if(e&&this.basemapTerrain.spatialReference){const e=f(this.basemapTerrain.extent)?A(z(this.basemapTerrain.extent,this.basemapTerrain.spatialReference),this.spatialReference):null;f(this.clippingArea)?this.featureTiles.filterExtent=this.clippingArea.intersection(e):this.featureTiles.filterExtent=e}else this.featureTiles.filterExtent=this.clippingArea;else this.featureTiles.filterExtent=null};this.handles.add([this.updatingHandles.add((()=>Me.FEATURE_TILE_TREE_SHOW_TILES),(e=>{e&&this.featureTiles&&!this.featureTreeDebugger?this.updatingHandles.addPromise(import("./3d/layers/support/FeatureTileTree3DDebugger.js")).then((({FeatureTileTree3DDebugger:e})=>{!this.featureTreeDebugger&&Me.FEATURE_TILE_TREE_SHOW_TILES&&(this.featureTreeDebugger=new e({view:this}))})):e||!this.featureTreeDebugger||Me.FEATURE_TILE_TREE_SHOW_TILES||(this.featureTreeDebugger.destroy(),this.featureTreeDebugger=null)}),M),this.updatingHandles.add((()=>this.clippingArea),e,M),this.updatingHandles.add((()=>this.basemapTerrain.extent),e,M)],"feature-tiles"),this.stateManager.init()}_exitGlobe(){this.state&&(this.stateManager.deinit(),this.handles.remove("render-coords-helper"),this.handles.remove("feature-tiles"),this.featureTiles.destroy(),this._set("featureTiles",null),this.pointsOfInterest.destroy(),this._set("pointsOfInterest",null),this._exitBasemapTerrain(),this.state.exit(),this._exitCoordinateSystem())}_initCoordinateSystem(){if(this.spatialReference){const e=this.spatialReference;this.mapCoordsHelper&&this.mapCoordsHelper.spatialReference.equals(e)||this._set("mapCoordsHelper",new Te(this.map,e));const t=this.state.isGlobal,i=B(t,e);i!==this.renderSpatialReference&&(this._set("renderCoordsHelper",xe.create(this.state.viewingMode,i)),t||this.handles.add(this.watch("basemapTerrain.extent",(e=>{const t=this.renderCoordsHelper.spatialReference;0===e[0]&&0===e[1]&&0===e[2]&&0===e[3]||!W(e,this.basemapTerrain.spatialReference,gt,t)||(this.renderCoordsHelper.extent=gt)}),!0),"render-coords-helper"),this.sceneIntersectionHelper&&this.sceneIntersectionHelper.setTolerance(Fe/this.renderCoordsHelper.unitInMeters))}else this._set("mapCoordsHelper",null),this._set("renderCoordsHelper",null)}_exitCoordinateSystem(){this.mapCoordsHelper&&(this.handles.remove("render-coords-helper"),this._set("renderCoordsHelper",null),this._set("mapCoordsHelper",null))}_updatingChanged(){this.notifyChange("updating")}_updateUpdatingMonitors(e=null){f(e)&&e.type===w.MOVE||(this.handles.remove("updatingMonitors"),this.allLayerViews.forEach((e=>{e.destroyed||(this.handles.add([e.watch(["updating","updatingProgress"],(()=>this._updatingChanged()),!0)],"updatingMonitors"),e.when((()=>this._updatingChanged()),(()=>this._updatingChanged())))})),this._updatingChanged())}_renderScreenshotOverlay(e,t){if(!this.overlay||!this.overlay.hasVisibleItems)return t;const i=e.getContext("2d");return i.putImageData(t,0,0),this.overlay.renderCanvas(e),i.getImageData(0,0,t.width,t.height)}_initStage(){const e={deactivatedWebGLExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions,alpha:this.alphaCompositingEnabled,canvas:this.renderCanvas,screenshot:{renderOverlay:(e,t)=>this._renderScreenshotOverlay(e,t)}},t=new _e(this.state.viewingMode,(e=>this._stage.layers.forAll(e)),this);this._set("sceneIntersectionHelper",t);const i=a(this.surface),{resourceController:r,state:s,renderSpatialReference:n}=this;this._stage=new Ae({options:e,container:i,resourceController:r,state:s,sceneIntersectionHelper:t,renderSR:n}),this._stage.renderView.setRenderParameters({slicePlane:this.slicePlane}),this._lostWebGLContextHandle=l(this._stage.renderView.canvas,"webglcontextlost",(()=>this.fatalError=new o("webgl-context-lost"))),this.handles.add([this.updatingHandles.add((()=>this.qualitySettings.antialiasingEnabled),(()=>this._stage.renderView.setRenderParameters({antialiasingEnabled:this.qualitySettings.antialiasingEnabled})),b),this.updatingHandles.add((()=>this.qualitySettings.highQualityTransparency),(()=>this._stage.renderView.setRenderParameters({highQualityTransparency:this.qualitySettings.highQualityTransparency})),b),R((()=>this.magnifier),(e=>this._stage.renderView.magnifier=e),M)],"stage");const p=()=>{this._stage.renderView.setRenderParameters({defaultHighlightOptions:Ve.toEngineOptions(this.highlightOptions)})};this.handles.add(this.updatingHandles.add((()=>[this.highlightOptions.color,this.highlightOptions.haloColor,this.highlightOptions.haloOpacity,this.highlightOptions.fillOpacity,this.highlightOptions.shadowOpacity,this.highlightOptions.shadowColor,this.highlightOptions.shadowDifference]),p),"stage"),p(),this.renderCoordsHelper&&this.sceneIntersectionHelper.setTolerance(Fe/this.renderCoordsHelper.unitInMeters),this._set("canvas",this._stage.renderView.canvas)}_exitStage(){this._set("sceneIntersectionHelper",null),this._stage.destroy(),this._stage=null,this._lostWebGLContextHandle.remove(),this._lostWebGLContextHandle=null,this.handles.remove("stage"),this._set("canvas",null)}_initSurface(e){this._exitSurface(),this.state.init(e,this.spatialReference),this._initStage(),this._initGlobe(),this.sharedSymbolResources=new Pe({view:this,viewingMode:e,resourceController:this._resourceController,pointsOfInterest:this.pointsOfInterest,viewState:this.state,objectResourceCache:new fe})}_exitSurface(){this.sharedSymbolResources&&(this.sharedSymbolResources.objectResourceCache.destroy(),this.sharedSymbolResources.destroy(),this.sharedSymbolResources=null,this._exitGlobe(),this._exitStage())}_createGraphicsViewIfNeeded(){if(this.graphicsView||this._createGraphicsViewController)return;if(0===this.graphics.length)return;this.handles.remove("graphics-view"),this._createGraphicsViewController=new AbortController;const e=()=>{this._createGraphicsViewController=null,this._updatingChanged()};this._createGraphicsViewAsync(this._createGraphicsViewController.signal).then(e,e),this._updatingChanged()}async _createGraphicsViewAsync(e){const t=(await import("./3d/layers/GraphicsView3D.js")).default;v(e),await S((()=>{var e;return!0===(null==(e=this.basemapTerrain)?void 0:e.ready)}),e),this._set("graphicsView",new t({view:this}))}_disposeGraphicsView(){this._createGraphicsViewController&&(this._createGraphicsViewController.abort(),this._createGraphicsViewController=null),this.handles.remove("graphics-view"),f(this.graphicsView)&&(this.handles.remove(this.graphicsView.processor.layer.id),this.graphicsView.destroy(),this._set("graphicsView",null))}_startup(){const e=oe(this.viewingMode);if(e===ne.Global&&(this._clippingArea=null),this._initSurface(e),this._set("ready",!0),this.handles.add(_((()=>this.graphics),"after-changes",(()=>this._createGraphicsViewIfNeeded())),"graphics-view"),this._createGraphicsViewIfNeeded(),!this._externallySet.environment){const e=this.get("map.initialViewProperties.environment");e&&(this.environment=e)}this.labeler.setup(),this.environmentManager.connectView(this),this.inputManager.connect();const t=this._resolveWhenReady;this._resolveWhenReady=[],t.forEach((e=>e(this)))}_teardown(){this._initialDefaultSpatialReference=null,this.inputManager.disconnect(),this.environmentManager.disconnectView(),this.labeler.dispose(),this._disposeGraphicsView(),this.handles.remove("graphics-view"),this._exitSurface(),this._set("ready",!1)}_updateDefaultToMapOptions(){if(this._defaultToMapOptions.include.clear(),this.map){this.map.ground&&this._defaultToMapOptions.include.add(Be);for(const e of this.map.allLayers.items)"integrated-mesh"===e.type&&this._defaultToMapOptions.include.add(e.uid)}}_updateDefaultHitTestOptions(){if(this._defaultHitTestOptions.exclude.clear(),this.map){this.map.ground&&this.map.ground.opacity<1&&this._defaultHitTestOptions.exclude.add(Be);for(const e of this.map.allLayers.items)"integrated-mesh"===e.type&&e.opacity<1&&this._defaultToMapOptions.exclude.add(e.uid)}}getVoxelWasmPerSceneView(){return $.getInstance().getVoxelWasmPerSceneView(this)}};function lt(e,t){e.layerUids||(e.layerUids=new Set),e.layerUids.add(t)}function pt(e,t){e.graphicUids||(e.graphicUids=new Set),e.graphicUids.add(t)}function ht(e,t){return f(e)&&U(e.spatialReference,t)?A(e,t):null}var dt;e([E()],ot.prototype,"_userClippingArea",void 0),e([E()],ot.prototype,"_resourceController",void 0),e([E()],ot.prototype,"_stage",void 0),e([E({readOnly:!0})],ot.prototype,"deconflictor",void 0),e([E({readOnly:!0})],ot.prototype,"labeler",void 0),e([E(L(K,"analyses"))],ot.prototype,"analyses",void 0),e([E({type:se,readOnly:!0,aliasOf:"state.animation"})],ot.prototype,"animation",void 0),e([E({readOnly:!0})],ot.prototype,"basemapTerrain",void 0),e([E({readOnly:!0})],ot.prototype,"elevationProvider",void 0),e([E({type:t,aliasOf:"stateManager.camera"})],ot.prototype,"camera",void 0),e([E({type:t,aliasOf:"stateManager.contentCamera"})],ot.prototype,"contentCamera",void 0),e([E({readOnly:!0})],ot.prototype,"canvas",void 0),e([E({type:nt,aliasOf:"stateManager.center"})],ot.prototype,"center",void 0),e([E({type:rt})],ot.prototype,"clippingArea",null),e([E({type:he})],ot.prototype,"constraints",void 0),e([E({type:rt,readOnly:!0})],ot.prototype,"renderDataExtent",null),e([E({type:rt,readOnly:!0})],ot.prototype,"dataExtent",null),e([E({type:rt,readOnly:!0})],ot.prototype,"groundAndLayersExtent",null),e([E({value:null,type:de})],ot.prototype,"environment",null),e([j("environment")],ot.prototype,"castEnvironment",null),e([E({readOnly:!0})],ot.prototype,"environmentManager",void 0),e([E({type:rt,aliasOf:"stateManager.extent"})],ot.prototype,"extent",void 0),e([E()],ot.prototype,"floors",void 0),e([E({readOnly:!0,aliasOf:"stateManager.screenCenter"})],ot.prototype,"screenCenter",void 0),e([E({aliasOf:"stateManager.frustum"})],ot.prototype,"frustum",void 0),e([E({type:Number,readOnly:!0})],ot.prototype,"fullOpacity",void 0),e([E({readOnly:!0})],ot.prototype,"graphicsView",void 0),e([E({readOnly:!0})],ot.prototype,"analysisViewManager",void 0),e([E()],ot.prototype,"groundView",void 0),e([E({type:Boolean})],ot.prototype,"initialExtentRequired",null),e([E()],ot.prototype,"_defaultsFromMapSettings",null),e([E({type:Boolean,readOnly:!0})],ot.prototype,"interacting",null),e([E()],ot.prototype,"stationary",null),e([E({aliasOf:"state.navigating"})],ot.prototype,"navigating",void 0),e([E()],ot.prototype,"map",void 0),e([E({readOnly:!0})],ot.prototype,"mapCoordsHelper",void 0),e([E({aliasOf:"stateManager.padding"})],ot.prototype,"padding",void 0),e([E({type:Ie,readOnly:!0})],ot.prototype,"pointsOfInterest",void 0),e([E({type:ye,readOnly:!0})],ot.prototype,"featureTiles",void 0),e([E()],ot.prototype,"featureTreeDebugger",void 0),e([E({type:Boolean})],ot.prototype,"screenSizePerspectiveEnabled",void 0),e([E({constructOnly:!0})],ot.prototype,"deactivatedWebGLExtensions",void 0),e([E({constructOnly:!0})],ot.prototype,"debugWebGLExtensions",void 0),e([E({constructOnly:!0})],ot.prototype,"renderCanvas",void 0),e([E({constructOnly:!0})],ot.prototype,"state",void 0),e([E({readOnly:!0})],ot.prototype,"inputManager",void 0),e([E({readOnly:!0})],ot.prototype,"stateManager",void 0),e([E({type:["low","medium","high"]})],ot.prototype,"qualityProfile",null),e([E({type:Oe,get(){let e=this._get("qualitySettings");return e||(e=new Oe,Se.apply(this.qualityProfile,e)),e}})],ot.prototype,"qualitySettings",void 0),e([E()],ot.prototype,"slicePlane",null),e([E({readOnly:!0})],ot.prototype,"typeSpecificPreconditionsReady",null),e([E({readOnly:!0})],ot.prototype,"renderCoordsHelper",void 0),e([E({readOnly:!0})],ot.prototype,"sceneIntersectionHelper",void 0),e([E({type:Number,dependsOn:["scale","spatialReference"],readOnly:!0})],ot.prototype,"resolution",null),e([E({type:Number,aliasOf:"stateManager.scale"})],ot.prototype,"scale",void 0),e([E()],ot.prototype,"heightModelInfo",null),e([E()],ot.prototype,"spatialReference",void 0),e([E({type:Boolean,constructOnly:!0})],ot.prototype,"alphaCompositingEnabled",void 0),e([E({type:Boolean})],ot.prototype,"supersampleScreenshotsEnabled",void 0),e([E({readOnly:!0})],ot.prototype,"type",void 0),e([E({type:tt})],ot.prototype,"ui",void 0),e([E({type:Boolean,readOnly:!0,dependsOn:["graphicsView.updating","basemapView.updating","basemapTerrain.updating","layerViewManager.updating","layerViewManager.updatingRemaining","_resourceController.updating","_stage.updating","featureTiles.updating","pointsOfInterest.updating","environmentManager.updating","overlay.updating","updatingHandles.updating","featureTreeDebugger.updating","labeler.updating","deconflictor.updating","ready","stationary","inputManager.hasPendingInputs","toolViewManager.updating","analysisViewManager.updating"]})],ot.prototype,"updating",null),e([E({type:Number,readOnly:!0,dependsOn:["updating"]})],ot.prototype,"updatingProgress",void 0),e([E({type:["global","local"]})],ot.prototype,"viewingMode",null),e([E({type:s,aliasOf:"stateManager.viewpoint"})],ot.prototype,"viewpoint",void 0),e([E({type:Number,aliasOf:"stateManager.zoom"})],ot.prototype,"zoom",void 0),e([E({type:Ve})],ot.prototype,"highlightOptions",void 0),ot=e([P("esri.views.SceneView")],ot),function(e){e[e.INCLUDE=0]="INCLUDE",e[e.EXCLUDE=1]="EXCLUDE"}(dt||(dt={}));const ct=G(),ut=O(),gt=q(),mt=ot;export{mt 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.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../Graphic.js";import r from"../../core/Error.js";import{unwrap as i,isNone as o}from"../../core/maybe.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{combinedViewLayerTimeExtentProperty as n}from"../../layers/support/commonProperties.js";import{getDefaultDatumTransformationForDataset as l,projectExtent as u}from"../../layers/support/rasterFunctions/rasterProjectionHelper.js";import{getFetchPopupTemplate as p}from"./support/popupUtils.js";const m=m=>{let f=class extends m{constructor(){super(...arguments),this._rasterFieldPrefix="Raster.",this.layer=null,this.view=null,this.tileInfo=null}get fullExtent(){return this._getfullExtent()}_getfullExtent(){return this.projectFullExtent(this.view.spatialReference)}get hasTilingEffects(){return this.layer.renderer&&"dynamicRangeAdjustment"in this.layer.renderer&&this.layer.renderer.dynamicRangeAdjustment}get datumTransformation(){return l(i(this.layer.fullExtent),this.view.spatialReference,!0)}supportsSpatialReference(t){return!!this.projectFullExtent(t)}projectFullExtent(t){const e=i(this.layer.fullExtent),r=l(e,t,!1);return u(e,t,r)}async fetchPopupFeatures(t,i){const{layer:s}=this;if(!t)return Promise.reject(new r("imageryTileLayerView:fetchPopupFeatures","Nothing to fetch without area",{layer:s}));const{popupEnabled:a}=s,n=p(s,i);if(!a||o(n))throw new r("imageryTileLayerView:fetchPopupFeatures","Missing required popupTemplate or popupEnabled",{popupEnabled:a,popupTemplate:n});const l=[],{value:u,magdirValue:m}=await s.identify(t,{timeExtent:this.timeExtent});let f="";if(u&&u.length){var c,d;f="imagery-tile"===s.type&&s.hasStandardTime()&&null!=u[0]?u.map((t=>s.getStandardTimeValue(t))).join(", "):u.join(", ");const t={ObjectId:0},r="Raster.ServicePixelValue";t[r]=this._formatAttributeValue(f,r);const i=null==(c=s.rasterInfo)||null==(d=c.attributeTable)?void 0:d.features;if(i&&i.length>0){const e=i.filter((t=>{const e=t.attributes.value||t.attributes.Value||t.attributes.VALUE;return String(e)===f}));if(e.length>0){const r=e[0];if(r)for(const e in r.attributes)if(r.attributes.hasOwnProperty(e)){const i=this._rasterFieldPrefix+e;t[i]=this._formatAttributeValue(r.attributes[e],i)}}}const o=s.rasterInfo.dataType;"vector-magdir"!==o&&"vector-uv"!==o||(t["Raster.Magnitude"]=null==m?void 0:m[0],t["Raster.Direction"]=null==m?void 0:m[1]);const a=new e(this.fullExtent.clone(),null,t);a.layer=s,a.sourceLayer=a.layer,l.push(a)}return l}_formatAttributeValue(t,e){if("string"==typeof t){const r=this.layer.popupTemplate&&this.layer.popupTemplate.fieldInfos,i=this._getFieldInfo(r,e),o=i&&i.format;if(o){let e,r;return t.trim().includes(",")?(e=",",r=e+" ",this._formatDelimitedString(t,e,r,o)):t.trim().includes(" ")?(e=r=" ",this._formatDelimitedString(t,e,r,o)):this._formatNumberFromString(t,o)}}return t}_getFieldInfo(t,e){if(!t||!t.length||!e)return;const r=e.toLowerCase();let i;return t.some((t=>!(!t.fieldName||t.fieldName.toLowerCase()!==r&&t.fieldName.toLowerCase()!==r.replace(/ /g,"_"))&&(i=t,!0))),i}_formatDelimitedString(t,e,r,i){return t&&e&&r&&i?t.trim().split(e).map((t=>this._formatNumberFromString(t,i))).join(r):t}_formatNumberFromString(t,e){if(!t||!e)return t;const r=Number(t);return isNaN(r)?t:e.format(r)}};return t([s()],f.prototype,"layer",void 0),t([s(n)],f.prototype,"timeExtent",void 0),t([s()],f.prototype,"view",void 0),t([s()],f.prototype,"fullExtent",null),t([s()],f.prototype,"tileInfo",void 0),t([s({readOnly:!0})],f.prototype,"hasTilingEffects",null),f=t([a("esri.views.layers.ImageryTileLayerView")],f),f};export{m as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../Graphic.js";import r from"../../core/Error.js";import{unwrap as i,isNone as o}from"../../core/maybe.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{combinedViewLayerTimeExtentProperty as n}from"../../layers/support/commonProperties.js";import{getDefaultDatumTransformationForDataset as l,projectExtent as u}from"../../layers/support/rasterFunctions/rasterProjectionHelper.js";import{getFetchPopupTemplate as p}from"./support/popupUtils.js";const m=m=>{let f=class extends m{constructor(){super(...arguments),this._rasterFieldPrefix="Raster.",this.layer=null,this.view=null,this.tileInfo=null}get fullExtent(){return this._getfullExtent()}_getfullExtent(){return this.projectFullExtent(this.view.spatialReference)}get hasTilingEffects(){return this.layer.renderer&&"dynamicRangeAdjustment"in this.layer.renderer&&this.layer.renderer.dynamicRangeAdjustment}get datumTransformation(){return l(i(this.layer.fullExtent),this.view.spatialReference,!0)}supportsSpatialReference(t){return!!this.projectFullExtent(t)}projectFullExtent(t){const e=i(this.layer.fullExtent),r=l(e,t,!1);return u(e,t,r)}async fetchPopupFeatures(t,i){const{layer:s}=this;if(!t)throw new r("imageryTileLayerView:fetchPopupFeatures","Nothing to fetch without area",{layer:s});const{popupEnabled:a}=s,n=p(s,i);if(!a||o(n))throw new r("imageryTileLayerView:fetchPopupFeatures","Missing required popupTemplate or popupEnabled",{popupEnabled:a,popupTemplate:n});const l=[],{value:u,magdirValue:m}=await s.identify(t,{timeExtent:this.timeExtent});let f="";if(u&&u.length){var c,d;f="imagery-tile"===s.type&&s.hasStandardTime()&&null!=u[0]?u.map((t=>s.getStandardTimeValue(t))).join(", "):u.join(", ");const t={ObjectId:0},r="Raster.ServicePixelValue";t[r]=this._formatAttributeValue(f,r);const i=null==(c=s.rasterInfo)||null==(d=c.attributeTable)?void 0:d.features;if(i&&i.length>0){const e=i.filter((t=>{const e=t.attributes.value||t.attributes.Value||t.attributes.VALUE;return String(e)===f}));if(e.length>0){const r=e[0];if(r)for(const e in r.attributes)if(r.attributes.hasOwnProperty(e)){const i=this._rasterFieldPrefix+e;t[i]=this._formatAttributeValue(r.attributes[e],i)}}}const o=s.rasterInfo.dataType;"vector-magdir"!==o&&"vector-uv"!==o||(t["Raster.Magnitude"]=null==m?void 0:m[0],t["Raster.Direction"]=null==m?void 0:m[1]);const a=new e(this.fullExtent.clone(),null,t);a.layer=s,a.sourceLayer=a.layer,l.push(a)}return l}_formatAttributeValue(t,e){if("string"==typeof t){const r=this.layer.popupTemplate&&this.layer.popupTemplate.fieldInfos,i=this._getFieldInfo(r,e),o=i&&i.format;if(o){let e,r;return t.trim().includes(",")?(e=",",r=e+" ",this._formatDelimitedString(t,e,r,o)):t.trim().includes(" ")?(e=r=" ",this._formatDelimitedString(t,e,r,o)):this._formatNumberFromString(t,o)}}return t}_getFieldInfo(t,e){if(!t||!t.length||!e)return;const r=e.toLowerCase();let i;return t.some((t=>!(!t.fieldName||t.fieldName.toLowerCase()!==r&&t.fieldName.toLowerCase()!==r.replace(/ /g,"_"))&&(i=t,!0))),i}_formatDelimitedString(t,e,r,i){return t&&e&&r&&i?t.trim().split(e).map((t=>this._formatNumberFromString(t,i))).join(r):t}_formatNumberFromString(t,e){if(!t||!e)return t;const r=Number(t);return isNaN(r)?t:e.format(r)}};return t([s()],f.prototype,"layer",void 0),t([s(n)],f.prototype,"timeExtent",void 0),t([s()],f.prototype,"view",void 0),t([s()],f.prototype,"fullExtent",null),t([s()],f.prototype,"tileInfo",void 0),t([s({readOnly:!0})],f.prototype,"hasTilingEffects",null),f=t([a("esri.views.layers.ImageryTileLayerView")],f),f};export{m as default};