@arcgis/core 6.0.0-next.48 → 6.0.0-next.49
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/Ground.js +1 -1
- package/analysis/AreaMeasurementAnalysis.d.ts +12 -10
- package/analysis/AreaMeasurementAnalysis.js +1 -1
- package/applications/Components/formatUtils.d.ts +3 -2
- package/applications/MapViewer/templateUtils.d.ts +4 -1
- package/applications/SceneViewer/sceneViewerUtils.d.ts +12 -1
- package/applications/SceneViewer/sceneViewerUtils.js +1 -1
- package/arcade/featureset/actions/SpatialFilter.js +1 -1
- package/arcade/functions/featuresetgeom.js +1 -1
- package/arcade/functions/geomasync.js +1 -1
- package/arcade/geometry/operatorsWorker.js +1 -1
- package/arcade/geometry/operatorsWorkerConnection.js +1 -1
- package/arcgisGlobal.d.ts +4 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/063cc462524646cd45e8.js +1 -0
- package/assets/esri/core/workers/chunks/119c62e9c9c7440a6129.js +1 -0
- package/assets/esri/core/workers/chunks/14c04fde8d33b739b415.js +1 -0
- package/assets/esri/core/workers/chunks/27a91b52d1bee92b6f20.js +1 -0
- package/assets/esri/core/workers/chunks/31eb09e96f31bced71ad.js +1 -0
- package/assets/esri/core/workers/chunks/{056a815273653271bf75.js → 3236e18921955450fc0d.js} +5 -5
- package/assets/esri/core/workers/chunks/3ce7120056040af3bab1.js +1 -0
- package/assets/esri/core/workers/chunks/435dacf493aec07ff6e3.js +1 -0
- package/assets/esri/core/workers/chunks/4c26d6408ee7a3b9d163.js +1 -0
- package/assets/esri/core/workers/chunks/{73bf76a3a0418edb26a5.js → 506954fb374ea528d020.js} +1 -1
- package/assets/esri/core/workers/chunks/55db28616f810ca063b7.js +1 -0
- package/assets/esri/core/workers/chunks/59ae5bd0ee1bae7a9fb3.js +1 -0
- package/assets/esri/core/workers/chunks/630a36c4817f33f4cad2.js +1 -0
- package/assets/esri/core/workers/chunks/6779afc2d6ee46c301b5.js +1 -0
- package/assets/esri/core/workers/chunks/6a509ffb4852d694a097.js +1 -0
- package/assets/esri/core/workers/chunks/6d25a7071fceb707858a.js +1 -0
- package/assets/esri/core/workers/chunks/7a97eec9823941fd210f.js +29 -0
- package/assets/esri/core/workers/chunks/82bbf0c5e18fc1c795f4.js +1 -0
- package/assets/esri/core/workers/chunks/91019e9dff63107f8cb4.js +1 -0
- package/assets/esri/core/workers/chunks/{1345413ec0b4128849b1.js → 954f9854a9bf4a852b81.js} +1 -1
- package/assets/esri/core/workers/chunks/9846abf2d3991a15b2b5.js +1 -0
- package/assets/esri/core/workers/chunks/9f74b3f0f453bc957e3a.js +1 -0
- package/assets/esri/core/workers/chunks/a0e2a1c6f37454547193.js +1 -0
- package/assets/esri/core/workers/chunks/a1c45e8f5bba471b3905.js +1 -0
- package/assets/esri/core/workers/chunks/a2825285d46f8cd5d814.js +1 -0
- package/assets/esri/core/workers/chunks/{d4f6be8290ad0243e1b8.js → b511b5c68defefccde0b.js} +1 -1
- package/assets/esri/core/workers/chunks/bf81b3670b5323621e2d.js +1 -0
- package/assets/esri/core/workers/chunks/c4794d692934098988e7.js +1 -0
- package/assets/esri/core/workers/chunks/d0900a901197948bd7df.js +1 -0
- package/assets/esri/core/workers/chunks/d2ed93bbfa98395bbed7.js +1 -0
- package/assets/esri/core/workers/chunks/d486a8a61ff993f8202a.js +1 -0
- package/assets/esri/core/workers/chunks/e06036392a982dbf3ae3.js +1 -0
- package/assets/esri/core/workers/chunks/{773ba0909ccd3a034c31.js → ed1db6571b0c61fe4f91.js} +1 -1
- package/chunks/BlendWeights.glsl.js +4 -5
- package/chunks/Blur.glsl.js +10 -7
- package/chunks/BlurEmission.glsl.js +27 -7
- package/chunks/Clouds.glsl.js +2 -2
- package/chunks/Component.glsl.js +1 -1
- package/chunks/EdgeDetect.glsl.js +1 -1
- package/chunks/EdgeShader.glsl.js +1 -1
- package/chunks/EmissionComposite.glsl.js +2 -2
- package/chunks/Fog.glsl.js +4 -4
- package/chunks/GlobalIlluminationBlur.glsl.js +1 -1
- package/chunks/HighlightSharpApply.glsl.js +4 -1
- package/chunks/LineMarker.glsl.js +4 -4
- package/chunks/Magnifier.glsl.js +1 -1
- package/chunks/NoiseTextureAtlas.glsl.js +3 -3
- package/chunks/Pattern.glsl.js +35 -32
- package/chunks/{ChapmanAtmosphere.glsl.js → RealisticAtmosphere.glsl.js} +18 -9
- package/chunks/RealisticAtmosphereCompositing.glsl.js +35 -0
- package/chunks/SSAO.glsl.js +2 -2
- package/chunks/SimpleAtmosphere.glsl.js +1 -1
- package/config.js +1 -1
- package/core/accessorSupport/ObservableBase.js +1 -1
- package/core/accessorSupport/tracking/ObservationHandle.js +1 -1
- package/core/accessorSupport/tracking/SimpleObservable.js +1 -1
- package/core/accessorSupport/tracking/SimpleTrackingTarget.js +1 -1
- package/core/accessorSupport/tracking/TrackingTarget.js +1 -1
- package/core/quantity.js +1 -1
- package/core/timeUtils.js +1 -1
- package/geometry/coordinateConversion/CoordinateConversionModel.d.ts +258 -0
- package/geometry/coordinateConversion/CoordinateConversionModel.js +2 -0
- package/geometry/coordinateConversion/support/Conversion.d.ts +73 -0
- package/geometry/coordinateConversion/support/Conversion.js +2 -0
- package/geometry/coordinateConversion/support/Format.d.ts +131 -0
- package/geometry/coordinateConversion/support/Format.js +2 -0
- package/geometry/coordinateConversion/support/coordinateConversionUtils.js +2 -0
- package/geometry/coordinateConversion/support/formatUtils.js +2 -0
- package/geometry/coordinateConversion/types.d.ts +116 -0
- package/kernel.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/IntegratedMeshLayer.js +1 -1
- package/layers/catalog/CatalogFootprintLayer.d.ts +2 -2
- package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
- package/layers/knowledgeGraph/cypherUtils.js +1 -1
- package/layers/mixins/FeatureLayerBase.d.ts +2 -2
- package/layers/raster/formats/Lzw.js +1 -1
- package/layers/raster/formats/TiffDecoder.js +1 -1
- package/layers/raster/formats/tiffParser.js +1 -1
- package/layers/raster/formats/tiffTag.js +1 -1
- package/layers/support/IntegratedMeshSemantics.js +2 -0
- package/layers/support/VideoElement.js +1 -1
- package/legend/ActiveLayerInfo.js +1 -1
- package/package.json +2 -2
- package/symbols/FillSymbol3DLayer.d.ts +1 -4
- package/time/daylightUtils.d.ts +29 -0
- package/time/daylightUtils.js +2 -0
- package/time/timeZoneUtils.js +1 -1
- package/time/types.d.ts +57 -1
- package/views/2d/analysis/AreaMeasurement/AreaMeasurementTool.js +1 -1
- package/views/2d/analysis/AreaMeasurementAnalysisView2D.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
- package/views/2d/layers/GeospatialPDFLayerView2D.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/3d/GroundView3D.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
- package/views/3d/analysis/AreaMeasurementAnalysisView3D.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
- package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementController.js +1 -1
- package/views/3d/interactive/Manipulator3D.js +1 -1
- package/views/3d/interactive/Manipulator3DBase.js +2 -0
- package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbol.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWebStyleSymbol.js +1 -1
- package/views/3d/layers/graphics/SymbolComplexity.js +1 -1
- package/views/3d/layers/graphics/webStyleUtils.js +1 -1
- package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
- package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
- package/views/3d/layers/support/Tiles3DMeshIntersectionHandler.js +1 -1
- package/views/3d/layers/support/patternUtils.js +1 -1
- package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
- package/views/3d/support/GroundAndIMSurface.js +1 -1
- package/views/3d/support/engineContent/line.js +1 -1
- package/views/3d/support/hitTest.js +1 -1
- package/views/3d/support/pointsOfInterest/StableSurfaceCenter.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/PatchGeometryFactory.js +1 -1
- package/views/3d/terrain/PatchRenderDataWaterproofness.js +1 -1
- package/views/3d/terrain/SphericalPatch.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterialInitParameters.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterialRepository.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPass.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceRayMarching.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterColor.glsl.js +6 -4
- package/views/3d/webgl-engine/core/shaderLibrary/util/BlendModes.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/CloudsParallaxShading.glsl.js +10 -9
- package/views/3d/webgl-engine/core/shaderLibrary/util/GaussianSplatUnpacking.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/cameraUniforms.js +1 -1
- package/views/3d/webgl-engine/effects/WeatherFader.js +1 -1
- package/views/3d/webgl-engine/effects/atmosphere/ChapmanApproximation.glsl.js +3 -3
- package/views/3d/webgl-engine/effects/atmosphere/{ChapmanAtmosphere.glsl.js → RealisticAtmosphere.glsl.js} +1 -1
- package/views/3d/webgl-engine/effects/atmosphere/RealisticAtmosphere.js +2 -0
- package/views/3d/webgl-engine/effects/atmosphere/RealisticAtmosphereCompositing.glsl.js +2 -0
- package/views/3d/webgl-engine/effects/atmosphere/RealisticAtmosphereCompositingTechnique.js +2 -0
- package/views/3d/webgl-engine/effects/atmosphere/RealisticAtmosphereTechnique.js +2 -0
- package/views/3d/webgl-engine/effects/fog/Fog.js +1 -1
- package/views/3d/webgl-engine/effects/glow/BlurEmission.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/glow/applyEmissiveGlow.glsl.js +87 -41
- package/views/3d/webgl-engine/effects/precipitation/Precipitation.js +1 -1
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/lib/EmissionComposite.glsl.js +1 -1
- package/views/3d/webgl-engine/lib/EmissionComposite.js +1 -1
- package/views/3d/webgl-engine/lib/ManagedTexture.js +1 -1
- package/views/3d/webgl-engine/lib/Octree.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/lib/intersectorUtilsConversions.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/InstanceOctree.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/shaders/Pattern.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/PatternLayouts.js +1 -1
- package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/PatternTechniqueConfiguration.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/VideoView.js +1 -1
- package/views/interactive/Tooltip.js +1 -1
- package/views/interactive/snapping/RightAngleTriangleSnapper.js +1 -1
- package/views/interactive/snapping/SnappingAlgorithm.js +1 -1
- package/views/interactive/tooltip/content/TooltipContent.js +1 -1
- package/widgets/CoordinateConversion/CoordinateConversionViewModel.d.ts +3 -0
- package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
- package/widgets/CoordinateConversion.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/022565ef98a702ab952f.js +0 -1
- package/assets/esri/core/workers/chunks/163e97987e1f75610009.js +0 -1
- package/assets/esri/core/workers/chunks/1d57b1445afec89a7941.js +0 -1
- package/assets/esri/core/workers/chunks/3654672d772d11484883.js +0 -1
- package/assets/esri/core/workers/chunks/3af0ff5a0b82872aac38.js +0 -1
- package/assets/esri/core/workers/chunks/3b9415dfd7546aeec261.js +0 -1
- package/assets/esri/core/workers/chunks/5109b48666138df14038.js +0 -1
- package/assets/esri/core/workers/chunks/6b73dfc9252b32f1eae2.js +0 -1
- package/assets/esri/core/workers/chunks/6e4698879e7d8fbc4d12.js +0 -1
- package/assets/esri/core/workers/chunks/71295afd21fc5bc5ddbc.js +0 -1
- package/assets/esri/core/workers/chunks/794a9f116c4700bb1210.js +0 -1
- package/assets/esri/core/workers/chunks/8e0ecc7f55dd8bf2cf16.js +0 -1
- package/assets/esri/core/workers/chunks/9dece842ada6278c33ef.js +0 -1
- package/assets/esri/core/workers/chunks/a12e29f2cb78fdaa0753.js +0 -1
- package/assets/esri/core/workers/chunks/b70af9fb974ef9836efd.js +0 -1
- package/assets/esri/core/workers/chunks/c0f2b6a10bcc766318f5.js +0 -1
- package/assets/esri/core/workers/chunks/c248db5e4d92cfb3c4d1.js +0 -1
- package/assets/esri/core/workers/chunks/ce02adb527389b90223d.js +0 -1
- package/assets/esri/core/workers/chunks/d8eea5ffe05c620fac9e.js +0 -1
- package/assets/esri/core/workers/chunks/d997d81d0965c05447d4.js +0 -1
- package/assets/esri/core/workers/chunks/e1645882f54818c4036a.js +0 -1
- package/assets/esri/core/workers/chunks/e44679a0d271c1efb60d.js +0 -1
- package/assets/esri/core/workers/chunks/f11f40017ec97a2a6b5f.js +0 -29
- package/assets/esri/core/workers/chunks/f7f5d8256e63d303cbcb.js +0 -1
- package/assets/esri/core/workers/chunks/f87d5450190896e61ff8.js +0 -1
- package/assets/esri/core/workers/chunks/fdee2255f49b43056e9d.js +0 -1
- package/assets/esri/core/workers/chunks/ff1e614fde01781360fa.js +0 -1
- package/chunks/AtmosphereCompositing.glsl.js +0 -25
- package/views/3d/analysis/ShadowCast/sunlightUtils.js +0 -2
- package/views/3d/webgl-engine/effects/atmosphere/ChapmanAtmosphere.js +0 -2
- package/views/3d/webgl-engine/effects/atmosphere/ChapmanAtmosphereTechnique.js +0 -2
- package/views/3d/webgl-engine/shaders/AtmosphereCompositing.glsl.js +0 -2
- package/views/3d/webgl-engine/shaders/AtmosphereCompositingTechnique.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{EventEmitter as e}from"../../../../core/Evented.js";import{set as t,add as n,scale as r}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{exactEquals as a,copy as o}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as s,clone as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectBuffer as l}from"../../../../geometry/projection/projectBuffer.js";import{expandWithBuffer as u}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as d}from"../../../../geometry/support/DoubleArray.js";import{makeDehydratedPoint as f}from"../../../../layers/graphics/dehydratedPoint.js";import{getGeometryEffectiveElevationMode as p}from"../../../../support/elevationInfoUtils.js";import m from"../../../../symbols/support/ElevationInfo.js";import{EngineVisualElement as h}from"./EngineVisualElement.js";import{LaserlineVisualElement as g}from"./LaserlineVisualElement.js";import{ElevationContext as _}from"../../layers/graphics/ElevationContext.js";import{
|
|
2
|
+
import{EventEmitter as e}from"../../../../core/Evented.js";import{set as t,add as n,scale as r}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{exactEquals as a,copy as o}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as s,clone as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectBuffer as l}from"../../../../geometry/projection/projectBuffer.js";import{expandWithBuffer as u}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as d}from"../../../../geometry/support/DoubleArray.js";import{makeDehydratedPoint as f}from"../../../../layers/graphics/dehydratedPoint.js";import{getGeometryEffectiveElevationMode as p}from"../../../../support/elevationInfoUtils.js";import m from"../../../../symbols/support/ElevationInfo.js";import{EngineVisualElement as h}from"./EngineVisualElement.js";import{LaserlineVisualElement as g}from"./LaserlineVisualElement.js";import{ElevationContext as _}from"../../layers/graphics/ElevationContext.js";import{selectLocalOrigin as v,createBufferGeometry as y}from"../../support/engineContent/line.js";import{geometryToRenderInfoDraped as b,geometryToRenderInfo as x}from"../../support/renderInfoUtils/line.js";import{BufferObject3D as S}from"../../webgl-engine/lib/BufferObject3D.js";import{add as C}from"../../webgl-engine/lib/bufferVectorMath.js";import{RibbonLineMaterial as w}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{getRibbonLinePositions as T}from"../../webgl-engine/materials/internal/ribbonLineBufferUtils.js";class E extends h{constructor(t){super(t),this._attachmentOrigin=f(0,0,0,null),this._attachmentOriginDirty=!0,this.events=new e,this._geometry=null,this._width=1,this._color=s(1,0,1,1),this._innerWidth=0,this._innerColor=s(1,1,1,1),this._stipplePattern=null,this._stippleOffColor=null,this._falloff=0,this._elevationInfo=null,this._laserlineStyle=null,this._laserlineEnabled=!1,this._renderOccluded=8,this._attachmentOrigin.spatialReference=t.view.spatialReference,this._laserline=new g({view:t.view,isDecoration:t.isDecoration}),this.applyProperties(t),this.attached=t.attached??!0}destroy(){this._laserline.destroy(),super.destroy()}createObject3DResourceFactory(e){return{view:e,createObject:()=>new S({geometries:[]}),createResources:e=>this._createObject3DResources(e),destroyResources:D,recreateGeometry:(e,t)=>{e.geometries.length=0,this._recreateGeometry(t,e.material,e.geometries)},forEachMaterial:(e,t)=>t(e.material)}}createDrapedResourceFactory(e){return{view:e,createResources:()=>this._createDrapedResources(),destroyResources:D,recreateGeometry:e=>{e.geometries=this._createBufferGeometriesDraped(e.material),this._attachmentOriginChanged()},forEachMaterial:(e,t)=>t(e.material)}}get _laserlineAttached(){return this.attached&&this.visible&&this._laserlineStyle!=null&&!this.isDraped&&this.laserlineEnabled}onAttachedChange(e){this._laserline.attached=this._laserlineAttached,e&&this._attachmentOriginChanged()}get isDecoration(){return this._isDecoration}set isDecoration(e){this._isDecoration=e,this._updateMaterial()}get geometry(){return this._geometry}set geometry(e){let t=this._isClosed;this._geometry=e,t!==this._isClosed&&this._updateMaterial(),this.recreateGeometry()}get width(){return this._width}set width(e){e!==this._width&&(this._width=e,this._updateMaterial())}get color(){return this._color}set color(e){a(e,this._color)||(o(this._color,e),this._updateMaterial())}get innerWidth(){return this._innerWidth}set innerWidth(e){e!==this._innerWidth&&(this._innerWidth=e,this._updateMaterial())}get innerColor(){return this._innerColor}set innerColor(e){a(e,this._innerColor)||(o(this._innerColor,e),this._updateMaterial())}get stipplePattern(){return this._stipplePattern}set stipplePattern(e){let t=e!=null!=(this._stipplePattern!=null);this._stipplePattern=e,t?this.recreate():this._updateMaterial()}get stippleOffColor(){return this._stippleOffColor}set stippleOffColor(e){e&&this._stippleOffColor&&a(e,this._stippleOffColor)||(this._stippleOffColor=e?c(e):null,this._updateMaterial())}get falloff(){return this._falloff}set falloff(e){e!==this._falloff&&(this._falloff=e,this._updateMaterial())}get elevationInfo(){return this._elevationInfo}set elevationInfo(e){this._elevationInfo=e,this.recreateGeometry()}get laserlineStyle(){return this._laserlineStyle}set laserlineStyle(e){this._laserlineStyle=e,this._laserline.attached=this._laserlineAttached,e!=null&&(this._laserline.style=e)}get laserlineEnabled(){return this._laserlineEnabled}set laserlineEnabled(e){this._laserlineEnabled!==e&&(this._laserlineEnabled=e,this._laserline.attached=this._laserlineAttached)}get renderOccluded(){return this._renderOccluded}set renderOccluded(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._updateMaterial())}get attachmentOrigin(){if(!this._attachmentOriginDirty)return this._attachmentOrigin;let e=this.object3dResources.resources?.geometries;if(!e||e.length===0)return null;t(k,0,0,0);let i=0;for(let t of e)t.computeAttachmentOrigin(O)&&(n(k,k,O),i++);return i===0?null:(r(k,k,1/i),this.view.renderCoordsHelper.fromRenderCoords(k,this._attachmentOrigin),this._attachmentOriginDirty=!1,this._attachmentOrigin)}_updateMaterial(){this.object3dResources.resources?.material.setParameters(this._materialParameters),this.drapedResources.resources?.material.setParameters(this._materialParameters)}get _isClosed(){return this.geometry!=null&&this.geometry.type===`polygon`}get _materialParameters(){return{width:this._width,color:this._color,stippleOffColor:this._stippleOffColor,stipplePattern:this._stipplePattern,stipplePreferContinuous:!1,isClosed:this._isClosed,falloff:this._falloff,innerColor:this._innerColor,innerWidth:this._innerWidth,join:`round`,polygonOffset:3,renderOccluded:this._normalizedRenderOccluded,isDecoration:this.isDecoration}}get _normalizedRenderOccluded(){return this.isDraped&&this._renderOccluded===8?4:this._renderOccluded}_recreateGeometry(e,t,n){this._createBufferGeometries(t,n);for(let t of n)e.addGeometry(t);this._attachmentOriginChanged()}_attachmentOriginChanged(){this._attachmentOriginDirty=!0,this.events.emit(`attachment-origin-changed`)}_createObject3DResources(e){let t=new w(this._materialParameters,this.view),n=[];return this._recreateGeometry(e,t,n),{material:t,geometries:n}}_createDrapedResources(){let e=new w(this._materialParameters,this.view);return{material:e,geometries:this._createBufferGeometriesDraped(e)}}_createBufferGeometriesDraped(e){let{geometry:t,view:n}=this,r=n.groundView.spatialReference;return t==null||r==null?[]:b(t,r).lines.map(({position:t})=>{let i={overlayInfo:{spatialReference:r,renderCoordsHelper:n.renderCoordsHelper},attributeData:{position:t},removeDuplicateStartEnd:this._isClosed},a=v(t,n.overlayManager.renderer.localOriginFactory);return y(e,i,a)})}calculateMapBounds(e){if(this.object3dResources.resources==null)return!1;let t=this.view.renderCoordsHelper;for(let n of this.object3dResources.resources.geometries){let r=T(n,n.material.parameters.isClosed),i=d(r.count*3);for(let e=0;e<r.count;e++)r.getVec(e,O),C(O,0,n.localOrigin.vec3,0,i,e*3);l(i,t.spatialReference,0,i,this.view.spatialReference,0),u(e,i)}return!0}_createBufferGeometries(e,t){let n=this.geometry;if(n==null)return;let r=x(n,this.view.elevationProvider,this.view.renderCoordsHelper,_.fromElevationInfo(this.elevationInfo??new m({mode:p(n,null)}))),i=[];for(let{position:n,mapPositions:a}of r.lines){let r={mapPositions:a,attributeData:{position:n},removeDuplicateStartEnd:this._isClosed},o=v(n,this.view.stage.localOriginFactory);t.push(y(e,r,o)),i.push(n)}this._laserline.pathVerticalPlane=i}}function D(e){e.geometries=[]}const O=i(),k=i();export{E as OutlineVisualElement};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{watch as e}from"../../../../core/reactiveUtils.js";import{castScreenPointArray as t,createScreenPointArray as n}from"../../../../core/screenUtils.js";import{normalize as r,subtract as i,scale as a,set as o,add as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{exactEquals as l,copy as u,normalize as d,subtract as f,add as p}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as m,fromValues as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{exactEquals as g,copy as _}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as v}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{newDoubleArray as y}from"../../../../geometry/support/DoubleArray.js";import{makeDehydratedPoint as b}from"../../../../layers/graphics/dehydratedPoint.js";import{EngineVisualElement as x}from"./EngineVisualElement.js";import{needsBufferGeometryOriginUpdate as S,updateBufferGeometry as C,createBufferGeometry as w,selectLocalOrigin as T}from"../../support/engineContent/line.js";import{drapedZ as E}from"../../terrain/DrapedZ.js";import{BufferObject3D as D}from"../../webgl-engine/lib/BufferObject3D.js";import{RibbonLineMaterial as O}from"../../webgl-engine/materials/RibbonLineMaterial.js";class k extends x{constructor(e){super(e),this._location=m(),this._direction=h(1,0,0),this._width=1,this._offset=1,this._length=18,this._color=v(1,0,1,1),this._renderOccluded=4,this._transparentRenderOrder=0,this.applyProperties(e)}createObject3DResourceFactory(e){return{view:e,createObject:()=>new D({geometries:[]}),createResources:e=>this._createObject3DResources(e),destroyResources:M,recreateGeometry:(e,t)=>this._recreateObject3DGeometry(e,t),cameraChanged:()=>this._updateGeometry(),forEachMaterial:(e,t)=>t(e.material)}}createDrapedResourceFactory(e){return{view:e,createResources:()=>this._createDrapedResources(),destroyResources:N,recreateGeometry:e=>this._recreateDrapedGeometry(e),forEachMaterial:(e,t)=>t(e.material)}}get location(){return this._location}set location(e){l(this._location,e)||(u(this._location,e),this._updateGeometry())}get direction(){return this._direction}set direction(e){l(this._direction,e)||(u(this._direction,e),this._updateGeometry())}setDirectionFromPoints(e,t){d(this._direction,f(this._direction,t,e)),this._updateGeometry()}get width(){return this._width}set width(e){e!==this._width&&(this._width=e,this._updateMaterial())}get offset(){return this._offset}set offset(e){e!==this._offset&&(this._offset=e,this._updateGeometry())}get length(){return this._length}set length(e){e!==this._length&&(this._length=e,this._updateGeometry())}get color(){return this._color}set color(e){g(e,this._color)||(_(this._color,e),this._updateMaterial())}get renderOccluded(){return this._renderOccluded}set renderOccluded(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._updateMaterial())}get transparentRenderOrder(){return this._transparentRenderOrder}set transparentRenderOrder(e){e!==this._transparentRenderOrder&&(this._transparentRenderOrder=e,this._updateMaterial())}get isDecoration(){return this._isDecoration}set isDecoration(e){this._isDecoration=e,this._updateMaterial()}_createObject3DResources(e){let t=new O(this.materialParameters,this.view),n=[];return this._createObject3DGeometry(t,e,n),{material:t,geometries:n}}_recreateObject3DGeometry(e,t){e.geometries.length=0,this._createObject3DGeometry(e.material,t,e.geometries)}_createObject3DGeometry(e,t,n){this._computeLinePositionsObject3D(F);let[r,i]=A(e,F,this.view.stage.localOriginFactory);t.addGeometry(r),t.addGeometry(i),n.push(r),n.push(i)}_createDrapedResources(){let t=new O(this.materialParameters,this.view),n=e(()=>this.view.state.contentPixelRatio,()=>this.drapedResources.recreateGeometry());return{material:t,geometries:this._createDrapedGeometry(t),pixelRatioHandle:n}}_recreateDrapedGeometry(e){e.geometries=this._createDrapedGeometry(e.material)}_createDrapedGeometry(e){return this._computePositionsDraped(F),A(e,F,this.view.overlayManager.renderer.localOriginFactory)}_updateMaterial(){let{materialParameters:e}=this;this.object3dResources.resources?.material.setParameters(e),this.drapedResources.resources?.material.setParameters(e)}get materialParameters(){return{width:this._width,color:this._color,renderOccluded:this._renderOccluded,testsTransparentRenderOrder:this._transparentRenderOrder,isDecoration:this.isDecoration}}_updateGeometry(){if(this.isDraped)this.drapedResources.recreateGeometry();else{let e=this.object3dResources.object;e&&this._updateVerticesObject3D(e)}}_updateVerticesObject3D(e){this._computeLinePositionsObject3D(F);let[t,n]=e.geometries,[r,i]=F,{localOriginFactory:a}=this.view.stage;S(t.localOrigin,a,r)||S(n.localOrigin,a,i)?this.object3dResources.recreateGeometry():(C(t,r),e.geometryVertexAttributeUpdated(t,`position`),C(n,i),e.geometryVertexAttributeUpdated(n,`position`))}_computeLinePositionsObject3D(e){let t=this.view.state.camera;t.projectToScreen(this.location,z),p(P,this.location,this.direction),t.projectToScreen(P,B),r(B,i(B,B,z)),this._computeSegmentPositionsObject3D(t,e[0],z,B,1),this._computeSegmentPositionsObject3D(t,e[1],z,B,-1)}_computeSegmentPositionsObject3D(e,n,r,i,a){let{start:o,end:s}=j(i,r,a,this.offset,this.width,this.length);e.unprojectFromScreen(t(o),P),n[0]=P[0],n[1]=P[1],n[2]=P[2],e.unprojectFromScreen(t(s),P),n[3]=P[0],n[4]=P[1],n[5]=P[2]}_computePositionsDraped(e){let{view:{overlayManager:t,state:{contentPixelRatio:n}}}=this,{location:r,width:i,length:a,offset:o}=this,s=V;s.spatialReference=t.spatialReference,s.x=r[0],s.y=r[1];let c=this.view.overlayPixelSizeInMapUnits(s)*n,l=i*c,u=a*c,d=o*c;this._computeLinePositionsDraped(e[0],l,u,d,-1),this._computeLinePositionsDraped(e[1],l,u,d,1)}_computeLinePositionsDraped(e,t,n,r,i){let{location:a,direction:o}=this,{start:s,end:c}=j(o,a,i,r,t,n);e[0]=s[0],e[1]=s[1],e[2]=E,e[3]=c[0],e[4]=c[1],e[5]=E}}function A(e,[t,n],r){return[w(e,{attributeData:{position:t}},T(t,r)),w(e,{attributeData:{position:n}},T(n,r))]}function j(e,t,n,r,i,c){let l=a(I,o(I,e[1]*n,e[0]*-n),r+i/2),u=s(L,s(L,s(L,t,a(L,e,c/2)),l),l);return{start:u,end:s(R,u,a(R,e,-c))}}function M(e){e.geometries.length=0}function N(e){e.pixelRatioHandle.remove(),e.geometries=[]}const P=m(),F=[y(6),y(6)],I=c(),L=c(),R=c(),z=n(),B=n(),V=b(0,0,void 0,null);export{k as ParallelLineVisualElement};
|
|
2
|
+
import{watch as e}from"../../../../core/reactiveUtils.js";import{castScreenPointArray as t,createScreenPointArray as n}from"../../../../core/screenUtils.js";import{normalize as r,subtract as i,scale as a,set as o,add as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{exactEquals as l,copy as u,normalize as d,subtract as f,add as p}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as m,fromValues as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{exactEquals as g,copy as _}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as v}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{newDoubleArray as y}from"../../../../geometry/support/DoubleArray.js";import{makeDehydratedPoint as b}from"../../../../layers/graphics/dehydratedPoint.js";import{EngineVisualElement as x}from"./EngineVisualElement.js";import{needsBufferGeometryOriginUpdate as S,updateBufferGeometry as C,createBufferGeometry as w,selectLocalOrigin as T}from"../../support/engineContent/line.js";import{drapedZ as E}from"../../terrain/DrapedZ.js";import{BufferObject3D as D}from"../../webgl-engine/lib/BufferObject3D.js";import{RibbonLineMaterial as O}from"../../webgl-engine/materials/RibbonLineMaterial.js";class k extends x{constructor(e){super(e),this._location=m(),this._direction=h(1,0,0),this._width=1,this._offset=1,this._length=18,this._color=v(1,0,1,1),this._renderOccluded=4,this._transparentRenderOrder=0,this.applyProperties(e)}createObject3DResourceFactory(e){return{view:e,createObject:()=>new D({geometries:[]}),createResources:e=>this._createObject3DResources(e),destroyResources:M,recreateGeometry:(e,t)=>this._recreateObject3DGeometry(e,t),cameraChanged:()=>this._updateGeometry(),forEachMaterial:(e,t)=>t(e.material)}}createDrapedResourceFactory(e){return{view:e,createResources:()=>this._createDrapedResources(),destroyResources:N,recreateGeometry:e=>this._recreateDrapedGeometry(e),forEachMaterial:(e,t)=>t(e.material)}}get location(){return this._location}set location(e){l(this._location,e)||(u(this._location,e),this._updateGeometry())}get direction(){return this._direction}set direction(e){l(this._direction,e)||(u(this._direction,e),this._updateGeometry())}setDirectionFromPoints(e,t){d(this._direction,f(this._direction,t,e)),this._updateGeometry()}get width(){return this._width}set width(e){e!==this._width&&(this._width=e,this._updateMaterial())}get offset(){return this._offset}set offset(e){e!==this._offset&&(this._offset=e,this._updateGeometry())}get length(){return this._length}set length(e){e!==this._length&&(this._length=e,this._updateGeometry())}get color(){return this._color}set color(e){g(e,this._color)||(_(this._color,e),this._updateMaterial())}get renderOccluded(){return this._renderOccluded}set renderOccluded(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._updateMaterial())}get transparentRenderOrder(){return this._transparentRenderOrder}set transparentRenderOrder(e){e!==this._transparentRenderOrder&&(this._transparentRenderOrder=e,this._updateMaterial())}get isDecoration(){return this._isDecoration}set isDecoration(e){this._isDecoration=e,this._updateMaterial()}_createObject3DResources(e){let t=new O(this.materialParameters,this.view),n=[];return this._createObject3DGeometry(t,e,n),{material:t,geometries:n}}_recreateObject3DGeometry(e,t){e.geometries.length=0,this._createObject3DGeometry(e.material,t,e.geometries)}_createObject3DGeometry(e,t,n){this._computeLinePositionsObject3D(F);let[r,i]=A(e,F,this.view.stage.localOriginFactory);t.addGeometry(r),t.addGeometry(i),n.push(r),n.push(i)}_createDrapedResources(){let t=new O(this.materialParameters,this.view),n=e(()=>this.view.state.contentPixelRatio,()=>this.drapedResources.recreateGeometry());return{material:t,geometries:this._createDrapedGeometry(t),pixelRatioHandle:n}}_recreateDrapedGeometry(e){e.geometries=this._createDrapedGeometry(e.material)}_createDrapedGeometry(e){return this._computePositionsDraped(F),A(e,F,this.view.overlayManager.renderer.localOriginFactory)}_updateMaterial(){let{materialParameters:e}=this;this.object3dResources.resources?.material.setParameters(e),this.drapedResources.resources?.material.setParameters(e)}get materialParameters(){return{width:this._width,color:this._color,renderOccluded:this._renderOccluded,testsTransparentRenderOrder:this._transparentRenderOrder,isDecoration:this.isDecoration}}_updateGeometry(){if(this.isDraped)this.drapedResources.recreateGeometry();else{let e=this.object3dResources.object;e&&this._updateVerticesObject3D(e)}}_updateVerticesObject3D(e){this._computeLinePositionsObject3D(F);let[t,n]=e.geometries,[r,i]=F,{localOriginFactory:a}=this.view.stage;S(t.localOrigin,a,r)||S(n.localOrigin,a,i)?this.object3dResources.recreateGeometry():(C(t,r),e.geometryVertexAttributeUpdated(t,`position`),C(n,i),e.geometryVertexAttributeUpdated(n,`position`))}_computeLinePositionsObject3D(e){let t=this.view.state.camera;t.projectToScreen(this.location,z),p(P,this.location,this.direction),t.projectToScreen(P,B),r(B,i(B,B,z)),this._computeSegmentPositionsObject3D(t,e[0],z,B,1),this._computeSegmentPositionsObject3D(t,e[1],z,B,-1)}_computeSegmentPositionsObject3D(e,n,r,i,a){let{start:o,end:s}=j(i,r,a,this.offset,this.width,this.length);e.unprojectFromScreen(t(o),P),n[0]=P[0],n[1]=P[1],n[2]=P[2],e.unprojectFromScreen(t(s),P),n[3]=P[0],n[4]=P[1],n[5]=P[2]}_computePositionsDraped(e){let{view:{overlayManager:t,state:{contentPixelRatio:n}}}=this,{location:r,width:i,length:a,offset:o}=this,s=V;s.spatialReference=t.spatialReference,s.x=r[0],s.y=r[1];let c=this.view.overlayPixelSizeInMapUnits(s)*n,l=i*c,u=a*c,d=o*c;this._computeLinePositionsDraped(e[0],l,u,d,-1),this._computeLinePositionsDraped(e[1],l,u,d,1)}_computeLinePositionsDraped(e,t,n,r,i){let{location:a,direction:o}=this,{start:s,end:c}=j(o,a,i,r,t,n);e[0]=s[0],e[1]=s[1],e[2]=E,e[3]=c[0],e[4]=c[1],e[5]=E}}function A(e,[t,n],r){return[w(e,{attributeData:{position:t},removeDuplicateStartEnd:!1},T(t,r)),w(e,{attributeData:{position:n},removeDuplicateStartEnd:!1},T(n,r))]}function j(e,t,n,r,i,c){let l=a(I,o(I,e[1]*n,e[0]*-n),r+i/2),u=s(L,s(L,s(L,t,a(L,e,c/2)),l),l);return{start:u,end:s(R,u,a(R,e,-c))}}function M(e){e.geometries.length=0}function N(e){e.pixelRatioHandle.remove(),e.geometries=[]}const P=m(),F=[y(6),y(6)],I=c(),L=c(),R=c(),z=n(),B=n(),V=b(0,0,void 0,null);export{k as ParallelLineVisualElement};
|
|
@@ -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 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>0x6400000?(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};
|
|
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 fe}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 ge}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as O}from"../../../geometry/projection/projectVectorToVector.js";import{create as k,fromBuffer as _e,toRect as A}from"../../../geometry/support/aaBoundingBox.js";import{create as j,intersects as M}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as N,ensurePackedMat4f64 as P}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{IntegratedMeshSemantics as R}from"../../../layers/support/IntegratedMeshSemantics.js";import z from"../../../layers/support/SceneModification.js";import{getColor as Ce,getOpacity as we}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{isBasemapLayerView as B}from"../../../support/basemapUtils.js";import{getElevationOffset as V}from"../../../support/elevationInfoUtils.js";import{loadArcade as Te}from"../../../support/loadArcade.js";import H 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 U}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 W,getSymbolInfo as at,transparentEdgeMaterial as G,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 K}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 q}from"../support/debugFlags.js";import{ElevationRange as J}from"../support/ElevationRange.js";import{toBoundingRect as mt}from"../support/extentUtils.js";import{Obb as Y,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 wt}from"../webgl-engine/core/shaderLibrary/output/getEmissions.glsl.js";import{getHighlightName as Tt}from"../../support/highlightOptionsUtils.js";import{TextureCompressionTracker as Et}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as Dt}from"../../../webscene/support/AlphaCutoff.js";const Ot=[1,1,1,1];class kt 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 J,this._geometryElevationRange=new J,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=[],this.edgeMemoryUsage=0,this.cachedSymbologyStride=5,this.elevationAlignmentOffset=0,this._baseGeometryElevationRange=new J(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 At=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 fe,this._highlights=null,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._compressionTracker=new Et,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>=Dt}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`?V(e,this.layer.spatialReference):0}get elevationInfo(){let e=this.layer?.elevationInfo;switch(e?.mode){case`absolute-height`:return new Z(0,V(e,this.layer.spatialReference));case`relative-to-ground`:return new Z(1,V(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 J;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,integratedMeshSemantics:new R(this.layer),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)),Gt):t&&this.removeHandles(Gt)},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(()=>q.I3S_TREE_SHOW_TILES,e=>{if(e&&!this._treeDebugger){let e=this._controller.crsIndex;import(`./support/I3STreeDebugger.js`).then(({I3STreeDebugger:t})=>{!this._treeDebugger&&q.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))})}else!e&&!q.I3S_TREE_SHOW_TILES&&(this._treeDebugger=s(this._treeDebugger))},f),p(()=>q.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),!q.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:Lt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion})))}_getObjectIdField(){return this.layer.objectIdField||L}_getGlobalIdField(){return this.layer.globalIdField}_findGraphicNodeAndIndex(e){let t=K(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=K(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,N(24),0),a=this.view.renderSpatialReference,o=this.view.spatialReference;return he(i,a,0,i,o,0)?_e(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?qt:e===D(e)?Jt:this.layer.spatialReference.equals(e)?Kt: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=P(r.globalTrafo),r.nodeVersion===e.version?(this.elevationInfo.mode===0&&(e.geometryObbInRenderSR=Y.fromData(r.geometryObbData)),this.loadMissingTextures(r.requiredTextures,r.textureData,n,t).then(n=>(n&&this._idbCache.initialized&&r.textureData!=null&&(r.byteSize=Bt(r.transformedGeometry,r.textureData),r.textureData.every(zt)&&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 Rt(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=P(r.globalTrafo),m=x(Ut,i.center.x,i.center.y,i.center.z);S(m,m,p);let h=new Y(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:Bt(u,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&this._indexedDbSizeCheck(e,g)){let t=g.textureData==null?null:g.textureData.map(e=>zt(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 J,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=ge(l,u),m=ge(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=P(t.globalTrafo);re(w,E,w);let fe=ie(T(),w),D=y(te(),w),me=this._isIntegratedMesh?this._imShading?2:0:1,he=S.textureCoordinateType,ge=!b(D,ne),k=new bt(h,me,he,+!!ge),_e=new xt({interleavedVertexData:_,vertexCount:C,indexData:g},{positions:ve(v.data),indices:ye(v.indices)},ue,k),A=this.view.renderSpatialReference,j=this.view.groundView.spatialReference,M=Y.fromData(ht(t.geometryObbData)).getCenter(Zt),N=[1,1,1];pe(M,A,N,j)||a.getLogger(this).errorOnce(`Unsupported coordinate system for IM overlay`);let F=T();O(M,A,F,j);let I=te();ee(I,D);let L=T();ce(L,le(L,M,fe),I);let be=F[0]-L[0]*N[0],xe=F[1]-L[1]*N[1],Se=S.textureCoordinateType===2,{textures:z,texturePromise:Ce,materialParameters:we}=this._initMaterialAndTextures(x,s,Se,e),B=p.createObject(new vt(de(be,xe,N[0],N[1]),new Ct(fe,D),Y.fromData(ht(t.geometryObbData)),_e,!(this.layer.type===`integrated-mesh`&&R.shouldIntersectAsGround(this.layer))),we);e.memory+=this._memEstimateGeometryAdded(B),e.memory+=z.reduce((e,t)=>e+(t==null?0:this._memEstimateTextureAdded(t)),0);let V=!!x.hasParametersFromSource,Te=x.alphaMode!==`blend`&&x.metallicRoughness.baseColorFactor[3]>=1,H=new kt(e,u,B,this._getInvalidRendererVersion(),r.attributeInfo,{hasParametersFromSource:V,isOpaque:Te},z,d,f,t.geometryMinElevation,t.geometryMaxElevation);r.meta=H,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(H),Ce]).then(([t,r])=>(this._addTasks.has(e.index)&&t?.updateObjectVisibility(H.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,H),n.meta=null,!this.contentVisible){this._removeNodeStageData(e.index,this.elevationOffset);return}p.setObjectVisibility(B,!0),t?.updateObjectVisibility(H.objectHandle,!0).catch(e=>this._logEdgeViewError(e,this.layer.title)),H.attributeInfo=n.attributeInfo;let r=H.cachedRendererVersion!==this._rendererVersion,i=Ee!==this.slicePlaneEnabled;this._updateElevationOffsets(H);let a=H.elevationOffsets;this._updateComponentData(H);let o=this._applyFiltersToNode(H);(r||t!=null&&(i||o||a))&&this._addOrUpdateEdgeRendering(H).catch(()=>{}),this._labeler!=null&&this._addMetaToLabeler(this._labeler,H),this._visibleGeometryChanged(H,0),this._highlights?.objectCreated(H),this._updateMaterial(H),this._setNewNodeOpacity(H),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=Ut,u=Wt,d=s===2,f=this.view.renderCoordsHelper,p=e.featureIds.length,m=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;let t=N(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),O(l,r,l,o),t[s+2]=f.getAltitude(l),O(l,o,l,a),t[s]=l[0],t[s+1]=l[1]):(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),O(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=Lt(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,integratedMeshSemantics:new R(this.layer),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 Ht(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=j();this._renderClippingArea=mt(this.view.clippingArea,n,e)?n:null;let r=j();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=Xt(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?U(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,It,this.view.renderSpatialReference),it(t,It)}_boundingRectFeatureTest(e,t,n){return this._collection.getComponentAabb(e.objectHandle,t,jt),A(jt,Mt),M(n,Mt)}_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(Nt,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=Yt(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=Xt(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=W(this._rendererVersion,1),this._controller?.requestUpdate()}_getInvalidRendererVersion(){return W(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange(`rendererTextureUsage`),this._rendererVersion=W(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=B(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 H))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=G,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]]=U(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:Ft,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,Ot,l.color):Ie(g,_,null,null,Ot,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]>=Dt,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]=G;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?wt:v?.emissive?.strength;y!==wt&&!e.emissiveStrengths&&(e.emissiveStrengths=Array(e.featureIds.length).fill(wt)),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!==G),perFeatureEdgeMaterials:t};let r=0,i=!1,a=t.map((t,a)=>e.featureIds[a]===n[r]?(i||=t!==G,r++,t):G);return{hasEdges:i,perFeatureEdgeMaterials:a}}_updateComponentData(e){if(!this._hasComponentData)return;let{objectHandle:t}=e,n=this._getComponentParameters(e);this._collection.setComponentData(t,n),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),this._controller!=null&&this._controller.restartNodeLoading()}_refreshGroundUsage(){this._intersectionHandler.integratedMeshSemantics=new R(this.layer),this.contentVisible&&(this.view.elevationProvider.unregister(this._elevationProvider),this.view.elevationProvider.register(this._elevationContext,this._elevationProvider)),this._reloadAll(),this.clearMemCache()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach(t=>{t!=null&&(this._collection.updateObjectOpacity(t.objectHandle,e),X(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))})}_updateMaterial(e){e.objectHandle.updateMaterial({slicePlaneEnabled:this.slicePlaneEnabled,usePBR:this._usePBR})}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e).catch(()=>{}),this._visibleGeometryChanged(e,2)}intersect(e,t,n,r){this._intersectionHandler.intersectRay(e,t,n,r,null,!1)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this._labeler!=null&&(this._labeler.slicePlaneEnabled=e),this._foreachMeta(t=>{t.objectHandle.updateMaterial({slicePlaneEnabled:e}),this._updateEdgeRendering(t,!1)})}_updatePBR(e){this._foreachMeta(t=>t.objectHandle.updateMaterial({usePBR:e})),this._hasLoadedPBRTextures=!0}_foreachMeta(e){this._nodeId2Meta.forEach(t=>{t!=null&&e(t)})}get _usePBR(){return this._imShading&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){this._edgeView!=null&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t).catch(()=>{})}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?(t,n,r)=>r.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?0:e(t,n,r):e}_forAllFeatures(e,t,n){for(let r of this._nodeId2Meta.values())if(r!=null&&!(t&&r.node.serviceMbsInIndexSR&&t(r.node.serviceMbsInIndexSR)===1))switch(n){case 1:this._forAllFeaturesOfNode(r,e);break;case 0:this._forAllVisibleFeaturesOfNode(r,e);break;case 2:this._forAllQueryableFeaturesOfNode(r,e)}}_forAllFeaturesOfNode(e,t){e.featureIds.forEach((n,r)=>t(n,r,e))}_forAllVisibleFeaturesOfNode(e,t){let n=e.featureIds;this._collection.forEachVisibleComponent(e.objectHandle,r=>t(n[r],r,e)===0)}_forAllQueryableFeaturesOfNode(e,t){let n=this._ignoreClientNodeOverriddenFeatures(t);if(this._renderClippingArea==null)return this._forAllFeaturesOfNode(e,n);let r=this._boundingRectNodeTest(e,this._renderClippingArea);if(r===0)return;if(r===3)return this._forAllFeaturesOfNode(e,n);let i=e.featureIds,a=e.objectHandle,o=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]=U(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=Tt(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=>K(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=k();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=Vt(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>0x6400000?(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:[z]})],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},jt=k(),Mt=j(),Nt=j(),Pt=new Y,Ft=new t([0,0,0,0]),It=new F(0,0,0,0);function Lt(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 Rt(e){return`geometryData`in e}function zt(e){return e!=null&&g(e.data)}function Bt(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 Vt(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=Pt,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 Ht{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 Ut=T(),Wt=k(),Gt=`elevation-change`,Kt=``,qt=`@null`,Jt=`@ECEF`;function Yt(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 Xt(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 Zt=T();export{At 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,watch as c,when as l}from"../../../core/reactiveUtils.js";import{schedule as u}from"../../../core/scheduling.js";import{isUint8Array as d,isFloat32Array as f,isUint32Array as p,isUint16Array as m}from"../../../core/typedArrayUtil.js";import{property as h,subclass as g}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as _,invert as v}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as y,IDENTITY as b}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as x}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as S}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as C,sub as w,dot as T,set as E}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as D,freeze as O,clone as k,ZEROS as A,fromValues as j}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as ee,clone as M,ONES as te}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as ne,isMars as N,getReferenceEllipsoid as P,SphericalECEFSpatialReferenceLike as F}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as I}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as L}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as re}from"../../../geometry/projection/projectVectorToVector.js";import{create as ie}from"../../../geometry/support/aaBoundingRect.js";import{isInEffectiveScaleRange as ae,validateScaleRange as oe}from"../../../geometry/support/scaleUtils.js";import{isCGCS2000 as se}from"../../../geometry/support/spatialReferenceUtils.js";import{BufferViewVec4u8 as ce,BufferViewVec3u8 as le,BufferViewVec2f as ue,BufferViewVec3f as R,BufferViewUint32 as z,BufferViewUint16 as B}from"../../../geometry/support/buffer/BufferView.js";import{nullId as V}from"../../../layers/ILyr3DWasmPerSceneView.js";import H from"../../../layers/support/SceneModification.js";import{validateEntity3D as U,makeCacheKey as W,isValidHandle as G}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as K}from"../../../support/elevationInfoUtils.js";import{IntegratedMesh3DTilesLayerWorkerHandle as de}from"./IntegratedMesh3DTilesLayerWorkerHandle.js";import{LayerView3D as fe}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as pe}from"./Lyr3DViewPerformanceInfo.js";import{getLyr3DWasm as me}from"./Lyr3DWasm.js";import{toWasmModification as he}from"./SceneLayerWorkerHandle.js";import{IntegratedMesh3DTilesLayerView3DSymbol as ge}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as _e,alphaModeConversion as ve,faceCullingConversion as ye,wrapModeConversion as be}from"./support/lyr3dTypeConversions.js";import{makeScheduleFunction as xe}from"./support/makeScheduleFunction.js";import{intersectsRay as Se,intersectsSphere as q}from"./support/tileBoundingVolumeUtils.js";import{Tiles3DLayerViewRegistration as Ce}from"./support/Tiles3DLayerViewRegistration.js";import{Tiles3DMeshIntersectionHandler as we}from"./support/Tiles3DMeshIntersectionHandler.js";import{Frustum as Te}from"../state/Frustum.js";import{ElevationRange as Ee}from"../support/ElevationRange.js";import{toBoundingRect as De}from"../support/extentUtils.js";import{Obb as Oe}from"../support/orientedBoundingBox.js";import{glLayout as ke}from"../support/buffer/glUtil.js";import{getGroundTransparencyModeFromOpacity as Ae}from"../terrain/TransparencyMode.js";import{ComponentGeometryParameters as je,SourceGeometry as Me}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as Ne}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Pe}from"../webgl-engine/core/material/RenderTexture.js";import{ManagedTexture as Fe}from"../webgl-engine/lib/ManagedTexture.js";import{compressNormals as Ie}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as Le}from"../webgl-engine/materials/pbrUtils.js";import Re from"../../layers/LayerView.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 Be(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 fe(Re){static{Z=ge}constructor(e){super(e),this[Z]=!0,this.type=`integrated-mesh-3dtiles`,this._registration=new Ce(this),this.skipHeightModelInfoValidation=!0,this.freeze=!1,this._modifications=[],this._visibleGeometryChangedSchedulerHandle=null,this._initializationController=null,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.fullExtentInLocalViewSpatialReference=null,this._applySSAO=!has(`disable-feature:im-ssao`),this._imShading=!!has(`enable-feature:im-shading`),this._imVertexNormals=!!has(`enable-feature:im-vertex-normals`),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._dbgFlags=new Set;let t=e.view.resourceController;this._memCache=t.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._replacesTerrain=e.layer.replacesTerrain,this._frameTask=t.scheduler.registerTask(ze.TILES3D,this),this._frustum=new Te(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 de(xe(e.resourceController)),this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),s),this._initializationController=new AbortController,this.addResolvingPromise(this._registration.initialize(this._initializationController.signal,()=>this._initializeRegistered(e)))}_initializeRegistered(e){let t=new we(this);this._intersectionHandler=t,this._registration.registerQueries(t,this._getElevationContext()),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged()),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.overlayManager.renderer.isEmpty,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),s),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),s),this._updatingHandles.add(()=>this.layer.isUsedAsGroundLayer,()=>this._groundUsageChanged()),e.overlayManager.registerDrapeTarget(this),this.addHandles([c(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),l(()=>this.fullOpacity,()=>this._opacityChange())]),this._registration.synchronizeSuspension(),this.addHandles(c(()=>this.freeze,e=>{e?this._wasm?.incrementFrozenLayerViewCount(this):(this._wasm?.decrementFrozenLayerViewCount(this),this._cameraChanged())})),this._initializationController=null,this.addHandles(c(()=>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(){this.freeze=!1,this._initializationController=n(this._initializationController),this._dbg(2,`Tiles3DLayerView3D destroy() called`),this._workerHandle?.destroyContextAndSelf(this.uid),this._registration.unregisterWasm(),this.layer.queryElevationCallback=null,this._registration.unregisterQueries(e=>{let t=Array.from(this._lyrHandleToObjects.values()),n=t.reduce((e,{componentObjects:t})=>e+t.length,0);e.notifyObjectsChangedFunctional(n,e=>{for(let{componentObjects:n}of t)for(let{obb:t}of n)if(!e(t))return})}),this._intersectionHandler=null,this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._frameTask.remove(),this._updatingHandles=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:Ae(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(){this._registration.setElevationContext(this._getElevationContext()),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 e=has(`enable-feature:im-as-ground`)?this.usedAsGround:this.replacesTerrain,t=this._renderOpacity,n=this._groundTransparencyMode;this.forEachComponentObject(r=>r.updateMaterial({isGround:e,opacity:t,groundTransparencyMode:n}))}_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=he(this._layerClippingArea,this._modifications,e,this.view.state.isGlobal);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){let e=this.layer.spatialReference,t=ie();this._layerClippingArea=De(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=u(()=>{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 me(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._registration.wasmLayerId}get metersPerVCSUnit(){return this._registration.metersPerVCSUnit}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get useEsriCrs(){return this._registration.useEsriCrs}get visibleAtCurrentScale(){return this.replacesTerrain||ae(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||oe(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 pe(this.usedMemory,i,a,$(t),$(e),$(r),$(n))}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._registration.elevationProvider}get elevationOffset(){return K(this.layer.elevationInfo)}get elevationRange(){return this._intersectionHandler?.elevationRange}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){let e=new Ee;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||se(n)||ne(n)||N(n);if(this.view.state.isGlobal||!r)return this.forEachVisibleTile(e);let i=P(n).radius,{eye:a,viewForward:o,near:s}=t.state.contentCamera,c=C(D(),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=D();this.forEachVisibleTile(t=>{let{mbsRadius:n,mbsCenter:r}=t;if(n<0)return;w(m,r,a);let i=T(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(!U(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 He(e.handle,o,d,u,l,c,a,e.stableNodeId,e.nodeDepth,s);return this._lyrHandleToObjects.set(e.handle,f),()=>{this._memCache.put(W(f.handle),f);let{usedMemory:e}=f;return this._cacheMemory+=e,{memUsageBytes:e}}}catch(e){throw r.forEach(e=>e.cleanup()),i?.componentObjects.forEach(e=>this._collection.destroyObject(e)),n.forEach(e=>this._stage?.removeTexture(e)),e}}_createPrimitiveTextureBundles(e,t){let n=[];try{let r=e.desc.geometry;for(let i of e.validPrimitiveIndices){let a=r.prims[i].materialId,o=e.desc.materials?.materials&&a!=null&&a!==V?e.desc.materials.materials[a]:null,s=Promise.resolve(We),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 Ge(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=O(...e.origin),a=this.view.groundView.spatialReference,o=this.view.state.isGlobal,s=b;if(o){let e=x();I(F,i,e,a),s=_(y(),e)}let c=Ue(r.obb),l=o?P(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)),_e[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!==b,h=m?v(y(),s)??b:b,{vertexProcessingOutputs:g,obbHalfSizeAccumulator:_,elevationRange:x}=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 S=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,aabbInWorldCoordinates:_}=o,v=e.validPrimitiveIndices[s],y=r.geometry.prims[v],b=t[s],x=c.clone(),C=ke(d),w=new Uint32Array([0,u.typedBuffer.length]),T=new je(C,this._imShading?2:0,f,m?2:0),E=new Me({interleavedVertexData:p,vertexCount:p.byteLength/C[0].stride,indexData:g},{positions:l.typedBuffer,indices:u.typedBuffer},w,T),O=this.view.renderSpatialReference,k=D(),A=[1,1,1];L(i,O,A,a)||this._dbg(3,`Unsupported coordinate system for IM overlay`),re(i,O,k,a);let j=this._createComponentMaterialInitParameters(S,y.materialId,b);j.baseColorTexture||this._dbg(3,`No colour texture 1`);let M=this._collection.createObject({toMapSpace:ee(k[0],k[1],A[0],A[1]),transform:new Ne(i,h),obb:x,geometry:E,elevationAlignable:!1,aabbInWorldCoordinates:_},j);n.push(M)}return x.minElevation=Math.max(x.minElevation,d),x.maxElevation=Math.min(x.maxElevation,f),{tileObb:c,componentObjects:n,elevationRange:x}}catch(e){throw n.forEach(e=>this._collection.destroyObject(e)),e}}_createComponentMaterialInitParameters(e,t,n){let r=e?.materials!=null&&t!=null&&t!==V?e.materials[t]:null,i=1,a=r?.baseColorTex?.imageId;if(a!=null&&e&&Array.isArray(e.images)&&a>=0&&a<e.images.length){let t=e.images[a];t.alpha&&(i=ve[t.alpha])}let o=(r==null?`Unlit`:r.lightingModel)===`Pbr`,s=te,c=X,l=!1,u=2,d=j(0,0,0),f=k(Le),p=n.baseColorTexture,m=n.metallicRoughnessTexture,h=n.emissionTexture,g=n.occlusionTexture,_=n.normalTexture;return r&&(s=M(r.baseColorFactor),c=r.alphaCutoff??X,o&&(E(f,r.metallicFactor,r.roughnessFactor,0),r.emissiveFactor&&(d=r.emissiveFactor)),l=r.isDoubleSided,u=ye[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 Pe(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=be[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=Be(c,d,n.format),t=new Fe(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`||!f(c.data)?this._dbg(3,`[Unsupported Feature] Unsupported view for Position (`+c+`)`):n=new R(l,0,void 0,u);break;case`Normal`:if(c.ncomp!==3||c.dataType!==`F32`||!f(c.data))this._dbg(3,`[Unsupported Feature] Unsupported view for Normal (`+c+`)`);else{let e=new R(l,0,void 0,u);a=new Uint32Array(e.count),Ie(e.typedBuffer,new Int16Array(a.buffer,a.byteOffset,a.length*2))}break;case`TexCoord`:c.ncomp!==2||c.dataType!==`F32`||!f(c.data)?this._dbg(3,`[Unsupported Feature] Unsupported view for Texcoord (`+c+`)`):i===void 0&&(i=new ue(l,0,void 0,u).typedBuffer);break;case`Color`:c.dataType===`U8`&&d(c.data)&&(c.ncomp===4?r=new ce(l,0,void 0,u):c.ncomp===3&&(r=new le(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&&m(n.data)&&(o=new B(n.data.buffer,0,void 0,e));break;case`U32`:n.ncomp===1&&p(n.data)&&(o=new z(n.data.buffer,0,void 0,e))}s=!o}}if(!s&&o==null&&n!=null){let e=n.count;o=o=e<65535?new B(new Uint16Array(e).buffer):new z(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([h()],Q.prototype,`freeze`,void 0),e([h()],Q.prototype,`fullOpacity`,null),e([h()],Q.prototype,`opaque`,null),e([h()],Q.prototype,`invisible`,null),e([h({readOnly:!0})],Q.prototype,`ready`,null),e([h({type:[H]})],Q.prototype,`_modifications`,void 0),e([h()],Q.prototype,`_visibleGeometryChangedSchedulerHandle`,void 0),e([h()],Q.prototype,`layer`,void 0),e([h({readOnly:!0})],Q.prototype,`visibleAtCurrentScale`,null),e([h({readOnly:!0})],Q.prototype,`_collection`,null),e([h()],Q.prototype,`elevationOffset`,null),e([h({readOnly:!0})],Q.prototype,`visibleElevationRange`,null),e([h()],Q.prototype,`fullExtentInLocalViewSpatialReference`,void 0),Q=e([g(`esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D`)],Q);const Ve=Q;class He{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=D();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(D()):A}get usedMemory(){return this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this._mbsCenter}boundingVolumeIntersectsRay(e,t){return Se(this.obb,this._obbCenterX,this._obbCenterY,this._obbCenterZ,this._obbRadiusSquared,e,t)}boundingVolumeIntersectsSphere(e){return q(this.obb,this._obbCenterX,this._obbCenterY,this._obbCenterZ,this._obbRadius,this._obbShortestHalfsize,e)}}function $(e){return Math.round(e/1048.576)/1e3}function Ue(e){return new Oe(e.center,e.halfSize,S(...e.quaternion))}const We=[];class Ge{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{Ve 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,watch as c,when as l}from"../../../core/reactiveUtils.js";import{schedule as u}from"../../../core/scheduling.js";import{isUint8Array as d,isFloat32Array as f,isUint32Array as p,isUint16Array as m}from"../../../core/typedArrayUtil.js";import{property as h,subclass as g}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as _,invert as v}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as y,IDENTITY as b}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as x}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as S}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as C,sub as w,dot as T,set as E}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as D,freeze as O,clone as k,ZEROS as A,fromValues as j}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as M,clone as N,ONES as ee}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as P,isMars as F,getReferenceEllipsoid as I,SphericalECEFSpatialReferenceLike as L}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as te}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as ne}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as re}from"../../../geometry/projection/projectVectorToVector.js";import{create as ie}from"../../../geometry/support/aaBoundingRect.js";import{isInEffectiveScaleRange as ae,validateScaleRange as oe}from"../../../geometry/support/scaleUtils.js";import{isCGCS2000 as se}from"../../../geometry/support/spatialReferenceUtils.js";import{BufferViewVec4u8 as ce,BufferViewVec3u8 as le,BufferViewVec2f as ue,BufferViewVec3f as R,BufferViewUint32 as z,BufferViewUint16 as B}from"../../../geometry/support/buffer/BufferView.js";import{nullId as V}from"../../../layers/ILyr3DWasmPerSceneView.js";import{IntegratedMeshSemantics as H}from"../../../layers/support/IntegratedMeshSemantics.js";import U from"../../../layers/support/SceneModification.js";import{validateEntity3D as de,makeCacheKey as W,isValidHandle as G}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as K}from"../../../support/elevationInfoUtils.js";import{IntegratedMesh3DTilesLayerWorkerHandle as fe}from"./IntegratedMesh3DTilesLayerWorkerHandle.js";import{LayerView3D as pe}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as me}from"./Lyr3DViewPerformanceInfo.js";import{getLyr3DWasm as he}from"./Lyr3DWasm.js";import{toWasmModification as ge}from"./SceneLayerWorkerHandle.js";import{IntegratedMesh3DTilesLayerView3DSymbol as _e}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as ve,alphaModeConversion as ye,faceCullingConversion as be,wrapModeConversion as xe}from"./support/lyr3dTypeConversions.js";import{makeScheduleFunction as Se}from"./support/makeScheduleFunction.js";import{intersectsRay as Ce,intersectsSphere as we}from"./support/tileBoundingVolumeUtils.js";import{Tiles3DLayerViewRegistration as Te}from"./support/Tiles3DLayerViewRegistration.js";import{Tiles3DMeshIntersectionHandler as Ee}from"./support/Tiles3DMeshIntersectionHandler.js";import{Frustum as De}from"../state/Frustum.js";import{ElevationRange as Oe}from"../support/ElevationRange.js";import{toBoundingRect as ke}from"../support/extentUtils.js";import{Obb as Ae}from"../support/orientedBoundingBox.js";import{glLayout as je}from"../support/buffer/glUtil.js";import{getGroundTransparencyModeFromOpacity as Me}from"../terrain/TransparencyMode.js";import{ComponentGeometryParameters as Ne,SourceGeometry as Pe}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as Fe}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Ie}from"../webgl-engine/core/material/RenderTexture.js";import{ManagedTexture as Le}from"../webgl-engine/lib/ManagedTexture.js";import{compressNormals as Re}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as ze}from"../webgl-engine/materials/pbrUtils.js";import Be from"../../layers/LayerView.js";import{TaskPriority as q}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 Ve(e,t,n){if(t===`image/vnd-ms.dds`)switch(n){case`Dxt1`:return J.COMPRESSED_RGB_S3TC_DXT1_EXT;case`Dxt5`:return J.COMPRESSED_RGBA_S3TC_DXT5_EXT;default:return null}if(t===`image/ktx`)return n===`Etc1`?J.COMPRESSED_RGB8_ETC2:null;switch(e){case 33319:return Y.RG8;case 6407:return Y.RGB8;case 6408:return Y.RGBA8;case 6403:return Y.R8;default:return null}}let Q=class extends pe(Be){static{Z=_e}constructor(e){super(e),this[Z]=!0,this.type=`integrated-mesh-3dtiles`,this._registration=new Te(this),this.skipHeightModelInfoValidation=!0,this.freeze=!1,this._modifications=[],this._visibleGeometryChangedSchedulerHandle=null,this._initializationController=null,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.fullExtentInLocalViewSpatialReference=null,this._applySSAO=!has(`disable-feature:im-ssao`),this._imShading=!!has(`enable-feature:im-shading`),this._imVertexNormals=!!has(`enable-feature:im-vertex-normals`),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._dbgFlags=new Set;let t=e.view.resourceController;this._memCache=t.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._replacesTerrain=e.layer.replacesTerrain,this._frameTask=t.scheduler.registerTask(q.TILES3D,this),this._frustum=new De(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 fe(Se(e.resourceController)),this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),s),this._initializationController=new AbortController,this.addResolvingPromise(this._registration.initialize(this._initializationController.signal,()=>this._initializeRegistered(e)))}_initializeRegistered(e){let t=new Ee(this,new H(this.layer,this.replacesTerrain));this._intersectionHandler=t,this._registration.registerQueries(t,this._getElevationContext()),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged()),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.overlayManager.renderer.isEmpty,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),s),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),s),this._updatingHandles.add(()=>this.layer.isUsedAsGroundLayer,()=>this._groundUsageChanged()),e.overlayManager.registerDrapeTarget(this),this.addHandles([c(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),l(()=>this.fullOpacity,()=>this._opacityChange())]),this._registration.synchronizeSuspension(),this.addHandles(c(()=>this.freeze,e=>{e?this._wasm?.incrementFrozenLayerViewCount(this):(this._wasm?.decrementFrozenLayerViewCount(this),this._cameraChanged())})),this._initializationController=null,this.addHandles(c(()=>this._replacesTerrain&&!!this._wasm?.isTerrainReady||!this._replacesTerrain&&H.contributesToGroundElevation(this.layer),e=>{this.layer.queryElevationCallback=e?(e,t)=>this._queryElevation(e,t):null},s))}destroy(){this.freeze=!1,this._initializationController=n(this._initializationController),this._dbg(2,`Tiles3DLayerView3D destroy() called`),this._workerHandle?.destroyContextAndSelf(this.uid),this._registration.unregisterWasm(),this.layer.queryElevationCallback=null,this._registration.unregisterQueries(e=>{let t=Array.from(this._lyrHandleToObjects.values()),n=t.reduce((e,{componentObjects:t})=>e+t.length,0);e.notifyObjectsChangedFunctional(n,e=>{for(let{componentObjects:n}of t)for(let{obb:t}of n)if(!e(t))return})}),this._intersectionHandler=null,this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._frameTask.remove(),this._updatingHandles=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(){switch(H.opacitySource(this.layer,this.replacesTerrain)){case`ground`:return this.view.map.ground.opacity;case`layer`:return this.layer.opacity;case`opaque`:return 1}}get opaque(){return this._groundTransparencyMode===0}get invisible(){return this._groundTransparencyMode===3}get _groundTransparencyMode(){return H.opacitySource(this.layer,this._replacesTerrain)===`ground`?Me(this.fullOpacity,this.view.overlayManager.renderer.isEmpty):0}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:H.shouldUseSceneElevationContext(this.layer)?2:1}_groundUsageChanged(){this._registration.setElevationContext(this._getElevationContext());let e=new H(this.layer,this.replacesTerrain);this._intersectionHandler.integratedMeshSemantics=e,this._intersectionHandler.slicePlaneEnabled=this.slicePlaneEnabled&&!this.replacesTerrain,this.view.overlayManager.unregisterDrapeTarget(this),this.view.overlayManager.registerDrapeTarget(this),this._loadModifications();let t=this._renderOpacity,n=this._groundTransparencyMode;this.forEachComponentObject(r=>r.updateMaterial({opacity:t,groundTransparencyMode:n,integratedMeshSemantics:e}))}_cameraChanged(){if(this.freeze)return;let e=this._frustum;e.update(this.view.state.contentCamera);let t=this._visibleObjects,n=!1;this._loadedObjects.forEach(r=>{let i=r.obb?.intersectsFrustum(e)??!1;i!==r.isVisible&&(r.isVisible=i,i?t.add(r):t.delete(r),r.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,i)),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(i,r.elevationRange))}),n&&this._setVisibleElevationRangeDirty()}intersect(e,t,n,r){this._intersectionHandler.intersectRay(e,t,n,r,null,!1)}get ready(){return!this.replacesTerrain||!!this._wasm?.isTerrainReady}_modificationsChanged(){let e=this.useEsriCrs?this.layer.supportedSpatialReferences[1]:this.layer.supportedSpatialReferences[0],t=ge(this._layerClippingArea,this._modifications,e,this.view.state.isGlobal);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){let e=this.layer.spatialReference,t=ie();this._layerClippingArea=ke(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=u(()=>{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 he(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._registration.wasmLayerId}get metersPerVCSUnit(){return this._registration.metersPerVCSUnit}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get useEsriCrs(){return this._registration.useEsriCrs}get visibleAtCurrentScale(){return this.replacesTerrain||ae(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||oe(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 me(this.usedMemory,i,a,$(t),$(e),$(r),$(n))}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._registration.elevationProvider}get elevationOffset(){return K(this.layer.elevationInfo)}get elevationRange(){return this._intersectionHandler?.elevationRange}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){let e=new Oe;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||se(n)||P(n)||F(n);if(this.view.state.isGlobal||!r)return this.forEachVisibleTile(e);let i=I(n).radius,{eye:a,viewForward:o,near:s}=t.state.contentCamera,c=C(D(),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=D();this.forEachVisibleTile(t=>{let{mbsRadius:n,mbsCenter:r}=t;if(n<0)return;w(m,r,a);let i=T(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+!H.shouldDrapeRaster(this.layer,this.replacesTerrain)}isUpdating(){let e=this._wasm;return!this.freeze&&this.wasmLayerId>=0&&e!=null&&e.isUpdating(this.wasmLayerId)}get readyToRun(){return!!this._frameTask?.readyToRun}runTask(e){this._frameTask.processQueue(e)}updatingFlagChanged(){this.notifyChange(`updating`)}async createRenderable(e){if(this.destroyed||this.destroying)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy`);let{entity3d:t}=e;if(!de(t))throw Error(`entity3D not valid`);let n=new Map,r;try{r=this._createPrimitiveTextureBundles(t,n)}catch(e){throw n.forEach(e=>this._stage?.removeTexture(e)),e}let i=null;try{if(i=await this._createRenderableMain(t,r),this.destroyed)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderable aborted due to destroyed instance`);let{tileObb:a,componentObjects:o,elevationRange:s}=i,c=0,l=0,u=0;for(let e of o){let{texture:t,textureMetallicRoughness:n,textureEmissive:r,textureOcclusion:i,textureNormal:a}=e.renderable.drawParameters;c+=(t?.usedMemory??0)+(n?.usedMemory??0)+(r?.usedMemory??0)+(i?.usedMemory??0)+(a?.usedMemory??0),l+=this._collection.getObjectGPUMemoryUsage(e),u+=e.intersectionGeometry.usedMemory}let d=Array.from(n.values()),f=new Ue(e.handle,o,d,u,l,c,a,e.stableNodeId,e.nodeDepth,s);return this._lyrHandleToObjects.set(e.handle,f),()=>{this._memCache.put(W(f.handle),f);let{usedMemory:e}=f;return this._cacheMemory+=e,{memUsageBytes:e}}}catch(e){throw r.forEach(e=>e.cleanup()),i?.componentObjects.forEach(e=>this._collection.destroyObject(e)),n.forEach(e=>this._stage?.removeTexture(e)),e}}_createPrimitiveTextureBundles(e,t){let n=[];try{let r=e.desc.geometry;for(let i of e.validPrimitiveIndices){let a=r.prims[i].materialId,o=e.desc.materials?.materials&&a!=null&&a!==V?e.desc.materials.materials[a]:null,s=Promise.resolve(Ge),c=null,l=null,u=null,d=null,f=null;if(o){let n=o.lightingModel===`Pbr`;c=this._getTexture(o.baseColorTex,e,t),l=n?this._getTexture(o.metalTex,e,t):null,u=n?this._getTexture(o.emissiveTex,e,t):null,d=n?this._getTexture(o.occlusionTex,e,t):null,f=n?this._getTexture(o.normalTex,e,t):null;let r=[c,l,u,d,f].map(e=>e?.loadPromise??null);s=Promise.all(r)}n.push(new Ke(s,c,l,u,d,f))}}catch(e){throw n.forEach(e=>e.cleanup()),e}return n}async _createRenderableMain(e,t){if(this.destroyed||this.destroying)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderableMain called after destroy`);let n=[],r=e.desc,i=O(...e.origin),a=this.view.groundView.spatialReference,o=this.view.state.isGlobal,s=b;if(o){let e=x();te(L,i,e,a),s=_(y(),e)}let c=We(r.obb),l=o?I(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)),ve[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!==b,h=m?v(y(),s)??b:b,{vertexProcessingOutputs:g,obbHalfSizeAccumulator:_,elevationRange:x}=await this._workerHandle.processTiles3DVertices(p,i,l,o,s,c,this._imVertexNormals&&H.shouldGenerateVertexNormals(this.layer));if(this.destroyed)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance`);let S=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,aabbInWorldCoordinates:_}=o,v=e.validPrimitiveIndices[s],y=r.geometry.prims[v],b=t[s],x=c.clone(),C=je(d),w=new Uint32Array([0,u.typedBuffer.length]),T=new Ne(C,this._imShading?2:0,f,m?2:0),E=new Pe({interleavedVertexData:p,vertexCount:p.byteLength/C[0].stride,indexData:g},{positions:l.typedBuffer,indices:u.typedBuffer},w,T),O=this.view.renderSpatialReference,k=D(),A=[1,1,1];ne(i,O,A,a)||this._dbg(3,`Unsupported coordinate system for IM overlay`),re(i,O,k,a);let j=this._createComponentMaterialInitParameters(S,y.materialId,b);j.baseColorTexture||this._dbg(3,`No colour texture 1`);let N=this._collection.createObject({toMapSpace:M(k[0],k[1],A[0],A[1]),transform:new Fe(i,h),obb:x,geometry:E,elevationAlignable:!1,aabbInWorldCoordinates:_},j);n.push(N)}return x.minElevation=Math.max(x.minElevation,d),x.maxElevation=Math.min(x.maxElevation,f),{tileObb:c,componentObjects:n,elevationRange:x}}catch(e){throw n.forEach(e=>this._collection.destroyObject(e)),e}}_createComponentMaterialInitParameters(e,t,n){let r=e?.materials!=null&&t!=null&&t!==V?e.materials[t]:null,i=1,a=r?.baseColorTex?.imageId;if(a!=null&&e&&Array.isArray(e.images)&&a>=0&&a<e.images.length){let t=e.images[a];t.alpha&&(i=ye[t.alpha])}let o=(r==null?`Unlit`:r.lightingModel)===`Pbr`,s=ee,c=X,l=!1,u=2,d=j(0,0,0),f=k(ze),p=n.baseColorTexture,m=n.metallicRoughnessTexture,h=n.emissionTexture,g=n.occlusionTexture,_=n.normalTexture;return r&&(s=N(r.baseColorFactor),c=r.alphaCutoff??X,o&&(E(f,r.metallicFactor,r.roughnessFactor,0),r.emissiveFactor&&(d=r.emissiveFactor)),l=r.isDoubleSided,u=be[r.faceCulling??`NotSet`]),{isIntegratedMesh:!0,integratedMeshSemantics:new H(this.layer,this.replacesTerrain),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,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 Ie(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=xe[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=Ve(c,d,n.format),t=new Le(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`||!f(c.data)?this._dbg(3,`[Unsupported Feature] Unsupported view for Position (`+c+`)`):n=new R(l,0,void 0,u);break;case`Normal`:if(c.ncomp!==3||c.dataType!==`F32`||!f(c.data))this._dbg(3,`[Unsupported Feature] Unsupported view for Normal (`+c+`)`);else{let e=new R(l,0,void 0,u);a=new Uint32Array(e.count),Re(e.typedBuffer,new Int16Array(a.buffer,a.byteOffset,a.length*2))}break;case`TexCoord`:c.ncomp!==2||c.dataType!==`F32`||!f(c.data)?this._dbg(3,`[Unsupported Feature] Unsupported view for Texcoord (`+c+`)`):i===void 0&&(i=new ue(l,0,void 0,u).typedBuffer);break;case`Color`:c.dataType===`U8`&&d(c.data)&&(c.ncomp===4?r=new ce(l,0,void 0,u):c.ncomp===3&&(r=new le(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&&m(n.data)&&(o=new B(n.data.buffer,0,void 0,e));break;case`U32`:n.ncomp===1&&p(n.data)&&(o=new z(n.data.buffer,0,void 0,e))}s=!o}}if(!s&&o==null&&n!=null){let e=n.count;o=o=e<65535?new B(new Uint16Array(e).buffer):new z(new Uint32Array(e).buffer);for(let t=0;t<e;t++)o.set(t,t)}return{positionView:n,colorView:r,texCoord0Data:i,indicesView:o,normalsData:a}}_loadModifications(){if(this.removeHandles(`modifications`),this.layer.modifications==null){this._modifications=[];return}let e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>H.shouldApplyModification(this.layer,e.type)).toArray(),this._modifications.length<e.length&&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([h()],Q.prototype,`freeze`,void 0),e([h()],Q.prototype,`fullOpacity`,null),e([h()],Q.prototype,`opaque`,null),e([h()],Q.prototype,`invisible`,null),e([h({readOnly:!0})],Q.prototype,`ready`,null),e([h({type:[U]})],Q.prototype,`_modifications`,void 0),e([h()],Q.prototype,`_visibleGeometryChangedSchedulerHandle`,void 0),e([h()],Q.prototype,`layer`,void 0),e([h({readOnly:!0})],Q.prototype,`visibleAtCurrentScale`,null),e([h({readOnly:!0})],Q.prototype,`_collection`,null),e([h()],Q.prototype,`elevationOffset`,null),e([h({readOnly:!0})],Q.prototype,`visibleElevationRange`,null),e([h()],Q.prototype,`fullExtentInLocalViewSpatialReference`,void 0),Q=e([g(`esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D`)],Q);const He=Q;class Ue{constructor(e,t,n,r,i,a,o,s,c,l){this.handle=e,this.componentObjects=t,this.textures=n,this.cpuMemoryUsage=r,this.vboMemoryUsage=i,this.textureMemoryUsage=a,this.obb=o,this.stableNodeId=s,this.nodeDepth=c,this.elevationRange=l,this.bvhIntersectionGeneration=0,this.isLoaded=!1,this.isVisible=!1;let u=D();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(D()):A}get usedMemory(){return this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this._mbsCenter}boundingVolumeIntersectsRay(e,t){return Ce(this.obb,this._obbCenterX,this._obbCenterY,this._obbCenterZ,this._obbRadiusSquared,e,t)}boundingVolumeIntersectsSphere(e){return we(this.obb,this._obbCenterX,this._obbCenterY,this._obbCenterZ,this._obbRadius,this._obbShortestHalfsize,e)}}function $(e){return Math.round(e/1048.576)/1e3}function We(e){return new Ae(e.center,e.halfSize,S(...e.quaternion))}const Ge=[];class Ke{constructor(e,t,n,r,i,a){this.materialPromise=e,this.baseColorTexture=t,this.metallicRoughnessTexture=n,this.emissionTexture=r,this.occlusionTexture=i,this.normalTexture=a}cleanup(){this.baseColorTexture?.dispose(),this.metallicRoughnessTexture?.dispose(),this.emissionTexture?.dispose(),this.occlusionTexture?.dispose(),this.normalTexture?.dispose()}}export{He as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{initial as t}from"../../../core/reactiveUtils.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{isInEffectiveScaleRange as i}from"../../../geometry/support/scaleUtils.js";import{
|
|
2
|
+
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{initial as t}from"../../../core/reactiveUtils.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{isInEffectiveScaleRange as i}from"../../../geometry/support/scaleUtils.js";import{IntegratedMeshSemantics as a}from"../../../layers/support/IntegratedMeshSemantics.js";import{I3SMeshView3D as o}from"./I3SMeshView3D.js";import{LayerView3D as s}from"./LayerView3D.js";import{ElevationRange as c}from"../support/ElevationRange.js";import{updatingProgress as l}from"../support/updatingProperties.js";import{getGroundTransparencyModeFromOpacity as u}from"../terrain/TransparencyMode.js";import d from"../../layers/LayerView.js";import{alphaCutoff as f}from"../../../webscene/support/AlphaCutoff.js";let p=class extends o(s(d)){constructor(){super(...arguments),this.type=`integrated-mesh-3d`,this.visibleElevationRange=new c(1/0,-1/0),this._supportsLabeling=!1,this._applySSAO=!has(`disable-feature:im-ssao`)}get usedAsGround(){return this.layer.isUsedAsGroundLayer}get replacesTerrain(){return this.layer.replacesTerrain}get updatingProgressValue(){return this._controller?.updatingProgress??0}get lodFactor(){return this.view?.qualitySettings?.sceneService?.meshLoDFactor??1}get progressiveLoadFactor(){return this.lodFactor>=1?.2:1}get visibleAtCurrentScale(){return i(this.layer.effectiveScaleRange,this.view.scale)}get fullOpacity(){let e=a.opacitySource(this.layer);if(e!==`opaque`){let t=e===`ground`?this.view.map.ground.opacity:this.layer.opacity;return t===0&&!this.view.overlayManager.renderer.isEmpty?f:t}return 1}get opaque(){return this._groundTransparencyMode===0}get invisible(){return this._groundTransparencyMode===3}get _groundTransparencyMode(){let e=a.opacitySource(this.layer);if(e===`opaque`)return 0;let t=e===`ground`?this.view.map.ground.opacity:this.layer.opacity;return u(t,this.view.overlayManager.renderer.isEmpty)}get layerPopupEnabledAndHasTemplate(){return!1}get _elevationContext(){return a.shouldUseSceneElevationContext(this.layer)?2:1}get drapeTargetType(){return+!a.shouldDrapeRaster(this.layer)}initialize(){this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),t),this._updatingHandles.add(()=>this.layer.isUsedAsGroundLayer,()=>this._groundUsageChanged()),this.view.overlayManager.registerDrapeTarget(this)}_groundUsageChanged(){this._refreshGroundUsage(),this.view.overlayManager.unregisterDrapeTarget(this),this.view.overlayManager.registerDrapeTarget(this)}destroy(){this.view.overlayManager.unregisterDrapeTarget(this)}get ready(){return this.layer.loaded}_createLayerGraphic(){}canResume(){return super.canResume()&&(!this._controller||this._controller.rootNodeVisible)}_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.toArray(),t),`modifications`)}};e([n()],p.prototype,`layer`,void 0),e([n(l)],p.prototype,`updatingProgress`,void 0),e([n()],p.prototype,`updatingProgressValue`,null),e([n()],p.prototype,`lodFactor`,null),e([n({readOnly:!0})],p.prototype,`progressiveLoadFactor`,null),e([n({readOnly:!0})],p.prototype,`visibleAtCurrentScale`,null),e([n({readOnly:!0})],p.prototype,`visibleElevationRange`,void 0),e([n()],p.prototype,`fullOpacity`,null),e([n()],p.prototype,`opaque`,null),e([n()],p.prototype,`invisible`,null),p=e([r(`esri.views.3d.layers.IntegratedMeshLayerView3D`)],p);const m=p;export{m as default};
|