@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"../../../Color.js";import r from"../../../core/Evented.js";import i from"../../../core/Handles.js";import{destroyMaybe as n,isSome as s,isNone as o,mapOr as a}from"../../../core/maybe.js";import{after as h}from"../../../core/promiseUtils.js";import{watch as c,sync as d,syncAndInitial as l}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 _}from"../../../core/accessorSupport/decorators/subclass.js";import{s as u,g as m,c as f,h as g}from"../../../chunks/vec3.js";import{c as P,f as v}from"../../../chunks/vec3f64.js";import{b,f as w}from"../../../chunks/vec4f64.js";import{canProjectToWGS84ComparableLonLat as C,projectPointToWGS84ComparableLonLat as y}from"../../../geometry/projection.js";import{isEarth as U}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as T}from"../../ViewingMode.js";import{EnvironmentRenderer as R}from"./EnvironmentRenderer.js";import{positionToTimezoneInfo as S}from"../support/earthUtils.js";import{computeColorAndIntensity as M,computeVirtualLightDirection as H,ColorAndIntensity as W,computeShadowsEnabled as G}from"../support/sunUtils.js";import{Update as j}from"../webgl-engine/lib/Update.js";import{MainLight as L,AmbientLight as k,FillLight as E}from"../webgl-engine/lighting/Lightsources.js";import Q from"../../../webscene/background/ColorBackground.js";let D=class extends r.EventedAccessor{constructor(){super(),this._referencePointUpdateDelay=200,this._referencePointUpdateInterval=3e3,this._referencePointUpdateDistThreshold=1e6,this._referencePosUpdateQuery=null,this._referencePosMapCoordsRequested=null,this._viewHandles=new i,this._preserveAbsoluteDateTime=!1,this._trackingEnabled=!1,this._referencePosResetPreserveAbsoluteTime=!1,this._referencePosUpdateTimer=null,this._referencePosMapCoords=null,this._mainLight=new L,this._ambientLight=new k,this._moonLight=new E,this.disableQueries=!1,this._disableWeather=!1,this._renderer=null,this._referencePosWGS84Comparable=null,this._resetReferencePosition()}destroy(){this.disconnectView(),this._viewHandles.destroy()}get _view(){return this._renderer?.view}get updating(){return!((this.disableQueries||!this._referencePosUpdateQuery&&!this._referencePosMapCoordsRequested)&&!this._renderer?.updating)}get weatherEnabled(){return this._view?.environment.atmosphereEnabled&&!this._disableWeather&&this._view?.state?.viewingMode===T.Global&&U(this._view.spatialReference)}get weatherVisible(){return this.weatherEnabled&&this._renderer?.weatherVisible}get referencePositionWGS84Comparable(){return this._referencePosWGS84Comparable}connectView(e){if(this._renderer)return;this._renderer=new R({view:e});const t=()=>this._updateRenderParameters(),r=()=>this._cameraHandler();this._viewHandles.add([c((()=>e.environment.lighting),(e=>this._updateLightingHandler(e)),d),c((()=>"virtual"!==e.environment.lighting.type?e.environment.lighting.date:null),(e=>this._lightingDateHandler(e)),d),c((()=>e.stationary),(()=>this._interactingStationaryHandler())),c((()=>e.environment.lighting.directShadowsEnabled),t,d),c((()=>e.environment.lighting.ambientOcclusionEnabled),t,d),c((()=>e.environment.lighting.waterReflectionEnabled),t,d),c((()=>e.environment.background?.color),t,d),c((()=>e.spatialReference),(()=>this._resetReferencePosition(!0)),d),c((()=>e.environment.weather.type),(()=>this._updateLighting(null,j.Faded)),d),c((()=>this.weatherEnabled),(()=>this._updateLighting(null,j.Faded)),d),c((()=>e.viewingMode),(()=>this._resetReferencePosition(!0)),l),c((()=>"virtual"!==e.environment.lighting.type&&e.environment.lighting.cameraTrackingEnabled),(e=>this._updateCameraTracking(e)),l),c((()=>e.state.camera),r,l),c((()=>this.disableQueries),r)]),this._updateRenderParameters(),this._updateLighting(),this._cameraHandler(),this.notifyChange("updating")}disconnectView(){this._viewHandles.removeAll(),this._resetReferencePosition(),this._renderer=n(this._renderer)}_updateLightingHandler(e){this._updateCameraTracking("virtual"!==e.type&&e.cameraTrackingEnabled),this._lightingDateHandler("virtual"!==e.type?e.date:null),this._updateRenderParameters()}_updateCameraTracking(e){if(this._trackingEnabled=e,e)this._cameraHandler();else{const e=this._view.environment.lighting;"virtual"!==e?.type&&(e.positionTimezoneInfo.autoUpdated=!1)}}_lightingDateHandler(e){const t=this._view.environment.lighting;if("virtual"!==t?.type){if(e){if(!t.positionTimezoneInfo.autoUpdated){this._preserveAbsoluteDateTime=!0;const r=this._view.spatialReference;if(!C(r)){const e=this._view.camera.position;if(!this._referencePosMapCoords||!this._referencePosMapCoords.equals(e))return void this._requestReferencePositionUpdate(e)}if(this._preupdateTracking(e),s(this._referencePosWGS84Comparable)){const e=S(this._referencePosWGS84Comparable,V);s(e)&&(t.autoUpdate(null,e),this._trackingEnabled&&(t.positionTimezoneInfo.autoUpdated=!0))}}this._updateLighting(e)}}else this._updateLighting()}_preupdateTracking(e){!this._trackingEnabled&&"virtual"!==this._view.environment.lighting.type&&this._view.environment.lighting.cameraTrackingEnabled&&this._cameraHandler(e)}_cameraHandler(e=null){const t=this._view;if(!t.ready)return;const r=t.stateManager.camera;r&&(this._cameraHandlerClientSide(r,e)||this._cameraHandlerServerSide(r))}_cameraHandlerClientSide(e,t){const r=U(this._view.spatialReference);if(r&&!C(this._view.spatialReference))return"virtual"===this._view.environment.lighting.type&&this._updateLighting(),!1;const i=e.position;return o(this._referencePosWGS84Comparable)&&(this._referencePosWGS84Comparable=P()),r?y(i,this._referencePosWGS84Comparable):u(this._referencePosWGS84Comparable,i.longitude,i.latitude,i.z),this.notifyChange("referencePositionWGS84Comparable"),this._autoUpdateTimezone(this._referencePosWGS84Comparable,t)||this._updateLighting(t),!0}_cameraHandlerServerSide(e){const t=e.position;(!this._referencePosMapCoords||this._referencePosMapCoordsRequested||this._exceedsReferencePosDistThreshold(t))&&this._requestReferencePositionUpdate(t,!0),this._view.mapCoordsHelper&&this._referencePosWGS84Comparable&&(this._referencePosWGS84Comparable[2]=t.z*this._view.mapCoordsHelper.unitInMeters,this._referencePosChanged())}_interactingStationaryHandler(){this._view.stationary&&this._executePendingReferencePositionUpdate()}_updateLighting(e,t=j.Immediate){const r=this._view;e=e||("virtual"===r.environment.lighting.type?null:r.environment.lighting.date);const i=this._referencePosWGS84Comparable,n=s(i)?q:A,o=this.weatherVisible?r.environment.weather.type:"disabled";s(i)?M(e,i,r.state.viewingMode,o,r.state.camera,n):"virtual"===r.environment.lighting.type&&H(r.state.camera,r.state.viewingMode,n.direct.directionToLightSource);const a=this._mainLight,h=n.direct;m(a.intensity,h.color,h.intensity*Math.PI),f(a.direction,h.directionToLightSource),a.specularStrength=n.specularStrength,a.environmentStrength=n.environmentStrength;const c=this._ambientLight;m(c.intensity,n.ambient.color,n.ambient.intensity);const d=this._moonLight;g(d.intensity,z,x,n.globalFactor);const l=(1-.5*n.globalFactor)*(1-.4*n.noonFactor*(1-n.globalFactor));m(d.intensity,d.intensity,l),f(d.direction,h.directionToLightSource),this._renderer.updateLightSources([a,c,d],n.noonFactor,n.globalFactor,t),this._updateRenderParameters()}_autoUpdateTimezone(e,t=null){if("virtual"===this._view.environment.lighting.type||!this._view.environment.lighting.cameraTrackingEnabled||o(e))return!1;const r=I;r.setTime((t||this._view.environment.lighting.date).getTime());const i=S(e,V);if(o(i))return!1;let n=this._view.environment.lighting.positionTimezoneInfo;if(n.autoUpdated){if(n.hours===i.hours&&n.minutes===i.minutes&&n.seconds===i.seconds)return!1}else n=i;const s=r.getUTCHours()-(i.hours-n.hours),a=r.getUTCMinutes()-(i.minutes-n.minutes),h=r.getUTCSeconds()-(i.seconds-n.seconds);return r.setUTCHours(s),r.setUTCMinutes(a),r.setUTCSeconds(h),!t&&this._view.environment.lighting.autoUpdate(r,i)}_updateRenderParameters(){const e=this._view._stage;if(!e)return;const r=a(this._referencePosWGS84Comparable,!0,(e=>G(e[2],this._view.state.viewingMode))),i=this._view.environment.background,n=i instanceof Q?{type:"color",color:b(t.toUnitRGBA(i.color))}:{type:"color",color:w(0,0,0,1)};e.renderer.setParameters({shadowMap:this._view.environment.lighting.directShadowsEnabled&&r,background:n,environment:this._view.environment,weatherVisible:this._view.environmentManager.weatherVisible})}_resetReferencePosition(e=!1){this._cancelReferencePosUpdates(),this._referencePosMapCoords=null,this._referencePosMapCoordsRequested=null,this._referencePosResetPreserveAbsoluteTime=null,this._referencePosWGS84Comparable=null,this.notifyChange("updating"),e&&this._cameraHandler()}_requestReferencePositionUpdate(e,t=!1){if(!this.disableQueries&&(this._referencePosMapCoordsRequested?this._referencePosMapCoordsRequested.copy(e):this._referencePosMapCoordsRequested=e.clone(),this._referencePosResetPreserveAbsoluteTime=!!t,!this._referencePosUpdateQuery&&!this._referencePosUpdateTimer&&this._view.stationary)){const e=this._referencePosUpdateQuery=h(this._referencePointUpdateDelay).then((()=>{if(this._referencePosUpdateQuery===e){const t=()=>this._referencePosUpdateQuery!==e;return this._doReferencePositionUpdateQuery(t)}})).catch((e=>{"mapcoordshelper:missing-geometry-service"===e.name&&(this.disableQueries=!0)})).then((()=>{this._referencePosUpdateQuery===e&&(this._referencePosUpdateQuery=null,this._referencePosUpdateTimer||this._executePendingReferencePositionUpdate(),this.notifyChange("updating"))})),t=this._referencePosUpdateTimer=h(this._referencePointUpdateInterval).then((()=>{this._referencePosUpdateTimer===t&&(this._referencePosUpdateTimer=null,this._referencePosUpdateQuery||this._executePendingReferencePositionUpdate())}));this.notifyChange("updating")}}async _doReferencePositionUpdateQuery(e){this._referencePosResetPreserveAbsoluteTime&&(this._preserveAbsoluteDateTime=!1),this._referencePosMapCoords?this._referencePosMapCoords.copy(this._referencePosMapCoordsRequested):this._referencePosMapCoords=this._referencePosMapCoordsRequested.clone(),this._referencePosResetPreserveAbsoluteTime=null,this._referencePosMapCoordsRequested=null;const t=await this._view.mapCoordsHelper.toGeographic(this._referencePosMapCoords);if(!e()&&!isNaN(t[0])&&!isNaN(t[1])){const e=this._referencePosMapCoords.z*this._view.mapCoordsHelper.unitInMeters;this._referencePosWGS84Comparable?(this._referencePosWGS84Comparable[0]=t[0],this._referencePosWGS84Comparable[1]=t[1],this._referencePosWGS84Comparable[2]=e):this._referencePosWGS84Comparable=[t[0],t[1],e],this._referencePosChanged()}}_executePendingReferencePositionUpdate(){const e=this._referencePosMapCoordsRequested;e&&this._requestReferencePositionUpdate(e,this._referencePosResetPreserveAbsoluteTime)}_referencePosChanged(){this._preserveAbsoluteDateTime?this._updateLighting():this._autoUpdateTimezone(this._referencePosWGS84Comparable)||this._updateLighting(),this.notifyChange("referencePositionWGS84Comparable")}_exceedsReferencePosDistThreshold(e){if(this._referencePosMapCoords){let t=this._referencePosMapCoords.distance(e);return this._view.mapCoordsHelper&&(t*=this._view.mapCoordsHelper.unitInMeters),t>this._referencePointUpdateDistThreshold}return!0}_cancelReferencePosUpdates(){const e=!!this._referencePosUpdateQuery;return this._referencePosUpdateQuery=null,this._referencePosUpdateTimer=null,e}get test(){const e=this;return{get renderer(){return e._renderer},set referencePointUpdateInterval(t){e._referencePointUpdateInterval=t},set referencePointUpdateDistThreshold(t){e._referencePointUpdateDistThreshold=t},set referencePosUpdateTimer(t){e._referencePosUpdateTimer=t},set referencePointUpdateDelay(t){e._referencePointUpdateDelay=t},set disableWeather(t){e._disableWeather=t}}}};e([p({type:Boolean,readOnly:!0})],D.prototype,"updating",null),e([p()],D.prototype,"disableQueries",void 0),e([p()],D.prototype,"_disableWeather",void 0),e([p()],D.prototype,"weatherEnabled",null),e([p()],D.prototype,"weatherVisible",null),e([p()],D.prototype,"referencePositionWGS84Comparable",null),e([p()],D.prototype,"_renderer",void 0),e([p()],D.prototype,"_referencePosWGS84Comparable",void 0),D=e([_("esri.views.3d.environment.SceneViewEnvironmentManager")],D);const q=new W,A=new W,I=new Date,V={hours:0,minutes:0,seconds:0},z=v(.22,.22,.33),x=v(.22,.22,.22);export{D as SceneViewEnvironmentManager};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import r from"../../../core/Evented.js";import i from"../../../core/Handles.js";import{destroyMaybe as n,isSome as s,isNone as o,mapOr as a}from"../../../core/maybe.js";import{after as h}from"../../../core/promiseUtils.js";import{watch as c,sync as d,syncAndInitial as l}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 _}from"../../../core/accessorSupport/decorators/subclass.js";import{s as u,g as m,c as f,h as g}from"../../../chunks/vec3.js";import{c as P,f as v}from"../../../chunks/vec3f64.js";import{b,f as w}from"../../../chunks/vec4f64.js";import{canProjectToWGS84ComparableLonLat as C,projectPointToWGS84ComparableLonLat as y}from"../../../geometry/projection.js";import{isEarth as U}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as T}from"../../ViewingMode.js";import{EnvironmentRenderer as R}from"./EnvironmentRenderer.js";import{positionToTimezoneInfo as S}from"../support/earthUtils.js";import{computeColorAndIntensity as M,computeVirtualLightDirection as H,ColorAndIntensity as W,computeShadowsEnabled as G}from"../support/sunUtils.js";import{Update as j}from"../webgl-engine/lib/Update.js";import{MainLight as L,AmbientLight as k,FillLight as E}from"../webgl-engine/lighting/Lightsources.js";import Q from"../../../webscene/background/ColorBackground.js";let D=class extends r.EventedAccessor{constructor(){super(),this._referencePointUpdateDelay=200,this._referencePointUpdateInterval=3e3,this._referencePointUpdateDistThreshold=1e6,this._referencePosUpdateQuery=null,this._referencePosMapCoordsRequested=null,this._viewHandles=new i,this._preserveAbsoluteDateTime=!1,this._trackingEnabled=!1,this._referencePosResetPreserveAbsoluteTime=!1,this._referencePosUpdateTimer=null,this._referencePosMapCoords=null,this._mainLight=new L,this._ambientLight=new k,this._moonLight=new E,this.disableQueries=!1,this._disableWeather=!1,this._renderer=null,this._referencePosWGS84Comparable=null,this._resetReferencePosition()}destroy(){this.disconnectView(),this._viewHandles.destroy()}get _view(){return this._renderer?.view}get updating(){return!((this.disableQueries||!this._referencePosUpdateQuery&&!this._referencePosMapCoordsRequested)&&!this._renderer?.updating)}get weatherEnabled(){return this._view?.environment.atmosphereEnabled&&!this._disableWeather&&this._view?.state?.viewingMode===T.Global&&U(this._view.spatialReference)}get weatherVisible(){return this.weatherEnabled&&this._renderer?.weatherVisible}get referencePositionWGS84Comparable(){return this._referencePosWGS84Comparable}connectView(e){if(this._renderer)return;this._renderer=new R({view:e});const t=()=>this._updateRenderParameters(),r=()=>this._cameraHandler();this._viewHandles.add([c((()=>e.environment.lighting),(e=>this._updateLightingHandler(e)),d),c((()=>"virtual"!==e.environment.lighting.type?e.environment.lighting.date:null),(e=>this._lightingDateHandler(e)),d),c((()=>e.stationary),(()=>this._interactingStationaryHandler())),c((()=>e.environment.lighting.directShadowsEnabled),t,d),c((()=>e.environment.lighting.ambientOcclusionEnabled),t,d),c((()=>e.environment.lighting.waterReflectionEnabled),t,d),c((()=>e.environment.background?.color),t,d),c((()=>e.spatialReference),(()=>this._resetReferencePosition(!0)),d),c((()=>e.environment.weather.type),(()=>this._updateLighting(null,j.Faded)),d),c((()=>this.weatherEnabled),(()=>this._updateLighting(null,j.Faded)),d),c((()=>e.viewingMode),(()=>this._resetReferencePosition(!0)),l),c((()=>"virtual"!==e.environment.lighting.type&&e.environment.lighting.cameraTrackingEnabled),(e=>this._updateCameraTracking(e)),l),c((()=>e.state.camera),r,l),c((()=>this.disableQueries),r)]),this._updateRenderParameters(),this._updateLighting(),this._cameraHandler(),this.notifyChange("updating")}disconnectView(){this._viewHandles.removeAll(),this._resetReferencePosition(),this._renderer=n(this._renderer)}_updateLightingHandler(e){this._updateCameraTracking("virtual"!==e.type&&e.cameraTrackingEnabled),this._lightingDateHandler("virtual"!==e.type?e.date:null),this._updateRenderParameters()}_updateCameraTracking(e){if(this._trackingEnabled=e,e)this._cameraHandler();else{const e=this._view.environment.lighting;"virtual"!==e?.type&&(e.positionTimezoneInfo.autoUpdated=!1)}}_lightingDateHandler(e){const t=this._view.environment.lighting;if("virtual"!==t?.type){if(e){if(!t.positionTimezoneInfo.autoUpdated){this._preserveAbsoluteDateTime=!0;const r=this._view.spatialReference;if(!C(r)){const e=this._view.camera.position;if(!this._referencePosMapCoords||!this._referencePosMapCoords.equals(e))return void this._requestReferencePositionUpdate(e)}if(this._preupdateTracking(e),s(this._referencePosWGS84Comparable)){const e=S(this._referencePosWGS84Comparable,V);s(e)&&(t.autoUpdate(null,e),this._trackingEnabled&&(t.positionTimezoneInfo.autoUpdated=!0))}}this._updateLighting(e)}}else this._updateLighting()}_preupdateTracking(e){!this._trackingEnabled&&"virtual"!==this._view.environment.lighting.type&&this._view.environment.lighting.cameraTrackingEnabled&&this._cameraHandler(e)}_cameraHandler(e=null){const t=this._view;if(!t.ready)return;const r=t.stateManager.camera;r&&(this._cameraHandlerClientSide(r,e)||this._cameraHandlerServerSide(r))}_cameraHandlerClientSide(e,t){const r=U(this._view.spatialReference);if(r&&!C(this._view.spatialReference))return"virtual"===this._view.environment.lighting.type&&this._updateLighting(),!1;const i=e.position;return o(this._referencePosWGS84Comparable)&&(this._referencePosWGS84Comparable=P()),r?y(i,this._referencePosWGS84Comparable):u(this._referencePosWGS84Comparable,i.longitude??0,i.latitude??0,i.z??0),this.notifyChange("referencePositionWGS84Comparable"),this._autoUpdateTimezone(this._referencePosWGS84Comparable,t)||this._updateLighting(t),!0}_cameraHandlerServerSide(e){const t=e.position;(!this._referencePosMapCoords||this._referencePosMapCoordsRequested||this._exceedsReferencePosDistThreshold(t))&&this._requestReferencePositionUpdate(t,!0),this._view.mapCoordsHelper&&this._referencePosWGS84Comparable&&(this._referencePosWGS84Comparable[2]=(t.z??0)*this._view.mapCoordsHelper.unitInMeters,this._referencePosChanged())}_interactingStationaryHandler(){this._view.stationary&&this._executePendingReferencePositionUpdate()}_updateLighting(e,t=j.Immediate){const r=this._view;e=e||("virtual"===r.environment.lighting.type?null:r.environment.lighting.date);const i=this._referencePosWGS84Comparable,n=s(i)?q:A,o=this.weatherVisible?r.environment.weather.type:"disabled";s(i)?M(e,i,r.state.viewingMode,o,r.state.camera,n):"virtual"===r.environment.lighting.type&&H(r.state.camera,r.state.viewingMode,n.direct.directionToLightSource);const a=this._mainLight,h=n.direct;m(a.intensity,h.color,h.intensity*Math.PI),f(a.direction,h.directionToLightSource),a.specularStrength=n.specularStrength,a.environmentStrength=n.environmentStrength;const c=this._ambientLight;m(c.intensity,n.ambient.color,n.ambient.intensity);const d=this._moonLight;g(d.intensity,z,x,n.globalFactor);const l=(1-.5*n.globalFactor)*(1-.4*n.noonFactor*(1-n.globalFactor));m(d.intensity,d.intensity,l),f(d.direction,h.directionToLightSource),this._renderer.updateLightSources([a,c,d],n.noonFactor,n.globalFactor,t),this._updateRenderParameters()}_autoUpdateTimezone(e,t=null){if("virtual"===this._view.environment.lighting.type||!this._view.environment.lighting.cameraTrackingEnabled||o(e))return!1;const r=I;r.setTime((t||this._view.environment.lighting.date).getTime());const i=S(e,V);if(o(i))return!1;let n=this._view.environment.lighting.positionTimezoneInfo;if(n.autoUpdated){if(n.hours===i.hours&&n.minutes===i.minutes&&n.seconds===i.seconds)return!1}else n=i;const s=r.getUTCHours()-(i.hours-n.hours),a=r.getUTCMinutes()-(i.minutes-n.minutes),h=r.getUTCSeconds()-(i.seconds-n.seconds);return r.setUTCHours(s),r.setUTCMinutes(a),r.setUTCSeconds(h),!t&&this._view.environment.lighting.autoUpdate(r,i)}_updateRenderParameters(){const e=this._view._stage;if(!e)return;const r=a(this._referencePosWGS84Comparable,!0,(e=>G(e[2],this._view.state.viewingMode))),i=this._view.environment.background,n=i instanceof Q?{type:"color",color:b(t.toUnitRGBA(i.color))}:{type:"color",color:w(0,0,0,1)};e.renderer.setParameters({shadowMap:this._view.environment.lighting.directShadowsEnabled&&r,background:n,environment:this._view.environment,weatherVisible:this._view.environmentManager.weatherVisible})}_resetReferencePosition(e=!1){this._cancelReferencePosUpdates(),this._referencePosMapCoords=null,this._referencePosMapCoordsRequested=null,this._referencePosResetPreserveAbsoluteTime=null,this._referencePosWGS84Comparable=null,this.notifyChange("updating"),e&&this._cameraHandler()}_requestReferencePositionUpdate(e,t=!1){if(!this.disableQueries&&(this._referencePosMapCoordsRequested?this._referencePosMapCoordsRequested.copy(e):this._referencePosMapCoordsRequested=e.clone(),this._referencePosResetPreserveAbsoluteTime=!!t,!this._referencePosUpdateQuery&&!this._referencePosUpdateTimer&&this._view.stationary)){const e=this._referencePosUpdateQuery=h(this._referencePointUpdateDelay).then((()=>{if(this._referencePosUpdateQuery===e){const t=()=>this._referencePosUpdateQuery!==e;return this._doReferencePositionUpdateQuery(t)}})).catch((e=>{"mapcoordshelper:missing-geometry-service"===e.name&&(this.disableQueries=!0)})).then((()=>{this._referencePosUpdateQuery===e&&(this._referencePosUpdateQuery=null,this._referencePosUpdateTimer||this._executePendingReferencePositionUpdate(),this.notifyChange("updating"))})),t=this._referencePosUpdateTimer=h(this._referencePointUpdateInterval).then((()=>{this._referencePosUpdateTimer===t&&(this._referencePosUpdateTimer=null,this._referencePosUpdateQuery||this._executePendingReferencePositionUpdate())}));this.notifyChange("updating")}}async _doReferencePositionUpdateQuery(e){this._referencePosResetPreserveAbsoluteTime&&(this._preserveAbsoluteDateTime=!1),this._referencePosMapCoords?this._referencePosMapCoords.copy(this._referencePosMapCoordsRequested):this._referencePosMapCoords=this._referencePosMapCoordsRequested.clone(),this._referencePosResetPreserveAbsoluteTime=null,this._referencePosMapCoordsRequested=null;const t=await this._view.mapCoordsHelper.toGeographic(this._referencePosMapCoords);if(!e()&&!isNaN(t[0])&&!isNaN(t[1])){const e=(this._referencePosMapCoords.z??0)*this._view.mapCoordsHelper.unitInMeters;this._referencePosWGS84Comparable?(this._referencePosWGS84Comparable[0]=t[0],this._referencePosWGS84Comparable[1]=t[1],this._referencePosWGS84Comparable[2]=e):this._referencePosWGS84Comparable=[t[0],t[1],e],this._referencePosChanged()}}_executePendingReferencePositionUpdate(){const e=this._referencePosMapCoordsRequested;e&&this._requestReferencePositionUpdate(e,this._referencePosResetPreserveAbsoluteTime)}_referencePosChanged(){this._preserveAbsoluteDateTime?this._updateLighting():this._autoUpdateTimezone(this._referencePosWGS84Comparable)||this._updateLighting(),this.notifyChange("referencePositionWGS84Comparable")}_exceedsReferencePosDistThreshold(e){if(this._referencePosMapCoords){let t=this._referencePosMapCoords.distance(e);return this._view.mapCoordsHelper&&(t*=this._view.mapCoordsHelper.unitInMeters),t>this._referencePointUpdateDistThreshold}return!0}_cancelReferencePosUpdates(){const e=!!this._referencePosUpdateQuery;return this._referencePosUpdateQuery=null,this._referencePosUpdateTimer=null,e}get test(){const e=this;return{get renderer(){return e._renderer},set referencePointUpdateInterval(t){e._referencePointUpdateInterval=t},set referencePointUpdateDistThreshold(t){e._referencePointUpdateDistThreshold=t},set referencePosUpdateTimer(t){e._referencePosUpdateTimer=t},set referencePointUpdateDelay(t){e._referencePointUpdateDelay=t},set disableWeather(t){e._disableWeather=t}}}};e([p({type:Boolean,readOnly:!0})],D.prototype,"updating",null),e([p()],D.prototype,"disableQueries",void 0),e([p()],D.prototype,"_disableWeather",void 0),e([p()],D.prototype,"weatherEnabled",null),e([p()],D.prototype,"weatherVisible",null),e([p()],D.prototype,"referencePositionWGS84Comparable",null),e([p()],D.prototype,"_renderer",void 0),e([p()],D.prototype,"_referencePosWGS84Comparable",void 0),D=e([_("esri.views.3d.environment.SceneViewEnvironmentManager")],D);const q=new W,A=new W,I=new Date,V={hours:0,minutes:0,seconds:0},z=v(.22,.22,.33),x=v(.22,.22,.22);export{D as SceneViewEnvironmentManager};
@@ -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{forEach as t,result as r}from"../../../core/asyncUtils.js";import{makeHandle as i}from"../../../core/handleUtils.js";import a from"../../../core/Logger.js";import{isNone as s,isSome as n}from"../../../core/maybe.js";import{debounce as o,isAbortError as l,eachAlways as h,onAbort as d,isAborted as m,createAbortError as c,throwIfAborted as g}from"../../../core/promiseUtils.js";import{whenOnce as u}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 f}from"../../../core/accessorSupport/decorators/subclass.js";import y from"../../../geometry/Extent.js";import{equals as _,create as w,width as x,height as R,copy as v,intersection as S}from"../../../geometry/support/aaBoundingRect.js";import{DrapeSourceType as b}from"./interfaces.js";import{LayerView3D as E}from"./LayerView3D.js";import{computeImageExportSize as j,createGeometryForExtent as I,createOuterImageGeometry as A}from"./support/overlayImageUtils.js";import{toViewIfLocal as C}from"./support/projectExtentUtils.js";import D from"../support/debugFlags.js";import{OverlayIndex as L}from"../terrain/interfaces.js";import{DirtyOperation as M}from"../webgl-engine/lib/ModelDirtyTypes.js";import{RenderGeometry as T}from"../webgl-engine/lib/RenderGeometry.js";import{Texture as G}from"../webgl-engine/lib/Texture.js";import{UpdatePolicy as P}from"../webgl-engine/lib/UpdatePolicy.js";import{ImageMaterial as O}from"../webgl-engine/materials/ImageMaterial.js";import U from"../../layers/LayerView.js";import H from"../../layers/RefreshableLayerView.js";import{isScaleRangeActive as N}from"../../support/layerViewUtils.js";import{TextureWrapMode as V}from"../../webgl/enums.js";let z=class extends(H(E(U))){constructor(){super(...arguments),this.drapeSourceType=b.RasterImage,this.updatePolicy=P.SYNC,this.fullExtentInLocalViewSpatialReference=null,this.maximumDataResolution=null,this._images=new Array,this._extents=new Array,this._overlays=new Array,this.updateWhenStationary=!0,this._drapeSourceRenderer=null,this.refreshDebounced=o((async e=>{this.destroyed||await this._doRefresh(e).catch((e=>{l(e)||a.getLogger(this.declaredClass).error(e)}))}),2e3)}initialize(){this._drapeSourceRenderer=this.view.basemapTerrain.overlayManager.registerGeometryDrapeSource(this),this.handles.add(i((()=>this.view.basemapTerrain.overlayManager.unregisterDrapeSource(this)))),this.addResolvingPromise(C(this).then((e=>this._set("fullExtentInLocalViewSpatialReference",e)))),this.updatingHandles.add((()=>this.suspended),(()=>this._suspendedChangeHandler())),this.handles.add(this.view.resourceController.scheduler.registerIdleStateCallbacks((()=>{this._isScaleRangeActive()&&this.notifyChange("suspended")}),(()=>{}))),this._isScaleRangeLayer()&&this.updatingHandles.add((()=>this.layer.effectiveScaleRange),(()=>this.notifyChange("suspended")))}destroy(){this.clear()}setDrapingExtent(e,t){this._spatialReference=t,e.forEach((e=>{this._overlays[e.index]=e,this._updateImageExtent(e)}))}_updateImageExtent(e){const t=this._clippedExtent(e.extent,q);if(s(t))return;const r=j(e.extent,t,e.resolution);let i=e.pixelRatio*this.view.state.pixelRatio;const{layer:n}=this;if("imageMaxWidth"in n&&null!=n.imageMaxWidth||"imageMaxHeight"in n&&null!=n.imageMaxHeight){const e=n.imageMaxWidth,t=n.imageMaxHeight;if(r.width>e){const t=e/r.width;r.height=Math.floor(r.height*t),r.width=e,i*=t}if(r.height>t){const e=t/r.height;r.width=Math.floor(r.width*e),r.height=t,i*=e}}const o=this._extents[e.index];o&&_(o.extent,t)&&this._imageSizeEquals(t,o.imageSize,r)||(this._extents[e.index]={extent:w(t),imageSize:r,pixelRatio:i},this.suspended||this._fetch(e.index).catch((e=>{l(e)||a.getLogger(this.declaredClass).error(e)})))}clear(){for(let e=0;e<this._images.length;e++)this._clearImage(e)}async doRefresh(){return this._doRefresh()}async _doRefresh(e){if(this.suspended)return;const t=[];for(let r=0;r<this._extents.length;r++)this._extents[r]&&t.push(this._fetch(r,e));await h(t)}canResume(){if(!super.canResume())return!1;const e=this.layer;if(this._isScaleRangeActive()){const{minScale:t,maxScale:r}=e.effectiveScaleRange,i=this.view.scale;if(i<r||t>0&&i>t)return!1}return!0}isUpdating(){return this._images.some((e=>!!e.loadingPromise))}async processResult(e,t,r){(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement)&&(e.image=t)}findExtentInfoAt(e){for(const t of this._extents){const r=t.extent;if(new y(r[0],r[1],r[2],r[3],this._spatialReference).contains(e))return t}return null}getFetchOptions(){}async redraw(e,r){await t(this._images,(async(t,i)=>{t&&(await e(t,r),await this._createStageObjects(i,t.image,r))}))}_imageSizeEquals(e,t,r){if(!this.maximumDataResolution)return!1;const i=x(e)/this.maximumDataResolution.x,a=R(e)/this.maximumDataResolution.y,s=i/t.width,n=a/t.height,o=i/r.width,l=a/r.height,h=Math.abs(s-o),d=Math.abs(n-l),m=D.TESTS_DISABLE_OPTIMIZATIONS?0:1.5;return h<=m&&d<=m}async _fetch(e,t){if(this.suspended)return;const r=this._extents[e],i=r.extent;this._images[e]||(this._images[e]={texture:null,material:null,renderGeometry:null,loadingPromise:null,loadingAbortController:null,image:null,pixelData:null,renderExtent:w(i)});const s=this._images[e];s.loadingAbortController&&(s.loadingAbortController.abort(),s.loadingAbortController=null);const n=new y(i[0],i[1],i[2],i[3],this._spatialReference);if(0===n.width||0===n.height)return void this._clearImage(e);const o=new AbortController;s.loadingAbortController=o,d(t,(()=>o.abort()));const h=o.signal,g=this._waitFetchReady(h).then((async()=>{const t={requestAsImageElement:!0,pixelRatio:this._overlays[e].pixelRatio,...this.getFetchOptions(),signal:h},{height:i,width:a}=r.imageSize;return this.layer.fetchImage(n,a,i,t)})).then((e=>{if(m(h))throw a.getLogger(this.declaredClass).warnOnce("A call to fetchImage resolved even though the request was aborted. fetchImage should not resolve if options.signal.aborted is true."),c();return this.processResult(s,e)})).then((()=>{v(s.renderExtent,i)})).finally((()=>{g===s.loadingPromise&&(s.loadingPromise=null,s.loadingAbortController=null)}));s.loadingPromise=g,this.notifyChange("updating"),await g.then((async()=>{if(h.aborted)throw c();await this._createStageObjects(e,s.image,h),this.notifyChange("updating")})).catch((e=>{throw e&&!l(e)&&a.getLogger(this.declaredClass).error(e),this.notifyChange("updating"),e}))}_clearImage(e){const t=this._images[e];if(t){n(t.renderGeometry)&&(this._drapeSourceRenderer.removeGeometries([t.renderGeometry],M.UPDATE),t.renderGeometry=null);const e=this.view._stage;e.remove(t.texture),t.texture=null,e.remove(t.material),t.material=null,t.loadingAbortController&&(t.loadingAbortController.abort(),t.loadingAbortController=null),t.loadingPromise=null,t.image=null,t.pixelData=null}}async _createStageObjects(e,t,i){const a=this.view._stage,o=this._images[e],l=()=>{a.remove(o.texture),o.texture=null,n(o.renderGeometry)&&(this._drapeSourceRenderer.removeGeometries([o.renderGeometry],M.UPDATE),o.renderGeometry=null)};if(t){const n=new G(t,{width:t.width,height:t.height,preMultiplyAlpha:!0,wrap:{s:V.CLAMP_TO_EDGE,t:V.CLAMP_TO_EDGE}});let h;if(await r(this._images[e===L.INNER?L.OUTER:L.INNER].loadingPromise),g(i),l(),a.add(n),await a.loadImmediate(n),o.texture=n,s(o.material)?(o.material=new O({transparent:!0,textureId:n.id}),a.add(o.material)):o.material.setParameters({textureId:n.id}),e===L.INNER)h=I(o.material,o.renderExtent);else{const e=this._images[0].renderExtent;if(!e)return void l();h=A(o.material,e,o.renderExtent)}o.renderGeometry=new T(h),o.renderGeometry.localOrigin=this._overlays[e].renderLocalOrigin,this._drapeSourceRenderer.addGeometries([o.renderGeometry],M.UPDATE)}else l(),a.remove(o.material),o.material=null}_isScaleRangeLayer(){return"effectiveScaleRange"in this.layer}_isScaleRangeActive(){const e=this.layer;if(!this._isScaleRangeLayer())return!1;const{minScale:t,maxScale:r}=e.effectiveScaleRange;return N(t,r)}_clippedExtent(e,t){if("local"!==this.view.viewingMode)return v(t,e);const r=this.view.basemapTerrain;return r.ready?S(e,r.extent,t):v(t,e)}_suspendedChangeHandler(){this.suspended?this.clear():this.refreshDebounced()}async _waitFetchReady(e){await u((()=>this.view.stationary),e),g(e)}};e([p()],z.prototype,"layer",void 0),e([p()],z.prototype,"suspended",void 0),e([p({readOnly:!0})],z.prototype,"fullExtentInLocalViewSpatialReference",void 0),e([p()],z.prototype,"updating",void 0),z=e([f("esri.views.3d.layers.DynamicLayerView3D")],z);const F=z,q=w();export{F as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{forEach as t,result as i}from"../../../core/asyncUtils.js";import{makeHandle as r}from"../../../core/handleUtils.js";import a from"../../../core/Logger.js";import{isNone as s,abortMaybe as n,isSome as o}from"../../../core/maybe.js";import{debounce as l,isAbortError as h,eachAlways as m,onAbort as d,isAborted as c,createAbortError as g,throwIfAborted as u}from"../../../core/promiseUtils.js";import{whenOnce as p}from"../../../core/reactiveUtils.js";import{property as f}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as y}from"../../../core/accessorSupport/decorators/subclass.js";import _ from"../../../geometry/Extent.js";import{equals as w,create as x,width as R,height as v,copy as S,intersection as b}from"../../../geometry/support/aaBoundingRect.js";import{DrapeSourceType as E}from"./interfaces.js";import{LayerView3D as j}from"./LayerView3D.js";import{computeImageExportSize as I,createGeometryForExtent as A,createOuterImageGeometry as C}from"./support/overlayImageUtils.js";import{toViewIfLocal as D}from"./support/projectExtentUtils.js";import L from"../support/debugFlags.js";import{OverlayIndex as M}from"../terrain/interfaces.js";import{DirtyOperation as T}from"../webgl-engine/lib/ModelDirtyTypes.js";import{RenderGeometry as G}from"../webgl-engine/lib/RenderGeometry.js";import{Texture as P}from"../webgl-engine/lib/Texture.js";import{UpdatePolicy as O}from"../webgl-engine/lib/UpdatePolicy.js";import{ImageMaterial as U}from"../webgl-engine/materials/ImageMaterial.js";import H from"../../layers/LayerView.js";import N from"../../layers/RefreshableLayerView.js";import{isScaleRangeActive as V}from"../../support/layerViewUtils.js";import{TextureWrapMode as z}from"../../webgl/enums.js";let F=class extends(N(j(H))){constructor(){super(...arguments),this.drapeSourceType=E.RasterImage,this.updatePolicy=O.SYNC,this.fullExtentInLocalViewSpatialReference=null,this.maximumDataResolution=null,this._images=new Array,this._extents=new Array,this._overlays=new Array,this.updateWhenStationary=!0,this._drapeSourceRenderer=null,this.refreshDebounced=l((async e=>{this.destroyed||await this._doRefresh(e).catch((e=>{h(e)||a.getLogger(this.declaredClass).error(e)}))}),2e3)}initialize(){this._drapeSourceRenderer=this.view.basemapTerrain.overlayManager.registerGeometryDrapeSource(this),this.handles.add(r((()=>this.view.basemapTerrain.overlayManager.unregisterDrapeSource(this)))),this.addResolvingPromise(D(this).then((e=>this._set("fullExtentInLocalViewSpatialReference",e)))),this.updatingHandles.add((()=>this.suspended),(()=>this._suspendedChangeHandler())),this.handles.add(this.view.resourceController.scheduler.registerIdleStateCallbacks((()=>{this._isScaleRangeActive()&&this.notifyChange("suspended")}),(()=>{}))),this._isScaleRangeLayer()&&this.updatingHandles.add((()=>this.layer.effectiveScaleRange),(()=>this.notifyChange("suspended")))}destroy(){this.clear()}setDrapingExtent(e,t){this._spatialReference=t,e.forEach((e=>{this._overlays[e.index]=e,this._updateImageExtent(e)}))}_updateImageExtent(e){const t=this._clippedExtent(e.extent,W);if(s(t))return;const i=I(e.extent,t,e.resolution);let r=e.pixelRatio*this.view.state.pixelRatio;const{layer:n}=this;if("imageMaxWidth"in n&&null!=n.imageMaxWidth||"imageMaxHeight"in n&&null!=n.imageMaxHeight){const e=n.imageMaxWidth,t=n.imageMaxHeight;if(i.width>e){const t=e/i.width;i.height=Math.floor(i.height*t),i.width=e,r*=t}if(i.height>t){const e=t/i.height;i.width=Math.floor(i.width*e),i.height=t,r*=e}}const o=this._extents[e.index];o&&w(o.extent,t)&&this._imageSizeEquals(t,o.imageSize,i)||(this._extents[e.index]={extent:x(t),imageSize:i,pixelRatio:r},this.suspended||this._fetch(e.index).catch((e=>{h(e)||a.getLogger(this.declaredClass).error(e)})))}clear(){for(let e=0;e<this._images.length;e++)this._clearImage(e)}async doRefresh(){return this._doRefresh()}async _doRefresh(e){if(this.suspended)return;const t=[];for(let i=0;i<this._extents.length;i++)this._extents[i]&&t.push(this._fetch(i,e));await m(t)}canResume(){if(!super.canResume())return!1;const e=this.layer;if(this._isScaleRangeActive()){const{minScale:t,maxScale:i}=e.effectiveScaleRange,r=this.view.scale;if(r<i||t>0&&r>t)return!1}return!0}isUpdating(){return this._images.some((e=>!!e.loadingPromise))}async processResult(e,t,i){(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement)&&(e.image=t)}findExtentInfoAt(e){for(const t of this._extents){const i=t.extent;if(new _(i[0],i[1],i[2],i[3],this._spatialReference).contains(e))return t}return null}getFetchOptions(){}async redraw(e,i){await t(this._images,(async(t,r)=>{t&&(await e(t,i),await this._createStageObjects(r,t.image,i))}))}_imageSizeEquals(e,t,i){if(!this.maximumDataResolution)return!1;const r=R(e)/this.maximumDataResolution.x,a=v(e)/this.maximumDataResolution.y,s=r/t.width,n=a/t.height,o=r/i.width,l=a/i.height,h=Math.abs(s-o),m=Math.abs(n-l),d=L.TESTS_DISABLE_OPTIMIZATIONS?0:1.5;return h<=d&&m<=d}async _fetch(e,t){if(this.suspended)return;const i=this._extents[e],r=i.extent;this._images[e]||(this._images[e]={texture:null,material:null,renderGeometry:null,loadingPromise:null,loadingAbortController:null,image:null,pixelData:null,renderExtent:x(r)});const s=this._images[e];s.loadingAbortController=n(s.loadingAbortController);const o=new _(r[0],r[1],r[2],r[3],this._spatialReference);if(0===o.width||0===o.height)return void this._clearImage(e);const l=new AbortController;s.loadingAbortController=l,d(t,(()=>l.abort()));const m=l.signal,u=this._waitFetchReady(m).then((async()=>{const t={requestAsImageElement:!0,pixelRatio:this._overlays[e].pixelRatio,...this.getFetchOptions(),signal:m},{height:r,width:a}=i.imageSize;return this.layer.fetchImage(o,a,r,t)})).then((e=>{if(c(m))throw a.getLogger(this.declaredClass).warnOnce("A call to fetchImage resolved even though the request was aborted. fetchImage should not resolve if options.signal.aborted is true."),g();return this.processResult(s,e)})).then((()=>{S(s.renderExtent,r)})).finally((()=>{u===s.loadingPromise&&(s.loadingPromise=null,s.loadingAbortController=null)}));s.loadingPromise=u,this.notifyChange("updating"),await u.then((async()=>{if(m.aborted)throw g();await this._createStageObjects(e,s.image,m),this.notifyChange("updating")})).catch((e=>{throw e&&!h(e)&&a.getLogger(this.declaredClass).error(e),this.notifyChange("updating"),e}))}_clearImage(e){const t=this._images[e];if(t){o(t.renderGeometry)&&(this._drapeSourceRenderer.removeGeometries([t.renderGeometry],T.UPDATE),t.renderGeometry=null);const e=this.view._stage;e.remove(t.texture),t.texture=null,e.remove(t.material),t.material=null,t.loadingAbortController=n(t.loadingAbortController),t.loadingPromise=null,t.image=null,t.pixelData=null}}async _createStageObjects(e,t,r){const a=this.view._stage,n=this._images[e],l=()=>{a.remove(n.texture),n.texture=null,o(n.renderGeometry)&&(this._drapeSourceRenderer.removeGeometries([n.renderGeometry],T.UPDATE),n.renderGeometry=null)};if(t){const o=new P(t,{width:t.width,height:t.height,preMultiplyAlpha:!0,wrap:{s:z.CLAMP_TO_EDGE,t:z.CLAMP_TO_EDGE}});let h;if(await i(this._images[e===M.INNER?M.OUTER:M.INNER].loadingPromise),u(r),l(),a.add(o),await a.loadImmediate(o),n.texture=o,s(n.material)?(n.material=new U({transparent:!0,textureId:o.id}),a.add(n.material)):n.material.setParameters({textureId:o.id}),e===M.INNER)h=A(n.material,n.renderExtent);else{const e=this._images[0].renderExtent;if(!e)return void l();h=C(n.material,e,n.renderExtent)}n.renderGeometry=new G(h),n.renderGeometry.localOrigin=this._overlays[e].renderLocalOrigin,this._drapeSourceRenderer.addGeometries([n.renderGeometry],T.UPDATE)}else l(),a.remove(n.material),n.material=null}_isScaleRangeLayer(){return"effectiveScaleRange"in this.layer}_isScaleRangeActive(){const e=this.layer;if(!this._isScaleRangeLayer())return!1;const{minScale:t,maxScale:i}=e.effectiveScaleRange;return V(t,i)}_clippedExtent(e,t){if("local"!==this.view.viewingMode)return S(t,e);const i=this.view.basemapTerrain;return i.ready?b(e,i.extent,t):S(t,e)}_suspendedChangeHandler(){this.suspended?this.clear():this.refreshDebounced()}async _waitFetchReady(e){await p((()=>this.view.stationary),e),u(e)}};e([f()],F.prototype,"layer",void 0),e([f()],F.prototype,"suspended",void 0),e([f({readOnly:!0})],F.prototype,"fullExtentInLocalViewSpatialReference",void 0),e([f()],F.prototype,"updating",void 0),F=e([y("esri.views.3d.layers.DynamicLayerView3D")],F);const q=F,W=x();export{q 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"../../../Color.js";import i from"../../../Graphic.js";import{removeUnordered as s}from"../../../core/arrayUtils.js";import{ByteSizeUnit as r}from"../../../core/byteSizeEstimations.js";import o from"../../../core/Collection.js";import has from"../../../core/has.js";import a from"../../../core/Logger.js";import{someMap as n}from"../../../core/MapUtils.js";import{unwrapOr as l,destroyMaybe as d,isSome as h,isNone as c,applySome as u}from"../../../core/maybe.js";import _ from"../../../core/PooledArray.js";import{isAbortError as m,throwIfAborted as g,createResolver as p}from"../../../core/promiseUtils.js";import{initial as f,watch as b}from"../../../core/reactiveUtils.js";import{schedule as y}from"../../../core/scheduling.js";import{isArrayBuffer as v}from"../../../core/typedArrayUtil.js";import{getMetersPerVerticalUnitForSR as I}from"../../../core/unitUtils.js";import{property as M}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as C}from"../../../core/accessorSupport/decorators/subclass.js";import{f as x}from"../../../chunks/mat3.js";import{c as O}from"../../../chunks/mat3f32.js";import{m as E,D as S}from"../../../chunks/mat4.js";import{b as j,c as w}from"../../../chunks/mat4f64.js";import{f as T}from"../../../chunks/quatf64.js";import{m as A,s as D,t as R,a as N,c as P,g as F,b as V}from"../../../chunks/vec3.js";import{c as U}from"../../../chunks/vec3f64.js";import{s as H}from"../../../chunks/vec4.js";import{f as G}from"../../../chunks/vec4f64.js";import{projectBuffer as L,getProjectorName as k,localLinearScaleFactors as B,projectVectorToVector as q,projectBoundingSphere as z}from"../../../geometry/projection.js";import{create as K,empty as W,expandWithBuffer as $,toRect as X}from"../../../geometry/support/aaBoundingBox.js";import{create as Y,intersects as Q}from"../../../geometry/support/aaBoundingRect.js";import{fallbackObjectIDAttribute as J}from"../../../layers/LayerConstants.js";import Z from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as ee}from"../../../layers/support/fieldUtils.js";import te from"../../../layers/support/SceneModification.js";import{getColor as ie,getOpacity as se}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{loadArcade as re}from"../../../support/arcadeOnDemand.js";import oe from"../../../symbols/Symbol3D.js";import{getMetersPerUnit as ae}from"../../../symbols/support/unitConversionUtils.js";import ne from"./I3SMeshViewLabeler.js";import{I3SMeshWorkerHandle as le,toWasmModification as de}from"./I3SMeshWorkerHandle.js";import{ForAllFeaturesVisibilityMode as he,ForAllFeaturesReturnType as ce}from"./II3SMeshView3D.js";import{initialize as ue,setModificationsSync as _e,filterObbsForModificationsSync as me,interpretObbModificationResults as ge}from"./SceneLayerWorker.js";import{overrideColor as pe}from"./graphics/graphicUtils.js";import{areLabelsVisible as fe}from"./graphics/Labeler.js";import{TextureUsage as be,TextureEncoding as ye}from"./i3s/enums.js";import ve from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as Ie}from"./i3s/I3SAsyncElevationUpdater.js";import{I3SCrossfadeHelper as Me,NodeCrossfadeMetaData as Ce}from"./i3s/I3SCrossfadeHelper.js";import xe from"./i3s/I3SElevationProvider.js";import{boundingBoxCornerPoints as Oe}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Ee}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Se,selectEncoding as je,defaultMaterial as we,createTexture as Te,configureMaterial as Ae}from"./i3s/I3SMaterialUtil.js";import{NodeIMModificationImpact as De,NodeState as Re}from"./i3s/I3SNode.js";import{I3SOverrides as Ne}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as Pe,getLocalOrigin as Fe}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as Ve,checkSceneLayerValid as Ue,checkSceneLayerCompatibleWithView as He,getCacheKeySuffix as Ge,whenGraphicAttributes as Le,computeVisibilityObb as ke,filterInPlace as Be,getCachedAttributeValue as qe,intersectBoundingRectWithMbs as ze,MbsIntersectResult as Ke,addWraparound as We,getSymbolInfo as $e,transparentEdgeMaterial as Xe,getClipRect as Ye}from"./i3s/I3SUtil.js";import{IDBCache as Qe}from"./i3s/IDBCache.js";import{IDBMockCache as Je}from"./i3s/IDBMockCache.js";import{attributeLookup as Ze}from"./support/attributeUtils.js";import{ColorMixModeEnum as et}from"./support/symbolColorUtils.js";import tt from"../support/debugFlags.js";import{toBoundingRect as it}from"../support/extentUtils.js";import{create as st,clone as rt}from"../support/orientedBoundingBox.js";import{updatingProgress as ot}from"../support/updatingProperties.js";import{glLayout as at}from"../support/buffer/glUtil.js";import{State as nt}from"../webgl-engine/collections/Component/ComponentObject.js";import{createVertexBufferLayout as lt}from"../webgl-engine/collections/Component/SourceGeometry.js";import{TextureCoordinateAttributeType as dt}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{loadBasis as ht}from"../webgl-engine/lib/BasisUtil.js";import{newDoubleArray as ct}from"../webgl-engine/lib/DoubleArray.js";import{Transparency as ut}from"../webgl-engine/lib/edgeRendering/interfaces.js";const _t="esri.views.3d.layers.I3SMeshView3D",mt=a.getLogger(_t),gt=[1,1,1,1];class pt extends Ce{constructor(e,t,i,s,r,o,a){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=a,this.cachedMidsTerrainSR=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0,this.cachedSymbology=null}}var ft;!function(e){e[e.CastShadows=4]="CastShadows",e[e.Pickable=5]="Pickable"}(ft||(ft={}));const bt=19,yt=100*r.MEGABYTES,vt=t=>{let r=class extends t{constructor(...e){super(e),this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._idbCache=has("enable-feature:idb-mock-cache")?new Je:new Qe("esri-scenelayer-cache","geometries"),this._hasComponentData=!1,this._hasVertexColors=!1,this.holeFilling="auto",this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=new Array,this._layerUrl="",this._cacheKeySuffix=null,this._elevationTask=null,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i(null,null,{}),this._crossfadeHelper=new Me(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerUid(){return this.i3slayer&&this.i3slayer.uid}get sublayerUid(){return null}get layerId(){return this.i3slayer&&this.i3slayer.id}get sublayerId(){return null}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?"yes":"probably-not":"unknown"}get rendererTextureUsage(){return Ve(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?be.AllTexturesPBR:be.AllTextures:this._usePBR||this._hasLoadedPBRTextures?be.GeometryTexturesPBR:be.GeometryTextures}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null!=e&&"absolute-height"===e.mode){const t=I(this.i3slayer.spatialReference),i=ae(e.unit);return l(e.offset,0)*i/t}return 0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return{mode:Ut.Absolute,offset:0};const t=I(this.i3slayer.spatialReference),i=ae(e.unit),s=l(e.offset,0)*i/t;switch(e.mode){case"absolute-height":return{mode:Ut.Absolute,offset:s};case"relative-to-ground":return{mode:Ut.RelativeToGround,offset:s};case"on-the-ground":return{mode:Ut.OnTheGround,offset:0};default:return{mode:Ut.Absolute,offset:0}}}get supportedTextureEncodings(){return Se(this.view._stage.renderView.capabilities)}get uncompressedTextureDownsamplingEnabled(){const e=this.view?.qualitySettings.sceneService.uncompressedTextureDownsamplingEnabled,t=0==(this.supportedTextureEncodings&ye.DDS_S3TC);return e&&t}initialize(){this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const e=this.view.resourceController;this.i3sOverrides=new Ne({view:this.view,layer:this.i3slayer,memoryController:e.memoryController}),this._worker=new le((t=>e.immediate.schedule(t))),this.addResolvingPromise(this._worker.promise);const t=this.i3slayer.store;this._worker.setLegacySchema(this.layerUid,t.defaultGeometrySchema),Ue(this.i3slayer),He(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new Z({layerView:this}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view._stage,this._collection=this._stage.renderView.componentObjectCollection,this._highlights=new ve({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,he.ALL),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)});const i=t.defaultGeometrySchema;if(this._isIntegratedMesh||!i)this._hasComponentData=!1;else{const e=i.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(i?.vertexAttributes.color??null)&&(null==this.i3slayer.cachedDrawingInfo||!this.i3slayer.cachedDrawingInfo.color),this._isIntegratedMesh||(this._edgeView=this._stage.renderer.ensureEdgeView());const s=this.view.resourceController.memoryController.newCache(this.i3slayer.uid,(e=>this._deleteComponentObject(e)));this._memCache=s;const r=e=>h(this._controller.index)&&h(this._controller.index.rootNode)?this._controller.index.traverse(this._controller.index.rootNode,(t=>{const i=t.index,s=this._nodeId2Meta.get(i)||this._nodeId2MetaReloading.get(i);return e(t,h(s)?s.objectHandle:null)})):()=>{};this._intersectionHandler=new Ee({layerUid:this.layerUid,sublayerUid:this.sublayerUid,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:r}),this._elevationProvider=new xe({layerView:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this.updatingHandles.add((()=>this.view.clippingArea),(()=>this._clippingAreaChanged()),f),this.updatingHandles.add((()=>this.fullOpacity),(e=>this._opacityChange(e))),this.updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this.updatingHandles.add((()=>this.elevationOffset),((e,t)=>{this._reloadAll(t),this._controller.invalidateVisibilityObbs()})),this.updatingHandles.add((()=>this.elevationInfo),((e,t)=>this._elevationInfoChanged(e,t)),f),this.updatingHandles.add((()=>!this.suspended&&this.elevationInfo.mode!==Ut.Absolute),((e,t)=>{e?this.handles.add(this.view.basemapTerrain.on("elevation-change",(({extent:e})=>this._ensureElevationTask().addExtent(e))),Lt):t&&this.handles.remove(Lt)}),f),this.updatingHandles.add((()=>this._usePBR),(e=>this._updatePBR(e)));const o=()=>{this._reloadAll(),this.clearMemCache()};this.updatingHandles.add((()=>this.rendererTextureUsage),o),this.updatingHandles.add((()=>this.uncompressedTextureDownsamplingEnabled),o),this.updatingHandles.add((()=>this.suspended),(e=>this._suspendedChange(e)),f),this.updatingHandles.add((()=>this.i3slayer.labelsVisible),(()=>this._labelingChanged()),f),this.updatingHandles.add((()=>this.i3slayer.labelingInfo),(()=>this._labelingChanged()),f),this.updatingHandles.add((()=>this._modifications),(()=>this._modificationsChanged()),f),this.handles.add([b((()=>tt.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&&tt.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||tt.I3S_TREE_SHOW_TILES||(this._treeDebugger=d(this._treeDebugger))}),f),b((()=>tt.I3S_SHOW_MODIFICATIONS),(()=>this._showModifications()),f)]),this._cacheKeySuffix=Ge(this.i3slayer.spatialReference,this.view.renderSpatialReference),this._idbCache.init().catch((e=>mt.warn(`Failed to initialize IndexedDB cache: ${e}`)))}destroy(){this._clearAddTasks(),this._elevationTask=d(this._elevationTask),this.i3sOverrides=d(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.layerChanged(),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._worker;e&&(e.destroyContext(this.i3slayer.uid).then((()=>e.destroy())),this._worker=null),this._removeAllNodeDataFromStage(),this._memCache=d(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=d(this._labeler),this._treeDebugger=d(this._treeDebugger),this._controller=d(this._controller),this._highlights.destroy(),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null)}_memEstimateTextureAdded(e){const t=e.estimatedTexMemRequired;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(h(e)){const t=e.estimatedTexMemRequired;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){const t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){const t=this._collection.getObjectGPUMemoryUsage(e);this._gpuMemoryEstimate-=t,this._geoMemoryEstimate-=t}isNodeLoaded(e){return this._nodeId2Meta.has(e)}isNodeReloading(e){return this._nodeId2MetaReloading.has(e)}getUsedMemory(){let e=h(this._labeler)?this._labeler.usedMemory:0;return this._nodeId2Meta.forEach((t=>e+=h(t)?t.node.memory:0)),this._nodeId2MetaReloading.forEach((t=>e+=h(t)?t.node.memory:0)),e}getUnloadedMemory(){return(h(this._controller)?this._controller.unloadedMemoryEstimate:0)+(h(this._labeler)?this._labeler.unloadedMemoryEstimate:0)}ignoresMemoryFactor(){return!1}_labelingChanged(){if(!(fe(this.i3slayer)&&this._supportsLabeling))return void(h(this._labeler)&&(this._labeler.destroy(),this._labeler=null));if(h(this._labeler))return;const e=new ne({view:this.view,layer:this.i3slayer,collection:this._collection});this._nodeId2Meta.forEach((t=>h(t)&&this._addMetaToLabeler(e,t))),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then((e=>(--this._asyncModuleLoading,e)),(e=>{throw--this._asyncModuleLoading,e}))}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=ue().then((()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()})),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=this.i3slayer.uid,t=this.i3slayer.spatialReference;this._worker.setModifications(e,this._layerClippingArea,this._modifications,t);const i=de(this._layerClippingArea,this._modifications,t);_e({context:e,modifications:i,isGeodetic:t.isGeographic}),this._controller.modificationsChanged();const s=this.hasModifications?new _:null;this._nodeId2Meta.forEach(((e,t)=>{c(e)?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):h(s)&&s.push(e.node)})),h(s)&&this._nodeId2MetaReloading.forEach((e=>s.push(e.node))),h(s)&&s.length>0&&(this.updateNodeModificationStatus(s),s.forAll((e=>{if(e.imModificationImpact!==De.Culled){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),h(t)?(this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t)):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}}))),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(h(this._modificationGraphics)&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!tt.I3S_SHOW_MODIFICATIONS||0===this._modifications.length)return;const e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={type:"simple-fill",outline:{color:[255,255,255],width:1}};this._modificationGraphics=new Array;for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.i3slayer.spatialReference;const o={...t,color:e[s.type]};this._modificationGraphics.push(new i({geometry:r,symbol:o}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,((e,t)=>this._createAttributes(e,t)))}_suspendedChange(e){e?(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler)):(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){const t=this._nodeId2Meta.get(e);if(h(t)&&h(t.attributeInfo))return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(h(t)&&h(t.attributeInfo))return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);h(i)&&h(i.attributeInfo)&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);h(s)&&(await this.i3sOverrides.apply(s.featureIds,t,i),s.attributeInfo=t,this._controller.reschedule((()=>this._attributeValuesChanged(s)),i).catch((e=>{m(e)||mt.warn("Error while updating attribute values. Layer might not display correctly.",e)})))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.filteredIds=null,h(this._labeler)&&this._labeler.setNodeMetaAttributes(e,((e,t)=>this._createAttributes(e,t))),this._updateEngineObject(e)}clearMemCache(){h(this._memCache)&&this._memCache.clear()}getVisibleNodes(){const e=new Array;return this._nodeId2Meta.forEach((t=>h(t)&&e.push(t.node))),e}getNodeComponentObb(e){const t=this._nodeId2Meta.get(e.index)??this._nodeId2MetaReloading.get(e.index);return h(t)?this._collection.getComponentObb(t.objectHandle):null}getLoadedNodeIndices(e){this._nodeId2Meta.forEach(((t,i)=>e.push(i))),this._nodeId2MetaReloading.forEach(((t,i)=>e.push(i)))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&0!=(this.supportedTextureEncodings&ye.Basis)&&u(this.i3slayer.textureSetDefinitions,(e=>e.some((e=>e.formats.some((e=>"basis"===e.format||"ktx2"===e.format))))))&&ht()}_getVertexBufferLayout(e,t){const i={hasTexture:Tt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion};return at(lt(this._getGeometryParameters(i)))}_getObjectIdField(){return this.i3slayer.objectIdField||J}_findGraphicNodeAndIndex(e){const t=Ze(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());let i=null;return n(this._nodeId2Meta,(e=>{if(c(e))return!1;const s=e.featureIds.indexOf(t);return-1!==s&&(i={node:e.node,index:s},!0)})),i}_getGraphicIndices(e,t){const i=this._nodeId2Meta.get(e.index);if(c(i))return[];const s=[],r=this._getObjectIdField(),o=this.i3slayer.fieldsIndex;for(const a of t){const e=Ze(o,a.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this._getAABB(t.node.index,t.index);return c(i)?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this._getAABB(e.nodeIndex,e.componentIndex)}_getAABB(e,t){const i=this._nodeId2Meta.get(e);if(c(i)||null==i.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=Oe(t,this._collection,s,ct(24)),o=this.view.renderSpatialReference,a=this.view.spatialReference;if(!L(r,o,0,r,a,0,8))return null;const n=W();return $(n,r,0,8),n}whenGraphicAttributes(e,t){return Le(this.i3slayer,e,this._getObjectIdField(),t,(()=>[...this._nodeId2Meta.values()].filter(h)))}getGraphicFromIntersectorTarget(e){if(null==e.nodeIndex||null==e.componentIndex)return null;const t=this._nodeId2Meta.get(e.nodeIndex);return c(t)||null==t.featureIds||e.componentIndex>=t.featureIds.length?null:this._createGraphic(e.componentIndex,t)}_getCacheKey(e){return`${this._layerUrl}/v${bt}/${e.id}${this._cacheKeySuffix}`}_getMemCacheKey(e,t=this.elevationOffset){return e+"#"+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&0===this.elevationOffset&&null!=this._cacheKeySuffix}loadCachedGPUData(e){return h(this._memCache)?this._memCache.pop(this._getMemCacheKey(e.index)):null}deleteCachedGPUData(e){h(e)&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(c(this._memCache))return void this._deleteComponentObject(e);const i=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,e.node.memory,i)}loadMissingTextures(e,t,i,s){const r=e?.filter(((e,i)=>{if(0==(e.usage&this.rendererTextureUsage))return!1;if(c(t))return!0;const s=je(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(c(r)||null==r.data||s&&r.encoding!==s.encoding)}))??[];return 0===r.length?Promise.resolve(!1):i(r,s).then((i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0}))}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e),t).then((s=>null==s?null:s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e)),null):(this.elevationInfo.mode===Ut.Absolute&&(e.geometryObb=s.geometryObb),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then((i=>(i&&this._idbCache.initialized&&h(s.textureData)&&(s.byteSize=Rt(s.transformedGeometry,s.textureData),s.textureData.every(Dt)&&Nt(e,s)&&this._idbCache.put(this._getCacheKey(e),s).catch((t=>mt.warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`)))),g(t),s)))))):Promise.resolve(null)}addNode(e,t,i){return At(t)?null==t.geometryBuffer?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,(()=>this._transformNode(e,t,i).then((s=>this._safeReschedule((()=>{if(c(s))return e.hasModifications=!1,this._addCachedNodeData(e,null,i);e.hasModifications=s.transformedGeometry.hasModifications;const{obb:r,componentOffsets:o,featureIds:a,transformedGeometry:n}=s,l=this._controller.crsIndex,d=this.view.renderSpatialReference,u=Pe(e.mbs,this.elevationOffset,l,d),_=st([r.center.x,r.center.y,r.center.z],[r.extents.x,r.extents.y,r.extents.z],T(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));A(_.center,_.center,u),this.elevationInfo.mode===Ut.Absolute&&(e.geometryObb=_),t.geometryData.componentOffsets=o,a&&(t.geometryData.featureIds=Array.from(a));const m={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:n,globalTrafo:u,geometryObb:_,byteSize:Rt(n,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&Nt(e,m)){const t=h(m.textureData)?m.textureData.map((e=>Dt(e)?e:null)):null;this._idbCache.put(this._getCacheKey(e),{...m,textureData:t}).catch((t=>mt.warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`)))}return this._addCachedNodeData(e,m,i)}),i))))):Promise.reject()}computeVisibilityObb(e){return ke(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications)}_transformNode(e,t,i){const s=t.geometryData.geometries,r=new Array(s.length);for(let c=0;c<s.length;++c)r[c]=this._getVertexBufferLayout(s[c],t.geometryDescriptor);const o=e.mbs,a=this.elevationOffset,n=this._controller.crsIndex,l=this._controller.crsVertex,d=this.view.renderSpatialReference,h=Fe(o,a,n),u=Pe(o,a,n,d),_=k(n,l),m=k(l,d);if(c(_)||c(m))return Promise.resolve(null);const g={context:this.i3slayer.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,localOrigin:h,globalTrafo:u,mbs:o,obb:e.serviceObb,elevationOffset:a,needNormals:!this._isIntegratedMesh&&this._controller.isMeshPyramid,normalReferenceFrame:this.i3slayer.normalReferenceFrame||"none",indexToVertexProjector:_,vertexToRenderProjector:m};return this._worker.invoke(g,i)}get _supportsNodeCrossFading(){return!this.view?._stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){const t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,i){if(this.elevationInfo.mode===Ut.Absolute&&(e.geometryObb=rt(this._collection.getComponentObb(t.objectHandle))),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);h(this._labeler)&&this._addMetaToLabeler(this._labeler,t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,nt.Visible),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==Ut.Absolute&&this._ensureElevationTask().schedule(s),this._updateEngineObject(t),this._highlights.objectCreated(t),h(this._treeDebugger)&&this._treeDebugger.update()}addCachedNodeData(e,t,i,s){return this._addData(e,i,(()=>this._addCachedNodeData(e,t,s)))}async _addCachedNodeData(e,t,i){if(this.suspended||!this._controller.isGeometryVisible(e))return void this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);if(c(t))return void this._addNodeMeta(e.index,null);const s=this._addTasks.get(e.index),{geometryData:r,transformedGeometry:o,globalTrafo:a}=t;await this.i3sOverrides.apply(r.featureIds,s.attributeInfo,i);const n=h(t.textureData)?t.textureData.filter((e=>h(e)&&0!=(e.usage&this.rendererTextureUsage))):[];!has("disable-feature:i3s-basis")&&n.some((e=>h(e)&&(e.encoding===ye.Basis||e.encoding===ye.KTX2)))&&await ht(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:u}=r,_=this._collection,m=d[0],{layout:g,indices:p,interleavedVertexData:f,positionData:b,hasColors:y}=o,v=this._materialParameters(m,g),I=l||new Uint32Array([0,p?p.length:f.byteLength/g[0].stride]),M={vertices:{data:f,count:f.byteLength/g[0].stride,layoutParameters:v.geometryParams},positionData:{positions:b.data,indices:b.indices},indices:p,componentOffsets:I},C=m.transformation?j(m.transformation):w();E(C,a,C);const T=S(U(),C),A=x(O(),C),D=this.view.renderSpatialReference,R=this.view.basemapTerrain.spatialReference,N=U(),P=[1,1,1];B(T,D,P,R)||mt.errorOnce("Unsupported coordinate system for IM overlay"),q(T,D,N,R);const F=_.createObject({toMapSpace:G(N[0],N[1],P[0],P[1]),geometry:M,obb:t.geometryObb,transform:{position:T,rotationScale:A}}),V=v.geometryParams.textureCoordinates===dt.Atlas,{textures:H,texturePromise:L}=this._initMaterialAndTextures(F,v.material,n,V);e.memory+=this._memEstimateGeometryAdded(F),e.memory+=H.reduce(((e,t)=>e+(h(t)?this._memEstimateTextureAdded(t):0)),0);const k=!!v.material.hasParametersFromSource,z="blend"!==v.material.alphaMode&&v.material.metallicRoughness.baseColorFactor[3]>=1,K=new pt(e,u,F,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:k,isOpaque:z},H);s.meta=K,!this._hasTextures&&t.requiredTextures?.some((({usage:e})=>0!=(e&be.ColorTextures)))&&(this._hasTextures=!0),this._hasData=!0,this._hasColors=this._hasColors||y,this._hasTextures=this._hasTextures||!!e.resources.texture,this.notifyChange("hasTexturesOrVertexColors");const W=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(K),L]).then((([t,s])=>(h(t)&&t.updateObjectVisibility(K.objectHandle,!1).catch((e=>It(e,this.i3slayer.title))),this._safeReschedule((()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,K),i.meta=null,this.suspended)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(F,nt.Visible),h(t)&&t.updateObjectVisibility(K.objectHandle,!0).catch((e=>It(e,this.i3slayer.title))),K.attributeInfo=i.attributeInfo;const s=K.cachedRendererVersion!==this._rendererVersion,r=W!==this.slicePlaneEnabled;this._updateElevationOffsets(K);const o=K.elevationOffsets;this._updateComponentData(K);const a=this._applyFiltersToNode(K);(s||h(t)&&(r||a||o))&&this._addOrUpdateEdgeRendering(K),h(this._labeler)&&this._addMetaToLabeler(this._labeler,K),this._visibleGeometryChanged(K,Mt.ADD),this._highlights.objectCreated(K),this._updateMaterial(K),this._setNewNodeOpacity(K),h(this._treeDebugger)&&this._treeDebugger.update()}),i)))).catch((e=>{throw h(s.meta)&&(this._cacheGPUData(s.meta),s.meta=null),e}))}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){mt.error("Removing duplicated node");const t=this._nodeId2Meta.get(e);h(t)&&this._deleteComponentObject(t)}else this._controller.updateLoadStatus(e,!0);h(t)&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&Vt(t.cachedEdgeMaterials,0)),this._nodeId2Meta.set(e,t)}_updateElevationOffsets(e){const t=this.view.renderSpatialReference,i=this.elevationInfo,s=this.view.basemapTerrain,r=s.spatialReference,o=i.mode;if(c(t)||c(r)||o===Ut.Absolute)return void(e.elevationOffsets=null);const a=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const n=Ht,l=Gt,d=o===Ut.OnTheGround,u=this.view.renderCoordsHelper,_=!!e.cachedMidsTerrainSR,m=e.featureIds.length;if(!_){e.cachedMidsTerrainSR=ct(3*m);const i=e.cachedMidsTerrainSR;for(let s=0;s<m;s++){this._collection.getComponentAabb(e.objectHandle,s,l,!0),D(n,(l[0]+l[3])/2,(l[1]+l[4])/2,l[2]),R(n,n,a.rotationScale),N(n,n,a.position);const o=3*s;i[o+2]=u.getAltitude(n),q(n,t,n,r),i[o+0]=n[0],i[o+1]=n[1]}}const g=e.cachedMidsTerrainSR,p=i.offset,f=e.elevationOffsets,b=(e,t)=>{const i=d?g[3*e+2]:0;f[e]=p+(h(t)?t-i:0)};s.getElevations(g,m,b)}_ensureElevationTask(){return h(this._elevationTask)||(this._elevationTask=new Ie(this.view.resourceController.scheduler,(e=>{const t=this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference);return h(t)?t.filterInPlace((e=>h(this._nodeId2Meta.get(e)))):null}),(e=>{const t=this._nodeId2Meta.get(e);this._nodeElevationAlignmentChanged(t)}))),this._elevationTask}_elevationInfoChanged(e,t){const i=e.mode!==Ut.Absolute,s=!!t&&t!==e&&t.mode!==Ut.Absolute;this._intersectionHandler.updateElevationAlignState(i,this.view.state.viewingMode),i&&!s&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach((e=>this._nodeElevationAlignmentChanged(e)))}_nodeElevationAlignmentChanged(e){c(e)||(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),h(this._labeler)&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,Mt.UPDATE))}_safeReschedule(e,t){return g(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=h(e.params.material)?e.params.material:we(),s=t.some((e=>"uvRegion"===e.name)),r=t.some((e=>"normalCompressed"===e.name)),o=Tt(i);return{geometryParams:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s){const r=this._stage.renderView,o=i.map((e=>Te(e,t,s,r)));this._stage.addMany(o);let a=null;return this._collection.updateMaterial(e,(e=>{a=Ae(e,t,o,i,this.view._stage.renderView.textureRepository,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference}),this._updateMaterialOverlay(e)})),{textures:o,texturePromise:a}}_getGeometryParameters(e){return{textureCoordinates:e.hasTexture?e.hasRegions?dt.Atlas:dt.Default:dt.None,colors:this._hasVertexColors,normals:e.hasNormals&&!this._isIntegratedMesh}}_addData(e,t,i){let s=this._addTasks.get(e.index);return s?s.attributeInfo=t:(s={...p(),attributeInfo:t,meta:null},this._addTasks.set(e.index,s),i().then(s.resolve,s.reject).then((()=>this._addTasks.delete(e.index))).catch((t=>{throw this._addTasks.delete(e.index),t}))),s.promise}_clearAddTasks(){this._addTasks.forEach((e=>{h(e.meta)&&(this._cacheGPUData(e.meta),e.meta=null)})),this._addTasks.clear()}_clippingAreaChanged(){const e=this.view.renderSpatialReference,t=this.i3slayer.spatialReference,i=Y();this._renderClippingArea=it(this.view.clippingArea,i,e)?i:null;const s=Y();this._layerClippingArea=it(this.view.clippingArea,s,t)?s:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){const e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e)}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach((e=>{h(e)&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Mt.UPDATE))}))}getFilters(){const e=[],t=this._renderClippingArea;return h(t)&&e.push(((e,i)=>this._boundingRectFilter(e,i,t))),e}addSqlFilter(e,t,i){if(h(t)){const s=t.fieldNames;e.push(((e,r)=>this._sqlFilter(e,r,t,s,i)))}}_sqlFilter(e,t,i,s,r){const o={},a=this._createLayerGraphic(o),n=this.i3slayer.objectIdField,l=t.featureIds,d=h(t.attributeInfo)&&t.attributeInfo.attributeData;s.every((e=>e===n||d&&null!=d[e]))&&Be(e,l,(e=>{o[n]=l[e];for(const i of s)i!==n&&(o[i]=d?qe(d[i],e):null);try{return i.testFeature(a)}catch(t){return r(t),!1}}))}_boundingRectNodeTest(e,t){return z(e.node.mbs,this._controller.crsIndex,wt,this.view.renderSpatialReference),ze(t,wt)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,Ct),X(Ct,xt),Q(i,xt)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(r===Ke.INSIDE)return;if(r===Ke.OUTSIDE)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const a=this._transformClippingArea(Ot,i,t.objectHandle);Be(e,t.featureIds,(e=>this._boundingRectFeatureTest(t,e,a)))}_transformClippingArea(e,t,i){const s=this._collection.getObjectTransform(i),r=s.position,o=s.rotationScale;return e[0]=(t[0]-r[0])/o[0],e[1]=(t[1]-r[1])/o[4],e[2]=(t[2]-r[0])/o[0],e[3]=(t[3]-r[1])/o[4],e}_addOrUpdateEdgeRendering(e,t=!0){const i=this._edgeView;if(c(i))return Promise.resolve(null);const s=e.objectHandle,r=i.hasObject(s),{hasEdges:o,perFeatureEdgeMaterials:a}=this._getFilteredEdgeMaterials(e),n={hasSlicePlane:this.slicePlaneEnabled};if(o&&r){if(this.nodeCrossfadingEnabled){Vt(a,this.getNodeOpacity(e))}return i.updateAllComponentMaterials(s,a,n,t).catch((e=>It(e,this.i3slayer.title))),i.updateObjectVisibility(s,!0).catch((e=>It(e,this.i3slayer.title))),i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>It(e,this.i3slayer.title))),Promise.resolve(i)}return o&&!r?this._collection.addEdges(s,i,a,n).then((t=>(e.edgeMemoryUsage=t,e.node.memory+=t,i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>It(e,this.i3slayer.title))),i))):(!o&&r&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,i.removeObject(s)),Promise.resolve(null))}_applyFiltersToNode(e){return!!this._applyFiltersToNodeComponents(e)&&(h(this._labeler)&&this._labeler.applyFilterChange(e),!0)}_applyFiltersToNodeComponents(e){const t=this._collection,i=0===t.getComponentCount(e.objectHandle).invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!i;if(this._updateCachedFilteredIds(e),e.filteredIds===e.featureIds)return!i;const s=this._computeFilteredComponentIndices(e);return t.setAllComponentVisibilities(e.objectHandle,s),!0}_updateCachedFilteredIds(e){null!=e.filteredIds&&e.appliedFilters===this._filters||(e.filteredIds=this._computeFilteredIds(e),e.appliedFilters=this._filters)}_computeFilteredIds(e){const t=e.featureIds.slice();for(const i of this._filters)if(i(t,e),0===t.length)break;return t.length===e.featureIds.length?e.featureIds:t}_computeFilteredComponentIndices(e){const t=new Array,i=e.filteredIds;return h(i)&&e.featureIds.forEach(((e,s)=>{i[t.length]===e&&t.push(s)})),t}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach(((t,i)=>this._removeNodeStageData(i,e))),this._nodeId2MetaReloading.forEach(((t,i)=>this._removeNodeStageData(i,e,this._nodeId2MetaReloading))),this._elevationTask=d(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),h(this._elevationTask)&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);c(s)?i.delete(e):(this._collection.setObjectVisibility(s.objectHandle,nt.Hidden),h(this._edgeView)&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch((e=>It(e,this.i3slayer.title))),this._visibleGeometryChanged(s,Mt.REMOVE),h(this._labeler)&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights.objectDeleted(s),i===this._nodeId2Meta?(this._cacheGPUData(s,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(s)):this._deleteComponentObject(s),h(this._treeDebugger)&&this._treeDebugger.update())}_deleteComponentObject(e){if(h(this._edgeView)&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(const t of e.textures)this._memEstimateTextureRemoved(t),this._stage.remove(t)}updateNodeState(e,t){const i=this._nodeId2Meta.get(e);h(i)&&this._collection.updateMaterial(i.objectHandle,(e=>e.polygonOffsetEnabled=t===Re.Hole))}_invalidateAllSymbols(){this._rendererVersion=We(this._rendererVersion,1),this._controller&&this._controller.requestUpdate()}_getInvalidRendererVersion(){return We(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=We(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.i3slayer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&"arcadeRequired"in e&&e.arcadeRequired&&(this._arcade=await re()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:mt.warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.getSymbols())"mesh-3d"!==t.type&&mt.error(`Symbols of type '${t.type}' are not supported for 3D Object Scene Services.`);this._controller&&this._controller.requestUpdate()}_getCachedEdgeMaterials(e){return this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e),e.cachedEdgeMaterials}_getComponentParameters(e){this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e);const t=e.cachedSymbology;return(i,s)=>{const r=5*i;if(H(s.externalColor,t[r+0]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255),h(this._stage.renderView.objectAndLayerIdRenderHelper)){const t=e.featureIds[i];this._stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(t,t,this.layerId,this.layerUid,this.layerPopupEnabled,e.node.resources.attributes,i,this.sublayerId),s.objectAndLayerIdColor=this._stage.renderView.getObjectAndLayerIdColor({graphicUid:t,layerUid:this.layerUid})}s.externalColorMixMode=t[r+4]&(1<<ft.CastShadows)-1,s.castShadows=0!=(t[r+4]&1<<ft.CastShadows),s.pickable=0!=(t[r+4]&1<<ft.Pickable),s.elevationOffset=e.elevationOffsets?.[i]??0}}_getSymbolInfo(e,t){const i=e&&e.getSymbol(t,{arcade:this._arcade});if(!(i instanceof oe))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=$e(i);return this._symbolInfos.set(s,r),r}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=h(this._symbologyOverrideFields)&&this._symbologyOverrideFields.length>0?h(this._rendererFields)&&this._rendererFields.length>0?ee(this.i3slayer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;const t=this._tmpAttributeOnlyGraphic,i={};t.attributes=i;const s=this._currentRenderer,r=h(e.attributeInfo)&&e.attributeInfo.attributeData,o=null!=e.featureIds?this.i3slayer.objectIdField:null,a=null!=r&&h(this._symbologyFields)&&this._symbologyFields.length>0;let n=null,l=null;if(a&&h(this._symbologyFields)){n=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(n.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=new Uint8Array(5*e.featureIds.length));const d={color:St,castShadows:!0,pickable:!0,colorMixMode:et.Multiply,edgeMaterial:null},u=this.fullOpacity,_=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):u;let m=null,g=ut.OPAQUE,p=Xe,f=0;for(let b=0;b<e.featureIds.length;b++){if(null!=o&&(i[o]=e.featureIds[b]),a&&n)for(let e=0;e<n.length;e++)i[n[e]]=qe(l[e],b);const r=s?this._getSymbolInfo(s,t):null;let u=null,y=null;if(s&&"visualVariables"in s){if(this._colorVariable){const e=ie(this._colorVariable,t,{color:jt,arcade:this._arcade});e&&(u=St,u[0]=e.r/255,u[1]=e.g/255,u[2]=e.b/255,this._opacityVariable||null===e.a||(y=e.a))}this._opacityVariable&&(y=se(this._opacityVariable,t,{arcade:this._arcade}))}if(r&&r.material){const e=r.material;u=c(u)||c(y)?pe(u,y,e.color,e.alpha,gt,St):pe(u,y,null,null,gt,St)}if(c(u)&&(u=St,u[0]=1,u[1]=1,u[2]=1,u[3]=1),d.pickable=!0,d.castShadows=!r||r.castShadows,d.colorMixMode=r&&r.material?r.material.colorMixMode:et.Multiply,d.edgeMaterial=r?r.edgeMaterial:null,h(this._symbologyOverride)&&(d.color=u,this._symbologyOverride(t,d),u=d.color),h(d.edgeMaterial)){const t=u[3]<=0?ut.INVISIBLE:u[3]>=1&&(e.material.isOpaque||d.colorMixMode===et.Replace)?ut.OPAQUE:ut.TRANSPARENT;d.edgeMaterial===m&&t===g||(p={...d.edgeMaterial,opacity:_,objectTransparency:t},m=d.edgeMaterial,g=t),e.cachedEdgeMaterials[b]=p}else e.cachedEdgeMaterials[b]=Xe;e.cachedSymbology[f+0]=Math.round(255*u[0]),e.cachedSymbology[f+1]=Math.round(255*u[1]),e.cachedSymbology[f+2]=Math.round(255*u[2]),e.cachedSymbology[f+3]=Math.round(255*u[3]),e.cachedSymbology[f+4]=d.colorMixMode|+d.castShadows<<ft.CastShadows|+d.pickable<<ft.Pickable,f+=5}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||Vt(t,this.fullOpacity);const i=e.filteredIds;if(c(i)){return{hasEdges:t.some((e=>e!==Xe)),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map(((t,o)=>e.featureIds[o]!==i[s]?Xe:(r=r||t!==Xe,s++,t)));return{hasEdges:r,perFeatureEdgeMaterials:o}}_updateComponentData(e){if(!this._hasComponentData)return;const t=e.objectHandle,i=this._getComponentParameters(e);this._collection.setComponentData(t,i),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),null!=this._controller&&this._controller.restartNodeLoading()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach((t=>{c(t)||(this._collection.updateMaterial(t.objectHandle,(t=>t.objectOpacity=e)),Vt(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))}))}_updateMaterial(e){this._collection.updateMaterial(e.objectHandle,(e=>{e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.usePBR=this._usePBR,this._updateMaterialOverlay(e)}))}_updateMaterialOverlay(e){}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Mt.UPDATE)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),h(this._labeler)&&(this._labeler.slicePlaneEnabled=e),this._nodeId2Meta.forEach((t=>{c(t)||(this._collection.updateMaterial(t.objectHandle,(t=>t.commonMaterialParameters.hasSlicePlane=e)),this._updateEdgeRendering(t,!1))}))}_updatePBR(e){this._nodeId2Meta.forEach((t=>{c(t)||this._collection.updateMaterial(t.objectHandle,(t=>t.usePBR=e))})),this._hasLoadedPBRTextures=!0}get _usePBR(){return!this._isIntegratedMesh&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){h(this._edgeView)&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_forAllFeatures(e,t,i=he.VISIBLE_ONLY){n(this._nodeId2Meta,(s=>{if(c(s))return!1;if(h(t)){switch(t(s)){case ce.EXIT:return!0;case ce.SKIP:return!1}}let r=ce.CONTINUE;switch(i){case he.ALL:r=this._forAllFeaturesOfNode(s,e);break;case he.VISIBLE_ONLY:r=this._forVisibleFeaturesOfNode(s,e);break;case he.ALL_IN_CLIPPING_AREA:r=this._forAllFeaturesOfNodeInClippingArea(s,e)}return r===ce.EXIT}))}_forAllFeaturesOfNode(e,t){let i=ce.CONTINUE;const s=e.featureIds;for(let r=0;r<s.length;r++)if(i=t(s[r],r,e),i===ce.EXIT)return i;return i}_forVisibleFeaturesOfNode(e,t){let i=ce.CONTINUE;const s=e.featureIds;return this._collection.forEachVisibleComponent(e.objectHandle,(r=>(i=t(s[r],r,e),i===ce.CONTINUE))),i}_forAllFeaturesOfNodeInClippingArea(e,t){if(c(this._renderClippingArea))return this._forAllFeaturesOfNode(e,t);const i=this._boundingRectNodeTest(e,this._renderClippingArea);if(i===Ke.OUTSIDE)return ce.CONTINUE;if(i===Ke.INSIDE)return this._forAllFeaturesOfNode(e,t);const s=ce.CONTINUE,r=e.featureIds,o=e.objectHandle,a=Ye(this._renderClippingArea,this._collection.getObjectTransform(o));for(let n=0;n<r.length;n++){if(!this._boundingRectFeatureTest(e,n,a))continue;const i=t(r[n],n,e);if(i===ce.EXIT)return i}return s}_createAttributes(e,t){const i={};null!=t.featureIds&&(i[this._getObjectIdField()]=t.featureIds[e]);const s=h(t.attributeInfo)&&t.attributeInfo.attributeData;if(h(s))for(const r of Object.keys(s))i[r]=qe(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e){const t=this._highlights;if("number"==typeof e||e instanceof i?e=[e]:e instanceof o&&(e=e.toArray()),Array.isArray(e)&&e.length>0){if(e[0]instanceof i){const i=e,s=this.i3slayer.fieldsIndex,r=this._getObjectIdField(),o=i.map((e=>Ze(s,e.attributes,r))),{set:a,handle:n}=t.acquireSet();return t.setFeatureIds(a,o),n}if("number"==typeof e[0]){const i=e,{set:s,handle:r}=t.acquireSet();return t.setFeatureIds(s,i),r}}return Ft}_visibleGeometryChanged(e,t){this._elevationProvider&&(this._elevationProvider.objectChanged(e.node),null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=y((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))),this._updateSnappingSources(e,t))}get performanceInfo(){const e={displayedNumberOfFeatures:0,maximumNumberOfFeatures:0,totalNumberOfFeatures:0,core:null,index:0,nodes:this._nodeId2Meta.size,"Total GPU Memory Estimate":(this._gpuMemoryEstimate/1048576).toFixed(1)+"MB","Geometry Memory Estimate":(this._geoMemoryEstimate/1048576).toFixed(1)+"MB","Texture Memory Estimate":(this._texMemoryEstimate/1048576).toFixed(1)+"MB","Unloaded Memory Estimate":(this.getUnloadedMemory()/1048576).toFixed(1)+"MB"};return h(this._memCache)&&(e.MemCache=Math.round(100*this._memCache.hitRate)+"% hit"),this._controller&&(this._idbCacheEnabled&&(e.IDBCache=Math.round(100*this._idbCache.getHitRate())+"% hit"),this._controller.updateStats(e)),e}get test(){const e=this;return{controller:this._controller,labeler:this._labeler,get visibleObjectIds(){const t=[];return e._forAllFeatures((e=>(t.push(e),ce.CONTINUE)),null,he.VISIBLE_ONLY),t.sort(((e,t)=>e-t)),t},get numNodes(){return e._nodeId2Meta.size},get loadedNodes(){return Array.from(e._nodeId2Meta.keys()).sort(((e,t)=>e-t))}}}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return h(e)?this._collection.getMaterial(e.objectHandle).objectOpacity:0}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(((t,i)=>e(i,t)))}fadeNode(e,t,i){if(!this.nodeCrossfadingEnabled)return;const s=this._nodeId2Meta.get(e);h(s)&&this._crossfadeHelper.fadeNode(e,s,t,i)}setNodeOpacityByIndex(e,t){const i=this._nodeId2Meta.get(e);h(i)&&this._setNodeOpacity(i,t)}_setNodeOpacity(e,t){this._collection.updateMaterial(e.objectHandle,(e=>e.objectOpacity=t)),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(c(this._edgeView)||!e.cachedEdgeMaterials)return;Vt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch((e=>It(e,this.i3slayer.title)))}get hasModifications(){return this._isIntegratedMesh&&h(this._layerClippingArea)||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){const t=e.length;if(!this.hasModifications||t<=0||!0!==this._i3sWasmLoaded)return;const i=this.i3slayer.uid,s=Pt(e);if(h(s)){const t={context:i,buffer:s.buffer};me(t);const r=new Float64Array(s.buffer);e.forAll(((e,t)=>{const i=r[t],s=ge(i);e.imModificationImpact=s,s!==De.Unmodified&&this._controller.invalidateGeometryVisibility(e.index)}))}}notifyUpdate(){this.notifyChange("updating")}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!(!this._controller||!this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||h(this._labeler)&&this._labeler.updating||this._crossfadeHelper.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||h(this._elevationTask)&&this._elevationTask.running}trackSnappingSources(e){const t={events:e,fetchEdgeLocations:async(e,t,i)=>{const s=this._nodeId2Meta.get(e);if(c(s))throw new Error("invalid-node");const{origin:r,buffer:o}=await this._collection.extractEdgeInformation(s.objectHandle,t,i);return this._snappingLocationsApplyElevation(s,o,r),{type:"components",objectIds:s.featureIds,locations:o,origin:r}},remove:()=>{s(this._snappingSourcesTrackers,t)}};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach(((t,i)=>{if(c(t))return;const s=this._controller.getRenderMbs(t.node);h(s)&&e.add(i,s)})),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||this.elevationInfo.mode===Ut.Absolute)return;const s=t.position0,r=t.position1,o=t.componentIndex,a=U(),n=U(),l=(e,t)=>{N(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,n),N(e,e,F(n,n,t)),V(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,a),l(a,t),s.setVec(d,a),r.getVec(d,a),l(a,t),r.setVec(d,a)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(!c(s))for(const r of this._snappingSourcesTrackers)t!==Mt.REMOVE&&t!==Mt.UPDATE||r.events.remove(i),t!==Mt.ADD&&t!==Mt.UPDATE||r.events.add(i,s)}};return e([M()],r.prototype,"_hasLoadedPBRTextures",void 0),e([M()],r.prototype,"_asyncModuleLoading",void 0),e([M()],r.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([M()],r.prototype,"view",void 0),e([M()],r.prototype,"i3slayer",void 0),e([M()],r.prototype,"_controller",void 0),e([M()],r.prototype,"_labeler",void 0),e([M()],r.prototype,"updating",void 0),e([M()],r.prototype,"suspended",void 0),e([M()],r.prototype,"holeFilling",void 0),e([M(ot)],r.prototype,"updatingProgress",void 0),e([M()],r.prototype,"updatingProgressValue",null),e([M()],r.prototype,"hasTexturesOrVertexColors",null),e([M()],r.prototype,"rendererTextureUsage",null),e([M()],r.prototype,"elevationOffset",null),e([M()],r.prototype,"elevationInfo",null),e([M({type:Boolean})],r.prototype,"slicePlaneEnabled",void 0),e([M()],r.prototype,"supportedTextureEncodings",null),e([M()],r.prototype,"uncompressedTextureDownsamplingEnabled",null),e([M({type:[te]})],r.prototype,"_modifications",void 0),e([M()],r.prototype,"_elevationTask",void 0),e([M({readOnly:!0})],r.prototype,"_usePBR",null),r=e([C(_t)],r),r};function It(e,t){m(e)||mt.warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}var Mt;!function(e){e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE"}(Mt||(Mt={}));const Ct=K(),xt=Y(),Ot=Y(),Et=st(),St=[0,0,0,0],jt=new t([0,0,0,0]),wt=[0,0,0,0];function Tt(e){if(c(e))return!1;const t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function At(e){return"geometryData"in e}function Dt(e){return h(e)&&v(e.data)}function Rt(e,t){let i=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(h(t))for(const s of t)h(s)&&v(s.data)&&(i+=s.data.byteLength);return i}function Nt(e,t){return t.byteSize>yt?(mt.warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}function Pt(e){if(0===e.length)return null;const t=10*e.length,i=new Float64Array(t);return e.forAll(((e,t)=>{let s=e.serviceObb;c(s)&&(s=Et,P(s.center,e.mbs),s.halfSize[0]=s.halfSize[1]=s.halfSize[2]=e.mbs[3]);const r=10*t;i[r+0]=s.center[0],i[r+1]=s.center[1],i[r+2]=s.center[2],i[r+3]=s.halfSize[0],i[r+4]=s.halfSize[1],i[r+5]=s.halfSize[2],i[r+6]=s.quaternion[0],i[r+7]=s.quaternion[1],i[r+8]=s.quaternion[2],i[r+9]=s.quaternion[3]})),i}const Ft={remove(){},pause(){},resume(){}};function Vt(e,t){e.forEach((e=>e.opacity=t))}var Ut;!function(e){e[e.Absolute=0]="Absolute",e[e.RelativeToGround=1]="RelativeToGround",e[e.OnTheGround=2]="OnTheGround"}(Ut||(Ut={}));const Ht=U(),Gt=K(),Lt="elevation-change";export{Ut as ElevationMode,vt as I3SMeshView3D};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../Graphic.js";import{removeUnordered as s}from"../../../core/arrayUtils.js";import{ByteSizeUnit as r}from"../../../core/byteSizeEstimations.js";import o from"../../../core/Collection.js";import has from"../../../core/has.js";import a from"../../../core/Logger.js";import{someMap as n}from"../../../core/MapUtils.js";import{unwrapOr as l,destroyMaybe as d,isSome as h,isNone as c,applySome as u}from"../../../core/maybe.js";import _ from"../../../core/PooledArray.js";import{isAbortError as m,throwIfAborted as g,createResolver as p}from"../../../core/promiseUtils.js";import{initial as f,watch as b}from"../../../core/reactiveUtils.js";import{schedule as y}from"../../../core/scheduling.js";import{isArrayBuffer as v}from"../../../core/typedArrayUtil.js";import{getMetersPerVerticalUnitForSR as I}from"../../../core/unitUtils.js";import{property as M}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as C}from"../../../core/accessorSupport/decorators/subclass.js";import{f as x}from"../../../chunks/mat3.js";import{c as O}from"../../../chunks/mat3f32.js";import{m as E,D as S}from"../../../chunks/mat4.js";import{b as j,c as w}from"../../../chunks/mat4f64.js";import{f as T}from"../../../chunks/quatf64.js";import{m as A,s as D,t as R,a as N,c as P,g as F,b as V}from"../../../chunks/vec3.js";import{c as U}from"../../../chunks/vec3f64.js";import{s as H}from"../../../chunks/vec4.js";import{f as G}from"../../../chunks/vec4f64.js";import{projectBuffer as L,getProjectorName as k,localLinearScaleFactors as B,projectVectorToVector as q,projectBoundingSphere as z}from"../../../geometry/projection.js";import{create as K,empty as W,expandWithBuffer as $,toRect as X}from"../../../geometry/support/aaBoundingBox.js";import{create as Y,intersects as Q}from"../../../geometry/support/aaBoundingRect.js";import{fallbackObjectIDAttribute as J}from"../../../layers/LayerConstants.js";import Z from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as ee}from"../../../layers/support/fieldUtils.js";import te from"../../../layers/support/SceneModification.js";import{getColor as ie,getOpacity as se}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{loadArcade as re}from"../../../support/arcadeOnDemand.js";import oe from"../../../symbols/Symbol3D.js";import{getMetersPerUnit as ae}from"../../../symbols/support/unitConversionUtils.js";import ne from"./I3SMeshViewLabeler.js";import{I3SMeshWorkerHandle as le,toWasmModification as de}from"./I3SMeshWorkerHandle.js";import{ForAllFeaturesVisibilityMode as he,ForAllFeaturesReturnType as ce}from"./II3SMeshView3D.js";import{initialize as ue,setModificationsSync as _e,filterObbsForModificationsSync as me,interpretObbModificationResults as ge}from"./SceneLayerWorker.js";import{overrideColor as pe}from"./graphics/graphicUtils.js";import{areLabelsVisible as fe}from"./graphics/Labeler.js";import{TextureUsage as be,TextureEncoding as ye}from"./i3s/enums.js";import ve from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as Ie}from"./i3s/I3SAsyncElevationUpdater.js";import{I3SCrossfadeHelper as Me,NodeCrossfadeMetaData as Ce}from"./i3s/I3SCrossfadeHelper.js";import xe from"./i3s/I3SElevationProvider.js";import{boundingBoxCornerPoints as Oe}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Ee}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Se,selectEncoding as je,defaultMaterial as we,createTexture as Te,configureMaterial as Ae}from"./i3s/I3SMaterialUtil.js";import{NodeIMModificationImpact as De,NodeState as Re}from"./i3s/I3SNode.js";import{I3SOverrides as Ne}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as Pe,getLocalOrigin as Fe}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as Ve,checkSceneLayerValid as Ue,checkSceneLayerCompatibleWithView as He,getCacheKeySuffix as Ge,whenGraphicAttributes as Le,computeVisibilityObb as ke,filterInPlace as Be,getCachedAttributeValue as qe,intersectBoundingRectWithMbs as ze,MbsIntersectResult as Ke,addWraparound as We,getSymbolInfo as $e,transparentEdgeMaterial as Xe,getClipRect as Ye}from"./i3s/I3SUtil.js";import{IDBCache as Qe}from"./i3s/IDBCache.js";import{IDBMockCache as Je}from"./i3s/IDBMockCache.js";import{attributeLookup as Ze}from"./support/attributeUtils.js";import{ColorMixModeEnum as et}from"./support/symbolColorUtils.js";import tt from"../support/debugFlags.js";import{toBoundingRect as it}from"../support/extentUtils.js";import{create as st,clone as rt}from"../support/orientedBoundingBox.js";import{updatingProgress as ot}from"../support/updatingProperties.js";import{glLayout as at}from"../support/buffer/glUtil.js";import{State as nt}from"../webgl-engine/collections/Component/ComponentObject.js";import{createVertexBufferLayout as lt}from"../webgl-engine/collections/Component/SourceGeometry.js";import{TextureCoordinateAttributeType as dt}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{loadBasis as ht}from"../webgl-engine/lib/BasisUtil.js";import{newDoubleArray as ct}from"../webgl-engine/lib/DoubleArray.js";import{Transparency as ut}from"../webgl-engine/lib/edgeRendering/interfaces.js";const _t="esri.views.3d.layers.I3SMeshView3D",mt=a.getLogger(_t),gt=[1,1,1,1];class pt extends Ce{constructor(e,t,i,s,r,o,a){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=a,this.cachedMidsTerrainSR=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0,this.cachedSymbology=null}}var ft;!function(e){e[e.CastShadows=4]="CastShadows",e[e.Pickable=5]="Pickable"}(ft||(ft={}));const bt=19,yt=100*r.MEGABYTES,vt=t=>{let r=class extends t{constructor(...e){super(e),this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._idbCache=has("enable-feature:idb-mock-cache")?new Je:new Qe("esri-scenelayer-cache","geometries"),this._hasComponentData=!1,this._hasVertexColors=!1,this.holeFilling="auto",this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=new Array,this._layerUrl="",this._cacheKeySuffix=null,this._elevationTask=null,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i(null,null,{}),this._crossfadeHelper=new Me(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerUid(){return this.i3slayer&&this.i3slayer.uid}get sublayerUid(){return null}get layerId(){return this.i3slayer&&this.i3slayer.id}get sublayerId(){return null}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?"yes":"probably-not":"unknown"}get rendererTextureUsage(){return Ve(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?be.AllTexturesPBR:be.AllTextures:this._usePBR||this._hasLoadedPBRTextures?be.GeometryTexturesPBR:be.GeometryTextures}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null!=e&&"absolute-height"===e.mode){const t=I(this.i3slayer.spatialReference),i=ae(e.unit);return l(e.offset,0)*i/t}return 0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return{mode:Ut.Absolute,offset:0};const t=I(this.i3slayer.spatialReference),i=ae(e.unit),s=l(e.offset,0)*i/t;switch(e.mode){case"absolute-height":return{mode:Ut.Absolute,offset:s};case"relative-to-ground":return{mode:Ut.RelativeToGround,offset:s};case"on-the-ground":return{mode:Ut.OnTheGround,offset:0};default:return{mode:Ut.Absolute,offset:0}}}get supportedTextureEncodings(){return Se(this.view._stage.renderView.capabilities)}get uncompressedTextureDownsamplingEnabled(){const e=this.view?.qualitySettings.sceneService.uncompressedTextureDownsamplingEnabled,t=0==(this.supportedTextureEncodings&ye.DDS_S3TC);return e&&t}initialize(){this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const e=this.view.resourceController;this.i3sOverrides=new Ne({view:this.view,layer:this.i3slayer,memoryController:e.memoryController}),this._worker=new le((t=>e.immediate.schedule(t))),this.addResolvingPromise(this._worker.promise);const t=this.i3slayer.store;this._worker.setLegacySchema(this.layerUid,t.defaultGeometrySchema),Ue(this.i3slayer),He(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new Z({layerView:this}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view._stage,this._collection=this._stage.renderView.componentObjectCollection,this._highlights=new ve({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,he.ALL),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)});const i=t.defaultGeometrySchema;if(this._isIntegratedMesh||!i)this._hasComponentData=!1;else{const e=i.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(i?.vertexAttributes.color??null)&&(null==this.i3slayer.cachedDrawingInfo||!this.i3slayer.cachedDrawingInfo.color),this._isIntegratedMesh||(this._edgeView=this._stage.renderer.ensureEdgeView());const s=this.view.resourceController.memoryController.newCache(this.i3slayer.uid,(e=>this._deleteComponentObject(e)));this._memCache=s;const r=e=>h(this._controller.index)&&h(this._controller.index.rootNode)?this._controller.index.traverse(this._controller.index.rootNode,(t=>{const i=t.index,s=this._nodeId2Meta.get(i)||this._nodeId2MetaReloading.get(i);return e(t,h(s)?s.objectHandle:null)})):()=>{};this._intersectionHandler=new Ee({layerUid:this.layerUid,sublayerUid:this.sublayerUid,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:r}),this._elevationProvider=new xe({layerView:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this.updatingHandles.add((()=>this.view.clippingArea),(()=>this._clippingAreaChanged()),f),this.updatingHandles.add((()=>this.fullOpacity),(e=>this._opacityChange(e))),this.updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this.updatingHandles.add((()=>this.elevationOffset),((e,t)=>{this._reloadAll(t),this._controller.invalidateVisibilityObbs()})),this.updatingHandles.add((()=>this.elevationInfo),((e,t)=>this._elevationInfoChanged(e,t)),f),this.updatingHandles.add((()=>!this.suspended&&this.elevationInfo.mode!==Ut.Absolute),((e,t)=>{e?this.handles.add(this.view.basemapTerrain.on("elevation-change",(({extent:e})=>this._ensureElevationTask().addExtent(e))),Lt):t&&this.handles.remove(Lt)}),f),this.updatingHandles.add((()=>this._usePBR),(e=>this._updatePBR(e)));const o=()=>{this._reloadAll(),this.clearMemCache()};this.updatingHandles.add((()=>this.rendererTextureUsage),o),this.updatingHandles.add((()=>this.uncompressedTextureDownsamplingEnabled),o),this.updatingHandles.add((()=>this.suspended),(e=>this._suspendedChange(e)),f),this.updatingHandles.add((()=>this.i3slayer.labelsVisible),(()=>this._labelingChanged()),f),this.updatingHandles.add((()=>this.i3slayer.labelingInfo),(()=>this._labelingChanged()),f),this.updatingHandles.add((()=>this._modifications),(()=>this._modificationsChanged()),f),this.handles.add([b((()=>tt.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&&tt.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||tt.I3S_TREE_SHOW_TILES||(this._treeDebugger=d(this._treeDebugger))}),f),b((()=>tt.I3S_SHOW_MODIFICATIONS),(()=>this._showModifications()),f)]),this._cacheKeySuffix=Ge(this.i3slayer.spatialReference,this.view.renderSpatialReference),this._idbCache.init().catch((e=>mt.warn(`Failed to initialize IndexedDB cache: ${e}`)))}destroy(){this._clearAddTasks(),this._elevationTask=d(this._elevationTask),this.i3sOverrides=d(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.layerChanged(),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._worker;e&&(e.destroyContext(this.i3slayer.uid).then((()=>e.destroy())),this._worker=null),this._removeAllNodeDataFromStage(),this._memCache=d(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=d(this._labeler),this._treeDebugger=d(this._treeDebugger),this._controller=d(this._controller),this._highlights.destroy(),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null)}_memEstimateTextureAdded(e){const t=e.estimatedTexMemRequired;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(h(e)){const t=e.estimatedTexMemRequired;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){const t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){const t=this._collection.getObjectGPUMemoryUsage(e);this._gpuMemoryEstimate-=t,this._geoMemoryEstimate-=t}isNodeLoaded(e){return this._nodeId2Meta.has(e)}isNodeReloading(e){return this._nodeId2MetaReloading.has(e)}getUsedMemory(){let e=h(this._labeler)?this._labeler.usedMemory:0;return this._nodeId2Meta.forEach((t=>e+=h(t)?t.node.memory:0)),this._nodeId2MetaReloading.forEach((t=>e+=h(t)?t.node.memory:0)),e}getUnloadedMemory(){return(h(this._controller)?this._controller.unloadedMemoryEstimate:0)+(h(this._labeler)?this._labeler.unloadedMemoryEstimate:0)}ignoresMemoryFactor(){return!1}_labelingChanged(){if(!(fe(this.i3slayer)&&this._supportsLabeling))return void(h(this._labeler)&&(this._labeler.destroy(),this._labeler=null));if(h(this._labeler))return;const e=new ne({view:this.view,layer:this.i3slayer,collection:this._collection});this._nodeId2Meta.forEach((t=>h(t)&&this._addMetaToLabeler(e,t))),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then((e=>(--this._asyncModuleLoading,e)),(e=>{throw--this._asyncModuleLoading,e}))}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=ue().then((()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()})),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=this.i3slayer.uid,t=this.i3slayer.spatialReference;this._worker.setModifications(e,this._layerClippingArea,this._modifications,t);const i=de(this._layerClippingArea,this._modifications,t);_e({context:e,modifications:i,isGeodetic:t.isGeographic}),this._controller.modificationsChanged();const s=this.hasModifications?new _:null;this._nodeId2Meta.forEach(((e,t)=>{c(e)?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):h(s)&&s.push(e.node)})),h(s)&&this._nodeId2MetaReloading.forEach((e=>s.push(e.node))),h(s)&&s.length>0&&(this.updateNodeModificationStatus(s),s.forAll((e=>{if(e.imModificationImpact!==De.Culled){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),h(t)?(this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t)):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}}))),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(h(this._modificationGraphics)&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!tt.I3S_SHOW_MODIFICATIONS||0===this._modifications.length)return;const e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={type:"simple-fill",outline:{color:[255,255,255],width:1}};this._modificationGraphics=new Array;for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.i3slayer.spatialReference;const o={...t,color:e[s.type]};this._modificationGraphics.push(new i({geometry:r,symbol:o}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,((e,t)=>this._createAttributes(e,t)))}_suspendedChange(e){e?(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler)):(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){const t=this._nodeId2Meta.get(e);if(h(t)&&h(t.attributeInfo))return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(h(t)&&h(t.attributeInfo))return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);h(i)&&h(i.attributeInfo)&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);h(s)&&(await this.i3sOverrides.apply(s.featureIds,t,i),s.attributeInfo=t,this._controller.reschedule((()=>this._attributeValuesChanged(s)),i).catch((e=>{m(e)||mt.warn("Error while updating attribute values. Layer might not display correctly.",e)})))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.filteredIds=null,h(this._labeler)&&this._labeler.setNodeMetaAttributes(e,((e,t)=>this._createAttributes(e,t))),this._updateEngineObject(e)}clearMemCache(){h(this._memCache)&&this._memCache.clear()}getVisibleNodes(){const e=new Array;return this._nodeId2Meta.forEach((t=>h(t)&&e.push(t.node))),e}getNodeComponentObb(e){const t=this._nodeId2Meta.get(e.index)??this._nodeId2MetaReloading.get(e.index);return h(t)?this._collection.getComponentObb(t.objectHandle):null}getLoadedNodeIndices(e){this._nodeId2Meta.forEach(((t,i)=>e.push(i))),this._nodeId2MetaReloading.forEach(((t,i)=>e.push(i)))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&0!=(this.supportedTextureEncodings&ye.Basis)&&u(this.i3slayer.textureSetDefinitions,(e=>e.some((e=>e.formats.some((e=>"basis"===e.format||"ktx2"===e.format))))))&&ht()}_getVertexBufferLayout(e,t){const i={hasTexture:Tt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion};return at(lt(this._getGeometryParameters(i)))}_getObjectIdField(){return this.i3slayer.objectIdField||J}_findGraphicNodeAndIndex(e){const t=Ze(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());let i=null;return n(this._nodeId2Meta,(e=>{if(c(e))return!1;const s=e.featureIds.indexOf(t);return-1!==s&&(i={node:e.node,index:s},!0)})),i}_getGraphicIndices(e,t){const i=this._nodeId2Meta.get(e.index);if(c(i))return[];const s=[],r=this._getObjectIdField(),o=this.i3slayer.fieldsIndex;for(const a of t){const e=Ze(o,a.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this._getAABB(t.node.index,t.index);return c(i)?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this._getAABB(e.nodeIndex,e.componentIndex)}_getAABB(e,t){const i=this._nodeId2Meta.get(e);if(c(i)||null==i.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=Oe(t,this._collection,s,ct(24)),o=this.view.renderSpatialReference,a=this.view.spatialReference;if(!L(r,o,0,r,a,0,8))return null;const n=W();return $(n,r,0,8),n}whenGraphicAttributes(e,t){return Le(this.i3slayer,e,this._getObjectIdField(),t,(()=>[...this._nodeId2Meta.values()].filter(h)))}getGraphicFromIntersectorTarget(e){if(null==e.nodeIndex||null==e.componentIndex)return null;const t=this._nodeId2Meta.get(e.nodeIndex);return c(t)||null==t.featureIds||e.componentIndex>=t.featureIds.length?null:this._createGraphic(e.componentIndex,t)}_getCacheKey(e){return`${this._layerUrl}/v${bt}/${e.id}${this._cacheKeySuffix}`}_getMemCacheKey(e,t=this.elevationOffset){return e+"#"+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&0===this.elevationOffset&&null!=this._cacheKeySuffix}loadCachedGPUData(e){return h(this._memCache)?this._memCache.pop(this._getMemCacheKey(e.index)):null}deleteCachedGPUData(e){h(e)&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(c(this._memCache))return void this._deleteComponentObject(e);const i=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,e.node.memory,i)}loadMissingTextures(e,t,i,s){const r=e?.filter(((e,i)=>{if(0==(e.usage&this.rendererTextureUsage))return!1;if(c(t))return!0;const s=je(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(c(r)||null==r.data||s&&r.encoding!==s.encoding)}))??[];return 0===r.length?Promise.resolve(!1):i(r,s).then((i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0}))}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e),t).then((s=>null==s?null:s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e)),null):(this.elevationInfo.mode===Ut.Absolute&&(e.geometryObb=s.geometryObb),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then((i=>(i&&this._idbCache.initialized&&h(s.textureData)&&(s.byteSize=Rt(s.transformedGeometry,s.textureData),s.textureData.every(Dt)&&Nt(e,s)&&this._idbCache.put(this._getCacheKey(e),s).catch((t=>mt.warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`)))),g(t),s)))))):Promise.resolve(null)}addNode(e,t,i){return At(t)?null==t.geometryBuffer?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,(()=>this._transformNode(e,t,i).then((s=>this._safeReschedule((()=>{if(c(s))return e.hasModifications=!1,this._addCachedNodeData(e,null,i);e.hasModifications=s.transformedGeometry.hasModifications;const{obb:r,componentOffsets:o,featureIds:a,transformedGeometry:n}=s,l=this._controller.crsIndex,d=this.view.renderSpatialReference,u=Pe(e.mbs,this.elevationOffset,l,d),_=st([r.center.x,r.center.y,r.center.z],[r.extents.x,r.extents.y,r.extents.z],T(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));A(_.center,_.center,u),this.elevationInfo.mode===Ut.Absolute&&(e.geometryObb=_),t.geometryData.componentOffsets=o,a&&(t.geometryData.featureIds=Array.from(a));const m={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:n,globalTrafo:u,geometryObb:_,byteSize:Rt(n,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&Nt(e,m)){const t=h(m.textureData)?m.textureData.map((e=>Dt(e)?e:null)):null;this._idbCache.put(this._getCacheKey(e),{...m,textureData:t}).catch((t=>mt.warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`)))}return this._addCachedNodeData(e,m,i)}),i))))):Promise.reject()}computeVisibilityObb(e){return ke(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let c=0;c<s.length;++c)r[c]=this._getVertexBufferLayout(s[c],t.geometryDescriptor);const o=e.mbs,a=this.elevationOffset,n=this._controller.crsIndex,l=this._controller.crsVertex,d=this.view.renderSpatialReference,h=Fe(o,a,n),u=Pe(o,a,n,d),_=k(n,l),m=k(l,d);if(c(_)||c(m))return Promise.resolve(null);const g={context:this.i3slayer.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,localOrigin:h,globalTrafo:u,mbs:o,obb:e.serviceObb,elevationOffset:a,needNormals:!this._isIntegratedMesh&&this._controller.isMeshPyramid,normalReferenceFrame:this.i3slayer.normalReferenceFrame||"none",indexToVertexProjector:_,vertexToRenderProjector:m};return this._worker.invoke(g,i)}get _supportsNodeCrossFading(){return!this.view?._stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){const t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,i){if(this.elevationInfo.mode===Ut.Absolute&&(e.geometryObb=rt(this._collection.getComponentObb(t.objectHandle))),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);h(this._labeler)&&this._addMetaToLabeler(this._labeler,t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,nt.Visible),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==Ut.Absolute&&this._ensureElevationTask().schedule(s),this._updateEngineObject(t),this._highlights.objectCreated(t),h(this._treeDebugger)&&this._treeDebugger.update()}addCachedNodeData(e,t,i,s){return this._addData(e,i,(()=>this._addCachedNodeData(e,t,s)))}async _addCachedNodeData(e,t,i){if(this.suspended||!this._controller.isGeometryVisible(e))return void this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);if(c(t))return void this._addNodeMeta(e.index,null);const s=this._addTasks.get(e.index),{geometryData:r,transformedGeometry:o,globalTrafo:a}=t;await this.i3sOverrides.apply(r.featureIds,s.attributeInfo,i);const n=h(t.textureData)?t.textureData.filter((e=>h(e)&&0!=(e.usage&this.rendererTextureUsage))):[];!has("disable-feature:i3s-basis")&&n.some((e=>h(e)&&(e.encoding===ye.Basis||e.encoding===ye.KTX2)))&&await ht(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:u}=r,_=this._collection,m=d[0],{layout:g,indices:p,interleavedVertexData:f,positionData:b,hasColors:y}=o,v=this._materialParameters(m,g),I=l||new Uint32Array([0,p?p.length:f.byteLength/g[0].stride]),M={vertices:{data:f,count:f.byteLength/g[0].stride,layoutParameters:v.geometryParams},positionData:{positions:b.data,indices:b.indices},indices:p,componentOffsets:I},C=m.transformation?j(m.transformation):w();E(C,a,C);const T=S(U(),C),A=x(O(),C),D=this.view.renderSpatialReference,R=this.view.basemapTerrain.spatialReference,N=U(),P=[1,1,1];B(T,D,P,R)||mt.errorOnce("Unsupported coordinate system for IM overlay"),q(T,D,N,R);const F=_.createObject({toMapSpace:G(N[0],N[1],P[0],P[1]),geometry:M,obb:t.geometryObb,transform:{position:T,rotationScale:A}}),V=v.geometryParams.textureCoordinates===dt.Atlas,{textures:H,texturePromise:L}=this._initMaterialAndTextures(F,v.material,n,V);e.memory+=this._memEstimateGeometryAdded(F),e.memory+=H.reduce(((e,t)=>e+(h(t)?this._memEstimateTextureAdded(t):0)),0);const k=!!v.material.hasParametersFromSource,z="blend"!==v.material.alphaMode&&v.material.metallicRoughness.baseColorFactor[3]>=1,K=new pt(e,u,F,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:k,isOpaque:z},H);s.meta=K,!this._hasTextures&&t.requiredTextures?.some((({usage:e})=>0!=(e&be.ColorTextures)))&&(this._hasTextures=!0),this._hasData=!0,this._hasColors=this._hasColors||y,this._hasTextures=this._hasTextures||!!e.resources.texture,this.notifyChange("hasTexturesOrVertexColors");const W=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(K),L]).then((([t,s])=>(h(t)&&t.updateObjectVisibility(K.objectHandle,!1).catch((e=>It(e,this.i3slayer.title))),this._safeReschedule((()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,K),i.meta=null,this.suspended)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(F,nt.Visible),h(t)&&t.updateObjectVisibility(K.objectHandle,!0).catch((e=>It(e,this.i3slayer.title))),K.attributeInfo=i.attributeInfo;const s=K.cachedRendererVersion!==this._rendererVersion,r=W!==this.slicePlaneEnabled;this._updateElevationOffsets(K);const o=K.elevationOffsets;this._updateComponentData(K);const a=this._applyFiltersToNode(K);(s||h(t)&&(r||a||o))&&this._addOrUpdateEdgeRendering(K),h(this._labeler)&&this._addMetaToLabeler(this._labeler,K),this._visibleGeometryChanged(K,Mt.ADD),this._highlights.objectCreated(K),this._updateMaterial(K),this._setNewNodeOpacity(K),h(this._treeDebugger)&&this._treeDebugger.update()}),i)))).catch((e=>{throw h(s.meta)&&(this._cacheGPUData(s.meta),s.meta=null),e}))}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){mt.error("Removing duplicated node");const t=this._nodeId2Meta.get(e);h(t)&&this._deleteComponentObject(t)}else this._controller.updateLoadStatus(e,!0);h(t)&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&Vt(t.cachedEdgeMaterials,0)),this._nodeId2Meta.set(e,t)}_updateElevationOffsets(e){const t=this.view.renderSpatialReference,i=this.elevationInfo,s=this.view.basemapTerrain,r=s.spatialReference,o=i.mode;if(c(t)||c(r)||o===Ut.Absolute)return void(e.elevationOffsets=null);const a=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const n=Ht,l=Gt,d=o===Ut.OnTheGround,u=this.view.renderCoordsHelper,_=!!e.cachedMidsTerrainSR,m=e.featureIds.length;if(!_){e.cachedMidsTerrainSR=ct(3*m);const i=e.cachedMidsTerrainSR;for(let s=0;s<m;s++){this._collection.getComponentAabb(e.objectHandle,s,l,!0),D(n,(l[0]+l[3])/2,(l[1]+l[4])/2,l[2]),R(n,n,a.rotationScale),N(n,n,a.position);const o=3*s;i[o+2]=u.getAltitude(n),q(n,t,n,r),i[o+0]=n[0],i[o+1]=n[1]}}const g=e.cachedMidsTerrainSR,p=i.offset,f=e.elevationOffsets,b=(e,t)=>{const i=d?g[3*e+2]:0;f[e]=p+(h(t)?t-i:0)};s.getElevations(g,m,b)}_ensureElevationTask(){return h(this._elevationTask)||(this._elevationTask=new Ie(this.view.resourceController.scheduler,(e=>{const t=this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference);return h(t)?t.filterInPlace((e=>h(this._nodeId2Meta.get(e)))):null}),(e=>{const t=this._nodeId2Meta.get(e);this._nodeElevationAlignmentChanged(t)}))),this._elevationTask}_elevationInfoChanged(e,t){const i=e.mode!==Ut.Absolute,s=!!t&&t!==e&&t.mode!==Ut.Absolute;this._intersectionHandler.updateElevationAlignState(i,this.view.state.viewingMode),i&&!s&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach((e=>this._nodeElevationAlignmentChanged(e)))}_nodeElevationAlignmentChanged(e){c(e)||(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),h(this._labeler)&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,Mt.UPDATE))}_safeReschedule(e,t){return g(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=h(e.params.material)?e.params.material:we(),s=t.some((e=>"uvRegion"===e.name)),r=t.some((e=>"normalCompressed"===e.name)),o=Tt(i);return{geometryParams:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s){const r=this._stage.renderView,o=i.map((e=>Te(e,t,s,r)));this._stage.addMany(o);let a=null;return this._collection.updateMaterial(e,(e=>{a=Ae(e,t,o,i,this.view._stage.renderView.textureRepository,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference}),this._updateMaterialOverlay(e)})),{textures:o,texturePromise:a}}_getGeometryParameters(e){return{textureCoordinates:e.hasTexture?e.hasRegions?dt.Atlas:dt.Default:dt.None,colors:this._hasVertexColors,normals:e.hasNormals&&!this._isIntegratedMesh}}_addData(e,t,i){let s=this._addTasks.get(e.index);return s?s.attributeInfo=t:(s={...p(),attributeInfo:t,meta:null},this._addTasks.set(e.index,s),i().then(s.resolve,s.reject).then((()=>this._addTasks.delete(e.index))).catch((t=>{throw this._addTasks.delete(e.index),t}))),s.promise}_clearAddTasks(){this._addTasks.forEach((e=>{h(e.meta)&&(this._cacheGPUData(e.meta),e.meta=null)})),this._addTasks.clear()}_clippingAreaChanged(){const e=this.view.renderSpatialReference,t=this.i3slayer.spatialReference,i=Y();this._renderClippingArea=it(this.view.clippingArea,i,e)?i:null;const s=Y();this._layerClippingArea=it(this.view.clippingArea,s,t)?s:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){const e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e)}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach((e=>{h(e)&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Mt.UPDATE))}))}getFilters(){const e=[],t=this._renderClippingArea;return h(t)&&e.push(((e,i)=>this._boundingRectFilter(e,i,t))),e}addSqlFilter(e,t,i){if(h(t)){const s=t.fieldNames;e.push(((e,r)=>this._sqlFilter(e,r,t,s,i)))}}_sqlFilter(e,t,i,s,r){const o={},a=this._createLayerGraphic(o),n=this.i3slayer.objectIdField,l=t.featureIds,d=h(t.attributeInfo)&&t.attributeInfo.attributeData;s.every((e=>e===n||d&&null!=d[e]))&&Be(e,l,(e=>{o[n]=l[e];for(const i of s)i!==n&&(o[i]=d?qe(d[i],e):null);try{return i.testFeature(a)}catch(t){return r(t),!1}}))}_boundingRectNodeTest(e,t){return z(e.node.mbs,this._controller.crsIndex,wt,this.view.renderSpatialReference),ze(t,wt)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,Ct),X(Ct,xt),Q(i,xt)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(r===Ke.INSIDE)return;if(r===Ke.OUTSIDE)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const a=this._transformClippingArea(Ot,i,t.objectHandle);Be(e,t.featureIds,(e=>this._boundingRectFeatureTest(t,e,a)))}_transformClippingArea(e,t,i){const s=this._collection.getObjectTransform(i),r=s.position,o=s.rotationScale;return e[0]=(t[0]-r[0])/o[0],e[1]=(t[1]-r[1])/o[4],e[2]=(t[2]-r[0])/o[0],e[3]=(t[3]-r[1])/o[4],e}_addOrUpdateEdgeRendering(e,t=!0){const i=this._edgeView;if(c(i))return Promise.resolve(null);const s=e.objectHandle,r=i.hasObject(s),{hasEdges:o,perFeatureEdgeMaterials:a}=this._getFilteredEdgeMaterials(e),n={hasSlicePlane:this.slicePlaneEnabled};if(o&&r){if(this.nodeCrossfadingEnabled){Vt(a,this.getNodeOpacity(e))}return i.updateAllComponentMaterials(s,a,n,t).catch((e=>It(e,this.i3slayer.title))),i.updateObjectVisibility(s,!0).catch((e=>It(e,this.i3slayer.title))),i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>It(e,this.i3slayer.title))),Promise.resolve(i)}return o&&!r?this._collection.addEdges(s,i,a,n).then((t=>(e.edgeMemoryUsage=t,e.node.memory+=t,i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>It(e,this.i3slayer.title))),i))):(!o&&r&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,i.removeObject(s)),Promise.resolve(null))}_applyFiltersToNode(e){return!!this._applyFiltersToNodeComponents(e)&&(h(this._labeler)&&this._labeler.applyFilterChange(e),!0)}_applyFiltersToNodeComponents(e){const t=this._collection,i=0===t.getComponentCount(e.objectHandle).invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!i;if(this._updateCachedFilteredIds(e),e.filteredIds===e.featureIds)return!i;const s=this._computeFilteredComponentIndices(e);return t.setAllComponentVisibilities(e.objectHandle,s),!0}_updateCachedFilteredIds(e){null!=e.filteredIds&&e.appliedFilters===this._filters||(e.filteredIds=this._computeFilteredIds(e),e.appliedFilters=this._filters)}_computeFilteredIds(e){const t=e.featureIds.slice();for(const i of this._filters)if(i(t,e),0===t.length)break;return t.length===e.featureIds.length?e.featureIds:t}_computeFilteredComponentIndices(e){const t=new Array,i=e.filteredIds;return h(i)&&e.featureIds.forEach(((e,s)=>{i[t.length]===e&&t.push(s)})),t}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach(((t,i)=>this._removeNodeStageData(i,e))),this._nodeId2MetaReloading.forEach(((t,i)=>this._removeNodeStageData(i,e,this._nodeId2MetaReloading))),this._elevationTask=d(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),h(this._elevationTask)&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);c(s)?i.delete(e):(this._collection.setObjectVisibility(s.objectHandle,nt.Hidden),h(this._edgeView)&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch((e=>It(e,this.i3slayer.title))),this._visibleGeometryChanged(s,Mt.REMOVE),h(this._labeler)&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights.objectDeleted(s),i===this._nodeId2Meta?(this._cacheGPUData(s,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(s)):this._deleteComponentObject(s),h(this._treeDebugger)&&this._treeDebugger.update())}_deleteComponentObject(e){if(h(this._edgeView)&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(const t of e.textures)this._memEstimateTextureRemoved(t),this._stage.remove(t)}updateNodeState(e,t){const i=this._nodeId2Meta.get(e);h(i)&&this._collection.updateMaterial(i.objectHandle,(e=>e.polygonOffsetEnabled=t===Re.Hole))}_invalidateAllSymbols(){this._rendererVersion=We(this._rendererVersion,1),this._controller&&this._controller.requestUpdate()}_getInvalidRendererVersion(){return We(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=We(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.i3slayer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&"arcadeRequired"in e&&e.arcadeRequired&&(this._arcade=await re()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:mt.warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.getSymbols())"mesh-3d"!==t.type&&mt.error(`Symbols of type '${t.type}' are not supported for 3D Object Scene Services.`);this._controller&&this._controller.requestUpdate()}_getCachedEdgeMaterials(e){return this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e),e.cachedEdgeMaterials}_getComponentParameters(e){this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e);const t=e.cachedSymbology;return(i,s)=>{const r=5*i;if(H(s.externalColor,t[r+0]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255),h(this._stage.renderView.objectAndLayerIdRenderHelper)){const t=e.featureIds[i];this._stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(t,t,this.layerId,this.layerUid,this.layerPopupEnabled,e.node.resources.attributes,i,this.sublayerId),s.objectAndLayerIdColor=this._stage.renderView.getObjectAndLayerIdColor({graphicUid:t,layerUid:this.layerUid})}s.externalColorMixMode=t[r+4]&(1<<ft.CastShadows)-1,s.castShadows=0!=(t[r+4]&1<<ft.CastShadows),s.pickable=0!=(t[r+4]&1<<ft.Pickable),s.elevationOffset=e.elevationOffsets?.[i]??0}}_getSymbolInfo(e,t){const i=e&&e.getSymbol(t,{arcade:this._arcade});if(!(i instanceof oe))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=$e(i);return this._symbolInfos.set(s,r),r}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=h(this._symbologyOverrideFields)&&this._symbologyOverrideFields.length>0?h(this._rendererFields)&&this._rendererFields.length>0?ee(this.i3slayer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;const t=this._tmpAttributeOnlyGraphic,i={};t.attributes=i;const s=this._currentRenderer,r=h(e.attributeInfo)&&e.attributeInfo.attributeData,o=null!=e.featureIds?this.i3slayer.objectIdField:null,a=null!=r&&h(this._symbologyFields)&&this._symbologyFields.length>0;let n=null,l=null;if(a&&h(this._symbologyFields)){n=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(n.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=new Uint8Array(5*e.featureIds.length));const d={color:St,castShadows:!0,pickable:!0,colorMixMode:et.Multiply,edgeMaterial:null},u=this.fullOpacity,_=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):u;let m=null,g=ut.OPAQUE,p=Xe,f=0;for(let b=0;b<e.featureIds.length;b++){if(null!=o&&(i[o]=e.featureIds[b]),a&&n)for(let e=0;e<n.length;e++)i[n[e]]=qe(l[e],b);const r=s?this._getSymbolInfo(s,t):null;let u=null,y=null;if(s&&"visualVariables"in s){if(this._colorVariable){const e=ie(this._colorVariable,t,{color:jt,arcade:this._arcade});e&&(u=St,u[0]=e.r/255,u[1]=e.g/255,u[2]=e.b/255,this._opacityVariable||null===e.a||(y=e.a))}this._opacityVariable&&(y=se(this._opacityVariable,t,{arcade:this._arcade}))}if(r&&r.material){const e=r.material;u=c(u)||c(y)?pe(u,y,e.color,e.alpha,gt,St):pe(u,y,null,null,gt,St)}if(c(u)&&(u=St,u[0]=1,u[1]=1,u[2]=1,u[3]=1),d.pickable=!0,d.castShadows=!r||r.castShadows,d.colorMixMode=r&&r.material?r.material.colorMixMode:et.Multiply,d.edgeMaterial=r?r.edgeMaterial:null,h(this._symbologyOverride)&&(d.color=u,this._symbologyOverride(t,d),u=d.color),h(d.edgeMaterial)){const t=u[3]<=0?ut.INVISIBLE:u[3]>=1&&(e.material.isOpaque||d.colorMixMode===et.Replace)?ut.OPAQUE:ut.TRANSPARENT;d.edgeMaterial===m&&t===g||(p={...d.edgeMaterial,opacity:_,objectTransparency:t},m=d.edgeMaterial,g=t),e.cachedEdgeMaterials[b]=p}else e.cachedEdgeMaterials[b]=Xe;e.cachedSymbology[f+0]=Math.round(255*u[0]),e.cachedSymbology[f+1]=Math.round(255*u[1]),e.cachedSymbology[f+2]=Math.round(255*u[2]),e.cachedSymbology[f+3]=Math.round(255*u[3]),e.cachedSymbology[f+4]=d.colorMixMode|+d.castShadows<<ft.CastShadows|+d.pickable<<ft.Pickable,f+=5}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||Vt(t,this.fullOpacity);const i=e.filteredIds;if(c(i)){return{hasEdges:t.some((e=>e!==Xe)),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map(((t,o)=>e.featureIds[o]!==i[s]?Xe:(r=r||t!==Xe,s++,t)));return{hasEdges:r,perFeatureEdgeMaterials:o}}_updateComponentData(e){if(!this._hasComponentData)return;const t=e.objectHandle,i=this._getComponentParameters(e);this._collection.setComponentData(t,i),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),null!=this._controller&&this._controller.restartNodeLoading()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach((t=>{c(t)||(this._collection.updateMaterial(t.objectHandle,(t=>t.objectOpacity=e)),Vt(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))}))}_updateMaterial(e){this._collection.updateMaterial(e.objectHandle,(e=>{e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.usePBR=this._usePBR,this._updateMaterialOverlay(e)}))}_updateMaterialOverlay(e){}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Mt.UPDATE)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),h(this._labeler)&&(this._labeler.slicePlaneEnabled=e),this._nodeId2Meta.forEach((t=>{c(t)||(this._collection.updateMaterial(t.objectHandle,(t=>t.commonMaterialParameters.hasSlicePlane=e)),this._updateEdgeRendering(t,!1))}))}_updatePBR(e){this._nodeId2Meta.forEach((t=>{c(t)||this._collection.updateMaterial(t.objectHandle,(t=>t.usePBR=e))})),this._hasLoadedPBRTextures=!0}get _usePBR(){return!this._isIntegratedMesh&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){h(this._edgeView)&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_forAllFeatures(e,t,i=he.VISIBLE_ONLY){n(this._nodeId2Meta,(s=>{if(c(s))return!1;if(h(t)){switch(t(s)){case ce.EXIT:return!0;case ce.SKIP:return!1}}let r=ce.CONTINUE;switch(i){case he.ALL:r=this._forAllFeaturesOfNode(s,e);break;case he.VISIBLE_ONLY:r=this._forVisibleFeaturesOfNode(s,e);break;case he.ALL_IN_CLIPPING_AREA:r=this._forAllFeaturesOfNodeInClippingArea(s,e)}return r===ce.EXIT}))}_forAllFeaturesOfNode(e,t){let i=ce.CONTINUE;const s=e.featureIds;for(let r=0;r<s.length;r++)if(i=t(s[r],r,e),i===ce.EXIT)return i;return i}_forVisibleFeaturesOfNode(e,t){let i=ce.CONTINUE;const s=e.featureIds;return this._collection.forEachVisibleComponent(e.objectHandle,(r=>(i=t(s[r],r,e),i===ce.CONTINUE))),i}_forAllFeaturesOfNodeInClippingArea(e,t){if(c(this._renderClippingArea))return this._forAllFeaturesOfNode(e,t);const i=this._boundingRectNodeTest(e,this._renderClippingArea);if(i===Ke.OUTSIDE)return ce.CONTINUE;if(i===Ke.INSIDE)return this._forAllFeaturesOfNode(e,t);const s=ce.CONTINUE,r=e.featureIds,o=e.objectHandle,a=Ye(this._renderClippingArea,this._collection.getObjectTransform(o));for(let n=0;n<r.length;n++){if(!this._boundingRectFeatureTest(e,n,a))continue;const i=t(r[n],n,e);if(i===ce.EXIT)return i}return s}_createAttributes(e,t){const i={};null!=t.featureIds&&(i[this._getObjectIdField()]=t.featureIds[e]);const s=h(t.attributeInfo)&&t.attributeInfo.attributeData;if(h(s))for(const r of Object.keys(s))i[r]=qe(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e){const t=this._highlights;if("number"==typeof e||e instanceof i?e=[e]:e instanceof o&&(e=e.toArray()),Array.isArray(e)&&e.length>0){if(e[0]instanceof i){const i=e,s=this.i3slayer.fieldsIndex,r=this._getObjectIdField(),o=i.map((e=>Ze(s,e.attributes,r))),{set:a,handle:n}=t.acquireSet();return t.setFeatureIds(a,o),n}if("number"==typeof e[0]){const i=e,{set:s,handle:r}=t.acquireSet();return t.setFeatureIds(s,i),r}}return Ft}_visibleGeometryChanged(e,t){this._elevationProvider&&(this._elevationProvider.objectChanged(e.node),null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=y((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))),this._updateSnappingSources(e,t))}get performanceInfo(){const e={displayedNumberOfFeatures:0,maximumNumberOfFeatures:0,totalNumberOfFeatures:0,core:null,index:0,nodes:this._nodeId2Meta.size,"Total GPU Memory Estimate":(this._gpuMemoryEstimate/1048576).toFixed(1)+"MB","Geometry Memory Estimate":(this._geoMemoryEstimate/1048576).toFixed(1)+"MB","Texture Memory Estimate":(this._texMemoryEstimate/1048576).toFixed(1)+"MB","Unloaded Memory Estimate":(this.getUnloadedMemory()/1048576).toFixed(1)+"MB"};return h(this._memCache)&&(e.MemCache=Math.round(100*this._memCache.hitRate)+"% hit"),this._controller&&(this._idbCacheEnabled&&(e.IDBCache=Math.round(100*this._idbCache.getHitRate())+"% hit"),this._controller.updateStats(e)),e}get test(){const e=this;return{controller:this._controller,labeler:this._labeler,get visibleObjectIds(){const t=[];return e._forAllFeatures((e=>(t.push(e),ce.CONTINUE)),null,he.VISIBLE_ONLY),t.sort(((e,t)=>e-t)),t},get numNodes(){return e._nodeId2Meta.size},get loadedNodes(){return Array.from(e._nodeId2Meta.keys()).sort(((e,t)=>e-t))}}}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return h(e)?this._collection.getMaterial(e.objectHandle).objectOpacity:0}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(((t,i)=>e(i,t)))}fadeNode(e,t,i){if(!this.nodeCrossfadingEnabled)return;const s=this._nodeId2Meta.get(e);h(s)&&this._crossfadeHelper.fadeNode(e,s,t,i)}setNodeOpacityByIndex(e,t){const i=this._nodeId2Meta.get(e);h(i)&&this._setNodeOpacity(i,t)}_setNodeOpacity(e,t){this._collection.updateMaterial(e.objectHandle,(e=>e.objectOpacity=t)),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(c(this._edgeView)||!e.cachedEdgeMaterials)return;Vt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch((e=>It(e,this.i3slayer.title)))}get hasModifications(){return this._isIntegratedMesh&&h(this._layerClippingArea)||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){const t=e.length;if(!this.hasModifications||t<=0||!0!==this._i3sWasmLoaded)return;const i=this.i3slayer.uid,s=Pt(e);if(h(s)){const t={context:i,buffer:s.buffer};me(t);const r=new Float64Array(s.buffer);e.forAll(((e,t)=>{const i=r[t],s=ge(i);e.imModificationImpact=s,s!==De.Unmodified&&this._controller.invalidateGeometryVisibility(e.index)}))}}notifyUpdate(){this.notifyChange("updating")}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!(!this._controller||!this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||h(this._labeler)&&this._labeler.updating||this._crossfadeHelper.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||h(this._elevationTask)&&this._elevationTask.running}trackSnappingSources(e){const t={events:e,fetchEdgeLocations:async(e,t,i)=>{const s=this._nodeId2Meta.get(e);if(c(s))throw new Error("invalid-node");const{origin:r,buffer:o}=await this._collection.extractEdgeInformation(s.objectHandle,t,i);return this._snappingLocationsApplyElevation(s,o,r),{type:"components",objectIds:s.featureIds,locations:o,origin:r}},remove:()=>{s(this._snappingSourcesTrackers,t)}};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach(((t,i)=>{if(c(t))return;const s=this._controller.getRenderMbs(t.node);h(s)&&e.add(i,s)})),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||this.elevationInfo.mode===Ut.Absolute)return;const s=t.position0,r=t.position1,o=t.componentIndex,a=U(),n=U(),l=(e,t)=>{N(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,n),N(e,e,F(n,n,t)),V(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,a),l(a,t),s.setVec(d,a),r.getVec(d,a),l(a,t),r.setVec(d,a)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(!c(s))for(const r of this._snappingSourcesTrackers)t!==Mt.REMOVE&&t!==Mt.UPDATE||r.events.remove(i),t!==Mt.ADD&&t!==Mt.UPDATE||r.events.add(i,s)}};return e([M()],r.prototype,"_hasLoadedPBRTextures",void 0),e([M()],r.prototype,"_asyncModuleLoading",void 0),e([M()],r.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([M()],r.prototype,"view",void 0),e([M()],r.prototype,"i3slayer",void 0),e([M()],r.prototype,"_controller",void 0),e([M()],r.prototype,"_labeler",void 0),e([M()],r.prototype,"updating",void 0),e([M()],r.prototype,"suspended",void 0),e([M()],r.prototype,"holeFilling",void 0),e([M(ot)],r.prototype,"updatingProgress",void 0),e([M()],r.prototype,"updatingProgressValue",null),e([M()],r.prototype,"hasTexturesOrVertexColors",null),e([M()],r.prototype,"rendererTextureUsage",null),e([M()],r.prototype,"elevationOffset",null),e([M()],r.prototype,"elevationInfo",null),e([M({type:Boolean})],r.prototype,"slicePlaneEnabled",void 0),e([M()],r.prototype,"supportedTextureEncodings",null),e([M()],r.prototype,"uncompressedTextureDownsamplingEnabled",null),e([M({type:[te]})],r.prototype,"_modifications",void 0),e([M()],r.prototype,"_elevationTask",void 0),e([M({readOnly:!0})],r.prototype,"_usePBR",null),r=e([C(_t)],r),r};function It(e,t){m(e)||mt.warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}var Mt;!function(e){e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE"}(Mt||(Mt={}));const Ct=K(),xt=Y(),Ot=Y(),Et=st(),St=[0,0,0,0],jt=new t([0,0,0,0]),wt=[0,0,0,0];function Tt(e){if(c(e))return!1;const t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function At(e){return"geometryData"in e}function Dt(e){return h(e)&&v(e.data)}function Rt(e,t){let i=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(h(t))for(const s of t)h(s)&&v(s.data)&&(i+=s.data.byteLength);return i}function Nt(e,t){return t.byteSize>yt?(mt.warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}function Pt(e){if(0===e.length)return null;const t=10*e.length,i=new Float64Array(t);return e.forAll(((e,t)=>{let s=e.serviceObb;c(s)&&(s=Et,P(s.center,e.mbs),s.halfSize[0]=s.halfSize[1]=s.halfSize[2]=e.mbs[3]);const r=10*t;i[r+0]=s.center[0],i[r+1]=s.center[1],i[r+2]=s.center[2],i[r+3]=s.halfSize[0],i[r+4]=s.halfSize[1],i[r+5]=s.halfSize[2],i[r+6]=s.quaternion[0],i[r+7]=s.quaternion[1],i[r+8]=s.quaternion[2],i[r+9]=s.quaternion[3]})),i}const Ft={remove(){},pause(){},resume(){}};function Vt(e,t){e.forEach((e=>e.opacity=t))}var Ut;!function(e){e[e.Absolute=0]="Absolute",e[e.RelativeToGround=1]="RelativeToGround",e[e.OnTheGround=2]="OnTheGround"}(Ut||(Ut={}));const Ht=U(),Gt=K(),Lt="elevation-change";export{Ut as ElevationMode,vt as I3SMeshView3D};
@@ -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"../../../Graphic.js";import"../../../symbols.js";import i from"../../../core/Accessor.js";import t from"../../../core/Handles.js";import{destroyMaybe as s,isNone as o,isSome as a}from"../../../core/maybe.js";import{watch as n}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 p}from"../../../core/accessorSupport/decorators/subclass.js";import{diff as c}from"../../../core/accessorSupport/diffUtils.js";import{c as d}from"../../../chunks/vec3f64.js";import{makeDehydratedPoint as h}from"../../../layers/graphics/dehydratedFeatures.js";import{Graphics3DCore as g}from"./graphics/Graphics3DCore.js";import m from"./graphics/Graphics3DScaleVisibility.js";import{boundingBoxTop as y}from"./i3s/I3SGeometryUtil.js";import{LimitGraphicsMap as u}from"../support/LimitGraphicsMap.js";import{UpdatePolicy as f}from"../webgl-engine/lib/UpdatePolicy.js";import b from"../../../symbols/PointSymbol3D.js";let v=class extends i{get updating(){return this._graphicsCore?.updating??!1}constructor(e){super(e),this.loadedGraphics=new u(5e4),this.slicePlaneEnabled=!1,this._renderingInfo={symbol:new b},this._handles=new t,this._graphicsByNode=new Map}initialize(){const e=this.view.basemapTerrain;this._graphicsCore=new g({owner:this,layer:this.layer,preferredUpdatePolicy:f.ASYNC,elevationFeatureExpressionEnabled:!1,graphicSymbolSupported:!1,getRenderingInfoWithoutRenderer:!0,hasZ:!0,hasM:!1,componentFactories:{deconflictor:e=>this.view.deconflictor.addGraphicsOwner(e),labeler:(e,r)=>this.view.labeler.addGraphicsOwner(e,r,{emptySymbolLabelSupported:!0,elevationInfoOverride:{mode:"absolute-height",offset:0},disablePlacement:{logEntityDescription:"3D Object Scene Layer features"}}),scaleVisibility:(r,i)=>new m({graphicsCoreOwner:this,layer:this.layer,queryGraphicUIDsInExtent:i,graphicsCore:r,basemapTerrain:e,layerScaleEnabled:!1})}}),this._graphicsCore.initializePromise.then((()=>this._graphicsCore.startCreateGraphics())).catch((()=>{})),this._handles.add(n((()=>this.layer.labelingInfo),((e,r)=>{c(e,r)&&this._graphicsCore.updateLabelingInfo()})))}destroy(){this._handles=s(this._handles),this._graphicsCore=s(this._graphicsCore),this.loadedGraphics=s(this.loadedGraphics),this.view=null}addNodeMeta(e,i){let t=0;const s=e.filteredIds,a=this.view.spatialReference,n=e.featureIds.map(((n,l)=>{y(l,this.collection,e.objectHandle,_);const p=h(0,0,0,a);this.view.renderCoordsHelper.fromRenderCoords(_,p);const c=i(l,e);let d=!1;return o(s)?d=!0:t<s.length&&n===s[t]&&(d=!0,t++),{objectId:n,uid:r.generateUID(),attributes:c,visible:d,geometry:p}}));this.loadedGraphics.addMany(n),this._graphicsByNode.set(e.node.index,n)}updateLabelPositions(e){const r=this._graphicsByNode.get(e.node.index);let i=0;const t=this.view.spatialReference,s=this.view.renderCoordsHelper;for(let n=0;n<e.featureIds.length;n++){const l=r[i];if(e.featureIds[n]===l.objectId){i++;const r=this._graphicsCore.getGraphics3DGraphicById(l.uid);if(o(r))continue;y(n,this.collection,e.objectHandle,_),this.view.renderCoordsHelper.fromRenderCoords(_,_,t),r.alignWithAbsoluteElevation(_[2],s,!1),a(l.geometry)&&"point"===l.geometry.type&&(l.geometry.z=_[2])}}}setNodeMetaAttributes(e,r){const i=this._graphicsByNode.get(e.node.index),t=new Array(i.length);for(let s=0;s<i.length;s++){const o=i[s];o.attributes=r(s,e),t[s]=o.uid}this._graphicsCore.updateLabelingInfo(t)}applyFilterChange(e){const r=this._graphicsByNode.get(e.node.index);if(r)if(o(e.filteredIds))for(const i of r)i.visible||(i.visible=!0,C.graphic=i,C.property="visible",C.oldValue=!1,C.newValue=!0,this._graphicsCore.graphicUpdateHandler(C));else{let i=0;for(const t of r){const r=t.visible;i<e.filteredIds.length&&t.objectId===e.filteredIds[i]?(t.visible=!0,i++):t.visible=!1,r!==t.visible&&(C.graphic=t,C.property="visible",C.oldValue=r,C.newValue=t.visible,this._graphicsCore.graphicUpdateHandler(C))}}}removeNodeMeta(e){this.loadedGraphics.removeManyByObjectId(e.featureIds)}getRenderingInfo(){return this._renderingInfo}notifyGraphicGeometryChanged(){}notifyGraphicVisibilityChanged(){}get updatePolicy(){return this._graphicsCore.effectiveUpdatePolicy}get usedMemory(){return this._graphicsCore.usedMemory}get unloadedMemoryEstimate(){return this._graphicsCore.unprocessedMemoryEstimate}get test(){return{graphicsCore:this._graphicsCore}}};e([l()],v.prototype,"view",void 0),e([l()],v.prototype,"layer",void 0),e([l()],v.prototype,"collection",void 0),e([l()],v.prototype,"loadedGraphics",void 0),e([l()],v.prototype,"updating",null),e([l()],v.prototype,"slicePlaneEnabled",void 0),e([l()],v.prototype,"_graphicsCore",void 0),v=e([p("esri.views.3d.layers.I3SMeshViewLabeler")],v);const C={graphic:null,property:null,oldValue:null,newValue:null},_=d(),j=v;export{j as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../Graphic.js";import"../../../symbols.js";import i from"../../../core/Accessor.js";import t from"../../../core/Handles.js";import{destroyMaybe as s,isNone as o,isSome as a}from"../../../core/maybe.js";import{watch as n}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 p}from"../../../core/accessorSupport/decorators/subclass.js";import{diff as c}from"../../../core/accessorSupport/diffUtils.js";import{c as d}from"../../../chunks/vec3f64.js";import{makeDehydratedPoint as h}from"../../../layers/graphics/dehydratedFeatures.js";import{Graphics3DCore as g}from"./graphics/Graphics3DCore.js";import m from"./graphics/Graphics3DScaleVisibility.js";import{boundingBoxTop as y}from"./i3s/I3SGeometryUtil.js";import{LimitGraphicsMap as u}from"../support/LimitGraphicsMap.js";import{UpdatePolicy as f}from"../webgl-engine/lib/UpdatePolicy.js";import b from"../../../symbols/PointSymbol3D.js";let v=class extends i{get updating(){return this._graphicsCore?.updating??!1}constructor(e){super(e),this.loadedGraphics=new u(5e4),this.slicePlaneEnabled=!1,this._renderingInfo={symbol:new b},this._handles=new t,this._graphicsByNode=new Map}initialize(){const e=this.view.basemapTerrain;this._graphicsCore=new g({owner:this,layer:this.layer,preferredUpdatePolicy:f.ASYNC,elevationFeatureExpressionEnabled:!1,graphicSymbolSupported:!1,getRenderingInfoWithoutRenderer:!0,hasZ:!0,hasM:!1,componentFactories:{deconflictor:e=>this.view.deconflictor.addGraphicsOwner(e),labeler:(e,r)=>this.view.labeler.addGraphicsOwner(e,r,{emptySymbolLabelSupported:!0,elevationInfoOverride:{mode:"absolute-height",offset:0},disablePlacement:{logEntityDescription:"3D Object Scene Layer features"}}),scaleVisibility:(r,i)=>new m({graphicsCoreOwner:this,layer:this.layer,queryGraphicUIDsInExtent:i,graphicsCore:r,basemapTerrain:e,layerScaleEnabled:!1})}}),this._graphicsCore.initializePromise.then((()=>this._graphicsCore.startCreateGraphics())).catch((()=>{})),this._handles.add(n((()=>this.layer.labelingInfo),((e,r)=>{c(e,r)&&this._graphicsCore.updateLabelingInfo()})))}destroy(){this._handles=s(this._handles),this._graphicsCore=s(this._graphicsCore),this.loadedGraphics=s(this.loadedGraphics),this.view=null}addNodeMeta(e,i){let t=0;const s=e.filteredIds,a=this.view.spatialReference,n=e.featureIds.map(((n,l)=>{y(l,this.collection,e.objectHandle,_);const p=h(0,0,0,a);this.view.renderCoordsHelper.fromRenderCoords(_,p);const c=i(l,e);let d=!1;return o(s)?d=!0:t<s.length&&n===s[t]&&(d=!0,t++),{objectId:n,uid:r.generateUID(),attributes:c,visible:d,geometry:p}}));this.loadedGraphics.addMany(n),this._graphicsByNode.set(e.node.index,n)}updateLabelPositions(e){const r=this._graphicsByNode.get(e.node.index);if(!r)return;let i=0;const t=this.view.spatialReference,s=this.view.renderCoordsHelper;for(let n=0;n<e.featureIds.length;n++){const l=r[i];if(e.featureIds[n]===l.objectId){i++;const r=this._graphicsCore.getGraphics3DGraphicById(l.uid);if(o(r))continue;y(n,this.collection,e.objectHandle,_),this.view.renderCoordsHelper.fromRenderCoords(_,_,t),r.alignWithAbsoluteElevation(_[2],s,!1),a(l.geometry)&&"point"===l.geometry.type&&(l.geometry.z=_[2])}}}setNodeMetaAttributes(e,r){const i=this._graphicsByNode.get(e.node.index);if(!i)return;const t=new Array(i.length);for(let s=0;s<i.length;s++){const o=i[s];o.attributes=r(s,e),t[s]=o.uid}this._graphicsCore.updateLabelingInfo(t)}applyFilterChange(e){const r=this._graphicsByNode.get(e.node.index);if(r)if(o(e.filteredIds))for(const i of r)i.visible||(i.visible=!0,C.graphic=i,C.property="visible",C.oldValue=!1,C.newValue=!0,this._graphicsCore.graphicUpdateHandler(C));else{let i=0;for(const t of r){const r=t.visible;i<e.filteredIds.length&&t.objectId===e.filteredIds[i]?(t.visible=!0,i++):t.visible=!1,r!==t.visible&&(C.graphic=t,C.property="visible",C.oldValue=r,C.newValue=t.visible,this._graphicsCore.graphicUpdateHandler(C))}}}removeNodeMeta(e){this.loadedGraphics.removeManyByObjectId(e.featureIds)}getRenderingInfo(){return this._renderingInfo}notifyGraphicGeometryChanged(){}notifyGraphicVisibilityChanged(){}get updatePolicy(){return this._graphicsCore.effectiveUpdatePolicy}get usedMemory(){return this._graphicsCore.usedMemory}get unloadedMemoryEstimate(){return this._graphicsCore.unprocessedMemoryEstimate}get test(){return{graphicsCore:this._graphicsCore}}};e([l()],v.prototype,"view",void 0),e([l()],v.prototype,"layer",void 0),e([l()],v.prototype,"collection",void 0),e([l()],v.prototype,"loadedGraphics",void 0),e([l()],v.prototype,"updating",null),e([l()],v.prototype,"slicePlaneEnabled",void 0),e([l()],v.prototype,"_graphicsCore",void 0),v=e([p("esri.views.3d.layers.I3SMeshViewLabeler")],v);const C={graphic:null,property:null,oldValue:null,newValue:null},_=d(),j=v;export{j 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{result as t,forEach as i}from"../../../core/asyncUtils.js";import r from"../../../core/Collection.js";import s from"../../../core/Logger.js";import{unwrapOr as o,isSome as n,isNone as a,mapSome as d}from"../../../core/maybe.js";import{eachAlways as l,isAbortError as h,eachAlwaysValues as u,throwIfAborted as p}from"../../../core/promiseUtils.js";import{initial as c,watch as _,sync as m}from"../../../core/reactiveUtils.js";import{pt2px as g}from"../../../core/screenUtils.js";import{estimateSize as f,isArrayBuffer as y}from"../../../core/typedArrayUtil.js";import{getMetersPerVerticalUnitForSR as b}from"../../../core/unitUtils.js";import{property as w}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as N}from"../../../core/accessorSupport/decorators/subclass.js";import{e as P,c as x}from"../../../chunks/vec3.js";import{b as v}from"../../../chunks/vec3f32.js";import{projectBoundingRect as C}from"../../../geometry/projection.js";import{create as S}from"../../../geometry/support/aaBoundingBox.js";import{containsPoint as A,create as I}from"../../../geometry/support/aaBoundingRect.js";import{create as k,fromNormalAndOffset as V}from"../../../geometry/support/plane.js";import{makeDehydratedPoint as R}from"../../../layers/graphics/dehydratedFeatures.js";import{CodedValue as L}from"../../../layers/support/CodedValue.js";import"../../../core/has.js";import j from"../../../layers/support/CodedValueDomain.js";import"../../../layers/support/Domain.js";import"../../../layers/support/InheritedDomain.js";import"../../../layers/support/RangeDomain.js";import{unpackFieldNames as U}from"../../../layers/support/fieldUtils.js";import{PromiseQueue as Q}from"../../../layers/support/PromiseQueue.js";import{getMetersPerUnit as D}from"../../../symbols/support/unitConversionUtils.js";import{LayerView3D as F}from"./LayerView3D.js";import{PointCloudWorkerHandle as z}from"./PointCloudWorkerHandle.js";import{checkPointCloudLayerValid as M,checkPointCloudLayerCompatibleWithView as W}from"./i3s/I3SUtil.js";import{nodeDiff as E,sortFrontToBack as O,splitWorkEntries as B}from"./i3s/LoDUtil.js";import G from"./i3s/PagedNodeIndex.js";import{getSplatSizeAlgorithm as H,getFixedSizeAlgorithm as q,getRendererInfo as T,getFilterInfo as $,rendererUsesFixedSizes as J,getAttributeInfo as K}from"./i3s/PointCloudRendererUtil.js";import{getAttributeValues as X,readGeometry as Y,elevationFromPositions as Z}from"./i3s/PointCloudWorkerUtil.js";import{PointGraphic as ee}from"./i3s/PointGraphic.js";import{PointRenderer as te,isInstanceOfNode as ie,PointRendererNode as re}from"./i3s/PointRenderer.js";import{PopupSceneLayerView as se}from"./support/PopupSceneLayerView.js";import{projectToBoundingBox as oe}from"../support/extentUtils.js";import{ClientType as ne}from"../support/index.js";import{minimumDistancePlane as ae}from"../support/orientedBoundingBox.js";import{updatingProgress as de}from"../support/updatingProperties.js";import{RenderSlot as le}from"../webgl-engine/lib/RenderSlot.js";import he from"../../layers/LayerView.js";import{isScaleRangeActive as ue,extractSafeScaleBounds as pe,scaleBoundsPredicate as ce}from"../../support/layerViewUtils.js";import{TaskPriority as _e}from"../../support/Scheduler.js";const me=8,ge=k();let fe=class extends(se(F(he))){constructor(){super(...arguments),this.type="point-cloud-3d",this.maximumPointCount=4e6,this.slicePlaneEnabled=!1,this._renderer=null,this._rendererAdded=!1,this._renderedNodes=new Set,this._nodeScales=new Map,this._updateViewNeeded=!0,this._lodFactor=1,this._maxLoggedBoxWarnings=5,this._pageMultiplier=1,this._nodeLoadEpoch=0,this._indexQueue=[],this._workQueue=new Array,this._idleQueue=new Q,this._indexPagesLoading=new Map,this._loadingNodes=new Map,this._recalcWork=!0,this._layerIsVisible=!1,this._codedDomainPopulationPromise=null,this._codedDomainPopulationAbortController=null,this._totalWork=0,this._index=null,this._loadingInitNodePage=!1,this._nodeIdArray=[]}get baseUrl(){return this.layer.parsedUrl.path}get pointScale(){const e=H(this.layer&&this.layer.renderer),t=1;return e&&null!=e.scaleFactor?e.scaleFactor:t}get useRealWorldSymbolSizes(){const e=q(this.layer&&this.layer.renderer),t=!1;return e&&null!=e.useRealWorldSymbolSizes?e.useRealWorldSymbolSizes:t}get pointSize(){const e=q(this.layer&&this.layer.renderer),t=0;return e&&null!=e.size?e.size:t}get inverseDensity(){const e=96;return this.layer&&this.layer.renderer?1*e/this.layer.renderer.pointsPerInch:5}get availableFields(){const e=T(this.layer),t=new Set;e.primaryAttribute&&t.add(e.primaryAttribute.name),e.modulationAttribute&&t.add(e.primaryAttribute.name);const i=$(this.layer);if(i)for(const r of i)t.add(r.attributeInfo.name);if(this.layer.outFields)for(const r of U(this.layer.fieldsIndex,this.layer.outFields))t.add(r);return Array.from(t)}get _clippingBox(){if(!this.view||!this.view.clippingArea)return null;const e=S(),t=this.view.renderSpatialReference;return oe(this.view.clippingArea,e,t)?e:null}get _elevationOffset(){const e=this.layer&&this.layer.elevationInfo;if(e&&"absolute-height"===e.mode){const t=b(this.layer.spatialReference),i=D(e.unit);return o(e.offset,0)*i/t}return 0}initialize(){const e=this.view.resourceController;this._worker=new z((t=>e.immediate.schedule(t))),this.addResolvingPromise(this._worker.promise),this._tmpPoint=R(0,0,0,this.layer.spatialReference),M(this.layer),W(this.layer,this.view),this._indexRequester=e.createStreamDataRequester(ne.I3S_INDEX),this._dataRequester=e.createStreamDataRequester(ne.I3S_DATA),this._initRenderer();const t=this._initNodePages(),i=this.view.resourceController.memoryController;this._memCache=i.newCache(this.layer.uid),this.updatingHandles.add((()=>this._clippingBox),(()=>this._setUpdateViewNeeded()),c),this.updatingHandles.add((()=>this._elevationOffset),(()=>this._elevationOffsetChanged()),c),this.updatingHandles.add((()=>this.layer.renderer),(()=>this._rendererChanged()),c),this.updatingHandles.add((()=>this.layer.filters),(()=>this._reload()),c),this.updatingHandles.add((()=>this.layer.outFields),(()=>this._reload()),c),this.updatingHandles.add((()=>this.layer.effectiveScaleRange),(()=>this._setUpdateViewNeeded())),this.updatingHandles.add((()=>this.view.state.contentCamera),(()=>this._setUpdateViewNeeded())),this.handles.add([this.view.basemapTerrain.on("scale-change",(e=>this._scaleUpdateHandler(e))),_((()=>i.memoryFactor),(()=>this._setUpdateViewNeeded()),m)]),this.addResolvingPromise(t),this.when((()=>{this.handles.add([e.scheduler.registerTask(_e.POINT_CLOUD_LAYER,this),e.scheduler.registerIdleStateCallbacks((()=>this._idleBegin()),(()=>this._idleEnd())),this.updatingHandles.add((()=>this.suspended),(e=>{e?this._clearNodeState():this._setUpdateViewNeeded()}),c)])}),(()=>{this.updatingHandles.removeAll(),this.handles.removeAll()}))}_setUpdateViewNeeded(){this._updateViewNeeded=!0,this._updateLoading()}destroy(){this.cancelLoading(),this._worker&&(this._worker.destroy(),this._worker=null),this._destroyRenderer(),this._memCache.destroy(),this._memCache=null,this._codedDomainPopulationAbortController&&(this._codedDomainPopulationAbortController.abort(),this._codedDomainPopulationAbortController=null),this._codedDomainPopulationPromise=null}_initRenderer(){this._renderer=new te({createGraphic:(e,t,i)=>this._createGraphic(e,t,i)}),this._renderer.layerUid=this.layer.uid,this.updatingHandles.add((()=>this._clippingBox),(e=>this._renderer.clippingBox=e),c),this.updatingHandles.add((()=>this.suspended),(e=>this._setPointsVisible(!e)),c),this.updatingHandles.add((()=>this.pointScale),(e=>this._renderer.scaleFactor=e),c),this._renderer.minSizePx=Math.sqrt(2),this.updatingHandles.add((()=>this.useRealWorldSymbolSizes),(e=>this._renderer.useRealWorldSymbolSizes=e),c),this.updatingHandles.add((()=>this.pointSize),(e=>{const t=g(e);this._renderer.size=e,this._renderer.sizePx=t}),c),this.updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._renderer.slicePlaneEnabled=e),c),this.updatingHandles.add((()=>this.inverseDensity),(()=>this._setUpdateViewNeeded()),c),this.updatingHandles.add((()=>this.maximumPointCount),(()=>this._setUpdateViewNeeded()),c),this.updatingHandles.add((()=>this.view.qualitySettings.sceneService.pointCloud.lodFactor),(e=>{this._lodFactor=e,this._setUpdateViewNeeded()}),c)}_destroyRenderer(){this._renderer.removeAll(),this._setPointsVisible(!1)}_createGraphic(e,t,i){const r=n(e.pointIdFilterMap)?e.pointIdFilterMap[t]:t,s=this.view.computeMapPointFromVec3d(i),o=this._createGraphicAttributes(e,r);return new ee({pointCloudMetadata:{nodeId:e.id,pointIndexInNode:t,attributePointIndexInNode:r,epoch:this._nodeLoadEpoch},geometry:s,attributes:o,layer:this.layer,sourceLayer:this.layer})}_createGraphicAttributes(e,t){const i={};for(const r of e.attributes)this._encodeGraphicAttribute(r.attributeInfo,r.values,t,i);return i}_encodeGraphicAttribute(e,t,i,r){const s=e.storageInfo&&e.storageInfo.attributeValues,o=s?s.valuesPerElement:1;if(1===o)r[e.name]=t[i];else if("UInt8"===s.valueType&&o<=4){let s=0;const n=i*o;for(let e=n;e<n+o;e++)s=(s<<8)+t[e];r[e.name]=s}else r[e.name]=void 0}_setPointsVisible(e){e&&!this._rendererAdded?(this.view._stage.addRenderPlugin([le.OPAQUE_MATERIAL],this._renderer),this._rendererAdded=!0):!e&&this._rendererAdded&&(this.view._stage.removeRenderPlugin(this._renderer),this._rendererAdded=!1)}_rendererChanged(){this._renderer.useFixedSizes=J(this.layer.renderer),this._reload()}_reload(){this._clearNodeState(),this._memCache.clear(),this._setUpdateViewNeeded()}_elevationOffsetChanged(){this._clearNodeState(),this._memCache.clear(),this._initNodePages()}_scaleUpdateHandler(e){const t=this.layer.effectiveScaleRange;ue(t.minScale,t.maxScale)?C(e.extent,e.spatialReference,we,this.layer.spatialReference)&&(this._nodeScales.forEach(((t,i)=>{if(!this._renderedNodes.has(i))return void this._nodeScales.delete(i);const r=this._index.getNode(i);A(we,r.obb.center)&&this._nodeScales.set(i,e.scale)})),this._setUpdateViewNeeded()):this._nodeScales.clear()}_displayNodes(e){this._workQueue=E([...this._renderedNodes],e,this._index),O(this._workQueue,this.view.state.contentCamera.viewForward,this._index),B(this._workQueue,me,this._index),this._updateQueues(),this._totalWork=this._computeWork(),this._updateLoading(),this._layerIsVisible=e.length>0||this._loadingInitNodePage,this.notifyChange("suspended")}cancelLoading(){this._cancelNodeLoading(),this._cancelIndexLoading()}_cancelNodeLoading(){const e=new Array;this._loadingNodes.forEach((({abortController:t})=>e.push(t))),this._loadingNodes.clear();for(const t of e)t.abort();this._workQueue=[],this._idleQueue.cancelAll(),this._totalWork=this._computeWork(),this._updateLoading()}_updateQueues(){const e=new Set;this._workQueue.forEach((t=>t.load.forEach((t=>e.add(t)))));const t=new Array,i=new Map;this._loadingNodes.forEach(((r,s)=>{e.has(s)?i.set(s,r):t.push(r)})),this._loadingNodes=i;for(const{abortController:r}of t)r.abort();this._workQueue=this._workQueue.filter((e=>{for(const t of e.load)if(this._loadingNodes.has(t))return this._recalcWork=!0,!1;return!0})),this._totalWork=this._computeWork(),this._updateLoading()}_cancelIndexLoading(){this._indexQueue=[],this._indexPagesLoading.forEach((({abortController:e})=>e.abort())),this._indexPagesLoading.clear(),this._totalWork=this._computeWork(),this._updateLoading()}_clearNodeState(){this._nodeLoadEpoch++,this._renderedNodes.forEach((e=>this._removeFromRenderer(e))),this._cancelNodeLoading()}_idleBegin(){this._setUpdateViewNeeded()}_idleEnd(){this._setUpdateViewNeeded()}get running(){return this.suspended?this._updateViewNeeded:this._updateViewNeeded||this._indexQueue.length>0||this._workQueue.length>0||this._idleQueue.running}runTask(e){if(this.suspended){if(this._updateViewNeeded){this._updateViewNeeded=!1;const e=this._isRootNodeVisible();e!==this._layerIsVisible&&(this._layerIsVisible=e,this.notifyChange("suspended")),this._updateLoading()}}else{for(e.run((()=>this._updateWorkQueues()));this._indexQueue.length>0&&e.run((()=>this._processIndexQueue())););this._processWorkQueue(e),this._idleQueue.runTask(e)}}_processIndexQueue(){const e=this._indexQueue.shift(),t=this._loadNodePage(e);return this._indexPagesLoading.set(e,t),t.promise.then((t=>{this._index.addPage(e,t,this._elevationOffset),this._setUpdateViewNeeded()})).then((()=>{this._indexPagesLoading.delete(e)}),(()=>{this._indexPagesLoading.delete(e)})),!0}_processWorkQueue(e){for(;!e.done;){const t=this._scheduleWorkEntry();if(a(t))return;this._processWorkEntry(t),e.madeProgress()}}_scheduleWorkEntry(){let e=this._workQueue.length;for(;e--;){const e=this._workQueue.shift();if(!e.remove.find((e=>!this._renderedNodes.has(e))))return e;this._workQueue.push(e)}return null}_processWorkEntry(e){if(0!==e.load.length)Promise.all(e.load.map((e=>{const t=new AbortController,i=this._memCache.pop(e.toString());return n(i)?this._loadingNodes.set(e,{abortController:t,promise:Promise.resolve(i)}):this._loadingNodes.has(e)||this._loadingNodes.set(e,{abortController:t,promise:this._loadNode(e,t.signal)}),this._loadingNodes.get(e).promise}))).then((t=>{for(let i=0;i<e.load.length;i++)if(t[i]){const r=this._setupRendererData(e.load[i],t[i]);this._addToRenderer(r)}for(const i of e.remove)this._removeFromRenderer(i)})).catch((()=>{})).then((()=>{for(const t of e.load)this._loadingNodes.delete(t);this._updateLoading(),this._recalcWork&&!this._idleQueue.running&&0===this._indexQueue.length&&0===this._loadingNodes.size&&(this._recalcWork=!1,this._setUpdateViewNeeded())})),this._updateLoading();else for(const t of e.remove)this._removeFromRenderer(t)}async _populateClassCodeCodedDomain(e,i){const r="CLASS_CODE",s=this.layer.fieldsIndex.get(r);if(!s||s.domain)return;if(!e.includes(s.name))return;const o=await t(this.layer.queryCachedStatistics(r,{signal:i}));if(!1===o.ok)return;const n=o.value,a=n&&n.labels&&n.labels.labels;a&&Array.isArray(a)&&(s.domain=new j({name:"CLASS_CODE",codedValues:a.map((e=>new L({code:e.value,name:e.label})))}))}async prepareFetchPopupFeatures(e){return this._codedDomainPopulationPromise||(this._codedDomainPopulationAbortController=new AbortController,this._codedDomainPopulationPromise=this._populateClassCodeCodedDomain(e,this._codedDomainPopulationAbortController.signal).then((()=>{this._codedDomainPopulationAbortController=null}))),this._codedDomainPopulationPromise}async whenGraphicAttributes(e,t){const r=this._splitGraphicsPerNode(e),s=this.layer.attributeStorageInfo,o=t.map((e=>K(s,e))),n=async(e,t)=>{const r=this._index.getNode(t);await i(o,(async t=>{const i=t.useElevation?await this._loadElevationAttributeFromGeometry(r.resourceId):await this._loadAndParseAttribute(r,t);if(i)for(const r of e)if(this._isValidPointGraphic(r)){const e=r.pointCloudMetadata.attributePointIndexInNode;this._encodeGraphicAttribute(t,i,e,r.attributes)}}))},a=[];return r.forEach(((e,t)=>{a.push(n(e,t))})),await l(a),e}_isValidPointGraphic(e){return e instanceof ee&&e.pointCloudMetadata&&e.pointCloudMetadata.epoch===this._nodeLoadEpoch}_splitGraphicsPerNode(e){const t=new Map;for(const i of e){if(!this._isValidPointGraphic(i))continue;const e=i.pointCloudMetadata,r=t.get(e.nodeId);r?r.push(i):t.set(e.nodeId,[i])}return t}async _loadAndParseAttribute(e,t){const i=await this._loadAttribute(e.resourceId,t,null);return n(i)?X({attributeInfo:t,buffer:i},null,e.vertexCount):null}async _loadElevationAttributeFromGeometry(e){const t=this.layer.store.defaultGeometrySchema,i=Y(t,await this._loadGeometry(e,null));return Z(i,i.length/3)}highlight(e){if(!e)return{remove(){}};const t=r.isCollection(e)?e.toArray():Array.isArray(e)?e:[e];return this._renderer.highlight(t.map((e=>this._graphicToPointDefinition(e))))}_graphicToPointDefinition(e){if(!this._isValidPointGraphic(e))return null;const{nodeId:t,pointIndexInNode:i}=e.pointCloudMetadata;return null!=t&&null!=i?{nodeId:t,pointId:i}:null}_computeWork(){let e=0;for(const t of this._workQueue)e+=t.load.length+t.remove.length;return e+=this._loadingNodes.size,e+=(this._indexQueue.length+this._indexPagesLoading.size)*this._index.pageSize,e+=this._loadingInitNodePage?100:0,e+=this._updateViewNeeded?100:0,e}get updatingProgressValue(){if(this.suspended)return this._updateViewNeeded?0:1;const e=this._computeWork();return 1-Math.min(this._totalWork,e)/this._totalWork}_updateLoading(){this.notifyChange("updating"),this.notifyChange("updatingProgressValue")}canResume(){return super.canResume()&&this._layerIsVisible}isUpdating(){return this.suspended?this._updateViewNeeded:this._computeWork()>0}_initNodePages(){const e=this.layer.store.index,t=e.nodesPerPage||e.nodePerIndexBlock;return this._index=new G(this.layer.spatialReference,this.view.renderCoordsHelper.spatialReference,t),this._cancelIndexLoading(),this._traverseVisible=this._index.createVisibilityTraverse(),this._loadingInitNodePage=!0,this._layerIsVisible=!0,this.notifyChange("suspended"),this._updateLoading(),this._pageMultiplier=null!=e.nodesPerPage?1:e.nodePerIndexBlock,this._loadNodePage(0).promise.then((e=>{this._index.addPage(0,e,this._elevationOffset),this._loadingInitNodePage=!1,this._setUpdateViewNeeded()}))}_loadNodePage(e){const t=new AbortController,i=`${this.baseUrl}/nodepages/${e*this._pageMultiplier}`;return{promise:this._requestNodePage(i,t.signal).then((t=>t.nodes.map(((t,i)=>({resourceId:null!=t.resourceId?t.resourceId:e*this._index.pageSize+i,obb:t.obb,firstChild:t.firstChild,childCount:t.childCount,vertexCount:null!=t.vertexCount?t.vertexCount:t.pointCount,lodThreshold:null!=t.lodThreshold?t.lodThreshold:t.effectiveArea}))))),abortController:t}}_updateWorkQueues(){if(!this._updateViewNeeded)return!1;let e=this.inverseDensity/this._lodFactor*this._getLodMemoryFactor();const t=this.maximumPointCount*this._lodFactor*this._getLodMemoryFactor();let i=this._computeNodesForMinimumDensity(e),r=this._computePointCount(i),s=Math.sqrt(r/(.75*t));for(;r>t;)e*=s,i=this._computeNodesForMinimumDensity(e),r=this._computePointCount(i),s=Math.sqrt(2);return this._displayNodes(i),this._updateViewNeeded=!1,this._updateLoading(),!0}_computePointCount(e){let t=0;for(let i=0;i<e.length;i++){const r=this._index.getNode(e[i]);r&&(t+=r.vertexCount)}return t}_getLodMemoryFactor(){return this.view.resourceController.memoryController.memoryFactor}_isRootNodeVisible(){let e=!1;return this._traverseVisible({frustum:this.view.state.contentCamera.frustum,clippingBox:this._clippingBox},{predicate:(t,i,r)=>(e=r,!1),pageMiss:()=>{}}),e}_computeNodesForMinimumDensity(e){const t=this.view.state.contentCamera,i=t.frustum,r=this._clippingBox,s=t.viewForward,o=P(s,t.eye),n=V(s,-o,ge),a=t.perScreenPixelRatio/2,d=e*e,l=this._nodeIdArray;l.length=0;const{minScale:h,maxScale:u}=pe(this.layer),p=0===h&&0===u?e=>l.push(e):e=>{const t=this._getScale(e);ce(t,h,u)&&l.push(e)};return this._traverseVisible({frustum:i,clippingBox:r},{predicate:(e,t,i)=>{if(!i)return!1;if(0===t.childCount)return p(e),!1;const r=this._index.getRenderObb(e);return!(this._computeAveragePixelArea(r,t.lodThreshold,t.vertexCount,n,a)<=d)||(p(e),!1)},pageMiss:(e,t)=>{p(e),this._indexQueue.includes(t)||this._indexQueue.push(t)}}),l}_getScale(e){let t=this._nodeScales.get(e);if(null==t){const i=this._index.getNode(e).obb.center;this._tmpPoint.x=i[0],this._tmpPoint.y=i[1],this._tmpPoint.z=i[2],t=this.view.basemapTerrain.getScale(this._tmpPoint),this._nodeScales.set(e,t)}return t}_computeAveragePixelArea(e,t,i,r,s){const o=1e-7,n=Math.max(o,ae(e,r));return t/(n*n)/(4*s*s)/i}_loadNode(e,t){try{return this._loadNodeAsync(e,t)}catch(i){throw h(i)||s.getLogger(this.declaredClass).error(i),i}}async _loadAdditionalUserAttributes(e,t,i){const r=this.layer.outFields;if(!r)return[];const s=U(this.layer.fieldsIndex,r),o=new Set(e.map((e=>n(e)?e.name:null))),a=this.layer.attributeStorageInfo,l=[];for(const n of s){if(o.has(n))continue;const e=K(a,n);e&&l.push(t(e))}const h=await u(l);return p(i),d(h,(e=>e))}async _loadNodeAsync(e,t){const i=this._index.getNode(e),r=T(this.layer),s=$(this.layer),o=i.resourceId,d=async e=>{if(a(e))return null;if(e.useElevation)return{attributeInfo:e,buffer:null};const i=await this._loadAttribute(o,e,t);return n(i)?{attributeInfo:e,buffer:i}:null};return this._idleQueue.push((async()=>{const i=this._loadGeometry(o,t),{primaryAttribute:n,modulationAttribute:a}=r,l=d(n),h=d(a),u=s.map((e=>e.attributeInfo)),c=u.map((e=>d(e))),_=this._loadAdditionalUserAttributes([n,a,...u],d,t),[m,g,f,y,b]=await Promise.all([i,l,h,Promise.all(c),_]);p(t);const w={geometryBuffer:m,primaryAttributeData:g,modulationAttributeData:f,filterAttributesData:y,userAttributesData:b,schema:this.layer.store.defaultGeometrySchema,rendererInfo:r,filterInfo:s,obb:this._index.getRenderObb(e),elevationOffset:this._elevationOffset,inSR:this.layer.spatialReference.toJSON(),outSR:this.view.renderCoordsHelper.spatialReference.toJSON()};return this._worker.invoke(w,t)}),t)}async _loadGeometry(e,t){return this._requestData(`${this.baseUrl}/nodes/${e}/geometries/0`,t)}async _loadAttribute(e,t,i){if(a(t)||!t.storageInfo)return null;const r=t.storageInfo.key;return this._requestData(`${this.baseUrl}/nodes/${e}/attributes/${r}`,i)}_requestNodePage(e,t){const i={f:"json",token:this.layer.apiKey};return this._indexRequester.request(e,"json",{query:i,signal:t})}_requestData(e,t){return this._dataRequester.request(e,"binary",{query:{token:this.layer.apiKey},signal:t})}_removeFromRenderer(e){if(this._renderedNodes.has(e)){const t=this._renderer.removeNode(e);this._renderedNodes.delete(e),this._nodeScales.delete(e),this._memCache.put(t.id.toString(),t,be(t))}}_addToRenderer(e){this._renderedNodes.has(e.id)||(this._renderedNodes.add(e.id),this._renderer.addNode(e))}_setupRendererData(e,t){const i=this._index.getNode(e),r=Math.sqrt(i.lodThreshold/i.vertexCount),o=this._index.getRenderObb(e);if(ie(t))return t.splatSize=r,t.obb=o,x(t.origin,t.obb.center),t;const n=.01*Math.max(o.halfSize[0],o.halfSize[1],o.halfSize[2]);if(t.obb.halfSize[0]>o.halfSize[0]+n||t.obb.halfSize[1]>o.halfSize[1]+n||t.obb.halfSize[2]>o.halfSize[2]+n){if(this._maxLoggedBoxWarnings>0){const i=e=>`[${e.halfSize[0]}, ${e.halfSize[1]}, ${e.halfSize[2]}]`;s.getLogger(this.declaredClass).warn(`Node ${e} reported bounding box too small. got ${i(o)} but points cover ${i(t.obb)}`),0==--this._maxLoggedBoxWarnings&&s.getLogger(this.declaredClass).warn(" Too many bounding box errors, stopping reporting for this layer.")}this._index.setRenderObb(e,t.obb)}return new re(e,r,v(o.center),o,0===i.childCount,t.points,t.rgb,t.attributes,t.pointIdFilterMap)}getUsedMemory(){let e=0;return this._renderer.forEachNode((t=>{e+=Ne,e+=f(t.coordinates);for(const i of t.attributes){const t=i.values;y(t.buffer)&&(e+=f(t))}})),e}getUnloadedMemory(){const e=this._renderedNodes.size;if(e<4)return 0;const t=[...this._renderedNodes].reduce(((e,t)=>e+this._index.getNode(t).vertexCount));let i=this._loadingNodes.size;for(let r=0;r<this._workQueue.length;r++)i+=this._workQueue[r].load.length,i-=this._workQueue[r].remove.length;if(i<0)return 0;return i*t/e*((this.getUsedMemory()-e*Ne)/t)+i*Ne}ignoresMemoryFactor(){return!1}get performanceInfo(){return{nodes:this._renderedNodes.size,displayedNumberOfFeatures:[...this._renderedNodes].reduce(((e,t)=>e+this._index.getNode(t).vertexCount),0),maximumNumberOfFeatures:this.maximumPointCount,totalNumberOfFeatures:-1,core:null,"Loading Nodes":this._loadingNodes.size,"Index Queue":this._indexQueue.length,"Work Queue":this._workQueue.length,"Idle Queue":this._idleQueue.length}}get test(){return{index:this._index,visibleNodes:this._renderedNodes}}};e([w()],fe.prototype,"layer",void 0),e([w()],fe.prototype,"baseUrl",null),e([w()],fe.prototype,"pointScale",null),e([w()],fe.prototype,"useRealWorldSymbolSizes",null),e([w()],fe.prototype,"pointSize",null),e([w()],fe.prototype,"inverseDensity",null),e([w()],fe.prototype,"maximumPointCount",void 0),e([w({readOnly:!0})],fe.prototype,"availableFields",null),e([w({readOnly:!0})],fe.prototype,"_clippingBox",null),e([w({readOnly:!0})],fe.prototype,"_elevationOffset",null),e([w({type:Boolean})],fe.prototype,"slicePlaneEnabled",void 0),e([w()],fe.prototype,"updating",void 0),e([w(de)],fe.prototype,"updatingProgress",void 0),e([w({readOnly:!0})],fe.prototype,"updatingProgressValue",null),fe=e([N("esri.views.3d.layers.PointCloudLayerView3D")],fe);const ye=fe;function be(e){return 5*e.coordinates.length+128}const we=I(),Ne=160;export{ye as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{result as t,forEach as i}from"../../../core/asyncUtils.js";import r from"../../../core/Collection.js";import s from"../../../core/Logger.js";import{unwrapOr as o,destroyMaybe as n,abortMaybe as a,isSome as d,isNone as l,mapSome as h}from"../../../core/maybe.js";import{eachAlways as u,isAbortError as p,eachAlwaysValues as c,throwIfAborted as _}from"../../../core/promiseUtils.js";import{initial as m,watch as g,sync as f}from"../../../core/reactiveUtils.js";import{pt2px as y}from"../../../core/screenUtils.js";import{estimateSize as b,isArrayBuffer as w}from"../../../core/typedArrayUtil.js";import{getMetersPerVerticalUnitForSR as N}from"../../../core/unitUtils.js";import{property as P}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as x}from"../../../core/accessorSupport/decorators/subclass.js";import{e as v,c as C}from"../../../chunks/vec3.js";import{b as S}from"../../../chunks/vec3f32.js";import{projectBoundingRect as A}from"../../../geometry/projection.js";import{create as I}from"../../../geometry/support/aaBoundingBox.js";import{containsPoint as k,create as V}from"../../../geometry/support/aaBoundingRect.js";import{create as R,fromNormalAndOffset as L}from"../../../geometry/support/plane.js";import{makeDehydratedPoint as j}from"../../../layers/graphics/dehydratedFeatures.js";import{CodedValue as U}from"../../../layers/support/CodedValue.js";import"../../../core/has.js";import Q from"../../../layers/support/CodedValueDomain.js";import"../../../layers/support/Domain.js";import"../../../layers/support/InheritedDomain.js";import"../../../layers/support/RangeDomain.js";import{unpackFieldNames as D}from"../../../layers/support/fieldUtils.js";import{PromiseQueue as F}from"../../../layers/support/PromiseQueue.js";import{getMetersPerUnit as z}from"../../../symbols/support/unitConversionUtils.js";import{LayerView3D as M}from"./LayerView3D.js";import{PointCloudWorkerHandle as W}from"./PointCloudWorkerHandle.js";import{checkPointCloudLayerValid as E,checkPointCloudLayerCompatibleWithView as O}from"./i3s/I3SUtil.js";import{nodeDiff as B,sortFrontToBack as G,splitWorkEntries as H}from"./i3s/LoDUtil.js";import q from"./i3s/PagedNodeIndex.js";import{getSplatSizeAlgorithm as T,getFixedSizeAlgorithm as $,getRendererInfo as J,getFilterInfo as K,rendererUsesFixedSizes as X,getAttributeInfo as Y}from"./i3s/PointCloudRendererUtil.js";import{getAttributeValues as Z,readGeometry as ee,elevationFromPositions as te}from"./i3s/PointCloudWorkerUtil.js";import{PointGraphic as ie}from"./i3s/PointGraphic.js";import{PointRenderer as re,isInstanceOfNode as se,PointRendererNode as oe}from"./i3s/PointRenderer.js";import{PopupSceneLayerView as ne}from"./support/PopupSceneLayerView.js";import{projectToBoundingBox as ae}from"../support/extentUtils.js";import{ClientType as de}from"../support/index.js";import{minimumDistancePlane as le}from"../support/orientedBoundingBox.js";import{updatingProgress as he}from"../support/updatingProperties.js";import{RenderSlot as ue}from"../webgl-engine/lib/RenderSlot.js";import pe from"../../layers/LayerView.js";import{isScaleRangeActive as ce,extractSafeScaleBounds as _e,scaleBoundsPredicate as me}from"../../support/layerViewUtils.js";import{TaskPriority as ge}from"../../support/Scheduler.js";const fe=8,ye=R();let be=class extends(ne(M(pe))){constructor(){super(...arguments),this.type="point-cloud-3d",this.maximumPointCount=4e6,this.slicePlaneEnabled=!1,this._renderer=null,this._rendererAdded=!1,this._renderedNodes=new Set,this._nodeScales=new Map,this._updateViewNeeded=!0,this._lodFactor=1,this._maxLoggedBoxWarnings=5,this._pageMultiplier=1,this._nodeLoadEpoch=0,this._indexQueue=[],this._workQueue=new Array,this._idleQueue=new F,this._indexPagesLoading=new Map,this._loadingNodes=new Map,this._recalcWork=!0,this._layerIsVisible=!1,this._codedDomainPopulationPromise=null,this._codedDomainPopulationAbortController=null,this._totalWork=0,this._index=null,this._loadingInitNodePage=!1,this._nodeIdArray=[]}get baseUrl(){return this.layer.parsedUrl.path}get pointScale(){const e=T(this.layer&&this.layer.renderer),t=1;return e&&null!=e.scaleFactor?e.scaleFactor:t}get useRealWorldSymbolSizes(){const e=$(this.layer&&this.layer.renderer),t=!1;return e&&null!=e.useRealWorldSymbolSizes?e.useRealWorldSymbolSizes:t}get pointSize(){const e=$(this.layer&&this.layer.renderer),t=0;return e&&null!=e.size?e.size:t}get inverseDensity(){const e=96;return this.layer&&this.layer.renderer?1*e/this.layer.renderer.pointsPerInch:5}get availableFields(){const e=J(this.layer),t=new Set;e.primaryAttribute&&t.add(e.primaryAttribute.name),e.modulationAttribute&&t.add(e.modulationAttribute.name);const i=K(this.layer);if(i)for(const r of i)r.attributeInfo&&t.add(r.attributeInfo.name);if(this.layer.outFields)for(const r of D(this.layer.fieldsIndex,this.layer.outFields))t.add(r);return Array.from(t)}get _clippingBox(){if(!this.view||!this.view.clippingArea)return null;const e=I(),t=this.view.renderSpatialReference;return ae(this.view.clippingArea,e,t)?e:null}get _elevationOffset(){const e=this.layer&&this.layer.elevationInfo;if(e&&"absolute-height"===e.mode){const t=N(this.layer.spatialReference),i=z(e.unit);return o(e.offset,0)*i/t}return 0}initialize(){const e=this.view.resourceController;this._worker=new W((t=>e.immediate.schedule(t))),this.addResolvingPromise(this._worker.promise),this._tmpPoint=j(0,0,0,this.layer.spatialReference),E(this.layer),O(this.layer,this.view),this._indexRequester=e.createStreamDataRequester(de.I3S_INDEX),this._dataRequester=e.createStreamDataRequester(de.I3S_DATA),this._initRenderer();const t=this._initNodePages(),i=this.view.resourceController.memoryController;this._memCache=i.newCache(this.layer.uid),this.updatingHandles.add((()=>this._clippingBox),(()=>this._setUpdateViewNeeded()),m),this.updatingHandles.add((()=>this._elevationOffset),(()=>this._elevationOffsetChanged()),m),this.updatingHandles.add((()=>this.layer.renderer),(()=>this._rendererChanged()),m),this.updatingHandles.add((()=>this.layer.filters),(()=>this._reload()),m),this.updatingHandles.add((()=>this.layer.outFields),(()=>this._reload()),m),this.updatingHandles.add((()=>this.layer.effectiveScaleRange),(()=>this._setUpdateViewNeeded())),this.updatingHandles.add((()=>this.view.state.contentCamera),(()=>this._setUpdateViewNeeded())),this.handles.add([this.view.basemapTerrain.on("scale-change",(e=>this._scaleUpdateHandler(e))),g((()=>i.memoryFactor),(()=>this._setUpdateViewNeeded()),f)]),this.addResolvingPromise(t),this.when((()=>{this.handles.add([e.scheduler.registerTask(ge.POINT_CLOUD_LAYER,this),e.scheduler.registerIdleStateCallbacks((()=>this._idleBegin()),(()=>this._idleEnd())),this.updatingHandles.add((()=>this.suspended),(e=>{e?this._clearNodeState():this._setUpdateViewNeeded()}),m)])}),(()=>{this.updatingHandles.removeAll(),this.handles.removeAll()}))}_setUpdateViewNeeded(){this._updateViewNeeded=!0,this._updateLoading()}destroy(){this.cancelLoading(),this._worker=n(this._worker),this._destroyRenderer(),this._memCache=n(this._memCache),this._codedDomainPopulationAbortController=a(this._codedDomainPopulationAbortController),this._codedDomainPopulationPromise=null}_initRenderer(){this._renderer=new re({createGraphic:(e,t,i)=>this._createGraphic(e,t,i)}),this._renderer.layerUid=this.layer.uid,this.updatingHandles.add((()=>this._clippingBox),(e=>this._renderer.clippingBox=e),m),this.updatingHandles.add((()=>this.suspended),(e=>this._setPointsVisible(!e)),m),this.updatingHandles.add((()=>this.pointScale),(e=>this._renderer.scaleFactor=e),m),this._renderer.minSizePx=Math.sqrt(2),this.updatingHandles.add((()=>this.useRealWorldSymbolSizes),(e=>this._renderer.useRealWorldSymbolSizes=e),m),this.updatingHandles.add((()=>this.pointSize),(e=>{const t=y(e);this._renderer.size=e,this._renderer.sizePx=t}),m),this.updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._renderer.slicePlaneEnabled=e),m),this.updatingHandles.add((()=>this.inverseDensity),(()=>this._setUpdateViewNeeded()),m),this.updatingHandles.add((()=>this.maximumPointCount),(()=>this._setUpdateViewNeeded()),m),this.updatingHandles.add((()=>this.view.qualitySettings.sceneService.pointCloud.lodFactor),(e=>{this._lodFactor=e,this._setUpdateViewNeeded()}),m)}_destroyRenderer(){this._renderer.removeAll(),this._setPointsVisible(!1)}_createGraphic(e,t,i){const r=d(e.pointIdFilterMap)?e.pointIdFilterMap[t]:t,s=this.view.computeMapPointFromVec3d(i),o=this._createGraphicAttributes(e,r);return new ie({pointCloudMetadata:{nodeId:e.id,pointIndexInNode:t,attributePointIndexInNode:r,epoch:this._nodeLoadEpoch},geometry:s,attributes:o,layer:this.layer,sourceLayer:this.layer})}_createGraphicAttributes(e,t){const i={};for(const r of e.attributes)this._encodeGraphicAttribute(r.attributeInfo,r.values,t,i);return i}_encodeGraphicAttribute(e,t,i,r){const s=e.storageInfo?.attributeValues,o=s?.valuesPerElement??1;if(1===o)r[e.name]=t[i];else if("UInt8"===s?.valueType&&o<=4){let s=0;const n=i*o;for(let e=n;e<n+o;e++)s=(s<<8)+t[e];r[e.name]=s}else r[e.name]=void 0}_setPointsVisible(e){e&&!this._rendererAdded?(this.view._stage.addRenderPlugin([ue.OPAQUE_MATERIAL],this._renderer),this._rendererAdded=!0):!e&&this._rendererAdded&&(this.view._stage.removeRenderPlugin(this._renderer),this._rendererAdded=!1)}_rendererChanged(){this._renderer.useFixedSizes=X(this.layer.renderer),this._reload()}_reload(){this._clearNodeState(),this._memCache.clear(),this._setUpdateViewNeeded()}_elevationOffsetChanged(){this._clearNodeState(),this._memCache.clear(),this._initNodePages()}_scaleUpdateHandler(e){const t=this.layer.effectiveScaleRange;ce(t.minScale,t.maxScale)?A(e.extent,e.spatialReference,Pe,this.layer.spatialReference)&&(this._nodeScales.forEach(((t,i)=>{if(!this._renderedNodes.has(i))return void this._nodeScales.delete(i);const r=this._index.getNode(i);k(Pe,r.obb.center)&&this._nodeScales.set(i,e.scale)})),this._setUpdateViewNeeded()):this._nodeScales.clear()}_displayNodes(e){this._workQueue=B([...this._renderedNodes],e,this._index),G(this._workQueue,this.view.state.contentCamera.viewForward,this._index),H(this._workQueue,fe,this._index),this._updateQueues(),this._totalWork=this._computeWork(),this._updateLoading(),this._layerIsVisible=e.length>0||this._loadingInitNodePage,this.notifyChange("suspended")}cancelLoading(){this._cancelNodeLoading(),this._cancelIndexLoading()}_cancelNodeLoading(){const e=new Array;this._loadingNodes.forEach((({abortController:t})=>e.push(t))),this._loadingNodes.clear();for(const t of e)t.abort();this._workQueue=[],this._idleQueue.cancelAll(),this._totalWork=this._computeWork(),this._updateLoading()}_updateQueues(){const e=new Set;this._workQueue.forEach((t=>t.load.forEach((t=>e.add(t)))));const t=new Array,i=new Map;this._loadingNodes.forEach(((r,s)=>{e.has(s)?i.set(s,r):t.push(r)})),this._loadingNodes=i;for(const{abortController:r}of t)r.abort();this._workQueue=this._workQueue.filter((e=>{for(const t of e.load)if(this._loadingNodes.has(t))return this._recalcWork=!0,!1;return!0})),this._totalWork=this._computeWork(),this._updateLoading()}_cancelIndexLoading(){this._indexQueue=[],this._indexPagesLoading.forEach((({abortController:e})=>e.abort())),this._indexPagesLoading.clear(),this._totalWork=this._computeWork(),this._updateLoading()}_clearNodeState(){this._nodeLoadEpoch++,this._renderedNodes.forEach((e=>this._removeFromRenderer(e))),this._cancelNodeLoading()}_idleBegin(){this._setUpdateViewNeeded()}_idleEnd(){this._setUpdateViewNeeded()}get running(){return this.suspended?this._updateViewNeeded:this._updateViewNeeded||this._indexQueue.length>0||this._workQueue.length>0||this._idleQueue.running}runTask(e){if(this.suspended){if(this._updateViewNeeded){this._updateViewNeeded=!1;const e=this._isRootNodeVisible();e!==this._layerIsVisible&&(this._layerIsVisible=e,this.notifyChange("suspended")),this._updateLoading()}}else{for(e.run((()=>this._updateWorkQueues()));this._indexQueue.length>0&&e.run((()=>this._processIndexQueue())););this._processWorkQueue(e),this._idleQueue.runTask(e)}}_processIndexQueue(){const e=this._indexQueue.shift(),t=this._loadNodePage(e);return this._indexPagesLoading.set(e,t),t.promise.then((t=>{this._index.addPage(e,t,this._elevationOffset),this._setUpdateViewNeeded()})).then((()=>{this._indexPagesLoading.delete(e)}),(()=>{this._indexPagesLoading.delete(e)})),!0}_processWorkQueue(e){for(;!e.done;){const t=this._scheduleWorkEntry();if(l(t))return;this._processWorkEntry(t),e.madeProgress()}}_scheduleWorkEntry(){let e=this._workQueue.length;for(;e--;){const e=this._workQueue.shift();if(!e.remove.find((e=>!this._renderedNodes.has(e))))return e;this._workQueue.push(e)}return null}_processWorkEntry(e){if(0!==e.load.length)Promise.all(e.load.map((e=>{const t=new AbortController,i=this._memCache.pop(e.toString());return d(i)?this._loadingNodes.set(e,{abortController:t,promise:Promise.resolve(i)}):this._loadingNodes.has(e)||this._loadingNodes.set(e,{abortController:t,promise:this._loadNode(e,t.signal)}),this._loadingNodes.get(e).promise}))).then((t=>{for(let i=0;i<e.load.length;i++)if(t[i]){const r=this._setupRendererData(e.load[i],t[i]);this._addToRenderer(r)}for(const i of e.remove)this._removeFromRenderer(i)})).catch((()=>{})).then((()=>{for(const t of e.load)this._loadingNodes.delete(t);this._updateLoading(),this._recalcWork&&!this._idleQueue.running&&0===this._indexQueue.length&&0===this._loadingNodes.size&&(this._recalcWork=!1,this._setUpdateViewNeeded())})),this._updateLoading();else for(const t of e.remove)this._removeFromRenderer(t)}async _populateClassCodeCodedDomain(e,i){const r="CLASS_CODE",s=this.layer.fieldsIndex.get(r);if(!s||s.domain)return;if(!e.includes(s.name))return;const o=await t(this.layer.queryCachedStatistics(r,{signal:i}));if(!1===o.ok)return;const n=o.value,a=n&&n.labels&&n.labels.labels;a&&Array.isArray(a)&&(s.domain=new Q({name:"CLASS_CODE",codedValues:a.map((e=>new U({code:e.value,name:e.label})))}))}async prepareFetchPopupFeatures(e){return this._codedDomainPopulationPromise||(this._codedDomainPopulationAbortController=new AbortController,this._codedDomainPopulationPromise=this._populateClassCodeCodedDomain(e,this._codedDomainPopulationAbortController.signal).then((()=>{this._codedDomainPopulationAbortController=null}))),this._codedDomainPopulationPromise}async whenGraphicAttributes(e,t){const r=this._splitGraphicsPerNode(e),s=this.layer.attributeStorageInfo,o=t.map((e=>Y(s,e))).filter(d),n=async(e,t)=>{const r=this._index.getNode(t);await i(o,(async t=>{const i=t.useElevation?await this._loadElevationAttributeFromGeometry(r.resourceId):await this._loadAndParseAttribute(r,t);if(i)for(const r of e)if(this._isValidPointGraphic(r)){const e=r.pointCloudMetadata.attributePointIndexInNode;this._encodeGraphicAttribute(t,i,e,r.attributes)}}))},a=[];return r.forEach(((e,t)=>{a.push(n(e,t))})),await u(a),e}_isValidPointGraphic(e){return e instanceof ie&&e.pointCloudMetadata&&e.pointCloudMetadata.epoch===this._nodeLoadEpoch}_splitGraphicsPerNode(e){const t=new Map;for(const i of e){if(!this._isValidPointGraphic(i))continue;const e=i.pointCloudMetadata,r=t.get(e.nodeId);r?r.push(i):t.set(e.nodeId,[i])}return t}async _loadAndParseAttribute(e,t){const i=await this._loadAttribute(e.resourceId,t,null);return d(i)?Z({attributeInfo:t,buffer:i},null,e.vertexCount):null}async _loadElevationAttributeFromGeometry(e){const t=this.layer.store.defaultGeometrySchema,i=ee(t,await this._loadGeometry(e,null));return te(i,i.length/3)}highlight(e){if(!e)return{remove(){}};const t=r.isCollection(e)?e.toArray():Array.isArray(e)?e:[e];return this._renderer.highlight(t.map((e=>this._graphicToPointDefinition(e))))}_graphicToPointDefinition(e){if(!this._isValidPointGraphic(e))return null;const{nodeId:t,pointIndexInNode:i}=e.pointCloudMetadata;return null!=t&&null!=i?{nodeId:t,pointId:i}:null}_computeWork(){let e=0;for(const t of this._workQueue)e+=t.load.length+t.remove.length;return e+=this._loadingNodes.size,e+=(this._indexQueue.length+this._indexPagesLoading.size)*this._index.pageSize,e+=this._loadingInitNodePage?100:0,e+=this._updateViewNeeded?100:0,e}get updatingProgressValue(){if(this.suspended)return this._updateViewNeeded?0:1;const e=this._computeWork();return 1-Math.min(this._totalWork,e)/this._totalWork}_updateLoading(){this.notifyChange("updating"),this.notifyChange("updatingProgressValue")}canResume(){return super.canResume()&&this._layerIsVisible}isUpdating(){return this.suspended?this._updateViewNeeded:this._computeWork()>0}_initNodePages(){const e=this.layer.store.index,t=e.nodesPerPage||e.nodePerIndexBlock;return this._index=new q(this.layer.spatialReference,this.view.renderCoordsHelper.spatialReference,t),this._cancelIndexLoading(),this._traverseVisible=this._index.createVisibilityTraverse(),this._loadingInitNodePage=!0,this._layerIsVisible=!0,this.notifyChange("suspended"),this._updateLoading(),this._pageMultiplier=null!=e.nodesPerPage?1:e.nodePerIndexBlock,this._loadNodePage(0).promise.then((e=>{this._index.addPage(0,e,this._elevationOffset),this._loadingInitNodePage=!1,this._setUpdateViewNeeded()}))}_loadNodePage(e){const t=new AbortController,i=`${this.baseUrl}/nodepages/${e*this._pageMultiplier}`;return{promise:this._requestNodePage(i,t.signal).then((t=>t.nodes.map(((t,i)=>({resourceId:null!=t.resourceId?t.resourceId:e*this._index.pageSize+i,obb:t.obb,firstChild:t.firstChild,childCount:t.childCount,vertexCount:t.vertexCount??t.pointCount,lodThreshold:t.lodThreshold??t.effectiveArea}))))),abortController:t}}_updateWorkQueues(){if(!this._updateViewNeeded)return!1;let e=this.inverseDensity/this._lodFactor*this._getLodMemoryFactor();const t=this.maximumPointCount*this._lodFactor*this._getLodMemoryFactor();let i=this._computeNodesForMinimumDensity(e),r=this._computePointCount(i),s=Math.sqrt(r/(.75*t));for(;r>t;)e*=s,i=this._computeNodesForMinimumDensity(e),r=this._computePointCount(i),s=Math.sqrt(2);return this._displayNodes(i),this._updateViewNeeded=!1,this._updateLoading(),!0}_computePointCount(e){let t=0;for(let i=0;i<e.length;i++){const r=this._index.getNode(e[i]);r&&(t+=r.vertexCount)}return t}_getLodMemoryFactor(){return this.view.resourceController.memoryController.memoryFactor}_isRootNodeVisible(){let e=!1;return this._traverseVisible({frustum:this.view.state.contentCamera.frustum,clippingBox:this._clippingBox},{predicate:(t,i,r)=>(e=r,!1),pageMiss:()=>{}}),e}_computeNodesForMinimumDensity(e){const t=this.view.state.contentCamera,i=t.frustum,r=this._clippingBox,s=t.viewForward,o=v(s,t.eye),n=L(s,-o,ye),a=t.perScreenPixelRatio/2,d=e*e,l=this._nodeIdArray;l.length=0;const{minScale:h,maxScale:u}=_e(this.layer),p=0===h&&0===u?e=>l.push(e):e=>{const t=this._getScale(e);me(t,h,u)&&l.push(e)};return this._traverseVisible({frustum:i,clippingBox:r},{predicate:(e,t,i)=>{if(!i)return!1;if(0===t.childCount)return p(e),!1;const r=this._index.getRenderObb(e);return!(this._computeAveragePixelArea(r,t.lodThreshold,t.vertexCount,n,a)<=d)||(p(e),!1)},pageMiss:(e,t)=>{p(e),this._indexQueue.includes(t)||this._indexQueue.push(t)}}),l}_getScale(e){let t=this._nodeScales.get(e);if(null==t){const i=this._index.getNode(e).obb.center;this._tmpPoint.x=i[0],this._tmpPoint.y=i[1],this._tmpPoint.z=i[2],t=this.view.basemapTerrain.getScale(this._tmpPoint),this._nodeScales.set(e,t)}return t}_computeAveragePixelArea(e,t,i,r,s){const o=1e-7,n=Math.max(o,le(e,r));return t/(n*n)/(4*s*s)/i}_loadNode(e,t){try{return this._loadNodeAsync(e,t)}catch(i){throw p(i)||s.getLogger(this.declaredClass).error(i),i}}async _loadAdditionalUserAttributes(e,t,i){const r=this.layer.outFields;if(!r)return[];const s=D(this.layer.fieldsIndex,r),o=new Set(e.map((e=>d(e)?e.name:null))),n=this.layer.attributeStorageInfo,a=[];for(const d of s){if(o.has(d))continue;const e=Y(n,d);e&&a.push(t(e))}const l=await c(a);return _(i),h(l,(e=>e))}async _loadNodeAsync(e,t){const i=this._index.getNode(e),r=J(this.layer),s=K(this.layer),o=i.resourceId,n=async e=>{if(l(e))return null;if(e.useElevation)return{attributeInfo:e,buffer:null};const i=await this._loadAttribute(o,e,t);return d(i)?{attributeInfo:e,buffer:i}:null};return this._idleQueue.push((async()=>{const i=this._loadGeometry(o,t),{primaryAttribute:a,modulationAttribute:d}=r,l=n(a),h=n(d),u=s.map((e=>e.attributeInfo)),p=u.map((e=>n(e))),c=this._loadAdditionalUserAttributes([a,d,...u],n,t),[m,g,f,y,b]=await Promise.all([i,l,h,Promise.all(p),c]);_(t);const w={geometryBuffer:m,primaryAttributeData:g,modulationAttributeData:f,filterAttributesData:y,userAttributesData:b,schema:this.layer.store.defaultGeometrySchema,rendererInfo:r,filterInfo:s,obb:this._index.getRenderObb(e),elevationOffset:this._elevationOffset,inSR:this.layer.spatialReference.toJSON(),outSR:this.view.renderCoordsHelper.spatialReference.toJSON()};return this._worker.invoke(w,t)}),t)}async _loadGeometry(e,t){return this._requestData(`${this.baseUrl}/nodes/${e}/geometries/0`,t)}async _loadAttribute(e,t,i){if(l(t)||!t.storageInfo)return null;const r=t.storageInfo.key;return this._requestData(`${this.baseUrl}/nodes/${e}/attributes/${r}`,i)}_requestNodePage(e,t){const i={f:"json",token:this.layer.apiKey};return this._indexRequester.request(e,"json",{query:i,signal:t})}_requestData(e,t){return this._dataRequester.request(e,"binary",{query:{token:this.layer.apiKey},signal:t})}_removeFromRenderer(e){if(this._renderedNodes.has(e)){const t=this._renderer.removeNode(e);this._renderedNodes.delete(e),this._nodeScales.delete(e),this._memCache.put(t.id.toString(),t,Ne(t))}}_addToRenderer(e){this._renderedNodes.has(e.id)||(this._renderedNodes.add(e.id),this._renderer.addNode(e))}_setupRendererData(e,t){const i=this._index.getNode(e),r=Math.sqrt(i.lodThreshold/i.vertexCount),o=this._index.getRenderObb(e);if(se(t))return t.splatSize=r,t.obb=o,C(t.origin,t.obb.center),t;const n=.01*Math.max(o.halfSize[0],o.halfSize[1],o.halfSize[2]);if(t.obb.halfSize[0]>o.halfSize[0]+n||t.obb.halfSize[1]>o.halfSize[1]+n||t.obb.halfSize[2]>o.halfSize[2]+n){if(this._maxLoggedBoxWarnings>0){const i=e=>`[${e.halfSize[0]}, ${e.halfSize[1]}, ${e.halfSize[2]}]`;s.getLogger(this.declaredClass).warn(`Node ${e} reported bounding box too small. got ${i(o)} but points cover ${i(t.obb)}`),0==--this._maxLoggedBoxWarnings&&s.getLogger(this.declaredClass).warn(" Too many bounding box errors, stopping reporting for this layer.")}this._index.setRenderObb(e,t.obb)}return new oe(e,r,S(o.center),o,0===i.childCount,t.points,t.rgb,t.attributes,t.pointIdFilterMap)}getUsedMemory(){let e=0;return this._renderer.forEachNode((t=>{e+=xe,e+=b(t.coordinates);for(const i of t.attributes){const t=i.values;w(t.buffer)&&(e+=b(t))}})),e}getUnloadedMemory(){const e=this._renderedNodes.size;if(e<4)return 0;const t=[...this._renderedNodes].reduce(((e,t)=>e+this._index.getNode(t).vertexCount));let i=this._loadingNodes.size;for(let r=0;r<this._workQueue.length;r++)i+=this._workQueue[r].load.length,i-=this._workQueue[r].remove.length;if(i<0)return 0;return i*t/e*((this.getUsedMemory()-e*xe)/t)+i*xe}ignoresMemoryFactor(){return!1}get performanceInfo(){return{nodes:this._renderedNodes.size,displayedNumberOfFeatures:[...this._renderedNodes].reduce(((e,t)=>e+this._index.getNode(t).vertexCount),0),maximumNumberOfFeatures:this.maximumPointCount,totalNumberOfFeatures:-1,core:null,"Loading Nodes":this._loadingNodes.size,"Index Queue":this._indexQueue.length,"Work Queue":this._workQueue.length,"Idle Queue":this._idleQueue.length}}get test(){return{index:this._index,visibleNodes:this._renderedNodes}}};e([P()],be.prototype,"layer",void 0),e([P()],be.prototype,"baseUrl",null),e([P()],be.prototype,"pointScale",null),e([P()],be.prototype,"useRealWorldSymbolSizes",null),e([P()],be.prototype,"pointSize",null),e([P()],be.prototype,"inverseDensity",null),e([P()],be.prototype,"maximumPointCount",void 0),e([P({readOnly:!0})],be.prototype,"availableFields",null),e([P({readOnly:!0})],be.prototype,"_clippingBox",null),e([P({readOnly:!0})],be.prototype,"_elevationOffset",null),e([P({type:Boolean})],be.prototype,"slicePlaneEnabled",void 0),e([P()],be.prototype,"updating",void 0),e([P(he)],be.prototype,"updatingProgress",void 0),e([P({readOnly:!0})],be.prototype,"updatingProgressValue",null),be=e([x("esri.views.3d.layers.PointCloudLayerView3D")],be);const we=be;function Ne(e){return 5*e.coordinates.length+128}const Pe=V(),xe=160;export{we 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 t}from"../../../core/maybe.js";import{isArrayBuffer as r}from"../../../core/typedArrayUtil.js";import{c as e}from"../../../chunks/quat.js";import{c as a}from"../../../chunks/quatf32.js";import{q as o}from"../../../chunks/vec3.js";import{f,c as n}from"../../../chunks/vec3f32.js";import{projectBuffer as s}from"../../../geometry/projection.js";import i from"../../../geometry/SpatialReference.js";import{readGeometry as u,getAttributeValues as l,evaluateRenderer as b,filterInPlace as m}from"./i3s/PointCloudWorkerUtil.js";class c{transform(e){const a=this._transform(e),o=[a.points.buffer,a.rgb.buffer];t(a.pointIdFilterMap)&&o.push(a.pointIdFilterMap.buffer);for(const t of a.attributes)"buffer"in t.values&&r(t.values.buffer)&&t.values.buffer!==a.rgb.buffer&&o.push(t.values.buffer);return Promise.resolve({result:a,transferList:o})}_transform(r){const e=u(r.schema,r.geometryBuffer);let a=e.length/3,o=null;const f=[],n=l(r.primaryAttributeData,e,a);t(r.primaryAttributeData)&&n&&f.push({attributeInfo:r.primaryAttributeData.attributeInfo,values:n});const s=l(r.modulationAttributeData,e,a);t(r.modulationAttributeData)&&s&&f.push({attributeInfo:r.modulationAttributeData.attributeInfo,values:s});let c=b(r.rendererInfo,n,s,a);if(r.filterInfo&&r.filterInfo.length>0&&t(r.filterAttributesData)){const t=r.filterAttributesData.map((t=>{const r=l(t,e,a),o={attributeInfo:t.attributeInfo,values:r};return f.push(o),o}));o=new Uint32Array(a),a=m(e,c,o,r.filterInfo,t)}for(const t of r.userAttributesData){const r=l(t,e,a);f.push({attributeInfo:t.attributeInfo,values:r})}3*a<c.length&&(c=new Uint8Array(c.buffer.slice(0,3*a))),this._applyElevationOffsetInPlace(e,a,r.elevationOffset);const p=this._transformCoordinates(e,a,r.obb,i.fromJSON(r.inSR),i.fromJSON(r.outSR));return{obb:r.obb,points:p,rgb:c,attributes:f,pointIdFilterMap:o}}_transformCoordinates(t,r,a,i,u){if(!s(t,i,0,t,u,0,r))throw new Error("Can't reproject");const l=f(a.center[0],a.center[1],a.center[2]),b=n(),m=n();e(p,a.quaternion);const c=new Float32Array(3*r);for(let e=0;e<r;e++)b[0]=t[3*e]-l[0],b[1]=t[3*e+1]-l[1],b[2]=t[3*e+2]-l[2],o(m,b,p),a.halfSize[0]=Math.max(a.halfSize[0],Math.abs(m[0])),a.halfSize[1]=Math.max(a.halfSize[1],Math.abs(m[1])),a.halfSize[2]=Math.max(a.halfSize[2],Math.abs(m[2])),c[3*e]=b[0],c[3*e+1]=b[1],c[3*e+2]=b[2];return c}_applyElevationOffsetInPlace(t,r,e){if(0!==e)for(let a=0;a<r;a++)t[3*a+2]+=e}}const p=a();function h(){return new c}export{h as default};
5
+ import{isSome as t}from"../../../core/maybe.js";import{isArrayBuffer as r}from"../../../core/typedArrayUtil.js";import{c as e}from"../../../chunks/quat.js";import{c as a}from"../../../chunks/quatf32.js";import{q as o}from"../../../chunks/vec3.js";import{f,c as i}from"../../../chunks/vec3f32.js";import{projectBuffer as n}from"../../../geometry/projection.js";import s from"../../../geometry/SpatialReference.js";import{readGeometry as u,getAttributeValues as l,evaluateRenderer as b,filterInPlace as m}from"./i3s/PointCloudWorkerUtil.js";class c{transform(e){const a=this._transform(e),o=[a.points.buffer,a.rgb.buffer];t(a.pointIdFilterMap)&&o.push(a.pointIdFilterMap.buffer);for(const t of a.attributes)"buffer"in t.values&&r(t.values.buffer)&&t.values.buffer!==a.rgb.buffer&&o.push(t.values.buffer);return Promise.resolve({result:a,transferList:o})}_transform(r){const e=u(r.schema,r.geometryBuffer);let a=e.length/3,o=null;const f=[],i=l(r.primaryAttributeData,e,a);t(r.primaryAttributeData)&&i&&f.push({attributeInfo:r.primaryAttributeData.attributeInfo,values:i});const n=l(r.modulationAttributeData,e,a);t(r.modulationAttributeData)&&n&&f.push({attributeInfo:r.modulationAttributeData.attributeInfo,values:n});let c=b(r.rendererInfo,i,n,a);if(r.filterInfo&&r.filterInfo.length>0&&t(r.filterAttributesData)){const i=r.filterAttributesData.filter(t).map((t=>{const r=l(t,e,a),o={attributeInfo:t.attributeInfo,values:r};return f.push(o),o}));o=new Uint32Array(a),a=m(e,c,o,r.filterInfo,i)}for(const t of r.userAttributesData){const r=l(t,e,a);f.push({attributeInfo:t.attributeInfo,values:r})}3*a<c.length&&(c=new Uint8Array(c.buffer.slice(0,3*a))),this._applyElevationOffsetInPlace(e,a,r.elevationOffset);const p=this._transformCoordinates(e,a,r.obb,s.fromJSON(r.inSR),s.fromJSON(r.outSR));return{obb:r.obb,points:p,rgb:c,attributes:f,pointIdFilterMap:o}}_transformCoordinates(t,r,a,s,u){if(!n(t,s,0,t,u,0,r))throw new Error("Can't reproject");const l=f(a.center[0],a.center[1],a.center[2]),b=i(),m=i();e(p,a.quaternion);const c=new Float32Array(3*r);for(let e=0;e<r;e++)b[0]=t[3*e]-l[0],b[1]=t[3*e+1]-l[1],b[2]=t[3*e+2]-l[2],o(m,b,p),a.halfSize[0]=Math.max(a.halfSize[0],Math.abs(m[0])),a.halfSize[1]=Math.max(a.halfSize[1],Math.abs(m[1])),a.halfSize[2]=Math.max(a.halfSize[2],Math.abs(m[2])),c[3*e]=b[0],c[3*e+1]=b[1],c[3*e+2]=b[2];return c}_applyElevationOffsetInPlace(t,r,e){if(0!==e)for(let a=0;a<r;a++)t[3*a+2]+=e}}const p=a();function h(){return new c}export{h as default};