@arcgis/core 4.29.0-next.20231221 → 4.29.0-next.20231222
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/01dbff2fdff9d5c95892.js +1 -0
- package/assets/esri/core/workers/chunks/046b3920f4aca1061d06.js +1 -0
- package/assets/esri/core/workers/chunks/15af5fd13722ef57c8f7.js +1 -0
- package/assets/esri/core/workers/chunks/3a4598c384c4c31ab35b.js +1 -0
- package/assets/esri/core/workers/chunks/5c269c59f61a185ed5c7.js +1 -0
- package/assets/esri/core/workers/chunks/7435463436cda9eb4246.js +1 -0
- package/assets/esri/core/workers/chunks/c1c4f3909b724c13033d.js +1 -0
- package/assets/esri/core/workers/chunks/ccfdd3d278756f01f630.js +1 -0
- package/assets/esri/core/workers/chunks/d4cf3af5f5c30925539c.js +1 -0
- package/assets/esri/core/workers/chunks/ee0b43679cc0cc531d7c.js +1 -0
- package/assets/esri/core/workers/chunks/f9f3d6b4347e63f440e0.js +1 -0
- package/assets/esri/core/workers/chunks/fbfdb4779198f4c35c65.js +1 -0
- package/assets/esri/core/workers/chunks/ffad926201d92c4d6b4e.js +1 -0
- package/chunks/HUDMaterial.glsl.js +1 -1
- package/core/MemCache.js +1 -1
- package/core/MemCachePool.js +1 -1
- package/core/deprecate.js +1 -1
- package/layers/mixins/operationalLayerModuleMap.js +1 -1
- package/layers/mixins/operationalLayers.js +1 -1
- package/layers/support/editableLayers.js +1 -1
- package/layers/support/layersCreator.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/StreamLayerView2D.js +1 -1
- package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
- package/views/2d/layers/features/FeatureSourceEventLog.js +5 -0
- package/views/2d/layers/features/PipelineConnectionHandlers.js +1 -1
- package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/featureServiceUtils.js +5 -0
- package/views/2d/layers/features/layerAdapters/geometryUtils.js +5 -0
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/2d/layers/features/sources/strategies/AFetchLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/ATileLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/DrillDownTileLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/PagedTileLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/SnapshotLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/StreamLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/DrillDownTileSourceChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/PagedTileSourceChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderJSON.js +1 -1
- package/views/3d/effects/RenderNode.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/terrain/TerrainAttributesCache.js +1 -1
- package/views/3d/webgl-engine/effects/RenderNodes.js +5 -0
- package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/layers/FeatureLayerView.js +1 -1
- package/views/webgl/RenderingContext.js +1 -1
- package/webdoc/support/webdocSaveUtils.js +1 -1
- package/widgets/BasemapLayerList.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/LayerList.js +1 -1
- package/widgets/TableList.js +1 -1
- package/assets/esri/core/workers/chunks/251ceefdea4b345698a4.js +0 -1
- package/assets/esri/core/workers/chunks/2e6f1c788813b4162adf.js +0 -1
- package/assets/esri/core/workers/chunks/49ca15b23dd363bc3546.js +0 -1
- package/assets/esri/core/workers/chunks/521a38edbeff0073bfdd.js +0 -1
- package/assets/esri/core/workers/chunks/573ad8aa1c2cfad61eb8.js +0 -1
- package/assets/esri/core/workers/chunks/831283ac6653d7af90b6.js +0 -1
- package/assets/esri/core/workers/chunks/90444e25dd487d0bc438.js +0 -1
- package/assets/esri/core/workers/chunks/90b34ce04d5a83ea4344.js +0 -1
- package/assets/esri/core/workers/chunks/9c80cfae983c8ccfe616.js +0 -1
- package/assets/esri/core/workers/chunks/a1cf80c67ee8dbe9c897.js +0 -1
- package/assets/esri/core/workers/chunks/c76094c26e80656a2f8d.js +0 -1
- package/assets/esri/core/workers/chunks/df394ec25adfc9798f74.js +0 -1
- package/assets/esri/core/workers/chunks/e4ab40d895fccc81fe44.js +0 -1
- package/views/3d/webgl-engine/effects/RenderNodeCollection.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"../../../../../../core/has.js";import{throwIfAborted as
|
|
5
|
+
import has from"../../../../../../core/has.js";import{throwIfAborted as t,onAbort as e}from"../../../../../../core/promiseUtils.js";import{ATileLoadStrategy as s}from"./ATileLoadStrategy.js";import{DrillDownTileSourceChunk as o}from"./chunks/DrillDownTileSourceChunk.js";import{FeatureSetReaderJSON as i}from"../../support/FeatureSetReaderJSON.js";class r{constructor(t,s){this.subscription=t,this._tileIdToResult=new Map,this._controller=new AbortController,e(t.options,(()=>this._controller.abort())),e(s,(()=>this._controller.abort()))}get(t){return this._tileIdToResult.get(t)}set(t,e){this._tileIdToResult.set(t,e)}get options(){return{signal:this._controller.signal}}}class l extends s{constructor(){super(...arguments),this._loadStates=new Map}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(e){this._loadStates.has(e.key.id)||this._loadStates.set(e.key.id,new r(e,this._options));const s=this._loadStates.get(e.key.id);let l;try{for await(const i of this._fetchChunkInfos(s,e.tile,0)){const{queryJSON:s,reader:r,sourceTile:l,sourceTileDepth:n,tile:a}=i,u=new o(r,s,a,l,n,!1);t(e.options),this._addChunk(u)}}catch(a){l=a}const n=new o(i.empty(this._metadata),null,e.tile,null,-1,!0);if(this._addChunk(n),l)throw l}unload(t){super.unload(t),this._loadStates.delete(t.key.id)}async*_fetchChunkInfos(t,e,s){let o=t.get(e.id);const i=!!o;if(o||(o=await this._fetchChunkInfo(t,e,s),t.set(e.id,o)),o.reader.exceededTransferLimit&&s<has("featurelayer-query-max-depth"))for(const r of e.createChildTiles())yield*this._fetchChunkInfos(t,r,s+1);else i||(yield o)}async _fetchChunkInfo(t,e,s){const o=t.subscription.tile.getQuantizationParameters(),i=this._queryInfo.createTileQuery(e,{returnExceededLimitFeatures:!1,quantizationParameters:o});return{reader:await this.fetch(i,t.subscription.options),queryJSON:i.toJSON(),tile:t.subscription.tile,sourceTile:e,sourceTileDepth:s}}}export{l as DrillDownTileLoadStrategy};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{throwIfAborted as t,onAbort as e}from"../../../../../../core/promiseUtils.js";import{ATileLoadStrategy as o}from"./ATileLoadStrategy.js";import{PagedTileSourceChunk as s}from"./chunks/PagedTileSourceChunk.js";class
|
|
5
|
+
import{throwIfAborted as t,onAbort as e}from"../../../../../../core/promiseUtils.js";import{ATileLoadStrategy as o}from"./ATileLoadStrategy.js";import{PagedTileSourceChunk as s}from"./chunks/PagedTileSourceChunk.js";import{FeatureSetReaderJSON as r}from"../../support/FeatureSetReaderJSON.js";class a{constructor(t,o){this.subscription=t,this._pages=new Set,this._controller=new AbortController,this._done=!1,e(t.options,(()=>this._controller.abort())),e(o,(()=>this._controller.abort()))}resetAbortController(){this._controller=new AbortController}get pageStart(){let t=-1;for(const e of this._pages.values())t=Math.max(t,e);return t+1}get done(){return this._done}get options(){return{signal:this._controller.signal}}add(t,e){this._pages.add(t),this._done=this._done||e}}class i extends o{constructor(){super(...arguments),this._loadStates=new Map}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(t){this._loadStates.has(t.key.id)||this._loadStates.set(t.key.id,new a(t,this._options));const e=this._loadStates.get(t.key.id);let o;e.resetAbortController();try{await this._fetchPages(e)}catch(n){o=n}const i=new s(r.empty(this._metadata),null,t.tile,-1,!0);if(this._addChunk(i),o)throw o}unload(t){super.unload(t),this._loadStates.delete(t.key.id)}async _fetchPages(e){const o=4,s=20;let r=0,a=e.pageStart,i=1;for(;r<s&&!e.done;){const s=[];for(let t=0;t<i;t++)s.push(this._fetchChunk(e,a++));const n=await Promise.all(s);for(const o of n)(0!==o.size()||o.first)&&(e.add(o.page,!o.reader.exceededTransferLimit),t(e.options),this._addChunk(o));r++,i=Math.min(i+1,o)}}async _fetchChunk(t,e){const o=t.subscription.tile,r=this._queryInfo.createPagedTileQuery(o,e),a=await this.fetch(r,t.options);return new s(a,r.toJSON(),o,e,!1)}}export{i as PagedTileLoadStrategy};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import t from"../../../../../../core/Error.js";import{throwIfAborted as e}from"../../../../../../core/promiseUtils.js";import r from"../../../../../../core/RandomLCG.js";import{AFetchLoadStrategy as o}from"./AFetchLoadStrategy.js";import{FeatureSnapshotSourceChunk as s}from"./chunks/FeatureSnapshotSourceChunk.js";import{FeatureSetReaderJSON as n}from"../../support/FeatureSetReaderJSON.js";class a extends o{constructor(t,e,o,s,n){super(t,e,s,n),this._random=new r(1e3),this._promise=this._downloadPages(o)}get about(){return{willQueryAllFeatures:!0,willQueryFullResolutionGeometry:!0}}load(t){return this._promise}unload(t){}async _downloadPages(e){const r=Math.ceil(e/this._queryInfo.pageSize),o=Array.from({length:r},((t,e)=>e)).sort(((t,e)=>this._random.getInt()-this._random.getInt())),a=await Promise.all(o.map((t=>this._downloadPage(t)))),i=new s(n.empty(this._metadata),null,-1,!0);this._store.insert(i,this._queryInfo.version);const l=a.filter((t=>t));if(l.length)throw new t("featurelayer-query","Encountered errors when downloading data",{errors:l})}async _downloadPage(t){try{const r=this._queryInfo.createPagedQuery(t),o=await this.fetch(r,this._options),n=new s(o,r.toJSON(),t,!1);return e(this._options),this._store.insert(n,this._queryInfo.version),null}catch(r){return r}}}export{a as SnapshotLoadStrategy};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../../../core/Evented.js";import{handlesGroup as t}from"../../../../../../core/handleUtils.js";import"../../../../../../core/has.js";import{destroyMaybe as n}from"../../../../../../core/maybe.js";import{StreamFeatureManager as s}from"../../../../../../layers/graphics/data/StreamFeatureManager.js";import{createConnection as o}from"../../../../../../layers/graphics/sources/connections/createConnection.js";import{StreamConnectionState as
|
|
5
|
+
import e from"../../../../../../core/Evented.js";import{handlesGroup as t}from"../../../../../../core/handleUtils.js";import"../../../../../../core/has.js";import{destroyMaybe as n}from"../../../../../../core/maybe.js";import{StreamFeatureManager as s}from"../../../../../../layers/graphics/data/StreamFeatureManager.js";import{createConnection as o}from"../../../../../../layers/graphics/sources/connections/createConnection.js";import{StreamConnectionState as r}from"../StreamConnectionState.js";import{StreamFeatureStore as i}from"../StreamFeatureStore.js";import{ALoadStrategy as c}from"./ALoadStrategy.js";import{StreamSourceChunk as a}from"./chunks/StreamSourceChunk.js";class h extends c{constructor(t,n,o,c){super(t,n),this._queryInfo=t,this._streamOptions=o,this._connectionState=new r,this.events=new e;const{objectIdField:a,timeInfo:h,purgeOptions:m}=t.serviceInfo;this._stagingStore=new i(c,(e=>this.events.emit("features-updated",e))),this._manager=new s(this._stagingStore,a,h,m),this.connect()}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}get connectionStatus(){return this._connectionState.connectionStatus}get errorString(){return this._connectionState?.errorString}get service(){return this._queryInfo.serviceInfo}async refresh(){this._manager.checkForUpdates(),this._chunk&&this._store.remove(this._chunk),this._chunk=new a(this._stagingStore.reader),this._store.insert(this._chunk,this._queryInfo.version),this.events.emit("tick")}destroy(){super.destroy(),this.disconnect()}async load(e){}unload(e){}async updateFields(){this.disconnect(),this.clear(),this.connect()}disconnect(){this._connection=n(this._connection),this._connectionState.connection=null,this._handlesGroup?.remove()}connect(){if(null!=this._connection)return;const{geometryType:e,source:n,spatialReference:s,serviceFilter:r,maxReconnectionAttempts:i,maxReconnectionInterval:c,customParameters:a}=this._queryInfo.serviceInfo;this._connection=o(n,s,this._streamOptions.outSR,e,r,i,c,a??{}),this._handlesGroup=t([this._connection.on("data-received",(e=>this._onFeature(e))),this._connection.on("message-received",(e=>this._onWebSocketMessage(e)))]),this._connectionState.connection=this._connection}clear(){this._manager.checkForUpdates(),this._stagingStore.clear()}updateCustomParameters(e){this._connection?.updateCustomParameters(e)}sendMessageToSocket(e){this._connection?.sendMessageToSocket(e)}sendMessageToClient(e){this._connection?.sendMessageToClient(e)}_onWebSocketMessage(e){if("type"in e)switch(e.type){case"delete":if(e.objectIds)for(const t of e.objectIds)this._manager.removeById(t);if(e.trackIds)for(const t of e.trackIds)this._manager.removeByTrackId(t);break;case"clear":this.clear()}this.events.emit("message-received",e)}_onFeature(e){try{this._manager.add(e),this.events.emit("data-received",e)}catch(t){}}}export{h as StreamLoadStrategy};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ASourceChunk as e}from"./ASourceChunk.js";class t extends e{constructor(e,t,i,r,s,h){super(),this._reader=e,this._queryJSON=t,this._tile=i,this._sourceTile=r,this._sourceTileDepth=s,this._end=h,this.chunkId=`${this._tile.key.id}.${this._sourceTile
|
|
5
|
+
import{ASourceChunk as e}from"./ASourceChunk.js";class t extends e{constructor(e,t,i,r,s,h){super(),this._reader=e,this._queryJSON=t,this._tile=i,this._sourceTile=r,this._sourceTileDepth=s,this._end=h,this.chunkId=`${this._tile.key.id}.${this._sourceTile?.key.id}${this._end?"e":""}`}get queryInfo(){return{type:"drill-down-tile",chunkId:this.chunkId,tileId:this._tile.key.id,queryJSON:this._queryJSON,sourceTileDepth:this._sourceTileDepth,sourceTileId:this._sourceTile?.key.id,size:this.size(),end:this.end}}get first(){return 0===this._sourceTileDepth}get reader(){return this._reader}get end(){return this._end}get tile(){return this._tile}getTileReader(e){return this._tile.key.id===e.key.id?this.reader:null}}export{t as DrillDownTileSourceChunk};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ASourceChunk as e}from"./ASourceChunk.js";class
|
|
5
|
+
import{ASourceChunk as e}from"./ASourceChunk.js";class t extends e{constructor(e,t,r,s){super(),this._reader=e,this._queryJSON=t,this._page=r,this._end=s,this.chunkId=`${this._page}${this.end?"e":""}`}get reader(){return this._reader}get first(){return 0===this._page}get end(){return this._end}get queryInfo(){return{type:"snapshot",chunkId:this.chunkId,queryJSON:this._queryJSON,page:this._page,size:this.size(),end:this.end}}getTileReader(e){const t=this.queryFeaturesInBounds(e.bounds);return t.setTransformForDisplay(e.transform),t}}export{t as FeatureSnapshotSourceChunk};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ASourceChunk as e}from"./ASourceChunk.js";class t extends e{constructor(e,t,i,r){super(),this._reader=e,this._queryJSON=t,this._tile=i,this._page=r,this.chunkId=`${this._tile.key.id}.${this._page}${this.end?"e":""}`}get queryInfo(){return{type:"paged-tile",chunkId:this.chunkId,tileId:this._tile.key.id,queryJSON:this._queryJSON,page:this._page,size:this.size(),end:this.end}}get reader(){return this._reader}get first(){return 0===this._page}get end(){return!this.
|
|
5
|
+
import{ASourceChunk as e}from"./ASourceChunk.js";class t extends e{constructor(e,t,i,r,s){super(),this._reader=e,this._queryJSON=t,this._tile=i,this._page=r,this._end=s,this.chunkId=`${this._tile.key.id}.${this._page}${this.end?"e":""}`}get queryInfo(){return{type:"paged-tile",chunkId:this.chunkId,tileId:this._tile.key.id,queryJSON:this._queryJSON,page:this._page,size:this.size(),end:this.end}}get reader(){return this._reader}get first(){return 0===this._page}get end(){return!this._end}get page(){return this._page}get tile(){return this._tile}getTileReader(e){return this._tile.key.id===e.key.id?this.reader:null}}export{t as PagedTileSourceChunk};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../../../../core/Evented.js";import has from"../../../../../../../core/has.js";import{create as s}from"../../../../../../../geometry/support/aaBoundingBox.js";import{FeatureStoreQueryAdapter as r}from"../../../FeatureStoreQueryAdapter.js";import{OverrideChunk as o}from"./OverrideChunk.js";class t{constructor(s){this._onChange=s,this._chunks=new Map,this._overrideChunk=new o,this.events=new e,this.featureAdapter=new r}destroy(){for(const e of this.chunks())this.events.emit("remove",e);this._chunks.clear()}*chunks(){this._overrideChunk&&(yield this._overrideChunk),yield*this._chunks.values()}insert(e,s){has("esri-2d-update-debug")&&console.debug(`Version[${s}] Chunk[${e.chunkId}] SourceChunkStore.insert`),this._overrideChunk.overridenIds.size&&e.reader.removeIds(this._overrideChunk.overridenIds),this._chunks.set(e.chunkId,e),this.events.emit("changed"),this._onChange()}remove(e){has("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] SourceChunkStore.remove`),this._chunks.delete(e.chunkId),this.events.emit("remove",e)}applyOverrides(e){this._overrideChunk.applyOverrides(e);for(const s of this._chunks.values())s.reader.removeIds(this._overrideChunk.overridenIds)}forEach(e){const s=new Set;for(const r of this.chunks()){const o=r.reader.getCursor();for(;o.next();){const r=o.getObjectId();s.has(r)||(e(o.copy()),s.add(r))}}}forEachUnsafe(e){const s=new Set;for(const r of this.chunks()){const o=r.reader.getCursor();for(;o.next();){const r=o.getObjectId();s.has(r)||(e(o),s.add(r))}}}forEachInBounds(e,s){const r=new Set;for(const o of this.chunks()){const t=o.queryFeaturesInBounds(e);for(;t.next();){const e=t.getObjectId();r.has(e)||(s(t.copy()),r.add(e))}}}forEachBounds(e,r){const o=s();for(const s of e){s.getBounds(o)&&r(o)}}}export{t as FeatureSourceChunkStore};
|
|
5
|
+
import e from"../../../../../../../core/Evented.js";import has from"../../../../../../../core/has.js";import{create as s}from"../../../../../../../geometry/support/aaBoundingBox.js";import{FeatureStoreQueryAdapter as r}from"../../../FeatureStoreQueryAdapter.js";import{OverrideChunk as o}from"./OverrideChunk.js";class t{constructor(s){this._onChange=s,this._chunks=new Map,this._overrideChunk=new o,this.events=new e,this.featureAdapter=new r}destroy(){this.clear()}clear(){for(const e of this.chunks())this.events.emit("remove",e);this._chunks.clear()}*chunks(){this._overrideChunk&&(yield this._overrideChunk),yield*this._chunks.values()}insert(e,s){has("esri-2d-update-debug")&&console.debug(`Version[${s}] Chunk[${e.chunkId}] SourceChunkStore.insert`),this._overrideChunk.overridenIds.size&&e.reader.removeIds(this._overrideChunk.overridenIds),this._chunks.set(e.chunkId,e),this.events.emit("changed"),this._onChange()}remove(e){has("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] SourceChunkStore.remove`),this._chunks.delete(e.chunkId),this.events.emit("remove",e)}applyOverrides(e){this._overrideChunk.applyOverrides(e);for(const s of this._chunks.values())s.reader.removeIds(this._overrideChunk.overridenIds)}forEach(e){const s=new Set;for(const r of this.chunks()){const o=r.reader.getCursor();for(;o.next();){const r=o.getObjectId();s.has(r)||(e(o.copy()),s.add(r))}}}forEachUnsafe(e){const s=new Set;for(const r of this.chunks()){const o=r.reader.getCursor();for(;o.next();){const r=o.getObjectId();s.has(r)||(e(o),s.add(r))}}}forEachInBounds(e,s){const r=new Set;for(const o of this.chunks()){const t=o.queryFeaturesInBounds(e);for(;t.next();){const e=t.getObjectId();r.has(e)||(s(t.copy()),r.add(e))}}}forEachBounds(e,r){const o=s();for(const s of e){s.getBounds(o)&&r(o)}}}export{t as FeatureSourceChunkStore};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{convertFromFeatures as e,convertFromFeatureSet as t,getQuantizedArea as r}from"../../../../../layers/graphics/featureConversionUtils.js";import{hasGeometry as s}from"../../../../../layers/graphics/OptimizedFeature.js";import i from"../../../../../layers/support/FieldsIndex.js";import{FeatureSetReader as n}from"./FeatureSetReader.js";class u extends n{static fromFeatures(t,r){const{objectIdField:s,geometryType:i}=r,n=e([],t,i,!1,!1,s);for(let e=0;e<n.length;e++)n[e].displayId=t[e].displayId;return u.fromOptimizedFeatures(n,r)}static fromFeatureSet(e,r){const s=t(e,r.objectIdField);return u.fromOptimizedFeatureSet(s,r)}static fromOptimizedFeatureSet(e,t){const r=u.fromOptimizedFeatures(e.features,t);return r._exceededTransferLimit=e.exceededTransferLimit,r._transform=e.transform,r._fieldsIndex=new i(e.fields),r}static fromOptimizedFeatures(e,t,r){const s=new u(e,t);return s._fieldsIndex=t.fieldsIndex,s._transform=r,s}constructor(e,t){super(t),this._exceededTransferLimit=!1,this._featureIndex=-1,this._fieldsIndex=null,this._geometryType=t.geometryType,this._features=e}get fields(){return this._fieldsIndex}get geometryType(){return this._geometryType}get hasFeatures(){return!!this._features.length}get hasNext(){return this._featureIndex+1<this._features.length}get exceededTransferLimit(){return this._exceededTransferLimit}get hasZ(){return!1}get hasM(){return!1}get _current(){return this._features[this._featureIndex]}removeIds(e){const t=new Set(e);this._features=this._features.filter((e=>!(null!=e.objectId&&t.has(e.objectId))))}getSize(){return this._features.length}getCursor(){return this.copy()}getInTransform(){return this._transform}getAttributeHash(){let e="";for(const t in this._current.attributes)e+=this._current.attributes[t];return e}getIndex(){return this._featureIndex}setIndex(e){this._featureIndex=e}getObjectId(){return this._current?.objectId}getDisplayId(){return this._current.displayId}setDisplayId(e){this._current.displayId=e}copy(){const e=new u(this._features,this.metadata);return this.copyInto(e),e}next(){for(;++this._featureIndex<this._features.length&&!this._getExists(););return this._featureIndex<this._features.length}readGeometryArea(){return s(this._current)?r(this._current.geometry,2):0}_readX(){return s(this._current)?this._current.geometry.coords[0]:0}_readY(){return s(this._current)?this._current.geometry.coords[1]:0}_readGeometry(){return this._current.geometry??null}_readServerCentroid(){return this._current.centroid}_readAttribute(e,t){if(!this._fieldsIndex){const t=this._current.attributes[e];if(void 0!==t)return t;const r=e.toLowerCase();for(const e in this._current.attributes)if(e.toLowerCase()===r)return this._current.attributes[e];return}const r=this._fieldsIndex.get(e);if(!r)return;let s=this._current.attributes[r.name];return null==s?s:("esriFieldTypeTimestampOffset"===this.fields.get(e)?.type&&(s=this.parseTimestampOffset(s)),t&&this.fields.isDateField(e)?new Date(s):s)}_readAttributes(){return this._current.attributes}copyInto(e){super.copyInto(e),e._featureIndex=this._featureIndex,e._transform=this._transform,e._fieldsIndex=this._fieldsIndex}}export{u as FeatureSetReaderJSON};
|
|
5
|
+
import{convertFromFeatures as e,convertFromFeatureSet as t,getQuantizedArea as r}from"../../../../../layers/graphics/featureConversionUtils.js";import{hasGeometry as s}from"../../../../../layers/graphics/OptimizedFeature.js";import i from"../../../../../layers/support/FieldsIndex.js";import{FeatureSetReader as n}from"./FeatureSetReader.js";class u extends n{static fromFeatures(t,r){const{objectIdField:s,geometryType:i}=r,n=e([],t,i,!1,!1,s);for(let e=0;e<n.length;e++)n[e].displayId=t[e].displayId;return u.fromOptimizedFeatures(n,r)}static fromFeatureSet(e,r){const s=t(e,r.objectIdField);return u.fromOptimizedFeatureSet(s,r)}static fromOptimizedFeatureSet(e,t){const r=u.fromOptimizedFeatures(e.features,t);return r._exceededTransferLimit=e.exceededTransferLimit,r._transform=e.transform,r._fieldsIndex=new i(e.fields),r}static fromOptimizedFeatures(e,t,r){const s=new u(e,t);return s._fieldsIndex=t.fieldsIndex,s._transform=r,s}static empty(e){return new u([],e)}constructor(e,t){super(t),this._exceededTransferLimit=!1,this._featureIndex=-1,this._fieldsIndex=null,this._geometryType=t.geometryType,this._features=e}get fields(){return this._fieldsIndex}get geometryType(){return this._geometryType}get hasFeatures(){return!!this._features.length}get hasNext(){return this._featureIndex+1<this._features.length}get exceededTransferLimit(){return this._exceededTransferLimit}get hasZ(){return!1}get hasM(){return!1}get _current(){return this._features[this._featureIndex]}removeIds(e){const t=new Set(e);this._features=this._features.filter((e=>!(null!=e.objectId&&t.has(e.objectId))))}getSize(){return this._features.length}getCursor(){return this.copy()}getInTransform(){return this._transform}getAttributeHash(){let e="";for(const t in this._current.attributes)e+=this._current.attributes[t];return e}getIndex(){return this._featureIndex}setIndex(e){this._featureIndex=e}getObjectId(){return this._current?.objectId}getDisplayId(){return this._current.displayId}setDisplayId(e){this._current.displayId=e}copy(){const e=new u(this._features,this.metadata);return this.copyInto(e),e}next(){for(;++this._featureIndex<this._features.length&&!this._getExists(););return this._featureIndex<this._features.length}readGeometryArea(){return s(this._current)?r(this._current.geometry,2):0}_readX(){return s(this._current)?this._current.geometry.coords[0]:0}_readY(){return s(this._current)?this._current.geometry.coords[1]:0}_readGeometry(){return this._current.geometry??null}_readServerCentroid(){return this._current.centroid}_readAttribute(e,t){if(!this._fieldsIndex){const t=this._current.attributes[e];if(void 0!==t)return t;const r=e.toLowerCase();for(const e in this._current.attributes)if(e.toLowerCase()===r)return this._current.attributes[e];return}const r=this._fieldsIndex.get(e);if(!r)return;let s=this._current.attributes[r.name];return null==s?s:("esriFieldTypeTimestampOffset"===this.fields.get(e)?.type&&(s=this.parseTimestampOffset(s)),t&&this.fields.isDateField(e)?new Date(s):s)}_readAttributes(){return this._current.attributes}copyInto(e){super.copyInto(e),e._featureIndex=this._featureIndex,e._transform=this._transform,e._fieldsIndex=this._fieldsIndex}}export{u as FeatureSetReaderJSON};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";let i=class extends r{constructor(e){super(e)}initialize(){this.view._stage
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";let i=class extends r{constructor(e){super(e)}initialize(){this.view._stage?.renderer?.addRenderNode(this)}destroy(){this.view._stage?.renderer?.removeRenderNode(this)}get renderCamera(){return this.view.state.camera.clone()}get renderingContext(){return this.view._stage.renderView.renderingContext}get gl(){return this.view._stage.renderView.renderingContext.gl2}get fboCache(){return this.view._stage.renderer.fboCache}requestRender(){this.view._stage.renderView.requestRender()}bindTexture(e,r){this.renderingContext.bindTexture(e,r)}bindFramebuffer(e){e&&this.renderingContext.bindFramebuffer(e.fbo)}};e([t({constructOnly:!0})],i.prototype,"view",void 0),i=e([s("esri.views.3d.effects.RenderNode")],i);const n=i;export{n as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../Graphic.js";import{isSome as s,removeUnordered as r}from"../../../core/arrayUtils.js";import{ByteSizeUnit as o}from"../../../core/ByteSizeUnit.js";import a from"../../../core/Collection.js";import{makeHandle as n}from"../../../core/handleUtils.js";import has from"../../../core/has.js";import l from"../../../core/Logger.js";import{someMap as d}from"../../../core/MapUtils.js";import{destroyMaybe as h}from"../../../core/maybe.js";import c from"../../../core/PooledArray.js";import{isAbortError as u,throwIfAborted as _,createResolver as m}from"../../../core/promiseUtils.js";import{initial as g,watch as p}from"../../../core/reactiveUtils.js";import{schedule as f}from"../../../core/scheduling.js";import{isArrayBuffer as b}from"../../../core/typedArrayUtil.js";import{getMetersPerVerticalUnitForSR as y}from"../../../core/unitUtils.js";import{property as v}from"../../../core/accessorSupport/decorators/property.js";import{subclass as I}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as M}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as C}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as O,getTranslation as x}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as E,create as j}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as w}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{s as A,e as S,g as T,t as D,i as R,f as N}from"../../../chunks/vec32.js";import{create as V}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as F}from"../../../chunks/vec42.js";import{fromValues as P}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as H}from"../../../core/support/UpdatingHandles.js";import{localLinearScaleFactors as U}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as G}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as L}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as k}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as B}from"../../../geometry/projection/projectVectorToVector.js";import{create as q,empty as z,expandWithBuffer as K,toRect as W}from"../../../geometry/support/aaBoundingBox.js";import{create as $,intersects as Q}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as X}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as Y}from"../../../geometry/support/FloatArray.js";import{compactIndices as J}from"../../../geometry/support/Indices.js";import{g as Z,f as ee}from"../../../chunks/sphere.js";import{newUByteArray as te}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as ie}from"../../../layers/LayerConstants.js";import se from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as re}from"../../../layers/support/fieldUtils.js";import oe from"../../../layers/support/SceneModification.js";import{getColor as ae,getOpacity as ne}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{loadArcade as le}from"../../../support/arcadeOnDemand.js";import{isBasemapLayer as de}from"../../../support/basemapUtils.js";import he from"../../../symbols/Symbol3D.js";import{getMetersPerUnit as ce}from"../../../symbols/support/unitConversionUtils.js";import ue from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as _e}from"./I3SMeshViewPerformanceInfo.js";import{I3SMeshWorkerHandle as me,toWasmModification as ge}from"./I3SMeshWorkerHandle.js";import{ForAllFeaturesReturnType as pe,ForAllFeaturesMode as fe}from"./II3SMeshView3D.js";import{initialize as be,setModificationsSync as ye,filterObbsForModificationsSync as ve,interpretObbModificationResults as Ie}from"./SceneLayerWorker.js";import{overrideColor as Me}from"./graphics/graphicUtils.js";import{areLabelsVisible as Ce}from"./graphics/Labeler.js";import{TextureUsage as Oe,TextureEncoding as xe}from"./i3s/enums.js";import Ee from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as je}from"./i3s/I3SAsyncElevationUpdater.js";import{I3SCrossfadeHelper as we,NodeCrossfadeMetaData as Ae}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as Se}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Te}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as De,selectEncoding as Re,defaultMaterial as Ne,createTexture as Ve,configureMaterial as Fe}from"./i3s/I3SMaterialUtil.js";import{NodeIMModificationImpact as Pe,NodeState as He}from"./i3s/I3SNode.js";import{I3SOverrides as Ue}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as Ge,getLocalOrigin as Le}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as ke,checkSceneLayerValid as Be,checkSceneLayerCompatibleWithView as qe,getCacheKeySuffix as ze,whenGraphicAttributes as Ke,computeVisibilityObb as We,filterInPlace as $e,getCachedAttributeValue as Qe,intersectBoundingRectWithMbs as Xe,MbsIntersectResult as Ye,addWraparound as Je,getSymbolInfo as Ze,transparentEdgeMaterial as et,getClipRect as tt}from"./i3s/I3SUtil.js";import{IDBCache as it}from"./i3s/IDBCache.js";import{IDBMockCache as st}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as rt}from"./i3s/LayerElevationProvider.js";import{attributeLookup as ot}from"./support/attributeUtils.js";import{ColorMixModeEnum as at}from"./support/symbolColorUtils.js";import{debugFlags as nt}from"../support/debugFlags.js";import{ElevationRange as lt}from"../support/ElevationRange.js";import{toBoundingRect as dt}from"../support/extentUtils.js";import{Obb as ht}from"../support/orientedBoundingBox.js";import{updatingProgress as ct}from"../support/updatingProperties.js";import{glLayout as ut}from"../support/buffer/glUtil.js";import{createVertexBufferLayout as _t}from"../webgl-engine/collections/Component/SourceGeometry.js";import{TextureCoordinateAttributeType as mt}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{loadBasis as gt}from"../webgl-engine/lib/BasisUtil.js";import{Transparency as pt}from"../webgl-engine/lib/edgeRendering/interfaces.js";const ft="esri.views.3d.layers.I3SMeshView3D",bt=()=>l.getLogger(ft),yt=[1,1,1,1];class vt extends Ae{constructor(e,t,i,s,r,o,a,n,l){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=a,this.anchorIds=n,this.anchors=l,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0}}var It;!function(e){e[e.CastShadows=4]="CastShadows",e[e.Pickable=5]="Pickable"}(It||(It={}));const Mt=23,Ct=100*o.MEGABYTES,Ot=t=>{let o=class extends t{constructor(...e){super(e),this._needsNormals=!0,this._updatingHandles=new H,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._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=new Array,this.ignoresMemoryFactor=!1,this._layerUrl="",this._cacheKeySuffix=null,this._elevationTask=null,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i(null,null,{}),this._crossfadeHelper=new we(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerUid(){return this.i3slayer&&this.i3slayer.uid}get sublayerUid(){return null}get layerId(){return this.i3slayer&&this.i3slayer.id}get sublayerId(){return null}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?"yes":"probably-not":"unknown"}get rendererTextureUsage(){return ke(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?Oe.AllTexturesPBR:Oe.AllTextures:this._usePBR||this._hasLoadedPBRTextures?Oe.GeometryTexturesPBR:Oe.GeometryTextures}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null!=e&&"absolute-height"===e.mode){const t=y(this.i3slayer.spatialReference),i=ce(e.unit);return(e.offset??0)*i/t}return 0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return new kt(Lt.Absolute,0);const t=y(this.i3slayer.spatialReference),i=ce(e.unit),s=(e.offset??0)*i/t;switch(e.mode){case"absolute-height":return new kt(Lt.Absolute,s);case"relative-to-ground":return new kt(Lt.RelativeToGround,s);case"on-the-ground":return new kt(Lt.OnTheGround,0);default:return new kt(Lt.Absolute,0)}}get supportedTextureEncodings(){return De(this.view._stage.renderView.capabilities)}get uncompressedTextureDownsamplingEnabled(){const e=this.view?.qualitySettings.sceneService.uncompressedTextureDownsamplingEnabled,t=0==(this.supportedTextureEncodings&xe.DDS_S3TC);return e&&t}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){const e=this._nodeId2Meta,t=new lt;for(const i of e.values()){if(null==i)continue;const{node:{mbs:e}}=i,[,s,r]=e;t.union(s-r,s+r)}return t.valid?t:null}get fullExtent(){return this.i3slayer.fullExtent}initialize(){const e=has("enable-feature:idb-mock-cache");this._idbCache=e?new st(this.view,e):new it("esri-scenelayer-cache","geometries"),this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const t=this.view.resourceController,i=t.memoryController;this.i3sOverrides=new Ue({view:this.view,layer:this.i3slayer,memoryController:i}),this._worker=new me(Kt(t)),this.addResolvingPromise(this._worker.promise);const s=this.i3slayer.store;this._worker.setLegacySchema(this.uid,s.defaultGeometrySchema),Be(this.i3slayer),qe(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new se({layerView:this,worker:this._worker}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view._stage,this._collection=this._stage.renderView.componentObjectCollection,this.resetHighlights();const r=s.defaultGeometrySchema;if(this._isIntegratedMesh||!r)this._hasComponentData=!1;else{const e=r.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(r?.vertexAttributes.color??null)&&!this.i3slayer.cachedDrawingInfo?.color,this._isIntegratedMesh||(this._edgeView=this._stage.renderer.ensureEdgeView());const o=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,(e=>this._deleteComponentObject(e)));this._memCache=o;const a=e=>null!=this._controller.index?.rootNode?this._controller.index.traverse(this._controller.index.rootNode,(t=>{const i=t.index,s=this._nodeId2Meta.get(i)||this._nodeId2MetaReloading.get(i);return e(t,null!=s?s.objectHandle:null)})):()=>{};this._intersectionHandler=new Te({layerUid:this.layerUid,sublayerUid:this.sublayerUid,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:a}),this._updatingHandles.add((()=>this.layerUid),(e=>this._intersectionHandler.layerUid=e)),this._updatingHandles.add((()=>this.sublayerUid),(e=>this._intersectionHandler.sublayerUid=e)),this._elevationProvider=new rt({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add((()=>this.view.clippingArea),(()=>this._clippingAreaChanged()),g),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)),g),this._updatingHandles.add((()=>!this.suspended&&this.elevationInfo.mode!==Lt.Absolute),((e,t)=>{e?this.addHandles(this.view.basemapTerrain.on("elevation-change",(({extent:e})=>this._ensureElevationTask().addExtent(e))),zt):t&&this.removeHandles(zt)}),g),this._updatingHandles.add((()=>this._usePBR),(e=>this._updatePBR(e)));const n=()=>{this._reloadAll(),this.clearMemCache()};this._updatingHandles.add((()=>this.rendererTextureUsage),n),this._updatingHandles.add((()=>this.uncompressedTextureDownsamplingEnabled),n),this._updatingHandles.add((()=>this.contentVisible),(e=>this._contentVisibleChanged(e)),g),this._updatingHandles.add((()=>this.i3slayer.labelsVisible),(()=>this._labelingChanged()),g),this._updatingHandles.add((()=>this.i3slayer.labelingInfo),(()=>this._labelingChanged()),g),this._updatingHandles.add((()=>this._modifications),(()=>this._modificationsChanged()),g),this.addHandles([p((()=>nt.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&&nt.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||nt.I3S_TREE_SHOW_TILES||(this._treeDebugger=h(this._treeDebugger))}),g),p((()=>nt.I3S_SHOW_MODIFICATIONS),(()=>this._showModifications()),g)]),this._cacheKeySuffix=ze(this.i3slayer.spatialReference,this.view.renderSpatialReference),this._idbCache.init().catch((e=>bt().warn(`Failed to initialize IndexedDB cache: ${e}`)))}destroy(){this._clearAddTasks(),this._elevationTask=h(this._elevationTask),this.i3sOverrides=h(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.objectsChanged(this.getVisibleObbs()),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._worker;e&&(e.destroyContext(this.uid).then((()=>e.destroy())),this._worker=null),this._removeAllNodeDataFromStage(),this._memCache=h(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=h(this._labeler),this._treeDebugger=h(this._treeDebugger),this._controller=h(this._controller),this._highlights.destroy(),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=h(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null),this._updatingHandles=h(this._updatingHandles)}_memEstimateTextureAdded(e){const t=e.memoryEstimate;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(null!=e){const t=e.memoryEstimate;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){const t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){const t=this._collection.getObjectGPUMemoryUsage(e);this._gpuMemoryEstimate-=t,this._geoMemoryEstimate-=t}isNodeLoaded(e){return this._nodeId2Meta.has(e)}isNodeReloading(e){return this._nodeId2MetaReloading.has(e)}get usedMemory(){let e=null!=this._labeler?this._labeler.usedMemory:0;return this._nodeId2Meta.forEach((t=>e+=null!=t?t.node.memory:0)),this._nodeId2MetaReloading.forEach((t=>e+=null!=t?t.node.memory:0)),e}get unloadedMemory(){return(null!=this._controller?this._controller.unloadedMemoryEstimate:0)+(null!=this._labeler?this._labeler.unloadedMemoryEstimate:0)}_labelingChanged(){if(!(Ce(this.i3slayer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new ue({view:this.view,layer:this.i3slayer,collection:this._collection,overrides:this.i3sOverrides});this._nodeId2Meta.forEach((t=>null!=t&&this._addMetaToLabeler(e,t))),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then((e=>(--this._asyncModuleLoading,e)),(e=>{throw--this._asyncModuleLoading,e}))}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=be().then((()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()})),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=this.uid,t=this.i3slayer.spatialReference;this._worker.setModifications(e,this._layerClippingArea,this._modifications,t);const i=ge(this._layerClippingArea,this._modifications,t);ye({context:e,modifications:i,isGeodetic:t.isGeographic}),this._controller.modificationsChanged();const s=this.hasModifications?new c:null;this._nodeId2Meta.forEach(((e,t)=>{null==e?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):null!=s&&s.push(e.node)})),this.notifyChange("elevationRange"),null!=s&&this._nodeId2MetaReloading.forEach((e=>s.push(e.node))),null!=s&&s.length>0&&(this.updateNodeModificationStatus(s),s.forAll((e=>{if(e.imModificationImpact!==Pe.Culled){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),null!=t?(this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t),this.notifyChange("elevationRange")):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}}))),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(null!=this._modificationGraphics&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!nt.I3S_SHOW_MODIFICATIONS||0===this._modifications.length)return;const e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={type:"simple-fill",outline:{color:[255,255,255],width:1}};this._modificationGraphics=new Array;for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.i3slayer.spatialReference;const o={...t,color:e[s.type]};this._modificationGraphics.push(new i({geometry:r,symbol:o}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,((e,t)=>this._createAttributes(e,t)))}_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){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);null!=i?.attributeInfo&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);null!=s&&(await this.i3sOverrides.applyAttributeOverrides(s.featureIds,t,i,this._controller.requiredAttributes),s.attributeInfo=t,this._controller.reschedule((()=>this._attributeValuesChanged(s)),i).catch((e=>{u(e)||bt().warn("Error while updating attribute values. Layer might not display correctly.",e)})))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.filteredIds=null,null!=this._labeler&&this._labeler.setNodeMetaAttributes(e,((e,t)=>this._createAttributes(e,t))),this._updateEngineObject(e)}clearMemCache(){null!=this._memCache&&this._memCache.clear()}getVisibleNodes(){const e=new Array;return this._nodeId2Meta.forEach((t=>null!=t&&e.push(t.node))),e}getVisibleObbs(){const e=new Array;return this._nodeId2Meta.forEach((t=>{if(null!=t){const i=this.getNodeComponentObb(t.node);null!=i&&e.push(i)}})),e}getNodeComponentObb(e){const t=this._nodeId2Meta.get(e.index)??this._nodeId2MetaReloading.get(e.index);return null!=t?this._collection.getComponentObb(t.objectHandle):null}getLoadedNodeIndices(e){this._nodeId2Meta.forEach(((t,i)=>e.push(i))),this._nodeId2MetaReloading.forEach(((t,i)=>e.push(i)))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&0!=(this.supportedTextureEncodings&xe.Basis)&&this.i3slayer.textureSetDefinitions?.some((e=>e.formats.some((e=>"basis"===e.format||"ktx2"===e.format))))&>()}_getVertexBufferLayout(e,t){const i={hasTexture:Nt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion};return ut(_t(this._getGeometryParameters(i)))}_getObjectIdField(){return this.i3slayer.objectIdField||ie}_getGlobalIdField(){return this.i3slayer.associatedLayer?.globalIdField}_findGraphicNodeAndIndex(e){const t=ot(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());let i=null;return d(this._nodeId2Meta,(e=>{if(null==e)return!1;const s=e.featureIds.indexOf(t);return-1!==s&&(i={node:e.node,index:s},!0)})),i}_getGraphicIndices(e,t){const i=this._nodeId2Meta.get(e.index);if(null==i)return[];const s=[],r=this._getObjectIdField(),o=this.i3slayer.fieldsIndex;for(const a of t){const e=ot(o,a.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this._getAABB(t.node.index,t.index);return null==i?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this._getAABB(e.nodeIndex,e.componentIndex)}_getAABB(e,t){const i=this._nodeId2Meta.get(e);if(null==i?.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=Se(t,this._collection,s,X(24),0),o=this.view.renderSpatialReference,a=this.view.spatialReference;if(!L(r,o,0,r,a,0,8))return null;const n=z();return K(n,r,0,8),n}whenGraphicAttributes(e,t){return Ke(this.i3slayer,e,this._getObjectIdField(),t,(()=>[...this._nodeId2Meta.values()].filter(s)))}getGraphicFromIntersectorTarget(e){if(null==e.nodeIndex||null==e.componentIndex)return null;const t=this._nodeId2Meta.get(e.nodeIndex);return null==t?.featureIds||e.componentIndex>=t.featureIds.length?null:this._createGraphic(e.componentIndex,t)}_getCacheKey(e){return`${this._layerUrl}/v${Mt}/${e}${this._cacheKeySuffix}`}_getMemCacheKey(e,t=this.elevationOffset){return e+"#"+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&0===this.elevationOffset&&null!=this._cacheKeySuffix}loadCachedGPUData(e){return null!=this._memCache?this._memCache.pop(this._getMemCacheKey(e)):null}deleteCachedGPUData(e){null!=e&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(null==this._memCache)return void this._deleteComponentObject(e);const i=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,e.node.memory,i)}loadMissingTextures(e,t,i,s){const r=e?.filter(((e,i)=>{if(0==(e.usage&this.rendererTextureUsage))return!1;if(null==t)return!0;const s=Re(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(null==r?.data||s&&r.encoding!==s.encoding)}))??[];return 0===r.length?Promise.resolve(!1):i(r,s).then((i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0}))}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then((s=>null==s?null:s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(this.elevationInfo.mode===Lt.Absolute&&(e.geometryObb=ht.fromData(s.geometryObbData)),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then((i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=Pt(s.transformedGeometry,s.textureData),s.textureData.every(Ft)&&Ht(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch((t=>bt().warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`)))),_(t),s)))))):Promise.resolve(null)}addNode(e,t,i){return Vt(t)?null==t.geometryBuffer?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,(()=>this._transformNode(e,t,i).then((s=>this._safeReschedule((()=>{if(null==s)return e.hasModifications=!1,this._addCachedNodeData(e,null,i);e.hasModifications=s.transformedGeometry.hasModifications;const{obb:r,componentOffsets:o,featureIds:a,anchorIds:n,anchors:l,transformedGeometry:d}=s,h=this._controller.crsIndex,c=this.view.renderSpatialReference,u=Ge(e.mbs,this.elevationOffset,h,c),_=A(Bt,r.center.x,r.center.y,r.center.z);S(_,_,u);const m=new ht(_,[r.extents.x,r.extents.y,r.extents.z],w(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));this.elevationInfo.mode===Lt.Absolute&&(e.geometryObb=m),t.geometryData.componentOffsets=o,a&&(t.geometryData.featureIds=Array.from(a)),t.geometryData.anchorIds=n,t.geometryData.anchors=l;const g={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:d,globalTrafo:u,geometryObbData:m.data,byteSize:Pt(d,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&Ht(e,g)){const t=null!=g.textureData?g.textureData.map((e=>Ft(e)?e:null)):null;this._idbCache.put(this._getCacheKey(e.id),{...g,textureData:t}).catch((t=>bt().warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`)))}return this._addCachedNodeData(e,g,i)}),i))))):Promise.reject()}getElevationRange(e){const t=new lt,i=this.view,s=i.renderCoordsHelper,r=s.referenceEllipsoid.radius,o=this._collection;return this._nodeId2Meta.forEach((a=>{const n=a?.node.geometryObb;if(!n||!n?.intersectSphere(e))return;const l=o.getObjectTransform(a.objectHandle),d=s.getAltitude(l.position);for(let e=0;e<a.featureIds.length;e++){const s=o.getComponentAabb(a.objectHandle,e,qt);if("local"===i.viewingMode)t.union(d+s[2],d+s[5]);else{const e=Math.max(Math.abs(s[3]),Math.abs(s[0])),i=Math.max(Math.abs(s[4]),Math.abs(s[1])),o=d+s[5]+r;t.union(d+s[2],Math.sqrt(e*e+i*i+o*o)-r)}}})),t}computeVisibilityObb(e){return We(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications,this.view.renderCoordsHelper.sphericalPCPF)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let f=0;f<s.length;++f)r[f]=this._getVertexBufferLayout(s[f],t.geometryDescriptor);const o=e.mbs,a=this.elevationOffset,n=this._controller.crsIndex,l=this._controller.crsVertex,d=this.view.renderSpatialReference,h=Le(o,a,n),c=Ge(o,a,n,d),u=k(n,l),_=k(l,d);if(null==u||null==_)return Promise.resolve(null);const m=this.i3slayer.normalReferenceFrame,g=t.normalReferenceFrame??m??"none",p={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,localOrigin:h,globalTrafo:c,mbs:o,obbData:e.serviceObb?.data,elevationOffset:a,needNormals:this._needsNormals&&this._controller.isMeshPyramid,normalReferenceFrame:g,indexToVertexProjector:u,vertexToRenderProjector:_};return this._worker.invoke(p,i)}get _supportsNodeCrossFading(){return!this.view?._stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){const t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,i){if(this.elevationInfo.mode===Lt.Absolute&&(e.geometryObb=this._collection.getComponentObb(t.objectHandle).clone()),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);null!=this._labeler&&this._addMetaToLabeler(this._labeler,t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,!0),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==Lt.Absolute&&this._ensureElevationTask().schedule(s),this._updateEngineObject(t),this._highlights.objectCreated(t),null!=this._treeDebugger&&this._treeDebugger.update()}addCachedNodeData(e,t,i,s){return this._addData(e,i,(()=>this._addCachedNodeData(e,t,s)))}async deleteCachedNodeData(e){if(this._idbCacheEnabled)return this._idbCache.remove(this._getCacheKey(e))}async _addCachedNodeData(e,t,i){if(!this.contentVisible||!this._controller.isGeometryVisible(e))return void this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);if(null==t)return void this._addNodeMeta(e.index,null);const s=this._addTasks.get(e.index),{geometryData:r,transformedGeometry:o,globalTrafo:a}=t;await this.i3sOverrides.applyAttributeOverrides(r.featureIds,s.attributeInfo,i,this._controller.requiredAttributes);const n=null!=t.textureData?t.textureData.filter((e=>null!=e&&0!=(e.usage&this.rendererTextureUsage))):[];!has("disable-feature:i3s-basis")&&n.some((e=>null!=e&&(e.encoding===xe.Basis||e.encoding===xe.KTX2)))&&await gt(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:h,anchorIds:c,anchors:u}=r,_=this._collection,m=d[0],{layout:g,indices:p,interleavedVertexData:f,positionData:b,hasColors:y}=o,{material:v,geometryParameters:I}=this._materialParameters(m,g),w=l||new Uint32Array([0,p?p.length:f.byteLength/g[0].stride]),A={vertices:{data:f,count:f.byteLength/g[0].stride,layoutParameters:I},positionData:{positions:Y(b.data),indices:J(b.indices)},indices:p,componentOffsets:w},S=m.transformation?E(m.transformation):j();O(S,a,S);const T=x(V(),S),D=M(C(),S),R=this.view.renderSpatialReference,N=this.view.basemapTerrain.spatialReference,F=V(),H=[1,1,1];U(T,R,H,N)||bt().errorOnce("Unsupported coordinate system for IM overlay"),B(T,R,F,N);const G=_.createObject({toMapSpace:P(F[0],F[1],H[0],H[1]),geometry:A,obb:ht.fromData(t.geometryObbData),transform:{position:T,rotationScale:D}}),L=I.textureCoordinates===mt.Atlas,{textures:k,texturePromise:q}=this._initMaterialAndTextures(G,v,n,L);e.memory+=this._memEstimateGeometryAdded(G),e.memory+=k.reduce(((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0)),0);const z=!!v.hasParametersFromSource,K="blend"!==v.alphaMode&&v.metallicRoughness.baseColorFactor[3]>=1,W=new vt(e,h,G,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:z,isOpaque:K},k,c,u);s.meta=W,!this._hasTextures&&t.requiredTextures?.some((({usage:e})=>0!=(e&Oe.ColorTextures)))&&(this._hasTextures=!0),this._hasData=!0,this._hasColors=this._hasColors||y,this._hasTextures=this._hasTextures||!!e.resources.texture,this.notifyChange("hasTexturesOrVertexColors");const $=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(W),q]).then((([t,s])=>(null!=t&&t.updateObjectVisibility(W.objectHandle,!1).catch((e=>xt(e,this.i3slayer.title))),this._safeReschedule((()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,W),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(G,!0),null!=t&&t.updateObjectVisibility(W.objectHandle,!0).catch((e=>xt(e,this.i3slayer.title))),W.attributeInfo=i.attributeInfo;const s=W.cachedRendererVersion!==this._rendererVersion,r=$!==this.slicePlaneEnabled;this._updateElevationOffsets(W);const o=W.elevationOffsets;this._updateComponentData(W);const a=this._applyFiltersToNode(W);(s||null!=t&&(r||a||o))&&this._addOrUpdateEdgeRendering(W),null!=this._labeler&&this._addMetaToLabeler(this._labeler,W),this._visibleGeometryChanged(W,Et.ADD),this._highlights.objectCreated(W),this._updateMaterial(W),this._setNewNodeOpacity(W),null!=this._treeDebugger&&this._treeDebugger.update()}),i)))).catch((e=>{throw null!=s.meta&&(this._cacheGPUData(s.meta),s.meta=null),e}))}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){bt().error("Removing duplicated node");const t=this._nodeId2Meta.get(e);null!=t&&this._deleteComponentObject(t)}else this._controller.updateLoadStatus(e,!0);null!=t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&Gt(t.cachedEdgeMaterials,0)),this._nodeId2Meta.set(e,t),this.notifyChange("elevationRange")}_updateElevationOffsets(e){const t=this.view.renderSpatialReference,i=this._controller.crsIndex,s=this.elevationInfo,r=this.view.basemapTerrain,o=r.spatialReference,a=s.mode;if(null==t||null==o||a===Lt.Absolute)return void(e.elevationOffsets=null);const n=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const l=Bt,d=qt,h=a===Lt.OnTheGround,c=this.view.renderCoordsHelper,u=e.featureIds.length,_=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const s=X(3*u);e.cachedElevationAnchors=s;for(let r=0;r<u;r++){const a=3*r,h=e.anchorIds?.indexOf(r)??-1;e.anchors&&h>=0?(A(l,e.anchors[3*h],e.anchors[3*h+1],e.anchors[3*h+2]),T(l,l,Z(e.node.mbs)),B(l,i,l,o),s[a]=l[0],s[a+1]=l[1],s[a+2]=c.getAltitude(l)):(this._collection.getComponentAabb(e.objectHandle,r,d,!0),A(l,(d[0]+d[3])/2,(d[1]+d[4])/2,d[2]),D(l,l,n.rotationScale),T(l,l,n.position),s[a+2]=c.getAltitude(l),B(l,t,l,o),s[a]=l[0],s[a+1]=l[1])}return s})(),m=s.offset,g=e.elevationOffsets,p=(e,t)=>{const i=h?_[3*e+2]:0;g[e]=m+(null!=t?t-i:0)};r.getElevations(_,u,p)}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new je(this.view.resourceController.scheduler,(e=>{const t=this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference);return null!=t?t.filterInPlace((e=>null!=this._nodeId2Meta.get(e))):null}),(e=>{const t=this._nodeId2Meta.get(e);this._nodeElevationAlignmentChanged(t)}))),this._elevationTask}_elevationInfoChanged(e,t){const i=e.mode!==Lt.Absolute,s=!!t&&t!==e&&t.mode!==Lt.Absolute;this._intersectionHandler.updateElevationAlignState(i,this.view.state.viewingMode),i&&!s&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach((e=>this._nodeElevationAlignmentChanged(e)))}_nodeElevationAlignmentChanged(e){null!=e&&(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),null!=this._labeler&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,Et.UPDATE))}_safeReschedule(e,t){return _(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:Ne(),s=t.some((e=>"uvRegion"===e.name)),r=t.some((e=>"normalCompressed"===e.name)),o=Nt(i);return{geometryParameters:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s){const r=this._stage.renderView,o=i.map((e=>Ve(e,t,s,r)));this._stage.addMany(o);let a=null;return this._collection.updateMaterial(e,(e=>{a=Fe(e,t,o,i,this.view._stage.renderView.textureRepository,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference}),this._updateMaterialOverlay(e)})),{textures:o,texturePromise:a}}_getGeometryParameters(e){return{textureCoordinates:e.hasTexture?e.hasRegions?mt.Atlas:mt.Default:mt.None,colors:this._hasVertexColors,hasNormals:e.hasNormals&&this._needsNormals,needsNormals:this._needsNormals}}_addData(e,t,i){let s=this._addTasks.get(e.index);return s?s.attributeInfo=t:(s={...m(),attributeInfo:t,meta:null},this._addTasks.set(e.index,s),i().then(s.resolve,s.reject).then((()=>this._addTasks.delete(e.index))).catch((t=>{throw this._addTasks.delete(e.index),t}))),s.promise}_clearAddTasks(){this._addTasks.forEach((e=>{null!=e.meta&&(this._cacheGPUData(e.meta),e.meta=null)})),this._addTasks.clear()}_clippingAreaChanged(){const e=this.view.renderSpatialReference,t=this.i3slayer.spatialReference,i=$();this._renderClippingArea=dt(this.view.clippingArea,i,e)?i:null;const s=$();this._layerClippingArea=dt(this.view.clippingArea,s,t)?s:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){const e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e)}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach((e=>{null!=e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Et.UPDATE))}))}getFilters(){const e=[],t=this._renderClippingArea;return null!=t&&e.push(((e,i)=>this._boundingRectFilter(e,i,t))),e}addSqlFilter(e,t,i){if(null!=t){const s=t.fieldNames;e.push(((e,r)=>this._sqlFilter(e,r,t,s,i)))}}_sqlFilter(e,t,i,s,r){const o={},a=this._createLayerGraphic(o),n=this.i3slayer.objectIdField,l=t.featureIds,d=t.attributeInfo?.attributeData;s.every((e=>e===n||null!=d?.[e]))&&$e(e,l,(e=>{o[n]=l[e];for(const i of s)i!==n&&(o[i]=d?Qe(d[i],e):null);try{return i.testFeature(a)}catch(t){return r(t),!1}}))}_boundingRectNodeTest(e,t){return G(e.node.mbs,this._controller.crsIndex,Rt,this.view.renderSpatialReference),Xe(t,Rt)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,jt),W(jt,wt),Q(i,wt)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(r===Ye.INSIDE)return;if(r===Ye.OUTSIDE)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const a=this._transformClippingArea(At,i,t.objectHandle);$e(e,t.featureIds,(e=>this._boundingRectFeatureTest(t,e,a)))}_transformClippingArea(e,t,i){const s=this._collection.getObjectTransform(i),r=s.position,o=s.rotationScale;return e[0]=(t[0]-r[0])/o[0],e[1]=(t[1]-r[1])/o[4],e[2]=(t[2]-r[0])/o[0],e[3]=(t[3]-r[1])/o[4],e}_addOrUpdateEdgeRendering(e,t=!0){const i=this._edgeView;if(null==i)return Promise.resolve(null);const s=e.objectHandle,r=i.hasObject(s),{hasEdges:o,perFeatureEdgeMaterials:a}=this._getFilteredEdgeMaterials(e),n={hasSlicePlane:this.slicePlaneEnabled};if(o&&r){if(this.nodeCrossfadingEnabled){Gt(a,this.getNodeOpacity(e))}return i.updateAllComponentMaterials(s,a,n,t).catch((e=>xt(e,this.i3slayer.title))),i.updateObjectVisibility(s,!0).catch((e=>xt(e,this.i3slayer.title))),i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>xt(e,this.i3slayer.title))),Promise.resolve(i)}return o&&!r?this._collection.addEdges(s,i,a,n).then((t=>(e.edgeMemoryUsage=t,e.node.memory+=t,i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>xt(e,this.i3slayer.title))),i))):(!o&&r&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,i.removeObject(s)),Promise.resolve(null))}_applyFiltersToNode(e){return!!this._applyFiltersToNodeComponents(e)&&(null!=this._labeler&&this._labeler.applyFilterChange(e),!0)}_applyFiltersToNodeComponents(e){const t=this._collection,i=t.getComponentCount(e.objectHandle),s=null!=e.filteredIds,r=0===i.invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!r;if(this._updateCachedFilteredIds(e),s&&e.filteredIds===e.featureIds)return!r;const o=this._computeFilteredComponentIndices(e);return t.setAllComponentVisibilities(e.objectHandle,o),!0}_updateCachedFilteredIds(e){null!=e.filteredIds&&e.appliedFilters===this._filters||(e.filteredIds=this._computeFilteredIds(e),e.appliedFilters=this._filters)}_computeFilteredIds(e){const t=e.featureIds.slice();for(const i of this._filters)if(i(t,e),0===t.length)break;return t.length===e.featureIds.length?e.featureIds:t}_computeFilteredComponentIndices(e){const t=new Array,i=e.filteredIds;return null!=i&&e.featureIds.forEach(((e,s)=>{i[t.length]===e&&t.push(s)})),t}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach(((t,i)=>this._removeNodeStageData(i,e))),this._nodeId2MetaReloading.forEach(((t,i)=>this._removeNodeStageData(i,e,this._nodeId2MetaReloading))),this._elevationTask=h(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),null!=this._elevationTask&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);null!=s?(this._collection.setObjectVisibility(s.objectHandle,!1),null!=this._edgeView&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch((e=>xt(e,this.i3slayer.title))),this._visibleGeometryChanged(s,Et.REMOVE),null!=this._labeler&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights.objectDeleted(s),i===this._nodeId2Meta?(this._cacheGPUData(s,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(s)):this._deleteComponentObject(s),null!=this._treeDebugger&&this._treeDebugger.update()):i.delete(e)}_deleteComponentObject(e){if(null!=this._edgeView&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(const t of e.textures)this._memEstimateTextureRemoved(t),this._stage.remove(t)}updateNodeState(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._collection.updateMaterial(i.objectHandle,(e=>e.polygonOffsetEnabled=t===He.Hole))}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){const i=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,i),this.notifyChange("elevationRange")}const i=this._nodeId2MetaReloading.get(e);i&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,i))}_invalidateAllSymbols(){this._rendererVersion=Je(this._rendererVersion,1),this._controller&&this._controller.requestUpdate()}_getInvalidRendererVersion(){return Je(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=Je(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.i3slayer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&"arcadeRequired"in e&&e.arcadeRequired&&(this._arcade=await le()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:bt().warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.getSymbols())"mesh-3d"!==t.type&&bt().error(`Symbols of type '${t.type}' are not supported for 3D Object Scene Services.`);this._controller&&this._controller.requestUpdate()}_getCachedEdgeMaterials(e){return this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e),e.cachedEdgeMaterials}_getComponentParameters(e){this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e);const t=e.cachedSymbology;return(i,s)=>{const r=5*i;if(F(s.externalColor,t[r]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255),null!=this._stage.renderView.objectAndLayerIdRenderHelper){const t=e.featureIds[i],r=de(this.view.map,this.layerUid);this._stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(t,t,this.layerId,this.layerUid+"_"+this.sublayerId,this.layerPopupEnabledAndHasTemplate&&!r,e.node.resources.attributes,i,this.sublayerId),s.objectAndLayerIdColor=this._stage.renderView.getObjectAndLayerIdColor({graphicUid:t,layerUid:this.layerUid+"_"+this.sublayerId})}s.externalColorMixMode=t[r+4]&(1<<It.CastShadows)-1,s.castShadows=0!=(t[r+4]&1<<It.CastShadows),s.pickable=0!=(t[r+4]&1<<It.Pickable),s.elevationOffset=e.elevationOffsets?.[i]??0}}_getSymbolInfo(e,t){const i=e?.getSymbol(t,{arcade:this._arcade});if(!(i instanceof he))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=Ze(i);return this._symbolInfos.set(s,r),r}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=null!=this._symbologyOverrideFields&&this._symbologyOverrideFields.length>0?null!=this._rendererFields&&this._rendererFields.length>0?re(this.i3slayer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;const t=this._tmpAttributeOnlyGraphic,i={};t.attributes=i;const s=this._currentRenderer,r=e.attributeInfo?.attributeData,o=null!=e.featureIds?this.i3slayer.objectIdField:null,a=null!=r&&null!=this._symbologyFields&&this._symbologyFields.length>0;let n=null,l=null;if(a&&null!=this._symbologyFields){n=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(n.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=te(5*e.featureIds.length));const d={color:Tt,castShadows:!0,pickable:!0,colorMixMode:at.Multiply,edgeMaterial:null},h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=pt.OPAQUE,m=et,g=0;for(let p=0;p<e.featureIds.length;p++){if(null!=o&&(i[o]=e.featureIds[p]),a&&n)for(let e=0;e<n.length;e++)i[n[e]]=Qe(l[e],p);const r=s?this._getSymbolInfo(s,t):null;let h=null,f=null;if(s&&"visualVariables"in s){if(this._colorVariable){const e=ae(this._colorVariable,t,{color:Dt,arcade:this._arcade});e&&(h=Tt,h[0]=e.r/255,h[1]=e.g/255,h[2]=e.b/255,this._opacityVariable||null===e.a||(f=e.a))}this._opacityVariable&&(f=ne(this._opacityVariable,t,{arcade:this._arcade}))}if(r?.material){const e=r.material;h=null==h||null==f?Me(h,f,e.color,e.alpha,yt,Tt):Me(h,f,null,null,yt,Tt)}if(null==h&&(h=Tt,h[0]=1,h[1]=1,h[2]=1,h[3]=1),d.pickable=!0,d.castShadows=!r||r.castShadows,d.colorMixMode=r?.material?r.material.colorMixMode:at.Multiply,d.edgeMaterial=r?r.edgeMaterial:null,null!=this._symbologyOverride&&(d.color=h,this._symbologyOverride(t,d),h=d.color),null!=this._nodeColorOverride&&(this._nodeColorOverride(e.node,h),d.colorMixMode=at.Replace),null!=d.edgeMaterial){const t=h[3]<=0?pt.INVISIBLE:h[3]>=1&&(e.material.isOpaque||d.colorMixMode===at.Replace)?pt.OPAQUE:pt.TRANSPARENT;d.edgeMaterial===u&&t===_||(m={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,_=t),e.cachedEdgeMaterials[p]=m}else e.cachedEdgeMaterials[p]=et;e.cachedSymbology[g++]=Math.round(255*h[0]),e.cachedSymbology[g++]=Math.round(255*h[1]),e.cachedSymbology[g++]=Math.round(255*h[2]),e.cachedSymbology[g++]=Math.round(255*h[3]),e.cachedSymbology[g++]=d.colorMixMode|+d.castShadows<<It.CastShadows|+d.pickable<<It.Pickable}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||Gt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some((e=>e!==et)),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map(((t,o)=>e.featureIds[o]!==i[s]?et:(r=r||t!==et,s++,t)));return{hasEdges:r,perFeatureEdgeMaterials:o}}_updateComponentData(e){if(!this._hasComponentData)return;const t=e.objectHandle,i=this._getComponentParameters(e);this._collection.setComponentData(t,i),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),null!=this._controller&&this._controller.restartNodeLoading()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach((t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,(t=>t.objectOpacity=e)),Gt(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))}))}_updateMaterial(e){this._collection.updateMaterial(e.objectHandle,(e=>{e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.usePBR=this._usePBR,this._updateMaterialOverlay(e)}))}_updateMaterialOverlay(e){}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Et.UPDATE)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),null!=this._labeler&&(this._labeler.slicePlaneEnabled=e),this._nodeId2Meta.forEach((t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,(t=>t.commonMaterialParameters.hasSlicePlane=e)),this._updateEdgeRendering(t,!1))}))}_updatePBR(e){this._nodeId2Meta.forEach((t=>{null!=t&&this._collection.updateMaterial(t.objectHandle,(t=>t.usePBR=e))})),this._hasLoadedPBRTextures=!0}get _usePBR(){return this._needsNormals&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){null!=this._edgeView&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?(t,i,s)=>s.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?pe.CONTINUE:e(t,i,s):e}_forAllFeatures(e,t,i){d(this._nodeId2Meta,(s=>{if(null==s)return!1;if(null!=t){switch(t(s)){case pe.EXIT:return!0;case pe.SKIP:return!1}}let r=pe.CONTINUE;switch(i){case fe.ALL:r=this._forAllFeaturesOfNode(s,e);break;case fe.VISIBLE_ONLY:r=this._forAllVisibleFeaturesOfNode(s,e);break;case fe.QUERYABLE:r=this._forAllQueryableFeaturesOfNode(s,e)}return r===pe.EXIT}))}_forAllFeaturesOfNode(e,t){let i=pe.CONTINUE;const s=e.featureIds;for(let r=0;r<s.length;r++)if(i=t(s[r],r,e),i===pe.EXIT)return i;return i}_forAllVisibleFeaturesOfNode(e,t){let i=pe.CONTINUE;const s=e.featureIds;return this._collection.forEachVisibleComponent(e.objectHandle,(r=>(i=t(s[r],r,e),i===pe.CONTINUE))),i}_forAllQueryableFeaturesOfNode(e,t){const i=this._ignoreClientNodeOverriddenFeatures(t);if(null==this._renderClippingArea)return this._forAllFeaturesOfNode(e,i);const s=this._boundingRectNodeTest(e,this._renderClippingArea);if(s===Ye.OUTSIDE)return pe.CONTINUE;if(s===Ye.INSIDE)return this._forAllFeaturesOfNode(e,i);const r=pe.CONTINUE,o=e.featureIds,a=e.objectHandle,n=tt(this._renderClippingArea,this._collection.getObjectTransform(a));for(let l=0;l<o.length;l++){if(!this._boundingRectFeatureTest(e,l,n))continue;const t=i(o[l],l,e);if(t===pe.EXIT)return t}return r}_createAttributes(e,t){const i={};null!=t.featureIds&&(i[this._getObjectIdField()]=t.featureIds[e]);const s=t.attributeInfo?.attributeData;if(null!=s)for(const r of Object.keys(s))i[r]=Qe(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e){if("number"==typeof e||e instanceof i?e=[e]:e instanceof a&&(e=e.toArray()),Array.isArray(e)&&e.length>0){if(e[0]instanceof i){const t=e,i=this.i3slayer.fieldsIndex,s=this._getObjectIdField(),r=t.map((e=>ot(i,e.attributes,s))),{set:o,handle:a}=this._highlights.acquireSet();return this._highlights.setFeatureIds(o,r),a}if("number"==typeof e[0]){const t=e,{set:i,handle:s}=this._highlights.acquireSet();return this._highlights.setFeatureIds(i,t),s}}return n()}resetHighlights(){h(this._highlights),this._highlights=new Ee({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,fe.ALL),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)})}_visibleGeometryChanged(e,t){if(!this._elevationProvider)return;const i=this.getNodeComponentObb(e.node);i&&this._elevationProvider.objectChanged(i),null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=f((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))),this._updateSnappingSources(e,t)}get performanceInfo(){return new _e(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(100*this._idbCache.getHitRate()):0)}get test(){const e=this,t=e=>{this._nodeColorOverride=e,this._invalidateAllSymbols()};return{controller:this._controller,labeler:this._labeler,get visibleObjectIds(){const t=[];return e._forAllFeatures((e=>(t.push(e),pe.CONTINUE)),null,fe.VISIBLE_ONLY),t.sort(((e,t)=>e-t)),t},get numNodes(){return e._nodeId2Meta.size},get loadedNodes(){return Array.from(e._nodeId2Meta.keys()).sort(((e,t)=>e-t))},setNodeColorOverride:t,setNodeColoring:e=>{if("client-nodes"===e)t(((e,t)=>{e.index<0?(t[0]=1,t[1]=0,t[2]=0):(t[0]=1,t[1]=1,t[2]=1)}));else t(null)}}}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return null!=e?this._collection.getMaterial(e.objectHandle).objectOpacity:0}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(((t,i)=>e(i,t)))}fadeNode(e,t,i){if(!this.nodeCrossfadingEnabled)return;const s=this._nodeId2Meta.get(e);null!=s&&this._crossfadeHelper.fadeNode(e,s,t,i)}setNodeOpacityByIndex(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._setNodeOpacity(i,t)}_setNodeOpacity(e,t){this._collection.updateMaterial(e.objectHandle,(e=>e.objectOpacity=t)),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(null==this._edgeView||!e.cachedEdgeMaterials)return;Gt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch((e=>xt(e,this.i3slayer.title)))}get hasModifications(){return this._isIntegratedMesh&&null!=this._layerClippingArea||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){const t=e.length;if(!this.hasModifications||t<=0||!0!==this._i3sWasmLoaded)return;const i=this.uid,s=Ut(e);if(s){const t={context:i,buffer:s.buffer};ve(t);const r=new Float64Array(s.buffer);e.forAll(((e,t)=>{const i=r[t],s=Ie(i);e.imModificationImpact=s,s!==Pe.Unmodified&&this._controller.invalidateGeometryVisibility(e.index)}))}}notifyUpdate(){this.notifyChange("updating")}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!(!this._controller||!this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||null!=this._labeler&&this._labeler.updating||this._crossfadeHelper?.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||null!=this._elevationTask&&this._elevationTask.running}trackSnappingSources(e){const t={events:e,fetchEdgeLocations:async(e,t,i)=>{const s=this._nodeId2Meta.get(e);if(null==s)throw new Error("invalid-node");const{origin:r,buffer:o}=await this._collection.extractEdgeInformation(s.objectHandle,t,i);return this._snappingLocationsApplyElevation(s,o,r),{type:"components",objectIds:s.featureIds,locations:o,origin:r}},remove:()=>r(this._snappingSourcesTrackers,t)};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach(((t,i)=>{if(null==t)return;const s=this._controller.getRenderMbs(t.node);s&&e.add(i,s)})),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||this.elevationInfo.mode===Lt.Absolute)return;const s=t.position0,r=t.position1,o=t.componentIndex,a=V(),n=V(),l=(e,t)=>{T(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,n),T(e,e,R(n,n,t)),N(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,a),l(a,t),s.setVec(d,a),r.getVec(d,a),l(a,t),r.setVec(d,a)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(null!=s)for(const r of this._snappingSourcesTrackers)t!==Et.REMOVE&&t!==Et.UPDATE||r.events.remove(i),t!==Et.ADD&&t!==Et.UPDATE||r.events.add(i,s)}};return e([v()],o.prototype,"_hasLoadedPBRTextures",void 0),e([v()],o.prototype,"_asyncModuleLoading",void 0),e([v()],o.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([v()],o.prototype,"view",void 0),e([v()],o.prototype,"i3slayer",void 0),e([v()],o.prototype,"_controller",void 0),e([v()],o.prototype,"_labeler",void 0),e([v()],o.prototype,"updating",void 0),e([v()],o.prototype,"suspended",void 0),e([v()],o.prototype,"contentVisible",null),e([v({readOnly:!0})],o.prototype,"legendEnabled",null),e([v()],o.prototype,"holeFilling",void 0),e([v(ct)],o.prototype,"updatingProgress",void 0),e([v()],o.prototype,"updatingProgressValue",null),e([v()],o.prototype,"hasTexturesOrVertexColors",null),e([v()],o.prototype,"rendererTextureUsage",null),e([v()],o.prototype,"elevationOffset",null),e([v()],o.prototype,"elevationInfo",null),e([v({type:Boolean})],o.prototype,"slicePlaneEnabled",void 0),e([v()],o.prototype,"supportedTextureEncodings",null),e([v()],o.prototype,"uncompressedTextureDownsamplingEnabled",null),e([v({type:[oe]})],o.prototype,"_modifications",void 0),e([v({readOnly:!0})],o.prototype,"clientGeometry",null),e([v()],o.prototype,"elevationRange",null),e([v()],o.prototype,"fullExtent",null),e([v()],o.prototype,"_elevationTask",void 0),e([v({readOnly:!0})],o.prototype,"_usePBR",null),o=e([I(ft)],o),o};function xt(e,t){u(e)||bt().warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}var Et;!function(e){e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE"}(Et||(Et={}));const jt=q(),wt=$(),At=$(),St=new ht,Tt=[0,0,0,0],Dt=new t([0,0,0,0]),Rt=ee(0,0,0,0);function Nt(e){if(null==e)return!1;const t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function Vt(e){return"geometryData"in e}function Ft(e){return null!=e&&b(e.data)}function Pt(e,t){let i=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(null!=t)for(const s of t)null!=s&&b(s.data)&&(i+=s.data.byteLength);return i}function Ht(e,t){return t.byteSize>Ct?(bt().warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}function Ut(e){if(0===e.length)return;const t=10*e.length,i=new Float64Array(t);let s=0;return e.forAll((e=>{let t=e.serviceObb;null==t&&(t=St,t.center=Z(e.mbs),t.halfSize=[e.mbs[3],e.mbs[3],e.mbs[3]]);const r=t.data;i[s++]=r[0],i[s++]=r[1],i[s++]=r[2],i[s++]=r[3],i[s++]=r[4],i[s++]=r[5],i[s++]=r[6],i[s++]=r[7],i[s++]=r[8],i[s++]=r[9]})),i}function Gt(e,t){e.forEach((e=>e.opacity=t))}var Lt;!function(e){e[e.Absolute=0]="Absolute",e[e.RelativeToGround=1]="RelativeToGround",e[e.OnTheGround=2]="OnTheGround"}(Lt||(Lt={}));class kt{constructor(e,t){this.mode=e,this.offset=t}}const Bt=V(),qt=q(),zt="elevation-change";function Kt(e){return t=>{if(e.immediate)return e.immediate.schedule(t);throw console.error("Error no immediate schudler"),new Error("cant find immediate scheduler")}}export{Lt as ElevationMode,Ot as I3SMeshView3D,Kt as makeScheduleFunction};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../Graphic.js";import{isSome as s,removeUnordered as r}from"../../../core/arrayUtils.js";import{ByteSizeUnit as o}from"../../../core/ByteSizeUnit.js";import a from"../../../core/Collection.js";import{makeHandle as n}from"../../../core/handleUtils.js";import has from"../../../core/has.js";import l from"../../../core/Logger.js";import{someMap as d}from"../../../core/MapUtils.js";import{destroyMaybe as h}from"../../../core/maybe.js";import c from"../../../core/PooledArray.js";import{isAbortError as u,throwIfAborted as _,createResolver as m}from"../../../core/promiseUtils.js";import{initial as g,watch as p}from"../../../core/reactiveUtils.js";import{schedule as f}from"../../../core/scheduling.js";import{isArrayBuffer as b}from"../../../core/typedArrayUtil.js";import{getMetersPerVerticalUnitForSR as y}from"../../../core/unitUtils.js";import{property as v}from"../../../core/accessorSupport/decorators/property.js";import{subclass as I}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as M}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as C}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as O,getTranslation as x}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as E,create as j}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as w}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{s as A,e as S,g as T,t as D,i as R,f as N}from"../../../chunks/vec32.js";import{create as V}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as F}from"../../../chunks/vec42.js";import{fromValues as P}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as H}from"../../../core/support/UpdatingHandles.js";import{localLinearScaleFactors as U}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as G}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as L}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as k}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as B}from"../../../geometry/projection/projectVectorToVector.js";import{create as q,empty as z,expandWithBuffer as K,toRect as W}from"../../../geometry/support/aaBoundingBox.js";import{create as $,intersects as Q}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as X}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as Y}from"../../../geometry/support/FloatArray.js";import{compactIndices as J}from"../../../geometry/support/Indices.js";import{g as Z,f as ee}from"../../../chunks/sphere.js";import{newUByteArray as te}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as ie}from"../../../layers/LayerConstants.js";import se from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as re}from"../../../layers/support/fieldUtils.js";import oe from"../../../layers/support/SceneModification.js";import{getColor as ae,getOpacity as ne}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{loadArcade as le}from"../../../support/arcadeOnDemand.js";import{isBasemapLayer as de}from"../../../support/basemapUtils.js";import he from"../../../symbols/Symbol3D.js";import{getMetersPerUnit as ce}from"../../../symbols/support/unitConversionUtils.js";import ue from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as _e}from"./I3SMeshViewPerformanceInfo.js";import{I3SMeshWorkerHandle as me,toWasmModification as ge}from"./I3SMeshWorkerHandle.js";import{ForAllFeaturesReturnType as pe,ForAllFeaturesMode as fe}from"./II3SMeshView3D.js";import{initialize as be,setModificationsSync as ye,filterObbsForModificationsSync as ve,interpretObbModificationResults as Ie}from"./SceneLayerWorker.js";import{overrideColor as Me}from"./graphics/graphicUtils.js";import{areLabelsVisible as Ce}from"./graphics/Labeler.js";import{TextureUsage as Oe,TextureEncoding as xe}from"./i3s/enums.js";import Ee from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as je}from"./i3s/I3SAsyncElevationUpdater.js";import{I3SCrossfadeHelper as we,NodeCrossfadeMetaData as Ae}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as Se}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Te}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as De,selectEncoding as Re,defaultMaterial as Ne,createTexture as Ve,configureMaterial as Fe}from"./i3s/I3SMaterialUtil.js";import{NodeIMModificationImpact as Pe,NodeState as He}from"./i3s/I3SNode.js";import{I3SOverrides as Ue}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as Ge,getLocalOrigin as Le}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as ke,checkSceneLayerValid as Be,checkSceneLayerCompatibleWithView as qe,getCacheKeySuffix as ze,whenGraphicAttributes as Ke,computeVisibilityObb as We,filterInPlace as $e,getCachedAttributeValue as Qe,intersectBoundingRectWithMbs as Xe,MbsIntersectResult as Ye,addWraparound as Je,getSymbolInfo as Ze,transparentEdgeMaterial as et,getClipRect as tt}from"./i3s/I3SUtil.js";import{IDBCache as it}from"./i3s/IDBCache.js";import{IDBMockCache as st}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as rt}from"./i3s/LayerElevationProvider.js";import{attributeLookup as ot}from"./support/attributeUtils.js";import{ColorMixModeEnum as at}from"./support/symbolColorUtils.js";import{debugFlags as nt}from"../support/debugFlags.js";import{ElevationRange as lt}from"../support/ElevationRange.js";import{toBoundingRect as dt}from"../support/extentUtils.js";import{Obb as ht}from"../support/orientedBoundingBox.js";import{updatingProgress as ct}from"../support/updatingProperties.js";import{glLayout as ut}from"../support/buffer/glUtil.js";import{createVertexBufferLayout as _t}from"../webgl-engine/collections/Component/SourceGeometry.js";import{TextureCoordinateAttributeType as mt}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{loadBasis as gt}from"../webgl-engine/lib/BasisUtil.js";import{Transparency as pt}from"../webgl-engine/lib/edgeRendering/interfaces.js";const ft="esri.views.3d.layers.I3SMeshView3D",bt=()=>l.getLogger(ft),yt=[1,1,1,1];class vt extends Ae{constructor(e,t,i,s,r,o,a,n,l){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=a,this.anchorIds=n,this.anchors=l,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0}}var It;!function(e){e[e.CastShadows=4]="CastShadows",e[e.Pickable=5]="Pickable"}(It||(It={}));const Mt=23,Ct=100*o.MEGABYTES,Ot=t=>{let o=class extends t{constructor(...e){super(e),this._needsNormals=!0,this._updatingHandles=new H,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._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=new Array,this.ignoresMemoryFactor=!1,this._layerUrl="",this._cacheKeySuffix=null,this._elevationTask=null,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i(null,null,{}),this._crossfadeHelper=new we(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerUid(){return this.i3slayer&&this.i3slayer.uid}get sublayerUid(){return null}get layerId(){return this.i3slayer&&this.i3slayer.id}get sublayerId(){return null}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?"yes":"probably-not":"unknown"}get rendererTextureUsage(){return ke(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?Oe.AllTexturesPBR:Oe.AllTextures:this._usePBR||this._hasLoadedPBRTextures?Oe.GeometryTexturesPBR:Oe.GeometryTextures}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null!=e&&"absolute-height"===e.mode){const t=y(this.i3slayer.spatialReference),i=ce(e.unit);return(e.offset??0)*i/t}return 0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return new kt(Lt.Absolute,0);const t=y(this.i3slayer.spatialReference),i=ce(e.unit),s=(e.offset??0)*i/t;switch(e.mode){case"absolute-height":return new kt(Lt.Absolute,s);case"relative-to-ground":return new kt(Lt.RelativeToGround,s);case"on-the-ground":return new kt(Lt.OnTheGround,0);default:return new kt(Lt.Absolute,0)}}get supportedTextureEncodings(){return De(this.view._stage.renderView.capabilities)}get uncompressedTextureDownsamplingEnabled(){const e=this.view?.qualitySettings.sceneService.uncompressedTextureDownsamplingEnabled,t=0==(this.supportedTextureEncodings&xe.DDS_S3TC);return e&&t}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){const e=this._nodeId2Meta,t=new lt;for(const i of e.values()){if(null==i)continue;const{node:{mbs:e}}=i,[,s,r]=e;t.union(s-r,s+r)}return t.valid?t:null}get fullExtent(){return this.i3slayer.fullExtent}initialize(){const e=has("enable-feature:idb-mock-cache");this._idbCache=e?new st(this.view,e):new it("esri-scenelayer-cache","geometries"),this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const t=this.view.resourceController,i=t.memoryController;this.i3sOverrides=new Ue({view:this.view,layer:this.i3slayer,memoryController:i}),this._worker=new me(Kt(t)),this.addResolvingPromise(this._worker.promise);const s=this.i3slayer.store;this._worker.setLegacySchema(this.uid,s.defaultGeometrySchema),Be(this.i3slayer),qe(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new se({layerView:this,worker:this._worker}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view._stage,this._collection=this._stage.renderView.componentObjectCollection,this.resetHighlights();const r=s.defaultGeometrySchema;if(this._isIntegratedMesh||!r)this._hasComponentData=!1;else{const e=r.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(r?.vertexAttributes.color??null)&&!this.i3slayer.cachedDrawingInfo?.color,this._isIntegratedMesh||(this._edgeView=this._stage.renderer.ensureEdgeView());const o=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,(e=>this._deleteComponentObject(e)));this._memCache=o;const a=e=>null!=this._controller.index?.rootNode?this._controller.index.traverse(this._controller.index.rootNode,(t=>{const i=t.index,s=this._nodeId2Meta.get(i)||this._nodeId2MetaReloading.get(i);return e(t,null!=s?s.objectHandle:null)})):()=>{};this._intersectionHandler=new Te({layerUid:this.layerUid,sublayerUid:this.sublayerUid,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:a}),this._updatingHandles.add((()=>this.layerUid),(e=>this._intersectionHandler.layerUid=e)),this._updatingHandles.add((()=>this.sublayerUid),(e=>this._intersectionHandler.sublayerUid=e)),this._elevationProvider=new rt({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add((()=>this.view.clippingArea),(()=>this._clippingAreaChanged()),g),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)),g),this._updatingHandles.add((()=>!this.suspended&&this.elevationInfo.mode!==Lt.Absolute),((e,t)=>{e?this.addHandles(this.view.basemapTerrain.on("elevation-change",(({extent:e})=>this._ensureElevationTask().addExtent(e))),zt):t&&this.removeHandles(zt)}),g),this._updatingHandles.add((()=>this._usePBR),(e=>this._updatePBR(e)));const n=()=>{this._reloadAll(),this.clearMemCache()};this._updatingHandles.add((()=>this.rendererTextureUsage),n),this._updatingHandles.add((()=>this.uncompressedTextureDownsamplingEnabled),n),this._updatingHandles.add((()=>this.contentVisible),(e=>this._contentVisibleChanged(e)),g),this._updatingHandles.add((()=>this.i3slayer.labelsVisible),(()=>this._labelingChanged()),g),this._updatingHandles.add((()=>this.i3slayer.labelingInfo),(()=>this._labelingChanged()),g),this._updatingHandles.add((()=>this._modifications),(()=>this._modificationsChanged()),g),this.addHandles([p((()=>nt.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&&nt.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||nt.I3S_TREE_SHOW_TILES||(this._treeDebugger=h(this._treeDebugger))}),g),p((()=>nt.I3S_SHOW_MODIFICATIONS),(()=>this._showModifications()),g)]),this._cacheKeySuffix=ze(this.i3slayer.spatialReference,this.view.renderSpatialReference),this._idbCache.init().catch((e=>bt().warn(`Failed to initialize IndexedDB cache: ${e}`)))}destroy(){this._clearAddTasks(),this._elevationTask=h(this._elevationTask),this.i3sOverrides=h(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.objectsChanged(this.getVisibleObbs()),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._worker;e&&(e.destroyContext(this.uid).then((()=>e.destroy())),this._worker=null),this._removeAllNodeDataFromStage(),this._memCache=h(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=h(this._labeler),this._treeDebugger=h(this._treeDebugger),this._controller=h(this._controller),this._highlights.destroy(),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=h(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null),this._updatingHandles=h(this._updatingHandles)}_memEstimateTextureAdded(e){const t=e.memoryEstimate;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(null!=e){const t=e.memoryEstimate;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){const t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){const t=this._collection.getObjectGPUMemoryUsage(e);this._gpuMemoryEstimate-=t,this._geoMemoryEstimate-=t}isNodeLoaded(e){return this._nodeId2Meta.has(e)}isNodeReloading(e){return this._nodeId2MetaReloading.has(e)}get usedMemory(){let e=null!=this._labeler?this._labeler.usedMemory:0;return this._nodeId2Meta.forEach((t=>e+=null!=t?t.node.memory:0)),this._nodeId2MetaReloading.forEach((t=>e+=null!=t?t.node.memory:0)),e}get unloadedMemory(){return(null!=this._controller?this._controller.unloadedMemoryEstimate:0)+(null!=this._labeler?this._labeler.unloadedMemoryEstimate:0)}_labelingChanged(){if(!(Ce(this.i3slayer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new ue({view:this.view,layer:this.i3slayer,collection:this._collection,overrides:this.i3sOverrides});this._nodeId2Meta.forEach((t=>null!=t&&this._addMetaToLabeler(e,t))),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then((e=>(--this._asyncModuleLoading,e)),(e=>{throw--this._asyncModuleLoading,e}))}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=be().then((()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()})),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=this.uid,t=this.i3slayer.spatialReference;this._worker.setModifications(e,this._layerClippingArea,this._modifications,t);const i=ge(this._layerClippingArea,this._modifications,t);ye({context:e,modifications:i,isGeodetic:t.isGeographic}),this._controller.modificationsChanged();const s=this.hasModifications?new c:null;this._nodeId2Meta.forEach(((e,t)=>{null==e?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):null!=s&&s.push(e.node)})),this.notifyChange("elevationRange"),null!=s&&this._nodeId2MetaReloading.forEach((e=>s.push(e.node))),null!=s&&s.length>0&&(this.updateNodeModificationStatus(s),s.forAll((e=>{if(e.imModificationImpact!==Pe.Culled){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),null!=t?(this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t),this.notifyChange("elevationRange")):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}}))),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(null!=this._modificationGraphics&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!nt.I3S_SHOW_MODIFICATIONS||0===this._modifications.length)return;const e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={type:"simple-fill",outline:{color:[255,255,255],width:1}};this._modificationGraphics=new Array;for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.i3slayer.spatialReference;const o={...t,color:e[s.type]};this._modificationGraphics.push(new i({geometry:r,symbol:o}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,((e,t)=>this._createAttributes(e,t)))}_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){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);null!=i?.attributeInfo&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);null!=s&&(await this.i3sOverrides.applyAttributeOverrides(s.featureIds,t,i,this._controller.requiredAttributes),s.attributeInfo=t,this._controller.reschedule((()=>this._attributeValuesChanged(s)),i).catch((e=>{u(e)||bt().warn("Error while updating attribute values. Layer might not display correctly.",e)})))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.filteredIds=null,null!=this._labeler&&this._labeler.setNodeMetaAttributes(e,((e,t)=>this._createAttributes(e,t))),this._updateEngineObject(e)}clearMemCache(){null!=this._memCache&&this._memCache.clear()}getVisibleNodes(){const e=new Array;return this._nodeId2Meta.forEach((t=>null!=t&&e.push(t.node))),e}getVisibleObbs(){const e=new Array;return this._nodeId2Meta.forEach((t=>{if(null!=t){const i=this.getNodeComponentObb(t.node);null!=i&&e.push(i)}})),e}getNodeComponentObb(e){const t=this._nodeId2Meta.get(e.index)??this._nodeId2MetaReloading.get(e.index);return null!=t?this._collection.getComponentObb(t.objectHandle):null}getLoadedNodeIndices(e){this._nodeId2Meta.forEach(((t,i)=>e.push(i))),this._nodeId2MetaReloading.forEach(((t,i)=>e.push(i)))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&0!=(this.supportedTextureEncodings&xe.Basis)&&this.i3slayer.textureSetDefinitions?.some((e=>e.formats.some((e=>"basis"===e.format||"ktx2"===e.format))))&>()}_getVertexBufferLayout(e,t){const i={hasTexture:Nt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion};return ut(_t(this._getGeometryParameters(i)))}_getObjectIdField(){return this.i3slayer.objectIdField||ie}_getGlobalIdField(){return this.i3slayer.associatedLayer?.globalIdField}_findGraphicNodeAndIndex(e){const t=ot(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());let i=null;return d(this._nodeId2Meta,(e=>{if(null==e)return!1;const s=e.featureIds.indexOf(t);return-1!==s&&(i={node:e.node,index:s},!0)})),i}_getGraphicIndices(e,t){const i=this._nodeId2Meta.get(e.index);if(null==i)return[];const s=[],r=this._getObjectIdField(),o=this.i3slayer.fieldsIndex;for(const a of t){const e=ot(o,a.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this._getAABB(t.node.index,t.index);return null==i?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this._getAABB(e.nodeIndex,e.componentIndex)}_getAABB(e,t){const i=this._nodeId2Meta.get(e);if(null==i?.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=Se(t,this._collection,s,X(24),0),o=this.view.renderSpatialReference,a=this.view.spatialReference;if(!L(r,o,0,r,a,0,8))return null;const n=z();return K(n,r,0,8),n}whenGraphicAttributes(e,t){return Ke(this.i3slayer,e,this._getObjectIdField(),t,(()=>[...this._nodeId2Meta.values()].filter(s)))}getGraphicFromIntersectorTarget(e){if(null==e.nodeIndex||null==e.componentIndex)return null;const t=this._nodeId2Meta.get(e.nodeIndex);return null==t?.featureIds||e.componentIndex>=t.featureIds.length?null:this._createGraphic(e.componentIndex,t)}_getCacheKey(e){return`${this._layerUrl}/v${Mt}/${e}${this._cacheKeySuffix}`}_getMemCacheKey(e,t=this.elevationOffset){return e+"#"+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&0===this.elevationOffset&&null!=this._cacheKeySuffix}loadCachedGPUData(e){return null!=this._memCache?this._memCache.pop(this._getMemCacheKey(e)):null}deleteCachedGPUData(e){null!=e&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(null==this._memCache)return void this._deleteComponentObject(e);const i=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,e.node.memory,i)}loadMissingTextures(e,t,i,s){const r=e?.filter(((e,i)=>{if(0==(e.usage&this.rendererTextureUsage))return!1;if(null==t)return!0;const s=Re(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(null==r?.data||s&&r.encoding!==s.encoding)}))??[];return 0===r.length?Promise.resolve(!1):i(r,s).then((i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0}))}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then((s=>null==s?null:s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(this.elevationInfo.mode===Lt.Absolute&&(e.geometryObb=ht.fromData(s.geometryObbData)),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then((i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=Pt(s.transformedGeometry,s.textureData),s.textureData.every(Ft)&&Ht(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch((t=>bt().warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`)))),_(t),s)))))):Promise.resolve(null)}addNode(e,t,i){return Vt(t)?null==t.geometryBuffer?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,(()=>this._transformNode(e,t,i).then((s=>this._safeReschedule((()=>{if(null==s)return e.hasModifications=!1,this._addCachedNodeData(e,null,i);e.hasModifications=s.transformedGeometry.hasModifications;const{obb:r,componentOffsets:o,featureIds:a,anchorIds:n,anchors:l,transformedGeometry:d}=s,h=this._controller.crsIndex,c=this.view.renderSpatialReference,u=Ge(e.mbs,this.elevationOffset,h,c),_=A(Bt,r.center.x,r.center.y,r.center.z);S(_,_,u);const m=new ht(_,[r.extents.x,r.extents.y,r.extents.z],w(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));this.elevationInfo.mode===Lt.Absolute&&(e.geometryObb=m),t.geometryData.componentOffsets=o,a&&(t.geometryData.featureIds=Array.from(a)),t.geometryData.anchorIds=n,t.geometryData.anchors=l;const g={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:d,globalTrafo:u,geometryObbData:m.data,byteSize:Pt(d,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&Ht(e,g)){const t=null!=g.textureData?g.textureData.map((e=>Ft(e)?e:null)):null;this._idbCache.put(this._getCacheKey(e.id),{...g,textureData:t}).catch((t=>bt().warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`)))}return this._addCachedNodeData(e,g,i)}),i))))):Promise.reject()}getElevationRange(e){const t=new lt,{view:i}=this,{renderCoordsHelper:s}=i,r=s.referenceEllipsoid.radius,o=this._collection,a=this._controller,{index:n}=a;if(!n)return t;const{rootNode:l}=n;if(!l)return t;const d="local"===i.viewingMode,h=this._nodeId2Meta,c=i=>{const{visibilityObb:a,childrenLoaded:n}=i;if(0===n)return!1;if(a&&!a.intersectSphere(e))return!1;const l=h.get(i.index);if(l){const{geometryObb:a}=i;if(a?.intersectSphere(e)){const{objectHandle:e,featureIds:i}=l,a=o.getObjectTransform(e),n=s.getAltitude(a.position),h=i.length;for(let s=0;s<h;s++){const i=o.getComponentAabb(e,s,qt);if(d)t.union(n+i[2],n+i[5]);else{const e=Math.max(Math.abs(i[3]),Math.abs(i[0])),s=Math.max(Math.abs(i[4]),Math.abs(i[1])),o=n+i[5]+r;t.union(n+i[2],Math.sqrt(e*e+s*s+o*o)-r)}}}}return i.childCount>0};return n.traverse(l,c),t}computeVisibilityObb(e){return We(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications,this.view.renderCoordsHelper.sphericalPCPF)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let f=0;f<s.length;++f)r[f]=this._getVertexBufferLayout(s[f],t.geometryDescriptor);const o=e.mbs,a=this.elevationOffset,n=this._controller.crsIndex,l=this._controller.crsVertex,d=this.view.renderSpatialReference,h=Le(o,a,n),c=Ge(o,a,n,d),u=k(n,l),_=k(l,d);if(null==u||null==_)return Promise.resolve(null);const m=this.i3slayer.normalReferenceFrame,g=t.normalReferenceFrame??m??"none",p={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,localOrigin:h,globalTrafo:c,mbs:o,obbData:e.serviceObb?.data,elevationOffset:a,needNormals:this._needsNormals&&this._controller.isMeshPyramid,normalReferenceFrame:g,indexToVertexProjector:u,vertexToRenderProjector:_};return this._worker.invoke(p,i)}get _supportsNodeCrossFading(){return!this.view?._stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){const t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,i){if(this.elevationInfo.mode===Lt.Absolute&&(e.geometryObb=this._collection.getComponentObb(t.objectHandle).clone()),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);null!=this._labeler&&this._addMetaToLabeler(this._labeler,t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,!0),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==Lt.Absolute&&this._ensureElevationTask().schedule(s),this._updateEngineObject(t),this._highlights.objectCreated(t),null!=this._treeDebugger&&this._treeDebugger.update()}addCachedNodeData(e,t,i,s){return this._addData(e,i,(()=>this._addCachedNodeData(e,t,s)))}async deleteCachedNodeData(e){if(this._idbCacheEnabled)return this._idbCache.remove(this._getCacheKey(e))}async _addCachedNodeData(e,t,i){if(!this.contentVisible||!this._controller.isGeometryVisible(e))return void this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);if(null==t)return void this._addNodeMeta(e.index,null);const s=this._addTasks.get(e.index),{geometryData:r,transformedGeometry:o,globalTrafo:a}=t;await this.i3sOverrides.applyAttributeOverrides(r.featureIds,s.attributeInfo,i,this._controller.requiredAttributes);const n=null!=t.textureData?t.textureData.filter((e=>null!=e&&0!=(e.usage&this.rendererTextureUsage))):[];!has("disable-feature:i3s-basis")&&n.some((e=>null!=e&&(e.encoding===xe.Basis||e.encoding===xe.KTX2)))&&await gt(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:h,anchorIds:c,anchors:u}=r,_=this._collection,m=d[0],{layout:g,indices:p,interleavedVertexData:f,positionData:b,hasColors:y}=o,{material:v,geometryParameters:I}=this._materialParameters(m,g),w=l||new Uint32Array([0,p?p.length:f.byteLength/g[0].stride]),A={vertices:{data:f,count:f.byteLength/g[0].stride,layoutParameters:I},positionData:{positions:Y(b.data),indices:J(b.indices)},indices:p,componentOffsets:w},S=m.transformation?E(m.transformation):j();O(S,a,S);const T=x(V(),S),D=M(C(),S),R=this.view.renderSpatialReference,N=this.view.basemapTerrain.spatialReference,F=V(),H=[1,1,1];U(T,R,H,N)||bt().errorOnce("Unsupported coordinate system for IM overlay"),B(T,R,F,N);const G=_.createObject({toMapSpace:P(F[0],F[1],H[0],H[1]),geometry:A,obb:ht.fromData(t.geometryObbData),transform:{position:T,rotationScale:D}}),L=I.textureCoordinates===mt.Atlas,{textures:k,texturePromise:q}=this._initMaterialAndTextures(G,v,n,L);e.memory+=this._memEstimateGeometryAdded(G),e.memory+=k.reduce(((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0)),0);const z=!!v.hasParametersFromSource,K="blend"!==v.alphaMode&&v.metallicRoughness.baseColorFactor[3]>=1,W=new vt(e,h,G,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:z,isOpaque:K},k,c,u);s.meta=W,!this._hasTextures&&t.requiredTextures?.some((({usage:e})=>0!=(e&Oe.ColorTextures)))&&(this._hasTextures=!0),this._hasData=!0,this._hasColors=this._hasColors||y,this._hasTextures=this._hasTextures||!!e.resources.texture,this.notifyChange("hasTexturesOrVertexColors");const $=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(W),q]).then((([t,s])=>(null!=t&&t.updateObjectVisibility(W.objectHandle,!1).catch((e=>xt(e,this.i3slayer.title))),this._safeReschedule((()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,W),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(G,!0),null!=t&&t.updateObjectVisibility(W.objectHandle,!0).catch((e=>xt(e,this.i3slayer.title))),W.attributeInfo=i.attributeInfo;const s=W.cachedRendererVersion!==this._rendererVersion,r=$!==this.slicePlaneEnabled;this._updateElevationOffsets(W);const o=W.elevationOffsets;this._updateComponentData(W);const a=this._applyFiltersToNode(W);(s||null!=t&&(r||a||o))&&this._addOrUpdateEdgeRendering(W),null!=this._labeler&&this._addMetaToLabeler(this._labeler,W),this._visibleGeometryChanged(W,Et.ADD),this._highlights.objectCreated(W),this._updateMaterial(W),this._setNewNodeOpacity(W),null!=this._treeDebugger&&this._treeDebugger.update()}),i)))).catch((e=>{throw null!=s.meta&&(this._cacheGPUData(s.meta),s.meta=null),e}))}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){bt().error("Removing duplicated node");const t=this._nodeId2Meta.get(e);null!=t&&this._deleteComponentObject(t)}else this._controller.updateLoadStatus(e,!0);null!=t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&Gt(t.cachedEdgeMaterials,0)),this._nodeId2Meta.set(e,t),this.notifyChange("elevationRange")}_updateElevationOffsets(e){const t=this.view.renderSpatialReference,i=this._controller.crsIndex,s=this.elevationInfo,r=this.view.basemapTerrain,o=r.spatialReference,a=s.mode;if(null==t||null==o||a===Lt.Absolute)return void(e.elevationOffsets=null);const n=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const l=Bt,d=qt,h=a===Lt.OnTheGround,c=this.view.renderCoordsHelper,u=e.featureIds.length,_=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const s=X(3*u);e.cachedElevationAnchors=s;for(let r=0;r<u;r++){const a=3*r,h=e.anchorIds?.indexOf(r)??-1;e.anchors&&h>=0?(A(l,e.anchors[3*h],e.anchors[3*h+1],e.anchors[3*h+2]),T(l,l,Z(e.node.mbs)),B(l,i,l,o),s[a]=l[0],s[a+1]=l[1],s[a+2]=c.getAltitude(l)):(this._collection.getComponentAabb(e.objectHandle,r,d,!0),A(l,(d[0]+d[3])/2,(d[1]+d[4])/2,d[2]),D(l,l,n.rotationScale),T(l,l,n.position),s[a+2]=c.getAltitude(l),B(l,t,l,o),s[a]=l[0],s[a+1]=l[1])}return s})(),m=s.offset,g=e.elevationOffsets,p=(e,t)=>{const i=h?_[3*e+2]:0;g[e]=m+(null!=t?t-i:0)};r.getElevations(_,u,p)}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new je(this.view.resourceController.scheduler,(e=>{const t=this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference);return null!=t?t.filterInPlace((e=>null!=this._nodeId2Meta.get(e))):null}),(e=>{const t=this._nodeId2Meta.get(e);this._nodeElevationAlignmentChanged(t)}))),this._elevationTask}_elevationInfoChanged(e,t){const i=e.mode!==Lt.Absolute,s=!!t&&t!==e&&t.mode!==Lt.Absolute;this._intersectionHandler.updateElevationAlignState(i,this.view.state.viewingMode),i&&!s&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach((e=>this._nodeElevationAlignmentChanged(e)))}_nodeElevationAlignmentChanged(e){null!=e&&(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),null!=this._labeler&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,Et.UPDATE))}_safeReschedule(e,t){return _(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:Ne(),s=t.some((e=>"uvRegion"===e.name)),r=t.some((e=>"normalCompressed"===e.name)),o=Nt(i);return{geometryParameters:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s){const r=this._stage.renderView,o=i.map((e=>Ve(e,t,s,r)));this._stage.addMany(o);let a=null;return this._collection.updateMaterial(e,(e=>{a=Fe(e,t,o,i,this.view._stage.renderView.textureRepository,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference}),this._updateMaterialOverlay(e)})),{textures:o,texturePromise:a}}_getGeometryParameters(e){return{textureCoordinates:e.hasTexture?e.hasRegions?mt.Atlas:mt.Default:mt.None,colors:this._hasVertexColors,hasNormals:e.hasNormals&&this._needsNormals,needsNormals:this._needsNormals}}_addData(e,t,i){let s=this._addTasks.get(e.index);return s?s.attributeInfo=t:(s={...m(),attributeInfo:t,meta:null},this._addTasks.set(e.index,s),i().then(s.resolve,s.reject).then((()=>this._addTasks.delete(e.index))).catch((t=>{throw this._addTasks.delete(e.index),t}))),s.promise}_clearAddTasks(){this._addTasks.forEach((e=>{null!=e.meta&&(this._cacheGPUData(e.meta),e.meta=null)})),this._addTasks.clear()}_clippingAreaChanged(){const e=this.view.renderSpatialReference,t=this.i3slayer.spatialReference,i=$();this._renderClippingArea=dt(this.view.clippingArea,i,e)?i:null;const s=$();this._layerClippingArea=dt(this.view.clippingArea,s,t)?s:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){const e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e)}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach((e=>{null!=e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Et.UPDATE))}))}getFilters(){const e=[],t=this._renderClippingArea;return null!=t&&e.push(((e,i)=>this._boundingRectFilter(e,i,t))),e}addSqlFilter(e,t,i){if(null!=t){const s=t.fieldNames;e.push(((e,r)=>this._sqlFilter(e,r,t,s,i)))}}_sqlFilter(e,t,i,s,r){const o={},a=this._createLayerGraphic(o),n=this.i3slayer.objectIdField,l=t.featureIds,d=t.attributeInfo?.attributeData;s.every((e=>e===n||null!=d?.[e]))&&$e(e,l,(e=>{o[n]=l[e];for(const i of s)i!==n&&(o[i]=d?Qe(d[i],e):null);try{return i.testFeature(a)}catch(t){return r(t),!1}}))}_boundingRectNodeTest(e,t){return G(e.node.mbs,this._controller.crsIndex,Rt,this.view.renderSpatialReference),Xe(t,Rt)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,jt),W(jt,wt),Q(i,wt)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(r===Ye.INSIDE)return;if(r===Ye.OUTSIDE)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const a=this._transformClippingArea(At,i,t.objectHandle);$e(e,t.featureIds,(e=>this._boundingRectFeatureTest(t,e,a)))}_transformClippingArea(e,t,i){const s=this._collection.getObjectTransform(i),r=s.position,o=s.rotationScale;return e[0]=(t[0]-r[0])/o[0],e[1]=(t[1]-r[1])/o[4],e[2]=(t[2]-r[0])/o[0],e[3]=(t[3]-r[1])/o[4],e}_addOrUpdateEdgeRendering(e,t=!0){const i=this._edgeView;if(null==i)return Promise.resolve(null);const s=e.objectHandle,r=i.hasObject(s),{hasEdges:o,perFeatureEdgeMaterials:a}=this._getFilteredEdgeMaterials(e),n={hasSlicePlane:this.slicePlaneEnabled};if(o&&r){if(this.nodeCrossfadingEnabled){Gt(a,this.getNodeOpacity(e))}return i.updateAllComponentMaterials(s,a,n,t).catch((e=>xt(e,this.i3slayer.title))),i.updateObjectVisibility(s,!0).catch((e=>xt(e,this.i3slayer.title))),i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>xt(e,this.i3slayer.title))),Promise.resolve(i)}return o&&!r?this._collection.addEdges(s,i,a,n).then((t=>(e.edgeMemoryUsage=t,e.node.memory+=t,i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>xt(e,this.i3slayer.title))),i))):(!o&&r&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,i.removeObject(s)),Promise.resolve(null))}_applyFiltersToNode(e){return!!this._applyFiltersToNodeComponents(e)&&(null!=this._labeler&&this._labeler.applyFilterChange(e),!0)}_applyFiltersToNodeComponents(e){const t=this._collection,i=t.getComponentCount(e.objectHandle),s=null!=e.filteredIds,r=0===i.invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!r;if(this._updateCachedFilteredIds(e),s&&e.filteredIds===e.featureIds)return!r;const o=this._computeFilteredComponentIndices(e);return t.setAllComponentVisibilities(e.objectHandle,o),!0}_updateCachedFilteredIds(e){null!=e.filteredIds&&e.appliedFilters===this._filters||(e.filteredIds=this._computeFilteredIds(e),e.appliedFilters=this._filters)}_computeFilteredIds(e){const t=e.featureIds.slice();for(const i of this._filters)if(i(t,e),0===t.length)break;return t.length===e.featureIds.length?e.featureIds:t}_computeFilteredComponentIndices(e){const t=new Array,i=e.filteredIds;return null!=i&&e.featureIds.forEach(((e,s)=>{i[t.length]===e&&t.push(s)})),t}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach(((t,i)=>this._removeNodeStageData(i,e))),this._nodeId2MetaReloading.forEach(((t,i)=>this._removeNodeStageData(i,e,this._nodeId2MetaReloading))),this._elevationTask=h(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),null!=this._elevationTask&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);null!=s?(this._collection.setObjectVisibility(s.objectHandle,!1),null!=this._edgeView&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch((e=>xt(e,this.i3slayer.title))),this._visibleGeometryChanged(s,Et.REMOVE),null!=this._labeler&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights.objectDeleted(s),i===this._nodeId2Meta?(this._cacheGPUData(s,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(s)):this._deleteComponentObject(s),null!=this._treeDebugger&&this._treeDebugger.update()):i.delete(e)}_deleteComponentObject(e){if(null!=this._edgeView&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(const t of e.textures)this._memEstimateTextureRemoved(t),this._stage.remove(t)}updateNodeState(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._collection.updateMaterial(i.objectHandle,(e=>e.polygonOffsetEnabled=t===He.Hole))}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){const i=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,i),this.notifyChange("elevationRange")}const i=this._nodeId2MetaReloading.get(e);i&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,i))}_invalidateAllSymbols(){this._rendererVersion=Je(this._rendererVersion,1),this._controller&&this._controller.requestUpdate()}_getInvalidRendererVersion(){return Je(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=Je(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.i3slayer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&"arcadeRequired"in e&&e.arcadeRequired&&(this._arcade=await le()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:bt().warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.getSymbols())"mesh-3d"!==t.type&&bt().error(`Symbols of type '${t.type}' are not supported for 3D Object Scene Services.`);this._controller&&this._controller.requestUpdate()}_getCachedEdgeMaterials(e){return this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e),e.cachedEdgeMaterials}_getComponentParameters(e){this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e);const t=e.cachedSymbology;return(i,s)=>{const r=5*i;if(F(s.externalColor,t[r]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255),null!=this._stage.renderView.objectAndLayerIdRenderHelper){const t=e.featureIds[i],r=de(this.view.map,this.layerUid);this._stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(t,t,this.layerId,this.layerUid+"_"+this.sublayerId,this.layerPopupEnabledAndHasTemplate&&!r,e.node.resources.attributes,i,this.sublayerId),s.objectAndLayerIdColor=this._stage.renderView.getObjectAndLayerIdColor({graphicUid:t,layerUid:this.layerUid+"_"+this.sublayerId})}s.externalColorMixMode=t[r+4]&(1<<It.CastShadows)-1,s.castShadows=0!=(t[r+4]&1<<It.CastShadows),s.pickable=0!=(t[r+4]&1<<It.Pickable),s.elevationOffset=e.elevationOffsets?.[i]??0}}_getSymbolInfo(e,t){const i=e?.getSymbol(t,{arcade:this._arcade});if(!(i instanceof he))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=Ze(i);return this._symbolInfos.set(s,r),r}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=null!=this._symbologyOverrideFields&&this._symbologyOverrideFields.length>0?null!=this._rendererFields&&this._rendererFields.length>0?re(this.i3slayer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;const t=this._tmpAttributeOnlyGraphic,i={};t.attributes=i;const s=this._currentRenderer,r=e.attributeInfo?.attributeData,o=null!=e.featureIds?this.i3slayer.objectIdField:null,a=null!=r&&null!=this._symbologyFields&&this._symbologyFields.length>0;let n=null,l=null;if(a&&null!=this._symbologyFields){n=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(n.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=te(5*e.featureIds.length));const d={color:Tt,castShadows:!0,pickable:!0,colorMixMode:at.Multiply,edgeMaterial:null},h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=pt.OPAQUE,m=et,g=0;for(let p=0;p<e.featureIds.length;p++){if(null!=o&&(i[o]=e.featureIds[p]),a&&n)for(let e=0;e<n.length;e++)i[n[e]]=Qe(l[e],p);const r=s?this._getSymbolInfo(s,t):null;let h=null,f=null;if(s&&"visualVariables"in s){if(this._colorVariable){const e=ae(this._colorVariable,t,{color:Dt,arcade:this._arcade});e&&(h=Tt,h[0]=e.r/255,h[1]=e.g/255,h[2]=e.b/255,this._opacityVariable||null===e.a||(f=e.a))}this._opacityVariable&&(f=ne(this._opacityVariable,t,{arcade:this._arcade}))}if(r?.material){const e=r.material;h=null==h||null==f?Me(h,f,e.color,e.alpha,yt,Tt):Me(h,f,null,null,yt,Tt)}if(null==h&&(h=Tt,h[0]=1,h[1]=1,h[2]=1,h[3]=1),d.pickable=!0,d.castShadows=!r||r.castShadows,d.colorMixMode=r?.material?r.material.colorMixMode:at.Multiply,d.edgeMaterial=r?r.edgeMaterial:null,null!=this._symbologyOverride&&(d.color=h,this._symbologyOverride(t,d),h=d.color),null!=this._nodeColorOverride&&(this._nodeColorOverride(e.node,h),d.colorMixMode=at.Replace),null!=d.edgeMaterial){const t=h[3]<=0?pt.INVISIBLE:h[3]>=1&&(e.material.isOpaque||d.colorMixMode===at.Replace)?pt.OPAQUE:pt.TRANSPARENT;d.edgeMaterial===u&&t===_||(m={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,_=t),e.cachedEdgeMaterials[p]=m}else e.cachedEdgeMaterials[p]=et;e.cachedSymbology[g++]=Math.round(255*h[0]),e.cachedSymbology[g++]=Math.round(255*h[1]),e.cachedSymbology[g++]=Math.round(255*h[2]),e.cachedSymbology[g++]=Math.round(255*h[3]),e.cachedSymbology[g++]=d.colorMixMode|+d.castShadows<<It.CastShadows|+d.pickable<<It.Pickable}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||Gt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some((e=>e!==et)),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map(((t,o)=>e.featureIds[o]!==i[s]?et:(r=r||t!==et,s++,t)));return{hasEdges:r,perFeatureEdgeMaterials:o}}_updateComponentData(e){if(!this._hasComponentData)return;const t=e.objectHandle,i=this._getComponentParameters(e);this._collection.setComponentData(t,i),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),null!=this._controller&&this._controller.restartNodeLoading()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach((t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,(t=>t.objectOpacity=e)),Gt(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))}))}_updateMaterial(e){this._collection.updateMaterial(e.objectHandle,(e=>{e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.usePBR=this._usePBR,this._updateMaterialOverlay(e)}))}_updateMaterialOverlay(e){}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Et.UPDATE)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),null!=this._labeler&&(this._labeler.slicePlaneEnabled=e),this._nodeId2Meta.forEach((t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,(t=>t.commonMaterialParameters.hasSlicePlane=e)),this._updateEdgeRendering(t,!1))}))}_updatePBR(e){this._nodeId2Meta.forEach((t=>{null!=t&&this._collection.updateMaterial(t.objectHandle,(t=>t.usePBR=e))})),this._hasLoadedPBRTextures=!0}get _usePBR(){return this._needsNormals&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){null!=this._edgeView&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?(t,i,s)=>s.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?pe.CONTINUE:e(t,i,s):e}_forAllFeatures(e,t,i){d(this._nodeId2Meta,(s=>{if(null==s)return!1;if(null!=t){switch(t(s)){case pe.EXIT:return!0;case pe.SKIP:return!1}}let r=pe.CONTINUE;switch(i){case fe.ALL:r=this._forAllFeaturesOfNode(s,e);break;case fe.VISIBLE_ONLY:r=this._forAllVisibleFeaturesOfNode(s,e);break;case fe.QUERYABLE:r=this._forAllQueryableFeaturesOfNode(s,e)}return r===pe.EXIT}))}_forAllFeaturesOfNode(e,t){let i=pe.CONTINUE;const s=e.featureIds;for(let r=0;r<s.length;r++)if(i=t(s[r],r,e),i===pe.EXIT)return i;return i}_forAllVisibleFeaturesOfNode(e,t){let i=pe.CONTINUE;const s=e.featureIds;return this._collection.forEachVisibleComponent(e.objectHandle,(r=>(i=t(s[r],r,e),i===pe.CONTINUE))),i}_forAllQueryableFeaturesOfNode(e,t){const i=this._ignoreClientNodeOverriddenFeatures(t);if(null==this._renderClippingArea)return this._forAllFeaturesOfNode(e,i);const s=this._boundingRectNodeTest(e,this._renderClippingArea);if(s===Ye.OUTSIDE)return pe.CONTINUE;if(s===Ye.INSIDE)return this._forAllFeaturesOfNode(e,i);const r=pe.CONTINUE,o=e.featureIds,a=e.objectHandle,n=tt(this._renderClippingArea,this._collection.getObjectTransform(a));for(let l=0;l<o.length;l++){if(!this._boundingRectFeatureTest(e,l,n))continue;const t=i(o[l],l,e);if(t===pe.EXIT)return t}return r}_createAttributes(e,t){const i={};null!=t.featureIds&&(i[this._getObjectIdField()]=t.featureIds[e]);const s=t.attributeInfo?.attributeData;if(null!=s)for(const r of Object.keys(s))i[r]=Qe(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e){if("number"==typeof e||e instanceof i?e=[e]:e instanceof a&&(e=e.toArray()),Array.isArray(e)&&e.length>0){if(e[0]instanceof i){const t=e,i=this.i3slayer.fieldsIndex,s=this._getObjectIdField(),r=t.map((e=>ot(i,e.attributes,s))),{set:o,handle:a}=this._highlights.acquireSet();return this._highlights.setFeatureIds(o,r),a}if("number"==typeof e[0]){const t=e,{set:i,handle:s}=this._highlights.acquireSet();return this._highlights.setFeatureIds(i,t),s}}return n()}resetHighlights(){h(this._highlights),this._highlights=new Ee({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,fe.ALL),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)})}_visibleGeometryChanged(e,t){if(!this._elevationProvider)return;const i=this.getNodeComponentObb(e.node);i&&this._elevationProvider.objectChanged(i),null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=f((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))),this._updateSnappingSources(e,t)}get performanceInfo(){return new _e(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(100*this._idbCache.getHitRate()):0)}get test(){const e=this,t=e=>{this._nodeColorOverride=e,this._invalidateAllSymbols()};return{controller:this._controller,labeler:this._labeler,get visibleObjectIds(){const t=[];return e._forAllFeatures((e=>(t.push(e),pe.CONTINUE)),null,fe.VISIBLE_ONLY),t.sort(((e,t)=>e-t)),t},get numNodes(){return e._nodeId2Meta.size},get loadedNodes(){return Array.from(e._nodeId2Meta.keys()).sort(((e,t)=>e-t))},setNodeColorOverride:t,setNodeColoring:e=>{if("client-nodes"===e)t(((e,t)=>{e.index<0?(t[0]=1,t[1]=0,t[2]=0):(t[0]=1,t[1]=1,t[2]=1)}));else t(null)}}}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return null!=e?this._collection.getMaterial(e.objectHandle).objectOpacity:0}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(((t,i)=>e(i,t)))}fadeNode(e,t,i){if(!this.nodeCrossfadingEnabled)return;const s=this._nodeId2Meta.get(e);null!=s&&this._crossfadeHelper.fadeNode(e,s,t,i)}setNodeOpacityByIndex(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._setNodeOpacity(i,t)}_setNodeOpacity(e,t){this._collection.updateMaterial(e.objectHandle,(e=>e.objectOpacity=t)),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(null==this._edgeView||!e.cachedEdgeMaterials)return;Gt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch((e=>xt(e,this.i3slayer.title)))}get hasModifications(){return this._isIntegratedMesh&&null!=this._layerClippingArea||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){const t=e.length;if(!this.hasModifications||t<=0||!0!==this._i3sWasmLoaded)return;const i=this.uid,s=Ut(e);if(s){const t={context:i,buffer:s.buffer};ve(t);const r=new Float64Array(s.buffer);e.forAll(((e,t)=>{const i=r[t],s=Ie(i);e.imModificationImpact=s,s!==Pe.Unmodified&&this._controller.invalidateGeometryVisibility(e.index)}))}}notifyUpdate(){this.notifyChange("updating")}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!(!this._controller||!this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||null!=this._labeler&&this._labeler.updating||this._crossfadeHelper?.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||null!=this._elevationTask&&this._elevationTask.running}trackSnappingSources(e){const t={events:e,fetchEdgeLocations:async(e,t,i)=>{const s=this._nodeId2Meta.get(e);if(null==s)throw new Error("invalid-node");const{origin:r,buffer:o}=await this._collection.extractEdgeInformation(s.objectHandle,t,i);return this._snappingLocationsApplyElevation(s,o,r),{type:"components",objectIds:s.featureIds,locations:o,origin:r}},remove:()=>r(this._snappingSourcesTrackers,t)};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach(((t,i)=>{if(null==t)return;const s=this._controller.getRenderMbs(t.node);s&&e.add(i,s)})),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||this.elevationInfo.mode===Lt.Absolute)return;const s=t.position0,r=t.position1,o=t.componentIndex,a=V(),n=V(),l=(e,t)=>{T(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,n),T(e,e,R(n,n,t)),N(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,a),l(a,t),s.setVec(d,a),r.getVec(d,a),l(a,t),r.setVec(d,a)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(null!=s)for(const r of this._snappingSourcesTrackers)t!==Et.REMOVE&&t!==Et.UPDATE||r.events.remove(i),t!==Et.ADD&&t!==Et.UPDATE||r.events.add(i,s)}};return e([v()],o.prototype,"_hasLoadedPBRTextures",void 0),e([v()],o.prototype,"_asyncModuleLoading",void 0),e([v()],o.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([v()],o.prototype,"view",void 0),e([v()],o.prototype,"i3slayer",void 0),e([v()],o.prototype,"_controller",void 0),e([v()],o.prototype,"_labeler",void 0),e([v()],o.prototype,"updating",void 0),e([v()],o.prototype,"suspended",void 0),e([v()],o.prototype,"contentVisible",null),e([v({readOnly:!0})],o.prototype,"legendEnabled",null),e([v()],o.prototype,"holeFilling",void 0),e([v(ct)],o.prototype,"updatingProgress",void 0),e([v()],o.prototype,"updatingProgressValue",null),e([v()],o.prototype,"hasTexturesOrVertexColors",null),e([v()],o.prototype,"rendererTextureUsage",null),e([v()],o.prototype,"elevationOffset",null),e([v()],o.prototype,"elevationInfo",null),e([v({type:Boolean})],o.prototype,"slicePlaneEnabled",void 0),e([v()],o.prototype,"supportedTextureEncodings",null),e([v()],o.prototype,"uncompressedTextureDownsamplingEnabled",null),e([v({type:[oe]})],o.prototype,"_modifications",void 0),e([v({readOnly:!0})],o.prototype,"clientGeometry",null),e([v()],o.prototype,"elevationRange",null),e([v()],o.prototype,"fullExtent",null),e([v()],o.prototype,"_elevationTask",void 0),e([v({readOnly:!0})],o.prototype,"_usePBR",null),o=e([I(ft)],o),o};function xt(e,t){u(e)||bt().warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}var Et;!function(e){e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE"}(Et||(Et={}));const jt=q(),wt=$(),At=$(),St=new ht,Tt=[0,0,0,0],Dt=new t([0,0,0,0]),Rt=ee(0,0,0,0);function Nt(e){if(null==e)return!1;const t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function Vt(e){return"geometryData"in e}function Ft(e){return null!=e&&b(e.data)}function Pt(e,t){let i=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(null!=t)for(const s of t)null!=s&&b(s.data)&&(i+=s.data.byteLength);return i}function Ht(e,t){return t.byteSize>Ct?(bt().warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}function Ut(e){if(0===e.length)return;const t=10*e.length,i=new Float64Array(t);let s=0;return e.forAll((e=>{let t=e.serviceObb;null==t&&(t=St,t.center=Z(e.mbs),t.halfSize=[e.mbs[3],e.mbs[3],e.mbs[3]]);const r=t.data;i[s++]=r[0],i[s++]=r[1],i[s++]=r[2],i[s++]=r[3],i[s++]=r[4],i[s++]=r[5],i[s++]=r[6],i[s++]=r[7],i[s++]=r[8],i[s++]=r[9]})),i}function Gt(e,t){e.forEach((e=>e.opacity=t))}var Lt;!function(e){e[e.Absolute=0]="Absolute",e[e.RelativeToGround=1]="RelativeToGround",e[e.OnTheGround=2]="OnTheGround"}(Lt||(Lt={}));class kt{constructor(e,t){this.mode=e,this.offset=t}}const Bt=V(),qt=q(),zt="elevation-change";function Kt(e){return t=>{if(e.immediate)return e.immediate.schedule(t);throw console.error("Error no immediate schudler"),new Error("cant find immediate scheduler")}}export{Lt as ElevationMode,Ot as I3SMeshView3D,Kt as makeScheduleFunction};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import has from"../../../core/has.js";import r from"../../../core/Logger.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{watch as o,initial as i}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as l,invert as c}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as d,getTranslation as u}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as p}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{t as h}from"../../../chunks/vec32.js";import{fromArray as f,create as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as b}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as y}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as w}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as v}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as _}from"../../../geometry/projection/projectVectorToVector.js";import{BufferViewVec4f as x,BufferViewVec4u8 as j,BufferViewVec4u16 as M,BufferViewVec3f as T,BufferViewVec3u8 as P,BufferViewVec3u16 as U,BufferViewVec2f as C,BufferViewInt16 as O,BufferViewUint32 as E,BufferViewUint16 as I}from"../../../geometry/support/buffer/BufferView.js";import{invalidLayerView as V,wasmFailedToInit as F,Lyr3DLightingModel as R,Lyr3DUvWrapMode as A,Lyr3DImageFormat as H,Lyr3DPixelFormat as D,Lyr3DVtxAtrbSemantic as L,Lyr3DType as S}from"../../../layers/ILyr3DWasmPerSceneView.js";import{getMetersPerUnit as k}from"../../../symbols/support/unitConversionUtils.js";import{ViewingMode as B}from"../../ViewingMode.js";import{IntegratedMesh3DTilesViewPerformanceInfo as N}from"./IntegratedMesh3DTilesViewPerformanceInfo.js";import{DrapeTargetType as z}from"./interfaces.js";import{LayerView3D as W}from"./LayerView3D.js";import{addLayerViewToWasm as G,removeLayerViewFromWasm as J,getLyr3DWasm as $}from"./Lyr3DWasm.js";import{LayerElevationProvider as q}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as K,alphaModeConversion as Q,faceCullingConversion as X,wrapModeConversion as Y,lyr3DTypeToByteSize as Z}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as ee}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as te}from"../support/ElevationRange.js";import{compute as re}from"../support/orientedBoundingBox.js";import{createVertexBufferLayout as se}from"../webgl-engine/collections/Component/SourceGeometry.js";import{ComponentParameterSummary as oe}from"../webgl-engine/collections/Component/Material/ComponentMaterial.js";import{RenderTexture as ie}from"../webgl-engine/core/material/RenderTexture.js";import{TextureCoordinateAttributeType as ae}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{getEllipsoidMode as ne}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as le}from"../webgl-engine/lib/Attribute.js";import{CullFaceOptions as ce,AlphaDiscardMode as me,TextureEncodingMimeType as de}from"../webgl-engine/lib/basicInterfaces.js";import{compressAndTransformNormals as ue}from"../webgl-engine/lib/Normals.js";import{Texture as pe}from"../webgl-engine/lib/Texture.js";import{VertexAttribute as he}from"../webgl-engine/lib/VertexAttribute.js";import{writeDefaultAttribute as fe}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import ge from"../../layers/LayerView.js";var be;!function(e){e[e.API=1]="API",e[e.VerboseAPI=2]="VerboseAPI",e[e.Error=3]="Error"}(be||(be={}));class ye{constructor(){this.isVisible=!1,this.components=[],this.texMemoryUsage=0,this.vboMemoryUsage=0,this.cpuMemoryUsage=0,this.textures=[]}totalMemory(){return this.texMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}}function we(e){return Math.round(e/1048.576)/1e3}let ve=class extends(W(ge)){constructor(){super(...arguments),this.type="integrated-mesh-3dtiles",this._wasmLayerId=-1,this.ignoresMemoryFactor=!0,this.unloadedMemory=0,this._needsNormals=!has("disable-feature:im-normals"),this.drapeTargetType=z.WithoutRasterImage,this._lyrHandleToObjects=new Map,this._initialCullFace=new Map,this._suspendedHandle=null,this._dbgFlags=new Set}initialize(){if(this._dbgFlags.add(be.Error),this._dbg(be.VerboseAPI,"Tiles3DLayerView3D initialize() called"),!this._canProjectWithoutEngine())throw new t("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{});const e=G(this).then((e=>{this._intersectionHandler=new ee(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this._elevationProvider=new q({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this.view.elevationProvider.register("im",this._elevationProvider),this.view.basemapTerrain.overlayManager.registerDrapeTarget(this),this._wasmLayerId=e,this._suspendedHandle=o((()=>this.suspended),(e=>{const t=$(this.view);t&&t.setEnabled(this,!e)}),i),this.addHandles([o((()=>this.layer.elevationInfo),(e=>this._elevationInfoChanged(e)))])})).catch((e=>{if(J(this),this._wasmLayerId=-1,e===V)throw new t("tiles3d:addLayer-failure","The 3d tiles layer description was invalid.",{});if(e===F)throw new t("tiles3d:addLayer-failure","The 3d tiles layer web assembly module failed to download.",{})}));this.addResolvingPromise(e)}destroy(){this._dbg(be.VerboseAPI,"Tiles3DLayerView3D destroy() called"),J(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.objectsChanged(this._obbs),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.basemapTerrain.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(((e,t)=>this.freeRenderable(t))),this._lyrHandleToObjects.clear(),this._initialCullFace.clear(),this._updatingHandles=s(this._updatingHandles)}_slicePlaneEnabledChange(e){this.objects.forEach((t=>{const r=this._collection.getMaterial(t);r.commonMaterialParameters.hasSlicePlane=e,r.commonMaterialParameters.cullFace=e?ce.None:this._initialCullFace.get(t)}))}_elevationInfoChanged(e){const t=e?.offset??0,r=e?.unit?k(e?.unit):1,s=$(this.view);s&&s.setLayerOffset(this,t*r)}get _obbs(){return this.objects.map((e=>this._collection.getComponentObb(e)))}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){let e=0;return this._lyrHandleToObjects.forEach((t=>{e+=t.totalMemory()})),e}get performanceInfo(){let e=0,t=0,r=0,s=0,o=0,i=0;return this._lyrHandleToObjects.forEach((a=>{a.isVisible?(e+=a.texMemoryUsage,t+=a.vboMemoryUsage,o++):(r+=a.texMemoryUsage,s+=a.vboMemoryUsage,i++)})),new N(this.usedMemory,o,i,we(t),we(e),we(s),we(r))}_canProjectWithoutEngine(){if(this.view.state.viewingMode===B.Local){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view._stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationOffset(){return(this.layer.elevationInfo?.offset??0)*(this.layer.elevationInfo?.unit?k(this.layer.elevationInfo.unit):1)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new te(e.zmin,e.zmax):null}getElevationRange(e){return null}get fullExtent(){return this.layer.fullExtent}get objects(){return Array.from(this._lyrHandleToObjects.values()).reduce(((e,t)=>e.concat(t.components)),new Array)}isUpdating(){const e=$(this.view);return!(this._wasmLayerId<0||null==e)&&e.isUpdating(this._wasmLayerId)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const r=f(t.desc.origin);let s=0;const o=new Array,i=new Map,a=new ye;return this._lyrHandleToObjects.set(e.handle,a),t.desc.prims.forEach((e=>{this._dbg(be.VerboseAPI,JSON.stringify(e));if(null==K[e.ptype]||null==t.data)return void this._dbg(be.VerboseAPI,"[Unsupported Feature] Unsupported primitive mode ("+e.ptype+"). Skipping primitive.");const n=this.view.basemapTerrain.spatialReference,f=p();w(y,r,f,n);const x=l(m(),f),j=c(m(),x),M=p();d(M,M,r);const T=u(g(),M),{positionView:P,positionAttr:U,normalsView:C,normalsAttr:O,colorAttr:E,texCoord0Attr:I,indicesView:V}=this.getBufferViews(e,t.data.buffer,x);if(null==U||null==P||null==V)return;const F={colors:null!=E,textureCoordinates:null!=I?ae.Default:ae.None,hasNormals:null!=C,needsNormals:this._needsNormals},A=U.data.length/U.size,H=(e,t)=>!e||e.data.length/e.size===A||(this._dbg(be.Error,`${t} !== numPos. Skipping primitive.`),!1);if(!H(I,"numTexcoord")||!H(E,"numColors")||!H(O,"normals"))return;const D=se(F),L=g();for(let t=0;t<P.count;t++)P.getVec(t,L),h(L,L,x),P.setVec(t,L);const S=D.createBuffer(U.data.length),k=new Map([[he.POSITION,U]]);null!=I&&k.set(he.UV0,I),null!=E&&k.set(he.COLOR,E),null!=O&&k.set(he.NORMALCOMPRESSED,O),k.forEach(((e,t)=>{null!=e&&fe(t,e,null,null,S,0)}));const B=new Uint32Array([0,V.typedBuffer.length]),N={vertices:{data:S.buffer,count:S.byteLength/D.stride,layoutParameters:F},positionData:{positions:P.typedBuffer,indices:V.typedBuffer},indices:V.typedBuffer,componentOffsets:B};a.cpuMemoryUsage+=P.count,a.cpuMemoryUsage+=V.count,s+=N.vertices.count;const z=re(U),W=this.view.renderSpatialReference,G=g(),J=[1,1,1];v(T,W,J,n)||this._dbg(be.Error,"Unsupported coordinate system for IM overlay"),_(T,W,G,n);const $=this._collection.createObject({toMapSpace:b(G[0],G[1],J[0],J[1]),geometry:N,obb:z,transform:{position:T,rotationScale:j}});if(t.desc?.materials&&null!=e.materialId){const r=t.desc.materials[e.materialId];r&&this._collection.updateMaterial($,(e=>{e.baseColor=r.baseColorFactor,e.usePBR=r.lightingModel===R.Pbr,e.hasParametersFromSource=!1,e.baseColorTexture=this._getTexture(r.baseColorTex,t,i),e.usePBR&&(e.mrrFactors=[r.metallicFactor,r.roughnessFactor,0],e.emissiveFactor=r.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=this._getTexture(r.metalTex,t,i),e.emissionTexture=this._getTexture(r.emissiveTex,t,i),e.occlusionTexture=this._getTexture(r.occlusionTex,t,i),e.normalTexture=this._getTexture(r.normalTex,t,i)),e.objectOpacity=0,e.alphaDiscardMode=me.Mask;const s=[];e.baseColorTexture&&s.push(e.baseColorTexture.loadPromise),e.usePBR&&e.metallicRoughnessTexture&&s.push(e.metallicRoughnessTexture.loadPromise),e.usePBR&&e.emissionTexture&&s.push(e.emissionTexture.loadPromise),e.usePBR&&e.occlusionTexture&&s.push(e.occlusionTexture.loadPromise),e.usePBR&&e.normalTexture&&s.push(e.normalTexture.loadPromise);const n=Promise.all(s);o.push(n),n.then((()=>{e.alphaDiscardMode=Q[r.alphaMode],e.objectOpacity=1,a.texMemoryUsage+=e.baseColorTexture?.glTexture?.usedMemory||0,e.usePBR&&(a.texMemoryUsage+=e.metallicRoughnessTexture?.glTexture?.usedMemory||0,a.texMemoryUsage+=e.emissionTexture?.glTexture?.usedMemory||0,a.texMemoryUsage+=e.occlusionTexture?.glTexture?.usedMemory||0,a.texMemoryUsage+=e.normalTexture?.glTexture?.usedMemory||0)})),e.commonMaterialParameters.doubleSided=r.isDoubleSided,e.commonMaterialParameters.cullFace=r.faceCulling?X[r.faceCulling]:ce.Back,this._initialCullFace.set($,e.commonMaterialParameters.cullFace),e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=oe.All,e.textureAlphaCutoff=r.alphaCutoff??.1,e.alphaDiscardMode=Q[r.alphaMode],e.isIntegratedMesh=!0,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=ne(this.view.spatialReference)}))}a.components.push($),a.vboMemoryUsage+=this._collection.getObjectGPUMemoryUsage($)})),await Promise.all(o),i.forEach((e=>{a.textures.push(e)})),{vertexCount:s,vbMemUsage:a.vboMemoryUsage,ibMemUsage:0,texMemUsage:a.texMemoryUsage}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(t.components.forEach((e=>{t.textures.forEach((e=>{this._stage.remove(e)})),this._collection.destroyObject(e),this._initialCullFace.delete(e),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))})),this._lyrHandleToObjects.delete(e))}setRenderableVisibility(e,t){const r=this._lyrHandleToObjects.get(e);r&&(r.isVisible=t,r.components.forEach((e=>{this._collection.setObjectVisibility(e,t),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))})))}_getTexture(e,t,r){let s=null;if(e&&t.desc?.images&&t.data?.buffer){const o=t.desc.images[e?.imageId];if(s=r.get(o),!s&&o){const i=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,a=i>1,n=Y[e.wrapMode??A.None];let l=o.alpha?4:3;const c=new Uint8Array(t.data.buffer,o.data.byteOffset,o.data.byteCount);let m=null,d=null,u=null;switch(o.format){case H.Raw:o.pixelFormat===D.R8?(m=c.buffer,l=1,d=""):o.pixelFormat===D.Rgb8?(m=c.buffer,l=3,d=""):o.pixelFormat===D.Rgba8&&(m=c.buffer,l=4,d="");break;case H.Dxt1:m=c.buffer,l=3,d=de.DDS_ENCODING;break;case H.Dxt5:m=c.buffer,l=4,d=de.DDS_ENCODING;break;case H.Png:d="image/png",u=document.createElement("img");break;case H.Jpeg:d="image/jpeg",u=document.createElement("img");break;case H.Etc2:d="image/ktx",u=document.createElement("img");break;case H.Astc:this._dbg(be.Error,"Astc texture not supported");break;case H.Pvrtc:this._dbg(be.Error,"Pvrtc texture not supported")}if(u&&d){const e=new Blob([c],{type:d});u.src=URL.createObjectURL(e),m=u}m&&null!=d&&(s=new pe(m,{mipmap:a,maxAnisotropy:i,encoding:d,wrap:n,components:l,noUnpackFlip:!0,width:o.mip0Width,height:o.mip0Height}),this._stage.add(s),r.set(o,s))}}return s?new ie(this.view._stage.renderView.textureRepository,s.id):null}getBufferViews(e,t,r){let s,o,i,a,n,l,c,m;if(e.atrbs.forEach((e=>{const m=e.view,d=void 0,u=m.byteOffset+m.byteCount,p=m.byteCount/Z[m.type],h=[...Array(p).keys()].map((e=>e));try{switch(e.sem){case L.Position:3!==m.ncomp||m.type!==S.F32?this._dbg(be.Error,"[Unsupported Feature] Unsupported view for Position ("+m+")"):(s=new T(t,m.byteOffset,d,u),o=new le(s.typedBuffer,h,3));break;case L.Normal:if(3!==m.ncomp||m.type!==S.F32)this._dbg(be.Error,"[Unsupported Feature] Unsupported view for Normal ("+m+")");else if(this._needsNormals){const e=new T(t,m.byteOffset,d,u),s=ue(e.typedBuffer,r);n=new O(s),l=new le(n.typedBuffer,h,2)}break;case L.TexCoord:2!==m.ncomp||m.type!==S.F32?this._dbg(be.Error,"[Unsupported Feature] Unsupported view for Texcoord ("+m+")"):void 0===a&&(a=new le(new C(t,m.byteOffset,d,u).typedBuffer,h,2));break;case L.Color:4===m.ncomp?(m.type===S.F32&&(c=new x(t,m.byteOffset,d,u)),m.type===S.U8&&(c=new j(t,m.byteOffset,d,u)),m.type===S.U16&&(c=new M(t,m.byteOffset,d,u))):3===m.ncomp&&(m.type===S.F32&&(c=new T(t,m.byteOffset,d,u)),m.type===S.U8&&(c=new P(t,m.byteOffset,d,u)),m.type===S.U16&&(c=new U(t,m.byteOffset,d,u))),null==c?this._dbg(be.VerboseAPI,"[Unsupported Feature] Unsupported view for Color ("+m+")"):i=new le(c.typedBuffer,h,m.ncomp);break;case L.FeatureIndex:break;default:this._dbg(be.VerboseAPI,"[Unsupported Feature] Unsupported semantic ("+e.sem+"). Skipping vertex attribute.")}}catch(f){this._dbg(be.VerboseAPI,"Error Creating buffer ("+f+"). Skipping vertex attribute.")}})),e.index){const r=e.index.view,s=void 0,o=r.byteOffset+r.byteCount;switch(e.index.view.type){case S.U16:m=new I(t,r.byteOffset,s,o);break;case S.U32:m=new E(t,r.byteOffset,s,o);break;case S.U8:default:this._dbg(be.Error,"[Unsupported Feature] index type not supported ("+r.type+").")}}return{positionView:s,positionAttr:o,colorAttr:i,texCoord0Attr:a,indicesView:m,normalsView:n,normalsAttr:l}}_dbg(e,t){this._dbgFlags.has(e)&&(e===be.Error?r.getLogger(this).error(t):r.getLogger(this).warn(t))}};e([a()],ve.prototype,"layer",void 0),e([a()],ve.prototype,"elevationOffset",null),ve=e([n("esri.views.3d.layers.Tiles3DLayerView3D")],ve);const _e=ve;export{_e as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import has from"../../../core/has.js";import r from"../../../core/Logger.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{watch as o,initial as i}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as l,invert as c}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as d,getTranslation as u}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as p}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{t as h}from"../../../chunks/vec32.js";import{fromArray as f,create as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as b}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as y}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as w}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as v}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as _}from"../../../geometry/projection/projectVectorToVector.js";import{BufferViewVec4f as x,BufferViewVec4u8 as j,BufferViewVec4u16 as M,BufferViewVec3f as T,BufferViewVec3u8 as P,BufferViewVec3u16 as U,BufferViewVec2f as O,BufferViewInt16 as C,BufferViewUint32 as E,BufferViewUint16 as I}from"../../../geometry/support/buffer/BufferView.js";import{invalidLayerView as V,wasmFailedToInit as F,Lyr3DLightingModel as R,Lyr3DUvWrapMode as A,Lyr3DImageFormat as H,Lyr3DPixelFormat as D,Lyr3DVtxAtrbSemantic as L,Lyr3DType as S}from"../../../layers/ILyr3DWasmPerSceneView.js";import{getMetersPerUnit as k}from"../../../symbols/support/unitConversionUtils.js";import{ViewingMode as B}from"../../ViewingMode.js";import{IntegratedMesh3DTilesViewPerformanceInfo as N}from"./IntegratedMesh3DTilesViewPerformanceInfo.js";import{DrapeTargetType as z}from"./interfaces.js";import{LayerView3D as W}from"./LayerView3D.js";import{addLayerViewToWasm as G,removeLayerViewFromWasm as J,getLyr3DWasm as $}from"./Lyr3DWasm.js";import{LayerElevationProvider as q}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as K,alphaModeConversion as Q,faceCullingConversion as X,wrapModeConversion as Y,lyr3DTypeToByteSize as Z}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as ee}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as te}from"../support/ElevationRange.js";import{compute as re}from"../support/orientedBoundingBox.js";import{createVertexBufferLayout as se}from"../webgl-engine/collections/Component/SourceGeometry.js";import{ComponentParameterSummary as oe}from"../webgl-engine/collections/Component/Material/ComponentMaterial.js";import{RenderTexture as ie}from"../webgl-engine/core/material/RenderTexture.js";import{TextureCoordinateAttributeType as ae}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{getEllipsoidMode as ne}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as le}from"../webgl-engine/lib/Attribute.js";import{CullFaceOptions as ce,AlphaDiscardMode as me,TextureEncodingMimeType as de}from"../webgl-engine/lib/basicInterfaces.js";import{compressAndTransformNormals as ue}from"../webgl-engine/lib/Normals.js";import{Texture as pe}from"../webgl-engine/lib/Texture.js";import{VertexAttribute as he}from"../webgl-engine/lib/VertexAttribute.js";import{writeDefaultAttribute as fe}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import ge from"../../layers/LayerView.js";var be;!function(e){e[e.API=1]="API",e[e.VerboseAPI=2]="VerboseAPI",e[e.Error=3]="Error"}(be||(be={}));class ye{constructor(){this.isVisible=!1,this.components=[],this.texMemoryUsage=0,this.vboMemoryUsage=0,this.cpuMemoryUsage=0,this.textures=[]}totalMemory(){return this.texMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}}function we(e){return Math.round(e/1048.576)/1e3}let ve=class extends(W(ge)){constructor(){super(...arguments),this.type="integrated-mesh-3dtiles",this._wasmLayerId=-1,this.ignoresMemoryFactor=!0,this.unloadedMemory=0,this._needsNormals=!has("disable-feature:im-normals"),this.drapeTargetType=z.WithoutRasterImage,this._lyrHandleToObjects=new Map,this._initialCullFace=new Map,this._suspendedHandle=null,this._dbgFlags=new Set}initialize(){if(this._dbgFlags.add(be.Error),this._dbg(be.VerboseAPI,"Tiles3DLayerView3D initialize() called"),!this._canProjectWithoutEngine())throw new t("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{});const e=G(this).then((e=>{this._intersectionHandler=new ee(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this._elevationProvider=new q({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this.view.elevationProvider.register("im",this._elevationProvider),this.view.basemapTerrain.overlayManager.registerDrapeTarget(this),this._wasmLayerId=e,this._suspendedHandle=o((()=>this.suspended),(e=>{const t=$(this.view);t&&t.setEnabled(this,!e)}),i),this.addHandles([o((()=>this.layer.elevationInfo),(e=>this._elevationInfoChanged(e)))])})).catch((e=>{if(J(this),this._wasmLayerId=-1,e===V)throw new t("tiles3d:addLayer-failure","The 3d tiles layer description was invalid.",{});if(e===F)throw new t("tiles3d:addLayer-failure","The 3d tiles layer web assembly module failed to download.",{})}));this.addResolvingPromise(e)}destroy(){this._dbg(be.VerboseAPI,"Tiles3DLayerView3D destroy() called"),J(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.objectsChanged(this._obbs),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.basemapTerrain.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach((e=>this.freeObject(e))),this._lyrHandleToObjects.clear(),this._initialCullFace.clear(),this._updatingHandles=s(this._updatingHandles)}_slicePlaneEnabledChange(e){this.objects.forEach((t=>{const r=this._collection.getMaterial(t);r.commonMaterialParameters.hasSlicePlane=e,r.commonMaterialParameters.cullFace=e?ce.None:this._initialCullFace.get(t)}))}_elevationInfoChanged(e){const t=e?.offset??0,r=e?.unit?k(e?.unit):1,s=$(this.view);s&&s.setLayerOffset(this,t*r)}get _obbs(){return this.objects.map((e=>this._collection.getComponentObb(e)))}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){let e=0;return this._lyrHandleToObjects.forEach((t=>{e+=t.totalMemory()})),e}get performanceInfo(){let e=0,t=0,r=0,s=0,o=0,i=0;return this._lyrHandleToObjects.forEach((a=>{a.isVisible?(e+=a.texMemoryUsage,t+=a.vboMemoryUsage,o++):(r+=a.texMemoryUsage,s+=a.vboMemoryUsage,i++)})),new N(this.usedMemory,o,i,we(t),we(e),we(s),we(r))}_canProjectWithoutEngine(){if(this.view.state.viewingMode===B.Local){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view._stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationOffset(){return(this.layer.elevationInfo?.offset??0)*(this.layer.elevationInfo?.unit?k(this.layer.elevationInfo.unit):1)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new te(e.zmin,e.zmax):null}getElevationRange(e){return null}get fullExtent(){return this.layer.fullExtent}get objects(){return Array.from(this._lyrHandleToObjects.values()).reduce(((e,t)=>e.concat(t.components)),new Array)}isUpdating(){const e=$(this.view);return!(this._wasmLayerId<0||null==e)&&e.isUpdating(this._wasmLayerId)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const r=f(t.desc.origin);let s=0;const o=new Array,i=new Map,a=new ye;return this._lyrHandleToObjects.set(e.handle,a),t.desc.prims.forEach((e=>{this._dbg(be.VerboseAPI,JSON.stringify(e));if(null==K[e.ptype]||null==t.data)return void this._dbg(be.VerboseAPI,"[Unsupported Feature] Unsupported primitive mode ("+e.ptype+"). Skipping primitive.");const n=this.view.basemapTerrain.spatialReference,f=p();w(y,r,f,n);const x=l(m(),f),j=c(m(),x),M=p();d(M,M,r);const T=u(g(),M),{positionView:P,positionAttr:U,normalsView:O,normalsAttr:C,colorAttr:E,texCoord0Attr:I,indicesView:V}=this.getBufferViews(e,t.data.buffer,x);if(null==U||null==P||null==V)return;const F={colors:null!=E,textureCoordinates:null!=I?ae.Default:ae.None,hasNormals:null!=O,needsNormals:this._needsNormals},A=U.data.length/U.size,H=(e,t)=>!e||e.data.length/e.size===A||(this._dbg(be.Error,`${t} !== numPos. Skipping primitive.`),!1);if(!H(I,"numTexcoord")||!H(E,"numColors")||!H(C,"normals"))return;const D=se(F),L=g();for(let t=0;t<P.count;t++)P.getVec(t,L),h(L,L,x),P.setVec(t,L);const S=D.createBuffer(U.data.length),k=new Map([[he.POSITION,U]]);null!=I&&k.set(he.UV0,I),null!=E&&k.set(he.COLOR,E),null!=C&&k.set(he.NORMALCOMPRESSED,C),k.forEach(((e,t)=>{null!=e&&fe(t,e,null,null,S,0)}));const B=new Uint32Array([0,V.typedBuffer.length]),N={vertices:{data:S.buffer,count:S.byteLength/D.stride,layoutParameters:F},positionData:{positions:P.typedBuffer,indices:V.typedBuffer},indices:V.typedBuffer,componentOffsets:B};a.cpuMemoryUsage+=P.count,a.cpuMemoryUsage+=V.count,s+=N.vertices.count;const z=re(U),W=this.view.renderSpatialReference,G=g(),J=[1,1,1];v(T,W,J,n)||this._dbg(be.Error,"Unsupported coordinate system for IM overlay"),_(T,W,G,n);const $=this._collection.createObject({toMapSpace:b(G[0],G[1],J[0],J[1]),geometry:N,obb:z,transform:{position:T,rotationScale:j}});if(t.desc?.materials&&null!=e.materialId){const r=t.desc.materials[e.materialId];r&&this._collection.updateMaterial($,(e=>{e.baseColor=r.baseColorFactor,e.usePBR=r.lightingModel===R.Pbr,e.hasParametersFromSource=!1,e.baseColorTexture=this._getTexture(r.baseColorTex,t,i),e.usePBR&&(e.mrrFactors=[r.metallicFactor,r.roughnessFactor,0],e.emissiveFactor=r.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=this._getTexture(r.metalTex,t,i),e.emissionTexture=this._getTexture(r.emissiveTex,t,i),e.occlusionTexture=this._getTexture(r.occlusionTex,t,i),e.normalTexture=this._getTexture(r.normalTex,t,i)),e.objectOpacity=0,e.alphaDiscardMode=me.Mask;const s=[];e.baseColorTexture&&s.push(e.baseColorTexture.loadPromise),e.usePBR&&e.metallicRoughnessTexture&&s.push(e.metallicRoughnessTexture.loadPromise),e.usePBR&&e.emissionTexture&&s.push(e.emissionTexture.loadPromise),e.usePBR&&e.occlusionTexture&&s.push(e.occlusionTexture.loadPromise),e.usePBR&&e.normalTexture&&s.push(e.normalTexture.loadPromise);const n=Promise.all(s);o.push(n),n.then((()=>{e.alphaDiscardMode=Q[r.alphaMode],e.objectOpacity=1,a.texMemoryUsage+=e.baseColorTexture?.glTexture?.usedMemory||0,e.usePBR&&(a.texMemoryUsage+=e.metallicRoughnessTexture?.glTexture?.usedMemory||0,a.texMemoryUsage+=e.emissionTexture?.glTexture?.usedMemory||0,a.texMemoryUsage+=e.occlusionTexture?.glTexture?.usedMemory||0,a.texMemoryUsage+=e.normalTexture?.glTexture?.usedMemory||0)})),e.commonMaterialParameters.doubleSided=r.isDoubleSided,e.commonMaterialParameters.cullFace=r.faceCulling?X[r.faceCulling]:ce.Back,this._initialCullFace.set($,e.commonMaterialParameters.cullFace),e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=oe.All,e.textureAlphaCutoff=r.alphaCutoff??.1,e.alphaDiscardMode=Q[r.alphaMode],e.isIntegratedMesh=!0,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=ne(this.view.spatialReference)}))}a.components.push($),a.vboMemoryUsage+=this._collection.getObjectGPUMemoryUsage($)})),await Promise.all(o),i.forEach((e=>{a.textures.push(e)})),{vertexCount:s,vbMemUsage:a.vboMemoryUsage,ibMemUsage:0,texMemUsage:a.texMemoryUsage}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){e.components.forEach((t=>{e.textures.forEach((e=>{this._stage.remove(e)})),this._collection.destroyObject(t),this._initialCullFace.delete(t)}))}setRenderableVisibility(e,t){const r=this._lyrHandleToObjects.get(e);r&&(r.isVisible=t,r.components.forEach((e=>{this._collection.setObjectVisibility(e,t),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))})))}_getTexture(e,t,r){let s=null;if(e&&t.desc?.images&&t.data?.buffer){const o=t.desc.images[e?.imageId];if(s=r.get(o),!s&&o){const i=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,a=i>1,n=Y[e.wrapMode??A.None];let l=o.alpha?4:3;const c=new Uint8Array(t.data.buffer,o.data.byteOffset,o.data.byteCount);let m=null,d=null,u=null;switch(o.format){case H.Raw:o.pixelFormat===D.R8?(m=c.buffer,l=1,d=""):o.pixelFormat===D.Rgb8?(m=c.buffer,l=3,d=""):o.pixelFormat===D.Rgba8&&(m=c.buffer,l=4,d="");break;case H.Dxt1:m=c.buffer,l=3,d=de.DDS_ENCODING;break;case H.Dxt5:m=c.buffer,l=4,d=de.DDS_ENCODING;break;case H.Png:d="image/png",u=document.createElement("img");break;case H.Jpeg:d="image/jpeg",u=document.createElement("img");break;case H.Etc2:d="image/ktx",u=document.createElement("img");break;case H.Astc:this._dbg(be.Error,"Astc texture not supported");break;case H.Pvrtc:this._dbg(be.Error,"Pvrtc texture not supported")}if(u&&d){const e=new Blob([c],{type:d});u.src=URL.createObjectURL(e),m=u}m&&null!=d&&(s=new pe(m,{mipmap:a,maxAnisotropy:i,encoding:d,wrap:n,components:l,noUnpackFlip:!0,width:o.mip0Width,height:o.mip0Height}),this._stage.add(s),r.set(o,s))}}return s?new ie(this.view._stage.renderView.textureRepository,s.id):null}getBufferViews(e,t,r){let s,o,i,a,n,l,c,m;if(e.atrbs.forEach((e=>{const m=e.view,d=void 0,u=m.byteOffset+m.byteCount,p=m.byteCount/Z[m.type],h=[...Array(p).keys()].map((e=>e));try{switch(e.sem){case L.Position:3!==m.ncomp||m.type!==S.F32?this._dbg(be.Error,"[Unsupported Feature] Unsupported view for Position ("+m+")"):(s=new T(t,m.byteOffset,d,u),o=new le(s.typedBuffer,h,3));break;case L.Normal:if(3!==m.ncomp||m.type!==S.F32)this._dbg(be.Error,"[Unsupported Feature] Unsupported view for Normal ("+m+")");else if(this._needsNormals){const e=new T(t,m.byteOffset,d,u),s=ue(e.typedBuffer,r);n=new C(s),l=new le(n.typedBuffer,h,2)}break;case L.TexCoord:2!==m.ncomp||m.type!==S.F32?this._dbg(be.Error,"[Unsupported Feature] Unsupported view for Texcoord ("+m+")"):void 0===a&&(a=new le(new O(t,m.byteOffset,d,u).typedBuffer,h,2));break;case L.Color:4===m.ncomp?(m.type===S.F32&&(c=new x(t,m.byteOffset,d,u)),m.type===S.U8&&(c=new j(t,m.byteOffset,d,u)),m.type===S.U16&&(c=new M(t,m.byteOffset,d,u))):3===m.ncomp&&(m.type===S.F32&&(c=new T(t,m.byteOffset,d,u)),m.type===S.U8&&(c=new P(t,m.byteOffset,d,u)),m.type===S.U16&&(c=new U(t,m.byteOffset,d,u))),null==c?this._dbg(be.VerboseAPI,"[Unsupported Feature] Unsupported view for Color ("+m+")"):i=new le(c.typedBuffer,h,m.ncomp);break;case L.FeatureIndex:break;default:this._dbg(be.VerboseAPI,"[Unsupported Feature] Unsupported semantic ("+e.sem+"). Skipping vertex attribute.")}}catch(f){this._dbg(be.VerboseAPI,"Error Creating buffer ("+f+"). Skipping vertex attribute.")}})),e.index){const r=e.index.view,s=void 0,o=r.byteOffset+r.byteCount;switch(e.index.view.type){case S.U16:m=new I(t,r.byteOffset,s,o);break;case S.U32:m=new E(t,r.byteOffset,s,o);break;case S.U8:default:this._dbg(be.Error,"[Unsupported Feature] index type not supported ("+r.type+").")}}return{positionView:s,positionAttr:o,colorAttr:i,texCoord0Attr:a,indicesView:m,normalsView:n,normalsAttr:l}}_dbg(e,t){this._dbgFlags.has(e)&&(e===be.Error?r.getLogger(this).error(t):r.getLogger(this).warn(t))}};e([a()],ve.prototype,"layer",void 0),e([a()],ve.prototype,"elevationOffset",null),ve=e([n("esri.views.3d.layers.Tiles3DLayerView3D")],ve);const _e=ve;export{_e as default};
|