@arcgis/core 4.27.0-rc.2 → 4.27.0-rc.3
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/{a8565d1c676f3bfbcebb.js → 002fe1ec63ea33e6972d.js} +1 -1
- package/assets/esri/core/workers/chunks/{0610691a0c0d9fbbd6d2.js → 013de5c2955801b329b3.js} +1 -1
- package/assets/esri/core/workers/chunks/07163dcbb871f927a580.js +1 -0
- package/assets/esri/core/workers/chunks/0e46687004392c493c06.js +1 -0
- package/assets/esri/core/workers/chunks/0e65e00173b66c7fec2e.js +1 -0
- package/assets/esri/core/workers/chunks/1aa8dd317ecd3c41e0ea.js +1 -0
- package/assets/esri/core/workers/chunks/21328f3dd26abe84a10d.js +1 -0
- package/assets/esri/core/workers/chunks/28c67c98039503b62e6e.js +1 -0
- package/assets/esri/core/workers/chunks/{da57eba2fe25495ea217.js → 2faa8f08f2fdaac3f4af.js} +1 -1
- package/assets/esri/core/workers/chunks/{0407bf97ad621c89a734.js → 3160af63b860b52db389.js} +1 -1
- package/assets/esri/core/workers/chunks/3767b9e7660873b018c2.js +1 -0
- package/assets/esri/core/workers/chunks/39ae4b9b766f674bc6f2.js +1 -0
- package/assets/esri/core/workers/chunks/45629ff775e77234b227.js +1 -0
- package/assets/esri/core/workers/chunks/4a4f14a3d8da270059c4.js +1 -0
- package/assets/esri/core/workers/chunks/{3e239bfad611985e50fb.js → 50f910797c17c3028521.js} +1 -1
- package/assets/esri/core/workers/chunks/642c5a93c0a454bdd115.js +1 -0
- package/assets/esri/core/workers/chunks/{14145959a3dab1437818.js → 6627f1bc9ee6b620e3aa.js} +1 -1
- package/assets/esri/core/workers/chunks/{170bdbdb4e21bf91a17f.js → 6eaa7a51efde2dd4a5a4.js} +1 -1
- package/assets/esri/core/workers/chunks/{2bdc63395c7466ce1641.js → 7053c2f5a958d4c8629b.js} +1 -1
- package/assets/esri/core/workers/chunks/{4c35c663528f710e8c78.js → 79cb672c85ea29e8484a.js} +1 -1
- package/assets/esri/core/workers/chunks/82939ead43848a13f765.js +1 -0
- package/assets/esri/core/workers/chunks/89001ee8d3f69fa03cc1.js +1 -0
- package/assets/esri/core/workers/chunks/8b6b963230df56850580.js +1 -0
- package/assets/esri/core/workers/chunks/9472184ef1432fc55d6b.js +1 -0
- package/assets/esri/core/workers/chunks/a6ddf80eb324c35076e1.js +1 -0
- package/assets/esri/core/workers/chunks/a80a6267d88246ede5d3.js +1 -0
- package/assets/esri/core/workers/chunks/{f505ebd4bd3bfb6c790d.js → b6a55fdfe16795ebf02c.js} +1 -1
- package/assets/esri/core/workers/chunks/bf9e1fde9f6b2b4f10c0.js +1 -0
- package/assets/esri/core/workers/chunks/cfa3b2b1e184681e9af4.js +1 -0
- package/assets/esri/core/workers/chunks/{1f69fb9687de9ebfcf90.js → d4ba894a2583f3930a4f.js} +1 -1
- package/assets/esri/core/workers/chunks/d5dfd3d693d5e393a542.js +1 -0
- package/assets/esri/core/workers/chunks/{74fd2059ddda9083cbcc.js → dc6c97a43d642eeaf477.js} +1 -1
- package/assets/esri/core/workers/chunks/{2154d395f405be3cd3ba.js → eca0c3d57b3a1e3a14ee.js} +1 -1
- package/assets/esri/core/workers/chunks/f36697f6aac782007d1a.js +1 -0
- package/assets/esri/core/workers/chunks/f52054f27619a98b7bb7.js +1 -0
- package/assets/esri/core/workers/chunks/fb7fe307a583b6a22218.js +1 -0
- package/assets/esri/core/workers/chunks/fbd3c78ee8e2219a6c7a.js +1 -0
- package/assets/esri/core/workers/chunks/ff42585e1b1d0c5497af.js +1 -0
- package/assets/esri/images/portal/livestreamvideolayer16.png +0 -0
- package/assets/esri/images/portal/{mediaservice16.png → videolayer16.png} +0 -0
- package/assets/esri/themes/base/widgets/_FeatureForm.scss +19 -2
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/geometry/support/DoubleArray.js +1 -1
- package/interfaces.d.ts +84 -0
- package/kernel.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/support/editableLayers.js +1 -1
- package/layers/support/layerUtils.js +1 -1
- package/package.json +1 -1
- package/portal/PortalItem.js +1 -1
- package/request.js +1 -1
- package/support/requestUtils.js +1 -1
- package/support/revision.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/I3SMeshWorkerHandle.js +1 -1
- package/views/3d/layers/SceneLayerWorker.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +2 -2
- package/webmap/initialViewPropertiesUtils.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/CreateWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/UpdateWorkflowData.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Feature/support/featureUtils.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm/RelationshipInput.js +1 -1
- package/widgets/FeatureForm/css.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/FeatureTemplates/FeatureTemplatesViewModel.js +1 -1
- package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.d.ts +4 -0
- package/widgets/UtilityNetworkValidateTopology.d.ts +4 -0
- package/widgets/support/geolocationUtils.js +1 -1
- package/assets/esri/core/workers/chunks/0fcb8d408696075338e2.js +0 -1
- package/assets/esri/core/workers/chunks/16e459b16bdd6e1a821b.js +0 -1
- package/assets/esri/core/workers/chunks/1b8074269800b384ecf6.js +0 -1
- package/assets/esri/core/workers/chunks/2b55295590b4a0503749.js +0 -1
- package/assets/esri/core/workers/chunks/3ba2fcb9110230f8790c.js +0 -1
- package/assets/esri/core/workers/chunks/5576858f56314afcb4d5.js +0 -1
- package/assets/esri/core/workers/chunks/5706edf45402dff279a6.js +0 -1
- package/assets/esri/core/workers/chunks/659b7bad7281c0e2aed3.js +0 -1
- package/assets/esri/core/workers/chunks/6cd248d065f6d1616294.js +0 -1
- package/assets/esri/core/workers/chunks/9326120c750799eb2d28.js +0 -1
- package/assets/esri/core/workers/chunks/99e0cec47e3ef72c1de4.js +0 -1
- package/assets/esri/core/workers/chunks/9c0e1e87790424f42d7e.js +0 -1
- package/assets/esri/core/workers/chunks/9e66af3b1c70cf25fb32.js +0 -1
- package/assets/esri/core/workers/chunks/a1c31bb8c12831539328.js +0 -1
- package/assets/esri/core/workers/chunks/b0cda39b53ecd6c44cd0.js +0 -1
- package/assets/esri/core/workers/chunks/c08e03165043df67c11b.js +0 -1
- package/assets/esri/core/workers/chunks/c26148d4bfab3b3dfab2.js +0 -1
- package/assets/esri/core/workers/chunks/d6b6bb8aecc85d2a3f6b.js +0 -1
- package/assets/esri/core/workers/chunks/eeaf8010e38b65a101ac.js +0 -1
- package/assets/esri/core/workers/chunks/f235392c56063fbf89c6.js +0 -1
- package/assets/esri/core/workers/chunks/fdd0d3616c97e408b104.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/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 has from"../../../core/has.js";import n from"../../../core/Logger.js";import{someMap as l}from"../../../core/MapUtils.js";import{destroyMaybe as d,applySome 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"../../../core/accessorSupport/ensureType.js";import{subclass as I}from"../../../core/accessorSupport/decorators/subclass.js";import{f as M}from"../../../chunks/mat3.js";import{c as C}from"../../../chunks/mat3f64.js";import{m as O,B as x}from"../../../chunks/mat4.js";import{b as E,c as j}from"../../../chunks/mat4f64.js";import{f as w}from"../../../chunks/quatf64.js";import{m as S,s as A,a as T,t as D,c as R,g as N,b as F}from"../../../chunks/vec3.js";import{c as V}from"../../../chunks/vec3f64.js";import{s as P}from"../../../chunks/vec4.js";import{f as H}from"../../../chunks/vec4f64.js";import{getReferenceEllipsoid as U}from"../../../geometry/ellipsoidUtils.js";import{projectBuffer as G,getProjectorName as L,localLinearScaleFactors as k,projectVectorToVector as B,projectBoundingSphere as q}from"../../../geometry/projection.js";import{create as z,empty as K,expandWithBuffer as W,toRect as $}from"../../../geometry/support/aaBoundingBox.js";import{create as Q,intersects as X}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as Y}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as J}from"../../../geometry/support/FloatArray.js";import{compactIndices as Z}from"../../../geometry/support/Indices.js";import{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 de from"../../../symbols/Symbol3D.js";import{getMetersPerUnit as he}from"../../../symbols/support/unitConversionUtils.js";import ce from"./I3SMeshViewLabeler.js";import{I3SMeshWorkerHandle as ue,toWasmModification as _e}from"./I3SMeshWorkerHandle.js";import{ForAllFeaturesReturnType as me,ForAllFeaturesMode as ge}from"./II3SMeshView3D.js";import{initialize as pe,setModificationsSync as fe,filterObbsForModificationsSync as be,interpretObbModificationResults as ye}from"./SceneLayerWorker.js";import{overrideColor as ve}from"./graphics/graphicUtils.js";import{areLabelsVisible as Ie}from"./graphics/Labeler.js";import{TextureUsage as Me,TextureEncoding as Ce}from"./i3s/enums.js";import Oe from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as xe}from"./i3s/I3SAsyncElevationUpdater.js";import{I3SCrossfadeHelper as Ee,NodeCrossfadeMetaData as je}from"./i3s/I3SCrossfadeHelper.js";import we from"./i3s/I3SElevationProvider.js";import{boundingBoxCornerPoints as Se}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Ae}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Te,selectEncoding as De,defaultMaterial as Re,createTexture as Ne,configureMaterial as Fe}from"./i3s/I3SMaterialUtil.js";import{NodeIMModificationImpact as Ve,NodeState as Pe}from"./i3s/I3SNode.js";import{I3SOverrides as He}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as Ue,getLocalOrigin as Ge}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as Le,checkSceneLayerValid as ke,checkSceneLayerCompatibleWithView as Be,getCacheKeySuffix as qe,whenGraphicAttributes as ze,computeVisibilityObb as Ke,filterInPlace as We,getCachedAttributeValue as $e,intersectBoundingRectWithMbs as Qe,MbsIntersectResult as Xe,addWraparound as Ye,getSymbolInfo as Je,transparentEdgeMaterial as Ze,getClipRect as et}from"./i3s/I3SUtil.js";import{IDBCache as tt}from"./i3s/IDBCache.js";import{IDBMockCache as it}from"./i3s/IDBMockCache.js";import{attributeLookup as st}from"./support/attributeUtils.js";import{ColorMixModeEnum as rt}from"./support/symbolColorUtils.js";import ot from"../support/debugFlags.js";import{toBoundingRect as at}from"../support/extentUtils.js";import{create as nt,intersectSphere as lt,clone as dt}from"../support/orientedBoundingBox.js";import{updatingProgress as ht}from"../support/updatingProperties.js";import{glLayout as ct}from"../support/buffer/glUtil.js";import{State as ut}from"../webgl-engine/collections/Component/ComponentObject.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=n.getLogger(ft),yt=[1,1,1,1];class vt extends je{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=20,Ct=100*o.MEGABYTES,Ot=t=>{let o=class extends t{constructor(...e){super(e),this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._idbCache=has("enable-feature:idb-mock-cache")?new it:new tt("esri-scenelayer-cache","geometries"),this._hasComponentData=!1,this._hasVertexColors=!1,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 Ee(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 Le(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?Me.AllTexturesPBR:Me.AllTextures:this._usePBR||this._hasLoadedPBRTextures?Me.GeometryTexturesPBR:Me.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=he(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{mode:kt.Absolute,offset:0};const t=y(this.i3slayer.spatialReference),i=he(e.unit),s=(e.offset??0)*i/t;switch(e.mode){case"absolute-height":return{mode:kt.Absolute,offset:s};case"relative-to-ground":return{mode:kt.RelativeToGround,offset:s};case"on-the-ground":return{mode:kt.OnTheGround,offset:0};default:return{mode:kt.Absolute,offset:0}}}get supportedTextureEncodings(){return Te(this.view._stage.renderView.capabilities)}get uncompressedTextureDownsamplingEnabled(){const e=this.view?.qualitySettings.sceneService.uncompressedTextureDownsamplingEnabled,t=0==(this.supportedTextureEncodings&Ce.DDS_S3TC);return e&&t}get clientGeometry(){return this.i3sOverrides.geometryOverrides}initialize(){this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const e=this.view.resourceController,t=e.memoryController;this.i3sOverrides=new He({view:this.view,layer:this.i3slayer,memoryController:t}),this._worker=new ue(Kt(e)),this.addResolvingPromise(this._worker.promise);const i=this.i3slayer.store;this._worker.setLegacySchema(this.uid,i.defaultGeometrySchema),ke(this.i3slayer),Be(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new se({layerView:this}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view._stage,this._collection=this._stage.renderView.componentObjectCollection,this.resetHighlights();const s=i.defaultGeometrySchema;if(this._isIntegratedMesh||!s)this._hasComponentData=!1;else{const e=s.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(s?.vertexAttributes.color??null)&&(null==this.i3slayer.cachedDrawingInfo||!this.i3slayer.cachedDrawingInfo.color),this._isIntegratedMesh||(this._edgeView=this._stage.renderer.ensureEdgeView());const r=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,(e=>this._deleteComponentObject(e)));this._memCache=r;const o=e=>null!=this._controller.index&&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 Ae({layerUid:this.layerUid,sublayerUid:this.sublayerUid,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:o}),this.updatingHandles.add((()=>this.layerUid),(e=>this._intersectionHandler.layerUid=e)),this.updatingHandles.add((()=>this.sublayerUid),(e=>this._intersectionHandler.sublayerUid=e)),this._elevationProvider=new we({layerView: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.contentVisible&&this.elevationInfo.mode!==kt.Absolute),((e,t)=>{e?this.handles.add(this.view.basemapTerrain.on("elevation-change",(({extent:e})=>this._ensureElevationTask().addExtent(e))),zt):t&&this.handles.remove(zt)}),g),this.updatingHandles.add((()=>this._usePBR),(e=>this._updatePBR(e)));const a=()=>{this._reloadAll(),this.clearMemCache()};this.updatingHandles.add((()=>this.rendererTextureUsage),a),this.updatingHandles.add((()=>this.uncompressedTextureDownsamplingEnabled),a),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.handles.add([p((()=>ot.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&&ot.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||ot.I3S_TREE_SHOW_TILES||(this._treeDebugger=d(this._treeDebugger))}),g),p((()=>ot.I3S_SHOW_MODIFICATIONS),(()=>this._showModifications()),g)]),this._cacheKeySuffix=qe(this.i3slayer.spatialReference,this.view.renderSpatialReference),this._idbCache.init().catch((e=>bt.warn(`Failed to initialize IndexedDB cache: ${e}`)))}destroy(){this._clearAddTasks(),this._elevationTask=d(this._elevationTask),this.i3sOverrides=d(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.layerChanged(),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._worker;e&&(e.destroyContext(this.uid).then((()=>e.destroy())),this._worker=null),this._removeAllNodeDataFromStage(),this._memCache=d(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=d(this._labeler),this._treeDebugger=d(this._treeDebugger),this._controller=d(this._controller),this._highlights.destroy(),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=d(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null)}_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(!(Ie(this.i3slayer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new ce({view:this.view,layer:this.i3slayer,collection:this._collection});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=pe().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=_e(this._layerClippingArea,this._modifications,t);fe({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)})),null!=s&&this._nodeId2MetaReloading.forEach((e=>s.push(e.node))),null!=s&&s.length>0&&(this.updateNodeModificationStatus(s),s.forAll((e=>{if(e.imModificationImpact!==Ve.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._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),!ot.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&&null!=t.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(null!=t&&null!=t.attributeInfo)return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);null!=i&&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),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}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&Ce.Basis)&&h(this.i3slayer.textureSetDefinitions,(e=>e.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 ct(_t(this._getGeometryParameters(i)))}_getObjectIdField(){return this.i3slayer.objectIdField||ie}_getGlobalIdField(){return this.i3slayer.associatedLayer?.globalIdField}_findGraphicNodeAndIndex(e){const t=st(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());let i=null;return l(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=st(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||null==i.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=Se(t,this._collection,s,Y(24)),o=this.view.renderSpatialReference,a=this.view.spatialReference;if(!G(r,o,0,r,a,0,8))return null;const n=K();return W(n,r,0,8),n}whenGraphicAttributes(e,t){return ze(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||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=De(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(null==r||null==r.data||s&&r.encoding!==s.encoding)}))??[];return 0===r.length?Promise.resolve(!1):i(r,s).then((i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0}))}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then((s=>null==s?null:s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(this.elevationInfo.mode===kt.Absolute&&(e.geometryObb=s.geometryObb),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(Vt)&&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 Ft(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=Ue(e.mbs,this.elevationOffset,h,c),_=nt([r.center.x,r.center.y,r.center.z],[r.extents.x,r.extents.y,r.extents.z],w(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));S(_.center,_.center,u),this.elevationInfo.mode===kt.Absolute&&(e.geometryObb=_),t.geometryData.componentOffsets=o,a&&(t.geometryData.featureIds=Array.from(a)),t.geometryData.anchorIds=n,t.geometryData.anchors=l;const m={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:d,globalTrafo:u,geometryObb:_,byteSize:Pt(d,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&Ht(e,m)){const t=null!=m.textureData?m.textureData.map((e=>Vt(e)?e:null)):null;this._idbCache.put(this._getCacheKey(e.id),{...m,textureData:t}).catch((t=>bt.warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`)))}return this._addCachedNodeData(e,m,i)}),i))))):Promise.reject()}getElevationRange(e){let t=1/0,i=-1/0;const s=U(this.view.renderCoordsHelper.spatialReference);return this._nodeId2Meta.forEach((r=>{if(null!=r&&null!=r.node.geometryObb){const o=r.node.geometryObb;if(lt(o,e)){const e=this._collection.getObjectTransform(r.objectHandle),o=this.view.renderCoordsHelper.getAltitude(e.position);for(let a=0;a<r.featureIds.length;a++){const e=this._collection.getComponentAabb(r.objectHandle,a,qt);if("local"===this.view.viewingMode)t=Math.min(t,o+e[2]),i=Math.max(i,o+e[5]);else{t=Math.min(t,o+e[2]);const r=Math.max(Math.abs(e[3]),Math.abs(e[0])),a=Math.max(Math.abs(e[4]),Math.abs(e[1])),n=o+e[5]+s.radius;i=Math.max(i,Math.sqrt(r*r+a*a+n*n)-s.radius)}}}}})),{min:t,max:i}}computeVisibilityObb(e){return Ke(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let g=0;g<s.length;++g)r[g]=this._getVertexBufferLayout(s[g],t.geometryDescriptor);const o=e.mbs,a=this.elevationOffset,n=this._controller.crsIndex,l=this._controller.crsVertex,d=this.view.renderSpatialReference,h=Ge(o,a,n),c=Ue(o,a,n,d),u=L(n,l),_=L(l,d);if(null==u||null==_)return Promise.resolve(null);const m={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,localOrigin:h,globalTrafo:c,mbs:o,obb:e.serviceObb,elevationOffset:a,needNormals:!this._isIntegratedMesh&&this._controller.isMeshPyramid,normalReferenceFrame:this.i3slayer.normalReferenceFrame||"none",indexToVertexProjector:u,vertexToRenderProjector:_};return this._worker.invoke(m,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===kt.Absolute&&(e.geometryObb=dt(this._collection.getComponentObb(t.objectHandle))),!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,ut.Visible),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==kt.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);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===Ce.Basis||e.encoding===Ce.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,v=this._materialParameters(m,g),I=l||new Uint32Array([0,p?p.length:f.byteLength/g[0].stride]),w={vertices:{data:f,count:f.byteLength/g[0].stride,layoutParameters:v.geometryParams},positionData:{positions:J(b.data),indices:Z(b.indices)},indices:p,componentOffsets:I},S=m.transformation?E(m.transformation):j();O(S,a,S);const A=x(V(),S),T=M(C(),S),D=this.view.renderSpatialReference,R=this.view.basemapTerrain.spatialReference,N=V(),F=[1,1,1];k(A,D,F,R)||bt.errorOnce("Unsupported coordinate system for IM overlay"),B(A,D,N,R);const P=_.createObject({toMapSpace:H(N[0],N[1],F[0],F[1]),geometry:w,obb:t.geometryObb,transform:{position:A,rotationScale:T}}),U=v.geometryParams.textureCoordinates===mt.Atlas,{textures:G,texturePromise:L}=this._initMaterialAndTextures(P,v.material,n,U);e.memory+=this._memEstimateGeometryAdded(P),e.memory+=G.reduce(((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0)),0);const q=!!v.material.hasParametersFromSource,z="blend"!==v.material.alphaMode&&v.material.metallicRoughness.baseColorFactor[3]>=1,K=new vt(e,h,P,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:q,isOpaque:z},G,c,u);s.meta=K,!this._hasTextures&&t.requiredTextures?.some((({usage:e})=>0!=(e&Me.ColorTextures)))&&(this._hasTextures=!0),this._hasData=!0,this._hasColors=this._hasColors||y,this._hasTextures=this._hasTextures||!!e.resources.texture,this.notifyChange("hasTexturesOrVertexColors");const W=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(K),L]).then((([t,s])=>(null!=t&&t.updateObjectVisibility(K.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,K),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(P,ut.Visible),null!=t&&t.updateObjectVisibility(K.objectHandle,!0).catch((e=>xt(e,this.i3slayer.title))),K.attributeInfo=i.attributeInfo;const s=K.cachedRendererVersion!==this._rendererVersion,r=W!==this.slicePlaneEnabled;this._updateElevationOffsets(K);const o=K.elevationOffsets;this._updateComponentData(K);const a=this._applyFiltersToNode(K);(s||null!=t&&(r||a||o))&&this._addOrUpdateEdgeRendering(K),null!=this._labeler&&this._addMetaToLabeler(this._labeler,K),this._visibleGeometryChanged(K,Et.ADD),this._highlights.objectCreated(K),this._updateMaterial(K),this._setNewNodeOpacity(K),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&&Lt(t.cachedEdgeMaterials,0)),this._nodeId2Meta.set(e,t)}_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===kt.Absolute)return void(e.elevationOffsets=null);const n=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const l=Bt,d=qt,h=a===kt.OnTheGround,c=this.view.renderCoordsHelper,u=e.featureIds.length,_=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const s=Y(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,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 xe(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!==kt.Absolute,s=!!t&&t!==e&&t.mode!==kt.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:Re(),s=t.some((e=>"uvRegion"===e.name)),r=t.some((e=>"normalCompressed"===e.name)),o=Nt(i);return{geometryParams:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s){const r=this._stage.renderView,o=i.map((e=>Ne(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,normals:e.hasNormals&&!this._isIntegratedMesh}}_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=Q();this._renderClippingArea=at(this.view.clippingArea,i,e)?i:null;const s=Q();this._layerClippingArea=at(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=null!=t.attributeInfo&&t.attributeInfo.attributeData;s.every((e=>e===n||d&&null!=d[e]))&&We(e,l,(e=>{o[n]=l[e];for(const i of s)i!==n&&(o[i]=d?$e(d[i],e):null);try{return i.testFeature(a)}catch(t){return r(t),!1}}))}_boundingRectNodeTest(e,t){return q(e.node.mbs,this._controller.crsIndex,Rt,this.view.renderSpatialReference),Qe(t,Rt)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,jt),$(jt,wt),X(i,wt)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(r===Xe.INSIDE)return;if(r===Xe.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(St,i,t.objectHandle);We(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){Lt(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=0===t.getComponentCount(e.objectHandle).invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!i;if(this._updateCachedFilteredIds(e),e.filteredIds===e.featureIds)return!i;const s=this._computeFilteredComponentIndices(e);return t.setAllComponentVisibilities(e.objectHandle,s),!0}_updateCachedFilteredIds(e){null!=e.filteredIds&&e.appliedFilters===this._filters||(e.filteredIds=this._computeFilteredIds(e),e.appliedFilters=this._filters)}_computeFilteredIds(e){const t=e.featureIds.slice();for(const i of this._filters)if(i(t,e),0===t.length)break;return t.length===e.featureIds.length?e.featureIds:t}_computeFilteredComponentIndices(e){const t=new Array,i=e.filteredIds;return 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=d(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,ut.Hidden),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===Pe.Hole))}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){const i=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,i)}const i=this._nodeId2MetaReloading.get(e);i&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,i))}_invalidateAllSymbols(){this._rendererVersion=Ye(this._rendererVersion,1),this._controller&&this._controller.requestUpdate()}_getInvalidRendererVersion(){return Ye(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=Ye(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(P(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];this._stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(t,t,this.layerId,this.layerUid+"_"+this.sublayerId,this.layerPopupEnabledAndHasTemplate,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&&e.getSymbol(t,{arcade:this._arcade});if(!(i instanceof de))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=Je(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:rt.Multiply,edgeMaterial:null},h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=pt.OPAQUE,m=Ze,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]]=$e(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&&r.material){const e=r.material;h=null==h||null==f?ve(h,f,e.color,e.alpha,yt,Tt):ve(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&&r.material?r.material.colorMixMode:rt.Multiply,d.edgeMaterial=r?r.edgeMaterial:null,null!=this._symbologyOverride&&(d.color=h,this._symbologyOverride(t,d),h=d.color),null!=d.edgeMaterial){const t=h[3]<=0?pt.INVISIBLE:h[3]>=1&&(e.material.isOpaque||d.colorMixMode===rt.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]=Ze;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||Lt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some((e=>e!==Ze)),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map(((t,o)=>e.featureIds[o]!==i[s]?Ze:(r=r||t!==Ze,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)),Lt(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._isIntegratedMesh&&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 0===this.i3sOverrides._geometryChangedObjectIds.size?e:(t,i,s)=>s.node.index>=0&&this.i3sOverrides._geometryChangedObjectIds.has(t)?me.CONTINUE:e(t,i,s)}_forAllFeatures(e,t,i){l(this._nodeId2Meta,(s=>{if(null==s)return!1;if(null!=t){switch(t(s)){case me.EXIT:return!0;case me.SKIP:return!1}}let r=me.CONTINUE;switch(i){case ge.ALL:r=this._forAllFeaturesOfNode(s,e);break;case ge.VISIBLE_ONLY:r=this._forAllVisibleFeaturesOfNode(s,e);break;case ge.QUERYABLE:r=this._forAllQueryableFeaturesOfNode(s,e)}return r===me.EXIT}))}_forAllFeaturesOfNode(e,t){let i=me.CONTINUE;const s=e.featureIds;for(let r=0;r<s.length;r++)if(i=t(s[r],r,e),i===me.EXIT)return i;return i}_forAllVisibleFeaturesOfNode(e,t){let i=me.CONTINUE;const s=e.featureIds;return this._collection.forEachVisibleComponent(e.objectHandle,(r=>(i=t(s[r],r,e),i===me.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===Xe.OUTSIDE)return me.CONTINUE;if(s===Xe.INSIDE)return this._forAllFeaturesOfNode(e,i);const r=me.CONTINUE,o=e.featureIds,a=e.objectHandle,n=et(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===me.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]=$e(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e){const t=this._highlights;if("number"==typeof e||e instanceof i?e=[e]:e instanceof a&&(e=e.toArray()),Array.isArray(e)&&e.length>0){if(e[0]instanceof i){const i=e,s=this.i3slayer.fieldsIndex,r=this._getObjectIdField(),o=i.map((e=>st(s,e.attributes,r))),{set:a,handle:n}=t.acquireSet();return t.setFeatureIds(a,o),n}if("number"==typeof e[0]){const i=e,{set:s,handle:r}=t.acquireSet();return t.setFeatureIds(s,i),r}}return Gt}resetHighlights(){d(this._highlights),this._highlights=new Oe({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,ge.ALL),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)})}_visibleGeometryChanged(e,t){this._elevationProvider&&(this._elevationProvider.objectChanged(e.node),null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=f((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))),this._updateSnappingSources(e,t))}get performanceInfo(){const e={displayedNumberOfFeatures:0,maximumNumberOfFeatures:0,totalNumberOfFeatures:0,core:null,index:0,nodes:this._nodeId2Meta.size,"Total GPU Memory Estimate":(this._gpuMemoryEstimate/1048576).toFixed(1)+"MB","Geometry Memory Estimate":(this._geoMemoryEstimate/1048576).toFixed(1)+"MB","Texture Memory Estimate":(this._texMemoryEstimate/1048576).toFixed(1)+"MB","Unloaded Memory Estimate":(this.unloadedMemory/1048576).toFixed(1)+"MB"};return null!=this._memCache&&(e.MemCache=Math.round(100*this._memCache.hitRate)+"% hit"),this._controller&&(this._idbCacheEnabled&&(e.IDBCache=Math.round(100*this._idbCache.getHitRate())+"% hit"),this._controller.updateStats(e)),e}get test(){const e=this;return{controller:this._controller,labeler:this._labeler,get visibleObjectIds(){const t=[];return e._forAllFeatures((e=>(t.push(e),me.CONTINUE)),null,ge.VISIBLE_ONLY),t.sort(((e,t)=>e-t)),t},get numNodes(){return e._nodeId2Meta.size},get loadedNodes(){return Array.from(e._nodeId2Meta.keys()).sort(((e,t)=>e-t))}}}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return 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;Lt(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(null!=s){const t={context:i,buffer:s.buffer};be(t);const r=new Float64Array(s.buffer);e.forAll(((e,t)=>{const i=r[t],s=ye(i);e.imModificationImpact=s,s!==Ve.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);null!=s&&e.add(i,s)})),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||this.elevationInfo.mode===kt.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,N(n,n,t)),F(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(ht)],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,"_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=z(),wt=Q(),St=Q(),At=nt(),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 Ft(e){return"geometryData"in e}function Vt(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 null;const t=10*e.length,i=new Float64Array(t);return e.forAll(((e,t)=>{let s=e.serviceObb;null==s&&(s=At,R(s.center,e.mbs),s.halfSize[0]=s.halfSize[1]=s.halfSize[2]=e.mbs[3]);const r=10*t;i[r]=s.center[0],i[r+1]=s.center[1],i[r+2]=s.center[2],i[r+3]=s.halfSize[0],i[r+4]=s.halfSize[1],i[r+5]=s.halfSize[2],i[r+6]=s.quaternion[0],i[r+7]=s.quaternion[1],i[r+8]=s.quaternion[2],i[r+9]=s.quaternion[3]})),i}const Gt={remove(){},pause(){},resume(){}};function Lt(e,t){e.forEach((e=>e.opacity=t))}var kt;!function(e){e[e.Absolute=0]="Absolute",e[e.RelativeToGround=1]="RelativeToGround",e[e.OnTheGround=2]="OnTheGround"}(kt||(kt={}));const Bt=V(),qt=z(),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{kt as ElevationMode,Ot as I3SMeshView3D};
|
|
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 has from"../../../core/has.js";import n from"../../../core/Logger.js";import{someMap as l}from"../../../core/MapUtils.js";import{destroyMaybe as d,applySome 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"../../../core/accessorSupport/ensureType.js";import{subclass as I}from"../../../core/accessorSupport/decorators/subclass.js";import{f as M}from"../../../chunks/mat3.js";import{c as C}from"../../../chunks/mat3f64.js";import{m as O,B as x}from"../../../chunks/mat4.js";import{b as E,c as j}from"../../../chunks/mat4f64.js";import{f as w}from"../../../chunks/quatf64.js";import{m as S,s as A,a as T,t as D,c as R,g as N,b as F}from"../../../chunks/vec3.js";import{c as V}from"../../../chunks/vec3f64.js";import{s as P}from"../../../chunks/vec4.js";import{f as H}from"../../../chunks/vec4f64.js";import{getReferenceEllipsoid as U}from"../../../geometry/ellipsoidUtils.js";import{projectBuffer as G,getProjectorName as L,localLinearScaleFactors as k,projectVectorToVector as B,projectBoundingSphere as q}from"../../../geometry/projection.js";import{create as z,empty as K,expandWithBuffer as W,toRect as $}from"../../../geometry/support/aaBoundingBox.js";import{create as Q,intersects as X}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as Y}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as J}from"../../../geometry/support/FloatArray.js";import{compactIndices as Z}from"../../../geometry/support/Indices.js";import{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 de from"../../../symbols/Symbol3D.js";import{getMetersPerUnit as he}from"../../../symbols/support/unitConversionUtils.js";import ce from"./I3SMeshViewLabeler.js";import{I3SMeshWorkerHandle as ue,toWasmModification as _e}from"./I3SMeshWorkerHandle.js";import{ForAllFeaturesReturnType as me,ForAllFeaturesMode as ge}from"./II3SMeshView3D.js";import{initialize as pe,setModificationsSync as fe,filterObbsForModificationsSync as be,interpretObbModificationResults as ye}from"./SceneLayerWorker.js";import{overrideColor as ve}from"./graphics/graphicUtils.js";import{areLabelsVisible as Ie}from"./graphics/Labeler.js";import{TextureUsage as Me,TextureEncoding as Ce}from"./i3s/enums.js";import Oe from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as xe}from"./i3s/I3SAsyncElevationUpdater.js";import{I3SCrossfadeHelper as Ee,NodeCrossfadeMetaData as je}from"./i3s/I3SCrossfadeHelper.js";import we from"./i3s/I3SElevationProvider.js";import{boundingBoxCornerPoints as Se}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Ae}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Te,selectEncoding as De,defaultMaterial as Re,createTexture as Ne,configureMaterial as Fe}from"./i3s/I3SMaterialUtil.js";import{NodeIMModificationImpact as Ve,NodeState as Pe}from"./i3s/I3SNode.js";import{I3SOverrides as He}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as Ue,getLocalOrigin as Ge}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as Le,checkSceneLayerValid as ke,checkSceneLayerCompatibleWithView as Be,getCacheKeySuffix as qe,whenGraphicAttributes as ze,computeVisibilityObb as Ke,filterInPlace as We,getCachedAttributeValue as $e,intersectBoundingRectWithMbs as Qe,MbsIntersectResult as Xe,addWraparound as Ye,getSymbolInfo as Je,transparentEdgeMaterial as Ze,getClipRect as et}from"./i3s/I3SUtil.js";import{IDBCache as tt}from"./i3s/IDBCache.js";import{IDBMockCache as it}from"./i3s/IDBMockCache.js";import{attributeLookup as st}from"./support/attributeUtils.js";import{ColorMixModeEnum as rt}from"./support/symbolColorUtils.js";import ot from"../support/debugFlags.js";import{toBoundingRect as at}from"../support/extentUtils.js";import{create as nt,intersectSphere as lt,clone as dt}from"../support/orientedBoundingBox.js";import{updatingProgress as ht}from"../support/updatingProperties.js";import{glLayout as ct}from"../support/buffer/glUtil.js";import{State as ut}from"../webgl-engine/collections/Component/ComponentObject.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=n.getLogger(ft),yt=[1,1,1,1];class vt extends je{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=21,Ct=100*o.MEGABYTES,Ot=t=>{let o=class extends t{constructor(...e){super(e),this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._idbCache=has("enable-feature:idb-mock-cache")?new it:new tt("esri-scenelayer-cache","geometries"),this._hasComponentData=!1,this._hasVertexColors=!1,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 Ee(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 Le(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?Me.AllTexturesPBR:Me.AllTextures:this._usePBR||this._hasLoadedPBRTextures?Me.GeometryTexturesPBR:Me.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=he(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{mode:kt.Absolute,offset:0};const t=y(this.i3slayer.spatialReference),i=he(e.unit),s=(e.offset??0)*i/t;switch(e.mode){case"absolute-height":return{mode:kt.Absolute,offset:s};case"relative-to-ground":return{mode:kt.RelativeToGround,offset:s};case"on-the-ground":return{mode:kt.OnTheGround,offset:0};default:return{mode:kt.Absolute,offset:0}}}get supportedTextureEncodings(){return Te(this.view._stage.renderView.capabilities)}get uncompressedTextureDownsamplingEnabled(){const e=this.view?.qualitySettings.sceneService.uncompressedTextureDownsamplingEnabled,t=0==(this.supportedTextureEncodings&Ce.DDS_S3TC);return e&&t}get clientGeometry(){return this.i3sOverrides.geometryOverrides}initialize(){this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const e=this.view.resourceController,t=e.memoryController;this.i3sOverrides=new He({view:this.view,layer:this.i3slayer,memoryController:t}),this._worker=new ue(Kt(e)),this.addResolvingPromise(this._worker.promise);const i=this.i3slayer.store;this._worker.setLegacySchema(this.uid,i.defaultGeometrySchema),ke(this.i3slayer),Be(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 s=i.defaultGeometrySchema;if(this._isIntegratedMesh||!s)this._hasComponentData=!1;else{const e=s.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(s?.vertexAttributes.color??null)&&(null==this.i3slayer.cachedDrawingInfo||!this.i3slayer.cachedDrawingInfo.color),this._isIntegratedMesh||(this._edgeView=this._stage.renderer.ensureEdgeView());const r=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,(e=>this._deleteComponentObject(e)));this._memCache=r;const o=e=>null!=this._controller.index&&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 Ae({layerUid:this.layerUid,sublayerUid:this.sublayerUid,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:o}),this.updatingHandles.add((()=>this.layerUid),(e=>this._intersectionHandler.layerUid=e)),this.updatingHandles.add((()=>this.sublayerUid),(e=>this._intersectionHandler.sublayerUid=e)),this._elevationProvider=new we({layerView: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.contentVisible&&this.elevationInfo.mode!==kt.Absolute),((e,t)=>{e?this.handles.add(this.view.basemapTerrain.on("elevation-change",(({extent:e})=>this._ensureElevationTask().addExtent(e))),zt):t&&this.handles.remove(zt)}),g),this.updatingHandles.add((()=>this._usePBR),(e=>this._updatePBR(e)));const a=()=>{this._reloadAll(),this.clearMemCache()};this.updatingHandles.add((()=>this.rendererTextureUsage),a),this.updatingHandles.add((()=>this.uncompressedTextureDownsamplingEnabled),a),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.handles.add([p((()=>ot.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&&ot.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||ot.I3S_TREE_SHOW_TILES||(this._treeDebugger=d(this._treeDebugger))}),g),p((()=>ot.I3S_SHOW_MODIFICATIONS),(()=>this._showModifications()),g)]),this._cacheKeySuffix=qe(this.i3slayer.spatialReference,this.view.renderSpatialReference),this._idbCache.init().catch((e=>bt.warn(`Failed to initialize IndexedDB cache: ${e}`)))}destroy(){this._clearAddTasks(),this._elevationTask=d(this._elevationTask),this.i3sOverrides=d(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.layerChanged(),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._worker;e&&(e.destroyContext(this.uid).then((()=>e.destroy())),this._worker=null),this._removeAllNodeDataFromStage(),this._memCache=d(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=d(this._labeler),this._treeDebugger=d(this._treeDebugger),this._controller=d(this._controller),this._highlights.destroy(),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=d(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null)}_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(!(Ie(this.i3slayer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new ce({view:this.view,layer:this.i3slayer,collection:this._collection});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=pe().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=_e(this._layerClippingArea,this._modifications,t);fe({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)})),null!=s&&this._nodeId2MetaReloading.forEach((e=>s.push(e.node))),null!=s&&s.length>0&&(this.updateNodeModificationStatus(s),s.forAll((e=>{if(e.imModificationImpact!==Ve.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._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),!ot.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&&null!=t.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(null!=t&&null!=t.attributeInfo)return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);null!=i&&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),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}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&Ce.Basis)&&h(this.i3slayer.textureSetDefinitions,(e=>e.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 ct(_t(this._getGeometryParameters(i)))}_getObjectIdField(){return this.i3slayer.objectIdField||ie}_getGlobalIdField(){return this.i3slayer.associatedLayer?.globalIdField}_findGraphicNodeAndIndex(e){const t=st(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());let i=null;return l(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=st(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||null==i.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=Se(t,this._collection,s,Y(24)),o=this.view.renderSpatialReference,a=this.view.spatialReference;if(!G(r,o,0,r,a,0,8))return null;const n=K();return W(n,r,0,8),n}whenGraphicAttributes(e,t){return ze(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||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=De(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(null==r||null==r.data||s&&r.encoding!==s.encoding)}))??[];return 0===r.length?Promise.resolve(!1):i(r,s).then((i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0}))}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then((s=>null==s?null:s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(this.elevationInfo.mode===kt.Absolute&&(e.geometryObb=s.geometryObb),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(Vt)&&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 Ft(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=Ue(e.mbs,this.elevationOffset,h,c),_=nt([r.center.x,r.center.y,r.center.z],[r.extents.x,r.extents.y,r.extents.z],w(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));S(_.center,_.center,u),this.elevationInfo.mode===kt.Absolute&&(e.geometryObb=_),t.geometryData.componentOffsets=o,a&&(t.geometryData.featureIds=Array.from(a)),t.geometryData.anchorIds=n,t.geometryData.anchors=l;const m={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:d,globalTrafo:u,geometryObb:_,byteSize:Pt(d,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&Ht(e,m)){const t=null!=m.textureData?m.textureData.map((e=>Vt(e)?e:null)):null;this._idbCache.put(this._getCacheKey(e.id),{...m,textureData:t}).catch((t=>bt.warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`)))}return this._addCachedNodeData(e,m,i)}),i))))):Promise.reject()}getElevationRange(e){let t=1/0,i=-1/0;const s=U(this.view.renderCoordsHelper.spatialReference);return this._nodeId2Meta.forEach((r=>{if(null!=r&&null!=r.node.geometryObb){const o=r.node.geometryObb;if(lt(o,e)){const e=this._collection.getObjectTransform(r.objectHandle),o=this.view.renderCoordsHelper.getAltitude(e.position);for(let a=0;a<r.featureIds.length;a++){const e=this._collection.getComponentAabb(r.objectHandle,a,qt);if("local"===this.view.viewingMode)t=Math.min(t,o+e[2]),i=Math.max(i,o+e[5]);else{t=Math.min(t,o+e[2]);const r=Math.max(Math.abs(e[3]),Math.abs(e[0])),a=Math.max(Math.abs(e[4]),Math.abs(e[1])),n=o+e[5]+s.radius;i=Math.max(i,Math.sqrt(r*r+a*a+n*n)-s.radius)}}}}})),{min:t,max:i}}computeVisibilityObb(e){return Ke(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let g=0;g<s.length;++g)r[g]=this._getVertexBufferLayout(s[g],t.geometryDescriptor);const o=e.mbs,a=this.elevationOffset,n=this._controller.crsIndex,l=this._controller.crsVertex,d=this.view.renderSpatialReference,h=Ge(o,a,n),c=Ue(o,a,n,d),u=L(n,l),_=L(l,d);if(null==u||null==_)return Promise.resolve(null);const m={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,localOrigin:h,globalTrafo:c,mbs:o,obb:e.serviceObb,elevationOffset:a,needNormals:!this._isIntegratedMesh&&this._controller.isMeshPyramid,normalReferenceFrame:this.i3slayer.normalReferenceFrame||"none",indexToVertexProjector:u,vertexToRenderProjector:_};return this._worker.invoke(m,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===kt.Absolute&&(e.geometryObb=dt(this._collection.getComponentObb(t.objectHandle))),!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,ut.Visible),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==kt.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);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===Ce.Basis||e.encoding===Ce.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,v=this._materialParameters(m,g),I=l||new Uint32Array([0,p?p.length:f.byteLength/g[0].stride]),w={vertices:{data:f,count:f.byteLength/g[0].stride,layoutParameters:v.geometryParams},positionData:{positions:J(b.data),indices:Z(b.indices)},indices:p,componentOffsets:I},S=m.transformation?E(m.transformation):j();O(S,a,S);const A=x(V(),S),T=M(C(),S),D=this.view.renderSpatialReference,R=this.view.basemapTerrain.spatialReference,N=V(),F=[1,1,1];k(A,D,F,R)||bt.errorOnce("Unsupported coordinate system for IM overlay"),B(A,D,N,R);const P=_.createObject({toMapSpace:H(N[0],N[1],F[0],F[1]),geometry:w,obb:t.geometryObb,transform:{position:A,rotationScale:T}}),U=v.geometryParams.textureCoordinates===mt.Atlas,{textures:G,texturePromise:L}=this._initMaterialAndTextures(P,v.material,n,U);e.memory+=this._memEstimateGeometryAdded(P),e.memory+=G.reduce(((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0)),0);const q=!!v.material.hasParametersFromSource,z="blend"!==v.material.alphaMode&&v.material.metallicRoughness.baseColorFactor[3]>=1,K=new vt(e,h,P,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:q,isOpaque:z},G,c,u);s.meta=K,!this._hasTextures&&t.requiredTextures?.some((({usage:e})=>0!=(e&Me.ColorTextures)))&&(this._hasTextures=!0),this._hasData=!0,this._hasColors=this._hasColors||y,this._hasTextures=this._hasTextures||!!e.resources.texture,this.notifyChange("hasTexturesOrVertexColors");const W=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(K),L]).then((([t,s])=>(null!=t&&t.updateObjectVisibility(K.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,K),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(P,ut.Visible),null!=t&&t.updateObjectVisibility(K.objectHandle,!0).catch((e=>xt(e,this.i3slayer.title))),K.attributeInfo=i.attributeInfo;const s=K.cachedRendererVersion!==this._rendererVersion,r=W!==this.slicePlaneEnabled;this._updateElevationOffsets(K);const o=K.elevationOffsets;this._updateComponentData(K);const a=this._applyFiltersToNode(K);(s||null!=t&&(r||a||o))&&this._addOrUpdateEdgeRendering(K),null!=this._labeler&&this._addMetaToLabeler(this._labeler,K),this._visibleGeometryChanged(K,Et.ADD),this._highlights.objectCreated(K),this._updateMaterial(K),this._setNewNodeOpacity(K),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&&Lt(t.cachedEdgeMaterials,0)),this._nodeId2Meta.set(e,t)}_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===kt.Absolute)return void(e.elevationOffsets=null);const n=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const l=Bt,d=qt,h=a===kt.OnTheGround,c=this.view.renderCoordsHelper,u=e.featureIds.length,_=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const s=Y(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,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 xe(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!==kt.Absolute,s=!!t&&t!==e&&t.mode!==kt.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:Re(),s=t.some((e=>"uvRegion"===e.name)),r=t.some((e=>"normalCompressed"===e.name)),o=Nt(i);return{geometryParams:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s){const r=this._stage.renderView,o=i.map((e=>Ne(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,normals:e.hasNormals&&!this._isIntegratedMesh}}_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=Q();this._renderClippingArea=at(this.view.clippingArea,i,e)?i:null;const s=Q();this._layerClippingArea=at(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=null!=t.attributeInfo&&t.attributeInfo.attributeData;s.every((e=>e===n||d&&null!=d[e]))&&We(e,l,(e=>{o[n]=l[e];for(const i of s)i!==n&&(o[i]=d?$e(d[i],e):null);try{return i.testFeature(a)}catch(t){return r(t),!1}}))}_boundingRectNodeTest(e,t){return q(e.node.mbs,this._controller.crsIndex,Rt,this.view.renderSpatialReference),Qe(t,Rt)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,jt),$(jt,wt),X(i,wt)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(r===Xe.INSIDE)return;if(r===Xe.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(St,i,t.objectHandle);We(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){Lt(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=0===t.getComponentCount(e.objectHandle).invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!i;if(this._updateCachedFilteredIds(e),e.filteredIds===e.featureIds)return!i;const s=this._computeFilteredComponentIndices(e);return t.setAllComponentVisibilities(e.objectHandle,s),!0}_updateCachedFilteredIds(e){null!=e.filteredIds&&e.appliedFilters===this._filters||(e.filteredIds=this._computeFilteredIds(e),e.appliedFilters=this._filters)}_computeFilteredIds(e){const t=e.featureIds.slice();for(const i of this._filters)if(i(t,e),0===t.length)break;return t.length===e.featureIds.length?e.featureIds:t}_computeFilteredComponentIndices(e){const t=new Array,i=e.filteredIds;return 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=d(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,ut.Hidden),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===Pe.Hole))}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){const i=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,i)}const i=this._nodeId2MetaReloading.get(e);i&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,i))}_invalidateAllSymbols(){this._rendererVersion=Ye(this._rendererVersion,1),this._controller&&this._controller.requestUpdate()}_getInvalidRendererVersion(){return Ye(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=Ye(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(P(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];this._stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(t,t,this.layerId,this.layerUid+"_"+this.sublayerId,this.layerPopupEnabledAndHasTemplate,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&&e.getSymbol(t,{arcade:this._arcade});if(!(i instanceof de))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=Je(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:rt.Multiply,edgeMaterial:null},h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=pt.OPAQUE,m=Ze,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]]=$e(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&&r.material){const e=r.material;h=null==h||null==f?ve(h,f,e.color,e.alpha,yt,Tt):ve(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&&r.material?r.material.colorMixMode:rt.Multiply,d.edgeMaterial=r?r.edgeMaterial:null,null!=this._symbologyOverride&&(d.color=h,this._symbologyOverride(t,d),h=d.color),null!=d.edgeMaterial){const t=h[3]<=0?pt.INVISIBLE:h[3]>=1&&(e.material.isOpaque||d.colorMixMode===rt.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]=Ze;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||Lt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some((e=>e!==Ze)),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map(((t,o)=>e.featureIds[o]!==i[s]?Ze:(r=r||t!==Ze,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)),Lt(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._isIntegratedMesh&&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?e:(t,i,s)=>s.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?me.CONTINUE:e(t,i,s)}_forAllFeatures(e,t,i){l(this._nodeId2Meta,(s=>{if(null==s)return!1;if(null!=t){switch(t(s)){case me.EXIT:return!0;case me.SKIP:return!1}}let r=me.CONTINUE;switch(i){case ge.ALL:r=this._forAllFeaturesOfNode(s,e);break;case ge.VISIBLE_ONLY:r=this._forAllVisibleFeaturesOfNode(s,e);break;case ge.QUERYABLE:r=this._forAllQueryableFeaturesOfNode(s,e)}return r===me.EXIT}))}_forAllFeaturesOfNode(e,t){let i=me.CONTINUE;const s=e.featureIds;for(let r=0;r<s.length;r++)if(i=t(s[r],r,e),i===me.EXIT)return i;return i}_forAllVisibleFeaturesOfNode(e,t){let i=me.CONTINUE;const s=e.featureIds;return this._collection.forEachVisibleComponent(e.objectHandle,(r=>(i=t(s[r],r,e),i===me.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===Xe.OUTSIDE)return me.CONTINUE;if(s===Xe.INSIDE)return this._forAllFeaturesOfNode(e,i);const r=me.CONTINUE,o=e.featureIds,a=e.objectHandle,n=et(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===me.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]=$e(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e){const t=this._highlights;if("number"==typeof e||e instanceof i?e=[e]:e instanceof a&&(e=e.toArray()),Array.isArray(e)&&e.length>0){if(e[0]instanceof i){const i=e,s=this.i3slayer.fieldsIndex,r=this._getObjectIdField(),o=i.map((e=>st(s,e.attributes,r))),{set:a,handle:n}=t.acquireSet();return t.setFeatureIds(a,o),n}if("number"==typeof e[0]){const i=e,{set:s,handle:r}=t.acquireSet();return t.setFeatureIds(s,i),r}}return Gt}resetHighlights(){d(this._highlights),this._highlights=new Oe({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,ge.ALL),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)})}_visibleGeometryChanged(e,t){this._elevationProvider&&(this._elevationProvider.objectChanged(e.node),null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=f((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))),this._updateSnappingSources(e,t))}get performanceInfo(){const e={displayedNumberOfFeatures:0,maximumNumberOfFeatures:0,totalNumberOfFeatures:0,core:null,index:0,nodes:this._nodeId2Meta.size,"Total GPU Memory Estimate":(this._gpuMemoryEstimate/1048576).toFixed(1)+"MB","Geometry Memory Estimate":(this._geoMemoryEstimate/1048576).toFixed(1)+"MB","Texture Memory Estimate":(this._texMemoryEstimate/1048576).toFixed(1)+"MB","Unloaded Memory Estimate":(this.unloadedMemory/1048576).toFixed(1)+"MB"};return null!=this._memCache&&(e.MemCache=Math.round(100*this._memCache.hitRate)+"% hit"),this._controller&&(this._idbCacheEnabled&&(e.IDBCache=Math.round(100*this._idbCache.getHitRate())+"% hit"),this._controller.updateStats(e)),e}get test(){const e=this;return{controller:this._controller,labeler:this._labeler,get visibleObjectIds(){const t=[];return e._forAllFeatures((e=>(t.push(e),me.CONTINUE)),null,ge.VISIBLE_ONLY),t.sort(((e,t)=>e-t)),t},get numNodes(){return e._nodeId2Meta.size},get loadedNodes(){return Array.from(e._nodeId2Meta.keys()).sort(((e,t)=>e-t))}}}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return 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;Lt(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(null!=s){const t={context:i,buffer:s.buffer};be(t);const r=new Float64Array(s.buffer);e.forAll(((e,t)=>{const i=r[t],s=ye(i);e.imModificationImpact=s,s!==Ve.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);null!=s&&e.add(i,s)})),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||this.elevationInfo.mode===kt.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,N(n,n,t)),F(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(ht)],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,"_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=z(),wt=Q(),St=Q(),At=nt(),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 Ft(e){return"geometryData"in e}function Vt(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 null;const t=10*e.length,i=new Float64Array(t);return e.forAll(((e,t)=>{let s=e.serviceObb;null==s&&(s=At,R(s.center,e.mbs),s.halfSize[0]=s.halfSize[1]=s.halfSize[2]=e.mbs[3]);const r=10*t;i[r]=s.center[0],i[r+1]=s.center[1],i[r+2]=s.center[2],i[r+3]=s.halfSize[0],i[r+4]=s.halfSize[1],i[r+5]=s.halfSize[2],i[r+6]=s.quaternion[0],i[r+7]=s.quaternion[1],i[r+8]=s.quaternion[2],i[r+9]=s.quaternion[3]})),i}const Gt={remove(){},pause(){},resume(){}};function Lt(e,t){e.forEach((e=>e.opacity=t))}var kt;!function(e){e[e.Absolute=0]="Absolute",e[e.RelativeToGround=1]="RelativeToGround",e[e.OnTheGround=2]="OnTheGround"}(kt||(kt={}));const Bt=V(),qt=z(),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{kt as ElevationMode,Ot as I3SMeshView3D};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import s from"../../../core/Logger.js";import{unwrapOrThrow as e}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{WorkerHandle as t}from"../../../core/workers/WorkerHandle.js";import{canProjectWithoutEngine as r,projectVectorToVector as p}from"../../../geometry/projection.js";import{ModificationType as h}from"../../../libs/i3s/enums.js";class i extends t{constructor(s){super("SceneLayerWorker","process",{process:s=>[s.geometryBuffer]},s,{hasInitialize:!0})}setModifications(s,e,o,t){const r={context:s,modifications:a(e,o,t),isGeodetic:t.isGeographic};this.broadcast(r,"setModifications")}setLegacySchema(s,e){const o=JSON.stringify(e);this.broadcast({context:s,jsonSchema:o},"setLegacySchema")}destroyContext(s){return this.broadcast(s,"destroyContext")}}const u=new o({deallocator:null}),n=[0,0,0];function a(o,t,i){u.clear();let a=1/0,c=1/0,
|
|
5
|
+
import s from"../../../core/Logger.js";import{unwrapOrThrow as e}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{WorkerHandle as t}from"../../../core/workers/WorkerHandle.js";import{canProjectWithoutEngine as r,projectVectorToVector as p}from"../../../geometry/projection.js";import{ModificationType as h}from"../../../libs/i3s/enums.js";class i extends t{constructor(s){super("SceneLayerWorker","process",{process:s=>[s.geometryBuffer],project:s=>[s.position.buffer]},s,{hasInitialize:!0})}setModifications(s,e,o,t){const r={context:s,modifications:a(e,o,t),isGeodetic:t.isGeographic};this.broadcast(r,"setModifications")}setLegacySchema(s,e){const o=JSON.stringify(e);this.broadcast({context:s,jsonSchema:o},"setLegacySchema")}destroyContext(s){return this.broadcast(s,"destroyContext")}project(s,e){return this.invokeMethod("project",s,e)}}const u=new o({deallocator:null}),n=[0,0,0];function a(o,t,i){u.clear();let a=1/0,c=1/0,f=-1/0,l=-1/0,m=!1;for(const g of t){const o="clip"===g.type?h.Inside:"mask"===g.type?h.Outside:h.Replace,t=e(g.geometry,"modification.geometry");let d=s=>s;if(t.spatialReference){if(!r(t.spatialReference,i)){s.getLogger("esri.views.3d.layers.I3SMeshWorkerHandle").warn("Can't project modification polygon into layer spatial reference, ignoring modification");continue}d=s=>(p(s,t.spatialReference,n,i),n)}else t.hasZ||(n[2]=0,d=s=>(n[0]=s[0],n[1]=s[1],n));m=m||o===h.Outside,u.push(o),u.push(t.rings.length);for(const s of t.rings){u.push(s.length);for(const e of s){const s=d(e);u.push(s[0]),u.push(s[1]),u.push(s[2]),a=Math.min(a,s[0]),c=Math.min(c,s[1]),f=Math.max(f,s[0]),l=Math.max(l,s[1])}}}if(null!=o)if(m){const s=1e-4;u.push(h.Inside),u.push(2),u.push(4),u.push(a-s),u.push(c-s),u.push(0),u.push(f+s),u.push(c-s),u.push(0),u.push(f+s),u.push(l+s),u.push(0),u.push(a-s),u.push(l+s),u.push(0),u.push(4),u.push(o[0]),u.push(o[1]),u.push(0),u.push(o[2]),u.push(o[1]),u.push(0),u.push(o[2]),u.push(o[3]),u.push(0),u.push(o[0]),u.push(o[3]),u.push(0)}else u.push(h.Outside),u.push(1),u.push(4),u.push(o[0]),u.push(o[1]),u.push(0),u.push(o[2]),u.push(o[1]),u.push(0),u.push(o[2]),u.push(o[3]),u.push(0),u.push(o[0]),u.push(o[3]),u.push(0);u.push(h.Finished);const d=new Float64Array(u.length);for(let s=0;s<u.length;++s)d[s]=u.at(s);return d}export{i as I3SMeshWorkerHandle,a as toWasmModification};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{IndexType as
|
|
5
|
+
import e from"../../../geometry/SpatialReference.js";import{toFloat64Array as t}from"../../../geometry/support/DoubleArray.js";import r from"../../../geometry/support/MeshGeoreferencedRelativeVertexSpace.js";import o from"../../../geometry/support/MeshGeoreferencedVertexSpace.js";import n from"../../../geometry/support/MeshLocalVertexSpace.js";import{IndexType as s}from"../../../libs/i3s/enums.js";import{get as i}from"../../../libs/i3s/I3SModule.js";import{NodeIMModificationImpact as f}from"./i3s/I3SNode.js";async function a(e){await _();const t=[e.geometryBuffer];return{result:g(e,t),transferList:t}}async function l(e){await _();const t=[e.geometryBuffer],{geometryBuffer:r}=e,o=r.byteLength,n=b._malloc(o),s=new Uint8Array(b.HEAPU8.buffer,n,o);s.set(new Uint8Array(r));const i=b.dracoDecompressPointCloudData(n,s.byteLength);if(b._free(n),i.error.length>0)throw new Error(`i3s.wasm: ${i.error}`);const f=i.featureIds?.length>0?i.featureIds.slice():null,a=i.positions.slice();return f&&t.push(f.buffer),t.push(a.buffer),{result:{positions:a,featureIds:f},transferList:t}}async function c(e){await _(),w(e);const t={buffer:e.buffer};return{result:t,transferList:[t.buffer]}}async function u(e){await _(),h(e)}async function m(e){await _(),b.setLegacySchema(e.context,e.jsonSchema)}async function y(s){const{localMatrix:i,origin:f,position:a,vertexSpace:l}=s,c=e.fromJSON(s.indexSR),u=e.fromJSON(s.meshSR),m={georeferenced:o,georeferencedRelative:r,local:n}[l.type].fromJSON(l);let y;if("georeferenced"===m.type){const{projectBuffer:e,initializeProjection:t}=await import("../../../geometry/projection.js");await t(u,c),y=new Float64Array(a.length),e(a,u,0,y,c,0,y.length/3)}else{const{project:e}=await import("../../../geometry/support/meshUtils/georeference.js");y=t(e(u,i?{localMatrix:i}:void 0,m,a,c))}const d=y.length,[p,b,h]=f;for(let e=0;e<d;e+=3)y[e]-=p,y[e+1]-=b,y[e+2]-=h;return{result:[y,a],transferList:[y.buffer,a.buffer]}}function d(e){A(e)}let p,b;function h(e){const t=e.modifications,r=b._malloc(8*t.length),o=new Float64Array(b.HEAPU8.buffer,r,t.length);for(let n=0;n<t.length;++n)o[n]=t[n];b.setModifications(e.context,r,t.length,e.isGeodetic),b._free(r)}function g(e,t){if(!b)return null;const{context:r,localOrigin:o,globalTrafo:n,mbs:i,obb:f,elevationOffset:a,geometryBuffer:l,geometryDescriptor:c,indexToVertexProjector:u,vertexToRenderProjector:m}=e,y=b._malloc(l.byteLength),d=33,p=b._malloc(d*Float64Array.BYTES_PER_ELEMENT),h=new Uint8Array(b.HEAPU8.buffer,y,l.byteLength);h.set(new Uint8Array(l));const g=new Float64Array(b.HEAPU8.buffer,p,d);L(g,o);let E=g.byteOffset+3*g.BYTES_PER_ELEMENT,w=new Float64Array(g.buffer,E);L(w,n),E+=16*g.BYTES_PER_ELEMENT,w=new Float64Array(g.buffer,E),L(w,i),E+=4*g.BYTES_PER_ELEMENT,null!=f&&(w=new Float64Array(g.buffer,E),L(w,f.center),E+=3*g.BYTES_PER_ELEMENT,w=new Float64Array(g.buffer,E),L(w,f.halfSize),E+=3*g.BYTES_PER_ELEMENT,w=new Float64Array(g.buffer,E),L(w,f.quaternion));const A=c,_={isDraco:!1,isLegacy:!1,color:e.layouts.some((e=>e.some((e=>"color"===e.name)))),normal:e.needNormals&&e.layouts.some((e=>e.some((e=>"normalCompressed"===e.name)))),uv0:e.layouts.some((e=>e.some((e=>"uv0"===e.name)))),uvRegion:e.layouts.some((e=>e.some((e=>"uvRegion"===e.name)))),featureIndex:A.featureIndex},I=b.process(r,!!e.obb,y,h.byteLength,A,_,p,a,u,m,e.normalReferenceFrame);if(b._free(p),b._free(y),I.error.length>0)throw new Error(`i3s.wasm: ${I.error}`);if(I.discarded)return null;const S=I.componentOffsets.length>0?I.componentOffsets.slice():null,T=I.featureIds.length>0?I.featureIds.slice():null,x=I.anchorIds.length>0?Array.from(I.anchorIds):null,P=I.anchors.length>0?Array.from(I.anchors):null,j=I.interleavedVertedData.slice().buffer,M=I.indicesType===s.Int16?new Uint16Array(I.indices.buffer,I.indices.byteOffset,I.indices.byteLength/2).slice():new Uint32Array(I.indices.buffer,I.indices.byteOffset,I.indices.byteLength/4).slice(),R=I.positions.slice(),U=I.positionIndicesType===s.Int16?new Uint16Array(I.positionIndices.buffer,I.positionIndices.byteOffset,I.positionIndices.byteLength/2).slice():new Uint32Array(I.positionIndices.buffer,I.positionIndices.byteOffset,I.positionIndices.byteLength/4).slice(),B={layout:e.layouts[0],interleavedVertexData:j,indices:M,hasColors:I.hasColors,hasModifications:I.hasModifications,positionData:{data:R,indices:U}};return T&&t.push(T.buffer),S&&t.push(S.buffer),t.push(j),t.push(M.buffer),t.push(R.buffer),t.push(U.buffer),{componentOffsets:S,featureIds:T,anchorIds:x,anchors:P,transformedGeometry:B,obb:I.obb}}function E(e){return 0===e?f.Unmodified:1===e?f.PotentiallyModified:2===e?f.Culled:f.Unknown}function w(e){const{context:t,buffer:r}=e,o=b._malloc(r.byteLength),n=r.byteLength/Float64Array.BYTES_PER_ELEMENT,s=new Float64Array(b.HEAPU8.buffer,o,n),i=new Float64Array(r);s.set(i),b.filterOBBs(t,o,n),i.set(s),b._free(o)}function A(e){b&&(b.destroy(e),b=null)}function L(e,t){for(let r=0;r<t.length;++r)e[r]=t[r]}function _(){return b?Promise.resolve():(p||(p=i().then((e=>{b=e,p=null}))),p)}const I={transform:g,destroy:A};export{d as destroyContext,l as dracoDecompressPointCloudData,c as filterObbsForModifications,w as filterObbsForModificationsSync,_ as initialize,E as interpretObbModificationResults,a as process,y as project,m as setLegacySchema,u as setModifications,h as setModificationsSync,I as test};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import t from"../../../../core/Error.js";import{
|
|
5
|
+
import e from"../../../../Color.js";import t from"../../../../core/Error.js";import{assertIsSome as o}from"../../../../core/maybe.js";import{MIN_PRIORITY as n}from"../../../../core/MemCache.js";import{generateUUID as r}from"../../../../core/uuid.js";import{projectBoundingSphere as s}from"../../../../geometry/projection.js";import{k as a}from"../../../../chunks/sphere.js";import{loadImageAsync as i}from"../../../../support/requestUtils.js";import{EncodedMeshTexture as l}from"../../glTF/internal/resourceUtils.js";import{TextureUsage as u,TextureEncoding as d}from"./enums.js";import{CullFaceOptions as c}from"../../webgl-engine/lib/basicInterfaces.js";import{useSchematicPBR as m}from"../../webgl-engine/materials/pbrUtils.js";class h{constructor(e,t,o,n,r){this._uid=e,this._indexSR=t,this._renderSR=o,this._worker=r,this._id2Meta=new Map,this._oid2Meta=new Map,this._nextMeshNodeId=2,this._memCache=n.newCache(`sl-client-mesh-data-${this._uid}`)}get indexSR(){return this._indexSR}get renderSR(){return this._renderSR}createMeshNodeInfo(e,t){const o="mesh"+this._nextMeshNodeId++,n=e.extent,r=n.spatialReference,a=this._indexSR,i=f(n,e.origin);s(i,r,i,a);return{type:"mesh",id:o,version:b(e),oid:t,mbs:i,componentNodeIds:[],unloadedMesh:e,nodeIndex:null,loadMeshPromise:null}}addMeshNode(e,t){t.nodeIndex=e,this._id2Meta.set(t.id,t),this._oid2Meta.set(t.oid,t)}getMeshNodeIndex(e){const t=this._oid2Meta.get(e);return null==t||"mesh"!==t.type?null:t.nodeIndex}removeNode(e){if(null==e)return;const t=this._id2Meta.get(e);null!=t&&(this._id2Meta.delete(e),"mesh"===t.type&&this._oid2Meta.delete(t.oid))}async loadNodeJSON(e){const o=this._id2Meta.get(e);if(null==o)throw new t(`I3SClientNodeLoader::loadNodeJSON unable to find node ${e}`);switch(o.type){case"mesh":return this._loadMeshNodeJSON(o);case"mesh-component":return this._loadMeshComponentNodeJSON(o);default:throw new t(`I3SClientNodeLoader::loadNodeJSON unable to handle node ${e}`)}}async _loadMeshNodeJSON(e){const t=e.id,o=(await this._getMeshData(e)).loadedMesh;if(null==o.components||0===o.components.length)return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null};const n=[],r=o.components;for(let s=0;s<r.length;++s){const o=`${t}-component${s}`,r={type:"mesh-component",id:o,mbs:e.mbs,componentIndex:s,meshNodeInfo:e,textureData:new Map};this._id2Meta.set(r.id,r),e.componentNodeIds.push(o),n.push({id:r.id,href:null,mbs:r.mbs,obb:null})}return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:n}}updateNodeIndex(e,t,o){if(null==e)return;const n=this._id2Meta.get(e);n&&"mesh"===n.type&&(n.nodeIndex=o)}async _loadMeshComponentNodeJSON(e){return{id:e.id,version:e.meshNodeInfo.version,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null,isEmpty:!1}}async loadNodeData(e,n){const r=e.id,s=this._id2Meta.get(r);if(null==s||"mesh-component"!==s.type)throw new t(`Failed to load client node data for node ${e.id} (unexpected node info)`);const a=s.meshNodeInfo,i=await this._getMeshData(a),l=i.loadedMesh,u=a.oid;if(null==l.components)throw new t(`Failed to load client node data for node ${e.id} (unexpected null reference)`);const d=l.components[s.componentIndex],{material:c,requiredTextures:m,textureData:h}=await p(d.material);if(null!=h)for(const t of h)null!=t&&s.textureData.set(t.id,t);const f={params:{material:c},type:"ArrayBufferView"},{vertexSpace:x,origin:g,transform:y}=l,w=[g.x,g.y,g.z??0],b={featureDataPosition:w,featureIds:[],geometries:[f]},I={attributeData:{},loadedAttributes:[]};i.projectionPromise||(o(this._worker,"SceneLayerWorker is needed to project mesh"),i.projectionPromise=this._worker.project({localMatrix:y?.localMatrix,vertexSpace:x.toJSON(),origin:w,position:l.vertexAttributes.position,meshSR:l.spatialReference.toJSON(),indexSR:this._indexSR.toJSON()},n));const[N,S]=await i.projectionPromise;l.vertexAttributes.position=S;const{geometryBuffer:T,geometryDescriptor:_}=M(N,d.faces,l.vertexAttributes.normal,l.vertexAttributes.uv,l.vertexAttributes.color,u);return{geometryData:b,attributeDataInfo:I,geometryBuffer:T,geometryDescriptor:_,requiredTextures:m,textureData:h}}async loadAttributes(e,t,o){const n=e.numFeatures;for(const{field:{name:r}}of t)new Array(n);return{}}async loadTextures(e,t,o){const n=e.id,r=this._id2Meta.get(n);if(null==r||"mesh-component"!==r.type)throw new Error(`Failed to load textures for node ${e.id} (unexpected node info)`);const s=[];for(const a of t)s.push(r.textureData.get(a.id)||null);return s}async _getMeshData(e){const t=e.version,o=this._memCache.get(t);if(null==o){if(null!=e.loadMeshPromise)return e.loadMeshPromise;const o=async(o,r)=>{const s=e.unloadedMesh.clone();try{await s.load()}catch(l){r(l)}const a=s.memoryUsage,i={loadedMesh:s,projectionPromise:null,usedMemoryInBytes:a};this._memCache.put(t,i,a,n),e.loadMeshPromise=null,o(i)};return e.loadMeshPromise=new Promise(((e,t)=>o(e,t))),e.loadMeshPromise}return o}}function f(e,t){const o=[1,-1],n=[.5*e.width,.5*e.height,e.hasZ?.5*(e.zmax-e.zmin):0],r=e.center;let s=0;if(e.hasZ)for(let a=0;a<2;++a)for(let e=0;e<2;++e)for(let i=0;i<2;++i){const l=r.x+o[a]*n[0]-t.x,u=r.y+o[e]*n[1]-t.y,d=r.z+o[i]*n[2]-t.z;s=Math.max(l*l+u*u+d*d,s)}else for(let a=0;a<2;++a)for(let e=0;e<2;++e){const i=r.x+o[a]*n[0]-t.x,l=r.y+o[e]*n[1]-t.y;s=Math.max(i*i+l*l,s)}return a([t.x,t.y,t.z],Math.sqrt(s))}async function p(t){const o=[],n=[];if(null==t){return{material:{alphaMode:"opaque",alphaCutoff:.1,doubleSided:!0,cullFace:0,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[1,1,1,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6000000238418579},wrapTextures:!1,hasParametersFromSource:!0},requiredTextures:o,textureData:n}}const r=y(t);"auto"===t.alphaMode&&console.warn('alphaMode "auto" not supported by I3S PBRMaterial - defaulting to "blend".');return{material:{alphaMode:"auto"===t.alphaMode?"blend":t.alphaMode,alphaCutoff:t.alphaCutoff,doubleSided:t.doubleSided,cullFace:t.doubleSided?c.None:c.Back,normalTextureId:await x(t.normalTexture,o,n,u.Normal),emissiveTextureId:r?await x(t.emissiveTexture,o,n,u.Emissive):-1,occlusionTextureId:r?await x(t.occlusionTexture,o,n,u.Occlusion):-1,emissiveFactor:r&&null!=t.emissiveColor?e.toUnitRGB(t.emissiveColor):[0,0,0],metallicRoughness:{baseColorFactor:null!=t.color?e.toUnitRGBA(t.color):[1,1,1,1],baseColorTextureId:await x(t.colorTexture,o,n,u.Color),metallicRoughnessTextureId:r?await x(t.metallicRoughnessTexture,o,n,u.MetallicRoughness):-1,metallicFactor:r?t.metallic:0,roughnessFactor:r?t.roughness:0},wrapTextures:!0,hasParametersFromSource:m({normalTexture:t.normalTexture,emissiveTexture:r?t.emissiveTexture:null,emissiveFactor:r?e.toUnitRGBA(t.emissiveColor):null,occlusionTexture:r?t.occlusionTexture:null,metallicRoughnessTexture:r?t.metallicRoughnessTexture:null,metallicFactor:r?t.metallic:null,roughnessFactor:r?t.roughness:null})},requiredTextures:o,textureData:n}}async function x(e,o,n,r){if(null==e)return-1;const s=n.length,a=e.data,u=e.url;if(null!=a){if(a instanceof HTMLImageElement||a instanceof HTMLCanvasElement){const e=g(a);return n.push({id:s,usage:r,data:e,encoding:d.PNG,downsampled:!1}),o.push({id:s,usage:r,encodings:[{name:void 0,encoding:d.PNG}]}),s}if(a instanceof HTMLVideoElement)return-1;if(a instanceof ImageData)throw new t("ImageData textures not supported yet for client side I3S nodes");if(a instanceof l)throw new t("EncodedMeshTexture textures not supported yet for client side I3S nodes")}else if(null!=u){const e=new Image;e.src=u;const t=g(await i(e,e.src,!1,void 0));return n.push({id:s,usage:r,data:t,encoding:d.PNG,downsampled:!1}),o.push({id:s,usage:r,encodings:[{name:void 0,encoding:d.PNG}]}),s}return-1}function g(e){const t=1048576,o=4096,n=2;let r=e.width*e.height;if(r>=o){let o=e.width,s=e.height;do{o=Math.ceil(o/n),s=Math.ceil(s/n),r=o*s}while(r>t);const a=document.createElement("canvas");a.width=o,a.height=s;return a.getContext("2d").drawImage(e,0,0,o,s),a}return e}function y(e){return e.hasOwnProperty("metallicRoughnessTexture")}function M(e,t,o,n,r,s){const a=1,i=t.length/3,l=3*i;let u=0,d=0,c=!1,m=0,h=!1,f=0,p=!1,x=0,g=0,y=0;u+=I,u+=I,d=u,u+=3*l*N,null!=o&&(c=!0,m=u,u+=3*l*N),null!=n&&(h=!0,f=u,u+=2*l*N),null!=r&&(p=!0,x=u,u+=4*l*S),g=u,u+=a*T,y=u,u+=2*a*I;const M=new ArrayBuffer(u),b=new Uint8Array(M);w(b,0,l),w(b,I,a);const _=new Float32Array(M,d),v=null!=o?new Float32Array(M,m):null,D=null!=n?new Float32Array(M,f):null,R=null!=r?new Uint8Array(M,x):null;for(let w=0;w<i;++w){const s=3*w;for(let a=0;a<3;++a){const i=t[s+a],l=3*i,u=9*w+3*a;if(_[u]=e[l],_[u+1]=e[l+1],_[u+2]=e[l+2],null!=v&&(v[u]=o[l],v[u+1]=o[l+1],v[u+2]=o[l+2]),null!=D){const e=2*i,t=6*w+2*a;D[t]=n[e],D[t+1]=n[e+1]}if(null!=R){const e=4*i,t=12*w+4*a;R[t]=r[e],R[t+1]=r[e+1],R[t+2]=r[e+2],R[t+3]=r[e+3]}}}w(b,g,s),w(b,g+I,s/2**32),w(b,y,0),w(b,y+I,i-1);return{geometryBuffer:M,geometryDescriptor:{isDraco:!1,isLegacy:!0,color:p,normal:c,uv0:h,uvRegion:!1,featureIndex:!0}}}function w(e,t,o){e[t]=255&o,e[t+1]=255&o>>8,e[t+2]=255&o>>16,e[t+3]=255&o>>24}function b(e){const t=e.metadata.displaySource?.source;if(null==t||!Array.isArray(t)||!t.length||t[0]instanceof File)return r();const o=t;let n="";for(const r of o)n+=r.makeHash();return n+JSON.stringify(null!=e.transform?e.transform.toJSON():"")}const I=4,N=4,S=1,T=8;export{h as I3SClientNodeLoader,M as createGeometryData};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../request.js";import s from"../../../../core/Accessor.js";import{splitIntoChunks as i}from"../../../../core/arrayUtils.js";import{resultOrAbort as r,result as o}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as n,estimateNumberByteSize as a}from"../../../../core/byteSizeEstimations.js";import d from"../../../../core/Collection.js";import c from"../../../../core/Logger.js";import{destroyMaybe as h,abortMaybe as l}from"../../../../core/maybe.js";import{whenOrAbort as u}from"../../../../core/promiseUtils.js";import{watch as m,initial as g}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as y}from"../../../../core/accessorSupport/decorators/subclass.js";import{formatNumber as _}from"../../../../intl/number.js";import{getMaximumQuerySize as b,queryAllJSON as f}from"../../../../layers/support/featureQueryAll.js";import{assetMapFromAssetMapsJSON as O,extractMesh as C}from"../../../../rest/support/meshFeatureSet.js";import{direct3DObjectFeatureLayerDisplayEnabled as j,i3sPatchingEnabled as I,sceneLayerEditingEnabled as v}from"../../../../support/featureFlags.js";import F from"../FeatureLayerView3D.js";let A=class extends s{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=x,this._original3DOFLDefinitionExpression=null,this._interactiveEditingSessions=new d,this.geometryOverrides=new d,this._clientGeometryCache=new Map,this._associatedLayerView=null,this._attributeChangedObjectIds=new Set,this._geometryChangedObjectIds=new Set,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController}initialize(){this._memCache=this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.then((async()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null})),this.is3DOFL&&null!=this._associatedLayer&&(j()?this._associatedLayer.load().then((e=>{this.destroyed||(this._original3DOFLDefinitionExpression=e.definitionExpression,this.addHandles(m((()=>this._definitionExpression),(t=>e.definitionExpression=t),g)),this._associatedLayerView=new F({layer:this._associatedLayer,view:this.view}))})):I())}destroy(){this.is3DOFL&&null!=this._associatedLayer&&(j()?null!=this._associatedLayerView&&(this._associatedLayer.definitionExpression=this._original3DOFLDefinitionExpression):I()),this._set("layer",null),this._memCache=h(this._memCache),this._pendingFetchAbortController=l(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null}get is3DOFL(){return v()&&null!=this._associatedLayer&&null!=this._associatedLayer.infoFor3D}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort(((e,t)=>e-t)):[]}get _associatedLayer(){return null==this.layer?null:this.layer.associatedLayer}get _definitionExpression(){const e=this.sortedGeometryChangedObjectIds;return 0===e.length?"1 = 0":`OBJECTID IN (${e.join(",")})`}get updating(){if(!this.is3DOFL)return!1;if(j()){return!(null!=this._associatedLayerView)||null!=this._associatedLayerView&&this._associatedLayerView.updating}return I(),!1}get isEmpty(){return null==this._pendingFetchChangedObjectIds&&0===this._attributeChangedObjectIds.size&&0===this._geometryChangedObjectIds.size}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e),this.notifyChange("_attributeChangedObjectIds");const t=v()&&I()&&null!=this.is3DOFL,s=this._interactiveEditingSessions,i=new L(e,{rollback:()=>{s.remove(i)},commit:(s,i)=>{for(const[t,r]of s)this.updateAttributeValue(e,t,r);t&&null!=i&&this.updateGeometry(e,i)}});return s.unshift(i),i}async applyAttributeOverrides(e,t,s){if(null==t)return;const{loadedAttributes:i,attributeData:r}=t;if(null==i||0===i.length||null==r)return;if(this._pendingFetchChangedObjectIds&&await u(this._pendingFetchChangedObjectIds,s),0===this._attributeChangedObjectIds.size)return;const o={loadedAttributes:i,attributeData:r},n=this._getOverridesFromCache(e,o,this._attributeChangedObjectIds),{objectIds:a,fieldNames:d}=n;if(0===a.length||0===d.length)return;const c=await this._queryOverridesFromAssociatedLayer(a,d,!1,s);null!=c&&this._processOverridesFromAssociatedLayer(e,c,d,o)}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);const s=this._clientGeometryCache.get(e);if(null!=s&&(this.geometryOverrides.remove(s),this._clientGeometryCache.delete(e)),null!=t){const s={oid:e,mesh:t};this.geometryOverrides.add(s),this._clientGeometryCache.set(e,s)}this.notifyChange("_geometryChangedObjectIds")}updateAttributeValue(e,t,s){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,s),this.notifyChange("_attributeChangedObjectIds")}_cacheAttributeValue(e,t,s){this._memCache.put(this._getAttributeCacheKey(e,t),s,this._memCacheAttributeValueSize(s))}_cacheGeometry(e,t){this._memCache.put(this._getGeometryCacheKey(e),t,this._memCacheGeometrySize(t))}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:s},i){const r=new Set,o=new Array;if(this.is3DOFL&&0===Object.keys(s).length)return{objectIds:Array.from(e),fieldNames:t.map((e=>e.name))};for(const a of t)o[a.index]=s[a.name];const n=new Set;for(let a=0;a<e.length;a++){const s=e[a];if(i.has(s))for(const e of t){const t=this._attributeFromCache(s,e.index);void 0===t?(r.add(s),n.add(e.name)):o[e.index][a]=t}}return{objectIds:Array.from(r),fieldNames:Array.from(n)}}_attributeFromCache(e,t){const s=this._fromInteractiveEditingSession(e,t);if(void 0!==s)return s;const i=this._getAttributeCacheKey(e,t);return this._memCache.get(i)}_fromInteractiveEditingSession(e,t){if(null!=this._interactiveEditingSessions)for(const s of this._interactiveEditingSessions){if(s.objectId!==e)continue;const i=s.getAttribute(t);if(void 0!==i)return i}}_getAttributeCacheKey(e,t){return`${e}-${t}`}_getGeometryCacheKey(e){return`${e}-geometry`}async _queryOverridesFromAssociatedLayer(e,t,s,o){if(0===e.length||!1===s&&0===t.length)return null;e=e.sort(((e,t)=>e-t)),this._warnMaximumChangedObjectsExceeded&&(this._warnMaximumChangedObjectsExceeded=!1,this._logMaximumObjectsExceededWarning());const n=this.layer.associatedLayer;if(null==n)return null;const a=s&&this.is3DOFL&&I(),d=[n.objectIdField,...t];a&&null!=n.globalIdField&&d.push(n.globalIdField);const c=n.createQuery();c.where="1=1",c.returnGeometry=s,c.outFields=d,c.cacheHint=!0,c.objectIds=e;const h=b(n),l=e.length>h?i(e,h).map((e=>{const t=c.clone();return t.objectIds=e,r(f(n,t,{signal:o}))})):[r(f(n,c,{signal:o}))],u=await Promise.all(l);if(a&&null!=n.infoFor3D){const e=n.infoFor3D,t=n.spatialReference,s=[];for(const i of u){if(!i.ok)continue;const r=i.value;if(null==r.assetMaps)continue;const o=O(e,r.assetMaps);for(const i of r.features){const n=C(i,r.globalIdFieldName,t,e,o),a=i;null!=n?(a.geometry=n,s.push(a)):a.geometry=null}}return s}return u.reduce(((e,t)=>e.concat(t.ok?t.value.features:[])),[])}_logMaximumObjectsExceededWarning(){let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${_(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;t&&t.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,c.getLogger("esri.views.3d.layers.i3s.I3SOverrides").warn("#queryOverrides()",this.layer.title,`${e}.`)}_processOverridesFromAssociatedLayer(e,t,s,{loadedAttributes:i,attributeData:r}){const o=this._associatedLayer;if(null==o)return;const n=o.objectIdField,a=s.map((t=>(t in r||(r[t]=new Array(e.length)),r[t]))),d=new Map(i.map((e=>[e.name,e.index]))),c=s.map((e=>d.get(e))),h=new Map(Array.from(e,((e,t)=>[e,t])));for(const l of t){const e=l.attributes[n];for(let t=0;t<s.length;t++){const i=c[t],r=h.get(e),o=l.attributes[s[t]];a[t][r]=o,this._cacheAttributeValue(e,i,o)}}}_memCacheAttributeValueSize(e){return"string"==typeof e?n(e):a()}_memCacheGeometrySize(e){return 256}async _fetchChangedObjectIds(e){const s=this.layer;await s.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();const{associatedLayer:i}=s;if(null==i||!i.capabilities?.operations?.supportsChangeTracking)return;const r=this._getFetchChangedObjectIdsServerGen();if(null==r)return;const n=i.layerId,a=this.is3DOFL,d={f:"json",returnIdsOnly:!0,layers:`[${n}]`,returnUpdates:!0,returnDeletes:a,returnInserts:a,layerServerGens:JSON.stringify([{id:n,serverGen:r}])};if(a){const e=i.infoFor3D;d.fieldsToCompare=JSON.stringify({fields:[...Object.values(e.transformFieldRoles),e.sourceHashField]})}const c=await o(t(`${i.url}/extractChanges`,{method:"post",query:d,timeout:w,signal:e}));if(c.ok&&1===c.value.data?.edits?.length){const t=c.value.data.edits[0],s=t?.objectIds,r=t?.fieldUpdates,o=s?.adds??[],n=s?.updates??[],d=s?.deletes??[],h=[...o,...n,...d],l=a?[...o,...r??n,...d]:[],u=Math.min(this._maximumNumberOfEditOVerrides,h.length);u<h.length&&(this._warnMaximumChangedObjectsExceeded=!0);const m=h.sort(((e,t)=>e-t));for(let e=0;e<u;++e){const t=m[e];this._attributeChangedObjectIds.add(t)}for(const e of l)this._geometryChangedObjectIds.add(e);if(this.is3DOFL&&I()&&this._geometryChangedObjectIds.size>0){const t=await this._queryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),[],!0,e);if(null!=t)for(const e of t)null!=e.geometry&&this.updateGeometry(e.attributes[i.objectIdField],e.geometry)}}this.notifyChange("_attributeChangedObjectIds"),this.notifyChange("_geometryChangedObjectIds")}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(null!=e.serviceUpdateTimeStamp&&null!=e.serviceUpdateTimeStamp.lastUpdate)return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return null!=t&&null!=t.serverGens&&null!=t.serverGens.minServerGen?t.serverGens.minServerGen:null}get test(){const e=Array.from(this._attributeChangedObjectIds),t=this._pendingFetchChangedObjectIds,s=this;return{changedObjectIds:e,pendingFetchChangedObjectIds:t,get maximumNumberOfEditOVerrides(){return s._maximumNumberOfEditOVerrides},set maximumNumberOfEditOVerrides(e){s._maximumNumberOfEditOVerrides=e}}}};e([p({constructOnly:!0})],A.prototype,"view",void 0),e([p({constructOnly:!0})],A.prototype,"layer",void 0),e([p({readOnly:!0})],A.prototype,"is3DOFL",null),e([p()],A.prototype,"_interactiveEditingSessions",void 0),e([p({readOnly:!0})],A.prototype,"sortedGeometryChangedObjectIds",null),e([p({readOnly:!0})],A.prototype,"geometryOverrides",void 0),e([p()],A.prototype,"_clientGeometryCache",void 0),e([p()],A.prototype,"_associatedLayer",null),e([p()],A.prototype,"_associatedLayerView",void 0),e([p({constructOnly:!0})],A.prototype,"memoryController",void 0),e([p()],A.prototype,"_attributeChangedObjectIds",void 0),e([p()],A.prototype,"_geometryChangedObjectIds",void 0),e([p()],A.prototype,"_pendingFetchChangedObjectIds",void 0),e([p()],A.prototype,"_definitionExpression",null),e([p()],A.prototype,"updating",null),e([p()],A.prototype,"isEmpty",null),A=e([y("esri.views.3d.layers.i3s.I3SOverrides")],A);class L{constructor(e,t){this.objectId=e,this._options=t,this._updates=new Map,this._updatedGeometry=void 0,this._state=E.ACTIVE}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}getGeometry(){return this._updatedGeometry}setGeometry(e){this.isActive&&(this._updatedGeometry=e)}rollback(){this.isActive&&(this._state=E.ROLLED_BACK,this._options.rollback(),this._updatedGeometry=void 0)}commit(){this.isActive&&(this._state=E.COMMITTED,this._options.commit(this._updates,this._updatedGeometry),this._updates.clear(),this._updatedGeometry=void 0)}get isActive(){return this._state===E.ACTIVE}}var E;!function(e){e[e.ACTIVE=0]="ACTIVE",e[e.COMMITTED=1]="COMMITTED",e[e.ROLLED_BACK=2]="ROLLED_BACK"}(E||(E={}));const w=1e4,x=5e4;export{A as I3SOverrides};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../request.js";import s from"../../../../core/Accessor.js";import{splitIntoChunks as i}from"../../../../core/arrayUtils.js";import{resultOrAbort as r,result as o}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as n,estimateNumberByteSize as a}from"../../../../core/byteSizeEstimations.js";import d from"../../../../core/Collection.js";import c from"../../../../core/Logger.js";import{destroyMaybe as h,abortMaybe as l}from"../../../../core/maybe.js";import{whenOrAbort as u}from"../../../../core/promiseUtils.js";import m from"../../../../core/ReactiveSet.js";import{watch as p,initial as g}from"../../../../core/reactiveUtils.js";import{property as y}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as b}from"../../../../core/accessorSupport/decorators/subclass.js";import{formatNumber as _}from"../../../../intl/number.js";import{getMaximumQuerySize as f,queryAllJSON as O}from"../../../../layers/support/featureQueryAll.js";import{assetMapFromAssetMapsJSON as C,extractMesh as j}from"../../../../rest/support/meshFeatureSet.js";import{direct3DObjectFeatureLayerDisplayEnabled as v,i3sPatchingEnabled as I,sceneLayerEditingEnabled as F}from"../../../../support/featureFlags.js";import{isTimeoutError as A}from"../../../../support/requestUtils.js";import L from"../FeatureLayerView3D.js";const E="esri.views.3d.layers.i3s.I3SOverrides";let w=class extends s{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=S,this._original3DOFLDefinitionExpression=null,this._interactiveEditingSessions=new d,this.geometryOverrides=new d,this._clientGeometryCache=new Map,this._associatedLayerView=null,this._attributeChangedObjectIds=new m,this._geometryChangedObjectIds=new m,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController}initialize(){this._memCache=this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.finally((()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null})),this.is3DOFL&&null!=this._associatedLayer&&(v()?this._associatedLayer.load().then((e=>{this.destroyed||(this._original3DOFLDefinitionExpression=e.definitionExpression,this.addHandles(p((()=>this._definitionExpression),(t=>e.definitionExpression=t),g)),this._associatedLayerView=new L({layer:this._associatedLayer,view:this.view}))})):I())}destroy(){this.is3DOFL&&null!=this._associatedLayer&&(v()?null!=this._associatedLayerView&&(this._associatedLayer.definitionExpression=this._original3DOFLDefinitionExpression):I()),this._set("layer",null),this._memCache=h(this._memCache),this._pendingFetchAbortController=l(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null}get is3DOFL(){return F()&&null!=this._associatedLayer&&null!=this._associatedLayer.infoFor3D}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort(((e,t)=>e-t)):[]}get _associatedLayer(){return null==this.layer?null:this.layer.associatedLayer}get hasGeometryChanges(){return this._geometryChangedObjectIds.size>0}get _definitionExpression(){const e=this.sortedGeometryChangedObjectIds;return 0===e.length?"1 = 0":`OBJECTID IN (${e.join(",")})`}get updating(){if(!this.is3DOFL)return!1;if(v()){return!(null!=this._associatedLayerView)||null!=this._associatedLayerView&&this._associatedLayerView.updating}return I(),!1}get isEmpty(){return null==this._pendingFetchChangedObjectIds&&0===this._attributeChangedObjectIds.size&&0===this._geometryChangedObjectIds.size}featureHasGeometryChanges(e){return this._geometryChangedObjectIds.has(e)}featureHasAttributeChanges(e){return this._attributeChangedObjectIds.has(e)}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e);const t=F()&&I()&&null!=this.is3DOFL,s=this._interactiveEditingSessions,i=new x(e,{rollback:()=>{s.remove(i)},commit:(s,i)=>{for(const[t,r]of s)this.updateAttributeValue(e,t,r);t&&null!=i&&this.updateGeometry(e,i)}});return s.unshift(i),i}async applyAttributeOverrides(e,t,s){if(null==t)return;const{loadedAttributes:i,attributeData:r}=t;if(null==i||0===i.length||null==r)return;if(this._pendingFetchChangedObjectIds&&await u(this._pendingFetchChangedObjectIds,s),0===this._attributeChangedObjectIds.size)return;const o={loadedAttributes:i,attributeData:r},n=this._getOverridesFromCache(e,o,this._attributeChangedObjectIds),{objectIds:a,fieldNames:d}=n;if(0===a.length||0===d.length)return;const c=await this._queryOverridesFromAssociatedLayer(a,d,!1,s);null!=c&&this._processOverridesFromAssociatedLayer(e,c,d,o)}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);const s=this._clientGeometryCache.get(e);if(null!=s&&(this.geometryOverrides.remove(s),this._clientGeometryCache.delete(e)),null!=t){const s={oid:e,mesh:t};this.geometryOverrides.add(s),this._clientGeometryCache.set(e,s)}}updateAttributeValue(e,t,s){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,s)}_cacheAttributeValue(e,t,s){this._memCache.put(this._getAttributeCacheKey(e,t),s,this._memCacheAttributeValueSize(s))}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:s},i){const r=new Set,o=new Array;if(this.is3DOFL&&0===Object.keys(s).length)return{objectIds:Array.from(e),fieldNames:t.map((e=>e.name))};for(const a of t)o[a.index]=s[a.name];const n=new Set;for(let a=0;a<e.length;a++){const s=e[a];if(i.has(s))for(const e of t){const t=this._attributeFromCache(s,e.index);void 0===t?(r.add(s),n.add(e.name)):o[e.index][a]=t}}return{objectIds:Array.from(r),fieldNames:Array.from(n)}}_attributeFromCache(e,t){const s=this._fromInteractiveEditingSession(e,t);if(void 0!==s)return s;const i=this._getAttributeCacheKey(e,t);return this._memCache.get(i)}_fromInteractiveEditingSession(e,t){if(null!=this._interactiveEditingSessions)for(const s of this._interactiveEditingSessions){if(s.objectId!==e)continue;const i=s.getAttribute(t);if(void 0!==i)return i}}_getAttributeCacheKey(e,t){return`${e}-${t}`}async _queryOverridesFromAssociatedLayer(e,t,s,o){if(0===e.length||!1===s&&0===t.length)return null;e=e.sort(((e,t)=>e-t)),this._warnMaximumChangedObjectsExceeded&&(this._warnMaximumChangedObjectsExceeded=!1,this._logMaximumObjectsExceededWarning());const n=this.layer.associatedLayer;if(null==n)return null;const a=s&&this.is3DOFL&&I(),d=[n.objectIdField,...t];a&&null!=n.globalIdField&&d.push(n.globalIdField);const c=n.createQuery();c.where="1=1",c.returnGeometry=s,c.outFields=d,c.cacheHint=!0,c.objectIds=e;const h=f(n),l=e.length>h?i(e,h).map((e=>{const t=c.clone();return t.objectIds=e,r(O(n,t,{signal:o}))})):[r(O(n,c,{signal:o}))],u=await Promise.all(l);if(a&&null!=n.infoFor3D){const e=n.infoFor3D,t=n.spatialReference,s=[];for(const i of u){if(!i.ok)continue;const r=i.value;if(null==r.assetMaps)continue;const o=C(e,r.assetMaps);for(const i of r.features){const n=j(i,r.globalIdFieldName,t,e,o),a=i;null!=n?(a.geometry=n,s.push(a)):a.geometry=null}}return s}return u.reduce(((e,t)=>e.concat(t.ok?t.value.features:[])),[])}_logMaximumObjectsExceededWarning(){let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${_(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;t&&t.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,c.getLogger(E).warn("#queryOverrides()",this.layer.title,`${e}.`)}_processOverridesFromAssociatedLayer(e,t,s,{loadedAttributes:i,attributeData:r}){const o=this._associatedLayer;if(null==o)return;const n=o.objectIdField,a=s.map((t=>(t in r||(r[t]=new Array(e.length)),r[t]))),d=new Map(i.map((e=>[e.name,e.index]))),c=s.map((e=>d.get(e))),h=new Map(Array.from(e,((e,t)=>[e,t])));for(const l of t){const e=l.attributes[n];for(let t=0;t<s.length;t++){const i=c[t],r=h.get(e),o=l.attributes[s[t]];a[t][r]=o,this._cacheAttributeValue(e,i,o)}}}_memCacheAttributeValueSize(e){return"string"==typeof e?n(e):a()}async _fetchChangedObjectIds(e){const s=this.layer;await s.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();const{associatedLayer:i}=s;if(null==i||!i.capabilities?.operations?.supportsChangeTracking)return;const r=this._getFetchChangedObjectIdsServerGen();if(null==r)return;const n=i.layerId,a=this.is3DOFL,d={f:"json",returnIdsOnly:!0,layers:`[${n}]`,returnUpdates:!0,returnDeletes:a,returnInserts:a,layerServerGens:JSON.stringify([{id:n,serverGen:r}])};if(a){const e=i.infoFor3D;d.fieldsToCompare=JSON.stringify({fields:[...Object.values(e.transformFieldRoles),e.sourceHashField]})}const h=await o(t(`${i.url}/extractChanges`,{method:"post",query:d,timeout:G,signal:e}));if(!h.ok&&A(h.error)){const e=this.layer.title;c.getLogger(E).warn("extractChanges:timeout",e,`${e} could not obtain edited features that are not cached in the scene service. Display of features may not be up to date with the latest edits. Consider re-caching the scene service.`)}if(h.ok&&1===h.value.data?.edits?.length){const t=h.value.data.edits[0],s=t?.objectIds,r=t?.fieldUpdates,o=s?.adds??[],n=s?.updates??[],d=s?.deletes??[],c=[...o,...n,...d],l=a?[...o,...r??n,...d]:[],u=Math.min(this._maximumNumberOfEditOVerrides,c.length);u<c.length&&(this._warnMaximumChangedObjectsExceeded=!0);const m=c.sort(((e,t)=>e-t));for(let e=0;e<u;++e){const t=m[e];this._attributeChangedObjectIds.add(t)}for(const e of l)this._geometryChangedObjectIds.add(e);if(this.is3DOFL&&I()&&this._geometryChangedObjectIds.size>0){const t=await this._queryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),[],!0,e);if(null!=t)for(const e of t)null!=e.geometry&&this.updateGeometry(e.attributes[i.objectIdField],e.geometry)}}}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(null!=e.serviceUpdateTimeStamp&&null!=e.serviceUpdateTimeStamp.lastUpdate)return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return null!=t&&null!=t.serverGens&&null!=t.serverGens.minServerGen?t.serverGens.minServerGen:null}get test(){const e=Array.from(this._attributeChangedObjectIds),t=this._pendingFetchChangedObjectIds,s=this;return{changedObjectIds:e,pendingFetchChangedObjectIds:t,get maximumNumberOfEditOVerrides(){return s._maximumNumberOfEditOVerrides},set maximumNumberOfEditOVerrides(e){s._maximumNumberOfEditOVerrides=e}}}};e([y({constructOnly:!0})],w.prototype,"view",void 0),e([y({constructOnly:!0})],w.prototype,"layer",void 0),e([y({readOnly:!0})],w.prototype,"is3DOFL",null),e([y()],w.prototype,"_interactiveEditingSessions",void 0),e([y({readOnly:!0})],w.prototype,"sortedGeometryChangedObjectIds",null),e([y({readOnly:!0})],w.prototype,"geometryOverrides",void 0),e([y()],w.prototype,"_clientGeometryCache",void 0),e([y()],w.prototype,"_associatedLayer",null),e([y()],w.prototype,"_associatedLayerView",void 0),e([y({constructOnly:!0})],w.prototype,"memoryController",void 0),e([y()],w.prototype,"_attributeChangedObjectIds",void 0),e([y()],w.prototype,"_geometryChangedObjectIds",void 0),e([y()],w.prototype,"hasGeometryChanges",null),e([y()],w.prototype,"_pendingFetchChangedObjectIds",void 0),e([y()],w.prototype,"_pendingFetchAbortController",void 0),e([y()],w.prototype,"_definitionExpression",null),e([y()],w.prototype,"updating",null),e([y()],w.prototype,"isEmpty",null),w=e([b(E)],w);class x{constructor(e,t){this.objectId=e,this._options=t,this._updates=new Map,this._updatedGeometry=void 0,this._state=D.ACTIVE}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}getGeometry(){return this._updatedGeometry}setGeometry(e){this.isActive&&(this._updatedGeometry=e)}rollback(){this.isActive&&(this._state=D.ROLLED_BACK,this._options.rollback(),this._updatedGeometry=void 0)}commit(){this.isActive&&(this._state=D.COMMITTED,this._options.commit(this._updates,this._updatedGeometry),this._updates.clear(),this._updatedGeometry=void 0)}get isActive(){return this._state===D.ACTIVE}}var D;!function(e){e[e.ACTIVE=0]="ACTIVE",e[e.COMMITTED=1]="COMMITTED",e[e.ROLLED_BACK=2]="ROLLED_BACK"}(D||(D={}));const G=1e4,S=5e4;export{w as I3SOverrides};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{I as e}from"../../../../../../chunks/mat4f64.js";import{c as a}from"../../../../../../chunks/vec3f64.js";import{RgbaFloatEncoding as s}from"../util/RgbaFloatEncoding.glsl.js";import{Float4PassUniform as o}from"../../shaderModules/Float4PassUniform.js";import{IntegerPassUniform as t}from"../../shaderModules/IntegerPassUniform.js";import{NoParameters as i,glsl as r}from"../../shaderModules/interfaces.js";import{Matrix4sDrawUniform as d}from"../../shaderModules/Matrix4sDrawUniform.js";import{Matrix4sPassUniform as l}from"../../shaderModules/Matrix4sPassUniform.js";import{Texture2DPassUniform as n}from"../../shaderModules/Texture2DPassUniform.js";class p extends i{constructor(){super(...arguments),this.origin=a()}}class c extends p{constructor(){super(...arguments),this.modelTransformation=e}}
|
|
5
|
+
import{I as e}from"../../../../../../chunks/mat4f64.js";import{c as a}from"../../../../../../chunks/vec3f64.js";import{RgbaFloatEncoding as s}from"../util/RgbaFloatEncoding.glsl.js";import{Float4PassUniform as o}from"../../shaderModules/Float4PassUniform.js";import{IntegerPassUniform as t}from"../../shaderModules/IntegerPassUniform.js";import{NoParameters as i,glsl as r}from"../../shaderModules/interfaces.js";import{Matrix4sDrawUniform as d}from"../../shaderModules/Matrix4sDrawUniform.js";import{Matrix4sPassUniform as l}from"../../shaderModules/Matrix4sPassUniform.js";import{Texture2DPassUniform as n}from"../../shaderModules/Texture2DPassUniform.js";class p extends i{constructor(){super(...arguments),this.origin=a()}}class c extends p{}class h extends i{constructor(){super(...arguments),this.modelTransformation=e}}class v extends h{constructor(){super(...arguments),this.origin=a()}}function f(e,a){a.receiveShadows&&(e.fragment.uniforms.add(new l("shadowMapMatrix",((e,a)=>a.shadowMap.getShadowMapMatrices(e.origin,e.modelTransformation)),4)),u(e))}function m(e,a){a.receiveShadows&&(e.fragment.uniforms.add(new d("shadowMapMatrix",((e,a,s)=>a.shadowMap.getShadowMapMatrices(e.origin,s.modelTransformation)),4)),u(e))}function u(e){const a=e.fragment;a.include(s),a.uniforms.add(new n("shadowMapTex",((e,a)=>a.shadowMap.depthTexture)),new t("numCascades",((e,a)=>a.shadowMap.numCascades)),new o("cascadeDistances",((e,a)=>a.shadowMap.cascadeDistances))),a.code.add(r`int chooseCascade(float depth, out mat4 mat) {
|
|
6
6
|
vec4 distance = cascadeDistances;
|
|
7
7
|
int i = depth < distance[1] ? 0 : depth < distance[2] ? 1 : depth < distance[3] ? 2 : 3;
|
|
8
8
|
mat = i == 0 ? shadowMapMatrix[0] : i == 1 ? shadowMapMatrix[1] : i == 2 ? shadowMapMatrix[2] : shadowMapMatrix[3];
|
|
@@ -40,4 +40,4 @@ if (lvpos.z >= 1.0) { return 0.0; }
|
|
|
40
40
|
if (lvpos.x < 0.0 || lvpos.x > 1.0 || lvpos.y < 0.0 || lvpos.y > 1.0) { return 0.0; }
|
|
41
41
|
vec2 uv = cascadeCoordinates(i, lvpos);
|
|
42
42
|
return filterShadow(uv, lvpos, float(textureSize(shadowMapTex, 0).x), shadowMapTex);
|
|
43
|
-
}`)}export{
|
|
43
|
+
}`)}export{m as ReadShadowMapDraw,c as ReadShadowMapDrawParameters,h as ReadShadowMapParameters,f as ReadShadowMapPass,v as ReadShadowMapPassParameters};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import e from"../Viewpoint.js";import{geographicToWebMercator as t}from"../geometry/support/webMercatorUtils.js";import{project as r}from"../rest/geometryService/project.js";import o from"../rest/support/ProjectParameters.js";async function n(t,r,o){const n=t?.viewpoint?.targetGeometry;if(n)return null;const s=await i(t,r,o);if(!s)return null;return new e({targetGeometry:s})}async function i(e,n,i){const s=e?.spatialReference,a=n?.extent;if(!s||!a)return null;if(s.isWGS84)return a.clone();if(s.isWebMercator)return t(a);const{getGeometryServiceURL:c}=await import("../portal/support/geometryServiceUtils.js");try{const e=await c(n),t=new o;t.geometries=[a],t.outSpatialReference=s;return(await r(e,t))[0]}catch(p){i.error("Error projecting item's extent:",p)}return null}export{n as computeInitialViewpoint};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{remove as t}from"../../core/arrayUtils.js";import{makeHandle as a,handlesGroup as i}from"../../core/handleUtils.js";import{removeMaybe as r,destroyMaybe as n}from"../../core/maybe.js";import{throwIfAborted as o}from"../../core/promiseUtils.js";import{whenOnce as s,watch as l,syncAndInitial as c}from"../../core/reactiveUtils.js";import{generateBracedUUID as d}from"../../core/uuid.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as p,getEffectiveEditingEnabled as f}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as m}from"../../views/draw/support/helpMessageUtils.js";import g from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as w}from"./CreateFeaturesWorkflowData.js";import{isModelUpload as y,waitForModelUpload as v}from"./modelUploadUtils.js";import _ from"./Workflow.js";import{shouldShowAttachmentsForCreateWorkflow as F,startCreatingNewFeature as I,findLayerInfo as b,updateGraphicSymbolWhenRequired as M,isTerminalUpdateEventType as A,getVisualVariableAttributes as k,startUpdatingFeature as V,createWorkflowSteps as j,avoidFeatureTemplateSelectionWithOnlyOneItem as C,prepareAttachmentsForCreateWorkflow as E,showProgressCursor as U,visualVariableInteractiveUpdate as S}from"./workflowUtils.js";var G;const H=Symbol();let O=G=class extends _{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._attachmentFileInfos=new Map,this._highlightHandles=new Map,this._preventDefaultActionOnCancel=!1,this._lastActiveGraphics=[]}get hasPendingEdits(){if(this.numPendingFeatures)return!0;const{data:e}=this,{upload:t}=e;return!(!t||t.error)||!!e.creationInfo?.geometryToPlace}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=t.sketchViewModel.createGraphic?.geometry;return m(a,i,t.view)}get numPendingFeatures(){return this.pendingFeatures.length}get pendingFeatures(){return this.data.viewModel.sketchViewModel.layer.graphics}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){const{creationInfo:e}=this.data;if(!e)return!1;const{layer:t}=e,a=t.capabilities?.operations.supportsAdd,i=p(t)?.operations.supportsAdd;return f(t)&&!t.editingEnabled||!!i&&!a}get shouldShowAttachments(){return!!(this.data&&this.data.creationInfo&&this.data.viewModel)&&F(this.data)}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get updating(){return this.updatingHandles.updating}get test(){return{addAttachment:(e,t)=>{this._attachmentFileInfos.set(e,t)}}}async enter(){}exit(){}async updatePendingFeature(e,a){return this._preventDefaultActionOnCancel=!0,this.data.viewModel.sketchViewModel.cancel(),t(this._lastActiveGraphics,e),this._startUpdating(e,a)}static create(e,t,a,i,r){const n=new G({data:new w({creationInfo:t,viewModel:e}),onCommit:async e=>{const{creationInfo:t,viewModel:a}=e;if(!t)return;t.geometryToPlace&&(e.creationInfo=null);const o=a.sketchViewModel.layer.graphics.toArray(),{layer:s}=t,l=s.capabilities?.editing.supportsGlobalId&&"globalIdField"in s,c=n._attachmentFileInfos;if(l){const e=T(o,s,c);return void await i(s,e,{globalIdUsed:!0})}const d=await i(s,{addFeatures:o});if(c.size>0){const e=d?.addFeatureResults??[];await r(s,P(o,e,s,c))}}});return n._set("steps",this._createWorkflowSteps(n,a)),n}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",a((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,a((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t?.type&&this._highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){r(this._highlightHandles.get(e)),this._highlightHandles.delete(e)}async _startCreating(e){const{data:t}=this,{creationInfo:a}=t;if(a)return this.createFeatureState="create-new",I(t.viewModel.sketchViewModel,a,e)}async _startUpdating(e,t){const{creationInfo:a,viewModel:n}=this.data,{featureFormViewModel:o,layerInfos:s,sketchViewModel:l,view:c}=n;if(!c||!a)return;const d=a.layer,u=b(s,d),h=u?.formTemplate,p=c.spatialReference;return o.set({arcadeEditType:"INSERT",feature:e,formTemplate:h,spatialReference:p,view:c}),await M(e,t),r(this._featureFormHandle),this._featureFormHandle=i([o.on("value-change",(async()=>{e.attributes=o.getValues(),await M(e,t)})),l.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&A(e.toolEventInfo.type))&&o.notifyFeatureGeometryChanged()}))]),this._removeHighlight(e),this.createFeatureState="update-pending",this._visualVariableAttributes=k(e),V(l,e,d,this._visualVariableAttributes,t)}static _createWorkflowSteps(e,n="awaiting-feature-creation-info"){const{data:c,handles:d}=e;let u=null,h=!0;const p=new Map,f=j(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],n,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(t){const{creationInfo:a,viewModel:i}=c,{view:r}=i;if(r)if(y(a)){const a=await v({view:r,data:c,signal:t,next:()=>e.next(),cancel:()=>i.cancelWorkflow()});o(t),d.add(a,this.id)}else c.creationInfo=null,d.add(i.featureTemplatesViewModel.on("select",(({item:e})=>{e&&(c.creationInfo=e,i.activeWorkflow?.next())})),this.id)},async tearDown(){d.remove(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){if(d.has(this.id))return;const{viewModel:n}=c,{view:o}=n;if(!o)return;const f=n.sketchViewModel;h=f.updateOnGraphicClick,f.updateOnGraphicClick=!1,e._lastActiveGraphics=[],e._featureFormHandle=r(e._featureFormHandle),e._visualVariableAttributes={rotation:null,size:null},E(n.attachmentsViewModel);const m="2d"===o.type&&c.creationInfo?e._fadeExistingFeatures(c.creationInfo.layer):null,g=f.on("create",(async t=>{if("cancel"===t.state){if(e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);if(e._lastActiveGraphics.length<1)return e._startCreating(p);const t=e._lastActiveGraphics.pop();return e._startUpdating(t,p)}if("complete"===t.state&&t.graphic)return e._startUpdating(t.graphic,p)})),w=f.on("update",(async t=>{const{viewModel:a}=c,{attachmentsViewModel:i,featureFormViewModel:r}=a,n=t.graphics[0];if("complete"===t.state){if(n!==u&&(e._lastActiveGraphics.push(n),e._highlight(n)),u=null,e.numPendingFeatures===c.creationInfo?.maxFeatures){const t=e._lastActiveGraphics.pop();return e._startUpdating(t,p)}return"add"!==i.mode&&"edit"!==i.mode||a.activeWorkflow?.previous(),t.aborted&&e._preventDefaultActionOnCancel?void(e._preventDefaultActionOnCancel=!1):(d.add([U(o),o.on("click",(e=>e.preventDefault()))],H),s((()=>!r.updating)).then((()=>{d.remove(H),e._startCreating(p)})))}if("start"===t.state){e._removeHighlight(n),"add"!==i.mode&&"edit"!==i.mode||a.activeWorkflow?.previous(),i.fileInfos.removeAll(),i.graphic=n,i.mode="view";(e._attachmentFileInfos.get(n)||[]).forEach((({file:e,form:t})=>i.addFile(e,t)))}const l=e._visualVariableAttributes;await S(o,n,t,l,p);const h=n.attributes,{rotation:f,size:m}=l;if(null!=f){const{field:e}=f;r.setValue(e,h[e])}if(null!=m){const{field:e}=m;r.setValue(e,h[e])}})),v=f.on("delete",(async a=>{const i=a.graphics[0];t(e._lastActiveGraphics,i),u=i})),_=D(f,c),F=o.on("immediate-click",(async t=>{if(y(c.creationInfo))return;const{results:a}=await o.hitTest(t,{include:f.layer}),i=a.find((e=>"graphic"===e.type));if(!i)return;const r=i.graphic;if("transform"===f.activeTool||"reshape"===f.activeTool){if(f.updateGraphics.at(0)===r)return;await e.updatePendingFeature(r,p)}})),I=l((()=>n.attachmentsViewModel.mode),(t=>{switch(t){case"add":e.go("adding-attachment");break;case"edit":e.go("editing-attachment")}})),b=U(o);try{await e._startCreating(p)}finally{b.remove()}const M=i([b,e._featureFormHandle,g,w,v,_,a((()=>f.cancel())),F,I,m]);d.add(M,e._handleKeys.beforeCommit),d.add(M,this.id)},async tearDown(t){const{viewModel:a}=c;t.canceled&&(a.sketchViewModel.layer.removeAll(),d.remove([this.id,H]),a.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear(),a.sketchViewModel.updateOnGraphicClick=h)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=c.viewModel,{graphic:a,fileInfos:i}=t;e._attachmentFileInfos.set(a,i.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=c.viewModel,{graphic:a,fileInfos:i}=t;e._attachmentFileInfos.set(a,i.toArray()),t.mode="view"}})});return C(c,f)}};function D(e,t){let r=null;const o=()=>e.snappingOptions.featureSources,s=()=>(r=new g({layer:e.layer}),o().add(r),r),d=()=>{null!=r&&(o().remove(r),r=n(r))};return i([l((()=>{const e=t.creationInfo?.layer,a=o().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return d();r??=s(),r.enabled=t}),c),a(d)])}function P(e,t,a,i){const r=[];return t.forEach(((t,n)=>{if(!t.error){const o=e[n],s=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,s.forEach((({form:e})=>r.push({feature:o,attachment:e})))}})),r}function T(e,t,a){const i=[],r=t.globalIdField;return e.forEach(((t,n)=>{e[n].attributes[r]??=d(),(a?.get(t)||[]).forEach((({file:e})=>i.push({feature:t,attachment:{globalId:d(),data:e}})))})),i.length?{addFeatures:e,addAttachments:i}:{addFeatures:e}}e([u()],O.prototype,"hasPendingEdits",null),e([u()],O.prototype,"helpMessage",null),e([u()],O.prototype,"keyboardCancellationEnabled",null),e([u()],O.prototype,"reliesOnOwnerAdminPrivileges",null),e([u()],O.prototype,"shouldShowAttachments",null),e([u()],O.prototype,"shouldAllowAttachmentEditing",null),e([u()],O.prototype,"updating",null),O=G=e([h("esri.widgets.Editor.CreateFeaturesWorkflow")],O);const x=O;export{x as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{remove as t}from"../../core/arrayUtils.js";import{makeHandle as a,handlesGroup as i}from"../../core/handleUtils.js";import{removeMaybe as r,destroyMaybe as n}from"../../core/maybe.js";import{throwIfAborted as o}from"../../core/promiseUtils.js";import{whenOnce as s,watch as l,syncAndInitial as c}from"../../core/reactiveUtils.js";import{generateBracedUUID as d}from"../../core/uuid.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as p,getEffectiveEditingEnabled as f,isTable as g}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as m}from"../../views/draw/support/helpMessageUtils.js";import w from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as v}from"./CreateFeaturesWorkflowData.js";import{isModelUpload as y,waitForModelUpload as _}from"./modelUploadUtils.js";import F from"./Workflow.js";import{shouldShowAttachmentsForCreateWorkflow as b,startCreatingNewFeature as I,findLayerInfo as M,updateGraphicSymbolWhenRequired as A,isTerminalUpdateEventType as k,getVisualVariableAttributes as V,startUpdatingFeature as C,createWorkflowSteps as S,avoidFeatureTemplateSelectionWithOnlyOneItem as j,showProgressCursor as E,visualVariableInteractiveUpdate as U,prepareAttachmentsForCreateWorkflow as G}from"./workflowUtils.js";var H;const O=Symbol();let D=H=class extends F{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._attachmentFileInfos=new Map,this._highlightHandles=new Map,this._preventDefaultActionOnCancel=!1,this._lastActiveGraphics=[]}get hasPendingEdits(){if(this.numPendingFeatures)return!0;const{data:e}=this,{upload:t}=e;return!(!t||t.error)||!!e.creationInfo?.geometryToPlace}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=t.sketchViewModel.createGraphic?.geometry;return m(a,i,t.view)}get numPendingFeatures(){return this.pendingFeatures.length}get pendingFeatures(){return this.data.viewModel.sketchViewModel.layer.graphics}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){const{creationInfo:e}=this.data;if(!e)return!1;const{layer:t}=e,a=t.capabilities?.operations.supportsAdd,i=p(t)?.operations.supportsAdd;return f(t)&&!t.editingEnabled||!!i&&!a}get shouldShowAttachments(){return!!(this.data&&this.data.creationInfo&&this.data.viewModel)&&b(this.data)}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get updating(){return this.updatingHandles.updating}get test(){return{addAttachment:(e,t)=>{this._attachmentFileInfos.set(e,t)}}}async enter(){}exit(){}async updatePendingFeature(e,a){return this._preventDefaultActionOnCancel=!0,this.data.viewModel.sketchViewModel.cancel(),t(this._lastActiveGraphics,e),this._startUpdating(e,a)}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,creationInfo:i,startAt:r,viewModel:n}=e,o=new H({data:new v({creationInfo:i,viewModel:n}),onCommit:async e=>{const{creationInfo:i,viewModel:r}=e;if(!i)return;i.geometryToPlace&&(e.creationInfo=null);const n=r.sketchViewModel.layer.graphics.toArray(),{layer:s}=i,l=s.capabilities?.editing.supportsGlobalId&&"globalIdField"in s,c=o._attachmentFileInfos;if(l){const e=x(n,s,c);return void await a(s,e,{globalIdUsed:!0})}const d=await a(s,{addFeatures:n});if(c.size>0){const e=d?.addFeatureResults??[];await t(s,T(n,e,s,c))}}});return o._set("steps",this._createWorkflowSteps(o,r)),o}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",a((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,a((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t?.type&&this._highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){r(this._highlightHandles.get(e)),this._highlightHandles.delete(e)}async _startCreating(e){const{data:t}=this,{creationInfo:a}=t;if(a)return this.createFeatureState="create-new",I(t.viewModel.sketchViewModel,a,e)}async _startUpdating(e,t){const{creationInfo:a,viewModel:n}=this.data,{featureFormViewModel:o,layerInfos:s,sketchViewModel:l,view:c}=n;if(!c||!a)return;const d=a.layer,u=M(s,d),h=u?.formTemplate,p=c.spatialReference;return o.set({arcadeEditType:"INSERT",feature:e,formTemplate:h,spatialReference:p,view:c}),await A(e,t),r(this._featureFormHandle),this._featureFormHandle=i([o.on("value-change",(async()=>{e.attributes=o.getValues(),await A(e,t)})),l.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&k(e.toolEventInfo.type))&&o.notifyFeatureGeometryChanged()}))]),this._removeHighlight(e),this.createFeatureState="update-pending",this._visualVariableAttributes=V(e),g(d)?void 0:C({graphic:e,sketchViewModel:l,sourceLayer:d,visualVariables:this._visualVariableAttributes,webStyleCache:t})}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a,handles:n}=e,s=S(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(t){const{creationInfo:i,viewModel:r}=a,{view:s}=r;if(s)if(y(i)){const i=await _({view:s,data:a,signal:t,next:()=>e.next(),cancel:()=>r.cancelWorkflow()});o(t),n.add(i,this.id)}else a.creationInfo=null,n.add(r.featureTemplatesViewModel.on("select",(({item:e})=>{e&&(a.creationInfo=e,r.activeWorkflow?.next())})),this.id)},async tearDown(){n.remove(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){if(n.has(this.id))return;const{viewModel:t}=a,{view:o}=t;if(!o)return;const s=new Map,c=[];e._lastActiveGraphics=[],e._featureFormHandle=r(e._featureFormHandle),e._visualVariableAttributes={rotation:null,size:null},G(t.attachmentsViewModel),c.push(l((()=>t.attachmentsViewModel.mode),(t=>{switch(t){case"add":e.go("adding-attachment");break;case"edit":e.go("editing-attachment")}})));const d=E(o);c.push(d);const u=e.data.creationInfo?.layer;try{g(u)||c.push(H._configureSketchViewModel(e,s));const t=a.creationInfo?.initialFeature;t?(e.pendingFeatures.add(t),await e._startUpdating(t,s)):await e._startCreating(s)}finally{d.remove()}const h=i([...c,d,e._featureFormHandle]);n.add(h,e._handleKeys.beforeCommit),n.add(h,this.id)},async tearDown(t){const{viewModel:i}=a;t.canceled&&(i.sketchViewModel.layer.removeAll(),n.remove([this.id,O]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return j(a,s)}static _configureSketchViewModel(e,r){const{data:n,handles:o}=e,{viewModel:l}=n,{view:c}=l,d=l.sketchViewModel;let u=null;const h=[];if(!c)return a();const p=d.updateOnGraphicClick;return d.updateOnGraphicClick=!1,h.push(a((()=>d.updateOnGraphicClick=p))),"2d"===c.type&&n.creationInfo&&h.push(e._fadeExistingFeatures(n.creationInfo.layer)),h.push(d.on("create",(async t=>{if("cancel"===t.state){if(e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);if(e._lastActiveGraphics.length<1)return e._startCreating(r);const t=e._lastActiveGraphics.pop();return e._startUpdating(t,r)}if("complete"===t.state&&t.graphic)return e._startUpdating(t.graphic,r)})),d.on("update",(async t=>{const{viewModel:a}=n,{attachmentsViewModel:i,featureFormViewModel:l}=a,d=t.graphics[0];if("complete"===t.state){if(d!==u&&(e._lastActiveGraphics.push(d),e._highlight(d)),u=null,e.numPendingFeatures===n.creationInfo?.maxFeatures){const t=e._lastActiveGraphics.pop();return e._startUpdating(t,r)}if("add"!==i.mode&&"edit"!==i.mode||a.activeWorkflow?.previous(),t.aborted&&e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);o.add([E(c),c.on("click",(e=>e.preventDefault()))],O),await s((()=>!l.updating)),o.remove(O),e._startCreating(r)}if("start"===t.state){e._removeHighlight(d),"add"!==i.mode&&"edit"!==i.mode||a.activeWorkflow?.previous(),i.fileInfos.removeAll(),i.graphic=d,i.mode="view";(e._attachmentFileInfos.get(d)||[]).forEach((({file:e,form:t})=>i.addFile(e,t)))}const h=e._visualVariableAttributes;await U(c,d,t,h,r);const p=d.attributes,{rotation:f,size:g}=h;if(null!=f){const{field:e}=f;l.setValue(e,p[e])}if(null!=g){const{field:e}=g;l.setValue(e,p[e])}})),d.on("delete",(async a=>{const i=a.graphics[0];t(e._lastActiveGraphics,i),u=i})),c.on("immediate-click",(async t=>{if(y(n.creationInfo))return;const{results:a}=await c.hitTest(t,{include:d.layer}),i=a.find((e=>"graphic"===e.type));if(!i)return;const o=i.graphic;if("transform"===d.activeTool||"reshape"===d.activeTool){if(d.updateGraphics.at(0)===o)return;await e.updatePendingFeature(o,r)}})),a((()=>d.cancel())),P(d,n)),i(h)}};function P(e,t){let r=null;const o=()=>e.snappingOptions.featureSources,s=()=>(r=new w({layer:e.layer}),o().add(r),r),d=()=>{null!=r&&(o().remove(r),r=n(r))};return i([l((()=>{const e=t.creationInfo?.layer,a=o().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return d();r??=s(),r.enabled=t}),c),a(d)])}function T(e,t,a,i){const r=[];return t.forEach(((t,n)=>{if(!t.error){const o=e[n],s=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,s.forEach((({form:e})=>r.push({feature:o,attachment:e})))}})),r}function x(e,t,a){const i=[],r=t.globalIdField;return e.forEach(((t,n)=>{e[n].attributes[r]??=d(),(a?.get(t)||[]).forEach((({file:e})=>i.push({feature:t,attachment:{globalId:d(),data:e}})))})),i.length?{addFeatures:e,addAttachments:i}:{addFeatures:e}}e([u()],D.prototype,"hasPendingEdits",null),e([u()],D.prototype,"helpMessage",null),e([u()],D.prototype,"keyboardCancellationEnabled",null),e([u()],D.prototype,"reliesOnOwnerAdminPrivileges",null),e([u()],D.prototype,"shouldShowAttachments",null),e([u()],D.prototype,"shouldAllowAttachmentEditing",null),e([u()],D.prototype,"updating",null),D=H=e([h("esri.widgets.Editor.CreateFeaturesWorkflow")],D);const W=D;export{W as default};
|