@arcgis/core 4.26.0-next.20230119 → 4.26.0-next.20230121

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 (98) hide show
  1. package/arcade/ArcadeDate.js +1 -1
  2. package/arcade/Feature.js +1 -1
  3. package/arcade/featureset/support/shared.js +1 -1
  4. package/arcade/featureset/support/sqlUtils.js +1 -1
  5. package/arcade/languageUtils.js +1 -1
  6. package/arcade/lib/arcade-parser.js +1 -1
  7. package/arcade/lib/parser.js +1 -1
  8. package/arcade/lib/scanner.js +1 -1
  9. package/arcade/lib/types.js +1 -1
  10. package/arcade/validation/arcadeValidator.js +1 -1
  11. package/arcade/validation/diagnosticMessages.js +1 -1
  12. package/arcade/validation/languageKeywords.js +5 -0
  13. package/assets/esri/core/workers/RemoteClient.js +1 -1
  14. package/assets/esri/core/workers/chunks/{e6c6e3c9750829ec82c1.js → 09ac51aeb0f6fe16aa30.js} +1 -1
  15. package/assets/esri/core/workers/chunks/293594192932f0e00ecf.js +1 -0
  16. package/assets/esri/core/workers/chunks/4f4064eabbbc4a66f95a.js +1 -0
  17. package/assets/esri/core/workers/chunks/{0417369a1d563a6280ff.js → 63706a04e173000994db.js} +1 -1
  18. package/assets/esri/core/workers/chunks/6a90b1d73d5941ebb112.js +1 -0
  19. package/assets/esri/core/workers/chunks/{0c242aa92ab4f0c996db.js → 70f1fe5f36bc4abff2d2.js} +1 -1
  20. package/assets/esri/core/workers/chunks/96d4c50f74a9c0dcdb66.js +1 -0
  21. package/assets/esri/core/workers/chunks/b26a671d3523b8a48404.js +1 -0
  22. package/assets/esri/core/workers/chunks/{5dfed65b615b33588488.js → db96a2dc1879b4944cb8.js} +1 -1
  23. package/assets/esri/core/workers/chunks/fcf033c581f58d006cf6.js +1 -0
  24. package/assets/esri/core/workers/chunks/{5e872adb3a5e84c49865.js → fde8827bd7f1a97a6db3.js} +1 -1
  25. package/assets/esri/themes/base/widgets/_Editor.scss +9 -14
  26. package/assets/esri/themes/dark/main.css +1 -1
  27. package/assets/esri/themes/light/main.css +1 -1
  28. package/assets/esri/themes/light/view.css +1 -1
  29. package/chunks/languageUtils.js +1 -1
  30. package/core/scheduling.js +1 -1
  31. package/interfaces.d.ts +24 -12
  32. package/layers/StreamLayer.js +1 -1
  33. package/layers/VoxelWasmPerSceneView.js +1 -1
  34. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  35. package/layers/graphics/controllers/StreamController.js +1 -1
  36. package/layers/graphics/data/StreamFeatureManager.js +1 -1
  37. package/layers/graphics/sources/connections/GeoEventConnection.js +1 -1
  38. package/layers/graphics/sources/connections/WebSocketConnection.js +1 -1
  39. package/layers/support/FeatureReductionBinning.js +1 -1
  40. package/layers/support/FeatureReductionCluster.js +1 -1
  41. package/layers/support/StreamConnection.js +1 -1
  42. package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
  43. package/layers/support/rasterFormats/pixelRangeUtils.js +1 -1
  44. package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
  45. package/package.json +1 -1
  46. package/support/revision.js +1 -1
  47. package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
  48. package/views/2d/interactive/editingTools/MediaTransformToolsWrapper.js +1 -1
  49. package/views/2d/interactive/editingTools/TransformTool.js +1 -1
  50. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  51. package/views/2d/layers/StreamLayerView2D.js +1 -1
  52. package/views/2d/layers/features/controllers/FeatureController2D.js +1 -1
  53. package/views/2d/layers/features/schemaUtils.js +1 -1
  54. package/views/2d/layers/features/sources/GeoEventSource.js +1 -1
  55. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  56. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  57. package/views/2d/layers/support/FeatureLayerProxy.js +1 -1
  58. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  59. package/views/3d/environment/SceneViewEnvironmentManager.js +1 -1
  60. package/views/3d/layers/DynamicLayerView3D.js +1 -1
  61. package/views/3d/layers/I3SMeshView3D.js +1 -1
  62. package/views/3d/layers/I3SMeshViewLabeler.js +1 -1
  63. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  64. package/views/3d/layers/PointCloudWorker.js +1 -1
  65. package/views/3d/layers/RouteLayerView3D.js +1 -1
  66. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  67. package/views/3d/layers/SceneLayerView3D.js +1 -1
  68. package/views/3d/layers/StreamLayerView3D.js +1 -1
  69. package/views/3d/layers/TileLayerView3D.js +1 -1
  70. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  71. package/views/3d/layers/i3s/I3SLodHandling.js +1 -1
  72. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  73. package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
  74. package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
  75. package/views/3d/layers/i3s/I3SQueryEngine.js +1 -1
  76. package/views/3d/layers/i3s/PointCloudRendererUtil.js +1 -1
  77. package/views/3d/layers/i3s/PointCloudWorkerUtil.js +1 -1
  78. package/views/3d/layers/support/FeatureTileTree3D.js +1 -1
  79. package/views/3d/layers/support/I3STreeDebugger.js +1 -1
  80. package/views/3d/layers/support/SceneLayerViewRequiredFields.js +1 -1
  81. package/views/3d/terrain/TerrainSurface.js +1 -1
  82. package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceReflections.glsl.js +1 -1
  83. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  84. package/views/PopupView.js +1 -1
  85. package/views/SceneView.js +1 -1
  86. package/views/interactive/SegmentLabels.js +1 -1
  87. package/views/layers/ImageryLayerView.js +1 -1
  88. package/views/layers/SceneLayerView.js +1 -1
  89. package/views/layers/StreamLayerView.js +1 -1
  90. package/widgets/Editor.js +1 -1
  91. package/widgets/Fullscreen/FullscreenViewModel.js +1 -1
  92. package/widgets/Home/HomeViewModel.js +1 -1
  93. package/assets/esri/core/workers/chunks/0efee8d9fc5632346cb4.js +0 -1
  94. package/assets/esri/core/workers/chunks/10e715aa4ac96d7dd1b4.js +0 -1
  95. package/assets/esri/core/workers/chunks/2dfb17fa5b6a5d239942.js +0 -1
  96. package/assets/esri/core/workers/chunks/2e3962506c353b562a88.js +0 -1
  97. package/assets/esri/core/workers/chunks/7320e6d8f207399bc8f1.js +0 -1
  98. package/assets/esri/core/workers/chunks/a194f90ffe13b3d448b0.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.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Collection.js";import r from"../../../core/CollectionFlattener.js";import{destroyMaybe as s,isSome as i}from"../../../core/maybe.js";import{initial as o,when as n,watch as a}from"../../../core/reactiveUtils.js";import{property as p}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import c from"../../../rest/support/DirectionLine.js";import u from"../../../rest/support/DirectionPoint.js";import d from"../../../rest/support/PointBarrier.js";import h from"../../../rest/support/PolygonBarrier.js";import m from"../../../rest/support/PolylineBarrier.js";import y from"../../../rest/support/RouteInfo.js";import f from"../../../rest/support/Stop.js";import{LayerView3D as g}from"./LayerView3D.js";import{GraphicsProcessor as b}from"./graphics/GraphicsProcessor.js";import{toViewIfLocal as j}from"./support/projectExtentUtils.js";import{EventedSet as v}from"../support/EventedSet.js";import{UpdatePolicy as w}from"../webgl-engine/lib/UpdatePolicy.js";import I from"../../layers/LayerView.js";function S(e){return e instanceof c||e instanceof u||e instanceof d||e instanceof h||e instanceof m||e instanceof y||e instanceof f}let _=class extends(g(I)){constructor(){super(...arguments),this.type="route-3d",this.loadedGraphics=new v,this._byObjectID=new Map,this.slicePlaneEnabled=!1,this.fullExtentInLocalViewSpatialReference=null}initialize(){this._set("processor",new b({owner:this,scaleVisibilityEnabled:!0,frustumVisibilityEnabled:!0})),this.addResolvingPromise(this.processor.initializePromise),this.updatingHandles.addOnCollectionChange((()=>this._routeItems),(e=>this._routeItemsChanged(e)),o),this.addResolvingPromise(j(this).then((e=>this.fullExtentInLocalViewSpatialReference=e))),this.handles.add(n((()=>this.view?.basemapTerrain?.ready),(()=>()=>this.notifyChange("updating")),{once:!0}))}destroy(){this.handles.removeAll(),this.updatingHandles.removeAll(),this._set("processor",s(this.processor)),this._get("_routeItems")?.destroy()}get _routeItems(){return new r({getCollections:()=>[this.layer.pointBarriers,this.layer.polygonBarriers,this.layer.polylineBarriers,this.layer.stops,this.layer.directionLines,this.layer.directionPoints,i(this.layer.routeInfo)?new t([this.layer.routeInfo]):null]})}_routeItemsChanged(e){if(e.removed.length){this.loadedGraphics.removeMany(e.removed.map((e=>{const t=this._byObjectID.get(e);return this._byObjectID.delete(e),t})));for(const t of e.removed)this.handles.remove(t)}if(e.added.length){this.loadedGraphics.addMany(e.added.map((e=>{const t=e.toGraphic();return this._byObjectID.set(e,t),t})));for(const t of e.added)this.handles.add([a((()=>t.geometry),((e,r)=>{this._updateGraphic(t,"geometry",e,r)})),a((()=>t.symbol),((e,r)=>{this._updateGraphic(t,"symbol",e,r)}))],t)}}get legendEnabled(){return this.canResume()&&!this.processor?.frustumVisibilitySuspended}getSuspendInfo(){const e=super.getSuspendInfo();return e.outsideScaleRange=this.processor?.scaleVisibilitySuspended??!1,e.outsideOfView=this.processor?.frustumVisibilitySuspended??!1,e}async fetchPopupFeatures(e,t){return i(t)?t.clientGraphics:null}getHit(e){return this.processor.getHit(e)}whenGraphicBounds(e,t){return this.processor.whenGraphicBounds(e,t)}computeAttachmentOrigin(e,t){return this.processor?.computeAttachmentOrigin(e,t)}getSymbolLayerSize(e,t){return this.processor.getSymbolLayerSize(e,t)}async queryGraphics(){return new t(this.loadedGraphics.toArray())}maskOccludee(e){return this.processor.maskOccludee(e)}highlight(e){if(S(e)){const t=this._byObjectID.get(e);return this.processor.highlight(t)}return this.processor.highlight(e)}get updatePolicy(){return this.processor?.graphicsCore.effectiveUpdatePolicy||w.SYNC}canResume(){return super.canResume()&&!this.processor?.scaleVisibilitySuspended}isUpdating(){return!(!this.processor?.updating&&this.view?.basemapTerrain?.ready)}get performanceInfo(){return{displayedNumberOfFeatures:this.loadedGraphics.length,maximumNumberOfFeatures:-1,totalNumberOfFeatures:-1,nodes:0,core:null,updating:this.updating,elevationUpdating:this.processor?.elevationAlignment.updating??!1,visibilityFrustum:!this.processor?.frustumVisibilitySuspended}}_updateGraphic(e,t,r,s){const i=this._byObjectID.get(e);i[t]=r,O.graphic=i,O.property=t,O.oldValue=s,O.newValue=r,this.processor?.graphicsCore.graphicUpdateHandler(O)}};e([p()],_.prototype,"_routeItems",null),e([p()],_.prototype,"loadedGraphics",void 0),e([p({readOnly:!0})],_.prototype,"legendEnabled",null),e([p()],_.prototype,"layer",void 0),e([p({readOnly:!0})],_.prototype,"processor",void 0),e([p({type:Boolean})],_.prototype,"slicePlaneEnabled",void 0),_=e([l("esri.views.3d.layers.RouteLayerView3D")],_);const O={graphic:null,property:null,oldValue:null,newValue:null},V=_;export{V as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Collection.js";import r from"../../../core/CollectionFlattener.js";import{destroyMaybe as s,isSome as o,unwrap as i}from"../../../core/maybe.js";import{initial as n,when as a,watch as p}from"../../../core/reactiveUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import u from"../../../rest/support/DirectionLine.js";import d from"../../../rest/support/DirectionPoint.js";import h from"../../../rest/support/PointBarrier.js";import m from"../../../rest/support/PolygonBarrier.js";import y from"../../../rest/support/PolylineBarrier.js";import f from"../../../rest/support/RouteInfo.js";import g from"../../../rest/support/Stop.js";import{LayerView3D as b}from"./LayerView3D.js";import{GraphicsProcessor as j}from"./graphics/GraphicsProcessor.js";import{toViewIfLocal as v}from"./support/projectExtentUtils.js";import{EventedSet as w}from"../support/EventedSet.js";import{UpdatePolicy as I}from"../webgl-engine/lib/UpdatePolicy.js";import S from"../../layers/LayerView.js";function _(e){return e instanceof u||e instanceof d||e instanceof h||e instanceof m||e instanceof y||e instanceof f||e instanceof g}let O=class extends(b(S)){constructor(){super(...arguments),this.type="route-3d",this.loadedGraphics=new w,this._byObjectID=new Map,this.slicePlaneEnabled=!1,this.fullExtentInLocalViewSpatialReference=null}initialize(){this._set("processor",new j({owner:this,scaleVisibilityEnabled:!0,frustumVisibilityEnabled:!0})),this.addResolvingPromise(this.processor.initializePromise),this.updatingHandles.addOnCollectionChange((()=>this._routeItems),(e=>this._routeItemsChanged(e)),n),this.addResolvingPromise(v(this).then((e=>this.fullExtentInLocalViewSpatialReference=e))),this.handles.add(a((()=>this.view?.basemapTerrain?.ready),(()=>()=>this.notifyChange("updating")),{once:!0}))}destroy(){this.handles.removeAll(),this.updatingHandles.removeAll(),this._set("processor",s(this.processor)),this._get("_routeItems")?.destroy()}get _routeItems(){return new r({getCollections:()=>[this.layer.pointBarriers,this.layer.polygonBarriers,this.layer.polylineBarriers,this.layer.stops,this.layer.directionLines,this.layer.directionPoints,o(this.layer.routeInfo)?new t([this.layer.routeInfo]):null]})}_routeItemsChanged(e){if(e.removed.length){this.loadedGraphics.removeMany(e.removed.map((e=>{const t=this._byObjectID.get(e);return this._byObjectID.delete(e),t})));for(const t of e.removed)this.handles.remove(t)}if(e.added.length){this.loadedGraphics.addMany(e.added.map((e=>{const t=e.toGraphic();return this._byObjectID.set(e,t),t})));for(const t of e.added)this.handles.add([p((()=>t.geometry),((e,r)=>{this._updateGraphic(t,"geometry",e,r)})),p((()=>t.symbol),((e,r)=>{this._updateGraphic(t,"symbol",e,r)}))],t)}}get legendEnabled(){return this.canResume()&&!this.processor?.frustumVisibilitySuspended}getSuspendInfo(){const e=super.getSuspendInfo();return e.outsideScaleRange=this.processor?.scaleVisibilitySuspended??!1,e.outsideOfView=this.processor?.frustumVisibilitySuspended??!1,e}async fetchPopupFeatures(e,t){return i(t)?.clientGraphics??[]}getHit(e){return this.processor.getHit(e)}whenGraphicBounds(e,t){return this.processor.whenGraphicBounds(e,t)}computeAttachmentOrigin(e,t){return this.processor?.computeAttachmentOrigin(e,t)}getSymbolLayerSize(e,t){return this.processor.getSymbolLayerSize(e,t)}async queryGraphics(){return new t(this.loadedGraphics.toArray())}maskOccludee(e){return this.processor.maskOccludee(e)}highlight(e){return _(e)&&(e=this._byObjectID.get(e)),this.processor.highlight(e)}get updatePolicy(){return this.processor?.graphicsCore.effectiveUpdatePolicy||I.SYNC}canResume(){return super.canResume()&&!this.processor?.scaleVisibilitySuspended}isUpdating(){return!(!this.processor?.updating&&this.view?.basemapTerrain?.ready)}get performanceInfo(){return{displayedNumberOfFeatures:this.loadedGraphics.length,maximumNumberOfFeatures:-1,totalNumberOfFeatures:-1,nodes:0,core:null,updating:this.updating,elevationUpdating:this.processor?.elevationAlignment.updating??!1,visibilityFrustum:!this.processor?.frustumVisibilitySuspended}}_updateGraphic(e,t,r,s){const o=this._byObjectID.get(e);o[t]=r,V.graphic=o,V.property=t,V.oldValue=s,V.newValue=r,this.processor?.graphicsCore.graphicUpdateHandler(V)}};e([l()],O.prototype,"_routeItems",null),e([l()],O.prototype,"loadedGraphics",void 0),e([l({readOnly:!0})],O.prototype,"legendEnabled",null),e([l()],O.prototype,"layer",void 0),e([l({readOnly:!0})],O.prototype,"processor",void 0),e([l({type:Boolean})],O.prototype,"slicePlaneEnabled",void 0),O=e([c("esri.views.3d.layers.RouteLayerView3D")],O);const V={graphic:null,property:null,oldValue:null,newValue:null},G=O;export{G as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import{binaryIndexOf as r}from"../../../core/arrayUtils.js";import i from"../../../core/Logger.js";import{destroyMaybe as s,isNone as o,isSome as a,unwrap as n}from"../../../core/maybe.js";import{initial as d,watch as l}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{s as c}from"../../../chunks/vec3.js";import{c as p}from"../../../chunks/vec3f64.js";import{projectBuffer as g,projectVectorToVector as m}from"../../../geometry/projection.js";import{extentContainsCoords3D as f}from"../../../geometry/support/contains.js";import{getGeometryZScaler as y}from"../../../geometry/support/zscale.js";import{fallbackObjectIDAttribute as _}from"../../../layers/LayerConstants.js";import{makeDehydratedPoint as b,estimateSize as v}from"../../../layers/graphics/dehydratedFeatures.js";import{hydrateGraphic as x}from"../../../layers/graphics/hydratedFeatures.js";import E from"../../../layers/graphics/controllers/I3SOnDemandController.js";import I from"../../../layers/support/FeatureFilter.js";import w from"../../../rest/support/Query.js";import{I3SPointsWorkerHandle as N}from"./I3SPointsWorkerHandle.js";import{LayerView3D as C}from"./LayerView3D.js";import D from"./graphics/Graphics3DFeatureProcessor.js";import{QueryEngine as O}from"./graphics/QueryEngine.js";import{createInteractiveEditSession as F,processAttributeEdits as j}from"./i3s/attributeEditing.js";import{I3SGraphicsMap as S}from"./i3s/I3SGraphicsMap.js";import{I3SOverrides as G}from"./i3s/I3SOverrides.js";import{checkSpatialReferences as A,containsDraco as L,whenGraphicAttributes as P,getCachedAttributeValue as V}from"./i3s/I3SUtil.js";import{DefinitionExpressionSceneLayerView as M}from"./support/DefinitionExpressionSceneLayerView.js";import{defineFieldProperties as R}from"./support/fieldProperties.js";import{PopupSceneLayerView as H}from"./support/PopupSceneLayerView.js";import{SceneLayerViewRequiredFields as U}from"./support/SceneLayerViewRequiredFields.js";import q from"../support/debugFlags.js";import{compute as Q}from"../support/orientedBoundingBox.js";import{updatingProgress as T}from"../support/updatingProperties.js";import{Attribute as B}from"../webgl-engine/lib/Attribute.js";import{newDoubleArray as k}from"../webgl-engine/lib/DoubleArray.js";import{UpdatePolicy as z}from"../webgl-engine/lib/UpdatePolicy.js";import Z from"../../layers/SceneLayerView.js";import{TaskPriority as W}from"../../support/Scheduler.js";const K=R();let Y=class extends(M(H(C(Z)))){constructor(){super(...arguments),this.type="scene-layer-graphics-3d",this._queryEngine=null,this._memCache=null,this._interactiveEditingSessions=new Map,this.loadedGraphics=new S(((e,t,r)=>ee(e,t,r)),(e=>this.processor.graphicsCore.recreateGraphics(e))),this.holeFilling="always",this.progressiveLoadFactor=1,this.supportsHeightUnitConversion=!0,this._coordinatesOutsideExtentErrors=0,this._maxCoordinatesOutsideExtentErrors=20}initialize(){const e=this.layer;this.addResolvingPromise(e.indexInfo),this._i3sOverrides=new G({view:this.view,layer:this.layer,memoryController:this.view.resourceController?.memoryController}),A(e,this.view.spatialReference,this.view.viewingMode),this._fieldsHelper=new U({layerView:this}),this.updatingHandles.add((()=>this.layer.rangeInfos),(e=>this._rangeInfosChanged(e)),d),this.updatingHandles.add((()=>e.renderer),((e,t)=>this._rendererChange(e,t))),this.updatingHandles.add((()=>[this.parsedDefinitionExpression,this._excludeObjectIdsSorted]),(()=>this._filterChange())),this.handles.add(l((()=>q.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&&q.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||!this._treeDebugger||q.I3S_TREE_SHOW_TILES||(this._treeDebugger.destroy(),this._treeDebugger=null)}),d)),this._set("processor",new D({owner:this,preferredUpdatePolicy:z.ASYNC,scaleVisibilityEnabled:!0,filterVisibilityEnabled:!0,timeExtentEnabled:!1,frustumVisibilityEnabled:!1,elevationAlignmentEnabled:!0,elevationFeatureExpressionEnabled:!1,setUidToIdOnAdd:!1,dataExtent:e.fullExtent,updateClippingExtent:e=>this._updateClippingExtent(e)})),this.processor.elevationAlignment?.events.on("invalidate-elevation",(e=>this._controller.updateElevationChanged(e.extent,e.spatialReference))),this.supportsHeightUnitConversion&&(this._verticalScale=y("point",e.spatialReference,this.view.spatialReference)),this.addResolvingPromise(this.processor.initializePromise),this._memCache=this.view.resourceController.memoryController.newCache(e.uid),this._controller=new E({layerView:this,scaleVisibilityEnabled:!1}),L(this.layer.geometryDefinitions)&&(this._worker=new N((e=>this.view.resourceController.immediate.schedule(e)))),this.handles.add(this.layer.on("apply-edits",(e=>this.updatingHandles.addPromise(e.result)))),this.handles.add(this.layer.on("edits",(e=>this._handleEdits(e)))),this.when((()=>{this._setupQueryEngine(),this.updatingHandles.add((()=>this.maximumNumberOfFeatures),(e=>this._controller.featureTarget=e),d),this.updatingHandles.add((()=>this.suspended),(e=>{e&&this._removeAllNodeData()}))}))}destroy(){this._treeDebugger=s(this._treeDebugger),this._i3sOverrides=s(this._i3sOverrides),this._set("processor",s(this.processor)),this._controller=s(this._controller),this._queryEngine=s(this._queryEngine),this._worker=s(this._worker),this._memCache=s(this._memCache),this.loadedGraphics.clear(),this._fieldsHelper=s(this._fieldsHelper)}get i3slayer(){return this.layer}get updatingProgressValue(){return this._controller?.updatingProgress??1}get requiredFields(){return this._fieldsHelper?.requiredFields??[]}get maximumNumberOfFeatures(){const e=this.processor?.graphicsCore?.displayFeatureLimit;return e?.maximumNumberOfFeatures??0}set maximumNumberOfFeatures(e){null!=e?(this._override("maximumNumberOfFeatures",e),this._controller.fixedFeatureTarget=!0):(this._clearOverride("maximumNumberOfFeatures"),this._controller.fixedFeatureTarget=!1)}get maximumNumberOfFeaturesExceeded(){return!this.suspended&&(!!this._controller?.useMaximumNumberOfFeatures&&!this._controller.leavesReached)}get _excludeObjectIdsSorted(){const e=this.layer.excludeObjectIds;return e.length?e.toArray().sort(((e,t)=>e-t)):null}get lodFactor(){return"Labels"===this.layer.semantic?1:this.view.qualitySettings.sceneService.point.lodFactor}get hasM(){return!1}get hasZ(){return!0}async whenGraphicAttributes(e,t){return P(this.layer,e,this._getObjectIdField(),t,(()=>[...this.loadedGraphics.nodes()]))}getHit(e){if(!this.loadedGraphics)return null;const t=x(this.loadedGraphics.find((t=>t.uid===e)),this.layer),r=this._getObjectIdField();return t&&t.attributes&&t.attributes[r]?(t.layer=this.layer,t.sourceLayer=this.layer,{type:"graphic",graphic:t,layer:t.layer}):null}whenGraphicBounds(e,t){return this.processor.whenGraphicBounds(e,t)}computeAttachmentOrigin(e,t){return this.processor.computeAttachmentOrigin(e,t)}canResume(){return super.canResume()&&(!this._controller||this._controller.rootNodeVisible)}isUpdating(){return!!(this._controller?.updating||this.processor?.updating||this._fieldsHelper?.updating||this.layerFilterUpdating)}highlight(e){return this.processor.highlight(e,this.layer.objectIdField)}get updatePolicy(){return this.processor.graphicsCore.effectiveUpdatePolicy}createInteractiveEditSession(e){return F(this._attributeEditingContext,e)}async _decompressBinaryPointData(e,t){const r={geometryBuffer:e.geometryBuffer};o(this._worker)&&(this._worker=new N((e=>this.view.resourceController.immediate.schedule(e))));const i=await this._worker.invoke(r,t);if(o(i))throw new Error("Failed to decompress Draco point data");return{positionData:i.positions,featureIds:i.featureIds}}async addNode(e,t,r){if(!X(t)&&!J(t))throw new Error;if(this.loadedGraphics.hasNode(e.index))return void i.getLogger(this.declaredClass).error("I3S node "+e.id+" already added");const s=a(this.layer.fullExtent)?re(this.layer.fullExtent.clone(),.5):null,o=[],{featureIds:n,pointPositions:d}=X(t)?await this._extractBinaryPointPositions(e,t,r):this._extractLegacyPointPositions(t);this._validatePositions(e,n,d,s,o);const l=this._controller.crsVertex,h=this.view.spatialReference;g(d,l,0,d,h,0,n.length);const u=X(t)?e.level:0,c={graphics:this._createGraphics(n,d,e.index,u),featureIds:n,attributeInfo:t.attributeDataInfo,node:e};if(await this._i3sOverrides.apply(c.featureIds,t.attributeDataInfo,r),e.numFeatures=c.graphics.length,this._updateNodeMemory(e),te(c),o.length>0&&(this._computeObb(e,o,l),this._controller.updateVisibility(e.index)),!this._controller.isGeometryVisible(e))return void this._cacheNodeData(c);if(a(this._verticalScale))for(const i of c.graphics)this._verticalScale(i.geometry);const p=this.view._stage.renderView.objectAndLayerIdRenderHelper;if(a(p))for(let i=0;i<c.featureIds.length;i++){const e=c.featureIds[i];p.setUidToObjectAndLayerId(e,c.graphics[i].uid,this.layer.id,this.layer.uid,this.layer.popupEnabled,c.node.resources.attributes,i)}this.loadedGraphics.addNode(e.index,c),this._controller.updateLoadStatus(e.index,!0),this._filterNode(c),this._treeDebugger&&this._treeDebugger.update()}_computeObb(e,t,r){const i=this._controller.crsIndex,s=i.isGeographic?this.view.renderSpatialReference:i;g(t,r,0,t,s,0,t.length/3),e.serviceObb=Q(new B(t,3)),i.isGeographic&&m(e.serviceObb.center,s,e.serviceObb.center,i)}isNodeLoaded(e){return this.loadedGraphics.hasNode(e)}isNodeReloading(){return!1}updateNodeState(){}async _extractBinaryPointPositions(e,t,r){const i=await this._decompressBinaryPointData(t,r),s=i.positionData,o=3,n=s.length/o,d=k(3*n),l=a(e.serviceObb)?e.serviceObb.center:[0,0,0],h=Math.abs(l[2])*2**-20;for(let a=0;a<n;a++){const e=a*o;d[e+0]=s[e+0]+l[0],d[e+1]=s[e+1]+l[1],d[e+2]=s[e+2]+l[2],Math.abs(d[e+2])<h&&(d[e+2]=0)}return{featureIds:Array.from(i.featureIds),pointPositions:d}}_extractLegacyPointPositions(e){const t=e.pointData.length,r=k(3*t),i=new Array;for(let s=0;s<t;s++){const t=e.pointData[s],o=t.featureDataPosition,a=o.length,n=t.geometries?.[0]??ie[a],d=t.featureIds[0];if("Embedded"!==n.type||"points"!==n.params.type||a<2||a>3)continue;const l=n.params.vertexAttributes?.position??[0,0,0],h=3*i.length;r[h+0]=o[0]+l[0],r[h+1]=o[1]+l[1],r[h+2]=3===a?o[2]+l[2]:NaN,i.push(d)}return{featureIds:i,pointPositions:r}}_validatePositions(e,t,r,s,n){if(o(s)&&e.serviceObb)return;const d=t.length,l=3;for(let o=0;o<d;o++){const t=o*l;c(se,r[t],r[t+1],r[t+2]),a(s)&&!f(s,se)&&(this._coordinatesOutsideExtentErrors<this._maxCoordinatesOutsideExtentErrors&&i.getLogger(this.declaredClass).error("Service Error: Coordinates outside of layer extent"),this._coordinatesOutsideExtentErrors+1===this._maxCoordinatesOutsideExtentErrors&&i.getLogger(this.declaredClass).error("Maximum number of errors reached. Further errors are ignored."),this._coordinatesOutsideExtentErrors++),e.serviceObb||n.push(se[0],se[1],se[2])}}_createGraphics(e,r,i,s){const o=e.length,d=3,l=this._getObjectIdField(),h=this.processor.graphicsCore,u=new Array,c=this.view.spatialReference;for(let p=0;p<o;p++){const o=e[p],g={};null!=o&&(g[l]=o);const m=o??t.generateUID(),f=p*d,y=isNaN(r[f+2])?void 0:r[f+2],_=b(r[f],r[f+1],y,c),v=this.loadedGraphics.get(m);if(a(v))(null==v.level||v.level<s)&&(oe.property="geometry",oe.graphic=v,oe.oldValue=n(v.geometry),oe.newValue=_,v.geometry=_,v.level=s,h.graphicUpdateHandler(oe)),u.push(v);else{const e=t.generateUID();u.push({objectId:m,uid:e,geometry:_,attributes:g,visible:!0,nodeIndex:i,level:s})}}return u}_updateNodeMemory(e){e.memory=4096+(a(e.numFeatures)?e.numFeatures*this.processor.graphicsCore.usedMemoryPerGraphic:0)}_cacheNodeData(e){const t=e.graphics.reduce(((e,t)=>v(t)+e),512+8*e.featureIds.length+1024);this._memCache.put(this._getMemCacheKey(e.node),e,t)}_getMemCacheKey(e){return`${e.index}`}_removeAllNodeData(){this.loadedGraphics.forEachNode(((e,t)=>{if(e){const t=e.node;this._updateNodeMemory(t),this._cacheNodeData(e)}this._controller.updateLoadStatus(t,!1)})),this._treeDebugger&&this._treeDebugger.update(),this.loadedGraphics.clear()}removeNode(e){const t=this._removeNodeStageData(e);t&&(this._updateNodeMemory(t.node),this._cacheNodeData(t))}_removeNodeStageData(e){const t=this.loadedGraphics.getNode(e);return o(t)?null:(this._controller.updateLoadStatus(e,!1),this.loadedGraphics.removeNode(e),this._treeDebugger&&this._treeDebugger.update(),t)}async loadCachedNodeData(e){return this._memCache?.pop(this._getMemCacheKey(e))}async addCachedNodeData(e,t,r,s){this.loadedGraphics.hasNode(e.index)?i.getLogger(this.declaredClass).error("I3S node "+e.id+" already added"):(await this._i3sOverrides.apply(t.featureIds,r,s),this.loadedGraphics.addNode(e.index,t),this._controller.updateLoadStatus(e.index,!0),this._updateNodeMemory(e),t.attributeInfo=r,this._attributeValuesChanged(t),this._filterNode(t),this._treeDebugger&&this._treeDebugger.update())}getLoadedNodeIds(){const e=[];return this.loadedGraphics.forEachNode((t=>e.push(t.node.id))),e.sort()}getVisibleNodes(){const e=new Array;return this.loadedGraphics.forEachNode((t=>e.push(t.node))),e}getLoadedNodeIndices(e){this.loadedGraphics.forEachNode(((t,r)=>e.push(r)))}getLoadedAttributes(e){const t=this.loadedGraphics.getNode(e);if(a(t)&&a(t.attributeInfo))return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this.loadedGraphics.getNode(e);if(a(t)&&a(t.attributeInfo))return t.attributeInfo.attributeData}_setAttributeData(e,t){const r=this.loadedGraphics.getNode(e);o(r)||o(r.attributeInfo)||(r.attributeInfo.attributeData=t,this._attributeValuesChanged(r))}async updateAttributes(e,t,r){const i=this.loadedGraphics.getNode(e);o(i)||(await this._i3sOverrides.apply(i.featureIds,t,r),i.attributeInfo=t,this._attributeValuesChanged(i))}_attributeValuesChanged(e){if(te(e),this._filterNode(e),this.processor.graphicsCore.labelsEnabled){const t=e.graphics.map((e=>e.uid));this.processor.graphicsCore.updateLabelingInfo(t)}}_updateClippingExtent(e){return this._controller&&this._controller.updateClippingArea(e),!1}_getObjectIdField(){return this.layer.objectIdField||_}async _rendererChange(e,t){const{layer:{fieldsIndex:r}}=this,i=new Set;let s,o;e?(await e.collectRequiredFields(i,r),s=Array.from(i).sort()):s=[],i.clear(),t?(await t.collectRequiredFields(i,r),o=Array.from(i).sort()):o=[],s.length===o.length&&s.every(((e,t)=>s[t]===o[t]))||this._reloadAllNodes()}_rangeInfosChanged(e){null!=e&&e.length>0&&i.getLogger(this.declaredClass).warn("Unsupported property: rangeInfos are currently only serialized to and from web scenes but do not affect rendering.")}_filterChange(){this.loadedGraphics.forEachNode((e=>this._filterNode(e)))}_reloadAllNodes(){this._removeAllNodeData(),this._controller&&this._controller.restartNodeLoading()}_filterNode(e){const t=this.parsedDefinitionExpression,i=this._excludeObjectIdsSorted,s=this._getObjectIdField();for(const a of e.graphics){const e=a.visible,n=!t||this._evaluateClause(t,a),d=o(i)||r(i,a.attributes[s])<0;a.visible=n&&d,e!==a.visible&&(oe.graphic=a,oe.property="visible",oe.oldValue=e,oe.newValue=a.visible,this.processor.graphicsCore.graphicUpdateHandler(oe))}}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference};return a(this.filter)?this.filter.createQuery(e):new w(e)}queryFeatures(e,t){return this._queryEngine.executeQuery(this._ensureQuery(e),t?.signal)}queryObjectIds(e,t){return this._queryEngine.executeQueryForIds(this._ensureQuery(e),t?.signal)}queryFeatureCount(e,t){return this._queryEngine.executeQueryForCount(this._ensureQuery(e),t?.signal)}queryExtent(e,t){return this._queryEngine.executeQueryForExtent(this._ensureQuery(e),t?.signal)}_ensureQuery(e){return this._addDefinitionExpressionToQuery(o(e)?this.createQuery():w.from(e))}_setupQueryEngine(){const e=()=>this.processor.featureStore;this._queryEngine=new O({context:{spatialReference:this.view.spatialReference,layer:this.layer,scheduler:this.view.resourceController.scheduler,get featureStore(){return e()},hasZ:this.hasZ,hasM:this.hasM},priority:W.FEATURE_QUERY_ENGINE})}getUsedMemory(){return this.processor?.graphicsCore?.usedMemory??0}getUnloadedMemory(){return.8*((this._controller?.unloadedMemoryEstimate??0)+(this.processor?.graphicsCore?.unprocessedMemoryEstimate??0))}ignoresMemoryFactor(){return this._controller&&this._controller.fixedFeatureTarget}_handleEdits(e){j(this._attributeEditingContext,e)}get _attributeEditingContext(){const e=this._getObjectIdField();return{sessions:this._interactiveEditingSessions,fieldsIndex:this.layer.fieldsIndex,objectIdField:e,forEachNode:e=>this.loadedGraphics.forEachNode((t=>e(t.node,t.featureIds))),attributeStorageInfo:this.i3slayer.attributeStorageInfo,i3sOverrides:this._i3sOverrides,getAttributeData:e=>this.getAttributeData(e),setAttributeData:(t,r,i)=>{this._setAttributeData(t,r);const s=this.loadedGraphics.getNode(t);if(a(i)){const t=this.loadedGraphics.get(i.attributes[e]);a(t)&&this.processor.graphicsCore.recreateGraphics([t])}else a(s)&&this.processor.graphicsCore.recreateGraphics(s.graphics)},clearMemCache:()=>{}}}get performanceInfo(){const e={displayedNumberOfFeatures:this.loadedGraphics.length,maximumNumberOfFeatures:this.maximumNumberOfFeatures,totalNumberOfFeatures:-1,nodes:this.loadedGraphics.nodeCount,core:this.processor.graphicsCore.performanceInfo};return this._controller&&this._controller.updateStats(e),e}get test(){return{controller:this._controller,numNodes:this.loadedGraphics.nodeCount,loadedGraphics:this.loadedGraphics}}};e([h()],Y.prototype,"processor",void 0),e([h({type:I})],Y.prototype,"filter",void 0),e([h()],Y.prototype,"loadedGraphics",void 0),e([h()],Y.prototype,"i3slayer",null),e([h()],Y.prototype,"_controller",void 0),e([h()],Y.prototype,"updating",void 0),e([h()],Y.prototype,"suspended",void 0),e([h()],Y.prototype,"holeFilling",void 0),e([h(T)],Y.prototype,"updatingProgress",void 0),e([h()],Y.prototype,"updatingProgressValue",null),e([h(K.requiredFields)],Y.prototype,"requiredFields",null),e([h(K.availableFields)],Y.prototype,"availableFields",void 0),e([h()],Y.prototype,"_fieldsHelper",void 0),e([h({type:Number})],Y.prototype,"maximumNumberOfFeatures",null),e([h({readOnly:!0})],Y.prototype,"maximumNumberOfFeaturesExceeded",null),e([h()],Y.prototype,"_excludeObjectIdsSorted",null),e([h({readOnly:!0})],Y.prototype,"lodFactor",null),e([h({readOnly:!0})],Y.prototype,"hasM",null),e([h({readOnly:!0})],Y.prototype,"hasZ",null),Y=e([u("esri.views.3d.layers.SceneLayerGraphicsView3D")],Y);const $=Y;function J(e){return"pointData"in e}function X(e){return"geometryBuffer"in e&&null!==e.geometryBuffer}function ee(e,t,r){const i=t.attributeInfo;if(o(i)||o(i.loadedAttributes)||o(i.attributeData))return!1;let s=!1;for(const{name:o}of i.loadedAttributes)if(i.attributeData[o]){const t=V(i.attributeData[o],r);t!==e.attributes[o]&&(e.attributes[o]=t,s=!0)}return s}function te(e){const t=e.attributeInfo,r=e.node.index;if(!(o(t)||o(t.loadedAttributes)||o(t.attributeData)))for(let i=0;i<e.graphics.length;i++){const s=e.graphics[i];if(s.nodeIndex===r){s.attributes||(s.attributes={});for(const{name:e}of t.loadedAttributes)t.attributeData[e]&&(s.attributes[e]=V(t.attributeData[e],i))}}}function re(e,t){return e.xmin-=t,e.ymin-=t,e.xmax+=t,e.ymax+=t,e.hasZ&&(e.zmin-=t,e.zmax+=t),e.hasM&&(e.mmin-=t,e.mmax+=t),e}const ie={2:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0]}}},3:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0,0]}}}},se=p(),oe={graphic:null,property:null,oldValue:null,newValue:null};export{$ as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import{binaryIndexOf as r}from"../../../core/arrayUtils.js";import i from"../../../core/Logger.js";import{destroyMaybe as s,isNone as o,isSome as a,unwrap as n}from"../../../core/maybe.js";import{initial as d,watch as l}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{s as c}from"../../../chunks/vec3.js";import{c as p}from"../../../chunks/vec3f64.js";import{projectBuffer as g,projectVectorToVector as m}from"../../../geometry/projection.js";import{extentContainsCoords3D as f}from"../../../geometry/support/contains.js";import{getGeometryZScaler as y}from"../../../geometry/support/zscale.js";import{fallbackObjectIDAttribute as _}from"../../../layers/LayerConstants.js";import{makeDehydratedPoint as b,estimateSize as v}from"../../../layers/graphics/dehydratedFeatures.js";import{hydrateGraphic as x}from"../../../layers/graphics/hydratedFeatures.js";import E from"../../../layers/graphics/controllers/I3SOnDemandController.js";import I from"../../../layers/support/FeatureFilter.js";import w from"../../../rest/support/Query.js";import{I3SPointsWorkerHandle as N}from"./I3SPointsWorkerHandle.js";import{LayerView3D as C}from"./LayerView3D.js";import D from"./graphics/Graphics3DFeatureProcessor.js";import{QueryEngine as O}from"./graphics/QueryEngine.js";import{createInteractiveEditSession as F,processAttributeEdits as j}from"./i3s/attributeEditing.js";import{I3SGraphicsMap as S}from"./i3s/I3SGraphicsMap.js";import{I3SOverrides as G}from"./i3s/I3SOverrides.js";import{checkSpatialReferences as A,containsDraco as L,whenGraphicAttributes as P,getCachedAttributeValue as V}from"./i3s/I3SUtil.js";import{DefinitionExpressionSceneLayerView as M}from"./support/DefinitionExpressionSceneLayerView.js";import{defineFieldProperties as R}from"./support/fieldProperties.js";import{PopupSceneLayerView as H}from"./support/PopupSceneLayerView.js";import{SceneLayerViewRequiredFields as U}from"./support/SceneLayerViewRequiredFields.js";import q from"../support/debugFlags.js";import{compute as Q}from"../support/orientedBoundingBox.js";import{updatingProgress as T}from"../support/updatingProperties.js";import{Attribute as B}from"../webgl-engine/lib/Attribute.js";import{newDoubleArray as k}from"../webgl-engine/lib/DoubleArray.js";import{UpdatePolicy as z}from"../webgl-engine/lib/UpdatePolicy.js";import W from"../../layers/SceneLayerView.js";import{TaskPriority as Z}from"../../support/Scheduler.js";const K=R();let Y=class extends(M(H(C(W)))){constructor(){super(...arguments),this.type="scene-layer-graphics-3d",this._queryEngine=null,this._memCache=null,this._interactiveEditingSessions=new Map,this.loadedGraphics=new S(((e,t,r)=>ee(e,t,r)),(e=>this.processor.graphicsCore.recreateGraphics(e))),this.holeFilling="always",this.progressiveLoadFactor=1,this.supportsHeightUnitConversion=!0,this._coordinatesOutsideExtentErrors=0,this._maxCoordinatesOutsideExtentErrors=20}initialize(){const e=this.layer;this.addResolvingPromise(e.indexInfo),this._i3sOverrides=new G({view:this.view,layer:this.layer,memoryController:this.view.resourceController?.memoryController}),A(e,this.view.spatialReference,this.view.viewingMode),this._fieldsHelper=new U({layerView:this}),this.updatingHandles.add((()=>this.layer.rangeInfos),(e=>this._rangeInfosChanged(e)),d),this.updatingHandles.add((()=>e.renderer),((e,t)=>this._rendererChange(e,t))),this.updatingHandles.add((()=>[this.parsedDefinitionExpression,this._excludeObjectIdsSorted]),(()=>this._filterChange())),this.handles.add(l((()=>q.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&&q.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||!this._treeDebugger||q.I3S_TREE_SHOW_TILES||(this._treeDebugger.destroy(),this._treeDebugger=null)}),d)),this._set("processor",new D({owner:this,preferredUpdatePolicy:z.ASYNC,scaleVisibilityEnabled:!0,filterVisibilityEnabled:!0,timeExtentEnabled:!1,frustumVisibilityEnabled:!1,elevationAlignmentEnabled:!0,elevationFeatureExpressionEnabled:!1,setUidToIdOnAdd:!1,dataExtent:e.fullExtent,updateClippingExtent:e=>this._updateClippingExtent(e)})),this.processor.elevationAlignment?.events.on("invalidate-elevation",(e=>this._controller.updateElevationChanged(e.extent,e.spatialReference))),this.supportsHeightUnitConversion&&(this._verticalScale=y("point",e.spatialReference,this.view.spatialReference)),this.addResolvingPromise(this.processor.initializePromise),this._memCache=this.view.resourceController.memoryController.newCache(e.uid),this._controller=new E({layerView:this,scaleVisibilityEnabled:!1}),L(this.layer.geometryDefinitions)&&(this._worker=new N((e=>this.view.resourceController.immediate.schedule(e)))),this.handles.add(this.layer.on("apply-edits",(e=>this.updatingHandles.addPromise(e.result)))),this.handles.add(this.layer.on("edits",(e=>this._handleEdits(e)))),this.when((()=>{this._setupQueryEngine(),this.updatingHandles.add((()=>this.maximumNumberOfFeatures),(e=>this._controller.featureTarget=e),d),this.updatingHandles.add((()=>this.suspended),(e=>{e&&this._removeAllNodeData()}))}))}destroy(){this._treeDebugger=s(this._treeDebugger),this._i3sOverrides=s(this._i3sOverrides),this._set("processor",s(this.processor)),this._controller=s(this._controller),this._queryEngine=s(this._queryEngine),this._worker=s(this._worker),this._memCache=s(this._memCache),this.loadedGraphics.clear(),this._fieldsHelper=s(this._fieldsHelper)}get i3slayer(){return this.layer}get updatingProgressValue(){return this._controller?.updatingProgress??1}get requiredFields(){return this._fieldsHelper?.requiredFields??[]}get maximumNumberOfFeatures(){const e=this.processor?.graphicsCore?.displayFeatureLimit;return e?.maximumNumberOfFeatures??0}set maximumNumberOfFeatures(e){null!=e?(this._override("maximumNumberOfFeatures",e),this._controller.fixedFeatureTarget=!0):(this._clearOverride("maximumNumberOfFeatures"),this._controller.fixedFeatureTarget=!1)}get maximumNumberOfFeaturesExceeded(){return!this.suspended&&(!!this._controller?.useMaximumNumberOfFeatures&&!this._controller.leavesReached)}get _excludeObjectIdsSorted(){const e=this.layer.excludeObjectIds;return e.length?e.toArray().sort(((e,t)=>e-t)):null}get lodFactor(){return"Labels"===this.layer.semantic?1:this.view.qualitySettings.sceneService.point.lodFactor}get hasM(){return!1}get hasZ(){return!0}async whenGraphicAttributes(e,t){return P(this.layer,e,this._getObjectIdField(),t,(()=>[...this.loadedGraphics.nodes()]))}getHit(e){if(!this.loadedGraphics)return null;const t=x(this.loadedGraphics.find((t=>t.uid===e)),this.layer),r=this._getObjectIdField();return t&&t.attributes&&t.attributes[r]?(t.layer=this.layer,t.sourceLayer=this.layer,{type:"graphic",graphic:t,layer:t.layer}):null}whenGraphicBounds(e,t){return this.processor.whenGraphicBounds(e,t)}computeAttachmentOrigin(e,t){return this.processor.computeAttachmentOrigin(e,t)}canResume(){return super.canResume()&&(!this._controller||this._controller.rootNodeVisible)}isUpdating(){return!!(this._controller?.updating||this.processor?.updating||this._fieldsHelper?.updating||this.layerFilterUpdating)}highlight(e){return this.processor.highlight(e,this.layer.objectIdField)}get updatePolicy(){return this.processor.graphicsCore.effectiveUpdatePolicy}createInteractiveEditSession(e){return F(this._attributeEditingContext,e)}async _decompressBinaryPointData(e,t){const r={geometryBuffer:e.geometryBuffer};o(this._worker)&&(this._worker=new N((e=>this.view.resourceController.immediate.schedule(e))));const i=await this._worker.invoke(r,t);if(o(i))throw new Error("Failed to decompress Draco point data");return{positionData:i.positions,featureIds:i.featureIds}}async addNode(e,t,r){if(!X(t)&&!J(t))throw new Error;if(this.loadedGraphics.hasNode(e.index))return void i.getLogger(this.declaredClass).error("I3S node "+e.id+" already added");const s=a(this.layer.fullExtent)?re(this.layer.fullExtent.clone(),.5):null,o=[],{featureIds:n,pointPositions:d}=X(t)?await this._extractBinaryPointPositions(e,t,r):this._extractLegacyPointPositions(t);this._validatePositions(e,n,d,s,o);const l=this._controller.crsVertex,h=this.view.spatialReference;g(d,l,0,d,h,0,n.length);const u=X(t)?e.level:0,c={graphics:this._createGraphics(n,d,e.index,u),featureIds:n,attributeInfo:t.attributeDataInfo,node:e};if(await this._i3sOverrides.apply(c.featureIds,t.attributeDataInfo,r),e.numFeatures=c.graphics.length,this._updateNodeMemory(e),te(c),o.length>0&&(this._computeObb(e,o,l),this._controller.updateVisibility(e.index)),!this._controller.isGeometryVisible(e))return void this._cacheNodeData(c);if(a(this._verticalScale))for(const i of c.graphics)this._verticalScale(i.geometry);const p=this.view._stage.renderView.objectAndLayerIdRenderHelper;if(a(p))for(let i=0;i<c.featureIds.length;i++){const e=c.featureIds[i];p.setUidToObjectAndLayerId(e,c.graphics[i].uid,this.layer.id,this.layer.uid,this.layer.popupEnabled,c.node.resources.attributes,i)}this.loadedGraphics.addNode(e.index,c),this._controller.updateLoadStatus(e.index,!0),this._filterNode(c),this._treeDebugger&&this._treeDebugger.update()}_computeObb(e,t,r){const i=this._controller.crsIndex,s=i.isGeographic?this.view.renderSpatialReference:i;g(t,r,0,t,s,0,t.length/3),e.serviceObb=Q(new B(t,3)),i.isGeographic&&m(e.serviceObb.center,s,e.serviceObb.center,i)}isNodeLoaded(e){return this.loadedGraphics.hasNode(e)}isNodeReloading(){return!1}updateNodeState(){}async _extractBinaryPointPositions(e,t,r){const i=await this._decompressBinaryPointData(t,r),s=i.positionData,o=3,n=s.length/o,d=k(3*n),l=a(e.serviceObb)?e.serviceObb.center:[0,0,0],h=Math.abs(l[2])*2**-20;for(let a=0;a<n;a++){const e=a*o;d[e+0]=s[e+0]+l[0],d[e+1]=s[e+1]+l[1],d[e+2]=s[e+2]+l[2],Math.abs(d[e+2])<h&&(d[e+2]=0)}return{featureIds:i.featureIds?Array.from(i.featureIds):[],pointPositions:d}}_extractLegacyPointPositions(e){const t=e.pointData.length,r=k(3*t),i=new Array;for(let s=0;s<t;s++){const t=e.pointData[s],o=t.featureDataPosition,a=o.length,n=t.geometries?.[0]??ie[a],d=t.featureIds[0];if("Embedded"!==n.type||"points"!==n.params.type||a<2||a>3)continue;const l=n.params.vertexAttributes?.position??[0,0,0],h=3*i.length;r[h+0]=o[0]+l[0],r[h+1]=o[1]+l[1],r[h+2]=3===a?o[2]+l[2]:NaN,i.push(d)}return{featureIds:i,pointPositions:r}}_validatePositions(e,t,r,s,n){if(o(s)&&e.serviceObb)return;const d=t.length,l=3;for(let o=0;o<d;o++){const t=o*l;c(se,r[t],r[t+1],r[t+2]),a(s)&&!f(s,se)&&(this._coordinatesOutsideExtentErrors<this._maxCoordinatesOutsideExtentErrors&&i.getLogger(this.declaredClass).error("Service Error: Coordinates outside of layer extent"),this._coordinatesOutsideExtentErrors+1===this._maxCoordinatesOutsideExtentErrors&&i.getLogger(this.declaredClass).error("Maximum number of errors reached. Further errors are ignored."),this._coordinatesOutsideExtentErrors++),e.serviceObb||n.push(se[0],se[1],se[2])}}_createGraphics(e,r,i,s){const o=e.length,d=3,l=this._getObjectIdField(),h=this.processor.graphicsCore,u=new Array,c=this.view.spatialReference;for(let p=0;p<o;p++){const o=e[p],g={};null!=o&&(g[l]=o);const m=o??t.generateUID(),f=p*d,y=isNaN(r[f+2])?void 0:r[f+2],_=b(r[f],r[f+1],y,c),v=this.loadedGraphics.get(m);if(a(v))(null==v.level||v.level<s)&&(oe.property="geometry",oe.graphic=v,oe.oldValue=n(v.geometry),oe.newValue=_,v.geometry=_,v.level=s,h.graphicUpdateHandler(oe)),u.push(v);else{const e=t.generateUID();u.push({objectId:m,uid:e,geometry:_,attributes:g,visible:!0,nodeIndex:i,level:s})}}return u}_updateNodeMemory(e){e.memory=4096+(a(e.numFeatures)?e.numFeatures*this.processor.graphicsCore.usedMemoryPerGraphic:0)}_cacheNodeData(e){const t=e.graphics.reduce(((e,t)=>v(t)+e),512+8*e.featureIds.length+1024);this._memCache.put(this._getMemCacheKey(e.node),e,t)}_getMemCacheKey(e){return`${e.index}`}_removeAllNodeData(){this.loadedGraphics.forEachNode(((e,t)=>{if(e){const t=e.node;this._updateNodeMemory(t),this._cacheNodeData(e)}this._controller.updateLoadStatus(t,!1)})),this._treeDebugger&&this._treeDebugger.update(),this.loadedGraphics.clear()}removeNode(e){const t=this._removeNodeStageData(e);t&&(this._updateNodeMemory(t.node),this._cacheNodeData(t))}_removeNodeStageData(e){const t=this.loadedGraphics.getNode(e);return o(t)?null:(this._controller.updateLoadStatus(e,!1),this.loadedGraphics.removeNode(e),this._treeDebugger&&this._treeDebugger.update(),t)}async loadCachedNodeData(e){return this._memCache?.pop(this._getMemCacheKey(e))}async addCachedNodeData(e,t,r,s){this.loadedGraphics.hasNode(e.index)?i.getLogger(this.declaredClass).error("I3S node "+e.id+" already added"):(await this._i3sOverrides.apply(t.featureIds,r,s),this.loadedGraphics.addNode(e.index,t),this._controller.updateLoadStatus(e.index,!0),this._updateNodeMemory(e),t.attributeInfo=r,this._attributeValuesChanged(t),this._filterNode(t),this._treeDebugger&&this._treeDebugger.update())}getLoadedNodeIds(){const e=[];return this.loadedGraphics.forEachNode((t=>e.push(t.node.id))),e.sort()}getVisibleNodes(){const e=new Array;return this.loadedGraphics.forEachNode((t=>e.push(t.node))),e}getLoadedNodeIndices(e){this.loadedGraphics.forEachNode(((t,r)=>e.push(r)))}getLoadedAttributes(e){const t=this.loadedGraphics.getNode(e);if(a(t)&&a(t.attributeInfo))return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this.loadedGraphics.getNode(e);if(a(t)&&a(t.attributeInfo))return t.attributeInfo.attributeData}_setAttributeData(e,t){const r=this.loadedGraphics.getNode(e);o(r)||o(r.attributeInfo)||(r.attributeInfo.attributeData=t,this._attributeValuesChanged(r))}async updateAttributes(e,t,r){const i=this.loadedGraphics.getNode(e);o(i)||(await this._i3sOverrides.apply(i.featureIds,t,r),i.attributeInfo=t,this._attributeValuesChanged(i))}_attributeValuesChanged(e){if(te(e),this._filterNode(e),this.processor.graphicsCore.labelsEnabled){const t=e.graphics.map((e=>e.uid));this.processor.graphicsCore.updateLabelingInfo(t)}}_updateClippingExtent(e){return this._controller&&this._controller.updateClippingArea(e),!1}_getObjectIdField(){return this.layer.objectIdField||_}async _rendererChange(e,t){const{layer:{fieldsIndex:r}}=this,i=new Set;let s,o;e?(await e.collectRequiredFields(i,r),s=Array.from(i).sort()):s=[],i.clear(),t?(await t.collectRequiredFields(i,r),o=Array.from(i).sort()):o=[],s.length===o.length&&s.every(((e,t)=>s[t]===o[t]))||this._reloadAllNodes()}_rangeInfosChanged(e){null!=e&&e.length>0&&i.getLogger(this.declaredClass).warn("Unsupported property: rangeInfos are currently only serialized to and from web scenes but do not affect rendering.")}_filterChange(){this.loadedGraphics.forEachNode((e=>this._filterNode(e)))}_reloadAllNodes(){this._removeAllNodeData(),this._controller&&this._controller.restartNodeLoading()}_filterNode(e){const t=this.parsedDefinitionExpression,i=this._excludeObjectIdsSorted,s=this._getObjectIdField();for(const a of e.graphics){const e=a.visible,n=!t||this._evaluateClause(t,a),d=o(i)||r(i,a.attributes[s])<0;a.visible=n&&d,e!==a.visible&&(oe.graphic=a,oe.property="visible",oe.oldValue=e,oe.newValue=a.visible,this.processor.graphicsCore.graphicUpdateHandler(oe))}}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference};return a(this.filter)?this.filter.createQuery(e):new w(e)}queryFeatures(e,t){return this._queryEngine.executeQuery(this._ensureQuery(e),t?.signal)}queryObjectIds(e,t){return this._queryEngine.executeQueryForIds(this._ensureQuery(e),t?.signal)}queryFeatureCount(e,t){return this._queryEngine.executeQueryForCount(this._ensureQuery(e),t?.signal)}queryExtent(e,t){return this._queryEngine.executeQueryForExtent(this._ensureQuery(e),t?.signal)}_ensureQuery(e){return this._addDefinitionExpressionToQuery(o(e)?this.createQuery():w.from(e))}_setupQueryEngine(){const e=()=>this.processor.featureStore;this._queryEngine=new O({context:{spatialReference:this.view.spatialReference,layer:this.layer,scheduler:this.view.resourceController.scheduler,get featureStore(){return e()},hasZ:this.hasZ,hasM:this.hasM},priority:Z.FEATURE_QUERY_ENGINE})}getUsedMemory(){return this.processor?.graphicsCore?.usedMemory??0}getUnloadedMemory(){return.8*((this._controller?.unloadedMemoryEstimate??0)+(this.processor?.graphicsCore?.unprocessedMemoryEstimate??0))}ignoresMemoryFactor(){return this._controller&&this._controller.fixedFeatureTarget}_handleEdits(e){j(this._attributeEditingContext,e)}get _attributeEditingContext(){const e=this._getObjectIdField();return{sessions:this._interactiveEditingSessions,fieldsIndex:this.layer.fieldsIndex,objectIdField:e,forEachNode:e=>this.loadedGraphics.forEachNode((t=>e(t.node,t.featureIds))),attributeStorageInfo:this.i3slayer.attributeStorageInfo??[],i3sOverrides:this._i3sOverrides,getAttributeData:e=>this.getAttributeData(e),setAttributeData:(t,r,i)=>{this._setAttributeData(t,r);const s=this.loadedGraphics.getNode(t);if(a(i)){const t=this.loadedGraphics.get(i.attributes[e]);a(t)&&this.processor.graphicsCore.recreateGraphics([t])}else a(s)&&this.processor.graphicsCore.recreateGraphics(s.graphics)},clearMemCache:()=>{}}}get performanceInfo(){const e={displayedNumberOfFeatures:this.loadedGraphics.length,maximumNumberOfFeatures:this.maximumNumberOfFeatures,totalNumberOfFeatures:-1,nodes:this.loadedGraphics.nodeCount,core:this.processor.graphicsCore.performanceInfo};return this._controller&&this._controller.updateStats(e),e}get test(){return{controller:this._controller,numNodes:this.loadedGraphics.nodeCount,loadedGraphics:this.loadedGraphics}}};e([h()],Y.prototype,"processor",void 0),e([h({type:I})],Y.prototype,"filter",void 0),e([h()],Y.prototype,"loadedGraphics",void 0),e([h()],Y.prototype,"i3slayer",null),e([h()],Y.prototype,"_controller",void 0),e([h()],Y.prototype,"updating",void 0),e([h()],Y.prototype,"suspended",void 0),e([h()],Y.prototype,"holeFilling",void 0),e([h(T)],Y.prototype,"updatingProgress",void 0),e([h()],Y.prototype,"updatingProgressValue",null),e([h(K.requiredFields)],Y.prototype,"requiredFields",null),e([h(K.availableFields)],Y.prototype,"availableFields",void 0),e([h()],Y.prototype,"_fieldsHelper",void 0),e([h({type:Number})],Y.prototype,"maximumNumberOfFeatures",null),e([h({readOnly:!0})],Y.prototype,"maximumNumberOfFeaturesExceeded",null),e([h()],Y.prototype,"_excludeObjectIdsSorted",null),e([h({readOnly:!0})],Y.prototype,"lodFactor",null),e([h({readOnly:!0})],Y.prototype,"hasM",null),e([h({readOnly:!0})],Y.prototype,"hasZ",null),Y=e([u("esri.views.3d.layers.SceneLayerGraphicsView3D")],Y);const $=Y;function J(e){return"pointData"in e}function X(e){return"geometryBuffer"in e&&null!==e.geometryBuffer}function ee(e,t,r){const i=t.attributeInfo;if(o(i)||o(i.loadedAttributes)||o(i.attributeData))return!1;let s=!1;for(const{name:o}of i.loadedAttributes)if(i.attributeData[o]){const t=V(i.attributeData[o],r);t!==e.attributes[o]&&(e.attributes[o]=t,s=!0)}return s}function te(e){const t=e.attributeInfo,r=e.node.index;if(!(o(t)||o(t.loadedAttributes)||o(t.attributeData)))for(let i=0;i<e.graphics.length;i++){const s=e.graphics[i];if(s.nodeIndex===r){s.attributes||(s.attributes={});for(const{name:e}of t.loadedAttributes)t.attributeData[e]&&(s.attributes[e]=V(t.attributeData[e],i))}}}function re(e,t){return e.xmin-=t,e.ymin-=t,e.xmax+=t,e.ymax+=t,null!=e.zmin&&null!=e.zmax&&(e.zmin-=t,e.zmax+=t),null!=e.mmin&&null!=e.mmax&&(e.mmin-=t,e.mmax+=t),e}const ie={2:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0]}}},3:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0,0]}}}},se=p(),oe={graphic:null,property:null,oldValue:null,newValue:null};export{$ as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Logger.js";import{isNone as i,isSome as s,destroyMaybe as o}from"../../../core/maybe.js";import{initial as l}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{WhereClause as u}from"../../../core/sql/WhereClause.js";import d from"../../../layers/support/FeatureFilter.js";import{getFloorFilterClause as h}from"../../../layers/support/floorFilterUtils.js";import p from"../../../rest/support/Query.js";import{sceneLayerEditingEnabled as c}from"../../../support/featureFlags.js";import{I3SMeshView3D as y}from"./I3SMeshView3D.js";import{ForAllFeaturesVisibilityMode as g}from"./II3SMeshView3D.js";import{LayerView3D as f}from"./LayerView3D.js";import{createInteractiveEditSession as m,processGeometryEdits as _,processAttributeEdits as F}from"./i3s/attributeEditing.js";import{createGetFeatureExtent as j}from"./i3s/I3SGeometryUtil.js";import{I3SMeshViewFilter as I}from"./i3s/I3SMeshViewFilter.js";import{NodeFilterImpact as S}from"./i3s/I3SNode.js";import{I3SQueryEngine as w}from"./i3s/I3SQueryEngine.js";import{I3SQueryFeatureAdapter as b}from"./i3s/I3SQueryFeatureAdapter.js";import{I3SQueryFeatureStore as v}from"./i3s/I3SQueryFeatureStore.js";import{getIndexCrs as E,objectIdFilter as x}from"./i3s/I3SUtil.js";import{DefinitionExpressionSceneLayerView as C}from"./support/DefinitionExpressionSceneLayerView.js";import{defineFieldProperties as Q}from"./support/fieldProperties.js";import{PopupSceneLayerView as q}from"./support/PopupSceneLayerView.js";import{SceneLayerViewRequiredFields as D}from"./support/SceneLayerViewRequiredFields.js";import{updatingProgress as O}from"../support/updatingProperties.js";import A from"../../layers/SceneLayerView.js";import{TaskPriority as H}from"../../support/Scheduler.js";const L=Q();let R=class extends(y(C(q(f(A))))){constructor(){super(...arguments),this.type="scene-layer-3d",this.progressiveLoadFactor=1,this._elevationContext="scene",this._isIntegratedMesh=!1,this._supportsLabeling=!0,this._interactiveEditingSessions=new Map,this._queryEngine=null}get i3slayer(){return this.layer}get layerPopupEnabled(){return this.layer.popupEnabled}get filter(){return this._get("filter")}set filter(e){this._set("filter",I.checkSupport(e)?e:null)}get viewFilter(){const e=this.filter,t=this.layerFilter;if(i(e)&&i(t))return null;const r=this._get("viewFilter");return i(r)?new I({layerFilter:t,viewFilter:e,layerFieldsIndex:this.layer.fieldsIndex,loadAsyncModule:e=>this._loadAsyncModule(e),addSqlFilter:(e,t)=>this.addSqlFilter(e,t,this.logError)}):(r.viewFilter=e,r.layerFilter=t,r)}get requiredFields(){return this._fieldsHelper?.requiredFields??[]}get _floorFilterClause(){const e=h(this);return s(e)?u.create(e,this.layer.fieldsIndex):null}get _excludeObjectIdsSorted(){let e=this.layer.excludeObjectIds.toArray();return c()&&this.i3sOverrides.geometryChangedObjectIds.length>0&&(e=e.concat(this.i3sOverrides.geometryChangedObjectIds)),e.length?e.sort(((e,t)=>e-t)):null}get _objectQualitySettings(){return this.view?.qualitySettings?.sceneService?.object}get lodFactor(){return this._objectQualitySettings?.lodFactor??1}get lodCrossfadeinDuration(){return this._objectQualitySettings.lodCrossfadeinDuration??0}get lodCrossfadeoutDuration(){return this._objectQualitySettings.lodCrossfadeoutDuration??0}get lodCrossfadeUncoveredDuration(){return this._objectQualitySettings.lodCrossfadeUncoveredDuration??0}get updatingProgressValue(){return this._controller?.updatingProgress??0}initialize(){this._fieldsHelper=new D({layerView:this}),this.updatingHandles.add((()=>this.layer.rangeInfos),(e=>this._rangeInfosChanged(e)),l),this.updatingHandles.add((()=>this.layer.renderer),(e=>this.updatingHandles.addPromise(this._rendererChange(e))),l);const e=()=>this._filterChange();this.updatingHandles.add((()=>this.parsedDefinitionExpression),e),this.updatingHandles.add((()=>this.filter),e),this.updatingHandles.add((()=>this._floorFilterClause),e),this.updatingHandles.add((()=>this._excludeObjectIdsSorted),e),this.updatingHandles.add((()=>s(this.viewFilter)?this.viewFilter.sortedObjectIds:null),e),this.updatingHandles.add((()=>s(this.viewFilter)?this.viewFilter.parsedWhereClause:null),e),this.updatingHandles.add((()=>[s(this.viewFilter)?this.viewFilter.parsedGeometry:null,s(this.filter)?this.filter.spatialRelationship:null,s(this.layer.filter)?this.layer.filter.spatialRelationship:null]),(()=>this._geometryFilterChange())),this.handles.add(this.layer.on("apply-edits",(e=>this.updatingHandles.addPromise(e.result)))),this.handles.add(this.layer.on("edits",(e=>this._handleEdits(e))))}destroy(){this._fieldsHelper=o(this._fieldsHelper)}_rangeInfosChanged(e){null!=e&&e.length>0&&r.getLogger(this.declaredClass).warn("Unsupported property: rangeInfos are currently only serialized to and from web scenes but do not affect rendering.")}createQuery(){const e={outFields:["*"],returnGeometry:!1,outSpatialReference:this.view.spatialReference};return s(this.filter)?this.filter.createQuery(e):new p(e)}queryExtent(e,t){return this._ensureQueryEngine().executeQueryForExtent(this._ensureQuery(e),t?.signal)}queryFeatureCount(e,t){return this._ensureQueryEngine().executeQueryForCount(this._ensureQuery(e),t?.signal)}queryFeatures(e,t){return this._ensureQueryEngine().executeQuery(this._ensureQuery(e),t?.signal).then((e=>{if(!e?.features)return e;const t=this.layer;for(const r of e.features)r.layer=t,r.sourceLayer=t;return e}))}queryObjectIds(e,t){return this._ensureQueryEngine().executeQueryForIds(this._ensureQuery(e),t?.signal)}_ensureQueryEngine(){return this._queryEngine||(this._queryEngine=this._createQueryEngine()),this._queryEngine}_createQueryEngine(){const e=j(this.view.spatialReference,this.view.renderSpatialReference,this._collection);return new w({layerView:this,priority:H.FEATURE_QUERY_ENGINE,spatialIndex:new v({featureAdapter:new b({objectIdField:this.layer.objectIdField,attributeStorageInfo:this.layer.attributeStorageInfo,getFeatureExtent:e}),forAllFeatures:(e,t)=>this._forAllFeatures(((t,r,i)=>e({id:t,index:r,meta:i})),t,g.ALL_IN_CLIPPING_AREA),getFeatureExtent:e,sourceSpatialReference:E(this.layer),viewSpatialReference:this.view.spatialReference})})}highlight(e){const t=this._highlights;if(e instanceof p){const{set:r,handle:i}=t.acquireSet();return this.queryObjectIds(e).then((e=>t.setFeatureIds(r,e))),i}return super.highlight(e)}createInteractiveEditSession(e){return m(this._attributeEditingContext,e)}_createLayerGraphic(e){const r=new t(null,null,e);return r.layer=this.layer,r.sourceLayer=this.layer,r}canResume(){return super.canResume()&&(!this._controller||this._controller.rootNodeVisible)}getFilters(){const e=super.getFilters(),t=this._excludeObjectIdsSorted;return s(t)&&e.push((e=>x(t,!1,e))),this._floorFilterClause&&this.addSqlFilter(e,this._floorFilterClause,this.logError),this.addSqlFilter(e,this.parsedDefinitionExpression,this.logError),s(this.viewFilter)&&this.viewFilter.addFilters(e,this.view,this._controller.crsIndex,this._collection),e}isUpdating(){return super.isUpdating()||this.layerFilterUpdating||s(this.viewFilter)&&this.viewFilter.updating||s(this.i3sOverrides)&&this.i3sOverrides.updating}_ensureQuery(e){return this._addDefinitionExpressionToQuery(i(e)?this.createQuery():p.from(e))}get _attributeEditingContext(){return{sessions:this._interactiveEditingSessions,fieldsIndex:this.layer.fieldsIndex,objectIdField:this._getObjectIdField(),forEachNode:e=>this._forAllNodes((t=>s(t)?e(t.node,t.featureIds):null)),attributeStorageInfo:this.i3slayer.attributeStorageInfo,i3sOverrides:this.i3sOverrides,getAttributeData:e=>this.getAttributeData(e),setAttributeData:(e,t)=>this.setAttributeData(e,t),clearMemCache:()=>this.clearMemCache()}}_handleEdits(e){c()&&_(this._attributeEditingContext,e),F(this._attributeEditingContext,e)}get hasGeometryFilter(){const e=this.viewFilter;return s(e)&&s(e.parsedGeometry)}computeNodeFiltering(e){const t=this.viewFilter;return i(t)||t.isMBSGeometryVisible(e,this.view.spatialReference,this._controller.crsIndex)?S.Unmodified:S.Culled}};e([n()],R.prototype,"i3slayer",null),e([n(O)],R.prototype,"updatingProgress",void 0),e([n({type:d})],R.prototype,"filter",null),e([n({readOnly:!0})],R.prototype,"viewFilter",null),e([n(L.requiredFields)],R.prototype,"requiredFields",null),e([n(L.availableFields)],R.prototype,"availableFields",void 0),e([n()],R.prototype,"_fieldsHelper",void 0),e([n()],R.prototype,"_floorFilterClause",null),e([n()],R.prototype,"_excludeObjectIdsSorted",null),e([n()],R.prototype,"_objectQualitySettings",null),e([n()],R.prototype,"lodFactor",null),e([n()],R.prototype,"updatingProgressValue",null),R=e([a("esri.views.3d.layers.SceneLayerView3D")],R);const V=R;export{V as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Logger.js";import{isNone as i,isSome as s,destroyMaybe as o}from"../../../core/maybe.js";import{initial as l}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{WhereClause as u}from"../../../core/sql/WhereClause.js";import d from"../../../layers/support/FeatureFilter.js";import{getFloorFilterClause as h}from"../../../layers/support/floorFilterUtils.js";import p from"../../../rest/support/Query.js";import{sceneLayerEditingEnabled as c}from"../../../support/featureFlags.js";import{I3SMeshView3D as y}from"./I3SMeshView3D.js";import{ForAllFeaturesVisibilityMode as g}from"./II3SMeshView3D.js";import{LayerView3D as f}from"./LayerView3D.js";import{createInteractiveEditSession as m,processGeometryEdits as _,processAttributeEdits as F}from"./i3s/attributeEditing.js";import{createGetFeatureExtent as j}from"./i3s/I3SGeometryUtil.js";import{I3SMeshViewFilter as I}from"./i3s/I3SMeshViewFilter.js";import{NodeFilterImpact as S}from"./i3s/I3SNode.js";import{I3SQueryEngine as w}from"./i3s/I3SQueryEngine.js";import{I3SQueryFeatureAdapter as b}from"./i3s/I3SQueryFeatureAdapter.js";import{I3SQueryFeatureStore as v}from"./i3s/I3SQueryFeatureStore.js";import{getIndexCrs as E,objectIdFilter as x}from"./i3s/I3SUtil.js";import{DefinitionExpressionSceneLayerView as C}from"./support/DefinitionExpressionSceneLayerView.js";import{defineFieldProperties as Q}from"./support/fieldProperties.js";import{PopupSceneLayerView as q}from"./support/PopupSceneLayerView.js";import{SceneLayerViewRequiredFields as D}from"./support/SceneLayerViewRequiredFields.js";import{updatingProgress as O}from"../support/updatingProperties.js";import A from"../../layers/SceneLayerView.js";import{TaskPriority as H}from"../../support/Scheduler.js";const L=Q();let R=class extends(y(C(q(f(A))))){constructor(){super(...arguments),this.type="scene-layer-3d",this.progressiveLoadFactor=1,this._elevationContext="scene",this._isIntegratedMesh=!1,this._supportsLabeling=!0,this._interactiveEditingSessions=new Map,this._queryEngine=null}get i3slayer(){return this.layer}get layerPopupEnabled(){return this.layer.popupEnabled}get filter(){return this._get("filter")}set filter(e){this._set("filter",I.checkSupport(e)?e:null)}get viewFilter(){const e=this.filter,t=this.layerFilter;if(i(e)&&i(t))return null;const r=this._get("viewFilter");return i(r)?new I({layerFilter:t,viewFilter:e,layerFieldsIndex:this.layer.fieldsIndex,loadAsyncModule:e=>this._loadAsyncModule(e),addSqlFilter:(e,t)=>this.addSqlFilter(e,t,this.logError)}):(r.viewFilter=e,r.layerFilter=t,r)}get requiredFields(){return this._fieldsHelper?.requiredFields??[]}get _floorFilterClause(){const e=h(this);return s(e)?u.create(e,this.layer.fieldsIndex):null}get _excludeObjectIdsSorted(){let e=this.layer.excludeObjectIds.toArray();return c()&&this.i3sOverrides.geometryChangedObjectIds.length>0&&(e=e.concat(this.i3sOverrides.geometryChangedObjectIds)),e.length?e.sort(((e,t)=>e-t)):null}get _objectQualitySettings(){return this.view?.qualitySettings?.sceneService?.object}get lodFactor(){return this._objectQualitySettings?.lodFactor??1}get lodCrossfadeinDuration(){return this._objectQualitySettings.lodCrossfadeinDuration??0}get lodCrossfadeoutDuration(){return this._objectQualitySettings.lodCrossfadeoutDuration??0}get lodCrossfadeUncoveredDuration(){return this._objectQualitySettings.lodCrossfadeUncoveredDuration??0}get updatingProgressValue(){return this._controller?.updatingProgress??0}initialize(){this._fieldsHelper=new D({layerView:this}),this.updatingHandles.add((()=>this.layer.rangeInfos),(e=>this._rangeInfosChanged(e)),l),this.updatingHandles.add((()=>this.layer.renderer),(e=>this.updatingHandles.addPromise(this._rendererChange(e))),l);const e=()=>this._filterChange();this.updatingHandles.add((()=>this.parsedDefinitionExpression),e),this.updatingHandles.add((()=>this.filter),e),this.updatingHandles.add((()=>this._floorFilterClause),e),this.updatingHandles.add((()=>this._excludeObjectIdsSorted),e),this.updatingHandles.add((()=>s(this.viewFilter)?this.viewFilter.sortedObjectIds:null),e),this.updatingHandles.add((()=>s(this.viewFilter)?this.viewFilter.parsedWhereClause:null),e),this.updatingHandles.add((()=>[s(this.viewFilter)?this.viewFilter.parsedGeometry:null,s(this.filter)?this.filter.spatialRelationship:null,s(this.layer.filter)?this.layer.filter.spatialRelationship:null]),(()=>this._geometryFilterChange())),this.handles.add(this.layer.on("apply-edits",(e=>this.updatingHandles.addPromise(e.result)))),this.handles.add(this.layer.on("edits",(e=>this._handleEdits(e))))}destroy(){this._fieldsHelper=o(this._fieldsHelper)}_rangeInfosChanged(e){null!=e&&e.length>0&&r.getLogger(this.declaredClass).warn("Unsupported property: rangeInfos are currently only serialized to and from web scenes but do not affect rendering.")}createQuery(){const e={outFields:["*"],returnGeometry:!1,outSpatialReference:this.view.spatialReference};return s(this.filter)?this.filter.createQuery(e):new p(e)}queryExtent(e,t){return this._ensureQueryEngine().executeQueryForExtent(this._ensureQuery(e),t?.signal)}queryFeatureCount(e,t){return this._ensureQueryEngine().executeQueryForCount(this._ensureQuery(e),t?.signal)}queryFeatures(e,t){return this._ensureQueryEngine().executeQuery(this._ensureQuery(e),t?.signal).then((e=>{if(!e?.features)return e;const t=this.layer;for(const r of e.features)r.layer=t,r.sourceLayer=t;return e}))}queryObjectIds(e,t){return this._ensureQueryEngine().executeQueryForIds(this._ensureQuery(e),t?.signal)}_ensureQueryEngine(){return this._queryEngine||(this._queryEngine=this._createQueryEngine()),this._queryEngine}_createQueryEngine(){const e=j(this.view.spatialReference,this.view.renderSpatialReference,this._collection);return new w({layerView:this,priority:H.FEATURE_QUERY_ENGINE,spatialIndex:new v({featureAdapter:new b({objectIdField:this.layer.objectIdField,attributeStorageInfo:this.layer.attributeStorageInfo??[],getFeatureExtent:e}),forAllFeatures:(e,t)=>this._forAllFeatures(((t,r,i)=>e({id:t,index:r,meta:i})),t,g.ALL_IN_CLIPPING_AREA),getFeatureExtent:e,sourceSpatialReference:E(this.layer),viewSpatialReference:this.view.spatialReference})})}highlight(e){const t=this._highlights;if(e instanceof p){const{set:r,handle:i}=t.acquireSet();return this.queryObjectIds(e).then((e=>t.setFeatureIds(r,e))),i}return super.highlight(e)}createInteractiveEditSession(e){return m(this._attributeEditingContext,e)}_createLayerGraphic(e){const r=new t(null,null,e);return r.layer=this.layer,r.sourceLayer=this.layer,r}canResume(){return super.canResume()&&(!this._controller||this._controller.rootNodeVisible)}getFilters(){const e=super.getFilters(),t=this._excludeObjectIdsSorted;return s(t)&&e.push((e=>x(t,!1,e))),this._floorFilterClause&&this.addSqlFilter(e,this._floorFilterClause,this.logError),this.addSqlFilter(e,this.parsedDefinitionExpression,this.logError),s(this.viewFilter)&&this.viewFilter.addFilters(e,this.view,this._controller.crsIndex,this._collection),e}isUpdating(){return super.isUpdating()||this.layerFilterUpdating||s(this.viewFilter)&&this.viewFilter.updating||s(this.i3sOverrides)&&this.i3sOverrides.updating}_ensureQuery(e){return this._addDefinitionExpressionToQuery(i(e)?this.createQuery():p.from(e))}get _attributeEditingContext(){return{sessions:this._interactiveEditingSessions,fieldsIndex:this.layer.fieldsIndex,objectIdField:this._getObjectIdField(),forEachNode:e=>this._forAllNodes((t=>s(t)?e(t.node,t.featureIds):null)),attributeStorageInfo:this.i3slayer.attributeStorageInfo??[],i3sOverrides:this.i3sOverrides,getAttributeData:e=>this.getAttributeData(e),setAttributeData:(e,t)=>this.setAttributeData(e,t),clearMemCache:()=>this.clearMemCache()}}_handleEdits(e){c()&&_(this._attributeEditingContext,e),F(this._attributeEditingContext,e)}get hasGeometryFilter(){const e=this.viewFilter;return s(e)&&s(e.parsedGeometry)}computeNodeFiltering(e){const t=this.viewFilter;return i(t)||t.isMBSGeometryVisible(e,this.view.spatialReference,this._controller.crsIndex)?S.Unmodified:S.Culled}};e([n()],R.prototype,"i3slayer",null),e([n(O)],R.prototype,"updatingProgress",void 0),e([n({type:d})],R.prototype,"filter",null),e([n({readOnly:!0})],R.prototype,"viewFilter",null),e([n(L.requiredFields)],R.prototype,"requiredFields",null),e([n(L.availableFields)],R.prototype,"availableFields",void 0),e([n()],R.prototype,"_fieldsHelper",void 0),e([n()],R.prototype,"_floorFilterClause",null),e([n()],R.prototype,"_excludeObjectIdsSorted",null),e([n()],R.prototype,"_objectQualitySettings",null),e([n()],R.prototype,"lodFactor",null),e([n()],R.prototype,"updatingProgressValue",null),R=e([a("esri.views.3d.layers.SceneLayerView3D")],R);const V=R;export{V as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as r}from"../../../chunks/tslib.es6.js";import e from"../../../core/Error.js";import{watch as t}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{StreamController as i}from"../../../layers/graphics/controllers/StreamController.js";import a from"../../../rest/support/Query.js";import{FeatureLikeLayerView3D as n}from"./FeatureLikeLayerView3D.js";import{LayerView3D as l}from"./LayerView3D.js";import{UpdatePolicy as p}from"../webgl-engine/lib/UpdatePolicy.js";import c from"../../layers/LayerView.js";import m from"../../layers/StreamLayerView.js";let y=class extends(m(n(l(c)))){constructor(){super(...arguments),this.type="stream-3d",this.updatePolicy=p.ASYNC,this.hasZ=!0,this.hasM=!1}initialize(){this.handles.add(t((()=>this.suspended),(r=>{this.controller&&(r?this.controller.pauseStream():this.controller.resumeStream())})))}get connectionError(){const r=this.get("controller.connection.errorString");if(r)return new e("stream-controller",r)}createQuery(){return new a({outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference})}queryLatestObservations(r,e){return this.queryEngine.executeQueryForLatestObservations(this._ensureQuery(r),e?.signal)}createController(){return new i({layer:this.layer,layerView:this})}beforeSetController(){}};r([o({readOnly:!0})],y.prototype,"updatePolicy",void 0),r([o({readOnly:!0})],y.prototype,"connectionError",null),r([o()],y.prototype,"controller",void 0),r([o({readOnly:!0})],y.prototype,"hasZ",void 0),r([o({readOnly:!0})],y.prototype,"hasM",void 0),y=r([s("esri.views.3d.layers.StreamLayerView3D")],y);const u=y;export{u as default};
5
+ import{_ as r}from"../../../chunks/tslib.es6.js";import e from"../../../core/Error.js";import{watch as t}from"../../../core/reactiveUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{StreamController as i}from"../../../layers/graphics/controllers/StreamController.js";import a from"../../../rest/support/Query.js";import{FeatureLikeLayerView3D as l}from"./FeatureLikeLayerView3D.js";import{LayerView3D as n}from"./LayerView3D.js";import{UpdatePolicy as p}from"../webgl-engine/lib/UpdatePolicy.js";import c from"../../layers/LayerView.js";import u from"../../layers/StreamLayerView.js";let m=class extends(u(l(n(c)))){constructor(){super(...arguments),this.type="stream-3d",this.updatePolicy=p.ASYNC,this.hasZ=!0,this.hasM=!1,this._isUserPaused=!1}initialize(){this.handles.add(t((()=>this.suspended),(r=>{this.controller&&(r?this.controller.pauseStream():this._isUserPaused||this.controller.resumeStream())})))}get connectionError(){const r=this.get("controller.connection.errorString");if(r)return new e("stream-controller",r)}pause(){this._isUserPaused=!0,this.controller.pauseStream()}resume(){this._isUserPaused=!1,this.controller.resumeStream()}createQuery(){return new a({outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference})}queryLatestObservations(r,e){return this.queryEngine.executeQueryForLatestObservations(this._ensureQuery(r),e?.signal)}createController(){return new i({layer:this.layer,layerView:this})}beforeSetController(){}};r([s({readOnly:!0})],m.prototype,"updatePolicy",void 0),r([s({readOnly:!0})],m.prototype,"connectionError",null),r([s()],m.prototype,"controller",void 0),r([s({readOnly:!0})],m.prototype,"hasZ",void 0),r([s({readOnly:!0})],m.prototype,"hasM",void 0),m=r([o("esri.views.3d.layers.StreamLayerView3D")],m);const y=m;export{y as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import{isNone as r}from"../../../core/maybe.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{canProjectWithoutEngine as o}from"../../../geometry/projection.js";import{LayerView3D as a}from"./LayerView3D.js";import{TiledLayerView3D as l}from"./TiledLayerView3D.js";import p from"../../layers/LayerView.js";import n from"../../layers/RefreshableLayerView.js";import{isMapServiceLayerView as m,MapServiceLayerViewHelper as h}from"../../layers/support/MapServiceLayerViewHelper.js";import{createQueryGeometry as u}from"../../support/drapedUtils.js";let c=class extends(n(l(a(p)))){constructor(){super(...arguments),this.type="tile-3d",this._popupHighlightHelper=null}get imageFormatIsOpaque(){return"jpg"===this.layer.tileInfo.format}get hasMixedImageFormats(){return"mixed"===this.layer.tileInfo.format}get tileInfo(){return this.layer?.tileInfo}get dataLevelRange(){if(this.tileInfo){const e=this.tileInfo.lods,t=e[0].scale,r=e[e.length-1].scale;return this.levelRangeFromScaleRange(t,r)}return{minLevel:0,maxLevel:0}}initialize(){if("web-tile"===this.layer.type){const e=this.layer.get("fullExtent.spatialReference"),i=this.layer.get("tileInfo.spatialReference");if(r(e)||r(i)||!o(e,i)){const e="defaults"===this.layer.originOf("fullExtent")||r(this.layer.fullExtent)?"SceneView requires fullExtent to be specified by the user on WebTileLayer":"SceneView requires fullExtent to be specified in the same spatial reference as tileInfo on WebTileLayer";this.addResolvingPromise(Promise.reject(new t("layerview:incompatible-fullextent",e)))}}m(this)&&(this._popupHighlightHelper=new h({createFetchPopupFeaturesQueryGeometry:(e,t)=>u(e,t,this.view),layerView:this,updatingHandles:this.updatingHandles})),this._addTilingSchemeMatchPromise()}destroy(){this._popupHighlightHelper?.destroy()}async fetchPopupFeatures(e,t){return this._popupHighlightHelper?this._popupHighlightHelper.fetchPopupFeatures(e,t):[]}async doRefresh(){this.suspended||this.emit("data-changed")}};e([i()],c.prototype,"imageFormatIsOpaque",null),e([i()],c.prototype,"hasMixedImageFormats",null),e([i()],c.prototype,"layer",void 0),e([i()],c.prototype,"tileInfo",null),e([i()],c.prototype,"dataLevelRange",null),c=e([s("esri.views.3d.layers.TileLayerView3D")],c);const f=c;export{f as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import{isNone as r}from"../../../core/maybe.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{canProjectWithoutEngine as o}from"../../../geometry/projection.js";import{LayerView3D as a}from"./LayerView3D.js";import{TiledLayerView3D as l}from"./TiledLayerView3D.js";import p from"../../layers/LayerView.js";import n from"../../layers/RefreshableLayerView.js";import{isMapServiceLayerView as m,MapServiceLayerViewHelper as h}from"../../layers/support/MapServiceLayerViewHelper.js";import{createQueryGeometry as u}from"../../support/drapedUtils.js";let c=class extends(n(l(a(p)))){constructor(){super(...arguments),this.type="tile-3d",this._popupHighlightHelper=null}get imageFormatIsOpaque(){return"jpg"===this.layer.tileInfo.format}get hasMixedImageFormats(){return"mixed"===this.layer.tileInfo.format}get tileInfo(){return this.layer.tileInfo}get dataLevelRange(){if(this.tileInfo){const e=this.tileInfo.lods,t=e[0].scale,r=e[e.length-1].scale;return this.levelRangeFromScaleRange(t,r)}return{minLevel:0,maxLevel:0}}initialize(){if("web-tile"===this.layer.type){const e=this.layer.get("fullExtent.spatialReference"),i=this.layer.get("tileInfo.spatialReference");if(r(e)||r(i)||!o(e,i)){const e="defaults"===this.layer.originOf("fullExtent")||r(this.layer.fullExtent)?"SceneView requires fullExtent to be specified by the user on WebTileLayer":"SceneView requires fullExtent to be specified in the same spatial reference as tileInfo on WebTileLayer";this.addResolvingPromise(Promise.reject(new t("layerview:incompatible-fullextent",e)))}}m(this)&&(this._popupHighlightHelper=new h({createFetchPopupFeaturesQueryGeometry:(e,t)=>u(e,t,this.view),layerView:this,updatingHandles:this.updatingHandles})),this._addTilingSchemeMatchPromise()}destroy(){this._popupHighlightHelper?.destroy()}async fetchPopupFeatures(e,t){return this._popupHighlightHelper?this._popupHighlightHelper.fetchPopupFeatures(e,t):[]}async doRefresh(){this.suspended||this.emit("data-changed")}};e([i()],c.prototype,"imageFormatIsOpaque",null),e([i()],c.prototype,"hasMixedImageFormats",null),e([i()],c.prototype,"layer",void 0),e([i()],c.prototype,"tileInfo",null),e([i()],c.prototype,"dataLevelRange",null),c=e([s("esri.views.3d.layers.TileLayerView3D")],c);const f=c;export{f as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as e,isNone as t,unwrap as i}from"../../../../core/maybe.js";import s from"../../../../core/PooledArray.js";import{isAbortError as n}from"../../../../core/promiseUtils.js";import{l as r}from"../../../../chunks/vec3.js";import{b as o}from"../../../../chunks/vec4f64.js";import{LodMetric as a,NodeBase as d,Node as l,ElevationRange as h,NodeFilterImpact as u,NodeIMModificationImpact as c,NodeTraversalState as _}from"./I3SNode.js";import{invalidateMbs as g,invalidateObb as m,addWraparound as f}from"./I3SUtil.js";import{clone as v}from"../../support/orientedBoundingBox.js";class b{constructor(e,t,i,s,n){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this.ref=s,this.node=n,this.useAsHole=0,this.filterImpact=u.NotChecked}}class p{constructor(e,t,i,n,r,o,d,l,h,u,c,_,g,m){this._streamDataController=i,this._viewportQueries=n,this._logger=r,this.holeFilling=o,this._isLoaded=d,this._isReloading=l,this._isSelected=h,this._enable=u,this._needsUpdate=c,this._canRequest=_,this._computeVisibilityObb=g,this._computeNodeFiltering=m,this._dirty=!0,this._nodePages=[],this._nodeCount=0,this._nodesPerPage=0,this._rootIndex=0,this._lodMetric=a.None,this._lodConversion=e=>e,this._urlPrefix="",this._loading=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._nodeTraversalState=new Map,this._version=I(0),this._visibilityCacheVersion=I(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._missing=new s({deallocator:null}),this._prefetch=new s({deallocator:null}),this._updates=new N(this._missing),this._imModificationUncategorized=new s({deallocator:null}),this.ignoreServiceObb=!1,this.progressiveLoadPenalty=0,this._pageQueue=[],this.needNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._logLayer=e,e.serviceUpdateTimeStamp&&e.serviceUpdateTimeStamp.lastUpdate&&(this._lastUpdate=`${e.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,this._init(t)}_init(e){if("page"===e.type){switch(this._urlPrefix=e.urlPrefix,this._nodesPerPage=e.pageSize,this._rootIndex=e.rootIndex,e.lodMetric){case"maxScreenThreshold":this._lodMetric=a.MaxScreenThreshold;break;case"maxScreenThresholdSQ":this._lodMetric=a.MaxScreenThreshold,this._lodConversion=V}this._addPage(S(this._rootIndex,this._nodesPerPage),e.rootPage),this._updateParentsAndLevel()}else if("node"===e.type){this._urlPrefix=e.urlPrefix,this._nodePages.push({nodes:[],children:[],parents:[]}),this._makeRefNode(new d(e.rootNode.id,null),-1);const t=this._validateNode(e.rootNode.id,e.rootNode);t&&this._addNode(t,0)}}_loadPage(e){this._loading.add(e);const t=this._urlPrefix+e;this._streamDataController.request(t,"json").then((t=>{this._pageQueue.push({pageIndex:e,page:t})})).catch((t=>{this._loading.delete(e),n(t)||(this._failedPages.add(e),this._logger.error("#loadPage()",this._logLayer,`Error when loading page ${e}`,t))}))}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){const{pageIndex:t,page:i}=this._pageQueue.shift();this._addPage(t,i),this._loading.delete(t),e.madeProgress()}this._updateParentsAndLevel()}_addPage(e,t){for(let r=this._nodePages.length;r<e;r++)this._nodePages[r]=null;const i=[],s=[],n=t.nodes.map(((t,n)=>{const a=i.length,d=t.children?t.children.length:0;s.push(-1);for(let e=0;e<d;e++)i.push(t.children[e]);const h=`${t.index}`,u=v(t.obb),c=o([u.center[0],u.center[1],u.center[2],r(u.halfSize)]),_=t.mesh&&t.mesh.attribute,g=t.mesh&&t.mesh.geometry,m=t.mesh&&t.mesh.material,f={hasSharedResource:!1,hasFeatureData:!!g,attributes:_&&null!=_.resource?`${_.resource}`:void 0,geometry:g&&null!=g.resource?`${g.resource}`:void 0,texture:m&&null!=m.resource?`${m.resource}`:void 0,geometryDefinition:g?g.definition:-1,materialDefinition:m?m.definition:-1},p=new l(h,e*this._nodesPerPage+n,c,d,0,f,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),g?g.featureCount:null);return p.serviceObb=u,p.visibilityObb=this._computeVisibilityObb(p),p.vertexCount=g?g.vertexCount:0,new b(a,d,x(this._visibilityCacheVersion),null,p)}));this._nodePages[e]={nodes:n,children:i,parents:s},this._nodeCount+=n.length}_updateParentsAndLevel(){const t=new Array,i=(i,s,n)=>{const r=this._getPage(i);if(e(r)){const o=R(i,this._nodesPerPage);r.parents[o]=s;const a=r.nodes[o].node;e(a)&&(a.level=n,t.push(i))}};for(i(this._rootIndex,-1,0);t.length;){const s=t.pop(),n=this.getNode(s);if(e(n))for(let e=0;e<n.childCount;e++){i(this.getChildIndex(n.index,e),s,n.level+1),this._maxLevel=Math.max(this._maxLevel,n.level+1)}}}_getPage(e){return this._nodePages[S(e,this._nodesPerPage)]}_getNodeInternal(e){const i=this._getPage(e);return t(i)?null:i.nodes[R(e,this._nodesPerPage)]}_addNode(t,s){null!=t.children&&this.populateChildren(s,t.children);const n=this.getParent(s),r=e(n)?n.level+1:0;this._maxLevel=Math.max(this._maxLevel,t.children?r+1:r);const{lodMetric:a,maxError:d}=E(t.lodSelection),h=i(this._getNodeInternal(s));return h.node=new l(t.id,s,o(t.mbs),h.childCount,r,t.resources,t.version,a,d,t.numFeatures),t.obb&&(h.node.serviceObb=v(t.obb)),h.node.visibilityObb=this._computeVisibilityObb(h.node),e(h.ref)&&(null==h.ref.mbs&&(h.ref.mbs=t.mbs),h.node.renderMbs=h.ref.renderMbs,h.node.serviceObbInRenderSR=h.ref.serviceObbInRenderSR,h.ref.visibilityObb=h.node.visibilityObb),h.node}_makeRefNode(e,t){const i=this._nodePages[0];if(null==i)return-1;const s=i.nodes.length;return i.nodes.push(new b(0,0,x(this._visibilityCacheVersion),e,null)),this._nodeCount++,i.parents.push(t),g(e.renderMbs),m(e.serviceObbInRenderSR),s}populateChildren(e,t){const s=i(this._getNodeInternal(e)),n=i(this._getPage(e));s.childOffset=n.children.length,s.childCount=t.length;for(let i=0;i<t.length;i++){const s=this._makeRefNode(t[i],e);n.children.push(s)}}getNode(t){const i=this._getNodeInternal(t);return e(i)?i.node:null}getIndexById(t){let i;return this._forAllNodes(((s,n)=>{(e(s.node)&&s.node.id===t||e(s.ref)&&s.ref.id===t)&&(i=n)})),i}getNodeById(e){const t=this.getIndexById(e);return null!=t&&t>=0?this.getNode(t):null}getChildIndex(e,i){const s=this._getPage(e);if(t(s))return-1;const n=s.nodes[R(e,this._nodesPerPage)];return s.children[n.childOffset+i]}getParentIndex(t){const i=this._getPage(t);return e(i)?i.parents[R(t,this._nodesPerPage)]:-1}getParent(e){return(e=this.getParentIndex(e))>=0?this.getNode(e):null}isLeaf(t){const i=this._getNodeInternal(t);return e(i)&&0===i.childCount}get rootNode(){return this.getNode(this._rootIndex)}get size(){return this._nodeCount}removeAllGeometryObbs(){this._forAllNodes((t=>{e(t.node)&&(t.node.geometryObb=null)}))}invalidateVisibilityCache(){this._visibilityCacheVersion=I(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(t){const i=this._getNodeInternal(t);e(i)&&this.invalidateNodeVisibilityCacheInternal(i)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=x(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(t){const i=this._getNodeInternal(t);e(i)&&(P(i),this.invalidateNodeVisibilityCacheInternal(i))}updateElevationChanged(i){const s=this._getNodeInternal(i);if(t(s))return;if(!this.needNodeElevationRange)return void this.invalidateBoundingVolumeCache(i);const n=e(s.node)?s.node:s.ref;if(t(n))return;const r=n.elevationRange;t(r)||(r.valid=!1)}invalidateGeometryVisibility(t){const i=this._getNodeInternal(t);e(i)&&e(i.node)&&(i.node.geometryObb=null,g(i.node.renderMbs),m(i.node.serviceObbInRenderSR))}invalidateVisibilityObbs(){t(this.rootNode)||this.traverse(this.rootNode,(e=>(e.visibilityObb=this._computeVisibilityObb(e),e.geometryObb=null,!0)))}_updateElevationRange(i){const s=this._getNodeInternal(i);if(t(s))return null;const n=e(s.node)?s.node:s.ref;if(t(n))return null;const r=n.elevationRange;if(e(r)&&r.valid)return r;const o=new h;let a=!1;for(let e=0;e<s.childCount;e++){const s=this._updateElevationRange(this.getChildIndex(i,e));t(s)?a=!0:(o.min=Math.min(o.min,s.min),o.max=Math.max(o.max,s.max))}if(0===s.childCount||a&&e(s.node)&&s.node.resources.geometry){const t=this._viewportQueries.getElevationRange(n);e(t)&&(o.min=Math.min(o.min,t.min),o.max=Math.max(o.max,t.max))}return e(r)&&r.min===o.min&&r.max===o.max?(r.valid=!0,r):(o.valid=!0,n.elevationRange=o,this.invalidateBoundingVolumeCache(i),o)}isNodeVisible(i){const s=this._getNodeInternal(i);if(t(s)||e(s.ref)&&!s.ref.mbs)return!0;if(this.needNodeElevationRange&&this._updateElevationRange(i),!w(s.visibilityCache,this._visibilityCacheVersion)){const i=s.node,n=e(i)&&(t(s.ref)||e(i.visibilityObb))?i:e(s.ref)?s.ref:null;if(this._layerHasFilter&&this._computeNodeFiltering&&(e(i)||e(s.ref))&&s.filterImpact===u.NotChecked){const t=e(i)?i.mbs:e(s.ref)?s.ref.mbs:null;s.filterImpact=null!=t?this._computeNodeFiltering(t):u.Unmodified}const r=e(i)&&s.filterImpact===u.Culled,o=!(e(i)&&i.imModificationImpact===c.Culled)&&(!n||this._viewportQueries.isNodeVisible(n))&&!r;return s.visibilityCache=C(o,this._visibilityCacheVersion),o}return M(s.visibilityCache)}isGeometryVisible(t){if(!this.isNodeVisible(t))return!1;const i=this._getNodeInternal(t);return!(e(i)&&e(i.node)&&e(i.node.geometryObb)&&(!this.layerHasModifications||i.node.imModificationImpact!==c.NotChecked))||this._viewportQueries.isGeometryVisible(i.node)}_traverseCoverage(s,n,r,o,a){const d=this._getPage(s);if(t(d)||0===n.childCount)return;const l=n.childOffset+n.childCount,h=new Array;for(let t=n.childOffset;t<l;++t){const i=d.children[t],s=this._getNodeInternal(i);e(s)&&e(s.node)&&this.isGeometryVisible(i)&&h.push(s)}o/=h.length;for(const e of h){const t=i(e.node).index;this._isLoaded(t)||this._isReloading(t)?(a.delta=Math.max(a.delta,r),a.coverage+=o):this._traverseCoverage(t,e,r+1,o,a)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const i=this._getNodeInternal(e);if(t(i))return!1;if("always"===this.holeFilling)return!0;if(w(i.useAsHole,this._version))return M(i.useAsHole);const s={delta:0,coverage:0};this._traverseCoverage(e,i,0,1,s);const n=s.delta*s.coverage<=.5;return i.useAsHole=C(n,this._version),n}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.add.prune(),this._updates.update.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=I(this._version)}imModificationsChanged(t){this.layerHasModifications=t,this._forAllNodes((({node:t})=>{e(t)&&(t.imModificationImpact=c.NotChecked,t.visibilityObb=this._computeVisibilityObb(t),t.hasModifications&&this.invalidateGeometryVisibility(t.index))})),this.invalidateVisibilityCache()}layerFilterChanged(t){this._layerHasFilter=t,this._forAllNodes((t=>{if(e(t)){t.filterImpact=u.NotChecked;const i=t.node;e(i)&&this.invalidateNodeVisibilityCache(i.index)}})),this.invalidateVisibilityCache()}update(s,n,r){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(n),this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missing.clear(),this._prefetch.clear(),this._updates.reset(s),y.clear();let o=!0;const a=new O,d=new O,l=this._imModificationUncategorized;l.clear();const h=new Set,u=(u,_,g)=>{if(t(_)){let e=this._entryPriority(u);e===1/0&&(e=this._entryPriority(g));const t=S(u,this._nodesPerPage);return y.set(t,Math.max(e,y.get(t)||0)),this._loading.has(t)||this._failedPages.has(t)||this._missing.push(t),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const m=_.node;if(this._updateNodeFeatureEstimate(m,d),t(m)){const e=this._entryPriority(u);return this._loading.has(u)||this._failedNodes.has(u)||(this._missing.push(u),y.set(u,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const f=i(this._getPage(u));if(0===this._missing.length&&0===this._nodesPerPage)for(let t=0;t<_.childCount;t++){const i=f.children[_.childOffset+t],s=this._getNodeInternal(i);!e(s)||s.node||this._loading.has(i)||this._failedNodes.has(i)||(y.set(i,this._entryPriority(i)),this._prefetch.push(i))}if(m.failed||!m.resources.hasFeatureData)return void(o&&_.childCount>0&&this._isSelected(m)&&(o=!1));if(h.add(m.id),this._isLoaded(u)){if(a.known+=m.memory,++a.knownNodes,this._isSelected(m)?_.childCount>0&&(o=!1):(a.unremoved+=m.memory,o=!1),this._needsUpdate(m)){const e=this._entryPriority(u);y.set(u,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(u)}return}if(m.memory&&(a.known+=m.memory,++a.knownNodes),!this._isSelected(m))return void(this._isReloading(u)&&this._updates.remove.push(u));if(_.childCount>0&&(o=!1),m.memory?(a.missing+=m.memory,a.known+=m.memory,++a.knownNodes):++a.missingNodes,s.includes(m.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._entryPriority(u)),void(this._updates.cancel=this._updates.cancel.filter((e=>e!==m.index)));if(!n.done&&this._enable(m))return void n.madeProgress();const v=this._entryPriority(u);y.set(u,v),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,v),this._updates.add.push(u),this.layerHasModifications&&r&&e(m)&&m.imModificationImpact===c.NotChecked&&l.push(u)};this.traverseVisible(u);const _=this._updates.add;_.length>0&&this.layerHasModifications&&(l.length>0&&r?.(l),_.filterInPlace((e=>{const i=this._getNodeInternal(e),s=t(i)||t(i.node)||i.node.imModificationImpact!==c.Culled;return s||this.invalidateNodeVisibilityCache(e),s}))),this._unloadedMemoryEstimate=a.missing-a.unremoved,a.knownNodes>3&&a.missingNodes>0&&(this._unloadedMemoryEstimate+=a.known/a.knownNodes*a.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate),this._featureEstimate.estimate=this._computeFeatureEstimate(d),this._featureEstimate.leavesReached=o,this._missing.sort(((e,t)=>e-t)),this._missing.filterInPlace(((e,t)=>t<1||this._missing.data[t-1]!==e)),this._missing.sort(((e,t)=>y.get(e)-y.get(t))),this._missing.length>0&&(this._maxUnloadedPrio=y.get(this._missing.back()),this._prefetch.clear()),this._updates.add.filterInPlace((e=>y.get(e)>=this._maxUnloadedPrio)).sort(((e,t)=>y.get(e)-y.get(t))),this._updates.update.sort(((e,t)=>y.get(e)-y.get(t))),this._indexMissing=this._loading.size+this._missing.length,this._dirty=this._indexMissing>0,y.clear()}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let s=t,n=t,r=i,o=10;for(;o--;){const i=new O;this._updateFeatureEstimate(s,i);if(this._computeFeatureEstimate(i)<=e){if(s>=t||i.missingNodes>0||0===o)break;r=s,s=.5*(s+n)}else n=s,s=.5*(s+r)}return this._version=I(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,s)}_updateFeatureEstimate(t,i){this._version=I(this._version),this._viewportQueries.updateScreenSpaceErrorBias(t),this.traverseVisible(((t,s)=>this._updateNodeFeatureEstimate(e(s)?s.node:void 0,i)))}_updateNodeFeatureEstimate(i,s){if(!(t(i)||i.failed||t(i.numFeatures)))return this._isLoaded(i.index)?(s.known+=i.numFeatures,++s.knownNodes,void(this._isSelected(i)||(s.unremoved+=i.numFeatures))):void(this._isSelected(i)&&(e(i.numFeatures)?(s.missing+=i.numFeatures,s.known+=i.numFeatures,++s.knownNodes):++s.missingNodes))}_computeFeatureEstimate(e){let t=e.known-e.unremoved;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.known/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._missing)}prefetch(){return this._prefetch.sort(((e,t)=>y.get(e)-y.get(t))),this._load(this._prefetch)}_load(e){if(0===e.length||!this._canRequest())return!1;for(;e.length>0&&this._canRequest();)0===this._nodesPerPage?this._loadNode(e.pop()):this._loadPage(e.pop());return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetch.length>0}get indexLoading(){return this._loading.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(t(e))return null;let i=this._nodeTraversalState.get(e.index);if(i&&w(i.version,this._version))return i;const s=this._viewportQueries.getLodLevel(e),n=this._viewportQueries.hasLOD(e);let r=!0;if(n){const t=this.getParentIndex(e.index);if(t>=0){const e=this._nodeTraversalState.get(t);r=!!e&&s>e.lodLevel}else r=s>0}else r=0===e.childCount;return i?(i.lodLevel=s,i.isChosen=r,i.version=C(!0,this._version),i):(i=new _(n,r,s,C(!0,this._version)),this._nodeTraversalState.set(e.index,i),i)}_loadNode(e){this._loading.add(e);const s=i(this._getNodeInternal(e)).ref;if(t(s))return void this._failedNodes.add(e);const r=s.id,o=this._urlPrefix+r,a=()=>{this._loading.delete(e),0===this._missing.length&&0===this._loading.size&&this.requestUpdate()};this._streamDataController.request(o,"json").then((t=>{a();const i=this._validateNode(r,t);if(null==i)return;i.obb&&this.invalidateNodeVisibilityCache(e);const s=this._addNode(i,e);this.nodeTraversalState(s)}),(t=>{a(),n(t)||(this._logger.error("#loadNode()",this._logLayer,"Error loading node: "+o),this._failedNodes.add(e))}))}_validateNode(e,t){if(null==t||"object"!=typeof t||t.id!==e)return this._logger.error("#validateNode()",this._logLayer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error("#validateNode()",this._logLayer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this._logger.warn("#validateNode()",this._logLayer,`Invalid shared resource href on node "${e}"`),null==t.geometryData||Array.isArray(t.geometryData)&&1===t.geometryData.length&&"./geometries/0"===t.geometryData[0].href||this._logger.warn("#validateNode()",this._logLayer,`Invalid geometry data on node "${e}"`),null==t.attributeData||Array.isArray(t.attributeData)&&!t.attributeData.some(((e,t)=>e.href!==`./attributes/f_${t}/0`))||this._logger.warn("#validateNode()",this._logLayer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn("#validateNode()",this._logLayer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);const i=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,s=t.featureData&&1===t.featureData.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,n=t=>{if(null==t)return null;const i=t=>this._logger.error("#validateNode()",this._logLayer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;t.href&&t.href!=="../"+t.id&&this._logger.error("#validateNode()",this._logLayer,`Invalid node href on node "${e}"`);const s=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,n=new d(`${t.id}`,t.mbs);return n.serviceObb=s,n.visibilityObb=this._computeVisibilityObb(n),n},r=Array.isArray(t.children)?t.children.map(n).filter((e=>null!=e)):null;return{id:e,mbs:t.mbs,obb:i,children:r,resources:{hasFeatureData:t.featureData&&t.featureData.length>0,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:null!=t.geometryData?e:void 0},version:"string"==typeof t.version?t.version:null,lodSelection:Array.isArray(t.lodSelection)?t.lodSelection:null,numFeatures:s}}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes((t=>{e(t.node)&&(t.node.failed=!1)}))}_entryPriority(i){const s=this._getNodeInternal(i),n=this.getParentIndex(i);if(t(s)||n<0&&null==s.node)return n<0?1/0:this._entryPriority(n);let r=0;if(s.node&&n>=0){const e=this._nodeTraversalState.get(n);null!=e&&(r=e.lodLevel)}let o=this.progressiveLoadPenalty;for(let e=i;e>=0;e=this.getParentIndex(e))if(this._isLoaded(e)){o=0;break}const a=e(s.ref)?this._viewportQueries.distToPOI(s.ref):e(s.node)?this._viewportQueries.distToPOI(s.node):0;return-a-r*(a+this.progressiveLoadPenalty)+o}traverseVisible(e){const i=this._getNodeInternal(this._rootIndex);t(i)?e(this._rootIndex,null,null):this._traverseVisible(this._rootIndex,-1,i,e)}_traverseVisible(t,s,n,r){if(n.node&&0===n.childCount)return void(this.isGeometryVisible(t)&&r(t,n,s));if(!this.isNodeVisible(t))return;if(r(t,n,s),null==n.node)return;const o=this.nodeTraversalState(n.node);if(o?.nodeHasLOD&&o.lodLevel===this._maxLodLevel)return;const a=i(this._getPage(t));for(let i=0;i<n.childCount;i++){const s=a.children[n.childOffset+i],o=this._getNodeInternal(s);e(o)?this._traverseVisible(s,t,o,r):r(s,null,t)}}traverse(e,t){t(e)&&this.traverseChildren(e,t)}traverseChildren(t,i){const s=t.index,n=this._getNodeInternal(s);e(n)&&this._traverseChildren(s,n,i)}_traverseChildren(i,s,n){const r=this._getPage(i);if(t(r))return;const o=s.childOffset+s.childCount;for(let t=s.childOffset;t<o;++t){const i=r.children[t],s=this._getNodeInternal(i);e(s)&&e(s.node)&&n(s.node)&&this._traverseChildren(i,s,n)}}updateChildrenLoaded(t,i){let s=this.getNode(t);for(;e(s);)s.childrenLoaded+=i,s=this.getParent(s.index)}checkChildrenLoadedInvariant(){if(t(this.rootNode))return!0;const e=[],i=t=>{let s=this._isLoaded(t.index)||this._isReloading(t.index)?1:0;return this.traverseChildren(t,(e=>(s+=i(e),!1))),t.childrenLoaded!==s&&e.push(t.index),s};return i(this.rootNode),e.length&&this._logger.error("childrenLoaded invariant broken at following nodes: "+e.join(",")),e.length>0}updateStats(e){if(this._updates.add.length>0&&(e.nodes+=" + "+this._updates.add.length),(this._indexMissing||this._prefetch.length>0)&&(e.index+=" + "+this._indexMissing||this._prefetch.length),e.prio=this._maxProcessingPrio,this._featureEstimate.estimate){const t=this._featureEstimate.estimate-e.features;t>0?e.features+=" + "+t:t<0&&(e.features+=" - "+-t)}}updateElevationInfo(e,t){this.needNodeElevationRange=t&&e&&("relative-to-ground"===e.mode||"on-the-ground"===e.mode),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes((t=>{P(t),e(t.node)&&(t.node.elevationRange=null),e(t.ref)&&(t.ref.elevationRange=null)}))}_forAllNodes(e){for(let t=0;t<this._nodePages.length;t++){const i=this._nodePages[t];if(i){const s=t*this._nodesPerPage;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],s+t)}}}get test(){return{addNode:(e,t)=>this._addNode(e,t)}}}const y=new Map;class N{constructor(e){this.missing=e,this.update=new s({deallocator:null}),this.add=new s({deallocator:null}),this.remove=new s({deallocator:null}),this.cancel=[]}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function P(t){e(t.node)&&(g(t.node.renderMbs),m(t.node.serviceObbInRenderSR)),e(t.ref)&&(g(t.ref.renderMbs),m(t.ref.serviceObbInRenderSR))}function x(e){return f(e,-2)}function I(e){return f(e,2)}function C(e,t){return t+(e?1:0)}function w(e,t){return(-2&e)===t}function M(e){return 1==(1&e)}function S(e,t){return 0===t?0:e/t|0}function R(e,t){return 0===t?e:e%t}const L=[["maxScreenThreshold",a.MaxScreenThreshold],["screenSpaceRelative",a.ScreenSpaceRelative],["removedFeatureDiameter",a.RemovedFeatureDiameter],["distanceRangeFromDefaultCamera",a.DistanceRangeFromDefaultCamera]];function E(e){if(e)for(let t=0;t<e.length;t++)for(const i of L)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:a.None,maxError:0}}class O{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}function V(e){return Math.sqrt(e*(4/Math.PI))}export{p as I3SIndex,E as selectErrorMetric};
5
+ import{isSome as e,isNone as t,unwrap as i}from"../../../../core/maybe.js";import s from"../../../../core/PooledArray.js";import{isAbortError as n}from"../../../../core/promiseUtils.js";import{l as r}from"../../../../chunks/vec3.js";import{b as o}from"../../../../chunks/vec4f64.js";import{LodMetric as a,NodeBase as d,Node as l,ElevationRange as h,NodeFilterImpact as u,NodeIMModificationImpact as c,NodeTraversalState as _}from"./I3SNode.js";import{invalidateMbs as g,invalidateObb as m,addWraparound as f}from"./I3SUtil.js";import{clone as v}from"../../support/orientedBoundingBox.js";class b{constructor(e,t,i,s,n){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this.ref=s,this.node=n,this.useAsHole=0,this.filterImpact=u.NotChecked}}class p{constructor(e,t,i,n,r,o,d,l,h,u,c,_,g,m){this._streamDataController=i,this._viewportQueries=n,this._logger=r,this.holeFilling=o,this._isLoaded=d,this._isReloading=l,this._isSelected=h,this._enable=u,this._needsUpdate=c,this._canRequest=_,this._computeVisibilityObb=g,this._computeNodeFiltering=m,this._dirty=!0,this._nodePages=[],this._nodeCount=0,this._nodesPerPage=0,this._rootIndex=0,this._lodMetric=a.None,this._lodConversion=e=>e,this._urlPrefix="",this._loading=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._nodeTraversalState=new Map,this._version=I(0),this._visibilityCacheVersion=I(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._missing=new s({deallocator:null}),this._prefetch=new s({deallocator:null}),this._updates=new N(this._missing),this._imModificationUncategorized=new s({deallocator:null}),this.ignoreServiceObb=!1,this.progressiveLoadPenalty=0,this._pageQueue=[],this.needNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._logLayer=e,e.serviceUpdateTimeStamp&&e.serviceUpdateTimeStamp.lastUpdate&&(this._lastUpdate=`${e.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,this._init(t)}_init(e){if("page"===e.type){switch(this._urlPrefix=e.urlPrefix,this._nodesPerPage=e.pageSize,this._rootIndex=e.rootIndex,e.lodMetric){case"maxScreenThreshold":this._lodMetric=a.MaxScreenThreshold;break;case"maxScreenThresholdSQ":this._lodMetric=a.MaxScreenThreshold,this._lodConversion=V}this._addPage(S(this._rootIndex,this._nodesPerPage),e.rootPage),this._updateParentsAndLevel()}else if("node"===e.type){this._urlPrefix=e.urlPrefix,this._nodePages.push({nodes:[],children:[],parents:[]}),this._makeRefNode(new d(e.rootNode.id,null),-1);const t=this._validateNode(e.rootNode.id,e.rootNode);t&&this._addNode(t,0)}}_loadPage(e){this._loading.add(e);const t=this._urlPrefix+e;this._streamDataController.request(t,"json").then((t=>{this._pageQueue.push({pageIndex:e,page:t})})).catch((t=>{this._loading.delete(e),n(t)||(this._failedPages.add(e),this._logger.error("#loadPage()",this._logLayer,`Error when loading page ${e}`,t))}))}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){const{pageIndex:t,page:i}=this._pageQueue.shift();this._addPage(t,i),this._loading.delete(t),e.madeProgress()}this._updateParentsAndLevel()}_addPage(e,t){for(let r=this._nodePages.length;r<e;r++)this._nodePages[r]=null;const i=[],s=[],n=t.nodes.map(((t,n)=>{const a=i.length,d=t.children?t.children.length:0;s.push(-1);for(let e=0;e<d;e++)i.push(t.children[e]);const h=`${t.index}`,u=v(t.obb),c=o([u.center[0],u.center[1],u.center[2],r(u.halfSize)]),_=t.mesh&&t.mesh.attribute,g=t.mesh&&t.mesh.geometry,m=t.mesh&&t.mesh.material,f={hasSharedResource:!1,hasFeatureData:!!g,attributes:_&&null!=_.resource?`${_.resource}`:void 0,geometry:g&&null!=g.resource?`${g.resource}`:void 0,texture:m&&null!=m.resource?`${m.resource}`:void 0,geometryDefinition:g?g.definition:-1,materialDefinition:m?m.definition:-1},p=new l(h,e*this._nodesPerPage+n,c,d,0,f,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),g?g.featureCount:null);return p.serviceObb=u,p.visibilityObb=this._computeVisibilityObb(p),p.vertexCount=g?g.vertexCount:0,new b(a,d,x(this._visibilityCacheVersion),null,p)}));this._nodePages[e]={nodes:n,children:i,parents:s},this._nodeCount+=n.length}_updateParentsAndLevel(){const t=new Array,i=(i,s,n)=>{const r=this._getPage(i);if(e(r)){const o=R(i,this._nodesPerPage);r.parents[o]=s;const a=r.nodes[o].node;e(a)&&(a.level=n,t.push(i))}};for(i(this._rootIndex,-1,0);t.length;){const s=t.pop(),n=this.getNode(s);if(e(n))for(let e=0;e<n.childCount;e++){i(this.getChildIndex(n.index,e),s,n.level+1),this._maxLevel=Math.max(this._maxLevel,n.level+1)}}}_getPage(e){return this._nodePages[S(e,this._nodesPerPage)]}_getNodeInternal(e){const i=this._getPage(e);return t(i)?null:i.nodes[R(e,this._nodesPerPage)]}_addNode(t,s){null!=t.children&&this.populateChildren(s,t.children);const n=this.getParent(s),r=e(n)?n.level+1:0;this._maxLevel=Math.max(this._maxLevel,t.children?r+1:r);const{lodMetric:a,maxError:d}=E(t.lodSelection),h=i(this._getNodeInternal(s));return h.node=new l(t.id,s,o(t.mbs),h.childCount,r,t.resources,t.version,a,d,t.numFeatures),t.obb&&(h.node.serviceObb=v(t.obb)),h.node.visibilityObb=this._computeVisibilityObb(h.node),e(h.ref)&&(null==h.ref.mbs&&(h.ref.mbs=t.mbs),h.node.renderMbs=h.ref.renderMbs,h.node.serviceObbInRenderSR=h.ref.serviceObbInRenderSR,h.ref.visibilityObb=h.node.visibilityObb),h.node}_makeRefNode(e,t){const i=this._nodePages[0];if(null==i)return-1;const s=i.nodes.length;return i.nodes.push(new b(0,0,x(this._visibilityCacheVersion),e,null)),this._nodeCount++,i.parents.push(t),g(e.renderMbs),m(e.serviceObbInRenderSR),s}populateChildren(e,t){const s=i(this._getNodeInternal(e)),n=i(this._getPage(e));s.childOffset=n.children.length,s.childCount=t.length;for(let i=0;i<t.length;i++){const s=this._makeRefNode(t[i],e);n.children.push(s)}}getNode(t){const i=this._getNodeInternal(t);return e(i)?i.node:null}getIndexById(t){let i;return this._forAllNodes(((s,n)=>{(e(s.node)&&s.node.id===t||e(s.ref)&&s.ref.id===t)&&(i=n)})),i}getNodeById(e){const t=this.getIndexById(e);return null!=t&&t>=0?this.getNode(t):null}getChildIndex(e,i){const s=this._getPage(e);if(t(s))return-1;const n=s.nodes[R(e,this._nodesPerPage)];return s.children[n.childOffset+i]}getParentIndex(t){const i=this._getPage(t);return e(i)?i.parents[R(t,this._nodesPerPage)]:-1}getParent(e){return(e=this.getParentIndex(e))>=0?this.getNode(e):null}isLeaf(t){const i=this._getNodeInternal(t);return e(i)&&0===i.childCount}get rootNode(){return this.getNode(this._rootIndex)}get size(){return this._nodeCount}removeAllGeometryObbs(){this._forAllNodes((t=>{e(t.node)&&(t.node.geometryObb=null)}))}invalidateVisibilityCache(){this._visibilityCacheVersion=I(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(t){const i=this._getNodeInternal(t);e(i)&&this.invalidateNodeVisibilityCacheInternal(i)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=x(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(t){const i=this._getNodeInternal(t);e(i)&&(P(i),this.invalidateNodeVisibilityCacheInternal(i))}updateElevationChanged(i){const s=this._getNodeInternal(i);if(t(s))return;if(!this.needNodeElevationRange)return void this.invalidateBoundingVolumeCache(i);const n=e(s.node)?s.node:s.ref;if(t(n))return;const r=n.elevationRange;t(r)||(r.valid=!1)}invalidateGeometryVisibility(t){const i=this._getNodeInternal(t);e(i)&&e(i.node)&&(i.node.geometryObb=null,g(i.node.renderMbs),m(i.node.serviceObbInRenderSR))}invalidateVisibilityObbs(){t(this.rootNode)||this.traverse(this.rootNode,(e=>(e.visibilityObb=this._computeVisibilityObb(e),e.geometryObb=null,!0)))}_updateElevationRange(i){const s=this._getNodeInternal(i);if(t(s))return null;const n=e(s.node)?s.node:s.ref;if(t(n))return null;const r=n.elevationRange;if(e(r)&&r.valid)return r;const o=new h;let a=!1;for(let e=0;e<s.childCount;e++){const s=this._updateElevationRange(this.getChildIndex(i,e));t(s)?a=!0:(o.min=Math.min(o.min,s.min),o.max=Math.max(o.max,s.max))}if(0===s.childCount||a&&e(s.node)&&s.node.resources.geometry){const t=this._viewportQueries.getElevationRange(n);e(t)&&(o.min=Math.min(o.min,t.min),o.max=Math.max(o.max,t.max))}return e(r)&&r.min===o.min&&r.max===o.max?(r.valid=!0,r):(o.valid=!0,n.elevationRange=o,this.invalidateBoundingVolumeCache(i),o)}isNodeVisible(i){const s=this._getNodeInternal(i);if(t(s)||e(s.ref)&&!s.ref.mbs)return!0;if(this.needNodeElevationRange&&this._updateElevationRange(i),!w(s.visibilityCache,this._visibilityCacheVersion)){const i=s.node,n=e(i)&&(t(s.ref)||e(i.visibilityObb))?i:e(s.ref)?s.ref:null;if(this._layerHasFilter&&this._computeNodeFiltering&&(e(i)||e(s.ref))&&s.filterImpact===u.NotChecked){const t=e(i)?i.mbs:e(s.ref)?s.ref.mbs:null;s.filterImpact=null!=t?this._computeNodeFiltering(t):u.Unmodified}const r=e(i)&&s.filterImpact===u.Culled,o=!(e(i)&&i.imModificationImpact===c.Culled)&&(!n||this._viewportQueries.isNodeVisible(n))&&!r;return s.visibilityCache=C(o,this._visibilityCacheVersion),o}return M(s.visibilityCache)}isGeometryVisible(t){if(!this.isNodeVisible(t))return!1;const i=this._getNodeInternal(t);return!(e(i)&&e(i.node)&&e(i.node.geometryObb)&&(!this.layerHasModifications||i.node.imModificationImpact!==c.NotChecked))||this._viewportQueries.isGeometryVisible(i.node)}_traverseCoverage(s,n,r,o,a){const d=this._getPage(s);if(t(d)||0===n.childCount)return;const l=n.childOffset+n.childCount,h=new Array;for(let t=n.childOffset;t<l;++t){const i=d.children[t],s=this._getNodeInternal(i);e(s)&&e(s.node)&&this.isGeometryVisible(i)&&h.push(s)}o/=h.length;for(const e of h){const t=i(e.node).index;this._isLoaded(t)||this._isReloading(t)?(a.delta=Math.max(a.delta,r),a.coverage+=o):this._traverseCoverage(t,e,r+1,o,a)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const i=this._getNodeInternal(e);if(t(i))return!1;if("always"===this.holeFilling)return!0;if(w(i.useAsHole,this._version))return M(i.useAsHole);const s={delta:0,coverage:0};this._traverseCoverage(e,i,0,1,s);const n=s.delta*s.coverage<=.5;return i.useAsHole=C(n,this._version),n}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.add.prune(),this._updates.update.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=I(this._version)}imModificationsChanged(t){this.layerHasModifications=t,this._forAllNodes((({node:t})=>{e(t)&&(t.imModificationImpact=c.NotChecked,t.visibilityObb=this._computeVisibilityObb(t),t.hasModifications&&this.invalidateGeometryVisibility(t.index))})),this.invalidateVisibilityCache()}layerFilterChanged(t){this._layerHasFilter=t,this._forAllNodes((t=>{if(e(t)){t.filterImpact=u.NotChecked;const i=t.node;e(i)&&this.invalidateNodeVisibilityCache(i.index)}})),this.invalidateVisibilityCache()}update(s,n,r){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(n),this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missing.clear(),this._prefetch.clear(),this._updates.reset(s),y.clear();let o=!0;const a=new O,d=new O,l=this._imModificationUncategorized;l.clear();const h=new Set,u=(u,_,g)=>{if(t(_)){let e=this._entryPriority(u);e===1/0&&(e=this._entryPriority(g));const t=S(u,this._nodesPerPage);return y.set(t,Math.max(e,y.get(t)||0)),this._loading.has(t)||this._failedPages.has(t)||this._missing.push(t),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const m=_.node;if(this._updateNodeFeatureEstimate(m,d),t(m)){const e=this._entryPriority(u);return this._loading.has(u)||this._failedNodes.has(u)||(this._missing.push(u),y.set(u,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const f=i(this._getPage(u));if(0===this._missing.length&&0===this._nodesPerPage)for(let t=0;t<_.childCount;t++){const i=f.children[_.childOffset+t],s=this._getNodeInternal(i);!e(s)||s.node||this._loading.has(i)||this._failedNodes.has(i)||(y.set(i,this._entryPriority(i)),this._prefetch.push(i))}if(m.failed||!m.resources.hasFeatureData)return void(o&&_.childCount>0&&this._isSelected(m)&&(o=!1));if(h.add(m.id),this._isLoaded(u)){if(a.known+=m.memory,++a.knownNodes,this._isSelected(m)?_.childCount>0&&(o=!1):(a.unremoved+=m.memory,o=!1),this._needsUpdate(m)){const e=this._entryPriority(u);y.set(u,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(u)}return}if(m.memory&&(a.known+=m.memory,++a.knownNodes),!this._isSelected(m))return void(this._isReloading(u)&&this._updates.remove.push(u));if(_.childCount>0&&(o=!1),m.memory?(a.missing+=m.memory,a.known+=m.memory,++a.knownNodes):++a.missingNodes,s.includes(m.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._entryPriority(u)),void(this._updates.cancel=this._updates.cancel.filter((e=>e!==m.index)));if(!n.done&&this._enable(m))return void n.madeProgress();const v=this._entryPriority(u);y.set(u,v),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,v),this._updates.add.push(u),this.layerHasModifications&&r&&e(m)&&m.imModificationImpact===c.NotChecked&&l.push(u)};this.traverseVisible(u);const _=this._updates.add;_.length>0&&this.layerHasModifications&&(l.length>0&&r?.(l),_.filterInPlace((e=>{const i=this._getNodeInternal(e),s=t(i)||t(i.node)||i.node.imModificationImpact!==c.Culled;return s||this.invalidateNodeVisibilityCache(e),s}))),this._unloadedMemoryEstimate=a.missing-a.unremoved,a.knownNodes>3&&a.missingNodes>0&&(this._unloadedMemoryEstimate+=a.known/a.knownNodes*a.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate),this._featureEstimate.estimate=this._computeFeatureEstimate(d),this._featureEstimate.leavesReached=o,this._missing.sort(((e,t)=>e-t)),this._missing.filterInPlace(((e,t)=>t<1||this._missing.data[t-1]!==e)),this._missing.sort(((e,t)=>y.get(e)-y.get(t))),this._missing.length>0&&(this._maxUnloadedPrio=y.get(this._missing.back()),this._prefetch.clear()),this._updates.add.filterInPlace((e=>y.get(e)>=this._maxUnloadedPrio)).sort(((e,t)=>y.get(e)-y.get(t))),this._updates.update.sort(((e,t)=>y.get(e)-y.get(t))),this._indexMissing=this._loading.size+this._missing.length,this._dirty=this._indexMissing>0,y.clear()}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let s=t,n=t,r=i,o=10;for(;o--;){const i=new O;this._updateFeatureEstimate(s,i);if(this._computeFeatureEstimate(i)<=e){if(s>=t||i.missingNodes>0||0===o)break;r=s,s=.5*(s+n)}else n=s,s=.5*(s+r)}return this._version=I(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,s)}_updateFeatureEstimate(t,i){this._version=I(this._version),this._viewportQueries.updateScreenSpaceErrorBias(t),this.traverseVisible(((t,s)=>this._updateNodeFeatureEstimate(e(s)?s.node:void 0,i)))}_updateNodeFeatureEstimate(i,s){if(!(t(i)||i.failed||t(i.numFeatures)))return this._isLoaded(i.index)?(s.known+=i.numFeatures,++s.knownNodes,void(this._isSelected(i)||(s.unremoved+=i.numFeatures))):void(this._isSelected(i)&&(e(i.numFeatures)?(s.missing+=i.numFeatures,s.known+=i.numFeatures,++s.knownNodes):++s.missingNodes))}_computeFeatureEstimate(e){let t=e.known-e.unremoved;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.known/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._missing)}prefetch(){return this._prefetch.sort(((e,t)=>y.get(e)-y.get(t))),this._load(this._prefetch)}_load(e){if(0===e.length||!this._canRequest())return!1;for(;e.length>0&&this._canRequest();)0===this._nodesPerPage?this._loadNode(e.pop()):this._loadPage(e.pop());return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetch.length>0}get indexLoading(){return this._loading.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(t(e))return null;let i=this._nodeTraversalState.get(e.index);if(i&&w(i.version,this._version))return i;const s=this._viewportQueries.getLodLevel(e),n=this._viewportQueries.hasLOD(e);let r=!0;if(n){const t=this.getParentIndex(e.index);if(t>=0){const e=this._nodeTraversalState.get(t);r=!!e&&s>e.lodLevel}else r=s>0}else r=0===e.childCount;return i?(i.lodLevel=s,i.isChosen=r,i.version=C(!0,this._version),i):(i=new _(n,r,s,C(!0,this._version)),this._nodeTraversalState.set(e.index,i),i)}_loadNode(e){this._loading.add(e);const s=i(this._getNodeInternal(e)).ref;if(t(s))return void this._failedNodes.add(e);const r=s.id,o=this._urlPrefix+r,a=()=>{this._loading.delete(e),0===this._missing.length&&0===this._loading.size&&this.requestUpdate()};this._streamDataController.request(o,"json").then((t=>{a();const i=this._validateNode(r,t);if(null==i)return;i.obb&&this.invalidateNodeVisibilityCache(e);const s=this._addNode(i,e);this.nodeTraversalState(s)}),(t=>{a(),n(t)||(this._logger.error("#loadNode()",this._logLayer,"Error loading node: "+o),this._failedNodes.add(e))}))}_validateNode(e,t){if(null==t||"object"!=typeof t||t.id!==e)return this._logger.error("#validateNode()",this._logLayer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error("#validateNode()",this._logLayer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this._logger.warn("#validateNode()",this._logLayer,`Invalid shared resource href on node "${e}"`),null==t.geometryData||Array.isArray(t.geometryData)&&1===t.geometryData.length&&"./geometries/0"===t.geometryData[0].href||this._logger.warn("#validateNode()",this._logLayer,`Invalid geometry data on node "${e}"`),null==t.attributeData||Array.isArray(t.attributeData)&&!t.attributeData.some(((e,t)=>e.href!==`./attributes/f_${t}/0`))||this._logger.warn("#validateNode()",this._logLayer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn("#validateNode()",this._logLayer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);const i=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,s=t.featureData&&1===t.featureData.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,n=t=>{if(null==t)return null;const i=t=>this._logger.error("#validateNode()",this._logLayer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;t.href&&t.href!=="../"+t.id&&this._logger.error("#validateNode()",this._logLayer,`Invalid node href on node "${e}"`);const s=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,n=new d(`${t.id}`,t.mbs);return n.serviceObb=s,n.visibilityObb=this._computeVisibilityObb(n),n},r=Array.isArray(t.children)?t.children.map(n).filter((e=>null!=e)):null;return{id:e,mbs:t.mbs,obb:i,children:r,resources:{hasFeatureData:t.featureData&&t.featureData.length>0,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:null!=t.geometryData?e:void 0},version:"string"==typeof t.version?t.version:null,lodSelection:Array.isArray(t.lodSelection)?t.lodSelection:null,numFeatures:s}}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes((t=>{e(t.node)&&(t.node.failed=!1)}))}_entryPriority(i){const s=this._getNodeInternal(i),n=this.getParentIndex(i);if(t(s)||n<0&&null==s.node)return n<0?1/0:this._entryPriority(n);let r=0;if(s.node&&n>=0){const e=this._nodeTraversalState.get(n);null!=e&&(r=e.lodLevel)}let o=this.progressiveLoadPenalty;for(let e=i;e>=0;e=this.getParentIndex(e))if(this._isLoaded(e)){o=0;break}const a=e(s.ref)?this._viewportQueries.distToPOI(s.ref):e(s.node)?this._viewportQueries.distToPOI(s.node):0;return-a-r*(a+this.progressiveLoadPenalty)+o}traverseVisible(e){const i=this._getNodeInternal(this._rootIndex);t(i)?e(this._rootIndex,null,null):this._traverseVisible(this._rootIndex,-1,i,e)}_traverseVisible(t,s,n,r){if(n.node&&0===n.childCount)return void(this.isGeometryVisible(t)&&r(t,n,s));if(!this.isNodeVisible(t))return;if(r(t,n,s),null==n.node)return;const o=this.nodeTraversalState(n.node);if(o?.nodeHasLOD&&o.lodLevel===this._maxLodLevel)return;const a=i(this._getPage(t));for(let i=0;i<n.childCount;i++){const s=a.children[n.childOffset+i],o=this._getNodeInternal(s);e(o)?this._traverseVisible(s,t,o,r):r(s,null,t)}}traverse(e,t){t(e)&&this.traverseChildren(e,t)}traverseChildren(t,i){const s=t.index,n=this._getNodeInternal(s);e(n)&&this._traverseChildren(s,n,i)}_traverseChildren(i,s,n){const r=this._getPage(i);if(t(r))return;const o=s.childOffset+s.childCount;for(let t=s.childOffset;t<o;++t){const i=r.children[t],s=this._getNodeInternal(i);e(s)&&e(s.node)&&n(s.node)&&this._traverseChildren(i,s,n)}}updateChildrenLoaded(t,i){let s=this.getNode(t);for(;e(s);)s.childrenLoaded+=i,s=this.getParent(s.index)}checkChildrenLoadedInvariant(){if(t(this.rootNode))return!0;const e=[],i=t=>{let s=this._isLoaded(t.index)||this._isReloading(t.index)?1:0;return this.traverseChildren(t,(e=>(s+=i(e),!1))),t.childrenLoaded!==s&&e.push(t.index),s};return i(this.rootNode),e.length&&this._logger.error("childrenLoaded invariant broken at following nodes: "+e.join(",")),e.length>0}updateStats(e){if(this._updates.add.length>0&&(e.nodes+=" + "+this._updates.add.length),(this._indexMissing||this._prefetch.length>0)&&(e.index+=" + "+this._indexMissing||this._prefetch.length),e.prio=this._maxProcessingPrio,this._featureEstimate.estimate){const t=this._featureEstimate.estimate-e.features;t>0?e.features+=" + "+t:t<0&&(e.features+=" - "+-t)}}updateElevationInfo(e,t){this.needNodeElevationRange=t&&!!e&&("relative-to-ground"===e.mode||"on-the-ground"===e.mode),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes((t=>{P(t),e(t.node)&&(t.node.elevationRange=null),e(t.ref)&&(t.ref.elevationRange=null)}))}_forAllNodes(e){for(let t=0;t<this._nodePages.length;t++){const i=this._nodePages[t];if(i){const s=t*this._nodesPerPage;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],s+t)}}}get test(){return{addNode:(e,t)=>this._addNode(e,t)}}}const y=new Map;class N{constructor(e){this.missing=e,this.update=new s({deallocator:null}),this.add=new s({deallocator:null}),this.remove=new s({deallocator:null}),this.cancel=[]}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function P(t){e(t.node)&&(g(t.node.renderMbs),m(t.node.serviceObbInRenderSR)),e(t.ref)&&(g(t.ref.renderMbs),m(t.ref.serviceObbInRenderSR))}function x(e){return f(e,-2)}function I(e){return f(e,2)}function C(e,t){return t+(e?1:0)}function w(e,t){return(-2&e)===t}function M(e){return 1==(1&e)}function S(e,t){return 0===t?0:e/t|0}function R(e,t){return 0===t?e:e%t}const L=[["maxScreenThreshold",a.MaxScreenThreshold],["screenSpaceRelative",a.ScreenSpaceRelative],["removedFeatureDiameter",a.RemovedFeatureDiameter],["distanceRangeFromDefaultCamera",a.DistanceRangeFromDefaultCamera]];function E(e){if(e)for(let t=0;t<e.length;t++)for(const i of L)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:a.None,maxError:0}}class O{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}function V(e){return Math.sqrt(e*(4/Math.PI))}export{p as I3SIndex,E as selectErrorMetric};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{isNone as e,isSome as i}from"../../../../core/maybe.js";import o from"../../../../core/PooledArray.js";import{NodeState as s}from"./I3SNode.js";import{FadeDirection as d}from"../support/I3SLayerView.js";class t{constructor(e){this._layerView=e,this._lodGlobalDirty=!1}startNodeLoading(e,i,o,s){this._maxLodLevel=s.maxLodLevel,this._index=o,this._isNodeInScaleBounds=e,this._removeNodes=i}shouldLoadNode(i){if(e(i))return!1;const o=this._index.nodeTraversalState(i);return!!this._isChosenMaxLOD(o)||!!o.isChosen&&this._childrenRequireLoading(i)}setLodGlobalDirty(){this._lodGlobalDirty=!0}get requiresLODGlobalHandling(){return null!=this._index&&!0===this._lodGlobalDirty}lodGlobalHandling(e){if(!this.requiresLODGlobalHandling)return!1;this._lodGlobalDirty=!1;const i=this._layerView.view.resourceController.memoryController.usedMemory,o=Math.max(0,Math.floor(10*(i-1)));r.clear(),this._lodGlobalHandling(this._index.rootNode,o,!1,this._layerView.nodeCrossfadingEnabled);const s=r.length;this._removeNodes(r,e);const d=r.length<s;return 0!==r.length&&(this._lodGlobalDirty=!0),r.clear(),d}_lodGlobalHandling(o,t,l,n){if(e(o))return!1;const a=o.index,h=this._index,_=this._layerView,u=h.nodeTraversalState(o),c=this._isChosenMaxLOD(u),x=!o.resources.hasFeatureData;if(c&&x)return o.childrenLoaded>0&&this._removeChildrenRecursive(o),!0;const L=_.isNodeLoaded(a);if(n&&L&&c){const e=!l&&this.hasNoVisibleChildren(o);_.fadeNode(a,d.FadeIn,!e)}const N=L&&(!_.isNodeFullyFadedIn||_.isNodeFullyFadedIn(a));if(L&&(_.updateNodeState(a,c?s.Leaf:s.Hole),c))return N&&this._removeChildrenRecursive(o),N;const m=o.childCount>0;let y=m;if(m)for(let e=0;e<o.childCount;e++){const o=h.getChildIndex(a,e),s=h.getNode(o);if(i(s)){!(!h.isGeometryVisible(o)||this._lodGlobalHandling(s,t,l||N,n))&&this._isNodeInScaleBounds(s)&&(y=!1)}else h.isNodeVisible(o)&&(y=!1)}const b=L&&!c&&(y||r.length<t);b&&r.push(a),!n||b||!L||l||y||_.fadeNode(a,d.FadeIn,!1);const f=!o.resources.hasFeatureData;return y||N&&!b||f}_removeChildrenRecursive(e){this._index.traverseChildren(e,(e=>((this._layerView.isNodeLoaded(e.index)||this._layerView.isNodeReloading(e.index))&&r.push(e.index),e.childrenLoaded>0)))}hasNoVisibleChildren(e){let i=!0;return this._index.traverseChildren(e,(e=>!(!i||!this._index.isNodeVisible(e.index))&&(this._layerView.isNodeLoaded(e.index)?(i=!1,!1):e.childrenLoaded>0))),i}_childrenRequireLoading(e){let i=!1,o=!0;return this._index.traverseChildren(e,(e=>{if(!o||!this._index.isNodeVisible(e.index))return!1;const s=this._index.nodeTraversalState(e);return this._isChosenMaxLOD(s)&&this._index.isGeometryVisible(e.index)&&(i=!0),this._layerView.isNodeLoaded(e.index)?(o=!1,!1):e.childrenLoaded>0})),o&&i}_isChosenMaxLOD(e){return e.isChosen&&(!e.nodeHasLOD||e.lodLevel===this._maxLodLevel)}}const r=new o({deallocator:null});export{t as default};
5
+ import{isNone as e,isSome as i}from"../../../../core/maybe.js";import o from"../../../../core/PooledArray.js";import{NodeState as s}from"./I3SNode.js";import{FadeDirection as d}from"../support/I3SLayerView.js";class t{constructor(e){this._layerView=e,this._lodGlobalDirty=!1}startNodeLoading(e,i,o,s){this._maxLodLevel=s.maxLodLevel,this._index=o,this._isNodeInScaleBounds=e,this._removeNodes=i}shouldLoadNode(i){if(e(i))return!1;const o=this._index.nodeTraversalState(i);return!!this._isChosenMaxLOD(o)||!!o.isChosen&&this._childrenRequireLoading(i)}setLodGlobalDirty(){this._lodGlobalDirty=!0}get requiresLODGlobalHandling(){return null!=this._index&&!0===this._lodGlobalDirty}lodGlobalHandling(e){if(!this.requiresLODGlobalHandling)return!1;this._lodGlobalDirty=!1;const i=this._layerView.view.resourceController.memoryController.usedMemory,o=Math.max(0,Math.floor(10*(i-1)));r.clear(),this._lodGlobalHandling(this._index.rootNode,o,!1,!!this._layerView.nodeCrossfadingEnabled);const s=r.length;this._removeNodes(r,e);const d=r.length<s;return 0!==r.length&&(this._lodGlobalDirty=!0),r.clear(),d}_lodGlobalHandling(o,t,l,n){if(e(o))return!1;const a=o.index,h=this._index,_=this._layerView,u=h.nodeTraversalState(o),c=this._isChosenMaxLOD(u),x=!o.resources.hasFeatureData;if(c&&x)return o.childrenLoaded>0&&this._removeChildrenRecursive(o),!0;const L=_.isNodeLoaded(a);if(n&&L&&c){const e=!l&&this.hasNoVisibleChildren(o);_.fadeNode(a,d.FadeIn,!e)}const N=L&&(!_.isNodeFullyFadedIn||_.isNodeFullyFadedIn(a));if(L&&(_.updateNodeState(a,c?s.Leaf:s.Hole),c))return N&&this._removeChildrenRecursive(o),N;const m=o.childCount>0;let y=m;if(m)for(let e=0;e<o.childCount;e++){const o=h.getChildIndex(a,e),s=h.getNode(o);if(i(s)){!(!h.isGeometryVisible(o)||this._lodGlobalHandling(s,t,l||N,n))&&this._isNodeInScaleBounds(s)&&(y=!1)}else h.isNodeVisible(o)&&(y=!1)}const b=L&&!c&&(y||r.length<t);b&&r.push(a),!n||b||!L||l||y||_.fadeNode(a,d.FadeIn,!1);const f=!o.resources.hasFeatureData;return y||N&&!b||f}_removeChildrenRecursive(e){this._index.traverseChildren(e,(e=>((this._layerView.isNodeLoaded(e.index)||this._layerView.isNodeReloading(e.index))&&r.push(e.index),e.childrenLoaded>0)))}hasNoVisibleChildren(e){let i=!0;return this._index.traverseChildren(e,(e=>!(!i||!this._index.isNodeVisible(e.index))&&(this._layerView.isNodeLoaded(e.index)?(i=!1,!1):e.childrenLoaded>0))),i}_childrenRequireLoading(e){let i=!1,o=!0;return this._index.traverseChildren(e,(e=>{if(!o||!this._index.isNodeVisible(e.index))return!1;const s=this._index.nodeTraversalState(e);return this._isChosenMaxLOD(s)&&this._index.isGeometryVisible(e.index)&&(i=!0),this._layerView.isNodeLoaded(e.index)?(o=!1,!1):e.childrenLoaded>0})),o&&i}_isChosenMaxLOD(e){return e.isChosen&&(!e.nodeHasLOD||e.lodLevel===this._maxLodLevel)}}const r=new o({deallocator:null});export{t as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import{clamp as e,isPowerOfTwo as a}from"../../../../core/mathUtils.js";import{isSome as o,isNone as r}from"../../../../core/maybe.js";import{TextureEncoding as s,TextureUsage as t}from"./enums.js";import{RenderTexture as n}from"../../webgl-engine/core/material/RenderTexture.js";import{PBRSchematicMRRValues as l}from"../../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as i}from"../../webgl-engine/core/shaderLibrary/util/AlphaCutoff.js";import{getEllipsoidMode as u}from"../../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{TextureEncodingMimeType as c,CullFaceOptions as m,AlphaDiscardMode as d}from"../../webgl-engine/lib/basicInterfaces.js";import{Texture as g}from"../../webgl-engine/lib/Texture.js";import{TextureWrapMode as p}from"../../../webgl/enums.js";function h(e,a){const s=new Map,n=(e,a)=>{if(r(e))return-1;if(s.has(e.id)){const o=s.get(e.id);return o.usage|=a,o.id}const o=s.size;return s.set(e.id,{id:o,usage:a}),o},i=a.pbrMetallicRoughness,u=i&&i.baseColorFactor,c=a.emissiveFactor,d=null==a.normalTexture&&null==a.emissiveTexture&&null==a.occlusionTexture&&(!i||null==i.metallicRoughnessTexture&&1===i.roughnessFactor&&(1===i.metallicFactor||0===i.metallicFactor)),g=d?l[0]:i?i.metallicFactor:1,p=d?l[1]:i?i.roughnessFactor:1,h="mask"===a.alphaMode?t.Color|t.AlphaMask:t.Color,x={baseColorFactor:u?[u[0],u[1],u[2],u[3]]:[1,1,1,1],baseColorTextureId:n(i&&i.baseColorTexture,h),metallicRoughnessTextureId:n(i&&i.metallicRoughnessTexture,t.MetallicRoughness),metallicFactor:g,roughnessFactor:p},b={alphaMode:a.alphaMode,alphaCutoff:a.alphaCutoff,doubleSided:a.doubleSided,cullFace:"none"===a.cullFace?m.None:"back"===a.cullFace?m.Back:"front"===a.cullFace?m.Front:void 0,normalTextureId:n(a.normalTexture,t.Normal),emissiveTextureId:n(a.emissiveTexture,t.Emissive),occlusionTextureId:n(a.occlusionTexture,t.Occlusion),emissiveFactor:c?[c[0],c[1],c[2]]:[0,0,0],metallicRoughness:x,wrapTextures:!1,hasParametersFromSource:d},F=[];return s.forEach((({usage:a},r)=>{const s=o(e)&&e[r]&&e[r].formats,t=s?f(s.map((({name:e,format:a})=>({name:e,encoding:T[a]})))):[];F.push({id:r,usage:a,encodings:t})})),{material:b,textures:F}}function f(e){return e.sort(((e,a)=>e.encoding-a.encoding))}const T={ktx2:s.KTX2,basis:s.Basis,dds:s.DDS_S3TC,png:s.PNG,jpg:s.JPG,"ktx-etc2":s.KTX_ETC2},x={[c.KTX2_ENCODING]:s.Basis,[c.BASIS_ENCODING]:s.Basis,[c.DDS_ENCODING]:s.DDS_S3TC,"image/png":s.PNG,"image/jpg":s.JPG,"image/jpeg":s.JPG,"image/ktx":s.KTX_ETC2};function b(a){const o=a&&a.materialDefinitions?Object.keys(a.materialDefinitions)[0]:null,r=a&&a.textureDefinitions?Object.keys(a.textureDefinitions)[0]:null,s=o&&a.materialDefinitions[o],n=r&&a.textureDefinitions[r],l=F();if(null!=s){const a=s.params;a.diffuse&&(l.metallicRoughness.baseColorFactor=[a.diffuse[0],a.diffuse[1],a.diffuse[2],1]),null!=a.doubleSided&&(l.doubleSided=a.doubleSided,l.cullFace=a.doubleSided?m.None:m.Back),"none"!==a.cullFace&&"front"!==a.cullFace&&"back"!==a.cullFace||(l.cullFace="none"===a.cullFace?m.None:"back"===a.cullFace?m.Back:m.Front),a.transparency&&(l.metallicRoughness.baseColorFactor[3]=e(1-a.transparency,0,1)),(a.useVertexColorAlpha||l.metallicRoughness.baseColorFactor[3]<1)&&(l.alphaMode="blend")}const i=[];if(null!=n){const e=0;!n.wrap||"repeat"!==n.wrap[0]&&"repeat"!==n.wrap[1]||(l.wrapTextures=!0);let a=t.Color;"rgba"===n.channels&&(l.alphaMode="blend",a|=t.AlphaMask);const o=n.images.length-1,r=n.images[o],s=e=>e&&e.split("/").pop(),u=Array.isArray(n.encoding)?f(n.encoding.map(((e,a)=>({name:s(r.href[a]),encoding:x[e]||0})))):[{name:s(r.href),encoding:x[n.encoding]||0}];i.push({id:e,usage:a,encodings:u}),l.metallicRoughness.baseColorTextureId=e}return{material:l,textures:i}}const F=()=>({alphaMode:"opaque",alphaCutoff:i,doubleSided:!0,cullFace:m.None,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[.8,.8,.8,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6},wrapTextures:!1,hasParametersFromSource:!0});function C(e,o,s,n){if(r(e)||null==e.data)return null;const l=e.data,i=!(l instanceof HTMLImageElement)||a(l.width)&&a(l.height),u=n.renderingContext.parameters.maxMaxAnisotropy,c=s&&!n.capabilities.shaderTextureLOD?1:u,m=i&&!e.downsampled&&c>1,d=s||!o.wrapTextures?P:M,p=E(e.encoding),h=e.usage&t.Color?"opaque"===o.alphaMode?3:4:3;return new g(l,{mipmap:m,maxAnisotropy:c,encoding:p,wrap:d,components:h,noUnpackFlip:!0})}const P={s:p.CLAMP_TO_EDGE,t:p.CLAMP_TO_EDGE},M={s:p.REPEAT,t:p.REPEAT};function S(a,r,s,l,c,m){const g=m.rendererTextureUsage,p=e=>R(l,s,e&g),h=r.metallicRoughness.baseColorFactor,f=e(r.metallicRoughness.baseColorFactor[3],0,1);a.baseColor=[h[0],h[1],h[2],f],a.hasParametersFromSource=!!r.hasParametersFromSource,a.usePBR=m.usePBR,a.mrrFactors=[r.metallicRoughness.metallicFactor,r.metallicRoughness.roughnessFactor,r.hasParametersFromSource?.2:.5],a.emissiveFactor=r.emissiveFactor,a.isIntegratedMesh=m.isIntegratedMesh,a.textureAlphaCutoff="mask"===r.alphaMode?r.alphaCutoff:i,a.alphaDiscardMode="opaque"===r.alphaMode?d.Opaque:"mask"===r.alphaMode?d.Mask:d.MaskBlend;const T=[],x=p(t.Color|t.AlphaMask);o(x)&&(a.baseColorTexture=new n(c,x),T.push(a.baseColorTexture.loadPromise));const b=p(t.MetallicRoughness);o(b)&&(a.metallicRoughnessTexture=new n(c,b),T.push(a.metallicRoughnessTexture.loadPromise));const F=p(t.Emissive);o(F)&&(a.emissionTexture=new n(c,F),T.push(a.emissionTexture.loadPromise));const C=p(t.Occlusion);o(C)&&(a.occlusionTexture=new n(c,C),T.push(a.occlusionTexture.loadPromise));const P=p(t.Normal);return o(P)&&(a.normalTexture=new n(c,P),T.push(a.normalTexture.loadPromise)),a.commonMaterialParameters.hasSlicePlane=m.slicePlaneEnabled,a.commonMaterialParameters.doubleSided=r.doubleSided,a.commonMaterialParameters.cullFace=r.cullFace,a.ellipsoidMode=u(m.viewSpatialReference),Promise.all(T)}function D(e){const a=!!e.compressedTextureS3TC,o=!!e.compressedTextureETC,r=has("disable-feature:i3s-basis")?0:s.Basis|s.KTX2,t=s.JPG|s.PNG,n=r|s.DDS_S3TC;return t|(a?n:0)|(o?r:0)}function w(e,a){return e.find((e=>0!=(e.encoding&a)))}function R(e,a,s){if(r(e)||s===t.None)return null;for(let r=0;r<e.length;r++){const t=e[r];if(o(t)&&0!=(t.usage&s)){const e=a[r];return o(e)?e.id:null}}return null}function E(e){switch(e){case s.KTX2:return c.KTX2_ENCODING;case s.Basis:return c.BASIS_ENCODING;case s.DDS_S3TC:return c.DDS_ENCODING;case s.PNG:return"image/png";case s.JPG:return"image/jpeg";case s.KTX_ETC2:return"image/ktx";default:return""}}export{S as configureMaterial,C as createTexture,F as defaultMaterial,h as getMaterialAndTextures,b as getMaterialAndTexturesFromShared,D as getSupportedEncodings,w as selectEncoding};
5
+ import has from"../../../../core/has.js";import{clamp as e,isPowerOfTwo as a}from"../../../../core/mathUtils.js";import{isSome as o,isNone as r}from"../../../../core/maybe.js";import{TextureEncoding as s,TextureUsage as t}from"./enums.js";import{RenderTexture as n}from"../../webgl-engine/core/material/RenderTexture.js";import{PBRSchematicMRRValues as l}from"../../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as i}from"../../webgl-engine/core/shaderLibrary/util/AlphaCutoff.js";import{getEllipsoidMode as u}from"../../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{TextureEncodingMimeType as c,CullFaceOptions as m,AlphaDiscardMode as d}from"../../webgl-engine/lib/basicInterfaces.js";import{Texture as g}from"../../webgl-engine/lib/Texture.js";import{TextureWrapMode as p}from"../../../webgl/enums.js";function h(e,a){const s=new Map,n=(e,a)=>{if(r(e))return-1;const o=s.get(e.id);if(o)return o.usage|=a,o.id;const t=s.size;return s.set(e.id,{id:t,usage:a}),t},i=a.pbrMetallicRoughness,u=i&&i.baseColorFactor,c=a.emissiveFactor,d=null==a.normalTexture&&null==a.emissiveTexture&&null==a.occlusionTexture&&(!i||null==i.metallicRoughnessTexture&&1===i.roughnessFactor&&(1===i.metallicFactor||0===i.metallicFactor)),g=d?l[0]:i?i.metallicFactor:1,p=d?l[1]:i?i.roughnessFactor:1,h="mask"===a.alphaMode?t.Color|t.AlphaMask:t.Color,x={baseColorFactor:u?[u[0],u[1],u[2],u[3]]:[1,1,1,1],baseColorTextureId:n(i&&i.baseColorTexture,h),metallicRoughnessTextureId:n(i&&i.metallicRoughnessTexture,t.MetallicRoughness),metallicFactor:g,roughnessFactor:p},b={alphaMode:a.alphaMode,alphaCutoff:a.alphaCutoff,doubleSided:a.doubleSided,cullFace:"none"===a.cullFace?m.None:"back"===a.cullFace?m.Back:"front"===a.cullFace?m.Front:m.None,normalTextureId:n(a.normalTexture,t.Normal),emissiveTextureId:n(a.emissiveTexture,t.Emissive),occlusionTextureId:n(a.occlusionTexture,t.Occlusion),emissiveFactor:c?[c[0],c[1],c[2]]:[0,0,0],metallicRoughness:x,wrapTextures:!1,hasParametersFromSource:d},F=[];return s.forEach((({usage:a},r)=>{const s=o(e)&&e[r]&&e[r].formats,t=s?f(s.map((({name:e,format:a})=>({name:e,encoding:T[a]})))):[];F.push({id:r,usage:a,encodings:t})})),{material:b,textures:F}}function f(e){return e.sort(((e,a)=>e.encoding-a.encoding))}const T={ktx2:s.KTX2,basis:s.Basis,dds:s.DDS_S3TC,png:s.PNG,jpg:s.JPG,"ktx-etc2":s.KTX_ETC2},x={[c.KTX2_ENCODING]:s.Basis,[c.BASIS_ENCODING]:s.Basis,[c.DDS_ENCODING]:s.DDS_S3TC,"image/png":s.PNG,"image/jpg":s.JPG,"image/jpeg":s.JPG,"image/ktx":s.KTX_ETC2};function b(a){const o=a&&a.materialDefinitions?Object.keys(a.materialDefinitions)[0]:null,r=a&&a.textureDefinitions?Object.keys(a.textureDefinitions)[0]:null,s=o?a.materialDefinitions?.[o]:null,n=r?a.textureDefinitions?.[r]:null,l=F();if(null!=s){const a=s.params;a.diffuse&&(l.metallicRoughness.baseColorFactor=[a.diffuse[0],a.diffuse[1],a.diffuse[2],1]),null!=a.doubleSided&&(l.doubleSided=a.doubleSided,l.cullFace=a.doubleSided?m.None:m.Back),"none"!==a.cullFace&&"front"!==a.cullFace&&"back"!==a.cullFace||(l.cullFace="none"===a.cullFace?m.None:"back"===a.cullFace?m.Back:m.Front),a.transparency&&(l.metallicRoughness.baseColorFactor[3]=e(1-a.transparency,0,1)),(a.useVertexColorAlpha||l.metallicRoughness.baseColorFactor[3]<1)&&(l.alphaMode="blend")}const i=[];if(null!=n){const e=0;!n.wrap||"repeat"!==n.wrap[0]&&"repeat"!==n.wrap[1]||(l.wrapTextures=!0);let a=t.Color;"rgba"===n.channels&&(l.alphaMode="blend",a|=t.AlphaMask);const o=n.images.length-1,r=n.images[o],s=e=>e&&e.split("/").pop(),u=Array.isArray(n.encoding)?f(n.encoding.map(((e,a)=>({name:s(r.href[a]),encoding:x[e]||0})))):[{name:s(r.href),encoding:x[n.encoding]||0}];i.push({id:e,usage:a,encodings:u}),l.metallicRoughness.baseColorTextureId=e}return{material:l,textures:i}}const F=()=>({alphaMode:"opaque",alphaCutoff:i,doubleSided:!0,cullFace:m.None,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[.8,.8,.8,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6},wrapTextures:!1,hasParametersFromSource:!0});function C(e,o,s,n){if(r(e)||null==e.data)return null;const l=e.data,i=!(l instanceof HTMLImageElement)||a(l.width)&&a(l.height),u=n.renderingContext.parameters.maxMaxAnisotropy,c=s&&!n.capabilities.shaderTextureLOD?1:u,m=i&&!e.downsampled&&c>1,d=s||!o.wrapTextures?P:M,p=E(e.encoding),h=e.usage&t.Color?"opaque"===o.alphaMode?3:4:3;return new g(l,{mipmap:m,maxAnisotropy:c,encoding:p,wrap:d,components:h,noUnpackFlip:!0})}const P={s:p.CLAMP_TO_EDGE,t:p.CLAMP_TO_EDGE},M={s:p.REPEAT,t:p.REPEAT};function S(a,r,s,l,c,m){const g=m.rendererTextureUsage,p=e=>R(l,s,e&g),h=r.metallicRoughness.baseColorFactor,f=e(r.metallicRoughness.baseColorFactor[3],0,1);a.baseColor=[h[0],h[1],h[2],f],a.hasParametersFromSource=!!r.hasParametersFromSource,a.usePBR=m.usePBR,a.mrrFactors=[r.metallicRoughness.metallicFactor,r.metallicRoughness.roughnessFactor,r.hasParametersFromSource?.2:.5],a.emissiveFactor=r.emissiveFactor,a.isIntegratedMesh=m.isIntegratedMesh,a.textureAlphaCutoff="mask"===r.alphaMode?r.alphaCutoff:i,a.alphaDiscardMode="opaque"===r.alphaMode?d.Opaque:"mask"===r.alphaMode?d.Mask:d.MaskBlend;const T=[],x=p(t.Color|t.AlphaMask);o(x)&&(a.baseColorTexture=new n(c,x),T.push(a.baseColorTexture.loadPromise));const b=p(t.MetallicRoughness);o(b)&&(a.metallicRoughnessTexture=new n(c,b),T.push(a.metallicRoughnessTexture.loadPromise));const F=p(t.Emissive);o(F)&&(a.emissionTexture=new n(c,F),T.push(a.emissionTexture.loadPromise));const C=p(t.Occlusion);o(C)&&(a.occlusionTexture=new n(c,C),T.push(a.occlusionTexture.loadPromise));const P=p(t.Normal);return o(P)&&(a.normalTexture=new n(c,P),T.push(a.normalTexture.loadPromise)),a.commonMaterialParameters.hasSlicePlane=m.slicePlaneEnabled,a.commonMaterialParameters.doubleSided=r.doubleSided,a.commonMaterialParameters.cullFace=r.cullFace,a.ellipsoidMode=u(m.viewSpatialReference),Promise.all(T)}function D(e){const a=!!e.compressedTextureS3TC,o=!!e.compressedTextureETC,r=has("disable-feature:i3s-basis")?0:s.Basis|s.KTX2,t=s.JPG|s.PNG,n=r|s.DDS_S3TC;return t|(a?n:0)|(o?r:0)}function w(e,a){if(null!=a)return e.find((e=>0!=(e.encoding&a)))}function R(e,a,s){if(r(e)||s===t.None)return null;for(let r=0;r<e.length;r++){const t=e[r];if(o(t)&&0!=(t.usage&s)){const e=a[r];return o(e)?e.id:null}}return null}function E(e){switch(e){case s.KTX2:return c.KTX2_ENCODING;case s.Basis:return c.BASIS_ENCODING;case s.DDS_S3TC:return c.DDS_ENCODING;case s.PNG:return"image/png";case s.JPG:return"image/jpeg";case s.KTX_ETC2:return"image/ktx";default:return""}}export{S as configureMaterial,C as createTexture,F as defaultMaterial,h as getMaterialAndTextures,b as getMaterialAndTexturesFromShared,D as getSupportedEncodings,w as selectEncoding};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import t from"../../../../core/Accessor.js";import{PositionHint as r,indexOf as i}from"../../../../core/arrayUtils.js";import s from"../../../../core/Logger.js";import{clamp as n}from"../../../../core/mathUtils.js";import{isNone as o,isSome as a,unwrap as c}from"../../../../core/maybe.js";import{unwrapUpdating as l,updating as p,isUpdating as u}from"../../../../core/maybeUpdating.js";import{whenOnce as g}from"../../../../core/reactiveUtils.js";import{getUnitString as m}from"../../../../core/unitUtils.js";import{property as f}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{t as y,a as h,s as j}from"../../../../chunks/vec3.js";import{WhereClause as S}from"../../../../core/sql/WhereClause.js";import{projectBoundingSphere as w,load as R,project as E,projectVectorToVector as b}from"../../../../geometry/projection.js";import{create as v}from"../../../../geometry/support/aaBoundingBox.js";import{fromValues as F,expandWithNestedArray as _,expand as k}from"../../../../geometry/support/aaBoundingRect.js";import{earth as I}from"../../../../geometry/support/Ellipsoid.js";import{isWGS84 as M,isWebMercator as D}from"../../../../geometry/support/spatialReferenceUtils.js";import{project as T}from"../../../../geometry/support/webMercatorUtils.js";import G from"../../../../layers/support/FeatureFilter.js";import{objectIdFilter as C,filterInPlace as A}from"./I3SUtil.js";import{doubleArrayFrom as x}from"../../webgl-engine/lib/DoubleArray.js";import O from"../../../../geometry/SpatialReference.js";const B="esri.views.3d.layers.i3s.I3SMeshViewFilter",L=s.getLogger(B);let P=class extends t{constructor(e){super(e),this._projectionEngineLoaded=!1}initialize(){g((()=>c(this.viewFilter)?.geometry||a(this.layerFilter))).then((()=>this.loadAsyncModule(import("../../../../geometry/geometryEngine.js").then((e=>{this.destroyed||(this._geometryEngine=e)})))))}get sortedObjectIds(){if(o(this.viewFilter)||o(this.viewFilter.objectIds))return null;const e=x(this.viewFilter.objectIds);return e.sort(),e}get parsedWhereClause(){const e=a(this.viewFilter)?this.viewFilter.where:null;if(o(e)||!e)return null;try{return S.create(e,this.layerFieldsIndex)}catch(t){L.error(`Failed to parse filter where clause: ${t}`)}return null}addFilters(e,t,r,i){const s=this.sortedObjectIds;a(s)&&e.push((e=>C(s,!0,e))),this.addSqlFilter(e,this.parsedWhereClause);const n=l(this._layerMaskGeometries),o=this._geometryEngine;if(a(n)&&a(this.layerFilter)&&a(o)){const s=this.layerFilter.spatialRelationship;e.push(((e,a)=>N(o,e,a,i,t,r,n,s)))}const c=l(this._viewMaskGeometries);if(a(c)&&a(this.viewFilter)&&a(o)){const s=this.viewFilter.spatialRelationship;e.push(((e,n)=>N(o,e,n,i,t,r,c,s)))}}isMBSGeometryVisible(e,t,r){const i=l(this._layerMaskGeometries),s=this._geometryEngine;if(a(i)&&a(this.layerFilter)&&a(s)){const n=this.layerFilter.spatialRelationship,o=i[0].spatialReference||t;if(!w(e,r,$,o))return L.warnOnce("SceneLayer.mask geometry is using unsupported SpatialReference, skipping geometry filter for MBS"),!0;return q(s,$,i,o,n)}const n=l(this._viewMaskGeometries);if(a(n)&&a(this.viewFilter)&&a(s)){const i=this.viewFilter.spatialRelationship,o=n[0].spatialReference||t;if(!w(e,r,$,o))return L.warnOnce("SceneLayerView.filter.geometry is using unsupported SpatialReference, skipping geometry filter for MBS"),!0;return q(s,$,n,o,i)}return!0}get parsedGeometry(){const e=l(this._viewMaskGeometries),t=l(this._layerMaskGeometries);return o(e)||o(t)?e||t:t.concat(e)}get _layerMaskGeometries(){const e=this.layerFilter;return o(e)?null:o(this._geometryEngine)?p:"disjoint"===e.spatialRelationship?e.geometries.map((e=>({type:"polygon",rings:e.rings,spatialReference:e.spatialReference,cache:{}}))):[e.geometries.reduce(((e,t)=>(e.rings=e.rings.concat(t.rings),e)),{type:"polygon",rings:[],spatialReference:e.geometries[0].spatialReference,cache:{}})]}get _viewMaskGeometries(){if(o(this.viewFilter))return null;const{geometry:e}=this.viewFilter;if(o(e))return null;if(o(this.viewFilter)||o(this._geometryEngine))return p;const{distance:t,units:r}=this.viewFilter,i=this.viewFilter.spatialRelationship,s="mesh"===e.type?e.extent:e;if(o(t)||0===t)return V(this._geometryEngine,s,i);const n=r||m(s.spatialReference);if(s.spatialReference.isWGS84){const e=this._geometryEngine.geodesicBuffer(s,t,n);return V(this._geometryEngine,e,i)}const c=T(s,O.WGS84);if(a(c)){const e=T(this._geometryEngine.geodesicBuffer(c,t,n),s.spatialReference);return V(this._geometryEngine,e,i)}if(!this._projectionEngineLoaded&&(this.loadAsyncModule(R().then((()=>this._projectionEngineLoaded=!0))),!this._projectionEngineLoaded))return null;let l=null;try{l=E(s,O.WGS84)}catch(u){}if(l)try{l=E(this._geometryEngine.geodesicBuffer(l,t,n),s.spatialReference)}catch(u){l=null}return l||L.error(`Filter by geodesic buffer (distance) unsupported, failed to project input geometry (${s.spatialReference.wkid}) to WGS84.`),V(this._geometryEngine,l,i)}get updating(){return u(this._layerMaskGeometries)||u(this._viewMaskGeometries)}static checkSupport(e){return!o(e)&&(e.timeExtent?(L.warn("Filters with a timeExtent are not supported for mesh scene layers"),!1):!!U(e.spatialRelationship)||(L.warn(`Filters with spatialRelationship other than ${K.join(", ")} are not supported for mesh scene layers`),!1))}};e([f()],P.prototype,"layerFilter",void 0),e([f({type:G})],P.prototype,"viewFilter",void 0),e([f()],P.prototype,"layerFieldsIndex",void 0),e([f()],P.prototype,"loadAsyncModule",void 0),e([f()],P.prototype,"addSqlFilter",void 0),e([f({readOnly:!0})],P.prototype,"sortedObjectIds",null),e([f({readOnly:!0})],P.prototype,"parsedWhereClause",null),e([f({readOnly:!0})],P.prototype,"parsedGeometry",null),e([f({readOnly:!0})],P.prototype,"_layerMaskGeometries",null),e([f({readOnly:!0})],P.prototype,"_viewMaskGeometries",null),e([f()],P.prototype,"updating",null),e([f()],P.prototype,"_projectionEngineLoaded",void 0),e([f()],P.prototype,"_geometryEngine",void 0),P=e([d(B)],P);const K=(e=>e)(["contains","intersects","disjoint"]);function U(e){return null!=e&&K.includes(e)}var W;function V(e,t,s){if(o(t))return null;if("disjoint"===s&&"polygon"===t.type){const s=t.rings.length,n=t.spatialReference,o=new Array(s);for(let e=0;e<s;++e){const r=F(1/0,1/0,-1/0,-1/0);_(r,t.rings[e]),o[e]={type:"polygon",rings:[t.rings[e]],spatialReference:n,cache:{},aabr:r}}o.sort(((e,t)=>e.aabr[0]-t.aabr[0]));const a=new Set,c=new r;for(let t=0;t<o.length;++t){const r=o[t],s=r.aabr[0];a.forEach((t=>{if(s>=t.aabr[2])return void a.delete(t);if(r.aabr[1]>t.aabr[3]||r.aabr[3]<t.aabr[1]||!e.intersects(r,t))return;r.rings=r.rings.concat(t.rings),k(r.aabr,t.aabr,r.aabr),r.cache={},a.delete(t);const n=i(o,t,o.length,c);o.splice(n,1)})),a.add(r)}for(const e of o)delete e.aabr;return o}return[t]}function q(e,t,r,i,s){const n=H(e,t,i);return r.every((t=>Z(e,t,n,s)!==W.DISCARD))}function N(e,t,r,i,s,n,o,a){const c=o[0].spatialReference||s.spatialReference;if(!w(r.node.mbs,n,$,c))return void L.warnOnce("SceneLayerView.filter.geometry is using unsupported SpatialReference, skipping geometry filter");const l=H(e,$,c),p=z(a,s,c,i,r.objectHandle);for(const u of o){if(0===t.length)return;switch(Z(e,u,l,a)){case W.DISCARD:return void(t.length=0);case W.KEEP:continue}A(t,r.featureIds,(t=>X(e,u,t,p)))}}!function(e){e[e.KEEP=0]="KEEP",e[e.DISCARD=1]="DISCARD",e[e.TEST=2]="TEST"}(W||(W={}));const $=[0,0,0,0];function z(e,t,r,i,s){const n=t.renderSpatialReference,o=new Map,a={type:"polygon",rings:[[[0,0,0],[0,0,0],[0,0,0],[0,0,0]]],spatialReference:r};a.rings[0][3]=a.rings[0][0];const c={indices:null,data:null,stride:0,startIndex:0,endIndex:0};let l,p;switch(e){case"intersects":l=(e,t,r)=>e.intersects(t,r)?W.KEEP:W.TEST,p=J;break;case"contains":l=(e,t,r)=>e.contains(t,r)?W.TEST:W.DISCARD,p=J;break;default:l=(e,t,r)=>e.disjoint(t,r)?W.TEST:W.DISCARD,p=Q}return{collection:i,object:s,type:e,maskSR:r,renderSR:n,aabbCache:o,triangle:a,positions:c,triangleTest:l,geometryTest:p}}function H(e,t,r){const i={type:"point",x:t[0],y:t[1],hasZ:!1,hasM:!1,spatialReference:r},s=!M(r)&&!D(r),o=Number.isNaN(t[3])?0:n(t[3],0,2*I.radius),a=s?e.buffer(i,o,1):e.geodesicBuffer(i,o,1);return a.type="polygon",a}function Z(e,t,r,i){switch(i){case"intersects":case"contains":return J(e,t,r);case"disjoint":return Q(e,t,r)}}function J(e,t,r){return e.intersects(t,r)?e.contains(t,r)?W.KEEP:W.TEST:W.DISCARD}function Q(e,t,r){return e.intersects(t,r)?e.contains(t,r)?W.DISCARD:W.TEST:W.KEEP}function X(e,t,r,i){const{collection:s,object:n,renderSR:o,maskSR:a,geometryTest:c,aabbCache:l}=i;let p=l.get(r);if(!p){const e=s.getObjectTransform(n);s.getComponentAabb(n,r,Y);const t=[[Y[0],Y[1],0],[Y[0],Y[4],0],[Y[3],Y[4],0],[Y[3],Y[1],0]];for(let r=0;r<4;++r)y(t[r],t[r],e.rotationScale),h(t[r],t[r],e.position),b(t[r],o,t[r],a);p={type:"polygon",rings:[t],spatialReference:a,cache:{}},p.rings[0][4]=p.rings[0][0],l.set(r,p)}switch(c(e,t,p)){case W.DISCARD:return!1;case W.KEEP:return!0}const{triangle:u,triangleTest:g,positions:m}=i,f=u.rings[0][0],d=u.rings[0][1],S=u.rings[0][2],w=s.getObjectTransform(n);s.getComponentPositions(n,r,m);const{indices:R,data:E,stride:v,startIndex:F,endIndex:_}=m;for(let k=F;k<_;k+=3){const r=v*R[k+0],i=v*R[k+1],s=v*R[k+2];switch(j(f,E[r+0],E[r+1],E[r+2]),j(d,E[i+0],E[i+1],E[i+2]),j(S,E[s+0],E[s+1],E[s+2]),y(f,f,w.rotationScale),y(d,d,w.rotationScale),y(S,S,w.rotationScale),h(f,f,w.position),h(d,d,w.position),h(S,S,w.position),b(f,o,f,a),b(d,o,d,a),b(S,o,S,a),g(e,t,u)){case W.DISCARD:return!1;case W.KEEP:return!0}}return"intersects"!==i.type}const Y=v();export{P as I3SMeshViewFilter};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import t from"../../../../core/Accessor.js";import{PositionHint as r,indexOf as i}from"../../../../core/arrayUtils.js";import s from"../../../../core/Logger.js";import{clamp as o}from"../../../../core/mathUtils.js";import{isNone as n,isSome as a,unwrap as c}from"../../../../core/maybe.js";import{unwrapUpdating as l,updating as p,isUpdating as u}from"../../../../core/maybeUpdating.js";import{whenOnce as g}from"../../../../core/reactiveUtils.js";import{getUnitString as m}from"../../../../core/unitUtils.js";import{property as f}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{t as y,a as h,s as j}from"../../../../chunks/vec3.js";import{WhereClause as S}from"../../../../core/sql/WhereClause.js";import{projectBoundingSphere as w,load as R,project as E,projectVectorToVector as b}from"../../../../geometry/projection.js";import{create as v}from"../../../../geometry/support/aaBoundingBox.js";import{fromValues as F,expandWithNestedArray as _,expand as k}from"../../../../geometry/support/aaBoundingRect.js";import{earth as I}from"../../../../geometry/support/Ellipsoid.js";import{isWGS84 as M,isWebMercator as D}from"../../../../geometry/support/spatialReferenceUtils.js";import{project as T}from"../../../../geometry/support/webMercatorUtils.js";import G from"../../../../layers/support/FeatureFilter.js";import{objectIdFilter as C,filterInPlace as A}from"./I3SUtil.js";import{doubleArrayFrom as x}from"../../webgl-engine/lib/DoubleArray.js";import O from"../../../../geometry/SpatialReference.js";const B="esri.views.3d.layers.i3s.I3SMeshViewFilter",L=s.getLogger(B);let P=class extends t{constructor(e){super(e),this._projectionEngineLoaded=!1}initialize(){g((()=>c(this.viewFilter)?.geometry||a(this.layerFilter))).then((()=>this.loadAsyncModule(import("../../../../geometry/geometryEngine.js").then((e=>{this.destroyed||(this._geometryEngine=e)})))))}get sortedObjectIds(){if(n(this.viewFilter)||n(this.viewFilter.objectIds))return null;const e=x(this.viewFilter.objectIds);return e.sort(),e}get parsedWhereClause(){const e=a(this.viewFilter)?this.viewFilter.where:null;if(n(e)||!e)return null;try{return S.create(e,this.layerFieldsIndex)}catch(t){L.error(`Failed to parse filter where clause: ${t}`)}return null}addFilters(e,t,r,i){const s=this.sortedObjectIds;a(s)&&e.push((e=>C(s,!0,e))),this.addSqlFilter(e,this.parsedWhereClause);const o=l(this._layerMaskGeometries),n=this._geometryEngine;if(a(o)&&a(this.layerFilter)&&a(n)){const s=this.layerFilter.spatialRelationship;e.push(((e,a)=>N(n,e,a,i,t,r,o,s)))}const c=l(this._viewMaskGeometries);if(a(c)&&a(this.viewFilter)&&a(n)){const s=this.viewFilter.spatialRelationship;e.push(((e,o)=>N(n,e,o,i,t,r,c,s)))}}isMBSGeometryVisible(e,t,r){const i=l(this._layerMaskGeometries),s=this._geometryEngine;if(a(i)&&a(this.layerFilter)&&a(s)){const o=this.layerFilter.spatialRelationship,n=i[0].spatialReference||t;if(!w(e,r,$,n))return L.warnOnce("SceneLayer.mask geometry is using unsupported SpatialReference, skipping geometry filter for MBS"),!0;return q(s,$,i,n,o)}const o=l(this._viewMaskGeometries);if(a(o)&&a(this.viewFilter)&&a(s)){const i=this.viewFilter.spatialRelationship,n=o[0].spatialReference||t;if(!w(e,r,$,n))return L.warnOnce("SceneLayerView.filter.geometry is using unsupported SpatialReference, skipping geometry filter for MBS"),!0;return q(s,$,o,n,i)}return!0}get parsedGeometry(){const e=l(this._viewMaskGeometries),t=l(this._layerMaskGeometries);return n(e)||n(t)?e||t:t.concat(e)}get _layerMaskGeometries(){const e=this.layerFilter;return n(e)?null:n(this._geometryEngine)?p:"disjoint"===e.spatialRelationship?e.geometries.map((e=>({type:"polygon",rings:e.rings,spatialReference:e.spatialReference,cache:{}}))):[e.geometries.reduce(((e,t)=>(e.rings=[...e.rings,...t.rings],e)),{type:"polygon",rings:[],spatialReference:e.geometries[0].spatialReference,cache:{}})]}get _viewMaskGeometries(){if(n(this.viewFilter))return null;const{geometry:e}=this.viewFilter;if(n(e))return null;if(n(this.viewFilter)||n(this._geometryEngine))return p;const{distance:t,units:r}=this.viewFilter,i=this.viewFilter.spatialRelationship,s="mesh"===e.type?e.extent:e;if(n(t)||0===t)return V(this._geometryEngine,s,i);const o=r||m(s.spatialReference);if(s.spatialReference.isWGS84){const e=this._geometryEngine.geodesicBuffer(s,t,o);return V(this._geometryEngine,e,i)}const c=T(s,O.WGS84);if(a(c)){const e=T(this._geometryEngine.geodesicBuffer(c,t,o),s.spatialReference);return V(this._geometryEngine,e,i)}if(!this._projectionEngineLoaded&&(this.loadAsyncModule(R().then((()=>this._projectionEngineLoaded=!0))),!this._projectionEngineLoaded))return null;let l=null;try{l=E(s,O.WGS84)}catch(u){}if(l)try{l=E(this._geometryEngine.geodesicBuffer(l,t,o),s.spatialReference)}catch(u){l=null}return l||L.error(`Filter by geodesic buffer (distance) unsupported, failed to project input geometry (${s.spatialReference.wkid}) to WGS84.`),V(this._geometryEngine,l,i)}get updating(){return u(this._layerMaskGeometries)||u(this._viewMaskGeometries)}static checkSupport(e){return!n(e)&&(e.timeExtent?(L.warn("Filters with a timeExtent are not supported for mesh scene layers"),!1):!!U(e.spatialRelationship)||(L.warn(`Filters with spatialRelationship other than ${K.join(", ")} are not supported for mesh scene layers`),!1))}};e([f()],P.prototype,"layerFilter",void 0),e([f({type:G})],P.prototype,"viewFilter",void 0),e([f()],P.prototype,"layerFieldsIndex",void 0),e([f()],P.prototype,"loadAsyncModule",void 0),e([f()],P.prototype,"addSqlFilter",void 0),e([f({readOnly:!0})],P.prototype,"sortedObjectIds",null),e([f({readOnly:!0})],P.prototype,"parsedWhereClause",null),e([f({readOnly:!0})],P.prototype,"parsedGeometry",null),e([f({readOnly:!0})],P.prototype,"_layerMaskGeometries",null),e([f({readOnly:!0})],P.prototype,"_viewMaskGeometries",null),e([f()],P.prototype,"updating",null),e([f()],P.prototype,"_projectionEngineLoaded",void 0),e([f()],P.prototype,"_geometryEngine",void 0),P=e([d(B)],P);const K=(e=>e)(["contains","intersects","disjoint"]);function U(e){return null!=e&&K.includes(e)}var W;function V(e,t,s){if(n(t))return null;if("disjoint"===s&&"polygon"===t.type){const s=t.rings.length,o=t.spatialReference,n=new Array(s);for(let e=0;e<s;++e){const r=F(1/0,1/0,-1/0,-1/0);_(r,t.rings[e]),n[e]={type:"polygon",rings:[t.rings[e]],spatialReference:o,cache:{},aabr:r}}n.sort(((e,t)=>e.aabr[0]-t.aabr[0]));const a=new Set,c=new r;for(let t=0;t<n.length;++t){const r=n[t],s=r.aabr[0];a.forEach((t=>{if(s>=t.aabr[2])return void a.delete(t);if(r.aabr[1]>t.aabr[3]||r.aabr[3]<t.aabr[1]||!e.intersects(r,t))return;r.rings=r.rings.concat(t.rings),k(r.aabr,t.aabr,r.aabr),r.cache={},a.delete(t);const o=i(n,t,n.length,c);n.splice(o,1)})),a.add(r)}for(const e of n)e.aabr=void 0;return n}return[t]}function q(e,t,r,i,s){const o=H(e,t,i);return r.every((t=>Z(e,t,o,s)!==W.DISCARD))}function N(e,t,r,i,s,o,n,a){const c=n[0].spatialReference||s.spatialReference;if(!w(r.node.mbs,o,$,c))return void L.warnOnce("SceneLayerView.filter.geometry is using unsupported SpatialReference, skipping geometry filter");const l=H(e,$,c),p=z(a,s,c,i,r.objectHandle);for(const u of n){if(0===t.length)return;switch(Z(e,u,l,a)){case W.DISCARD:return void(t.length=0);case W.KEEP:continue}A(t,r.featureIds,(t=>X(e,u,t,p)))}}!function(e){e[e.KEEP=0]="KEEP",e[e.DISCARD=1]="DISCARD",e[e.TEST=2]="TEST"}(W||(W={}));const $=[0,0,0,0];function z(e,t,r,i,s){const o=t.renderSpatialReference,n=new Map,a={type:"polygon",rings:[[[0,0,0],[0,0,0],[0,0,0],[0,0,0]]],spatialReference:r};a.rings[0][3]=a.rings[0][0];const c={indices:null,data:null,stride:0,startIndex:0,endIndex:0};let l,p;switch(e){case"intersects":l=(e,t,r)=>e.intersects(t,r)?W.KEEP:W.TEST,p=J;break;case"contains":l=(e,t,r)=>e.contains(t,r)?W.TEST:W.DISCARD,p=J;break;default:l=(e,t,r)=>e.disjoint(t,r)?W.TEST:W.DISCARD,p=Q}return{collection:i,object:s,type:e,maskSR:r,renderSR:o,aabbCache:n,triangle:a,positions:c,triangleTest:l,geometryTest:p}}function H(e,t,r){const i={type:"point",x:t[0],y:t[1],hasZ:!1,hasM:!1,spatialReference:r},s=!M(r)&&!D(r),n=Number.isNaN(t[3])?0:o(t[3],0,2*I.radius),a=s?e.buffer(i,n,1):e.geodesicBuffer(i,n,1);return a.type="polygon",a}function Z(e,t,r,i){switch(i){case"intersects":case"contains":return J(e,t,r);case"disjoint":return Q(e,t,r)}}function J(e,t,r){return e.intersects(t,r)?e.contains(t,r)?W.KEEP:W.TEST:W.DISCARD}function Q(e,t,r){return e.intersects(t,r)?e.contains(t,r)?W.DISCARD:W.TEST:W.KEEP}function X(e,t,r,i){const{collection:s,object:o,renderSR:n,maskSR:a,geometryTest:c,aabbCache:l}=i;let p=l.get(r);if(!p){const e=s.getObjectTransform(o);s.getComponentAabb(o,r,Y);const t=[[Y[0],Y[1],0],[Y[0],Y[4],0],[Y[3],Y[4],0],[Y[3],Y[1],0]];for(let r=0;r<4;++r)y(t[r],t[r],e.rotationScale),h(t[r],t[r],e.position),b(t[r],n,t[r],a);p={type:"polygon",rings:[t],spatialReference:a,cache:{}},p.rings[0][4]=p.rings[0][0],l.set(r,p)}switch(c(e,t,p)){case W.DISCARD:return!1;case W.KEEP:return!0}const{triangle:u,triangleTest:g,positions:m}=i,f=u.rings[0][0],d=u.rings[0][1],S=u.rings[0][2],w=s.getObjectTransform(o);s.getComponentPositions(o,r,m);const{indices:R,data:E,stride:v,startIndex:F,endIndex:_}=m;for(let k=F;k<_;k+=3){const r=v*R[k+0],i=v*R[k+1],s=v*R[k+2];switch(j(f,E[r+0],E[r+1],E[r+2]),j(d,E[i+0],E[i+1],E[i+2]),j(S,E[s+0],E[s+1],E[s+2]),y(f,f,w.rotationScale),y(d,d,w.rotationScale),y(S,S,w.rotationScale),h(f,f,w.position),h(d,d,w.position),h(S,S,w.position),b(f,n,f,a),b(d,n,d,a),b(S,n,S,a),g(e,t,u)){case W.DISCARD:return!1;case W.KEEP:return!0}}return"intersects"!==i.type}const Y=v();export{P as I3SMeshViewFilter};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{result as e,assertResult as t}from"../../../../core/asyncUtils.js";import has from"../../../../core/has.js";import{clone as r}from"../../../../core/lang.js";import{isNone as i,isSome as o}from"../../../../core/maybe.js";import{eachAlways as n,isAbortError as s}from"../../../../core/promiseUtils.js";import{makeAbsolute as a}from"../../../../core/urlUtils.js";import{TextureEncoding as u}from"./enums.js";import{readBinaryAttribute as l,createGeometryDescriptor as f}from"./I3SBinaryReader.js";import{getMaterialAndTextures as d,getMaterialAndTexturesFromShared as c,selectEncoding as m}from"./I3SMaterialUtil.js";class h{constructor(e,t,r,i,o,n){if(this._streamDataController=t,this._logger=r,this._defaultGeometrySchema=i,this._requiredAttributes=o,this._options=n,this._logLayer=e,this._layerUrl=e.parsedUrl.path,this._geometryDefinitions=e.geometryDefinitions,e.materialDefinitions){const t=e.textureSetDefinitions;this._materialAndTextures=e.materialDefinitions.map((e=>d(t,e)))}}_load(e,t,r){return this._streamDataController.request(e,t,r)}_loadAttribute(e,t,r){const i=`${this._layerUrl}/nodes/${e.resources.attributes}/attributes/${t.key}/0`;return this._load(i,"binary",r).then((e=>l(t,e)))}loadAttributes(e,t,r){return n(t.map((t=>this._loadAttribute(e,t.attributeStorageInfo,r)))).then((r=>{const i={};for(let o=0;o<t.length;++o){const n=r[o].value;if(n)i[t[o].name]=n;else{if(s(r[o].error))throw r[o].error;this._logger.error("#loadAttributes",this._logLayer,`Failed to load attributeData for '${t[o].name}' on node '${e.id}'`,r[o].error)}}return i}))}async loadNodeData(r,n){const s=null!=this._requiredAttributes&&r.resources.attributes?e(this.loadAttributes(r,this._requiredAttributes,n)):null,{bufferDefinition:a,bufferIndex:u}=D(this._geometryDefinitions,r),l=!!r.resources.geometry,d=l?e(this._loadGeometry(r.resources.geometry,u,n)):null,m=r.resources.hasSharedResource?await this._loadShared(r,n):null,h=this._materialAndTextures&&r.resources.materialDefinition>=0?this._materialAndTextures[r.resources.materialDefinition]:null!=m?c(m):null,p=h&&h.material,x=h&&h.textures,A=`${r.id}`,w=!l&&this._options.loadFeatureData,T=w?await this._loadFeatureData(A,n):null,$=w?_(T):g(p),j=i($)&&y(T),I=null!=x&&x.length>0?e(this.loadTextures(r,x,n)):null;let U=null,S=null;if(d){U=t(await d);const e=b(this._defaultGeometrySchema,m);S=f(a,e)}const q=I?t(await I):null,B=s?t(await s):{},C=B?{attributeData:B,loadedAttributes:this._requiredAttributes}:null;if(o($))return{geometryData:$,attributeDataInfo:C,geometryBuffer:U,geometryDescriptor:S,requiredTextures:x,textureData:q};if(o(j))return{pointData:j,attributeDataInfo:C,geometryBuffer:U,geometryDescriptor:S,requiredTextures:x,textureData:q};throw new Error}static _addAbsoluteHrefTexture(e,t){const r=e.textureDefinitions;if(null!=r)for(const i of Object.keys(r))for(const e of r[i].images)Array.isArray(e.href)?e.hrefConcat=e.href.map((e=>a(e,t))):e.hrefConcat=a(e.href,t)}static _fixTextureEncodings(e){const t=e.textureDefinitions;if(null!=t)for(const r in t){const e=t[r];if(Array.isArray(e.encoding))for(let t=0;t<e.encoding.length;t++){const r=e.encoding[t];"data:"===r.substring(0,5)&&(e.encoding[t]=r.substring(5))}else{const t=e.encoding;"data:"===t.substring(0,5)&&(e.encoding=t.substring(5))}}}_loadShared(e,t){const r=`${this._layerUrl}/nodes/${e.resources.geometry}/shared`;return this._load(r,"json",t).then((e=>(h._fixTextureEncodings(e),h._addAbsoluteHrefTexture(e,r),e)))}_loadTexture(e,t,r,i,o,n){let s=!1;return o===u.DDS_S3TC||o===u.KTX2||o===u.Basis?this._load(e,"binary",n).then((e=>({id:t,usage:r,data:e,encoding:o,downsampled:s}))):this._load(e,"image",n).then((e=>{let n=e;const a=4096,u=2;if(i&&e.width*e.height>=a){const t=Math.ceil(e.width/u),r=Math.ceil(e.height/u),i=document.createElement("canvas");i.width=t,i.height=r;i.getContext("2d").drawImage(e,0,0,t,r),n=i,s=!0}return{id:t,usage:r,data:n,encoding:o,downsampled:s}}))}loadTextures(e,t,r){const i=this._options.uncompressedTextureDownsamplingEnabled,o=this._options.textureUsageMask;return Promise.all(t.map((t=>{if(0==(t.usage&o))return null;const n=m(t.encodings,this._options.textureEncodings);if(null==n)return this._logger.error("#loadTextures",this._logLayer,`No known encoding for texture found on node ${e.id}`),Promise.reject();const s=e.resources.texture||e.id,a=`${this._layerUrl}/nodes/${s}/textures/${n.name}`;return this._loadTexture(a,t.id,t.usage,i,n.encoding,r)})))}_loadFeatureData(e,t){const r=`${this._layerUrl}/nodes/${e}/features/0`;return this._load(r,"json",t)}_loadGeometry(e,t,r){const i=`${this._layerUrl}/nodes/${e}/geometries/${t}`;return this._load(i,"binary",r)}}function g(e){return{featureIds:[],geometries:[{type:"ArrayBufferView",params:{material:e}}],featureDataPosition:[0,0,0]}}function _(e){for(const t of e.featureData){const e=t.geometries;if(null!=e)for(const r of e)return{featureIds:[t.id],featureDataPosition:t.position,geometries:[r]}}return null}function y(e){const t=new Array;for(const r of e.featureData)null!=r.position&&t.push({featureIds:[r.id],featureDataPosition:r.position,geometries:null});return t}function b(e,t){if(!e||!t||!t.materialDefinitions)return e;const i=Object.keys(t.materialDefinitions)[0];return!t.materialDefinitions[i].params.vertexRegions&&e.vertexAttributes.region&&delete(e=r(e)).vertexAttributes.region,e}function D(e,t){const r={bufferDefinition:null,bufferIndex:0};if(null==e||t.resources.geometryDefinition<0)return r;const i=t.resources.geometryDefinition>=0?e[t.resources.geometryDefinition].geometryBuffers:null;if(null==i)return r;for(let o=0;o<i.length;o++){const e=i[o];if(null==e.compressedAttributes)r.bufferIndex=o,r.bufferDefinition=i[o];else if("draco"===e.compressedAttributes.encoding&&!has("disable-feature:i3s-draco"))return r.bufferIndex=o,r.bufferDefinition=e,r}return r}export{h as default};
5
+ import{result as e,assertResult as t}from"../../../../core/asyncUtils.js";import has from"../../../../core/has.js";import{clone as r}from"../../../../core/lang.js";import{isNone as i,isSome as o}from"../../../../core/maybe.js";import{eachAlways as n,isAbortError as s}from"../../../../core/promiseUtils.js";import{makeAbsolute as a}from"../../../../core/urlUtils.js";import{TextureEncoding as u}from"./enums.js";import{readBinaryAttribute as l,createGeometryDescriptor as f}from"./I3SBinaryReader.js";import{getMaterialAndTextures as d,getMaterialAndTexturesFromShared as c,selectEncoding as h}from"./I3SMaterialUtil.js";class m{constructor(e,t,r,i,o,n){if(this._streamDataController=t,this._logger=r,this._defaultGeometrySchema=i,this._requiredAttributes=o,this._options=n,this._logLayer=e,this._layerUrl=e.parsedUrl.path,this._geometryDefinitions=e.geometryDefinitions,e.materialDefinitions){const t=e.textureSetDefinitions;this._materialAndTextures=e.materialDefinitions.map((e=>d(t,e)))}}_load(e,t,r){return this._streamDataController.request(e,t,r)}_loadAttribute(e,t,r){const i=`${this._layerUrl}/nodes/${e.resources.attributes}/attributes/${t.key}/0`;return this._load(i,"binary",r).then((e=>l(t,e)))}loadAttributes(e,t,r){return n(t.map((t=>this._loadAttribute(e,t.attributeStorageInfo,r)))).then((r=>{const i={};for(let o=0;o<t.length;++o){const n=r[o].value;if(n)i[t[o].name]=n;else{if(s(r[o].error))throw r[o].error;this._logger.error("#loadAttributes",this._logLayer,`Failed to load attributeData for '${t[o].name}' on node '${e.id}'`,r[o].error)}}return i}))}async loadNodeData(r,n){const s=null!=this._requiredAttributes&&r.resources.attributes?e(this.loadAttributes(r,this._requiredAttributes,n)):null,{bufferDefinition:a,bufferIndex:u}=D(this._geometryDefinitions,r),l=!!r.resources.geometry,d=l?e(this._loadGeometry(r.resources.geometry,u,n)):null,h=r.resources.hasSharedResource?await this._loadShared(r,n):null,m=r.resources.materialDefinition,p=this._materialAndTextures&&null!=m&&m>=0?this._materialAndTextures[m]:null!=h?c(h):null,x=p?.material,A=p?.textures??[],w=`${r.id}`,T=!l&&this._options.loadFeatureData,$=T?await this._loadFeatureData(w,n):null,j=T?_($):g(x),I=i(j)?b($):null,U=A.length>0?e(this.loadTextures(r,A,n)):null;let S=null,q=null;if(d){S=t(await d);const e=y(this._defaultGeometrySchema,h);q=f(a,e)}const B=U?t(await U):null,C=s?t(await s):{},E=C?{attributeData:C,loadedAttributes:this._requiredAttributes}:null;if(o(j))return{geometryData:j,attributeDataInfo:E,geometryBuffer:S,geometryDescriptor:q,requiredTextures:A,textureData:B};if(o(I))return{pointData:I,attributeDataInfo:E,geometryBuffer:S,geometryDescriptor:q,requiredTextures:A,textureData:B};throw new Error}static _addAbsoluteHrefTexture(e,t){const r=e.textureDefinitions;if(null!=r)for(const i of Object.keys(r))for(const e of r[i].images)Array.isArray(e.href)?e.hrefConcat=e.href.map((e=>a(e,t))):e.hrefConcat=a(e.href,t)}static _fixTextureEncodings(e){const t=e.textureDefinitions;if(null!=t)for(const r in t){const e=t[r];if(Array.isArray(e.encoding))for(let t=0;t<e.encoding.length;t++){const r=e.encoding[t];"data:"===r.substring(0,5)&&(e.encoding[t]=r.substring(5))}else{const t=e.encoding;"data:"===t.substring(0,5)&&(e.encoding=t.substring(5))}}}_loadShared(e,t){const r=`${this._layerUrl}/nodes/${e.resources.geometry}/shared`;return this._load(r,"json",t).then((e=>(m._fixTextureEncodings(e),m._addAbsoluteHrefTexture(e,r),e)))}_loadTexture(e,t,r,i,o,n){let s=!1;return o===u.DDS_S3TC||o===u.KTX2||o===u.Basis?this._load(e,"binary",n).then((e=>({id:t,usage:r,data:e,encoding:o,downsampled:s}))):this._load(e,"image",n).then((e=>{let n=e;const a=4096,u=2;if(i&&e.width*e.height>=a){const t=Math.ceil(e.width/u),r=Math.ceil(e.height/u),i=document.createElement("canvas");i.width=t,i.height=r;i.getContext("2d").drawImage(e,0,0,t,r),n=i,s=!0}return{id:t,usage:r,data:n,encoding:o,downsampled:s}}))}loadTextures(e,t,r){const i=!!this._options.uncompressedTextureDownsamplingEnabled,o=this._options.textureUsageMask;return Promise.all(t.map((t=>{if(0==(t.usage&o))return null;const n=h(t.encodings,this._options.textureEncodings);if(null==n)return this._logger.error("#loadTextures",this._logLayer,`No known encoding for texture found on node ${e.id}`),Promise.reject();const s=e.resources.texture||e.id,a=`${this._layerUrl}/nodes/${s}/textures/${n.name}`;return this._loadTexture(a,t.id,t.usage,i,n.encoding,r)})))}_loadFeatureData(e,t){const r=`${this._layerUrl}/nodes/${e}/features/0`;return this._load(r,"json",t)}_loadGeometry(e,t,r){const i=`${this._layerUrl}/nodes/${e}/geometries/${t}`;return this._load(i,"binary",r)}}function g(e){return{featureIds:[],geometries:[{type:"ArrayBufferView",params:{material:e}}],featureDataPosition:[0,0,0]}}function _(e){if(!e)return null;for(const t of e.featureData){const e=t.geometries;if(null!=e)for(const r of e)return{featureIds:[t.id],featureDataPosition:t.position,geometries:[r]}}return null}function b(e){if(!e)return null;const t=new Array;for(const r of e.featureData)null!=r.position&&t.push({featureIds:[r.id],featureDataPosition:r.position,geometries:[]});return t}function y(e,t){if(!e||!t||!t.materialDefinitions)return e;const i=Object.keys(t.materialDefinitions)[0];return!t.materialDefinitions[i].params.vertexRegions&&e.vertexAttributes.region&&delete(e=r(e)).vertexAttributes.region,e}function D(e,t){const r={bufferDefinition:null,bufferIndex:0},i=t.resources.geometryDefinition;if(null==e||null==i||i<0)return r;const o=i>=0?e[i].geometryBuffers:null;if(null==o)return r;for(let n=0;n<o.length;n++){const e=o[n];if(null==e.compressedAttributes)r.bufferIndex=n,r.bufferDefinition=o[n];else if("draco"===e.compressedAttributes.encoding&&!has("disable-feature:i3s-draco"))return r.bufferIndex=n,r.bufferDefinition=e,r}return r}export{m as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import t from"../../../../core/Error.js";import s from"../../../../core/Handles.js";import{isNone as n}from"../../../../core/maybe.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import a from"../../../../geometry/Extent.js";import{fallbackObjectIDAttribute as u}from"../../../../layers/LayerConstants.js";import{QueryEngine as y}from"../../../../layers/graphics/data/QueryEngine.js";import c from"../../../../rest/support/FeatureSet.js";import l from"../../../../rest/support/Query.js";const p=y;let d=class extends r{get spatialReference(){return this.layerView.view.spatialReference}get layer(){return this.layerView.i3slayer}get defaultQueryJSON(){return new l({outSpatialReference:this.spatialReference}).toJSON()}get _dataQueryEngine(){return this._ensureDataQueryEngine()}constructor(e){super(e),this._dataQueryEngineInstance=null,this._handles=new s}initialize(){this._handles.add(this.layerView.on("visible-geometry-changed",(()=>this.spatialIndex.events.emit("changed"))))}destroy(){this._dataQueryEngineInstance&&(this._dataQueryEngineInstance.destroy(),this._dataQueryEngineInstance=null),this._handles&&(this._handles.destroy(),this._handles=null),this._set("layerView",null)}async executeQueryForCount(e,r){return this._dataQueryEngine.executeQueryForCount(this._ensureQueryJSON(e),r)}async executeQueryForExtent(e,r){const{count:t,extent:s}=await this._dataQueryEngine.executeQueryForExtent(this._ensureQueryJSON(e),r);return{count:t,extent:a.fromJSON(s)}}async executeQueryForIds(e,r){return this._dataQueryEngine.executeQueryForIds(this._ensureQueryJSON(e),r)}async executeQuery(e,r){const s=this._ensureQueryJSON(e);if(s.returnGeometry)throw new t("feature-store:unsupported-query","returnGeometry is not yet supported for mesh scene layer queries");if(s.returnCentroid)throw new t("feature-store:unsupported-query","returnCentroid is not yet supported for mesh scene layer queries");const n=await this._dataQueryEngine.executeQuery(s,r),o=c.fromJSON(n);return o.features.forEach((e=>{e.geometry=null})),o}_ensureQueryJSON(e){return n(e)?this.defaultQueryJSON:e.toJSON()}_ensureDataQueryEngine(){if(this._dataQueryEngineInstance)return this._dataQueryEngineInstance;const e=this.layer.objectIdField||u,r="esriGeometryPolygon",t=this.layer.fields.map((e=>e.toJSON())),s=this.layerView.view.resourceController.scheduler,n=this.spatialReference.toJSON(),o=this.priority,i=this.spatialIndex;return this._dataQueryEngineInstance=new p({hasZ:!0,hasM:!1,geometryType:r,fields:t,timeInfo:null,spatialReference:n,objectIdField:e,featureStore:i,scheduler:s,priority:o}),this._dataQueryEngineInstance}};e([o({constructOnly:!0})],d.prototype,"layerView",void 0),e([o({constructOnly:!0})],d.prototype,"priority",void 0),e([o({constructOnly:!0})],d.prototype,"spatialIndex",void 0),e([o()],d.prototype,"spatialReference",null),e([o()],d.prototype,"layer",null),e([o()],d.prototype,"defaultQueryJSON",null),d=e([i("esri.views.3d.layers.i3s.I3SQueryEngine")],d);export{d as I3SQueryEngine};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import t from"../../../../core/Error.js";import s from"../../../../core/Handles.js";import{destroyMaybe as n,isNone as o}from"../../../../core/maybe.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import u from"../../../../geometry/Extent.js";import{fallbackObjectIDAttribute as y}from"../../../../layers/LayerConstants.js";import{QueryEngine as c}from"../../../../layers/graphics/data/QueryEngine.js";import l from"../../../../rest/support/FeatureSet.js";import p from"../../../../rest/support/Query.js";const d=c;let h=class extends r{get spatialReference(){return this.layerView.view.spatialReference}get layer(){return this.layerView.i3slayer}get defaultQueryJSON(){return new p({outSpatialReference:this.spatialReference}).toJSON()}get _dataQueryEngine(){return this._ensureDataQueryEngine()}constructor(e){super(e),this._handles=new s}initialize(){this._handles.add(this.layerView.on("visible-geometry-changed",(()=>this.spatialIndex.events.emit("changed"))))}destroy(){this._dataQueryEngineInstance=n(this._dataQueryEngineInstance),this._handles=n(this._handles),this._set("layerView",null)}async executeQueryForCount(e,r){return this._dataQueryEngine.executeQueryForCount(this._ensureQueryJSON(e),r)}async executeQueryForExtent(e,r){const{count:t,extent:s}=await this._dataQueryEngine.executeQueryForExtent(this._ensureQueryJSON(e),r);return{count:t,extent:u.fromJSON(s)}}async executeQueryForIds(e,r){return this._dataQueryEngine.executeQueryForIds(this._ensureQueryJSON(e),r)}async executeQuery(e,r){const s=this._ensureQueryJSON(e);if(s.returnGeometry)throw new t("feature-store:unsupported-query","returnGeometry is not yet supported for mesh scene layer queries");if(s.returnCentroid)throw new t("feature-store:unsupported-query","returnCentroid is not yet supported for mesh scene layer queries");const n=await this._dataQueryEngine.executeQuery(s,r),o=l.fromJSON(n);return o.features.forEach((e=>{e.geometry=null})),o}_ensureQueryJSON(e){return o(e)?this.defaultQueryJSON:e.toJSON()}_ensureDataQueryEngine(){if(this._dataQueryEngineInstance)return this._dataQueryEngineInstance;const e=this.layer.objectIdField||y,r="esriGeometryPolygon",t=this.layer.fields?.map((e=>e.toJSON()))??[],s=this.layerView.view.resourceController.scheduler,n=this.spatialReference.toJSON(),o=this.priority,i=this.spatialIndex;return this._dataQueryEngineInstance=new d({hasZ:!0,hasM:!1,geometryType:r,fields:t,timeInfo:null,spatialReference:n,objectIdField:e,featureStore:i,scheduler:s,priority:o}),this._dataQueryEngineInstance}};e([i({constructOnly:!0})],h.prototype,"layerView",void 0),e([i({constructOnly:!0})],h.prototype,"priority",void 0),e([i({constructOnly:!0})],h.prototype,"spatialIndex",void 0),e([i()],h.prototype,"spatialReference",null),e([i()],h.prototype,"layer",null),e([i()],h.prototype,"defaultQueryJSON",null),h=e([a("esri.views.3d.layers.i3s.I3SQueryEngine")],h);export{h as I3SQueryEngine};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- function t(t){const e=t.renderer,n=e&&e.type,o=e&&t.renderer.toJSON()||null;let r=null,i=!1;"point-cloud-unique-value"===n||"point-cloud-stretch"===n||"point-cloud-class-breaks"===n?r=u(t.attributeStorageInfo,e.field):"point-cloud-rgb"===n?(r=l(t.attributeStorageInfo,e.field),i=null!=r):(r=l(t.attributeStorageInfo,"RGB"),i=null!=r);let a=null;return e&&e.colorModulation&&(a=u(t.attributeStorageInfo,e.colorModulation.field)),{rendererJSON:o,isRGBRenderer:i,primaryAttribute:r,modulationAttribute:a}}function e(t){const e=t.filters;return e?e.map((e=>({filterJSON:e.toJSON(),attributeInfo:u(t.attributeStorageInfo,e.field)}))):[]}function n(t){const e=t&&t.pointSizeAlgorithm;return e&&"splat"===e.type?e:null}function o(t){const e=t&&t.pointSizeAlgorithm;return e&&"fixed-size"===e.type?e:null}function r(t){const e=t&&t.pointSizeAlgorithm;return!(!e||!e.type)&&"fixed-size"===e.type}function l(t,e){for(const n of t)if(n.name===e&&null!=n.attributeValues&&"UInt8"===n.attributeValues.valueType&&3===n.attributeValues.valuesPerElement)return{name:e,storageInfo:n,useElevation:!1};return null}function u(t,e){for(const n of t)if(n.name===e){const t="embedded-elevation"===n.encoding;return{name:e,storageInfo:t?null:n,useElevation:t}}return"elevation"===e.toLowerCase()?{name:e,storageInfo:null,useElevation:!0}:null}export{u as getAttributeInfo,e as getFilterInfo,o as getFixedSizeAlgorithm,t as getRendererInfo,n as getSplatSizeAlgorithm,r as rendererUsesFixedSizes};
5
+ function t(t){const e=t.renderer,n=e?.type,o=e?.toJSON()??null;let l=null,i=!1;const a=t.attributeStorageInfo;"point-cloud-unique-value"===n||"point-cloud-stretch"===n||"point-cloud-class-breaks"===n?l=u(a,e.field):"point-cloud-rgb"===n?(l=r(a,e.field),i=null!=l):(l=r(a,"RGB"),i=null!=l);let s=null;return e?.colorModulation&&(s=u(a,e.colorModulation.field)),{rendererJSON:o,isRGBRenderer:i,primaryAttribute:l,modulationAttribute:s}}function e(t){const e=t.filters;return e?e.map((e=>({filterJSON:e.toJSON(),attributeInfo:u(t.attributeStorageInfo,e.field)}))):[]}function n(t){const e=t?.pointSizeAlgorithm;return e&&"splat"===e.type?e:null}function o(t){const e=t?.pointSizeAlgorithm;return e&&"fixed-size"===e.type?e:null}function l(t){const e=t?.pointSizeAlgorithm;return!(!e||!e.type)&&"fixed-size"===e.type}function r(t,e){for(const n of t??[])if(n.name===e&&null!=n.attributeValues&&"UInt8"===n.attributeValues.valueType&&3===n.attributeValues.valuesPerElement)return{name:e,storageInfo:n,useElevation:!1};return null}function u(t,e){for(const n of t??[])if(n.name===e){const t="embedded-elevation"===n.encoding;return{name:e,storageInfo:t?null:n,useElevation:t}}return"elevation"===e?.toLowerCase()?{name:e,storageInfo:null,useElevation:!0}:null}export{u as getAttributeInfo,e as getFilterInfo,o as getFixedSizeAlgorithm,t as getRendererInfo,n as getSplatSizeAlgorithm,l as rendererUsesFixedSizes};