@arcgis/core 6.0.0-next.35 → 6.0.0-next.37
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/{0202eb8c2b2865f99981.js → 00311d1b18d5952a014b.js} +1 -1
- package/assets/esri/core/workers/chunks/0b21d0e2e5a91c34a108.js +1 -0
- package/assets/esri/core/workers/chunks/{f717005e14a7e9141df7.js → 2050c844b5a29b1df28a.js} +1 -1
- package/assets/esri/core/workers/chunks/2c3612379111457c3221.js +1 -0
- package/assets/esri/core/workers/chunks/2f9072563194026e320e.js +1 -0
- package/assets/esri/core/workers/chunks/{d9a240a3c6bf85124474.js → 342a97974a78007b25e0.js} +1 -1
- package/assets/esri/core/workers/chunks/34467f7d84baffd772a3.js +1 -0
- package/assets/esri/core/workers/chunks/{4d18b48d4a282a0f341c.js → 427d929dc7f89b0a1ea9.js} +1 -1
- package/assets/esri/core/workers/chunks/432728c557be5dfa26b5.js +1 -0
- package/assets/esri/core/workers/chunks/46969f379623810b2eca.js +1 -0
- package/assets/esri/core/workers/chunks/592b5db1459c02cf6a0c.js +1 -0
- package/assets/esri/core/workers/chunks/6a21dc13a465757ba007.js +1 -0
- package/assets/esri/core/workers/chunks/{379db67f78161ebd5468.js → 7023651ed6398dcf8efb.js} +1 -1
- package/assets/esri/core/workers/chunks/{90360c0bd053d3e3fd77.js → 7027a0e7bfabb3bb7fc2.js} +1 -1
- package/assets/esri/core/workers/chunks/78818c2a898444f7e890.js +1 -0
- package/assets/esri/core/workers/chunks/{40c2674dae73f0942751.js → 7d497df6e13162156342.js} +1 -1
- package/assets/esri/core/workers/chunks/8a3dfe997712dc2ddead.js +1 -0
- package/assets/esri/core/workers/chunks/{81bcc495e6eaf2cf7474.js → 8f82a0a6747f673a2a7e.js} +1 -1
- package/assets/esri/core/workers/chunks/9826baa3c15ea2062669.js +1 -0
- package/assets/esri/core/workers/chunks/{d3369ffed19f4c264dcd.js → 9ab0735e86cf8932bf9d.js} +1 -1
- package/assets/esri/core/workers/chunks/ab0ea4042f4e13874aed.js +1 -0
- package/assets/esri/core/workers/chunks/ab98ade3257360015d6c.js +1 -0
- package/assets/esri/core/workers/chunks/{796c6195b6bf59dcc9bd.js → b25a05c58b0fd0f6ac60.js} +1 -1
- package/assets/esri/core/workers/chunks/b90271ce38522bcf813b.js +1 -0
- package/assets/esri/core/workers/chunks/ba91df9835cdea7698a9.js +1 -0
- package/assets/esri/core/workers/chunks/bfe13ac9fa1aafb190a1.js +1 -0
- package/assets/esri/core/workers/chunks/ce0274847ccce6a1ac53.js +1 -0
- package/assets/esri/core/workers/chunks/cf2e5f827cea7d7319ce.js +1 -0
- package/assets/esri/core/workers/chunks/dae2036faa28dade2119.js +1 -0
- package/assets/esri/core/workers/chunks/{e8fb2ba7b7a4f0916325.js → eed4b90494a54f8b337b.js} +1 -1
- package/assets/esri/core/workers/chunks/fc77eb7683e708774168.js +1 -0
- package/chunks/Clouds.glsl.js +7 -11
- package/chunks/RibbonLine.glsl.js +158 -84
- package/config.js +1 -1
- package/core/libs/gl-matrix-2/math/vec3.js +1 -1
- package/kernel.js +1 -1
- package/layers/BaseElevationLayer.js +1 -1
- package/layers/ElevationLayer.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/IntegratedMeshLayer.d.ts +2 -0
- package/layers/IntegratedMeshLayer.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
- package/layers/support/ElevationQuery.js +1 -1
- package/layers/video/VideoController.js +3 -3
- package/layers/video/types.d.ts +12 -0
- package/package.json +3 -3
- package/support/timeUtils.js +1 -1
- package/views/2d/engine/Bitmap.js +1 -1
- package/views/2d/engine/flow/styles/Imagery.js +1 -1
- package/views/2d/engine/vectorTiles/SpriteMosaic.js +1 -1
- package/views/2d/engine/vectorTiles/VTLPainter3D.js +1 -1
- package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
- package/views/2d/engine/webgl/GlyphMosaic.js +1 -1
- package/views/2d/engine/webgl/Overlay.js +1 -1
- package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
- package/views/2d/engine/webgl/SpriteMosaic.js +1 -1
- package/views/2d/engine/webgl/VideoScreenRenderer.js +1 -1
- package/views/2d/engine/webgl/animations/store/AnimationStore.js +1 -1
- package/views/2d/engine/webgl/collisions/LabelStore.js +1 -1
- package/views/2d/engine/webgl/effects/highlight/HighlightGradient.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/TextureStatisticsTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/blend/BlendTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/colorize/ColorizeTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityResources.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/drop-shadow/DropShadowTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/heatmap/HeatmapResources.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/magnifier/MagnifierTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/opacity/OpacityTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterColorizerTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterHighlightTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/textureUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/tile/TileDebugInfoTexture.js +1 -1
- package/views/2d/engine/webgl/textureUtils.js +1 -1
- package/views/2d/layers/LayerView2D.js +1 -1
- package/views/2d/webglDeps.js +1 -1
- package/views/3d/GroundView3D.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
- package/views/3d/analysis/LineOfSight/placementUtils.js +1 -1
- package/views/3d/analysis/Viewshed/placementUtils.js +1 -1
- package/views/3d/input/SceneInputManager.js +1 -1
- package/views/3d/interactive/Manipulator3D.js +1 -1
- package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
- package/views/3d/interactive/editingTools/originGeometryVisualElementUtils.js +1 -1
- package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/graphics/ElevationAligners.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
- package/views/3d/layers/support/Tiles3DBVH.js +1 -1
- package/views/3d/layers/support/Tiles3DMeshIntersectionHandler.js +1 -1
- package/views/3d/support/engineContent/line.js +1 -1
- package/views/3d/support/engineContent/marker.js +1 -1
- package/views/3d/support/flow/StreamlineResources3D.js +1 -1
- package/views/3d/support/flow/StreamlineResources3DOverlay.js +1 -1
- package/views/3d/support/flow/StreamlineResources3DShape.js +1 -1
- package/views/3d/support/flow/geometryUtils.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatFadeHelper.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatIntersectionHandler.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatOrderTexture.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatTextureAtlas.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianTile.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianTileBuilder.js +2 -0
- package/views/3d/support/gaussianSplatting/formatConstants.js +2 -0
- package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/StableSurfaceCenter.js +1 -1
- package/views/3d/support/pointsOfInterest/SurfaceGeometryUpdates.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/TileCompositor.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/webgl/RenderNode.d.ts +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/hud/HUD.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/GaussianSplatUnpacking.glsl.js +15 -11
- package/views/3d/webgl-engine/effects/atmosphere/LocalAtmosphere.js +1 -1
- package/views/3d/webgl-engine/effects/atmosphere/MarsAtmosphere.js +1 -1
- package/views/3d/webgl-engine/effects/clouds/CloudsRenderer.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
- package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
- package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
- package/views/3d/webgl-engine/effects/stars/Stars.js +1 -1
- package/views/3d/webgl-engine/lib/AttributeView.js +1 -1
- package/views/3d/webgl-engine/lib/BasisUtil.js +1 -1
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/lib/DDSUtil.js +1 -1
- package/views/3d/webgl-engine/lib/DrapedHeatmapRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/GPUPointOcclusionQuery.js +1 -1
- package/views/3d/webgl-engine/lib/GaussianSplatRenderUtils.js +1 -1
- package/views/3d/webgl-engine/lib/ManagedTexture.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/TextureBackedBuffer/TextureBuffer.js +1 -1
- package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBufferView.js +1 -1
- package/views/3d/webgl-engine/lib/VerticesView.js +2 -0
- package/views/3d/webgl-engine/lib/attributeViewUtils.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/strokes.js +1 -1
- package/views/3d/webgl-engine/lib/glUtil3D.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/internal/WaterTextureRepository.js +1 -1
- package/views/3d/webgl-engine/materials/internal/lineMarkerBufferUtils.js +2 -0
- package/views/3d/webgl-engine/materials/internal/ribbonLineBufferUtils.js +2 -0
- package/views/3d/webgl-engine/materials/renderers/VaoRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/stippleTextureRepository.js +1 -1
- package/views/draw/DrawTool.js +1 -1
- package/views/draw/support/ManagedTooltipField.js +1 -1
- package/views/support/TextureCompressionHelper.js +1 -1
- package/views/support/imageReprojection.js +1 -1
- package/views/webgl/FramebufferObject.js +1 -1
- package/views/webgl/RenderingContext.js +1 -1
- package/views/webgl/Texture.js +1 -1
- package/views/webgl/rasterUtils.js +1 -1
- package/views/webgl/testSVGPremultipliedAlpha.js +1 -1
- package/views/webgl/textureUtils.js +1 -1
- package/widgets/OrientedImageryViewer/navigation/NavigationManager.js +1 -1
- package/widgets/OrientedImageryViewer/navigation/queries.js +1 -1
- package/widgets/OrientedImageryViewer/navigation/utils.js +1 -1
- package/widgets/OrientedImageryViewer.js +2 -2
- package/widgets/ScaleRangeSlider/types.d.ts +3 -3
- package/assets/esri/core/workers/chunks/039d9bc5b5015012f811.js +0 -1
- package/assets/esri/core/workers/chunks/08140725277de5d2e41a.js +0 -1
- package/assets/esri/core/workers/chunks/16cda273927ab0a39544.js +0 -1
- package/assets/esri/core/workers/chunks/29c610ce1c81ebb84a6b.js +0 -1
- package/assets/esri/core/workers/chunks/3223f9fbc76ba9ef8d13.js +0 -1
- package/assets/esri/core/workers/chunks/3fdcc383bbd9cf0d274c.js +0 -1
- package/assets/esri/core/workers/chunks/46c290108a90518ef695.js +0 -1
- package/assets/esri/core/workers/chunks/48b8b57f559a53c6c513.js +0 -1
- package/assets/esri/core/workers/chunks/4a979fce1c971b614a18.js +0 -1
- package/assets/esri/core/workers/chunks/5bd1414220e42cb8ebcf.js +0 -1
- package/assets/esri/core/workers/chunks/5d781c2c6204cffffd0d.js +0 -1
- package/assets/esri/core/workers/chunks/723df53cfa0189837d01.js +0 -1
- package/assets/esri/core/workers/chunks/7400b8c454b47ee4fb3c.js +0 -1
- package/assets/esri/core/workers/chunks/7af4edc6e87d27b9d467.js +0 -1
- package/assets/esri/core/workers/chunks/990e96139b5a1dccb061.js +0 -1
- package/assets/esri/core/workers/chunks/a607541959169741a943.js +0 -1
- package/assets/esri/core/workers/chunks/aa779896fd9e5c341349.js +0 -1
- package/assets/esri/core/workers/chunks/c131e0dd180a4c10e12e.js +0 -1
- package/assets/esri/core/workers/chunks/f3b4159c0722df8ffe13.js +0 -1
- package/assets/esri/core/workers/chunks/f75eec2cbc541eec9712.js +0 -1
- package/views/3d/webgl-engine/lib/GaussianSplatPrepassDepthRenderer.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../Color.js";import n from"../../../Graphic.js";import{removeUnordered as r,isSome as i}from"../../../core/arrayUtils.js";import has from"../../../core/has.js";import a from"../../../core/Logger.js";import{equals as o}from"../../../core/MapUtils.js";import{destroyMaybe as s}from"../../../core/maybe.js";import c from"../../../core/PooledArray.js";import{ignoreAbortErrors as l,isAbortError as u,throwIfAborted as d}from"../../../core/promiseUtils.js";import{initial as f,watch as p}from"../../../core/reactiveUtils.js";import{schedule as m}from"../../../core/scheduling.js";import{equals as h}from"../../../core/SetUtils.js";import{isArrayBuffer as g}from"../../../core/typedArrayUtil.js";import{property as _,subclass as v}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as y,exactEquals as b,invert as ee}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as te,IDENTITY as ne}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as re,getTranslation as ie}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as ae,create as oe}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as se}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{set as x,transformMat4 as S,transformMat3 as ce,sub as le,add as C,scale as ue,subtract as w}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as T}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as E}from"../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as de}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as D}from"../../../core/support/UpdatingHandles.js";import{getSphericalPCPF as O}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{localLinearScaleFactors as fe}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as pe}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as me}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as k}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as A}from"../../../geometry/projection/projectVectorToVector.js";import{create as j,fromBuffer as he,toRect as ge}from"../../../geometry/support/aaBoundingBox.js";import{create as M,intersects as N}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as P,ensurePackedMat4f64 as _e}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as ve}from"../../../geometry/support/FloatArray.js";import{compactIndices as ye}from"../../../geometry/support/Indices.js";import{Sphere as F}from"../../../geometry/support/sphere.js";import{newUByteArray as I}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as L}from"../../../layers/LayerConstants.js";import be from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as xe}from"../../../layers/support/fieldUtils.js";import{I3SExtractChanges as Se}from"../../../layers/support/I3SExtractChanges.js";import R from"../../../layers/support/SceneModification.js";import{getColor as Ce,getOpacity as we}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{isBasemapLayerView as z}from"../../../support/basemapUtils.js";import{getElevationOffset as B}from"../../../support/elevationInfoUtils.js";import{loadArcade as Te}from"../../../support/loadArcade.js";import V from"../../../symbols/MeshSymbol3D.js";import Ee from"../../../symbols/SimpleFillSymbol.js";import{ContentGeometryUpdateEvent as De}from"./ContentGeometryLayerView.js";import Oe from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as ke}from"./I3SMeshViewPerformanceInfo.js";import{initialize as Ae,setModificationsSync as je,filterObbsForModificationsSync as Me,interpretObbModificationResults as Ne}from"./SceneLayerWorker.js";import{SceneLayerWorkerHandle as Pe,toWasmModification as Fe}from"./SceneLayerWorkerHandle.js";import{overrideColor as Ie}from"./graphics/graphicUtils.js";import{areLabelsVisible as Le}from"./graphics/Labeler.js";import Re from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as ze}from"./i3s/I3SAsyncElevationUpdater.js";import{getCachedAttributeValue as H}from"./i3s/I3SBinaryReader.js";import{I3SCrossfadeHelper as Be,NodeCrossfadeMetaData as Ve}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as He}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Ue,TraversedIntersectionNode as We}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Ge,selectEncoding as Ke,defaultMaterial as qe,createTexture as Je,configureMaterial as Ye}from"./i3s/I3SMaterialUtil.js";import{I3SOverrides as Xe}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as Ze}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as Qe,checkSceneLayerValid as $e,checkSceneLayerCompatibleWithView as et,whenGraphicAttributes as tt,computeVisibilityObb as nt,filterInPlace as rt,intersectBoundingRectWithMbs as it,addWraparound as U,getSymbolInfo as at,transparentEdgeMaterial as W,getClipRect as ot}from"./i3s/I3SUtil.js";import{IDBCache as st}from"./i3s/IDBCache.js";import{IDBMockCache as ct}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as lt}from"./i3s/LayerElevationProvider.js";import{SymbologyInfo as ut}from"./i3s/SymbologyInfo.js";import{attributeLookup as G}from"./support/attributeUtils.js";import{normalizeHighlightTarget as dt,emptyHighlightHandle as ft}from"./support/highlightUtils.js";import{makeScheduleFunction as pt}from"./support/makeScheduleFunction.js";import{debugFlags as K}from"../support/debugFlags.js";import{ElevationRange as q}from"../support/ElevationRange.js";import{toBoundingRect as mt}from"../support/extentUtils.js";import{Obb as J,ensurePackedObbData as ht}from"../support/orientedBoundingBox.js";import{updatingProgress as gt}from"../support/updatingProperties.js";import{glLayout as _t}from"../support/buffer/glUtil.js";import{ObjectParameters as vt}from"../webgl-engine/collections/Component/ObjectParameters.js";import{createVertexBufferLayout as yt,ComponentGeometryParameters as bt,SourceGeometry as xt,VertexBufferLayoutCreationParameters as St}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as Ct}from"../webgl-engine/collections/Component/Transform.js";import{emissiveStrengthDefault as Y}from"../webgl-engine/core/shaderLibrary/output/getEmissions.glsl.js";import{getHighlightName as wt}from"../../support/highlightOptionsUtils.js";import{TextureCompressionTracker as Tt}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as Et}from"../../../webscene/support/AlphaCutoff.js";const Dt=[1,1,1,1];class Ot extends Ve{constructor(e,t,n,r,i,a,o,s,c,l,u){super(),this.node=e,this.featureIds=t,this.objectHandle=n,this.cachedRendererVersion=r,this.attributeInfo=i,this.material=a,this.textures=o,this.anchorIds=s,this.anchors=c,this._elevationAlignmentRange=new q,this._geometryElevationRange=new q,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=[],this.edgeMemoryUsage=0,this.cachedSymbologyStride=5,this.elevationAlignmentOffset=0,this._baseGeometryElevationRange=new q(l,u),this.updateGeometryElevationRange()}get geometryElevationRange(){return this._geometryElevationRange}updateGeometryElevationRange(){let e=this._baseGeometryElevationRange;if(!e.elevationRangeValid||e.isEmpty){this._elevationAlignmentRange.invalidateElevationRange(),this._geometryElevationRange.invalidateElevationRange();return}let t=this.elevationOffsets;if(!t||t.length===0){let t=this.elevationAlignmentOffset;this._elevationAlignmentRange.setElevationRangeValues(t,t),this._geometryElevationRange.setElevationRangeValues(e.minElevation+t,e.maxElevation+t);return}let n=1/0,r=-1/0;for(let e=0;e<t.length;++e){let i=this.elevationAlignmentOffset+(t[e]??0);n=Math.min(n,i),r=Math.max(r,i)}this._elevationAlignmentRange.setElevationRangeValues(n,r),this._geometryElevationRange.setElevationRangeValues(e.minElevation+n,e.maxElevation+r)}get usedMemory(){return this.node.memory}get featureExtents(){return this._featureExtents??=new Float64Array(6*this.featureIds.length).fill(1/0),this._featureExtents}}const kt=t=>{let g=t,F=class extends g{constructor(){super(...arguments),this._extractChanges=null,this._applySSAO=!0,this._imShading=!!has(`enable-feature:im-shading`),this._imVertexNormals=!!has(`enable-feature:im-vertex-normals`),this._updatingHandles=new D,this._highlights=null,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._compressionTracker=new Tt,this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._hasComponentData=!1,this._hasVertexColors=!1,this._nodeColorOverride=null,this.updating=!0,this.holeFilling=`auto`,this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=[],this.ignoresMemoryFactor=!1,this._layerUrl=``,this._cacheKeySuffix=null,this._meshUtilsImporterModule=null,this._meshUtilsImporterPromise=null,this._planetRadiusInGlobalMode=0,this._elevationTask=null,this._needFilterResolve=!1,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new n,this._crossfadeHelper=new Be(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get extractChanges(){return this._extractChanges?.layer!==this.layer&&(this._extractChanges?.destroy(),this._extractChanges=new Se({layer:this.layer})),this._extractChanges}get layerViewUid(){return this.uid}get layerId(){return this.layer.id}get sublayerId(){return null}get _isIntegratedMesh(){return this.layer.type===`integrated-mesh`}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible&&this.fullOpacity>Et}get legendEnabled(){return this.contentVisible&&this.layer?.legendEnabled===!0}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?`yes`:`probably-not`:`unknown`}get rendererTextureUsage(){return Qe(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?63:53:this._usePBR||this._hasLoadedPBRTextures?44:36}get elevationOffset(){let e=this.layer?.elevationInfo;return e?.mode===`absolute-height`?B(e,this.layer.spatialReference):0}get elevationInfo(){let e=this.layer?.elevationInfo;switch(e?.mode){case`absolute-height`:return new Z(0,B(e,this.layer.spatialReference));case`relative-to-ground`:return new Z(1,B(e,this.layer.spatialReference));case`on-the-ground`:return new Z(2,0);default:return new Z(0,0)}}get supportedTextureEncodings(){return Ge(this.view.stage.renderView.capabilities)}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){let e=this._nodeId2Meta,t=new q;for(let n of e.values()){let e=n?.geometryElevationRange;e?.elevationRangeValid&&!e.isEmpty&&t.expandElevationRange(e)}return t.elevationRangeValid&&!t.isEmpty?t:null}get fullExtent(){return this.layer.fullExtent}initialize(){let e=has(`enable-feature:idb-mock-cache`);this._idbCache=e?new ct(this.view,e):new st(`esri-scenelayer-cache`,`geometries`),this.addResolvingPromise(this.layer.indexInfo);let t=this.view.resourceController,n=t.memoryController;this.i3sOverrides=new Xe({view:this.view,layer:this.layer,memoryController:n,extractChanges:this.extractChanges}),this._workerHandle=new Pe(pt(t)),this.addResolvingPromise(this._workerHandle.promise),$e(this.layer),et(this.layer,this.view);let r=this.layer.store.defaultGeometrySchema;if(this.addResolvingPromise(this._workerHandle.setLegacySchema(this.uid,r).catch(l)),this._layerUrl=this.layer.parsedUrl.path,this._controller=new be({layerView:this,worker:this._workerHandle}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view.stage,this._collection=this._stage.renderView.componentObjectCollection,this._isIntegratedMesh||!r)this._hasComponentData=!1;else{let e=r.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=(r?.vertexAttributes.color??null)!=null&&!this.layer.cachedDrawingInfo?.color;let i=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,e=>this._deleteComponentObject(e));this._memCache=i;let o=this._controller,c=this._nodeId2Meta,u=this._nodeId2MetaReloading;function*d(e){let t=o.index;if(!t)return;let n=t.rootNode;if(!n)return;let r=null;for(let i of t.traverseValues(n,t=>(r=(c.get(t.index)||u.get(t.index))?.objectHandle??null,e(t,r))))yield new We(i,r)}this._intersectionHandler=new Ue({layerViewUid:this.layerViewUid,sublayerId:this.sublayerId,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:has(`enable-feature:im-as-ground`)?this.layer.isUsedAsGroundLayer:this._isIntegratedMesh,traverseNodeHierarchy:d}),this._elevationProvider=new lt({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add(()=>this.view.clippingArea,()=>this._clippingAreaChanged(),f),this._updatingHandles.add(()=>this.fullOpacity,e=>this._opacityChange(e)),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this.elevationOffset,(e,t)=>{this._reloadAll(t),this._controller.invalidateVisibilityObbs()}),this._updatingHandles.add(()=>this.elevationInfo,(e,t)=>this._elevationInfoChanged(e,t),f),this._updatingHandles.add(()=>!this.suspended&&this.elevationInfo.mode!==0,(e,t)=>{e?this.addHandles(this.view.groundView.on(`elevation-change`,({extent:e})=>this._ensureElevationTask().addExtent(e)),Wt):t&&this.removeHandles(Wt)},f),this._updatingHandles.add(()=>this._usePBR,e=>this._updatePBR(e)),this._updatingHandles.add(()=>this.rendererTextureUsage,()=>{this._reloadAll(),this.clearMemCache()}),this._updatingHandles.add(()=>this.contentVisible,e=>this._contentVisibleChanged(e),f),this._updatingHandles.add(()=>this.layer.labelsVisible,()=>this._labelingChanged(),f),this._updatingHandles.add(()=>this.layer.labelingInfo,()=>this._labelingChanged(),f),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),f),this.addHandles([p(()=>K.I3S_TREE_SHOW_TILES,e=>{if(e&&!this._treeDebugger){let e=this._controller.crsIndex;import(`./support/I3STreeDebugger.js`).then(({I3STreeDebugger:t})=>{!this._treeDebugger&&K.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))})}else!e&&!K.I3S_TREE_SHOW_TILES&&(this._treeDebugger=s(this._treeDebugger))},f),p(()=>K.I3S_SHOW_MODIFICATIONS,()=>this._showModifications(),f)]),this._cacheKeySuffix=this._getCacheKeySuffix(),this._idbCache.init().catch(e=>a.getLogger(this).warn(`Failed to initialize IndexedDB cache: ${e}`));let{view:m}=this,{viewingMode:h,renderCoordsHelper:g}=m;this._planetRadiusInGlobalMode=h===`local`?0:g.referenceEllipsoid.radius}destroy(){this._clearAddTasks(),this._elevationTask=s(this._elevationTask),this.i3sOverrides=s(this.i3sOverrides),this._extractChanges=s(this._extractChanges),this._elevationProvider&&=(this._elevationProvider.notifyObjectsChanged(this.getVisibleObbs()),this.view.elevationProvider.unregister(this._elevationProvider),null),this._intersectionHandler&&=(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),null);let e=this._workerHandle;e&&(e.destroyContextAndSelf(this.uid),this._workerHandle=null),this._removeAllNodeDataFromStage(),this._memCache=s(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=s(this._labeler),this._treeDebugger=s(this._treeDebugger),this._controller=s(this._controller),this._highlights=s(this._highlights),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=s(this._crossfadeHelper),this.emit(`visible-geometry-changed`),this._visibleGeometryChangedSchedulerHandle&&=(this._visibleGeometryChangedSchedulerHandle.remove(),null),this._updatingHandles=s(this._updatingHandles)}_memEstimateTextureAdded(e){let t=e.usedMemory;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(e!=null){let t=e.usedMemory;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){let t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){let t=this._collection.getObjectGPUMemoryUsage(e);this._gpuMemoryEstimate-=t,this._geoMemoryEstimate-=t}isNodeLoaded(e){return this._nodeId2Meta.has(e)}isNodeReloading(e){return this._nodeId2MetaReloading.has(e)}get usedMemory(){let e=this._labeler==null?0:this._labeler.usedMemory;return this._nodeId2Meta.forEach(t=>e+=t==null?0:t.node.memory),this._nodeId2MetaReloading.forEach(t=>e+=t==null?0:t.node.memory),e}get unloadedMemory(){return(this._controller==null?0:this._controller.unloadedMemoryEstimate)+(this._labeler==null?0:this._labeler.unloadedMemoryEstimate)}_labelingChanged(){if(!(Le(this.layer)&&this._supportsLabeling)){this._labeler!=null&&(this._labeler.destroy(),this._labeler=null);return}if(this._labeler!=null)return;let e=new Oe({view:this.view,layer:this.layer,collection:this._collection,overrides:this.i3sOverrides,layerViewUid:this.uid});this._nodeId2Meta.forEach(t=>t!=null&&this._addMetaToLabeler(e,t)),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then(e=>(--this._asyncModuleLoading,e),e=>{throw--this._asyncModuleLoading,e})}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications){this._i3sWasmLoaded=Ae().then(()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()},()=>{}),this.notifyUpdate();return}if(this._i3sWasmLoaded!==!0)return;let e=e=>a.getLogger(this).error(`set-modifications-error`,`Error when setting modifications:`,e),t=this.uid,n=this.layer.spatialReference,r=n.isGeographic,i=Fe(this._layerClippingArea,this._modifications,n,this.view.state.isGlobal);this._workerHandle.setModifications(t,i,r).catch(e);try{je({context:t,modifications:i,isGeodetic:r})}catch(t){e(t)}this._controller.modificationsChanged();let o=this.hasModifications?new c:null;this._nodeId2Meta.forEach((e,t)=>{e==null?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._updateFeatureIdCounts(e,-1),this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):o?.push(e.node)}),this.notifyChange(`elevationRange`),o!=null&&this._nodeId2MetaReloading.forEach(e=>o.push(e.node)),o!=null&&o.length>0&&(this.updateNodeModificationStatus(o),o.forAll(e=>{if(e.imModificationImpact!==2){let t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),t==null?this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1)):(this._updateFeatureIdCounts(t,-1),this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t),this.notifyChange(`elevationRange`))}})),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(this._modificationGraphics!=null&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!K.I3S_SHOW_MODIFICATIONS||this._modifications.length===0)return;let e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={outline:{color:[255,255,255],width:1}};this._modificationGraphics=[];for(let r of this._modifications){let i=r.geometry;i.spatialReference=this.layer.spatialReference;let a=new Ee({...t,color:e[r.type]});this._modificationGraphics.push(new n({geometry:i,symbol:a}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,(e,t)=>this._createAttributes(e,t))}_contentVisibleChanged(e){e?(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler)):(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){let t=this._nodeId2Meta.get(e);if(t?.attributeInfo!=null)return t.attributeInfo.loadedAttributes}getAttributeData(e){let t=this._nodeId2Meta.get(e);if(t?.attributeInfo!=null)return t.attributeInfo.attributeData}setAttributeData(e,t){let n=this._nodeId2Meta.get(e);n?.attributeInfo!=null&&(n.attributeInfo.attributeData=t,this._attributeValuesChanged(n))}async updateAttributes(e,t,n){let r=this._nodeId2Meta.get(e);r!=null&&(await this.i3sOverrides.applyAttributeOverrides(r.featureIds,t,n,this._controller.requiredAttributes),r.attributeInfo=t,this._controller.reschedule(()=>{this._nodeId2Meta.get(e)===r&&this._attributeValuesChanged(r)},n).catch(e=>{u(e)||a.getLogger(this).warn(`Error while updating attribute values. Layer might not display correctly.`,e)}))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.appliedFilters=null,this._labeler!=null&&this._labeler.setNodeMetaAttributes(e,(e,t)=>this._createAttributes(e,t)),this._updateEngineObject(e)}clearMemCache(){this._memCache!=null&&this._memCache.clear(),this._addTasks.forEach(e=>e.allowMemCache=!1)}getVisibleNodes(){let e=[];return this._nodeId2Meta.forEach(t=>t!=null&&e.push(t.node)),e}getVisibleObbs(){let e=[];return this._nodeId2Meta.forEach(t=>t&&e.push(this._collection.getComponentObb(t.objectHandle))),e}getLoadedNodeIndices(e){this._nodeId2Meta.forEach((t,n)=>e.push(n)),this._nodeId2MetaReloading.forEach((t,n)=>e.push(n))}_getVertexBufferLayout(e,t){return _t(yt(this._getGeometryParameters({hasTexture:It(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion})))}_getObjectIdField(){return this.layer.objectIdField||L}_getGlobalIdField(){return this.layer.globalIdField}_findGraphicNodeAndIndex(e){let t=G(this.layer.fieldsIndex,e.attributes,this._getObjectIdField());for(let e of this._nodeId2Meta.values()){let n=e?.featureIds.indexOf(t);if(n!=null&&n>=0)return{node:e.node,index:n}}return null}_getGraphicIndices(e,t){let n=this._nodeId2Meta.get(e.index);if(n==null)return[];let r=[],i=this._getObjectIdField(),a=this.layer.fieldsIndex;for(let e of t){let t=G(a,e.attributes,i),o=n.featureIds.indexOf(t);o!==-1&&r.push(o)}return r}whenGraphicBounds(e){let t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();let n=this.getAABB(t.node.index,t.index);return n==null?Promise.reject():Promise.resolve({boundingBox:n,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return e.nodeIndex==null||e.componentIndex==null?null:this.getAABB(e.nodeIndex,e.componentIndex)}getAABB(e,t){let n=this._nodeId2Meta.get(e);if(n?.featureIds==null||t>=n.featureIds.length)return null;let r=n.objectHandle,i=He(t,this._collection,r,P(24),0),a=this.view.renderSpatialReference,o=this.view.spatialReference;return me(i,a,0,i,o,0)?he(i):null}whenGraphicAttributes(e,t){return tt(this.layer,e,this._getObjectIdField(),t,()=>this._nodeId2Meta.values().filter(i).toArray())}getGraphicFromIntersectorTarget(e,t){if(e.nodeIndex==null||e.componentIndex==null)return null;let n=this._nodeId2Meta.get(e.nodeIndex);if(n?.featureIds==null||e.componentIndex>=n.featureIds.length)return null;let r=this._createLayerGraphic(this._createAttributes(e.componentIndex,n));return r?this._meshUtilsImporterModule?(r.geometry=this._meshUtilsImporterModule.createMesh({layerView:this,nodeIndex:e.nodeIndex,featureIndex:e.componentIndex}),r):t.defer?(t.defer(async()=>(r.geometry=(await this._meshUtilsImporter).createMesh({layerView:this,nodeIndex:e.nodeIndex,featureIndex:e.componentIndex}),r)),null):r:null}_getCacheKey(e){return`${this._layerUrl}/v30/${e}${this._cacheKeySuffix}`}get _meshUtilsImporter(){return this._meshUtilsImporterPromise||(this._meshUtilsImporterPromise=import(`./i3s/meshUtils.js`),this._meshUtilsImporterPromise.then(e=>this._meshUtilsImporterModule=e,()=>{})),this._meshUtilsImporterPromise}_getCacheKeySuffix(){let e=this.view.renderSpatialReference;return e==null?Kt:e===O(e)?qt:this.layer.spatialReference.equals(e)?Gt:e.wkid==null?null:`@${e.wkid}`}_getMemCacheKey(e,t=this.elevationOffset){return e+`#`+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&this.elevationOffset===0&&this._cacheKeySuffix!=null}loadCachedGPUData(e){return this._memCache==null?null:this._memCache.pop(this._getMemCacheKey(e))}deleteCachedGPUData(e){e!=null&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(this._memCache==null){this._deleteComponentObject(e);return}let n=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,n)}loadMissingTextures(e,t,n,r){let i=e?.filter((e,n)=>{if((e.usage&this.rendererTextureUsage)===0)return!1;if(t==null)return!0;let r=Ke(e.encodings,this.supportedTextureEncodings),i=t[n];return!!(i?.data==null||r&&i.encoding!==r.encoding)})??[];return i.length===0?Promise.resolve(!1):n(i,r).then(n=>{let r=0;for(let i=0;i<e.length;i++)r<n.length&&n[r].id===e[i].id&&(t[i]=n[r],r++);return!0})}loadCachedNodeData(e,t,n){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then(r=>r==null?null:(r.globalTrafo=_e(r.globalTrafo),r.nodeVersion===e.version?(this.elevationInfo.mode===0&&(e.geometryObbInRenderSR=J.fromData(r.geometryObbData)),this.loadMissingTextures(r.requiredTextures,r.textureData,n,t).then(n=>(n&&this._idbCache.initialized&&r.textureData!=null&&(r.byteSize=zt(r.transformedGeometry,r.textureData),r.textureData.every(Rt)&&this._indexedDbSizeCheck(e,r)&&this._idbCache.put(this._getCacheKey(e.id),r).catch(t=>a.getLogger(this).warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`))),d(t),r))):(this._idbCache.remove(this._getCacheKey(e.id)),null))):Promise.resolve(null)}addNode(e,t,n){return Lt(t)?t.geometryBuffer==null?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,()=>this._transformNode(e,t,n).then(r=>this._safeReschedule(()=>{if(r==null)return e.hasModifications=!1,this._addCachedNodeData(e,null,n);let{obb:i,componentOffsets:o,featureIds:s,anchorIds:c,anchors:l,transformedGeometry:u,geometryMinElevation:d,geometryMaxElevation:f}=r;e.hasModifications=u.hasModifications;let p=_e(r.globalTrafo),m=x(Ht,i.center.x,i.center.y,i.center.z);S(m,m,p);let h=new J(m,[i.extents.x,i.extents.y,i.extents.z],se(i.orientation.x,i.orientation.y,i.orientation.z,i.orientation.w));this.elevationInfo.mode===0&&(e.geometryObbInRenderSR=h),t.geometryData.componentOffsets=o,s&&(t.geometryData.featureIds=Array.from(s)),t.geometryData.anchorIds=c,t.geometryData.anchors=l;let g={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:u,globalTrafo:p,geometryObbData:h.data,geometryMinElevation:d,geometryMaxElevation:f,byteSize:zt(u,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&this._indexedDbSizeCheck(e,g)){let t=g.textureData==null?null:g.textureData.map(e=>Rt(e)?e:null);this._idbCache.put(this._getCacheKey(e.id),{...g,textureData:t}).catch(t=>a.getLogger(this).warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`))}return this._addCachedNodeData(e,g,n)},n))):Promise.reject()}getElevationRange(e){let t=new q,n=this._controller,{index:r}=n;if(!r)return t;let{rootNode:i}=r;if(!i)return t;let a=this._nodeId2Meta,o=n.viewportQueries;return r.traverse(i,n=>{let{childrenLoaded:r}=n;if(r===0)return!1;let i=o.getAndUpdateVisibilityObbInRenderSR(n),s=null;if(i){if(!i.intersectSphereWithMBS(e,i.radius))return!1}else if(s=o.calculateServiceMbsInRenderSRElevationAdjusted(n),s?.isValid&&!e.intersects(s))return!1;let c=a.get(n.index);if(c){let{geometryObbInRenderSR:r}=n;if(!r||r.intersectSphereWithMBS(e)){let e=c.geometryElevationRange;e.elevationRangeValid&&!e.isEmpty&&t.expandElevationRange(e)}}return r-+!!c>0}),t}computeVisibilityObb(e){return nt(e,this.view.renderSpatialReference,this._controller.crsIndex,this.layer.spatialReference,this.elevationOffset,this._modifications,this.view.renderCoordsHelper.sphericalPCPF)}_transformNode(e,t,n){let r=t.geometryData.geometries??[],i=Array(r.length);for(let e=0;e<r.length;++e)i[e]=this._getVertexBufferLayout(r[e],t.geometryDescriptor);let a=this.layer.normalReferenceFrame,o=t.normalReferenceFrame??a??`none`,s=e.serviceMbsInIndexSR,c=this.elevationOffset,l=this._controller.crsIndex,u=this._controller.crsVertex,d=this.view.renderSpatialReference,f=Ze(s,c,o,l,d),p=k(l,u),m=k(u,d);if(p==null||m==null)return Promise.resolve(null);let h={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:i,globalTrafo:f,geometryElevationOffset:c,mbs:s.toJSON(),obbData:e.serviceObbInIndexSR?.data,elevationOffset:c,planetRadiusInGlobalMode:this._planetRadiusInGlobalMode,needNormals:this._controller.isMeshPyramid||this._imVertexNormals,computeNormals:this._isIntegratedMesh&&this._imVertexNormals,normalReferenceFrame:o,indexToVertexProjector:p,vertexToRenderProjector:m};return this._workerHandle.invoke(h,n)}get _supportsNodeCrossFading(){return!this.view?.stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){let t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,n){if(this.elevationInfo.mode===0&&(e.geometryObbInRenderSR=this._collection.getComponentObb(t.objectHandle).clone()),!this._controller.isGeometryVisible(e)){this._cacheGPUData(t);return}let r=e.index;this._addNodeMeta(r,t),this.updateNodeState(r,n),this._collection.setObjectVisibility(t.objectHandle,!0),this._updateElevationOffsets(t),this._labeler!=null&&this._addMetaToLabeler(this._labeler,t),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==0&&this._ensureElevationTask().schedule(r),this._updateEngineObject(t),this._highlights?.objectCreated(t),this._treeDebugger!=null&&this._treeDebugger.update()}addCachedNodeData(e,t,n,r){return this._addData(e,n,()=>this._addCachedNodeData(e,t,r))}async deleteCachedNodeData(e){if(this._idbCacheEnabled)return this._idbCache.remove(this._getCacheKey(e))}async _addCachedNodeData(e,t,n){if(!this.contentVisible||!this._controller.isGeometryVisible(e)){this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);return}if(t==null){this._addNodeMeta(e.index,null);return}let r=this._addTasks.get(e.index),{geometryData:i,transformedGeometry:o}=t;await this.i3sOverrides.applyAttributeOverrides(i.featureIds,r.attributeInfo,n,this._controller.requiredAttributes);let s=t.textureData==null?[]:t.textureData.filter(e=>e!=null&&(e.usage&this.rendererTextureUsage)!==0);e.memory=0;let{componentOffsets:c,geometries:l,featureIds:u,anchorIds:d,anchors:f}=i,p=this._collection,m=l[0],{layout:h,indices:g,interleavedVertexData:_,positionData:v,hasColors:se}=o,{material:x,geometryParameters:S}=this._materialParameters(m,h),C=_.byteLength/h[0].stride,ue=c||new Uint32Array([0,g?g.length:C]),w=m.transformation?ae(m.transformation):oe(),E=_e(t.globalTrafo);re(w,E,w);let D=ie(T(),w),O=y(te(),w),pe=this._isIntegratedMesh?this._imShading?2:0:1,me=S.textureCoordinateType,k=!b(O,ne),j=new bt(h,pe,me,+!!k),he=new xt({interleavedVertexData:_,vertexCount:C,indexData:g},{positions:ve(v.data),indices:ye(v.indices)},ue,j),ge=this.view.renderSpatialReference,M=this.view.groundView.spatialReference,N=J.fromData(ht(t.geometryObbData)).getCenter(Xt),P=[1,1,1];fe(N,ge,P,M)||a.getLogger(this).errorOnce(`Unsupported coordinate system for IM overlay`);let F=T();A(N,ge,F,M);let I=te();ee(I,O);let L=T();ce(L,le(L,N,D),I);let be=F[0]-L[0]*P[0],xe=F[1]-L[1]*P[1],Se=S.textureCoordinateType===2,{textures:R,texturePromise:Ce,materialParameters:we}=this._initMaterialAndTextures(x,s,Se,e),z=p.createObject(new vt(de(be,xe,P[0],P[1]),new Ct(D,O),J.fromData(ht(t.geometryObbData)),he,has(`enable-feature:im-as-ground`)?!this.layer.isUsedAsGroundLayer:!this._isIntegratedMesh),we);e.memory+=this._memEstimateGeometryAdded(z),e.memory+=R.reduce((e,t)=>e+(t==null?0:this._memEstimateTextureAdded(t)),0);let B=!!x.hasParametersFromSource,Te=x.alphaMode!==`blend`&&x.metallicRoughness.baseColorFactor[3]>=1,V=new Ot(e,u,z,this._getInvalidRendererVersion(),r.attributeInfo,{hasParametersFromSource:B,isOpaque:Te},R,d,f,t.geometryMinElevation,t.geometryMaxElevation);r.meta=V,this._hasTextures||=t.requiredTextures?.some(({usage:e})=>!!(e&19))||!!e.resources.texture,this._hasData=!0,this._hasColors||=se,this.notifyChange(`hasTexturesOrVertexColors`);let Ee=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(V),Ce]).then(([t,r])=>(this._addTasks.has(e.index)&&t?.updateObjectVisibility(V.objectHandle,!1).catch(e=>this._logEdgeViewError(e,this.layer.title)),this._safeReschedule(()=>{let n=this._addTasks.get(e.index);if(!n)return;if(this._addNodeMeta(e.index,V),n.meta=null,!this.contentVisible){this._removeNodeStageData(e.index,this.elevationOffset);return}p.setObjectVisibility(z,!0),t?.updateObjectVisibility(V.objectHandle,!0).catch(e=>this._logEdgeViewError(e,this.layer.title)),V.attributeInfo=n.attributeInfo;let r=V.cachedRendererVersion!==this._rendererVersion,i=Ee!==this.slicePlaneEnabled;this._updateElevationOffsets(V);let a=V.elevationOffsets;this._updateComponentData(V);let o=this._applyFiltersToNode(V);(r||t!=null&&(i||o||a))&&this._addOrUpdateEdgeRendering(V).catch(()=>{}),this._labeler!=null&&this._addMetaToLabeler(this._labeler,V),this._visibleGeometryChanged(V,0),this._highlights?.objectCreated(V),this._updateMaterial(V),this._setNewNodeOpacity(V),this._treeDebugger!=null&&this._treeDebugger.update()},n))).catch(e=>{let{meta:t,allowMemCache:n}=r;throw r.meta=null,t&&n?this._cacheGPUData(t):t&&this._deleteComponentObject(t),e})}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){a.getLogger(this).error(`Removing duplicated node`);let t=this._nodeId2Meta.get(e);t&&(this._deleteComponentObject(t),this._updateFeatureIdCounts(t,-1))}else this._controller.updateLoadStatus(e,!0);t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&X(t.cachedEdgeMaterials,0),this._updateFeatureIdCounts(t,1)),this._nodeId2Meta.set(e,t),this.notifyChange(`elevationRange`)}_updateElevationOffsets(e){if(!e.node.serviceMbsInIndexSR)return;let{view:t,elevationInfo:n}=this,r=this._controller.crsIndex,{groundView:i,groundSpatialReference:a,renderSpatialReference:o}=t,s=n.mode;if(s===0){e.elevationAlignmentOffset=n.offset,e.elevationOffsets=null,e.updateGeometryElevationRange(),this.notifyChange(`elevationRange`);return}if(e.elevationAlignmentOffset=0,o==null||a==null){e.elevationOffsets=null,e.updateGeometryElevationRange(),this.notifyChange(`elevationRange`);return}let c=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];let l=Ht,u=Ut,d=s===2,f=this.view.renderCoordsHelper,p=e.featureIds.length,m=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;let t=P(p*3);e.cachedElevationAnchors=t;let{center:n}=e.node.serviceMbsInIndexSR;for(let i=0;i<p;i++){let s=i*3,d=e.anchorIds?.indexOf(i)??-1;e.anchors&&d>=0?(x(l,e.anchors[d*3],e.anchors[d*3+1],e.anchors[d*3+2]),C(l,l,n),A(l,r,l,a),t[s]=l[0],t[s+1]=l[1],t[s+2]=f.getAltitude(l)):(this._collection.getComponentAabb(e.objectHandle,i,u,!0),x(l,(u[0]+u[3])/2,(u[1]+u[4])/2,u[2]),ce(l,l,c.rotationScale),C(l,l,c.position),t[s+2]=f.getAltitude(l),A(l,o,l,a),t[s]=l[0],t[s+1]=l[1])}return t})(),h=n.offset,g=e.elevationOffsets;i.getElevations(m,p,(e,t)=>{let n=d?m[e*3+2]:0;g[e]=h+(t??0)-n}),e.updateGeometryElevationRange(),this.notifyChange(`elevationRange`)}_ensureElevationTask(){return this._elevationTask??=new ze(this.view.resourceController.scheduler,e=>this._controller.updateElevationChanged(e,this.view.groundView.spatialReference)?.filterInPlace(e=>this._nodeId2Meta.get(e)!=null),e=>this._nodeElevationAlignmentChanged(this._nodeId2Meta.get(e)),()=>this.elevationInfo?.mode),this._elevationTask}_elevationInfoChanged(e,t){let n=e.mode!==0,r=!!t&&t!==e&&t.mode!==0;this._intersectionHandler.updateElevationAlignState(n,this.view.state.viewingMode),n&&!r&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach(e=>this._nodeElevationAlignmentChanged(e))}_nodeElevationAlignmentChanged(e){e!=null&&(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),this._labeler!=null&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,2),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}_safeReschedule(e,t){return d(t),this._controller.reschedule(e,t)}_materialParameters(e,t){let n=e.params.material==null?qe():e.params.material,r=t.some(({name:e})=>e===`uvRegion`),i=t.some(({name:e})=>e===`normalCompressed`),a=It(n);return{geometryParameters:this._getGeometryParameters({hasTexture:a,hasNormals:i,hasRegions:r}),material:n}}_initMaterialAndTextures(e,t,n,r){let i=this._stage.renderView,a=e=>{this._gpuMemoryEstimate-=e,this._texMemoryEstimate-=e,r.memory-=e},o=t.map(t=>Je(t,e,n,i,this._compressionTracker,a));this._stage.addTextures(o);let{materialParameters:s,texturePromise:c}=Ye(e,o,t,this.view.stage.renderView.textures,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,isGround:this.layer.isUsedAsGroundLayer,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference,applySSAO:this._applySSAO});return{textures:o,texturePromise:c,materialParameters:s}}_getGeometryParameters(e){return new St(this._hasVertexColors,e.hasNormals,e.hasTexture?e.hasRegions?2:1:0)}_addData(e,t,n){let r=this._addTasks.get(e.index);if(r)r.attributeInfo=t;else{let i=Promise.withResolvers();r=new Vt(t,null,i.promise),this._addTasks.set(e.index,r),n().then(i.resolve,i.reject).then(()=>this._addTasks.delete(e.index)).catch(t=>{throw this._addTasks.delete(e.index),t})}return r.promise}_clearAddTasks(){this._addTasks.forEach(e=>{e.meta!=null&&(this._cacheGPUData(e.meta),e.meta=null)}),this._addTasks.clear()}_clippingAreaChanged(){let e=this.view.renderSpatialReference,t=this.layer.spatialReference,n=M();this._renderClippingArea=mt(this.view.clippingArea,n,e)?n:null;let r=M();this._layerClippingArea=mt(this.view.clippingArea,r,t)?r:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){let e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e),this._assertFeatureIdNodeCounts(e)}_assertFeatureIdNodeCounts(e){e&&!this._featureIdCounts?(this._featureIdCounts=$(this._nodeId2Meta.values()),this._filteredIdCounts=$(this._nodeId2Meta.values(),1),this._weaklyRemovedIdCounts=$(this._nodeId2Meta.values(),2),this.addHandles(p(()=>this._controller.updating,e=>{!e&&this._needFilterResolve&&(this.multiGeometryFilterResolve(),this._needFilterResolve=!1,this.notifyUpdate())},{sync:!0}),`updateFinished`)):!e&&this._featureIdCounts&&(this._featureIdCounts=null,this._filteredIdCounts=null,this._weaklyRemovedIdCounts=null,this._mismatchShow=null,this._mismatchHide=null,this.removeHandles(`updateFinished`),this._needFilterResolve=!1,this.notifyUpdate())}_updateFeatureIdCounts(e,t){this._featureIdCounts&&(this._needFilterResolve=!0,Q(this._featureIdCounts,e.featureIds,t),Q(this._filteredIdCounts,e.filteredIds,t),Q(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,t))}_updateFilteredIdCounts(e,t,n){this._filteredIdCounts&&(this._needFilterResolve=!0,Q(this._filteredIdCounts,t,-1),Q(this._filteredIdCounts,e.filteredIds,1),Q(this._weaklyRemovedIdCounts,n,-1),Q(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,1))}_checkFeatureIdNodeCountInvariant(){let e=this._featureIdCounts!=null;if(this.hasGeometryFilter!==e&&a.getLogger(this).error(`checkFeatureIdNodeCountInvariant()`,`LayerView should have feature id node counts if and only if it has a geometry filter`,{layerView:this,hasNodeCounts:e}),!this._featureIdCounts||!this._filteredIdCounts)return;let t=$(this._nodeId2Meta.values());o(this._featureIdCounts,t)||a.getLogger(this).error(`checkFeatureIdNodeCountInvariant()`,`Incorrect _featureIdCounts`,{layerView:this,counts:this._featureIdCounts,expected:t});let n=$(this._nodeId2Meta.values(),1);o(this._filteredIdCounts,n)||a.getLogger(this).error(`checkFeatureIdNodeCountInvariant()`,`Incorrect _filteredIdCounts`,{layerView:this,counts:this._filteredIdCounts,expected:n});let r=$(this._nodeId2Meta.values(),2);o(this._weaklyRemovedIdCounts,r)||a.getLogger(this).error(`checkFeatureIdNodeCountInvariant()`,`Incorrect _weaklyRemovedIdCounts`,{layerView:this,counts:this._weaklyRemovedIdCounts,expected:n})}multiGeometryFilterResolve(){if(!this._featureIdCounts||!this._filteredIdCounts)return;let e=null,t=null;for(let[n,r]of this._filteredIdCounts){let i=this._featureIdCounts.get(n);i!==r&&(r+(this._weaklyRemovedIdCounts?.get(n)??0)===i?(e??=new Set,e.add(n)):(t??=new Set,t.add(n)))}h(e,this._mismatchShow)&&h(t,this._mismatchHide)||(this._mismatchShow=e,this._mismatchHide=t,this._nodeId2Meta.forEach(e=>{if(!e?.filteredIds)return;let t=Yt(e,this._mismatchShow,this._mismatchHide);this._collection.setAllComponentVisibilities(e.objectHandle,t),this._visibleGeometryChanged(e,2)}))}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach(e=>{e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e).catch(()=>{}),this._visibleGeometryChanged(e,2))})}getFilters(){let e=[],t=this._renderClippingArea;return t!=null&&e.push((e,n)=>this._boundingRectFilter(e,n,t)),e}addSqlFilter(e,t,n){if(t!=null){let r=t.fieldNames;e.push((e,i)=>this._sqlFilter(e,i,t,r,n))}}_sqlFilter(e,t,n,r,i){let a={},o=this._createLayerGraphic(a);if(!o)return;let s=this.layer.objectIdField,c=t.featureIds,l=t.attributeInfo?.attributeData;r.every(e=>e===s||l?.[e]!=null)&&rt(e,c,e=>{a[s]=c[e];for(let t of r)t!==s&&(a[t]=l?H(l[t],e):null);try{return n.testFeature(o)}catch(e){return i(e),!1}})}_boundingRectNodeTest(e,t){return pe(e.node.serviceMbsInIndexSR,this._controller.crsIndex,Ft,this.view.renderSpatialReference),it(t,Ft)}_boundingRectFeatureTest(e,t,n){return this._collection.getComponentAabb(e.objectHandle,t,At),ge(At,jt),N(n,jt)}_boundingRectFilter(e,t,n){let r=this._collection,i=this._boundingRectNodeTest(t,n);if(i===3)return;if(i===0){e.length=0;return}let a=r.getComponentCount(t.objectHandle);if(a.invisible+a.visible!==t.featureIds.length)return;let o=this._transformClippingArea(Mt,n,t.objectHandle);rt(e,t.featureIds,e=>this._boundingRectFeatureTest(t,e,o))}_transformClippingArea(e,t,n){let r=this._collection.getObjectTransform(n),i=r.position,a=r.rotationScale;return e[0]=(t[0]-i[0])/a[0],e[1]=(t[1]-i[1])/a[4],e[2]=(t[2]-i[0])/a[0],e[3]=(t[3]-i[1])/a[4],e}async _addOrUpdateEdgeRendering(e,t=!0){let n=e.objectHandle,{hasEdges:r,perFeatureEdgeMaterials:i}=this._getFilteredEdgeMaterials(e);if(r&&!this._edgeView)try{this._edgeView=await this._stage.renderer.loadEdgeView()}catch(e){if(!u(e))throw e}let a=this._edgeView;if(!a)return null;let o=a.hasObject(n);if(r){if(o)return this.nodeCrossfadingEnabled&&X(i,this.getNodeOpacity(e)),a.updateAllComponentMaterials(n,i,this.slicePlaneEnabled,t).catch(e=>this._logEdgeViewError(e,this.layer.title)),a.updateObjectVisibility(n,!0).catch(e=>this._logEdgeViewError(e,this.layer.title)),a.updateAllVerticalOffsets(n,e.elevationOffsets).catch(e=>this._logEdgeViewError(e,this.layer.title)),a;let r=await this._collection.addEdges(n,a,i,this.slicePlaneEnabled,e.elevationOffsets);return e.edgeMemoryUsage=r,e.node.memory+=r,a}return o&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,a.removeObject(n)),null}_applyFiltersToNode(e){let{filteredIds:t,weaklyRemovedIds:n}=e,r=this._applyFiltersToNodeComponents(e);return this._updateFilteredIdCounts(e,t,n),r&&this._labeler?.applyFilterChange(e),r}_applyFiltersToNodeComponents(e){let t=this._collection,n=t.getComponentCount(e.objectHandle),r=e.filteredIds!=null,i=n.invisible===0;if(t.setAllComponentVisibilities(e.objectHandle,`all`),this._filters.length===0)return e.filteredIds=null,!i;if((e.filteredIds==null||e.appliedFilters!==this._filters)&&(e.weaklyRemovedIds=null,e.filteredIds=Jt(e,this._filters),e.appliedFilters=this._filters),r&&e.filteredIds===e.featureIds&&(!this._mismatchHide||e.filteredIds.every(e=>!this._mismatchHide?.has(e))))return!i;let a=Yt(e,this._mismatchShow,this._mismatchHide);return t.setAllComponentVisibilities(e.objectHandle,a),!0}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach((t,n)=>this._removeNodeStageData(n,e)),this._nodeId2MetaReloading.forEach((t,n)=>this._removeNodeStageData(n,e,this._nodeId2MetaReloading)),this._elevationTask=s(this._elevationTask)}removeNode(e){let t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),this._elevationTask!=null&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,n=this._nodeId2Meta){n.has(e)&&this._controller.updateLoadStatus(e,!1);let r=n.get(e);r==null?n.delete(e):(this._collection.setObjectVisibility(r.objectHandle,!1),this._edgeView!=null&&this._edgeView.hasObject(r.objectHandle)&&this._edgeView.updateObjectVisibility(r.objectHandle,!1).catch(e=>this._logEdgeViewError(e,this.layer.title)),this._visibleGeometryChanged(r,1),this._labeler!=null&&this._labeler.removeNodeMeta(r),n.delete(e),this._highlights?.objectDeleted(r),n===this._nodeId2Meta?(this._updateFeatureIdCounts(r,-1),this._cacheGPUData(r,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(r)):this._deleteComponentObject(r),this._treeDebugger!=null&&this._treeDebugger.update())}_deleteComponentObject(e){if(this._edgeView!=null&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(let t of e.textures)this._memEstimateTextureRemoved(t),this._stage.removeTexture(t)}updateNodeState(e,t){this._nodeId2Meta.get(e)?.objectHandle.updateMaterial({polygonOffset:+(t===0)})}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){let n=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,n),this.notifyChange(`elevationRange`)}let n=this._nodeId2MetaReloading.get(e);n&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,n))}_invalidateAllSymbols(){this._rendererVersion=U(this._rendererVersion,1),this._controller?.requestUpdate()}_getInvalidRendererVersion(){return U(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange(`rendererTextureUsage`),this._rendererVersion=U(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.layer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&`arcadeRequired`in e&&e.arcadeRequired&&(this._arcade=await Te()),e&&`visualVariables`in e&&e.visualVariables)for(let t of e.visualVariables)t.type===`color`?this._colorVariable=t:t.type===`opacity`?this._opacityVariable=t:a.getLogger(this).warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(let t of e.symbols)t.type!==`mesh-3d`&&a.getLogger(this).error(`Symbols of type '${t.type}' are not supported for 3D Object Scene Services.`);this._controller&&this._controller.requestUpdate()}_getCachedEdgeMaterials(e){return this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e),e.cachedEdgeMaterials}_getComponentParameters(e){this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e);let t=e.cachedSymbology;return(n,r)=>{let i=n*e.cachedSymbologyStride;E(r.externalColor,t[i]/255,t[i+1]/255,t[i+2]/255,t[i+3]/255);let a=this._stage.renderView.olidRenderHelper;if(a){let t=e.featureIds[n],i=this.sublayerId?`${this.layerViewUid}_${this.sublayerId}`:this.layerViewUid,o=z(this.view,this.uid);a.setUidToObjectAndLayerId(t,t,this.layerId,i,this.layerPopupEnabledAndHasTemplate&&!o,e.node.resources.attributes,n,this.sublayerId),r.olidColor=a.getObjectAndLayerIdColor({graphicUid:t,layerViewUid:i})}r.externalColorMixMode=t[i+4]&15,r.castShadows=!!(t[i+4]&16),r.pickable=!!(t[i+4]&32),r.elevationOffset=e.elevationOffsets?.[n]??0,r.emissiveStrength=e.emissiveStrengths?.[n]??1,r.emissiveSource=e.emissiveSources?.[n]??0}}_getSymbolInfo(e,t){let n=e?.getSymbol(t,{arcade:this._arcade});if(!(n instanceof V))return null;let r=n.id;if(this._symbolInfos.has(r))return this._symbolInfos.get(r);let i=at(n);return this._symbolInfos.set(r,i),i}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=this._symbologyOverrideFields!=null&&this._symbologyOverrideFields.length>0?this._rendererFields!=null&&this._rendererFields.length>0?xe(this.layer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;let t=this._tmpAttributeOnlyGraphic,n={};t.attributes=n;let r=this._currentRenderer,i=e.attributeInfo?.attributeData,a=e.featureIds?this.layer.objectIdField:null,o=i!=null&&this._symbologyFields!=null&&this._symbologyFields.length>0,s=null,c=null;if(o&&this._symbologyFields!=null){s=[],c=[];for(let e of this._symbologyFields){let t=i[e];t&&(s.push(e),c.push(t))}}e.cachedSymbology||=I(e.featureIds.length*e.cachedSymbologyStride);let l=new ut,u=this.fullOpacity,d=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):u,f=null,p=1,m=W,h=0;for(let i=0;i<e.featureIds.length;i++){if(a!=null&&(n[a]=e.featureIds[i]),o&&s)for(let e=0;e<s.length;e++)n[s[e]]=H(c[e],i);let u=r?this._getSymbolInfo(r,t):null,g,_;if(l.pickable=!0,r&&`visualVariables`in r){if(this._colorVariable){let e=Ce(this._colorVariable,t,{color:Pt,arcade:this._arcade});e&&(g=l.color,g[0]=e.r/255,g[1]=e.g/255,g[2]=e.b/255,g[3]=e.a??1,!this._opacityVariable&&e.a!==null&&(_=e.a))}this._opacityVariable&&(_=we(this._opacityVariable,t,{arcade:this._arcade}))}if(u?.material){let e=u.material;g=g==null||_==null?Ie(g,_,e.color,e.alpha,Dt,l.color):Ie(g,_,null,null,Dt,l.color)}g??=E(l.color,1,1,1,1);let v=u?.material;if(l.colorMixMode=v?.colorMixMode??1,l.edgeMaterial=u?.edgeMaterial,this._symbologyOverride?.(t,l),this._nodeColorOverride!=null&&(this._nodeColorOverride(e.node,g),l.colorMixMode=3),l.pickable&&=g[3]>=Et,l.castShadows=u?u.castShadows:l.pickable,l.edgeMaterial!=null){let t=g[3]>=1&&(e.material.isOpaque||l.colorMixMode===3)?1:0;(l.edgeMaterial!==f||t!==p)&&(m={...l.edgeMaterial,opacity:d,objectTransparency:t},f=l.edgeMaterial,p=t),e.cachedEdgeMaterials[i]=m}else e.cachedEdgeMaterials[i]=W;e.cachedSymbology[h++]=Math.round(g[0]*255),e.cachedSymbology[h++]=Math.round(g[1]*255),e.cachedSymbology[h++]=Math.round(g[2]*255),e.cachedSymbology[h++]=Math.round(g[3]*255),e.cachedSymbology[h++]=l.colorMixMode|l.castShadows<<4|l.pickable<<5;let y=v?.emissive?.strength==null?Y:v?.emissive?.strength;y!==Y&&!e.emissiveStrengths&&(e.emissiveStrengths=Array(e.featureIds.length).fill(Y)),e.emissiveStrengths&&(e.emissiveStrengths[i]=y);let b=v?.emissive?.source||0;b!==0&&!e.emissiveSources&&(e.emissiveSources=Array(e.featureIds.length).fill(0)),e.emissiveSources&&(e.emissiveSources[i]=b)}}_getFilteredEdgeMaterials(e){let t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||X(t,this.fullOpacity);let n=e.filteredIds;if(n==null)return{hasEdges:t.some(e=>e!==W),perFeatureEdgeMaterials:t};let r=0,i=!1,a=t.map((t,a)=>e.featureIds[a]===n[r]?(i||=t!==W,r++,t):W);return{hasEdges:i,perFeatureEdgeMaterials:a}}_updateComponentData(e){if(!this._hasComponentData)return;let{objectHandle:t}=e,n=this._getComponentParameters(e);this._collection.setComponentData(t,n),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),this._controller!=null&&this._controller.restartNodeLoading()}_refreshGroundUsage(){this._intersectionHandler.isGround=has(`enable-feature:im-as-ground`)?this.layer.isUsedAsGroundLayer:this._isIntegratedMesh,this.contentVisible&&(this.view.elevationProvider.unregister(this._elevationProvider),this.view.elevationProvider.register(this._elevationContext,this._elevationProvider)),this._reloadAll(),this.clearMemCache()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach(t=>{t!=null&&(this._collection.updateObjectOpacity(t.objectHandle,e),X(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))})}_updateMaterial(e){e.objectHandle.updateMaterial({slicePlaneEnabled:this.slicePlaneEnabled,usePBR:this._usePBR})}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e).catch(()=>{}),this._visibleGeometryChanged(e,2)}intersect(e,t,n,r){this._intersectionHandler.intersectRay(e,t,n,r,null,!1)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this._labeler!=null&&(this._labeler.slicePlaneEnabled=e),this._foreachMeta(t=>{t.objectHandle.updateMaterial({slicePlaneEnabled:e}),this._updateEdgeRendering(t,!1)})}_updatePBR(e){this._foreachMeta(t=>t.objectHandle.updateMaterial({usePBR:e})),this._hasLoadedPBRTextures=!0}_foreachMeta(e){this._nodeId2Meta.forEach(t=>{t!=null&&e(t)})}get _usePBR(){return this._imShading&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){this._edgeView!=null&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t).catch(()=>{})}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?(t,n,r)=>r.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?0:e(t,n,r):e}_forAllFeatures(e,t,n){for(let r of this._nodeId2Meta.values())if(r!=null&&!(t&&r.node.serviceMbsInIndexSR&&t(r.node.serviceMbsInIndexSR)===1))switch(n){case 1:this._forAllFeaturesOfNode(r,e);break;case 0:this._forAllVisibleFeaturesOfNode(r,e);break;case 2:this._forAllQueryableFeaturesOfNode(r,e)}}_forAllFeaturesOfNode(e,t){e.featureIds.forEach((n,r)=>t(n,r,e))}_forAllVisibleFeaturesOfNode(e,t){let n=e.featureIds;this._collection.forEachVisibleComponent(e.objectHandle,r=>t(n[r],r,e)===0)}_forAllQueryableFeaturesOfNode(e,t){let n=this._ignoreClientNodeOverriddenFeatures(t);if(this._renderClippingArea==null)return this._forAllFeaturesOfNode(e,n);let r=this._boundingRectNodeTest(e,this._renderClippingArea);if(r===0)return;if(r===3)return this._forAllFeaturesOfNode(e,n);let i=e.featureIds,a=e.objectHandle,o=ot(this._renderClippingArea,this._collection.getObjectTransform(a));for(let t=0;t<i.length;t++)this._boundingRectFeatureTest(e,t,o)&&n(i[t],t,e)}_createAttributes(e,t){let n={};t.featureIds!=null&&(n[this._getObjectIdField()]=t.featureIds[e]);let r=t.attributeInfo?.attributeData;if(r!=null)for(let t of Object.keys(r))n[t]=H(r[t],e);return n}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e,t){let r=dt(e);if(r.length===0)return ft;let i=wt(t),a=r[0]instanceof n?this._featureIdsFromGraphics(r):typeof r[0]==`number`?r:null;if(!a)return ft;let o=this._ensureHighlights(),{set:s,handle:c}=o.acquireSet(i);return o.setFeatureIds(s,a),c}_featureIdsFromGraphics(e){let t=this.layer.fieldsIndex,n=this._getObjectIdField();return e.map(e=>G(t,e.attributes,n))}_ensureHighlights(){return this._highlights??=new Re({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,1),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)}),this._highlights}resetHighlights(){this._highlights=s(this._highlights)}_visibleGeometryChanged(e,t){this._elevationProvider&&(this._visibleGeometryChangedSchedulerHandle??=m(()=>{let{node:t}=e,n=t.visibilityObbInRenderSR??t.geometryObbInRenderSR??t.serviceObbInRenderSR;if(n!=null){let e=j();n.toAaBoundingBox(e),this.emit(`visible-geometry-changed`,new De(e))}else this.emit(`visible-geometry-changed`);this._visibleGeometryChangedSchedulerHandle=null}),this._updateSnappingSources(e,t),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}get performanceInfo(){return new ke(this.usedMemory,this._nodeId2Meta.size,Math.round(this._gpuMemoryEstimate/1048576),Math.round(this._geoMemoryEstimate/1048576),Math.round(this._texMemoryEstimate/1048576),Math.round(this.unloadedMemory/1048576),this._idbCacheEnabled?Math.round(this._idbCache.getHitRate()*100):0)}checkInvariants(){}get test(){}getNodeOpacityByIndex(e){let t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return e==null?0:this._collection.getObjectOpacity(e.objectHandle)}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}getNodeComponentHandle(e){return this._nodeId2Meta.get(e)?.objectHandle}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(e)}fadeNode(e,t,n){if(!this.nodeCrossfadingEnabled)return;let r=this._nodeId2Meta.get(e);r!=null&&this._crossfadeHelper.fadeNode(e,r,t,n)}setNodeOpacityByIndex(e,t){let n=this._nodeId2Meta.get(e);n!=null&&this._setNodeOpacity(n,t)}_setNodeOpacity(e,t){this._collection.updateObjectOpacity(e.objectHandle,t),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(this._edgeView==null||!e.cachedEdgeMaterials)return;X(e.cachedEdgeMaterials,t);let n=e.objectHandle;this._edgeView.hasObject(n)&&this._edgeView.updateAllComponentOpacities(n,t).catch(e=>this._logEdgeViewError(e,this.layer.title))}get hasModifications(){return this._isIntegratedMesh&&this._layerClippingArea!=null||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){let t=e.length;if(!this.hasModifications||t<=0||this._i3sWasmLoaded!==!0)return;let n=this.uid,r=Bt(e);if(r){let t={context:n,buffer:r.buffer};Me(t);let i=new Float64Array(r.buffer);e.forAll((e,t)=>{let n=i[t],r=Ne(n);e.imModificationImpact=r,r!==0&&this._controller.invalidateGeometryVisibility(e.index)})}}notifyUpdate(){this.notifyChange(`updating`)}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!!(this._controller&&this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||this._labeler!=null&&this._labeler.updating||this._crossfadeHelper?.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||this._elevationTask!=null&&this._elevationTask.readyToRun||this._needFilterResolve||this._compressionTracker.compressing}trackSnappingSources(e){let t={events:e,fetchEdgeLocations:async(e,t,n)=>{let r=this._nodeId2Meta.get(e);if(r==null)throw Error(`invalid-node`);let{origin:i,buffer:a}=await this._collection.extractEdgeInformation(r.objectHandle,t,n);return this._snappingLocationsApplyElevation(r,a,i),{type:`components`,objectIds:r.featureIds,locations:a,origin:i}},remove:()=>r(this._snappingSourcesTrackers,t)};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach((t,n)=>{if(t==null)return;let r=this._controller.getRenderMbs(t.node);r&&e.add(n,r)}),t}_snappingLocationsApplyElevation(e,t,n){if(!e.elevationOffsets||this.elevationInfo.mode===0)return;let r=t.position0,i=t.position1,a=t.componentIndex,o=T(),s=T(),c=(e,t)=>{C(e,e,n),this.view.renderCoordsHelper.worldUpAtPosition(e,s),C(e,e,ue(s,s,t)),w(e,e,n)};for(let t=0;t<r.count;t++){let n=e.elevationOffsets[a.get(t)];r.getVec(t,o),c(o,n),r.setVec(t,o),i.getVec(t,o),c(o,n),i.setVec(t,o)}}_updateSnappingSources(e,t){let{index:n}=e.node,r=this._controller.getRenderMbs(e.node);if(r!=null)for(let e of this._snappingSourcesTrackers)(t===1||t===2)&&e.events.remove(n),(t===0||t===2)&&e.events.add(n,r)}_logEdgeViewError(e,t){u(e)||a.getLogger(this).warn(`Error while processing edges. Edges on this layer might not display correctly`,t,e)}_indexedDbSizeCheck(e,t){return t.byteSize>104857600?(a.getLogger(this).warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}get elevationProvider(){return this._elevationProvider}};return e([_()],F.prototype,`extractChanges`,null),e([_()],F.prototype,`_hasLoadedPBRTextures`,void 0),e([_()],F.prototype,`_asyncModuleLoading`,void 0),e([_()],F.prototype,`_visibleGeometryChangedSchedulerHandle`,void 0),e([_()],F.prototype,`view`,void 0),e([_()],F.prototype,`layer`,void 0),e([_()],F.prototype,`_controller`,void 0),e([_()],F.prototype,`_labeler`,void 0),e([_()],F.prototype,`updating`,void 0),e([_()],F.prototype,`suspended`,void 0),e([_()],F.prototype,`contentVisible`,null),e([_({readOnly:!0})],F.prototype,`legendEnabled`,null),e([_(gt)],F.prototype,`updatingProgress`,void 0),e([_()],F.prototype,`updatingProgressValue`,null),e([_()],F.prototype,`hasTexturesOrVertexColors`,null),e([_()],F.prototype,`rendererTextureUsage`,null),e([_()],F.prototype,`elevationOffset`,null),e([_()],F.prototype,`elevationInfo`,null),e([_({type:Boolean})],F.prototype,`slicePlaneEnabled`,void 0),e([_()],F.prototype,`supportedTextureEncodings`,null),e([_({type:[R]})],F.prototype,`_modifications`,void 0),e([_({readOnly:!0})],F.prototype,`clientGeometry`,null),e([_()],F.prototype,`elevationRange`,null),e([_()],F.prototype,`fullExtent`,null),e([_()],F.prototype,`_elevationTask`,void 0),e([_({readOnly:!0})],F.prototype,`_usePBR`,null),F=e([v(`esri.views.3d.layers.I3SMeshView3D`)],F),F},At=j(),jt=M(),Mt=M(),Nt=new J,Pt=new t([0,0,0,0]),Ft=new F(0,0,0,0);function It(e){if(e==null)return!1;let t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function Lt(e){return`geometryData`in e}function Rt(e){return e!=null&&g(e.data)}function zt(e,t){let n=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(t!=null)for(let e of t)e!=null&&g(e.data)&&(n+=e.data.byteLength);return n}function Bt(e){if(e.length===0)return;let t=e.length*10,n=new Float64Array(t),r=0;return e.forAll(e=>{let t=e.serviceObbInIndexSR;t??(t=Nt,e.serviceMbsInIndexSR?(t.setCenter(e.serviceMbsInIndexSR.center),t.setHalfSizeFromValues(e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius)):t.invalidate());let i=t.data;n[r++]=i[0],n[r++]=i[1],n[r++]=i[2],n[r++]=i[3],n[r++]=i[4],n[r++]=i[5],n[r++]=i[6],n[r++]=i[7],n[r++]=i[8],n[r++]=i[9]}),n}class Vt{constructor(e,t,n){this.attributeInfo=e,this.meta=t,this.promise=n,this.allowMemCache=!0}}function X(e,t){e.forEach(e=>e.opacity=t)}class Z{constructor(e,t){this.mode=e,this.offset=t}}const Ht=T(),Ut=j(),Wt=`elevation-change`,Gt=``,Kt=`@null`,qt=`@ECEF`;function Jt(e,t){let n=e.featureIds.slice();for(let r of t)if(r(n,e),n.length===0)break;return n.length===e.featureIds.length?e.featureIds:n}function Yt(e,t,n){let r=[],i=e.filteredIds;if(i!=null&&!t?.size&&!n?.size)e.featureIds.forEach((e,t)=>{i[r.length]===e&&r.push(t)});else if(i!=null){let a=0;e.featureIds.forEach((e,o)=>{if(i[a]===e)++a;else if(!t?.has(e))return;n?.has(e)||r.push(o)})}return r}function Q(e,t,n){if(e&&t)for(let r of t){let t=(e.get(r)??0)+n;t>0?e.set(r,t):e.delete(r)}}function $(e,t=0){let n=new Map;for(let r of e)Q(n,t===0?r?.featureIds:t===1?r?.filteredIds:r?.weaklyRemovedIds,1);return n}const Xt=T();export{kt as I3SMeshView3D};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../Color.js";import n from"../../../Graphic.js";import{removeUnordered as r,isSome as i}from"../../../core/arrayUtils.js";import has from"../../../core/has.js";import a from"../../../core/Logger.js";import{equals as o}from"../../../core/MapUtils.js";import{destroyMaybe as s}from"../../../core/maybe.js";import c from"../../../core/PooledArray.js";import{ignoreAbortErrors as l,isAbortError as u,throwIfAborted as d}from"../../../core/promiseUtils.js";import{initial as f,watch as p}from"../../../core/reactiveUtils.js";import{schedule as m}from"../../../core/scheduling.js";import{equals as h}from"../../../core/SetUtils.js";import{isArrayBuffer as g}from"../../../core/typedArrayUtil.js";import{property as _,subclass as v}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as y,exactEquals as ee,invert as te}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as ne,IDENTITY as re}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as ie,getTranslation as ae}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as oe,create as se}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as ce}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{set as b,transformMat4 as x,transformMat3 as le,sub as ue,add as S,scale as de,subtract as C}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as T}from"../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as fe}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as E}from"../../../core/support/UpdatingHandles.js";import{getSphericalPCPF as D}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{localLinearScaleFactors as pe}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as me}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as he}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as O}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as k}from"../../../geometry/projection/projectVectorToVector.js";import{create as A,fromBuffer as ge,toRect as j}from"../../../geometry/support/aaBoundingBox.js";import{create as M,intersects as N}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as P,ensurePackedMat4f64 as _e}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as ve}from"../../../geometry/support/FloatArray.js";import{compactIndices as ye}from"../../../geometry/support/Indices.js";import{Sphere as F}from"../../../geometry/support/sphere.js";import{newUByteArray as I}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as L}from"../../../layers/LayerConstants.js";import be from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as xe}from"../../../layers/support/fieldUtils.js";import{I3SExtractChanges as Se}from"../../../layers/support/I3SExtractChanges.js";import R from"../../../layers/support/SceneModification.js";import{getColor as Ce,getOpacity as we}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{isBasemapLayerView as z}from"../../../support/basemapUtils.js";import{getElevationOffset as B}from"../../../support/elevationInfoUtils.js";import{loadArcade as Te}from"../../../support/loadArcade.js";import V from"../../../symbols/MeshSymbol3D.js";import Ee from"../../../symbols/SimpleFillSymbol.js";import{ContentGeometryUpdateEvent as De}from"./ContentGeometryLayerView.js";import Oe from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as ke}from"./I3SMeshViewPerformanceInfo.js";import{initialize as Ae,setModificationsSync as je,filterObbsForModificationsSync as Me,interpretObbModificationResults as Ne}from"./SceneLayerWorker.js";import{SceneLayerWorkerHandle as Pe,toWasmModification as Fe}from"./SceneLayerWorkerHandle.js";import{overrideColor as Ie}from"./graphics/graphicUtils.js";import{areLabelsVisible as Le}from"./graphics/Labeler.js";import Re from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as ze}from"./i3s/I3SAsyncElevationUpdater.js";import{getCachedAttributeValue as H}from"./i3s/I3SBinaryReader.js";import{I3SCrossfadeHelper as Be,NodeCrossfadeMetaData as Ve}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as He}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Ue,TraversedIntersectionNode as We}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Ge,selectEncoding as Ke,defaultMaterial as qe,createTexture as Je,configureMaterial as Ye}from"./i3s/I3SMaterialUtil.js";import{I3SOverrides as Xe}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as Ze}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as Qe,checkSceneLayerValid as $e,checkSceneLayerCompatibleWithView as et,whenGraphicAttributes as tt,computeVisibilityObb as nt,filterInPlace as rt,intersectBoundingRectWithMbs as it,addWraparound as U,getSymbolInfo as at,transparentEdgeMaterial as W,getClipRect as ot}from"./i3s/I3SUtil.js";import{IDBCache as st}from"./i3s/IDBCache.js";import{IDBMockCache as ct}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as lt}from"./i3s/LayerElevationProvider.js";import{SymbologyInfo as ut}from"./i3s/SymbologyInfo.js";import{attributeLookup as G}from"./support/attributeUtils.js";import{normalizeHighlightTarget as dt,emptyHighlightHandle as ft}from"./support/highlightUtils.js";import{makeScheduleFunction as pt}from"./support/makeScheduleFunction.js";import{debugFlags as K}from"../support/debugFlags.js";import{ElevationRange as q}from"../support/ElevationRange.js";import{toBoundingRect as mt}from"../support/extentUtils.js";import{Obb as J,ensurePackedObbData as ht}from"../support/orientedBoundingBox.js";import{updatingProgress as gt}from"../support/updatingProperties.js";import{glLayout as _t}from"../support/buffer/glUtil.js";import{ObjectParameters as vt}from"../webgl-engine/collections/Component/ObjectParameters.js";import{createVertexBufferLayout as yt,ComponentGeometryParameters as bt,SourceGeometry as xt,VertexBufferLayoutCreationParameters as St}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as Ct}from"../webgl-engine/collections/Component/Transform.js";import{emissiveStrengthDefault as Y}from"../webgl-engine/core/shaderLibrary/output/getEmissions.glsl.js";import{getHighlightName as wt}from"../../support/highlightOptionsUtils.js";import{TextureCompressionTracker as Tt}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as Et}from"../../../webscene/support/AlphaCutoff.js";const Dt=[1,1,1,1];class Ot extends Ve{constructor(e,t,n,r,i,a,o,s,c,l,u){super(),this.node=e,this.featureIds=t,this.objectHandle=n,this.cachedRendererVersion=r,this.attributeInfo=i,this.material=a,this.textures=o,this.anchorIds=s,this.anchors=c,this._elevationAlignmentRange=new q,this._geometryElevationRange=new q,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=[],this.edgeMemoryUsage=0,this.cachedSymbologyStride=5,this.elevationAlignmentOffset=0,this._baseGeometryElevationRange=new q(l,u),this.updateGeometryElevationRange()}get geometryElevationRange(){return this._geometryElevationRange}updateGeometryElevationRange(){let e=this._baseGeometryElevationRange;if(!e.elevationRangeValid||e.isEmpty){this._elevationAlignmentRange.invalidateElevationRange(),this._geometryElevationRange.invalidateElevationRange();return}let t=this.elevationOffsets;if(!t||t.length===0){let t=this.elevationAlignmentOffset;this._elevationAlignmentRange.setElevationRangeValues(t,t),this._geometryElevationRange.setElevationRangeValues(e.minElevation+t,e.maxElevation+t);return}let n=1/0,r=-1/0;for(let e=0;e<t.length;++e){let i=this.elevationAlignmentOffset+(t[e]??0);n=Math.min(n,i),r=Math.max(r,i)}this._elevationAlignmentRange.setElevationRangeValues(n,r),this._geometryElevationRange.setElevationRangeValues(e.minElevation+n,e.maxElevation+r)}get usedMemory(){return this.node.memory}get featureExtents(){return this._featureExtents??=new Float64Array(6*this.featureIds.length).fill(1/0),this._featureExtents}}const kt=t=>{let g=t,F=class extends g{constructor(){super(...arguments),this._extractChanges=null,this._applySSAO=!0,this._imShading=!!has(`enable-feature:im-shading`),this._imVertexNormals=!!has(`enable-feature:im-vertex-normals`),this._updatingHandles=new E,this._highlights=null,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._compressionTracker=new Tt,this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._hasComponentData=!1,this._hasVertexColors=!1,this._nodeColorOverride=null,this.updating=!0,this.holeFilling=`auto`,this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=[],this.ignoresMemoryFactor=!1,this._layerUrl=``,this._cacheKeySuffix=null,this._meshUtilsImporterModule=null,this._meshUtilsImporterPromise=null,this._planetRadiusInGlobalMode=0,this._elevationTask=null,this._needFilterResolve=!1,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new n,this._crossfadeHelper=new Be(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get extractChanges(){return this._extractChanges?.layer!==this.layer&&(this._extractChanges?.destroy(),this._extractChanges=new Se({layer:this.layer})),this._extractChanges}get layerViewUid(){return this.uid}get layerId(){return this.layer.id}get sublayerId(){return null}get _isIntegratedMesh(){return this.layer.type===`integrated-mesh`}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible&&this.fullOpacity>Et}get legendEnabled(){return this.contentVisible&&this.layer?.legendEnabled===!0}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?`yes`:`probably-not`:`unknown`}get rendererTextureUsage(){return Qe(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?63:53:this._usePBR||this._hasLoadedPBRTextures?44:36}get elevationOffset(){let e=this.layer?.elevationInfo;return e?.mode===`absolute-height`?B(e,this.layer.spatialReference):0}get elevationInfo(){let e=this.layer?.elevationInfo;switch(e?.mode){case`absolute-height`:return new Z(0,B(e,this.layer.spatialReference));case`relative-to-ground`:return new Z(1,B(e,this.layer.spatialReference));case`on-the-ground`:return new Z(2,0);default:return new Z(0,0)}}get supportedTextureEncodings(){return Ge(this.view.stage.renderView.capabilities)}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){let e=this._nodeId2Meta,t=new q;for(let n of e.values()){let e=n?.geometryElevationRange;e?.elevationRangeValid&&!e.isEmpty&&t.expandElevationRange(e)}return t.elevationRangeValid&&!t.isEmpty?t:null}get fullExtent(){return this.layer.fullExtent}initialize(){let e=has(`enable-feature:idb-mock-cache`);this._idbCache=e?new ct(this.view,e):new st(`esri-scenelayer-cache`,`geometries`),this.addResolvingPromise(this.layer.indexInfo);let t=this.view.resourceController,n=t.memoryController;this.i3sOverrides=new Xe({view:this.view,layer:this.layer,memoryController:n,extractChanges:this.extractChanges}),this._workerHandle=new Pe(pt(t)),this.addResolvingPromise(this._workerHandle.promise),$e(this.layer),et(this.layer,this.view);let r=this.layer.store.defaultGeometrySchema;if(this.addResolvingPromise(this._workerHandle.setLegacySchema(this.uid,r).catch(l)),this._layerUrl=this.layer.parsedUrl.path,this._controller=new be({layerView:this,worker:this._workerHandle}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view.stage,this._collection=this._stage.renderView.componentObjectCollection,this._isIntegratedMesh||!r)this._hasComponentData=!1;else{let e=r.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=(r?.vertexAttributes.color??null)!=null&&!this.layer.cachedDrawingInfo?.color;let i=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,e=>this._deleteComponentObject(e));this._memCache=i;let o=this._controller,c=this._nodeId2Meta,u=this._nodeId2MetaReloading;function*d(e){let t=o.index;if(!t)return;let n=t.rootNode;if(!n)return;let r=null;for(let i of t.traverseValues(n,t=>(r=(c.get(t.index)||u.get(t.index))?.objectHandle??null,e(t,r))))yield new We(i,r)}this._intersectionHandler=new Ue({layerViewUid:this.layerViewUid,sublayerId:this.sublayerId,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:has(`enable-feature:im-as-ground`)?this.layer.isUsedAsGroundLayer:this._isIntegratedMesh,traverseNodeHierarchy:d}),this._elevationProvider=new lt({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add(()=>this.view.clippingArea,()=>this._clippingAreaChanged(),f),this._updatingHandles.add(()=>this.fullOpacity,e=>this._opacityChange(e)),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this.elevationOffset,(e,t)=>{this._reloadAll(t),this._controller.invalidateVisibilityObbs()}),this._updatingHandles.add(()=>this.elevationInfo,(e,t)=>this._elevationInfoChanged(e,t),f),this._updatingHandles.add(()=>!this.suspended&&this.elevationInfo.mode!==0,(e,t)=>{e?this.addHandles(this.view.groundView.on(`elevation-change`,({extent:e})=>this._ensureElevationTask().addExtent(e)),Wt):t&&this.removeHandles(Wt)},f),this._updatingHandles.add(()=>this._usePBR,e=>this._updatePBR(e)),this._updatingHandles.add(()=>this.rendererTextureUsage,()=>{this._reloadAll(),this.clearMemCache()}),this._updatingHandles.add(()=>this.contentVisible,e=>this._contentVisibleChanged(e),f),this._updatingHandles.add(()=>this.layer.labelsVisible,()=>this._labelingChanged(),f),this._updatingHandles.add(()=>this.layer.labelingInfo,()=>this._labelingChanged(),f),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),f),this.addHandles([p(()=>K.I3S_TREE_SHOW_TILES,e=>{if(e&&!this._treeDebugger){let e=this._controller.crsIndex;import(`./support/I3STreeDebugger.js`).then(({I3STreeDebugger:t})=>{!this._treeDebugger&&K.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))})}else!e&&!K.I3S_TREE_SHOW_TILES&&(this._treeDebugger=s(this._treeDebugger))},f),p(()=>K.I3S_SHOW_MODIFICATIONS,()=>this._showModifications(),f)]),this._cacheKeySuffix=this._getCacheKeySuffix(),this._idbCache.init().catch(e=>a.getLogger(this).warn(`Failed to initialize IndexedDB cache: ${e}`));let{view:m}=this,{viewingMode:h,renderCoordsHelper:g}=m;this._planetRadiusInGlobalMode=h===`local`?0:g.referenceEllipsoid.radius}destroy(){this._clearAddTasks(),this._elevationTask=s(this._elevationTask),this.i3sOverrides=s(this.i3sOverrides),this._extractChanges=s(this._extractChanges),this._elevationProvider&&=(this._elevationProvider.notifyObjectsChanged(this.getVisibleObbs()),this.view.elevationProvider.unregister(this._elevationProvider),null),this._intersectionHandler&&=(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),null);let e=this._workerHandle;e&&(e.destroyContextAndSelf(this.uid),this._workerHandle=null),this._removeAllNodeDataFromStage(),this._memCache=s(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=s(this._labeler),this._treeDebugger=s(this._treeDebugger),this._controller=s(this._controller),this._highlights=s(this._highlights),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=s(this._crossfadeHelper),this.emit(`visible-geometry-changed`),this._visibleGeometryChangedSchedulerHandle&&=(this._visibleGeometryChangedSchedulerHandle.remove(),null),this._updatingHandles=s(this._updatingHandles)}_memEstimateTextureAdded(e){let t=e.usedMemory;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(e!=null){let t=e.usedMemory;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){let t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){let t=this._collection.getObjectGPUMemoryUsage(e);this._gpuMemoryEstimate-=t,this._geoMemoryEstimate-=t}isNodeLoaded(e){return this._nodeId2Meta.has(e)}isNodeReloading(e){return this._nodeId2MetaReloading.has(e)}get usedMemory(){let e=this._labeler==null?0:this._labeler.usedMemory;return this._nodeId2Meta.forEach(t=>e+=t==null?0:t.node.memory),this._nodeId2MetaReloading.forEach(t=>e+=t==null?0:t.node.memory),e}get unloadedMemory(){return(this._controller==null?0:this._controller.unloadedMemoryEstimate)+(this._labeler==null?0:this._labeler.unloadedMemoryEstimate)}_labelingChanged(){if(!(Le(this.layer)&&this._supportsLabeling)){this._labeler!=null&&(this._labeler.destroy(),this._labeler=null);return}if(this._labeler!=null)return;let e=new Oe({view:this.view,layer:this.layer,collection:this._collection,overrides:this.i3sOverrides,layerViewUid:this.uid});this._nodeId2Meta.forEach(t=>t!=null&&this._addMetaToLabeler(e,t)),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then(e=>(--this._asyncModuleLoading,e),e=>{throw--this._asyncModuleLoading,e})}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications){this._i3sWasmLoaded=Ae().then(()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()},()=>{}),this.notifyUpdate();return}if(this._i3sWasmLoaded!==!0)return;let e=e=>a.getLogger(this).error(`set-modifications-error`,`Error when setting modifications:`,e),t=this.uid,n=this.layer.spatialReference,r=n.isGeographic,i=Fe(this._layerClippingArea,this._modifications,n,this.view.state.isGlobal);this._workerHandle.setModifications(t,i,r).catch(e);try{je({context:t,modifications:i,isGeodetic:r})}catch(t){e(t)}this._controller.modificationsChanged();let o=this.hasModifications?new c:null;this._nodeId2Meta.forEach((e,t)=>{e==null?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._updateFeatureIdCounts(e,-1),this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):o?.push(e.node)}),this.notifyChange(`elevationRange`),o!=null&&this._nodeId2MetaReloading.forEach(e=>o.push(e.node)),o!=null&&o.length>0&&(this.updateNodeModificationStatus(o),o.forAll(e=>{if(e.imModificationImpact!==2){let t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),t==null?this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1)):(this._updateFeatureIdCounts(t,-1),this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t),this.notifyChange(`elevationRange`))}})),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(this._modificationGraphics!=null&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!K.I3S_SHOW_MODIFICATIONS||this._modifications.length===0)return;let e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={outline:{color:[255,255,255],width:1}};this._modificationGraphics=[];for(let r of this._modifications){let i=r.geometry;i.spatialReference=this.layer.spatialReference;let a=new Ee({...t,color:e[r.type]});this._modificationGraphics.push(new n({geometry:i,symbol:a}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,(e,t)=>this._createAttributes(e,t))}_contentVisibleChanged(e){e?(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler)):(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){let t=this._nodeId2Meta.get(e);if(t?.attributeInfo!=null)return t.attributeInfo.loadedAttributes}getAttributeData(e){let t=this._nodeId2Meta.get(e);if(t?.attributeInfo!=null)return t.attributeInfo.attributeData}setAttributeData(e,t){let n=this._nodeId2Meta.get(e);n?.attributeInfo!=null&&(n.attributeInfo.attributeData=t,this._attributeValuesChanged(n))}async updateAttributes(e,t,n){let r=this._nodeId2Meta.get(e);r!=null&&(await this.i3sOverrides.applyAttributeOverrides(r.featureIds,t,n,this._controller.requiredAttributes),r.attributeInfo=t,this._controller.reschedule(()=>{this._nodeId2Meta.get(e)===r&&this._attributeValuesChanged(r)},n).catch(e=>{u(e)||a.getLogger(this).warn(`Error while updating attribute values. Layer might not display correctly.`,e)}))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.appliedFilters=null,this._labeler!=null&&this._labeler.setNodeMetaAttributes(e,(e,t)=>this._createAttributes(e,t)),this._updateEngineObject(e)}clearMemCache(){this._memCache!=null&&this._memCache.clear(),this._addTasks.forEach(e=>e.allowMemCache=!1)}getVisibleNodes(){let e=[];return this._nodeId2Meta.forEach(t=>t!=null&&e.push(t.node)),e}getVisibleObbs(){let e=[];return this._nodeId2Meta.forEach(t=>t&&e.push(this._collection.getComponentObb(t.objectHandle))),e}getLoadedNodeIndices(e){this._nodeId2Meta.forEach((t,n)=>e.push(n)),this._nodeId2MetaReloading.forEach((t,n)=>e.push(n))}_getVertexBufferLayout(e,t){return _t(yt(this._getGeometryParameters({hasTexture:It(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion})))}_getObjectIdField(){return this.layer.objectIdField||L}_getGlobalIdField(){return this.layer.globalIdField}_findGraphicNodeAndIndex(e){let t=G(this.layer.fieldsIndex,e.attributes,this._getObjectIdField());for(let e of this._nodeId2Meta.values()){let n=e?.featureIds.indexOf(t);if(n!=null&&n>=0)return{node:e.node,index:n}}return null}_getGraphicIndices(e,t){let n=this._nodeId2Meta.get(e.index);if(n==null)return[];let r=[],i=this._getObjectIdField(),a=this.layer.fieldsIndex;for(let e of t){let t=G(a,e.attributes,i),o=n.featureIds.indexOf(t);o!==-1&&r.push(o)}return r}whenGraphicBounds(e){let t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();let n=this.getAABB(t.node.index,t.index);return n==null?Promise.reject():Promise.resolve({boundingBox:n,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return e.nodeIndex==null||e.componentIndex==null?null:this.getAABB(e.nodeIndex,e.componentIndex)}getAABB(e,t){let n=this._nodeId2Meta.get(e);if(n?.featureIds==null||t>=n.featureIds.length)return null;let r=n.objectHandle,i=He(t,this._collection,r,P(24),0),a=this.view.renderSpatialReference,o=this.view.spatialReference;return he(i,a,0,i,o,0)?ge(i):null}whenGraphicAttributes(e,t){return tt(this.layer,e,this._getObjectIdField(),t,()=>this._nodeId2Meta.values().filter(i).toArray())}getGraphicFromIntersectorTarget(e,t){if(e.nodeIndex==null||e.componentIndex==null)return null;let n=this._nodeId2Meta.get(e.nodeIndex);if(n?.featureIds==null||e.componentIndex>=n.featureIds.length)return null;let r=this._createLayerGraphic(this._createAttributes(e.componentIndex,n));return r?this._meshUtilsImporterModule?(r.geometry=this._meshUtilsImporterModule.createMesh({layerView:this,nodeIndex:e.nodeIndex,featureIndex:e.componentIndex}),r):t.defer?(t.defer(async()=>(r.geometry=(await this._meshUtilsImporter).createMesh({layerView:this,nodeIndex:e.nodeIndex,featureIndex:e.componentIndex}),r)),null):r:null}_getCacheKey(e){return`${this._layerUrl}/v30/${e}${this._cacheKeySuffix}`}get _meshUtilsImporter(){return this._meshUtilsImporterPromise||(this._meshUtilsImporterPromise=import(`./i3s/meshUtils.js`),this._meshUtilsImporterPromise.then(e=>this._meshUtilsImporterModule=e,()=>{})),this._meshUtilsImporterPromise}_getCacheKeySuffix(){let e=this.view.renderSpatialReference;return e==null?Kt:e===D(e)?qt:this.layer.spatialReference.equals(e)?Gt:e.wkid==null?null:`@${e.wkid}`}_getMemCacheKey(e,t=this.elevationOffset){return e+`#`+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&this.elevationOffset===0&&this._cacheKeySuffix!=null}loadCachedGPUData(e){return this._memCache==null?null:this._memCache.pop(this._getMemCacheKey(e))}deleteCachedGPUData(e){e!=null&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(this._memCache==null){this._deleteComponentObject(e);return}let n=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,n)}loadMissingTextures(e,t,n,r){let i=e?.filter((e,n)=>{if((e.usage&this.rendererTextureUsage)===0)return!1;if(t==null)return!0;let r=Ke(e.encodings,this.supportedTextureEncodings),i=t[n];return!!(i?.data==null||r&&i.encoding!==r.encoding)})??[];return i.length===0?Promise.resolve(!1):n(i,r).then(n=>{let r=0;for(let i=0;i<e.length;i++)r<n.length&&n[r].id===e[i].id&&(t[i]=n[r],r++);return!0})}loadCachedNodeData(e,t,n){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then(r=>r==null?null:(r.globalTrafo=_e(r.globalTrafo),r.nodeVersion===e.version?(this.elevationInfo.mode===0&&(e.geometryObbInRenderSR=J.fromData(r.geometryObbData)),this.loadMissingTextures(r.requiredTextures,r.textureData,n,t).then(n=>(n&&this._idbCache.initialized&&r.textureData!=null&&(r.byteSize=zt(r.transformedGeometry,r.textureData),r.textureData.every(Rt)&&this._indexedDbSizeCheck(e,r)&&this._idbCache.put(this._getCacheKey(e.id),r).catch(t=>a.getLogger(this).warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`))),d(t),r))):(this._idbCache.remove(this._getCacheKey(e.id)),null))):Promise.resolve(null)}addNode(e,t,n){return Lt(t)?t.geometryBuffer==null?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,()=>this._transformNode(e,t,n).then(r=>this._safeReschedule(()=>{if(r==null)return e.hasModifications=!1,this._addCachedNodeData(e,null,n);let{obb:i,componentOffsets:o,featureIds:s,anchorIds:c,anchors:l,transformedGeometry:u,geometryMinElevation:d,geometryMaxElevation:f}=r;e.hasModifications=u.hasModifications;let p=_e(r.globalTrafo),m=b(Ht,i.center.x,i.center.y,i.center.z);x(m,m,p);let h=new J(m,[i.extents.x,i.extents.y,i.extents.z],ce(i.orientation.x,i.orientation.y,i.orientation.z,i.orientation.w));this.elevationInfo.mode===0&&(e.geometryObbInRenderSR=h),t.geometryData.componentOffsets=o,s&&(t.geometryData.featureIds=Array.from(s)),t.geometryData.anchorIds=c,t.geometryData.anchors=l;let g={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:u,globalTrafo:p,geometryObbData:h.data,geometryMinElevation:d,geometryMaxElevation:f,byteSize:zt(u,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&this._indexedDbSizeCheck(e,g)){let t=g.textureData==null?null:g.textureData.map(e=>Rt(e)?e:null);this._idbCache.put(this._getCacheKey(e.id),{...g,textureData:t}).catch(t=>a.getLogger(this).warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`))}return this._addCachedNodeData(e,g,n)},n))):Promise.reject()}getElevationRange(e){let t=new q,n=this._controller,{index:r}=n;if(!r)return t;let{rootNode:i}=r;if(!i)return t;let a=this._nodeId2Meta,o=n.viewportQueries;return r.traverse(i,n=>{let{childrenLoaded:r}=n;if(r===0)return!1;let i=o.getAndUpdateVisibilityObbInRenderSR(n),s=null;if(i){if(!i.intersectSphereWithMBS(e,i.radius))return!1}else if(s=o.calculateServiceMbsInRenderSRElevationAdjusted(n),s?.isValid&&!e.intersects(s))return!1;let c=a.get(n.index);if(c){let{geometryObbInRenderSR:r}=n;if(!r||r.intersectSphereWithMBS(e)){let e=c.geometryElevationRange;e.elevationRangeValid&&!e.isEmpty&&t.expandElevationRange(e)}}return r-+!!c>0}),t}computeVisibilityObb(e){return nt(e,this.view.renderSpatialReference,this._controller.crsIndex,this.layer.spatialReference,this.elevationOffset,this._modifications,this.view.renderCoordsHelper.sphericalPCPF)}_transformNode(e,t,n){let r=t.geometryData.geometries??[],i=Array(r.length);for(let e=0;e<r.length;++e)i[e]=this._getVertexBufferLayout(r[e],t.geometryDescriptor);let a=this.layer.normalReferenceFrame,o=t.normalReferenceFrame??a??`none`,s=e.serviceMbsInIndexSR,c=this.elevationOffset,l=this._controller.crsIndex,u=this._controller.crsVertex,d=this.view.renderSpatialReference,f=Ze(s,c,o,l,d),p=O(l,u),m=O(u,d);if(p==null||m==null)return Promise.resolve(null);let h={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:i,globalTrafo:f,geometryElevationOffset:c,mbs:s.toJSON(),obbData:e.serviceObbInIndexSR?.data,elevationOffset:c,planetRadiusInGlobalMode:this._planetRadiusInGlobalMode,needNormals:this._controller.isMeshPyramid||this._imVertexNormals,computeNormals:this._isIntegratedMesh&&this._imVertexNormals,normalReferenceFrame:o,indexToVertexProjector:p,vertexToRenderProjector:m};return this._workerHandle.invoke(h,n)}get _supportsNodeCrossFading(){return!this.view?.stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){let t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,n){if(this.elevationInfo.mode===0&&(e.geometryObbInRenderSR=this._collection.getComponentObb(t.objectHandle).clone()),!this._controller.isGeometryVisible(e)){this._cacheGPUData(t);return}let r=e.index;this._addNodeMeta(r,t),this.updateNodeState(r,n),this._collection.setObjectVisibility(t.objectHandle,!0),this._updateElevationOffsets(t),this._labeler!=null&&this._addMetaToLabeler(this._labeler,t),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==0&&this._ensureElevationTask().schedule(r),this._updateEngineObject(t),this._highlights?.objectCreated(t),this._treeDebugger!=null&&this._treeDebugger.update()}addCachedNodeData(e,t,n,r){return this._addData(e,n,()=>this._addCachedNodeData(e,t,r))}async deleteCachedNodeData(e){if(this._idbCacheEnabled)return this._idbCache.remove(this._getCacheKey(e))}async _addCachedNodeData(e,t,n){if(!this.contentVisible||!this._controller.isGeometryVisible(e)){this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);return}if(t==null){this._addNodeMeta(e.index,null);return}let r=this._addTasks.get(e.index),{geometryData:i,transformedGeometry:o}=t;await this.i3sOverrides.applyAttributeOverrides(i.featureIds,r.attributeInfo,n,this._controller.requiredAttributes);let s=t.textureData==null?[]:t.textureData.filter(e=>e!=null&&(e.usage&this.rendererTextureUsage)!==0);e.memory=0;let{componentOffsets:c,geometries:l,featureIds:u,anchorIds:d,anchors:f}=i,p=this._collection,m=l[0],{layout:h,indices:g,interleavedVertexData:_,positionData:v,hasColors:ce}=o,{material:b,geometryParameters:x}=this._materialParameters(m,h),S=_.byteLength/h[0].stride,de=c||new Uint32Array([0,g?g.length:S]),C=m.transformation?oe(m.transformation):se(),T=_e(t.globalTrafo);ie(C,T,C);let E=ae(w(),C),D=y(ne(),C),me=this._isIntegratedMesh?this._imShading?2:0:1,he=x.textureCoordinateType,O=!ee(D,re),A=new bt(h,me,he,+!!O),ge=new xt({interleavedVertexData:_,vertexCount:S,indexData:g},{positions:ve(v.data),indices:ye(v.indices)},de,A),j=this.view.renderSpatialReference,M=this.view.groundView.spatialReference,N=J.fromData(ht(t.geometryObbData)).getCenter(Xt),P=[1,1,1];pe(N,j,P,M)||a.getLogger(this).errorOnce(`Unsupported coordinate system for IM overlay`);let F=w();k(N,j,F,M);let I=ne();te(I,D);let L=w();le(L,ue(L,N,E),I);let be=F[0]-L[0]*P[0],xe=F[1]-L[1]*P[1],Se=x.textureCoordinateType===2,{textures:R,texturePromise:Ce,materialParameters:we}=this._initMaterialAndTextures(b,s,Se,e),z=p.createObject(new vt(fe(be,xe,P[0],P[1]),new Ct(E,D),J.fromData(ht(t.geometryObbData)),ge,has(`enable-feature:im-as-ground`)?!this.layer.isUsedAsGroundLayer:!this._isIntegratedMesh),we);e.memory+=this._memEstimateGeometryAdded(z),e.memory+=R.reduce((e,t)=>e+(t==null?0:this._memEstimateTextureAdded(t)),0);let B=!!b.hasParametersFromSource,Te=b.alphaMode!==`blend`&&b.metallicRoughness.baseColorFactor[3]>=1,V=new Ot(e,u,z,this._getInvalidRendererVersion(),r.attributeInfo,{hasParametersFromSource:B,isOpaque:Te},R,d,f,t.geometryMinElevation,t.geometryMaxElevation);r.meta=V,this._hasTextures||=t.requiredTextures?.some(({usage:e})=>!!(e&19))||!!e.resources.texture,this._hasData=!0,this._hasColors||=ce,this.notifyChange(`hasTexturesOrVertexColors`);let Ee=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(V),Ce]).then(([t,r])=>(this._addTasks.has(e.index)&&t?.updateObjectVisibility(V.objectHandle,!1).catch(e=>this._logEdgeViewError(e,this.layer.title)),this._safeReschedule(()=>{let n=this._addTasks.get(e.index);if(!n)return;if(this._addNodeMeta(e.index,V),n.meta=null,!this.contentVisible){this._removeNodeStageData(e.index,this.elevationOffset);return}p.setObjectVisibility(z,!0),t?.updateObjectVisibility(V.objectHandle,!0).catch(e=>this._logEdgeViewError(e,this.layer.title)),V.attributeInfo=n.attributeInfo;let r=V.cachedRendererVersion!==this._rendererVersion,i=Ee!==this.slicePlaneEnabled;this._updateElevationOffsets(V);let a=V.elevationOffsets;this._updateComponentData(V);let o=this._applyFiltersToNode(V);(r||t!=null&&(i||o||a))&&this._addOrUpdateEdgeRendering(V).catch(()=>{}),this._labeler!=null&&this._addMetaToLabeler(this._labeler,V),this._visibleGeometryChanged(V,0),this._highlights?.objectCreated(V),this._updateMaterial(V),this._setNewNodeOpacity(V),this._treeDebugger!=null&&this._treeDebugger.update()},n))).catch(e=>{let{meta:t,allowMemCache:n}=r;throw r.meta=null,t&&n?this._cacheGPUData(t):t&&this._deleteComponentObject(t),e})}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){a.getLogger(this).error(`Removing duplicated node`);let t=this._nodeId2Meta.get(e);t&&(this._deleteComponentObject(t),this._updateFeatureIdCounts(t,-1))}else this._controller.updateLoadStatus(e,!0);t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&X(t.cachedEdgeMaterials,0),this._updateFeatureIdCounts(t,1)),this._nodeId2Meta.set(e,t),this.notifyChange(`elevationRange`)}_updateElevationOffsets(e){if(!e.node.serviceMbsInIndexSR)return;let{view:t,elevationInfo:n}=this,r=this._controller.crsIndex,{groundView:i,groundSpatialReference:a,renderSpatialReference:o}=t,s=n.mode;if(s===0){e.elevationAlignmentOffset=n.offset,e.elevationOffsets=null,e.updateGeometryElevationRange(),this.notifyChange(`elevationRange`);return}if(e.elevationAlignmentOffset=0,o==null||a==null){e.elevationOffsets=null,e.updateGeometryElevationRange(),this.notifyChange(`elevationRange`);return}let c=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];let l=Ht,u=Ut,d=s===2,f=this.view.renderCoordsHelper,p=e.featureIds.length,m=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;let t=P(p*3);e.cachedElevationAnchors=t;let{center:n}=e.node.serviceMbsInIndexSR;for(let i=0;i<p;i++){let s=i*3,d=e.anchorIds?.indexOf(i)??-1;e.anchors&&d>=0?(b(l,e.anchors[d*3],e.anchors[d*3+1],e.anchors[d*3+2]),S(l,l,n),k(l,r,l,o),t[s+2]=f.getAltitude(l),k(l,o,l,a),t[s]=l[0],t[s+1]=l[1]):(this._collection.getComponentAabb(e.objectHandle,i,u,!0),b(l,(u[0]+u[3])/2,(u[1]+u[4])/2,u[2]),le(l,l,c.rotationScale),S(l,l,c.position),t[s+2]=f.getAltitude(l),k(l,o,l,a),t[s]=l[0],t[s+1]=l[1])}return t})(),h=n.offset,g=e.elevationOffsets;i.getElevations(m,p,(e,t)=>{let n=d?m[e*3+2]:0;g[e]=h+(t??0)-n}),e.updateGeometryElevationRange(),this.notifyChange(`elevationRange`)}_ensureElevationTask(){return this._elevationTask??=new ze(this.view.resourceController.scheduler,e=>this._controller.updateElevationChanged(e,this.view.groundView.spatialReference)?.filterInPlace(e=>this._nodeId2Meta.get(e)!=null),e=>this._nodeElevationAlignmentChanged(this._nodeId2Meta.get(e)),()=>this.elevationInfo?.mode),this._elevationTask}_elevationInfoChanged(e,t){let n=e.mode!==0,r=!!t&&t!==e&&t.mode!==0;this._intersectionHandler.updateElevationAlignState(n,this.view.state.viewingMode),n&&!r&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach(e=>this._nodeElevationAlignmentChanged(e))}_nodeElevationAlignmentChanged(e){e!=null&&(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),this._labeler!=null&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,2),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}_safeReschedule(e,t){return d(t),this._controller.reschedule(e,t)}_materialParameters(e,t){let n=e.params.material==null?qe():e.params.material,r=t.some(({name:e})=>e===`uvRegion`),i=t.some(({name:e})=>e===`normalCompressed`),a=It(n);return{geometryParameters:this._getGeometryParameters({hasTexture:a,hasNormals:i,hasRegions:r}),material:n}}_initMaterialAndTextures(e,t,n,r){let i=this._stage.renderView,a=e=>{this._gpuMemoryEstimate-=e,this._texMemoryEstimate-=e,r.memory-=e},o=t.map(t=>Je(t,e,n,i,this._compressionTracker,a));this._stage.addTextures(o);let{materialParameters:s,texturePromise:c}=Ye(e,o,t,this.view.stage.renderView.textures,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,isGround:this.layer.isUsedAsGroundLayer,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference,applySSAO:this._applySSAO});return{textures:o,texturePromise:c,materialParameters:s}}_getGeometryParameters(e){return new St(this._hasVertexColors,e.hasNormals,e.hasTexture?e.hasRegions?2:1:0)}_addData(e,t,n){let r=this._addTasks.get(e.index);if(r)r.attributeInfo=t;else{let i=Promise.withResolvers();r=new Vt(t,null,i.promise),this._addTasks.set(e.index,r),n().then(i.resolve,i.reject).then(()=>this._addTasks.delete(e.index)).catch(t=>{throw this._addTasks.delete(e.index),t})}return r.promise}_clearAddTasks(){this._addTasks.forEach(e=>{e.meta!=null&&(this._cacheGPUData(e.meta),e.meta=null)}),this._addTasks.clear()}_clippingAreaChanged(){let e=this.view.renderSpatialReference,t=this.layer.spatialReference,n=M();this._renderClippingArea=mt(this.view.clippingArea,n,e)?n:null;let r=M();this._layerClippingArea=mt(this.view.clippingArea,r,t)?r:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){let e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e),this._assertFeatureIdNodeCounts(e)}_assertFeatureIdNodeCounts(e){e&&!this._featureIdCounts?(this._featureIdCounts=$(this._nodeId2Meta.values()),this._filteredIdCounts=$(this._nodeId2Meta.values(),1),this._weaklyRemovedIdCounts=$(this._nodeId2Meta.values(),2),this.addHandles(p(()=>this._controller.updating,e=>{!e&&this._needFilterResolve&&(this.multiGeometryFilterResolve(),this._needFilterResolve=!1,this.notifyUpdate())},{sync:!0}),`updateFinished`)):!e&&this._featureIdCounts&&(this._featureIdCounts=null,this._filteredIdCounts=null,this._weaklyRemovedIdCounts=null,this._mismatchShow=null,this._mismatchHide=null,this.removeHandles(`updateFinished`),this._needFilterResolve=!1,this.notifyUpdate())}_updateFeatureIdCounts(e,t){this._featureIdCounts&&(this._needFilterResolve=!0,Q(this._featureIdCounts,e.featureIds,t),Q(this._filteredIdCounts,e.filteredIds,t),Q(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,t))}_updateFilteredIdCounts(e,t,n){this._filteredIdCounts&&(this._needFilterResolve=!0,Q(this._filteredIdCounts,t,-1),Q(this._filteredIdCounts,e.filteredIds,1),Q(this._weaklyRemovedIdCounts,n,-1),Q(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,1))}_checkFeatureIdNodeCountInvariant(){let e=this._featureIdCounts!=null;if(this.hasGeometryFilter!==e&&a.getLogger(this).error(`checkFeatureIdNodeCountInvariant()`,`LayerView should have feature id node counts if and only if it has a geometry filter`,{layerView:this,hasNodeCounts:e}),!this._featureIdCounts||!this._filteredIdCounts)return;let t=$(this._nodeId2Meta.values());o(this._featureIdCounts,t)||a.getLogger(this).error(`checkFeatureIdNodeCountInvariant()`,`Incorrect _featureIdCounts`,{layerView:this,counts:this._featureIdCounts,expected:t});let n=$(this._nodeId2Meta.values(),1);o(this._filteredIdCounts,n)||a.getLogger(this).error(`checkFeatureIdNodeCountInvariant()`,`Incorrect _filteredIdCounts`,{layerView:this,counts:this._filteredIdCounts,expected:n});let r=$(this._nodeId2Meta.values(),2);o(this._weaklyRemovedIdCounts,r)||a.getLogger(this).error(`checkFeatureIdNodeCountInvariant()`,`Incorrect _weaklyRemovedIdCounts`,{layerView:this,counts:this._weaklyRemovedIdCounts,expected:n})}multiGeometryFilterResolve(){if(!this._featureIdCounts||!this._filteredIdCounts)return;let e=null,t=null;for(let[n,r]of this._filteredIdCounts){let i=this._featureIdCounts.get(n);i!==r&&(r+(this._weaklyRemovedIdCounts?.get(n)??0)===i?(e??=new Set,e.add(n)):(t??=new Set,t.add(n)))}h(e,this._mismatchShow)&&h(t,this._mismatchHide)||(this._mismatchShow=e,this._mismatchHide=t,this._nodeId2Meta.forEach(e=>{if(!e?.filteredIds)return;let t=Yt(e,this._mismatchShow,this._mismatchHide);this._collection.setAllComponentVisibilities(e.objectHandle,t),this._visibleGeometryChanged(e,2)}))}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach(e=>{e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e).catch(()=>{}),this._visibleGeometryChanged(e,2))})}getFilters(){let e=[],t=this._renderClippingArea;return t!=null&&e.push((e,n)=>this._boundingRectFilter(e,n,t)),e}addSqlFilter(e,t,n){if(t!=null){let r=t.fieldNames;e.push((e,i)=>this._sqlFilter(e,i,t,r,n))}}_sqlFilter(e,t,n,r,i){let a={},o=this._createLayerGraphic(a);if(!o)return;let s=this.layer.objectIdField,c=t.featureIds,l=t.attributeInfo?.attributeData;r.every(e=>e===s||l?.[e]!=null)&&rt(e,c,e=>{a[s]=c[e];for(let t of r)t!==s&&(a[t]=l?H(l[t],e):null);try{return n.testFeature(o)}catch(e){return i(e),!1}})}_boundingRectNodeTest(e,t){return me(e.node.serviceMbsInIndexSR,this._controller.crsIndex,Ft,this.view.renderSpatialReference),it(t,Ft)}_boundingRectFeatureTest(e,t,n){return this._collection.getComponentAabb(e.objectHandle,t,At),j(At,jt),N(n,jt)}_boundingRectFilter(e,t,n){let r=this._collection,i=this._boundingRectNodeTest(t,n);if(i===3)return;if(i===0){e.length=0;return}let a=r.getComponentCount(t.objectHandle);if(a.invisible+a.visible!==t.featureIds.length)return;let o=this._transformClippingArea(Mt,n,t.objectHandle);rt(e,t.featureIds,e=>this._boundingRectFeatureTest(t,e,o))}_transformClippingArea(e,t,n){let r=this._collection.getObjectTransform(n),i=r.position,a=r.rotationScale;return e[0]=(t[0]-i[0])/a[0],e[1]=(t[1]-i[1])/a[4],e[2]=(t[2]-i[0])/a[0],e[3]=(t[3]-i[1])/a[4],e}async _addOrUpdateEdgeRendering(e,t=!0){let n=e.objectHandle,{hasEdges:r,perFeatureEdgeMaterials:i}=this._getFilteredEdgeMaterials(e);if(r&&!this._edgeView)try{this._edgeView=await this._stage.renderer.loadEdgeView()}catch(e){if(!u(e))throw e}let a=this._edgeView;if(!a)return null;let o=a.hasObject(n);if(r){if(o)return this.nodeCrossfadingEnabled&&X(i,this.getNodeOpacity(e)),a.updateAllComponentMaterials(n,i,this.slicePlaneEnabled,t).catch(e=>this._logEdgeViewError(e,this.layer.title)),a.updateObjectVisibility(n,!0).catch(e=>this._logEdgeViewError(e,this.layer.title)),a.updateAllVerticalOffsets(n,e.elevationOffsets).catch(e=>this._logEdgeViewError(e,this.layer.title)),a;let r=await this._collection.addEdges(n,a,i,this.slicePlaneEnabled,e.elevationOffsets);return e.edgeMemoryUsage=r,e.node.memory+=r,a}return o&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,a.removeObject(n)),null}_applyFiltersToNode(e){let{filteredIds:t,weaklyRemovedIds:n}=e,r=this._applyFiltersToNodeComponents(e);return this._updateFilteredIdCounts(e,t,n),r&&this._labeler?.applyFilterChange(e),r}_applyFiltersToNodeComponents(e){let t=this._collection,n=t.getComponentCount(e.objectHandle),r=e.filteredIds!=null,i=n.invisible===0;if(t.setAllComponentVisibilities(e.objectHandle,`all`),this._filters.length===0)return e.filteredIds=null,!i;if((e.filteredIds==null||e.appliedFilters!==this._filters)&&(e.weaklyRemovedIds=null,e.filteredIds=Jt(e,this._filters),e.appliedFilters=this._filters),r&&e.filteredIds===e.featureIds&&(!this._mismatchHide||e.filteredIds.every(e=>!this._mismatchHide?.has(e))))return!i;let a=Yt(e,this._mismatchShow,this._mismatchHide);return t.setAllComponentVisibilities(e.objectHandle,a),!0}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach((t,n)=>this._removeNodeStageData(n,e)),this._nodeId2MetaReloading.forEach((t,n)=>this._removeNodeStageData(n,e,this._nodeId2MetaReloading)),this._elevationTask=s(this._elevationTask)}removeNode(e){let t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),this._elevationTask!=null&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,n=this._nodeId2Meta){n.has(e)&&this._controller.updateLoadStatus(e,!1);let r=n.get(e);r==null?n.delete(e):(this._collection.setObjectVisibility(r.objectHandle,!1),this._edgeView!=null&&this._edgeView.hasObject(r.objectHandle)&&this._edgeView.updateObjectVisibility(r.objectHandle,!1).catch(e=>this._logEdgeViewError(e,this.layer.title)),this._visibleGeometryChanged(r,1),this._labeler!=null&&this._labeler.removeNodeMeta(r),n.delete(e),this._highlights?.objectDeleted(r),n===this._nodeId2Meta?(this._updateFeatureIdCounts(r,-1),this._cacheGPUData(r,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(r)):this._deleteComponentObject(r),this._treeDebugger!=null&&this._treeDebugger.update())}_deleteComponentObject(e){if(this._edgeView!=null&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(let t of e.textures)this._memEstimateTextureRemoved(t),this._stage.removeTexture(t)}updateNodeState(e,t){this._nodeId2Meta.get(e)?.objectHandle.updatePolygonOffset(+(t===0))}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){let n=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,n),this.notifyChange(`elevationRange`)}let n=this._nodeId2MetaReloading.get(e);n&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,n))}_invalidateAllSymbols(){this._rendererVersion=U(this._rendererVersion,1),this._controller?.requestUpdate()}_getInvalidRendererVersion(){return U(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange(`rendererTextureUsage`),this._rendererVersion=U(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.layer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&`arcadeRequired`in e&&e.arcadeRequired&&(this._arcade=await Te()),e&&`visualVariables`in e&&e.visualVariables)for(let t of e.visualVariables)t.type===`color`?this._colorVariable=t:t.type===`opacity`?this._opacityVariable=t:a.getLogger(this).warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(let t of e.symbols)t.type!==`mesh-3d`&&a.getLogger(this).error(`Symbols of type '${t.type}' are not supported for 3D Object Scene Services.`);this._controller&&this._controller.requestUpdate()}_getCachedEdgeMaterials(e){return this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e),e.cachedEdgeMaterials}_getComponentParameters(e){this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e);let t=e.cachedSymbology;return(n,r)=>{let i=n*e.cachedSymbologyStride;T(r.externalColor,t[i]/255,t[i+1]/255,t[i+2]/255,t[i+3]/255);let a=this._stage.renderView.olidRenderHelper;if(a){let t=e.featureIds[n],i=this.sublayerId?`${this.layerViewUid}_${this.sublayerId}`:this.layerViewUid,o=z(this.view,this.uid);a.setUidToObjectAndLayerId(t,t,this.layerId,i,this.layerPopupEnabledAndHasTemplate&&!o,e.node.resources.attributes,n,this.sublayerId),r.olidColor=a.getObjectAndLayerIdColor({graphicUid:t,layerViewUid:i})}r.externalColorMixMode=t[i+4]&15,r.castShadows=!!(t[i+4]&16),r.pickable=!!(t[i+4]&32),r.elevationOffset=e.elevationOffsets?.[n]??0,r.emissiveStrength=e.emissiveStrengths?.[n]??1,r.emissiveSource=e.emissiveSources?.[n]??0}}_getSymbolInfo(e,t){let n=e?.getSymbol(t,{arcade:this._arcade});if(!(n instanceof V))return null;let r=n.id;if(this._symbolInfos.has(r))return this._symbolInfos.get(r);let i=at(n);return this._symbolInfos.set(r,i),i}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=this._symbologyOverrideFields!=null&&this._symbologyOverrideFields.length>0?this._rendererFields!=null&&this._rendererFields.length>0?xe(this.layer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;let t=this._tmpAttributeOnlyGraphic,n={};t.attributes=n;let r=this._currentRenderer,i=e.attributeInfo?.attributeData,a=e.featureIds?this.layer.objectIdField:null,o=i!=null&&this._symbologyFields!=null&&this._symbologyFields.length>0,s=null,c=null;if(o&&this._symbologyFields!=null){s=[],c=[];for(let e of this._symbologyFields){let t=i[e];t&&(s.push(e),c.push(t))}}e.cachedSymbology||=I(e.featureIds.length*e.cachedSymbologyStride);let l=new ut,u=this.fullOpacity,d=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):u,f=null,p=1,m=W,h=0;for(let i=0;i<e.featureIds.length;i++){if(a!=null&&(n[a]=e.featureIds[i]),o&&s)for(let e=0;e<s.length;e++)n[s[e]]=H(c[e],i);let u=r?this._getSymbolInfo(r,t):null,g,_;if(l.pickable=!0,r&&`visualVariables`in r){if(this._colorVariable){let e=Ce(this._colorVariable,t,{color:Pt,arcade:this._arcade});e&&(g=l.color,g[0]=e.r/255,g[1]=e.g/255,g[2]=e.b/255,g[3]=e.a??1,!this._opacityVariable&&e.a!==null&&(_=e.a))}this._opacityVariable&&(_=we(this._opacityVariable,t,{arcade:this._arcade}))}if(u?.material){let e=u.material;g=g==null||_==null?Ie(g,_,e.color,e.alpha,Dt,l.color):Ie(g,_,null,null,Dt,l.color)}g??=T(l.color,1,1,1,1);let v=u?.material;if(l.colorMixMode=v?.colorMixMode??1,l.edgeMaterial=u?.edgeMaterial,this._symbologyOverride?.(t,l),this._nodeColorOverride!=null&&(this._nodeColorOverride(e.node,g),l.colorMixMode=3),l.pickable&&=g[3]>=Et,l.castShadows=u?u.castShadows:l.pickable,l.edgeMaterial!=null){let t=g[3]>=1&&(e.material.isOpaque||l.colorMixMode===3)?1:0;(l.edgeMaterial!==f||t!==p)&&(m={...l.edgeMaterial,opacity:d,objectTransparency:t},f=l.edgeMaterial,p=t),e.cachedEdgeMaterials[i]=m}else e.cachedEdgeMaterials[i]=W;e.cachedSymbology[h++]=Math.round(g[0]*255),e.cachedSymbology[h++]=Math.round(g[1]*255),e.cachedSymbology[h++]=Math.round(g[2]*255),e.cachedSymbology[h++]=Math.round(g[3]*255),e.cachedSymbology[h++]=l.colorMixMode|l.castShadows<<4|l.pickable<<5;let y=v?.emissive?.strength==null?Y:v?.emissive?.strength;y!==Y&&!e.emissiveStrengths&&(e.emissiveStrengths=Array(e.featureIds.length).fill(Y)),e.emissiveStrengths&&(e.emissiveStrengths[i]=y);let ee=v?.emissive?.source||0;ee!==0&&!e.emissiveSources&&(e.emissiveSources=Array(e.featureIds.length).fill(0)),e.emissiveSources&&(e.emissiveSources[i]=ee)}}_getFilteredEdgeMaterials(e){let t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||X(t,this.fullOpacity);let n=e.filteredIds;if(n==null)return{hasEdges:t.some(e=>e!==W),perFeatureEdgeMaterials:t};let r=0,i=!1,a=t.map((t,a)=>e.featureIds[a]===n[r]?(i||=t!==W,r++,t):W);return{hasEdges:i,perFeatureEdgeMaterials:a}}_updateComponentData(e){if(!this._hasComponentData)return;let{objectHandle:t}=e,n=this._getComponentParameters(e);this._collection.setComponentData(t,n),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),this._controller!=null&&this._controller.restartNodeLoading()}_refreshGroundUsage(){this._intersectionHandler.isGround=has(`enable-feature:im-as-ground`)?this.layer.isUsedAsGroundLayer:this._isIntegratedMesh,this.contentVisible&&(this.view.elevationProvider.unregister(this._elevationProvider),this.view.elevationProvider.register(this._elevationContext,this._elevationProvider)),this._reloadAll(),this.clearMemCache()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach(t=>{t!=null&&(this._collection.updateObjectOpacity(t.objectHandle,e),X(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))})}_updateMaterial(e){e.objectHandle.updateMaterial({slicePlaneEnabled:this.slicePlaneEnabled,usePBR:this._usePBR})}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e).catch(()=>{}),this._visibleGeometryChanged(e,2)}intersect(e,t,n,r){this._intersectionHandler.intersectRay(e,t,n,r,null,!1)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this._labeler!=null&&(this._labeler.slicePlaneEnabled=e),this._foreachMeta(t=>{t.objectHandle.updateMaterial({slicePlaneEnabled:e}),this._updateEdgeRendering(t,!1)})}_updatePBR(e){this._foreachMeta(t=>t.objectHandle.updateMaterial({usePBR:e})),this._hasLoadedPBRTextures=!0}_foreachMeta(e){this._nodeId2Meta.forEach(t=>{t!=null&&e(t)})}get _usePBR(){return this._imShading&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){this._edgeView!=null&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t).catch(()=>{})}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?(t,n,r)=>r.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?0:e(t,n,r):e}_forAllFeatures(e,t,n){for(let r of this._nodeId2Meta.values())if(r!=null&&!(t&&r.node.serviceMbsInIndexSR&&t(r.node.serviceMbsInIndexSR)===1))switch(n){case 1:this._forAllFeaturesOfNode(r,e);break;case 0:this._forAllVisibleFeaturesOfNode(r,e);break;case 2:this._forAllQueryableFeaturesOfNode(r,e)}}_forAllFeaturesOfNode(e,t){e.featureIds.forEach((n,r)=>t(n,r,e))}_forAllVisibleFeaturesOfNode(e,t){let n=e.featureIds;this._collection.forEachVisibleComponent(e.objectHandle,r=>t(n[r],r,e)===0)}_forAllQueryableFeaturesOfNode(e,t){let n=this._ignoreClientNodeOverriddenFeatures(t);if(this._renderClippingArea==null)return this._forAllFeaturesOfNode(e,n);let r=this._boundingRectNodeTest(e,this._renderClippingArea);if(r===0)return;if(r===3)return this._forAllFeaturesOfNode(e,n);let i=e.featureIds,a=e.objectHandle,o=ot(this._renderClippingArea,this._collection.getObjectTransform(a));for(let t=0;t<i.length;t++)this._boundingRectFeatureTest(e,t,o)&&n(i[t],t,e)}_createAttributes(e,t){let n={};t.featureIds!=null&&(n[this._getObjectIdField()]=t.featureIds[e]);let r=t.attributeInfo?.attributeData;if(r!=null)for(let t of Object.keys(r))n[t]=H(r[t],e);return n}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e,t){let r=dt(e);if(r.length===0)return ft;let i=wt(t),a=r[0]instanceof n?this._featureIdsFromGraphics(r):typeof r[0]==`number`?r:null;if(!a)return ft;let o=this._ensureHighlights(),{set:s,handle:c}=o.acquireSet(i);return o.setFeatureIds(s,a),c}_featureIdsFromGraphics(e){let t=this.layer.fieldsIndex,n=this._getObjectIdField();return e.map(e=>G(t,e.attributes,n))}_ensureHighlights(){return this._highlights??=new Re({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,1),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)}),this._highlights}resetHighlights(){this._highlights=s(this._highlights)}_visibleGeometryChanged(e,t){this._elevationProvider&&(this._visibleGeometryChangedSchedulerHandle??=m(()=>{let{node:t}=e,n=t.visibilityObbInRenderSR??t.geometryObbInRenderSR??t.serviceObbInRenderSR;if(n!=null){let e=A();n.toAaBoundingBox(e),this.emit(`visible-geometry-changed`,new De(e))}else this.emit(`visible-geometry-changed`);this._visibleGeometryChangedSchedulerHandle=null}),this._updateSnappingSources(e,t),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}get performanceInfo(){return new ke(this.usedMemory,this._nodeId2Meta.size,Math.round(this._gpuMemoryEstimate/1048576),Math.round(this._geoMemoryEstimate/1048576),Math.round(this._texMemoryEstimate/1048576),Math.round(this.unloadedMemory/1048576),this._idbCacheEnabled?Math.round(this._idbCache.getHitRate()*100):0)}checkInvariants(){}get test(){}getNodeOpacityByIndex(e){let t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return e==null?0:this._collection.getObjectOpacity(e.objectHandle)}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}getNodeComponentHandle(e){return this._nodeId2Meta.get(e)?.objectHandle}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(e)}fadeNode(e,t,n){if(!this.nodeCrossfadingEnabled)return;let r=this._nodeId2Meta.get(e);r!=null&&this._crossfadeHelper.fadeNode(e,r,t,n)}setNodeOpacityByIndex(e,t){let n=this._nodeId2Meta.get(e);n!=null&&this._setNodeOpacity(n,t)}_setNodeOpacity(e,t){this._collection.updateObjectOpacity(e.objectHandle,t),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(this._edgeView==null||!e.cachedEdgeMaterials)return;X(e.cachedEdgeMaterials,t);let n=e.objectHandle;this._edgeView.hasObject(n)&&this._edgeView.updateAllComponentOpacities(n,t).catch(e=>this._logEdgeViewError(e,this.layer.title))}get hasModifications(){return this._isIntegratedMesh&&this._layerClippingArea!=null||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){let t=e.length;if(!this.hasModifications||t<=0||this._i3sWasmLoaded!==!0)return;let n=this.uid,r=Bt(e);if(r){let t={context:n,buffer:r.buffer};Me(t);let i=new Float64Array(r.buffer);e.forAll((e,t)=>{let n=i[t],r=Ne(n);e.imModificationImpact=r,r!==0&&this._controller.invalidateGeometryVisibility(e.index)})}}notifyUpdate(){this.notifyChange(`updating`)}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!!(this._controller&&this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||this._labeler!=null&&this._labeler.updating||this._crossfadeHelper?.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||this._elevationTask!=null&&this._elevationTask.readyToRun||this._needFilterResolve||this._compressionTracker.compressing}trackSnappingSources(e){let t={events:e,fetchEdgeLocations:async(e,t,n)=>{let r=this._nodeId2Meta.get(e);if(r==null)throw Error(`invalid-node`);let{origin:i,buffer:a}=await this._collection.extractEdgeInformation(r.objectHandle,t,n);return this._snappingLocationsApplyElevation(r,a,i),{type:`components`,objectIds:r.featureIds,locations:a,origin:i}},remove:()=>r(this._snappingSourcesTrackers,t)};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach((t,n)=>{if(t==null)return;let r=this._controller.getRenderMbs(t.node);r&&e.add(n,r)}),t}_snappingLocationsApplyElevation(e,t,n){if(!e.elevationOffsets||this.elevationInfo.mode===0)return;let r=t.position0,i=t.position1,a=t.componentIndex,o=w(),s=w(),c=(e,t)=>{S(e,e,n),this.view.renderCoordsHelper.worldUpAtPosition(e,s),S(e,e,de(s,s,t)),C(e,e,n)};for(let t=0;t<r.count;t++){let n=e.elevationOffsets[a.get(t)];r.getVec(t,o),c(o,n),r.setVec(t,o),i.getVec(t,o),c(o,n),i.setVec(t,o)}}_updateSnappingSources(e,t){let{index:n}=e.node,r=this._controller.getRenderMbs(e.node);if(r!=null)for(let e of this._snappingSourcesTrackers)(t===1||t===2)&&e.events.remove(n),(t===0||t===2)&&e.events.add(n,r)}_logEdgeViewError(e,t){u(e)||a.getLogger(this).warn(`Error while processing edges. Edges on this layer might not display correctly`,t,e)}_indexedDbSizeCheck(e,t){return t.byteSize>104857600?(a.getLogger(this).warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}get elevationProvider(){return this._elevationProvider}};return e([_()],F.prototype,`extractChanges`,null),e([_()],F.prototype,`_hasLoadedPBRTextures`,void 0),e([_()],F.prototype,`_asyncModuleLoading`,void 0),e([_()],F.prototype,`_visibleGeometryChangedSchedulerHandle`,void 0),e([_()],F.prototype,`view`,void 0),e([_()],F.prototype,`layer`,void 0),e([_()],F.prototype,`_controller`,void 0),e([_()],F.prototype,`_labeler`,void 0),e([_()],F.prototype,`updating`,void 0),e([_()],F.prototype,`suspended`,void 0),e([_()],F.prototype,`contentVisible`,null),e([_({readOnly:!0})],F.prototype,`legendEnabled`,null),e([_(gt)],F.prototype,`updatingProgress`,void 0),e([_()],F.prototype,`updatingProgressValue`,null),e([_()],F.prototype,`hasTexturesOrVertexColors`,null),e([_()],F.prototype,`rendererTextureUsage`,null),e([_()],F.prototype,`elevationOffset`,null),e([_()],F.prototype,`elevationInfo`,null),e([_({type:Boolean})],F.prototype,`slicePlaneEnabled`,void 0),e([_()],F.prototype,`supportedTextureEncodings`,null),e([_({type:[R]})],F.prototype,`_modifications`,void 0),e([_({readOnly:!0})],F.prototype,`clientGeometry`,null),e([_()],F.prototype,`elevationRange`,null),e([_()],F.prototype,`fullExtent`,null),e([_()],F.prototype,`_elevationTask`,void 0),e([_({readOnly:!0})],F.prototype,`_usePBR`,null),F=e([v(`esri.views.3d.layers.I3SMeshView3D`)],F),F},At=A(),jt=M(),Mt=M(),Nt=new J,Pt=new t([0,0,0,0]),Ft=new F(0,0,0,0);function It(e){if(e==null)return!1;let t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function Lt(e){return`geometryData`in e}function Rt(e){return e!=null&&g(e.data)}function zt(e,t){let n=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(t!=null)for(let e of t)e!=null&&g(e.data)&&(n+=e.data.byteLength);return n}function Bt(e){if(e.length===0)return;let t=e.length*10,n=new Float64Array(t),r=0;return e.forAll(e=>{let t=e.serviceObbInIndexSR;t??(t=Nt,e.serviceMbsInIndexSR?(t.setCenter(e.serviceMbsInIndexSR.center),t.setHalfSizeFromValues(e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius)):t.invalidate());let i=t.data;n[r++]=i[0],n[r++]=i[1],n[r++]=i[2],n[r++]=i[3],n[r++]=i[4],n[r++]=i[5],n[r++]=i[6],n[r++]=i[7],n[r++]=i[8],n[r++]=i[9]}),n}class Vt{constructor(e,t,n){this.attributeInfo=e,this.meta=t,this.promise=n,this.allowMemCache=!0}}function X(e,t){e.forEach(e=>e.opacity=t)}class Z{constructor(e,t){this.mode=e,this.offset=t}}const Ht=w(),Ut=A(),Wt=`elevation-change`,Gt=``,Kt=`@null`,qt=`@ECEF`;function Jt(e,t){let n=e.featureIds.slice();for(let r of t)if(r(n,e),n.length===0)break;return n.length===e.featureIds.length?e.featureIds:n}function Yt(e,t,n){let r=[],i=e.filteredIds;if(i!=null&&!t?.size&&!n?.size)e.featureIds.forEach((e,t)=>{i[r.length]===e&&r.push(t)});else if(i!=null){let a=0;e.featureIds.forEach((e,o)=>{if(i[a]===e)++a;else if(!t?.has(e))return;n?.has(e)||r.push(o)})}return r}function Q(e,t,n){if(e&&t)for(let r of t){let t=(e.get(r)??0)+n;t>0?e.set(r,t):e.delete(r)}}function $(e,t=0){let n=new Map;for(let r of e)Q(n,t===0?r?.featureIds:t===1?r?.filteredIds:r?.weaklyRemovedIds,1);return n}const Xt=w();export{kt as I3SMeshView3D};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{abortMaybe as n,destroyMaybe as r,removeMaybe as i}from"../../../core/maybe.js";import{throwIfAborted as a,createAbortError as o}from"../../../core/promiseUtils.js";import{initial as s,whenOnce as c,watch as l,when as u}from"../../../core/reactiveUtils.js";import{schedule as d}from"../../../core/scheduling.js";import{isUint8Array as f,isFloat32Array as p,isUint32Array as m,isUint16Array as h}from"../../../core/typedArrayUtil.js";import{unitFromRESTJSON as g,convertUnit as _}from"../../../core/units.js";import{property as v,subclass as y}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as b,invert as x}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as S,IDENTITY as C}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as T}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as E,sub as D,dot as O,set as k}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as A,freeze as j,clone as ee,ZEROS as te,fromValues as ne}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as re,clone as ie,ONES as ae}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as oe,isMars as se,getReferenceEllipsoid as M,SphericalECEFSpatialReferenceLike as ce}from"../../../geometry/ellipsoidUtils.js";import le from"../../../geometry/HeightModelInfo.js";import{computeTranslationToOriginAndRotation as ue}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as de}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as fe}from"../../../geometry/projection/projectVectorToVector.js";import{create as pe}from"../../../geometry/support/aaBoundingRect.js";import{isCompatible as me}from"../../../geometry/support/heightModelInfoUtils.js";import{isInEffectiveScaleRange as he,validateScaleRange as ge}from"../../../geometry/support/scaleUtils.js";import{isPlateCarree as N,isWebMercator as P,equals as F,isGeographic as I,isCGCS2000 as L}from"../../../geometry/support/spatialReferenceUtils.js";import R from"../../../geometry/support/WKIDUnitConversion.js";import{BufferViewVec4u8 as _e,BufferViewVec3u8 as ve,BufferViewVec2f as ye,BufferViewVec3f as z,BufferViewUint32 as B,BufferViewUint16 as V}from"../../../geometry/support/buffer/BufferView.js";import{nullId as H}from"../../../layers/ILyr3DWasmPerSceneView.js";import be from"../../../layers/support/SceneModification.js";import{getHeightModelInfoFromVCS as xe,validateEntity3D as Se,makeCacheKey as U,isValidHandle as W}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as G}from"../../../support/elevationInfoUtils.js";import{IntegratedMesh3DTilesLayerWorkerHandle as Ce}from"./IntegratedMesh3DTilesLayerWorkerHandle.js";import{LayerView3D as we}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as Te}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as Ee,removeLayerViewFromWasm as De,getLyr3DWasm as Oe}from"./Lyr3DWasm.js";import{toWasmModification as K}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as ke}from"./i3s/LayerElevationProvider.js";import{IntegratedMesh3DTilesLayerView3DSymbol as Ae}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as je,alphaModeConversion as Me,faceCullingConversion as Ne,wrapModeConversion as Pe}from"./support/lyr3dTypeConversions.js";import{makeScheduleFunction as Fe}from"./support/makeScheduleFunction.js";import{Tiles3DMeshIntersectionHandler as Ie}from"./support/Tiles3DMeshIntersectionHandler.js";import{Frustum as Le}from"../state/Frustum.js";import{ElevationRange as q}from"../support/ElevationRange.js";import{toBoundingRect as Re}from"../support/extentUtils.js";import{Obb as ze}from"../support/orientedBoundingBox.js";import{glLayout as Be}from"../support/buffer/glUtil.js";import{getGroundTransparencyModeFromOpacity as Ve}from"../terrain/TransparencyMode.js";import{ComponentGeometryParameters as He,SourceGeometry as Ue}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as We}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Ge}from"../webgl-engine/core/material/RenderTexture.js";import{ManagedTexture as Ke}from"../webgl-engine/lib/ManagedTexture.js";import{compressNormals as qe}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as Je}from"../webgl-engine/materials/pbrUtils.js";import Ye from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as Xe}from"../../support/layerViewUtils.js";import{TaskPriority as Ze}from"../../support/Scheduler.js";import{CompressedTextureFormat as J,SizedPixelFormat as Y}from"../../webgl/enums.js";import{alphaCutoff as X}from"../../../webscene/support/AlphaCutoff.js";var Z;function Qe(e,t,n){if(t===`image/vnd-ms.dds`)switch(n){case`Dxt1`:return J.COMPRESSED_RGB_S3TC_DXT1_EXT;case`Dxt5`:return J.COMPRESSED_RGBA_S3TC_DXT5_EXT;default:return null}if(t===`image/ktx`)return n===`Etc1`?J.COMPRESSED_RGB8_ETC2:null;switch(e){case 33319:return Y.RG8;case 6407:return Y.RGB8;case 6408:return Y.RGBA8;case 6403:return Y.R8;default:return null}}let Q=class extends we(Ye){static{Z=Ae}constructor(e){super(e),this[Z]=!0,this.type=`integrated-mesh-3dtiles`,this.skipHeightModelInfoValidation=!0,this.freeze=!1,this._modifications=[],this._visibleGeometryChangedSchedulerHandle=null,this._initializationController=null,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this._useEsriCrs=!1,this.fullExtentInLocalViewSpatialReference=null,this._applySSAO=!has(`disable-feature:im-ssao`),this._imShading=!!has(`enable-feature:im-shading`),this._imVertexNormals=!!has(`enable-feature:im-vertex-normals`),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._dbgFlags=new Set;let t=e.view.resourceController;this._memCache=t.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._replacesTerrain=e.layer.replacesTerrain,this._frameTask=t.scheduler.registerTask(Ze.TILES3D,this),this._frustum=new Le(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{a(t);let n=this.layer.queryElevationCallback;this.layer=e,this.layer.queryElevationCallback=n}):null}canRecycleWith(e){return e.url===this.layer.url&&e.type===`integrated-mesh-3dtiles`&&e.replacesTerrain===this._replacesTerrain}initialize(){this._dbg(2,`Tiles3DLayerView3D initialize() called`);let{view:e}=this;this._workerHandle=new Ce(Fe(e.resourceController)),this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),s),this.addResolvingPromise(this._initializeAsync(e))}async _initializeAsync(e){this._initializationController=new AbortController;let{signal:t}=this._initializationController;if(await c(()=>e?.defaultsFromMap.heightModelInfoReady,t),a(t),!this._canProjectWithoutEngine())throw Xe(`layer`,this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);this._wasmLayerId=await Ee(this,t),a(t);let n=new Ie(this);this._intersectionHandler=n,e.sceneIntersectionHelper.addIntersectionHandler(n),this._elevationProvider=new ke({view:e,layerElevationSource:this,intersectionHandler:n});let r=this._getElevationContext();e.elevationProvider.register(r,this._elevationProvider),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged()),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.overlayManager.renderer.isEmpty,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),s),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),s),this._updatingHandles.add(()=>this.layer.isUsedAsGroundLayer,()=>this._groundUsageChanged()),e.overlayManager.registerDrapeTarget(this),this.addHandles([l(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),u(()=>this.fullOpacity,()=>this._opacityChange()),l(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),s),l(()=>this.freeze,e=>{e?this._wasm?.incrementFrozenLayerViewCount(this):(this._wasm?.decrementFrozenLayerViewCount(this),this._cameraChanged())})]),this._initializationController=null,this.addHandles(l(()=>this._replacesTerrain&&!!this._wasm?.isTerrainReady||!this._replacesTerrain&&!!has(`enable-feature:im-as-ground`)&&this.layer.isUsedAsGroundLayer,e=>{this.layer.queryElevationCallback=e?(e,t)=>this._queryElevation(e,t):null},s))}destroy(){if(this.freeze=!1,this._initializationController=n(this._initializationController),this._dbg(2,`Tiles3DLayerView3D destroy() called`),this._workerHandle?.destroyContextAndSelf(this.uid),De(this),this.layer.queryElevationCallback=null,this._intersectionHandler&&=(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler.destroy(),null),this._elevationProvider){let e=Array.from(this._lyrHandleToObjects.values()),t=e.reduce((e,{componentObjects:t})=>e+t.length,0);this._elevationProvider.notifyObjectsChangedFunctional(t,t=>{for(let{componentObjects:n}of e)for(let{obb:e}of n)if(!t(e))return}),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null}this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._frameTask.remove(),this._updatingHandles=r(this._updatingHandles),this.emit(`visible-geometry-changed`),this._visibleGeometryChangedSchedulerHandle=i(this._visibleGeometryChangedSchedulerHandle)}get usedAsGround(){return this.layer.isUsedAsGroundLayer}get replacesTerrain(){return this._replacesTerrain}get fullOpacity(){return has(`enable-feature:im-as-ground`)?this.usedAsGround?this.view.map.ground.opacity:this.layer.opacity:this.replacesTerrain?this.view.map.ground.opacity:1}get opaque(){return this._groundTransparencyMode===0}get invisible(){return this._groundTransparencyMode===3}get _groundTransparencyMode(){return(has(`enable-feature:im-as-ground`)?!this.usedAsGround:!this._replacesTerrain)?0:Ve(this.fullOpacity,this.view.overlayManager.renderer.isEmpty)}get _renderOpacity(){switch(this._groundTransparencyMode){case 3:return 0;case 2:return X;default:return this.fullOpacity}}get hasModifications(){return this._modifications&&this._modifications.length>0}_opacityChange(){let e=this._renderOpacity,t=this._groundTransparencyMode;this.forEachComponentObject(n=>this._collection.updateObjectOpacity(n,e,t))}_getElevationContext(){return this.replacesTerrain?0:has(`enable-feature:im-as-ground`)?this.usedAsGround?1:2:1}_groundUsageChanged(){let e=this._getElevationContext();this.view.elevationProvider.unregister(this._elevationProvider),this.view.elevationProvider.register(e,this._elevationProvider),this._intersectionHandler.isGround=!has(`enable-feature:im-as-ground`)||this.usedAsGround,this._intersectionHandler.slicePlaneEnabled=this.slicePlaneEnabled&&!this.replacesTerrain,this.view.overlayManager.unregisterDrapeTarget(this),this.view.overlayManager.registerDrapeTarget(this),this._loadModifications();let t=has(`enable-feature:im-as-ground`)?this.usedAsGround:this.replacesTerrain,n=this._renderOpacity,r=this._groundTransparencyMode;this.forEachComponentObject(e=>e.updateMaterial({isGround:t,opacity:n,groundTransparencyMode:r}))}_cameraChanged(){if(this.freeze)return;let e=this._frustum;e.update(this.view.state.contentCamera);let t=this._visibleObjects,n=!1;this._loadedObjects.forEach(r=>{let i=r.obb?.intersectsFrustum(e)??!1;i!==r.isVisible&&(r.isVisible=i,i?t.add(r):t.delete(r),r.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,i)),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(i,r.elevationRange))}),n&&this._setVisibleElevationRangeDirty()}intersect(e,t,n,r){this._intersectionHandler.intersectRay(e,t,n,r,null,!1)}get ready(){return!this.replacesTerrain||!!this._wasm?.isTerrainReady}_modificationsChanged(){let e=this.useEsriCrs?this.layer.supportedSpatialReferences[1]:this.layer.supportedSpatialReferences[0],t=K(this._layerClippingArea,this._modifications,e,this.view.state.isGlobal);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){let e=this.layer.spatialReference,t=pe();this._layerClippingArea=Re(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=d(()=>{this.emit(`visible-geometry-changed`),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.replacesTerrain),this.forEachComponentObject(t=>t.updateMaterial({slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,G(e))}get _wasm(){return Oe(this.view)}_queryElevation(e,t){return this.destroying||this.destroyed?Promise.reject(o()):this._wasm?.queryElevation(this,e,t)??Promise.reject(o())}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get useEsriCrs(){return this._useEsriCrs}get visibleAtCurrentScale(){return this.replacesTerrain||he(this.layer.effectiveScaleRange,this.view.scale)}canResume(){let e=this.layer&&`effectiveScaleRange`in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.replacesTerrain||ge(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,n=0,r=0,i=0,a=0;return this._lyrHandleToObjects.forEach(o=>{o.isLoaded?(e+=o.textureMemoryUsage,t+=o.vboMemoryUsage,i++):(n+=o.textureMemoryUsage,r+=o.vboMemoryUsage,a++)}),new Te(this.usedMemory,i,a,$(t),$(e),$(r),$(n))}_canProjectWithoutEngine(){if(this.view.state.viewingMode===1||N(this.view.renderSpatialReference)||P(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&F(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(this.layer.esriCrsSpatialReference.vcsWkid===115700)return!1;let e=xe(this.layer.esriCrsSpatialReference);if(!e){let t=this.layer.esriCrsSpatialReference,n=I(t),r=`meters`;!n&&t.wkid&&t.wkid!==-1&&(r=g(R.units[R[t.wkid]])),r&&(e=new le({heightModel:`gravity-related-height`,heightUnit:r}))}let t=this.view.heightModelInfo;return this._useEsriCrs=me(e,t,!1)===0,this._useEsriCrs&&(e&&(this._metersPerVCSUnit=_(1,e.heightUnit,`meters`)),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return G(this.layer.elevationInfo)}get elevationRange(){let e=this.fullExtent;return e?.zmin&&e?.zmax?new q(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){let e=new q;this._visibleObjects.size===0?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this._forEachRelevantVisibleTile(t=>e.expandElevationRange(t.elevationRange)),e.minElevation===1/0&&e.setElevationRangeValues(0,0));let t=this._get(`visibleElevationRange`);return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange(`visibleElevationRange`)}_forEachRelevantVisibleTile(e){let{view:t}=this,{spatialReference:n}=t,r=n.isWGS84||n.isWebMercator||L(n)||oe(n)||se(n);if(this.view.state.isGlobal||!r)return this.forEachVisibleTile(e);let i=M(n).radius,{eye:a,viewForward:o,near:s}=t.state.contentCamera,c=E(A(),o),l=Math.max(a[2],500),u=l+i,d=Math.sqrt(u**2-i**2),f=Math.abs(Math.atan2(d,i))*i,p=l>.5*i?.5*Math.PI*i:f,m=A();this.forEachVisibleTile(t=>{let{mbsRadius:n,mbsCenter:r}=t;if(n<0)return;D(m,r,a);let i=O(m,c);Math.abs(i)<p&&i+n>s&&i-n<p&&e(t)})}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(let t of this._visibleObjects)e(t)}forEachTile(e){for(let t of this._loadedObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(let{componentObjects:n}of e)for(let e of n)t(e)}get drapeTargetType(){return has(`enable-feature:im-as-ground`)?+!this.usedAsGround:+!this.replacesTerrain}isUpdating(){let e=this._wasm;return!this.freeze&&this._wasmLayerId>=0&&e!=null&&e.isUpdating(this._wasmLayerId)}get readyToRun(){return!!this._frameTask?.readyToRun}runTask(e){this._frameTask.processQueue(e)}updatingFlagChanged(){this.notifyChange(`updating`)}async createRenderable(e){if(this.destroyed||this.destroying)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy`);let{entity3d:t}=e;if(!Se(t))throw Error(`entity3D not valid`);let n=new Map,r;try{r=this._createPrimitiveTextureBundles(t,n)}catch(e){throw n.forEach(e=>this._stage?.removeTexture(e)),e}let i=null;try{if(i=await this._createRenderableMain(t,r),this.destroyed)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderable aborted due to destroyed instance`);let{tileObb:a,componentObjects:o,elevationRange:s}=i,c=0,l=0,u=0;for(let e of o){let{texture:t,textureMetallicRoughness:n,textureEmissive:r,textureOcclusion:i,textureNormal:a}=e.renderable.drawParameters;c+=(t?.usedMemory??0)+(n?.usedMemory??0)+(r?.usedMemory??0)+(i?.usedMemory??0)+(a?.usedMemory??0),l+=this._collection.getObjectGPUMemoryUsage(e),u+=e.intersectionGeometry.usedMemory}let d=Array.from(n.values()),f=new et(e.handle,o,d,u,l,c,a,e.stableNodeId,e.nodeDepth,s);return this._lyrHandleToObjects.set(e.handle,f),()=>{this._memCache.put(U(f.handle),f);let{usedMemory:e}=f;return this._cacheMemory+=e,{memUsageBytes:e}}}catch(e){throw r.forEach(e=>e.cleanup()),i?.componentObjects.forEach(e=>this._collection.destroyObject(e)),n.forEach(e=>this._stage?.removeTexture(e)),e}}_createPrimitiveTextureBundles(e,t){let n=[];try{let r=e.desc.geometry;for(let i of e.validPrimitiveIndices){let a=r.prims[i].materialId,o=e.desc.materials?.materials&&a!=null&&a!==H?e.desc.materials.materials[a]:null,s=Promise.resolve(nt),c=null,l=null,u=null,d=null,f=null;if(o){let n=o.lightingModel===`Pbr`;c=this._getTexture(o.baseColorTex,e,t),l=n?this._getTexture(o.metalTex,e,t):null,u=n?this._getTexture(o.emissiveTex,e,t):null,d=n?this._getTexture(o.occlusionTex,e,t):null,f=n?this._getTexture(o.normalTex,e,t):null;let r=[c,l,u,d,f].map(e=>e?.loadPromise??null);s=Promise.all(r)}n.push(new rt(s,c,l,u,d,f))}}catch(e){throw n.forEach(e=>e.cleanup()),e}return n}async _createRenderableMain(e,t){if(this.destroyed||this.destroying)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderableMain called after destroy`);let n=[],r=e.desc,i=j(...e.origin),a=this.view.groundView.spatialReference,o=this.view.state.isGlobal,s=C;if(o){let e=w();ue(ce,i,e,a),s=b(S(),e)}let c=tt(r.obb),l=o?M(this.view.spatialReference).radius:0,u=[];try{let d=-1;for(let n of e.validPrimitiveIndices){d+=1;let i=r.geometry.prims[n],a=t[d];if(this._dbgFlags.has(2)&&this._dbg(2,JSON.stringify(i)),je[i.ptype]==null){this._dbg(2,`[Unsupported Feature] Unsupported primitive mode (`+i.ptype+`). Skipping primitive.`),a.cleanup();continue}let{positionView:o,normalsData:s,colorView:c,texCoord0Data:l,indicesView:f}=this._getBufferViews(i,e);if(o==null||f==null){a.cleanup();continue}let p=o.count,m=(e,t)=>e!=null&&e!==p?(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1):!0;!m(l==null?void 0:l.length/2,`numTexcoord`)||!m(c?.count,`numColors`)||!m(s?.length,`normals`)?a.cleanup():u.push({componentIndex:d,positionView:o,indicesView:f,texCoord0Data:l,colorView:c,normalsData:s})}let f=s!==C,p=f?x(S(),s)??C:C,{vertexProcessingOutputs:m,obbHalfSizeAccumulator:h,elevationRange:g}=await this._workerHandle.processTiles3DVertices(u,i,l,o,s,c,this._imVertexNormals&&!this.usedAsGround);if(this.destroyed)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance`);let _=r.materials;if(await Promise.all(t.map(e=>e.materialPromise)),this.destroyed)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance`);m.length>0&&c.setHalfSize(h);for(let o of m){let{componentIndex:s,positionView:l,indicesView:u,layout:d,textureCoordinateType:m,interleavedVertexData:h,indices:g}=o,v=e.validPrimitiveIndices[s],y=r.geometry.prims[v],b=t[s],x=c.clone(),S=Be(d),C=new Uint32Array([0,u.typedBuffer.length]),w=new He(S,this._imShading?2:0,m,f?2:0),T=new Ue({interleavedVertexData:h,vertexCount:h.byteLength/S[0].stride,indexData:g},{positions:l.typedBuffer,indices:u.typedBuffer},C,w),E=this.view.renderSpatialReference,D=A(),O=[1,1,1];de(i,E,O,a)||this._dbg(3,`Unsupported coordinate system for IM overlay`),fe(i,E,D,a);let k=this._createComponentMaterialInitParameters(_,y.materialId,b);k.baseColorTexture||this._dbg(3,`No colour texture 1`);let j=this._collection.createObject({toMapSpace:re(D[0],D[1],O[0],O[1]),transform:new We(i,p),obb:x,geometry:T,elevationAlignable:!1},k);n.push(j)}let{fullExtent:v}=this.layer;return v?.hasZ&&v.zmax&&v.zmin&&(g.minElevation=Math.max(g.minElevation,v.zmin),g.maxElevation=Math.min(g.maxElevation,v.zmax)),{tileObb:c,componentObjects:n,elevationRange:g}}catch(e){throw n.forEach(e=>this._collection.destroyObject(e)),e}}_createComponentMaterialInitParameters(e,t,n){let r=e?.materials!=null&&t!=null&&t!==H?e.materials[t]:null,i=1,a=r?.baseColorTex?.imageId;if(a!=null&&e&&Array.isArray(e.images)&&a>=0&&a<e.images.length){let t=e.images[a];t.alpha&&(i=Me[t.alpha])}let o=(r==null?`Unlit`:r.lightingModel)===`Pbr`,s=ae,c=X,l=!1,u=2,d=ne(0,0,0),f=ee(Je),p=n.baseColorTexture,m=n.metallicRoughnessTexture,h=n.emissionTexture,g=n.occlusionTexture,_=n.normalTexture;return r&&(s=ie(r.baseColorFactor),c=r.alphaCutoff??X,o&&(k(f,r.metallicFactor,r.roughnessFactor,0),r.emissiveFactor&&(d=r.emissiveFactor)),l=r.isDoubleSided,u=Ne[r.faceCulling??`NotSet`]),{isIntegratedMesh:!0,baseColor:s,textureAlphaCutoff:c,mrrFactors:f,baseColorTexture:p,metallicRoughnessTexture:m,normalTexture:_,occlusionTexture:g,emissionTexture:h,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:i,doubleSided:l,cullFace:u,isGround:has(`enable-feature:im-as-ground`)?this.usedAsGround:this.replacesTerrain,groundTransparencyMode:this._groundTransparencyMode,emissiveBaseColor:d,usePBR:o,slicePlaneEnabled:this.slicePlaneEnabled,opacity:this._renderOpacity,polygonOffset:0,ellipsoidMode:1,applySSAO:this._applySSAO}}freeRenderable(e){let t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._intersectionHandler.removeTile(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){let t=U(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,n){if(this.destroyed||this.destroying)return;let r=this._frustum,i=[],a=!1,o=!1;for(let s=0;s<n;++s){if(!t[s])continue;let n=e[s],c=this._lyrHandleToObjects.get(n);if(c){if(c.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${c.stableNodeId}`);continue}a=!0,c.isLoaded=!0,this._loadedObjects.add(c),this._intersectionHandler.addTile(c),this._usedMemory+=c.usedMemory,this._cacheMemory-=c.usedMemory;let e=c.obb?.intersectsFrustum(r)??!0;c.isVisible=e,e&&(this._visibleObjects.add(c),o||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,c.elevationRange)),i.push(c.obb),c.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(U(n))}else this._dbg(3,`Tried to mark Non existent object ${n} as loaded`)}for(let r=0;r<n;++r){let n=e[r];if(t[r])continue;let a=this._lyrHandleToObjects.get(n);if(a){if(!a.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${a.stableNodeId}`);continue}let e=a.isVisible;this._visibleObjects.delete(a),a.isVisible=!1,a.isLoaded=!1,this._loadedObjects.delete(a),this._intersectionHandler.removeTile(a),e&&(this._visibleGeometryChanged(),o||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,a.elevationRange)),this._usedMemory-=a.usedMemory,this._cacheMemory+=a.usedMemory,i.push(a.obb),a.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(U(n),a)}else this._dbg(3,`Tried to mark Non existent object ${n} as not loaded`)}a&&this._visibleGeometryChanged(),i.length>0&&this._elevationProvider.notifyObjectsChanged(i),o&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){let{visibleElevationRange:n}=this,{minElevation:r,maxElevation:i}=t;return e?r<n.minElevation||i>n.maxElevation:r===n.minElevation||i===n.maxElevation}_getTexture(e,t,n){let r=e&&t.desc.materials?.images?.[e.imageId];if(!r||!W(r.data))return null;let i=t.assets[r.data];if(!i||i.byteCount<1||i.dataType!==`U8`)return null;let a=n.get(r)??this._createTexture(e,r,i,n);return a?new Ge(this._stage.renderView.textures,a.id):null}_createTexture(e,n,r,i){let a=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,o=n.mipCount?!0:a>1,s=Pe[e.wrapMode??`None`],c=n.alpha?6408:6407,l=new Uint8Array(r.data.buffer,0,r.byteCount),u=null,d=null;switch(n.format){case`Raw`:if(n.pixelFormat===`R8`)u=l,c=6403,d=``;else if(n.pixelFormat===`Rg8`||n.pixelFormat===`Ga8`)u=l,c=33319,d=``;else if(n.pixelFormat===`Rgb8`)u=l,c=6407,d=``;else if(n.pixelFormat===`Rgba8`)u=l,c=6408,d=``;else return t.getLogger(this).error(`Raw texture pixel format ${n.pixelFormat} not supported`),null;break;case`Dxt1`:u=l,c=6407,d=`image/vnd-ms.dds`;break;case`Dxt5`:u=l,c=6408,d=`image/vnd-ms.dds`;break;case`Basis`:u=l,c=6407,d=`image/ktx2`;break;case`Etc1`:u=l,c=6407,d=`image/ktx`;break;default:return t.getLogger(this).error(`${n.format} texture not supported`),null}if(u&&d!=null){let e=Qe(c,d,n.format),t=new Ke(u,{mipmap:o,maxAnisotropy:a,encoding:d,wrap:s,pixelFormat:c,internalFormat:e??void 0,immutable:e!=null,noUnpackFlip:!0,width:n.mip0Width,height:n.mip0Height});return this._stage.addTexture(t),i.set(n,t),t}return null}_getBufferViews(e,t){let n,r,i,a;for(let o=0;o<e.atrbs.length;o++){let s=e.atrbs[o],c=t.assets[s.assetId];if(!c)continue;let l=c.data.buffer,u=c.byteCount;try{switch(s.sem){case`Position`:c.ncomp!==3||c.dataType!==`F32`||!p(c.data)?this._dbg(3,`[Unsupported Feature] Unsupported view for Position (`+c+`)`):n=new z(l,0,void 0,u);break;case`Normal`:if(c.ncomp!==3||c.dataType!==`F32`||!p(c.data))this._dbg(3,`[Unsupported Feature] Unsupported view for Normal (`+c+`)`);else{let e=new z(l,0,void 0,u);a=new Uint32Array(e.count),qe(e.typedBuffer,new Int16Array(a.buffer,a.byteOffset,a.length*2))}break;case`TexCoord`:c.ncomp!==2||c.dataType!==`F32`||!p(c.data)?this._dbg(3,`[Unsupported Feature] Unsupported view for Texcoord (`+c+`)`):i===void 0&&(i=new ye(l,0,void 0,u).typedBuffer);break;case`Color`:c.dataType===`U8`&&f(c.data)&&(c.ncomp===4?r=new _e(l,0,void 0,u):c.ncomp===3&&(r=new ve(l,0,void 0,u))),r??this._dbg(3,`[Unsupported Feature] Unsupported view for Color (`+c+`)`);break;case`FeatureIndex`:break;default:this._dbg(2,`[Unsupported Feature] Unsupported semantic (`+s.sem+`). Skipping vertex attribute.`)}}catch(e){this._dbg(2,`Error Creating buffer (`+e+`). Skipping vertex attribute.`)}}let o,s=!1;if(W(e.index)){let n=t.assets[e.index];if(!n)s=!0;else{let e=n.byteCount;switch(n.dataType){case`U16`:n.ncomp===1&&h(n.data)&&(o=new V(n.data.buffer,0,void 0,e));break;case`U32`:n.ncomp===1&&m(n.data)&&(o=new B(n.data.buffer,0,void 0,e))}s=!o}}if(!s&&o==null&&n!=null){let e=n.count;o=o=e<65535?new V(new Uint16Array(e).buffer):new B(new Uint32Array(e).buffer);for(let t=0;t<e;t++)o.set(t,t)}return{positionView:n,colorView:r,texCoord0Data:i,indicesView:o,normalsData:a}}_loadModifications(){if(this.removeHandles(`modifications`),this.layer.modifications==null){this._modifications=[];return}let e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.usedAsGround&&e.type!==`replace`)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info(`Ground layers only support replace modifications. Other modification types have been ignored.`)},s),`modifications`)}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,n){this._dbgFlags.has(e)&&(e===3?t.getLogger(this).error(n):t.getLogger(this).warn(n))}};e([v()],Q.prototype,`freeze`,void 0),e([v()],Q.prototype,`fullOpacity`,null),e([v()],Q.prototype,`opaque`,null),e([v()],Q.prototype,`invisible`,null),e([v({readOnly:!0})],Q.prototype,`ready`,null),e([v({type:[be]})],Q.prototype,`_modifications`,void 0),e([v()],Q.prototype,`_visibleGeometryChangedSchedulerHandle`,void 0),e([v()],Q.prototype,`layer`,void 0),e([v({readOnly:!0})],Q.prototype,`visibleAtCurrentScale`,null),e([v({readOnly:!0})],Q.prototype,`_collection`,null),e([v()],Q.prototype,`elevationOffset`,null),e([v({readOnly:!0})],Q.prototype,`visibleElevationRange`,null),e([v()],Q.prototype,`fullExtentInLocalViewSpatialReference`,void 0),Q=e([y(`esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D`)],Q);const $e=Q;class et{constructor(e,t,n,r,i,a,o,s,c,l){this.handle=e,this.componentObjects=t,this.textures=n,this.cpuMemoryUsage=r,this.vboMemoryUsage=i,this.textureMemoryUsage=a,this.obb=o,this.stableNodeId=s,this.nodeDepth=c,this.elevationRange=l,this.bvhIntersectionGeneration=0,this.isLoaded=!1,this.isVisible=!1;let u=A();o?.getCenter(u),this._obbCenterX=u[0],this._obbCenterY=u[1],this._obbCenterZ=u[2];let d=o?.radius??-1;this._obbRadius=d,this._obbRadiusSquared=d*d,this._obbShortestHalfsize=o?Math.min(o.halfSizeX,o.halfSizeY,o.halfSizeZ):0,this._mbsCenter=o?o.getCenter(A()):te}get usedMemory(){return this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this._mbsCenter}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;let{_obbCenterX:n,_obbCenterY:r,_obbCenterZ:i}=this,a=n-e[0],o=r-e[1],s=i-e[2],c=a*t[0]+o*t[1]+s*t[2];return a*a+o*o+s*s-c*c<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){let t=this._obbRadius;if(t<0)return!0;let n=e.center,r=e.radius,i=t+r,a=this._obbCenterX-n[0];if(a>i)return!1;let o=this._obbCenterY-n[1];if(o>i)return!1;let s=this._obbCenterZ-n[2];if(s>i)return!1;let c=a*a+o*o+s*s;if(c>i*i)return!1;if(c<=(this._obbShortestHalfsize+r)**2)return!0;let l=r-t;return l>0&&c<=l*l?!0:this.obb?.intersectSphere(e)??!0}}function $(e){return Math.round(e/1048.576)/1e3}function tt(e){return new ze(e.center,e.halfSize,T(...e.quaternion))}const nt=[];class rt{constructor(e,t,n,r,i,a){this.materialPromise=e,this.baseColorTexture=t,this.metallicRoughnessTexture=n,this.emissionTexture=r,this.occlusionTexture=i,this.normalTexture=a}cleanup(){this.baseColorTexture?.dispose(),this.metallicRoughnessTexture?.dispose(),this.emissionTexture?.dispose(),this.occlusionTexture?.dispose(),this.normalTexture?.dispose()}}export{$e as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{abortMaybe as n,destroyMaybe as r,removeMaybe as i}from"../../../core/maybe.js";import{throwIfAborted as a,createAbortError as o}from"../../../core/promiseUtils.js";import{initial as s,whenOnce as c,watch as l,when as u}from"../../../core/reactiveUtils.js";import{schedule as d}from"../../../core/scheduling.js";import{isUint8Array as f,isFloat32Array as p,isUint32Array as m,isUint16Array as h}from"../../../core/typedArrayUtil.js";import{unitFromRESTJSON as g,convertUnit as _}from"../../../core/units.js";import{property as v,subclass as y}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as b,invert as x}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as S,IDENTITY as C}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as T}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as E,sub as D,dot as O,set as k}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as A,freeze as j,clone as ee,ZEROS as te,fromValues as ne}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as re,clone as ie,ONES as ae}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as oe,isMars as se,getReferenceEllipsoid as M,SphericalECEFSpatialReferenceLike as ce}from"../../../geometry/ellipsoidUtils.js";import le from"../../../geometry/HeightModelInfo.js";import{computeTranslationToOriginAndRotation as ue}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as de}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as fe}from"../../../geometry/projection/projectVectorToVector.js";import{create as pe}from"../../../geometry/support/aaBoundingRect.js";import{isCompatible as me}from"../../../geometry/support/heightModelInfoUtils.js";import{isInEffectiveScaleRange as he,validateScaleRange as N}from"../../../geometry/support/scaleUtils.js";import{isPlateCarree as P,isWebMercator as F,equals as I,isGeographic as L,isCGCS2000 as R}from"../../../geometry/support/spatialReferenceUtils.js";import z from"../../../geometry/support/WKIDUnitConversion.js";import{BufferViewVec4u8 as ge,BufferViewVec3u8 as _e,BufferViewVec2f as ve,BufferViewVec3f as B,BufferViewUint32 as V,BufferViewUint16 as H}from"../../../geometry/support/buffer/BufferView.js";import{nullId as U}from"../../../layers/ILyr3DWasmPerSceneView.js";import ye from"../../../layers/support/SceneModification.js";import{getHeightModelInfoFromVCS as be,validateEntity3D as xe,makeCacheKey as W,isValidHandle as G}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as K}from"../../../support/elevationInfoUtils.js";import{IntegratedMesh3DTilesLayerWorkerHandle as Se}from"./IntegratedMesh3DTilesLayerWorkerHandle.js";import{LayerView3D as Ce}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as we}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as Te,removeLayerViewFromWasm as Ee,getLyr3DWasm as De}from"./Lyr3DWasm.js";import{toWasmModification as q}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as Oe}from"./i3s/LayerElevationProvider.js";import{IntegratedMesh3DTilesLayerView3DSymbol as ke}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as Ae,alphaModeConversion as je,faceCullingConversion as Me,wrapModeConversion as Ne}from"./support/lyr3dTypeConversions.js";import{makeScheduleFunction as Pe}from"./support/makeScheduleFunction.js";import{Tiles3DMeshIntersectionHandler as Fe}from"./support/Tiles3DMeshIntersectionHandler.js";import{Frustum as Ie}from"../state/Frustum.js";import{ElevationRange as Le}from"../support/ElevationRange.js";import{toBoundingRect as Re}from"../support/extentUtils.js";import{Obb as ze}from"../support/orientedBoundingBox.js";import{glLayout as Be}from"../support/buffer/glUtil.js";import{getGroundTransparencyModeFromOpacity as Ve}from"../terrain/TransparencyMode.js";import{ComponentGeometryParameters as He,SourceGeometry as Ue}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as We}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Ge}from"../webgl-engine/core/material/RenderTexture.js";import{ManagedTexture as Ke}from"../webgl-engine/lib/ManagedTexture.js";import{compressNormals as qe}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as Je}from"../webgl-engine/materials/pbrUtils.js";import Ye from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as Xe}from"../../support/layerViewUtils.js";import{TaskPriority as Ze}from"../../support/Scheduler.js";import{CompressedTextureFormat as J,SizedPixelFormat as Y}from"../../webgl/enums.js";import{alphaCutoff as X}from"../../../webscene/support/AlphaCutoff.js";var Z;function Qe(e,t,n){if(t===`image/vnd-ms.dds`)switch(n){case`Dxt1`:return J.COMPRESSED_RGB_S3TC_DXT1_EXT;case`Dxt5`:return J.COMPRESSED_RGBA_S3TC_DXT5_EXT;default:return null}if(t===`image/ktx`)return n===`Etc1`?J.COMPRESSED_RGB8_ETC2:null;switch(e){case 33319:return Y.RG8;case 6407:return Y.RGB8;case 6408:return Y.RGBA8;case 6403:return Y.R8;default:return null}}let Q=class extends Ce(Ye){static{Z=ke}constructor(e){super(e),this[Z]=!0,this.type=`integrated-mesh-3dtiles`,this.skipHeightModelInfoValidation=!0,this.freeze=!1,this._modifications=[],this._visibleGeometryChangedSchedulerHandle=null,this._initializationController=null,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this._useEsriCrs=!1,this.fullExtentInLocalViewSpatialReference=null,this._applySSAO=!has(`disable-feature:im-ssao`),this._imShading=!!has(`enable-feature:im-shading`),this._imVertexNormals=!!has(`enable-feature:im-vertex-normals`),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._dbgFlags=new Set;let t=e.view.resourceController;this._memCache=t.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._replacesTerrain=e.layer.replacesTerrain,this._frameTask=t.scheduler.registerTask(Ze.TILES3D,this),this._frustum=new Ie(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{a(t);let n=this.layer.queryElevationCallback;this.layer=e,this.layer.queryElevationCallback=n}):null}canRecycleWith(e){return e.url===this.layer.url&&e.type===`integrated-mesh-3dtiles`&&e.replacesTerrain===this._replacesTerrain}initialize(){this._dbg(2,`Tiles3DLayerView3D initialize() called`);let{view:e}=this;this._workerHandle=new Se(Pe(e.resourceController)),this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),s),this.addResolvingPromise(this._initializeAsync(e))}async _initializeAsync(e){this._initializationController=new AbortController;let{signal:t}=this._initializationController;if(await c(()=>e?.defaultsFromMap.heightModelInfoReady,t),a(t),!this._canProjectWithoutEngine())throw Xe(`layer`,this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);this._wasmLayerId=await Te(this,t),a(t);let n=new Fe(this);this._intersectionHandler=n,e.sceneIntersectionHelper.addIntersectionHandler(n),this._elevationProvider=new Oe({view:e,layerElevationSource:this,intersectionHandler:n});let r=this._getElevationContext();e.elevationProvider.register(r,this._elevationProvider),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged()),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.overlayManager.renderer.isEmpty,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),s),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),s),this._updatingHandles.add(()=>this.layer.isUsedAsGroundLayer,()=>this._groundUsageChanged()),e.overlayManager.registerDrapeTarget(this),this.addHandles([l(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),u(()=>this.fullOpacity,()=>this._opacityChange()),l(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),s),l(()=>this.freeze,e=>{e?this._wasm?.incrementFrozenLayerViewCount(this):(this._wasm?.decrementFrozenLayerViewCount(this),this._cameraChanged())})]),this._initializationController=null,this.addHandles(l(()=>this._replacesTerrain&&!!this._wasm?.isTerrainReady||!this._replacesTerrain&&!!has(`enable-feature:im-as-ground`)&&this.layer.isUsedAsGroundLayer,e=>{this.layer.queryElevationCallback=e?(e,t)=>this._queryElevation(e,t):null},s))}destroy(){if(this.freeze=!1,this._initializationController=n(this._initializationController),this._dbg(2,`Tiles3DLayerView3D destroy() called`),this._workerHandle?.destroyContextAndSelf(this.uid),Ee(this),this.layer.queryElevationCallback=null,this._intersectionHandler&&=(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler.destroy(),null),this._elevationProvider){let e=Array.from(this._lyrHandleToObjects.values()),t=e.reduce((e,{componentObjects:t})=>e+t.length,0);this._elevationProvider.notifyObjectsChangedFunctional(t,t=>{for(let{componentObjects:n}of e)for(let{obb:e}of n)if(!t(e))return}),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null}this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._frameTask.remove(),this._updatingHandles=r(this._updatingHandles),this.emit(`visible-geometry-changed`),this._visibleGeometryChangedSchedulerHandle=i(this._visibleGeometryChangedSchedulerHandle)}get usedAsGround(){return this.layer.isUsedAsGroundLayer}get replacesTerrain(){return this._replacesTerrain}get fullOpacity(){return has(`enable-feature:im-as-ground`)?this.usedAsGround?this.view.map.ground.opacity:this.layer.opacity:this.replacesTerrain?this.view.map.ground.opacity:1}get opaque(){return this._groundTransparencyMode===0}get invisible(){return this._groundTransparencyMode===3}get _groundTransparencyMode(){return(has(`enable-feature:im-as-ground`)?!this.usedAsGround:!this._replacesTerrain)?0:Ve(this.fullOpacity,this.view.overlayManager.renderer.isEmpty)}get _renderOpacity(){switch(this._groundTransparencyMode){case 3:return 0;case 2:return X;default:return this.fullOpacity}}get hasModifications(){return this._modifications&&this._modifications.length>0}_opacityChange(){let e=this._renderOpacity,t=this._groundTransparencyMode;this.forEachComponentObject(n=>this._collection.updateObjectOpacity(n,e,t))}_getElevationContext(){return this.replacesTerrain?0:has(`enable-feature:im-as-ground`)?this.usedAsGround?1:2:1}_groundUsageChanged(){let e=this._getElevationContext();this.view.elevationProvider.unregister(this._elevationProvider),this.view.elevationProvider.register(e,this._elevationProvider),this._intersectionHandler.isGround=!has(`enable-feature:im-as-ground`)||this.usedAsGround,this._intersectionHandler.slicePlaneEnabled=this.slicePlaneEnabled&&!this.replacesTerrain,this.view.overlayManager.unregisterDrapeTarget(this),this.view.overlayManager.registerDrapeTarget(this),this._loadModifications();let t=has(`enable-feature:im-as-ground`)?this.usedAsGround:this.replacesTerrain,n=this._renderOpacity,r=this._groundTransparencyMode;this.forEachComponentObject(e=>e.updateMaterial({isGround:t,opacity:n,groundTransparencyMode:r}))}_cameraChanged(){if(this.freeze)return;let e=this._frustum;e.update(this.view.state.contentCamera);let t=this._visibleObjects,n=!1;this._loadedObjects.forEach(r=>{let i=r.obb?.intersectsFrustum(e)??!1;i!==r.isVisible&&(r.isVisible=i,i?t.add(r):t.delete(r),r.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,i)),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(i,r.elevationRange))}),n&&this._setVisibleElevationRangeDirty()}intersect(e,t,n,r){this._intersectionHandler.intersectRay(e,t,n,r,null,!1)}get ready(){return!this.replacesTerrain||!!this._wasm?.isTerrainReady}_modificationsChanged(){let e=this.useEsriCrs?this.layer.supportedSpatialReferences[1]:this.layer.supportedSpatialReferences[0],t=q(this._layerClippingArea,this._modifications,e,this.view.state.isGlobal);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){let e=this.layer.spatialReference,t=pe();this._layerClippingArea=Re(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=d(()=>{this.emit(`visible-geometry-changed`),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.replacesTerrain),this.forEachComponentObject(t=>t.updateMaterial({slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,K(e))}get _wasm(){return De(this.view)}_queryElevation(e,t){return this.destroying||this.destroyed?Promise.reject(o()):this._wasm?.queryElevation(this,e,t)??Promise.reject(o())}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get useEsriCrs(){return this._useEsriCrs}get visibleAtCurrentScale(){return this.replacesTerrain||he(this.layer.effectiveScaleRange,this.view.scale)}canResume(){let e=this.layer&&`effectiveScaleRange`in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.replacesTerrain||N(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,n=0,r=0,i=0,a=0;return this._lyrHandleToObjects.forEach(o=>{o.isLoaded?(e+=o.textureMemoryUsage,t+=o.vboMemoryUsage,i++):(n+=o.textureMemoryUsage,r+=o.vboMemoryUsage,a++)}),new we(this.usedMemory,i,a,$(t),$(e),$(r),$(n))}_canProjectWithoutEngine(){if(this.view.state.viewingMode===1||P(this.view.renderSpatialReference)||F(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&I(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(this.layer.esriCrsSpatialReference.vcsWkid===115700)return!1;let e=be(this.layer.esriCrsSpatialReference);if(!e){let t=this.layer.esriCrsSpatialReference,n=L(t),r=`meters`;!n&&t.wkid&&t.wkid!==-1&&(r=g(z.units[z[t.wkid]])),r&&(e=new le({heightModel:`gravity-related-height`,heightUnit:r}))}let t=this.view.heightModelInfo;return this._useEsriCrs=me(e,t,!1)===0,this._useEsriCrs&&(e&&(this._metersPerVCSUnit=_(1,e.heightUnit,`meters`)),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return K(this.layer.elevationInfo)}get elevationRange(){return this._intersectionHandler?.elevationRange}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){let e=new Le;this._visibleObjects.size===0?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this._forEachRelevantVisibleTile(t=>e.expandElevationRange(t.elevationRange)),e.minElevation===1/0&&e.setElevationRangeValues(0,0));let t=this._get(`visibleElevationRange`);return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange(`visibleElevationRange`)}_forEachRelevantVisibleTile(e){let{view:t}=this,{spatialReference:n}=t,r=n.isWGS84||n.isWebMercator||R(n)||oe(n)||se(n);if(this.view.state.isGlobal||!r)return this.forEachVisibleTile(e);let i=M(n).radius,{eye:a,viewForward:o,near:s}=t.state.contentCamera,c=E(A(),o),l=Math.max(a[2],500),u=l+i,d=Math.sqrt(u**2-i**2),f=Math.abs(Math.atan2(d,i))*i,p=l>.5*i?.5*Math.PI*i:f,m=A();this.forEachVisibleTile(t=>{let{mbsRadius:n,mbsCenter:r}=t;if(n<0)return;D(m,r,a);let i=O(m,c);Math.abs(i)<p&&i+n>s&&i-n<p&&e(t)})}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(let t of this._visibleObjects)e(t)}forEachTile(e){for(let t of this._loadedObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(let{componentObjects:n}of e)for(let e of n)t(e)}get drapeTargetType(){return has(`enable-feature:im-as-ground`)?+!this.usedAsGround:+!this.replacesTerrain}isUpdating(){let e=this._wasm;return!this.freeze&&this._wasmLayerId>=0&&e!=null&&e.isUpdating(this._wasmLayerId)}get readyToRun(){return!!this._frameTask?.readyToRun}runTask(e){this._frameTask.processQueue(e)}updatingFlagChanged(){this.notifyChange(`updating`)}async createRenderable(e){if(this.destroyed||this.destroying)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy`);let{entity3d:t}=e;if(!xe(t))throw Error(`entity3D not valid`);let n=new Map,r;try{r=this._createPrimitiveTextureBundles(t,n)}catch(e){throw n.forEach(e=>this._stage?.removeTexture(e)),e}let i=null;try{if(i=await this._createRenderableMain(t,r),this.destroyed)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderable aborted due to destroyed instance`);let{tileObb:a,componentObjects:o,elevationRange:s}=i,c=0,l=0,u=0;for(let e of o){let{texture:t,textureMetallicRoughness:n,textureEmissive:r,textureOcclusion:i,textureNormal:a}=e.renderable.drawParameters;c+=(t?.usedMemory??0)+(n?.usedMemory??0)+(r?.usedMemory??0)+(i?.usedMemory??0)+(a?.usedMemory??0),l+=this._collection.getObjectGPUMemoryUsage(e),u+=e.intersectionGeometry.usedMemory}let d=Array.from(n.values()),f=new et(e.handle,o,d,u,l,c,a,e.stableNodeId,e.nodeDepth,s);return this._lyrHandleToObjects.set(e.handle,f),()=>{this._memCache.put(W(f.handle),f);let{usedMemory:e}=f;return this._cacheMemory+=e,{memUsageBytes:e}}}catch(e){throw r.forEach(e=>e.cleanup()),i?.componentObjects.forEach(e=>this._collection.destroyObject(e)),n.forEach(e=>this._stage?.removeTexture(e)),e}}_createPrimitiveTextureBundles(e,t){let n=[];try{let r=e.desc.geometry;for(let i of e.validPrimitiveIndices){let a=r.prims[i].materialId,o=e.desc.materials?.materials&&a!=null&&a!==U?e.desc.materials.materials[a]:null,s=Promise.resolve(nt),c=null,l=null,u=null,d=null,f=null;if(o){let n=o.lightingModel===`Pbr`;c=this._getTexture(o.baseColorTex,e,t),l=n?this._getTexture(o.metalTex,e,t):null,u=n?this._getTexture(o.emissiveTex,e,t):null,d=n?this._getTexture(o.occlusionTex,e,t):null,f=n?this._getTexture(o.normalTex,e,t):null;let r=[c,l,u,d,f].map(e=>e?.loadPromise??null);s=Promise.all(r)}n.push(new rt(s,c,l,u,d,f))}}catch(e){throw n.forEach(e=>e.cleanup()),e}return n}async _createRenderableMain(e,t){if(this.destroyed||this.destroying)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderableMain called after destroy`);let n=[],r=e.desc,i=j(...e.origin),a=this.view.groundView.spatialReference,o=this.view.state.isGlobal,s=C;if(o){let e=w();ue(ce,i,e,a),s=b(S(),e)}let c=tt(r.obb),l=o?M(this.view.spatialReference).radius:0,u=o?Math.hypot(c.centerX,c.centerY,c.centerZ)-l:c.centerZ,d=o?Math.max(-l,u-c.radius):u-c.radius,f=u+c.radius,p=[];try{let u=-1;for(let n of e.validPrimitiveIndices){u+=1;let i=r.geometry.prims[n],a=t[u];if(this._dbgFlags.has(2)&&this._dbg(2,JSON.stringify(i)),Ae[i.ptype]==null){this._dbg(2,`[Unsupported Feature] Unsupported primitive mode (`+i.ptype+`). Skipping primitive.`),a.cleanup();continue}let{positionView:o,normalsData:s,colorView:c,texCoord0Data:l,indicesView:d}=this._getBufferViews(i,e);if(o==null||d==null){a.cleanup();continue}let f=o.count,m=(e,t)=>e!=null&&e!==f?(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1):!0;!m(l==null?void 0:l.length/2,`numTexcoord`)||!m(c?.count,`numColors`)||!m(s?.length,`normals`)?a.cleanup():p.push({componentIndex:u,positionView:o,indicesView:d,texCoord0Data:l,colorView:c,normalsData:s})}let m=s!==C,h=m?x(S(),s)??C:C,{vertexProcessingOutputs:g,obbHalfSizeAccumulator:_,elevationRange:v}=await this._workerHandle.processTiles3DVertices(p,i,l,o,s,c,this._imVertexNormals&&!this.usedAsGround);if(this.destroyed)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance`);let y=r.materials;if(await Promise.all(t.map(e=>e.materialPromise)),this.destroyed)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance`);g.length>0&&c.setHalfSize(_);for(let o of g){let{componentIndex:s,positionView:l,indicesView:u,layout:d,textureCoordinateType:f,interleavedVertexData:p,indices:g}=o,_=e.validPrimitiveIndices[s],v=r.geometry.prims[_],b=t[s],x=c.clone(),S=Be(d),C=new Uint32Array([0,u.typedBuffer.length]),w=new He(S,this._imShading?2:0,f,m?2:0),T=new Ue({interleavedVertexData:p,vertexCount:p.byteLength/S[0].stride,indexData:g},{positions:l.typedBuffer,indices:u.typedBuffer},C,w),E=this.view.renderSpatialReference,D=A(),O=[1,1,1];de(i,E,O,a)||this._dbg(3,`Unsupported coordinate system for IM overlay`),fe(i,E,D,a);let k=this._createComponentMaterialInitParameters(y,v.materialId,b);k.baseColorTexture||this._dbg(3,`No colour texture 1`);let j=this._collection.createObject({toMapSpace:re(D[0],D[1],O[0],O[1]),transform:new We(i,h),obb:x,geometry:T,elevationAlignable:!1},k);n.push(j)}return v.minElevation=Math.max(v.minElevation,d),v.maxElevation=Math.min(v.maxElevation,f),{tileObb:c,componentObjects:n,elevationRange:v}}catch(e){throw n.forEach(e=>this._collection.destroyObject(e)),e}}_createComponentMaterialInitParameters(e,t,n){let r=e?.materials!=null&&t!=null&&t!==U?e.materials[t]:null,i=1,a=r?.baseColorTex?.imageId;if(a!=null&&e&&Array.isArray(e.images)&&a>=0&&a<e.images.length){let t=e.images[a];t.alpha&&(i=je[t.alpha])}let o=(r==null?`Unlit`:r.lightingModel)===`Pbr`,s=ae,c=X,l=!1,u=2,d=ne(0,0,0),f=ee(Je),p=n.baseColorTexture,m=n.metallicRoughnessTexture,h=n.emissionTexture,g=n.occlusionTexture,_=n.normalTexture;return r&&(s=ie(r.baseColorFactor),c=r.alphaCutoff??X,o&&(k(f,r.metallicFactor,r.roughnessFactor,0),r.emissiveFactor&&(d=r.emissiveFactor)),l=r.isDoubleSided,u=Me[r.faceCulling??`NotSet`]),{isIntegratedMesh:!0,baseColor:s,textureAlphaCutoff:c,mrrFactors:f,baseColorTexture:p,metallicRoughnessTexture:m,normalTexture:_,occlusionTexture:g,emissionTexture:h,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:i,doubleSided:l,cullFace:u,isGround:has(`enable-feature:im-as-ground`)?this.usedAsGround:this.replacesTerrain,groundTransparencyMode:this._groundTransparencyMode,emissiveBaseColor:d,usePBR:o,slicePlaneEnabled:this.slicePlaneEnabled,opacity:this._renderOpacity,polygonOffset:0,ellipsoidMode:1,applySSAO:this._applySSAO}}freeRenderable(e){let t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._intersectionHandler.removeTile(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){let t=W(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,n){if(this.destroyed||this.destroying)return;let r=this._frustum,i=[],a=!1,o=!1;for(let s=0;s<n;++s){if(!t[s])continue;let n=e[s],c=this._lyrHandleToObjects.get(n);if(c){if(c.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${c.stableNodeId}`);continue}a=!0,c.isLoaded=!0,this._loadedObjects.add(c),this._intersectionHandler.addTile(c),this._usedMemory+=c.usedMemory,this._cacheMemory-=c.usedMemory;let e=c.obb?.intersectsFrustum(r)??!0;c.isVisible=e,e&&(this._visibleObjects.add(c),o||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,c.elevationRange)),i.push(c.obb),c.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(W(n))}else this._dbg(3,`Tried to mark Non existent object ${n} as loaded`)}for(let r=0;r<n;++r){let n=e[r];if(t[r])continue;let a=this._lyrHandleToObjects.get(n);if(a){if(!a.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${a.stableNodeId}`);continue}let e=a.isVisible;this._visibleObjects.delete(a),a.isVisible=!1,a.isLoaded=!1,this._loadedObjects.delete(a),this._intersectionHandler.removeTile(a),e&&(this._visibleGeometryChanged(),o||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,a.elevationRange)),this._usedMemory-=a.usedMemory,this._cacheMemory+=a.usedMemory,i.push(a.obb),a.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(W(n),a)}else this._dbg(3,`Tried to mark Non existent object ${n} as not loaded`)}a&&this._visibleGeometryChanged(),i.length>0&&this._elevationProvider.notifyObjectsChanged(i),o&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){let{visibleElevationRange:n}=this,{minElevation:r,maxElevation:i}=t;return e?r<n.minElevation||i>n.maxElevation:r===n.minElevation||i===n.maxElevation}_getTexture(e,t,n){let r=e&&t.desc.materials?.images?.[e.imageId];if(!r||!G(r.data))return null;let i=t.assets[r.data];if(!i||i.byteCount<1||i.dataType!==`U8`)return null;let a=n.get(r)??this._createTexture(e,r,i,n);return a?new Ge(this._stage.renderView.textures,a.id):null}_createTexture(e,n,r,i){let a=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,o=n.mipCount?!0:a>1,s=Ne[e.wrapMode??`None`],c=n.alpha?6408:6407,l=new Uint8Array(r.data.buffer,0,r.byteCount),u=null,d=null;switch(n.format){case`Raw`:if(n.pixelFormat===`R8`)u=l,c=6403,d=``;else if(n.pixelFormat===`Rg8`||n.pixelFormat===`Ga8`)u=l,c=33319,d=``;else if(n.pixelFormat===`Rgb8`)u=l,c=6407,d=``;else if(n.pixelFormat===`Rgba8`)u=l,c=6408,d=``;else return t.getLogger(this).error(`Raw texture pixel format ${n.pixelFormat} not supported`),null;break;case`Dxt1`:u=l,c=6407,d=`image/vnd-ms.dds`;break;case`Dxt5`:u=l,c=6408,d=`image/vnd-ms.dds`;break;case`Basis`:u=l,c=6407,d=`image/ktx2`;break;case`Etc1`:u=l,c=6407,d=`image/ktx`;break;default:return t.getLogger(this).error(`${n.format} texture not supported`),null}if(u&&d!=null){let e=Qe(c,d,n.format),t=new Ke(u,{mipmap:o,maxAnisotropy:a,encoding:d,wrap:s,pixelFormat:c,internalFormat:e??void 0,immutable:e!=null,noUnpackFlip:!0,width:n.mip0Width,height:n.mip0Height});return this._stage.addTexture(t),i.set(n,t),t}return null}_getBufferViews(e,t){let n,r,i,a;for(let o=0;o<e.atrbs.length;o++){let s=e.atrbs[o],c=t.assets[s.assetId];if(!c)continue;let l=c.data.buffer,u=c.byteCount;try{switch(s.sem){case`Position`:c.ncomp!==3||c.dataType!==`F32`||!p(c.data)?this._dbg(3,`[Unsupported Feature] Unsupported view for Position (`+c+`)`):n=new B(l,0,void 0,u);break;case`Normal`:if(c.ncomp!==3||c.dataType!==`F32`||!p(c.data))this._dbg(3,`[Unsupported Feature] Unsupported view for Normal (`+c+`)`);else{let e=new B(l,0,void 0,u);a=new Uint32Array(e.count),qe(e.typedBuffer,new Int16Array(a.buffer,a.byteOffset,a.length*2))}break;case`TexCoord`:c.ncomp!==2||c.dataType!==`F32`||!p(c.data)?this._dbg(3,`[Unsupported Feature] Unsupported view for Texcoord (`+c+`)`):i===void 0&&(i=new ve(l,0,void 0,u).typedBuffer);break;case`Color`:c.dataType===`U8`&&f(c.data)&&(c.ncomp===4?r=new ge(l,0,void 0,u):c.ncomp===3&&(r=new _e(l,0,void 0,u))),r??this._dbg(3,`[Unsupported Feature] Unsupported view for Color (`+c+`)`);break;case`FeatureIndex`:break;default:this._dbg(2,`[Unsupported Feature] Unsupported semantic (`+s.sem+`). Skipping vertex attribute.`)}}catch(e){this._dbg(2,`Error Creating buffer (`+e+`). Skipping vertex attribute.`)}}let o,s=!1;if(G(e.index)){let n=t.assets[e.index];if(!n)s=!0;else{let e=n.byteCount;switch(n.dataType){case`U16`:n.ncomp===1&&h(n.data)&&(o=new H(n.data.buffer,0,void 0,e));break;case`U32`:n.ncomp===1&&m(n.data)&&(o=new V(n.data.buffer,0,void 0,e))}s=!o}}if(!s&&o==null&&n!=null){let e=n.count;o=o=e<65535?new H(new Uint16Array(e).buffer):new V(new Uint32Array(e).buffer);for(let t=0;t<e;t++)o.set(t,t)}return{positionView:n,colorView:r,texCoord0Data:i,indicesView:o,normalsData:a}}_loadModifications(){if(this.removeHandles(`modifications`),this.layer.modifications==null){this._modifications=[];return}let e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.usedAsGround&&e.type!==`replace`)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info(`Ground layers only support replace modifications. Other modification types have been ignored.`)},s),`modifications`)}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,n){this._dbgFlags.has(e)&&(e===3?t.getLogger(this).error(n):t.getLogger(this).warn(n))}};e([v()],Q.prototype,`freeze`,void 0),e([v()],Q.prototype,`fullOpacity`,null),e([v()],Q.prototype,`opaque`,null),e([v()],Q.prototype,`invisible`,null),e([v({readOnly:!0})],Q.prototype,`ready`,null),e([v({type:[ye]})],Q.prototype,`_modifications`,void 0),e([v()],Q.prototype,`_visibleGeometryChangedSchedulerHandle`,void 0),e([v()],Q.prototype,`layer`,void 0),e([v({readOnly:!0})],Q.prototype,`visibleAtCurrentScale`,null),e([v({readOnly:!0})],Q.prototype,`_collection`,null),e([v()],Q.prototype,`elevationOffset`,null),e([v({readOnly:!0})],Q.prototype,`visibleElevationRange`,null),e([v()],Q.prototype,`fullExtentInLocalViewSpatialReference`,void 0),Q=e([y(`esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D`)],Q);const $e=Q;class et{constructor(e,t,n,r,i,a,o,s,c,l){this.handle=e,this.componentObjects=t,this.textures=n,this.cpuMemoryUsage=r,this.vboMemoryUsage=i,this.textureMemoryUsage=a,this.obb=o,this.stableNodeId=s,this.nodeDepth=c,this.elevationRange=l,this.bvhIntersectionGeneration=0,this.isLoaded=!1,this.isVisible=!1;let u=A();o?.getCenter(u),this._obbCenterX=u[0],this._obbCenterY=u[1],this._obbCenterZ=u[2];let d=o?.radius??-1;this._obbRadius=d,this._obbRadiusSquared=d*d,this._obbShortestHalfsize=o?Math.min(o.halfSizeX,o.halfSizeY,o.halfSizeZ):0,this._mbsCenter=o?o.getCenter(A()):te}get usedMemory(){return this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this._mbsCenter}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;let{_obbCenterX:n,_obbCenterY:r,_obbCenterZ:i}=this,a=n-e[0],o=r-e[1],s=i-e[2],c=a*t[0]+o*t[1]+s*t[2];return a*a+o*o+s*s-c*c<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){let t=this._obbRadius;if(t<0)return!0;let n=e.center,r=e.radius,i=t+r,a=this._obbCenterX-n[0];if(a>i)return!1;let o=this._obbCenterY-n[1];if(o>i)return!1;let s=this._obbCenterZ-n[2];if(s>i)return!1;let c=a*a+o*o+s*s;if(c>i*i)return!1;if(c<=(this._obbShortestHalfsize+r)**2)return!0;let l=r-t;return l>0&&c<=l*l?!0:this.obb?.intersectSphere(e)??!0}}function $(e){return Math.round(e/1048.576)/1e3}function tt(e){return new ze(e.center,e.halfSize,T(...e.quaternion))}const nt=[];class rt{constructor(e,t,n,r,i,a){this.materialPromise=e,this.baseColorTexture=t,this.metallicRoughnessTexture=n,this.emissionTexture=r,this.occlusionTexture=i,this.normalTexture=a}cleanup(){this.baseColorTexture?.dispose(),this.metallicRoughnessTexture?.dispose(),this.emissionTexture?.dispose(),this.occlusionTexture?.dispose(),this.normalTexture?.dispose()}}export{$e as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{copy as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as n,add as r,subtract as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as a,ZEROS as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as s}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as c}from"../../../../geometry/projection/projectBuffer.js";import{BufferViewVec3f as l}from"../../../../geometry/support/buffer/BufferView.js";import{SampleElevationInfo as
|
|
2
|
+
import{copy as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as n,add as r,subtract as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as a,ZEROS as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as s}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as c}from"../../../../geometry/projection/projectBuffer.js";import{BufferViewVec3f as l,BufferViewVec4f16 as u}from"../../../../geometry/support/buffer/BufferView.js";import{SampleElevationInfo as d,updateBufferPointGroundDistance as f,computePointTransformation as p,applyBufferPointTransformation as m}from"./elevationAlignmentUtils.js";import{debugFlags as h}from"../../support/debugFlags.js";import{SamplePosition as g}from"../../support/ElevationProvider.js";import{updateVertexFieldVec3f as _,updateObjectVertexField as v}from"../../webgl-engine/lib/bufferGeometryUtils.js";import{isGeometryWithMapPositions as y}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{assert as b}from"../../webgl-engine/lib/Util.js";import{writeLineMarkerPositions as x}from"../../webgl-engine/materials/internal/lineMarkerBufferUtils.js";import{getRibbonLineBufferPositions as S,fillRibbonLinePadding as C,updateRibbonLineDistances as w}from"../../webgl-engine/materials/internal/ribbonLineBufferUtils.js";function T(e,t,a,o,s,d){let f=N/s.unitInMeters,p=0,m=0;for(let{line:_,marker:v,wireframe:y}of d){let{mapPositions:d,material:T,localOrigin:E}=_,D=T.parameters,O=_.getMutableStorageField(`position`,l),k=S(O,!!D.isClosed);if(d==null||k.count===0)continue;let A=new g(d,a),j=0,M=!h.ENABLE_OPTIMIZATIONS;for(let e=0;e<k.count;e++,A.offset+=3)o(A,z),t.requiresSampledElevationInfo&&(j+=z.sampledElevation),k.getVec(e,I),h.ENABLE_OPTIMIZATIONS?(r(P,I,E.vec3),s.setAltitude(P,z.z)):(n(P,A.array[A.offset],A.array[A.offset+1],z.z),c(P,a,0,P,s.spatialReference,0,1)),i(P,P,E.vec3),M||=V(I,P[0],P[1],P[2],f),k.setVec(e,P);j/=k.count,C(_.buffers.storage,k.count,!!D.isClosed&&k.count>2),w(_,!!D.isClosed),M&&e.geometryVertexAttributeUpdated(_,`position`),p+=j,m++,y!=null&&(b(y.localOrigin===E,`Line outputs must use the same local origin`),y.getMutableStorageField(`position`,l),y.buffers.storage.copyFrom(_.buffers.storage),M&&e.geometryVertexAttributeUpdated(y,`position`),p+=j,m++),v!=null&&(b(v.localOrigin===E,`Line outputs must use the same local origin`),x(k,v.material.parameters,{position:v.getMutableVertexField(`position`,l),previousDelta:v.getMutableVertexField(`previousDelta`,u),offset:0}),M&&e.geometryVertexAttributeUpdated(v,`position`),p+=j,m++)}return m===0?0:p/m}function E(e,t,n,r,i){let a=e.stageObject,o=a.geometries,s=0;for(let e of o){if(!y(e))continue;let{update:o,averageGeometrySampledElevation:c}=B(e,t,n,r,i);s+=c,o&&a.geometryVertexAttributeUpdated(e,`position`)}return s/o.length}function D(e,t,a,o,s){let u=t.requiresSampledElevationInfo,{geometries:d}=e,f=N/s.unitInMeters,p=0;if(d.length===0)return 0;for(let t of d){let d=t.buffers.vertex.getField(`position`,l);if(t.mapPositions==null||d.count===0)continue;let m=t.localOrigin.vec3,v=new g(t.mapPositions,a),y=0,b=!1;for(let e=0;e<d.count;e++,v.offset+=3)o(v,z),u&&(y+=z.sampledElevation),d.getVec(e,I),h.ENABLE_OPTIMIZATIONS?(r(P,I,m),s.setAltitude(P,z.z)):(n(P,v.array[v.offset],v.array[v.offset+1],z.z),c(P,a,0,P,s.spatialReference,0,1)),i(P,P,m),(!h.ENABLE_OPTIMIZATIONS||V(I,P[0],P[1],P[2],f))&&(b=_(t,`position`,e,P)||b);b&&e.geometryVertexAttributeUpdated(t,`position`),p+=y/d.count}return p/d.length}function O(t,r,i,a,o,c){let l=t.stageObject,u=r.centerInElevationSR;a(u,z);let d=r.requiresSampledElevationInfo?z.sampledElevation:0,f=e(j,c??l.transformation),p=n(R,f[12],f[13],f[14]);h.ENABLE_OPTIMIZATIONS?o.setAltitudeOfTransformation(z.z,f):(P[0]=u[0],P[1]=u[1],P[2]=z.z,s(i,P,f,o.spatialReference)&&(c?e(c,f):l.transformation=f));let m=N/o.unitInMeters;return V(p,f[12],f[13],f[14],m)&&(c?e(c,f):l.transformation=f),d}function k(e,t,n,r,i){return A(e,t,n,r,i,o)}function A(e,t,a,o,s,c){let u=t.centerInElevationSR;if(o(u,z),f(e,z.verticalDistanceToGround),h.ENABLE_OPTIMIZATIONS){let t=N/s.unitInMeters;for(let n of e.geometries){let a=n.buffers.vertex.getField(`position`,l),o=n.localOrigin.vec3;a.getVec(0,I),r(P,I,o),i(P,P,c),s.setAltitude(P,z.z),r(P,P,c),i(P,P,o),V(I,P[0],P[1],P[2],t)&&v(e,_,n,`position`,0,P)}}else n(P,u[0],u[1],z.z),p(P,a,s,j)&&(j[12]+=c[0],j[13]+=c[1],j[14]+=c[2],m(e,j));return z.sampledElevation}const j=t();function M(e,t,r,i,a){let o=e.graphics3DSymbolLayer.lodRenderer;if(o==null)return 0;let c=t.centerInElevationSR;i(c,z);let l=t.mode===`absolute-height`?0:z.sampledElevation,u=o.instanceData,d=e.instanceIndex,f=L;u.getGlobalTransform(d,f);let p=n(R,f[12],f[13],f[14]);h.ENABLE_OPTIMIZATIONS?a.setAltitudeOfTransformation(z.z,f):(P[0]=c[0],P[1]=c[1],P[2]=z.z,s(r,P,f,a.spatialReference)&&u.setGlobalTransform(d,f));let m=N/a.unitInMeters;return(!h.ENABLE_OPTIMIZATIONS||V(p,f[12],f[13],f[14],m))&&u.setGlobalTransform(d,f),l}const N=.01,P=a(),F=a(),I=a(),L=t(),R=a(),z=new d;function B(e,t,n,r,i){let a=!1,o=e.transformation,s=t.requiresSampledElevationInfo;F[0]=o[12],F[1]=o[13],F[2]=o[14],e.invalidateBoundingInfo();let l=e.getMutableAttribute(`position`),u=l.data,d=l.size,f=u.length/d,p=new g(e.mapPositions,n),m=0,_=0;for(let e=0;e<f;e++){if(I[0]=u[m],I[1]=u[m+1],I[2]=u[m+2],r(p,z),s&&(_+=z.sampledElevation),h.ENABLE_OPTIMIZATIONS){P[0]=u[m]+F[0],P[1]=u[m+1]+F[1],P[2]=u[m+2]+F[2],i.setAltitude(P,z.z),u[m]=P[0]-F[0],u[m+1]=P[1]-F[1],u[m+2]=P[2]-F[2];let e=N/i.unitInMeters;V(I,u[m],u[m+1],u[m+2],e)&&(a=!0)}else u[m]=p.array[p.offset],u[m+1]=p.array[p.offset+1],u[m+2]=z.z,c(u,n,m,u,i.spatialReference,m,1),u[m]-=F[0],u[m+1]-=F[1],u[m+2]-=F[2],a=!0;m+=d,p.offset+=3}return _/=f,{update:a,averageGeometrySampledElevation:_}}function V(e,t,n,r,i){return Math.abs(e[0]-t)>=i||Math.abs(e[1]-n)>=i||Math.abs(e[2]-r)>=i}export{T as perBufferLineElevationAligner,k as perBufferPointElevationAligner,D as perBufferVertexElevationAligner,M as perLodInstanceElevationAligner,O as perObjectElevationAligner,A as perTranslatedBufferPointElevationAligner,E as perVertexElevationAligner};
|