@arcgis/core 4.33.0-next.20250313 → 4.33.0-next.20250314
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/065ae931b5891847a06f.js +1 -0
- package/assets/esri/core/workers/chunks/{08bfceab05b5ea02bb4e.js → 23aa7254fffe67e3f1bc.js} +3 -3
- package/assets/esri/core/workers/chunks/29ba2022c2978e9bd53e.js +1 -0
- package/assets/esri/core/workers/chunks/2b21152c7e2d9c170ed7.js +1 -0
- package/assets/esri/core/workers/chunks/7ded83eb64eff069b761.js +1 -0
- package/assets/esri/core/workers/chunks/a7a1832274892e99c388.js +1 -0
- package/assets/esri/core/workers/chunks/{6388fdacb434a266b039.js → c43c273725b1a33712ec.js} +5 -5
- package/chunks/FocusAreaMask.glsl.js +2 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/3d/analysis/Dimension/DimensionVisualization.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/analysis/Slice/SliceTool.js +1 -1
- package/views/3d/environment/ChapmanAtmosphere.js +1 -1
- package/views/3d/environment/EnvironmentManager.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/environment/Fog.js +1 -1
- package/views/3d/environment/MarsAtmosphere.js +1 -1
- package/views/3d/environment/Precipitation.js +1 -1
- package/views/3d/interactive/Manipulator3D.js +1 -1
- package/views/3d/interactive/editingTools/transform/extentTransform/ExtentRotate.js +1 -1
- package/views/3d/interactive/visualElements/LabelVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/LaserlineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/Object3DVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/VisualElement.js +1 -1
- package/views/3d/interactive/visualElements/VisualElementResources.js +1 -1
- package/views/3d/layers/DrapedSubView3D.js +5 -0
- package/views/3d/layers/DynamicLayerView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/ImageryLayerView3D.js +1 -1
- package/views/3d/layers/ImagerySubView3D.js +5 -0
- package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/Lyr3DWasm.js +1 -1
- package/views/3d/layers/MediaLayerView3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/SubView3D.js +5 -0
- package/views/3d/layers/VoxelLayerView3D.js +1 -1
- package/views/3d/layers/WMSLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Labeler.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/LodRenderer.js +1 -1
- package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
- package/views/3d/layers/support/Tiles3DIntersectionHandler.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/state/controllers/FovController.js +1 -1
- package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
- package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
- package/views/3d/state/controllers/RotateController.js +1 -1
- package/views/3d/state/controllers/ZoomControllerGlobal.js +1 -1
- package/views/3d/state/controllers/ZoomControllerLocal.js +1 -1
- package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
- package/views/3d/state/controllers/ZoomStepControllerLocal.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/support/MemoryController.js +1 -1
- package/views/3d/support/SceneViewPerformanceInfo.js +1 -1
- package/views/3d/support/SharedSymbolResources.js +1 -1
- package/views/3d/support/buffer/InterleavedLayout.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/TileCompositor.js +1 -1
- package/views/3d/webgl/RenderNode.js +1 -1
- package/views/3d/webgl-engine/Stage.js +1 -1
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
- package/views/3d/webgl-engine/effects/geometry/ObjectAndLayerIDRenderNode.js +1 -1
- package/views/3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js +1 -1
- package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
- package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/GridLocalOriginFactory.js +1 -1
- package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
- package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/FocusAreas.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/webgl/Program.js +1 -1
- package/views/webgl/RenderingContext.js +1 -1
- package/views/webgl/Texture.js +1 -1
- package/views/webgl/capabilities/Capabilities.js +1 -1
- package/views/webgl/checkWebGLError.js +1 -1
- package/views/webgl/enums.js +1 -1
- package/views/webgl/testFloatBufferBlend.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/DataCaptureAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/dataCaptureUtils.js +1 -1
- package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/025f8b72d7d8b5cccb0f.js +0 -1
- package/assets/esri/core/workers/chunks/0e5c77d043ed4641556f.js +0 -1
- package/assets/esri/core/workers/chunks/10fc47b441ae49ef4db8.js +0 -1
- package/assets/esri/core/workers/chunks/4908b36ef448bfe1f448.js +0 -1
- package/assets/esri/core/workers/chunks/fe6e7ac83cd2293d576e.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.33/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 has from"../../../core/has.js";import a from"../../../core/Logger.js";import{equals as n}from"../../../core/MapUtils.js";import{destroyMaybe as l}from"../../../core/maybe.js";import d from"../../../core/PooledArray.js";import{ignoreAbortErrors as h,isAbortError as c,throwIfAborted as u,createResolver as _}from"../../../core/promiseUtils.js";import{initial as m,watch as g}from"../../../core/reactiveUtils.js";import{schedule as f}from"../../../core/scheduling.js";import{equals as p}from"../../../core/SetUtils.js";import{isArrayBuffer as y}from"../../../core/typedArrayUtil.js";import{property as b}from"../../../core/accessorSupport/decorators/property.js";import{subclass as v}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as I,invert as C}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as M}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as w,getTranslation as x}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as E,create as R}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as O}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{i as j,t as S,q as A,a as D,g as T,h as F,d as N,H as V}from"../../../chunks/vec32.js";import{create as H}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as P}from"../../../chunks/vec42.js";import{fromValues as U}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as k}from"../../../core/support/UpdatingHandles.js";import{getSphericalPCPF as G}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{localLinearScaleFactors as L}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as B}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as q}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as W}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as z}from"../../../geometry/projection/projectVectorToVector.js";import{create as K,fromBuffer as $,toRect as Q}from"../../../geometry/support/aaBoundingBox.js";import{create as X,intersects as Y}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as J}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as Z}from"../../../geometry/support/FloatArray.js";import{compactIndices as ee}from"../../../geometry/support/Indices.js";import{a as te,f as ie,g as se}from"../../../chunks/sphere.js";import{newUByteArray as re}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as oe}from"../../../layers/LayerConstants.js";import ae from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as ne}from"../../../layers/support/fieldUtils.js";import le from"../../../layers/support/SceneModification.js";import{getColor as de,getOpacity as he}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{isBasemapLayer as ce}from"../../../support/basemapUtils.js";import{getElevationOffset as ue}from"../../../support/elevationInfoUtils.js";import{isQuery as _e}from"../../../support/guards.js";import{loadArcade as me}from"../../../support/loadArcade.js";import ge from"../../../symbols/MeshSymbol3D.js";import fe from"../../../symbols/SimpleFillSymbol.js";import pe from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as ye}from"./I3SMeshViewPerformanceInfo.js";import{I3SMeshWorkerHandle as be,toWasmModification as ve}from"./I3SMeshWorkerHandle.js";import{ElevationMode as Ie,ForAllFeaturesReturnType as Ce,ForAllFeaturesMode as Me}from"./II3SMeshView3D.js";import{initialize as we,setModificationsSync as xe,filterObbsForModificationsSync as Ee,interpretObbModificationResults as Re}from"./SceneLayerWorker.js";import{overrideColor as Oe}from"./graphics/graphicUtils.js";import{areLabelsVisible as je}from"./graphics/Labeler.js";import{TextureUsage as Se,TextureEncoding as Ae}from"./i3s/enums.js";import De from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as Te}from"./i3s/I3SAsyncElevationUpdater.js";import{I3SCrossfadeHelper as Fe,NodeCrossfadeMetaData as Ne}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as Ve}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as He}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Pe,selectEncoding as Ue,defaultMaterial as ke,createTexture as Ge,configureMaterial as Le}from"./i3s/I3SMaterialUtil.js";import{NodeIMModificationImpact as Be,NodeState as qe}from"./i3s/I3SNode.js";import{I3SOverrides as We}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as ze}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as Ke,checkSceneLayerValid as $e,checkSceneLayerCompatibleWithView as Qe,whenGraphicAttributes as Xe,computeVisibilityObb as Ye,filterInPlace as Je,getCachedAttributeValue as Ze,intersectBoundingRectWithMbs as et,MbsIntersectResult as tt,addWraparound as it,getSymbolInfo as st,transparentEdgeMaterial as rt,getClipRect as ot}from"./i3s/I3SUtil.js";import{IDBCache as at}from"./i3s/IDBCache.js";import{IDBMockCache as nt}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as lt}from"./i3s/LayerElevationProvider.js";import{SymbologyInfo as dt}from"./i3s/SymbologyInfo.js";import{attributeLookup as ht}from"./support/attributeUtils.js";import{emptyHighlightHandle as ct,normalizeHighlightTargetExceptQuery as ut}from"./support/highlightUtils.js";import{makeScheduleFunction as _t}from"./support/makeScheduleFunction.js";import{ColorMixModeEnum as mt}from"./support/symbolColorUtils.js";import{debugFlags as gt}from"../support/debugFlags.js";import{ElevationRange as ft}from"../support/ElevationRange.js";import{toBoundingRect as pt}from"../support/extentUtils.js";import{Obb as yt}from"../support/orientedBoundingBox.js";import{updatingProgress as bt}from"../support/updatingProperties.js";import{glLayout as vt}from"../support/buffer/glUtil.js";import{ObjectParameters as It}from"../webgl-engine/collections/Component/ObjectParameters.js";import{createVertexBufferLayout as Ct,GeometryParameters as Mt}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as wt}from"../webgl-engine/collections/Component/Transform.js";import{TextureCoordinateType as xt}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{loadBasisTranscoder as Et}from"../webgl-engine/lib/BasisUtil.js";import{Transparency as Rt}from"../webgl-engine/lib/edgeRendering/interfaces.js";import{defaultHighlightName as Ot}from"../../support/HighlightDefaults.js";import{alphaCutoff as jt}from"../../../webscene/support/AlphaCutoff.js";const St="esri.views.3d.layers.I3SMeshView3D",At=()=>a.getLogger(St),Dt=[1,1,1,1];class Tt extends Ne{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}get cachedMemory(){return this.node.memory}get featureExtents(){return this._featureExtents??=new Float64Array(6*this.featureIds.length).fill(Number.POSITIVE_INFINITY),this._featureExtents}}var Ft;!function(e){e[e.CastShadows=4]="CastShadows",e[e.Pickable=5]="Pickable"}(Ft||(Ft={}));const Nt=26,Vt=100*o.MEGABYTES,Ht=t=>{let o=class extends t{constructor(){super(...arguments),this._applySSAO=!0,this._shadeNormals=!0,this._updatingHandles=new k,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._hasComponentData=!1,this._hasVertexColors=!1,this._nodeColorOverride=null,this.updating=!0,this.holeFilling="auto",this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=new Array,this.ignoresMemoryFactor=!1,this._layerUrl="",this._cacheKeySuffix=null,this._planetRadiusInGlobalMode=0,this._elevationTask=null,this._needFilterResolve=!1,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i,this._crossfadeHelper=new Fe(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 _isIntegratedMesh(){return"integrated-mesh"===this.i3slayer.type}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible&&this.fullOpacity>jt}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?"yes":"probably-not":"unknown"}get rendererTextureUsage(){return Ke(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?Se.AllTexturesPBR:Se.AllTextures:this._usePBR||this._hasLoadedPBRTextures?Se.GeometryTexturesPBR:Se.GeometryTextures}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;return null!=e&&"absolute-height"===e.mode?ue(e,this.i3slayer.spatialReference):0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return new ei(Ie.Absolute,0);const t=ue(e,this.i3slayer.spatialReference);switch(e.mode){case"absolute-height":return new ei(Ie.Absolute,t);case"relative-to-ground":return new ei(Ie.RelativeToGround,t);case"on-the-ground":return new ei(Ie.OnTheGround,0);default:return new ei(Ie.Absolute,0)}}get supportedTextureEncodings(){return Pe(this.view._stage.renderView.capabilities)}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){const e=this._nodeId2Meta,t=new ft;for(const i of e.values()){if(null==i)continue;const{node:{serviceMbsInIndexSR:e}}=i,[s,r,o,a]=e;t.expandElevationRangeValues(o-a,o+a)}return t.elevationRangeValid?t:null}get fullExtent(){return this.i3slayer.fullExtent}initialize(){const e=has("enable-feature:idb-mock-cache");this._idbCache=e?new nt(this.view,e):new at("esri-scenelayer-cache","geometries"),this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const t=this.view.resourceController,i=t.memoryController;this.i3sOverrides=new We({view:this.view,layer:this.i3slayer,memoryController:i}),this._worker=new be(_t(t)),this.addResolvingPromise(this._worker.promise);const s=this.i3slayer.store;this.addResolvingPromise(this._worker.setLegacySchema(this.uid,s.defaultGeometrySchema).catch(h)),$e(this.i3slayer),Qe(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new ae({layerView:this,worker:this._worker}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view._stage,this._collection=this._stage.renderView.componentObjectCollection,this.resetHighlights();const r=s.defaultGeometrySchema;if(this._isIntegratedMesh||!r)this._hasComponentData=!1;else{const e=r.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(r?.vertexAttributes.color??null)&&!this.i3slayer.cachedDrawingInfo?.color;const o=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,(e=>this._deleteComponentObject(e)));this._memCache=o;const a=this._controller,n=this._nodeId2Meta,d=this._nodeId2MetaReloading,c=e=>{const t=a.index;if(!t)return;const i=t.rootNode;if(!i)return;const s=t=>{const i=t.index,s=n.get(i)||d.get(i);return e(t,s?.objectHandle??null)};t.traverse(i,s)};this._intersectionHandler=new He({layerUid:this.layerUid,sublayerUid:this.sublayerUid,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:c}),this._updatingHandles.add((()=>this.layerUid),(e=>this._intersectionHandler.layerUid=e)),this._updatingHandles.add((()=>this.sublayerUid),(e=>this._intersectionHandler.sublayerUid=e)),this._elevationProvider=new lt({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add((()=>this.view.clippingArea),(()=>this._clippingAreaChanged()),m),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)),m),this._updatingHandles.add((()=>!this.suspended&&this.elevationInfo.mode!==Ie.Absolute),((e,t)=>{e?this.addHandles(this.view.basemapTerrain.on("elevation-change",(({extent:e})=>this._ensureElevationTask().addExtent(e))),si):t&&this.removeHandles(si)}),m),this._updatingHandles.add((()=>this._usePBR),(e=>this._updatePBR(e)));const u=()=>{this._reloadAll(),this.clearMemCache()};this._updatingHandles.add((()=>this.rendererTextureUsage),u),this._updatingHandles.add((()=>this.contentVisible),(e=>this._contentVisibleChanged(e)),m),this._updatingHandles.add((()=>this.i3slayer.labelsVisible),(()=>this._labelingChanged()),m),this._updatingHandles.add((()=>this.i3slayer.labelingInfo),(()=>this._labelingChanged()),m),this._updatingHandles.add((()=>this._modifications),(()=>this._modificationsChanged()),m),this.addHandles([g((()=>gt.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&>.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||gt.I3S_TREE_SHOW_TILES||(this._treeDebugger=l(this._treeDebugger))}),m),g((()=>gt.I3S_SHOW_MODIFICATIONS),(()=>this._showModifications()),m)]),this._cacheKeySuffix=this._getCacheKeySuffix(),this._idbCache.init().catch((e=>At().warn(`Failed to initialize IndexedDB cache: ${e}`)));const{view:_}=this,{viewingMode:f,renderCoordsHelper:p}=_;this._planetRadiusInGlobalMode="local"===f?0:p.referenceEllipsoid.radius}destroy(){this._clearAddTasks(),this._elevationTask=l(this._elevationTask),this.i3sOverrides=l(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.objectsChanged(this.getVisibleObbs()),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._worker;e&&(e.destroyContext(this.uid).then((()=>e.destroy())),this._worker=null),this._removeAllNodeDataFromStage(),this._memCache=l(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=l(this._labeler),this._treeDebugger=l(this._treeDebugger),this._controller=l(this._controller),this._highlights.destroy(),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=l(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null),this._updatingHandles=l(this._updatingHandles)}_memEstimateTextureAdded(e){const t=e.usedMemory;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(null!=e){const t=e.usedMemory;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(!(je(this.i3slayer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new pe({view:this.view,layer:this.i3slayer,collection:this._collection,overrides:this.i3sOverrides});this._nodeId2Meta.forEach((t=>null!=t&&this._addMetaToLabeler(e,t))),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then((e=>(--this._asyncModuleLoading,e)),(e=>{throw--this._asyncModuleLoading,e}))}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=we().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=ve(this._layerClippingArea,this._modifications,t);xe({context:e,modifications:i,isGeodetic:t.isGeographic}),this._controller.modificationsChanged();const s=this.hasModifications?new d:null;this._nodeId2Meta.forEach(((e,t)=>{null==e?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._updateFeatureIdCounts(e,-1),this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):null!=s&&s.push(e.node)})),this.notifyChange("elevationRange"),null!=s&&this._nodeId2MetaReloading.forEach((e=>s.push(e.node))),null!=s&&s.length>0&&(this.updateNodeModificationStatus(s),s.forAll((e=>{if(e.imModificationImpact!==Be.Culled){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),null!=t?(this._updateFeatureIdCounts(t,-1),this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t),this.notifyChange("elevationRange")):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}}))),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(null!=this._modificationGraphics&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!gt.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={outline:{color:[255,255,255],width:1}};this._modificationGraphics=[];for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.i3slayer.spatialReference;const o=new fe({...t,color:e[s.type]});this._modificationGraphics.push(new i({geometry:r,symbol:o}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,((e,t)=>this._createAttributes(e,t)))}_contentVisibleChanged(e){e?(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler)):(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);null!=i?.attributeInfo&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);null!=s&&(await this.i3sOverrides.applyAttributeOverrides(s.featureIds,t,i,this._controller.requiredAttributes),s.attributeInfo=t,this._controller.reschedule((()=>this._attributeValuesChanged(s)),i).catch((e=>{c(e)||At().warn("Error while updating attribute values. Layer might not display correctly.",e)})))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.appliedFilters=null,null!=this._labeler&&this._labeler.setNodeMetaAttributes(e,((e,t)=>this._createAttributes(e,t))),this._updateEngineObject(e)}clearMemCache(){null!=this._memCache&&this._memCache.clear(),this._addTasks.forEach((e=>e.allowMemCache=!1))}getVisibleNodes(){const e=new Array;return this._nodeId2Meta.forEach((t=>null!=t&&e.push(t.node))),e}getVisibleObbs(){const e=new Array;return this._nodeId2Meta.forEach((t=>t&&e.push(this._collection.getComponentObb(t.objectHandle)))),e}getLoadedNodeIndices(e){this._nodeId2Meta.forEach(((t,i)=>e.push(i))),this._nodeId2MetaReloading.forEach(((t,i)=>e.push(i)))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&this.supportedTextureEncodings&Ae.Basis&&this.i3slayer.textureSetDefinitions?.some((e=>e.formats.some((e=>"basis"===e.format||"ktx2"===e.format))))&&Et()}_getVertexBufferLayout(e,t){return vt(Ct(this._getGeometryParameters({hasTexture:zt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion})))}_getObjectIdField(){return this.i3slayer.objectIdField||oe}_getGlobalIdField(){return this.i3slayer.associatedLayer?.globalIdField}_findGraphicNodeAndIndex(e){const t=ht(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());for(const i of this._nodeId2Meta.values()){const e=i?.featureIds.indexOf(t);if(null!=e&&e>=0)return{node:i.node,index:e}}return null}_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=ht(o,a.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this._getAABB(t.node.index,t.index);return null==i?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this._getAABB(e.nodeIndex,e.componentIndex)}_getAABB(e,t){const i=this._nodeId2Meta.get(e);if(null==i?.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=Ve(t,this._collection,s,J(24),0),o=this.view.renderSpatialReference,a=this.view.spatialReference;return q(r,o,0,r,a,0)?$(r):null}whenGraphicAttributes(e,t){return Xe(this.i3slayer,e,this._getObjectIdField(),t,(()=>[...this._nodeId2Meta.values()].filter(s)))}getGraphicFromIntersectorTarget(e){if(null==e.nodeIndex||null==e.componentIndex)return null;const t=this._nodeId2Meta.get(e.nodeIndex);return null==t?.featureIds||e.componentIndex>=t.featureIds.length?null:this._createGraphic(e.componentIndex,t)}_getCacheKey(e){return`${this._layerUrl}/v${Nt}/${e}${this._cacheKeySuffix}`}_getCacheKeySuffix(){const e=this.view.renderSpatialReference;if(null==e)return oi;if(e===G(e))return ai;return this.i3slayer.spatialReference.equals(e)?ri:null!=e.wkid?`@${e.wkid}`:null}_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,i)}loadMissingTextures(e,t,i,s){const r=e?.filter(((e,i)=>{if(!(e.usage&this.rendererTextureUsage))return!1;if(null==t)return!0;const s=Ue(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(null==r?.data||s&&r.encoding!==s.encoding)}))??[];return 0===r.length?Promise.resolve(!1):i(r,s).then((i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0}))}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then((s=>null==s?null:s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(this.elevationInfo.mode===Ie.Absolute&&(e.geometryObbInRenderSR=yt.fromData(s.geometryObbData)),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then((i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=Qt(s.transformedGeometry,s.textureData),s.textureData.every($t)&&Xt(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch((t=>At().warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`)))),u(t),s)))))):Promise.resolve(null)}addNode(e,t,i){return Kt(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,globalTrafo:h}=s,c=j(ti,r.center.x,r.center.y,r.center.z);S(c,c,h);const u=new yt(c,[r.extents.x,r.extents.y,r.extents.z],O(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));this.elevationInfo.mode===Ie.Absolute&&(e.geometryObbInRenderSR=u),t.geometryData.componentOffsets=o,a&&(t.geometryData.featureIds=Array.from(a)),t.geometryData.anchorIds=n,t.geometryData.anchors=l;const _={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:d,globalTrafo:h,geometryObbData:u.data,byteSize:Qt(d,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&Xt(e,_)){const t=null!=_.textureData?_.textureData.map((e=>$t(e)?e:null)):null;this._idbCache.put(this._getCacheKey(e.id),{..._,textureData:t}).catch((t=>At().warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`)))}return this._addCachedNodeData(e,_,i)}),i))))):Promise.reject()}getElevationRange(e){const t=new ft,i=this._controller,{index:s}=i;if(!s)return t;const{rootNode:r}=s;if(!r)return t;const o=this._nodeId2Meta,a=e[3],n=i.viewportQueries,l=this._planetRadiusInGlobalMode,{view:d}=this,{renderCoordsHelper:h}=d,c=h.referenceEllipsoid.radius,u=this._collection,_=i=>{const{childrenLoaded:s}=i;if(0===s)return!1;const r=n.getAndUpdateVisibilityObbInRenderSR(i);let d=null,_=-1;if(r){if(_=r.radius,!r.intersectSphereWithMBS(e,_))return!1}else d=n.getServiceMbsInRenderSR(i),d&&(_=d[3]);if(_>=0&&a>=1*_)return null!=r?di(t,r,l):null!=d&&d[3]>=0&&hi(t,d,l),!1;const m=li;if(m.elevationRangeMin=1/0,m.elevationRangeMax=-1/0,(null!=r||null!=d)&&(null!=r?di(m,r,l):null!=d&&hi(m,d,l),m.elevationRangeMin>=t.elevationRangeMin&&m.elevationRangeMax<=t.elevationRangeMax))return!1;const g=o.get(i.index);if(g){const{geometryObbInRenderSR:s}=i;if(!s||s.intersectSphereWithMBS(e)){if(s){if(a>0*s.radius)return di(t,s,l),!1}const{objectHandle:e}=g,i=u.getObjectTransform(e),r=h.getAltitude(i.position);u.expandRangeWithComponentObjectElevationRange(e,r,c,t)}}return s-(g?1:0)>0};return s.traverse(r,_),t}computeVisibilityObb(e){return Ye(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications,this.view.renderCoordsHelper.sphericalPCPF)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let f=0;f<s.length;++f)r[f]=this._getVertexBufferLayout(s[f],t.geometryDescriptor);const o=this.i3slayer.normalReferenceFrame,a=t.normalReferenceFrame??o??"none",n=e.serviceMbsInIndexSR,l=this.elevationOffset,d=this._controller.crsIndex,h=this._controller.crsVertex,c=this.view.renderSpatialReference,u=ze(n,l,a,d,c),_=W(d,h),m=W(h,c);if(null==_||null==m)return Promise.resolve(null);const g={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,globalTrafo:u,mbs:n,obbData:e.serviceObbInIndexSR?.data,elevationOffset:l,needNormals:this._controller.isMeshPyramid,normalReferenceFrame:a,indexToVertexProjector:_,vertexToRenderProjector:m};return this._worker.invoke(g,i)}get _supportsNodeCrossFading(){return!this.view?._stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){const t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,i){if(this.elevationInfo.mode===Ie.Absolute&&(e.geometryObbInRenderSR=this._collection.getComponentObb(t.objectHandle).clone()),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);null!=this._labeler&&this._addMetaToLabeler(this._labeler,t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,!0),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==Ie.Absolute&&this._ensureElevationTask().schedule(s),this._updateEngineObject(t),this._highlights.objectCreated(t),null!=this._treeDebugger&&this._treeDebugger.update()}addCachedNodeData(e,t,i,s){return this._addData(e,i,(()=>this._addCachedNodeData(e,t,s)))}async deleteCachedNodeData(e){if(this._idbCacheEnabled)return this._idbCache.remove(this._getCacheKey(e))}async _addCachedNodeData(e,t,i){if(!this.contentVisible||!this._controller.isGeometryVisible(e))return void this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);if(null==t)return void this._addNodeMeta(e.index,null);const s=this._addTasks.get(e.index),{geometryData:r,transformedGeometry:o,globalTrafo:a}=t;await this.i3sOverrides.applyAttributeOverrides(r.featureIds,s.attributeInfo,i,this._controller.requiredAttributes);const n=null!=t.textureData?t.textureData.filter((e=>null!=e&&!!(e.usage&this.rendererTextureUsage))):[];!has("disable-feature:i3s-basis")&&n.some((e=>null!=e&&(e.encoding===Ae.Basis||e.encoding===Ae.KTX2)))&&await Et(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:h,anchorIds:c,anchors:u}=r,_=this._collection,m=d[0],{layout:g,indices:f,interleavedVertexData:p,positionData:y,hasColors:b}=o,{material:v,geometryParameters:O}=this._materialParameters(m,g),j=l||new Uint32Array([0,f?f.length:p.byteLength/g[0].stride]),S={vertices:{data:p,count:p.byteLength/g[0].stride,layoutParameters:O},positionData:{positions:Z(y.data),indices:ee(y.indices)},indices:f,componentOffsets:j},T=m.transformation?E(m.transformation):R();w(T,a,T);const F=x(H(),T),N=I(M(),T),V=this.view.renderSpatialReference,P=this.view.basemapTerrain.spatialReference,k=yt.fromData(t.geometryObbData).center,G=[1,1,1];L(k,V,G,P)||At().errorOnce("Unsupported coordinate system for IM overlay");const B=H();z(k,V,B,P);const q=M();C(q,N);const W=H();A(W,D(W,k,F),q);const K=B[0]-W[0]*G[0],$=B[1]-W[1]*G[1],Q=_.createObject(new It(U(K,$,G[0],G[1]),new wt(F,N),yt.fromData(t.geometryObbData),S)),X=O.textureCoordinates===xt.Atlas,{textures:Y,texturePromise:J}=this._initMaterialAndTextures(Q,v,n,X);e.memory+=this._memEstimateGeometryAdded(Q),e.memory+=Y.reduce(((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0)),0);const te=!!v.hasParametersFromSource,ie="blend"!==v.alphaMode&&v.metallicRoughness.baseColorFactor[3]>=1,se=new Tt(e,h,Q,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:te,isOpaque:ie},Y,c,u);s.meta=se,this._hasTextures||=t.requiredTextures?.some((({usage:e})=>!!(e&Se.ColorTextures))),this._hasData=!0,this._hasColors||=b,this._hasTextures||=!!e.resources.texture,this.notifyChange("hasTexturesOrVertexColors");const re=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(se),J]).then((([t,s])=>(this._addTasks.has(e.index)&&t?.updateObjectVisibility(se.objectHandle,!1).catch((e=>Pt(e,this.i3slayer.title))),this._safeReschedule((()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,se),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(Q,!0),t?.updateObjectVisibility(se.objectHandle,!0).catch((e=>Pt(e,this.i3slayer.title))),se.attributeInfo=i.attributeInfo;const s=se.cachedRendererVersion!==this._rendererVersion,r=re!==this.slicePlaneEnabled;this._updateElevationOffsets(se);const o=se.elevationOffsets;this._updateComponentData(se);const a=this._applyFiltersToNode(se);(s||null!=t&&(r||a||o))&&this._addOrUpdateEdgeRendering(se),null!=this._labeler&&this._addMetaToLabeler(this._labeler,se),this._visibleGeometryChanged(se,Ut.ADD),this._highlights.objectCreated(se),this._updateMaterial(se),this._setNewNodeOpacity(se),null!=this._treeDebugger&&this._treeDebugger.update()}),i)))).catch((e=>{const{meta:t,allowMemCache:i}=s;throw s.meta=null,t&&i?this._cacheGPUData(t):t&&this._deleteComponentObject(t),e}))}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){At().error("Removing duplicated node");const t=this._nodeId2Meta.get(e);t&&(this._deleteComponentObject(t),this._updateFeatureIdCounts(t,-1))}else this._controller.updateLoadStatus(e,!0);t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&Zt(t.cachedEdgeMaterials,0),this._updateFeatureIdCounts(t,1)),this._nodeId2Meta.set(e,t),this.notifyChange("elevationRange")}_updateElevationOffsets(e){const t=this.view.renderSpatialReference,i=this._controller.crsIndex,s=this.elevationInfo,r=this.view.basemapTerrain,o=r.spatialReference,a=s.mode;if(null==t||null==o||a===Ie.Absolute)return void(e.elevationOffsets=null);const n=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const l=ti,d=ii,h=a===Ie.OnTheGround,c=this.view.renderCoordsHelper,u=e.featureIds.length,_=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const s=J(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?(j(l,e.anchors[3*h],e.anchors[3*h+1],e.anchors[3*h+2]),T(l,l,te(e.node.serviceMbsInIndexSR)),z(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),j(l,(d[0]+d[3])/2,(d[1]+d[4])/2,d[2]),A(l,l,n.rotationScale),T(l,l,n.position),s[a+2]=c.getAltitude(l),z(l,t,l,o),s[a]=l[0],s[a+1]=l[1])}return s})(),m=s.offset,g=e.elevationOffsets,f=(e,t)=>{const i=h?_[3*e+2]:0;g[e]=m+(t??0)-i};r.getElevations(_,u,f)}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new Te(this.view.resourceController.scheduler,(e=>this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference)?.filterInPlace((e=>null!=this._nodeId2Meta.get(e)))),(e=>this._nodeElevationAlignmentChanged(this._nodeId2Meta.get(e))),(()=>this.elevationInfo?.mode))),this._elevationTask}_elevationInfoChanged(e,t){const i=e.mode!==Ie.Absolute,s=!!t&&t!==e&&t.mode!==Ie.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,Ut.UPDATE),this._elevationProvider.objectChanged(this._collection.getComponentObb(e.objectHandle)))}_safeReschedule(e,t){return u(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:ke(),s=t.some((e=>"uvRegion"===e.name)),r=t.some((e=>"normalCompressed"===e.name)),o=zt(i);return{geometryParameters:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s){const r=this._stage.renderView,o=i.map((e=>Ge(e,t,s,r)));this._stage.addMany(o);let a=null;return this._collection.updateMaterial(e,(e=>{a=Le(e,t,o,i,this.view._stage.renderView.textures,{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 new Mt(this._hasVertexColors,e.hasTexture?e.hasRegions?xt.Atlas:xt.Default:xt.None,e.hasNormals,this._shadeNormals,this._applySSAO)}_addData(e,t,i){let s=this._addTasks.get(e.index);if(s)s.attributeInfo=t;else{const r=_();s=new Jt(t,null,r.promise),this._addTasks.set(e.index,s),i().then(r.resolve,r.reject).then((()=>this._addTasks.delete(e.index))).catch((t=>{throw this._addTasks.delete(e.index),t}))}return 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=X();this._renderClippingArea=pt(this.view.clippingArea,i,e)?i:null;const s=X();this._layerClippingArea=pt(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),this._assertFeatureIdNodeCounts(e)}_assertFeatureIdNodeCounts(e){e&&!this._featureIdCounts?(this._featureIdCounts=gi(this._nodeId2Meta.values()),this._filteredIdCounts=gi(this._nodeId2Meta.values(),mi.Filtered),this._weaklyRemovedIdCounts=gi(this._nodeId2Meta.values(),mi.WeaklyRemoved),this.addHandles(g((()=>this._controller.updating),(e=>{!e&&this._needFilterResolve&&(this.multiGeometryFilterResolve(),this._needFilterResolve=!1,this.notifyUpdate())}),{sync:!0}),"updateFinished")):!e&&this._featureIdCounts&&(this._featureIdCounts=null,this._filteredIdCounts=null,this._weaklyRemovedIdCounts=null,this._mismatchShow=null,this._mismatchHide=null,this.removeHandles("updateFinished"),this._needFilterResolve=!1,this.notifyUpdate())}_updateFeatureIdCounts(e,t){this._featureIdCounts&&(this._needFilterResolve=!0,_i(this._featureIdCounts,e.featureIds,t),_i(this._filteredIdCounts,e.filteredIds,t),_i(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,t))}_updateFilteredIdCounts(e,t,i){this._filteredIdCounts&&(this._needFilterResolve=!0,_i(this._filteredIdCounts,t,-1),_i(this._filteredIdCounts,e.filteredIds,1),_i(this._weaklyRemovedIdCounts,i,-1),_i(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,1))}_checkFeatureIdNodeCountInvariant(){const e=null!=this._featureIdCounts;if(this.hasGeometryFilter!==e&&At().error("checkFeatureIdNodeCountInvariant()","LayerView should have feature id node counts if and only if it has a geometry filter",{layerView:this,hasNodeCounts:e}),!this._featureIdCounts||!this._filteredIdCounts)return;const t=gi(this._nodeId2Meta.values());n(this._featureIdCounts,t)||At().error("checkFeatureIdNodeCountInvariant()","Incorrect _featureIdCounts",{layerView:this,counts:this._featureIdCounts,expected:t});const i=gi(this._nodeId2Meta.values(),mi.Filtered);n(this._filteredIdCounts,i)||At().error("checkFeatureIdNodeCountInvariant()","Incorrect _filteredIdCounts",{layerView:this,counts:this._filteredIdCounts,expected:i});const s=gi(this._nodeId2Meta.values(),mi.WeaklyRemoved);n(this._weaklyRemovedIdCounts,s)||At().error("checkFeatureIdNodeCountInvariant()","Incorrect _weaklyRemovedIdCounts",{layerView:this,counts:this._weaklyRemovedIdCounts,expected:i})}multiGeometryFilterResolve(){if(!this._featureIdCounts||!this._filteredIdCounts)return;let e=null,t=null;for(const[i,s]of this._filteredIdCounts){const r=this._featureIdCounts.get(i);if(r!==s){s+(this._weaklyRemovedIdCounts?.get(i)??0)===r?(e??=new Set,e.add(i)):(t??=new Set,t.add(i))}}p(e,this._mismatchShow)&&p(t,this._mismatchHide)||(this._mismatchShow=e,this._mismatchHide=t,this._nodeId2Meta.forEach((e=>{if(!e?.filteredIds)return;const t=ui(e,this._mismatchShow,this._mismatchHide);this._collection.setAllComponentVisibilities(e.objectHandle,t),this._visibleGeometryChanged(e,Ut.UPDATE)})))}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach((e=>{e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Ut.UPDATE))}))}getFilters(){const e=[],t=this._renderClippingArea;return null!=t&&e.push(((e,i)=>this._boundingRectFilter(e,i,t))),e}addSqlFilter(e,t,i){if(null!=t){const s=t.fieldNames;e.push(((e,r)=>this._sqlFilter(e,r,t,s,i)))}}_sqlFilter(e,t,i,s,r){const o={},a=this._createLayerGraphic(o),n=this.i3slayer.objectIdField,l=t.featureIds,d=t.attributeInfo?.attributeData;s.every((e=>e===n||null!=d?.[e]))&&Je(e,l,(e=>{o[n]=l[e];for(const i of s)i!==n&&(o[i]=d?Ze(d[i],e):null);try{return i.testFeature(a)}catch(t){return r(t),!1}}))}_boundingRectNodeTest(e,t){return B(e.node.serviceMbsInIndexSR,this._controller.crsIndex,Wt,this.view.renderSpatialReference),et(t,Wt)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,kt),Q(kt,Gt),Y(i,Gt)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(r===tt.INSIDE)return;if(r===tt.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(Lt,i,t.objectHandle);Je(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}async _addOrUpdateEdgeRendering(e,t=!0){const i=e.objectHandle,{hasEdges:s,perFeatureEdgeMaterials:r}=this._getFilteredEdgeMaterials(e);s&&!this._edgeView&&(this._edgeView=await this._stage.renderer.loadEdgeView());const o=this._edgeView;if(!o)return null;const a=o.hasObject(i);if(s){if(a){if(this.nodeCrossfadingEnabled){Zt(r,this.getNodeOpacity(e))}return o.updateAllComponentMaterials(i,r,this.slicePlaneEnabled,t).catch((e=>Pt(e,this.i3slayer.title))),o.updateObjectVisibility(i,!0).catch((e=>Pt(e,this.i3slayer.title))),o.updateAllVerticalOffsets(i,e.elevationOffsets).catch((e=>Pt(e,this.i3slayer.title))),o}const s=await this._collection.addEdges(i,o,r,this.slicePlaneEnabled,e.elevationOffsets);return e.edgeMemoryUsage=s,e.node.memory+=s,o}return a&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,o.removeObject(i)),null}_applyFiltersToNode(e){const t=e.filteredIds,i=e.weaklyRemovedIds;return!!this._applyFiltersToNodeComponents(e)&&(this._updateFilteredIdCounts(e,t,i),this._labeler?.applyFilterChange(e),!0)}_applyFiltersToNodeComponents(e){const t=this._collection,i=t.getComponentCount(e.objectHandle),s=null!=e.filteredIds,r=0===i.invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!r;if(null!=e.filteredIds&&e.appliedFilters===this._filters||(e.weaklyRemovedIds=null,e.filteredIds=ci(e,this._filters),e.appliedFilters=this._filters),s&&e.filteredIds===e.featureIds&&(!this._mismatchHide||e.filteredIds.every((e=>!this._mismatchHide?.has(e)))))return!r;const o=ui(e,this._mismatchShow,this._mismatchHide);return t.setAllComponentVisibilities(e.objectHandle,o),!0}_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=l(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),null!=this._elevationTask&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);null!=s?(this._collection.setObjectVisibility(s.objectHandle,!1),null!=this._edgeView&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch((e=>Pt(e,this.i3slayer.title))),this._visibleGeometryChanged(s,Ut.REMOVE),null!=this._labeler&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights.objectDeleted(s),i===this._nodeId2Meta?(this._updateFeatureIdCounts(s,-1),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===qe.Hole))}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){const i=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,i),this.notifyChange("elevationRange")}const i=this._nodeId2MetaReloading.get(e);i&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,i))}_invalidateAllSymbols(){this._rendererVersion=it(this._rendererVersion,1),this._controller&&this._controller.requestUpdate()}_getInvalidRendererVersion(){return it(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=it(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 me()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:At().warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.symbols)"mesh-3d"!==t.type&&At().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;P(s.externalColor,t[r]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255);const o=this._stage.renderView.olidRenderHelper;if(o){const t=e.featureIds[i],r=ce(this.view.map,this.layerUid);o.setUidToObjectAndLayerId(t,t,this.layerId,this.layerUid+"_"+this.sublayerId,this.layerPopupEnabledAndHasTemplate&&!r,e.node.resources.attributes,i,this.sublayerId),s.objectAndLayerIdColor=this._stage.renderView.getObjectAndLayerIdColor({graphicUid:t,layerUid:this.layerUid+"_"+this.sublayerId})}s.externalColorMixMode=t[r+4]&(1<<Ft.CastShadows)-1,s.castShadows=!!(t[r+4]&1<<Ft.CastShadows),s.pickable=!!(t[r+4]&1<<Ft.Pickable),s.elevationOffset=e.elevationOffsets?.[i]??0}}_getSymbolInfo(e,t){const i=e?.getSymbol(t,{arcade:this._arcade});if(!(i instanceof ge))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=st(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?ne(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=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=re(5*e.featureIds.length));const d=new dt,h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=Rt.OPAQUE,m=rt,g=0;for(let f=0;f<e.featureIds.length;f++){if(null!=o&&(i[o]=e.featureIds[f]),a&&n)for(let e=0;e<n.length;e++)i[n[e]]=Ze(l[e],f);const r=s?this._getSymbolInfo(s,t):null;let h,p;if(d.pickable=!0,s&&"visualVariables"in s){if(this._colorVariable){const e=de(this._colorVariable,t,{color:qt,arcade:this._arcade});e&&(h=d.color,h[0]=e.r/255,h[1]=e.g/255,h[2]=e.b/255,h[3]=e.a??1,this._opacityVariable||null===e.a||(p=e.a))}this._opacityVariable&&(p=he(this._opacityVariable,t,{arcade:this._arcade}))}if(r?.material){const e=r.material;h=null==h||null==p?Oe(h,p,e.color,e.alpha,Dt,d.color):Oe(h,p,null,null,Dt,d.color)}if(h??=P(d.color,1,1,1,1),d.colorMixMode=r?.material?.colorMixMode??mt.Multiply,d.edgeMaterial=r?.edgeMaterial,this._symbologyOverride?.(t,d),null!=this._nodeColorOverride&&(this._nodeColorOverride(e.node,h),d.colorMixMode=mt.Replace),d.pickable&&=h[3]>=jt,d.castShadows=r?r.castShadows:d.pickable,null!=d.edgeMaterial){const t=h[3]>=1&&(e.material.isOpaque||d.colorMixMode===mt.Replace)?Rt.OPAQUE:Rt.TRANSPARENT;d.edgeMaterial===u&&t===_||(m={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,_=t),e.cachedEdgeMaterials[f]=m}else e.cachedEdgeMaterials[f]=rt;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<<Ft.CastShadows|+d.pickable<<Ft.Pickable}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||Zt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some((e=>e!==rt)),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map(((t,o)=>e.featureIds[o]!==i[s]?rt:(r=r||t!==rt,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)),Zt(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,Ut.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._shadeNormals&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){null!=this._edgeView&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?(t,i,s)=>s.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?Ce.CONTINUE:e(t,i,s):e}_forAllFeatures(e,t,i){for(const s of this._nodeId2Meta.values()){if(null==s)continue;if(null!=t){switch(t(s)){case Ce.EXIT:return;case Ce.SKIP:continue}}let r=Ce.CONTINUE;switch(i){case Me.ALL:r=this._forAllFeaturesOfNode(s,e);break;case Me.VISIBLE_ONLY:r=this._forAllVisibleFeaturesOfNode(s,e);break;case Me.QUERYABLE:r=this._forAllQueryableFeaturesOfNode(s,e)}if(r===Ce.EXIT)return}}_forAllFeaturesOfNode(e,t){let i=Ce.CONTINUE;const s=e.featureIds;for(let r=0;r<s.length;r++)if(i=t(s[r],r,e),i===Ce.EXIT)return i;return i}_forAllVisibleFeaturesOfNode(e,t){let i=Ce.CONTINUE;const s=e.featureIds;return this._collection.forEachVisibleComponent(e.objectHandle,(r=>(i=t(s[r],r,e),i===Ce.CONTINUE))),i}_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===tt.OUTSIDE)return Ce.CONTINUE;if(s===tt.INSIDE)return this._forAllFeaturesOfNode(e,i);const r=Ce.CONTINUE,o=e.featureIds,a=e.objectHandle,n=ot(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===Ce.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]=Ze(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e,t){if(_e(e))return ct;const s=ut(e);if(0===s.length)return ct;const r=t?.name??Ot,o=s[0]instanceof i?this._featureIdsFromGraphics(s):"number"==typeof s[0]?s:null;if(!o)return ct;const{set:a,handle:n}=this._highlights.acquireSet(r);return this._highlights.setFeatureIds(a,o),n}_featureIdsFromGraphics(e){const t=this.i3slayer.fieldsIndex,i=this._getObjectIdField();return e.map((e=>ht(t,e.attributes,i)))}resetHighlights(){l(this._highlights),this._highlights=new De({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,Me.ALL),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)})}_visibleGeometryChanged(e,t){this._elevationProvider&&(null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=f((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))),this._updateSnappingSources(e,t),this._elevationProvider.objectChanged(this._collection.getComponentObb(e.objectHandle)))}get performanceInfo(){return new ye(this.usedMemory,this._nodeId2Meta.size,Math.round(this._gpuMemoryEstimate/1048576),Math.round(this._geoMemoryEstimate/1048576),Math.round(this._texMemoryEstimate/1048576),Math.round(this.unloadedMemory/1048576),this._idbCacheEnabled?Math.round(100*this._idbCache.getHitRate()):0)}checkInvariants(){}get test(){}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(e)}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;Zt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch((e=>Pt(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=Yt(e);if(s){const t={context:i,buffer:s.buffer};Ee(t);const r=new Float64Array(s.buffer);e.forAll(((e,t)=>{const i=r[t],s=Re(i);e.imModificationImpact=s,s!==Be.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||this._needFilterResolve}trackSnappingSources(e){const t={events:e,fetchEdgeLocations:async(e,t,i)=>{const s=this._nodeId2Meta.get(e);if(null==s)throw new Error("invalid-node");const{origin:r,buffer:o}=await this._collection.extractEdgeInformation(s.objectHandle,t,i);return this._snappingLocationsApplyElevation(s,o,r),{type:"components",objectIds:s.featureIds,locations:o,origin:r}},remove:()=>r(this._snappingSourcesTrackers,t)};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach(((t,i)=>{if(null==t)return;const s=this._controller.getRenderMbs(t.node);s&&e.add(i,s)})),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||this.elevationInfo.mode===Ie.Absolute)return;const s=t.position0,r=t.position1,o=t.componentIndex,a=H(),n=H(),l=(e,t)=>{T(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,n),T(e,e,F(n,n,t)),N(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,a),l(a,t),s.setVec(d,a),r.getVec(d,a),l(a,t),r.setVec(d,a)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(null!=s)for(const r of this._snappingSourcesTrackers)t!==Ut.REMOVE&&t!==Ut.UPDATE||r.events.remove(i),t!==Ut.ADD&&t!==Ut.UPDATE||r.events.add(i,s)}};return e([b()],o.prototype,"_hasLoadedPBRTextures",void 0),e([b()],o.prototype,"_asyncModuleLoading",void 0),e([b()],o.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([b()],o.prototype,"view",void 0),e([b()],o.prototype,"i3slayer",void 0),e([b()],o.prototype,"_controller",void 0),e([b()],o.prototype,"_labeler",void 0),e([b()],o.prototype,"updating",void 0),e([b()],o.prototype,"suspended",void 0),e([b()],o.prototype,"contentVisible",null),e([b({readOnly:!0})],o.prototype,"legendEnabled",null),e([b()],o.prototype,"holeFilling",void 0),e([b(bt)],o.prototype,"updatingProgress",void 0),e([b()],o.prototype,"updatingProgressValue",null),e([b()],o.prototype,"hasTexturesOrVertexColors",null),e([b()],o.prototype,"rendererTextureUsage",null),e([b()],o.prototype,"elevationOffset",null),e([b()],o.prototype,"elevationInfo",null),e([b({type:Boolean})],o.prototype,"slicePlaneEnabled",void 0),e([b()],o.prototype,"supportedTextureEncodings",null),e([b({type:[le]})],o.prototype,"_modifications",void 0),e([b({readOnly:!0})],o.prototype,"clientGeometry",null),e([b()],o.prototype,"elevationRange",null),e([b()],o.prototype,"fullExtent",null),e([b()],o.prototype,"_elevationTask",void 0),e([b({readOnly:!0})],o.prototype,"_usePBR",null),o=e([v(St)],o),o};function Pt(e,t){c(e)||At().warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}var Ut;!function(e){e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE"}(Ut||(Ut={}));const kt=K(),Gt=X(),Lt=X(),Bt=new yt,qt=new t([0,0,0,0]),Wt=ie(0,0,0,0);function zt(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 Kt(e){return"geometryData"in e}function $t(e){return null!=e&&y(e.data)}function Qt(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&&y(s.data)&&(i+=s.data.byteLength);return i}function Xt(e,t){return t.byteSize>Vt?(At().warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}function Yt(e){if(0===e.length)return;const t=10*e.length,i=new Float64Array(t);let s=0;return e.forAll((e=>{let t=e.serviceObbInIndexSR;null==t&&(t=Bt,t.center=te(e.serviceMbsInIndexSR),t.halfSize=[e.serviceMbsInIndexSR[3],e.serviceMbsInIndexSR[3],e.serviceMbsInIndexSR[3]]);const r=t.data;i[s++]=r[0],i[s++]=r[1],i[s++]=r[2],i[s++]=r[3],i[s++]=r[4],i[s++]=r[5],i[s++]=r[6],i[s++]=r[7],i[s++]=r[8],i[s++]=r[9]})),i}class Jt{constructor(e,t,i){this.attributeInfo=e,this.meta=t,this.promise=i,this.allowMemCache=!0}}function Zt(e,t){e.forEach((e=>e.opacity=t))}class ei{constructor(e,t){this.mode=e,this.offset=t}}const ti=H(),ii=K(),si="elevation-change",ri="",oi="@null",ai="@ECEF",ni=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],li=new ft;function di(e,t,i){let s=e.elevationRangeMin,r=e.elevationRangeMax;const o=i;if(o>0){t.getCorners(ni);for(const e of ni){const t=V(e)-o;s=Math.min(s,t),r=Math.max(r,t)}}else{t.getCorners(ni);for(const e of ni){const t=e[2];s=Math.min(s,t),r=Math.max(r,t)}}e.expandElevationRangeValues(s,r)}function hi(e,t,i){const s=te(t),r=i>0?V(s)-i:s[2],o=se(t);e.expandElevationRangeValues(r-o,r+o)}function ci(e,t){const i=e.featureIds.slice();for(const s of t)if(s(i,e),0===i.length)break;return i.length===e.featureIds.length?e.featureIds:i}function ui(e,t,i){const s=new Array,r=e.filteredIds;if(null==r||t?.size||i?.size){if(null!=r){let o=0;e.featureIds.forEach(((e,a)=>{if(r[o]===e)++o;else if(!t?.has(e))return;i?.has(e)||s.push(a)}))}}else e.featureIds.forEach(((e,t)=>{r[s.length]===e&&s.push(t)}));return s}function _i(e,t,i){if(e&&t)for(const s of t){const t=(e.get(s)??0)+i;t>0?e.set(s,t):e.delete(s)}}var mi;function gi(e,t=mi.All){const i=new Map;for(const s of e){_i(i,t===mi.All?s?.featureIds:t===mi.Filtered?s?.filteredIds:s?.weaklyRemovedIds,1)}return i}!function(e){e[e.All=0]="All",e[e.Filtered=1]="Filtered",e[e.WeaklyRemoved=2]="WeaklyRemoved"}(mi||(mi={}));export{Ht 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 has from"../../../core/has.js";import a from"../../../core/Logger.js";import{equals as n}from"../../../core/MapUtils.js";import{destroyMaybe as l}from"../../../core/maybe.js";import d from"../../../core/PooledArray.js";import{ignoreAbortErrors as h,isAbortError as c,throwIfAborted as u,createResolver as _}from"../../../core/promiseUtils.js";import{initial as m,watch as g}from"../../../core/reactiveUtils.js";import{schedule as f}from"../../../core/scheduling.js";import{equals as p}from"../../../core/SetUtils.js";import{isArrayBuffer as y}from"../../../core/typedArrayUtil.js";import{property as b}from"../../../core/accessorSupport/decorators/property.js";import{subclass as v}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as I,invert as C}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as M}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as w,getTranslation as x}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as E,create as R}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as O}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{i as j,t as S,q as A,a as D,g as T,h as F,d as N,H as V}from"../../../chunks/vec32.js";import{create as H}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as P}from"../../../chunks/vec42.js";import{fromValues as U}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as k}from"../../../core/support/UpdatingHandles.js";import{getSphericalPCPF as G}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{localLinearScaleFactors as L}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as B}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as q}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as W}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as z}from"../../../geometry/projection/projectVectorToVector.js";import{create as K,fromBuffer as $,toRect as Q}from"../../../geometry/support/aaBoundingBox.js";import{create as X,intersects as Y}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as J}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as Z}from"../../../geometry/support/FloatArray.js";import{compactIndices as ee}from"../../../geometry/support/Indices.js";import{a as te,f as ie,g as se}from"../../../chunks/sphere.js";import{newUByteArray as re}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as oe}from"../../../layers/LayerConstants.js";import ae from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as ne}from"../../../layers/support/fieldUtils.js";import le from"../../../layers/support/SceneModification.js";import{getColor as de,getOpacity as he}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{isBasemapLayer as ce}from"../../../support/basemapUtils.js";import{getElevationOffset as ue}from"../../../support/elevationInfoUtils.js";import{isQuery as _e}from"../../../support/guards.js";import{loadArcade as me}from"../../../support/loadArcade.js";import ge from"../../../symbols/MeshSymbol3D.js";import fe from"../../../symbols/SimpleFillSymbol.js";import pe from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as ye}from"./I3SMeshViewPerformanceInfo.js";import{I3SMeshWorkerHandle as be,toWasmModification as ve}from"./I3SMeshWorkerHandle.js";import{ElevationMode as Ie,ForAllFeaturesReturnType as Ce,ForAllFeaturesMode as Me}from"./II3SMeshView3D.js";import{initialize as we,setModificationsSync as xe,filterObbsForModificationsSync as Ee,interpretObbModificationResults as Re}from"./SceneLayerWorker.js";import{overrideColor as Oe}from"./graphics/graphicUtils.js";import{areLabelsVisible as je}from"./graphics/Labeler.js";import{TextureUsage as Se,TextureEncoding as Ae}from"./i3s/enums.js";import De from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as Te}from"./i3s/I3SAsyncElevationUpdater.js";import{I3SCrossfadeHelper as Fe,NodeCrossfadeMetaData as Ne}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as Ve}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as He}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Pe,selectEncoding as Ue,defaultMaterial as ke,createTexture as Ge,configureMaterial as Le}from"./i3s/I3SMaterialUtil.js";import{NodeIMModificationImpact as Be,NodeState as qe}from"./i3s/I3SNode.js";import{I3SOverrides as We}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as ze}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as Ke,checkSceneLayerValid as $e,checkSceneLayerCompatibleWithView as Qe,whenGraphicAttributes as Xe,computeVisibilityObb as Ye,filterInPlace as Je,getCachedAttributeValue as Ze,intersectBoundingRectWithMbs as et,MbsIntersectResult as tt,addWraparound as it,getSymbolInfo as st,transparentEdgeMaterial as rt,getClipRect as ot}from"./i3s/I3SUtil.js";import{IDBCache as at}from"./i3s/IDBCache.js";import{IDBMockCache as nt}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as lt}from"./i3s/LayerElevationProvider.js";import{SymbologyInfo as dt}from"./i3s/SymbologyInfo.js";import{attributeLookup as ht}from"./support/attributeUtils.js";import{emptyHighlightHandle as ct,normalizeHighlightTargetExceptQuery as ut}from"./support/highlightUtils.js";import{makeScheduleFunction as _t}from"./support/makeScheduleFunction.js";import{ColorMixModeEnum as mt}from"./support/symbolColorUtils.js";import{debugFlags as gt}from"../support/debugFlags.js";import{ElevationRange as ft}from"../support/ElevationRange.js";import{toBoundingRect as pt}from"../support/extentUtils.js";import{Obb as yt}from"../support/orientedBoundingBox.js";import{updatingProgress as bt}from"../support/updatingProperties.js";import{glLayout as vt}from"../support/buffer/glUtil.js";import{ObjectParameters as It}from"../webgl-engine/collections/Component/ObjectParameters.js";import{createVertexBufferLayout as Ct,GeometryParameters as Mt}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as wt}from"../webgl-engine/collections/Component/Transform.js";import{TextureCoordinateType as xt}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{loadBasisTranscoder as Et}from"../webgl-engine/lib/BasisUtil.js";import{Transparency as Rt}from"../webgl-engine/lib/edgeRendering/interfaces.js";import{defaultHighlightName as Ot}from"../../support/HighlightDefaults.js";import{alphaCutoff as jt}from"../../../webscene/support/AlphaCutoff.js";const St="esri.views.3d.layers.I3SMeshView3D",At=()=>a.getLogger(St),Dt=[1,1,1,1];class Tt extends Ne{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}get cachedMemory(){return this.node.memory}get featureExtents(){return this._featureExtents??=new Float64Array(6*this.featureIds.length).fill(Number.POSITIVE_INFINITY),this._featureExtents}}var Ft;!function(e){e[e.CastShadows=4]="CastShadows",e[e.Pickable=5]="Pickable"}(Ft||(Ft={}));const Nt=26,Vt=100*o.MEGABYTES,Ht=t=>{let o=class extends t{constructor(){super(...arguments),this._applySSAO=!0,this._shadeNormals=!0,this._updatingHandles=new k,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._hasComponentData=!1,this._hasVertexColors=!1,this._nodeColorOverride=null,this.updating=!0,this.holeFilling="auto",this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=new Array,this.ignoresMemoryFactor=!1,this._layerUrl="",this._cacheKeySuffix=null,this._planetRadiusInGlobalMode=0,this._elevationTask=null,this._needFilterResolve=!1,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i,this._crossfadeHelper=new Fe(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 _isIntegratedMesh(){return"integrated-mesh"===this.i3slayer.type}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible&&this.fullOpacity>jt}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?"yes":"probably-not":"unknown"}get rendererTextureUsage(){return Ke(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?Se.AllTexturesPBR:Se.AllTextures:this._usePBR||this._hasLoadedPBRTextures?Se.GeometryTexturesPBR:Se.GeometryTextures}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;return null!=e&&"absolute-height"===e.mode?ue(e,this.i3slayer.spatialReference):0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return new ei(Ie.Absolute,0);const t=ue(e,this.i3slayer.spatialReference);switch(e.mode){case"absolute-height":return new ei(Ie.Absolute,t);case"relative-to-ground":return new ei(Ie.RelativeToGround,t);case"on-the-ground":return new ei(Ie.OnTheGround,0);default:return new ei(Ie.Absolute,0)}}get supportedTextureEncodings(){return Pe(this.view.stage.renderView.capabilities)}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){const e=this._nodeId2Meta,t=new ft;for(const i of e.values()){if(null==i)continue;const{node:{serviceMbsInIndexSR:e}}=i,[s,r,o,a]=e;t.expandElevationRangeValues(o-a,o+a)}return t.elevationRangeValid?t:null}get fullExtent(){return this.i3slayer.fullExtent}initialize(){const e=has("enable-feature:idb-mock-cache");this._idbCache=e?new nt(this.view,e):new at("esri-scenelayer-cache","geometries"),this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const t=this.view.resourceController,i=t.memoryController;this.i3sOverrides=new We({view:this.view,layer:this.i3slayer,memoryController:i}),this._worker=new be(_t(t)),this.addResolvingPromise(this._worker.promise);const s=this.i3slayer.store;this.addResolvingPromise(this._worker.setLegacySchema(this.uid,s.defaultGeometrySchema).catch(h)),$e(this.i3slayer),Qe(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new ae({layerView:this,worker:this._worker}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view.stage,this._collection=this._stage.renderView.componentObjectCollection,this.resetHighlights();const r=s.defaultGeometrySchema;if(this._isIntegratedMesh||!r)this._hasComponentData=!1;else{const e=r.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(r?.vertexAttributes.color??null)&&!this.i3slayer.cachedDrawingInfo?.color;const o=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,(e=>this._deleteComponentObject(e)));this._memCache=o;const a=this._controller,n=this._nodeId2Meta,d=this._nodeId2MetaReloading,c=e=>{const t=a.index;if(!t)return;const i=t.rootNode;if(!i)return;const s=t=>{const i=t.index,s=n.get(i)||d.get(i);return e(t,s?.objectHandle??null)};t.traverse(i,s)};this._intersectionHandler=new He({layerUid:this.layerUid,sublayerUid:this.sublayerUid,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:c}),this._updatingHandles.add((()=>this.layerUid),(e=>this._intersectionHandler.layerUid=e)),this._updatingHandles.add((()=>this.sublayerUid),(e=>this._intersectionHandler.sublayerUid=e)),this._elevationProvider=new lt({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add((()=>this.view.clippingArea),(()=>this._clippingAreaChanged()),m),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)),m),this._updatingHandles.add((()=>!this.suspended&&this.elevationInfo.mode!==Ie.Absolute),((e,t)=>{e?this.addHandles(this.view.basemapTerrain.on("elevation-change",(({extent:e})=>this._ensureElevationTask().addExtent(e))),si):t&&this.removeHandles(si)}),m),this._updatingHandles.add((()=>this._usePBR),(e=>this._updatePBR(e)));const u=()=>{this._reloadAll(),this.clearMemCache()};this._updatingHandles.add((()=>this.rendererTextureUsage),u),this._updatingHandles.add((()=>this.contentVisible),(e=>this._contentVisibleChanged(e)),m),this._updatingHandles.add((()=>this.i3slayer.labelsVisible),(()=>this._labelingChanged()),m),this._updatingHandles.add((()=>this.i3slayer.labelingInfo),(()=>this._labelingChanged()),m),this._updatingHandles.add((()=>this._modifications),(()=>this._modificationsChanged()),m),this.addHandles([g((()=>gt.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&>.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||gt.I3S_TREE_SHOW_TILES||(this._treeDebugger=l(this._treeDebugger))}),m),g((()=>gt.I3S_SHOW_MODIFICATIONS),(()=>this._showModifications()),m)]),this._cacheKeySuffix=this._getCacheKeySuffix(),this._idbCache.init().catch((e=>At().warn(`Failed to initialize IndexedDB cache: ${e}`)));const{view:_}=this,{viewingMode:f,renderCoordsHelper:p}=_;this._planetRadiusInGlobalMode="local"===f?0:p.referenceEllipsoid.radius}destroy(){this._clearAddTasks(),this._elevationTask=l(this._elevationTask),this.i3sOverrides=l(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.objectsChanged(this.getVisibleObbs()),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._worker;e&&(e.destroyContext(this.uid).then((()=>e.destroy())),this._worker=null),this._removeAllNodeDataFromStage(),this._memCache=l(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=l(this._labeler),this._treeDebugger=l(this._treeDebugger),this._controller=l(this._controller),this._highlights.destroy(),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=l(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null),this._updatingHandles=l(this._updatingHandles)}_memEstimateTextureAdded(e){const t=e.usedMemory;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(null!=e){const t=e.usedMemory;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(!(je(this.i3slayer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new pe({view:this.view,layer:this.i3slayer,collection:this._collection,overrides:this.i3sOverrides});this._nodeId2Meta.forEach((t=>null!=t&&this._addMetaToLabeler(e,t))),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then((e=>(--this._asyncModuleLoading,e)),(e=>{throw--this._asyncModuleLoading,e}))}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=we().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=ve(this._layerClippingArea,this._modifications,t);xe({context:e,modifications:i,isGeodetic:t.isGeographic}),this._controller.modificationsChanged();const s=this.hasModifications?new d:null;this._nodeId2Meta.forEach(((e,t)=>{null==e?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._updateFeatureIdCounts(e,-1),this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):null!=s&&s.push(e.node)})),this.notifyChange("elevationRange"),null!=s&&this._nodeId2MetaReloading.forEach((e=>s.push(e.node))),null!=s&&s.length>0&&(this.updateNodeModificationStatus(s),s.forAll((e=>{if(e.imModificationImpact!==Be.Culled){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),null!=t?(this._updateFeatureIdCounts(t,-1),this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t),this.notifyChange("elevationRange")):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}}))),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(null!=this._modificationGraphics&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!gt.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={outline:{color:[255,255,255],width:1}};this._modificationGraphics=[];for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.i3slayer.spatialReference;const o=new fe({...t,color:e[s.type]});this._modificationGraphics.push(new i({geometry:r,symbol:o}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,((e,t)=>this._createAttributes(e,t)))}_contentVisibleChanged(e){e?(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler)):(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);null!=i?.attributeInfo&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);null!=s&&(await this.i3sOverrides.applyAttributeOverrides(s.featureIds,t,i,this._controller.requiredAttributes),s.attributeInfo=t,this._controller.reschedule((()=>this._attributeValuesChanged(s)),i).catch((e=>{c(e)||At().warn("Error while updating attribute values. Layer might not display correctly.",e)})))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.appliedFilters=null,null!=this._labeler&&this._labeler.setNodeMetaAttributes(e,((e,t)=>this._createAttributes(e,t))),this._updateEngineObject(e)}clearMemCache(){null!=this._memCache&&this._memCache.clear(),this._addTasks.forEach((e=>e.allowMemCache=!1))}getVisibleNodes(){const e=new Array;return this._nodeId2Meta.forEach((t=>null!=t&&e.push(t.node))),e}getVisibleObbs(){const e=new Array;return this._nodeId2Meta.forEach((t=>t&&e.push(this._collection.getComponentObb(t.objectHandle)))),e}getLoadedNodeIndices(e){this._nodeId2Meta.forEach(((t,i)=>e.push(i))),this._nodeId2MetaReloading.forEach(((t,i)=>e.push(i)))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&this.supportedTextureEncodings&Ae.Basis&&this.i3slayer.textureSetDefinitions?.some((e=>e.formats.some((e=>"basis"===e.format||"ktx2"===e.format))))&&Et()}_getVertexBufferLayout(e,t){return vt(Ct(this._getGeometryParameters({hasTexture:zt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion})))}_getObjectIdField(){return this.i3slayer.objectIdField||oe}_getGlobalIdField(){return this.i3slayer.associatedLayer?.globalIdField}_findGraphicNodeAndIndex(e){const t=ht(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());for(const i of this._nodeId2Meta.values()){const e=i?.featureIds.indexOf(t);if(null!=e&&e>=0)return{node:i.node,index:e}}return null}_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=ht(o,a.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this._getAABB(t.node.index,t.index);return null==i?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this._getAABB(e.nodeIndex,e.componentIndex)}_getAABB(e,t){const i=this._nodeId2Meta.get(e);if(null==i?.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=Ve(t,this._collection,s,J(24),0),o=this.view.renderSpatialReference,a=this.view.spatialReference;return q(r,o,0,r,a,0)?$(r):null}whenGraphicAttributes(e,t){return Xe(this.i3slayer,e,this._getObjectIdField(),t,(()=>[...this._nodeId2Meta.values()].filter(s)))}getGraphicFromIntersectorTarget(e){if(null==e.nodeIndex||null==e.componentIndex)return null;const t=this._nodeId2Meta.get(e.nodeIndex);return null==t?.featureIds||e.componentIndex>=t.featureIds.length?null:this._createGraphic(e.componentIndex,t)}_getCacheKey(e){return`${this._layerUrl}/v${Nt}/${e}${this._cacheKeySuffix}`}_getCacheKeySuffix(){const e=this.view.renderSpatialReference;if(null==e)return oi;if(e===G(e))return ai;return this.i3slayer.spatialReference.equals(e)?ri:null!=e.wkid?`@${e.wkid}`:null}_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,i)}loadMissingTextures(e,t,i,s){const r=e?.filter(((e,i)=>{if(!(e.usage&this.rendererTextureUsage))return!1;if(null==t)return!0;const s=Ue(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(null==r?.data||s&&r.encoding!==s.encoding)}))??[];return 0===r.length?Promise.resolve(!1):i(r,s).then((i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0}))}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then((s=>null==s?null:s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(this.elevationInfo.mode===Ie.Absolute&&(e.geometryObbInRenderSR=yt.fromData(s.geometryObbData)),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then((i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=Qt(s.transformedGeometry,s.textureData),s.textureData.every($t)&&Xt(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch((t=>At().warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`)))),u(t),s)))))):Promise.resolve(null)}addNode(e,t,i){return Kt(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,globalTrafo:h}=s,c=j(ti,r.center.x,r.center.y,r.center.z);S(c,c,h);const u=new yt(c,[r.extents.x,r.extents.y,r.extents.z],O(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));this.elevationInfo.mode===Ie.Absolute&&(e.geometryObbInRenderSR=u),t.geometryData.componentOffsets=o,a&&(t.geometryData.featureIds=Array.from(a)),t.geometryData.anchorIds=n,t.geometryData.anchors=l;const _={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:d,globalTrafo:h,geometryObbData:u.data,byteSize:Qt(d,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&Xt(e,_)){const t=null!=_.textureData?_.textureData.map((e=>$t(e)?e:null)):null;this._idbCache.put(this._getCacheKey(e.id),{..._,textureData:t}).catch((t=>At().warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`)))}return this._addCachedNodeData(e,_,i)}),i))))):Promise.reject()}getElevationRange(e){const t=new ft,i=this._controller,{index:s}=i;if(!s)return t;const{rootNode:r}=s;if(!r)return t;const o=this._nodeId2Meta,a=e[3],n=i.viewportQueries,l=this._planetRadiusInGlobalMode,{view:d}=this,{renderCoordsHelper:h}=d,c=h.referenceEllipsoid.radius,u=this._collection,_=i=>{const{childrenLoaded:s}=i;if(0===s)return!1;const r=n.getAndUpdateVisibilityObbInRenderSR(i);let d=null,_=-1;if(r){if(_=r.radius,!r.intersectSphereWithMBS(e,_))return!1}else d=n.getServiceMbsInRenderSR(i),d&&(_=d[3]);if(_>=0&&a>=1*_)return null!=r?di(t,r,l):null!=d&&d[3]>=0&&hi(t,d,l),!1;const m=li;if(m.elevationRangeMin=1/0,m.elevationRangeMax=-1/0,(null!=r||null!=d)&&(null!=r?di(m,r,l):null!=d&&hi(m,d,l),m.elevationRangeMin>=t.elevationRangeMin&&m.elevationRangeMax<=t.elevationRangeMax))return!1;const g=o.get(i.index);if(g){const{geometryObbInRenderSR:s}=i;if(!s||s.intersectSphereWithMBS(e)){if(s){if(a>0*s.radius)return di(t,s,l),!1}const{objectHandle:e}=g,i=u.getObjectTransform(e),r=h.getAltitude(i.position);u.expandRangeWithComponentObjectElevationRange(e,r,c,t)}}return s-(g?1:0)>0};return s.traverse(r,_),t}computeVisibilityObb(e){return Ye(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications,this.view.renderCoordsHelper.sphericalPCPF)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let f=0;f<s.length;++f)r[f]=this._getVertexBufferLayout(s[f],t.geometryDescriptor);const o=this.i3slayer.normalReferenceFrame,a=t.normalReferenceFrame??o??"none",n=e.serviceMbsInIndexSR,l=this.elevationOffset,d=this._controller.crsIndex,h=this._controller.crsVertex,c=this.view.renderSpatialReference,u=ze(n,l,a,d,c),_=W(d,h),m=W(h,c);if(null==_||null==m)return Promise.resolve(null);const g={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,globalTrafo:u,mbs:n,obbData:e.serviceObbInIndexSR?.data,elevationOffset:l,needNormals:this._controller.isMeshPyramid,normalReferenceFrame:a,indexToVertexProjector:_,vertexToRenderProjector:m};return this._worker.invoke(g,i)}get _supportsNodeCrossFading(){return!this.view?.stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){const t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,i){if(this.elevationInfo.mode===Ie.Absolute&&(e.geometryObbInRenderSR=this._collection.getComponentObb(t.objectHandle).clone()),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);null!=this._labeler&&this._addMetaToLabeler(this._labeler,t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,!0),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==Ie.Absolute&&this._ensureElevationTask().schedule(s),this._updateEngineObject(t),this._highlights.objectCreated(t),null!=this._treeDebugger&&this._treeDebugger.update()}addCachedNodeData(e,t,i,s){return this._addData(e,i,(()=>this._addCachedNodeData(e,t,s)))}async deleteCachedNodeData(e){if(this._idbCacheEnabled)return this._idbCache.remove(this._getCacheKey(e))}async _addCachedNodeData(e,t,i){if(!this.contentVisible||!this._controller.isGeometryVisible(e))return void this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);if(null==t)return void this._addNodeMeta(e.index,null);const s=this._addTasks.get(e.index),{geometryData:r,transformedGeometry:o,globalTrafo:a}=t;await this.i3sOverrides.applyAttributeOverrides(r.featureIds,s.attributeInfo,i,this._controller.requiredAttributes);const n=null!=t.textureData?t.textureData.filter((e=>null!=e&&!!(e.usage&this.rendererTextureUsage))):[];!has("disable-feature:i3s-basis")&&n.some((e=>null!=e&&(e.encoding===Ae.Basis||e.encoding===Ae.KTX2)))&&await Et(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:h,anchorIds:c,anchors:u}=r,_=this._collection,m=d[0],{layout:g,indices:f,interleavedVertexData:p,positionData:y,hasColors:b}=o,{material:v,geometryParameters:O}=this._materialParameters(m,g),j=l||new Uint32Array([0,f?f.length:p.byteLength/g[0].stride]),S={vertices:{data:p,count:p.byteLength/g[0].stride,layoutParameters:O},positionData:{positions:Z(y.data),indices:ee(y.indices)},indices:f,componentOffsets:j},T=m.transformation?E(m.transformation):R();w(T,a,T);const F=x(H(),T),N=I(M(),T),V=this.view.renderSpatialReference,P=this.view.basemapTerrain.spatialReference,k=yt.fromData(t.geometryObbData).center,G=[1,1,1];L(k,V,G,P)||At().errorOnce("Unsupported coordinate system for IM overlay");const B=H();z(k,V,B,P);const q=M();C(q,N);const W=H();A(W,D(W,k,F),q);const K=B[0]-W[0]*G[0],$=B[1]-W[1]*G[1],Q=_.createObject(new It(U(K,$,G[0],G[1]),new wt(F,N),yt.fromData(t.geometryObbData),S)),X=O.textureCoordinates===xt.Atlas,{textures:Y,texturePromise:J}=this._initMaterialAndTextures(Q,v,n,X);e.memory+=this._memEstimateGeometryAdded(Q),e.memory+=Y.reduce(((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0)),0);const te=!!v.hasParametersFromSource,ie="blend"!==v.alphaMode&&v.metallicRoughness.baseColorFactor[3]>=1,se=new Tt(e,h,Q,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:te,isOpaque:ie},Y,c,u);s.meta=se,this._hasTextures||=t.requiredTextures?.some((({usage:e})=>!!(e&Se.ColorTextures))),this._hasData=!0,this._hasColors||=b,this._hasTextures||=!!e.resources.texture,this.notifyChange("hasTexturesOrVertexColors");const re=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(se),J]).then((([t,s])=>(this._addTasks.has(e.index)&&t?.updateObjectVisibility(se.objectHandle,!1).catch((e=>Pt(e,this.i3slayer.title))),this._safeReschedule((()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,se),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(Q,!0),t?.updateObjectVisibility(se.objectHandle,!0).catch((e=>Pt(e,this.i3slayer.title))),se.attributeInfo=i.attributeInfo;const s=se.cachedRendererVersion!==this._rendererVersion,r=re!==this.slicePlaneEnabled;this._updateElevationOffsets(se);const o=se.elevationOffsets;this._updateComponentData(se);const a=this._applyFiltersToNode(se);(s||null!=t&&(r||a||o))&&this._addOrUpdateEdgeRendering(se),null!=this._labeler&&this._addMetaToLabeler(this._labeler,se),this._visibleGeometryChanged(se,Ut.ADD),this._highlights.objectCreated(se),this._updateMaterial(se),this._setNewNodeOpacity(se),null!=this._treeDebugger&&this._treeDebugger.update()}),i)))).catch((e=>{const{meta:t,allowMemCache:i}=s;throw s.meta=null,t&&i?this._cacheGPUData(t):t&&this._deleteComponentObject(t),e}))}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){At().error("Removing duplicated node");const t=this._nodeId2Meta.get(e);t&&(this._deleteComponentObject(t),this._updateFeatureIdCounts(t,-1))}else this._controller.updateLoadStatus(e,!0);t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&Zt(t.cachedEdgeMaterials,0),this._updateFeatureIdCounts(t,1)),this._nodeId2Meta.set(e,t),this.notifyChange("elevationRange")}_updateElevationOffsets(e){const t=this.view.renderSpatialReference,i=this._controller.crsIndex,s=this.elevationInfo,r=this.view.basemapTerrain,o=r.spatialReference,a=s.mode;if(null==t||null==o||a===Ie.Absolute)return void(e.elevationOffsets=null);const n=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const l=ti,d=ii,h=a===Ie.OnTheGround,c=this.view.renderCoordsHelper,u=e.featureIds.length,_=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const s=J(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?(j(l,e.anchors[3*h],e.anchors[3*h+1],e.anchors[3*h+2]),T(l,l,te(e.node.serviceMbsInIndexSR)),z(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),j(l,(d[0]+d[3])/2,(d[1]+d[4])/2,d[2]),A(l,l,n.rotationScale),T(l,l,n.position),s[a+2]=c.getAltitude(l),z(l,t,l,o),s[a]=l[0],s[a+1]=l[1])}return s})(),m=s.offset,g=e.elevationOffsets,f=(e,t)=>{const i=h?_[3*e+2]:0;g[e]=m+(t??0)-i};r.getElevations(_,u,f)}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new Te(this.view.resourceController.scheduler,(e=>this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference)?.filterInPlace((e=>null!=this._nodeId2Meta.get(e)))),(e=>this._nodeElevationAlignmentChanged(this._nodeId2Meta.get(e))),(()=>this.elevationInfo?.mode))),this._elevationTask}_elevationInfoChanged(e,t){const i=e.mode!==Ie.Absolute,s=!!t&&t!==e&&t.mode!==Ie.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,Ut.UPDATE),this._elevationProvider.objectChanged(this._collection.getComponentObb(e.objectHandle)))}_safeReschedule(e,t){return u(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:ke(),s=t.some((e=>"uvRegion"===e.name)),r=t.some((e=>"normalCompressed"===e.name)),o=zt(i);return{geometryParameters:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s){const r=this._stage.renderView,o=i.map((e=>Ge(e,t,s,r)));this._stage.addMany(o);let a=null;return this._collection.updateMaterial(e,(e=>{a=Le(e,t,o,i,this.view.stage.renderView.textures,{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 new Mt(this._hasVertexColors,e.hasTexture?e.hasRegions?xt.Atlas:xt.Default:xt.None,e.hasNormals,this._shadeNormals,this._applySSAO)}_addData(e,t,i){let s=this._addTasks.get(e.index);if(s)s.attributeInfo=t;else{const r=_();s=new Jt(t,null,r.promise),this._addTasks.set(e.index,s),i().then(r.resolve,r.reject).then((()=>this._addTasks.delete(e.index))).catch((t=>{throw this._addTasks.delete(e.index),t}))}return 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=X();this._renderClippingArea=pt(this.view.clippingArea,i,e)?i:null;const s=X();this._layerClippingArea=pt(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),this._assertFeatureIdNodeCounts(e)}_assertFeatureIdNodeCounts(e){e&&!this._featureIdCounts?(this._featureIdCounts=gi(this._nodeId2Meta.values()),this._filteredIdCounts=gi(this._nodeId2Meta.values(),mi.Filtered),this._weaklyRemovedIdCounts=gi(this._nodeId2Meta.values(),mi.WeaklyRemoved),this.addHandles(g((()=>this._controller.updating),(e=>{!e&&this._needFilterResolve&&(this.multiGeometryFilterResolve(),this._needFilterResolve=!1,this.notifyUpdate())}),{sync:!0}),"updateFinished")):!e&&this._featureIdCounts&&(this._featureIdCounts=null,this._filteredIdCounts=null,this._weaklyRemovedIdCounts=null,this._mismatchShow=null,this._mismatchHide=null,this.removeHandles("updateFinished"),this._needFilterResolve=!1,this.notifyUpdate())}_updateFeatureIdCounts(e,t){this._featureIdCounts&&(this._needFilterResolve=!0,_i(this._featureIdCounts,e.featureIds,t),_i(this._filteredIdCounts,e.filteredIds,t),_i(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,t))}_updateFilteredIdCounts(e,t,i){this._filteredIdCounts&&(this._needFilterResolve=!0,_i(this._filteredIdCounts,t,-1),_i(this._filteredIdCounts,e.filteredIds,1),_i(this._weaklyRemovedIdCounts,i,-1),_i(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,1))}_checkFeatureIdNodeCountInvariant(){const e=null!=this._featureIdCounts;if(this.hasGeometryFilter!==e&&At().error("checkFeatureIdNodeCountInvariant()","LayerView should have feature id node counts if and only if it has a geometry filter",{layerView:this,hasNodeCounts:e}),!this._featureIdCounts||!this._filteredIdCounts)return;const t=gi(this._nodeId2Meta.values());n(this._featureIdCounts,t)||At().error("checkFeatureIdNodeCountInvariant()","Incorrect _featureIdCounts",{layerView:this,counts:this._featureIdCounts,expected:t});const i=gi(this._nodeId2Meta.values(),mi.Filtered);n(this._filteredIdCounts,i)||At().error("checkFeatureIdNodeCountInvariant()","Incorrect _filteredIdCounts",{layerView:this,counts:this._filteredIdCounts,expected:i});const s=gi(this._nodeId2Meta.values(),mi.WeaklyRemoved);n(this._weaklyRemovedIdCounts,s)||At().error("checkFeatureIdNodeCountInvariant()","Incorrect _weaklyRemovedIdCounts",{layerView:this,counts:this._weaklyRemovedIdCounts,expected:i})}multiGeometryFilterResolve(){if(!this._featureIdCounts||!this._filteredIdCounts)return;let e=null,t=null;for(const[i,s]of this._filteredIdCounts){const r=this._featureIdCounts.get(i);if(r!==s){s+(this._weaklyRemovedIdCounts?.get(i)??0)===r?(e??=new Set,e.add(i)):(t??=new Set,t.add(i))}}p(e,this._mismatchShow)&&p(t,this._mismatchHide)||(this._mismatchShow=e,this._mismatchHide=t,this._nodeId2Meta.forEach((e=>{if(!e?.filteredIds)return;const t=ui(e,this._mismatchShow,this._mismatchHide);this._collection.setAllComponentVisibilities(e.objectHandle,t),this._visibleGeometryChanged(e,Ut.UPDATE)})))}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach((e=>{e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Ut.UPDATE))}))}getFilters(){const e=[],t=this._renderClippingArea;return null!=t&&e.push(((e,i)=>this._boundingRectFilter(e,i,t))),e}addSqlFilter(e,t,i){if(null!=t){const s=t.fieldNames;e.push(((e,r)=>this._sqlFilter(e,r,t,s,i)))}}_sqlFilter(e,t,i,s,r){const o={},a=this._createLayerGraphic(o),n=this.i3slayer.objectIdField,l=t.featureIds,d=t.attributeInfo?.attributeData;s.every((e=>e===n||null!=d?.[e]))&&Je(e,l,(e=>{o[n]=l[e];for(const i of s)i!==n&&(o[i]=d?Ze(d[i],e):null);try{return i.testFeature(a)}catch(t){return r(t),!1}}))}_boundingRectNodeTest(e,t){return B(e.node.serviceMbsInIndexSR,this._controller.crsIndex,Wt,this.view.renderSpatialReference),et(t,Wt)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,kt),Q(kt,Gt),Y(i,Gt)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(r===tt.INSIDE)return;if(r===tt.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(Lt,i,t.objectHandle);Je(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}async _addOrUpdateEdgeRendering(e,t=!0){const i=e.objectHandle,{hasEdges:s,perFeatureEdgeMaterials:r}=this._getFilteredEdgeMaterials(e);s&&!this._edgeView&&(this._edgeView=await this._stage.renderer.loadEdgeView());const o=this._edgeView;if(!o)return null;const a=o.hasObject(i);if(s){if(a){if(this.nodeCrossfadingEnabled){Zt(r,this.getNodeOpacity(e))}return o.updateAllComponentMaterials(i,r,this.slicePlaneEnabled,t).catch((e=>Pt(e,this.i3slayer.title))),o.updateObjectVisibility(i,!0).catch((e=>Pt(e,this.i3slayer.title))),o.updateAllVerticalOffsets(i,e.elevationOffsets).catch((e=>Pt(e,this.i3slayer.title))),o}const s=await this._collection.addEdges(i,o,r,this.slicePlaneEnabled,e.elevationOffsets);return e.edgeMemoryUsage=s,e.node.memory+=s,o}return a&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,o.removeObject(i)),null}_applyFiltersToNode(e){const t=e.filteredIds,i=e.weaklyRemovedIds;return!!this._applyFiltersToNodeComponents(e)&&(this._updateFilteredIdCounts(e,t,i),this._labeler?.applyFilterChange(e),!0)}_applyFiltersToNodeComponents(e){const t=this._collection,i=t.getComponentCount(e.objectHandle),s=null!=e.filteredIds,r=0===i.invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!r;if(null!=e.filteredIds&&e.appliedFilters===this._filters||(e.weaklyRemovedIds=null,e.filteredIds=ci(e,this._filters),e.appliedFilters=this._filters),s&&e.filteredIds===e.featureIds&&(!this._mismatchHide||e.filteredIds.every((e=>!this._mismatchHide?.has(e)))))return!r;const o=ui(e,this._mismatchShow,this._mismatchHide);return t.setAllComponentVisibilities(e.objectHandle,o),!0}_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=l(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),null!=this._elevationTask&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);null!=s?(this._collection.setObjectVisibility(s.objectHandle,!1),null!=this._edgeView&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch((e=>Pt(e,this.i3slayer.title))),this._visibleGeometryChanged(s,Ut.REMOVE),null!=this._labeler&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights.objectDeleted(s),i===this._nodeId2Meta?(this._updateFeatureIdCounts(s,-1),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===qe.Hole))}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){const i=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,i),this.notifyChange("elevationRange")}const i=this._nodeId2MetaReloading.get(e);i&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,i))}_invalidateAllSymbols(){this._rendererVersion=it(this._rendererVersion,1),this._controller&&this._controller.requestUpdate()}_getInvalidRendererVersion(){return it(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=it(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 me()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:At().warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.symbols)"mesh-3d"!==t.type&&At().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;P(s.externalColor,t[r]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255);const o=this._stage.renderView.olidRenderHelper;if(o){const t=e.featureIds[i],r=ce(this.view.map,this.layerUid);o.setUidToObjectAndLayerId(t,t,this.layerId,this.layerUid+"_"+this.sublayerId,this.layerPopupEnabledAndHasTemplate&&!r,e.node.resources.attributes,i,this.sublayerId),s.objectAndLayerIdColor=this._stage.renderView.getObjectAndLayerIdColor({graphicUid:t,layerUid:this.layerUid+"_"+this.sublayerId})}s.externalColorMixMode=t[r+4]&(1<<Ft.CastShadows)-1,s.castShadows=!!(t[r+4]&1<<Ft.CastShadows),s.pickable=!!(t[r+4]&1<<Ft.Pickable),s.elevationOffset=e.elevationOffsets?.[i]??0}}_getSymbolInfo(e,t){const i=e?.getSymbol(t,{arcade:this._arcade});if(!(i instanceof ge))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=st(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?ne(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=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=re(5*e.featureIds.length));const d=new dt,h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=Rt.OPAQUE,m=rt,g=0;for(let f=0;f<e.featureIds.length;f++){if(null!=o&&(i[o]=e.featureIds[f]),a&&n)for(let e=0;e<n.length;e++)i[n[e]]=Ze(l[e],f);const r=s?this._getSymbolInfo(s,t):null;let h,p;if(d.pickable=!0,s&&"visualVariables"in s){if(this._colorVariable){const e=de(this._colorVariable,t,{color:qt,arcade:this._arcade});e&&(h=d.color,h[0]=e.r/255,h[1]=e.g/255,h[2]=e.b/255,h[3]=e.a??1,this._opacityVariable||null===e.a||(p=e.a))}this._opacityVariable&&(p=he(this._opacityVariable,t,{arcade:this._arcade}))}if(r?.material){const e=r.material;h=null==h||null==p?Oe(h,p,e.color,e.alpha,Dt,d.color):Oe(h,p,null,null,Dt,d.color)}if(h??=P(d.color,1,1,1,1),d.colorMixMode=r?.material?.colorMixMode??mt.Multiply,d.edgeMaterial=r?.edgeMaterial,this._symbologyOverride?.(t,d),null!=this._nodeColorOverride&&(this._nodeColorOverride(e.node,h),d.colorMixMode=mt.Replace),d.pickable&&=h[3]>=jt,d.castShadows=r?r.castShadows:d.pickable,null!=d.edgeMaterial){const t=h[3]>=1&&(e.material.isOpaque||d.colorMixMode===mt.Replace)?Rt.OPAQUE:Rt.TRANSPARENT;d.edgeMaterial===u&&t===_||(m={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,_=t),e.cachedEdgeMaterials[f]=m}else e.cachedEdgeMaterials[f]=rt;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<<Ft.CastShadows|+d.pickable<<Ft.Pickable}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||Zt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some((e=>e!==rt)),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map(((t,o)=>e.featureIds[o]!==i[s]?rt:(r=r||t!==rt,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)),Zt(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,Ut.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._shadeNormals&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){null!=this._edgeView&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?(t,i,s)=>s.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?Ce.CONTINUE:e(t,i,s):e}_forAllFeatures(e,t,i){for(const s of this._nodeId2Meta.values()){if(null==s)continue;if(null!=t){switch(t(s)){case Ce.EXIT:return;case Ce.SKIP:continue}}let r=Ce.CONTINUE;switch(i){case Me.ALL:r=this._forAllFeaturesOfNode(s,e);break;case Me.VISIBLE_ONLY:r=this._forAllVisibleFeaturesOfNode(s,e);break;case Me.QUERYABLE:r=this._forAllQueryableFeaturesOfNode(s,e)}if(r===Ce.EXIT)return}}_forAllFeaturesOfNode(e,t){let i=Ce.CONTINUE;const s=e.featureIds;for(let r=0;r<s.length;r++)if(i=t(s[r],r,e),i===Ce.EXIT)return i;return i}_forAllVisibleFeaturesOfNode(e,t){let i=Ce.CONTINUE;const s=e.featureIds;return this._collection.forEachVisibleComponent(e.objectHandle,(r=>(i=t(s[r],r,e),i===Ce.CONTINUE))),i}_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===tt.OUTSIDE)return Ce.CONTINUE;if(s===tt.INSIDE)return this._forAllFeaturesOfNode(e,i);const r=Ce.CONTINUE,o=e.featureIds,a=e.objectHandle,n=ot(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===Ce.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]=Ze(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e,t){if(_e(e))return ct;const s=ut(e);if(0===s.length)return ct;const r=t?.name??Ot,o=s[0]instanceof i?this._featureIdsFromGraphics(s):"number"==typeof s[0]?s:null;if(!o)return ct;const{set:a,handle:n}=this._highlights.acquireSet(r);return this._highlights.setFeatureIds(a,o),n}_featureIdsFromGraphics(e){const t=this.i3slayer.fieldsIndex,i=this._getObjectIdField();return e.map((e=>ht(t,e.attributes,i)))}resetHighlights(){l(this._highlights),this._highlights=new De({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,Me.ALL),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)})}_visibleGeometryChanged(e,t){this._elevationProvider&&(null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=f((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))),this._updateSnappingSources(e,t),this._elevationProvider.objectChanged(this._collection.getComponentObb(e.objectHandle)))}get performanceInfo(){return new ye(this.usedMemory,this._nodeId2Meta.size,Math.round(this._gpuMemoryEstimate/1048576),Math.round(this._geoMemoryEstimate/1048576),Math.round(this._texMemoryEstimate/1048576),Math.round(this.unloadedMemory/1048576),this._idbCacheEnabled?Math.round(100*this._idbCache.getHitRate()):0)}checkInvariants(){}get test(){}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(e)}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;Zt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch((e=>Pt(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=Yt(e);if(s){const t={context:i,buffer:s.buffer};Ee(t);const r=new Float64Array(s.buffer);e.forAll(((e,t)=>{const i=r[t],s=Re(i);e.imModificationImpact=s,s!==Be.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||this._needFilterResolve}trackSnappingSources(e){const t={events:e,fetchEdgeLocations:async(e,t,i)=>{const s=this._nodeId2Meta.get(e);if(null==s)throw new Error("invalid-node");const{origin:r,buffer:o}=await this._collection.extractEdgeInformation(s.objectHandle,t,i);return this._snappingLocationsApplyElevation(s,o,r),{type:"components",objectIds:s.featureIds,locations:o,origin:r}},remove:()=>r(this._snappingSourcesTrackers,t)};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach(((t,i)=>{if(null==t)return;const s=this._controller.getRenderMbs(t.node);s&&e.add(i,s)})),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||this.elevationInfo.mode===Ie.Absolute)return;const s=t.position0,r=t.position1,o=t.componentIndex,a=H(),n=H(),l=(e,t)=>{T(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,n),T(e,e,F(n,n,t)),N(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,a),l(a,t),s.setVec(d,a),r.getVec(d,a),l(a,t),r.setVec(d,a)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(null!=s)for(const r of this._snappingSourcesTrackers)t!==Ut.REMOVE&&t!==Ut.UPDATE||r.events.remove(i),t!==Ut.ADD&&t!==Ut.UPDATE||r.events.add(i,s)}};return e([b()],o.prototype,"_hasLoadedPBRTextures",void 0),e([b()],o.prototype,"_asyncModuleLoading",void 0),e([b()],o.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([b()],o.prototype,"view",void 0),e([b()],o.prototype,"i3slayer",void 0),e([b()],o.prototype,"_controller",void 0),e([b()],o.prototype,"_labeler",void 0),e([b()],o.prototype,"updating",void 0),e([b()],o.prototype,"suspended",void 0),e([b()],o.prototype,"contentVisible",null),e([b({readOnly:!0})],o.prototype,"legendEnabled",null),e([b()],o.prototype,"holeFilling",void 0),e([b(bt)],o.prototype,"updatingProgress",void 0),e([b()],o.prototype,"updatingProgressValue",null),e([b()],o.prototype,"hasTexturesOrVertexColors",null),e([b()],o.prototype,"rendererTextureUsage",null),e([b()],o.prototype,"elevationOffset",null),e([b()],o.prototype,"elevationInfo",null),e([b({type:Boolean})],o.prototype,"slicePlaneEnabled",void 0),e([b()],o.prototype,"supportedTextureEncodings",null),e([b({type:[le]})],o.prototype,"_modifications",void 0),e([b({readOnly:!0})],o.prototype,"clientGeometry",null),e([b()],o.prototype,"elevationRange",null),e([b()],o.prototype,"fullExtent",null),e([b()],o.prototype,"_elevationTask",void 0),e([b({readOnly:!0})],o.prototype,"_usePBR",null),o=e([v(St)],o),o};function Pt(e,t){c(e)||At().warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}var Ut;!function(e){e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE"}(Ut||(Ut={}));const kt=K(),Gt=X(),Lt=X(),Bt=new yt,qt=new t([0,0,0,0]),Wt=ie(0,0,0,0);function zt(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 Kt(e){return"geometryData"in e}function $t(e){return null!=e&&y(e.data)}function Qt(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&&y(s.data)&&(i+=s.data.byteLength);return i}function Xt(e,t){return t.byteSize>Vt?(At().warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}function Yt(e){if(0===e.length)return;const t=10*e.length,i=new Float64Array(t);let s=0;return e.forAll((e=>{let t=e.serviceObbInIndexSR;null==t&&(t=Bt,t.center=te(e.serviceMbsInIndexSR),t.halfSize=[e.serviceMbsInIndexSR[3],e.serviceMbsInIndexSR[3],e.serviceMbsInIndexSR[3]]);const r=t.data;i[s++]=r[0],i[s++]=r[1],i[s++]=r[2],i[s++]=r[3],i[s++]=r[4],i[s++]=r[5],i[s++]=r[6],i[s++]=r[7],i[s++]=r[8],i[s++]=r[9]})),i}class Jt{constructor(e,t,i){this.attributeInfo=e,this.meta=t,this.promise=i,this.allowMemCache=!0}}function Zt(e,t){e.forEach((e=>e.opacity=t))}class ei{constructor(e,t){this.mode=e,this.offset=t}}const ti=H(),ii=K(),si="elevation-change",ri="",oi="@null",ai="@ECEF",ni=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],li=new ft;function di(e,t,i){let s=e.elevationRangeMin,r=e.elevationRangeMax;const o=i;if(o>0){t.getCorners(ni);for(const e of ni){const t=V(e)-o;s=Math.min(s,t),r=Math.max(r,t)}}else{t.getCorners(ni);for(const e of ni){const t=e[2];s=Math.min(s,t),r=Math.max(r,t)}}e.expandElevationRangeValues(s,r)}function hi(e,t,i){const s=te(t),r=i>0?V(s)-i:s[2],o=se(t);e.expandElevationRangeValues(r-o,r+o)}function ci(e,t){const i=e.featureIds.slice();for(const s of t)if(s(i,e),0===i.length)break;return i.length===e.featureIds.length?e.featureIds:i}function ui(e,t,i){const s=new Array,r=e.filteredIds;if(null==r||t?.size||i?.size){if(null!=r){let o=0;e.featureIds.forEach(((e,a)=>{if(r[o]===e)++o;else if(!t?.has(e))return;i?.has(e)||s.push(a)}))}}else e.featureIds.forEach(((e,t)=>{r[s.length]===e&&s.push(t)}));return s}function _i(e,t,i){if(e&&t)for(const s of t){const t=(e.get(s)??0)+i;t>0?e.set(s,t):e.delete(s)}}var mi;function gi(e,t=mi.All){const i=new Map;for(const s of e){_i(i,t===mi.All?s?.featureIds:t===mi.Filtered?s?.filteredIds:s?.weaklyRemovedIds,1)}return i}!function(e){e[e.All=0]="All",e[e.Filtered=1]="Filtered",e[e.WeaklyRemoved=2]="WeaklyRemoved"}(mi||(mi={}));export{Ht 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.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import{
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import i from"./DynamicLayerView3D.js";import s from"./ImagerySubView3D.js";import o from"../../layers/ImageryLayerView.js";let a=class extends(o(i)){constructor(){super(...arguments),this.type="imagery-3d"}_initSubView(){this.subView=new s({layerView:this})}get highlightOptions(){return null}get pixelData(){return null}initialize(){const e=()=>this._updatingHandles.addPromise(this.refreshDebounced());this._updatingHandles.add((()=>this.layer?.exportImageServiceParameters?.version),e),this._updatingHandles.add((()=>this.layer?.renderer),e),this._updatingHandles.add((()=>this.timeExtent),e)}getFetchOptions(){return{timeExtent:this.timeExtent}}highlight(e){throw new Error("Not implemented")}};e([t()],a.prototype,"highlightOptions",null),e([t()],a.prototype,"pixelData",null),a=e([r("esri.views.3d.layers.ImageryLayerView3D")],a);const n=a;export{n as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import{debounce as a}from"../../../core/promiseUtils.js";import{when as i}from"../../../core/reactiveUtils.js";import"../../../core/Logger.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import"../../../core/Error.js";import{subclass as t}from"../../../core/accessorSupport/decorators/subclass.js";import r from"./DrapedSubView3D.js";let s=class extends r{constructor(e){super(e),this.redrawDebounced=a((async e=>{this.redraw(((e,a)=>this._redrawImage(e,a)),e)}),2e3)}initialize(){this.addHandles([i((()=>this.view.basemapTerrain.ready),(()=>this._initializeMaximumDataResolution()),{once:!0,initial:!0}),this.layer.on("redraw",(()=>this.updatingHandles.addPromise(this.redrawDebounced())))])}_initializeMaximumDataResolution(){this.maximumDataResolution=this.layer.loaded?this.layer.serviceRasterInfo.pixelSize:null}async processResult(e,a,i){a.imageOrCanvasElement?e.image=a.imageOrCanvasElement:(e.image=document.createElement("canvas"),e.pixelData=a.pixelData,await this._redrawImage(e,i))}async _redrawImage(e,a){if(!(e.image instanceof HTMLCanvasElement)||null==e.pixelData)throw new Error;const i=e.image,t=i.getContext("2d"),r=await this.layer.applyRenderer(e.pixelData,{signal:a}),s=this.layer.applyFilter(r).pixelBlock;if(null==s)throw new Error;i.width=s.width,i.height=s.height;const o=t.createImageData(s.width,s.height);o.data.set(s.getAsRGBA()),t.putImageData(o,0,0)}};s=e([t("esri.views.3d.layers.ImagerySubView3D")],s);const o=s;export{o as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import{whenOnce as r}from"../../../core/reactiveUtils.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{projectDatasetExtent as a}from"../../../layers/support/rasterFunctions/rasterProjectionHelper.js";import{LayerView3D as l}from"./LayerView3D.js";import{TiledLayerView3D as n}from"./TiledLayerView3D.js";import{RasterTile as o}from"../terrain/RasterTile.js";import m from"../../layers/ImageryTileLayerView.js";import p from"../../layers/LayerView.js";import h from"../../layers/RefreshableLayerView.js";import{createQueryGeometry as c}from"../../support/drapedUtils.js";import{getWebGLCapabilities as d}from"../../webgl/capabilities.js";let y=class extends(m(h(n(l(p))))){constructor(){super(...arguments),this.type="imagery-tile-3d",this._isAlignedMapTile=!0}initialize(){this.layer.increaseRasterJobHandlerUsage(),null==this.fullExtent&&this.addResolvingPromise(Promise.reject(new t("layerview:spatial-reference-incompatible","The layer extent cannot be projected to the view's spatial reference",{layer:this.layer})));const e=r((()=>this.view?.basemapTerrain?.tilingSchemeLocked)).then((()=>{const e=this.view.basemapTerrain.tilingScheme,t=this.layer.tileInfo;this._isAlignedMapTile=["png","png24","png32","jpg","mixed"].includes(t.format)&&e.compatibleWith(t),this.tileInfo=this._isAlignedMapTile?t:e.toTileInfo(),this._updatingHandles.add((()=>[this.layer.renderer,this.layer.interpolation,this.layer.bandIds,this.layer.multidimensionalDefinition,this.layer.multidimensionalSubset,this.layer.rasterFunction,this.timeExtent]),(()=>this.refresh()))}));this.addResolvingPromise(e)}destroy(){this.layer.decreaseRasterJobHandlerUsage()}get _blankTile(){const e=document.createElement("canvas"),t=e.getContext("2d"),[r,i]=this.tileInfo.size;return e.width=r,e.height=i,t.clearRect(0,0,r,i),t.getImageData(0,0,r,i)}get imageFormatIsOpaque(){return"jpg"===this.layer.tileInfo.format}get hasMixedImageFormats(){return"mixed"===this.layer.tileInfo.format}get dataLevelRange(){const e=this.layer.tileInfo,t=this.tileInfo.lodAt(0)?.scale,r=this.layer.tileInfo.lodAt(e.lods.length-1)?.scale;return this.levelRangeFromScaleRange(t,r)}_getFullExtent(){return a(this.layer.serviceRasterInfo,this.view.basemapTerrain?.spatialReference??this.view.spatialReference)}async fetchTile(e,t){const r=this.tileInfo,i=this._canSymbolizeInWebGL(),s={tileInfo:r,requestRawData:i,signal:t.signal,timeExtent:this.timeExtent,requestAsImageElement:this._isAlignedMapTile,noClip:!1},{layer:a}=this,[l,n,m]=e,p=await a.fetchTile(l,n,m,s);if(p instanceof HTMLImageElement)return p;let h=p?.pixelBlock;if(null==h)return this._blankTile;if(!i&&(h=await a.applyRenderer(p),null==h))return this._blankTile;const c=new o([l,n,m],h,r.size[0],r.size[1]);return i?(c.symbolizerRenderer=a.symbolizer.rendererJSON,c.symbolizerParameters=a.symbolizer.generateWebGLParameters(this._getSymbolizerOptions(l)),c.transformGrid=p.transformGrid,c.bandIds=a.bandIds):(c.isRendereredSource=!0,c.bandIds=null),c.interpolation=a.interpolation,c}_getSymbolizerOptions(e){const t=this.tileInfo.lodAt(e).resolution;return{pixelBlock:null,isGCS:null!=this.view.basemapTerrain?.spatialReference?this.view.basemapTerrain.spatialReference.isGeographic:this.view.spatialReference.isGeographic,resolution:{x:t,y:t},bandIds:this.layer.bandIds}}ensureSymbolizerParameters(e){this._canSymbolizeInWebGL()&&JSON.stringify(e.symbolizerRenderer)!==JSON.stringify(this.layer.symbolizer.rendererJSON)&&(e.symbolizerParameters=this.layer.symbolizer.generateWebGLParameters(this._getSymbolizerOptions(e.lij[0])))}createFetchPopupFeaturesQueryGeometry(e,t){return c(e,t,this.view)}refresh(){this.emit("data-changed")}async doRefresh(){this.suspended||this.emit("data-changed")}_canSymbolizeInWebGL(){const e=d(),{symbolizer:t}=this.layer,r=t.lookup?.colormapLut?.indexedColormap,i=!!this.layer.rasterFunction?.hasClipFunction,s=r&&r.length>4*(e.maxTextureSize||
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import{whenOnce as r}from"../../../core/reactiveUtils.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{projectDatasetExtent as a}from"../../../layers/support/rasterFunctions/rasterProjectionHelper.js";import{LayerView3D as l}from"./LayerView3D.js";import{TiledLayerView3D as n}from"./TiledLayerView3D.js";import{RasterTile as o}from"../terrain/RasterTile.js";import m from"../../layers/ImageryTileLayerView.js";import p from"../../layers/LayerView.js";import h from"../../layers/RefreshableLayerView.js";import{createQueryGeometry as c}from"../../support/drapedUtils.js";import{getWebGLCapabilities as d}from"../../webgl/capabilities.js";let y=class extends(m(h(n(l(p))))){constructor(){super(...arguments),this.type="imagery-tile-3d",this._isAlignedMapTile=!0}initialize(){this.layer.increaseRasterJobHandlerUsage(),null==this.fullExtent&&this.addResolvingPromise(Promise.reject(new t("layerview:spatial-reference-incompatible","The layer extent cannot be projected to the view's spatial reference",{layer:this.layer})));const e=r((()=>this.view?.basemapTerrain?.tilingSchemeLocked)).then((()=>{const e=this.view.basemapTerrain.tilingScheme,t=this.layer.tileInfo;this._isAlignedMapTile=["png","png24","png32","jpg","mixed"].includes(t.format)&&e.compatibleWith(t),this.tileInfo=this._isAlignedMapTile?t:e.toTileInfo(),this._updatingHandles.add((()=>[this.layer.renderer,this.layer.interpolation,this.layer.bandIds,this.layer.multidimensionalDefinition,this.layer.multidimensionalSubset,this.layer.rasterFunction,this.timeExtent]),(()=>this.refresh()))}));this.addResolvingPromise(e)}destroy(){this.layer.decreaseRasterJobHandlerUsage()}get _blankTile(){const e=document.createElement("canvas"),t=e.getContext("2d"),[r,i]=this.tileInfo.size;return e.width=r,e.height=i,t.clearRect(0,0,r,i),t.getImageData(0,0,r,i)}get imageFormatIsOpaque(){return"jpg"===this.layer.tileInfo.format}get hasMixedImageFormats(){return"mixed"===this.layer.tileInfo.format}get dataLevelRange(){const e=this.layer.tileInfo,t=this.tileInfo.lodAt(0)?.scale,r=this.layer.tileInfo.lodAt(e.lods.length-1)?.scale;return this.levelRangeFromScaleRange(t,r)}_getFullExtent(){return a(this.layer.serviceRasterInfo,this.view.basemapTerrain?.spatialReference??this.view.spatialReference)}async fetchTile(e,t){const r=this.tileInfo,i=this._canSymbolizeInWebGL(),s={tileInfo:r,requestRawData:i,signal:t.signal,timeExtent:this.timeExtent,requestAsImageElement:this._isAlignedMapTile,noClip:!1},{layer:a}=this,[l,n,m]=e,p=await a.fetchTile(l,n,m,s);if(p instanceof HTMLImageElement)return p;let h=p?.pixelBlock;if(null==h)return this._blankTile;if(!i&&(h=await a.applyRenderer(p),null==h))return this._blankTile;const c=new o([l,n,m],h,r.size[0],r.size[1]);return i?(c.symbolizerRenderer=a.symbolizer.rendererJSON,c.symbolizerParameters=a.symbolizer.generateWebGLParameters(this._getSymbolizerOptions(l)),c.transformGrid=p.transformGrid,c.bandIds=a.bandIds):(c.isRendereredSource=!0,c.bandIds=null),c.interpolation=a.interpolation,c}_getSymbolizerOptions(e){const t=this.tileInfo.lodAt(e).resolution;return{pixelBlock:null,isGCS:null!=this.view.basemapTerrain?.spatialReference?this.view.basemapTerrain.spatialReference.isGeographic:this.view.spatialReference.isGeographic,resolution:{x:t,y:t},bandIds:this.layer.bandIds}}ensureSymbolizerParameters(e){this._canSymbolizeInWebGL()&&JSON.stringify(e.symbolizerRenderer)!==JSON.stringify(this.layer.symbolizer.rendererJSON)&&(e.symbolizerParameters=this.layer.symbolizer.generateWebGLParameters(this._getSymbolizerOptions(e.lij[0])))}createFetchPopupFeaturesQueryGeometry(e,t){return c(e,t,this.view)}refresh(){this.emit("data-changed")}async doRefresh(){this.suspended||this.emit("data-changed")}_canSymbolizeInWebGL(){const e=d(),{symbolizer:t}=this.layer,r=t.lookup?.colormapLut?.indexedColormap,i=!!this.layer.rasterFunction?.hasClipFunction,s=r&&r.length>4*(e.maxTextureSize||4096);return t.canRenderInWebGL&&!s&&!i}};e([i({readOnly:!0})],y.prototype,"_blankTile",null),e([i({readOnly:!0})],y.prototype,"imageFormatIsOpaque",null),e([i({readOnly:!0})],y.prototype,"hasMixedImageFormats",null),e([i({readOnly:!0})],y.prototype,"dataLevelRange",null),y=e([s("esri.views.3d.layers.ImageryTileLayerView3D")],y);const u=y;export{u as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import has from"../../../core/has.js";import r from"../../../core/Logger.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{watch as i,initial as o}from"../../../core/reactiveUtils.js";import{schedule as a}from"../../../core/scheduling.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as c,invert as m}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{IDENTITY as d,create as h}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as u,getTranslation as p}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{g as b,q as y}from"../../../chunks/vec32.js";import{fromArray as w,create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as v}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as x}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as j}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as C}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as T}from"../../../geometry/projection/projectVectorToVector.js";import{BufferViewVec4f as M,BufferViewVec4u8 as P,BufferViewVec4u16 as O,BufferViewVec3f as U,BufferViewVec3u8 as E,BufferViewVec3u16 as I,BufferViewVec2f as V,BufferViewInt16 as A,BufferViewUint32 as H,BufferViewUint16 as S}from"../../../geometry/support/buffer/BufferView.js";import{invalidLayerView as R,wasmFailedToInit as F,Lyr3DLightingModel as D,Lyr3DUvWrapMode as L,Lyr3DImageFormat as k,Lyr3DPixelFormat as B,Lyr3DVtxAtrbSemantic as N,Lyr3DType as G}from"../../../layers/ILyr3DWasmPerSceneView.js";import{getElevationOffsetInMeters as z}from"../../../support/elevationInfoUtils.js";import{ViewingMode as W}from"../../ViewingMode.js";import{IntegratedMesh3DTilesViewPerformanceInfo as $}from"./IntegratedMesh3DTilesViewPerformanceInfo.js";import{DrapeTargetType as q}from"./interfaces.js";import{LayerView3D as J}from"./LayerView3D.js";import{addLayerViewToWasm as K,removeLayerViewFromWasm as X,getLyr3DWasm as Q}from"./Lyr3DWasm.js";import{LayerElevationProvider as Y}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as Z,alphaModeConversion as ee,faceCullingConversion as te,wrapModeConversion as re,lyr3DTypeToByteSize as se}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as ie}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as oe}from"../support/ElevationRange.js";import{Obb as ae,compute as ne}from"../support/orientedBoundingBox.js";import{ObjectParameters as le}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as ce,createVertexBufferLayout as me}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as de}from"../webgl-engine/collections/Component/Transform.js";import{ComponentParameterSummary as he}from"../webgl-engine/collections/Component/Material/ComponentMaterial.js";import{RenderTexture as ue}from"../webgl-engine/core/material/RenderTexture.js";import{TextureCoordinateType as pe}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{getEllipsoidMode as fe}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as ge}from"../webgl-engine/lib/Attribute.js";import{CullFaceOptions as be,AlphaDiscardMode as ye,TextureEncodingMimeType as we}from"../webgl-engine/lib/basicInterfaces.js";import{compressAndTransformNormals as _e}from"../webgl-engine/lib/Normals.js";import{Texture as ve}from"../webgl-engine/lib/Texture.js";import{VertexAttribute as xe}from"../webgl-engine/lib/VertexAttribute.js";import{writeDefaultAttribute as je}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import Ce from"../../layers/LayerView.js";import{isInEffectiveScaleRange as Te}from"../../support/layerViewUtils.js";import{alphaCutoff as Me}from"../../../webscene/support/AlphaCutoff.js";var Pe;!function(e){e[e.API=1]="API",e[e.VerboseAPI=2]="VerboseAPI",e[e.Error=3]="Error"}(Pe||(Pe={}));class Oe{constructor(){this.handle=0,this.isVisible=!1,this.components=[],this.texMemoryUsage=0,this.vboMemoryUsage=0,this.cpuMemoryUsage=0,this.textures=[]}get usedMemory(){return this.texMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get cachedMemory(){return this.usedMemory}}function Ue(e){return Math.round(e/1048.576)/1e3}let Ee=class extends(J(Ce)){constructor(){super(...arguments),this.type="integrated-mesh-3dtiles",this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this.drapeTargetType=q.WithoutRasterImage,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._initialCullFace=new Map,this._suspendedHandle=null,this._dbgFlags=new Set}initialize(){if(this._dbgFlags.add(Pe.Error),this._dbg(Pe.VerboseAPI,"Tiles3DLayerView3D initialize() called"),!this._canProjectWithoutEngine())throw new t("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{});const e=K(this).then((e=>{this._intersectionHandler=new ie(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this._elevationProvider=new Y({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this.view.elevationProvider.register("im",this._elevationProvider),this.view.basemapTerrain.overlayManager.registerDrapeTarget(this),this._wasmLayerId=e;const t=this.view.resourceController.memoryController.newCache(`t3d-${this.uid}`,(e=>this._onRemoveFromCache(e)));this._memCache=t,this.addHandles([i((()=>this.layer.elevationInfo),(e=>this._elevationInfoChanged(e)))]),this._suspendedHandle=i((()=>this.suspended),(e=>this._wasm?.setEnabled(this,!e)),o)})).catch((e=>{if(X(this),this._wasmLayerId=-1,e===R)throw new t("tiles3d:addLayer-failure","The 3d tiles layer description was invalid.",{});if(e===F)throw new t("tiles3d:addLayer-failure","The 3d tiles layer web assembly module failed to download.",{})}));this.addResolvingPromise(e)}destroy(){this._dbg(Pe.VerboseAPI,"Tiles3DLayerView3D destroy() called"),X(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.objectsChanged(this._obbs),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.basemapTerrain.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach((e=>this.freeObject(e))),this._lyrHandleToObjects.clear(),this._initialCullFace.clear(),this._memCache=s(this._memCache),this._updatingHandles=s(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null)}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=a((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this.objects.forEach((t=>{const r=this._collection.getMaterial(t);r.commonMaterialParameters.hasSlicePlane=e,r.commonMaterialParameters.cullFace=e?be.None:this._initialCullFace.get(t)}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,z(e))}get _obbs(){return this.objects.map((e=>this._collection.getComponentObb(e)))}get _wasm(){return Q(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){let e=0;return this._lyrHandleToObjects.forEach((t=>{t.isVisible&&(e+=t.usedMemory)})),e}get unloadedMemory(){return 0}get cachedMemory(){let e=0;return this._lyrHandleToObjects.forEach((t=>{t.isVisible||(e+=t.usedMemory)})),e}get visibleAtCurrentScale(){return Te(this.layer.effectiveScaleRange,this.view.scale)}get performanceInfo(){let e=0,t=0,r=0,s=0,i=0,o=0;return this._lyrHandleToObjects.forEach((a=>{a.isVisible?(e+=a.texMemoryUsage,t+=a.vboMemoryUsage,i++):(r+=a.texMemoryUsage,s+=a.vboMemoryUsage,o++)})),new $(this.usedMemory,i,o,Ue(t),Ue(e),Ue(s),Ue(r))}_canProjectWithoutEngine(){if(this.view.state.viewingMode===W.Local){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view._stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationOffset(){return z(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new oe(e.zmin,e.zmax):null}getElevationRange(e){return null}get fullExtent(){return this.layer.fullExtent}get objects(){return Array.from(this._lyrHandleToObjects.values()).reduce(((e,t)=>e.concat(t.components)),new Array)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&e.isUpdating(this._wasmLayerId)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const r=w(t.desc.origin),s=new Array,i=new Map,o=new Oe;o.handle=e.handle,this._lyrHandleToObjects.set(e.handle,o);const a=this.view.basemapTerrain.spatialReference;let n,l;if("global"===this.view.viewingMode){const e=f();j(x,r,e,a),n=c(h(),e),l=m(h(),n)}else n=d,l=d;const M=f();u(M,M,r);const P=p(_(),M);let O=null;const U=_();if(t.desc.obb){const e=t.desc.obb.quaternion;O=new ae(t.desc.obb.center,t.desc.obb.halfSize,g(e[0],e[1],e[2],e[3]))}for(let c=0;c<t.desc.prims.length;c++){const e=t.desc.prims[c];this._dbg(Pe.VerboseAPI,JSON.stringify(e));if(null==Z[e.ptype]||null==t.data){this._dbg(Pe.VerboseAPI,"[Unsupported Feature] Unsupported primitive mode ("+e.ptype+"). Skipping primitive.");continue}const m=t.desc?.materials&&null!=e.materialId?t.desc.materials[e.materialId]:null,h=null!=m?m.lightingModel:D.Unlit,{positionView:u,positionAttr:p,normalsView:f,normalsAttr:g,colorAttr:w,texCoord0Attr:x,indicesView:j}=this.getBufferViews(e,t.data.buffer,n);if(null==p||null==u||null==j)continue;const M=new ce(null!=w,null!=x?pe.Default:pe.None,null!=f,this._shadeNormals,this._applySSAO),E=p.data.length/p.size,I=(e,t)=>!e||e.data.length/e.size===E||(this._dbg(Pe.Error,`${t} !== numPos. Skipping primitive.`),!1);if(!I(x,"numTexcoord")||!I(w,"numColors")||!I(g,"normals"))continue;const V=me(M);if(null!=O?O=O.clone():(O=ne(p),b(U,O.center,r),O.center=U),n!==d)for(let t=0;t<u.count;t++)u.getVec(t,U),y(U,U,n),u.setVec(t,U);const A=V.createBuffer(p.data.length),H=new Map([[xe.POSITION,p]]);null!=x&&H.set(xe.UV0,x),null!=w&&H.set(xe.COLOR,w),null!=g&&H.set(xe.NORMALCOMPRESSED,g),H.forEach(((e,t)=>{null!=e&&je(t,e,null,null,A,0)}));const S=new Uint32Array([0,j.typedBuffer.length]),R={vertices:{data:A.buffer,count:A.byteLength/V.stride,layoutParameters:M},positionData:{positions:u.typedBuffer,indices:j.typedBuffer},indices:j.typedBuffer,componentOffsets:S};o.cpuMemoryUsage+=u.count,o.cpuMemoryUsage+=j.count;const F=this.view.renderSpatialReference,L=_(),k=[1,1,1];C(P,F,k,a)||this._dbg(Pe.Error,"Unsupported coordinate system for IM overlay"),T(P,F,L,a);const B=this._collection.createObject(new le(v(L[0],L[1],k[0],k[1]),new de(P,l),O,R));m&&this._collection.updateMaterial(B,(e=>{e.baseColor=m.baseColorFactor,e.usePBR=h===D.Pbr,e.hasParametersFromSource=!1,e.baseColorTexture=this._getTexture(m.baseColorTex,t,i),e.usePBR&&(e.mrrFactors=[m.metallicFactor,m.roughnessFactor,0],e.emissiveFactor=m.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=this._getTexture(m.metalTex,t,i),e.emissionTexture=this._getTexture(m.emissiveTex,t,i),e.occlusionTexture=this._getTexture(m.occlusionTex,t,i),e.normalTexture=this._getTexture(m.normalTex,t,i)),e.objectOpacity=0,e.alphaDiscardMode=ye.Mask;const r=[];e.baseColorTexture&&r.push(e.baseColorTexture.loadPromise),e.usePBR&&e.metallicRoughnessTexture&&r.push(e.metallicRoughnessTexture.loadPromise),e.usePBR&&e.emissionTexture&&r.push(e.emissionTexture.loadPromise),e.usePBR&&e.occlusionTexture&&r.push(e.occlusionTexture.loadPromise),e.usePBR&&e.normalTexture&&r.push(e.normalTexture.loadPromise);const a=Promise.all(r);s.push(a),a.then((()=>{e.alphaDiscardMode=ee[m.alphaMode],e.objectOpacity=1,o.texMemoryUsage+=e.baseColorTexture?.glTexture?.usedMemory||0,e.usePBR&&(o.texMemoryUsage+=e.metallicRoughnessTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.emissionTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.occlusionTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.normalTexture?.glTexture?.usedMemory||0)})),e.commonMaterialParameters.doubleSided=m.isDoubleSided,e.commonMaterialParameters.cullFace=m.faceCulling?te[m.faceCulling]:be.Back,this._initialCullFace.set(B,e.commonMaterialParameters.cullFace),e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=he.All,e.textureAlphaCutoff=m.alphaCutoff??Me,e.alphaDiscardMode=ee[m.alphaMode],e.isIntegratedMesh=!0,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=fe(this.view.spatialReference)})),o.components.push(B),o.vboMemoryUsage+=this._collection.getObjectGPUMemoryUsage(B)}if(await Promise.all(s),i.forEach((e=>{o.textures.push(e)})),!this._memCache)throw new Error("no memCache");return this._memCache.put(`${o.handle}`,o),{memUsageBytes:o.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){this._memCache&&this._memCache.pop(`${e.handle}`),e.components.forEach((t=>{e.textures.forEach((e=>{this._stage.remove(e)})),this._collection.destroyObject(t),this._initialCullFace.delete(t)}))}setRenderableVisibility(e,t,r){if(this._memCache){for(let s=0;s<r;++s){const r=e[s],i=t[s];if(!i)continue;const o=this._lyrHandleToObjects.get(r);o&&(this._visibleGeometryChanged(),o.isVisible=i,o.components.forEach((e=>{this._collection.setObjectVisibility(e,i),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))})),this._memCache.pop(`${r}`))}for(let s=0;s<r;++s){const r=e[s],i=t[s];if(i)continue;const o=this._lyrHandleToObjects.get(r);o&&(this._visibleGeometryChanged(),o.isVisible=i,o.components.forEach((e=>{this._collection.setObjectVisibility(e,i),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))})),this._memCache.put(`${r}`,o))}}}_getTexture(e,t,r){let s=null;if(e&&t.desc?.images&&t.data?.buffer){const i=t.desc.images[e?.imageId];if(s=r.get(i),!s&&i){const o=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,a=!!i.mipCount||o>1,n=re[e.wrapMode??L.None];let l=i.alpha?4:3;const c=new Uint8Array(t.data.buffer,i.data.byteOffset,i.data.byteCount);let m=null,d=null,h=null;switch(i.format){case k.Raw:i.pixelFormat===B.R8?(m=c,l=1,d=""):i.pixelFormat===B.Rgb8?(m=c,l=3,d=""):i.pixelFormat===B.Rgba8&&(m=c,l=4,d="");break;case k.Dxt1:m=c,l=3,d=we.DDS_ENCODING;break;case k.Dxt5:m=c,l=4,d=we.DDS_ENCODING;break;case k.Basis:m=c,l=3,d=we.KTX2_ENCODING;break;case k.Png:d="image/png",h=document.createElement("img");break;case k.Jpeg:d="image/jpeg",h=document.createElement("img");break;case k.Etc2:d="image/ktx",h=document.createElement("img");break;case k.Astc:this._dbg(Pe.Error,"Astc texture not supported");break;case k.Pvrtc:this._dbg(Pe.Error,"Pvrtc texture not supported")}if(h&&d){const e=new Blob([c],{type:d});h.src=URL.createObjectURL(e),m=h}m&&null!=d&&(s=new ve(m,{mipmap:a,maxAnisotropy:o,encoding:d,wrap:n,components:l,noUnpackFlip:!0,width:i.mip0Width,height:i.mip0Height}),this._stage.add(s),r.set(i,s))}}return s?new ue(this.view._stage.renderView.textures,s.id):null}getBufferViews(e,t,r){let s,i,o,a,n,l,c,m=null;for(let h=0;h<e.atrbs.length;h++){const c=e.atrbs[h],u=c.view,p=void 0,f=u.byteOffset+u.byteCount,g=u.byteCount/se[u.type],b=[...Array(g).keys()].map((e=>e));try{switch(c.sem){case N.Position:3!==u.ncomp||u.type!==G.F32?this._dbg(Pe.Error,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(s=new U(t,u.byteOffset,p,f),i=new ge(s.typedBuffer,b,3));break;case N.Normal:if(3!==u.ncomp||u.type!==G.F32)this._dbg(Pe.Error,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new U(t,u.byteOffset,p,f),s=_e(e.typedBuffer,r);n=new A(s),l=new ge(n.typedBuffer,b,2)}break;case N.TexCoord:2!==u.ncomp||u.type!==G.F32?this._dbg(Pe.Error,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===a&&(a=new ge(new V(t,u.byteOffset,p,f).typedBuffer,b,2));break;case N.Color:4===u.ncomp?(u.type===G.F32&&(m=new M(t,u.byteOffset,p,f)),u.type===G.U8&&(m=new P(t,u.byteOffset,p,f)),u.type===G.U16&&(m=new O(t,u.byteOffset,p,f))):3===u.ncomp&&(u.type===G.F32&&(m=new U(t,u.byteOffset,p,f)),u.type===G.U8&&(m=new E(t,u.byteOffset,p,f)),u.type===G.U16&&(m=new I(t,u.byteOffset,p,f))),null==m?this._dbg(Pe.VerboseAPI,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new ge(m.typedBuffer,b,u.ncomp);break;case N.FeatureIndex:break;default:this._dbg(Pe.VerboseAPI,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(d){this._dbg(Pe.VerboseAPI,"Error Creating buffer ("+d+"). Skipping vertex attribute.")}}if(e.index){const r=e.index.view,s=void 0,i=r.byteOffset+r.byteCount;switch(e.index.view.type){case G.U16:c=new S(t,r.byteOffset,s,i);break;case G.U32:c=new H(t,r.byteOffset,s,i);break;case G.U8:default:this._dbg(Pe.Error,"[Unsupported Feature] index type not supported ("+r.type+").")}}if(null==c&&null!=s){const e=s.count;if(e<65535){const t=new Uint16Array(e);c=new S(t)}else{const t=new Uint32Array(e);c=new H(t)}for(let t=0;t<e;t++)c.set(t,t)}return{positionView:s,positionAttr:i,colorAttr:o,texCoord0Attr:a,indicesView:c,normalsView:n,normalsAttr:l}}_onRemoveFromCache(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,t){this._dbgFlags.has(e)&&(e===Pe.Error?r.getLogger(this).error(t):r.getLogger(this).warn(t))}};e([n()],Ee.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([n()],Ee.prototype,"layer",void 0),e([n({readOnly:!0})],Ee.prototype,"visibleAtCurrentScale",null),e([n()],Ee.prototype,"elevationOffset",null),Ee=e([l("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Ee);const Ie=Ee;export{Ie as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import has from"../../../core/has.js";import r from"../../../core/Logger.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{watch as i,initial as o}from"../../../core/reactiveUtils.js";import{schedule as a}from"../../../core/scheduling.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as c,invert as m}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{IDENTITY as d,create as h}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as u,getTranslation as p}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{g as b,q as y}from"../../../chunks/vec32.js";import{fromArray as w,create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as v}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as x}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as j}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as C}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as T}from"../../../geometry/projection/projectVectorToVector.js";import{BufferViewVec4f as M,BufferViewVec4u8 as P,BufferViewVec4u16 as O,BufferViewVec3f as U,BufferViewVec3u8 as E,BufferViewVec3u16 as I,BufferViewVec2f as V,BufferViewInt16 as A,BufferViewUint32 as H,BufferViewUint16 as S}from"../../../geometry/support/buffer/BufferView.js";import{invalidLayerView as R,wasmFailedToInit as F,Lyr3DLightingModel as D,Lyr3DUvWrapMode as L,Lyr3DImageFormat as k,Lyr3DPixelFormat as B,Lyr3DVtxAtrbSemantic as N,Lyr3DType as G}from"../../../layers/ILyr3DWasmPerSceneView.js";import{getElevationOffsetInMeters as z}from"../../../support/elevationInfoUtils.js";import{ViewingMode as W}from"../../ViewingMode.js";import{IntegratedMesh3DTilesViewPerformanceInfo as $}from"./IntegratedMesh3DTilesViewPerformanceInfo.js";import{DrapeTargetType as q}from"./interfaces.js";import{LayerView3D as J}from"./LayerView3D.js";import{addLayerViewToWasm as K,removeLayerViewFromWasm as X,getLyr3DWasm as Q}from"./Lyr3DWasm.js";import{LayerElevationProvider as Y}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as Z,alphaModeConversion as ee,faceCullingConversion as te,wrapModeConversion as re,lyr3DTypeToByteSize as se}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as ie}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as oe}from"../support/ElevationRange.js";import{Obb as ae,compute as ne}from"../support/orientedBoundingBox.js";import{ObjectParameters as le}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as ce,createVertexBufferLayout as me}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as de}from"../webgl-engine/collections/Component/Transform.js";import{ComponentParameterSummary as he}from"../webgl-engine/collections/Component/Material/ComponentMaterial.js";import{RenderTexture as ue}from"../webgl-engine/core/material/RenderTexture.js";import{TextureCoordinateType as pe}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{getEllipsoidMode as fe}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as ge}from"../webgl-engine/lib/Attribute.js";import{CullFaceOptions as be,AlphaDiscardMode as ye,TextureEncodingMimeType as we}from"../webgl-engine/lib/basicInterfaces.js";import{compressAndTransformNormals as _e}from"../webgl-engine/lib/Normals.js";import{Texture as ve}from"../webgl-engine/lib/Texture.js";import{VertexAttribute as xe}from"../webgl-engine/lib/VertexAttribute.js";import{writeDefaultAttribute as je}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import Ce from"../../layers/LayerView.js";import{isInEffectiveScaleRange as Te}from"../../support/layerViewUtils.js";import{alphaCutoff as Me}from"../../../webscene/support/AlphaCutoff.js";var Pe;!function(e){e[e.API=1]="API",e[e.VerboseAPI=2]="VerboseAPI",e[e.Error=3]="Error"}(Pe||(Pe={}));class Oe{constructor(){this.handle=0,this.isVisible=!1,this.components=[],this.texMemoryUsage=0,this.vboMemoryUsage=0,this.cpuMemoryUsage=0,this.textures=[]}get usedMemory(){return this.texMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get cachedMemory(){return this.usedMemory}}function Ue(e){return Math.round(e/1048.576)/1e3}let Ee=class extends(J(Ce)){constructor(){super(...arguments),this.type="integrated-mesh-3dtiles",this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this.drapeTargetType=q.WithoutRasterImage,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._initialCullFace=new Map,this._suspendedHandle=null,this._dbgFlags=new Set}initialize(){if(this._dbgFlags.add(Pe.Error),this._dbg(Pe.VerboseAPI,"Tiles3DLayerView3D initialize() called"),!this._canProjectWithoutEngine())throw new t("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{});const e=K(this).then((e=>{this._intersectionHandler=new ie(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this._elevationProvider=new Y({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this.view.elevationProvider.register("im",this._elevationProvider),this.view.basemapTerrain.overlayManager.registerDrapeTarget(this),this._wasmLayerId=e;const t=this.view.resourceController.memoryController.newCache(`t3d-${this.uid}`,(e=>this._onRemoveFromCache(e)));this._memCache=t,this.addHandles([i((()=>this.layer.elevationInfo),(e=>this._elevationInfoChanged(e)))]),this._suspendedHandle=i((()=>this.suspended),(e=>this._wasm?.setEnabled(this,!e)),o)})).catch((e=>{if(X(this),this._wasmLayerId=-1,e===R)throw new t("tiles3d:addLayer-failure","The 3d tiles layer description was invalid.",{});if(e===F)throw new t("tiles3d:addLayer-failure","The 3d tiles layer web assembly module failed to download.",{})}));this.addResolvingPromise(e)}destroy(){this._dbg(Pe.VerboseAPI,"Tiles3DLayerView3D destroy() called"),X(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.objectsChanged(this._obbs),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.basemapTerrain.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach((e=>this.freeObject(e))),this._lyrHandleToObjects.clear(),this._initialCullFace.clear(),this._memCache=s(this._memCache),this._updatingHandles=s(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null)}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=a((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this.objects.forEach((t=>{const r=this._collection.getMaterial(t);r.commonMaterialParameters.hasSlicePlane=e,r.commonMaterialParameters.cullFace=e?be.None:this._initialCullFace.get(t)}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,z(e))}get _obbs(){return this.objects.map((e=>this._collection.getComponentObb(e)))}get _wasm(){return Q(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){let e=0;return this._lyrHandleToObjects.forEach((t=>{t.isVisible&&(e+=t.usedMemory)})),e}get unloadedMemory(){return 0}get cachedMemory(){let e=0;return this._lyrHandleToObjects.forEach((t=>{t.isVisible||(e+=t.usedMemory)})),e}get visibleAtCurrentScale(){return Te(this.layer.effectiveScaleRange,this.view.scale)}get performanceInfo(){let e=0,t=0,r=0,s=0,i=0,o=0;return this._lyrHandleToObjects.forEach((a=>{a.isVisible?(e+=a.texMemoryUsage,t+=a.vboMemoryUsage,i++):(r+=a.texMemoryUsage,s+=a.vboMemoryUsage,o++)})),new $(this.usedMemory,i,o,Ue(t),Ue(e),Ue(s),Ue(r))}_canProjectWithoutEngine(){if(this.view.state.viewingMode===W.Local){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationOffset(){return z(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new oe(e.zmin,e.zmax):null}getElevationRange(e){return null}get fullExtent(){return this.layer.fullExtent}get objects(){return Array.from(this._lyrHandleToObjects.values()).reduce(((e,t)=>e.concat(t.components)),new Array)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&e.isUpdating(this._wasmLayerId)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const r=w(t.desc.origin),s=new Array,i=new Map,o=new Oe;o.handle=e.handle,this._lyrHandleToObjects.set(e.handle,o);const a=this.view.basemapTerrain.spatialReference;let n,l;if("global"===this.view.viewingMode){const e=f();j(x,r,e,a),n=c(h(),e),l=m(h(),n)}else n=d,l=d;const M=f();u(M,M,r);const P=p(_(),M);let O=null;const U=_();if(t.desc.obb){const e=t.desc.obb.quaternion;O=new ae(t.desc.obb.center,t.desc.obb.halfSize,g(e[0],e[1],e[2],e[3]))}for(let c=0;c<t.desc.prims.length;c++){const e=t.desc.prims[c];this._dbg(Pe.VerboseAPI,JSON.stringify(e));if(null==Z[e.ptype]||null==t.data){this._dbg(Pe.VerboseAPI,"[Unsupported Feature] Unsupported primitive mode ("+e.ptype+"). Skipping primitive.");continue}const m=t.desc?.materials&&null!=e.materialId?t.desc.materials[e.materialId]:null,h=null!=m?m.lightingModel:D.Unlit,{positionView:u,positionAttr:p,normalsView:f,normalsAttr:g,colorAttr:w,texCoord0Attr:x,indicesView:j}=this.getBufferViews(e,t.data.buffer,n);if(null==p||null==u||null==j)continue;const M=new ce(null!=w,null!=x?pe.Default:pe.None,null!=f,this._shadeNormals,this._applySSAO),E=p.data.length/p.size,I=(e,t)=>!e||e.data.length/e.size===E||(this._dbg(Pe.Error,`${t} !== numPos. Skipping primitive.`),!1);if(!I(x,"numTexcoord")||!I(w,"numColors")||!I(g,"normals"))continue;const V=me(M);if(null!=O?O=O.clone():(O=ne(p),b(U,O.center,r),O.center=U),n!==d)for(let t=0;t<u.count;t++)u.getVec(t,U),y(U,U,n),u.setVec(t,U);const A=V.createBuffer(p.data.length),H=new Map([[xe.POSITION,p]]);null!=x&&H.set(xe.UV0,x),null!=w&&H.set(xe.COLOR,w),null!=g&&H.set(xe.NORMALCOMPRESSED,g),H.forEach(((e,t)=>{null!=e&&je(t,e,null,null,A,0)}));const S=new Uint32Array([0,j.typedBuffer.length]),R={vertices:{data:A.buffer,count:A.byteLength/V.stride,layoutParameters:M},positionData:{positions:u.typedBuffer,indices:j.typedBuffer},indices:j.typedBuffer,componentOffsets:S};o.cpuMemoryUsage+=u.count,o.cpuMemoryUsage+=j.count;const F=this.view.renderSpatialReference,L=_(),k=[1,1,1];C(P,F,k,a)||this._dbg(Pe.Error,"Unsupported coordinate system for IM overlay"),T(P,F,L,a);const B=this._collection.createObject(new le(v(L[0],L[1],k[0],k[1]),new de(P,l),O,R));m&&this._collection.updateMaterial(B,(e=>{e.baseColor=m.baseColorFactor,e.usePBR=h===D.Pbr,e.hasParametersFromSource=!1,e.baseColorTexture=this._getTexture(m.baseColorTex,t,i),e.usePBR&&(e.mrrFactors=[m.metallicFactor,m.roughnessFactor,0],e.emissiveFactor=m.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=this._getTexture(m.metalTex,t,i),e.emissionTexture=this._getTexture(m.emissiveTex,t,i),e.occlusionTexture=this._getTexture(m.occlusionTex,t,i),e.normalTexture=this._getTexture(m.normalTex,t,i)),e.objectOpacity=0,e.alphaDiscardMode=ye.Mask;const r=[];e.baseColorTexture&&r.push(e.baseColorTexture.loadPromise),e.usePBR&&e.metallicRoughnessTexture&&r.push(e.metallicRoughnessTexture.loadPromise),e.usePBR&&e.emissionTexture&&r.push(e.emissionTexture.loadPromise),e.usePBR&&e.occlusionTexture&&r.push(e.occlusionTexture.loadPromise),e.usePBR&&e.normalTexture&&r.push(e.normalTexture.loadPromise);const a=Promise.all(r);s.push(a),a.then((()=>{e.alphaDiscardMode=ee[m.alphaMode],e.objectOpacity=1,o.texMemoryUsage+=e.baseColorTexture?.glTexture?.usedMemory||0,e.usePBR&&(o.texMemoryUsage+=e.metallicRoughnessTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.emissionTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.occlusionTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.normalTexture?.glTexture?.usedMemory||0)})),e.commonMaterialParameters.doubleSided=m.isDoubleSided,e.commonMaterialParameters.cullFace=m.faceCulling?te[m.faceCulling]:be.Back,this._initialCullFace.set(B,e.commonMaterialParameters.cullFace),e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=he.All,e.textureAlphaCutoff=m.alphaCutoff??Me,e.alphaDiscardMode=ee[m.alphaMode],e.isIntegratedMesh=!0,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=fe(this.view.spatialReference)})),o.components.push(B),o.vboMemoryUsage+=this._collection.getObjectGPUMemoryUsage(B)}if(await Promise.all(s),i.forEach((e=>{o.textures.push(e)})),!this._memCache)throw new Error("no memCache");return this._memCache.put(`${o.handle}`,o),{memUsageBytes:o.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){this._memCache&&this._memCache.pop(`${e.handle}`),e.components.forEach((t=>{e.textures.forEach((e=>{this._stage.remove(e)})),this._collection.destroyObject(t),this._initialCullFace.delete(t)}))}setRenderableVisibility(e,t,r){if(this._memCache){for(let s=0;s<r;++s){const r=e[s],i=t[s];if(!i)continue;const o=this._lyrHandleToObjects.get(r);o&&(this._visibleGeometryChanged(),o.isVisible=i,o.components.forEach((e=>{this._collection.setObjectVisibility(e,i),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))})),this._memCache.pop(`${r}`))}for(let s=0;s<r;++s){const r=e[s],i=t[s];if(i)continue;const o=this._lyrHandleToObjects.get(r);o&&(this._visibleGeometryChanged(),o.isVisible=i,o.components.forEach((e=>{this._collection.setObjectVisibility(e,i),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))})),this._memCache.put(`${r}`,o))}}}_getTexture(e,t,r){let s=null;if(e&&t.desc?.images&&t.data?.buffer){const i=t.desc.images[e?.imageId];if(s=r.get(i),!s&&i){const o=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,a=!!i.mipCount||o>1,n=re[e.wrapMode??L.None];let l=i.alpha?4:3;const c=new Uint8Array(t.data.buffer,i.data.byteOffset,i.data.byteCount);let m=null,d=null,h=null;switch(i.format){case k.Raw:i.pixelFormat===B.R8?(m=c,l=1,d=""):i.pixelFormat===B.Rgb8?(m=c,l=3,d=""):i.pixelFormat===B.Rgba8&&(m=c,l=4,d="");break;case k.Dxt1:m=c,l=3,d=we.DDS_ENCODING;break;case k.Dxt5:m=c,l=4,d=we.DDS_ENCODING;break;case k.Basis:m=c,l=3,d=we.KTX2_ENCODING;break;case k.Png:d="image/png",h=document.createElement("img");break;case k.Jpeg:d="image/jpeg",h=document.createElement("img");break;case k.Etc2:d="image/ktx",h=document.createElement("img");break;case k.Astc:this._dbg(Pe.Error,"Astc texture not supported");break;case k.Pvrtc:this._dbg(Pe.Error,"Pvrtc texture not supported")}if(h&&d){const e=new Blob([c],{type:d});h.src=URL.createObjectURL(e),m=h}m&&null!=d&&(s=new ve(m,{mipmap:a,maxAnisotropy:o,encoding:d,wrap:n,components:l,noUnpackFlip:!0,width:i.mip0Width,height:i.mip0Height}),this._stage.add(s),r.set(i,s))}}return s?new ue(this.view.stage.renderView.textures,s.id):null}getBufferViews(e,t,r){let s,i,o,a,n,l,c,m=null;for(let h=0;h<e.atrbs.length;h++){const c=e.atrbs[h],u=c.view,p=void 0,f=u.byteOffset+u.byteCount,g=u.byteCount/se[u.type],b=[...Array(g).keys()].map((e=>e));try{switch(c.sem){case N.Position:3!==u.ncomp||u.type!==G.F32?this._dbg(Pe.Error,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(s=new U(t,u.byteOffset,p,f),i=new ge(s.typedBuffer,b,3));break;case N.Normal:if(3!==u.ncomp||u.type!==G.F32)this._dbg(Pe.Error,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new U(t,u.byteOffset,p,f),s=_e(e.typedBuffer,r);n=new A(s),l=new ge(n.typedBuffer,b,2)}break;case N.TexCoord:2!==u.ncomp||u.type!==G.F32?this._dbg(Pe.Error,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===a&&(a=new ge(new V(t,u.byteOffset,p,f).typedBuffer,b,2));break;case N.Color:4===u.ncomp?(u.type===G.F32&&(m=new M(t,u.byteOffset,p,f)),u.type===G.U8&&(m=new P(t,u.byteOffset,p,f)),u.type===G.U16&&(m=new O(t,u.byteOffset,p,f))):3===u.ncomp&&(u.type===G.F32&&(m=new U(t,u.byteOffset,p,f)),u.type===G.U8&&(m=new E(t,u.byteOffset,p,f)),u.type===G.U16&&(m=new I(t,u.byteOffset,p,f))),null==m?this._dbg(Pe.VerboseAPI,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new ge(m.typedBuffer,b,u.ncomp);break;case N.FeatureIndex:break;default:this._dbg(Pe.VerboseAPI,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(d){this._dbg(Pe.VerboseAPI,"Error Creating buffer ("+d+"). Skipping vertex attribute.")}}if(e.index){const r=e.index.view,s=void 0,i=r.byteOffset+r.byteCount;switch(e.index.view.type){case G.U16:c=new S(t,r.byteOffset,s,i);break;case G.U32:c=new H(t,r.byteOffset,s,i);break;case G.U8:default:this._dbg(Pe.Error,"[Unsupported Feature] index type not supported ("+r.type+").")}}if(null==c&&null!=s){const e=s.count;if(e<65535){const t=new Uint16Array(e);c=new S(t)}else{const t=new Uint32Array(e);c=new H(t)}for(let t=0;t<e;t++)c.set(t,t)}return{positionView:s,positionAttr:i,colorAttr:o,texCoord0Attr:a,indicesView:c,normalsView:n,normalsAttr:l}}_onRemoveFromCache(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,t){this._dbgFlags.has(e)&&(e===Pe.Error?r.getLogger(this).error(t):r.getLogger(this).warn(t))}};e([n()],Ee.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([n()],Ee.prototype,"layer",void 0),e([n({readOnly:!0})],Ee.prototype,"visibleAtCurrentScale",null),e([n()],Ee.prototype,"elevationOffset",null),Ee=e([l("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Ee);const Ie=Ee;export{Ie as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
let e,t=null;const i=new Map;async function n(n){null==t&&(null==e&&(e=import("../../../layers/Lyr3DWasmPerSceneView.js")),t=await e);const r=n.view;let s=i.get(r);s||(s=new t.default({view:r}),i.set(r,s));const a=!!r.
|
|
5
|
+
let e,t=null;const i=new Map;async function n(n){null==t&&(null==e&&(e=import("../../../layers/Lyr3DWasmPerSceneView.js")),t=await e);const r=n.view;let s=i.get(r);s||(s=new t.default({view:r}),i.set(r,s));const a=!!r.stage.renderView.renderingContext.capabilities.compressedTextureS3TC,l=!!r.stage.renderView.renderingContext.capabilities.compressedTextureETC;return await s.initializeWasm(a,l),s.add3DTilesLayerView(n)}function r(e){return i.get(e)}function s(n){const r=n.view,s=i.get(r);if(s){s.remove3DTilesLayerView(n)<1&&(i.delete(r),0===i.size&&(e=null,t=null))}}export{n as addLayerViewToWasm,r as getLyr3DWasm,s as removeLayerViewFromWasm};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import{makeHandle as r,handlesGroup as i,destroyHandle as n}from"../../../core/handleUtils.js";import"../../../core/has.js";import{isIterable as s}from"../../../core/iteratorUtils.js";import{getProjectiveTransform as a}from"../../../core/perspectiveUtils.js";import{debounce as o,isPromiseLike as d}from"../../../core/promiseUtils.js";import{watch as l,on as m,syncAndInitial as h}from"../../../core/reactiveUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import{create as g}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{toExtent as u}from"../../../geometry/support/aaBoundingRect.js";import{MediaElementView as y}from"../../../layers/support/MediaElementView.js";import{DrapeSourceType as _}from"./interfaces.js";import{LayerView3D as f}from"./LayerView3D.js";import{MediaLayerInteraction as E}from"./support/MediaLayerInteraction.js";import{drapedZ as w}from"../terrain/OverlayRenderer.js";import{Attribute as v}from"../webgl-engine/lib/Attribute.js";import{ContentObjectType as D}from"../webgl-engine/lib/ContentObjectType.js";import{Geometry as b}from"../webgl-engine/lib/Geometry.js";import{DirtyState as R,DirtyOperation as j}from"../webgl-engine/lib/ModelDirtyTypes.js";import{Object3DHighlightStateID as H}from"../webgl-engine/lib/Object3DStateID.js";import{RenderGeometry as I}from"../webgl-engine/lib/RenderGeometry.js";import{Texture as G}from"../webgl-engine/lib/Texture.js";import{UpdatePolicy as A}from"../webgl-engine/lib/UpdatePolicy.js";import{VertexAttribute as M}from"../webgl-engine/lib/VertexAttribute.js";import{ImageMaterial as T}from"../webgl-engine/materials/ImageMaterial.js";import x from"../../layers/LayerView.js";import P from"../../layers/MediaLayerView.js";import{defaultHighlightName as S}from"../../support/HighlightDefaults.js";import{isInEffectiveScaleRange as L}from"../../support/layerViewUtils.js";import{TextureWrapMode as O}from"../../webgl/enums.js";let V=class extends(f(P(x))){get interactive(){return this._interaction.enabled}set interactive(e){this._interaction&&(this._interaction.enabled=e)}get selectedElement(){return this._interaction.selectedElement}set selectedElement(e){this._interaction&&(this._interaction.selectedElement=e)}get visibleAtCurrentScale(){return L(this.layer.effectiveScaleRange,this.view.scale)}get usedMemory(){return Array.from(this._renderElements.values()).reduce(((e,t)=>e+(t.getRenderData()?.texture.usedMemory??0)),0)}constructor(e){super(e),this.type="media-3d",this.drapeSourceType=_.Features,this.updatePolicy=A.SYNC,this.ignoresMemoryFactor=!0,this.unloadedMemory=0,this._uidToElement=new Map,this._highlightedElements=new Map,this._elementsInHighlightedId=new Map,this._renderElements=new Map,this._lastDrapingExtent=null,this._update=o((async(e,t,r)=>{const i=await this._collectMediaElements(e,t,r);this._synchronizeRenderElements(i)}),0);const{view:t,layer:r}=e;this._interaction=new E({view:t,layer:r}),this.addHandles(l((()=>this.interactionOptions),(e=>this._interaction.options=e),h))}initialize(){const{view:e,layer:t}=this;this._renderer=e.basemapTerrain.overlayManager.registerGeometryDrapeSource(this);const i=()=>this._updateWithLastDrapingExtent();this.addHandles([r((()=>e.basemapTerrain.overlayManager.unregisterDrapeSource(this))),m((()=>t.effectiveSource),"change",i),m((()=>t.effectiveSource),"refresh",i)]),this._updatingHandles.add((()=>this.suspended),i)}setDrapingExtent(e,t){this._lastDrapingExtent={overlays:e,spatialReference:t},this._updateWithLastDrapingExtent()}getHit(e){const t=this._uidToElement.get(e);return t?{type:"media",element:t,layer:this.layer}:null}highlight(e,t){const i=new H(t?.name??S),n=s(e)?Array.from(e):[e];this._elementsInHighlightedId.set(i,n);for(const r of n){const e=this._highlightedElements.get(r);e?e.add(i):this._highlightedElements.set(r,new Set([i]));const t=this._renderElements.get(r)?.getRenderData();t&&(t.renderGeometry.geometry.addHighlight(i),this._renderer.modifyGeometries([t.renderGeometry],R.HIGHLIGHT))}return r((()=>{const e=this._elementsInHighlightedId.get(i);if(e){for(const t of e){const e=this._highlightedElements.get(t);if(!e)continue;e.delete(i);const r=this._renderElements.get(t)?.getRenderData();r&&(r.renderGeometry.geometry.removeHighlight(i),this._renderer.modifyGeometries([r.renderGeometry],R.HIGHLIGHT)),0===e.size&&this._highlightedElements.delete(t)}this._elementsInHighlightedId.delete(i)}}))}isUpdating(){return super.isUpdating()||this._interaction.updating}_updateWithLastDrapingExtent(){if(null==this._lastDrapingExtent||this.suspended)return void(this._renderer&&this._synchronizeRenderElements(new Set));const{overlays:e,spatialReference:t}=this._lastDrapingExtent;this._updatingHandles.addPromise(this._update(e,t).catch((()=>{})))}async _collectMediaElements(e,t,r){const i=this.layer.effectiveSource;return null==i?new Set:new Set((await Promise.all(e.map((e=>i.queryElements(u(e.extent,t),{signal:r}))))).flat())}_synchronizeRenderElements(e){this._synchronizeRenderElementsRemove(e),this._synchronizeRenderElementsAdd(e)}_synchronizeRenderElementsRemove(e){this._renderElements.forEach(((t,r)=>{e.has(r)||(this._removeElement(r,t),this.emit("element-render-changed",{element:r}))}))}_synchronizeRenderElementsAdd(e){for(const t of e)this._renderElements.has(t)||this._createRenderElement(t)}_removeElement(e,t){this._destroyRenderData(e,t),this._renderElements.delete(e),this._uidToElement.delete(e.uid),t.handle.remove()}_createRenderElement(e){const t=new y({spatialReference:this.view.spatialReference,element:e}),r=new U(i([this._updatingHandles.add((()=>e.opacity),(e=>r.getRenderData()?.material.setParameters({opacity:e}))),this._updatingHandles.add((()=>t.coords),(()=>{r.data?this._updateGeometry(t,r):this._initializeRenderData(t,r)})),this._updatingHandles.add((()=>e.content),(()=>this._initializeRenderData(t,r))),n(t)]));this._renderElements.set(e,r),this._uidToElement.set(e.uid,e),this._updatingHandles.addPromise(e.load().catch((()=>{}))),this._initializeRenderData(t,r)}_initializeRenderData(e,t){const{coords:r,element:i}=e,{contentWidth:n,contentHeight:s}=i;if(null==r||null==i.content)return void this._destroyRenderData(i,t);if(t.data)return;const a=this._createTexture(i.content),o=a.load(this.view.
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import{makeHandle as r,handlesGroup as i,destroyHandle as n}from"../../../core/handleUtils.js";import"../../../core/has.js";import{isIterable as s}from"../../../core/iteratorUtils.js";import{getProjectiveTransform as a}from"../../../core/perspectiveUtils.js";import{debounce as o,isPromiseLike as d}from"../../../core/promiseUtils.js";import{watch as l,on as m,syncAndInitial as h}from"../../../core/reactiveUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import{create as g}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{toExtent as u}from"../../../geometry/support/aaBoundingRect.js";import{MediaElementView as y}from"../../../layers/support/MediaElementView.js";import{DrapeSourceType as _}from"./interfaces.js";import{LayerView3D as f}from"./LayerView3D.js";import{MediaLayerInteraction as E}from"./support/MediaLayerInteraction.js";import{drapedZ as w}from"../terrain/OverlayRenderer.js";import{Attribute as v}from"../webgl-engine/lib/Attribute.js";import{ContentObjectType as D}from"../webgl-engine/lib/ContentObjectType.js";import{Geometry as b}from"../webgl-engine/lib/Geometry.js";import{DirtyState as R,DirtyOperation as j}from"../webgl-engine/lib/ModelDirtyTypes.js";import{Object3DHighlightStateID as H}from"../webgl-engine/lib/Object3DStateID.js";import{RenderGeometry as I}from"../webgl-engine/lib/RenderGeometry.js";import{Texture as G}from"../webgl-engine/lib/Texture.js";import{UpdatePolicy as A}from"../webgl-engine/lib/UpdatePolicy.js";import{VertexAttribute as M}from"../webgl-engine/lib/VertexAttribute.js";import{ImageMaterial as T}from"../webgl-engine/materials/ImageMaterial.js";import x from"../../layers/LayerView.js";import P from"../../layers/MediaLayerView.js";import{defaultHighlightName as S}from"../../support/HighlightDefaults.js";import{isInEffectiveScaleRange as L}from"../../support/layerViewUtils.js";import{TextureWrapMode as O}from"../../webgl/enums.js";let V=class extends(f(P(x))){get interactive(){return this._interaction.enabled}set interactive(e){this._interaction&&(this._interaction.enabled=e)}get selectedElement(){return this._interaction.selectedElement}set selectedElement(e){this._interaction&&(this._interaction.selectedElement=e)}get visibleAtCurrentScale(){return L(this.layer.effectiveScaleRange,this.view.scale)}get usedMemory(){return Array.from(this._renderElements.values()).reduce(((e,t)=>e+(t.getRenderData()?.texture.usedMemory??0)),0)}constructor(e){super(e),this.type="media-3d",this.drapeSourceType=_.Features,this.updatePolicy=A.SYNC,this.ignoresMemoryFactor=!0,this.unloadedMemory=0,this._uidToElement=new Map,this._highlightedElements=new Map,this._elementsInHighlightedId=new Map,this._renderElements=new Map,this._lastDrapingExtent=null,this._update=o((async(e,t,r)=>{const i=await this._collectMediaElements(e,t,r);this._synchronizeRenderElements(i)}),0);const{view:t,layer:r}=e;this._interaction=new E({view:t,layer:r}),this.addHandles(l((()=>this.interactionOptions),(e=>this._interaction.options=e),h))}initialize(){const{view:e,layer:t}=this;this._renderer=e.basemapTerrain.overlayManager.registerGeometryDrapeSource(this);const i=()=>this._updateWithLastDrapingExtent();this.addHandles([r((()=>e.basemapTerrain.overlayManager.unregisterDrapeSource(this))),m((()=>t.effectiveSource),"change",i),m((()=>t.effectiveSource),"refresh",i)]),this._updatingHandles.add((()=>this.suspended),i)}setDrapingExtent(e,t){this._lastDrapingExtent={overlays:e,spatialReference:t},this._updateWithLastDrapingExtent()}getHit(e){const t=this._uidToElement.get(e);return t?{type:"media",element:t,layer:this.layer}:null}highlight(e,t){const i=new H(t?.name??S),n=s(e)?Array.from(e):[e];this._elementsInHighlightedId.set(i,n);for(const r of n){const e=this._highlightedElements.get(r);e?e.add(i):this._highlightedElements.set(r,new Set([i]));const t=this._renderElements.get(r)?.getRenderData();t&&(t.renderGeometry.geometry.addHighlight(i),this._renderer.modifyGeometries([t.renderGeometry],R.HIGHLIGHT))}return r((()=>{const e=this._elementsInHighlightedId.get(i);if(e){for(const t of e){const e=this._highlightedElements.get(t);if(!e)continue;e.delete(i);const r=this._renderElements.get(t)?.getRenderData();r&&(r.renderGeometry.geometry.removeHighlight(i),this._renderer.modifyGeometries([r.renderGeometry],R.HIGHLIGHT)),0===e.size&&this._highlightedElements.delete(t)}this._elementsInHighlightedId.delete(i)}}))}isUpdating(){return super.isUpdating()||this._interaction.updating}_updateWithLastDrapingExtent(){if(null==this._lastDrapingExtent||this.suspended)return void(this._renderer&&this._synchronizeRenderElements(new Set));const{overlays:e,spatialReference:t}=this._lastDrapingExtent;this._updatingHandles.addPromise(this._update(e,t).catch((()=>{})))}async _collectMediaElements(e,t,r){const i=this.layer.effectiveSource;return null==i?new Set:new Set((await Promise.all(e.map((e=>i.queryElements(u(e.extent,t),{signal:r}))))).flat())}_synchronizeRenderElements(e){this._synchronizeRenderElementsRemove(e),this._synchronizeRenderElementsAdd(e)}_synchronizeRenderElementsRemove(e){this._renderElements.forEach(((t,r)=>{e.has(r)||(this._removeElement(r,t),this.emit("element-render-changed",{element:r}))}))}_synchronizeRenderElementsAdd(e){for(const t of e)this._renderElements.has(t)||this._createRenderElement(t)}_removeElement(e,t){this._destroyRenderData(e,t),this._renderElements.delete(e),this._uidToElement.delete(e.uid),t.handle.remove()}_createRenderElement(e){const t=new y({spatialReference:this.view.spatialReference,element:e}),r=new U(i([this._updatingHandles.add((()=>e.opacity),(e=>r.getRenderData()?.material.setParameters({opacity:e}))),this._updatingHandles.add((()=>t.coords),(()=>{r.data?this._updateGeometry(t,r):this._initializeRenderData(t,r)})),this._updatingHandles.add((()=>e.content),(()=>this._initializeRenderData(t,r))),n(t)]));this._renderElements.set(e,r),this._uidToElement.set(e.uid,e),this._updatingHandles.addPromise(e.load().catch((()=>{}))),this._initializeRenderData(t,r)}_initializeRenderData(e,t){const{coords:r,element:i}=e,{contentWidth:n,contentHeight:s}=i;if(null==r||null==i.content)return void this._destroyRenderData(i,t);if(t.data)return;const a=this._createTexture(i.content),o=a.load(this.view.stage.renderView.renderingContext),l=()=>{if(!a.loaded)return;this.view.stage.add(a);const e=new T({texture:a,opacity:i.opacity,perspectiveInterpolation:!0}),o=this._getPositionAttributeArray(r),d=[0,0,1,0,1,1,0,1],l=this._getPerspectiveDivideAttributeArray(o,n,s),m=[0,1,2,0,2,3],h=new b(e,[[M.POSITION,new v(o,m,3,!0)],[M.UV0,new v(d,m,2,!0)],[M.PERSPECTIVEDIVIDE,new v(l,m,1,!0)]]),c=new I(h,{layerUid:this.layer.uid,graphicUid:i.uid}),p=this._highlightedElements.get(i);p?.forEach((e=>c.geometry.addHighlight(e))),this._renderer.addGeometries([c],j.ADD),t.data=new C(c,a,e),this.emit("element-render-changed",{element:i})};d(o)?(t.data=a,this._updatingHandles.addPromise(o),o.then(l).catch((()=>a.dispose()))):l()}_updateGeometry(e,t){const{coords:r,element:i}=e;if(null==r||null==i.content)return void this._destroyRenderData(i,t);const n=t.getRenderData();if(!n)return;const s=this._getPositionAttributeArray(r);n.renderGeometry.geometry.setAttributeData(M.POSITION,s);const a=this._getPerspectiveDivideAttributeArray(s,i.contentWidth,i.contentHeight);n.renderGeometry.geometry.setAttributeData(M.PERSPECTIVEDIVIDE,a),n.renderGeometry.geometry.invalidateBoundingInfo(),this._renderer.modifyGeometries([n.renderGeometry],R.GEOMETRY),this.emit("element-render-changed",{element:i})}_getPositionAttributeArray(e){const[t,r,i,n]=e.rings[0];return[t[0],t[1],w,n[0],n[1],w,i[0],i[1],w,r[0],r[1],w]}_getPerspectiveDivideAttributeArray(e,t,r){a(z,[0,0,t,0,t,r,0,r],[e[0],e[1],e[3],e[4],e[6],e[7],e[9],e[10]]);const i=z[6]/z[8]*t,n=z[7]/z[8]*r;return[1,1+i,1+i+n,1+n]}_destroyRenderData(e,t){const r=t.data;if(null==r)return;if(t.data=null,r?.type===D.Texture)return void r.dispose();const i=r.texture;i.unload(),this.view.stage.remove(i),this._renderer.removeGeometries([r.renderGeometry],j.REMOVE),this.emit("element-render-changed",{element:e})}_createTexture(e){const r=e instanceof HTMLImageElement?e.naturalWidth:e.width,i=e instanceof HTMLImageElement?e.naturalHeight:e.height;if("getFrame"in e)throw new t("media-layer-view-3d","animation is not supported");return new G(e,{wrap:{s:O.CLAMP_TO_EDGE,t:O.CLAMP_TO_EDGE},preMultiplyAlpha:!0,width:r,height:i,mipmap:!0,updateCallback:()=>this.view.basemapTerrain.overlayManager.requestRender()})}get test(){}};e([c({readOnly:!0})],V.prototype,"type",void 0),e([c()],V.prototype,"layer",void 0),e([c()],V.prototype,"interactive",null),e([c()],V.prototype,"selectedElement",null),e([c({readOnly:!0})],V.prototype,"visibleAtCurrentScale",null),V=e([p("esri.views.3d.layers.MediaLayerView3D")],V);const z=g();class U{constructor(e){this.handle=e}getRenderData(){return this.data?.type===D.Texture?null:this.data}}class C{constructor(e,t,r){this.renderGeometry=e,this.texture=t,this.material=r,this.type="RenderData"}}const W=V;export{W as default};
|