@arcgis/core 4.31.0-next.20240607 → 4.31.0-next.20240608

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 (79) hide show
  1. package/README.md +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{fa5e171c8ce844363b6c.js → 465c718f0b9f7ba0f1ea.js} +1 -1
  4. package/assets/esri/core/workers/chunks/4e2943968517e385bd12.js +1 -0
  5. package/assets/esri/core/workers/chunks/5f3600a6d7159228731d.js +1 -0
  6. package/assets/esri/core/workers/chunks/ace3297f0f314c3724da.js +1 -0
  7. package/assets/esri/core/workers/chunks/{342426c8a8c9f5f84811.js → b62e942e675d5770ea24.js} +1 -1
  8. package/assets/esri/core/workers/chunks/c660649465058ef82045.js +1 -0
  9. package/assets/esri/core/workers/chunks/{4faf7055457c04dc9fc1.js → cd03ad7dc45fbbeb1a2f.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{6a943f384fcd0af5888b.js → e66ebcfffd081f847efe.js} +1 -1
  11. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  12. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  13. package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core-simd.wasm +0 -0
  14. package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core.wasm +0 -0
  15. package/assets/esri/themes/base/widgets/_BasemapLayerList.scss +8 -0
  16. package/assets/esri/themes/base/widgets/_CatalogLayerList.scss +8 -0
  17. package/assets/esri/themes/base/widgets/_LayerList.scss +8 -0
  18. package/assets/esri/themes/base/widgets/_Print.scss +12 -0
  19. package/assets/esri/themes/base/widgets/_TableList.scss +8 -0
  20. package/assets/esri/themes/dark/main.css +1 -1
  21. package/assets/esri/themes/light/main.css +1 -1
  22. package/assets/esri/themes/light/view.css +1 -1
  23. package/chunks/Terrain.glsl.js +3 -1
  24. package/chunks/lyr3DWorker.js +1 -1
  25. package/interfaces.d.ts +152 -32
  26. package/layers/CatalogLayer.js +1 -1
  27. package/layers/MapImageLayer.js +1 -1
  28. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  29. package/layers/support/Sublayer.js +1 -1
  30. package/layers/support/arcgisLayers.js +1 -1
  31. package/package.json +1 -1
  32. package/smartMapping/renderers/size.js +1 -1
  33. package/support/elevationInfoUtils.js +1 -1
  34. package/support/revision.js +1 -1
  35. package/symbols/support/styleUtils.js +1 -1
  36. package/views/3d/analysis/Viewshed/FieldOfViewManipulation.js +1 -1
  37. package/views/3d/analysis/Viewshed/ScaleOrientManipulation.js +1 -1
  38. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  39. package/views/3d/interactive/editingTools/manipulatorUtils.js +1 -1
  40. package/views/3d/interactive/editingTools/originGeometryVisualElementUtils.js +1 -1
  41. package/views/3d/layers/BuildingSceneLayerView3D.js +1 -1
  42. package/views/3d/layers/TiledLayerView3D.js +1 -1
  43. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  44. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  45. package/views/3d/state/NearFarHeuristic.js +1 -1
  46. package/views/3d/terrain/OverlayRenderer.js +1 -1
  47. package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
  48. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  49. package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
  50. package/webdoc/support/webdocSaveUtils.js +1 -1
  51. package/widgets/BasemapLayerList/css.js +1 -1
  52. package/widgets/BasemapLayerList.js +1 -1
  53. package/widgets/CatalogLayerList/css.js +1 -1
  54. package/widgets/CatalogLayerList.js +1 -1
  55. package/widgets/Feature/support/featureUtils.js +1 -1
  56. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  57. package/widgets/FeatureTable/FieldColumn.js +1 -1
  58. package/widgets/FeatureTable/Grid/Column.js +1 -1
  59. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  60. package/widgets/FeatureTable/RelationshipColumn.js +1 -1
  61. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  62. package/widgets/FeatureTable/support/tableUtils.js +1 -1
  63. package/widgets/FeatureTable.js +1 -1
  64. package/widgets/Features/FeaturesViewModel.js +1 -1
  65. package/widgets/Fullscreen.js +1 -1
  66. package/widgets/LayerList/css.js +1 -1
  67. package/widgets/LayerList.js +1 -1
  68. package/widgets/Locate.js +1 -1
  69. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  70. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  71. package/widgets/Print/PrintViewModel.js +1 -1
  72. package/widgets/Print.js +1 -1
  73. package/widgets/TableList/css.js +1 -1
  74. package/widgets/TableList.js +1 -1
  75. package/widgets/Track.js +1 -1
  76. package/assets/esri/core/workers/chunks/441f3eaef3b703dd1026.js +0 -1
  77. package/assets/esri/core/workers/chunks/ba988cd3a49987a0fb83.js +0 -1
  78. package/assets/esri/core/workers/chunks/c70683b7183458b338f8.js +0 -1
  79. package/assets/esri/core/workers/chunks/d03ada1212b13e76bff4.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.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import{whenOnce as i}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import{LayerViewPerformanceInfo as l}from"./support/LayerViewPerformanceInfo.js";import{updatingProgress as s,updatingProgressValue as n}from"../support/updatingProperties.js";import{checkIfTileInfoSupportedForView as o}from"../terrain/terrainUtils.js";const c=c=>{let p=class extends c{constructor(){super(...arguments),this.hasMixedImageFormats=!0}get imageFormatIsOpaque(){return!1}get fullExtent(){return this.layer.fullExtent}get isOpaque(){return this.fullOpacity>=1&&this.imageFormatIsOpaque}get dataScaleRange(){const e=this.tileInfo.lods;let t=e[0].scale,i=e[e.length-1].scale;if("tilemapCache"in this.layer&&this.layer.tilemapCache){const{effectiveMinLOD:e,effectiveMaxLOD:a}=this.layer.tilemapCache;t=this.tileInfo.lodAt(e).scale,i=this.tileInfo.lodAt(a).scale}return{minScale:t,maxScale:i}}get dataLevelRange(){const{minScale:e,maxScale:t}=this.dataScaleRange;return this.levelRangeFromScaleRange(e,t)}get displayLevelRange(){const e=this.layer.minScale||this.dataScaleRange.minScale,t=this.layer.maxScale||this.dataScaleRange.maxScale,i=this.levelRangeFromScaleRange(e,t);return this.layer.maxScale&&i.maxLevel++,i}get performanceInfo(){return new l(this.view.basemapTerrain.getUsedMemoryForLayerView(this))}getTileUrl(e){return this.layer.getTileUrl(e[0],e[1],e[2])}_addTilingSchemeMatchPromise(){if(null==this.fullExtent)return this.addResolvingPromise(Promise.reject(new t("tilingscheme:extent-not-defined","This layer doesn't define a fullExtent.")));const e=this._getTileInfoSupportError(this.tileInfo,this.fullExtent);if(e)return this.addResolvingPromise(Promise.reject(e));this.addResolvingPromise(i((()=>this.view?.basemapTerrain?.tilingSchemeLocked)).then((()=>{const e=this.view.basemapTerrain.tilingScheme,t="tilemapCache"in this.layer?this.layer.tilemapCache?.effectiveMaxLOD:void 0,i=this._getTileInfoCompatibilityError(this.tileInfo,e,t);if(i)throw i})))}_getTileInfoSupportError(e,i){const a=o(e,i,this.view.spatialReference,this.view.state.viewingMode,"tilemapCache"in this.layer?this.layer.tilemapCache?.effectiveMaxLOD:void 0);if(!a)return;const r={layer:this.layer,error:a};switch(a.name){case"tilingscheme:spatial-reference-mismatch":case"tilingscheme:global-unsupported-spatial-reference":case"tilingscheme:local-unsupported-spatial-reference":return new t("layerview:spatial-reference-incompatible","The spatial reference of this layer does not meet the requirements of the view",r);default:return new t("layerview:tiling-scheme-unsupported","The tiling scheme of this layer is not supported by SceneView",r)}}_getTileInfoCompatibilityError(e,i,a){return null!=e&&i.compatibleWith(e,a)?null:new t("layerview:tiling-scheme-incompatible","The tiling scheme of this layer is incompatible with the tiling scheme of the surface")}levelRangeFromScaleRange(e,t){const i={minLevel:0,maxLevel:1/0},a=this.view&&this.view.basemapTerrain&&this.view.basemapTerrain.tilingScheme;if(!a)return i;const r=a.levels[0],l=e=>{const t=Math.log(r.scale/e)/Math.LN2;return.5-Math.abs(.5-t%1)<1e-9?Math.round(t):Math.ceil(t)};return null!=e&&e>0&&(i.minLevel=Math.max(0,l(e))),null!=t&&t>0&&(i.maxLevel=Math.max(0,l(t))),i}isUpdating(){return!!(this.view&&this.view.basemapTerrain&&this.view.basemapTerrain.updating)}};return e([a({readOnly:!0})],p.prototype,"imageFormatIsOpaque",null),e([a({readOnly:!0})],p.prototype,"updating",void 0),e([a(s)],p.prototype,"updatingProgress",void 0),e([a(n)],p.prototype,"updatingProgressValue",void 0),e([a()],p.prototype,"hasMixedImageFormats",void 0),e([a()],p.prototype,"fullExtent",null),e([a({readOnly:!0})],p.prototype,"isOpaque",null),e([a()],p.prototype,"dataScaleRange",null),e([a({readOnly:!0})],p.prototype,"dataLevelRange",null),e([a({readOnly:!0})],p.prototype,"displayLevelRange",null),e([a()],p.prototype,"layer",void 0),p=e([r("esri.views.3d.layers.TiledLayerView3D")],p),p};export{c as TiledLayerView3D};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import{whenOnce as i}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import{LayerViewPerformanceInfo as l}from"./support/LayerViewPerformanceInfo.js";import{updatingProgress as s,updatingProgressValue as n}from"../support/updatingProperties.js";import{checkIfTileInfoSupportedForView as o}from"../terrain/terrainUtils.js";import{isScaleRangeActive as c,validateScaleRange as h}from"../../support/layerViewUtils.js";const p=p=>{let m=class extends p{constructor(){super(...arguments),this.hasMixedImageFormats=!0}get imageFormatIsOpaque(){return!1}get fullExtent(){return this.layer.fullExtent}get isOpaque(){return this.fullOpacity>=1&&this.imageFormatIsOpaque}get visibleAtCurrentScale(){if(!c(this.layer.minScale,this.layer.maxScale)||!this.view.terrainScale)return!0;const e=Math.round(this.view.basemapTerrain.tilingScheme.levelAtScale(this.view.terrainScale));return e>=this.displayLevelRange.minLevel&&e<=this.displayLevelRange.maxLevel}get dataScaleRange(){const e=this.tileInfo.lods;let t=e[0].scale,i=e[e.length-1].scale;if("tilemapCache"in this.layer&&this.layer.tilemapCache){const{effectiveMinLOD:e,effectiveMaxLOD:a}=this.layer.tilemapCache;t=this.tileInfo.lodAt(e).scale,i=this.tileInfo.lodAt(a).scale}return{minScale:t,maxScale:i}}canResume(){const e=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&!this.parent?.suspended&&this.view?.ready&&h(e)&&this.visibleAtCurrentTimeExtent||!1}get dataLevelRange(){const{minScale:e,maxScale:t}=this.dataScaleRange;return this.levelRangeFromScaleRange(e,t)}get displayLevelRange(){const e=this.layer.minScale||this.dataScaleRange.minScale,t=this.layer.maxScale||this.dataScaleRange.maxScale,i=this.levelRangeFromScaleRange(e,t);return this.layer.maxScale&&i.maxLevel++,i}get performanceInfo(){return new l(this.view.basemapTerrain.getUsedMemoryForLayerView(this))}getTileUrl(e){return this.layer.getTileUrl(e[0],e[1],e[2])}_addTilingSchemeMatchPromise(){if(null==this.fullExtent)return this.addResolvingPromise(Promise.reject(new t("tilingscheme:extent-not-defined","This layer doesn't define a fullExtent.")));const e=this._getTileInfoSupportError(this.tileInfo,this.fullExtent);if(e)return this.addResolvingPromise(Promise.reject(e));this.addResolvingPromise(i((()=>this.view?.basemapTerrain?.tilingSchemeLocked)).then((()=>{const e=this.view.basemapTerrain.tilingScheme,t="tilemapCache"in this.layer?this.layer.tilemapCache?.effectiveMaxLOD:void 0,i=this._getTileInfoCompatibilityError(this.tileInfo,e,t);if(i)throw i})))}_getTileInfoSupportError(e,i){const a=o(e,i,this.view.spatialReference,this.view.state.viewingMode,"tilemapCache"in this.layer?this.layer.tilemapCache?.effectiveMaxLOD:void 0);if(!a)return;const r={layer:this.layer,error:a};switch(a.name){case"tilingscheme:spatial-reference-mismatch":case"tilingscheme:global-unsupported-spatial-reference":case"tilingscheme:local-unsupported-spatial-reference":return new t("layerview:spatial-reference-incompatible","The spatial reference of this layer does not meet the requirements of the view",r);default:return new t("layerview:tiling-scheme-unsupported","The tiling scheme of this layer is not supported by SceneView",r)}}_getTileInfoCompatibilityError(e,i,a){return null!=e&&i.compatibleWith(e,a)?null:new t("layerview:tiling-scheme-incompatible","The tiling scheme of this layer is incompatible with the tiling scheme of the surface")}levelRangeFromScaleRange(e,t){const i={minLevel:0,maxLevel:1/0},a=this.view&&this.view.basemapTerrain&&this.view.basemapTerrain.tilingScheme;if(!a)return i;const r=a.levels[0],l=e=>{const t=Math.log(r.scale/e)/Math.LN2;return.5-Math.abs(.5-t%1)<1e-9?Math.round(t):Math.ceil(t)};return null!=e&&e>0&&(i.minLevel=Math.max(0,l(e))),null!=t&&t>0&&(i.maxLevel=Math.max(0,l(t))),i}isUpdating(){return!!(this.view&&this.view.basemapTerrain&&this.view.basemapTerrain.updating)}};return e([a({readOnly:!0})],m.prototype,"imageFormatIsOpaque",null),e([a({readOnly:!0})],m.prototype,"updating",void 0),e([a(s)],m.prototype,"updatingProgress",void 0),e([a(n)],m.prototype,"updatingProgressValue",void 0),e([a()],m.prototype,"hasMixedImageFormats",void 0),e([a()],m.prototype,"fullExtent",null),e([a({readOnly:!0})],m.prototype,"isOpaque",null),e([a({readOnly:!0})],m.prototype,"visibleAtCurrentScale",null),e([a()],m.prototype,"dataScaleRange",null),e([a({readOnly:!0})],m.prototype,"dataLevelRange",null),e([a({readOnly:!0})],m.prototype,"displayLevelRange",null),e([a()],m.prototype,"layer",void 0),m=e([r("esri.views.3d.layers.TiledLayerView3D")],m),m};export{p as TiledLayerView3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import"../../../../renderers/ClassBreaksRenderer.js";import"../../../../renderers/DictionaryRenderer.js";import"../../../../renderers/DotDensityRenderer.js";import"../../../../renderers/HeatmapRenderer.js";import"../../../../renderers/PieChartRenderer.js";import"../../../../renderers/Renderer.js";import"../../../../renderers/SimpleRenderer.js";import t from"../../../../renderers/UniqueValueRenderer.js";import"../../../../renderers/support/jsonUtils.js";import i from"../../../../core/Logger.js";import"../../../../symbols.js";import r from"../../../../core/Accessor.js";import{isSome as s}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import a from"../../../../core/Error.js";import{makeHandle as n}from"../../../../core/handleUtils.js";import{findInMap as o}from"../../../../core/MapUtils.js";import{removeMaybe as l,destroyMaybe as h,disposeMaybe as d}from"../../../../core/maybe.js";import{MinPriority as p}from"../../../../core/MemCache.js";import c from"../../../../core/PooledArray.js";import{throwIfAborted as y,createResolver as g,isAbortError as u,ignoreAbortErrors as m}from"../../../../core/promiseUtils.js";import{watch as b,when as _,on as f,syncAndInitial as v,whenOnce as C}from"../../../../core/reactiveUtils.js";import{schedule as S}from"../../../../core/scheduling.js";import{property as G}from"../../../../core/accessorSupport/decorators/property.js";import{subclass as w}from"../../../../core/accessorSupport/decorators/subclass.js";import{diff as R,isEmpty as x}from"../../../../core/accessorSupport/diffUtils.js";import{s as P,g as D,j as E}from"../../../../chunks/vec32.js";import{create as I}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{canProjectWithoutEngine as U}from"../../../../geometry/projection.js";import{projectBuffer as A}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as L}from"../../../../geometry/projection/projectVectorToVector.js";import{projectXYZToVector as j}from"../../../../geometry/projection/projectXYZToVector.js";import{create as O,center as V,fromRect as F,equals as T}from"../../../../geometry/support/aaBoundingBox.js";import{create as M}from"../../../../geometry/support/aaBoundingRect.js";import{equals as k}from"../../../../geometry/support/spatialReferenceUtils.js";import z from"../../../../layers/Layer.js";import{getObjectId as W,computeAABB as H,hasGeometry as N}from"../../../../layers/graphics/dehydratedFeatures.js";import{hydrateGraphic as B}from"../../../../layers/graphics/hydratedFeatures.js";import{PromiseQueue as q}from"../../../../layers/support/PromiseQueue.js";import{isSupportedRenderer3D as Y,validateTo3D as Q}from"../../../../renderers/support/rendererConversion.js";import{loadArcade as $}from"../../../../support/arcadeOnDemand.js";import{isBasemapLayer as Z}from"../../../../support/basemapUtils.js";import{getDefaultSymbol3D as J}from"../../../../symbols/support/defaults3D.js";import{to3D as X}from"../../../../symbols/support/symbolConversion.js";import{averageSymbolComplexities as K,defaultSymbolComplexity as ee}from"./defaultSymbolComplexity.js";import{DisplayFeatureLimit as te}from"./DisplayFeatureLimit.js";import{ViewElevationProvider as ie}from"./ElevationQuery.js";import{VisibilityGroup as re,VisibilityFlag as se}from"./enums.js";import{extractExpressionInfo as ae,createContext as ne}from"./featureExpressionInfoUtils.js";import{Graphics3DFeatureStore as oe}from"./Graphics3DFeatureStore.js";import{Graphics3DGraphicCreationContext as le}from"./Graphics3DGraphicCreationContext.js";import{Graphics3DSymbolCreationContext as he}from"./Graphics3DSymbolCreationContext.js";import{make as de}from"./Graphics3DSymbolFactory.js";import{Graphics3DWebStyleSymbol as pe}from"./Graphics3DWebStyleSymbol.js";import{GraphicsCorePerformanceInfo as ce}from"./GraphicsCorePerformanceInfo.js";import{GraphicStateTracking as ye}from"./GraphicStateTracking.js";import{computeCentroid as ge}from"./graphicUtils.js";import{ApplyRendererDiffResult as ue}from"./interfaces.js";import{LoadStatus as me}from"./Loadable.js";import{SpatialIndex2D as be}from"./SpatialIndex2D.js";import{getSymbolMemorySize as _e}from"./symbolMemory.js";import{StageLayerElevationProvider as fe}from"../support/StageLayerElevationProvider.js";import{toBoundingRect as ve}from"../../support/extentUtils.js";import{PropertiesPool as Ce}from"../../support/PropertiesPool.js";import{GridLocalOriginFactory as Se}from"../../webgl-engine/lib/GridLocalOriginFactory.js";import{UpdatePolicy as Ge}from"../../webgl-engine/lib/UpdatePolicy.js";import{affectsGeometry as we}from"../../webgl-engine/lib/VertexAttribute.js";import{WebGLLayer as Re}from"../../webgl-engine/lib/WebGLLayer.js";import{hasPopupTemplate as xe}from"../../../layers/support/popupUtils.js";import{ImmediateTask as Pe,noBudget as De,TaskPriority as Ee}from"../../../support/Scheduler.js";import{Yield as Ie}from"../../../support/Yield.js";import Ue from"../../../../geometry/Extent.js";import Ae from"../../../../geometry/Point.js";import Le from"../../../../symbols/LabelSymbol3D.js";import je from"../../../../symbols/TextSymbol.js";import Oe from"../../../../symbols/WebStyleSymbol.js";var Ve;const Fe=I(),Te=O();let Me=Ve=class extends r{get _viewSpatialReference(){return this.owner.view.spatialReference}get spatialIndex(){return this._spatialIndex||(this._spatialIndex=new be({objectIdField:this.owner.layer?.objectIdField,spatialReference:this._viewSpatialReference,hasZ:!!this.hasZ,hasM:!!this.hasM}),this._spatialIndex.setup(Array.from(this.graphics3DGraphics.values()))),this._spatialIndex.update(),this._spatialIndex}get deconflictor(){return this._deconflictor}get labeler(){return this._labeler}get numberOfGraphics(){return this._numberOfGraphics}get effectiveUpdatePolicy(){return null!=this.currentRenderer&&"dictionary"===this.currentRenderer.type?Ge.ASYNC:this._forcedUpdatePolicy??this.preferredUpdatePolicy}get featureStore(){return this._featureStore}get initializePromise(){return this._initializePromise}get scaleVisibility(){return this._scaleVisibility}get elevationAlignment(){return this._elevationAlignment}get objectStates(){return this._objectStates}get filterVisibility(){return this._filterVisibility}get updating(){return!!(this.dataUpdating||this._elevationAlignment?.updating||this._scaleVisibility?.updating||this._filterVisibility?.updating||this._rendererChangeAbortController||this._elevationInfoChangeAbortController||this._frameTaskHandle.updating||this.running)}get dataUpdating(){return!!(this._graphicsWaitingForSymbol.size>0||this._pendingUpdates.size>0||this._spatialIndex?.updating||this._updatingPendingLoadedGraphicsChange||this._dataUpdateQueue.running||this._loadingSymbols>0)}get running(){return this._pendingUpdates.size>0||!!this._spatialIndex?.updating||this._dataUpdateQueue.running||this._updateQueue.running}get suspendedOrOutsideOfView(){return this.owner.suspended||!!this.owner.suspendInfo?.outsideOfView}get updatingRemaining(){return this.updating?this._pendingUpdates.size+.1*(this._spatialIndex?.updatingRemaining||0)+.1*(this._elevationAlignment?.updatingRemaining||0):0}get displayFeatureLimit(){const e=this.owner&&this.owner.view&&this.owner.view.qualitySettings,t=e?.graphics3D.minTotalNumberOfFeatures??0,i=e?.graphics3D.maxTotalNumberOfFeatures??0,r=e?.graphics3D.maxNumberOfDrawCalls??0,s=e?.graphics3D.maxTotalNumberOfVertices??0,a=this.averageSymbolComplexity,n=Math.max(1,a?.verticesPerFeature??1),o=a&&a.drawCallsPerFeature>0&&r>0?r/a.drawCallsPerFeature:i,l=Math.ceil(s/n),h=Math.max(t,Math.min(i,l,o)),d=this._get("displayFeatureLimit");return d&&d.maximumTotalNumberOfVertices===s&&d.averageSymbolComplexity===a&&d.maximumNumberOfFeatures===h?d:new te(s,h,a)}get averageSymbolComplexity(){const e=K(this._symbolComplexities),t=this._get("averageSymbolComplexity");return 0===e.numComplexities||null!=t&&(e.estimated&&(t.verticesPerFeature>=e.verticesPerFeature||t.verticesPerCoordinate>=e.verticesPerCoordinate||t.drawCallsPerFeature>=e.drawCallsPerFeature)||t.verticesPerFeature===e.verticesPerFeature&&t.verticesPerCoordinate===e.verticesPerCoordinate&&t.drawCallsPerFeature===e.drawCallsPerFeature)?t:e}get usedMemory(){const e=null!=this.averageSymbolComplexity&&this.labelsEnabled?this.averageSymbolComplexity.memory.bytesPerFeatureLabel*this._numberOfGraphics:0,t=this._getSymbolComplexitiesUsed().reduce(((e,t)=>e+t.memory.resourceBytes),0),i=this.owner.view._stage.renderer,r=this.owner.view.basemapTerrain.overlayManager.renderer,s=Array.from(this._symbols.values()).reduce(((e,t)=>e+(t?.symbolLayers.reduce(((e,t)=>e+(t?.materials.reduce(((e,t)=>t?e+(i.plugins.getMaterialRenderer(t)?.usedMemory??0)+r.getMemoryForMaterial(t):e),0)??0)),0)??0)),0);return this._usedMemory+e+t+s}get usedMemoryPerGraphic(){if(this._usedMemory&&this._numberOfGraphics){const e=this._numberOfGraphics/(this._numberOfGraphics+Math.max(this._pendingAdds,this._pendingRemoves));return this._usedMemory/this._numberOfGraphics*e}if(null!=this.averageSymbolComplexity){const e=this.labelsEnabled?this.averageSymbolComplexity.memory.bytesPerFeatureLabel:0;return this.averageSymbolComplexity.memory.bytesPerFeature+e}return 0}get unprocessedMemoryEstimate(){return(this._pendingAdds-this._pendingRemoves)*this.usedMemoryPerGraphic}get _symbolComplexities(){return this.currentRenderer?this._getSymbolComplexitiesUsedOrRenderer(this.currentRenderer):this._getSymbolComplexitiesUsed()}get visible(){return this._visible}_getConvertedSymbol(e){if("web-style"===e.type)return e.clone();const t=this._symbolConversionCache.get(e.id);if(null!=t)return t;const r=X(e,{geometryType:this.layer?.geometryType??void 0,retainId:!0,hasLabelingContext:this._hasLabelingContext(e),cimFallbackEnabled:!0}),s=r.symbol||null;return null==s&&r.error&&i.getLogger(this).error(r.error.message),this._symbolConversionCache.set(e.id,s),s}_getSymbolComplexitiesUsedOrRenderer(e){if(null==e)return[];const t=e.getSymbols(),i="backgroundFillSymbol"in e?e.backgroundFillSymbol:null;if(!i&&!t?.length)return[];const r=[],s=this._getSymbolComplexityUsedOrRenderer(i);null!=s&&r.push(s);for(const a of t){const e=this._getSymbolComplexityUsedOrRenderer(a);null!=e&&r.push(e)}return r}_getSymbolComplexityUsedOrRenderer(e){if(null==e)return null;const t=this._symbols.get(e.id);if(null!=t)return t.complexity;const i=this._getConvertedSymbol(e);return null!=i?ee(i):null}_getSymbolComplexitiesUsed(){const e=[];return this._symbols.forEach((t=>{null!=t&&e.push(t.complexity)})),e}get _objectIdField(){return this.layer.objectIdField}constructor(e){super(e),this._propertiesPool=new Ce({computedExtent:Ue},this),this.computedExtent=null,this.currentRenderer=null,this.rendererHasGeometryOperations=!1,this._graphicStateTracking=null,this.graphics3DGraphics=new Map,this.stageLayer=null,this.stage=null,this._graphicsDrapedUids=new Set,this._graphicsBySymbol=new Map,this._symbolConversionCache=new Map,this._symbols=new Map,this._graphicsWithoutSymbol=new Map,this._graphicsWaitingForSymbol=new Map,this._graphicsUpdateId=0,this._frameTaskHandle=Pe,this._dataUpdateQueue=new q,this._updateQueue=new q,this._suspendSymbolCleanup=!1,this._arcadeOnDemand=null,this._rendererChangeAbortController=null,this._elevationInfoChangeAbortController=null,this._initializeAbortController=null,this._elevationAlignment=null,this._scaleVisibility=null,this._filterVisibility=null,this._spatialIndex=null,this.extentPadding=0,this._updatingPendingLoadedGraphicsChange=null,this._featureStore=null,this._deconflictor=null,this._labeler=null,this._objectStates=null,this._viewElevationProvider=null,this._stageLayerElevationProvider=null,this._sharedSymbolResourcesOwnerHandle=null,this._whenGraphics3DGraphicRequests={},this._pendingUpdates=new Map,this._numberOfGraphics=0,this._numberOfGraphicsProvidingElevation=0,this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1,this._loadingSymbols=0,this._pendingUpdatesPool=new c({allocator:e=>e||new ze,deallocator:e=>(e.clear(),e)}),this._symbolWarningLogged=!1,this._geometryWarningLogged=!1,this._objectIdInvisibleSet=new Set,this._whenSymbolRemoved=new c,this.preferredUpdatePolicy=Ge.SYNC,this._forcedUpdatePolicy=null,this.elevationFeatureExpressionEnabled=!0,this.owner=null,this.layer=null,this.graphicSymbolSupported=!0,this.getRenderingInfoWithoutRenderer=!1,this.setUidToIdOnAdd=!0,this.hasZ=null,this.hasM=null,this._usedMemory=0,this._visible=!1,this._startCreateGraphics=!1,this._unusedSymbolsCache=e.owner.view.resourceController.memoryController.newCache("graphics-3d-unused-symbols",(e=>e.destroy())),this.symbolCreationContext=new he(e.owner.view.resourceController.scheduler,((e,t)=>this._updateQueue.push(e,t)))}initialize(){this._featureStore=new oe({objectIdField:this.owner.layer?.objectIdField,hasZ:!!this.hasZ,hasM:!!this.hasM,viewSpatialReference:this._viewSpatialReference,featureSpatialReference:this.owner.featureSpatialReference,getSpatialIndex:()=>this.spatialIndex,forEach:e=>this.graphics3DGraphics.forEach(e)});const e=(e,t,i)=>this.spatialIndex.queryGraphicUIDsInExtent(e,t,i),{componentFactories:t}=this;this._elevationAlignment=t.elevationAlignment?.(this,e),this._scaleVisibility=t.scaleVisibility?.(this,e),this._filterVisibility=t.filterVisibility?.({featureStore:this._featureStore,getFeatureCount:()=>this.graphics3DGraphics.size,updateFeatureVisibilities:e=>this.modifyGraphics3DGraphicVisibilities((t=>t.setVisibilityFlag(re.GRAPHIC,se.FILTER,e(W(t.graphic,this._objectIdField))))),setAllFeaturesVisibility:e=>this.modifyGraphics3DGraphicVisibilities((t=>t.setVisibilityFlag(re.GRAPHIC,se.FILTER,e))),clearFeaturesVisibility:()=>this.modifyGraphics3DGraphicVisibilities((e=>e.setVisibilityFlag(re.GRAPHIC,se.FILTER,!0)))}),this._deconflictor=t.deconflictor?.(this),this._labeler=t.labeler?.(this,this._scaleVisibility),this._objectStates=t.objectStates?.(this),this._initializeAbortController=new AbortController,this._initializePromise=this._initializeAsync()}async _initializeAsync(){const e=this._initializeAbortController?.signal,t=this.owner.view;this._viewElevationProvider=new ie(this._viewSpatialReference,t),this._initializeStage(t,this.layer.uid);const r=t.sharedSymbolResources;this.symbolCreationContext.sharedResources=r,this._sharedSymbolResourcesOwnerHandle=r.addGraphicsOwner(this.owner),null!=this.currentRenderer&&(this.symbolCreationContext.renderer=this.currentRenderer),this.symbolCreationContext.stage=this.stage,this.symbolCreationContext.streamDataRequester=r.streamDataRequester,this.symbolCreationContext.renderCoordsHelper=t.renderCoordsHelper,this.symbolCreationContext.layer=this.layer,this.symbolCreationContext.graphicsCoreOwner=this.owner,this.symbolCreationContext.localOriginFactory=new Se(t.renderSpatialReference),this.symbolCreationContext.elevationProvider=t.elevationProvider,this.symbolCreationContext.notifyGraphicGeometryChanged=e=>this.notifyGraphicGeometryChanged(e),this.symbolCreationContext.notifyGraphicVisibilityChanged=e=>this.notifyGraphicVisibilityChanged(e);const s=ae(this.layer.elevationInfo,this.elevationFeatureExpressionEnabled);if(this.symbolCreationContext.featureExpressionInfoContext=await ne(s,this._viewSpatialReference,e,i.getLogger(this)),y(e),this.symbolCreationContext.screenSizePerspectiveEnabled=t.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled,this.symbolCreationContext.slicePlaneEnabled=!!this.owner.slicePlaneEnabled,this.symbolCreationContext.physicalBasedRenderingEnabled=!!this.owner.view.qualitySettings?.physicallyBasedRenderingEnabled,this.symbolCreationContext.skipHighSymbolLods=!!this.owner.view.qualitySettings?.graphics3D?.skipHighSymbolLods,"drapeSourceType"in this.owner){const{owner:e}=this;this.symbolCreationContext.drapeSourceRenderer=t.basemapTerrain.overlayManager.registerGeometryDrapeSource(e),this.addHandles(n((()=>t.basemapTerrain.overlayManager.unregisterDrapeSource(e))))}this.addHandles([b((()=>this.suspendedOrOutsideOfView),(()=>this._updateQueue.unshift((()=>this._updateLayerVisibility()),null).catch(m))),b((()=>[this.layer?.screenSizePerspectiveEnabled,this.owner.view?.screenSizePerspectiveEnabled]),(()=>{const e=t.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled;e!==this.symbolCreationContext.screenSizePerspectiveEnabled&&(this.symbolCreationContext.screenSizePerspectiveEnabled=e,this._labeler?.reset(),this.recreateAllGraphicsAndSymbols())})),b((()=>this.owner.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(!!e))),b((()=>this.owner.view.state?.rasterPixelRatio),(()=>this._pixelRatioChange())),b((()=>!!this.owner.view.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._physicalBasedRenderingChange(e))),b((()=>!!this.owner.view.qualitySettings?.graphics3D?.skipHighSymbolLods),(e=>this._skipHighSymbolLoDsChange(e))),_((()=>t.basemapTerrain?.tilingScheme),(e=>{if(e.spatialReference.equals(this.symbolCreationContext.overlaySR)||null==t.basemapTerrain.spatialReference||(this.symbolCreationContext.overlaySR=t.basemapTerrain.spatialReference),this.hasHandles("loaded-graphics"))this.recreateAllGraphics();else{const e=()=>this.owner?.loadedGraphics;this.addHandles([f(e,"change",(e=>{this._graphicsCollectionChanged(e),this._signalUpdatingDuringAsyncLoadedGraphicsChange()}),{onListenerAdd:()=>{this.recreateAllGraphics(),this._signalUpdatingDuringAsyncLoadedGraphicsChange()}})],"loaded-graphics")}}),{initial:!0}),b((()=>this.effectiveUpdatePolicy),(e=>{null!=this.stageLayer&&(this.stageLayer.updatePolicy=e),this.symbolCreationContext.isAsync=this.effectiveUpdatePolicy===Ge.ASYNC,e===Ge.SYNC&&this.runTask(De)}),v)]),this._frameTaskHandle=t.resourceController.scheduler.registerTask(Ee.GRAPHICS_CORE,this),this.layer&&"featureReduction"in this.layer&&this.addHandles(b((()=>this.layer.featureReduction),(()=>this._deconflictor?.featureReductionChange()))),this.notifyChange("averageSymbolComplexity"),this.rendererChange(this.owner.renderer).catch((()=>{})),this._initializeAbortController=null}_abortInitialize(){this._initializeAbortController&&(this._initializeAbortController.abort(),this._initializeAbortController=null)}destroy(){this._unusedSymbolsCache.destroy(),this._abortInitialize(),this._abortRendererChange(),this._abortElevationInfoChange(),this._frameTaskHandle.remove(),this._frameTaskHandle=Pe,this._dataUpdateQueue.cancelAll(),this._updateQueue.cancelAll(),this._deconflictor=l(this._deconflictor),this._labeler=l(this._labeler),this._elevationAlignment=h(this._elevationAlignment),this._scaleVisibility=h(this._scaleVisibility),this._filterVisibility=h(this._filterVisibility),this._objectStates=h(this._objectStates),this.clear(),this._featureStore=h(this._featureStore),this._updatingPendingLoadedGraphicsChange=l(this._updatingPendingLoadedGraphicsChange),this._graphicStateTracking=h(this._graphicStateTracking),this.stage&&(this.stageLayer=h(this.stageLayer),this.stage=null),this._set("owner",null);for(const e in this._whenGraphics3DGraphicRequests)this._whenGraphics3DGraphicRequests[e].reject(new a("graphic:layer-destroyed","Layer has been destroyed"));this._whenGraphics3DGraphicRequests=null,this._sharedSymbolResourcesOwnerHandle=l(this._sharedSymbolResourcesOwnerHandle),this._propertiesPool=h(this._propertiesPool),this._pendingUpdatesPool=null,this._symbolConversionCache.clear(),this._objectIdInvisibleSet.clear(),this._spatialIndex=h(this._spatialIndex)}clear(){this._objectStates?.allGraphicsDeleted(),null!=this._graphicStateTracking&&this._graphicStateTracking.allGraphicsDeleted(),this.graphics3DGraphics.forEach((e=>e.destroy())),this._spatialIndex?.clear(),this.graphics3DGraphics.clear(),this._numberOfGraphics=0,this._usedMemory=0,this._updateLayerVisibility(),this._symbols.forEach(h),this._symbols.clear(),this._graphicsBySymbol.clear(),this._graphicsWithoutSymbol.clear(),this._graphicsWaitingForSymbol.clear(),this._pendingUpdates.clear(),this._pendingUpdatesPool.clear(),this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1,this.notifyChange("dataUpdating"),this.notifyChange("running"),this.notifyChange("updatingRemaining"),this._featureStore.events.emit("changed")}_initializeStage(e,t){this.stage=e._stage,this.stageLayer=new Re(this.stage,{pickable:!this.suspendedOrOutsideOfView,updatePolicy:this.effectiveUpdatePolicy},t);const i=this.stageLayer.events;i.on("transformationChanged",(e=>this.notifyGraphicGeometryChanged(e.graphicUid))),i.on("shaderTransformationChanged",(e=>this.notifyGraphicGeometryChanged(e.graphicUid))),i.on("visibilityChanged",(e=>this.notifyGraphicVisibilityChanged(e.graphicUid))),i.on("geometryAdded",(e=>this.notifyGraphicGeometryChanged(e.object.graphicUid))),i.on("geometryRemoved",(e=>this.notifyGraphicGeometryChanged(e.object.graphicUid))),i.on("attributesChanged",(e=>we(e.attribute)&&this.notifyGraphicGeometryChanged(e.object.graphicUid)))}notifyGraphicGeometryChanged(e){if(null==this._graphicStateTracking||null==e)return;const t=this.graphics3DGraphics.get(e);t&&this._graphicStateTracking.updateGraphicGeometry(t)}notifyGraphicVisibilityChanged(e){if(null==this._graphicStateTracking||null==e)return;const t=this.graphics3DGraphics.get(e);t&&this._graphicStateTracking.updateGraphicVisibility(t)}_updateLayerVisibility(){const e=this.displayFeatureLimit.maximumNumberOfFeatures,t=this._numberOfGraphics>e*We,i=!this.suspendedOrOutsideOfView&&!t;i!==this._visible&&(this._visible=i,i?(this.stageLayer.pickable=!0,this.updateAllGraphicsVisibility()):(this.stageLayer.pickable=!1,this._hideAllGraphics()),this._updateStageLayerVisibility())}_updateStageLayerVisibility(){this.stageLayer.visible=this._visible&&(null==this.layer.opacity||this.layer.opacity>0)}getGraphics3DGraphicById(e){return null!=e?this.graphics3DGraphics.get(e):void 0}getGraphics3DGraphicByObjectId(e){return this.owner.layer?.objectIdField?this._findGraphics3DGraphicByObjectId(e):null}_getGraphicObjectID(e,t=this.owner.layer?.objectIdField){return W(e,t)}get graphics3DGraphicsByObjectID(){const e=this.owner.layer?.objectIdField;if(!e)return;const t=new Map;return this.graphics3DGraphics.forEach((i=>{if(!i)return;const r=i.graphic,s=this._getGraphicObjectID(r,e);null!=s&&t.set(s,i)})),t}get labelsEnabled(){return!!this._labeler?.layerLabelsEnabled()}async updateLabelingInfo(e){const t=this._deconflictor?.labelingInfoChange(e),i=this._labeler?.labelingInfoChange(e);await Promise.allSettled([t,i])}updateVisibilityInfo(){this._deconflictor?.labelingInfoChange(),this._labeler?.visibilityInfoChange()}get symbolUpdateType(){if(this._pendingUpdates.size>0)return"unknown";let e=0,t=0;for(const[i,r]of this._symbols)if(null!=r){const s=r.getFastUpdateStatus();if(s.loading>0)return"unknown";this._graphicsBySymbol.has(i)&&(t+=s.fast,e+=s.slow)}return t>=0&&0===e?"fast":e>=0&&0===t?"slow":"mixed"}runTask(e){if(this._dataUpdateQueue.runTask(e),this._updateQueue.runTask(e),this._applyPendingUpdates(e),this.notifyChange("running"),this.running||this.notifyChange("dataUpdating"),this.notifyChange("updatingRemaining"),!e.hasProgressed)return Ie}setObjectIdVisibility(e,t){t?this._objectIdInvisibleSet.delete(e):this._objectIdInvisibleSet.add(e);const i=this._findGraphics3DGraphicByObjectId(e);null!=i&&this._updateUserVisibility(i)}_findGraphics3DGraphicByObjectId(e){return o(this.graphics3DGraphics,(t=>this._getGraphicObjectID(t.graphic)===e))}_updateUserVisibility(e){if(null==e)return!1;const t=e.graphic,i=this._getGraphicObjectID(t),r=t.visible&&!this.owner.suspended&&(null==i||!this._objectIdInvisibleSet.has(i));return e.setVisibilityFlag(re.GRAPHIC,se.USER,r)}_whenGraphics3DGraphic(e){const t=this.graphics3DGraphics.get(e.uid);if(t)return Promise.resolve(t);const i=this._whenGraphics3DGraphicRequests[e.uid];if(i)return i.promise;const r=g();return this._whenGraphics3DGraphicRequests[e.uid]=r,r.promise}async _boundsForGraphics3DGraphic(e,t){const i=this._viewSpatialReference,r=this.owner.view.renderSpatialReference,s=this.owner.view.basemapTerrain.spatialReference,a=(e,t,s)=>A(e,r,t,e,i,t,s),n=(e,t,r)=>A(e,s,t,e,i,t,r),o=this._viewElevationProvider?{service:this._viewElevationProvider,useViewElevation:null!=t&&!!t.useViewElevation,minDemResolution:null!=t?t.minDemResolution:null,minDemResolutionForPoints:this.owner.view.resolution}:null,l=await e.getProjectedBoundingBox(a,n,o,t?.signal);if(!l)return null;const h=l.boundingBox;if(l.requiresDrapedElevation){const e=this.symbolCreationContext.elevationProvider;if(e){V(h,Fe);const t=e.getElevation(Fe[0],Fe[1],0,i,"ground")??0;h[2]=Math.min(h[2],t),h[5]=Math.max(h[5],t)}}return{boundingBox:h,screenSpaceObjects:l.screenSpaceObjects}}async whenGraphicBounds(e,t){await C((()=>this.owner?.loadedGraphics));const i=this.owner.layer?.objectIdField,r=this.owner.loadedGraphics.find((t=>t===e||null!=i&&null!=t.attributes&&e.attributes&&t.attributes[i]===e.attributes[i]));if(!r)throw new a("internal:graphic-not-part-of-view","Graphic is not part of this view");const s=await this._whenGraphics3DGraphic(r);return this._boundsForGraphics3DGraphic(s,t)}computeAttachmentOrigin(e,t){const i=this.graphics3DGraphics.get(e.uid);if(!i)return null;const r=i.computeAttachmentOrigin();if(0===r.render.num&&0===r.draped.num)return null;P(He,0,0,0);let s=0;if(r.render.num>0){if(!L(r.render.origin,this.symbolCreationContext.renderCoordsHelper.spatialReference,Ne,t))return null;D(He,He,Ne),s++}if(r.draped.num>0){const[e,i]=r.draped.origin,a=this._viewElevationProvider.getElevation(e,i,"ground")??0;if(P(Ne,e,i,a),!L(Ne,this._viewElevationProvider.spatialReference,Ne,t))return null;D(He,He,Ne),s++}return s>1&&E(He,He,1/s),new Ae({x:He[0],y:He[1],z:He[2],spatialReference:t})}getSymbolLayerSize(e,t){const i=this._symbols.get(e.id);if(null==i)throw new a("internal:symbol-not-part-of-view","Symbol is not part of this view");const r=e.symbolLayers.indexOf(t);if(-1===r)throw new a("internal:missing-symbol-layer","Symbol layer is not in symbol");const s=i.getSymbolLayerSize(r);if(null==s)throw new a("internal:missing-size","Symbol layer has no valid size");return s}_graphicsCollectionChanged(e){this._startCreateGraphics&&(this.add(e.added),this.remove(e.removed))}graphicUpdateHandler(e){const t=e.graphic.uid,i=this.graphics3DGraphics.get(t);if(null!=i||null!=this._graphicsWithoutSymbol.get(t))switch(e.property){case"visible":this._graphicUpdateVisibleHandler(i);break;case"geometry":this._graphicUpdateGeometryHandler(i,e);break;case"symbol":this._graphicUpdateSymbolHandler(i,e);break;case"attributes":break;case"origin-transform":this._graphicUpdateTransformHandler(i,e)}}_graphicUpdateGeometryHandler(e,t){this._graphicUpdateGeometryOrTransformHandler(e,t,(()=>!(null==t.newValue||null==e||!e.graphics3DSymbol.updateGeometry(e,t.newValue)||!(this._labeler?.updateGraphicGeometry(e)??1))&&(this._labeler?.setDirty(),!0)));const i=t.graphic.geometry;null!=i&&this._expandComputedExtent(i)}_graphicUpdateTransformHandler(e,t){const i=t.graphic.geometry;this._graphicUpdateGeometryOrTransformHandler(e,t,(()=>null!=t.newValue&&null!=e&&null!=i&&e.graphics3DSymbol.updateTransform(e,i.spatialReference,t.newValue,t.action)))}_graphicUpdateGeometryOrTransformHandler(e,t,i){if(null!=t.graphic.geometry)if(null!=e)i()||this._recreateGraphic(e.graphic);else{const e=t.graphic.symbol?.id;if(e){const t=this._symbols.get(e);if(null!=t&&t.loadStatus===me.LOADING)return}this._recreateGraphic(t.graphic)}else this._recreateGraphic(t.graphic)}_graphicUpdateSymbolHandler(e,t){const i=t.graphic,r=null!=e?e.graphics3DSymbol:null!=t.oldValue?this._symbols.get(t.oldValue.id):null;if(null==r||null==t.newValue)return void this._recreateGraphic(i);const s=r.symbol,a=this._getConvertedSymbol(t.newValue);if(null!=a&&(a.type!==s.type||"web-style"===a.type)||"web-style"===s.type)return void this._recreateGraphic(i);const n=this._graphicsBySymbol.get(s.id);if(n&&1!==n.size)return void this._recreateGraphic(i);const o=R(s,a);if(null==o)return void this._updateSymbolMapping(s.id,a);const l={diff:o,graphics3DGraphicPatches:[],symbolStatePatches:[]};if(r.prepareSymbolPatch(l),!x(l.diff))return void this._recreateGraphic(i);const h=this._getRenderingInfo(i);if(null==h)return void this._recreateGraphic(i);const d=r.extentPadding;for(const p of l.symbolStatePatches)p();if(d!==r.extentPadding&&this._recomputeExtentPadding(),null!=e)for(const p of l.graphics3DGraphicPatches)p(e,h);this._updateSymbolMapping(s.id,a)}_graphicUpdateVisibleHandler(e){this._updateUserVisibility(e)&&(this._labeler?.setDirty(),this._deconflictor?.setDirty())}recreateGraphics(e){this._suspendSymbolCleanup=!0,this.remove(e),this.add(e),this._suspendSymbolCleanup=!1,this.effectiveUpdatePolicy===Ge.SYNC&&this._cleanupSymbols()}_recreateGraphic(e){this.recreateGraphics([e])}_beginGraphicUpdate(e){const t=this._graphicsUpdateId;return this._graphicsUpdateId++,this._graphicsWaitingForSymbol.set(e.uid,t),1===this._graphicsWaitingForSymbol.size&&this.notifyChange("dataUpdating"),t}_endGraphicUpdate(e){e&&(this._graphicsWaitingForSymbol.delete(e.uid),0===this._graphicsWaitingForSymbol.size&&(this._cleanupSymbols(),this.notifyChange("dataUpdating")))}_recomputeExtentPadding(){let e=0;this._symbols.forEach((t=>{null!=t&&(e=Math.max(e,t.extentPadding))})),this._set("extentPadding",e)}_expandComputedExtent(e){const t=Te,i=e.spatialReference;H(e,t);const r=this._viewSpatialReference,s=Ve.tmpVec;if(k(i,r)||j(t[0],t[1],0,i,s,r)&&(t[0]=s[0],t[1]=s[1],j(t[3],t[4],0,i,s,r),t[3]=s[0],t[4]=s[1]),!(isFinite(t[0])&&isFinite(t[3])&&isFinite(t[1])&&isFinite(t[4])))return;const a=this.computedExtent;let n=null;const o=isFinite(t[2])&&isFinite(t[5]),l=o&&(null==a?.zmin||t[2]<a.zmin),h=o&&(null==a?.zmax||t[5]>a.zmax);if(a){(t[0]<a.xmin||t[1]<a.ymin||t[3]>a.xmax||t[4]>a.ymax||l||h)&&(n=this._propertiesPool.get("computedExtent"),n.xmin=Math.min(t[0],a.xmin),n.ymin=Math.min(t[1],a.ymin),n.xmax=Math.max(t[3],a.xmax),n.ymax=Math.max(t[4],a.ymax),n.spatialReference=r)}else n=this._propertiesPool.get("computedExtent"),n.xmin=t[0],n.ymin=t[1],n.xmax=t[3],n.ymax=t[4],n.spatialReference=r;n&&(l&&(n.zmin=t[2]),h&&(n.zmax=t[5]),this._set("computedExtent",n))}_abortElevationInfoChange(){this._elevationInfoChangeAbortController&&(this._elevationInfoChangeAbortController.abort(),this._elevationInfoChangeAbortController=null)}async elevationInfoChange(){this._abortElevationInfoChange();const e=new AbortController;this._elevationInfoChangeAbortController=e;const t=ae(this.layer.elevationInfo,this.elevationFeatureExpressionEnabled);this.symbolCreationContext.featureExpressionInfoContext=await ne(t,this._viewSpatialReference,e.signal,i.getLogger(this)),y(e.signal),this._elevationInfoChangeAbortController=null,this._labeler?.elevationInfoChange(),this.forEachGraphics3DSymbol(((e,t,i)=>{e.globalPropertyChanged("elevationInfo",t)?t.forEach((e=>{const t=e.graphic,i=e.labelLayers;for(const r of i){r.graphics3DSymbolLayer.updateGraphicElevationContext(t,r)}})):this._recreateSymbol(i)})),this.updateStageLayerElevationProvider(),this._elevationAlignment?.elevationInfoChange()}updateStageLayerElevationProvider(){this._stageLayerElevationProvider?(this.layer.elevationInfo&&"relative-to-scene"===this.layer.elevationInfo.mode||0===this._numberOfGraphicsProvidingElevation)&&(this.owner.view.elevationProvider.unregister(this._stageLayerElevationProvider),this._stageLayerElevationProvider=d(this._stageLayerElevationProvider)):(!this.layer.elevationInfo||this.layer.elevationInfo&&"relative-to-scene"!==this.layer.elevationInfo.mode)&&this._numberOfGraphicsProvidingElevation>0&&(this._stageLayerElevationProvider=new fe({layer:this.layer,stageLayer:this.stageLayer,view:this.owner.view}),this.owner.view.elevationProvider.register("scene",this._stageLayerElevationProvider))}_clearSymbolsAndGraphics(){this.clear(),null!=this._filterVisibility&&this._filterVisibility.clear(),this._labeler?.reset(),this._deconflictor?.clear(),this._elevationAlignment?.clear(),this.stageLayer?.invalidateSpatialQueryAccelerator(),this._stageLayerElevationProvider&&(this.owner.view.elevationProvider.unregister(this._stageLayerElevationProvider),this._stageLayerElevationProvider=d(this._stageLayerElevationProvider))}startCreateGraphics(){this._startCreateGraphics=!0,this.recreateAllGraphics()}recreateAllGraphics(){this._recreateAllGraphics(!1)}recreateAllGraphicsAndSymbols(){this._recreateAllGraphics(!0)}_recreateAllGraphics(e=!1){if(!this._startCreateGraphics)return;const{loadedGraphics:t,view:i}=this.owner,r=i.basemapTerrain.tilingScheme&&t?.length?t.toArray():null;!e&&r||this._clearSymbolsAndGraphics(),this.symbolCreationContext.screenSizePerspectiveEnabled=this.owner.view.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled,this.symbolCreationContext.slicePlaneEnabled=!!this.owner.slicePlaneEnabled,this._set("computedExtent",null),r&&(e?this.add(r):this.recreateGraphics(r))}_recreateSymbol(e){const t=this._graphicsBySymbol.get(e),i=[];t&&(t.forEach(((e,t)=>{const r=e.usedMemory;this._conditionalRemove(e,t),this._spatialIndex?.remove(e),i.push(e.graphic),e.destroy(),this._removeGraphics3DGraphic(t,r),this._updateLayerVisibility(),this._featureStore.events.emit("changed")})),this._graphicsBySymbol.set(e,new Map));const r=this._symbols.get(e);h(r),this._symbols.delete(e),this.add(i)}_recreateGraphicsForSymbol(e){const t=this._graphicsBySymbol.get(e);if(t){const e=[];t.forEach((t=>e.push(t.graphic))),this.recreateGraphics(e)}}_conditionalRemove(e,t){this._graphicsDrapedUids.delete(t),this._objectStates?.removeGraphic(e),this._labeler?.removeGraphic(e),this._deconflictor?.removeGraphic(e),null!=this._graphicStateTracking&&this._graphicStateTracking.removeGraphic(e)}add(e){e&&0!==e.length&&(this.owner.view.basemapTerrain?.tilingScheme?(this._updatePolicyForGraphics(e)===Ge.ASYNC?this._addDelayed(e):this._addImmediate(e),this.notifyChange("dataUpdating")):i.getLogger(this).error("#add()","Cannot add graphics before terrain surface has been initialized"))}_updatePolicyForGraphics(e){if(this.effectiveUpdatePolicy===Ge.SYNC&&("mesh"===this.layer.geometryType||null==this.layer.geometryType))for(const t of e)if(null!=t.geometry&&"mesh"===t.geometry.type&&!t.geometry.loaded)return Ge.ASYNC;return this.effectiveUpdatePolicy}_addImmediate(e){this._geometryWarningLogged=!1,this._symbolWarningLogged=!1;for(const t of e)this._addGraphic(t,this._getRenderingInfo(t,i.getLogger(this)),Ge.SYNC);this._cleanupSymbols(),this._labeler?.setDirty(),this._deconflictor?.setDirty()}_addDelayed(e){for(const t of e){const e=t.uid;let i=this._pendingUpdates.get(e);i?i.add?i.state!==ke.NEW&&i.abortController?.abort():this._pendingAdds++:(i=this._pendingUpdatesPool.pushNew(),this._pendingAdds++,this._pendingUpdates.set(e,i)),i.add=t}this.notifyChange("running"),this.notifyChange("updatingRemaining"),this.notifyChange("dataUpdating")}remove(e){this.effectiveUpdatePolicy===Ge.ASYNC?this._removeDelayed(e):this._removeImmediate(e),this.notifyChange("dataUpdating")}_removeImmediate(e){for(const t of e)this._removeGraphic(t);this._cleanupSymbols(),this._labeler?.setDirty(),this._deconflictor?.setDirty()}_removeDelayed(e){for(const t of e){const e=t.uid,i=this._pendingUpdates.get(e);if(i)i.add&&(i.remove?i.add=null:this._pendingUpdates.delete(e),i.state===ke.LOADING&&i.abortController?.abort(),this._pendingAdds--);else{const i=this._pendingUpdatesPool.pushNew();i.remove=t,this._pendingUpdates.set(e,i),this._pendingRemoves++,this._applyPendingRemovesFirst=!0}}0===this._pendingUpdates.size&&this._finishPendingUpdates(),this.notifyChange("running"),this.notifyChange("updatingRemaining"),this.notifyChange("dataUpdating")}_finishPendingUpdates(){this._pendingUpdatesPool.clear(),this._cleanupSymbols(),(this._pendingAdds||this._pendingRemoves)&&i.getLogger(this).warn("pendingAdds/Removes in inconsistent state!"),this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1}_applyPendingUpdates(e){if(this._geometryWarningLogged=!1,this._symbolWarningLogged=!1,0===this._pendingUpdates.size&&this._spatialIndex?.updating)return this._spatialIndex.update(),void e.madeProgress();if(this._applyPendingRemovesFirst){this._applyPendingRemovesFirst=!1;for(const[t,i]of this._pendingUpdates){if(e.done){this._applyPendingRemovesFirst=!0;break}if(i.remove&&!i.add&&(this._pendingRemoves--,e.madeProgress(),this._removeGraphic(i.remove),i.remove=null,this._pendingUpdates.delete(t),0===this._pendingRemoves))break}}for(const[t,i]of this._pendingUpdates){if(e.done)break;i.add&&i.state===ke.NEW&&this._processPendingUpdateNew(i);let r=this.effectiveUpdatePolicy;if(!i.remove||i.add&&i.state!==ke.READY||(this._pendingRemoves--,e.madeProgress(),this._removeGraphic(i.remove),i.remove=null,r=Ge.SYNC),i.add)switch(i.state){case ke.READY:this._addGraphic(i.add,i.renderingInfo,r),i.add=null,this._pendingAdds--,e.madeProgress();break;case ke.REJECTED:i.add=null,this._pendingAdds--;case ke.LOADING:}null==i.remove&&null==i.add&&this._pendingUpdates.delete(t)}0===this._pendingUpdates.size&&(this._finishPendingUpdates(),this.notifyChange("running"),this.notifyChange("dataUpdating"))}_processPendingUpdateNew(e){if(!e.add)return void(e.state=ke.READY);const t=e.add.geometry;null==t||"mesh"!==t.type||t.loaded?this._processPendingUpdateNewRenderingInfo(e):this._processPendingUpdateNewMesh(e,t)}async _processPendingUpdateNewMesh(e,t){e.state=ke.LOADING,e.abortController=new AbortController;const i=e.abortController.signal;try{await t.load({signal:i})}catch(r){return this._processPendingUpdateNewError(e,r)}e.abortController=null,this._processPendingUpdateNewRenderingInfo(e)}_processPendingUpdateNewError(e,t){e.abortController=null,u(t)?e.state=ke.NEW:e.state=ke.REJECTED}async _processPendingUpdateNewRenderingInfo(e){if(null==this.layer.renderer||"dictionary"!==this.layer.renderer.type)return e.renderingInfo=this._getRenderingInfo(e.add,i.getLogger(this)),void(e.state=ke.READY);e.state=ke.LOADING,e.abortController=new AbortController;let t=null;try{t=await this._getRenderingInfoAsync(e.add,{signal:e.abortController.signal})}catch(r){return e.abortController=null,void(u(r)?e.state=ke.NEW:e.state=ke.REJECTED)}null==t?.symbol?(this._symbolWarningLogged||(this._symbolWarningLogged=!0,i.getLogger(this).warn(`Graphic in layer ${this.layer.id} has no symbol and will not render`)),e.renderingInfo=null):e.renderingInfo=t,e.state=ke.READY}_addGraphic(e,t,i){if(this._graphicsWithoutSymbol.set(e.uid,e),null==t?.symbol||!N(e))return;if(null!=this.stage.renderView.objectAndLayerIdRenderHelper&&this.setUidToIdOnAdd){const t=Z(this.owner.view.map,this.layer.uid);this.stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(e.objectId,e.uid,this.layer.id,this.layer.uid,!!this.layer.popupEnabled&&!t&&xe(this.layer,this.owner.view.popup?.defaultPopupTemplateEnabled))}const r=t.symbol,s=this.getOrCreateGraphics3DSymbol(r,t.renderer);if(null==s)return;this._expandComputedExtent(e.geometry);const a=this._beginGraphicUpdate(e),n=new le(e,t,this.layer);let o=!1;const l=e=>{e===s.symbol.id&&(o=!0)};this._whenSymbolRemoved.push(l);const h=()=>{if(--this._loadingSymbols,this.destroyed)return;this._whenSymbolRemoved.removeUnordered(l);if(this._graphicsWaitingForSymbol.get(e.uid)!==a||o||s.destroyed||this.graphicSymbolSupported&&e.symbol&&e.symbol.id!==s.symbol.id)--s.referenced,this._cleanupSymbols();else{const t=this._createGraphics3DGraphic(s,n);this._spatialIndex&&null!=t&&this._spatialIndex.add(t),--s.referenced,this._endGraphicUpdate(e)}this._featureStore.events.emit("changed"),this._labeler?.setDirty()},d=t=>{--this._loadingSymbols,this.destroyed||(this._whenSymbolRemoved.removeUnordered(l),o||(u(t)?this.add([e]):s.destroyed||this._endGraphicUpdate(e)))};++this._loadingSymbols,i===Ge.ASYNC?s.load((()=>this._dataUpdateQueue.push(h,null).catch(m)),(e=>this._dataUpdateQueue.push((()=>d(e)),null).catch(m))):s.load(h,d)}_removeGraphic(e){const t=e.uid,i=this.graphics3DGraphics.get(t);if(i){i.graphics3DSymbol.onRemoveGraphic(i);const e=i.usedMemory,r=i.isElevationSource;this._conditionalRemove(i,t),this._spatialIndex?.remove(i);const s=i.graphics3DSymbol.symbol.id;this._graphicsBySymbol.get(s)?.delete(t),this._graphicsWithoutSymbol.delete(t),this._removeGraphics3DGraphic(t,e,r),i.destroy(),this._featureStore.events.emit("changed")}else this._graphicsWithoutSymbol.delete(t),this._graphicsWaitingForSymbol.delete(t),0===this._graphicsWaitingForSymbol.size&&(this._cleanupSymbols(),this.notifyChange("dataUpdating"))}_hasLabelingContext(e){if(e instanceof Le||e instanceof je){const t=this.symbolCreationContext.layer;return!!t.labelingInfo&&t.labelingInfo.some((t=>t.symbol===e))}return!1}_hasValidSymbolCreationContext(e){return!(e instanceof Le&&!this._hasLabelingContext(e))||(i.getLogger(this).error("LabelSymbol3D is only valid as part of a LabelClass. Using LabelSymbol3D as a renderer symbol is not supported."),!1)}_getRenderingInfo(e,t){const i=e.geometry;if(null==i)return t&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,t.warn(`Graphic in layer ${this.layer.id} has no geometry and will not render`)),null;if(!U(i.spatialReference,this._viewSpatialReference))return t&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,t.warn(`Graphic in layer ${this.layer.id} has incompatible spatial reference and will not render`)),null;if(!this.graphicSymbolSupported&&null!=e.symbol)return t&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,t.warn(`Graphic in layer ${this.layer.id} is not allowed to have a symbol, use a renderer instead`)),null;const r=this.rendererHasGeometryOperations?B(e,this.layer):e;let s;if(this.owner.getRenderingInfo&&(this.getRenderingInfoWithoutRenderer||null!=this.currentRenderer))s=this.owner.getRenderingInfo(r,this.currentRenderer,this._arcadeOnDemand);else{s={symbol:r.symbol||J(r.geometry)}}return null==s?.symbol?(t&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,t.warn(`Graphic in layer ${this.layer.id} has no symbol and will not render`)),null):s}_getRenderingInfoAsync(e,t){if(null==e.geometry)return this._geometryWarningLogged||(this._geometryWarningLogged=!0,i.getLogger(this).warn(`Graphic in layer ${this.layer.id} has no geometry and will not render`)),null;if(!this.graphicSymbolSupported&&null!=e.symbol)return this._symbolWarningLogged||(this._symbolWarningLogged=!0,i.getLogger(this).warn(`Graphic in layer ${this.layer.id} is not allowed to have a symbol, use a renderer instead`)),null;const r=this.rendererHasGeometryOperations?B(e,this.layer):e;return this.owner.getRenderingInfoAsync(r,this.currentRenderer,this._arcadeOnDemand,t)}_createGraphics3DSymbol(e,t){if(!this._hasValidSymbolCreationContext(e))return null;const i=this._getConvertedSymbol(e);if(!i)return null;let r;if(null!=t&&"backgroundFillSymbol"in t&&t.backgroundFillSymbol){const e=X(t.backgroundFillSymbol,{ignoreDrivers:!0});null!=e.symbol&&(r=e.symbol.symbolLayers)}const s=de(i,this.symbolCreationContext,r);return s.load((()=>{const e=s.extentPadding;e>this.extentPadding&&this._set("extentPadding",e),this.notifyChange("averageSymbolComplexity")}),(()=>{})),s}getOrCreateGraphics3DSymbol(e,t){let i=this._symbols.get(e.id);if(void 0===i){const r=this._unusedSymbolsCache.pop(e.id);i=null!=r?r:e instanceof Oe?new pe(e,(e=>this._dataUpdateQueue.push(e,null)),(e=>this._createGraphics3DSymbol(e,t))):this._createGraphics3DSymbol(e,t),this._symbols.set(e.id,i)}return null!=i&&++i.referenced,i}trackGraphicState(e){return null==this._graphicStateTracking&&(this._graphicStateTracking=new ye(this)),this._graphicStateTracking.add(e)}_addGraphics3DGraphic(e){this._usedMemory+=e.usedMemory,this.graphics3DGraphics.set(e.graphic.uid,e),this._numberOfGraphics++,e.isElevationSource&&(this._numberOfGraphicsProvidingElevation++,this.updateStageLayerElevationProvider()),this._updateLayerVisibility()}_removeGraphics3DGraphic(e,t,i=!1){this._usedMemory-=t,this.graphics3DGraphics.delete(e),this._numberOfGraphics--,i&&(this._numberOfGraphicsProvidingElevation--,this.updateStageLayerElevationProvider()),this._updateLayerVisibility()}_createGraphics3DGraphic(e,t){const i=t.graphic;if(this._graphicsWithoutSymbol.delete(i.uid),!this._symbols.has(e.symbol.id))return this.add([i]),null;if(this.graphics3DGraphics.has(i.uid))return null;const r=e.createGraphics3DGraphic(t);if(null==r)return null;this._addGraphics3DGraphic(r);const s=e.symbol.id;this._graphicsBySymbol.has(s)||this._graphicsBySymbol.set(s,new Map),this._graphicsBySymbol.get(s).set(i.uid,r);if(r.isDraped&&this._graphicsDrapedUids.add(i.uid),r.centroid=null,null!=i.geometry&&"point"!==i.geometry.type&&(r.centroid=ge(i.geometry,this._viewSpatialReference)),this._updateUserVisibility(r),null!=this._scaleVisibility&&this._scaleVisibility.updateVisibility(r),null!=this._filterVisibility){const{defaultVisibility:e}=this._filterVisibility;r.setVisibilityFlag(re.GRAPHIC,se.FILTER,e),e||this._filterVisibility.reapply()}this._deconflictor?.addGraphic(r),this._labeler?.addGraphic(r),this._objectStates?.addGraphic(r),r.initialize(this.stageLayer,this.owner),null!=this._graphicStateTracking&&this._graphicStateTracking.addGraphic(r);const a=this._whenGraphics3DGraphicRequests[i.uid];return a&&(delete this._whenGraphics3DGraphicRequests[i.uid],a.resolve(r)),r}_abortRendererChange(){this._rendererChangeAbortController&&(this._rendererChangeAbortController.abort(),this._rendererChangeAbortController=null)}async rendererChange(e){if(this._abortRendererChange(),e!==this.currentRenderer)if(this._validateRenderer(e),null==e&&this._currentRendererChange(null,!1),Y(e))if(e?.arcadeRequired){const t=new AbortController;this._rendererChangeAbortController=t;const{arcadeUtils:i}=await this._ensureArcade();y(t);const r=i.hasGeometryOperations(e);r&&(await i.enableGeometryOperations(),y(t)),this.effectiveUpdatePolicy===Ge.ASYNC?await this._updateQueue.push((()=>this._currentRendererChange(e,r)),t.signal):this._currentRendererChange(e,r),this._rendererChangeAbortController=null}else if(this.effectiveUpdatePolicy===Ge.ASYNC){const t=new AbortController;this._rendererChangeAbortController=t,await this._updateQueue.push((()=>this._currentRendererChange(e,!1)),t.signal),this._rendererChangeAbortController=null}else this._currentRendererChange(e,!1);else this._currentRendererChange(e,!1)}async _ensureArcade(){return null==this._arcadeOnDemand?(this._arcadeOnDemand=await $(),this._arcadeOnDemand):this._arcadeOnDemand}_currentRendererChange(e,t){this.currentRenderer=e,this.rendererHasGeometryOperations=t,this.symbolCreationContext.arcade=this._arcadeOnDemand;const i=this.symbolCreationContext.renderer;if(e===i)return;if(this._symbolConversionCache.clear(),this._unusedSymbolsCache.clear(),null==e)return this.symbolCreationContext.renderer=null,void this.recreateAllGraphicsAndSymbols();const r=R(i,e);this._updateUnchangedSymbolMappings(r,e,i),this.symbolCreationContext.renderer=e,null!=r&&("complete"===r.type?this.recreateAllGraphicsAndSymbols():"partial"===r.type&&(this._applyRendererDiff(r,e,i)?this._labeler?.reset():this.recreateAllGraphicsAndSymbols()),this.notifyChange("averageSymbolComplexity"))}_diffHasSymbolChange(e){for(const t in e.diff)switch(t){case"visualVariables":case"defaultSymbol":case"uniqueValueInfos":break;case"uniqueValueGroups":case"authoringInfo":case"fieldDelimiter":delete e.diff[t];break;default:return!0}return!1}_applySymbolSetDiff(e,t,i){e=e||[],t=t||[];const r=[];for(const s of t){const t=this._graphicsBySymbol.get(s.id);t&&t.forEach(((a,n)=>{const o=a.graphic,l=this.layer instanceof z?this.layer:null,h=this._arcadeOnDemand;if(s===i.defaultSymbol&&i.getSymbol(B(o,l),{arcade:h})===i.defaultSymbol)return;const d=a.usedMemory;e.length||i.defaultSymbol?r.push(o):this._graphicsWithoutSymbol.set(n,o);const p=this.graphics3DGraphics.get(n);this._conditionalRemove(p,n),a.destroy(),t.delete(n),this._removeGraphics3DGraphic(n,d),this._updateLayerVisibility()})),this._whenSymbolRemoved.forAll((e=>e(s.id)))}(e.length||r.length)&&(this._graphicsWithoutSymbol.forEach((e=>r.push(e))),this._graphicsWithoutSymbol.clear(),this.add(r)),this._cleanupSymbols(),this._labeler?.setDirty(),this._deconflictor?.setDirty()}_applyUniqueValueRendererDiff(e,t,i){const r=e.diff.defaultSymbol,a=e.diff.uniqueValueInfos;if(r||a){const n=a?a.added.map((e=>e.symbol)).filter(s):[],o=a?a.removed.map((e=>e.symbol)).filter(s):[];if(a)for(let e=0;e<a.changed.length;e++)n.push(a.changed[e].newValue.symbol),o.push(a.changed[e].oldValue.symbol);return r?(i.defaultSymbol&&o.push(i.defaultSymbol),t.defaultSymbol&&n.push(t.defaultSymbol)):i.defaultSymbol&&n.length&&o.push(t.defaultSymbol),this._applySymbolSetDiff(n,o,t),delete e.diff.defaultSymbol,delete e.diff.uniqueValueInfos,!0}return!1}_calculateUnchangedSymbolMapping(e,t,i){if("unique-value"!==t?.type||"unique-value"!==i?.type||null!=e&&"partial"!==e.type)return[];const r=e=>null!=e?e.id:null,s=e&&e.diff,a=s?.defaultSymbol,n=s&&s.uniqueValueInfos;let o;if(n)o=n.unchanged.map((e=>({oldId:r(e.oldValue.symbol),newId:r(e.newValue.symbol)})));else{o=[];for(const e of i.uniqueValueInfos??[]){const i=r(e.symbol),s=t.uniqueValueInfos?.find((t=>t.value===e.value));s&&i!==r(s.symbol)&&o.push({oldId:i,newId:r(s.symbol)})}}return!a&&i.defaultSymbol&&o.push({oldId:r(i.defaultSymbol),newId:r(t.defaultSymbol)}),o}_updateSymbolMapping(e,t){const i=null!=t&&t?"string"==typeof t?t:t.id:null;if(null==e||e===i)return;const r=this._graphicsBySymbol.get(e);this._graphicsBySymbol.delete(e),void 0!==r&&this._graphicsBySymbol.set(i,r);const s=this._symbols.get(e);if(void 0!==s&&(this._symbols.delete(e),this._symbols.set(i,s),null!=s)){const e="string"==typeof t?null:t;null!=e?s.symbol=e:s.symbol.id=i}}_updateUnchangedSymbolMappings(e,t,i){const r=this._calculateUnchangedSymbolMapping(e,t,i);for(const{oldId:s,newId:a}of r)this._updateSymbolMapping(s,a)}_applyRendererDiff(e,i,r){if(this._diffHasSymbolChange(e))return!1;if(i instanceof t&&r instanceof t&&this._applyUniqueValueRendererDiff(e,i,r)&&0===Object.keys(e.diff).length)return!0;for(const t of this._graphicsBySymbol.keys()){const r=this._symbols.get(t);if(null!=r)switch(r.applyRendererDiff(e,i)){case ue.RecreateSymbol:this._recreateSymbol(t);break;case ue.RecreateGraphics:this._recreateGraphicsForSymbol(t);case ue.FastUpdate:}}return!0}opacityChange(){this.forEachGraphics3DSymbol(((e,t)=>e.globalPropertyChanged("opacity",t))),this._updateStageLayerVisibility()}_slicePlaneEnabledChange(e){e!==this.symbolCreationContext.slicePlaneEnabled&&(this.symbolCreationContext.slicePlaneEnabled=e,this.stageLayer.sliceable=e,this.forEachGraphics3DSymbol(((e,t)=>e.globalPropertyChanged("slicePlaneEnabled",t))),this._deconflictor?.slicePlaneEnabledChange(),this._labeler?.slicePlaneEnabledChange())}_physicalBasedRenderingChange(e){this.symbolCreationContext.physicalBasedRenderingEnabled=e,this.forEachGraphics3DSymbol(((e,t,i)=>{e.globalPropertyChanged("physicalBasedRenderingEnabled",t)||this._recreateSymbol(i)}))}_skipHighSymbolLoDsChange(e){this.symbolCreationContext.skipHighSymbolLods=e,this.forEachGraphics3DSymbol(((e,t,i)=>{e.globalPropertyChanged("skipHighSymbolLods",t)||this._recreateSymbol(i)}))}_pixelRatioChange(){this.forEachGraphics3DSymbol(((e,t,i)=>{e.globalPropertyChanged("pixelRatio",t)||this._recreateSymbol(i)}))}_signalUpdatingDuringAsyncLoadedGraphicsChange(){this._updatingPendingLoadedGraphicsChange&&this._updatingPendingLoadedGraphicsChange.remove(),this._updatingPendingLoadedGraphicsChange=S((()=>{this._updatingPendingLoadedGraphicsChange=null}))}setClippingExtent(e,t){const i=this.symbolCreationContext.clippingExtent,r=M();return ve(e,r,t)?this.symbolCreationContext.clippingExtent=F(O(),r):this.symbolCreationContext.clippingExtent=null,!T(this.symbolCreationContext.clippingExtent,i)}modifyGraphics3DGraphicVisibilities(e){if(this.destroyed)return;let t=!1;this.graphics3DGraphics.forEach((i=>{e(i)&&(t=!0)})),t&&(this._labeler?.setDirty(),this._deconflictor?.setDirty())}forEachGraphics3DSymbol(e){for(const[t,i]of this._symbols){if(null==i)return;e(i,this._graphicsBySymbol.get(t)||Be,t)}}updateAllGraphicsVisibility(){null!=this._filterVisibility&&this._filterVisibility.reapply(),this.modifyGraphics3DGraphicVisibilities((e=>{const t=this._updateUserVisibility(e),i=null!=this._scaleVisibility&&this._scaleVisibility.updateVisibility(e);return t||i}))}_hideAllGraphics(){this.modifyGraphics3DGraphicVisibilities((e=>e.setVisibilityFlag(re.GRAPHIC,se.USER,!1)))}_validateRenderer(e){const t=()=>`'${this.layer.title?`${this.layer.title}, `:""}id:${this.layer.id}'`,r=Q(e,{geometryType:this.layer?.geometryType,logWarning:e=>i.getLogger(this).warn(`Symbology conversion for layer ${t()}: ${e}`)});if(r){const e=`Renderer for layer ${t} is not supported in a SceneView`;i.getLogger(this).warn(e,r.message)}}_cleanupSymbols(){if(this._graphicsWaitingForSymbol.size>0||this._suspendSymbolCleanup)return;let e=!1;this._symbols.forEach(((t,i)=>{if(null==t||t.referenced>0)return;const r=this._graphicsBySymbol.get(i);r&&0!==r.size||(this._graphicsBySymbol.delete(i),this._symbols.delete(i),this._unusedSymbolsCache.put(i,t,_e(t),p),e=!0)})),e&&(this._recomputeExtentPadding(),this.notifyChange("averageSymbolComplexity"))}get test(){}get performanceInfo(){return new ce(this.graphics3DGraphics.size,this._graphicsWithoutSymbol.size,this._pendingUpdates.size)}};var ke;Me.tmpVec=I(),e([G({readOnly:!0})],Me.prototype,"computedExtent",void 0),e([G()],Me.prototype,"currentRenderer",void 0),e([G()],Me.prototype,"rendererHasGeometryOperations",void 0),e([G()],Me.prototype,"_frameTaskHandle",void 0),e([G()],Me.prototype,"_dataUpdateQueue",void 0),e([G()],Me.prototype,"_updateQueue",void 0),e([G({readOnly:!0})],Me.prototype,"_viewSpatialReference",null),e([G()],Me.prototype,"_rendererChangeAbortController",void 0),e([G()],Me.prototype,"_elevationInfoChangeAbortController",void 0),e([G()],Me.prototype,"_initializeAbortController",void 0),e([G()],Me.prototype,"_elevationAlignment",void 0),e([G()],Me.prototype,"_scaleVisibility",void 0),e([G()],Me.prototype,"_filterVisibility",void 0),e([G()],Me.prototype,"_initializePromise",void 0),e([G()],Me.prototype,"_spatialIndex",void 0),e([G({readOnly:!0})],Me.prototype,"extentPadding",void 0),e([G()],Me.prototype,"_updatingPendingLoadedGraphicsChange",void 0),e([G()],Me.prototype,"_featureStore",void 0),e([G()],Me.prototype,"_objectStates",void 0),e([G()],Me.prototype,"_loadingSymbols",void 0),e([G()],Me.prototype,"preferredUpdatePolicy",void 0),e([G()],Me.prototype,"_forcedUpdatePolicy",void 0),e([G({readOnly:!0})],Me.prototype,"effectiveUpdatePolicy",null),e([G({constructOnly:!0})],Me.prototype,"elevationFeatureExpressionEnabled",void 0),e([G({constructOnly:!0})],Me.prototype,"owner",void 0),e([G({constructOnly:!0})],Me.prototype,"layer",void 0),e([G({constructOnly:!0})],Me.prototype,"graphicSymbolSupported",void 0),e([G({constructOnly:!0})],Me.prototype,"getRenderingInfoWithoutRenderer",void 0),e([G({constructOnly:!0})],Me.prototype,"componentFactories",void 0),e([G({constructOnly:!0})],Me.prototype,"setUidToIdOnAdd",void 0),e([G()],Me.prototype,"featureStore",null),e([G()],Me.prototype,"initializePromise",null),e([G()],Me.prototype,"scaleVisibility",null),e([G()],Me.prototype,"elevationAlignment",null),e([G()],Me.prototype,"objectStates",null),e([G()],Me.prototype,"filterVisibility",null),e([G({readOnly:!0})],Me.prototype,"updating",null),e([G({readOnly:!0})],Me.prototype,"dataUpdating",null),e([G({readOnly:!0})],Me.prototype,"running",null),e([G({readOnly:!0})],Me.prototype,"suspendedOrOutsideOfView",null),e([G({readOnly:!0,dependsOn:[]})],Me.prototype,"updatingRemaining",null),e([G({readOnly:!0})],Me.prototype,"displayFeatureLimit",null),e([G({readOnly:!0,dependsOn:[]})],Me.prototype,"averageSymbolComplexity",null),e([G({constructOnly:!0})],Me.prototype,"hasZ",void 0),e([G({constructOnly:!0})],Me.prototype,"hasM",void 0),e([G()],Me.prototype,"_objectIdField",null),Me=Ve=e([w("esri.views.3d.layers.graphics.Graphics3DCore")],Me),function(e){e[e.NEW=0]="NEW",e[e.LOADING=1]="LOADING",e[e.READY=2]="READY",e[e.REJECTED=3]="REJECTED"}(ke||(ke={}));class ze{constructor(){this.add=null,this.renderingInfo=null,this.state=ke.NEW,this.abortController=null,this.remove=null}clear(){this.add=null,this.renderingInfo=null,this.state=ke.NEW,this.abortController=null,this.remove=null}}const We=10,He=I(),Ne=I(),Be=new Map;export{Me as Graphics3DCore};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import"../../../../renderers/ClassBreaksRenderer.js";import"../../../../renderers/DictionaryRenderer.js";import"../../../../renderers/DotDensityRenderer.js";import"../../../../renderers/HeatmapRenderer.js";import"../../../../renderers/PieChartRenderer.js";import"../../../../renderers/Renderer.js";import"../../../../renderers/SimpleRenderer.js";import t from"../../../../renderers/UniqueValueRenderer.js";import"../../../../renderers/support/jsonUtils.js";import i from"../../../../core/Logger.js";import"../../../../symbols.js";import r from"../../../../core/Accessor.js";import{isSome as s}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import a from"../../../../core/Error.js";import{makeHandle as n}from"../../../../core/handleUtils.js";import{findInMap as o}from"../../../../core/MapUtils.js";import{removeMaybe as l,destroyMaybe as h,disposeMaybe as d}from"../../../../core/maybe.js";import{MinPriority as p}from"../../../../core/MemCache.js";import c from"../../../../core/PooledArray.js";import{throwIfAborted as y,createResolver as g,isAbortError as u,ignoreAbortErrors as m}from"../../../../core/promiseUtils.js";import{watch as b,when as _,on as f,syncAndInitial as v,whenOnce as C}from"../../../../core/reactiveUtils.js";import{schedule as S}from"../../../../core/scheduling.js";import{property as G}from"../../../../core/accessorSupport/decorators/property.js";import{subclass as w}from"../../../../core/accessorSupport/decorators/subclass.js";import{diff as R,isEmpty as x}from"../../../../core/accessorSupport/diffUtils.js";import{s as P,g as D,j as E}from"../../../../chunks/vec32.js";import{create as I}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{canProjectWithoutEngine as U}from"../../../../geometry/projection.js";import{projectBuffer as A}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as L}from"../../../../geometry/projection/projectVectorToVector.js";import{projectXYZToVector as j}from"../../../../geometry/projection/projectXYZToVector.js";import{create as O,center as V,fromRect as F,equals as M}from"../../../../geometry/support/aaBoundingBox.js";import{create as T}from"../../../../geometry/support/aaBoundingRect.js";import{equals as k}from"../../../../geometry/support/spatialReferenceUtils.js";import z from"../../../../layers/Layer.js";import{getObjectId as W,computeAABB as H,hasGeometry as N}from"../../../../layers/graphics/dehydratedFeatures.js";import{hydrateGraphic as B}from"../../../../layers/graphics/hydratedFeatures.js";import{PromiseQueue as q}from"../../../../layers/support/PromiseQueue.js";import{isSupportedRenderer3D as Y,validateTo3D as Q}from"../../../../renderers/support/rendererConversion.js";import{loadArcade as $}from"../../../../support/arcadeOnDemand.js";import{isBasemapLayer as Z}from"../../../../support/basemapUtils.js";import{getDefaultSymbol3D as J}from"../../../../symbols/support/defaults3D.js";import{to3D as X}from"../../../../symbols/support/symbolConversion.js";import{averageSymbolComplexities as K,defaultSymbolComplexity as ee}from"./defaultSymbolComplexity.js";import{DisplayFeatureLimit as te}from"./DisplayFeatureLimit.js";import{ViewElevationProvider as ie}from"./ElevationQuery.js";import{VisibilityGroup as re,VisibilityFlag as se}from"./enums.js";import{extractExpressionInfo as ae,createContext as ne}from"./featureExpressionInfoUtils.js";import{Graphics3DFeatureStore as oe}from"./Graphics3DFeatureStore.js";import{Graphics3DGraphicCreationContext as le}from"./Graphics3DGraphicCreationContext.js";import{Graphics3DSymbolCreationContext as he}from"./Graphics3DSymbolCreationContext.js";import{make as de}from"./Graphics3DSymbolFactory.js";import{Graphics3DWebStyleSymbol as pe}from"./Graphics3DWebStyleSymbol.js";import{GraphicsCorePerformanceInfo as ce}from"./GraphicsCorePerformanceInfo.js";import{GraphicStateTracking as ye}from"./GraphicStateTracking.js";import{computeCentroid as ge}from"./graphicUtils.js";import{ApplyRendererDiffResult as ue}from"./interfaces.js";import{LoadStatus as me}from"./Loadable.js";import{SpatialIndex2D as be}from"./SpatialIndex2D.js";import{getSymbolMemorySize as _e}from"./symbolMemory.js";import{StageLayerElevationProvider as fe}from"../support/StageLayerElevationProvider.js";import{toBoundingRect as ve}from"../../support/extentUtils.js";import{PropertiesPool as Ce}from"../../support/PropertiesPool.js";import{GridLocalOriginFactory as Se}from"../../webgl-engine/lib/GridLocalOriginFactory.js";import{UpdatePolicy as Ge}from"../../webgl-engine/lib/UpdatePolicy.js";import{affectsGeometry as we}from"../../webgl-engine/lib/VertexAttribute.js";import{WebGLLayer as Re}from"../../webgl-engine/lib/WebGLLayer.js";import{hasPopupTemplate as xe}from"../../../layers/support/popupUtils.js";import{ImmediateTask as Pe,noBudget as De,TaskPriority as Ee}from"../../../support/Scheduler.js";import{Yield as Ie}from"../../../support/Yield.js";import Ue from"../../../../geometry/Extent.js";import Ae from"../../../../geometry/Point.js";import Le from"../../../../symbols/LabelSymbol3D.js";import je from"../../../../symbols/TextSymbol.js";import Oe from"../../../../symbols/WebStyleSymbol.js";var Ve;const Fe=I(),Me=O();let Te=Ve=class extends r{get _viewSpatialReference(){return this.owner.view.spatialReference}get spatialIndex(){return this._spatialIndex||(this._spatialIndex=new be({objectIdField:this.owner.layer?.objectIdField,spatialReference:this._viewSpatialReference,hasZ:!!this.hasZ,hasM:!!this.hasM}),this._spatialIndex.setup(Array.from(this.graphics3DGraphics.values()))),this._spatialIndex.update(),this._spatialIndex}get deconflictor(){return this._deconflictor}get labeler(){return this._labeler}get numberOfGraphics(){return this._numberOfGraphics}get effectiveUpdatePolicy(){return null!=this.currentRenderer&&"dictionary"===this.currentRenderer.type?Ge.ASYNC:this._forcedUpdatePolicy??this.preferredUpdatePolicy}get featureStore(){return this._featureStore}get initializePromise(){return this._initializePromise}get scaleVisibility(){return this._scaleVisibility}get elevationAlignment(){return this._elevationAlignment}get objectStates(){return this._objectStates}get filterVisibility(){return this._filterVisibility}get updating(){return!!(this.dataUpdating||this._elevationAlignment?.updating||this._scaleVisibility?.updating||this._filterVisibility?.updating||this._rendererChangeAbortController||this._elevationInfoChangeAbortController||this._frameTaskHandle.updating||this.running)}get dataUpdating(){return!!(this._graphicsWaitingForSymbol.size>0||this._pendingUpdates.size>0||this._spatialIndex?.updating||this._updatingPendingLoadedGraphicsChange||this._dataUpdateQueue.running||this._loadingSymbols>0)}get running(){return this._pendingUpdates.size>0||!!this._spatialIndex?.updating||this._dataUpdateQueue.running||this._updateQueue.running}get suspendedOrOutsideOfView(){return this.owner.suspended||!!this.owner.suspendInfo?.outsideOfView}get updatingRemaining(){return this.updating?this._pendingUpdates.size+.1*(this._spatialIndex?.updatingRemaining||0)+.1*(this._elevationAlignment?.updatingRemaining||0):0}get displayFeatureLimit(){const e=this.owner&&this.owner.view&&this.owner.view.qualitySettings,t=e?.graphics3D.minTotalNumberOfFeatures??0,i=e?.graphics3D.maxTotalNumberOfFeatures??0,r=e?.graphics3D.maxNumberOfDrawCalls??0,s=e?.graphics3D.maxTotalNumberOfVertices??0,a=this.averageSymbolComplexity,n=Math.max(1,a?.verticesPerFeature??1),o=a&&a.drawCallsPerFeature>0&&r>0?r/a.drawCallsPerFeature:i,l=Math.ceil(s/n),h=Math.max(t,Math.min(i,l,o)),d=this._get("displayFeatureLimit");return d&&d.maximumTotalNumberOfVertices===s&&d.averageSymbolComplexity===a&&d.maximumNumberOfFeatures===h?d:new te(s,h,a)}get averageSymbolComplexity(){const e=K(this._symbolComplexities),t=this._get("averageSymbolComplexity");return 0===e.numComplexities||null!=t&&(e.estimated&&(t.verticesPerFeature>=e.verticesPerFeature||t.verticesPerCoordinate>=e.verticesPerCoordinate||t.drawCallsPerFeature>=e.drawCallsPerFeature)||t.verticesPerFeature===e.verticesPerFeature&&t.verticesPerCoordinate===e.verticesPerCoordinate&&t.drawCallsPerFeature===e.drawCallsPerFeature)?t:e}get usedMemory(){const e=null!=this.averageSymbolComplexity&&this.labelsEnabled?this.averageSymbolComplexity.memory.bytesPerFeatureLabel*this._numberOfGraphics:0,t=this._getSymbolComplexitiesUsed().reduce(((e,t)=>e+t.memory.resourceBytes),0);if(null==this._symbolMaterials){this._symbolMaterials=[];for(const e of this._symbols.values())if(null!=e)for(const t of e.symbolLayers)if(t)for(const e of t.materials)e&&this._symbolMaterials.push(e)}const i=this.owner.view._stage.renderer.plugins,r=this.owner.view.basemapTerrain.overlayManager.renderer,s=this._symbolMaterials.reduce(((e,t)=>e+((i.getMaterialRenderer(t)||r.getMaterialRenderer(t))?.usedMemory??0)),0);return this._usedMemory+e+t+s}get usedMemoryPerGraphic(){if(this._usedMemory&&this._numberOfGraphics){const e=this._numberOfGraphics/(this._numberOfGraphics+Math.max(this._pendingAdds,this._pendingRemoves));return this._usedMemory/this._numberOfGraphics*e}if(null!=this.averageSymbolComplexity){const e=this.labelsEnabled?this.averageSymbolComplexity.memory.bytesPerFeatureLabel:0;return this.averageSymbolComplexity.memory.bytesPerFeature+e}return 0}get unprocessedMemoryEstimate(){return(this._pendingAdds-this._pendingRemoves)*this.usedMemoryPerGraphic}get _symbolComplexities(){return this.currentRenderer?this._getSymbolComplexitiesUsedOrRenderer(this.currentRenderer):this._getSymbolComplexitiesUsed()}get visible(){return this._visible}_getConvertedSymbol(e){if("web-style"===e.type)return e.clone();const t=this._symbolConversionCache.get(e.id);if(null!=t)return t;const r=X(e,{geometryType:this.layer?.geometryType??void 0,retainId:!0,hasLabelingContext:this._hasLabelingContext(e),cimFallbackEnabled:!0}),s=r.symbol||null;return null==s&&r.error&&i.getLogger(this).error(r.error.message),this._symbolConversionCache.set(e.id,s),s}_getSymbolComplexitiesUsedOrRenderer(e){if(null==e)return[];const t=e.getSymbols(),i="backgroundFillSymbol"in e?e.backgroundFillSymbol:null;if(!i&&!t?.length)return[];const r=[],s=this._getSymbolComplexityUsedOrRenderer(i);null!=s&&r.push(s);for(const a of t){const e=this._getSymbolComplexityUsedOrRenderer(a);null!=e&&r.push(e)}return r}_getSymbolComplexityUsedOrRenderer(e){if(null==e)return null;const t=this._symbols.get(e.id);if(null!=t)return t.complexity;const i=this._getConvertedSymbol(e);return null!=i?ee(i):null}_getSymbolComplexitiesUsed(){const e=[];return this._symbols.forEach((t=>{null!=t&&e.push(t.complexity)})),e}get _objectIdField(){return this.layer.objectIdField}constructor(e){super(e),this._propertiesPool=new Ce({computedExtent:Ue},this),this.computedExtent=null,this.currentRenderer=null,this.rendererHasGeometryOperations=!1,this._graphicStateTracking=null,this.graphics3DGraphics=new Map,this.stageLayer=null,this.stage=null,this._graphicsDrapedUids=new Set,this._graphicsBySymbol=new Map,this._symbolConversionCache=new Map,this._symbols=new Map,this._graphicsWithoutSymbol=new Map,this._graphicsWaitingForSymbol=new Map,this._graphicsUpdateId=0,this._frameTaskHandle=Pe,this._dataUpdateQueue=new q,this._updateQueue=new q,this._suspendSymbolCleanup=!1,this._arcadeOnDemand=null,this._rendererChangeAbortController=null,this._elevationInfoChangeAbortController=null,this._initializeAbortController=null,this._elevationAlignment=null,this._scaleVisibility=null,this._filterVisibility=null,this._spatialIndex=null,this.extentPadding=0,this._updatingPendingLoadedGraphicsChange=null,this._featureStore=null,this._deconflictor=null,this._labeler=null,this._objectStates=null,this._viewElevationProvider=null,this._stageLayerElevationProvider=null,this._sharedSymbolResourcesOwnerHandle=null,this._whenGraphics3DGraphicRequests={},this._pendingUpdates=new Map,this._numberOfGraphics=0,this._numberOfGraphicsProvidingElevation=0,this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1,this._loadingSymbols=0,this._pendingUpdatesPool=new c({allocator:e=>e||new ze,deallocator:e=>(e.clear(),e)}),this._symbolWarningLogged=!1,this._geometryWarningLogged=!1,this._objectIdInvisibleSet=new Set,this._whenSymbolRemoved=new c,this.preferredUpdatePolicy=Ge.SYNC,this._forcedUpdatePolicy=null,this.elevationFeatureExpressionEnabled=!0,this.owner=null,this.layer=null,this.graphicSymbolSupported=!0,this.getRenderingInfoWithoutRenderer=!1,this.setUidToIdOnAdd=!0,this.hasZ=null,this.hasM=null,this._usedMemory=0,this._visible=!1,this._startCreateGraphics=!1,this._unusedSymbolsCache=e.owner.view.resourceController.memoryController.newCache("graphics-3d-unused-symbols",(e=>e.destroy())),this.symbolCreationContext=new he(e.owner.view.resourceController.scheduler,((e,t)=>this._updateQueue.push(e,t)))}initialize(){this._featureStore=new oe({objectIdField:this.owner.layer?.objectIdField,hasZ:!!this.hasZ,hasM:!!this.hasM,viewSpatialReference:this._viewSpatialReference,featureSpatialReference:this.owner.featureSpatialReference,getSpatialIndex:()=>this.spatialIndex,forEach:e=>this.graphics3DGraphics.forEach(e)});const e=(e,t,i)=>this.spatialIndex.queryGraphicUIDsInExtent(e,t,i),{componentFactories:t}=this;this._elevationAlignment=t.elevationAlignment?.(this,e),this._scaleVisibility=t.scaleVisibility?.(this,e),this._filterVisibility=t.filterVisibility?.({featureStore:this._featureStore,getFeatureCount:()=>this.graphics3DGraphics.size,updateFeatureVisibilities:e=>this.modifyGraphics3DGraphicVisibilities((t=>t.setVisibilityFlag(re.GRAPHIC,se.FILTER,e(W(t.graphic,this._objectIdField))))),setAllFeaturesVisibility:e=>this.modifyGraphics3DGraphicVisibilities((t=>t.setVisibilityFlag(re.GRAPHIC,se.FILTER,e))),clearFeaturesVisibility:()=>this.modifyGraphics3DGraphicVisibilities((e=>e.setVisibilityFlag(re.GRAPHIC,se.FILTER,!0)))}),this._deconflictor=t.deconflictor?.(this),this._labeler=t.labeler?.(this,this._scaleVisibility),this._objectStates=t.objectStates?.(this),this._initializeAbortController=new AbortController,this._initializePromise=this._initializeAsync()}async _initializeAsync(){const e=this._initializeAbortController?.signal,t=this.owner.view;this._viewElevationProvider=new ie(this._viewSpatialReference,t),this._initializeStage(t,this.layer.uid);const r=t.sharedSymbolResources;this.symbolCreationContext.sharedResources=r,this._sharedSymbolResourcesOwnerHandle=r.addGraphicsOwner(this.owner),null!=this.currentRenderer&&(this.symbolCreationContext.renderer=this.currentRenderer),this.symbolCreationContext.stage=this.stage,this.symbolCreationContext.streamDataRequester=r.streamDataRequester,this.symbolCreationContext.renderCoordsHelper=t.renderCoordsHelper,this.symbolCreationContext.layer=this.layer,this.symbolCreationContext.graphicsCoreOwner=this.owner,this.symbolCreationContext.localOriginFactory=new Se(t.renderSpatialReference),this.symbolCreationContext.elevationProvider=t.elevationProvider,this.symbolCreationContext.notifyGraphicGeometryChanged=e=>this.notifyGraphicGeometryChanged(e),this.symbolCreationContext.notifyGraphicVisibilityChanged=e=>this.notifyGraphicVisibilityChanged(e);const s=ae(this.layer.elevationInfo,this.elevationFeatureExpressionEnabled);if(this.symbolCreationContext.featureExpressionInfoContext=await ne(s,this._viewSpatialReference,e,i.getLogger(this)),y(e),this.symbolCreationContext.screenSizePerspectiveEnabled=t.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled,this.symbolCreationContext.slicePlaneEnabled=!!this.owner.slicePlaneEnabled,this.symbolCreationContext.physicalBasedRenderingEnabled=!!this.owner.view.qualitySettings?.physicallyBasedRenderingEnabled,this.symbolCreationContext.skipHighSymbolLods=!!this.owner.view.qualitySettings?.graphics3D?.skipHighSymbolLods,"drapeSourceType"in this.owner){const{owner:e}=this;this.symbolCreationContext.drapeSourceRenderer=t.basemapTerrain.overlayManager.registerGeometryDrapeSource(e),this.addHandles(n((()=>t.basemapTerrain.overlayManager.unregisterDrapeSource(e))))}this.addHandles([b((()=>this.suspendedOrOutsideOfView),(()=>this._updateQueue.unshift((()=>this._updateLayerVisibility()),null).catch(m))),b((()=>[this.layer?.screenSizePerspectiveEnabled,this.owner.view?.screenSizePerspectiveEnabled]),(()=>{const e=t.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled;e!==this.symbolCreationContext.screenSizePerspectiveEnabled&&(this.symbolCreationContext.screenSizePerspectiveEnabled=e,this._labeler?.reset(),this.recreateAllGraphicsAndSymbols())})),b((()=>this.owner.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(!!e))),b((()=>this.owner.view.state?.rasterPixelRatio),(()=>this._pixelRatioChange())),b((()=>!!this.owner.view.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._physicalBasedRenderingChange(e))),b((()=>!!this.owner.view.qualitySettings?.graphics3D?.skipHighSymbolLods),(e=>this._skipHighSymbolLoDsChange(e))),_((()=>t.basemapTerrain?.tilingScheme),(e=>{if(e.spatialReference.equals(this.symbolCreationContext.overlaySR)||null==t.basemapTerrain.spatialReference||(this.symbolCreationContext.overlaySR=t.basemapTerrain.spatialReference),this.hasHandles("loaded-graphics"))this.recreateAllGraphics();else{const e=()=>this.owner?.loadedGraphics;this.addHandles([f(e,"change",(e=>{this._graphicsCollectionChanged(e),this._signalUpdatingDuringAsyncLoadedGraphicsChange()}),{onListenerAdd:()=>{this.recreateAllGraphics(),this._signalUpdatingDuringAsyncLoadedGraphicsChange()}})],"loaded-graphics")}}),{initial:!0}),b((()=>this.effectiveUpdatePolicy),(e=>{null!=this.stageLayer&&(this.stageLayer.updatePolicy=e),this.symbolCreationContext.isAsync=this.effectiveUpdatePolicy===Ge.ASYNC,e===Ge.SYNC&&this.runTask(De)}),v)]),this._frameTaskHandle=t.resourceController.scheduler.registerTask(Ee.GRAPHICS_CORE,this),this.layer&&"featureReduction"in this.layer&&this.addHandles(b((()=>this.layer.featureReduction),(()=>this._deconflictor?.featureReductionChange()))),this.notifyChange("averageSymbolComplexity"),this.rendererChange(this.owner.renderer).catch((()=>{})),this._initializeAbortController=null}_abortInitialize(){this._initializeAbortController&&(this._initializeAbortController.abort(),this._initializeAbortController=null)}destroy(){this._unusedSymbolsCache.destroy(),this._abortInitialize(),this._abortRendererChange(),this._abortElevationInfoChange(),this._frameTaskHandle.remove(),this._frameTaskHandle=Pe,this._dataUpdateQueue.cancelAll(),this._updateQueue.cancelAll(),this._deconflictor=l(this._deconflictor),this._labeler=l(this._labeler),this._elevationAlignment=h(this._elevationAlignment),this._scaleVisibility=h(this._scaleVisibility),this._filterVisibility=h(this._filterVisibility),this._objectStates=h(this._objectStates),this.clear(),this._featureStore=h(this._featureStore),this._updatingPendingLoadedGraphicsChange=l(this._updatingPendingLoadedGraphicsChange),this._graphicStateTracking=h(this._graphicStateTracking),this.stage&&(this.stageLayer=h(this.stageLayer),this.stage=null),this._set("owner",null);for(const e in this._whenGraphics3DGraphicRequests)this._whenGraphics3DGraphicRequests[e].reject(new a("graphic:layer-destroyed","Layer has been destroyed"));this._whenGraphics3DGraphicRequests=null,this._sharedSymbolResourcesOwnerHandle=l(this._sharedSymbolResourcesOwnerHandle),this._propertiesPool=h(this._propertiesPool),this._pendingUpdatesPool=null,this._symbolConversionCache.clear(),this._objectIdInvisibleSet.clear(),this._spatialIndex=h(this._spatialIndex)}clear(){this._objectStates?.allGraphicsDeleted(),null!=this._graphicStateTracking&&this._graphicStateTracking.allGraphicsDeleted(),this.graphics3DGraphics.forEach((e=>e.destroy())),this._spatialIndex?.clear(),this.graphics3DGraphics.clear(),this._numberOfGraphics=0,this._usedMemory=0,this._updateLayerVisibility(),this._symbols.forEach(h),this._symbols.clear(),this._symbolMaterials=null,this._graphicsBySymbol.clear(),this._graphicsWithoutSymbol.clear(),this._graphicsWaitingForSymbol.clear(),this._pendingUpdates.clear(),this._pendingUpdatesPool.clear(),this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1,this.notifyChange("dataUpdating"),this.notifyChange("running"),this.notifyChange("updatingRemaining"),this._featureStore.events.emit("changed")}_initializeStage(e,t){this.stage=e._stage,this.stageLayer=new Re(this.stage,{pickable:!this.suspendedOrOutsideOfView,updatePolicy:this.effectiveUpdatePolicy},t);const i=this.stageLayer.events;i.on("transformationChanged",(e=>this.notifyGraphicGeometryChanged(e.graphicUid))),i.on("shaderTransformationChanged",(e=>this.notifyGraphicGeometryChanged(e.graphicUid))),i.on("visibilityChanged",(e=>this.notifyGraphicVisibilityChanged(e.graphicUid))),i.on("geometryAdded",(e=>this.notifyGraphicGeometryChanged(e.object.graphicUid))),i.on("geometryRemoved",(e=>this.notifyGraphicGeometryChanged(e.object.graphicUid))),i.on("attributesChanged",(e=>we(e.attribute)&&this.notifyGraphicGeometryChanged(e.object.graphicUid)))}notifyGraphicGeometryChanged(e){if(null==this._graphicStateTracking||null==e)return;const t=this.graphics3DGraphics.get(e);t&&this._graphicStateTracking.updateGraphicGeometry(t)}notifyGraphicVisibilityChanged(e){if(null==this._graphicStateTracking||null==e)return;const t=this.graphics3DGraphics.get(e);t&&this._graphicStateTracking.updateGraphicVisibility(t)}_updateLayerVisibility(){const e=this.displayFeatureLimit.maximumNumberOfFeatures,t=this._numberOfGraphics>e*We,i=!this.suspendedOrOutsideOfView&&!t;i!==this._visible&&(this._visible=i,i?(this.stageLayer.pickable=!0,this.updateAllGraphicsVisibility()):(this.stageLayer.pickable=!1,this._hideAllGraphics()),this._updateStageLayerVisibility())}_updateStageLayerVisibility(){this.stageLayer.visible=this._visible&&(null==this.layer.opacity||this.layer.opacity>0)}getGraphics3DGraphicById(e){return null!=e?this.graphics3DGraphics.get(e):void 0}getGraphics3DGraphicByObjectId(e){return this.owner.layer?.objectIdField?this._findGraphics3DGraphicByObjectId(e):null}_getGraphicObjectID(e,t=this.owner.layer?.objectIdField){return W(e,t)}get graphics3DGraphicsByObjectID(){const e=this.owner.layer?.objectIdField;if(!e)return;const t=new Map;return this.graphics3DGraphics.forEach((i=>{if(!i)return;const r=i.graphic,s=this._getGraphicObjectID(r,e);null!=s&&t.set(s,i)})),t}get labelsEnabled(){return!!this._labeler?.layerLabelsEnabled()}async updateLabelingInfo(e){const t=this._deconflictor?.labelingInfoChange(e),i=this._labeler?.labelingInfoChange(e);await Promise.allSettled([t,i])}updateVisibilityInfo(){this._deconflictor?.labelingInfoChange(),this._labeler?.visibilityInfoChange()}get symbolUpdateType(){if(this._pendingUpdates.size>0)return"unknown";let e=0,t=0;for(const[i,r]of this._symbols)if(null!=r){const s=r.getFastUpdateStatus();if(s.loading>0)return"unknown";this._graphicsBySymbol.has(i)&&(t+=s.fast,e+=s.slow)}return t>=0&&0===e?"fast":e>=0&&0===t?"slow":"mixed"}runTask(e){if(this._dataUpdateQueue.runTask(e),this._updateQueue.runTask(e),this._applyPendingUpdates(e),this.notifyChange("running"),this.running||this.notifyChange("dataUpdating"),this.notifyChange("updatingRemaining"),!e.hasProgressed)return Ie}setObjectIdVisibility(e,t){t?this._objectIdInvisibleSet.delete(e):this._objectIdInvisibleSet.add(e);const i=this._findGraphics3DGraphicByObjectId(e);null!=i&&this._updateUserVisibility(i)}_findGraphics3DGraphicByObjectId(e){return o(this.graphics3DGraphics,(t=>this._getGraphicObjectID(t.graphic)===e))}_updateUserVisibility(e){if(null==e)return!1;const t=e.graphic,i=this._getGraphicObjectID(t),r=t.visible&&!this.owner.suspended&&(null==i||!this._objectIdInvisibleSet.has(i));return e.setVisibilityFlag(re.GRAPHIC,se.USER,r)}_whenGraphics3DGraphic(e){const t=this.graphics3DGraphics.get(e.uid);if(t)return Promise.resolve(t);const i=this._whenGraphics3DGraphicRequests[e.uid];if(i)return i.promise;const r=g();return this._whenGraphics3DGraphicRequests[e.uid]=r,r.promise}async _boundsForGraphics3DGraphic(e,t){const i=this._viewSpatialReference,r=this.owner.view.renderSpatialReference,s=this.owner.view.basemapTerrain.spatialReference,a=(e,t,s)=>A(e,r,t,e,i,t,s),n=(e,t,r)=>A(e,s,t,e,i,t,r),o=this._viewElevationProvider?{service:this._viewElevationProvider,useViewElevation:null!=t&&!!t.useViewElevation,minDemResolution:null!=t?t.minDemResolution:null,minDemResolutionForPoints:this.owner.view.resolution}:null,l=await e.getProjectedBoundingBox(a,n,o,t?.signal);if(!l)return null;const h=l.boundingBox;if(l.requiresDrapedElevation){const e=this.symbolCreationContext.elevationProvider;if(e){V(h,Fe);const t=e.getElevation(Fe[0],Fe[1],0,i,"ground")??0;h[2]=Math.min(h[2],t),h[5]=Math.max(h[5],t)}}return{boundingBox:h,screenSpaceObjects:l.screenSpaceObjects}}async whenGraphicBounds(e,t){await C((()=>this.owner?.loadedGraphics));const i=this.owner.layer?.objectIdField,r=this.owner.loadedGraphics.find((t=>t===e||null!=i&&null!=t.attributes&&e.attributes&&t.attributes[i]===e.attributes[i]));if(!r)throw new a("internal:graphic-not-part-of-view","Graphic is not part of this view");const s=await this._whenGraphics3DGraphic(r);return this._boundsForGraphics3DGraphic(s,t)}computeAttachmentOrigin(e,t){const i=this.graphics3DGraphics.get(e.uid);if(!i)return null;const r=i.computeAttachmentOrigin();if(0===r.render.num&&0===r.draped.num)return null;P(He,0,0,0);let s=0;if(r.render.num>0){if(!L(r.render.origin,this.symbolCreationContext.renderCoordsHelper.spatialReference,Ne,t))return null;D(He,He,Ne),s++}if(r.draped.num>0){const[e,i]=r.draped.origin,a=this._viewElevationProvider.getElevation(e,i,"ground")??0;if(P(Ne,e,i,a),!L(Ne,this._viewElevationProvider.spatialReference,Ne,t))return null;D(He,He,Ne),s++}return s>1&&E(He,He,1/s),new Ae({x:He[0],y:He[1],z:He[2],spatialReference:t})}getSymbolLayerSize(e,t){const i=this._symbols.get(e.id);if(null==i)throw new a("internal:symbol-not-part-of-view","Symbol is not part of this view");const r=e.symbolLayers.indexOf(t);if(-1===r)throw new a("internal:missing-symbol-layer","Symbol layer is not in symbol");const s=i.getSymbolLayerSize(r);if(null==s)throw new a("internal:missing-size","Symbol layer has no valid size");return s}_graphicsCollectionChanged(e){this._startCreateGraphics&&(this.add(e.added),this.remove(e.removed))}graphicUpdateHandler(e){const t=e.graphic.uid,i=this.graphics3DGraphics.get(t);if(null!=i||null!=this._graphicsWithoutSymbol.get(t))switch(e.property){case"visible":this._graphicUpdateVisibleHandler(i);break;case"geometry":this._graphicUpdateGeometryHandler(i,e);break;case"symbol":this._graphicUpdateSymbolHandler(i,e);break;case"attributes":break;case"origin-transform":this._graphicUpdateTransformHandler(i,e)}}_graphicUpdateGeometryHandler(e,t){this._graphicUpdateGeometryOrTransformHandler(e,t,(()=>!(null==t.newValue||null==e||!e.graphics3DSymbol.updateGeometry(e,t.newValue)||!(this._labeler?.updateGraphicGeometry(e)??1))&&(this._labeler?.setDirty(),!0)));const i=t.graphic.geometry;null!=i&&this._expandComputedExtent(i)}_graphicUpdateTransformHandler(e,t){const i=t.graphic.geometry;this._graphicUpdateGeometryOrTransformHandler(e,t,(()=>null!=t.newValue&&null!=e&&null!=i&&e.graphics3DSymbol.updateTransform(e,i.spatialReference,t.newValue,t.action)))}_graphicUpdateGeometryOrTransformHandler(e,t,i){if(null!=t.graphic.geometry)if(null!=e)i()||this._recreateGraphic(e.graphic);else{const e=t.graphic.symbol?.id;if(e){const t=this._symbols.get(e);if(null!=t&&t.loadStatus===me.LOADING)return}this._recreateGraphic(t.graphic)}else this._recreateGraphic(t.graphic)}_graphicUpdateSymbolHandler(e,t){const i=t.graphic,r=null!=e?e.graphics3DSymbol:null!=t.oldValue?this._symbols.get(t.oldValue.id):null;if(null==r||null==t.newValue)return void this._recreateGraphic(i);const s=r.symbol,a=this._getConvertedSymbol(t.newValue);if(null!=a&&(a.type!==s.type||"web-style"===a.type)||"web-style"===s.type)return void this._recreateGraphic(i);const n=this._graphicsBySymbol.get(s.id);if(n&&1!==n.size)return void this._recreateGraphic(i);const o=R(s,a);if(null==o)return void this._updateSymbolMapping(s.id,a);const l={diff:o,graphics3DGraphicPatches:[],symbolStatePatches:[]};if(r.prepareSymbolPatch(l),!x(l.diff))return void this._recreateGraphic(i);const h=this._getRenderingInfo(i);if(null==h)return void this._recreateGraphic(i);const d=r.extentPadding;for(const p of l.symbolStatePatches)p();if(d!==r.extentPadding&&this._recomputeExtentPadding(),null!=e)for(const p of l.graphics3DGraphicPatches)p(e,h);this._updateSymbolMapping(s.id,a)}_graphicUpdateVisibleHandler(e){this._updateUserVisibility(e)&&(this._labeler?.setDirty(),this._deconflictor?.setDirty())}recreateGraphics(e){this._suspendSymbolCleanup=!0,this.remove(e),this.add(e),this._suspendSymbolCleanup=!1,this.effectiveUpdatePolicy===Ge.SYNC&&this._cleanupSymbols()}_recreateGraphic(e){this.recreateGraphics([e])}_beginGraphicUpdate(e){const t=this._graphicsUpdateId;return this._graphicsUpdateId++,this._graphicsWaitingForSymbol.set(e.uid,t),1===this._graphicsWaitingForSymbol.size&&this.notifyChange("dataUpdating"),t}_endGraphicUpdate(e){e&&(this._graphicsWaitingForSymbol.delete(e.uid),0===this._graphicsWaitingForSymbol.size&&(this._cleanupSymbols(),this.notifyChange("dataUpdating")))}_recomputeExtentPadding(){let e=0;this._symbols.forEach((t=>{null!=t&&(e=Math.max(e,t.extentPadding))})),this._set("extentPadding",e)}_expandComputedExtent(e){const t=Me,i=e.spatialReference;H(e,t);const r=this._viewSpatialReference,s=Ve.tmpVec;if(k(i,r)||j(t[0],t[1],0,i,s,r)&&(t[0]=s[0],t[1]=s[1],j(t[3],t[4],0,i,s,r),t[3]=s[0],t[4]=s[1]),!(isFinite(t[0])&&isFinite(t[3])&&isFinite(t[1])&&isFinite(t[4])))return;const a=this.computedExtent;let n=null;const o=isFinite(t[2])&&isFinite(t[5]),l=o&&(null==a?.zmin||t[2]<a.zmin),h=o&&(null==a?.zmax||t[5]>a.zmax);if(a){(t[0]<a.xmin||t[1]<a.ymin||t[3]>a.xmax||t[4]>a.ymax||l||h)&&(n=this._propertiesPool.get("computedExtent"),n.xmin=Math.min(t[0],a.xmin),n.ymin=Math.min(t[1],a.ymin),n.xmax=Math.max(t[3],a.xmax),n.ymax=Math.max(t[4],a.ymax),n.spatialReference=r)}else n=this._propertiesPool.get("computedExtent"),n.xmin=t[0],n.ymin=t[1],n.xmax=t[3],n.ymax=t[4],n.spatialReference=r;n&&(l&&(n.zmin=t[2]),h&&(n.zmax=t[5]),this._set("computedExtent",n))}_abortElevationInfoChange(){this._elevationInfoChangeAbortController&&(this._elevationInfoChangeAbortController.abort(),this._elevationInfoChangeAbortController=null)}async elevationInfoChange(){this._abortElevationInfoChange();const e=new AbortController;this._elevationInfoChangeAbortController=e;const t=ae(this.layer.elevationInfo,this.elevationFeatureExpressionEnabled);this.symbolCreationContext.featureExpressionInfoContext=await ne(t,this._viewSpatialReference,e.signal,i.getLogger(this)),y(e.signal),this._elevationInfoChangeAbortController=null,this._labeler?.elevationInfoChange(),this.forEachGraphics3DSymbol(((e,t,i)=>{e.globalPropertyChanged("elevationInfo",t)?t.forEach((e=>{const t=e.graphic,i=e.labelLayers;for(const r of i){r.graphics3DSymbolLayer.updateGraphicElevationContext(t,r)}})):this._recreateSymbol(i)})),this.updateStageLayerElevationProvider(),this._elevationAlignment?.elevationInfoChange()}updateStageLayerElevationProvider(){this._stageLayerElevationProvider?(this.layer.elevationInfo&&"relative-to-scene"===this.layer.elevationInfo.mode||0===this._numberOfGraphicsProvidingElevation)&&(this.owner.view.elevationProvider.unregister(this._stageLayerElevationProvider),this._stageLayerElevationProvider=d(this._stageLayerElevationProvider)):(!this.layer.elevationInfo||this.layer.elevationInfo&&"relative-to-scene"!==this.layer.elevationInfo.mode)&&this._numberOfGraphicsProvidingElevation>0&&(this._stageLayerElevationProvider=new fe({layer:this.layer,stageLayer:this.stageLayer,view:this.owner.view}),this.owner.view.elevationProvider.register("scene",this._stageLayerElevationProvider))}_clearSymbolsAndGraphics(){this.clear(),null!=this._filterVisibility&&this._filterVisibility.clear(),this._labeler?.reset(),this._deconflictor?.clear(),this._elevationAlignment?.clear(),this.stageLayer?.invalidateSpatialQueryAccelerator(),this._stageLayerElevationProvider&&(this.owner.view.elevationProvider.unregister(this._stageLayerElevationProvider),this._stageLayerElevationProvider=d(this._stageLayerElevationProvider))}startCreateGraphics(){this._startCreateGraphics=!0,this.recreateAllGraphics()}recreateAllGraphics(){this._recreateAllGraphics(!1)}recreateAllGraphicsAndSymbols(){this._recreateAllGraphics(!0)}_recreateAllGraphics(e=!1){if(!this._startCreateGraphics)return;const{loadedGraphics:t,view:i}=this.owner,r=i.basemapTerrain.tilingScheme&&t?.length?t.toArray():null;!e&&r||this._clearSymbolsAndGraphics(),this.symbolCreationContext.screenSizePerspectiveEnabled=this.owner.view.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled,this.symbolCreationContext.slicePlaneEnabled=!!this.owner.slicePlaneEnabled,this._set("computedExtent",null),r&&(e?this.add(r):this.recreateGraphics(r))}_recreateSymbol(e){const t=this._graphicsBySymbol.get(e),i=[];t&&(t.forEach(((e,t)=>{const r=e.usedMemory;this._conditionalRemove(e,t),this._spatialIndex?.remove(e),i.push(e.graphic),e.destroy(),this._removeGraphics3DGraphic(t,r),this._updateLayerVisibility(),this._featureStore.events.emit("changed")})),this._graphicsBySymbol.set(e,new Map));const r=this._symbols.get(e);h(r),this._symbols.delete(e),this._symbolMaterials=null,this.add(i)}_recreateGraphicsForSymbol(e){const t=this._graphicsBySymbol.get(e);if(t){const e=[];t.forEach((t=>e.push(t.graphic))),this.recreateGraphics(e)}}_conditionalRemove(e,t){this._graphicsDrapedUids.delete(t),this._objectStates?.removeGraphic(e),this._labeler?.removeGraphic(e),this._deconflictor?.removeGraphic(e),null!=this._graphicStateTracking&&this._graphicStateTracking.removeGraphic(e)}add(e){e&&0!==e.length&&(this.owner.view.basemapTerrain?.tilingScheme?(this._updatePolicyForGraphics(e)===Ge.ASYNC?this._addDelayed(e):this._addImmediate(e),this.notifyChange("dataUpdating")):i.getLogger(this).error("#add()","Cannot add graphics before terrain surface has been initialized"))}_updatePolicyForGraphics(e){if(this.effectiveUpdatePolicy===Ge.SYNC&&("mesh"===this.layer.geometryType||null==this.layer.geometryType))for(const t of e)if(null!=t.geometry&&"mesh"===t.geometry.type&&!t.geometry.loaded)return Ge.ASYNC;return this.effectiveUpdatePolicy}_addImmediate(e){this._geometryWarningLogged=!1,this._symbolWarningLogged=!1;for(const t of e)this._addGraphic(t,this._getRenderingInfo(t,i.getLogger(this)),Ge.SYNC);this._cleanupSymbols(),this._labeler?.setDirty(),this._deconflictor?.setDirty()}_addDelayed(e){for(const t of e){const e=t.uid;let i=this._pendingUpdates.get(e);i?i.add?i.state!==ke.NEW&&i.abortController?.abort():this._pendingAdds++:(i=this._pendingUpdatesPool.pushNew(),this._pendingAdds++,this._pendingUpdates.set(e,i)),i.add=t}this.notifyChange("running"),this.notifyChange("updatingRemaining"),this.notifyChange("dataUpdating")}remove(e){this.effectiveUpdatePolicy===Ge.ASYNC?this._removeDelayed(e):this._removeImmediate(e),this.notifyChange("dataUpdating")}_removeImmediate(e){for(const t of e)this._removeGraphic(t);this._cleanupSymbols(),this._labeler?.setDirty(),this._deconflictor?.setDirty()}_removeDelayed(e){for(const t of e){const e=t.uid,i=this._pendingUpdates.get(e);if(i)i.add&&(i.remove?i.add=null:this._pendingUpdates.delete(e),i.state===ke.LOADING&&i.abortController?.abort(),this._pendingAdds--);else{const i=this._pendingUpdatesPool.pushNew();i.remove=t,this._pendingUpdates.set(e,i),this._pendingRemoves++,this._applyPendingRemovesFirst=!0}}0===this._pendingUpdates.size&&this._finishPendingUpdates(),this.notifyChange("running"),this.notifyChange("updatingRemaining"),this.notifyChange("dataUpdating")}_finishPendingUpdates(){this._pendingUpdatesPool.clear(),this._cleanupSymbols(),(this._pendingAdds||this._pendingRemoves)&&i.getLogger(this).warn("pendingAdds/Removes in inconsistent state!"),this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1}_applyPendingUpdates(e){if(this._geometryWarningLogged=!1,this._symbolWarningLogged=!1,0===this._pendingUpdates.size&&this._spatialIndex?.updating)return this._spatialIndex.update(),void e.madeProgress();if(this._applyPendingRemovesFirst){this._applyPendingRemovesFirst=!1;for(const[t,i]of this._pendingUpdates){if(e.done){this._applyPendingRemovesFirst=!0;break}if(i.remove&&!i.add&&(this._pendingRemoves--,e.madeProgress(),this._removeGraphic(i.remove),i.remove=null,this._pendingUpdates.delete(t),0===this._pendingRemoves))break}}for(const[t,i]of this._pendingUpdates){if(e.done)break;i.add&&i.state===ke.NEW&&this._processPendingUpdateNew(i);let r=this.effectiveUpdatePolicy;if(!i.remove||i.add&&i.state!==ke.READY||(this._pendingRemoves--,e.madeProgress(),this._removeGraphic(i.remove),i.remove=null,r=Ge.SYNC),i.add)switch(i.state){case ke.READY:this._addGraphic(i.add,i.renderingInfo,r),i.add=null,this._pendingAdds--,e.madeProgress();break;case ke.REJECTED:i.add=null,this._pendingAdds--;case ke.LOADING:}null==i.remove&&null==i.add&&this._pendingUpdates.delete(t)}0===this._pendingUpdates.size&&(this._finishPendingUpdates(),this.notifyChange("running"),this.notifyChange("dataUpdating"))}_processPendingUpdateNew(e){if(!e.add)return void(e.state=ke.READY);const t=e.add.geometry;null==t||"mesh"!==t.type||t.loaded?this._processPendingUpdateNewRenderingInfo(e):this._processPendingUpdateNewMesh(e,t)}async _processPendingUpdateNewMesh(e,t){e.state=ke.LOADING,e.abortController=new AbortController;const i=e.abortController.signal;try{await t.load({signal:i})}catch(r){return this._processPendingUpdateNewError(e,r)}e.abortController=null,this._processPendingUpdateNewRenderingInfo(e)}_processPendingUpdateNewError(e,t){e.abortController=null,u(t)?e.state=ke.NEW:e.state=ke.REJECTED}async _processPendingUpdateNewRenderingInfo(e){if(null==this.layer.renderer||"dictionary"!==this.layer.renderer.type)return e.renderingInfo=this._getRenderingInfo(e.add,i.getLogger(this)),void(e.state=ke.READY);e.state=ke.LOADING,e.abortController=new AbortController;let t=null;try{t=await this._getRenderingInfoAsync(e.add,{signal:e.abortController.signal})}catch(r){return e.abortController=null,void(u(r)?e.state=ke.NEW:e.state=ke.REJECTED)}null==t?.symbol?(this._symbolWarningLogged||(this._symbolWarningLogged=!0,i.getLogger(this).warn(`Graphic in layer ${this.layer.id} has no symbol and will not render`)),e.renderingInfo=null):e.renderingInfo=t,e.state=ke.READY}_addGraphic(e,t,i){if(this._graphicsWithoutSymbol.set(e.uid,e),null==t?.symbol||!N(e))return;if(null!=this.stage.renderView.objectAndLayerIdRenderHelper&&this.setUidToIdOnAdd){const t=Z(this.owner.view.map,this.layer.uid);this.stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(e.objectId,e.uid,this.layer.id,this.layer.uid,!!this.layer.popupEnabled&&!t&&xe(this.layer,this.owner.view.popup?.defaultPopupTemplateEnabled))}const r=t.symbol,s=this.getOrCreateGraphics3DSymbol(r,t.renderer);if(null==s)return;this._expandComputedExtent(e.geometry);const a=this._beginGraphicUpdate(e),n=new le(e,t,this.layer);let o=!1;const l=e=>{e===s.symbol.id&&(o=!0)};this._whenSymbolRemoved.push(l);const h=()=>{if(--this._loadingSymbols,this.destroyed)return;this._whenSymbolRemoved.removeUnordered(l);if(this._graphicsWaitingForSymbol.get(e.uid)!==a||o||s.destroyed||this.graphicSymbolSupported&&e.symbol&&e.symbol.id!==s.symbol.id)--s.referenced,this._cleanupSymbols();else{const t=this._createGraphics3DGraphic(s,n);this._spatialIndex&&null!=t&&this._spatialIndex.add(t),--s.referenced,this._endGraphicUpdate(e)}this._featureStore.events.emit("changed"),this._labeler?.setDirty()},d=t=>{--this._loadingSymbols,this.destroyed||(this._whenSymbolRemoved.removeUnordered(l),o||(u(t)?this.add([e]):s.destroyed||this._endGraphicUpdate(e)))};++this._loadingSymbols,i===Ge.ASYNC?s.load((()=>this._dataUpdateQueue.push(h,null).catch(m)),(e=>this._dataUpdateQueue.push((()=>d(e)),null).catch(m))):s.load(h,d)}_removeGraphic(e){const t=e.uid,i=this.graphics3DGraphics.get(t);if(i){i.graphics3DSymbol.onRemoveGraphic(i);const e=i.usedMemory,r=i.isElevationSource;this._conditionalRemove(i,t),this._spatialIndex?.remove(i);const s=i.graphics3DSymbol.symbol.id;this._graphicsBySymbol.get(s)?.delete(t),this._graphicsWithoutSymbol.delete(t),this._removeGraphics3DGraphic(t,e,r),i.destroy(),this._featureStore.events.emit("changed")}else this._graphicsWithoutSymbol.delete(t),this._graphicsWaitingForSymbol.delete(t),0===this._graphicsWaitingForSymbol.size&&(this._cleanupSymbols(),this.notifyChange("dataUpdating"))}_hasLabelingContext(e){if(e instanceof Le||e instanceof je){const t=this.symbolCreationContext.layer;return!!t.labelingInfo&&t.labelingInfo.some((t=>t.symbol===e))}return!1}_hasValidSymbolCreationContext(e){return!(e instanceof Le&&!this._hasLabelingContext(e))||(i.getLogger(this).error("LabelSymbol3D is only valid as part of a LabelClass. Using LabelSymbol3D as a renderer symbol is not supported."),!1)}_getRenderingInfo(e,t){const i=e.geometry;if(null==i)return t&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,t.warn(`Graphic in layer ${this.layer.id} has no geometry and will not render`)),null;if(!U(i.spatialReference,this._viewSpatialReference))return t&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,t.warn(`Graphic in layer ${this.layer.id} has incompatible spatial reference and will not render`)),null;if(!this.graphicSymbolSupported&&null!=e.symbol)return t&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,t.warn(`Graphic in layer ${this.layer.id} is not allowed to have a symbol, use a renderer instead`)),null;const r=this.rendererHasGeometryOperations?B(e,this.layer):e;let s;if(this.owner.getRenderingInfo&&(this.getRenderingInfoWithoutRenderer||null!=this.currentRenderer))s=this.owner.getRenderingInfo(r,this.currentRenderer,this._arcadeOnDemand);else{s={symbol:r.symbol||J(r.geometry)}}return null==s?.symbol?(t&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,t.warn(`Graphic in layer ${this.layer.id} has no symbol and will not render`)),null):s}_getRenderingInfoAsync(e,t){if(null==e.geometry)return this._geometryWarningLogged||(this._geometryWarningLogged=!0,i.getLogger(this).warn(`Graphic in layer ${this.layer.id} has no geometry and will not render`)),null;if(!this.graphicSymbolSupported&&null!=e.symbol)return this._symbolWarningLogged||(this._symbolWarningLogged=!0,i.getLogger(this).warn(`Graphic in layer ${this.layer.id} is not allowed to have a symbol, use a renderer instead`)),null;const r=this.rendererHasGeometryOperations?B(e,this.layer):e;return this.owner.getRenderingInfoAsync(r,this.currentRenderer,this._arcadeOnDemand,t)}_createGraphics3DSymbol(e,t){if(!this._hasValidSymbolCreationContext(e))return null;const i=this._getConvertedSymbol(e);if(!i)return null;let r;if(null!=t&&"backgroundFillSymbol"in t&&t.backgroundFillSymbol){const e=X(t.backgroundFillSymbol,{ignoreDrivers:!0});null!=e.symbol&&(r=e.symbol.symbolLayers)}const s=de(i,this.symbolCreationContext,r);return s.load((()=>{const e=s.extentPadding;e>this.extentPadding&&this._set("extentPadding",e),this.notifyChange("averageSymbolComplexity")}),(()=>{})),s}getOrCreateGraphics3DSymbol(e,t){let i=this._symbols.get(e.id);if(void 0===i){const r=this._unusedSymbolsCache.pop(e.id);i=null!=r?r:e instanceof Oe?new pe(e,(e=>this._dataUpdateQueue.push(e,null)),(e=>this._createGraphics3DSymbol(e,t))):this._createGraphics3DSymbol(e,t),this._symbols.set(e.id,i),this._symbolMaterials=null}return null!=i&&++i.referenced,i}trackGraphicState(e){return null==this._graphicStateTracking&&(this._graphicStateTracking=new ye(this)),this._graphicStateTracking.add(e)}_addGraphics3DGraphic(e){this._usedMemory+=e.usedMemory,this.graphics3DGraphics.set(e.graphic.uid,e),this._numberOfGraphics++,e.isElevationSource&&(this._numberOfGraphicsProvidingElevation++,this.updateStageLayerElevationProvider()),this._updateLayerVisibility()}_removeGraphics3DGraphic(e,t,i=!1){this._usedMemory-=t,this.graphics3DGraphics.delete(e),this._numberOfGraphics--,i&&(this._numberOfGraphicsProvidingElevation--,this.updateStageLayerElevationProvider()),this._updateLayerVisibility()}_createGraphics3DGraphic(e,t){const i=t.graphic;if(this._graphicsWithoutSymbol.delete(i.uid),!this._symbols.has(e.symbol.id))return this.add([i]),null;if(this.graphics3DGraphics.has(i.uid))return null;const r=e.createGraphics3DGraphic(t);if(null==r)return null;this._addGraphics3DGraphic(r);const s=e.symbol.id;this._graphicsBySymbol.has(s)||this._graphicsBySymbol.set(s,new Map),this._graphicsBySymbol.get(s).set(i.uid,r);if(r.isDraped&&this._graphicsDrapedUids.add(i.uid),r.centroid=null,null!=i.geometry&&"point"!==i.geometry.type&&(r.centroid=ge(i.geometry,this._viewSpatialReference)),this._updateUserVisibility(r),null!=this._scaleVisibility&&this._scaleVisibility.updateVisibility(r),null!=this._filterVisibility){const{defaultVisibility:e}=this._filterVisibility;r.setVisibilityFlag(re.GRAPHIC,se.FILTER,e),e||this._filterVisibility.reapply()}this._deconflictor?.addGraphic(r),this._labeler?.addGraphic(r),this._objectStates?.addGraphic(r),r.initialize(this.stageLayer,this.owner),null!=this._graphicStateTracking&&this._graphicStateTracking.addGraphic(r);const a=this._whenGraphics3DGraphicRequests[i.uid];return a&&(delete this._whenGraphics3DGraphicRequests[i.uid],a.resolve(r)),this._symbolMaterials=null,r}_abortRendererChange(){this._rendererChangeAbortController&&(this._rendererChangeAbortController.abort(),this._rendererChangeAbortController=null)}async rendererChange(e){if(this._abortRendererChange(),e!==this.currentRenderer)if(this._validateRenderer(e),null==e&&this._currentRendererChange(null,!1),Y(e))if(e?.arcadeRequired){const t=new AbortController;this._rendererChangeAbortController=t;const{arcadeUtils:i}=await this._ensureArcade();y(t);const r=i.hasGeometryOperations(e);r&&(await i.enableGeometryOperations(),y(t)),this.effectiveUpdatePolicy===Ge.ASYNC?await this._updateQueue.push((()=>this._currentRendererChange(e,r)),t.signal):this._currentRendererChange(e,r),this._rendererChangeAbortController=null}else if(this.effectiveUpdatePolicy===Ge.ASYNC){const t=new AbortController;this._rendererChangeAbortController=t,await this._updateQueue.push((()=>this._currentRendererChange(e,!1)),t.signal),this._rendererChangeAbortController=null}else this._currentRendererChange(e,!1);else this._currentRendererChange(e,!1)}async _ensureArcade(){return null==this._arcadeOnDemand?(this._arcadeOnDemand=await $(),this._arcadeOnDemand):this._arcadeOnDemand}_currentRendererChange(e,t){this.currentRenderer=e,this.rendererHasGeometryOperations=t,this.symbolCreationContext.arcade=this._arcadeOnDemand;const i=this.symbolCreationContext.renderer;if(e===i)return;if(this._symbolConversionCache.clear(),this._unusedSymbolsCache.clear(),null==e)return this.symbolCreationContext.renderer=null,void this.recreateAllGraphicsAndSymbols();const r=R(i,e);this._updateUnchangedSymbolMappings(r,e,i),this.symbolCreationContext.renderer=e,null!=r&&("complete"===r.type?this.recreateAllGraphicsAndSymbols():"partial"===r.type&&(this._applyRendererDiff(r,e,i)?this._labeler?.reset():this.recreateAllGraphicsAndSymbols()),this.notifyChange("averageSymbolComplexity"))}_diffHasSymbolChange(e){for(const t in e.diff)switch(t){case"visualVariables":case"defaultSymbol":case"uniqueValueInfos":break;case"uniqueValueGroups":case"authoringInfo":case"fieldDelimiter":delete e.diff[t];break;default:return!0}return!1}_applySymbolSetDiff(e,t,i){e=e||[],t=t||[];const r=[];for(const s of t){const t=this._graphicsBySymbol.get(s.id);t&&t.forEach(((a,n)=>{const o=a.graphic,l=this.layer instanceof z?this.layer:null,h=this._arcadeOnDemand;if(s===i.defaultSymbol&&i.getSymbol(B(o,l),{arcade:h})===i.defaultSymbol)return;const d=a.usedMemory;e.length||i.defaultSymbol?r.push(o):this._graphicsWithoutSymbol.set(n,o);const p=this.graphics3DGraphics.get(n);this._conditionalRemove(p,n),a.destroy(),t.delete(n),this._removeGraphics3DGraphic(n,d),this._updateLayerVisibility()})),this._whenSymbolRemoved.forAll((e=>e(s.id)))}(e.length||r.length)&&(this._graphicsWithoutSymbol.forEach((e=>r.push(e))),this._graphicsWithoutSymbol.clear(),this.add(r)),this._cleanupSymbols(),this._labeler?.setDirty(),this._deconflictor?.setDirty()}_applyUniqueValueRendererDiff(e,t,i){const r=e.diff.defaultSymbol,a=e.diff.uniqueValueInfos;if(r||a){const n=a?a.added.map((e=>e.symbol)).filter(s):[],o=a?a.removed.map((e=>e.symbol)).filter(s):[];if(a)for(let e=0;e<a.changed.length;e++)n.push(a.changed[e].newValue.symbol),o.push(a.changed[e].oldValue.symbol);return r?(i.defaultSymbol&&o.push(i.defaultSymbol),t.defaultSymbol&&n.push(t.defaultSymbol)):i.defaultSymbol&&n.length&&o.push(t.defaultSymbol),this._applySymbolSetDiff(n,o,t),delete e.diff.defaultSymbol,delete e.diff.uniqueValueInfos,!0}return!1}_calculateUnchangedSymbolMapping(e,t,i){if("unique-value"!==t?.type||"unique-value"!==i?.type||null!=e&&"partial"!==e.type)return[];const r=e=>null!=e?e.id:null,s=e&&e.diff,a=s?.defaultSymbol,n=s&&s.uniqueValueInfos;let o;if(n)o=n.unchanged.map((e=>({oldId:r(e.oldValue.symbol),newId:r(e.newValue.symbol)})));else{o=[];for(const e of i.uniqueValueInfos??[]){const i=r(e.symbol),s=t.uniqueValueInfos?.find((t=>t.value===e.value));s&&i!==r(s.symbol)&&o.push({oldId:i,newId:r(s.symbol)})}}return!a&&i.defaultSymbol&&o.push({oldId:r(i.defaultSymbol),newId:r(t.defaultSymbol)}),o}_updateSymbolMapping(e,t){const i=null!=t&&t?"string"==typeof t?t:t.id:null;if(null==e||e===i)return;const r=this._graphicsBySymbol.get(e);this._graphicsBySymbol.delete(e),void 0!==r&&this._graphicsBySymbol.set(i,r);const s=this._symbols.get(e);if(void 0!==s&&(this._symbols.delete(e),this._symbols.set(i,s),this._symbolMaterials=null,null!=s)){const e="string"==typeof t?null:t;null!=e?s.symbol=e:s.symbol.id=i}}_updateUnchangedSymbolMappings(e,t,i){const r=this._calculateUnchangedSymbolMapping(e,t,i);for(const{oldId:s,newId:a}of r)this._updateSymbolMapping(s,a)}_applyRendererDiff(e,i,r){if(this._diffHasSymbolChange(e))return!1;if(i instanceof t&&r instanceof t&&this._applyUniqueValueRendererDiff(e,i,r)&&0===Object.keys(e.diff).length)return!0;for(const t of this._graphicsBySymbol.keys()){const r=this._symbols.get(t);if(null!=r)switch(r.applyRendererDiff(e,i)){case ue.RecreateSymbol:this._recreateSymbol(t);break;case ue.RecreateGraphics:this._recreateGraphicsForSymbol(t);case ue.FastUpdate:}}return!0}opacityChange(){this.forEachGraphics3DSymbol(((e,t)=>e.globalPropertyChanged("opacity",t))),this._updateStageLayerVisibility()}_slicePlaneEnabledChange(e){e!==this.symbolCreationContext.slicePlaneEnabled&&(this.symbolCreationContext.slicePlaneEnabled=e,this.stageLayer.sliceable=e,this.forEachGraphics3DSymbol(((e,t)=>e.globalPropertyChanged("slicePlaneEnabled",t))),this._deconflictor?.slicePlaneEnabledChange(),this._labeler?.slicePlaneEnabledChange())}_physicalBasedRenderingChange(e){this.symbolCreationContext.physicalBasedRenderingEnabled=e,this.forEachGraphics3DSymbol(((e,t,i)=>{e.globalPropertyChanged("physicalBasedRenderingEnabled",t)||this._recreateSymbol(i)}))}_skipHighSymbolLoDsChange(e){this.symbolCreationContext.skipHighSymbolLods=e,this.forEachGraphics3DSymbol(((e,t,i)=>{e.globalPropertyChanged("skipHighSymbolLods",t)||this._recreateSymbol(i)}))}_pixelRatioChange(){this.forEachGraphics3DSymbol(((e,t,i)=>{e.globalPropertyChanged("pixelRatio",t)||this._recreateSymbol(i)}))}_signalUpdatingDuringAsyncLoadedGraphicsChange(){this._updatingPendingLoadedGraphicsChange&&this._updatingPendingLoadedGraphicsChange.remove(),this._updatingPendingLoadedGraphicsChange=S((()=>{this._updatingPendingLoadedGraphicsChange=null}))}setClippingExtent(e,t){const i=this.symbolCreationContext.clippingExtent,r=T();return ve(e,r,t)?this.symbolCreationContext.clippingExtent=F(O(),r):this.symbolCreationContext.clippingExtent=null,!M(this.symbolCreationContext.clippingExtent,i)}modifyGraphics3DGraphicVisibilities(e){if(this.destroyed)return;let t=!1;this.graphics3DGraphics.forEach((i=>{e(i)&&(t=!0)})),t&&(this._labeler?.setDirty(),this._deconflictor?.setDirty())}forEachGraphics3DSymbol(e){for(const[t,i]of this._symbols){if(null==i)return;e(i,this._graphicsBySymbol.get(t)||Be,t)}}updateAllGraphicsVisibility(){null!=this._filterVisibility&&this._filterVisibility.reapply(),this.modifyGraphics3DGraphicVisibilities((e=>{const t=this._updateUserVisibility(e),i=null!=this._scaleVisibility&&this._scaleVisibility.updateVisibility(e);return t||i}))}_hideAllGraphics(){this.modifyGraphics3DGraphicVisibilities((e=>e.setVisibilityFlag(re.GRAPHIC,se.USER,!1)))}_validateRenderer(e){const t=()=>`'${this.layer.title?`${this.layer.title}, `:""}id:${this.layer.id}'`,r=Q(e,{geometryType:this.layer?.geometryType,logWarning:e=>i.getLogger(this).warn(`Symbology conversion for layer ${t()}: ${e}`)});if(r){const e=`Renderer for layer ${t} is not supported in a SceneView`;i.getLogger(this).warn(e,r.message)}}_cleanupSymbols(){if(this._graphicsWaitingForSymbol.size>0||this._suspendSymbolCleanup)return;let e=!1;this._symbols.forEach(((t,i)=>{if(null==t||t.referenced>0)return;const r=this._graphicsBySymbol.get(i);r&&0!==r.size||(this._graphicsBySymbol.delete(i),this._symbols.delete(i),this._symbolMaterials=null,this._unusedSymbolsCache.put(i,t,_e(t),p),e=!0)})),e&&(this._recomputeExtentPadding(),this.notifyChange("averageSymbolComplexity"))}get test(){}get performanceInfo(){return new ce(this.graphics3DGraphics.size,this._graphicsWithoutSymbol.size,this._pendingUpdates.size)}};var ke;Te.tmpVec=I(),e([G({readOnly:!0})],Te.prototype,"computedExtent",void 0),e([G()],Te.prototype,"currentRenderer",void 0),e([G()],Te.prototype,"rendererHasGeometryOperations",void 0),e([G()],Te.prototype,"_frameTaskHandle",void 0),e([G()],Te.prototype,"_dataUpdateQueue",void 0),e([G()],Te.prototype,"_updateQueue",void 0),e([G({readOnly:!0})],Te.prototype,"_viewSpatialReference",null),e([G()],Te.prototype,"_rendererChangeAbortController",void 0),e([G()],Te.prototype,"_elevationInfoChangeAbortController",void 0),e([G()],Te.prototype,"_initializeAbortController",void 0),e([G()],Te.prototype,"_elevationAlignment",void 0),e([G()],Te.prototype,"_scaleVisibility",void 0),e([G()],Te.prototype,"_filterVisibility",void 0),e([G()],Te.prototype,"_initializePromise",void 0),e([G()],Te.prototype,"_spatialIndex",void 0),e([G({readOnly:!0})],Te.prototype,"extentPadding",void 0),e([G()],Te.prototype,"_updatingPendingLoadedGraphicsChange",void 0),e([G()],Te.prototype,"_featureStore",void 0),e([G()],Te.prototype,"_objectStates",void 0),e([G()],Te.prototype,"_loadingSymbols",void 0),e([G()],Te.prototype,"preferredUpdatePolicy",void 0),e([G()],Te.prototype,"_forcedUpdatePolicy",void 0),e([G({readOnly:!0})],Te.prototype,"effectiveUpdatePolicy",null),e([G({constructOnly:!0})],Te.prototype,"elevationFeatureExpressionEnabled",void 0),e([G({constructOnly:!0})],Te.prototype,"owner",void 0),e([G({constructOnly:!0})],Te.prototype,"layer",void 0),e([G({constructOnly:!0})],Te.prototype,"graphicSymbolSupported",void 0),e([G({constructOnly:!0})],Te.prototype,"getRenderingInfoWithoutRenderer",void 0),e([G({constructOnly:!0})],Te.prototype,"componentFactories",void 0),e([G({constructOnly:!0})],Te.prototype,"setUidToIdOnAdd",void 0),e([G()],Te.prototype,"featureStore",null),e([G()],Te.prototype,"initializePromise",null),e([G()],Te.prototype,"scaleVisibility",null),e([G()],Te.prototype,"elevationAlignment",null),e([G()],Te.prototype,"objectStates",null),e([G()],Te.prototype,"filterVisibility",null),e([G({readOnly:!0})],Te.prototype,"updating",null),e([G({readOnly:!0})],Te.prototype,"dataUpdating",null),e([G({readOnly:!0})],Te.prototype,"running",null),e([G({readOnly:!0})],Te.prototype,"suspendedOrOutsideOfView",null),e([G({readOnly:!0,dependsOn:[]})],Te.prototype,"updatingRemaining",null),e([G({readOnly:!0})],Te.prototype,"displayFeatureLimit",null),e([G({readOnly:!0,dependsOn:[]})],Te.prototype,"averageSymbolComplexity",null),e([G({constructOnly:!0})],Te.prototype,"hasZ",void 0),e([G({constructOnly:!0})],Te.prototype,"hasM",void 0),e([G()],Te.prototype,"_objectIdField",null),Te=Ve=e([w("esri.views.3d.layers.graphics.Graphics3DCore")],Te),function(e){e[e.NEW=0]="NEW",e[e.LOADING=1]="LOADING",e[e.READY=2]="READY",e[e.REJECTED=3]="REJECTED"}(ke||(ke={}));class ze{constructor(){this.add=null,this.renderingInfo=null,this.state=ke.NEW,this.abortController=null,this.remove=null}clear(){this.add=null,this.renderingInfo=null,this.state=ke.NEW,this.abortController=null,this.remove=null}}const We=10,He=I(),Ne=I(),Be=new Map;export{Te as Graphics3DCore};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{acosClamped as t}from"../../../../core/mathUtils.js";import e from"../../../../core/ObjectPool.js";import{n as s,z as i,m as r,r as n,s as o,F as u,b as c,g as a,j as l,H as d,k as _,f as h}from"../../../../chunks/vec32.js";import{create as f,fromValues as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as p}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as T}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBuffer as g}from"../../../../geometry/projection/projectBuffer.js";import{projectVec3Array as E}from"../../../../geometry/projection/projectVec3Array.js";import{PlaneIndex as R,PointIndex as F}from"../../../../geometry/support/frustum.js";import{create as I,signedDistance as O,projectVector as S,fromPoints as b,getNormal as A}from"../../../../geometry/support/plane.js";import{wrap as G}from"../../../../geometry/support/ray.js";import{ViewingMode as B}from"../../../ViewingMode.js";import{FeatureTileDescriptor3D as M,Visibility as P}from"./FeatureTileDescriptor3D.js";import{Frustum as j}from"../../state/Frustum.js";import{FrustumExtentIntersection as x}from"../../support/FrustumExtentIntersection.js";class N{constructor(t,e){this._renderCoordsHelper=t,this._getIsGroundOpaque=e,this._surfaceElevation=0,this._isGroundOpaque=!1,this._cache=new Map,this._frustumBoundingSphereCenter=f(),this._frustumBoundingSphereRadius=0,this._frustum=new j(t),this._extendedFrustum=new j(t),this._intersector=new x({renderCoordsHelper:t}),this._renderSR=t.spatialReference;const s=T(this._renderSR);this._renderSREllipsoidRadius=p(s).radius,this._renderCoordsHelper=t}begin(t,e){this._surfaceElevation=e,this._aboveGround=t.aboveGround,this._isGroundOpaque=this._getIsGroundOpaque(),this._frustum.update(t),k(this._frustum),this._updateExtendedFrustum(t),this._updateFrustumBoundingSphere()}end(){this._cache.clear()}calculate(t){const e=this._renderCoordsHelper.viewingMode===B.Global&&t.lij[0]>=V&&t.lij[0]<v,s=this._getOrCalculateSingleTileVisibility(t,!e);return s!==P.INVISIBLE&&e?this._calculateAggregatedChildrenVisibility(t):s}_calculateAggregatedChildrenVisibility(t){let e=P.INVISIBLE;const s=this._cache.get(t.id);if(null!=s)return s;const i=U.acquire();t.getChildren(i);for(const r of i){const t=this.calculate(r);if(t!==P.INVISIBLE&&(e=t,t===P.VISIBLE_ON_SURFACE))break}return U.release(i),this._cache.set(t.id,e),e}_getOrCalculateSingleTileVisibility(t,e){const s=this._cache.get(t.id);if(null!=s)return s;const i=this._calculateSingleTileVisibility(t);return e&&this._cache.set(t.id,i),i}_calculateSingleTileVisibility(t){if(!this._aboveGround&&this._renderCoordsHelper.viewingMode===B.Global&&t.lij[0]<H){return this._calculateSingleTileVisibilitySided(t,!1)===P.INVISIBLE?this._calculateSingleTileVisibilitySided(t,!0):void 0}return this._calculateSingleTileVisibilitySided(t,this._aboveGround)}_isTileVisibleInFrustum(t){return this._renderCoordsHelper.viewingMode===B.Local?this._isTileVisibleInFrustumLocal(t):this._isTileVisibleInFrustumGlobal(t)}_updateFrustumBoundingSphere(){const t=this._frustum,e=t.origin,o=at;s(o,t.direction);const u=t.points,c=lt;i(c,u[4],e);const a=.5*r(c,c)/r(o,c),l=this._frustumBoundingSphereCenter;n(l,e,o,a);const d=1+a;this._frustumBoundingSphereRadius=d}_isTileVisibleInFrustumLocal(t){const e=t.tilingScheme.spatialReference,s=t.extent,c=this._renderSR,a=$;if(a[0]=s[0],a[1]=s[1],a[2]=0,a[3]=s[2],a[4]=s[3],a[5]=0,!g(a,e,0,a,c,0,2))return!1;const l=tt;o(l[0],a[0],a[1],0),o(l[1],a[3],a[1],0),o(l[2],a[3],a[4],0),o(l[3],a[0],a[4],0);const d=et;o(d,.5*(a[0]+a[3]),.5*(a[1]+a[4]),.5*(a[2]+a[5]));const _=st;o(_,0,0,1);const h=.5*u(l[0],l[2]),f=this._frustum,m=this._frustumBoundingSphereRadius,p=this._frustumBoundingSphereCenter,T=_t;i(T,p,d);const E=r(_,T),R=dt;n(R,d,_,E);if(u(R,p)>h+m)return!1;const F=Z,I=this._isGroundOpaque&&this._aboveGround,O=this._isGroundOpaque&&!this._aboveGround,S=Math.min(O?yt:1/0,E+m),b=Math.max(I?-yt:-1/0,E-m);for(let i=0;i<4;++i)n(F[i],l[i],_,S),n(F[i+4],l[i],_,b);return!J(f.planes,F,8)}_isTileVisibleInFrustumGlobal(t){const e=t.tilingScheme.spatialReference,_=t.extent,h=this._isGroundOpaque&&this._aboveGround,p=this._isGroundOpaque&&!this._aboveGround;if(t.lij[0]<K)return!0;const T=tt,g=.5*(_[0]+_[2]);if(o(T[0],_[0],_[1],0),o(T[1],_[2],_[1],0),o(T[2],_[2],_[3],0),o(T[3],_[0],_[3],0),o(T[4],g,_[1],0),o(T[5],g,_[3],0),!E(T,e,0,T,this._renderSR,0,6))return!1;const R=T[0][2]>0,F=T[3][2]<0,I=R||F,S=this._renderSREllipsoidRadius;if(I){const t=m(0,0,1),e=rt;W(e,t,T[0]);const s=nt;if(W(s,t,T[1]),R){const i=it,r=T[4],n=ot;W(n,r,t),W(i,n,r);const o=T[0];c(o,e,i),D(o,S);const u=T[1];c(u,s,i),D(u,S)}else if(F){const i=it,r=T[5],n=ot;W(n,r,t),W(i,r,n);const o=T[3];c(o,i,e),D(o,S);const u=T[2];c(u,i,s),D(u,S)}}const b=et;{const t=i(Tt,T[3],T[0]);s(t,t);const e=a(gt,T[0],T[3]);l(e,e,.5);const o=-r(e,t),u=a(Et,T[0],T[1]);l(u,u,.5);const c=a(Rt,T[2],T[3]);l(c,c,.5);const d=i(Ft,c,u);s(d,d);const _=-(o+r(t,u))/r(t,d);n(b,u,d,_),D(b,S)}const A=this._frustumBoundingSphereRadius,G=this._frustumBoundingSphereCenter,B=this._frustum,M=B.planes,P=ut;s(P,b);const j=r(T[0],P)/d(T[0]),x=B.origin,N=B.points;let V=!1;if(h){{V=!0;const t=s(f(),x);for(let e=0;e<4;++e){const n=N[4+e],o=i(f(),n,x);s(o,o);const u=c(f(),t,o);s(u,u);const a=c(f(),o,u);s(a,a);if(r(x,a)>S){V=!1;break}}}if(V){if(r(x,P)<S*j-yt)return!1}const t=s(Ct,B.origin);if(r(t,P)<0)return!1;{const t=s(wt,B.direction);if(r(t,P)>qt)return!1}}const v=Math.sqrt(1-j*j);if(v>.9)return!0;let H=!1;{const t=r(P,G),e=d(G);if(e<=A&&!M.some((t=>O(t,ht)>0))){if(!h)return!0;H=!0}const s=t/e;if(!H&&t<=0){if(-t>A)return!1}const i=A/e;if(Math.sqrt(1-s*s)*Math.sqrt(1-i*i)-i*s>v)return!1}if(!V){if(T.some((t=>B.intersectsPoint(t))))return!0;if(B.intersectsPoint(b))return!0}const L=ft;i(L,G,ht);const y=r(L,P),C=ct;l(C,P,y);const w=u(C,G),q=e.isWGS84,U=t.lij,k=q&&U[2]===2**U[0]-1,X=q&&0===U[2],Y=X?jt:k?Mt:Gt,Z=X?xt:k?Pt:Bt;if(!H){const t=T,e=Nt,s=It,i=Ot,r=ht;for(const n of Y){const o=t[n];if(z(s,t[(n+1)%4],o),z(i,r,o),W(e,i,s),Q(e,N,1))return!1}}let $=null;if(!h&&y<1.01*A){const t=2.5*A;if(w>j*t+A)return!1;const e=pt,s=t/j;for(let i=0;i<4;++i)l(e[i],T[i],s/S);o(e[4],0,0,0),$=e}else{const t=(p?S+yt:y+A)/j,e=h?S-yt:(y-A)/j,s=mt;for(let i=0;i<4;++i){const r=T[i];l(s[i],r,e/S),l(s[i+4],r,t/S)}$=s}if(J(M,$,$.length))return!1;const st=B.lines,at=St,lt=bt;for(const r of st){s(lt,r.direction);for(const t of Z){const e=$[t];if(s(at,e),Lt(lt,at,$,N))return!1;const r=(t+1)%4;if(h){const t=$[r];if(i(at,t,e),s(at,at),Lt(lt,at,$,N))return!1}if(p){const e=$[4+t],n=$[4+r];if(i(at,n,e),s(at,at),Lt(lt,at,$,N))return!1}}}return!0}_calculateSingleTileVisibilitySided(t,e){return this._isTileVisibleInFrustum(t)?(this._intersector.update(t.extent,t.tilingScheme.spatialReference,this._surfaceElevation,e),this._intersector.isVisibleInFrustum(this._frustum,this._renderSREllipsoidRadius,!0)?P.VISIBLE_ON_SURFACE:P.VISIBLE_WHEN_EXTENDED):P.INVISIBLE}_updateExtendedFrustum(e){this._extendedFrustum.update(e),k(this._extendedFrustum);const s=this._renderCoordsHelper.worldUpAtPosition(e.eye,C);this._aboveGround||_(s,s);const i=t(-r(s,e.viewForward));if(this._hasExtendedFrustum=i>e.fovY/2,!this._hasExtendedFrustum)return;const n=this._extendedFrustumParameters(),o=this._extendedFrustum.mutablePoints;for(let t=0;t<4;t++){const e=n.pointIndices[t],s=o[e],i=this._renderCoordsHelper.getAltitude(s);if(n.needsAltitudeAdjustment(i)){switch(this._renderCoordsHelper.worldUpAtPosition(s,C),e){case F.FAR_BOTTOM_LEFT:case F.FAR_TOP_LEFT:case F.NEAR_BOTTOM_LEFT:case F.NEAR_TOP_LEFT:S(this._extendedFrustum.planes[R.LEFT],C,C);break;case F.FAR_BOTTOM_RIGHT:case F.FAR_TOP_RIGHT:case F.NEAR_BOTTOM_RIGHT:case F.NEAR_TOP_RIGHT:S(this._extendedFrustum.planes[R.RIGHT],C,C)}l(C,C,n.direction),this._renderCoordsHelper.intersectInfiniteManifold(G(s,C),n.zWithMargin,s)}}if(this._extendedFrustum.updatePoints(o),b(o[F.NEAR_BOTTOM_LEFT],o[F.NEAR_BOTTOM_RIGHT],o[F.NEAR_TOP_RIGHT],w),b(o[F.NEAR_BOTTOM_RIGHT],o[F.NEAR_TOP_RIGHT],o[F.NEAR_TOP_LEFT],q),r(A(w),A(q))<0){const t=this._extendedFrustum.mutablePoints;this._aboveGround?[t[F.NEAR_BOTTOM_LEFT],t[F.NEAR_BOTTOM_RIGHT]]=[t[F.NEAR_BOTTOM_RIGHT],t[F.NEAR_BOTTOM_LEFT]]:[t[F.NEAR_TOP_LEFT],t[F.NEAR_TOP_RIGHT]]=[t[F.NEAR_TOP_RIGHT],t[F.NEAR_TOP_LEFT]],this._extendedFrustum.updatePoints(t)}}_extendedFrustumParameters(){return this._aboveGround?this._extendedFrustumParametersAboveSurface():this._extendedFrustumParametersBelowSurface()}_extendedFrustumParametersAboveSurface(){const t=this._surfaceElevation-y;return{zWithMargin:t,pointIndices:j.planePointIndices.bottom,direction:-1,needsAltitudeAdjustment:e=>e>t}}_extendedFrustumParametersBelowSurface(){const t=this._surfaceElevation+y;return{zWithMargin:t,pointIndices:j.planePointIndices.top,direction:1,needsAltitudeAdjustment:e=>e<t}}}const V=2,v=6,H=12,L=.95,y=1,C=f(),w=I(),q=I(),U=new e(Array,(t=>{4!==t.length&&(t[0]=new M,t[1]=new M,t[2]=new M,t[3]=new M)}),(t=>{t[0].release(),t[1].release(),t[2].release(),t[3].release()}));function k(t){const e=j.nearFarLineIndices,s=t.mutablePoints;for(const i of e){const[t,e]=i,r=s[t],n=s[e];h(C,n,r),l(C,C,L),a(s[e],r,C)}t.updatePoints(s)}function W(t,e,i){return c(t,e,i),s(t,t),t}function z(t,e,r){return i(t,e,r),s(t,t),t}function D(t,e){return l(t,t,e/d(t)),t}const X=[R.LEFT,R.RIGHT,R.BOTTOM,R.TOP,R.FAR];function Y(t,e,s){for(let i=0;i<s;++i)if(O(t,e[i])<=0)return!1;return!0}function J(t,e,s){for(const i of X)if(Y(t[i],e,s))return!0;return!1}const K=3;function Q(t,e,s){for(const i of e)if(r(i,t)<s)return!1;return!0}const Z=[f(),f(),f(),f(),f(),f(),f(),f()],$=[0,0,0,0,0,0],tt=[f(),f(),f(),f(),f(),f()],et=f(),st=f(),it=f(),rt=f(),nt=f(),ot=f(),ut=f(),ct=f(),at=f(),lt=f(),dt=f(),_t=f(),ht=m(0,0,0),ft=f(),mt=[f(),f(),f(),f(),f(),f(),f(),f()],pt=[f(),f(),f(),f(),f()],Tt=f(),gt=f(),Et=f(),Rt=f(),Ft=f(),It=f(),Ot=f(),St=f(),bt=f(),At=f(),Gt=[0,1,2,3],Bt=[0,1,2,3],Mt=[0,1,3],Pt=[0,1,3],jt=[1,2,3],xt=[1,2,3],Nt=f();function Vt(t,e,s){let i=1/0,n=-1/0;for(const o of s){const t=r(e,o);i=Math.min(i,t),n=Math.max(n,t)}t[0]=i,t[1]=n}function vt(t,e,s,i){let n=1/0,o=-1/0;for(const u of i){const i=r(s,u);if(n=Math.min(n,i),o=Math.max(o,i),n<=e&&o>=t)return!1}return!0}const Ht=[0,0];function Lt(t,e,s,i){if(0===s.length||0===i.length)return!0;const r=At;W(r,t,e);const n=i[0]<s[0],o=n?s:i,u=Ht;return Vt(u,r,n?i:s),vt(u[0],u[1],r,o)}const yt=430,Ct=f(),wt=f(),qt=Math.cos(.25*Math.PI);export{N as FeatureTileVisibility3D,K as globalTileLevelThreshold,J as isConvexHullOutsideOfFrustum};
5
+ import{acosClamped as t}from"../../../../core/mathUtils.js";import e from"../../../../core/ObjectPool.js";import{n as s,z as i,m as r,r as n,s as o,F as u,b as c,g as a,j as l,H as d,k as _,f as h}from"../../../../chunks/vec32.js";import{create as f,fromValues as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as p}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as T}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBuffer as g}from"../../../../geometry/projection/projectBuffer.js";import{projectVec3Array as E}from"../../../../geometry/projection/projectVec3Array.js";import{PlaneIndex as R,PointIndex as F}from"../../../../geometry/support/frustum.js";import{create as I,signedDistance as O,projectVector as S,fromPoints as b,getNormal as A}from"../../../../geometry/support/plane.js";import{wrap as G}from"../../../../geometry/support/ray.js";import{ViewingMode as B}from"../../../ViewingMode.js";import{FeatureTileDescriptor3D as M,Visibility as P}from"./FeatureTileDescriptor3D.js";import{Frustum as j}from"../../state/Frustum.js";import{FrustumExtentIntersection as x}from"../../support/FrustumExtentIntersection.js";class N{constructor(t,e){this._renderCoordsHelper=t,this._getIsGroundOpaque=e,this._surfaceElevation=0,this._isGroundOpaque=!1,this._cache=new Map,this._frustumBoundingSphereCenter=f(),this._frustumBoundingSphereRadius=0,this._frustum=new j(t),this._extendedFrustum=new j(t),this._intersector=new x({renderCoordsHelper:t}),this._renderSR=t.spatialReference;const s=T(this._renderSR);this._renderSREllipsoidRadius=p(s).radius,this._renderCoordsHelper=t}begin(t,e){this._surfaceElevation=e,this._aboveGround=t.aboveGround,this._isGroundOpaque=this._getIsGroundOpaque(),this._frustum.update(t),k(this._frustum),this._updateExtendedFrustum(t),this._updateFrustumBoundingSphere()}end(){this._cache.clear()}calculate(t){const e=this._renderCoordsHelper.viewingMode===B.Global&&t.lij[0]>=V&&t.lij[0]<v,s=this._getOrCalculateSingleTileVisibility(t,!e);return s!==P.INVISIBLE&&e?this._calculateAggregatedChildrenVisibility(t):s}_calculateAggregatedChildrenVisibility(t){let e=P.INVISIBLE;const s=this._cache.get(t.id);if(null!=s)return s;const i=U.acquire();t.getChildren(i);for(const r of i){const t=this.calculate(r);if(t!==P.INVISIBLE&&(e=t,t===P.VISIBLE_ON_SURFACE))break}return U.release(i),this._cache.set(t.id,e),e}_getOrCalculateSingleTileVisibility(t,e){const s=this._cache.get(t.id);if(null!=s)return s;const i=this._calculateSingleTileVisibility(t);return e&&this._cache.set(t.id,i),i}_calculateSingleTileVisibility(t){if(!this._aboveGround&&this._renderCoordsHelper.viewingMode===B.Global&&t.lij[0]<H){return this._calculateSingleTileVisibilitySided(t,!1)===P.INVISIBLE?this._calculateSingleTileVisibilitySided(t,!0):void 0}return this._calculateSingleTileVisibilitySided(t,this._aboveGround)}_isTileVisibleInFrustum(t){return this._renderCoordsHelper.viewingMode===B.Local?this._isTileVisibleInFrustumLocal(t):this._isTileVisibleInFrustumGlobal(t)}_updateFrustumBoundingSphere(){const t=this._frustum,e=t.origin,o=at;s(o,t.direction);const u=t.points,c=lt;i(c,u[4],e);const a=.5*r(c,c)/r(o,c),l=this._frustumBoundingSphereCenter;n(l,e,o,a);const d=1+a;this._frustumBoundingSphereRadius=d}_isTileVisibleInFrustumLocal(t){const e=t.tilingScheme.spatialReference,s=t.extent,c=this._renderSR,a=$;if(a[0]=s[0],a[1]=s[1],a[2]=0,a[3]=s[2],a[4]=s[3],a[5]=0,!g(a,e,0,a,c,0,2))return!1;const l=tt;o(l[0],a[0],a[1],0),o(l[1],a[3],a[1],0),o(l[2],a[3],a[4],0),o(l[3],a[0],a[4],0);const d=et;o(d,.5*(a[0]+a[3]),.5*(a[1]+a[4]),.5*(a[2]+a[5]));const _=st;o(_,0,0,1);const h=.5*u(l[0],l[2]),f=this._frustum,m=this._frustumBoundingSphereRadius,p=this._frustumBoundingSphereCenter,T=_t;i(T,p,d);const E=r(_,T),R=dt;n(R,d,_,E);if(u(R,p)>h+m)return!1;const F=Z,I=this._isGroundOpaque&&this._aboveGround,O=this._isGroundOpaque&&!this._aboveGround,S=Math.min(O?yt:1/0,E+m),b=Math.max(I?-yt:-1/0,E-m);for(let i=0;i<4;++i)n(F[i],l[i],_,S),n(F[i+4],l[i],_,b);return!J(f.planes,F,8)}_isTileVisibleInFrustumGlobal(t){const e=t.tilingScheme.spatialReference,_=t.extent,h=this._isGroundOpaque&&this._aboveGround,p=this._isGroundOpaque&&!this._aboveGround;if(t.lij[0]<K)return!0;const T=tt,g=.5*(_[0]+_[2]);if(o(T[0],_[0],_[1],0),o(T[1],_[2],_[1],0),o(T[2],_[2],_[3],0),o(T[3],_[0],_[3],0),o(T[4],g,_[1],0),o(T[5],g,_[3],0),!E(T,e,0,T,this._renderSR,0,6))return!1;const R=T[0][2]>0,F=T[3][2]<0,I=R||F,S=this._renderSREllipsoidRadius;if(I){const t=m(0,0,1),e=rt;W(e,t,T[0]);const s=nt;if(W(s,t,T[1]),R){const i=it,r=T[4],n=ot;W(n,r,t),W(i,n,r);const o=T[0];c(o,e,i),D(o,S);const u=T[1];c(u,s,i),D(u,S)}else if(F){const i=it,r=T[5],n=ot;W(n,r,t),W(i,r,n);const o=T[3];c(o,i,e),D(o,S);const u=T[2];c(u,i,s),D(u,S)}}const b=et;{const t=i(Tt,T[3],T[0]);s(t,t);const e=a(gt,T[0],T[3]);l(e,e,.5);const o=-r(e,t),u=a(Et,T[0],T[1]);l(u,u,.5);const c=a(Rt,T[2],T[3]);l(c,c,.5);const d=i(Ft,c,u);s(d,d);const _=-(o+r(t,u))/r(t,d);n(b,u,d,_),D(b,S)}const A=this._frustumBoundingSphereRadius,G=this._frustumBoundingSphereCenter,B=this._frustum,M=B.planes,P=ut;s(P,b);const j=r(T[0],P)/d(T[0]),x=B.origin,N=B.points;let V=!1;if(h){{V=!0;const t=s(f(),x);for(let e=0;e<4;++e){const n=N[4+e],o=i(f(),n,x);s(o,o);const u=c(f(),t,o);s(u,u);const a=c(f(),o,u);s(a,a);if(r(x,a)>S){V=!1;break}}}if(V){if(r(x,P)<S*j-yt)return!1}const t=s(Ct,B.origin);if(r(t,P)<0)return!1;{const t=s(wt,B.direction);if(r(t,P)>qt)return!1}}const v=Math.sqrt(1-j*j);if(v>.9)return!0;let H=!1;{const t=r(P,G),e=d(G);if(e<=A&&!M.some((t=>O(t,ht)>0))){if(!h)return!0;H=!0}const s=t/e;if(!H&&t<=0){if(-t>A)return!1}const i=A/e;if(Math.sqrt(1-s*s)*Math.sqrt(1-i*i)-i*s>v)return!1}if(!V){if(T.some((t=>B.intersectsPoint(t))))return!0;if(B.intersectsPoint(b))return!0}const L=ft;i(L,G,ht);const y=r(L,P),C=ct;l(C,P,y);const w=u(C,G),q=e.isWGS84,U=t.lij,k=q&&U[2]===2**U[0]-1,X=q&&0===U[2],Y=X?jt:k?Mt:Gt,Z=X?xt:k?Pt:Bt;if(!H){const t=T,e=Nt,s=It,i=Ot,r=ht;for(const n of Y){const o=t[n];if(z(s,t[(n+1)%4],o),z(i,r,o),W(e,i,s),Q(e,N,1))return!1}}let $=null;if(!h&&y<1.01*A){const t=2.5*A;if(w>j*t+A)return!1;const e=pt,s=t/j;for(let i=0;i<4;++i)l(e[i],T[i],s/S);o(e[4],0,0,0),$=e}else{const t=(p?S+yt:y+A)/j,e=h?S-yt:(y-A)/j,s=mt;for(let i=0;i<4;++i){const r=T[i];l(s[i],r,e/S),l(s[i+4],r,t/S)}$=s}if(J(M,$,$.length))return!1;const st=B.lines,at=St,lt=bt;for(const r of st){s(lt,r.direction);for(const t of Z){const e=$[t];if(s(at,e),Lt(lt,at,$,N))return!1;const r=(t+1)%4;if(h){const t=$[r];if(i(at,t,e),s(at,at),Lt(lt,at,$,N))return!1}if(p){const e=$[4+t],n=$[4+r];if(i(at,n,e),s(at,at),Lt(lt,at,$,N))return!1}}}return!0}_calculateSingleTileVisibilitySided(t,e){return this._isTileVisibleInFrustum(t)?(this._intersector.update(t.extent,t.tilingScheme.spatialReference,this._surfaceElevation,e),this._intersector.isVisibleInFrustum(this._frustum,this._renderSREllipsoidRadius,!0)?P.VISIBLE_ON_SURFACE:P.VISIBLE_WHEN_EXTENDED):P.INVISIBLE}_updateExtendedFrustum(e){this._extendedFrustum.update(e),k(this._extendedFrustum);const s=this._renderCoordsHelper.worldUpAtPosition(e.eye,C);this._aboveGround||_(s,s);const i=t(-r(s,e.viewForward));if(this._hasExtendedFrustum=i>e.fovY/2,!this._hasExtendedFrustum)return;const n=this._extendedFrustumParameters(),o=this._extendedFrustum.mutablePoints;for(let t=0;t<4;t++){const e=n.pointIndices[t],s=o[e],i=this._renderCoordsHelper.getAltitude(s);if(n.needsAltitudeAdjustment(i)){switch(this._renderCoordsHelper.worldUpAtPosition(s,C),e){case F.FAR_BOTTOM_LEFT:case F.FAR_TOP_LEFT:case F.NEAR_BOTTOM_LEFT:case F.NEAR_TOP_LEFT:S(this._extendedFrustum.planes[R.LEFT],C,C);break;case F.FAR_BOTTOM_RIGHT:case F.FAR_TOP_RIGHT:case F.NEAR_BOTTOM_RIGHT:case F.NEAR_TOP_RIGHT:S(this._extendedFrustum.planes[R.RIGHT],C,C)}l(C,C,n.direction),this._renderCoordsHelper.intersectInfiniteManifold(G(s,C),n.zWithMargin,s)}}if(this._extendedFrustum.updatePoints(o),b(o[F.NEAR_BOTTOM_LEFT],o[F.NEAR_BOTTOM_RIGHT],o[F.NEAR_TOP_RIGHT],w),b(o[F.NEAR_BOTTOM_RIGHT],o[F.NEAR_TOP_RIGHT],o[F.NEAR_TOP_LEFT],q),r(A(w),A(q))<0){const t=this._extendedFrustum.mutablePoints;this._aboveGround?[t[F.NEAR_BOTTOM_LEFT],t[F.NEAR_BOTTOM_RIGHT]]=[t[F.NEAR_BOTTOM_RIGHT],t[F.NEAR_BOTTOM_LEFT]]:[t[F.NEAR_TOP_LEFT],t[F.NEAR_TOP_RIGHT]]=[t[F.NEAR_TOP_RIGHT],t[F.NEAR_TOP_LEFT]],this._extendedFrustum.updatePoints(t)}}_extendedFrustumParameters(){return this._aboveGround?this._extendedFrustumParametersAboveSurface():this._extendedFrustumParametersBelowSurface()}_extendedFrustumParametersAboveSurface(){const t=this._surfaceElevation-y;return{zWithMargin:t,pointIndices:j.planePointIndices.bottom,direction:-1,needsAltitudeAdjustment:e=>e>t}}_extendedFrustumParametersBelowSurface(){const t=this._surfaceElevation+y;return{zWithMargin:t,pointIndices:j.planePointIndices.top,direction:1,needsAltitudeAdjustment:e=>e<t}}}const V=2,v=6,H=12,L=.95,y=1,C=f(),w=I(),q=I(),U=new e(Array,(t=>{4!==t.length&&(t[0]=new M,t[1]=new M,t[2]=new M,t[3]=new M)}),(t=>{t[0].release(),t[1].release(),t[2].release(),t[3].release()}));function k(t){const e=j.nearFarLineIndices,s=t.mutablePoints;for(const i of e){const[t,e]=i,r=s[t],n=s[e];h(C,n,r),l(C,C,L),a(s[e],r,C)}t.updatePoints(s)}function W(t,e,i){return c(t,e,i),s(t,t),t}function z(t,e,r){return i(t,e,r),s(t,t),t}function D(t,e){return l(t,t,e/d(t)),t}const X=[R.LEFT,R.RIGHT,R.BOTTOM,R.TOP,R.FAR];function Y(t,e,s){for(let i=0;i<s;++i)if(O(t,e[i])<=0)return!1;return!0}function J(t,e,s){for(const i of X)if(Y(t[i],e,s))return!0;return!1}const K=4;function Q(t,e,s){for(const i of e)if(r(i,t)<s)return!1;return!0}const Z=[f(),f(),f(),f(),f(),f(),f(),f()],$=[0,0,0,0,0,0],tt=[f(),f(),f(),f(),f(),f()],et=f(),st=f(),it=f(),rt=f(),nt=f(),ot=f(),ut=f(),ct=f(),at=f(),lt=f(),dt=f(),_t=f(),ht=m(0,0,0),ft=f(),mt=[f(),f(),f(),f(),f(),f(),f(),f()],pt=[f(),f(),f(),f(),f()],Tt=f(),gt=f(),Et=f(),Rt=f(),Ft=f(),It=f(),Ot=f(),St=f(),bt=f(),At=f(),Gt=[0,1,2,3],Bt=[0,1,2,3],Mt=[0,1,3],Pt=[0,1,3],jt=[1,2,3],xt=[1,2,3],Nt=f();function Vt(t,e,s){let i=1/0,n=-1/0;for(const o of s){const t=r(e,o);i=Math.min(i,t),n=Math.max(n,t)}t[0]=i,t[1]=n}function vt(t,e,s,i){let n=1/0,o=-1/0;for(const u of i){const i=r(s,u);if(n=Math.min(n,i),o=Math.max(o,i),n<=e&&o>=t)return!1}return!0}const Ht=[0,0];function Lt(t,e,s,i){if(0===s.length||0===i.length)return!0;const r=At;W(r,t,e);const n=i[0]<s[0],o=n?s:i,u=Ht;return Vt(u,r,n?i:s),vt(u[0],u[1],r,o)}const yt=430,Ct=f(),wt=f(),qt=Math.cos(.25*Math.PI);export{N as FeatureTileVisibility3D,K as globalTileLevelThreshold,J as isConvexHullOutsideOfFrustum};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{lerp as e,clamp as t}from"../../../core/mathUtils.js";import{getMetersPerUnitForSR as i}from"../../../core/unitUtils.js";import{f as r,n as s,m as n,l as a}from"../../../chunks/vec32.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as o}from"../../../geometry/ellipsoidUtils.js";import h from"../../../geometry/Extent.js";import{ViewingMode as l}from"../../ViewingMode.js";import{computeInnerAltitudeFade as x}from"../environment/atmosphereUtils.js";function c(e,t,i){return e===l.Global?new M(i):new u(t,i)}class u{constructor(e,t){this._elevationProvider=e,this._referenceEllipsoid=o(t),this._unitInMeters=i(t,this._referenceEllipsoid.metersPerDegree)}compute(i,a,m,o,l){l||(l={near:0,far:0});let x=i[2]*this._unitInMeters;const c=x,u=x-o,M=this._elevationProvider?.visibleElevationBounds;M&&(x=u>=0?c-this._unitInMeters*M.min:this._unitInMeters*M.max-c);const _={x:(m=null!=m?m:new h({xmin:0,ymin:0,zmin:0,xmax:0,ymax:0,zmax:0})).xmax-m.xmin,y:m.ymax-m.ymin,z:4*Math.max(m.xmax-m.xmin,m.ymax-m.ymin)},I=Math.max(_.x,_.y,_.z);r(E,a,i),v[0]=E[0]>0?m.xmax:m.xmin,v[1]=E[1]>0?m.ymax:m.ymin,v[2]=E[2]>0?I/2:-I/2,r(v,v,i),s(E,E);const j=1.1*n(v,E)*this._unitInMeters,g=Math.sqrt(x*(x+2*this._referenceEllipsoid.radius)),b=Math.max(m.xmax-m.xmin,m.ymax-m.ymin),w=b*d*this._unitInMeters,z=b*y*this._unitInMeters,U=t((x-z)/(w-z),0,1)**3,P=Math.min(e(g,j,U),g)*Math.max(Math.log(Math.abs(u)),1);return f(Math.min(P,Math.max(34064e4,I))/this._unitInMeters,p,this._unitInMeters,l)}}class M{constructor(e){this._referenceEllipsoid=o(e)}compute(i,r,s,n,m){m||(m={near:0,far:0});const o=a(i),h=o-this._referenceEllipsoid.radius,l=this._referenceEllipsoid.radius+Math.min(0,n),c=Math.abs(h-n),u=Math.max(c,Math.abs(h)),M=Math.sqrt(u*(u+2*l)),p=o+this._referenceEllipsoid.radius;return f(1.2*e(M,p,x(u)),t(2e4-(Math.log(u)-7.983)/9.011*19e3,1e3,2e4),1,m)}}function f(e,t,i,r){const s=_/i;return e/t>s?(r.far=e,r.near=r.far/t):(r.near=s,r.far=r.near*t),r}const p=2e4,_=2,d=.001,y=1e-4,v=m(),E=m();export{c as createNearFarHeuristic};
5
+ import{lerp as t,clamp as e}from"../../../core/mathUtils.js";import{getMetersPerUnitForSR as i}from"../../../core/unitUtils.js";import{f as r,n as s,m as n,l as a}from"../../../chunks/vec32.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as o}from"../../../geometry/ellipsoidUtils.js";import h from"../../../geometry/Extent.js";import{ViewingMode as l}from"../../ViewingMode.js";import{computeInnerAltitudeFade as x}from"../environment/atmosphereUtils.js";function c(t,e,i){return t===l.Global?new M(i):new u(e,i)}class u{constructor(t,e){this._elevationProvider=t,this._referenceEllipsoid=o(e),this._unitInMeters=i(e,this._referenceEllipsoid.metersPerDegree)}compute(i,a,m,o,l){l||(l={near:0,far:0});let x=i[2]*this._unitInMeters;const c=x,u=x-o,M=this._elevationProvider?.visibleElevationBounds;M&&(x=u>=0?c-this._unitInMeters*M.min:this._unitInMeters*M.max-c);const _={x:(m=null!=m?m:new h({xmin:0,ymin:0,zmin:0,xmax:0,ymax:0,zmax:0})).xmax-m.xmin,y:m.ymax-m.ymin,z:4*Math.max(m.xmax-m.xmin,m.ymax-m.ymin)},I=Math.max(_.x,_.y,_.z);r(E,a,i),v[0]=E[0]>0?m.xmax:m.xmin,v[1]=E[1]>0?m.ymax:m.ymin,v[2]=E[2]>0?I/2:-I/2,r(v,v,i),s(E,E);const j=1.1*n(v,E)*this._unitInMeters,g=Math.sqrt(x*(x+2*this._referenceEllipsoid.radius)),b=Math.max(m.xmax-m.xmin,m.ymax-m.ymin),w=b*d*this._unitInMeters,z=b*y*this._unitInMeters,U=e((x-z)/(w-z),0,1)**3,P=Math.min(t(g,j,U),g)*Math.max(Math.log(Math.abs(u)),1);return f(Math.min(P,Math.max(34064e4,I))/this._unitInMeters,p,this._unitInMeters,l)}}class M{constructor(t){this._referenceEllipsoid=o(t)}compute(i,r,s,n,m){m||(m={near:0,far:0});const o=a(i),h=o-this._referenceEllipsoid.radius,l=this._referenceEllipsoid.radius+Math.min(0,n),c=Math.abs(h-n),u=Math.max(c,Math.abs(h)),M=Math.sqrt(u*(u+2*l)),p=o+this._referenceEllipsoid.radius;return f(1.2*t(M,p,x(u)),e(2e4-(Math.log(u)-7.983)/9.011*19900,100,2e4),1,m)}}function f(t,e,i,r){const s=_/i;return t/e>s?(r.far=t,r.near=r.far/e):(r.near=s,r.far=r.near*e),r}const p=2e4,_=2,d=.001,y=1e-4,v=m(),E=m();export{c as createNearFarHeuristic};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as t}from"../../../core/MapUtils.js";import{releaseMaybe as s,disposeMaybe as i,destroyMaybe as a}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{watch as n,syncAndInitial as h,on as d}from"../../../core/reactiveUtils.js";import{someSet as l}from"../../../core/SetUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{ortho as p,fromTranslation as m}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{s as _}from"../../../chunks/vec32.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ViewingMode as y}from"../../ViewingMode.js";import{DrapeTargetType as f,DrapeSourceType as R,DrapedRenderGroup as T}from"../layers/interfaces.js";import{debugFlags as b}from"../support/debugFlags.js";import{OverlayIndex as w}from"./interfaces.js";import{Overlay as x}from"./Overlay.js";import{OverlayContent as v}from"./OverlayContent.js";import{OverlayRenderTargets as D}from"./OverlayRenderTargets.js";import S from"../webgl/RenderCamera.js";import{ShaderOutput as C}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as P}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as O}from"../../../chunks/TextureOnly.glsl.js";import{ShaderTechniqueRepository as E}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{SyncRenderPlugin as j}from"../webgl-engine/effects/RenderPlugin.js";import{GLMaterialRepository as M}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as W}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as A}from"../webgl-engine/lib/Material.js";import{OverlayRenderContext as F,defaultRenderOccludedMask as L}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as q}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as I}from"../webgl-engine/lib/ShadowMap.js";import{SortedRenderGeometryRenderer as V}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{TextureTechnique as N}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as k}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{TransparencyPassType as U}from"../webgl-engine/lib/TransparencyPassType.js";import{UpdatePolicy as H}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as G}from"../webgl-engine/lighting/Lightsources.js";import{O as B}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as z}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as Y,noBudget as X}from"../../support/Scheduler.js";import{ClearBufferBit as J,TextureSamplingMode as K}from"../../webgl/enums.js";import{Texture as Q}from"../../webgl/Texture.js";import{TextureDescriptor as Z}from"../../webgl/TextureDescriptor.js";let $=class extends j{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new B,this.hasHighlights=!1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new o,this._passParameters=new O,this._materials=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new S,this.worldToPCSRatio=1,this.events=new r,this.longitudeCyclical=null,this.produces=new Map([[q.DRAPED_MATERIAL,e=>e!==C.Highlight||this.hasHighlights],[q.DRAPED_WATER,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1}initialize(){const e=this.view._stage.renderer.fboCache,r=this.view._stage.renderView,{waterTextures:t,stippleTextures:s,markerTextures:i}=r;this._techniques=new E({rctx:this._rctx,viewingMode:y.Local,stippleTextures:s,markerTextures:i,waterTextures:t}),this._renderContext=new F(this._rctx,new I(e,this.view.state.viewingMode),null),this.addHandles([n((()=>t.updating),(()=>this.events.emit("content-changed")),h),n((()=>this.spatialReference),(e=>this._localOriginFactory=new W(e)),h),d((()=>this.view.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0))]),this._materials=new M(r.textures,this._techniques,(()=>{this.notifyChange("rendersOccludedDraped"),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed"))),this._bindParameters.slot=q.DRAPED_MATERIAL,this._bindParameters.mainDepth=null,this._camera.near=1,this._camera.far=1e4,this._camera.relativeElevation=null,this._bindParameters.camera=this._camera,this._bindParameters.transparencyPassType=U.NONE,this._bindParameters.newLighting.noonFactor=0,this._bindParameters.newLighting.globalFactor=0,this._bindParameters.newLighting.set([new G(g(1,1,1))]),this.addHandles(this.view.resourceController.scheduler.registerTask(Y.STAGE,this))}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._debugTextureTechnique=s(this._debugTextureTechnique),this._passParameters.texture=i(this._passParameters.texture),this._techniques=a(this._techniques),this.disposeOverlays()}get _bindParameters(){return this._renderContext.bindParameters}get _rctx(){return this.view._stage.renderView.renderingContext}get rctx(){return this._rctx}get materials(){return this._materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}initializeRenderContext(e){this.pluginContext=e}uninitializeRenderContext(){}renderNode(){}get updating(){return this._sortedDrapeSourceRenderersDirty||t(this._renderers,(e=>e.updating))}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMemoryForMaterial(e){return Array.from(this._renderers.values()).reduce(((r,t)=>r+t.getMemoryForMaterial(e)),0)}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),this._sortedRenderers.map((e=>e.drapeSource.layer)).filter((e=>!!e))}createGeometryDrapeSourceRenderer(e){return this.createDrapeSourceRenderer(e,V)}createDrapeSourceRenderer(e,r,t){const s=this._renderers.get(e);null!=s&&s.destroy();const i=new r({...t,rendererContext:this,drapeSource:e});return this._renderers.set(e,i),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(n((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e),i}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(){this._renderTargets?.dispose()}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&l(e,(e=>e.drapeTargetType===f.WithoutRasterImage))}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=l(e,(e=>e.drapeSourceType===R.Features)),this._hasDrapedRasterSource=l(e,(e=>e.drapeSourceType===R.RasterImage))):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new D(this.view._stage.renderer.fboCache),this._overlays=[new x,new x]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets=i(this._renderTargets),this.events.emit("textures-disposed")}getTexture(e){if(null!=e)return e===v.ColorNoRasterImage&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource?this._renderTargets?.getTexture(v.Color):this._renderTargets?.getTexture(e)}get running(){return this.updating}runTask(e){this._processDrapeSources(e,(()=>!0))}_processDrapeSources(e,r){let s=!1;for(const[t,i]of this._renderers){if(e.done)break;(t.destroyed||r(t))&&(i.commitChanges()&&(s=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,s=!0,this._updateSortedDrapeSourceRenderers()),s&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this.events.emit("content-changed"),this.hasHighlights=t(this._renderers,(e=>e.hasHighlights)),this.notifyChange("rendersOccludedDraped"),this._updateHasWater())}processSyncDrapeSources(){this._processDrapeSources(X,(e=>e.updatePolicy===H.SYNC))}get isEmpty(){return!b.OVERLAY_DRAW_DEBUG_TEXTURE&&!t(this._renderers,(e=>!e.isEmpty))}get hasWater(){return this._hasWater}get rendersOccludedDraped(){const e=this._renderContext.renderOccludedMask;this._renderContext.renderOccludedMask=se;const r=this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)));return this._renderContext.renderOccludedMask=e,r}renders(e){return b.OVERLAY_DRAW_DEBUG_TEXTURE&&e!==v.Occluded||this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)))}get mode(){return this.isEmpty?P.Disabled:this._renderTargets?.getTexture(v.WaterNormal)?P.EnabledWithWater:this._renderTargets?.getTexture(v.Color)?P.Enabled:P.Disabled}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}drawOverlays(e){if(this._overlays&&this._renderTargets){for(const e of this._overlays)this.longitudeCyclical?e.setupGeometryViewsCyclical(this.longitudeCyclical):e.setupGeometryViewsDirect();for(const r of this._renderTargets.targets){if(r.content===v.ColorNoRasterImage&&!this._needsColorWithoutRasterImage)continue;const t=this._drawTarget(w.INNER,r,e),s=this._drawTarget(w.OUTER,r,e);(t||s)&&r.fbo.generateMipMap()}}}_drawTarget(e,r,t){const s=this._overlays[e],i=s.canvasGeometries;if(0===i.numViews)return!1;const{alignPixelEnabled:a,contentPixelRatio:o}=t;this._screenToWorldRatio=o*s.mapUnitsPerPixel/this._bindParameters.overlayStretch;const n=r.output;if(this.isEmpty||n===C.Highlight&&!this.hasHighlights||n===C.Normal&&!this.hasWater||!s.hasSomeSizedView())return!1;const h=this._rctx;if(this._camera.pixelRatio=s.pixelRatio*o,this._renderContext.output=n,this._bindParameters.alignPixelEnabled=a,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=n===C.Normal?q.DRAPED_WATER:q.DRAPED_MATERIAL,r.content===v.Occluded&&(this._renderContext.renderOccludedMask=se),!this.renders(r.content))return this._renderContext.renderOccludedMask=L,!1;const d=s.resolution;this._rctx.setViewport(e===w.INNER?0:d,0,d,d);const l=2*s.resolution,c=s.resolution,u=r.fbo;u.bind(h,l,c),e===w.INNER&&(h.setClearColor(0,0,0,0),h.clear(J.COLOR_BUFFER_BIT));if(b.OVERLAY_DRAW_DEBUG_TEXTURE&&r.content!==v.Occluded)for(let p=0;p<i.numViews;p++)this._setViewParameters(i.extents[p],s),this._ensureDebugPatternResources(s.resolution,re[e]),this._rctx.bindTechnique(this._debugTextureTechnique,this._renderContext.bindParameters,this._passParameters),this._rctx.screen.draw();return this._sortedRenderers.forAll((({drapeSource:t,renderer:a})=>{if(r.content===v.ColorNoRasterImage&&t.drapeSourceType===R.RasterImage)return;const{fullOpacity:o}=t,d=null!=o&&o<1&&n===C.Color?this.bindTemporaryFramebuffer(l,c):null;for(let e=0;e<i.numViews;e++)this._setViewParameters(i.extents[e],s),a.render(this._renderContext);if(d){u.bind(h,l,c),this._overlayParameters.texture=d.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const r=this.pluginContext.techniques.acquire(z);this._rctx.bindTechnique(r,this._renderContext.bindParameters,this._overlayParameters),this._rctx.screen.draw(),r.release(),d.release()}})),h.bindFramebuffer(null),this._renderContext.renderOccludedMask=L,!0}bindTemporaryFramebuffer(e,r){const t=this.view._stage.renderer.fboCache,s=t.acquire(e,r,"overlay tmp");return t.rctx.unbindTexture(s.fbo?.colorTexture),t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(J.COLOR_BUFFER_BIT),s}async reloadShaders(){await this._techniques.reloadAll()}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:a}of this._sortedRenderers)i=a.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this.view.map.allLayers,r=e.length;this._renderers.forEach(((t,s)=>{const i=e.indexOf(s.layer),a=i>=0,o=s.renderGroup??(a?T.MapLayer:T.ViewLayer),n=r*o+(a?i:0);this._sortedRenderers.push(new ee(s,t,n))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],p(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),m(t.viewMatrix,[-e[0],-e[1],0])}_updateHasWater(){const e=t(this._renderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_ensureDebugPatternResources(e,r){if(_(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let o=0;o<e;o++)for(let r=0;r<e;r++){const i=Math.floor(r/10),a=Math.floor(o/10);i<2||a<2||10*i>e-20||10*a>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&a?1&r^1&o?0:255:1&i^1&a?0:128)}const i=new Z(e);i.samplingMode=K.NEAREST,this._passParameters.texture=new Q(this._rctx,i,t);const a=new k;a.hasAlpha=!0,this._debugTextureTechnique=this._techniques.acquire(N,a)}get test(){}};e([c()],$.prototype,"hasHighlights",void 0),e([c()],$.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([c()],$.prototype,"_techniques",void 0),e([c({constructOnly:!0})],$.prototype,"view",void 0),e([c()],$.prototype,"worldToPCSRatio",void 0),e([c()],$.prototype,"spatialReference",void 0),e([c({type:Boolean,readOnly:!0})],$.prototype,"updating",null),e([c()],$.prototype,"isEmpty",null),e([c({readOnly:!0})],$.prototype,"rendersOccludedDraped",null),$=e([u("esri.views.3d.terrain.OverlayRenderer")],$);class ee{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const re=[[1,.5,.5],[.5,.5,1]],te=-2,se=A.OccludeAndTransparent;export{$ as OverlayRenderer,te as drapedZ,se as overlayRenderOccludedFlag};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as t}from"../../../core/MapUtils.js";import{releaseMaybe as s,disposeMaybe as i,destroyMaybe as a}from"../../../core/maybe.js";import n from"../../../core/PooledArray.js";import{watch as o,syncAndInitial as h,on as d}from"../../../core/reactiveUtils.js";import{someSet as l}from"../../../core/SetUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{ortho as p,fromTranslation as m}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{s as _}from"../../../chunks/vec32.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ViewingMode as y}from"../../ViewingMode.js";import{DrapeTargetType as f,DrapeSourceType as R,DrapedRenderGroup as T}from"../layers/interfaces.js";import{debugFlags as b}from"../support/debugFlags.js";import{OverlayIndex as w}from"./interfaces.js";import{Overlay as x}from"./Overlay.js";import{OverlayContent as v}from"./OverlayContent.js";import{OverlayRenderTargets as D}from"./OverlayRenderTargets.js";import S from"../webgl/RenderCamera.js";import{ShaderOutput as C}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as P}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as O}from"../../../chunks/TextureOnly.glsl.js";import{ShaderTechniqueRepository as E}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{SyncRenderPlugin as j}from"../webgl-engine/effects/RenderPlugin.js";import{GLMaterialRepository as W}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as M}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as A}from"../webgl-engine/lib/Material.js";import{OverlayRenderContext as F,defaultRenderOccludedMask as L}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as q}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as I}from"../webgl-engine/lib/ShadowMap.js";import{SortedRenderGeometryRenderer as V}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{TextureTechnique as N}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as k}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{TransparencyPassType as U}from"../webgl-engine/lib/TransparencyPassType.js";import{UpdatePolicy as H}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as G}from"../webgl-engine/lighting/Lightsources.js";import{O as B}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as z}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as Y,noBudget as X}from"../../support/Scheduler.js";import{ClearBufferBit as J,TextureSamplingMode as K}from"../../webgl/enums.js";import{Texture as Q}from"../../webgl/Texture.js";import{TextureDescriptor as Z}from"../../webgl/TextureDescriptor.js";let $=class extends j{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new B,this.hasHighlights=!1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new n,this._passParameters=new O,this._materials=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new S,this.worldToPCSRatio=1,this.events=new r,this.longitudeCyclical=null,this.produces=new Map([[q.DRAPED_MATERIAL,e=>e!==C.Highlight||this.hasHighlights],[q.DRAPED_WATER,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1}initialize(){const e=this.view._stage.renderer.fboCache,r=this.view._stage.renderView,{waterTextures:t,stippleTextures:s,markerTextures:i}=r;this._techniques=new E({rctx:this._rctx,viewingMode:y.Local,stippleTextures:s,markerTextures:i,waterTextures:t}),this._renderContext=new F(this._rctx,new I(e,this.view.state.viewingMode),null),this.addHandles([o((()=>t.updating),(()=>this.events.emit("content-changed")),h),o((()=>this.spatialReference),(e=>this._localOriginFactory=new M(e)),h),d((()=>this.view.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0))]),this._materials=new W(r.textures,this._techniques,(()=>{this.notifyChange("rendersOccludedDraped"),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed"))),this._bindParameters.slot=q.DRAPED_MATERIAL,this._bindParameters.mainDepth=null,this._camera.near=1,this._camera.far=1e4,this._camera.relativeElevation=null,this._bindParameters.camera=this._camera,this._bindParameters.transparencyPassType=U.NONE,this._bindParameters.newLighting.noonFactor=0,this._bindParameters.newLighting.globalFactor=0,this._bindParameters.newLighting.set([new G(g(1,1,1))]),this.addHandles(this.view.resourceController.scheduler.registerTask(Y.STAGE,this))}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._debugTextureTechnique=s(this._debugTextureTechnique),this._passParameters.texture=i(this._passParameters.texture),this._techniques=a(this._techniques),this.disposeOverlays()}get _bindParameters(){return this._renderContext.bindParameters}get _rctx(){return this.view._stage.renderView.renderingContext}get rctx(){return this._rctx}get materials(){return this._materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}initializeRenderContext(e){this.pluginContext=e}uninitializeRenderContext(){}renderNode(){}get updating(){return this._sortedDrapeSourceRenderersDirty||t(this._renderers,(e=>e.updating))}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMaterialRenderer(e){for(const r of this._renderers.values()){const t=r.getMaterialRenderer(e);if(t)return t}return null}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),this._sortedRenderers.map((e=>e.drapeSource.layer)).filter((e=>!!e))}createGeometryDrapeSourceRenderer(e){return this.createDrapeSourceRenderer(e,V)}createDrapeSourceRenderer(e,r,t){const s=this._renderers.get(e);null!=s&&s.destroy();const i=new r({...t,rendererContext:this,drapeSource:e});return this._renderers.set(e,i),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(o((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e),i}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(){this._renderTargets?.dispose()}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&l(e,(e=>e.drapeTargetType===f.WithoutRasterImage))}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=l(e,(e=>e.drapeSourceType===R.Features)),this._hasDrapedRasterSource=l(e,(e=>e.drapeSourceType===R.RasterImage))):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new D(this.view._stage.renderer.fboCache),this._overlays=[new x,new x]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets=i(this._renderTargets),this.events.emit("textures-disposed")}getTexture(e){if(null!=e)return e===v.ColorNoRasterImage&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource?this._renderTargets?.getTexture(v.Color):this._renderTargets?.getTexture(e)}get running(){return this.updating}runTask(e){this._processDrapeSources(e,(()=>!0))}_processDrapeSources(e,r){let s=!1;for(const[t,i]of this._renderers){if(e.done)break;(t.destroyed||r(t))&&(i.commitChanges()&&(s=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,s=!0,this._updateSortedDrapeSourceRenderers()),s&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this.events.emit("content-changed"),this.hasHighlights=t(this._renderers,(e=>e.hasHighlights)),this.notifyChange("rendersOccludedDraped"),this._updateHasWater())}processSyncDrapeSources(){this._processDrapeSources(X,(e=>e.updatePolicy===H.SYNC))}get isEmpty(){return!b.OVERLAY_DRAW_DEBUG_TEXTURE&&!t(this._renderers,(e=>!e.isEmpty))}get hasWater(){return this._hasWater}get rendersOccludedDraped(){const e=this._renderContext.renderOccludedMask;this._renderContext.renderOccludedMask=se;const r=this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)));return this._renderContext.renderOccludedMask=e,r}renders(e){return b.OVERLAY_DRAW_DEBUG_TEXTURE&&e!==v.Occluded||this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)))}get mode(){return this.isEmpty?P.Disabled:this._renderTargets?.getTexture(v.WaterNormal)?P.EnabledWithWater:this._renderTargets?.getTexture(v.Color)?P.Enabled:P.Disabled}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}drawOverlays(e){if(this._overlays&&this._renderTargets){for(const e of this._overlays)this.longitudeCyclical?e.setupGeometryViewsCyclical(this.longitudeCyclical):e.setupGeometryViewsDirect();for(const r of this._renderTargets.targets){if(r.content===v.ColorNoRasterImage&&!this._needsColorWithoutRasterImage)continue;const t=this._drawTarget(w.INNER,r,e),s=this._drawTarget(w.OUTER,r,e);(t||s)&&r.fbo.generateMipMap()}}}_drawTarget(e,r,t){const s=this._overlays[e],i=s.canvasGeometries;if(0===i.numViews)return!1;const{alignPixelEnabled:a,contentPixelRatio:n}=t;this._screenToWorldRatio=n*s.mapUnitsPerPixel/this._bindParameters.overlayStretch;const o=r.output;if(this.isEmpty||o===C.Highlight&&!this.hasHighlights||o===C.Normal&&!this.hasWater||!s.hasSomeSizedView())return!1;const h=this._rctx;if(this._camera.pixelRatio=s.pixelRatio*n,this._renderContext.output=o,this._bindParameters.alignPixelEnabled=a,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=o===C.Normal?q.DRAPED_WATER:q.DRAPED_MATERIAL,r.content===v.Occluded&&(this._renderContext.renderOccludedMask=se),!this.renders(r.content))return this._renderContext.renderOccludedMask=L,!1;const d=s.resolution;this._rctx.setViewport(e===w.INNER?0:d,0,d,d);const l=2*s.resolution,c=s.resolution,u=r.fbo;u.bind(h,l,c),e===w.INNER&&(h.setClearColor(0,0,0,0),h.clear(J.COLOR_BUFFER_BIT));if(b.OVERLAY_DRAW_DEBUG_TEXTURE&&r.content!==v.Occluded)for(let p=0;p<i.numViews;p++)this._setViewParameters(i.extents[p],s),this._ensureDebugPatternResources(s.resolution,re[e]),this._rctx.bindTechnique(this._debugTextureTechnique,this._renderContext.bindParameters,this._passParameters),this._rctx.screen.draw();return this._sortedRenderers.forAll((({drapeSource:t,renderer:a})=>{if(r.content===v.ColorNoRasterImage&&t.drapeSourceType===R.RasterImage)return;const{fullOpacity:n}=t,d=null!=n&&n<1&&o===C.Color?this.bindTemporaryFramebuffer(l,c):null;for(let e=0;e<i.numViews;e++)this._setViewParameters(i.extents[e],s),a.render(this._renderContext);if(d){u.bind(h,l,c),this._overlayParameters.texture=d.getTexture(),this._overlayParameters.opacity=n,this._overlayParameters.overlayIndex=e;const r=this.pluginContext.techniques.acquire(z);this._rctx.bindTechnique(r,this._renderContext.bindParameters,this._overlayParameters),this._rctx.screen.draw(),r.release(),d.release()}})),h.bindFramebuffer(null),this._renderContext.renderOccludedMask=L,!0}bindTemporaryFramebuffer(e,r){const t=this.view._stage.renderer.fboCache,s=t.acquire(e,r,"overlay tmp");return t.rctx.unbindTexture(s.fbo?.colorTexture),t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(J.COLOR_BUFFER_BIT),s}async reloadShaders(){await this._techniques.reloadAll()}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:a}of this._sortedRenderers)i=a.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this.view.map.allLayers,r=e.length;this._renderers.forEach(((t,s)=>{const i=e.indexOf(s.layer),a=i>=0,n=s.renderGroup??(a?T.MapLayer:T.ViewLayer),o=r*n+(a?i:0);this._sortedRenderers.push(new ee(s,t,o))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],p(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),m(t.viewMatrix,[-e[0],-e[1],0])}_updateHasWater(){const e=t(this._renderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_ensureDebugPatternResources(e,r){if(_(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let n=0;n<e;n++)for(let r=0;r<e;r++){const i=Math.floor(r/10),a=Math.floor(n/10);i<2||a<2||10*i>e-20||10*a>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&a?1&r^1&n?0:255:1&i^1&a?0:128)}const i=new Z(e);i.samplingMode=K.NEAREST,this._passParameters.texture=new Q(this._rctx,i,t);const a=new k;a.hasAlpha=!0,this._debugTextureTechnique=this._techniques.acquire(N,a)}get test(){}};e([c()],$.prototype,"hasHighlights",void 0),e([c()],$.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([c()],$.prototype,"_techniques",void 0),e([c({constructOnly:!0})],$.prototype,"view",void 0),e([c()],$.prototype,"worldToPCSRatio",void 0),e([c()],$.prototype,"spatialReference",void 0),e([c({type:Boolean,readOnly:!0})],$.prototype,"updating",null),e([c()],$.prototype,"isEmpty",null),e([c({readOnly:!0})],$.prototype,"rendersOccludedDraped",null),$=e([u("esri.views.3d.terrain.OverlayRenderer")],$);class ee{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const re=[[1,.5,.5],[.5,.5,1]],te=-2,se=A.OccludeAndTransparent;export{$ as OverlayRenderer,te as drapedZ,se as overlayRenderOccludedFlag};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{isPromiseLike as r,createAbortError as t}from"../../../../core/promiseUtils.js";import{signal as n}from"../../../../core/signal.js";import{ShaderOutput as s}from"../core/shaderLibrary/ShaderOutput.js";import{isPrepareRenderPlugin as o,isPreparesRenderPlugin as i}from"./RenderPlugin.js";import{Decorations as d}from"../lib/basicInterfaces.js";import{union as l,DepthRange as u}from"../lib/depthRange.js";import{RenderOccludedFlag as a}from"../lib/Material.js";import{RenderSlot as c}from"../lib/RenderSlot.js";class h{constructor(r){this._context=r,this._renderPlugins=new e,this._slots=new Array,this._renderVersion=n(0);for(let e=0;e<c.MAX_SLOTS;++e)this._slots[e]=[]}destroy(){this._renderPlugins.forEach((e=>e.destroy())),this._renderPlugins.clear()}get plugins(){return this._renderPlugins}add(e,n){const s=()=>{if(n?.aborted)throw e.uninitializeRenderContext(),t();this._renderPlugins.push(e),e.produces.forEach(((r,t)=>{this._slots[t].push(e)})),this._context.requestRender(),this._renderVersion.value++},o=e.initializeRenderContext(this._context,n);if(r(o))return o.then(s);s()}remove(e){if(null!=this._renderPlugins.removeUnordered(e)){for(let r=0;r<this._slots.length;++r)this._slots[r]=this._slots[r].filter((r=>r!==e));e.uninitializeRenderContext(),this._context.requestRender(),this._renderVersion.value++}}prepareRender(){this._renderPlugins.forAll((e=>{e.prepareRender&&e.prepareRender(this._context.renderContext)}))}updateAnimation(e){let r=!1;return this._renderPlugins.forAll((t=>{t.updateAnimation&&(r=t.updateAnimation(e)||r)})),r}renderFeatureChanged(){this._renderPlugins.forAll((e=>{e.renderFeatureChanged&&e.renderFeatureChanged()}))}prepare(...e){for(const r of e)this._context.renderContext.bindParameters.slot=r,this._slots[r].forEach((e=>{const t=e.produces.get(r);t?.(s.Color)&&(o(e)&&e.prepareTechnique(this._context.renderContext),i(e)&&e.prepareTechniques(this._context.renderContext))}))}_getRenderables(){const e=this._context.renderContext.bindParameters.slot,r=this._context.renderContext.output??s.Color,t=new Map;return this._slots[e].forEach((n=>{const s=n.produces.get(e);if(s?.(r)&&(!n.isDecoration||this._context.renderContext.bindParameters.decorations!==d.OFF))if(o(n)){const e=n.prepareTechnique(this._context.renderContext);null!=e&&t.set(n,e)}else if(i(n)){const e=n.prepareTechniques(this._context.renderContext);null!=e&&t.set(n,e)}else t.set(n,null)})),t}render(e,...r){for(const t of r)this._context.renderContext.bindParameters.slot=t,this._getRenderables().forEach(((r,t)=>t.renderNode(this._context.renderContext,r,e)))}queryDepthRange(e){const r=new u;return this._renderPlugins.forAll((t=>{const n=t.queryDepthRange?.(e);l(r,n)})),r}get updating(){return this._renderVersion.value>=0&&this._renderPlugins.some((e=>e.running))}produces(e,...r){for(const t of r)if(this._slots[t].some((r=>{const n=r.produces.get(t);return!!n&&n(e)})))return!0;return!1}consumes(e){return this._renderPlugins.some((r=>r.consumes().required.includes(e)))}getMaterialRenderer(e){return this._renderPlugins.find((r=>r.materialReference===e))}removeEmptyMaterialRenderers(){this._renderPlugins.filterInPlace((e=>!e.materialReference||0!==e.numGeometries||(e.destroy(),!1)))}get hasDecorations(){return this._renderPlugins.some((e=>e.isDecoration))}get hasOccludees(){return this._renderPlugins.some((e=>e.hasOccludees))}get renderOccludedFlags(){return this._renderPlugins.reduce(((e,r)=>e|r.renderOccludedFlags),a.None)}get usedMemory(){return this._renderPlugins.reduce(((e,r)=>null!==r.materialReference?e:e+(r.usedMemory??0)),0)}get test(){}}export{h as RenderPluginManager};
5
+ import"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{isPromiseLike as r,createAbortError as t}from"../../../../core/promiseUtils.js";import{signal as n}from"../../../../core/signal.js";import{ShaderOutput as s}from"../core/shaderLibrary/ShaderOutput.js";import{isPrepareRenderPlugin as i,isPreparesRenderPlugin as o}from"./RenderPlugin.js";import{Decorations as l}from"../lib/basicInterfaces.js";import{union as a,DepthRange as d}from"../lib/depthRange.js";import{RenderOccludedFlag as u}from"../lib/Material.js";import{RenderSlot as c}from"../lib/RenderSlot.js";class h{constructor(r){this._context=r,this._renderPlugins=new e,this._materialRenderers=new Map,this._slots=new Array,this._renderVersion=n(0);for(let e=0;e<c.MAX_SLOTS;++e)this._slots[e]=[]}destroy(){this._renderPlugins.forEach((e=>e.destroy())),this._renderPlugins.clear(),this._materialRenderers.clear()}get plugins(){return this._renderPlugins}add(e,n){const s=()=>{if(n?.aborted)throw e.uninitializeRenderContext(),t();this._renderPlugins.push(e),e.materialReference&&this._materialRenderers.set(e.materialReference,e),e.produces.forEach(((r,t)=>{this._slots[t].push(e)})),this._context.requestRender(),this._renderVersion.value++},i=e.initializeRenderContext(this._context,n);if(r(i))return i.then(s);s()}remove(e){if(null!=e.materialReference&&this._materialRenderers.delete(e.materialReference),null!=this._renderPlugins.removeUnordered(e)){for(let r=0;r<this._slots.length;++r)this._slots[r]=this._slots[r].filter((r=>r!==e));e.uninitializeRenderContext(),this._context.requestRender(),this._renderVersion.value++}}prepareRender(){this._renderPlugins.forAll((e=>{e.prepareRender&&e.prepareRender(this._context.renderContext)}))}updateAnimation(e){let r=!1;return this._renderPlugins.forAll((t=>{t.updateAnimation&&(r=t.updateAnimation(e)||r)})),r}renderFeatureChanged(){this._renderPlugins.forAll((e=>{e.renderFeatureChanged&&e.renderFeatureChanged()}))}prepare(...e){for(const r of e)this._context.renderContext.bindParameters.slot=r,this._slots[r].forEach((e=>{const t=e.produces.get(r);t?.(s.Color)&&(i(e)&&e.prepareTechnique(this._context.renderContext),o(e)&&e.prepareTechniques(this._context.renderContext))}))}_getRenderables(){const e=this._context.renderContext.bindParameters.slot,r=this._context.renderContext.output??s.Color,t=new Map;return this._slots[e].forEach((n=>{const s=n.produces.get(e);if(s?.(r)&&(!n.isDecoration||this._context.renderContext.bindParameters.decorations!==l.OFF))if(i(n)){const e=n.prepareTechnique(this._context.renderContext);null!=e&&t.set(n,e)}else if(o(n)){const e=n.prepareTechniques(this._context.renderContext);null!=e&&t.set(n,e)}else t.set(n,null)})),t}render(e,...r){for(const t of r)this._context.renderContext.bindParameters.slot=t,this._getRenderables().forEach(((r,t)=>t.renderNode(this._context.renderContext,r,e)))}queryDepthRange(e){const r=new d;return this._renderPlugins.forAll((t=>{const n=t.queryDepthRange?.(e);a(r,n)})),r}get updating(){return this._renderVersion.value>=0&&this._renderPlugins.some((e=>e.running))}produces(e,...r){for(const t of r)if(this._slots[t].some((r=>{const n=r.produces.get(t);return!!n&&n(e)})))return!0;return!1}consumes(e){return this._renderPlugins.some((r=>r.consumes().required.includes(e)))}getMaterialRenderer(e){return this._materialRenderers.get(e)}removeEmptyMaterialRenderers(){this._renderPlugins.filterInPlace((e=>!e.materialReference||0!==e.numGeometries||(this._materialRenderers.delete(e.materialReference),e.destroy(),!1)))}get hasDecorations(){return this._renderPlugins.some((e=>e.isDecoration))}get hasOccludees(){return this._renderPlugins.some((e=>e.hasOccludees))}get renderOccludedFlags(){return this._renderPlugins.reduce(((e,r)=>e|r.renderOccludedFlags),u.None)}get usedMemory(){return this._renderPlugins.reduce(((e,r)=>null!==r.materialReference?e:e+(r.usedMemory??0)),0)}get test(){}}export{h as RenderPluginManager};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{property as r}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{ColorFormat as t}from"../../../webgl/formats.js";import n from"../../../webgl/RenderNode.js";import{alphaCutoff as i}from"../../core/shaderLibrary/util/AlphaCutoff.js";import{glsl as s}from"../../core/shaderModules/interfaces.js";import{Default3D as a}from"../../lib/DefaultVertexAttributeLocations.js";import{ClearBufferBit as c,ColorAttachment as l,BlendFactor as u,SizedPixelFormat as p,PixelFormat as d,DataType as f}from"../../../../webgl/enums.js";let h=class extends n{constructor(e){super(e),this.destroyedCB=null,this.produces="final-color",this.consumes={required:["final-color"]},this._focusedFBOType=0,this._program=new Array}destroy(){this._program.forEach((e=>e.dispose())),this._program.length=0,this.destroyedCB()}render(e){const r=e.find((({name:e})=>"final-color"===e));if(!this._focusedFBO)return r;const o=this.renderingContext;o.bindFramebuffer(r.fbo),o.setClearColor(0,0,0,0),o.clear(c.COLOR_BUFFER_BIT);const t=this._ensureShader(o,!1);return o.useProgram(t),o.bindTexture(this._focusedFBO.getTexture(),0),t.setUniform1i("colorTex",0),t.setUniform1i("inputType",this._focusedFBOType),3===this._focusedFBOType&&t.setUniform2fv("nearFar",this.camera.nearFar),o.screen.draw(),r}getReplacingFBO(e,r,o,n,i){r===m.ON&&(n=e.width,i=e.height);const s=this.renderingContext,a=e.depthStencilTexture,d=this._ensureShader(s,null!=a),f=this.fboCache.acquire(n,i,"fbo visualizer"),h=!e.colorTexture?.descriptor.hasMipmap;h&&e.colorTexture?.generateMipmap(),s.useProgram(d),s.unbindTexture(f.fbo?.colorTexture),s.bindFramebuffer(f.fbo),a&&(s.bindTexture(a,1),d.setUniform1i("depthTex",1),f.acquireColor(l.COLOR_ATTACHMENT1,t.RGBA),s.gl.drawBuffers([l.COLOR_ATTACHMENT0,l.COLOR_ATTACHMENT1]));const T=s.getViewport();s.setViewport(0,0,n,i),s.setClearColor(0,0,0,0),s.clear(c.COLOR_BUFFER_BIT),s.setBlendingEnabled(!0),s.setBlendFunction(u.ONE,u.ONE_MINUS_SRC_ALPHA),s.bindTexture(e.colorTexture,0),d.setUniform1i("colorTex",0);const F="linear-depth"===o||o.includes("shadow"),v=e.colorTexture?.descriptor.internalFormat,g=F?3:v===p.R16F||v===p.R32F||v===p.R8?1:v===p.RG8?2:v===p.RGBA16F?4:0;return d.setUniform1i("inputType",g),F&&d.setUniform2fv("nearFar",this.camera.nearFar),s.screen.draw(),s.gl.drawBuffers([l.COLOR_ATTACHMENT0]),s.bindFramebuffer(null),s.setViewport(T.x,T.y,T.width,T.height),r===m.ON&&(this._focusedFBO=f,this._focusedFBOType=g),h&&e.colorTexture?.clearMipmap(),f}clearFocusedFBO(){this._focusedFBO=null}getPreviewContent(e,r,o,t){if(!o)return null;const n=this.renderingContext,i=this.fboCache.acquire(e,r,"fbo visualizer");n.bindFramebuffer(i?.fbo),n.setClearColor(0,0,0,0),n.clear(c.COLOR_BUFFER_BIT),n.setBlendingEnabled(!0),n.setBlendFunction(u.ONE,u.ONE_MINUS_SRC_ALPHA),n.setViewport(0,0,e,r);const s=this._ensureShader(n,!1);n.useProgram(s),n.bindTexture(o.getColorTexture(t),0),s.setUniform1i("colorTex",0),s.setUniform1i("inputType",0),n.screen.draw();const a=new ImageData(new Uint8ClampedArray(e*r*4),e,r);return n.gl.readPixels(0,0,e,r,d.RGBA,f.UNSIGNED_BYTE,new Uint8Array(a.data.buffer)),n.bindFramebuffer(null),i?.release(),a}_ensureShader(e,r){const o=r?1:0;if(this._program[o])return this._program[o];const t="#version 300 es\n in vec2 position;\n out vec2 uv;\n\n void main() {\n gl_Position = vec4(position, 0.0, 1.0);\n uv = position * 0.5 + vec2(0.5);\n }",n=`#version 300 es\n precision highp float;\n\n in vec2 uv;\n uniform sampler2D colorTex;\n layout(location = 0) out vec4 fragColor;\n ${r?"\n layout(location = 1) out vec4 fragDepth;\n uniform sampler2D depthTex;\n ":""}\n uniform int inputType;\n uniform vec2 nearFar;\n\n // Factors to convert rgba back to float\n const vec4 RGBA_2_FLOAT_FACTORS = vec4(\n 255.0 / (256.0),\n 255.0 / (256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0 * 256.0)\n );\n\n\n float rgba2float(vec4 rgba) {\n // Convert components from 0->1 back to 0->255 and then add the components together with their corresponding\n // fixed point factors, i.e. (256^1, 256^2, 256^3, 256^4)\n return dot(rgba, RGBA_2_FLOAT_FACTORS);\n }\n\n float linearDepthFromFloat(float depth) {\n depth = pow(depth, 0.2);\n return -(depth * (nearFar[1] - nearFar[0]) + nearFar[0]);\n }\n\n float linearDepthFromRGBA(vec4 depth) {\n return linearDepthFromFloat(rgba2float(depth));\n }\n\n float linearDepthFromTexture(sampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(texelFetch(depthTex, iuv, 0));\n }\n\n void main() {\n vec4 color;\n if(inputType == 1) {\n color = vec4(vec3(texture(colorTex, uv).r), 1.0);\n } else if(inputType == 2) {\n color = vec4(texture(colorTex, uv).rg, 0.0, 1.0);\n } else if(inputType == 3) {\n float depth = 1.0 - (-linearDepthFromTexture(colorTex, uv) / (nearFar[1] - nearFar[0]));\n color = vec4(vec3(depth), depth >= 0.999 ? 0.0 : 1.0);\n } else if(inputType == 4) {\n color = texture(colorTex, uv);\n color = vec4(color.rgb / color.a, color.a);\n } else {\n color = texture(colorTex, uv);\n }\n\n\n if(color.a < ${s.float(i)})\n discard;\n else {\n fragColor = color;\n ${r?"\n float depth = 1.0 - pow(texture(depthTex, uv).r, 10.0);\n fragDepth = vec4(vec3(depth), depth < 0.000001 ? 0.0 : 1.0);\n ":""}\n }\n }`;return this._program[o]=e.programCache.acquire(t,n,a),this._program[o]}};var m;e([r()],h.prototype,"destroyedCB",void 0),e([r()],h.prototype,"produces",void 0),e([r()],h.prototype,"consumes",void 0),h=e([o("esri.views.3d.webgl-engine.effects.debug.RenderNodeVisualizerNode")],h),function(e){e[e.ON=0]="ON",e[e.OFF=1]="OFF"}(m||(m={}));export{m as FocusState,h as RenderNodeVisualizerNode};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{property as r}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{ZEROS as t}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ColorFormat as n}from"../../../webgl/formats.js";import i from"../../../webgl/RenderNode.js";import{alphaCutoff as s}from"../../core/shaderLibrary/util/AlphaCutoff.js";import{glsl as a}from"../../core/shaderModules/interfaces.js";import{Default3D as c}from"../../lib/DefaultVertexAttributeLocations.js";import{ClearBufferBit as l,ColorAttachment as u,BlendFactor as p,SizedPixelFormat as d,PixelFormat as f,DataType as h}from"../../../../webgl/enums.js";let m=class extends i{constructor(e){super(e),this.destroyedCB=null,this.produces="composite-color",this.consumes={required:["composite-color"]},this.clearColor=t,this._focusedFBOType=0,this._program=new Array}destroy(){this._program.forEach((e=>e.dispose())),this._program.length=0,this.destroyedCB()}render(e){const r=e.find((({name:e})=>"final-color"===e));if(!this._focusedFBO)return r;const o=this.renderingContext;o.bindFramebuffer(r.fbo),o.setClearColor(0,0,0,0),o.clear(l.COLOR_BUFFER_BIT);const t=this._ensureShader(o,!1);return o.useProgram(t),o.bindTexture(this._focusedFBO.getTexture(),0),t.setUniform1i("colorTex",0),t.setUniform1i("inputType",this._focusedFBOType),3===this._focusedFBOType&&t.setUniform2fv("nearFar",this.camera.nearFar),o.screen.draw(),r}getReplacingFBO(e,r,o,t,i){r===T.ON&&(t=e.width,i=e.height);const s=this.renderingContext,a=e.depthStencilTexture,c=this._ensureShader(s,null!=a),f=this.fboCache.acquire(t,i,"fbo visualizer"),h=!e.colorTexture?.descriptor.hasMipmap;h&&e.colorTexture?.generateMipmap(),s.useProgram(c),s.unbindTexture(f.fbo?.colorTexture),s.bindFramebuffer(f.fbo),a&&(s.bindTexture(a,1),c.setUniform1i("depthTex",1),f.acquireColor(u.COLOR_ATTACHMENT1,n.RGBA),s.gl.drawBuffers([u.COLOR_ATTACHMENT0,u.COLOR_ATTACHMENT1]));const m=s.getViewport();s.setViewport(0,0,t,i),s.setClearColor(0,0,0,0),s.clear(l.COLOR_BUFFER_BIT),s.setBlendingEnabled(!0),s.setBlendFunction(p.ONE,p.ONE_MINUS_SRC_ALPHA),s.bindTexture(e.colorTexture,0),c.setUniform1i("colorTex",0);const v="linear-depth"===o||o.includes("shadow"),F=e.colorTexture?.descriptor.internalFormat,g=v?3:F===d.R16F||F===d.R32F||F===d.R8?1:F===d.RG8?2:F===d.RGBA16F?4:0;return c.setUniform1i("inputType",g),v&&c.setUniform2fv("nearFar",this.camera.nearFar),s.screen.draw(),s.gl.drawBuffers([u.COLOR_ATTACHMENT0]),s.bindFramebuffer(null),s.setViewport(m.x,m.y,m.width,m.height),r===T.ON&&(this._focusedFBO=f,this._focusedFBOType=g),h&&e.colorTexture?.clearMipmap(),f}clearFocusedFBO(){this._focusedFBO=null}getPreviewContent(e,r,o,t){if(!o)return null;const n=this.renderingContext,i=this.fboCache.acquire(e,r,"fbo visualizer");n.bindFramebuffer(i?.fbo),n.setClearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],this.clearColor[3]),n.clear(l.COLOR_BUFFER_BIT),n.setBlendingEnabled(!0),n.setBlendFunction(p.ONE,p.ONE_MINUS_SRC_ALPHA),n.setViewport(0,0,e,r);const s=this._ensureShader(n,!1);n.useProgram(s),n.bindTexture(o.getColorTexture(t),0),s.setUniform1i("colorTex",0),s.setUniform1i("inputType",0),n.screen.draw();const a=new ImageData(new Uint8ClampedArray(e*r*4),e,r);return n.gl.readPixels(0,0,e,r,f.RGBA,h.UNSIGNED_BYTE,new Uint8Array(a.data.buffer)),n.bindFramebuffer(null),i?.release(),a}_ensureShader(e,r){const o=r?1:0;if(this._program[o])return this._program[o];const t="#version 300 es\n in vec2 position;\n out vec2 uv;\n\n void main() {\n gl_Position = vec4(position, 0.0, 1.0);\n uv = position * 0.5 + vec2(0.5);\n }",n=`#version 300 es\n precision highp float;\n\n in vec2 uv;\n uniform sampler2D colorTex;\n layout(location = 0) out vec4 fragColor;\n ${r?"\n layout(location = 1) out vec4 fragDepth;\n uniform sampler2D depthTex;\n ":""}\n uniform int inputType;\n uniform vec2 nearFar;\n\n // Factors to convert rgba back to float\n const vec4 RGBA_2_FLOAT_FACTORS = vec4(\n 255.0 / (256.0),\n 255.0 / (256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0 * 256.0)\n );\n\n\n float rgba2float(vec4 rgba) {\n // Convert components from 0->1 back to 0->255 and then add the components together with their corresponding\n // fixed point factors, i.e. (256^1, 256^2, 256^3, 256^4)\n return dot(rgba, RGBA_2_FLOAT_FACTORS);\n }\n\n float linearDepthFromFloat(float depth) {\n depth = pow(depth, 0.2);\n return -(depth * (nearFar[1] - nearFar[0]) + nearFar[0]);\n }\n\n float linearDepthFromRGBA(vec4 depth) {\n return linearDepthFromFloat(rgba2float(depth));\n }\n\n float linearDepthFromTexture(sampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(texelFetch(depthTex, iuv, 0));\n }\n\n void main() {\n vec4 color;\n if(inputType == 1) {\n color = vec4(vec3(texture(colorTex, uv).r), 1.0);\n } else if(inputType == 2) {\n color = vec4(texture(colorTex, uv).rg, 0.0, 1.0);\n } else if(inputType == 3) {\n float depth = 1.0 - (-linearDepthFromTexture(colorTex, uv) / (nearFar[1] - nearFar[0]));\n color = vec4(vec3(depth), depth >= 0.999 ? 0.0 : 1.0);\n } else if(inputType == 4) {\n color = texture(colorTex, uv);\n color = vec4(color.rgb / color.a, color.a);\n } else {\n color = texture(colorTex, uv);\n }\n\n\n if(color.a < ${a.float(s)})\n discard;\n else {\n fragColor = color;\n ${r?"\n float depth = 1.0 - pow(texture(depthTex, uv).r, 10.0);\n fragDepth = vec4(vec3(depth), depth < 0.000001 ? 0.0 : 1.0);\n ":""}\n }\n }`;return this._program[o]=e.programCache.acquire(t,n,c),this._program[o]}};var T;e([r()],m.prototype,"destroyedCB",void 0),e([r()],m.prototype,"produces",void 0),e([r()],m.prototype,"consumes",void 0),e([r()],m.prototype,"clearColor",void 0),m=e([o("esri.views.3d.webgl-engine.effects.debug.RenderNodeVisualizerNode")],m),function(e){e[e.ON=0]="ON",e[e.OFF=1]="OFF"}(T||(T={}));export{T as FocusState,m as RenderNodeVisualizerNode};