@arcgis/core 6.0.0-next.56 → 6.0.0-next.57
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.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/00c227bcecc28fe278bb.js +1 -0
- package/assets/esri/core/workers/chunks/{88df1b8b295d3aed649f.js → 10499abb7678e95d9f05.js} +1 -1
- package/assets/esri/core/workers/chunks/1afc8820c283ef785729.js +1 -0
- package/assets/esri/core/workers/chunks/1c874f86bfd0963aa3d2.js +1 -0
- package/assets/esri/core/workers/chunks/2a84c9a81ec2bed3d4e5.js +1 -0
- package/assets/esri/core/workers/chunks/2f31766bc0f9d1d70c5a.js +1 -0
- package/assets/esri/core/workers/chunks/35109db6a6be66f895f7.js +1 -0
- package/assets/esri/core/workers/chunks/373b140f92eda3857f82.js +1 -0
- package/assets/esri/core/workers/chunks/38bba952c38af5a150e7.js +1 -0
- package/assets/esri/core/workers/chunks/3aea09191b737dc1de70.js +1 -0
- package/assets/esri/core/workers/chunks/3fc4b7d0ee460fc96176.js +1 -0
- package/assets/esri/core/workers/chunks/457bd1bd37c67b61efe8.js +1 -0
- package/assets/esri/core/workers/chunks/601d668e70c5d72fe58c.js +1 -0
- package/assets/esri/core/workers/chunks/651e33be8bb3995d749f.js +1 -0
- package/assets/esri/core/workers/chunks/721f43554b9654481de7.js +1 -0
- package/assets/esri/core/workers/chunks/75274ac3ddf7c45f47d7.js +1 -0
- package/assets/esri/core/workers/chunks/80d1267606383ae537f2.js +1 -0
- package/assets/esri/core/workers/chunks/8920d0b11951b57d6a66.js +1 -0
- package/assets/esri/core/workers/chunks/92d97e0fcc20dd5f5ac4.js +1 -0
- package/assets/esri/core/workers/chunks/9ca84fa9423654061d05.js +1 -0
- package/assets/esri/core/workers/chunks/9e372af03d62fa5ad10e.js +1 -0
- package/assets/esri/core/workers/chunks/b10c534cbe311d17b7d5.js +1 -0
- package/assets/esri/core/workers/chunks/{dfa1b0308e5e82d1ddfe.js → be0133fa63c5d6545a7f.js} +1 -1
- package/assets/esri/core/workers/chunks/cb0e3614b78c78040662.js +1 -0
- package/assets/esri/core/workers/chunks/d22e3b5d836dffdf91cc.js +1 -0
- package/assets/esri/core/workers/chunks/e0341def2d81e679a200.js +1 -0
- package/assets/esri/core/workers/chunks/e42e9dd3c933f5f864ab.js +1 -0
- package/assets/esri/core/workers/chunks/f4fcf87da4495584223d.js +1 -0
- package/assets/esri/core/workers/chunks/f989588dfdbb69056491.js +1 -0
- package/assets/esri/core/workers/chunks/fc5b920f9756e11c2f88.js +1 -0
- package/chunks/Component.glsl.js +1 -0
- package/chunks/GlobalIllumination.glsl.js +12 -11
- package/chunks/GlobalIlluminationBlur.glsl.js +6 -4
- package/chunks/Terrain.glsl.js +24 -23
- package/chunks/Water.glsl.js +24 -23
- package/config.js +1 -1
- package/core/memoryEstimations.js +1 -1
- package/interfaces.d.ts +0 -1
- package/kernel.js +1 -1
- package/layers/LinkChartLayer.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/dehydratedFeatures.js +1 -1
- package/layers/graphics/transferFeatures.js +1 -1
- package/layers/support/fieldUtils.d.ts +129 -57
- package/layers/support/fieldUtils.js +1 -1
- package/networks/Network.js +1 -1
- package/networks/support/TopologyValidationJobInfo.js +1 -1
- package/package.json +2 -2
- package/views/3d/GroundView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
- package/views/3d/layers/support/Tiles3DBVH.js +1 -1
- package/views/3d/layers/support/Tiles3DMeshIntersectionHandler.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/support/GroundAndIMSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectFixedBVH.js +1 -1
- package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/lastFrameUniforms.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +15 -12
- package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
- package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationBlur.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/globalIllumination/globalIlluminationUniforms.js +1 -1
- package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/TriangleIntersectionData.js +1 -1
- package/views/3d/webgl-engine/materials/Water.glsl.js +1 -1
- package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/WaterTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/materials/getWaterColor.glsl.js +89 -0
- package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
- package/assets/esri/core/workers/chunks/193a73a2c7f4f8482c21.js +0 -1
- package/assets/esri/core/workers/chunks/20acb6f3ed5140b6c6c6.js +0 -1
- package/assets/esri/core/workers/chunks/2d4788be418a4e5f6606.js +0 -1
- package/assets/esri/core/workers/chunks/333140b18aeb5a50b654.js +0 -1
- package/assets/esri/core/workers/chunks/4761cd436abceee858bf.js +0 -1
- package/assets/esri/core/workers/chunks/4de08ead94660025075b.js +0 -1
- package/assets/esri/core/workers/chunks/56f227e1a9e51d1fd742.js +0 -1
- package/assets/esri/core/workers/chunks/5bd451c7db17ee8f0315.js +0 -1
- package/assets/esri/core/workers/chunks/5c34d49a6c9cc34b7626.js +0 -1
- package/assets/esri/core/workers/chunks/62ddd3a82864e26f009a.js +0 -1
- package/assets/esri/core/workers/chunks/703373f529c1c334cfad.js +0 -1
- package/assets/esri/core/workers/chunks/733c32d8091427d84de7.js +0 -1
- package/assets/esri/core/workers/chunks/860552f49f17de2f3353.js +0 -1
- package/assets/esri/core/workers/chunks/9b727f45dfea84357b57.js +0 -1
- package/assets/esri/core/workers/chunks/a05a2c2aaf0c288f9681.js +0 -1
- package/assets/esri/core/workers/chunks/ab76170c374fd67ce8cd.js +0 -1
- package/assets/esri/core/workers/chunks/aebd12488b4004e207a3.js +0 -1
- package/assets/esri/core/workers/chunks/c7b1c6d57603fa385c54.js +0 -1
- package/assets/esri/core/workers/chunks/cd8181600623e18f511c.js +0 -1
- package/assets/esri/core/workers/chunks/cef537fa9705dd1cf685.js +0 -1
- package/assets/esri/core/workers/chunks/d33403d578fbeecaf844.js +0 -1
- package/assets/esri/core/workers/chunks/ddbfa664e69612295785.js +0 -1
- package/assets/esri/core/workers/chunks/ded81c504bf44806ca7d.js +0 -1
- package/assets/esri/core/workers/chunks/e0466387b2ab54d706ca.js +0 -1
- package/assets/esri/core/workers/chunks/ee70be138831cc2a0f56.js +0 -1
- package/assets/esri/core/workers/chunks/efd6ea0966f60ab19520.js +0 -1
- package/assets/esri/core/workers/chunks/f23c4fd014126ea7abc6.js +0 -1
- package/assets/esri/core/workers/chunks/f6e40f3faf0c80cf1b3a.js +0 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterColor.glsl.js +0 -70
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/core",
|
|
3
|
-
"version": "6.0.0-next.
|
|
3
|
+
"version": "6.0.0-next.57",
|
|
4
4
|
"description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ArcGIS",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@amcharts/amcharts5": "~5.25.0",
|
|
23
|
-
"@arcgis/toolkit": "6.0.0-next.
|
|
23
|
+
"@arcgis/toolkit": "6.0.0-next.57",
|
|
24
24
|
"@esri/arcgis-html-sanitizer": "~4.2.0",
|
|
25
25
|
"@esri/calcite-components": "^5.2.2",
|
|
26
26
|
"@vaadin/grid": "~25.3.7",
|
package/views/3d/GroundView3D.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{property as t}from"../../core/accessorSupport/decorators/property.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{EventedMixin as r}from"../../core/Evented.js";import{when as i,watch as a,syncAndInitial as o}from"../../core/reactiveUtils.js";import{create as s,equals as c,intersection as l,union as u}from"../../geometry/support/aaBoundingRect.js";import{IntegratedMeshSemantics as d}from"../../layers/support/IntegratedMeshSemantics.js";import f from"../GroundView.js";import{isIntegratedMeshLayerView as p}from"../support/layerViewUtils.js";import{noBudget as m}from"../support/Scheduler.js";import{ElevationRange as h}from"./support/ElevationRange.js";import{toBoundingRect as g}from"./support/extentUtils.js";import{webMercatorWorldExtent as _,geographicWorldExtent as v}from"./terrain/TerrainConst.js";const y=Symbol(`integrated-mesh-elevation-providers`);let b=class extends r(f){initialize(){super.initialize(),this.addHandles(i(()=>this._terrainSurface,e=>e.on(`elevation-change`,e=>this._elevationChange(e)))),a(()=>this._integratedMeshGroundLayerViews,()=>{this.removeHandles(y),this.addHandles(this._integratedMeshGroundLayerViews.map(({elevationProvider:e})=>e.on(`elevation-change`,e=>this._elevationChange(e))),y)},o),this.addHandles([a(()=>this.memoizedElevationQueryDependencies,()=>{this.emit(`elevation-query-change`)})])}get memoizedElevationQueryDependencies(){return(this.ground?.allLayers??[]).filter(e=>e.type===`elevation`||e.type===`integrated-mesh`||e.type===`integrated-mesh-3dtiles`&&e.replacesTerrain).map(e=>e.memoizedElevationQueryDependencies)}_elevationChange(e){this.emit(`elevation-change`,e)}get _integratedMeshGroundLayerViews(){return[...this.view?.basemapView?.groundLayerViews.filter(p).filter(e=>d.shouldRegisterGroundElevationProvider(!1,e.replacesTerrain))??[],...this.layerViews.filter(p).filter(e=>d.shouldRegisterGroundElevationProvider(!0,e.replacesTerrain))]}get _terrainSurface(){return this.view.basemapTerrain}get _usingTerrain(){return!this.hasTerrainReplacement&&(this._terrainSurface?.enabled??!1)}get spatialReference(){return this._terrainSurface?.spatialReference}get userClippingExtent(){let{spatialReference:e}=this,{clippingArea:t}=this.view;if(t==null||e==null)return null;let n=s(),r=g(t,n,e)?n:null,i=this._get(`userClippingExtent`);return c(r,i)?i:r}isUpdating(){return this._usingTerrain&&this._terrainSurface.updating||super.isUpdating()}getElevation(e,t,n,r){let i=this._usingTerrain?this._terrainSurface?.getElevation(e,t,n,r):null;return this._integratedMeshGroundLayerViews.reduce((i,a)=>{let o=a.elevationProvider.getElevation(e,t,n,r);return o==null?i:Math.max(o,i??o)},i)}getElevations(e,t,n){let r=this.view.groundSpatialReference;if(r==null)for(let e=0;e<t;++e)n(e,null);else for(let i=0;i<t;++i){let t=i*3;n(i,this.getElevation(e[t],e[t+1],e[t+2],r))}}intersect(e,t,n,r){this.intersectBudgeted(e,t,n,r,m)}intersectBudgeted(e,t,n,r,i){return this._usingTerrain&&!this._terrainSurface.intersectBudgeted(e,t,n,r,i)?!1:
|
|
2
|
+
import{__decorate as e}from"tslib";import{property as t}from"../../core/accessorSupport/decorators/property.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{EventedMixin as r}from"../../core/Evented.js";import{when as i,watch as a,syncAndInitial as o}from"../../core/reactiveUtils.js";import{create as s,equals as c,intersection as l,union as u}from"../../geometry/support/aaBoundingRect.js";import{IntegratedMeshSemantics as d}from"../../layers/support/IntegratedMeshSemantics.js";import f from"../GroundView.js";import{isIntegratedMeshLayerView as p}from"../support/layerViewUtils.js";import{noBudget as m}from"../support/Scheduler.js";import{ElevationRange as h}from"./support/ElevationRange.js";import{toBoundingRect as g}from"./support/extentUtils.js";import{webMercatorWorldExtent as _,geographicWorldExtent as v}from"./terrain/TerrainConst.js";const y=Symbol(`integrated-mesh-elevation-providers`);let b=class extends r(f){initialize(){super.initialize(),this.addHandles(i(()=>this._terrainSurface,e=>e.on(`elevation-change`,e=>this._elevationChange(e)))),a(()=>this._integratedMeshGroundLayerViews,()=>{this.removeHandles(y),this.addHandles(this._integratedMeshGroundLayerViews.map(({elevationProvider:e})=>e.on(`elevation-change`,e=>this._elevationChange(e))),y)},o),this.addHandles([a(()=>this.memoizedElevationQueryDependencies,()=>{this.emit(`elevation-query-change`)})])}get memoizedElevationQueryDependencies(){return(this.ground?.allLayers??[]).filter(e=>e.type===`elevation`||e.type===`integrated-mesh`||e.type===`integrated-mesh-3dtiles`&&e.replacesTerrain).map(e=>e.memoizedElevationQueryDependencies)}_elevationChange(e){this.emit(`elevation-change`,e)}get _integratedMeshGroundLayerViews(){return[...this.view?.basemapView?.groundLayerViews.filter(p).filter(e=>d.shouldRegisterGroundElevationProvider(!1,e.replacesTerrain))??[],...this.layerViews.filter(p).filter(e=>d.shouldRegisterGroundElevationProvider(!0,e.replacesTerrain))]}get _terrainSurface(){return this.view.basemapTerrain}get _usingTerrain(){return!this.hasTerrainReplacement&&(this._terrainSurface?.enabled??!1)}get spatialReference(){return this._terrainSurface?.spatialReference}get userClippingExtent(){let{spatialReference:e}=this,{clippingArea:t}=this.view;if(t==null||e==null)return null;let n=s(),r=g(t,n,e)?n:null,i=this._get(`userClippingExtent`);return c(r,i)?i:r}isUpdating(){return this._usingTerrain&&this._terrainSurface.updating||super.isUpdating()}getElevation(e,t,n,r){let i=this._usingTerrain?this._terrainSurface?.getElevation(e,t,n,r):null;return this._integratedMeshGroundLayerViews.reduce((i,a)=>{let o=a.elevationProvider.getElevation(e,t,n,r);return o==null?i:Math.max(o,i??o)},i)}getElevations(e,t,n){let r=this.view.groundSpatialReference;if(r==null)for(let e=0;e<t;++e)n(e,null);else for(let i=0;i<t;++i){let t=i*3;n(i,this.getElevation(e[t],e[t+1],e[t+2],r))}}intersect(e,t,n,r){this.intersectBudgeted(e,t,n,r,m)}intersectBudgeted(e,t,n,r,i){return this._usingTerrain&&!this._terrainSurface.intersectBudgeted(e,t,n,r,i)?!1:this._integratedMeshGroundLayerViews.every(a=>a.intersect(e,t,n,r,i))}getSphereElevationRange(e,t,n){let r=this._usingTerrain?this._terrainSurface?.getSphereElevationRange?.(e,t):null;return this._integratedMeshGroundLayerViews.reduce((n,r)=>{let i=r.elevationProvider.getSphereElevationRange?.(e,t);return i==null||(n??=new h,n.expandElevationRange(i)),n},r?new h(r.minElevation,r.maxElevation):null)}getRootElevationRange(){let e=this._usingTerrain?this._terrainSurface?.getRootElevationRange?.():null;return this._integratedMeshGroundLayerViews.reduce((e,t)=>{let n=t.elevationProvider.getRootElevationRange?.();return n==null||(e??=new h,e.expandElevationRange(n)),e},e?new h(e.minElevation,e.maxElevation):null)}get elevationQueryCache(){let e=this.view?.basemapTerrain;return e?.enabled?e.elevationQueryCache:null}get elevationQueryReady(){for(let e of this.ground?.allLayers??[])if(e.type===`integrated-mesh-3dtiles`&&e.replacesTerrain&&e.loadStatus!==`failed`&&e.queryElevationCallback==null)return!1;return!0}get groundExtent(){let{fullGroundExtent:e}=this;return e?this.userClippingExtent?l(e,this.userClippingExtent,s()):this.fullGroundExtent:null}get fullGroundExtent(){let e=this._usingTerrain?this._terrainSurface.fullGroundExtent:null;if(this._integratedMeshGroundLayerViews.length===0)return e;let t=this.view.spatialReference;if(!t.isWebMercator&&!t.isWGS84)return e;let n=S(t);return e?u(e,n,s()):n}get visibleElevationRange(){let e=this._usingTerrain?this._terrainSurface.visibleElevationRange:null,t=this._integratedMeshGroundLayerViews.reduce((e,t)=>e==null?new h(t.visibleElevationRange.minElevation,t.visibleElevationRange.maxElevation):(e.expandElevationRange(t.visibleElevationRange),e),e?new h(e.minElevation,e.maxElevation):null);return t&&!t.isEmpty?t:x}get opaque(){return this._usingTerrain&&this._terrainSurface.opaque||this._integratedMeshGroundLayerViews.some(({opaque:e})=>e)}get invisible(){return(!this._usingTerrain||this._terrainSurface.invisible)&&this._integratedMeshGroundLayerViews.every(({invisible:e})=>e)}get baseOpacity(){return this.ground?.opacity??1}get wireframe(){return this._usingTerrain?this._terrainSurface?.wireframe??!1:!1}get freeze(){return this._usingTerrain&&(this._terrainSurface?.freeze??!1)||this._integratedMeshGroundLayerViews.some(e=>e.type===`integrated-mesh-3dtiles`&&e.freeze)}set freeze(e){this._usingTerrain&&(this._terrainSurface.freeze=e),this._integratedMeshGroundLayerViews.forEach(t=>{t.type===`integrated-mesh-3dtiles`&&(t.freeze=e)})}get suspended(){return(!this._usingTerrain||super.suspended)&&this._integratedMeshGroundLayerViews.length>0&&this._integratedMeshGroundLayerViews.every(({suspended:e})=>e)}get ready(){return!this._usingTerrain&&this._integratedMeshGroundLayerViews.length===0?!1:(!this._usingTerrain||this._terrainSurface.ready)&&this._integratedMeshGroundLayerViews.every(({ready:e})=>e)}updateOverlayParameters(){this._terrainSurface?.updateOverlayParameters()}requestRender(e){this.view.stage.renderView?.requestRender(e)}};e([t()],b.prototype,`memoizedElevationQueryDependencies`,null),e([t({readOnly:!0})],b.prototype,`_integratedMeshGroundLayerViews`,null),e([t({readOnly:!0})],b.prototype,`_terrainSurface`,null),e([t({readOnly:!0})],b.prototype,`_usingTerrain`,null),e([t({readOnly:!0})],b.prototype,`spatialReference`,null),e([t({readOnly:!0})],b.prototype,`userClippingExtent`,null),e([t({readOnly:!0})],b.prototype,`elevationQueryCache`,null),e([t()],b.prototype,`elevationQueryReady`,null),e([t({readOnly:!0})],b.prototype,`groundExtent`,null),e([t({readOnly:!0})],b.prototype,`fullGroundExtent`,null),e([t({readOnly:!0})],b.prototype,`visibleElevationRange`,null),e([t({readOnly:!0})],b.prototype,`opaque`,null),e([t({readOnly:!0})],b.prototype,`invisible`,null),e([t({readOnly:!0})],b.prototype,`baseOpacity`,null),e([t({readOnly:!0})],b.prototype,`wireframe`,null),e([t()],b.prototype,`freeze`,null),e([t({readOnly:!0})],b.prototype,`suspended`,null),e([t({readOnly:!0})],b.prototype,`ready`,null),b=e([n(`esri.views.3d.GroundView3D`)],b);const x=new h(0,0);function S(e){return e.isWebMercator?_:v}export{b as GroundView3D};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../Color.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{removeUnordered as i,isSome as a}from"../../../core/arrayUtils.js";import has from"../../../core/has.js";import{fromMat4 as o,exactEquals as s,invert as c}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as l,IDENTITY as u}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as d,getTranslation as f}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as p,create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as h}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{set as g,transformMat4 as _,transformMat3 as v,sub as ee,add as y,scale as te,subtract as ne}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as x}from"../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as re}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import S from"../../../core/Logger.js";import{equals as C}from"../../../core/MapUtils.js";import{destroyMaybe as w}from"../../../core/maybe.js";import T from"../../../core/PooledArray.js";import{ignoreAbortErrors as ie,throwIfAborted as E,isAbortError as D}from"../../../core/promiseUtils.js";import{initial as O,watch as k}from"../../../core/reactiveUtils.js";import{schedule as ae}from"../../../core/scheduling.js";import{equals as oe}from"../../../core/SetUtils.js";import{UpdatingHandles as A}from"../../../core/support/UpdatingHandles.js";import{isArrayBuffer as j}from"../../../core/typedArrayUtil.js";import{localLinearScaleFactors as se}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as ce}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as M}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as le}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as N}from"../../../geometry/projection/projectVectorToVector.js";import{getSphericalPCPF as ue}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{create as P,fromBuffer as de,toRect as fe}from"../../../geometry/support/aaBoundingBox.js";import{create as F,intersects as pe}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as I,ensurePackedMat4f64 as L}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as me}from"../../../geometry/support/FloatArray.js";import{compactIndices as he}from"../../../geometry/support/Indices.js";import{Sphere as R}from"../../../geometry/support/sphere.js";import{newUByteArray as z}from"../../../geometry/support/UByteArray.js";import B from"../../../Graphic.js";import V from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fallbackObjectIDAttribute as ge}from"../../../layers/LayerConstants.js";import{fixFields as _e}from"../../../layers/support/fieldUtils.js";import{I3SExtractChanges as ve}from"../../../layers/support/I3SExtractChanges.js";import{IntegratedMeshSemantics as H}from"../../../layers/support/IntegratedMeshSemantics.js";import ye from"../../../layers/support/SceneModification.js";import{getColor as be,getOpacity as xe}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{isBasemapLayerView as U}from"../../../support/basemapUtils.js";import{getElevationOffset as W}from"../../../support/elevationInfoUtils.js";import{loadArcade as Se}from"../../../support/loadArcade.js";import G from"../../../symbols/MeshSymbol3D.js";import Ce from"../../../symbols/SimpleFillSymbol.js";import{alphaCutoff as we}from"../../../webscene/support/AlphaCutoff.js";import{getHighlightName as Te}from"../../support/highlightOptionsUtils.js";import{TextureCompressionTracker as Ee}from"../../support/TextureCompressionTracker.js";import{glLayout as De}from"../support/buffer/glUtil.js";import{debugFlags as K}from"../support/debugFlags.js";import{ElevationRange as q}from"../support/ElevationRange.js";import{toBoundingRect as Oe}from"../support/extentUtils.js";import{Obb as J,ensurePackedObbData as ke}from"../support/orientedBoundingBox.js";import{updatingProgress as Ae}from"../support/updatingProperties.js";import{ObjectParameters as je}from"../webgl-engine/collections/Component/ObjectParameters.js";import{createVertexBufferLayout as Me,ComponentGeometryParameters as Ne,SourceGeometry as Pe,VertexBufferLayoutCreationParameters as Fe}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as Ie}from"../webgl-engine/collections/Component/Transform.js";import{emissiveStrengthDefault as Le}from"../webgl-engine/core/shaderLibrary/output/getEmissions.glsl.js";import{ContentGeometryUpdateEvent as Re}from"./ContentGeometryLayerView.js";import{overrideColor as ze}from"./graphics/graphicUtils.js";import{areLabelsVisible as Be}from"./graphics/Labeler.js";import Ve from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as He}from"./i3s/I3SAsyncElevationUpdater.js";import{getCachedAttributeValue as Ue}from"./i3s/I3SBinaryReader.js";import{I3SCrossfadeHelper as We,NodeCrossfadeMetaData as Ge}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as Ke}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as qe,TraversedIntersectionNode as Je}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Ye,selectEncoding as Xe,defaultMaterial as Ze,createTexture as Qe,configureMaterial as $e}from"./i3s/I3SMaterialUtil.js";import{I3SOverrides as et}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as tt}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as nt,checkSceneLayerValid as rt,checkSceneLayerCompatibleWithView as it,whenGraphicAttributes as at,projectVisibilityModifications as ot,computeVisibilityObb as st,filterInPlace as ct,intersectBoundingRectWithMbs as lt,addWraparound as ut,getSymbolInfo as dt,transparentEdgeMaterial as Y,getClipRect as ft}from"./i3s/I3SUtil.js";import{IDBCache as pt}from"./i3s/IDBCache.js";import{IDBMockCache as mt}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as ht}from"./i3s/LayerElevationProvider.js";import{SymbologyInfo as gt}from"./i3s/SymbologyInfo.js";import _t from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as vt}from"./I3SMeshViewPerformanceInfo.js";import{initialize as yt,setModificationsSync as bt,filterObbsForModificationsSync as xt,interpretObbModificationResults as St}from"./SceneLayerWorker.js";import{SceneLayerWorkerHandle as Ct,toWasmModification as wt}from"./SceneLayerWorkerHandle.js";import{attributeLookup as Tt}from"./support/attributeUtils.js";import{normalizeHighlightTarget as Et,emptyHighlightHandle as Dt}from"./support/highlightUtils.js";import{makeScheduleFunction as Ot}from"./support/makeScheduleFunction.js";const kt=[1,1,1,1];class At extends Ge{constructor(e,t,n,r,i,a,o,s,c,l,u){super(),this.node=e,this.featureIds=t,this.objectHandle=n,this.cachedRendererVersion=r,this.attributeInfo=i,this.material=a,this.textures=o,this.anchorIds=s,this.anchors=c,this._elevationAlignmentRange=new q,this._geometryElevationRange=new q,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=[],this.edgeMemoryUsage=0,this.cachedSymbologyStride=5,this.elevationAlignmentOffset=0,this._baseGeometryElevationRange=new q(l,u),this.updateGeometryElevationRange()}get geometryElevationRange(){return this._geometryElevationRange}updateGeometryElevationRange(){let e=this._baseGeometryElevationRange;if(!e.elevationRangeValid||e.isEmpty){this._elevationAlignmentRange.invalidateElevationRange(),this._geometryElevationRange.invalidateElevationRange();return}let t=this.elevationOffsets;if(!t||t.length===0){let t=this.elevationAlignmentOffset;this._elevationAlignmentRange.setElevationRangeValues(t,t),this._geometryElevationRange.setElevationRangeValues(e.minElevation+t,e.maxElevation+t);return}let n=1/0,r=-1/0;for(let e=0;e<t.length;++e){let i=this.elevationAlignmentOffset+(t[e]??0);n=Math.min(n,i),r=Math.max(r,i)}this._elevationAlignmentRange.setElevationRangeValues(n,r),this._geometryElevationRange.setElevationRangeValues(e.minElevation+n,e.maxElevation+r)}get usedMemory(){return this.node.memory}get featureExtents(){return this._featureExtents??=new Float64Array(6*this.featureIds.length).fill(1/0),this._featureExtents}}const jt=t=>{let j=t,R=class extends j{constructor(){super(...arguments),this._extractChanges=null,this._applySSAO=!0,this._imShading=!!has(`enable-feature:im-shading`),this._imVertexNormals=!!has(`enable-feature:im-vertex-normals`),this._updatingHandles=new A,this._highlights=null,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._compressionTracker=new Ee,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._hasComponentData=!1,this._hasVertexColors=!1,this._nodeColorOverride=null,this.updating=!0,this.holeFilling=`auto`,this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=[],this._visibilityModifications=null,this.ignoresMemoryFactor=!1,this._layerUrl=``,this._cacheKeySuffix=null,this._meshUtilsImporterModule=null,this._meshUtilsImporterPromise=null,this._planetRadiusInGlobalMode=0,this._elevationTask=null,this._needFilterResolve=!1,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new B,this._crossfadeHelper=new We(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get extractChanges(){return this._extractChanges?.layer!==this.layer&&(this._extractChanges?.destroy(),this._extractChanges=new ve({layer:this.layer})),this._extractChanges}get layerViewUid(){return this.uid}get layerId(){return this.layer.id}get sublayerId(){return null}get _isIntegratedMesh(){return this.layer.type===`integrated-mesh`}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible&&this.fullOpacity>=we}get legendEnabled(){return this.contentVisible&&this.layer?.legendEnabled===!0}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?`yes`:`probably-not`:`unknown`}get rendererTextureUsage(){return nt(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?63:53:this._usePBR||this._hasLoadedPBRTextures?44:36}get elevationOffset(){let e=this.layer?.elevationInfo;return e?.mode===`absolute-height`?W(e,this.layer.spatialReference):0}get elevationInfo(){let e=this.layer?.elevationInfo;switch(e?.mode){case`absolute-height`:return new Z(0,W(e,this.layer.spatialReference));case`relative-to-ground`:return new Z(1,W(e,this.layer.spatialReference));case`on-the-ground`:return new Z(2,0);default:return new Z(0,0)}}get supportedTextureEncodings(){return Ye(this.view.stage.renderView.capabilities)}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){let e=this._nodeId2Meta,t=new q;for(let n of e.values()){let e=n?.geometryElevationRange;e?.elevationRangeValid&&!e.isEmpty&&t.expandElevationRange(e)}return t.elevationRangeValid&&!t.isEmpty?t:null}get fullExtent(){return this.layer.fullExtent}initialize(){let e=has(`enable-feature:idb-mock-cache`);this._idbCache=e?new mt(this.view,e):new pt(`esri-scenelayer-cache`,`geometries`),this.addResolvingPromise(this.layer.indexInfo);let t=this.view.resourceController,n=t.memoryController;this.i3sOverrides=new et({view:this.view,layer:this.layer,memoryController:n,extractChanges:this.extractChanges}),this._workerHandle=new Ct(Ot(t)),this.addResolvingPromise(this._workerHandle.promise),rt(this.layer),it(this.layer,this.view);let r=this.layer.store.defaultGeometrySchema;if(this.addResolvingPromise(this._workerHandle.setLegacySchema(this.uid,r).catch(ie)),this._layerUrl=this.layer.parsedUrl.path,this._controller=new V({layerView:this,worker:this._workerHandle}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view.stage,this._collection=this._stage.renderView.componentObjectCollection,this._isIntegratedMesh||!r)this._hasComponentData=!1;else{let e=r.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=(r?.vertexAttributes.color??null)!=null&&!this.layer.cachedDrawingInfo?.color;let i=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,e=>this._deleteComponentObject(e));this._memCache=i;let a=this._controller,o=this._nodeId2Meta,s=this._nodeId2MetaReloading;function*c(e){let t=a.index;if(!t)return;let n=t.rootNode;if(!n)return;let r=null;for(let i of t.traverseValues(n,t=>(r=(o.get(t.index)||s.get(t.index))?.objectHandle??null,e(t,r))))yield new Je(i,r)}this._intersectionHandler=new qe({layerViewUid:this.layerViewUid,sublayerId:this.sublayerId,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,integratedMeshSemantics:new H(this.layer),traverseNodeHierarchy:c}),this._elevationProvider=new ht({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add(()=>this.view.clippingArea,()=>this._clippingAreaChanged(),O),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),O),this._updatingHandles.add(()=>!this.suspended&&this.elevationInfo.mode!==0,(e,t)=>{e?this.addHandles(this.view.groundView.on(`elevation-change`,({extent:e})=>this._ensureElevationTask().addExtent(e)),Kt):t&&this.removeHandles(Kt)},O),this._updatingHandles.add(()=>this._usePBR,e=>this._updatePBR(e)),this._updatingHandles.add(()=>this.rendererTextureUsage,()=>{this._reloadAll(),this.clearMemCache()}),this._updatingHandles.add(()=>this.contentVisible,e=>this._contentVisibleChanged(e),O),this._updatingHandles.add(()=>this.layer.labelsVisible,()=>this._labelingChanged(),O),this._updatingHandles.add(()=>this.layer.labelingInfo,()=>this._labelingChanged(),O),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),O),this.addHandles([k(()=>K.I3S_TREE_SHOW_TILES,e=>{if(e&&!this._treeDebugger){let e=this._controller.crsIndex;import(`./support/I3STreeDebugger.js`).then(({I3STreeDebugger:t})=>{!this._treeDebugger&&K.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))})}else!e&&!K.I3S_TREE_SHOW_TILES&&(this._treeDebugger=w(this._treeDebugger))},O),k(()=>K.I3S_SHOW_MODIFICATIONS,()=>this._showModifications(),O)]),this._cacheKeySuffix=this._getCacheKeySuffix(),this._idbCache.init().catch(e=>S.getLogger(this).warn(`Failed to initialize IndexedDB cache: ${e}`));let{view:l}=this,{renderCoordsHelper:u}=l;this._planetRadiusInGlobalMode=l.state.isGlobal?u.referenceEllipsoid.radius:0}destroy(){this._clearAddTasks(),this._elevationTask=w(this._elevationTask),this.i3sOverrides=w(this.i3sOverrides),this._extractChanges=w(this._extractChanges),this._elevationProvider&&=(this._elevationProvider.notifyObjectsChanged(this.getVisibleObbs()),this.view.elevationProvider.unregister(this._elevationProvider),null),this._intersectionHandler&&=(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),null);let e=this._workerHandle;e&&(e.destroyContextAndSelf(this.uid),this._workerHandle=null),this._removeAllNodeDataFromStage(),this._memCache=w(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=w(this._labeler),this._treeDebugger=w(this._treeDebugger),this._controller=w(this._controller),this._highlights=w(this._highlights),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=w(this._crossfadeHelper),this.emit(`visible-geometry-changed`),this._visibleGeometryChangedSchedulerHandle&&=(this._visibleGeometryChangedSchedulerHandle.remove(),null),this._updatingHandles=w(this._updatingHandles)}_memEstimateTextureAdded(e){let t=e.usedMemory;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(e!=null){let t=e.usedMemory;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){let t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){let 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)}get usedMemory(){let e=this._labeler==null?0:this._labeler.usedMemory;return this._nodeId2Meta.forEach(t=>e+=t==null?0:t.node.memory),this._nodeId2MetaReloading.forEach(t=>e+=t==null?0:t.node.memory),e}get unloadedMemory(){return(this._controller==null?0:this._controller.unloadedMemoryEstimate)+(this._labeler==null?0:this._labeler.unloadedMemoryEstimate)}_labelingChanged(){if(!(Be(this.layer)&&this._supportsLabeling)){this._labeler!=null&&(this._labeler.destroy(),this._labeler=null);return}if(this._labeler!=null)return;let e=new _t({view:this.view,layer:this.layer,collection:this._collection,overrides:this.i3sOverrides,layerViewUid:this.uid});this._nodeId2Meta.forEach(t=>t!=null&&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._visibilityModifications=null,!this._i3sWasmLoaded&&this.hasModifications){this._i3sWasmLoaded=yt().then(()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()},()=>{}),this.notifyUpdate();return}if(this._i3sWasmLoaded!==!0)return;let e=e=>S.getLogger(this).error(`set-modifications-error`,`Error when setting modifications:`,e),t=this.uid,n=this.layer.spatialReference,r=n.isGeographic,i=wt(this._layerClippingArea,this._modifications,n,this.view.state.isGlobal);this._workerHandle.setModifications(t,i,r).catch(e);try{bt({context:t,modifications:i,isGeodetic:r})}catch(t){e(t)}this._controller.modificationsChanged();let a=this.hasModifications?new T:null;this._nodeId2Meta.forEach((e,t)=>{e==null?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._updateFeatureIdCounts(e,-1),this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):a?.push(e.node)}),this.notifyChange(`elevationRange`),a!=null&&this._nodeId2MetaReloading.forEach(e=>a.push(e.node)),a!=null&&a.length>0&&(this.updateNodeModificationStatus(a),a.forAll(e=>{if(e.imModificationImpact!==2){let t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),t==null?this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1)):(this._updateFeatureIdCounts(t,-1),this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t),this.notifyChange(`elevationRange`))}})),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(this._modificationGraphics!=null&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!K.I3S_SHOW_MODIFICATIONS||this._modifications.length===0)return;let e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={outline:{color:[255,255,255],width:1}};this._modificationGraphics=[];for(let n of this._modifications){let r=n.geometry;r.spatialReference=this.layer.spatialReference;let i=new Ce({...t,color:e[n.type]});this._modificationGraphics.push(new B({geometry:r,symbol:i}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,(e,t)=>this._createAttributes(e,t))}_contentVisibleChanged(e){e?(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler)):(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){let t=this._nodeId2Meta.get(e);if(t?.attributeInfo!=null)return t.attributeInfo.loadedAttributes}getAttributeData(e){let t=this._nodeId2Meta.get(e);if(t?.attributeInfo!=null)return t.attributeInfo.attributeData}setAttributeData(e,t){let n=this._nodeId2Meta.get(e);n?.attributeInfo!=null&&(n.attributeInfo.attributeData=t,this._attributeValuesChanged(n))}async updateAttributes(e,t,n){let r=this._nodeId2Meta.get(e);r!=null&&(await this.i3sOverrides.applyAttributeOverrides(r.featureIds,t,n,this._controller.requiredAttributes),E(n),r.attributeInfo=t,this._controller.reschedule(()=>{this._nodeId2Meta.get(e)===r&&this._attributeValuesChanged(r)},n).catch(e=>{D(e)||S.getLogger(this).warn(`Error while updating attribute values. Layer might not display correctly.`,e)}))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.appliedFilters=null,this._labeler!=null&&this._labeler.setNodeMetaAttributes(e,(e,t)=>this._createAttributes(e,t)),this._updateEngineObject(e)}clearMemCache(){this._memCache!=null&&this._memCache.clear(),this._addTasks.forEach(e=>e.allowMemCache=!1)}getVisibleNodes(){let e=[];return this._nodeId2Meta.forEach(t=>t!=null&&e.push(t.node)),e}getVisibleObbs(){let e=[];return this._nodeId2Meta.forEach(t=>t&&e.push(this._collection.getComponentObb(t.objectHandle))),e}getLoadedNodeIndices(e){this._nodeId2Meta.forEach((t,n)=>e.push(n)),this._nodeId2MetaReloading.forEach((t,n)=>e.push(n))}_getVertexBufferLayout(e,t){return De(Me(this._getGeometryParameters({hasTexture:Rt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion})))}_getObjectIdField(){return this.layer.objectIdField||ge}_getGlobalIdField(){return this.layer.globalIdField}_findGraphicNodeAndIndex(e){let t=Tt(this.layer.fieldsIndex,e.attributes,this._getObjectIdField());for(let e of this._nodeId2Meta.values()){let n=e?.featureIds.indexOf(t);if(n!=null&&n>=0)return{node:e.node,index:n}}return null}_getGraphicIndices(e,t){let n=this._nodeId2Meta.get(e.index);if(n==null)return[];let r=[],i=this._getObjectIdField(),a=this.layer.fieldsIndex;for(let e of t){let t=Tt(a,e.attributes,i),o=n.featureIds.indexOf(t);o!==-1&&r.push(o)}return r}whenGraphicBounds(e){let t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();let n=this.getAABB(t.node.index,t.index);return n==null?Promise.reject():Promise.resolve({boundingBox:n,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return e.nodeIndex==null||e.componentIndex==null?null:this.getAABB(e.nodeIndex,e.componentIndex)}getAABB(e,t){let n=this._nodeId2Meta.get(e);if(n?.featureIds==null||t>=n.featureIds.length)return null;let r=n.objectHandle,i=Ke(t,this._collection,r,I(24),0),a=this.view.renderSpatialReference,o=this.view.spatialReference;return M(i,a,0,i,o,0)?de(i):null}whenGraphicAttributes(e,t){return at(this.layer,e,this._getObjectIdField(),t,()=>this._nodeId2Meta.values().filter(a).toArray())}getGraphicFromIntersectorTarget(e,t){if(e.nodeIndex==null||e.componentIndex==null)return null;let n=this._nodeId2Meta.get(e.nodeIndex);if(n?.featureIds==null||e.componentIndex>=n.featureIds.length)return null;let r=this._createLayerGraphic(this._createAttributes(e.componentIndex,n));return r?this._meshUtilsImporterModule?(r.geometry=this._meshUtilsImporterModule.createMesh({layerView:this,nodeIndex:e.nodeIndex,featureIndex:e.componentIndex}),r):t.defer?(t.defer(async()=>(r.geometry=(await this._meshUtilsImporter).createMesh({layerView:this,nodeIndex:e.nodeIndex,featureIndex:e.componentIndex}),r)),null):r:null}_getCacheKey(e){return`${this._layerUrl}/v30/${e}${this._cacheKeySuffix}`}get _meshUtilsImporter(){return this._meshUtilsImporterPromise||(this._meshUtilsImporterPromise=import(`./i3s/meshUtils.js`),this._meshUtilsImporterPromise.then(e=>this._meshUtilsImporterModule=e,()=>{})),this._meshUtilsImporterPromise}_getCacheKeySuffix(){let e=this.view.renderSpatialReference;return e==null?Jt:e===ue(e)?Yt:this.layer.spatialReference.equals(e)?qt:e.wkid==null?null:`@${e.wkid}`}_getMemCacheKey(e,t=this.elevationOffset){return e+`#`+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&this.elevationOffset===0&&this._cacheKeySuffix!=null}loadCachedGPUData(e){return this._memCache==null?null:this._memCache.pop(this._getMemCacheKey(e))}deleteCachedGPUData(e){e!=null&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(this._memCache==null){this._deleteComponentObject(e);return}let n=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,n)}loadMissingTextures(e,t,n,r){let i=e?.filter((e,n)=>{if((e.usage&this.rendererTextureUsage)===0)return!1;if(t==null)return!0;let r=Xe(e.encodings,this.supportedTextureEncodings),i=t[n];return!!(i?.data==null||r&&i.encoding!==r.encoding)})??[];return i.length===0?Promise.resolve(!1):n(i,r).then(n=>{let r=0;for(let i=0;i<e.length;i++)r<n.length&&n[r].id===e[i].id&&(t[i]=n[r],r++);return!0})}loadCachedNodeData(e,t,n){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then(r=>r==null?null:(r.globalTrafo=L(r.globalTrafo),r.nodeVersion===e.version?(this.elevationInfo.mode===0&&(e.geometryObbInRenderSR=J.fromData(r.geometryObbData)),this.loadMissingTextures(r.requiredTextures,r.textureData,n,t).then(n=>(n&&this._idbCache.initialized&&r.textureData!=null&&(r.byteSize=Vt(r.transformedGeometry,r.textureData),r.textureData.every(Bt)&&this._indexedDbSizeCheck(e,r)&&this._idbCache.put(this._getCacheKey(e.id),r).catch(t=>S.getLogger(this).warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`))),E(t),r))):(this._idbCache.remove(this._getCacheKey(e.id)),null))):Promise.resolve(null)}addNode(e,t,n){return zt(t)?t.geometryBuffer==null?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,()=>this._transformNode(e,t,n).then(r=>this._safeReschedule(()=>{if(r==null)return e.hasModifications=!1,this._addCachedNodeData(e,null,n);let{obb:i,componentOffsets:a,featureIds:o,anchorIds:s,anchors:c,transformedGeometry:l,geometryMinElevation:u,geometryMaxElevation:d}=r;e.hasModifications=l.hasModifications;let f=L(r.globalTrafo),p=g(Wt,i.center.x,i.center.y,i.center.z);_(p,p,f);let m=new J(p,[i.extents.x,i.extents.y,i.extents.z],h(i.orientation.x,i.orientation.y,i.orientation.z,i.orientation.w));this.elevationInfo.mode===0&&(e.geometryObbInRenderSR=m),t.geometryData.componentOffsets=a,o&&(t.geometryData.featureIds=Array.from(o)),t.geometryData.anchorIds=s,t.geometryData.anchors=c;let v={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:l,globalTrafo:f,geometryObbData:m.data,geometryMinElevation:u,geometryMaxElevation:d,byteSize:Vt(l,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&this._indexedDbSizeCheck(e,v)){let t=v.textureData==null?null:v.textureData.map(e=>Bt(e)?e:null);this._idbCache.put(this._getCacheKey(e.id),{...v,textureData:t}).catch(t=>S.getLogger(this).warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`))}return this._addCachedNodeData(e,v,n)},n))):Promise.reject()}getElevationRange(e){let t=new q,n=this._controller,{index:r}=n;if(!r)return t;let{rootNode:i}=r;if(!i)return t;let a=this._nodeId2Meta,o=n.viewportQueries;return r.traverse(i,n=>{let{childrenLoaded:r}=n;if(r===0)return!1;let i=o.getAndUpdateVisibilityObbInRenderSR(n),s=null;if(i){if(!i.intersectSphereWithMBS(e,i.radius))return!1}else if(s=o.calculateServiceMbsInRenderSRElevationAdjusted(n),s?.isValid&&!e.intersects(s))return!1;let c=a.get(n.index);if(c){let{geometryObbInRenderSR:r}=n;if(!r||r.intersectSphereWithMBS(e)){let e=c.geometryElevationRange;e.elevationRangeValid&&!e.isEmpty&&t.expandElevationRange(e)}}return r-+!!c>0}),t}computeVisibilityObb(e){let t=this.view.renderSpatialReference;return t==null?null:(this._visibilityModifications??=ot(this._modifications,this.layer.spatialReference,t),st(e,t,this._controller.crsIndex,this.elevationOffset,this._visibilityModifications,this.view.renderCoordsHelper.sphericalPCPF))}_transformNode(e,t,n){let r=t.geometryData.geometries??[],i=Array(r.length);for(let e=0;e<r.length;++e)i[e]=this._getVertexBufferLayout(r[e],t.geometryDescriptor);let a=this.layer.normalReferenceFrame,o=t.normalReferenceFrame??a??`none`,s=e.serviceMbsInIndexSR,c=this.elevationOffset,l=this._controller.crsIndex,u=this._controller.crsVertex,d=this.view.renderSpatialReference,f=tt(s,c,o,l,d),p=le(l,u),m=le(u,d);if(p==null||m==null)return Promise.resolve(null);let h={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:i,globalTrafo:f,geometryElevationOffset:c,mbs:s.toJSON(),obbData:e.serviceObbInIndexSR?.data,elevationOffset:c,planetRadiusInGlobalMode:this._planetRadiusInGlobalMode,needNormals:this._controller.isMeshPyramid||this._imVertexNormals,computeNormals:this._isIntegratedMesh&&this._imVertexNormals,normalReferenceFrame:o,indexToVertexProjector:p,vertexToRenderProjector:m};return this._workerHandle.invoke(h,n)}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){let t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,n){if(this.elevationInfo.mode===0&&(e.geometryObbInRenderSR=this._collection.getComponentObb(t.objectHandle).clone()),!this._controller.isGeometryVisible(e)){this._cacheGPUData(t);return}let r=e.index;this._addNodeMeta(r,t),this.updateNodeState(r,n),this._collection.setObjectVisibility(t.objectHandle,!0),this._updateElevationOffsets(t),this._labeler!=null&&this._addMetaToLabeler(this._labeler,t),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==0&&this._ensureElevationTask().schedule(r),this._updateEngineObject(t),this._highlights?.objectCreated(t),this._treeDebugger!=null&&this._treeDebugger.update()}addCachedNodeData(e,t,n,r){return this._addData(e,n,()=>this._addCachedNodeData(e,t,r))}async deleteCachedNodeData(e){if(this._idbCacheEnabled)return this._idbCache.remove(this._getCacheKey(e))}async _addCachedNodeData(e,t,n){if(!this.contentVisible||!this._controller.isGeometryVisible(e)){this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);return}if(t==null){this._addNodeMeta(e.index,null);return}let r=this._addTasks.get(e.index),{geometryData:i,transformedGeometry:a}=t;await this.i3sOverrides.applyAttributeOverrides(i.featureIds,r.attributeInfo,n,this._controller.requiredAttributes);let h=t.textureData==null?[]:t.textureData.filter(e=>e!=null&&(e.usage&this.rendererTextureUsage)!==0);e.memory=0;let{componentOffsets:g,geometries:_,featureIds:y,anchorIds:te,anchors:ne}=i,x=this._collection,C=_[0],{layout:w,indices:T,interleavedVertexData:ie,positionData:E,hasColors:D}=a,{material:O,geometryParameters:k}=this._materialParameters(C,w),ae=ie.byteLength/w[0].stride,oe=g||new Uint32Array([0,T?T.length:ae]),A=C.transformation?p(C.transformation):m(),j=L(t.globalTrafo);d(A,j,A);let ce=f(b(),A),M=o(l(),A),le=this._isIntegratedMesh?this._imShading?2:0:1,ue=k.textureCoordinateType,P=!s(M,u),de=new Ne(w,le,ue,+!!P),fe=new Pe({interleavedVertexData:ie,vertexCount:ae,indexData:T},{positions:me(E.data),indices:he(E.indices)},oe,de),F=this.view.renderSpatialReference,pe=this.view.groundView.spatialReference,I=J.fromData(ke(t.geometryObbData)).getCenter(Qt),R=[1,1,1];se(I,F,R,pe)||S.getLogger(this).errorOnce(`Unsupported coordinate system for IM overlay`);let z=b();N(I,F,z,pe);let B=l();c(B,M);let V=b();v(V,ee(V,I,ce),B);let ge=z[0]-V[0]*R[0],_e=z[1]-V[1]*R[1],ve=k.textureCoordinateType===2,{textures:ye,texturePromise:be,materialParameters:xe}=this._initMaterialAndTextures(O,h,ve,e),U=x.createObject(new je(re(ge,_e,R[0],R[1]),new Ie(ce,M),J.fromData(ke(t.geometryObbData)),fe,!(this.layer.type===`integrated-mesh`&&H.shouldIntersectAsGround(this.layer))),xe);e.memory+=this._memEstimateGeometryAdded(U),e.memory+=ye.reduce((e,t)=>e+(t==null?0:this._memEstimateTextureAdded(t)),0);let W=!!O.hasParametersFromSource,Se=O.alphaMode!==`blend`&&O.metallicRoughness.baseColorFactor[3]>=1,G=new At(e,y,U,this._getInvalidRendererVersion(),r.attributeInfo,{hasParametersFromSource:W,isOpaque:Se},ye,te,ne,t.geometryMinElevation,t.geometryMaxElevation);r.meta=G,this._hasTextures||=t.requiredTextures?.some(({usage:e})=>!!(e&19))||!!e.resources.texture,this._hasData=!0,this._hasColors||=D,this.notifyChange(`hasTexturesOrVertexColors`);let Ce=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(G),be]).then(([t,r])=>(this._addTasks.has(e.index)&&t?.updateObjectVisibility(G.objectHandle,!1).catch(e=>this._logEdgeViewError(e,this.layer.title)),this._safeReschedule(()=>{let n=this._addTasks.get(e.index);if(!n)return;if(this._addNodeMeta(e.index,G),n.meta=null,!this.contentVisible){this._removeNodeStageData(e.index,this.elevationOffset);return}x.setObjectVisibility(U,!0),t?.updateObjectVisibility(G.objectHandle,!0).catch(e=>this._logEdgeViewError(e,this.layer.title)),G.attributeInfo=n.attributeInfo;let r=G.cachedRendererVersion!==this._rendererVersion,i=Ce!==this.slicePlaneEnabled;this._updateElevationOffsets(G);let a=G.elevationOffsets;this._updateComponentData(G);let o=this._applyFiltersToNode(G);(r||t!=null&&(i||o||a))&&this._addOrUpdateEdgeRendering(G).catch(()=>{}),this._labeler!=null&&this._addMetaToLabeler(this._labeler,G),this._visibleGeometryChanged(G,0),this._highlights?.objectCreated(G),this._updateMaterial(G),this._setNewNodeOpacity(G),this._treeDebugger!=null&&this._treeDebugger.update()},n))).catch(e=>{let{meta:t,allowMemCache:n}=r;throw r.meta=null,t&&n?this._cacheGPUData(t):t&&this._deleteComponentObject(t),e})}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){S.getLogger(this).error(`Removing duplicated node`);let t=this._nodeId2Meta.get(e);t&&(this._deleteComponentObject(t),this._updateFeatureIdCounts(t,-1))}else this._controller.updateLoadStatus(e,!0);t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&X(t.cachedEdgeMaterials,0),this._updateFeatureIdCounts(t,1)),this._nodeId2Meta.set(e,t),this.notifyChange(`elevationRange`)}_updateElevationOffsets(e){if(!e.node.serviceMbsInIndexSR)return;let{view:t,elevationInfo:n}=this,r=this._controller.crsIndex,{groundView:i,groundSpatialReference:a,renderSpatialReference:o}=t,s=n.mode;if(s===0){e.elevationAlignmentOffset=n.offset,e.elevationOffsets=null,e.updateGeometryElevationRange(),this.notifyChange(`elevationRange`);return}if(e.elevationAlignmentOffset=0,o==null||a==null){e.elevationOffsets=null,e.updateGeometryElevationRange(),this.notifyChange(`elevationRange`);return}let c=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];let l=Wt,u=Gt,d=s===2,f=this.view.renderCoordsHelper,p=e.featureIds.length,m=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;let t=I(p*3);e.cachedElevationAnchors=t;let{center:n}=e.node.serviceMbsInIndexSR;for(let i=0;i<p;i++){let s=i*3,d=e.anchorIds?.indexOf(i)??-1;e.anchors&&d>=0?(g(l,e.anchors[d*3],e.anchors[d*3+1],e.anchors[d*3+2]),y(l,l,n),N(l,r,l,o),t[s+2]=f.getAltitude(l),N(l,o,l,a),t[s]=l[0],t[s+1]=l[1]):(this._collection.getComponentAabb(e.objectHandle,i,u,!0),g(l,(u[0]+u[3])/2,(u[1]+u[4])/2,u[2]),v(l,l,c.rotationScale),y(l,l,c.position),t[s+2]=f.getAltitude(l),N(l,o,l,a),t[s]=l[0],t[s+1]=l[1])}return t})(),h=n.offset,_=e.elevationOffsets;i.getElevations(m,p,(e,t)=>{let n=d?m[e*3+2]:0;_[e]=h+(t??0)-n}),e.updateGeometryElevationRange(),this.notifyChange(`elevationRange`)}_ensureElevationTask(){return this._elevationTask??=new He(this.view.resourceController.scheduler,e=>this._controller.updateElevationChanged(e,this.view.groundView.spatialReference)?.filterInPlace(e=>this._nodeId2Meta.get(e)!=null),e=>this._nodeElevationAlignmentChanged(this._nodeId2Meta.get(e)),()=>this.elevationInfo?.mode),this._elevationTask}_elevationInfoChanged(e,t){let n=e.mode!==0,r=!!t&&t!==e&&t.mode!==0;this._intersectionHandler.updateElevationAlignState(n,this.view.state.isGlobal),n&&!r&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach(e=>this._nodeElevationAlignmentChanged(e))}_nodeElevationAlignmentChanged(e){e!=null&&(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),this._labeler!=null&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,2),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}_safeReschedule(e,t){return E(t),this._controller.reschedule(e,t)}_materialParameters(e,t){let n=e.params.material==null?Ze():e.params.material,r=t.some(({name:e})=>e===`uvRegion`),i=t.some(({name:e})=>e===`normalCompressed`),a=Rt(n);return{geometryParameters:this._getGeometryParameters({hasTexture:a,hasNormals:i,hasRegions:r}),material:n}}_initMaterialAndTextures(e,t,n,r){let i=this._stage.renderView,a=e=>{this._gpuMemoryEstimate-=e,this._texMemoryEstimate-=e,r.memory-=e},o=t.map(t=>Qe(t,e,n,i,this._compressionTracker,a));this._stage.addTextures(o);let{materialParameters:s,texturePromise:c}=$e(e,o,t,this.view.stage.renderView.textures,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,integratedMeshSemantics:new H(this.layer),slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference,applySSAO:this._applySSAO});return{textures:o,texturePromise:c,materialParameters:s}}_getGeometryParameters(e){return new Fe(this._hasVertexColors,e.hasNormals,e.hasTexture?e.hasRegions?2:1:0)}_addData(e,t,n){let r=this._addTasks.get(e.index);if(r)r.attributeInfo=t;else{let i=Promise.withResolvers();r=new Ut(t,null,i.promise),this._addTasks.set(e.index,r),n().then(i.resolve,i.reject).then(()=>this._addTasks.delete(e.index)).catch(t=>{throw this._addTasks.delete(e.index),t})}return r.promise}_clearAddTasks(){this._addTasks.forEach(e=>{e.meta!=null&&(this._cacheGPUData(e.meta),e.meta=null)}),this._addTasks.clear()}_clippingAreaChanged(){let e=this.view.renderSpatialReference,t=this.layer.spatialReference,n=F();this._renderClippingArea=Oe(this.view.clippingArea,n,e)?n:null;let r=F();this._layerClippingArea=Oe(this.view.clippingArea,r,t)?r:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){let e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e),this._assertFeatureIdNodeCounts(e)}_assertFeatureIdNodeCounts(e){e&&!this._featureIdCounts?(this._featureIdCounts=$(this._nodeId2Meta.values()),this._filteredIdCounts=$(this._nodeId2Meta.values(),1),this._weaklyRemovedIdCounts=$(this._nodeId2Meta.values(),2),this.addHandles(k(()=>this._controller.updating,e=>{!e&&this._needFilterResolve&&(this.multiGeometryFilterResolve(),this._needFilterResolve=!1,this.notifyUpdate())},{sync:!0}),`updateFinished`)):!e&&this._featureIdCounts&&(this._featureIdCounts=null,this._filteredIdCounts=null,this._weaklyRemovedIdCounts=null,this._mismatchShow=null,this._mismatchHide=null,this.removeHandles(`updateFinished`),this._needFilterResolve=!1,this.notifyUpdate())}_updateFeatureIdCounts(e,t){this._featureIdCounts&&(this._needFilterResolve=!0,Q(this._featureIdCounts,e.featureIds,t),Q(this._filteredIdCounts,e.filteredIds,t),Q(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,t))}_updateFilteredIdCounts(e,t,n){this._filteredIdCounts&&(this._needFilterResolve=!0,Q(this._filteredIdCounts,t,-1),Q(this._filteredIdCounts,e.filteredIds,1),Q(this._weaklyRemovedIdCounts,n,-1),Q(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,1))}_checkFeatureIdNodeCountInvariant(){let e=this._featureIdCounts!=null;if(this.hasGeometryFilter!==e&&S.getLogger(this).error(`checkFeatureIdNodeCountInvariant()`,`LayerView should have feature id node counts if and only if it has a geometry filter`,{layerView:this,hasNodeCounts:e}),!this._featureIdCounts||!this._filteredIdCounts)return;let t=$(this._nodeId2Meta.values());C(this._featureIdCounts,t)||S.getLogger(this).error(`checkFeatureIdNodeCountInvariant()`,`Incorrect _featureIdCounts`,{layerView:this,counts:this._featureIdCounts,expected:t});let n=$(this._nodeId2Meta.values(),1);C(this._filteredIdCounts,n)||S.getLogger(this).error(`checkFeatureIdNodeCountInvariant()`,`Incorrect _filteredIdCounts`,{layerView:this,counts:this._filteredIdCounts,expected:n});let r=$(this._nodeId2Meta.values(),2);C(this._weaklyRemovedIdCounts,r)||S.getLogger(this).error(`checkFeatureIdNodeCountInvariant()`,`Incorrect _weaklyRemovedIdCounts`,{layerView:this,counts:this._weaklyRemovedIdCounts,expected:n})}multiGeometryFilterResolve(){if(!this._featureIdCounts||!this._filteredIdCounts)return;let e=null,t=null;for(let[n,r]of this._filteredIdCounts){let i=this._featureIdCounts.get(n);i!==r&&(r+(this._weaklyRemovedIdCounts?.get(n)??0)===i?(e??=new Set,e.add(n)):(t??=new Set,t.add(n)))}oe(e,this._mismatchShow)&&oe(t,this._mismatchHide)||(this._mismatchShow=e,this._mismatchHide=t,this._nodeId2Meta.forEach(e=>{if(!e?.filteredIds)return;let t=Zt(e,this._mismatchShow,this._mismatchHide);this._collection.setAllComponentVisibilities(e.objectHandle,t),this._visibleGeometryChanged(e,2)}))}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach(e=>{e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e).catch(()=>{}),this._visibleGeometryChanged(e,2))})}getFilters(){let e=[],t=this._renderClippingArea;return t!=null&&e.push((e,n)=>this._boundingRectFilter(e,n,t)),e}addSqlFilter(e,t,n){if(t!=null){let r=t.fieldNames;e.push((e,i)=>this._sqlFilter(e,i,t,r,n))}}_sqlFilter(e,t,n,r,i){let a={},o=this._createLayerGraphic(a);if(!o)return;let s=this.layer.objectIdField,c=t.featureIds,l=t.attributeInfo?.attributeData;r.every(e=>e===s||l?.[e]!=null)&&ct(e,c,e=>{a[s]=c[e];for(let t of r)t!==s&&(a[t]=l?Ue(l[t],e):null);try{return n.testFeature(o)}catch(e){return i(e),!1}})}_boundingRectNodeTest(e,t){return ce(e.node.serviceMbsInIndexSR,this._controller.crsIndex,Lt,this.view.renderSpatialReference),lt(t,Lt)}_boundingRectFeatureTest(e,t,n){return this._collection.getComponentAabb(e.objectHandle,t,Mt),fe(Mt,Nt),pe(n,Nt)}_boundingRectFilter(e,t,n){let r=this._collection,i=this._boundingRectNodeTest(t,n);if(i===3)return;if(i===0){e.length=0;return}let a=r.getComponentCount(t.objectHandle);if(a.invisible+a.visible!==t.featureIds.length)return;let o=this._transformClippingArea(Pt,n,t.objectHandle);ct(e,t.featureIds,e=>this._boundingRectFeatureTest(t,e,o))}_transformClippingArea(e,t,n){let r=this._collection.getObjectTransform(n),i=r.position,a=r.rotationScale;return e[0]=(t[0]-i[0])/a[0],e[1]=(t[1]-i[1])/a[4],e[2]=(t[2]-i[0])/a[0],e[3]=(t[3]-i[1])/a[4],e}async _addOrUpdateEdgeRendering(e,t=!0){let n=e.objectHandle,{hasEdges:r,perFeatureEdgeMaterials:i}=this._getFilteredEdgeMaterials(e);if(r&&!this._edgeView)try{this._edgeView=await this._stage.renderer.loadEdgeView()}catch(e){if(!D(e))throw e}let a=this._edgeView;if(!a)return null;let o=a.hasObject(n);if(r){if(o)return this.nodeCrossfadingEnabled&&X(i,this.getNodeOpacity(e)),a.updateAllComponentMaterials(n,i,this.slicePlaneEnabled,t).catch(e=>this._logEdgeViewError(e,this.layer.title)),a.updateObjectVisibility(n,!0).catch(e=>this._logEdgeViewError(e,this.layer.title)),a.updateAllVerticalOffsets(n,e.elevationOffsets).catch(e=>this._logEdgeViewError(e,this.layer.title)),a;let r=await this._collection.addEdges(n,a,i,this.slicePlaneEnabled,e.elevationOffsets);return e.edgeMemoryUsage=r,e.node.memory+=r,a}return o&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,a.removeObject(n)),null}_applyFiltersToNode(e){let{filteredIds:t,weaklyRemovedIds:n}=e,r=this._applyFiltersToNodeComponents(e);return this._updateFilteredIdCounts(e,t,n),r&&this._labeler?.applyFilterChange(e),r}_applyFiltersToNodeComponents(e){let t=this._collection,n=t.getComponentCount(e.objectHandle),r=e.filteredIds!=null,i=n.invisible===0;if(t.setAllComponentVisibilities(e.objectHandle,`all`),this._filters.length===0)return e.filteredIds=null,!i;if((e.filteredIds==null||e.appliedFilters!==this._filters)&&(e.weaklyRemovedIds=null,e.filteredIds=Xt(e,this._filters),e.appliedFilters=this._filters),r&&e.filteredIds===e.featureIds&&(!this._mismatchHide||e.filteredIds.every(e=>!this._mismatchHide?.has(e))))return!i;let a=Zt(e,this._mismatchShow,this._mismatchHide);return t.setAllComponentVisibilities(e.objectHandle,a),!0}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach((t,n)=>this._removeNodeStageData(n,e)),this._nodeId2MetaReloading.forEach((t,n)=>this._removeNodeStageData(n,e,this._nodeId2MetaReloading)),this._elevationTask=w(this._elevationTask)}removeNode(e){let t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),this._elevationTask!=null&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,n=this._nodeId2Meta){n.has(e)&&this._controller.updateLoadStatus(e,!1);let r=n.get(e);r==null?n.delete(e):(this._collection.setObjectVisibility(r.objectHandle,!1),this._edgeView!=null&&this._edgeView.hasObject(r.objectHandle)&&this._edgeView.updateObjectVisibility(r.objectHandle,!1).catch(e=>this._logEdgeViewError(e,this.layer.title)),this._visibleGeometryChanged(r,1),this._labeler!=null&&this._labeler.removeNodeMeta(r),n.delete(e),this._highlights?.objectDeleted(r),n===this._nodeId2Meta?(this._updateFeatureIdCounts(r,-1),this._cacheGPUData(r,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(r)):this._deleteComponentObject(r),this._treeDebugger!=null&&this._treeDebugger.update())}_deleteComponentObject(e){if(this._edgeView!=null&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(let t of e.textures)this._memEstimateTextureRemoved(t),this._stage.removeTexture(t)}updateNodeState(e,t){this._nodeId2Meta.get(e)?.objectHandle.updatePolygonOffset(+(t===0))}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){let n=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,n),this.notifyChange(`elevationRange`)}let n=this._nodeId2MetaReloading.get(e);n&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,n))}_invalidateAllSymbols(){this._rendererVersion=ut(this._rendererVersion,1),this._controller?.requestUpdate()}_getInvalidRendererVersion(){return ut(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange(`rendererTextureUsage`),this._rendererVersion=ut(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.layer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&`arcadeRequired`in e&&e.arcadeRequired&&(this._arcade=await Se()),e&&`visualVariables`in e&&e.visualVariables)for(let t of e.visualVariables)t.type===`color`?this._colorVariable=t:t.type===`opacity`?this._opacityVariable=t:S.getLogger(this).warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(let t of e.symbols)t.type!==`mesh-3d`&&S.getLogger(this).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);let t=e.cachedSymbology;return(n,r)=>{let i=n*e.cachedSymbologyStride;x(r.externalColor,t[i]/255,t[i+1]/255,t[i+2]/255,t[i+3]/255);let a=this._stage.renderView.olidRenderHelper;if(a){let t=e.featureIds[n],i=this.sublayerId?`${this.layerViewUid}_${this.sublayerId}`:this.layerViewUid,o=U(this.view,this.uid);a.setUidToObjectAndLayerId(t,t,this.layerId,i,this.layerPopupEnabledAndHasTemplate&&!o,e.node.resources.attributes,n,this.sublayerId),r.olidColor=a.getObjectAndLayerIdColor({graphicUid:t,layerViewUid:i})}r.externalColorMixMode=t[i+4]&15,r.castShadows=!!(t[i+4]&16),r.pickable=!!(t[i+4]&32),r.elevationOffset=e.elevationOffsets?.[n]??0,r.emissiveStrength=e.emissiveStrengths?.[n]??1,r.emissiveSource=e.emissiveSources?.[n]??0}}_getSymbolInfo(e,t){let n=e?.getSymbol(t,{arcade:this._arcade});if(!(n instanceof G))return null;let r=n.id;if(this._symbolInfos.has(r))return this._symbolInfos.get(r);let i=dt(n);return this._symbolInfos.set(r,i),i}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=this._symbologyOverrideFields!=null&&this._symbologyOverrideFields.length>0?this._rendererFields!=null&&this._rendererFields.length>0?_e(this.layer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;let t=this._tmpAttributeOnlyGraphic,n={};t.attributes=n;let r=this._currentRenderer,i=e.attributeInfo?.attributeData,a=e.featureIds?this.layer.objectIdField:null,o=i!=null&&this._symbologyFields!=null&&this._symbologyFields.length>0,s=null,c=null;if(o&&this._symbologyFields!=null){s=[],c=[];for(let e of this._symbologyFields){let t=i[e];t&&(s.push(e),c.push(t))}}e.cachedSymbology||=z(e.featureIds.length*e.cachedSymbologyStride);let l=new gt,u=this.fullOpacity,d=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):u,f=null,p=1,m=Y,h=0;for(let i=0;i<e.featureIds.length;i++){if(a!=null&&(n[a]=e.featureIds[i]),o&&s)for(let e=0;e<s.length;e++)n[s[e]]=Ue(c[e],i);let u=r?this._getSymbolInfo(r,t):null,g,_;if(l.pickable=!0,r&&`visualVariables`in r){if(this._colorVariable){let e=be(this._colorVariable,t,{color:It,arcade:this._arcade});e&&(g=l.color,g[0]=e.r/255,g[1]=e.g/255,g[2]=e.b/255,g[3]=e.a??1,!this._opacityVariable&&e.a!==null&&(_=e.a))}this._opacityVariable&&(_=xe(this._opacityVariable,t,{arcade:this._arcade}))}if(u?.material){let e=u.material;g=g==null||_==null?ze(g,_,e.color,e.alpha,kt,l.color):ze(g,_,null,null,kt,l.color)}g??=x(l.color,1,1,1,1);let v=u?.material;if(l.colorMixMode=v?.colorMixMode??1,l.edgeMaterial=u?.edgeMaterial,this._symbologyOverride?.(t,l),this._nodeColorOverride!=null&&(this._nodeColorOverride(e.node,g),l.colorMixMode=3),l.pickable&&=g[3]>=we,l.castShadows=u?u.castShadows:l.pickable,l.edgeMaterial!=null){let t=g[3]>=1&&(e.material.isOpaque||l.colorMixMode===3)?1:0;(l.edgeMaterial!==f||t!==p)&&(m={...l.edgeMaterial,opacity:d,objectTransparency:t},f=l.edgeMaterial,p=t),e.cachedEdgeMaterials[i]=m}else e.cachedEdgeMaterials[i]=Y;e.cachedSymbology[h++]=Math.round(g[0]*255),e.cachedSymbology[h++]=Math.round(g[1]*255),e.cachedSymbology[h++]=Math.round(g[2]*255),e.cachedSymbology[h++]=Math.round(g[3]*255),e.cachedSymbology[h++]=l.colorMixMode|l.castShadows<<4|l.pickable<<5;let ee=v?.emissive?.strength==null?Le:v?.emissive?.strength;ee!==Le&&!e.emissiveStrengths&&(e.emissiveStrengths=Array(e.featureIds.length).fill(Le)),e.emissiveStrengths&&(e.emissiveStrengths[i]=ee);let y=v?.emissive?.source||0;y!==0&&!e.emissiveSources&&(e.emissiveSources=Array(e.featureIds.length).fill(0)),e.emissiveSources&&(e.emissiveSources[i]=y)}}_getFilteredEdgeMaterials(e){let t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||X(t,this.fullOpacity);let n=e.filteredIds;if(n==null)return{hasEdges:t.some(e=>e!==Y),perFeatureEdgeMaterials:t};let r=0,i=!1,a=t.map((t,a)=>e.featureIds[a]===n[r]?(i||=t!==Y,r++,t):Y);return{hasEdges:i,perFeatureEdgeMaterials:a}}_updateComponentData(e){if(!this._hasComponentData)return;let{objectHandle:t}=e,n=this._getComponentParameters(e);this._collection.setComponentData(t,n),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),this._controller!=null&&this._controller.restartNodeLoading()}_refreshGroundUsage(){this._intersectionHandler.integratedMeshSemantics=new H(this.layer),this.contentVisible&&(this.view.elevationProvider.unregister(this._elevationProvider),this.view.elevationProvider.register(this._elevationContext,this._elevationProvider)),this._reloadAll(),this.clearMemCache()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach(t=>{t!=null&&(this._collection.updateObjectOpacity(t.objectHandle,e),X(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))})}_updateMaterial(e){e.objectHandle.updateMaterial({slicePlaneEnabled:this.slicePlaneEnabled,usePBR:this._usePBR})}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e).catch(()=>{}),this._visibleGeometryChanged(e,2)}intersect(e,t,n,r){this._intersectionHandler.intersectRay(e,t,n,r,null,!1)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this._labeler!=null&&(this._labeler.slicePlaneEnabled=e),this._foreachMeta(t=>{t.objectHandle.updateMaterial({slicePlaneEnabled:e}),this._updateEdgeRendering(t,!1)})}_updatePBR(e){this._foreachMeta(t=>t.objectHandle.updateMaterial({usePBR:e})),this._hasLoadedPBRTextures=!0}_foreachMeta(e){this._nodeId2Meta.forEach(t=>{t!=null&&e(t)})}get _usePBR(){return this._imShading&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){this._edgeView!=null&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t).catch(()=>{})}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?(t,n,r)=>r.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?0:e(t,n,r):e}_forAllFeatures(e,t,n){for(let r of this._nodeId2Meta.values())if(r!=null&&!(t&&r.node.serviceMbsInIndexSR&&t(r.node.serviceMbsInIndexSR)===1))switch(n){case 1:this._forAllFeaturesOfNode(r,e);break;case 0:this._forAllVisibleFeaturesOfNode(r,e);break;case 2:this._forAllQueryableFeaturesOfNode(r,e)}}_forAllFeaturesOfNode(e,t){e.featureIds.forEach((n,r)=>t(n,r,e))}_forAllVisibleFeaturesOfNode(e,t){let n=e.featureIds;this._collection.forEachVisibleComponent(e.objectHandle,r=>t(n[r],r,e)===0)}_forAllQueryableFeaturesOfNode(e,t){let n=this._ignoreClientNodeOverriddenFeatures(t);if(this._renderClippingArea==null)return this._forAllFeaturesOfNode(e,n);let r=this._boundingRectNodeTest(e,this._renderClippingArea);if(r===0)return;if(r===3)return this._forAllFeaturesOfNode(e,n);let i=e.featureIds,a=e.objectHandle,o=ft(this._renderClippingArea,this._collection.getObjectTransform(a));for(let t=0;t<i.length;t++)this._boundingRectFeatureTest(e,t,o)&&n(i[t],t,e)}_createAttributes(e,t){let n={};t.featureIds!=null&&(n[this._getObjectIdField()]=t.featureIds[e]);let r=t.attributeInfo?.attributeData;if(r!=null)for(let t of Object.keys(r))n[t]=Ue(r[t],e);return n}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e,t){let n=Et(e);if(n.length===0)return Dt;let r=Te(t),i=n[0]instanceof B?this._featureIdsFromGraphics(n):typeof n[0]==`number`?n:null;if(!i)return Dt;let a=this._ensureHighlights(),{set:o,handle:s}=a.acquireSet(r);return a.setFeatureIds(o,i),s}_featureIdsFromGraphics(e){let t=this.layer.fieldsIndex,n=this._getObjectIdField();return e.map(e=>Tt(t,e.attributes,n))}_ensureHighlights(){return this._highlights??=new Ve({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,1),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)}),this._highlights}resetHighlights(){this._highlights=w(this._highlights)}_visibleGeometryChanged(e,t){this._elevationProvider&&(this._visibleGeometryChangedSchedulerHandle??=ae(()=>{let{node:t}=e,n=t.visibilityObbInRenderSR??t.geometryObbInRenderSR??t.serviceObbInRenderSR;if(n!=null){let e=P();n.toAaBoundingBox(e),this.emit(`visible-geometry-changed`,new Re(e))}else this.emit(`visible-geometry-changed`);this._visibleGeometryChangedSchedulerHandle=null}),this._updateSnappingSources(e,t),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}get performanceInfo(){return new vt(this.usedMemory,this._nodeId2Meta.size,Math.round(this._gpuMemoryEstimate/1048576),Math.round(this._geoMemoryEstimate/1048576),Math.round(this._texMemoryEstimate/1048576),Math.round(this.unloadedMemory/1048576),this._idbCacheEnabled?Math.round(this._idbCache.getHitRate()*100):0)}checkInvariants(){}get test(){}getNodeOpacityByIndex(e){let t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return e==null?0:this._collection.getObjectOpacity(e.objectHandle)}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}getNodeComponentHandle(e){return this._nodeId2Meta.get(e)?.objectHandle}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(e)}fadeNode(e,t,n){if(!this.nodeCrossfadingEnabled)return;let r=this._nodeId2Meta.get(e);r!=null&&this._crossfadeHelper.fadeNode(e,r,t,n)}setNodeOpacityByIndex(e,t){let n=this._nodeId2Meta.get(e);n!=null&&this._setNodeOpacity(n,t)}_setNodeOpacity(e,t){this._collection.updateObjectOpacity(e.objectHandle,t),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(this._edgeView==null||!e.cachedEdgeMaterials)return;X(e.cachedEdgeMaterials,t);let n=e.objectHandle;this._edgeView.hasObject(n)&&this._edgeView.updateAllComponentOpacities(n,t).catch(e=>this._logEdgeViewError(e,this.layer.title))}get hasModifications(){return this._isIntegratedMesh&&this._layerClippingArea!=null||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){let t=e.length;if(!this.hasModifications||t<=0||this._i3sWasmLoaded!==!0)return;let n=this.uid,r=Ht(e);if(r){let t={context:n,buffer:r.buffer};xt(t);let i=new Float64Array(r.buffer);e.forAll((e,t)=>{let n=i[t],r=St(n);e.imModificationImpact=r,r!==0&&this._controller.invalidateGeometryVisibility(e.index)})}}notifyUpdate(){this.notifyChange(`updating`)}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!!(this._controller&&this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||this._labeler!=null&&this._labeler.updating||this._crossfadeHelper?.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||this._elevationTask!=null&&this._elevationTask.readyToRun||this._needFilterResolve||this._compressionTracker.compressing}trackSnappingSources(e){let t={events:e,fetchEdgeLocations:async(e,t,n)=>{let r=this._nodeId2Meta.get(e);if(r==null)throw Error(`invalid-node`);let{origin:i,buffer:a}=await this._collection.extractEdgeInformation(r.objectHandle,t,n);return this._snappingLocationsApplyElevation(r,a,i),{type:`components`,objectIds:r.featureIds,locations:a,origin:i}},remove:()=>i(this._snappingSourcesTrackers,t)};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach((t,n)=>{if(t==null)return;let r=this._controller.getRenderMbs(t.node);r&&e.add(n,r)}),t}_snappingLocationsApplyElevation(e,t,n){if(!e.elevationOffsets||this.elevationInfo.mode===0)return;let r=t.position0,i=t.position1,a=t.componentIndex,o=b(),s=b(),c=(e,t)=>{y(e,e,n),this.view.renderCoordsHelper.worldUpAtPosition(e,s),y(e,e,te(s,s,t)),ne(e,e,n)};for(let t=0;t<r.count;t++){let n=e.elevationOffsets[a.get(t)];r.getVec(t,o),c(o,n),r.setVec(t,o),i.getVec(t,o),c(o,n),i.setVec(t,o)}}_updateSnappingSources(e,t){let{index:n}=e.node,r=this._controller.getRenderMbs(e.node);if(r!=null)for(let e of this._snappingSourcesTrackers)(t===1||t===2)&&e.events.remove(n),(t===0||t===2)&&e.events.add(n,r)}_logEdgeViewError(e,t){D(e)||S.getLogger(this).warn(`Error while processing edges. Edges on this layer might not display correctly`,t,e)}_indexedDbSizeCheck(e,t){return t.byteSize>0x6400000?(S.getLogger(this).warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}get elevationProvider(){return this._elevationProvider}};return e([n()],R.prototype,`extractChanges`,null),e([n()],R.prototype,`_hasLoadedPBRTextures`,void 0),e([n()],R.prototype,`_asyncModuleLoading`,void 0),e([n()],R.prototype,`_visibleGeometryChangedSchedulerHandle`,void 0),e([n()],R.prototype,`view`,void 0),e([n()],R.prototype,`layer`,void 0),e([n()],R.prototype,`_controller`,void 0),e([n()],R.prototype,`_labeler`,void 0),e([n()],R.prototype,`updating`,void 0),e([n()],R.prototype,`suspended`,void 0),e([n()],R.prototype,`contentVisible`,null),e([n({readOnly:!0})],R.prototype,`legendEnabled`,null),e([n(Ae)],R.prototype,`updatingProgress`,void 0),e([n()],R.prototype,`updatingProgressValue`,null),e([n()],R.prototype,`hasTexturesOrVertexColors`,null),e([n()],R.prototype,`rendererTextureUsage`,null),e([n()],R.prototype,`elevationOffset`,null),e([n()],R.prototype,`elevationInfo`,null),e([n({type:Boolean})],R.prototype,`slicePlaneEnabled`,void 0),e([n()],R.prototype,`supportedTextureEncodings`,null),e([n({type:[ye]})],R.prototype,`_modifications`,void 0),e([n({readOnly:!0})],R.prototype,`clientGeometry`,null),e([n()],R.prototype,`elevationRange`,null),e([n()],R.prototype,`fullExtent`,null),e([n()],R.prototype,`_elevationTask`,void 0),e([n({readOnly:!0})],R.prototype,`_usePBR`,null),R=e([r(`esri.views.3d.layers.I3SMeshView3D`)],R),R},Mt=P(),Nt=F(),Pt=F(),Ft=new J,It=new t([0,0,0,0]),Lt=new R(0,0,0,0);function Rt(e){if(e==null)return!1;let t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function zt(e){return`geometryData`in e}function Bt(e){return e!=null&&j(e.data)}function Vt(e,t){let n=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(t!=null)for(let e of t)e!=null&&j(e.data)&&(n+=e.data.byteLength);return n}function Ht(e){if(e.length===0)return;let t=e.length*10,n=new Float64Array(t),r=0;return e.forAll(e=>{let t=e.serviceObbInIndexSR;t??(t=Ft,e.serviceMbsInIndexSR?(t.setCenter(e.serviceMbsInIndexSR.center),t.setHalfSizeFromValues(e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius)):t.invalidate());let i=t.data;n[r++]=i[0],n[r++]=i[1],n[r++]=i[2],n[r++]=i[3],n[r++]=i[4],n[r++]=i[5],n[r++]=i[6],n[r++]=i[7],n[r++]=i[8],n[r++]=i[9]}),n}class Ut{constructor(e,t,n){this.attributeInfo=e,this.meta=t,this.promise=n,this.allowMemCache=!0}}function X(e,t){e.forEach(e=>e.opacity=t)}class Z{constructor(e,t){this.mode=e,this.offset=t}}const Wt=b(),Gt=P(),Kt=`elevation-change`,qt=``,Jt=`@null`,Yt=`@ECEF`;function Xt(e,t){let n=e.featureIds.slice();for(let r of t)if(r(n,e),n.length===0)break;return n.length===e.featureIds.length?e.featureIds:n}function Zt(e,t,n){let r=[],i=e.filteredIds;if(i!=null&&!t?.size&&!n?.size)e.featureIds.forEach((e,t)=>{i[r.length]===e&&r.push(t)});else if(i!=null){let a=0;e.featureIds.forEach((e,o)=>{if(i[a]===e)++a;else if(!t?.has(e))return;n?.has(e)||r.push(o)})}return r}function Q(e,t,n){if(e&&t)for(let r of t){let t=(e.get(r)??0)+n;t>0?e.set(r,t):e.delete(r)}}function $(e,t=0){let n=new Map;for(let r of e)Q(n,t===0?r?.featureIds:t===1?r?.filteredIds:r?.weaklyRemovedIds,1);return n}const Qt=b();export{jt as I3SMeshView3D};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../Color.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{removeUnordered as i,isSome as a}from"../../../core/arrayUtils.js";import has from"../../../core/has.js";import{fromMat4 as o,exactEquals as s,invert as c}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as l,IDENTITY as u}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as d,getTranslation as f}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as p,create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as h}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{set as g,transformMat4 as _,transformMat3 as v,sub as ee,add as y,scale as te,subtract as ne}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as x}from"../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as re}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import S from"../../../core/Logger.js";import{equals as C}from"../../../core/MapUtils.js";import{destroyMaybe as w}from"../../../core/maybe.js";import T from"../../../core/PooledArray.js";import{ignoreAbortErrors as ie,throwIfAborted as E,isAbortError as D}from"../../../core/promiseUtils.js";import{initial as O,watch as k}from"../../../core/reactiveUtils.js";import{schedule as ae}from"../../../core/scheduling.js";import{equals as oe}from"../../../core/SetUtils.js";import{UpdatingHandles as A}from"../../../core/support/UpdatingHandles.js";import{isArrayBuffer as j}from"../../../core/typedArrayUtil.js";import{localLinearScaleFactors as se}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as ce}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as M}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as le}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as N}from"../../../geometry/projection/projectVectorToVector.js";import{getSphericalPCPF as ue}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{create as P,fromBuffer as de,toRect as fe}from"../../../geometry/support/aaBoundingBox.js";import{create as F,intersects as pe}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as I,ensurePackedMat4f64 as L}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as me}from"../../../geometry/support/FloatArray.js";import{compactIndices as he}from"../../../geometry/support/Indices.js";import{Sphere as R}from"../../../geometry/support/sphere.js";import{newUByteArray as z}from"../../../geometry/support/UByteArray.js";import B from"../../../Graphic.js";import V from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fallbackObjectIDAttribute as ge}from"../../../layers/LayerConstants.js";import{fixFields as _e}from"../../../layers/support/fieldUtils.js";import{I3SExtractChanges as ve}from"../../../layers/support/I3SExtractChanges.js";import{IntegratedMeshSemantics as H}from"../../../layers/support/IntegratedMeshSemantics.js";import ye from"../../../layers/support/SceneModification.js";import{getColor as be,getOpacity as xe}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{isBasemapLayerView as U}from"../../../support/basemapUtils.js";import{getElevationOffset as W}from"../../../support/elevationInfoUtils.js";import{loadArcade as Se}from"../../../support/loadArcade.js";import G from"../../../symbols/MeshSymbol3D.js";import Ce from"../../../symbols/SimpleFillSymbol.js";import{alphaCutoff as we}from"../../../webscene/support/AlphaCutoff.js";import{getHighlightName as Te}from"../../support/highlightOptionsUtils.js";import{TextureCompressionTracker as Ee}from"../../support/TextureCompressionTracker.js";import{glLayout as De}from"../support/buffer/glUtil.js";import{debugFlags as K}from"../support/debugFlags.js";import{ElevationRange as q}from"../support/ElevationRange.js";import{toBoundingRect as Oe}from"../support/extentUtils.js";import{Obb as J,ensurePackedObbData as ke}from"../support/orientedBoundingBox.js";import{updatingProgress as Ae}from"../support/updatingProperties.js";import{ObjectParameters as je}from"../webgl-engine/collections/Component/ObjectParameters.js";import{createVertexBufferLayout as Me,ComponentGeometryParameters as Ne,SourceGeometry as Pe,VertexBufferLayoutCreationParameters as Fe}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as Ie}from"../webgl-engine/collections/Component/Transform.js";import{emissiveStrengthDefault as Le}from"../webgl-engine/core/shaderLibrary/output/getEmissions.glsl.js";import{ContentGeometryUpdateEvent as Re}from"./ContentGeometryLayerView.js";import{overrideColor as ze}from"./graphics/graphicUtils.js";import{areLabelsVisible as Be}from"./graphics/Labeler.js";import Ve from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as He}from"./i3s/I3SAsyncElevationUpdater.js";import{getCachedAttributeValue as Ue}from"./i3s/I3SBinaryReader.js";import{I3SCrossfadeHelper as We,NodeCrossfadeMetaData as Ge}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as Ke}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as qe,TraversedIntersectionNode as Je}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Ye,selectEncoding as Xe,defaultMaterial as Ze,createTexture as Qe,configureMaterial as $e}from"./i3s/I3SMaterialUtil.js";import{I3SOverrides as et}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as tt}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as nt,checkSceneLayerValid as rt,checkSceneLayerCompatibleWithView as it,whenGraphicAttributes as at,projectVisibilityModifications as ot,computeVisibilityObb as st,filterInPlace as ct,intersectBoundingRectWithMbs as lt,addWraparound as ut,getSymbolInfo as dt,transparentEdgeMaterial as Y,getClipRect as ft}from"./i3s/I3SUtil.js";import{IDBCache as pt}from"./i3s/IDBCache.js";import{IDBMockCache as mt}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as ht}from"./i3s/LayerElevationProvider.js";import{SymbologyInfo as gt}from"./i3s/SymbologyInfo.js";import _t from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as vt}from"./I3SMeshViewPerformanceInfo.js";import{initialize as yt,setModificationsSync as bt,filterObbsForModificationsSync as xt,interpretObbModificationResults as St}from"./SceneLayerWorker.js";import{SceneLayerWorkerHandle as Ct,toWasmModification as wt}from"./SceneLayerWorkerHandle.js";import{attributeLookup as Tt}from"./support/attributeUtils.js";import{normalizeHighlightTarget as Et,emptyHighlightHandle as Dt}from"./support/highlightUtils.js";import{makeScheduleFunction as Ot}from"./support/makeScheduleFunction.js";const kt=[1,1,1,1];class At extends Ge{constructor(e,t,n,r,i,a,o,s,c,l,u){super(),this.node=e,this.featureIds=t,this.objectHandle=n,this.cachedRendererVersion=r,this.attributeInfo=i,this.material=a,this.textures=o,this.anchorIds=s,this.anchors=c,this._elevationAlignmentRange=new q,this._geometryElevationRange=new q,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=[],this.edgeMemoryUsage=0,this.cachedSymbologyStride=5,this.elevationAlignmentOffset=0,this._baseGeometryElevationRange=new q(l,u),this.updateGeometryElevationRange()}get geometryElevationRange(){return this._geometryElevationRange}updateGeometryElevationRange(){let e=this._baseGeometryElevationRange;if(!e.elevationRangeValid||e.isEmpty){this._elevationAlignmentRange.invalidateElevationRange(),this._geometryElevationRange.invalidateElevationRange();return}let t=this.elevationOffsets;if(!t||t.length===0){let t=this.elevationAlignmentOffset;this._elevationAlignmentRange.setElevationRangeValues(t,t),this._geometryElevationRange.setElevationRangeValues(e.minElevation+t,e.maxElevation+t);return}let n=1/0,r=-1/0;for(let e=0;e<t.length;++e){let i=this.elevationAlignmentOffset+(t[e]??0);n=Math.min(n,i),r=Math.max(r,i)}this._elevationAlignmentRange.setElevationRangeValues(n,r),this._geometryElevationRange.setElevationRangeValues(e.minElevation+n,e.maxElevation+r)}get usedMemory(){return this.node.memory}get featureExtents(){return this._featureExtents??=new Float64Array(6*this.featureIds.length).fill(1/0),this._featureExtents}}const jt=t=>{let j=t,R=class extends j{constructor(){super(...arguments),this._extractChanges=null,this._applySSAO=!0,this._imShading=!!has(`enable-feature:im-shading`),this._imVertexNormals=!!has(`enable-feature:im-vertex-normals`),this._updatingHandles=new A,this._highlights=null,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._compressionTracker=new Ee,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._hasComponentData=!1,this._hasVertexColors=!1,this._nodeColorOverride=null,this.updating=!0,this.holeFilling=`auto`,this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=[],this._visibilityModifications=null,this.ignoresMemoryFactor=!1,this._layerUrl=``,this._cacheKeySuffix=null,this._meshUtilsImporterModule=null,this._meshUtilsImporterPromise=null,this._planetRadiusInGlobalMode=0,this._elevationTask=null,this._needFilterResolve=!1,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new B,this._crossfadeHelper=new We(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get extractChanges(){return this._extractChanges?.layer!==this.layer&&(this._extractChanges?.destroy(),this._extractChanges=new ve({layer:this.layer})),this._extractChanges}get layerViewUid(){return this.uid}get layerId(){return this.layer.id}get sublayerId(){return null}get _isIntegratedMesh(){return this.layer.type===`integrated-mesh`}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible&&this.fullOpacity>=we}get legendEnabled(){return this.contentVisible&&this.layer?.legendEnabled===!0}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?`yes`:`probably-not`:`unknown`}get rendererTextureUsage(){return nt(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?63:53:this._usePBR||this._hasLoadedPBRTextures?44:36}get elevationOffset(){let e=this.layer?.elevationInfo;return e?.mode===`absolute-height`?W(e,this.layer.spatialReference):0}get elevationInfo(){let e=this.layer?.elevationInfo;switch(e?.mode){case`absolute-height`:return new Z(0,W(e,this.layer.spatialReference));case`relative-to-ground`:return new Z(1,W(e,this.layer.spatialReference));case`on-the-ground`:return new Z(2,0);default:return new Z(0,0)}}get supportedTextureEncodings(){return Ye(this.view.stage.renderView.capabilities)}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){let e=this._nodeId2Meta,t=new q;for(let n of e.values()){let e=n?.geometryElevationRange;e?.elevationRangeValid&&!e.isEmpty&&t.expandElevationRange(e)}return t.elevationRangeValid&&!t.isEmpty?t:null}get fullExtent(){return this.layer.fullExtent}initialize(){let e=has(`enable-feature:idb-mock-cache`);this._idbCache=e?new mt(this.view,e):new pt(`esri-scenelayer-cache`,`geometries`),this.addResolvingPromise(this.layer.indexInfo);let t=this.view.resourceController,n=t.memoryController;this.i3sOverrides=new et({view:this.view,layer:this.layer,memoryController:n,extractChanges:this.extractChanges}),this._workerHandle=new Ct(Ot(t)),this.addResolvingPromise(this._workerHandle.promise),rt(this.layer),it(this.layer,this.view);let r=this.layer.store.defaultGeometrySchema;if(this.addResolvingPromise(this._workerHandle.setLegacySchema(this.uid,r).catch(ie)),this._layerUrl=this.layer.parsedUrl.path,this._controller=new V({layerView:this,worker:this._workerHandle}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view.stage,this._collection=this._stage.renderView.componentObjectCollection,this._isIntegratedMesh||!r)this._hasComponentData=!1;else{let e=r.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=(r?.vertexAttributes.color??null)!=null&&!this.layer.cachedDrawingInfo?.color;let i=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,e=>this._deleteComponentObject(e));this._memCache=i;let a=this._controller,o=this._nodeId2Meta,s=this._nodeId2MetaReloading;function*c(e){let t=a.index;if(!t)return;let n=t.rootNode;if(!n)return;let r=null;for(let i of t.traverseValues(n,t=>(r=(o.get(t.index)||s.get(t.index))?.objectHandle??null,e(t,r))))yield new Je(i,r)}this._intersectionHandler=new qe({layerViewUid:this.layerViewUid,sublayerId:this.sublayerId,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,integratedMeshSemantics:new H(this.layer),traverseNodeHierarchy:c}),this._elevationProvider=new ht({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add(()=>this.view.clippingArea,()=>this._clippingAreaChanged(),O),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),O),this._updatingHandles.add(()=>!this.suspended&&this.elevationInfo.mode!==0,(e,t)=>{e?this.addHandles(this.view.groundView.on(`elevation-change`,({extent:e})=>this._ensureElevationTask().addExtent(e)),Kt):t&&this.removeHandles(Kt)},O),this._updatingHandles.add(()=>this._usePBR,e=>this._updatePBR(e)),this._updatingHandles.add(()=>this.rendererTextureUsage,()=>{this._reloadAll(),this.clearMemCache()}),this._updatingHandles.add(()=>this.contentVisible,e=>this._contentVisibleChanged(e),O),this._updatingHandles.add(()=>this.layer.labelsVisible,()=>this._labelingChanged(),O),this._updatingHandles.add(()=>this.layer.labelingInfo,()=>this._labelingChanged(),O),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),O),this.addHandles([k(()=>K.I3S_TREE_SHOW_TILES,e=>{if(e&&!this._treeDebugger){let e=this._controller.crsIndex;import(`./support/I3STreeDebugger.js`).then(({I3STreeDebugger:t})=>{!this._treeDebugger&&K.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))})}else!e&&!K.I3S_TREE_SHOW_TILES&&(this._treeDebugger=w(this._treeDebugger))},O),k(()=>K.I3S_SHOW_MODIFICATIONS,()=>this._showModifications(),O)]),this._cacheKeySuffix=this._getCacheKeySuffix(),this._idbCache.init().catch(e=>S.getLogger(this).warn(`Failed to initialize IndexedDB cache: ${e}`));let{view:l}=this,{renderCoordsHelper:u}=l;this._planetRadiusInGlobalMode=l.state.isGlobal?u.referenceEllipsoid.radius:0}destroy(){this._clearAddTasks(),this._elevationTask=w(this._elevationTask),this.i3sOverrides=w(this.i3sOverrides),this._extractChanges=w(this._extractChanges),this._elevationProvider&&=(this._elevationProvider.notifyObjectsChanged(this.getVisibleObbs()),this.view.elevationProvider.unregister(this._elevationProvider),null),this._intersectionHandler&&=(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),null);let e=this._workerHandle;e&&(e.destroyContextAndSelf(this.uid),this._workerHandle=null),this._removeAllNodeDataFromStage(),this._memCache=w(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=w(this._labeler),this._treeDebugger=w(this._treeDebugger),this._controller=w(this._controller),this._highlights=w(this._highlights),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=w(this._crossfadeHelper),this.emit(`visible-geometry-changed`),this._visibleGeometryChangedSchedulerHandle&&=(this._visibleGeometryChangedSchedulerHandle.remove(),null),this._updatingHandles=w(this._updatingHandles)}_memEstimateTextureAdded(e){let t=e.usedMemory;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(e!=null){let t=e.usedMemory;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){let t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){let 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)}get usedMemory(){let e=this._labeler==null?0:this._labeler.usedMemory;return this._nodeId2Meta.forEach(t=>e+=t==null?0:t.node.memory),this._nodeId2MetaReloading.forEach(t=>e+=t==null?0:t.node.memory),e}get unloadedMemory(){return(this._controller==null?0:this._controller.unloadedMemoryEstimate)+(this._labeler==null?0:this._labeler.unloadedMemoryEstimate)}_labelingChanged(){if(!(Be(this.layer)&&this._supportsLabeling)){this._labeler!=null&&(this._labeler.destroy(),this._labeler=null);return}if(this._labeler!=null)return;let e=new _t({view:this.view,layer:this.layer,collection:this._collection,overrides:this.i3sOverrides,layerViewUid:this.uid});this._nodeId2Meta.forEach(t=>t!=null&&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._visibilityModifications=null,!this._i3sWasmLoaded&&this.hasModifications){this._i3sWasmLoaded=yt().then(()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()},()=>{}),this.notifyUpdate();return}if(this._i3sWasmLoaded!==!0)return;let e=e=>S.getLogger(this).error(`set-modifications-error`,`Error when setting modifications:`,e),t=this.uid,n=this.layer.spatialReference,r=n.isGeographic,i=wt(this._layerClippingArea,this._modifications,n,this.view.state.isGlobal);this._workerHandle.setModifications(t,i,r).catch(e);try{bt({context:t,modifications:i,isGeodetic:r})}catch(t){e(t)}this._controller.modificationsChanged();let a=this.hasModifications?new T:null;this._nodeId2Meta.forEach((e,t)=>{e==null?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._updateFeatureIdCounts(e,-1),this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):a?.push(e.node)}),this.notifyChange(`elevationRange`),a!=null&&this._nodeId2MetaReloading.forEach(e=>a.push(e.node)),a!=null&&a.length>0&&(this.updateNodeModificationStatus(a),a.forAll(e=>{if(e.imModificationImpact!==2){let t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),t==null?this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1)):(this._updateFeatureIdCounts(t,-1),this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t),this.notifyChange(`elevationRange`))}})),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(this._modificationGraphics!=null&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!K.I3S_SHOW_MODIFICATIONS||this._modifications.length===0)return;let e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={outline:{color:[255,255,255],width:1}};this._modificationGraphics=[];for(let n of this._modifications){let r=n.geometry;r.spatialReference=this.layer.spatialReference;let i=new Ce({...t,color:e[n.type]});this._modificationGraphics.push(new B({geometry:r,symbol:i}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,(e,t)=>this._createAttributes(e,t))}_contentVisibleChanged(e){e?(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler)):(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){let t=this._nodeId2Meta.get(e);if(t?.attributeInfo!=null)return t.attributeInfo.loadedAttributes}getAttributeData(e){let t=this._nodeId2Meta.get(e);if(t?.attributeInfo!=null)return t.attributeInfo.attributeData}setAttributeData(e,t){let n=this._nodeId2Meta.get(e);n?.attributeInfo!=null&&(n.attributeInfo.attributeData=t,this._attributeValuesChanged(n))}async updateAttributes(e,t,n){let r=this._nodeId2Meta.get(e);r!=null&&(await this.i3sOverrides.applyAttributeOverrides(r.featureIds,t,n,this._controller.requiredAttributes),E(n),r.attributeInfo=t,this._controller.reschedule(()=>{this._nodeId2Meta.get(e)===r&&this._attributeValuesChanged(r)},n).catch(e=>{D(e)||S.getLogger(this).warn(`Error while updating attribute values. Layer might not display correctly.`,e)}))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.appliedFilters=null,this._labeler!=null&&this._labeler.setNodeMetaAttributes(e,(e,t)=>this._createAttributes(e,t)),this._updateEngineObject(e)}clearMemCache(){this._memCache!=null&&this._memCache.clear(),this._addTasks.forEach(e=>e.allowMemCache=!1)}getVisibleNodes(){let e=[];return this._nodeId2Meta.forEach(t=>t!=null&&e.push(t.node)),e}getVisibleObbs(){let e=[];return this._nodeId2Meta.forEach(t=>t&&e.push(this._collection.getComponentObb(t.objectHandle))),e}getLoadedNodeIndices(e){this._nodeId2Meta.forEach((t,n)=>e.push(n)),this._nodeId2MetaReloading.forEach((t,n)=>e.push(n))}_getVertexBufferLayout(e,t){return De(Me(this._getGeometryParameters({hasTexture:Rt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion})))}_getObjectIdField(){return this.layer.objectIdField||ge}_getGlobalIdField(){return this.layer.globalIdField}_findGraphicNodeAndIndex(e){let t=Tt(this.layer.fieldsIndex,e.attributes,this._getObjectIdField());for(let e of this._nodeId2Meta.values()){let n=e?.featureIds.indexOf(t);if(n!=null&&n>=0)return{node:e.node,index:n}}return null}_getGraphicIndices(e,t){let n=this._nodeId2Meta.get(e.index);if(n==null)return[];let r=[],i=this._getObjectIdField(),a=this.layer.fieldsIndex;for(let e of t){let t=Tt(a,e.attributes,i),o=n.featureIds.indexOf(t);o!==-1&&r.push(o)}return r}whenGraphicBounds(e){let t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();let n=this.getAABB(t.node.index,t.index);return n==null?Promise.reject():Promise.resolve({boundingBox:n,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return e.nodeIndex==null||e.componentIndex==null?null:this.getAABB(e.nodeIndex,e.componentIndex)}getAABB(e,t){let n=this._nodeId2Meta.get(e);if(n?.featureIds==null||t>=n.featureIds.length)return null;let r=n.objectHandle,i=Ke(t,this._collection,r,I(24),0),a=this.view.renderSpatialReference,o=this.view.spatialReference;return M(i,a,0,i,o,0)?de(i):null}whenGraphicAttributes(e,t){return at(this.layer,e,this._getObjectIdField(),t,()=>this._nodeId2Meta.values().filter(a).toArray())}getGraphicFromIntersectorTarget(e,t){if(e.nodeIndex==null||e.componentIndex==null)return null;let n=this._nodeId2Meta.get(e.nodeIndex);if(n?.featureIds==null||e.componentIndex>=n.featureIds.length)return null;let r=this._createLayerGraphic(this._createAttributes(e.componentIndex,n));return r?this._meshUtilsImporterModule?(r.geometry=this._meshUtilsImporterModule.createMesh({layerView:this,nodeIndex:e.nodeIndex,featureIndex:e.componentIndex}),r):t.defer?(t.defer(async()=>(r.geometry=(await this._meshUtilsImporter).createMesh({layerView:this,nodeIndex:e.nodeIndex,featureIndex:e.componentIndex}),r)),null):r:null}_getCacheKey(e){return`${this._layerUrl}/v30/${e}${this._cacheKeySuffix}`}get _meshUtilsImporter(){return this._meshUtilsImporterPromise||(this._meshUtilsImporterPromise=import(`./i3s/meshUtils.js`),this._meshUtilsImporterPromise.then(e=>this._meshUtilsImporterModule=e,()=>{})),this._meshUtilsImporterPromise}_getCacheKeySuffix(){let e=this.view.renderSpatialReference;return e==null?Jt:e===ue(e)?Yt:this.layer.spatialReference.equals(e)?qt:e.wkid==null?null:`@${e.wkid}`}_getMemCacheKey(e,t=this.elevationOffset){return e+`#`+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&this.elevationOffset===0&&this._cacheKeySuffix!=null}loadCachedGPUData(e){return this._memCache==null?null:this._memCache.pop(this._getMemCacheKey(e))}deleteCachedGPUData(e){e!=null&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(this._memCache==null){this._deleteComponentObject(e);return}let n=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,n)}loadMissingTextures(e,t,n,r){let i=e?.filter((e,n)=>{if((e.usage&this.rendererTextureUsage)===0)return!1;if(t==null)return!0;let r=Xe(e.encodings,this.supportedTextureEncodings),i=t[n];return!!(i?.data==null||r&&i.encoding!==r.encoding)})??[];return i.length===0?Promise.resolve(!1):n(i,r).then(n=>{let r=0;for(let i=0;i<e.length;i++)r<n.length&&n[r].id===e[i].id&&(t[i]=n[r],r++);return!0})}loadCachedNodeData(e,t,n){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then(r=>r==null?null:(r.globalTrafo=L(r.globalTrafo),r.nodeVersion===e.version?(this.elevationInfo.mode===0&&(e.geometryObbInRenderSR=J.fromData(r.geometryObbData)),this.loadMissingTextures(r.requiredTextures,r.textureData,n,t).then(n=>(n&&this._idbCache.initialized&&r.textureData!=null&&(r.byteSize=Vt(r.transformedGeometry,r.textureData),r.textureData.every(Bt)&&this._indexedDbSizeCheck(e,r)&&this._idbCache.put(this._getCacheKey(e.id),r).catch(t=>S.getLogger(this).warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`))),E(t),r))):(this._idbCache.remove(this._getCacheKey(e.id)),null))):Promise.resolve(null)}addNode(e,t,n){return zt(t)?t.geometryBuffer==null?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,()=>this._transformNode(e,t,n).then(r=>this._safeReschedule(()=>{if(r==null)return e.hasModifications=!1,this._addCachedNodeData(e,null,n);let{obb:i,componentOffsets:a,featureIds:o,anchorIds:s,anchors:c,transformedGeometry:l,geometryMinElevation:u,geometryMaxElevation:d}=r;e.hasModifications=l.hasModifications;let f=L(r.globalTrafo),p=g(Wt,i.center.x,i.center.y,i.center.z);_(p,p,f);let m=new J(p,[i.extents.x,i.extents.y,i.extents.z],h(i.orientation.x,i.orientation.y,i.orientation.z,i.orientation.w));this.elevationInfo.mode===0&&(e.geometryObbInRenderSR=m),t.geometryData.componentOffsets=a,o&&(t.geometryData.featureIds=Array.from(o)),t.geometryData.anchorIds=s,t.geometryData.anchors=c;let v={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:l,globalTrafo:f,geometryObbData:m.data,geometryMinElevation:u,geometryMaxElevation:d,byteSize:Vt(l,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&this._indexedDbSizeCheck(e,v)){let t=v.textureData==null?null:v.textureData.map(e=>Bt(e)?e:null);this._idbCache.put(this._getCacheKey(e.id),{...v,textureData:t}).catch(t=>S.getLogger(this).warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`))}return this._addCachedNodeData(e,v,n)},n))):Promise.reject()}getElevationRange(e){let t=new q,n=this._controller,{index:r}=n;if(!r)return t;let{rootNode:i}=r;if(!i)return t;let a=this._nodeId2Meta,o=n.viewportQueries;return r.traverse(i,n=>{let{childrenLoaded:r}=n;if(r===0)return!1;let i=o.getAndUpdateVisibilityObbInRenderSR(n),s=null;if(i){if(!i.intersectSphereWithMBS(e,i.radius))return!1}else if(s=o.calculateServiceMbsInRenderSRElevationAdjusted(n),s?.isValid&&!e.intersects(s))return!1;let c=a.get(n.index);if(c){let{geometryObbInRenderSR:r}=n;if(!r||r.intersectSphereWithMBS(e)){let e=c.geometryElevationRange;e.elevationRangeValid&&!e.isEmpty&&t.expandElevationRange(e)}}return r-+!!c>0}),t}computeVisibilityObb(e){let t=this.view.renderSpatialReference;return t==null?null:(this._visibilityModifications??=ot(this._modifications,this.layer.spatialReference,t),st(e,t,this._controller.crsIndex,this.elevationOffset,this._visibilityModifications,this.view.renderCoordsHelper.sphericalPCPF))}_transformNode(e,t,n){let r=t.geometryData.geometries??[],i=Array(r.length);for(let e=0;e<r.length;++e)i[e]=this._getVertexBufferLayout(r[e],t.geometryDescriptor);let a=this.layer.normalReferenceFrame,o=t.normalReferenceFrame??a??`none`,s=e.serviceMbsInIndexSR,c=this.elevationOffset,l=this._controller.crsIndex,u=this._controller.crsVertex,d=this.view.renderSpatialReference,f=tt(s,c,o,l,d),p=le(l,u),m=le(u,d);if(p==null||m==null)return Promise.resolve(null);let h={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:i,globalTrafo:f,geometryElevationOffset:c,mbs:s.toJSON(),obbData:e.serviceObbInIndexSR?.data,elevationOffset:c,planetRadiusInGlobalMode:this._planetRadiusInGlobalMode,needNormals:this._controller.isMeshPyramid||this._imVertexNormals,computeNormals:this._isIntegratedMesh&&this._imVertexNormals,normalReferenceFrame:o,indexToVertexProjector:p,vertexToRenderProjector:m};return this._workerHandle.invoke(h,n)}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){let t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,n){if(this.elevationInfo.mode===0&&(e.geometryObbInRenderSR=this._collection.getComponentObb(t.objectHandle).clone()),!this._controller.isGeometryVisible(e)){this._cacheGPUData(t);return}let r=e.index;this._addNodeMeta(r,t),this.updateNodeState(r,n),this._collection.setObjectVisibility(t.objectHandle,!0),this._updateElevationOffsets(t),this._labeler!=null&&this._addMetaToLabeler(this._labeler,t),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==0&&this._ensureElevationTask().schedule(r),this._updateEngineObject(t),this._highlights?.objectCreated(t),this._treeDebugger!=null&&this._treeDebugger.update()}addCachedNodeData(e,t,n,r){return this._addData(e,n,()=>this._addCachedNodeData(e,t,r))}async deleteCachedNodeData(e){if(this._idbCacheEnabled)return this._idbCache.remove(this._getCacheKey(e))}async _addCachedNodeData(e,t,n){if(!this.contentVisible||!this._controller.isGeometryVisible(e)){this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);return}if(t==null){this._addNodeMeta(e.index,null);return}let r=this._addTasks.get(e.index),{geometryData:i,transformedGeometry:a}=t;await this.i3sOverrides.applyAttributeOverrides(i.featureIds,r.attributeInfo,n,this._controller.requiredAttributes);let h=t.textureData==null?[]:t.textureData.filter(e=>e!=null&&(e.usage&this.rendererTextureUsage)!==0);e.memory=0;let{componentOffsets:g,geometries:_,featureIds:y,anchorIds:te,anchors:ne}=i,x=this._collection,C=_[0],{layout:w,indices:T,interleavedVertexData:ie,positionData:E,hasColors:D}=a,{material:O,geometryParameters:k}=this._materialParameters(C,w),ae=ie.byteLength/w[0].stride,oe=g||new Uint32Array([0,T?T.length:ae]),A=C.transformation?p(C.transformation):m(),j=L(t.globalTrafo);d(A,j,A);let ce=f(b(),A),M=o(l(),A),le=this._isIntegratedMesh?this._imShading?2:0:1,ue=k.textureCoordinateType,P=!s(M,u),de=new Ne(w,le,ue,+!!P),fe=new Pe({interleavedVertexData:ie,vertexCount:ae,indexData:T},{positions:me(E.data),indices:he(E.indices)},oe,de),F=this.view.renderSpatialReference,pe=this.view.groundView.spatialReference,I=J.fromData(ke(t.geometryObbData)).getCenter(Qt),R=[1,1,1];se(I,F,R,pe)||S.getLogger(this).errorOnce(`Unsupported coordinate system for IM overlay`);let z=b();N(I,F,z,pe);let B=l();c(B,M);let V=b();v(V,ee(V,I,ce),B);let ge=z[0]-V[0]*R[0],_e=z[1]-V[1]*R[1],ve=k.textureCoordinateType===2,{textures:ye,texturePromise:be,materialParameters:xe}=this._initMaterialAndTextures(O,h,ve,e),U=x.createObject(new je(re(ge,_e,R[0],R[1]),new Ie(ce,M),J.fromData(ke(t.geometryObbData)),fe,!(this.layer.type===`integrated-mesh`&&H.shouldIntersectAsGround(this.layer))),xe);e.memory+=this._memEstimateGeometryAdded(U),e.memory+=ye.reduce((e,t)=>e+(t==null?0:this._memEstimateTextureAdded(t)),0);let W=!!O.hasParametersFromSource,Se=O.alphaMode!==`blend`&&O.metallicRoughness.baseColorFactor[3]>=1,G=new At(e,y,U,this._getInvalidRendererVersion(),r.attributeInfo,{hasParametersFromSource:W,isOpaque:Se},ye,te,ne,t.geometryMinElevation,t.geometryMaxElevation);r.meta=G,this._hasTextures||=t.requiredTextures?.some(({usage:e})=>!!(e&19))||!!e.resources.texture,this._hasData=!0,this._hasColors||=D,this.notifyChange(`hasTexturesOrVertexColors`);let Ce=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(G),be]).then(([t,r])=>(this._addTasks.has(e.index)&&t?.updateObjectVisibility(G.objectHandle,!1).catch(e=>this._logEdgeViewError(e,this.layer.title)),this._safeReschedule(()=>{let n=this._addTasks.get(e.index);if(!n)return;if(this._addNodeMeta(e.index,G),n.meta=null,!this.contentVisible){this._removeNodeStageData(e.index,this.elevationOffset);return}x.setObjectVisibility(U,!0),t?.updateObjectVisibility(G.objectHandle,!0).catch(e=>this._logEdgeViewError(e,this.layer.title)),G.attributeInfo=n.attributeInfo;let r=G.cachedRendererVersion!==this._rendererVersion,i=Ce!==this.slicePlaneEnabled;this._updateElevationOffsets(G);let a=G.elevationOffsets;this._updateComponentData(G);let o=this._applyFiltersToNode(G);(r||t!=null&&(i||o||a))&&this._addOrUpdateEdgeRendering(G).catch(()=>{}),this._labeler!=null&&this._addMetaToLabeler(this._labeler,G),this._visibleGeometryChanged(G,0),this._highlights?.objectCreated(G),this._updateMaterial(G),this._setNewNodeOpacity(G),this._treeDebugger!=null&&this._treeDebugger.update()},n))).catch(e=>{let{meta:t,allowMemCache:n}=r;throw r.meta=null,t&&n?this._cacheGPUData(t):t&&this._deleteComponentObject(t),e})}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){S.getLogger(this).error(`Removing duplicated node`);let t=this._nodeId2Meta.get(e);t&&(this._deleteComponentObject(t),this._updateFeatureIdCounts(t,-1))}else this._controller.updateLoadStatus(e,!0);t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&X(t.cachedEdgeMaterials,0),this._updateFeatureIdCounts(t,1)),this._nodeId2Meta.set(e,t),this.notifyChange(`elevationRange`)}_updateElevationOffsets(e){if(!e.node.serviceMbsInIndexSR)return;let{view:t,elevationInfo:n}=this,r=this._controller.crsIndex,{groundView:i,groundSpatialReference:a,renderSpatialReference:o}=t,s=n.mode;if(s===0){e.elevationAlignmentOffset=n.offset,e.elevationOffsets=null,e.updateGeometryElevationRange(),this.notifyChange(`elevationRange`);return}if(e.elevationAlignmentOffset=0,o==null||a==null){e.elevationOffsets=null,e.updateGeometryElevationRange(),this.notifyChange(`elevationRange`);return}let c=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];let l=Wt,u=Gt,d=s===2,f=this.view.renderCoordsHelper,p=e.featureIds.length,m=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;let t=I(p*3);e.cachedElevationAnchors=t;let{center:n}=e.node.serviceMbsInIndexSR;for(let i=0;i<p;i++){let s=i*3,d=e.anchorIds?.indexOf(i)??-1;e.anchors&&d>=0?(g(l,e.anchors[d*3],e.anchors[d*3+1],e.anchors[d*3+2]),y(l,l,n),N(l,r,l,o),t[s+2]=f.getAltitude(l),N(l,o,l,a),t[s]=l[0],t[s+1]=l[1]):(this._collection.getComponentAabb(e.objectHandle,i,u,!0),g(l,(u[0]+u[3])/2,(u[1]+u[4])/2,u[2]),v(l,l,c.rotationScale),y(l,l,c.position),t[s+2]=f.getAltitude(l),N(l,o,l,a),t[s]=l[0],t[s+1]=l[1])}return t})(),h=n.offset,_=e.elevationOffsets;i.getElevations(m,p,(e,t)=>{let n=d?m[e*3+2]:0;_[e]=h+(t??0)-n}),e.updateGeometryElevationRange(),this.notifyChange(`elevationRange`)}_ensureElevationTask(){return this._elevationTask??=new He(this.view.resourceController.scheduler,e=>this._controller.updateElevationChanged(e,this.view.groundView.spatialReference)?.filterInPlace(e=>this._nodeId2Meta.get(e)!=null),e=>this._nodeElevationAlignmentChanged(this._nodeId2Meta.get(e)),()=>this.elevationInfo?.mode),this._elevationTask}_elevationInfoChanged(e,t){let n=e.mode!==0,r=!!t&&t!==e&&t.mode!==0;this._intersectionHandler.updateElevationAlignState(n,this.view.state.isGlobal),n&&!r&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach(e=>this._nodeElevationAlignmentChanged(e))}_nodeElevationAlignmentChanged(e){e!=null&&(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),this._labeler!=null&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,2),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}_safeReschedule(e,t){return E(t),this._controller.reschedule(e,t)}_materialParameters(e,t){let n=e.params.material==null?Ze():e.params.material,r=t.some(({name:e})=>e===`uvRegion`),i=t.some(({name:e})=>e===`normalCompressed`),a=Rt(n);return{geometryParameters:this._getGeometryParameters({hasTexture:a,hasNormals:i,hasRegions:r}),material:n}}_initMaterialAndTextures(e,t,n,r){let i=this._stage.renderView,a=e=>{this._gpuMemoryEstimate-=e,this._texMemoryEstimate-=e,r.memory-=e},o=t.map(t=>Qe(t,e,n,i,this._compressionTracker,a));this._stage.addTextures(o);let{materialParameters:s,texturePromise:c}=$e(e,o,t,this.view.stage.renderView.textures,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,integratedMeshSemantics:new H(this.layer),slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference,applySSAO:this._applySSAO});return{textures:o,texturePromise:c,materialParameters:s}}_getGeometryParameters(e){return new Fe(this._hasVertexColors,e.hasNormals,e.hasTexture?e.hasRegions?2:1:0)}_addData(e,t,n){let r=this._addTasks.get(e.index);if(r)r.attributeInfo=t;else{let i=Promise.withResolvers();r=new Ut(t,null,i.promise),this._addTasks.set(e.index,r),n().then(i.resolve,i.reject).then(()=>this._addTasks.delete(e.index)).catch(t=>{throw this._addTasks.delete(e.index),t})}return r.promise}_clearAddTasks(){this._addTasks.forEach(e=>{e.meta!=null&&(this._cacheGPUData(e.meta),e.meta=null)}),this._addTasks.clear()}_clippingAreaChanged(){let e=this.view.renderSpatialReference,t=this.layer.spatialReference,n=F();this._renderClippingArea=Oe(this.view.clippingArea,n,e)?n:null;let r=F();this._layerClippingArea=Oe(this.view.clippingArea,r,t)?r:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){let e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e),this._assertFeatureIdNodeCounts(e)}_assertFeatureIdNodeCounts(e){e&&!this._featureIdCounts?(this._featureIdCounts=$(this._nodeId2Meta.values()),this._filteredIdCounts=$(this._nodeId2Meta.values(),1),this._weaklyRemovedIdCounts=$(this._nodeId2Meta.values(),2),this.addHandles(k(()=>this._controller.updating,e=>{!e&&this._needFilterResolve&&(this.multiGeometryFilterResolve(),this._needFilterResolve=!1,this.notifyUpdate())},{sync:!0}),`updateFinished`)):!e&&this._featureIdCounts&&(this._featureIdCounts=null,this._filteredIdCounts=null,this._weaklyRemovedIdCounts=null,this._mismatchShow=null,this._mismatchHide=null,this.removeHandles(`updateFinished`),this._needFilterResolve=!1,this.notifyUpdate())}_updateFeatureIdCounts(e,t){this._featureIdCounts&&(this._needFilterResolve=!0,Q(this._featureIdCounts,e.featureIds,t),Q(this._filteredIdCounts,e.filteredIds,t),Q(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,t))}_updateFilteredIdCounts(e,t,n){this._filteredIdCounts&&(this._needFilterResolve=!0,Q(this._filteredIdCounts,t,-1),Q(this._filteredIdCounts,e.filteredIds,1),Q(this._weaklyRemovedIdCounts,n,-1),Q(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,1))}_checkFeatureIdNodeCountInvariant(){let e=this._featureIdCounts!=null;if(this.hasGeometryFilter!==e&&S.getLogger(this).error(`checkFeatureIdNodeCountInvariant()`,`LayerView should have feature id node counts if and only if it has a geometry filter`,{layerView:this,hasNodeCounts:e}),!this._featureIdCounts||!this._filteredIdCounts)return;let t=$(this._nodeId2Meta.values());C(this._featureIdCounts,t)||S.getLogger(this).error(`checkFeatureIdNodeCountInvariant()`,`Incorrect _featureIdCounts`,{layerView:this,counts:this._featureIdCounts,expected:t});let n=$(this._nodeId2Meta.values(),1);C(this._filteredIdCounts,n)||S.getLogger(this).error(`checkFeatureIdNodeCountInvariant()`,`Incorrect _filteredIdCounts`,{layerView:this,counts:this._filteredIdCounts,expected:n});let r=$(this._nodeId2Meta.values(),2);C(this._weaklyRemovedIdCounts,r)||S.getLogger(this).error(`checkFeatureIdNodeCountInvariant()`,`Incorrect _weaklyRemovedIdCounts`,{layerView:this,counts:this._weaklyRemovedIdCounts,expected:n})}multiGeometryFilterResolve(){if(!this._featureIdCounts||!this._filteredIdCounts)return;let e=null,t=null;for(let[n,r]of this._filteredIdCounts){let i=this._featureIdCounts.get(n);i!==r&&(r+(this._weaklyRemovedIdCounts?.get(n)??0)===i?(e??=new Set,e.add(n)):(t??=new Set,t.add(n)))}oe(e,this._mismatchShow)&&oe(t,this._mismatchHide)||(this._mismatchShow=e,this._mismatchHide=t,this._nodeId2Meta.forEach(e=>{if(!e?.filteredIds)return;let t=Zt(e,this._mismatchShow,this._mismatchHide);this._collection.setAllComponentVisibilities(e.objectHandle,t),this._visibleGeometryChanged(e,2)}))}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach(e=>{e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e).catch(()=>{}),this._visibleGeometryChanged(e,2))})}getFilters(){let e=[],t=this._renderClippingArea;return t!=null&&e.push((e,n)=>this._boundingRectFilter(e,n,t)),e}addSqlFilter(e,t,n){if(t!=null){let r=t.fieldNames;e.push((e,i)=>this._sqlFilter(e,i,t,r,n))}}_sqlFilter(e,t,n,r,i){let a={},o=this._createLayerGraphic(a);if(!o)return;let s=this.layer.objectIdField,c=t.featureIds,l=t.attributeInfo?.attributeData;r.every(e=>e===s||l?.[e]!=null)&&ct(e,c,e=>{a[s]=c[e];for(let t of r)t!==s&&(a[t]=l?Ue(l[t],e):null);try{return n.testFeature(o)}catch(e){return i(e),!1}})}_boundingRectNodeTest(e,t){return ce(e.node.serviceMbsInIndexSR,this._controller.crsIndex,Lt,this.view.renderSpatialReference),lt(t,Lt)}_boundingRectFeatureTest(e,t,n){return this._collection.getComponentAabb(e.objectHandle,t,Mt),fe(Mt,Nt),pe(n,Nt)}_boundingRectFilter(e,t,n){let r=this._collection,i=this._boundingRectNodeTest(t,n);if(i===3)return;if(i===0){e.length=0;return}let a=r.getComponentCount(t.objectHandle);if(a.invisible+a.visible!==t.featureIds.length)return;let o=this._transformClippingArea(Pt,n,t.objectHandle);ct(e,t.featureIds,e=>this._boundingRectFeatureTest(t,e,o))}_transformClippingArea(e,t,n){let r=this._collection.getObjectTransform(n),i=r.position,a=r.rotationScale;return e[0]=(t[0]-i[0])/a[0],e[1]=(t[1]-i[1])/a[4],e[2]=(t[2]-i[0])/a[0],e[3]=(t[3]-i[1])/a[4],e}async _addOrUpdateEdgeRendering(e,t=!0){let n=e.objectHandle,{hasEdges:r,perFeatureEdgeMaterials:i}=this._getFilteredEdgeMaterials(e);if(r&&!this._edgeView)try{this._edgeView=await this._stage.renderer.loadEdgeView()}catch(e){if(!D(e))throw e}let a=this._edgeView;if(!a)return null;let o=a.hasObject(n);if(r){if(o)return this.nodeCrossfadingEnabled&&X(i,this.getNodeOpacity(e)),a.updateAllComponentMaterials(n,i,this.slicePlaneEnabled,t).catch(e=>this._logEdgeViewError(e,this.layer.title)),a.updateObjectVisibility(n,!0).catch(e=>this._logEdgeViewError(e,this.layer.title)),a.updateAllVerticalOffsets(n,e.elevationOffsets).catch(e=>this._logEdgeViewError(e,this.layer.title)),a;let r=await this._collection.addEdges(n,a,i,this.slicePlaneEnabled,e.elevationOffsets);return e.edgeMemoryUsage=r,e.node.memory+=r,a}return o&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,a.removeObject(n)),null}_applyFiltersToNode(e){let{filteredIds:t,weaklyRemovedIds:n}=e,r=this._applyFiltersToNodeComponents(e);return this._updateFilteredIdCounts(e,t,n),r&&this._labeler?.applyFilterChange(e),r}_applyFiltersToNodeComponents(e){let t=this._collection,n=t.getComponentCount(e.objectHandle),r=e.filteredIds!=null,i=n.invisible===0;if(t.setAllComponentVisibilities(e.objectHandle,`all`),this._filters.length===0)return e.filteredIds=null,!i;if((e.filteredIds==null||e.appliedFilters!==this._filters)&&(e.weaklyRemovedIds=null,e.filteredIds=Xt(e,this._filters),e.appliedFilters=this._filters),r&&e.filteredIds===e.featureIds&&(!this._mismatchHide||e.filteredIds.every(e=>!this._mismatchHide?.has(e))))return!i;let a=Zt(e,this._mismatchShow,this._mismatchHide);return t.setAllComponentVisibilities(e.objectHandle,a),!0}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach((t,n)=>this._removeNodeStageData(n,e)),this._nodeId2MetaReloading.forEach((t,n)=>this._removeNodeStageData(n,e,this._nodeId2MetaReloading)),this._elevationTask=w(this._elevationTask)}removeNode(e){let t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),this._elevationTask!=null&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,n=this._nodeId2Meta){n.has(e)&&this._controller.updateLoadStatus(e,!1);let r=n.get(e);r==null?n.delete(e):(this._collection.setObjectVisibility(r.objectHandle,!1),this._edgeView!=null&&this._edgeView.hasObject(r.objectHandle)&&this._edgeView.updateObjectVisibility(r.objectHandle,!1).catch(e=>this._logEdgeViewError(e,this.layer.title)),this._visibleGeometryChanged(r,1),this._labeler!=null&&this._labeler.removeNodeMeta(r),n.delete(e),this._highlights?.objectDeleted(r),n===this._nodeId2Meta?(this._updateFeatureIdCounts(r,-1),this._cacheGPUData(r,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(r)):this._deleteComponentObject(r),this._treeDebugger!=null&&this._treeDebugger.update())}_deleteComponentObject(e){if(this._edgeView!=null&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(let t of e.textures)this._memEstimateTextureRemoved(t),this._stage.removeTexture(t)}updateNodeState(e,t){this._nodeId2Meta.get(e)?.objectHandle.updatePolygonOffset(+(t===0))}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){let n=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,n),this.notifyChange(`elevationRange`)}let n=this._nodeId2MetaReloading.get(e);n&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,n))}_invalidateAllSymbols(){this._rendererVersion=ut(this._rendererVersion,1),this._controller?.requestUpdate()}_getInvalidRendererVersion(){return ut(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange(`rendererTextureUsage`),this._rendererVersion=ut(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.layer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&`arcadeRequired`in e&&e.arcadeRequired&&(this._arcade=await Se()),e&&`visualVariables`in e&&e.visualVariables)for(let t of e.visualVariables)t.type===`color`?this._colorVariable=t:t.type===`opacity`?this._opacityVariable=t:S.getLogger(this).warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(let t of e.symbols)t.type!==`mesh-3d`&&S.getLogger(this).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);let t=e.cachedSymbology;return(n,r)=>{let i=n*e.cachedSymbologyStride;x(r.externalColor,t[i]/255,t[i+1]/255,t[i+2]/255,t[i+3]/255);let a=this._stage.renderView.olidRenderHelper;if(a){let t=e.featureIds[n],i=this.sublayerId?`${this.layerViewUid}_${this.sublayerId}`:this.layerViewUid,o=U(this.view,this.uid);a.setUidToObjectAndLayerId(t,t,this.layerId,i,this.layerPopupEnabledAndHasTemplate&&!o,e.node.resources.attributes,n,this.sublayerId),r.olidColor=a.getObjectAndLayerIdColor({graphicUid:t,layerViewUid:i})}r.externalColorMixMode=t[i+4]&15,r.castShadows=!!(t[i+4]&16),r.pickable=!!(t[i+4]&32),r.elevationOffset=e.elevationOffsets?.[n]??0,r.emissiveStrength=e.emissiveStrengths?.[n]??1,r.emissiveSource=e.emissiveSources?.[n]??0}}_getSymbolInfo(e,t){let n=e?.getSymbol(t,{arcade:this._arcade});if(!(n instanceof G))return null;let r=n.id;if(this._symbolInfos.has(r))return this._symbolInfos.get(r);let i=dt(n);return this._symbolInfos.set(r,i),i}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=this._symbologyOverrideFields!=null&&this._symbologyOverrideFields.length>0?this._rendererFields!=null&&this._rendererFields.length>0?_e(this.layer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;let t=this._tmpAttributeOnlyGraphic,n={};t.attributes=n;let r=this._currentRenderer,i=e.attributeInfo?.attributeData,a=e.featureIds?this.layer.objectIdField:null,o=i!=null&&this._symbologyFields!=null&&this._symbologyFields.length>0,s=null,c=null;if(o&&this._symbologyFields!=null){s=[],c=[];for(let e of this._symbologyFields){let t=i[e];t&&(s.push(e),c.push(t))}}e.cachedSymbology||=z(e.featureIds.length*e.cachedSymbologyStride);let l=new gt,u=this.fullOpacity,d=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):u,f=null,p=1,m=Y,h=0;for(let i=0;i<e.featureIds.length;i++){if(a!=null&&(n[a]=e.featureIds[i]),o&&s)for(let e=0;e<s.length;e++)n[s[e]]=Ue(c[e],i);let u=r?this._getSymbolInfo(r,t):null,g,_;if(l.pickable=!0,r&&`visualVariables`in r){if(this._colorVariable){let e=be(this._colorVariable,t,{color:It,arcade:this._arcade});e&&(g=l.color,g[0]=e.r/255,g[1]=e.g/255,g[2]=e.b/255,g[3]=e.a??1,!this._opacityVariable&&e.a!==null&&(_=e.a))}this._opacityVariable&&(_=xe(this._opacityVariable,t,{arcade:this._arcade}))}if(u?.material){let e=u.material;g=g==null||_==null?ze(g,_,e.color,e.alpha,kt,l.color):ze(g,_,null,null,kt,l.color)}g??=x(l.color,1,1,1,1);let v=u?.material;if(l.colorMixMode=v?.colorMixMode??1,l.edgeMaterial=u?.edgeMaterial,this._symbologyOverride?.(t,l),this._nodeColorOverride!=null&&(this._nodeColorOverride(e.node,g),l.colorMixMode=3),l.pickable&&=g[3]>=we,l.castShadows=u?u.castShadows:l.pickable,l.edgeMaterial!=null){let t=g[3]>=1&&(e.material.isOpaque||l.colorMixMode===3)?1:0;(l.edgeMaterial!==f||t!==p)&&(m={...l.edgeMaterial,opacity:d,objectTransparency:t},f=l.edgeMaterial,p=t),e.cachedEdgeMaterials[i]=m}else e.cachedEdgeMaterials[i]=Y;e.cachedSymbology[h++]=Math.round(g[0]*255),e.cachedSymbology[h++]=Math.round(g[1]*255),e.cachedSymbology[h++]=Math.round(g[2]*255),e.cachedSymbology[h++]=Math.round(g[3]*255),e.cachedSymbology[h++]=l.colorMixMode|l.castShadows<<4|l.pickable<<5;let ee=v?.emissive?.strength==null?Le:v?.emissive?.strength;ee!==Le&&!e.emissiveStrengths&&(e.emissiveStrengths=Array(e.featureIds.length).fill(Le)),e.emissiveStrengths&&(e.emissiveStrengths[i]=ee);let y=v?.emissive?.source||0;y!==0&&!e.emissiveSources&&(e.emissiveSources=Array(e.featureIds.length).fill(0)),e.emissiveSources&&(e.emissiveSources[i]=y)}}_getFilteredEdgeMaterials(e){let t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||X(t,this.fullOpacity);let n=e.filteredIds;if(n==null)return{hasEdges:t.some(e=>e!==Y),perFeatureEdgeMaterials:t};let r=0,i=!1,a=t.map((t,a)=>e.featureIds[a]===n[r]?(i||=t!==Y,r++,t):Y);return{hasEdges:i,perFeatureEdgeMaterials:a}}_updateComponentData(e){if(!this._hasComponentData)return;let{objectHandle:t}=e,n=this._getComponentParameters(e);this._collection.setComponentData(t,n),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),this._controller!=null&&this._controller.restartNodeLoading()}_refreshGroundUsage(){this._intersectionHandler.integratedMeshSemantics=new H(this.layer),this.contentVisible&&(this.view.elevationProvider.unregister(this._elevationProvider),this.view.elevationProvider.register(this._elevationContext,this._elevationProvider)),this._reloadAll(),this.clearMemCache()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach(t=>{t!=null&&(this._collection.updateObjectOpacity(t.objectHandle,e),X(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))})}_updateMaterial(e){e.objectHandle.updateMaterial({slicePlaneEnabled:this.slicePlaneEnabled,usePBR:this._usePBR})}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e).catch(()=>{}),this._visibleGeometryChanged(e,2)}intersect(e,t,n,r,i){return this._intersectionHandler.intersectRay(e,t,n,r,null,!1,i)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this._labeler!=null&&(this._labeler.slicePlaneEnabled=e),this._foreachMeta(t=>{t.objectHandle.updateMaterial({slicePlaneEnabled:e}),this._updateEdgeRendering(t,!1)})}_updatePBR(e){this._foreachMeta(t=>t.objectHandle.updateMaterial({usePBR:e})),this._hasLoadedPBRTextures=!0}_foreachMeta(e){this._nodeId2Meta.forEach(t=>{t!=null&&e(t)})}get _usePBR(){return this._imShading&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){this._edgeView!=null&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t).catch(()=>{})}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?(t,n,r)=>r.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?0:e(t,n,r):e}_forAllFeatures(e,t,n){for(let r of this._nodeId2Meta.values())if(r!=null&&!(t&&r.node.serviceMbsInIndexSR&&t(r.node.serviceMbsInIndexSR)===1))switch(n){case 1:this._forAllFeaturesOfNode(r,e);break;case 0:this._forAllVisibleFeaturesOfNode(r,e);break;case 2:this._forAllQueryableFeaturesOfNode(r,e)}}_forAllFeaturesOfNode(e,t){e.featureIds.forEach((n,r)=>t(n,r,e))}_forAllVisibleFeaturesOfNode(e,t){let n=e.featureIds;this._collection.forEachVisibleComponent(e.objectHandle,r=>t(n[r],r,e)===0)}_forAllQueryableFeaturesOfNode(e,t){let n=this._ignoreClientNodeOverriddenFeatures(t);if(this._renderClippingArea==null)return this._forAllFeaturesOfNode(e,n);let r=this._boundingRectNodeTest(e,this._renderClippingArea);if(r===0)return;if(r===3)return this._forAllFeaturesOfNode(e,n);let i=e.featureIds,a=e.objectHandle,o=ft(this._renderClippingArea,this._collection.getObjectTransform(a));for(let t=0;t<i.length;t++)this._boundingRectFeatureTest(e,t,o)&&n(i[t],t,e)}_createAttributes(e,t){let n={};t.featureIds!=null&&(n[this._getObjectIdField()]=t.featureIds[e]);let r=t.attributeInfo?.attributeData;if(r!=null)for(let t of Object.keys(r))n[t]=Ue(r[t],e);return n}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e,t){let n=Et(e);if(n.length===0)return Dt;let r=Te(t),i=n[0]instanceof B?this._featureIdsFromGraphics(n):typeof n[0]==`number`?n:null;if(!i)return Dt;let a=this._ensureHighlights(),{set:o,handle:s}=a.acquireSet(r);return a.setFeatureIds(o,i),s}_featureIdsFromGraphics(e){let t=this.layer.fieldsIndex,n=this._getObjectIdField();return e.map(e=>Tt(t,e.attributes,n))}_ensureHighlights(){return this._highlights??=new Ve({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,1),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)}),this._highlights}resetHighlights(){this._highlights=w(this._highlights)}_visibleGeometryChanged(e,t){this._elevationProvider&&(this._visibleGeometryChangedSchedulerHandle??=ae(()=>{let{node:t}=e,n=t.visibilityObbInRenderSR??t.geometryObbInRenderSR??t.serviceObbInRenderSR;if(n!=null){let e=P();n.toAaBoundingBox(e),this.emit(`visible-geometry-changed`,new Re(e))}else this.emit(`visible-geometry-changed`);this._visibleGeometryChangedSchedulerHandle=null}),this._updateSnappingSources(e,t),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}get performanceInfo(){return new vt(this.usedMemory,this._nodeId2Meta.size,Math.round(this._gpuMemoryEstimate/1048576),Math.round(this._geoMemoryEstimate/1048576),Math.round(this._texMemoryEstimate/1048576),Math.round(this.unloadedMemory/1048576),this._idbCacheEnabled?Math.round(this._idbCache.getHitRate()*100):0)}checkInvariants(){}get test(){}getNodeOpacityByIndex(e){let t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return e==null?0:this._collection.getObjectOpacity(e.objectHandle)}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}getNodeComponentHandle(e){return this._nodeId2Meta.get(e)?.objectHandle}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(e)}fadeNode(e,t,n){if(!this.nodeCrossfadingEnabled)return;let r=this._nodeId2Meta.get(e);r!=null&&this._crossfadeHelper.fadeNode(e,r,t,n)}setNodeOpacityByIndex(e,t){let n=this._nodeId2Meta.get(e);n!=null&&this._setNodeOpacity(n,t)}_setNodeOpacity(e,t){this._collection.updateObjectOpacity(e.objectHandle,t),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(this._edgeView==null||!e.cachedEdgeMaterials)return;X(e.cachedEdgeMaterials,t);let n=e.objectHandle;this._edgeView.hasObject(n)&&this._edgeView.updateAllComponentOpacities(n,t).catch(e=>this._logEdgeViewError(e,this.layer.title))}get hasModifications(){return this._isIntegratedMesh&&this._layerClippingArea!=null||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){let t=e.length;if(!this.hasModifications||t<=0||this._i3sWasmLoaded!==!0)return;let n=this.uid,r=Ht(e);if(r){let t={context:n,buffer:r.buffer};xt(t);let i=new Float64Array(r.buffer);e.forAll((e,t)=>{let n=i[t],r=St(n);e.imModificationImpact=r,r!==0&&this._controller.invalidateGeometryVisibility(e.index)})}}notifyUpdate(){this.notifyChange(`updating`)}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!!(this._controller&&this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||this._labeler!=null&&this._labeler.updating||this._crossfadeHelper?.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||this._elevationTask!=null&&this._elevationTask.readyToRun||this._needFilterResolve||this._compressionTracker.compressing}trackSnappingSources(e){let t={events:e,fetchEdgeLocations:async(e,t,n)=>{let r=this._nodeId2Meta.get(e);if(r==null)throw Error(`invalid-node`);let{origin:i,buffer:a}=await this._collection.extractEdgeInformation(r.objectHandle,t,n);return this._snappingLocationsApplyElevation(r,a,i),{type:`components`,objectIds:r.featureIds,locations:a,origin:i}},remove:()=>i(this._snappingSourcesTrackers,t)};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach((t,n)=>{if(t==null)return;let r=this._controller.getRenderMbs(t.node);r&&e.add(n,r)}),t}_snappingLocationsApplyElevation(e,t,n){if(!e.elevationOffsets||this.elevationInfo.mode===0)return;let r=t.position0,i=t.position1,a=t.componentIndex,o=b(),s=b(),c=(e,t)=>{y(e,e,n),this.view.renderCoordsHelper.worldUpAtPosition(e,s),y(e,e,te(s,s,t)),ne(e,e,n)};for(let t=0;t<r.count;t++){let n=e.elevationOffsets[a.get(t)];r.getVec(t,o),c(o,n),r.setVec(t,o),i.getVec(t,o),c(o,n),i.setVec(t,o)}}_updateSnappingSources(e,t){let{index:n}=e.node,r=this._controller.getRenderMbs(e.node);if(r!=null)for(let e of this._snappingSourcesTrackers)(t===1||t===2)&&e.events.remove(n),(t===0||t===2)&&e.events.add(n,r)}_logEdgeViewError(e,t){D(e)||S.getLogger(this).warn(`Error while processing edges. Edges on this layer might not display correctly`,t,e)}_indexedDbSizeCheck(e,t){return t.byteSize>0x6400000?(S.getLogger(this).warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}get elevationProvider(){return this._elevationProvider}};return e([n()],R.prototype,`extractChanges`,null),e([n()],R.prototype,`_hasLoadedPBRTextures`,void 0),e([n()],R.prototype,`_asyncModuleLoading`,void 0),e([n()],R.prototype,`_visibleGeometryChangedSchedulerHandle`,void 0),e([n()],R.prototype,`view`,void 0),e([n()],R.prototype,`layer`,void 0),e([n()],R.prototype,`_controller`,void 0),e([n()],R.prototype,`_labeler`,void 0),e([n()],R.prototype,`updating`,void 0),e([n()],R.prototype,`suspended`,void 0),e([n()],R.prototype,`contentVisible`,null),e([n({readOnly:!0})],R.prototype,`legendEnabled`,null),e([n(Ae)],R.prototype,`updatingProgress`,void 0),e([n()],R.prototype,`updatingProgressValue`,null),e([n()],R.prototype,`hasTexturesOrVertexColors`,null),e([n()],R.prototype,`rendererTextureUsage`,null),e([n()],R.prototype,`elevationOffset`,null),e([n()],R.prototype,`elevationInfo`,null),e([n({type:Boolean})],R.prototype,`slicePlaneEnabled`,void 0),e([n()],R.prototype,`supportedTextureEncodings`,null),e([n({type:[ye]})],R.prototype,`_modifications`,void 0),e([n({readOnly:!0})],R.prototype,`clientGeometry`,null),e([n()],R.prototype,`elevationRange`,null),e([n()],R.prototype,`fullExtent`,null),e([n()],R.prototype,`_elevationTask`,void 0),e([n({readOnly:!0})],R.prototype,`_usePBR`,null),R=e([r(`esri.views.3d.layers.I3SMeshView3D`)],R),R},Mt=P(),Nt=F(),Pt=F(),Ft=new J,It=new t([0,0,0,0]),Lt=new R(0,0,0,0);function Rt(e){if(e==null)return!1;let t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function zt(e){return`geometryData`in e}function Bt(e){return e!=null&&j(e.data)}function Vt(e,t){let n=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(t!=null)for(let e of t)e!=null&&j(e.data)&&(n+=e.data.byteLength);return n}function Ht(e){if(e.length===0)return;let t=e.length*10,n=new Float64Array(t),r=0;return e.forAll(e=>{let t=e.serviceObbInIndexSR;t??(t=Ft,e.serviceMbsInIndexSR?(t.setCenter(e.serviceMbsInIndexSR.center),t.setHalfSizeFromValues(e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius)):t.invalidate());let i=t.data;n[r++]=i[0],n[r++]=i[1],n[r++]=i[2],n[r++]=i[3],n[r++]=i[4],n[r++]=i[5],n[r++]=i[6],n[r++]=i[7],n[r++]=i[8],n[r++]=i[9]}),n}class Ut{constructor(e,t,n){this.attributeInfo=e,this.meta=t,this.promise=n,this.allowMemCache=!0}}function X(e,t){e.forEach(e=>e.opacity=t)}class Z{constructor(e,t){this.mode=e,this.offset=t}}const Wt=b(),Gt=P(),Kt=`elevation-change`,qt=``,Jt=`@null`,Yt=`@ECEF`;function Xt(e,t){let n=e.featureIds.slice();for(let r of t)if(r(n,e),n.length===0)break;return n.length===e.featureIds.length?e.featureIds:n}function Zt(e,t,n){let r=[],i=e.filteredIds;if(i!=null&&!t?.size&&!n?.size)e.featureIds.forEach((e,t)=>{i[r.length]===e&&r.push(t)});else if(i!=null){let a=0;e.featureIds.forEach((e,o)=>{if(i[a]===e)++a;else if(!t?.has(e))return;n?.has(e)||r.push(o)})}return r}function Q(e,t,n){if(e&&t)for(let r of t){let t=(e.get(r)??0)+n;t>0?e.set(r,t):e.delete(r)}}function $(e,t=0){let n=new Map;for(let r of e)Q(n,t===0?r?.featureIds:t===1?r?.filteredIds:r?.weaklyRemovedIds,1);return n}const Qt=b();export{jt as I3SMeshView3D};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../../core/accessorSupport/decorators.js";import has from"../../../core/has.js";import{fromMat4 as r,invert as i}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as a,IDENTITY as o}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as s}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as c}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as l,sub as u,dot as d,set as f}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p,freeze as m,clone as h,ZEROS as g,fromValues as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as v,clone as y,ONES as b}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import x from"../../../core/Logger.js";import{abortMaybe as S,destroyMaybe as C,removeMaybe as w}from"../../../core/maybe.js";import{throwIfAborted as T,createAbortError as E}from"../../../core/promiseUtils.js";import{initial as D,watch as O,when as k}from"../../../core/reactiveUtils.js";import{schedule as A}from"../../../core/scheduling.js";import{isUint8Array as j,isFloat32Array as M,isUint32Array as N,isUint16Array as ee}from"../../../core/typedArrayUtil.js";import{isMoon as te,isMars as ne,getReferenceEllipsoid as P,SphericalECEFSpatialReferenceLike as re}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as ie}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as ae}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as oe}from"../../../geometry/projection/projectVectorToVector.js";import{create as F}from"../../../geometry/support/aaBoundingRect.js";import{BufferViewVec4u8 as se,BufferViewVec3u8 as ce,BufferViewVec2f as I,BufferViewVec3f as L,BufferViewUint32 as R,BufferViewUint16 as z}from"../../../geometry/support/buffer/BufferView.js";import{isInEffectiveScaleRange as le,validateScaleRange as ue}from"../../../geometry/support/scaleUtils.js";import{isCGCS2000 as B}from"../../../geometry/support/spatialReferenceUtils.js";import{nullId as V}from"../../../layers/ILyr3DWasmPerSceneView.js";import{IntegratedMeshSemantics as H}from"../../../layers/support/IntegratedMeshSemantics.js";import U from"../../../layers/support/SceneModification.js";import{validateEntity3D as de,makeCacheKey as W,isValidHandle as G}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as K}from"../../../support/elevationInfoUtils.js";import{alphaCutoff as q}from"../../../webscene/support/AlphaCutoff.js";import fe from"../../layers/LayerView.js";import{TaskPriority as pe}from"../../support/Scheduler.js";import{CompressedTextureFormat as J,SizedPixelFormat as Y}from"../../webgl/enums.js";import{Frustum as me}from"../state/Frustum.js";import{glLayout as he}from"../support/buffer/glUtil.js";import{ElevationRange as ge}from"../support/ElevationRange.js";import{toBoundingRect as _e}from"../support/extentUtils.js";import{Obb as X}from"../support/orientedBoundingBox.js";import{getGroundTransparencyModeFromOpacity as ve}from"../terrain/TransparencyMode.js";import{ComponentGeometryParameters as ye,SourceGeometry as be}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as xe}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Se}from"../webgl-engine/core/material/RenderTexture.js";import{ManagedTexture as Ce}from"../webgl-engine/lib/ManagedTexture.js";import{compressNormals as we}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as Te}from"../webgl-engine/materials/pbrUtils.js";import{IntegratedMesh3DTilesLayerWorkerHandle as Ee}from"./IntegratedMesh3DTilesLayerWorkerHandle.js";import{LayerView3D as De}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as Oe}from"./Lyr3DViewPerformanceInfo.js";import{getLyr3DWasm as ke}from"./Lyr3DWasm.js";import{toWasmModification as Ae}from"./SceneLayerWorkerHandle.js";import{IntegratedMesh3DTilesLayerView3DSymbol as je}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as Me,alphaModeConversion as Ne,faceCullingConversion as Pe,wrapModeConversion as Fe}from"./support/lyr3dTypeConversions.js";import{makeScheduleFunction as Ie}from"./support/makeScheduleFunction.js";import{intersectsRay as Le,intersectsSphere as Re}from"./support/tileBoundingVolumeUtils.js";import{Tiles3DLayerViewRegistration as ze}from"./support/Tiles3DLayerViewRegistration.js";import{Tiles3DMeshIntersectionHandler as Be}from"./support/Tiles3DMeshIntersectionHandler.js";var Z;function Ve(e,t,n){if(t===`image/vnd-ms.dds`)switch(n){case`Dxt1`:return J.COMPRESSED_RGB_S3TC_DXT1_EXT;case`Dxt5`:return J.COMPRESSED_RGBA_S3TC_DXT5_EXT;default:return null}if(t===`image/ktx`)return n===`Etc1`?J.COMPRESSED_RGB8_ETC2:null;switch(e){case 33319:return Y.RG8;case 6407:return Y.RGB8;case 6408:return Y.RGBA8;case 6403:return Y.R8;default:return null}}let Q=class extends De(fe){static{Z=je}constructor(e){super(e),this[Z]=!0,this.type=`integrated-mesh-3dtiles`,this._registration=new ze(this),this.skipHeightModelInfoValidation=!0,this.freeze=!1,this._modifications=[],this._visibleGeometryChangedSchedulerHandle=null,this._initializationController=null,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.fullExtentInLocalViewSpatialReference=null,this._applySSAO=!has(`disable-feature:im-ssao`),this._imShading=!!has(`enable-feature:im-shading`),this._imVertexNormals=!!has(`enable-feature:im-vertex-normals`),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._dbgFlags=new Set;let t=e.view.resourceController;this._memCache=t.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._replacesTerrain=e.layer.replacesTerrain,this._frameTask=t.scheduler.registerTask(pe.TILES3D,this),this._frustum=new me(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{T(t);let n=this.layer.queryElevationCallback;this.layer=e,this.layer.queryElevationCallback=n}):null}canRecycleWith(e){return e.url===this.layer.url&&e.type===`integrated-mesh-3dtiles`&&e.replacesTerrain===this._replacesTerrain}initialize(){this._dbg(2,`Tiles3DLayerView3D initialize() called`);let{view:e}=this;this._workerHandle=new Ee(Ie(e.resourceController)),this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),D),this._initializationController=new AbortController,this.addResolvingPromise(this._registration.initialize(this._initializationController.signal,()=>this._initializeRegistered(e)))}_initializeRegistered(e){let t=new Be(this,new H(this.layer,this.replacesTerrain));this._intersectionHandler=t,this._registration.registerQueries(t,this._getElevationContext()),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged()),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.overlayManager.renderer.isEmpty,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),D),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),D),this._updatingHandles.add(()=>this.layer.isUsedAsGroundLayer,()=>this._groundUsageChanged()),e.overlayManager.registerDrapeTarget(this),this.addHandles([O(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),k(()=>this.fullOpacity,()=>this._opacityChange())]),this._registration.synchronizeSuspension(),this.addHandles(O(()=>this.freeze,e=>{e?this._wasm?.incrementFrozenLayerViewCount(this):(this._wasm?.decrementFrozenLayerViewCount(this),this._cameraChanged())})),this._initializationController=null,this.addHandles(O(()=>this._replacesTerrain&&!!this._wasm?.isTerrainReady||!this._replacesTerrain&&H.contributesToGroundElevation(this.layer),e=>{this.layer.queryElevationCallback=e?(e,t)=>this._queryElevation(e,t):null},D))}destroy(){this.freeze=!1,this._initializationController=S(this._initializationController),this._dbg(2,`Tiles3DLayerView3D destroy() called`),this._workerHandle?.destroyContextAndSelf(this.uid),this._registration.unregisterWasm(),this.layer.queryElevationCallback=null,this._registration.unregisterQueries(e=>{let t=Array.from(this._lyrHandleToObjects.values()),n=t.reduce((e,{componentObjects:t})=>e+t.length,0);e.notifyObjectsChangedFunctional(n,e=>{for(let{componentObjects:n}of t)for(let{obb:t}of n)if(!e(t))return})}),this._intersectionHandler=null,this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._frameTask.remove(),this._updatingHandles=C(this._updatingHandles),this.emit(`visible-geometry-changed`),this._visibleGeometryChangedSchedulerHandle=w(this._visibleGeometryChangedSchedulerHandle)}get usedAsGround(){return this.layer.isUsedAsGroundLayer}get replacesTerrain(){return this._replacesTerrain}get fullOpacity(){switch(H.opacitySource(this.layer,this.replacesTerrain)){case`ground`:return this.view.map.ground.opacity;case`layer`:return this.layer.opacity;case`opaque`:return 1}}get opaque(){return this._groundTransparencyMode===0}get invisible(){return this._groundTransparencyMode===3}get _groundTransparencyMode(){return H.opacitySource(this.layer,this._replacesTerrain)===`ground`?ve(this.fullOpacity,this.view.overlayManager.renderer.isEmpty):0}get _renderOpacity(){switch(this._groundTransparencyMode){case 3:return 0;case 2:return q;default:return this.fullOpacity}}get hasModifications(){return this._modifications&&this._modifications.length>0}_opacityChange(){let e=this._renderOpacity,t=this._groundTransparencyMode;this.forEachComponentObject(n=>this._collection.updateObjectOpacity(n,e,t))}_getElevationContext(){return this.replacesTerrain?0:H.shouldUseSceneElevationContext(this.layer)?2:1}_groundUsageChanged(){this._registration.setElevationContext(this._getElevationContext());let e=new H(this.layer,this.replacesTerrain);this._intersectionHandler.integratedMeshSemantics=e,this._intersectionHandler.slicePlaneEnabled=this.slicePlaneEnabled&&!this.replacesTerrain,this.view.overlayManager.unregisterDrapeTarget(this),this.view.overlayManager.registerDrapeTarget(this),this._loadModifications();let t=this._renderOpacity,n=this._groundTransparencyMode;this.forEachComponentObject(r=>r.updateMaterial({opacity:t,groundTransparencyMode:n,integratedMeshSemantics:e}))}_cameraChanged(){if(this.freeze)return;let e=this._frustum;e.update(this.view.state.contentCamera);let t=this._visibleObjects,n=!1;this._loadedObjects.forEach(r=>{let i=r.obb?.intersectsFrustum(e)??!1;i!==r.isVisible&&(r.isVisible=i,i?t.add(r):t.delete(r),r.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,i)),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(i,r.elevationRange))}),n&&this._setVisibleElevationRangeDirty()}intersect(e,t,n,r){this._intersectionHandler.intersectRay(e,t,n,r,null,!1)}get ready(){return!this.replacesTerrain||!!this._wasm?.isTerrainReady}_modificationsChanged(){let e=this.useEsriCrs?this.layer.supportedSpatialReferences[1]:this.layer.supportedSpatialReferences[0],t=Ae(this._layerClippingArea,this._modifications,e,this.view.state.isGlobal);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){let e=this.layer.spatialReference,t=F();this._layerClippingArea=_e(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=A(()=>{this.emit(`visible-geometry-changed`),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.replacesTerrain),this.forEachComponentObject(t=>t.updateMaterial({slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,K(e))}get _wasm(){return ke(this.view)}_queryElevation(e,t){return this.destroying||this.destroyed?Promise.reject(E()):this._wasm?.queryElevation(this,e,t)??Promise.reject(E())}get wasmLayerId(){return this._registration.wasmLayerId}get metersPerVCSUnit(){return this._registration.metersPerVCSUnit}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get useEsriCrs(){return this._registration.useEsriCrs}get visibleAtCurrentScale(){return this.replacesTerrain||le(this.layer.effectiveScaleRange,this.view.scale)}canResume(){let e=this.layer&&`effectiveScaleRange`in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.replacesTerrain||ue(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,n=0,r=0,i=0,a=0;return this._lyrHandleToObjects.forEach(o=>{o.isLoaded?(e+=o.textureMemoryUsage,t+=o.vboMemoryUsage,i++):(n+=o.textureMemoryUsage,r+=o.vboMemoryUsage,a++)}),new Oe(this.usedMemory,i,a,$(t),$(e),$(r),$(n))}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._registration.elevationProvider}get elevationOffset(){return K(this.layer.elevationInfo)}get elevationRange(){return this._intersectionHandler?.elevationRange}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){let e=new ge;this._visibleObjects.size===0?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this._forEachRelevantVisibleTile(t=>e.expandElevationRange(t.elevationRange)),e.minElevation===1/0&&e.setElevationRangeValues(0,0));let t=this._get(`visibleElevationRange`);return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange(`visibleElevationRange`)}_forEachRelevantVisibleTile(e){let{view:t}=this,{spatialReference:n}=t,r=n.isWGS84||n.isWebMercator||B(n)||te(n)||ne(n);if(this.view.state.isGlobal||!r)return this.forEachVisibleTile(e);let i=P(n).radius,{eye:a,viewForward:o,near:s}=t.state.contentCamera,c=l(p(),o),f=Math.max(a[2],500),m=f+i,h=Math.sqrt(m**2-i**2),g=Math.abs(Math.atan2(h,i))*i,_=f>.5*i?.5*Math.PI*i:g,v=p();this.forEachVisibleTile(t=>{let{mbsRadius:n,mbsCenter:r}=t;if(n<0)return;u(v,r,a);let i=d(v,c);Math.abs(i)<_&&i+n>s&&i-n<_&&e(t)})}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(let t of this._visibleObjects)e(t)}forEachTile(e){for(let t of this._loadedObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(let{componentObjects:n}of e)for(let e of n)t(e)}get drapeTargetType(){return+!H.shouldDrapeRaster(this.layer,this.replacesTerrain)}isUpdating(){let e=this._wasm;return!this.freeze&&this.wasmLayerId>=0&&e!=null&&e.isUpdating(this.wasmLayerId)}get readyToRun(){return!!this._frameTask?.readyToRun}runTask(e){this._frameTask.processQueue(e)}updatingFlagChanged(){this.notifyChange(`updating`)}async createRenderable(e){if(this.destroyed||this.destroying)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy`);let{entity3d:t}=e;if(!de(t))throw Error(`entity3D not valid`);let n=new Map,r;try{r=this._createPrimitiveTextureBundles(t,n)}catch(e){throw n.forEach(e=>this._stage?.removeTexture(e)),e}let i=null;try{if(i=await this._createRenderableMain(t,r),this.destroyed)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderable aborted due to destroyed instance`);let{tileObb:a,componentObjects:o,elevationRange:s}=i,c=0,l=0,u=0;for(let e of o){let{texture:t,textureMetallicRoughness:n,textureEmissive:r,textureOcclusion:i,textureNormal:a}=e.renderable.drawParameters;c+=(t?.usedMemory??0)+(n?.usedMemory??0)+(r?.usedMemory??0)+(i?.usedMemory??0)+(a?.usedMemory??0),l+=this._collection.getObjectGPUMemoryUsage(e),u+=e.intersectionGeometry.usedMemory}let d=Array.from(n.values()),f=new Ue(e.handle,o,d,u,l,c,a,e.stableNodeId,e.nodeDepth,s);return this._lyrHandleToObjects.set(e.handle,f),()=>{this._memCache.put(W(f.handle),f);let{usedMemory:e}=f;return this._cacheMemory+=e,{memUsageBytes:e}}}catch(e){throw r.forEach(e=>e.cleanup()),i?.componentObjects.forEach(e=>this._collection.destroyObject(e)),n.forEach(e=>this._stage?.removeTexture(e)),e}}_createPrimitiveTextureBundles(e,t){let n=[];try{let r=e.desc.geometry;for(let i of e.validPrimitiveIndices){let a=r.prims[i].materialId,o=e.desc.materials?.materials&&a!=null&&a!==V?e.desc.materials.materials[a]:null,s=Promise.resolve(Ge),c=null,l=null,u=null,d=null,f=null;if(o){let n=o.lightingModel===`Pbr`;c=this._getTexture(o.baseColorTex,e,t),l=n?this._getTexture(o.metalTex,e,t):null,u=n?this._getTexture(o.emissiveTex,e,t):null,d=n?this._getTexture(o.occlusionTex,e,t):null,f=n?this._getTexture(o.normalTex,e,t):null;let r=[c,l,u,d,f].map(e=>e?.loadPromise??null);s=Promise.all(r)}n.push(new Ke(s,c,l,u,d,f))}}catch(e){throw n.forEach(e=>e.cleanup()),e}return n}async _createRenderableMain(e,t){if(this.destroyed||this.destroying)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderableMain called after destroy`);let n=[],c=e.desc,l=m(...e.origin),u=this.view.groundView.spatialReference,d=this.view.state.isGlobal,f=o;if(d){let e=s();ie(re,l,e,u),f=r(a(),e)}let h=We(c.obb),g=d?P(this.view.spatialReference).radius:0,_=d?Math.hypot(h.centerX,h.centerY,h.centerZ)-g:h.centerZ,y=d?Math.max(-g,_-h.radius):_-h.radius,b=_+h.radius,x=[];try{let r=-1;for(let n of e.validPrimitiveIndices){r+=1;let i=c.geometry.prims[n],a=t[r];if(this._dbgFlags.has(2)&&this._dbg(2,JSON.stringify(i)),Me[i.ptype]==null){this._dbg(2,`[Unsupported Feature] Unsupported primitive mode (`+i.ptype+`). Skipping primitive.`),a.cleanup();continue}let{positionView:o,normalsData:s,colorView:l,texCoord0Data:u,indicesView:d}=this._getBufferViews(i,e);if(o==null||d==null){a.cleanup();continue}let f=o.count,p=(e,t)=>e!=null&&e!==f?(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1):!0;!p(u==null?void 0:u.length/2,`numTexcoord`)||!p(l?.count,`numColors`)||!p(s?.length,`normals`)?a.cleanup():x.push({componentIndex:r,positionView:o,indicesView:d,texCoord0Data:u,colorView:l,normalsData:s})}let s=f!==o,m=s?i(a(),f)??o:o,{vertexProcessingOutputs:_,obbHalfSizeAccumulator:S,elevationRange:C}=await this._workerHandle.processTiles3DVertices(x,l,g,d,f,h,this._imVertexNormals&&H.shouldGenerateVertexNormals(this.layer));if(this.destroyed)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance`);let w=c.materials;if(await Promise.all(t.map(e=>e.materialPromise)),this.destroyed)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance`);_.length>0&&h.setHalfSize(S);for(let r of _){let{componentIndex:i,positionView:a,indicesView:o,layout:d,textureCoordinateType:f,interleavedVertexData:g,indices:_,aabbInWorldCoordinates:y}=r,b=e.validPrimitiveIndices[i],x=c.geometry.prims[b],S=t[i],C=h.clone(),T=he(d),E=new Uint32Array([0,o.typedBuffer.length]),D=new ye(T,this._imShading?2:0,f,s?2:0),O=new be({interleavedVertexData:g,vertexCount:g.byteLength/T[0].stride,indexData:_},{positions:a.typedBuffer,indices:o.typedBuffer},E,D),k=this.view.renderSpatialReference,A=p(),j=[1,1,1];ae(l,k,j,u)||this._dbg(3,`Unsupported coordinate system for IM overlay`),oe(l,k,A,u);let M=this._createComponentMaterialInitParameters(w,x.materialId,S);M.baseColorTexture||this._dbg(3,`No colour texture 1`);let N=this._collection.createObject({toMapSpace:v(A[0],A[1],j[0],j[1]),transform:new xe(l,m),obb:C,geometry:O,elevationAlignable:!1,aabbInWorldCoordinates:y},M);n.push(N)}return C.minElevation=Math.max(C.minElevation,y),C.maxElevation=Math.min(C.maxElevation,b),{tileObb:h,componentObjects:n,elevationRange:C}}catch(e){throw n.forEach(e=>this._collection.destroyObject(e)),e}}_createComponentMaterialInitParameters(e,t,n){let r=e?.materials!=null&&t!=null&&t!==V?e.materials[t]:null,i=1,a=r?.baseColorTex?.imageId;if(a!=null&&e&&Array.isArray(e.images)&&a>=0&&a<e.images.length){let t=e.images[a];t.alpha&&(i=Ne[t.alpha])}let o=(r==null?`Unlit`:r.lightingModel)===`Pbr`,s=b,c=q,l=!1,u=2,d=_(0,0,0),p=h(Te),m=n.baseColorTexture,g=n.metallicRoughnessTexture,v=n.emissionTexture,x=n.occlusionTexture,S=n.normalTexture;return r&&(s=y(r.baseColorFactor),c=r.alphaCutoff??q,o&&(f(p,r.metallicFactor,r.roughnessFactor,0),r.emissiveFactor&&(d=r.emissiveFactor)),l=r.isDoubleSided,u=Pe[r.faceCulling??`NotSet`]),{isIntegratedMesh:!0,integratedMeshSemantics:new H(this.layer,this.replacesTerrain),baseColor:s,textureAlphaCutoff:c,mrrFactors:p,baseColorTexture:m,metallicRoughnessTexture:g,normalTexture:S,occlusionTexture:x,emissionTexture:v,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:i,doubleSided:l,cullFace:u,groundTransparencyMode:this._groundTransparencyMode,emissiveBaseColor:d,usePBR:o,slicePlaneEnabled:this.slicePlaneEnabled,opacity:this._renderOpacity,polygonOffset:0,ellipsoidMode:1,applySSAO:this._applySSAO}}freeRenderable(e){let t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._intersectionHandler.removeTile(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){let t=W(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,n){if(this.destroyed||this.destroying)return;let r=this._frustum,i=[],a=!1,o=!1;for(let s=0;s<n;++s){if(!t[s])continue;let n=e[s],c=this._lyrHandleToObjects.get(n);if(c){if(c.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${c.stableNodeId}`);continue}a=!0,c.isLoaded=!0,this._loadedObjects.add(c),this._intersectionHandler.addTile(c),this._usedMemory+=c.usedMemory,this._cacheMemory-=c.usedMemory;let e=c.obb?.intersectsFrustum(r)??!0;c.isVisible=e,e&&(this._visibleObjects.add(c),o||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,c.elevationRange)),i.push(c.obb),c.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(W(n))}else this._dbg(3,`Tried to mark Non existent object ${n} as loaded`)}for(let r=0;r<n;++r){let n=e[r];if(t[r])continue;let a=this._lyrHandleToObjects.get(n);if(a){if(!a.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${a.stableNodeId}`);continue}let e=a.isVisible;this._visibleObjects.delete(a),a.isVisible=!1,a.isLoaded=!1,this._loadedObjects.delete(a),this._intersectionHandler.removeTile(a),e&&(this._visibleGeometryChanged(),o||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,a.elevationRange)),this._usedMemory-=a.usedMemory,this._cacheMemory+=a.usedMemory,i.push(a.obb),a.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(W(n),a)}else this._dbg(3,`Tried to mark Non existent object ${n} as not loaded`)}a&&this._visibleGeometryChanged(),i.length>0&&this.elevationProvider.notifyObjectsChanged(i),o&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){let{visibleElevationRange:n}=this,{minElevation:r,maxElevation:i}=t;return e?r<n.minElevation||i>n.maxElevation:r===n.minElevation||i===n.maxElevation}_getTexture(e,t,n){let r=e&&t.desc.materials?.images?.[e.imageId];if(!r||!G(r.data))return null;let i=t.assets[r.data];if(!i||i.byteCount<1||i.dataType!==`U8`)return null;let a=n.get(r)??this._createTexture(e,r,i,n);return a?new Se(this._stage.renderView.textures,a.id):null}_createTexture(e,t,n,r){let i=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,a=t.mipCount?!0:i>1,o=Fe[e.wrapMode??`None`],s=t.alpha?6408:6407,c=new Uint8Array(n.data.buffer,0,n.byteCount),l=null,u=null;switch(t.format){case`Raw`:if(t.pixelFormat===`R8`)l=c,s=6403,u=``;else if(t.pixelFormat===`Rg8`||t.pixelFormat===`Ga8`)l=c,s=33319,u=``;else if(t.pixelFormat===`Rgb8`)l=c,s=6407,u=``;else if(t.pixelFormat===`Rgba8`)l=c,s=6408,u=``;else return x.getLogger(this).error(`Raw texture pixel format ${t.pixelFormat} not supported`),null;break;case`Dxt1`:l=c,s=6407,u=`image/vnd-ms.dds`;break;case`Dxt5`:l=c,s=6408,u=`image/vnd-ms.dds`;break;case`Basis`:l=c,s=6407,u=`image/ktx2`;break;case`Etc1`:l=c,s=6407,u=`image/ktx`;break;default:return x.getLogger(this).error(`${t.format} texture not supported`),null}if(l&&u!=null){let e=Ve(s,u,t.format),n=new Ce(l,{mipmap:a,maxAnisotropy:i,encoding:u,wrap:o,pixelFormat:s,internalFormat:e??void 0,immutable:e!=null,noUnpackFlip:!0,width:t.mip0Width,height:t.mip0Height});return this._stage.addTexture(n),r.set(t,n),n}return null}_getBufferViews(e,t){let n,r,i,a;for(let o=0;o<e.atrbs.length;o++){let s=e.atrbs[o],c=t.assets[s.assetId];if(!c)continue;let l=c.data.buffer,u=c.byteCount;try{switch(s.sem){case`Position`:c.ncomp!==3||c.dataType!==`F32`||!M(c.data)?this._dbg(3,`[Unsupported Feature] Unsupported view for Position (`+c+`)`):n=new L(l,0,void 0,u);break;case`Normal`:if(c.ncomp!==3||c.dataType!==`F32`||!M(c.data))this._dbg(3,`[Unsupported Feature] Unsupported view for Normal (`+c+`)`);else{let e=new L(l,0,void 0,u);a=new Uint32Array(e.count),we(e.typedBuffer,new Int16Array(a.buffer,a.byteOffset,a.length*2))}break;case`TexCoord`:c.ncomp!==2||c.dataType!==`F32`||!M(c.data)?this._dbg(3,`[Unsupported Feature] Unsupported view for Texcoord (`+c+`)`):i===void 0&&(i=new I(l,0,void 0,u).typedBuffer);break;case`Color`:c.dataType===`U8`&&j(c.data)&&(c.ncomp===4?r=new se(l,0,void 0,u):c.ncomp===3&&(r=new ce(l,0,void 0,u))),r??this._dbg(3,`[Unsupported Feature] Unsupported view for Color (`+c+`)`);break;case`FeatureIndex`:break;default:this._dbg(2,`[Unsupported Feature] Unsupported semantic (`+s.sem+`). Skipping vertex attribute.`)}}catch(e){this._dbg(2,`Error Creating buffer (`+e+`). Skipping vertex attribute.`)}}let o,s=!1;if(G(e.index)){let n=t.assets[e.index];if(!n)s=!0;else{let e=n.byteCount;switch(n.dataType){case`U16`:n.ncomp===1&&ee(n.data)&&(o=new z(n.data.buffer,0,void 0,e));break;case`U32`:n.ncomp===1&&N(n.data)&&(o=new R(n.data.buffer,0,void 0,e))}s=!o}}if(!s&&o==null&&n!=null){let e=n.count;o=o=e<65535?new z(new Uint16Array(e).buffer):new R(new Uint32Array(e).buffer);for(let t=0;t<e;t++)o.set(t,t)}return{positionView:n,colorView:r,texCoord0Data:i,indicesView:o,normalsData:a}}_loadModifications(){if(this.removeHandles(`modifications`),this.layer.modifications==null){this._modifications=[];return}let e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>H.shouldApplyModification(this.layer,e.type)).toArray(),this._modifications.length<e.length&&x.getLogger(this).info(`Ground layers only support replace modifications. Other modification types have been ignored.`)},D),`modifications`)}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,t){this._dbgFlags.has(e)&&(e===3?x.getLogger(this).error(t):x.getLogger(this).warn(t))}};e([t()],Q.prototype,`freeze`,void 0),e([t()],Q.prototype,`fullOpacity`,null),e([t()],Q.prototype,`opaque`,null),e([t()],Q.prototype,`invisible`,null),e([t({readOnly:!0})],Q.prototype,`ready`,null),e([t({type:[U]})],Q.prototype,`_modifications`,void 0),e([t()],Q.prototype,`_visibleGeometryChangedSchedulerHandle`,void 0),e([t()],Q.prototype,`layer`,void 0),e([t({readOnly:!0})],Q.prototype,`visibleAtCurrentScale`,null),e([t({readOnly:!0})],Q.prototype,`_collection`,null),e([t()],Q.prototype,`elevationOffset`,null),e([t({readOnly:!0})],Q.prototype,`visibleElevationRange`,null),e([t()],Q.prototype,`fullExtentInLocalViewSpatialReference`,void 0),Q=e([n(`esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D`)],Q);const He=Q;class Ue{constructor(e,t,n,r,i,a,o,s,c,l){this.handle=e,this.componentObjects=t,this.textures=n,this.cpuMemoryUsage=r,this.vboMemoryUsage=i,this.textureMemoryUsage=a,this.obb=o,this.stableNodeId=s,this.nodeDepth=c,this.elevationRange=l,this.bvhIntersectionGeneration=0,this.isLoaded=!1,this.isVisible=!1;let u=p();o?.getCenter(u),this._obbCenterX=u[0],this._obbCenterY=u[1],this._obbCenterZ=u[2];let d=o?.radius??-1;this._obbRadius=d,this._obbRadiusSquared=d*d,this._obbShortestHalfsize=o?Math.min(o.halfSizeX,o.halfSizeY,o.halfSizeZ):0,this._mbsCenter=o?o.getCenter(p()):g}get usedMemory(){return this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this._mbsCenter}boundingVolumeIntersectsRay(e,t){return Le(this.obb,this._obbCenterX,this._obbCenterY,this._obbCenterZ,this._obbRadiusSquared,e,t)}boundingVolumeIntersectsSphere(e){return Re(this.obb,this._obbCenterX,this._obbCenterY,this._obbCenterZ,this._obbRadius,this._obbShortestHalfsize,e)}}function $(e){return Math.round(e/1048.576)/1e3}function We(e){return new X(e.center,e.halfSize,c(...e.quaternion))}const Ge=[];class Ke{constructor(e,t,n,r,i,a){this.materialPromise=e,this.baseColorTexture=t,this.metallicRoughnessTexture=n,this.emissionTexture=r,this.occlusionTexture=i,this.normalTexture=a}cleanup(){this.baseColorTexture?.dispose(),this.metallicRoughnessTexture?.dispose(),this.emissionTexture?.dispose(),this.occlusionTexture?.dispose(),this.normalTexture?.dispose()}}export{He as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../../core/accessorSupport/decorators.js";import has from"../../../core/has.js";import{fromMat4 as r,invert as i}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as a,IDENTITY as o}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as s}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as c}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as l,sub as u,dot as d,set as f}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p,freeze as m,clone as h,ZEROS as g,fromValues as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as v,clone as y,ONES as b}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import x from"../../../core/Logger.js";import{abortMaybe as S,destroyMaybe as C,removeMaybe as w}from"../../../core/maybe.js";import{throwIfAborted as T,createAbortError as E}from"../../../core/promiseUtils.js";import{initial as D,watch as O,when as k}from"../../../core/reactiveUtils.js";import{schedule as A}from"../../../core/scheduling.js";import{isUint8Array as j,isFloat32Array as M,isUint32Array as N,isUint16Array as ee}from"../../../core/typedArrayUtil.js";import{isMoon as te,isMars as ne,getReferenceEllipsoid as P,SphericalECEFSpatialReferenceLike as re}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as ie}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as ae}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as oe}from"../../../geometry/projection/projectVectorToVector.js";import{create as F}from"../../../geometry/support/aaBoundingRect.js";import{BufferViewVec4u8 as se,BufferViewVec3u8 as ce,BufferViewVec2f as I,BufferViewVec3f as L,BufferViewUint32 as R,BufferViewUint16 as z}from"../../../geometry/support/buffer/BufferView.js";import{isInEffectiveScaleRange as le,validateScaleRange as ue}from"../../../geometry/support/scaleUtils.js";import{isCGCS2000 as B}from"../../../geometry/support/spatialReferenceUtils.js";import{nullId as V}from"../../../layers/ILyr3DWasmPerSceneView.js";import{IntegratedMeshSemantics as H}from"../../../layers/support/IntegratedMeshSemantics.js";import U from"../../../layers/support/SceneModification.js";import{validateEntity3D as de,makeCacheKey as W,isValidHandle as G}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as K}from"../../../support/elevationInfoUtils.js";import{alphaCutoff as q}from"../../../webscene/support/AlphaCutoff.js";import fe from"../../layers/LayerView.js";import{TaskPriority as pe}from"../../support/Scheduler.js";import{CompressedTextureFormat as J,SizedPixelFormat as Y}from"../../webgl/enums.js";import{Frustum as me}from"../state/Frustum.js";import{glLayout as he}from"../support/buffer/glUtil.js";import{ElevationRange as ge}from"../support/ElevationRange.js";import{toBoundingRect as _e}from"../support/extentUtils.js";import{Obb as X}from"../support/orientedBoundingBox.js";import{getGroundTransparencyModeFromOpacity as ve}from"../terrain/TransparencyMode.js";import{ComponentGeometryParameters as ye,SourceGeometry as be}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as xe}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Se}from"../webgl-engine/core/material/RenderTexture.js";import{ManagedTexture as Ce}from"../webgl-engine/lib/ManagedTexture.js";import{compressNormals as we}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as Te}from"../webgl-engine/materials/pbrUtils.js";import{IntegratedMesh3DTilesLayerWorkerHandle as Ee}from"./IntegratedMesh3DTilesLayerWorkerHandle.js";import{LayerView3D as De}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as Oe}from"./Lyr3DViewPerformanceInfo.js";import{getLyr3DWasm as ke}from"./Lyr3DWasm.js";import{toWasmModification as Ae}from"./SceneLayerWorkerHandle.js";import{IntegratedMesh3DTilesLayerView3DSymbol as je}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as Me,alphaModeConversion as Ne,faceCullingConversion as Pe,wrapModeConversion as Fe}from"./support/lyr3dTypeConversions.js";import{makeScheduleFunction as Ie}from"./support/makeScheduleFunction.js";import{intersectsRay as Le,intersectsSphere as Re}from"./support/tileBoundingVolumeUtils.js";import{Tiles3DLayerViewRegistration as ze}from"./support/Tiles3DLayerViewRegistration.js";import{Tiles3DMeshIntersectionHandler as Be}from"./support/Tiles3DMeshIntersectionHandler.js";var Z;function Ve(e,t,n){if(t===`image/vnd-ms.dds`)switch(n){case`Dxt1`:return J.COMPRESSED_RGB_S3TC_DXT1_EXT;case`Dxt5`:return J.COMPRESSED_RGBA_S3TC_DXT5_EXT;default:return null}if(t===`image/ktx`)return n===`Etc1`?J.COMPRESSED_RGB8_ETC2:null;switch(e){case 33319:return Y.RG8;case 6407:return Y.RGB8;case 6408:return Y.RGBA8;case 6403:return Y.R8;default:return null}}let Q=class extends De(fe){static{Z=je}constructor(e){super(e),this[Z]=!0,this.type=`integrated-mesh-3dtiles`,this._registration=new ze(this),this.skipHeightModelInfoValidation=!0,this.freeze=!1,this._modifications=[],this._visibleGeometryChangedSchedulerHandle=null,this._initializationController=null,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.fullExtentInLocalViewSpatialReference=null,this._applySSAO=!has(`disable-feature:im-ssao`),this._imShading=!!has(`enable-feature:im-shading`),this._imVertexNormals=!!has(`enable-feature:im-vertex-normals`),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._dbgFlags=new Set;let t=e.view.resourceController;this._memCache=t.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._replacesTerrain=e.layer.replacesTerrain,this._frameTask=t.scheduler.registerTask(pe.TILES3D,this),this._frustum=new me(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{T(t);let n=this.layer.queryElevationCallback;this.layer=e,this.layer.queryElevationCallback=n}):null}canRecycleWith(e){return e.url===this.layer.url&&e.type===`integrated-mesh-3dtiles`&&e.replacesTerrain===this._replacesTerrain}initialize(){this._dbg(2,`Tiles3DLayerView3D initialize() called`);let{view:e}=this;this._workerHandle=new Ee(Ie(e.resourceController)),this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),D),this._initializationController=new AbortController,this.addResolvingPromise(this._registration.initialize(this._initializationController.signal,()=>this._initializeRegistered(e)))}_initializeRegistered(e){let t=new Be(this,new H(this.layer,this.replacesTerrain));this._intersectionHandler=t,this._registration.registerQueries(t,this._getElevationContext()),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged()),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.overlayManager.renderer.isEmpty,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),D),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),D),this._updatingHandles.add(()=>this.layer.isUsedAsGroundLayer,()=>this._groundUsageChanged()),e.overlayManager.registerDrapeTarget(this),this.addHandles([O(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),k(()=>this.fullOpacity,()=>this._opacityChange())]),this._registration.synchronizeSuspension(),this.addHandles(O(()=>this.freeze,e=>{e?this._wasm?.incrementFrozenLayerViewCount(this):(this._wasm?.decrementFrozenLayerViewCount(this),this._cameraChanged())})),this._initializationController=null,this.addHandles(O(()=>this._replacesTerrain&&!!this._wasm?.isTerrainReady||!this._replacesTerrain&&H.contributesToGroundElevation(this.layer),e=>{this.layer.queryElevationCallback=e?(e,t)=>this._queryElevation(e,t):null},D))}destroy(){this.freeze=!1,this._initializationController=S(this._initializationController),this._dbg(2,`Tiles3DLayerView3D destroy() called`),this._workerHandle?.destroyContextAndSelf(this.uid),this._registration.unregisterWasm(),this.layer.queryElevationCallback=null,this._registration.unregisterQueries(e=>{let t=Array.from(this._lyrHandleToObjects.values()),n=t.reduce((e,{componentObjects:t})=>e+t.length,0);e.notifyObjectsChangedFunctional(n,e=>{for(let{componentObjects:n}of t)for(let{obb:t}of n)if(!e(t))return})}),this._intersectionHandler=null,this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._frameTask.remove(),this._updatingHandles=C(this._updatingHandles),this.emit(`visible-geometry-changed`),this._visibleGeometryChangedSchedulerHandle=w(this._visibleGeometryChangedSchedulerHandle)}get usedAsGround(){return this.layer.isUsedAsGroundLayer}get replacesTerrain(){return this._replacesTerrain}get fullOpacity(){switch(H.opacitySource(this.layer,this.replacesTerrain)){case`ground`:return this.view.map.ground.opacity;case`layer`:return this.layer.opacity;case`opaque`:return 1}}get opaque(){return this._groundTransparencyMode===0}get invisible(){return this._groundTransparencyMode===3}get _groundTransparencyMode(){return H.opacitySource(this.layer,this._replacesTerrain)===`ground`?ve(this.fullOpacity,this.view.overlayManager.renderer.isEmpty):0}get _renderOpacity(){switch(this._groundTransparencyMode){case 3:return 0;case 2:return q;default:return this.fullOpacity}}get hasModifications(){return this._modifications&&this._modifications.length>0}_opacityChange(){let e=this._renderOpacity,t=this._groundTransparencyMode;this.forEachComponentObject(n=>this._collection.updateObjectOpacity(n,e,t))}_getElevationContext(){return this.replacesTerrain?0:H.shouldUseSceneElevationContext(this.layer)?2:1}_groundUsageChanged(){this._registration.setElevationContext(this._getElevationContext());let e=new H(this.layer,this.replacesTerrain);this._intersectionHandler.integratedMeshSemantics=e,this._intersectionHandler.slicePlaneEnabled=this.slicePlaneEnabled&&!this.replacesTerrain,this.view.overlayManager.unregisterDrapeTarget(this),this.view.overlayManager.registerDrapeTarget(this),this._loadModifications();let t=this._renderOpacity,n=this._groundTransparencyMode;this.forEachComponentObject(r=>r.updateMaterial({opacity:t,groundTransparencyMode:n,integratedMeshSemantics:e}))}_cameraChanged(){if(this.freeze)return;let e=this._frustum;e.update(this.view.state.contentCamera);let t=this._visibleObjects,n=!1;this._loadedObjects.forEach(r=>{let i=r.obb?.intersectsFrustum(e)??!1;i!==r.isVisible&&(r.isVisible=i,i?t.add(r):t.delete(r),r.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,i)),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(i,r.elevationRange))}),n&&this._setVisibleElevationRangeDirty()}intersect(e,t,n,r,i){return this._intersectionHandler.intersectRay(e,t,n,r,null,!1,i)}get ready(){return!this.replacesTerrain||!!this._wasm?.isTerrainReady}_modificationsChanged(){let e=this.useEsriCrs?this.layer.supportedSpatialReferences[1]:this.layer.supportedSpatialReferences[0],t=Ae(this._layerClippingArea,this._modifications,e,this.view.state.isGlobal);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){let e=this.layer.spatialReference,t=F();this._layerClippingArea=_e(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=A(()=>{this.emit(`visible-geometry-changed`),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.replacesTerrain),this.forEachComponentObject(t=>t.updateMaterial({slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,K(e))}get _wasm(){return ke(this.view)}_queryElevation(e,t){return this.destroying||this.destroyed?Promise.reject(E()):this._wasm?.queryElevation(this,e,t)??Promise.reject(E())}get wasmLayerId(){return this._registration.wasmLayerId}get metersPerVCSUnit(){return this._registration.metersPerVCSUnit}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get useEsriCrs(){return this._registration.useEsriCrs}get visibleAtCurrentScale(){return this.replacesTerrain||le(this.layer.effectiveScaleRange,this.view.scale)}canResume(){let e=this.layer&&`effectiveScaleRange`in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.replacesTerrain||ue(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,n=0,r=0,i=0,a=0;return this._lyrHandleToObjects.forEach(o=>{o.isLoaded?(e+=o.textureMemoryUsage,t+=o.vboMemoryUsage,i++):(n+=o.textureMemoryUsage,r+=o.vboMemoryUsage,a++)}),new Oe(this.usedMemory,i,a,$(t),$(e),$(r),$(n))}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._registration.elevationProvider}get elevationOffset(){return K(this.layer.elevationInfo)}get elevationRange(){return this._intersectionHandler?.elevationRange}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){let e=new ge;this._visibleObjects.size===0?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this._forEachRelevantVisibleTile(t=>e.expandElevationRange(t.elevationRange)),e.minElevation===1/0&&e.setElevationRangeValues(0,0));let t=this._get(`visibleElevationRange`);return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange(`visibleElevationRange`)}_forEachRelevantVisibleTile(e){let{view:t}=this,{spatialReference:n}=t,r=n.isWGS84||n.isWebMercator||B(n)||te(n)||ne(n);if(this.view.state.isGlobal||!r)return this.forEachVisibleTile(e);let i=P(n).radius,{eye:a,viewForward:o,near:s}=t.state.contentCamera,c=l(p(),o),f=Math.max(a[2],500),m=f+i,h=Math.sqrt(m**2-i**2),g=Math.abs(Math.atan2(h,i))*i,_=f>.5*i?.5*Math.PI*i:g,v=p();this.forEachVisibleTile(t=>{let{mbsRadius:n,mbsCenter:r}=t;if(n<0)return;u(v,r,a);let i=d(v,c);Math.abs(i)<_&&i+n>s&&i-n<_&&e(t)})}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(let t of this._visibleObjects)e(t)}forEachTile(e){for(let t of this._loadedObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(let{componentObjects:n}of e)for(let e of n)t(e)}get drapeTargetType(){return+!H.shouldDrapeRaster(this.layer,this.replacesTerrain)}isUpdating(){let e=this._wasm;return!this.freeze&&this.wasmLayerId>=0&&e!=null&&e.isUpdating(this.wasmLayerId)}get readyToRun(){return!!this._frameTask?.readyToRun}runTask(e){this._frameTask.processQueue(e)}updatingFlagChanged(){this.notifyChange(`updating`)}async createRenderable(e){if(this.destroyed||this.destroying)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy`);let{entity3d:t}=e;if(!de(t))throw Error(`entity3D not valid`);let n=new Map,r;try{r=this._createPrimitiveTextureBundles(t,n)}catch(e){throw n.forEach(e=>this._stage?.removeTexture(e)),e}let i=null;try{if(i=await this._createRenderableMain(t,r),this.destroyed)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderable aborted due to destroyed instance`);let{tileObb:a,componentObjects:o,elevationRange:s}=i,c=0,l=0,u=0;for(let e of o){let{texture:t,textureMetallicRoughness:n,textureEmissive:r,textureOcclusion:i,textureNormal:a}=e.renderable.drawParameters;c+=(t?.usedMemory??0)+(n?.usedMemory??0)+(r?.usedMemory??0)+(i?.usedMemory??0)+(a?.usedMemory??0),l+=this._collection.getObjectGPUMemoryUsage(e),u+=e.intersectionGeometry.usedMemory}let d=Array.from(n.values()),f=new Ue(e.handle,o,d,u,l,c,a,e.stableNodeId,e.nodeDepth,s);return this._lyrHandleToObjects.set(e.handle,f),()=>{this._memCache.put(W(f.handle),f);let{usedMemory:e}=f;return this._cacheMemory+=e,{memUsageBytes:e}}}catch(e){throw r.forEach(e=>e.cleanup()),i?.componentObjects.forEach(e=>this._collection.destroyObject(e)),n.forEach(e=>this._stage?.removeTexture(e)),e}}_createPrimitiveTextureBundles(e,t){let n=[];try{let r=e.desc.geometry;for(let i of e.validPrimitiveIndices){let a=r.prims[i].materialId,o=e.desc.materials?.materials&&a!=null&&a!==V?e.desc.materials.materials[a]:null,s=Promise.resolve(Ge),c=null,l=null,u=null,d=null,f=null;if(o){let n=o.lightingModel===`Pbr`;c=this._getTexture(o.baseColorTex,e,t),l=n?this._getTexture(o.metalTex,e,t):null,u=n?this._getTexture(o.emissiveTex,e,t):null,d=n?this._getTexture(o.occlusionTex,e,t):null,f=n?this._getTexture(o.normalTex,e,t):null;let r=[c,l,u,d,f].map(e=>e?.loadPromise??null);s=Promise.all(r)}n.push(new Ke(s,c,l,u,d,f))}}catch(e){throw n.forEach(e=>e.cleanup()),e}return n}async _createRenderableMain(e,t){if(this.destroyed||this.destroying)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderableMain called after destroy`);let n=[],c=e.desc,l=m(...e.origin),u=this.view.groundView.spatialReference,d=this.view.state.isGlobal,f=o;if(d){let e=s();ie(re,l,e,u),f=r(a(),e)}let h=We(c.obb),g=d?P(this.view.spatialReference).radius:0,_=d?Math.hypot(h.centerX,h.centerY,h.centerZ)-g:h.centerZ,y=d?Math.max(-g,_-h.radius):_-h.radius,b=_+h.radius,x=[];try{let r=-1;for(let n of e.validPrimitiveIndices){r+=1;let i=c.geometry.prims[n],a=t[r];if(this._dbgFlags.has(2)&&this._dbg(2,JSON.stringify(i)),Me[i.ptype]==null){this._dbg(2,`[Unsupported Feature] Unsupported primitive mode (`+i.ptype+`). Skipping primitive.`),a.cleanup();continue}let{positionView:o,normalsData:s,colorView:l,texCoord0Data:u,indicesView:d}=this._getBufferViews(i,e);if(o==null||d==null){a.cleanup();continue}let f=o.count,p=(e,t)=>e!=null&&e!==f?(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1):!0;!p(u==null?void 0:u.length/2,`numTexcoord`)||!p(l?.count,`numColors`)||!p(s?.length,`normals`)?a.cleanup():x.push({componentIndex:r,positionView:o,indicesView:d,texCoord0Data:u,colorView:l,normalsData:s})}let s=f!==o,m=s?i(a(),f)??o:o,{vertexProcessingOutputs:_,obbHalfSizeAccumulator:S,elevationRange:C}=await this._workerHandle.processTiles3DVertices(x,l,g,d,f,h,this._imVertexNormals&&H.shouldGenerateVertexNormals(this.layer));if(this.destroyed)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance`);let w=c.materials;if(await Promise.all(t.map(e=>e.materialPromise)),this.destroyed)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance`);_.length>0&&h.setHalfSize(S);for(let r of _){let{componentIndex:i,positionView:a,indicesView:o,layout:d,textureCoordinateType:f,interleavedVertexData:g,indices:_,aabbInWorldCoordinates:y}=r,b=e.validPrimitiveIndices[i],x=c.geometry.prims[b],S=t[i],C=h.clone(),T=he(d),E=new Uint32Array([0,o.typedBuffer.length]),D=new ye(T,this._imShading?2:0,f,s?2:0),O=new be({interleavedVertexData:g,vertexCount:g.byteLength/T[0].stride,indexData:_},{positions:a.typedBuffer,indices:o.typedBuffer},E,D),k=this.view.renderSpatialReference,A=p(),j=[1,1,1];ae(l,k,j,u)||this._dbg(3,`Unsupported coordinate system for IM overlay`),oe(l,k,A,u);let M=this._createComponentMaterialInitParameters(w,x.materialId,S);M.baseColorTexture||this._dbg(3,`No colour texture 1`);let N=this._collection.createObject({toMapSpace:v(A[0],A[1],j[0],j[1]),transform:new xe(l,m),obb:C,geometry:O,elevationAlignable:!1,aabbInWorldCoordinates:y},M);n.push(N)}return C.minElevation=Math.max(C.minElevation,y),C.maxElevation=Math.min(C.maxElevation,b),{tileObb:h,componentObjects:n,elevationRange:C}}catch(e){throw n.forEach(e=>this._collection.destroyObject(e)),e}}_createComponentMaterialInitParameters(e,t,n){let r=e?.materials!=null&&t!=null&&t!==V?e.materials[t]:null,i=1,a=r?.baseColorTex?.imageId;if(a!=null&&e&&Array.isArray(e.images)&&a>=0&&a<e.images.length){let t=e.images[a];t.alpha&&(i=Ne[t.alpha])}let o=(r==null?`Unlit`:r.lightingModel)===`Pbr`,s=b,c=q,l=!1,u=2,d=_(0,0,0),p=h(Te),m=n.baseColorTexture,g=n.metallicRoughnessTexture,v=n.emissionTexture,x=n.occlusionTexture,S=n.normalTexture;return r&&(s=y(r.baseColorFactor),c=r.alphaCutoff??q,o&&(f(p,r.metallicFactor,r.roughnessFactor,0),r.emissiveFactor&&(d=r.emissiveFactor)),l=r.isDoubleSided,u=Pe[r.faceCulling??`NotSet`]),{isIntegratedMesh:!0,integratedMeshSemantics:new H(this.layer,this.replacesTerrain),baseColor:s,textureAlphaCutoff:c,mrrFactors:p,baseColorTexture:m,metallicRoughnessTexture:g,normalTexture:S,occlusionTexture:x,emissionTexture:v,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:i,doubleSided:l,cullFace:u,groundTransparencyMode:this._groundTransparencyMode,emissiveBaseColor:d,usePBR:o,slicePlaneEnabled:this.slicePlaneEnabled,opacity:this._renderOpacity,polygonOffset:0,ellipsoidMode:1,applySSAO:this._applySSAO}}freeRenderable(e){let t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._intersectionHandler.removeTile(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){let t=W(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,n){if(this.destroyed||this.destroying)return;let r=this._frustum,i=[],a=!1,o=!1;for(let s=0;s<n;++s){if(!t[s])continue;let n=e[s],c=this._lyrHandleToObjects.get(n);if(c){if(c.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${c.stableNodeId}`);continue}a=!0,c.isLoaded=!0,this._loadedObjects.add(c),this._intersectionHandler.addTile(c),this._usedMemory+=c.usedMemory,this._cacheMemory-=c.usedMemory;let e=c.obb?.intersectsFrustum(r)??!0;c.isVisible=e,e&&(this._visibleObjects.add(c),o||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,c.elevationRange)),i.push(c.obb),c.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(W(n))}else this._dbg(3,`Tried to mark Non existent object ${n} as loaded`)}for(let r=0;r<n;++r){let n=e[r];if(t[r])continue;let a=this._lyrHandleToObjects.get(n);if(a){if(!a.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${a.stableNodeId}`);continue}let e=a.isVisible;this._visibleObjects.delete(a),a.isVisible=!1,a.isLoaded=!1,this._loadedObjects.delete(a),this._intersectionHandler.removeTile(a),e&&(this._visibleGeometryChanged(),o||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,a.elevationRange)),this._usedMemory-=a.usedMemory,this._cacheMemory+=a.usedMemory,i.push(a.obb),a.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(W(n),a)}else this._dbg(3,`Tried to mark Non existent object ${n} as not loaded`)}a&&this._visibleGeometryChanged(),i.length>0&&this.elevationProvider.notifyObjectsChanged(i),o&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){let{visibleElevationRange:n}=this,{minElevation:r,maxElevation:i}=t;return e?r<n.minElevation||i>n.maxElevation:r===n.minElevation||i===n.maxElevation}_getTexture(e,t,n){let r=e&&t.desc.materials?.images?.[e.imageId];if(!r||!G(r.data))return null;let i=t.assets[r.data];if(!i||i.byteCount<1||i.dataType!==`U8`)return null;let a=n.get(r)??this._createTexture(e,r,i,n);return a?new Se(this._stage.renderView.textures,a.id):null}_createTexture(e,t,n,r){let i=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,a=t.mipCount?!0:i>1,o=Fe[e.wrapMode??`None`],s=t.alpha?6408:6407,c=new Uint8Array(n.data.buffer,0,n.byteCount),l=null,u=null;switch(t.format){case`Raw`:if(t.pixelFormat===`R8`)l=c,s=6403,u=``;else if(t.pixelFormat===`Rg8`||t.pixelFormat===`Ga8`)l=c,s=33319,u=``;else if(t.pixelFormat===`Rgb8`)l=c,s=6407,u=``;else if(t.pixelFormat===`Rgba8`)l=c,s=6408,u=``;else return x.getLogger(this).error(`Raw texture pixel format ${t.pixelFormat} not supported`),null;break;case`Dxt1`:l=c,s=6407,u=`image/vnd-ms.dds`;break;case`Dxt5`:l=c,s=6408,u=`image/vnd-ms.dds`;break;case`Basis`:l=c,s=6407,u=`image/ktx2`;break;case`Etc1`:l=c,s=6407,u=`image/ktx`;break;default:return x.getLogger(this).error(`${t.format} texture not supported`),null}if(l&&u!=null){let e=Ve(s,u,t.format),n=new Ce(l,{mipmap:a,maxAnisotropy:i,encoding:u,wrap:o,pixelFormat:s,internalFormat:e??void 0,immutable:e!=null,noUnpackFlip:!0,width:t.mip0Width,height:t.mip0Height});return this._stage.addTexture(n),r.set(t,n),n}return null}_getBufferViews(e,t){let n,r,i,a;for(let o=0;o<e.atrbs.length;o++){let s=e.atrbs[o],c=t.assets[s.assetId];if(!c)continue;let l=c.data.buffer,u=c.byteCount;try{switch(s.sem){case`Position`:c.ncomp!==3||c.dataType!==`F32`||!M(c.data)?this._dbg(3,`[Unsupported Feature] Unsupported view for Position (`+c+`)`):n=new L(l,0,void 0,u);break;case`Normal`:if(c.ncomp!==3||c.dataType!==`F32`||!M(c.data))this._dbg(3,`[Unsupported Feature] Unsupported view for Normal (`+c+`)`);else{let e=new L(l,0,void 0,u);a=new Uint32Array(e.count),we(e.typedBuffer,new Int16Array(a.buffer,a.byteOffset,a.length*2))}break;case`TexCoord`:c.ncomp!==2||c.dataType!==`F32`||!M(c.data)?this._dbg(3,`[Unsupported Feature] Unsupported view for Texcoord (`+c+`)`):i===void 0&&(i=new I(l,0,void 0,u).typedBuffer);break;case`Color`:c.dataType===`U8`&&j(c.data)&&(c.ncomp===4?r=new se(l,0,void 0,u):c.ncomp===3&&(r=new ce(l,0,void 0,u))),r??this._dbg(3,`[Unsupported Feature] Unsupported view for Color (`+c+`)`);break;case`FeatureIndex`:break;default:this._dbg(2,`[Unsupported Feature] Unsupported semantic (`+s.sem+`). Skipping vertex attribute.`)}}catch(e){this._dbg(2,`Error Creating buffer (`+e+`). Skipping vertex attribute.`)}}let o,s=!1;if(G(e.index)){let n=t.assets[e.index];if(!n)s=!0;else{let e=n.byteCount;switch(n.dataType){case`U16`:n.ncomp===1&&ee(n.data)&&(o=new z(n.data.buffer,0,void 0,e));break;case`U32`:n.ncomp===1&&N(n.data)&&(o=new R(n.data.buffer,0,void 0,e))}s=!o}}if(!s&&o==null&&n!=null){let e=n.count;o=o=e<65535?new z(new Uint16Array(e).buffer):new R(new Uint32Array(e).buffer);for(let t=0;t<e;t++)o.set(t,t)}return{positionView:n,colorView:r,texCoord0Data:i,indicesView:o,normalsData:a}}_loadModifications(){if(this.removeHandles(`modifications`),this.layer.modifications==null){this._modifications=[];return}let e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>H.shouldApplyModification(this.layer,e.type)).toArray(),this._modifications.length<e.length&&x.getLogger(this).info(`Ground layers only support replace modifications. Other modification types have been ignored.`)},D),`modifications`)}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,t){this._dbgFlags.has(e)&&(e===3?x.getLogger(this).error(t):x.getLogger(this).warn(t))}};e([t()],Q.prototype,`freeze`,void 0),e([t()],Q.prototype,`fullOpacity`,null),e([t()],Q.prototype,`opaque`,null),e([t()],Q.prototype,`invisible`,null),e([t({readOnly:!0})],Q.prototype,`ready`,null),e([t({type:[U]})],Q.prototype,`_modifications`,void 0),e([t()],Q.prototype,`_visibleGeometryChangedSchedulerHandle`,void 0),e([t()],Q.prototype,`layer`,void 0),e([t({readOnly:!0})],Q.prototype,`visibleAtCurrentScale`,null),e([t({readOnly:!0})],Q.prototype,`_collection`,null),e([t()],Q.prototype,`elevationOffset`,null),e([t({readOnly:!0})],Q.prototype,`visibleElevationRange`,null),e([t()],Q.prototype,`fullExtentInLocalViewSpatialReference`,void 0),Q=e([n(`esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D`)],Q);const He=Q;class Ue{constructor(e,t,n,r,i,a,o,s,c,l){this.handle=e,this.componentObjects=t,this.textures=n,this.cpuMemoryUsage=r,this.vboMemoryUsage=i,this.textureMemoryUsage=a,this.obb=o,this.stableNodeId=s,this.nodeDepth=c,this.elevationRange=l,this.bvhIntersectionGeneration=0,this.isLoaded=!1,this.isVisible=!1;let u=p();o?.getCenter(u),this._obbCenterX=u[0],this._obbCenterY=u[1],this._obbCenterZ=u[2];let d=o?.radius??-1;this._obbRadius=d,this._obbRadiusSquared=d*d,this._obbShortestHalfsize=o?Math.min(o.halfSizeX,o.halfSizeY,o.halfSizeZ):0,this._mbsCenter=o?o.getCenter(p()):g}get usedMemory(){return this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this._mbsCenter}boundingVolumeIntersectsRay(e,t){return Le(this.obb,this._obbCenterX,this._obbCenterY,this._obbCenterZ,this._obbRadiusSquared,e,t)}boundingVolumeIntersectsSphere(e){return Re(this.obb,this._obbCenterX,this._obbCenterY,this._obbCenterZ,this._obbRadius,this._obbShortestHalfsize,e)}}function $(e){return Math.round(e/1048.576)/1e3}function We(e){return new X(e.center,e.halfSize,c(...e.quaternion))}const Ge=[];class Ke{constructor(e,t,n,r,i,a){this.materialPromise=e,this.baseColorTexture=t,this.metallicRoughnessTexture=n,this.emissionTexture=r,this.occlusionTexture=i,this.normalTexture=a}cleanup(){this.baseColorTexture?.dispose(),this.metallicRoughnessTexture?.dispose(),this.emissionTexture?.dispose(),this.occlusionTexture?.dispose(),this.normalTexture?.dispose()}}export{He as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{intersectsSphere as e}from"../../../../geometry/support/frustumPlanes.js";import{IntersectorResultRay as t}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as n}from"../../webgl-engine/lib/RayIntersections.js";import{getVerticalOffsetI3S as r}from"../../webgl-engine/lib/verticalOffsetUtils.js";import{I3sTarget as i}from"./Intersector.js";class a{constructor(e,t){this.node=e,this.objectHandle=t}}class o{get isGround(){return this.integratedMeshSemantics.shouldIntersectAsGround}constructor(e){this.type=2,this._needVerticalOffset=!1,this.layerViewUid=e.layerViewUid,this.sublayerId=e.sublayerId,this._collection=e.collection,this._traverseNodeHierarchy=e.traverseNodeHierarchy,this.slicePlaneEnabled=e.slicePlaneEnabled,this.integratedMeshSemantics=e.integratedMeshSemantics}updateElevationAlignState(e,t){this._needVerticalOffset=e&&t}intersectRay(e,a,o,c,l,u){let
|
|
2
|
+
import{intersectsSphere as e}from"../../../../geometry/support/frustumPlanes.js";import{IntersectorResultRay as t}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as n}from"../../webgl-engine/lib/RayIntersections.js";import{getVerticalOffsetI3S as r}from"../../webgl-engine/lib/verticalOffsetUtils.js";import{I3sTarget as i}from"./Intersector.js";class a{constructor(e,t){this.node=e,this.objectHandle=t}}class o{get isGround(){return this.integratedMeshSemantics.shouldIntersectAsGround}constructor(e){this.type=2,this._needVerticalOffset=!1,this.layerViewUid=e.layerViewUid,this.sublayerId=e.sublayerId,this._collection=e.collection,this._traverseNodeHierarchy=e.traverseNodeHierarchy,this.slicePlaneEnabled=e.slicePlaneEnabled,this.integratedMeshSemantics=e.integratedMeshSemantics}updateElevationAlignState(e,t){this._needVerticalOffset=e&&t}intersectRay(e,a,o,c,l,u,d){let f=e.options.store===2,p=e.ray.direction,m=e=>e,h=e=>e,g=r(e.verticalOffset??(this._needVerticalOffset?0:null));e.verticalOffset!=null&&g!=null&&(m=e=>g.applyToMbs(e),h=e=>g.applyToObb(e));let{results:_,tolerance:v}=e,y=new n(v,u,e.options.normalRequired,d),b=e=>{if(e.childrenLoaded===0)return!1;let t=e.serviceObbInRenderSR?.isValid?e.serviceObbInRenderSR:null;return!(t&&!h(t).intersectRay(o,p,v))};for(let{node:n,objectHandle:r}of this._traverseNodeHierarchy(b)){let l=n.serviceObbInRenderSR?.isValid?n.serviceObbInRenderSR:null,{serviceMbsInRenderSRElevationAdjusted:u}=n;if(r&&(l||!u.isValid||s(m(u),o,p,v))&&(n.geometryObbInRenderSR==null||h(n.geometryObbInRenderSR).intersectRay(o,p,v))&&!this._collection.intersectRay(r,o,c,g,y,(r,s,l,u,d)=>{if(s<0||a!=null&&!a(o,c,s))return;let p=e=>{let t=new i(this.layerViewUid,this.sublayerId,n.index,d,u);e.set(this.type,t,r,s,l)};if(this.isGround&&(_.ground.renderDistance==null||s<_.ground.renderDistance)&&p(_.ground),!e.options.isFiltered&&((_.min.renderDistance==null||s<_.min.renderDistance)&&p(_.min),(_.max.renderDistance==null||r>_.max.renderDistance)&&p(_.max),f)){let n=new t(e.ray);p(n),e.results.all.push(n)}}))return!1}return!0}*intersectScreenPolygon(t,n){if(t.camera==null)return;let a=r(this._needVerticalOffset?0:null),o=t=>{if(t.childrenLoaded===0)return!1;let r=t.serviceObbInRenderSR?.isValid?t.serviceObbInRenderSR:null;if(r!=null){if(!r.intersectsFrustumConservativeApproximation(n.broadPhaseFrustum))return!1}else{let r=t.serviceMbsInRenderSRElevationAdjusted;if(r.isValid&&!e(n.broadPhaseFrustum,r))return!1}return!0};for(let{node:e,objectHandle:r}of this._traverseNodeHierarchy(o))r!=null&&r.visible&&(e.geometryObbInRenderSR==null||e.geometryObbInRenderSR.intersectsFrustumConservativeApproximation(n.broadPhaseFrustum))&&(yield*this._collection.intersectScreenPolygon(r,t,n,a,(n,r,a,o)=>{t.polygonResults.add(this.type,new i(this.layerViewUid,this.sublayerId,e.index,n,o),r)}))}}function s(e,t,n,r=0){let i=e.radius+r,a=t[0]-e.center[0],o=t[1]-e.center[1],s=t[2]-e.center[2],[c,l,u]=n,d=c*c+l*l+u*u,f=c*a+l*o+u*s,p=a*a+o*o+s*s-i*i;return f*f-d*p>=0}export{o as I3SIntersectionHandler,a as TraversedIntersectionNode};
|