@arcgis/core 4.27.0-rc.2 → 4.27.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{a8565d1c676f3bfbcebb.js → 002fe1ec63ea33e6972d.js} +1 -1
- package/assets/esri/core/workers/chunks/09e677ca7532a281d262.js +1 -0
- package/assets/esri/core/workers/chunks/0f7ddb063ee0664f2fca.js +1 -0
- package/assets/esri/core/workers/chunks/17ab08f60764244b2cf8.js +1 -0
- package/assets/esri/core/workers/chunks/1aa8dd317ecd3c41e0ea.js +1 -0
- package/assets/esri/core/workers/chunks/28c67c98039503b62e6e.js +1 -0
- package/assets/esri/core/workers/chunks/{2446e336b1f7256d4fde.js → 2c587ed66e2586cccb8d.js} +1 -1
- package/assets/esri/core/workers/chunks/3767b9e7660873b018c2.js +1 -0
- package/assets/esri/core/workers/chunks/{00c7b9fb375c9a934158.js → 38c6452dc9cf18e8bca8.js} +1 -1
- package/assets/esri/core/workers/chunks/39ae4b9b766f674bc6f2.js +1 -0
- package/assets/esri/core/workers/chunks/45629ff775e77234b227.js +1 -0
- package/assets/esri/core/workers/chunks/{16db0bc87d87a7313dc4.js → 4806df402845c717c842.js} +1 -1
- package/assets/esri/core/workers/chunks/4884432d80e9af947449.js +1 -0
- package/assets/esri/core/workers/chunks/4a4f14a3d8da270059c4.js +1 -0
- package/assets/esri/core/workers/chunks/588cd91d08cec5207be1.js +1 -0
- package/assets/esri/core/workers/chunks/{83e3d104886b48f00397.js → 633c00c02a81397fc8df.js} +1 -1
- package/assets/esri/core/workers/chunks/{efb96aefe979a0f5c632.js → 640e8ac3498be30c6614.js} +1 -1
- package/assets/esri/core/workers/chunks/642c5a93c0a454bdd115.js +1 -0
- package/assets/esri/core/workers/chunks/{14145959a3dab1437818.js → 6627f1bc9ee6b620e3aa.js} +1 -1
- package/assets/esri/core/workers/chunks/{33901eb1574e46abd9af.js → 6c213768715c52625855.js} +1 -1
- package/assets/esri/core/workers/chunks/{5e6471dd2a08e66b47d0.js → 6e4940fe3bba014c921b.js} +57 -58
- package/assets/esri/core/workers/chunks/{170bdbdb4e21bf91a17f.js → 6eaa7a51efde2dd4a5a4.js} +1 -1
- package/assets/esri/core/workers/chunks/{0407bf97ad621c89a734.js → 6f724f75f85dc3989d60.js} +1 -1
- package/assets/esri/core/workers/chunks/{2bdc63395c7466ce1641.js → 7053c2f5a958d4c8629b.js} +1 -1
- package/assets/esri/core/workers/chunks/{4c35c663528f710e8c78.js → 79cb672c85ea29e8484a.js} +1 -1
- package/assets/esri/core/workers/chunks/82939ead43848a13f765.js +1 -0
- package/assets/esri/core/workers/chunks/8b05fb365336cc42fecc.js +1 -0
- package/assets/esri/core/workers/chunks/8b6b963230df56850580.js +1 -0
- package/assets/esri/core/workers/chunks/8eec6da5e862cc33ea2b.js +1 -0
- package/assets/esri/core/workers/chunks/90d8f297d9cb359e071d.js +1 -0
- package/assets/esri/core/workers/chunks/91785144901dfe56c5e2.js +1 -0
- package/assets/esri/core/workers/chunks/{471f6eba213412b82840.js → 927417abea79c955b216.js} +1 -1
- package/assets/esri/core/workers/chunks/9472184ef1432fc55d6b.js +1 -0
- package/assets/esri/core/workers/chunks/{adaa9d4239f4e905d011.js → 9d4bd73dd50400e9d328.js} +1 -1
- package/assets/esri/core/workers/chunks/a324cc07d486061d0d8e.js +1 -0
- package/assets/esri/core/workers/chunks/a40130579791293cefa2.js +1 -0
- package/assets/esri/core/workers/chunks/{3e239bfad611985e50fb.js → a49718c74053314ed741.js} +1 -1
- package/assets/esri/core/workers/chunks/a80a6267d88246ede5d3.js +1 -0
- package/assets/esri/core/workers/chunks/ad2891985e0fe45aa8d2.js +1 -0
- package/assets/esri/core/workers/chunks/afcba35eea836aea98ca.js +1 -0
- package/assets/esri/core/workers/chunks/b3d2e397ea74ebef4423.js +1 -0
- package/assets/esri/core/workers/chunks/b5fb9da45cc9dee286f8.js +1 -0
- package/assets/esri/core/workers/chunks/{f505ebd4bd3bfb6c790d.js → b6a55fdfe16795ebf02c.js} +1 -1
- package/assets/esri/core/workers/chunks/b846d4215210aac9f6ef.js +1 -0
- package/assets/esri/core/workers/chunks/c7dc821db8c14fec24a7.js +1 -0
- package/assets/esri/core/workers/chunks/c9df9a0a4a45f9a53ce9.js +1 -0
- package/assets/esri/core/workers/chunks/{45a4041881e6235d73a2.js → d0a9711f48dfa5fee68a.js} +1 -1
- package/assets/esri/core/workers/chunks/{1f69fb9687de9ebfcf90.js → d4ba894a2583f3930a4f.js} +1 -1
- package/assets/esri/core/workers/chunks/d5dfd3d693d5e393a542.js +1 -0
- package/assets/esri/core/workers/chunks/{74fd2059ddda9083cbcc.js → dc6c97a43d642eeaf477.js} +1 -1
- package/assets/esri/core/workers/chunks/e23ec4f867c4735eec20.js +1 -0
- package/assets/esri/core/workers/chunks/ea16230a0edfc9f756bd.js +1 -0
- package/assets/esri/core/workers/chunks/{2154d395f405be3cd3ba.js → eca0c3d57b3a1e3a14ee.js} +1 -1
- package/assets/esri/core/workers/chunks/ef900614353505afb210.js +1 -0
- package/assets/esri/core/workers/chunks/f36697f6aac782007d1a.js +1 -0
- package/assets/esri/core/workers/chunks/f52054f27619a98b7bb7.js +1 -0
- package/assets/esri/core/workers/chunks/fb7fe307a583b6a22218.js +1 -0
- package/assets/esri/core/workers/chunks/fbd3c78ee8e2219a6c7a.js +1 -0
- package/assets/esri/images/portal/livestreamvideolayer16.png +0 -0
- package/assets/esri/images/portal/{mediaservice16.png → videolayer16.png} +0 -0
- package/assets/esri/themes/base/_View.scss +2 -5
- package/assets/esri/themes/base/widgets/_Feature.scss +12 -4
- package/assets/esri/themes/base/widgets/_FeatureForm.scss +19 -2
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/DefaultMaterial.glsl.js +42 -42
- package/chunks/Terrain.glsl.js +7 -7
- package/copyright.txt +1 -1
- package/geometry/Mesh.js +1 -1
- package/geometry/support/DoubleArray.js +1 -1
- package/geometry/support/meshUtils/bounds.js +1 -1
- package/geometry/support/meshUtils/georeference.js +1 -1
- package/interfaces.d.ts +87 -3
- package/kernel.js +1 -1
- package/layers/OrientedImageryLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/VideoLayer.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/editingSupport.js +1 -1
- package/layers/graphics/sources/FeatureLayerSource.js +1 -1
- package/layers/graphics/sources/OGCFeatureSource.js +1 -1
- package/layers/graphics/sources/support/clientSideDefaults.js +1 -1
- package/layers/graphics/sources/support/uploadAssets.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/mixins/ImageryTileMixin.js +1 -1
- package/layers/orientedImagery/core/ExposurePoint.js +1 -1
- package/layers/orientedImagery/core/bestImageUtils.js +1 -1
- package/layers/orientedImagery/core/coverageUtils.js +1 -1
- package/layers/orientedImagery/transformations/groundToImageUtils.js +1 -1
- package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
- package/layers/support/SubtypeSublayer.js +1 -1
- package/layers/support/capabilities.js +1 -1
- package/layers/support/editableLayers.js +1 -1
- package/layers/support/layerUtils.js +1 -1
- package/layers/support/serviceCapabilitiesUtils.js +1 -1
- package/layers/video/VideoCameraSensorModel.js +5 -0
- package/layers/video/VideoController.js +1 -1
- package/layers/video/videoUtils.js +1 -1
- package/package.json +1 -1
- package/portal/PortalItem.js +1 -1
- package/renderers/support/colorRampUtils.js +1 -1
- package/request.js +1 -1
- package/rest/support/meshFeatureSet.js +1 -1
- package/smartMapping/labels/bins.js +5 -0
- package/smartMapping/labels/clusters.js +1 -1
- package/smartMapping/labels/support/utils.js +5 -0
- package/smartMapping/support/binningUtils.js +1 -1
- package/support/requestUtils.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/layers/features/schemaUtils.js +1 -1
- package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/I3SMeshViewLabeler.js +1 -1
- package/views/3d/layers/I3SMeshWorkerHandle.js +1 -1
- package/views/3d/layers/SceneLayerWorker.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/i3s/I3SClientMaterialUtil.js +5 -0
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SGeometryUtil.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +19 -20
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/TerrainTexture.glsl.js +9 -9
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
- package/views/DOMContainer.js +1 -1
- package/views/PopupView.js +1 -1
- package/views/ui/DefaultUI.js +1 -1
- package/views/ui/UI.js +1 -1
- package/webmap/initialViewPropertiesUtils.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/CreateWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/UpdateWorkflowData.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Feature/support/featureUtils.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
- package/widgets/FeatureForm/RelationshipInput.js +1 -1
- package/widgets/FeatureForm/css.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/FeatureTemplates/FeatureTemplatesViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/Popup.js +1 -1
- package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.d.ts +4 -0
- package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +1 -1
- package/widgets/UtilityNetworkValidateTopology.d.ts +4 -0
- package/widgets/support/geolocationUtils.js +1 -1
- package/assets/esri/core/workers/chunks/0610691a0c0d9fbbd6d2.js +0 -1
- package/assets/esri/core/workers/chunks/0618fb0058f39ecd363f.js +0 -1
- package/assets/esri/core/workers/chunks/0fcb8d408696075338e2.js +0 -1
- package/assets/esri/core/workers/chunks/16e459b16bdd6e1a821b.js +0 -1
- package/assets/esri/core/workers/chunks/1b8074269800b384ecf6.js +0 -1
- package/assets/esri/core/workers/chunks/2b55295590b4a0503749.js +0 -1
- package/assets/esri/core/workers/chunks/3ba2fcb9110230f8790c.js +0 -1
- package/assets/esri/core/workers/chunks/5576858f56314afcb4d5.js +0 -1
- package/assets/esri/core/workers/chunks/5706edf45402dff279a6.js +0 -1
- package/assets/esri/core/workers/chunks/624521961fe1f2c4f2c5.js +0 -1
- package/assets/esri/core/workers/chunks/659b7bad7281c0e2aed3.js +0 -1
- package/assets/esri/core/workers/chunks/6cd248d065f6d1616294.js +0 -1
- package/assets/esri/core/workers/chunks/6f510f28526c73ab453c.js +0 -1
- package/assets/esri/core/workers/chunks/7479dc0c790337af7597.js +0 -1
- package/assets/esri/core/workers/chunks/9326120c750799eb2d28.js +0 -1
- package/assets/esri/core/workers/chunks/99e0cec47e3ef72c1de4.js +0 -1
- package/assets/esri/core/workers/chunks/9c0e1e87790424f42d7e.js +0 -1
- package/assets/esri/core/workers/chunks/9e66af3b1c70cf25fb32.js +0 -1
- package/assets/esri/core/workers/chunks/a1c31bb8c12831539328.js +0 -1
- package/assets/esri/core/workers/chunks/a7fd2a95fde197c06828.js +0 -1
- package/assets/esri/core/workers/chunks/b0cda39b53ecd6c44cd0.js +0 -1
- package/assets/esri/core/workers/chunks/b8e6c64792a512df4c4d.js +0 -1
- package/assets/esri/core/workers/chunks/c08e03165043df67c11b.js +0 -1
- package/assets/esri/core/workers/chunks/c26148d4bfab3b3dfab2.js +0 -1
- package/assets/esri/core/workers/chunks/c96db6b7ce47bd343fdb.js +0 -1
- package/assets/esri/core/workers/chunks/d6b6bb8aecc85d2a3f6b.js +0 -1
- package/assets/esri/core/workers/chunks/d95ca50ca7af4c222036.js +0 -1
- package/assets/esri/core/workers/chunks/da57eba2fe25495ea217.js +0 -1
- package/assets/esri/core/workers/chunks/ee5ee03dd2c7dc940272.js +0 -1
- package/assets/esri/core/workers/chunks/eeaf8010e38b65a101ac.js +0 -1
- package/assets/esri/core/workers/chunks/f235392c56063fbf89c6.js +0 -1
- package/assets/esri/core/workers/chunks/f720967ba8c5486a26a2.js +0 -1
- package/assets/esri/core/workers/chunks/fdd0d3616c97e408b104.js +0 -1
- package/layers/orientedImagery/core/Affixes.js +0 -5
- package/layers/orientedImagery/core/CameraProperties.js +0 -5
- package/layers/orientedImagery/core/ImageProperties.js +0 -5
- package/layers/orientedImagery/core/ImageryTypes.js +0 -5
- package/layers/orientedImagery/core/imageryUtils.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../Graphic.js";import{isSome as s,removeUnordered as r}from"../../../core/arrayUtils.js";import{ByteSizeUnit as o}from"../../../core/ByteSizeUnit.js";import a from"../../../core/Collection.js";import has from"../../../core/has.js";import n from"../../../core/Logger.js";import{someMap as l}from"../../../core/MapUtils.js";import{destroyMaybe as d,applySome as h}from"../../../core/maybe.js";import c from"../../../core/PooledArray.js";import{isAbortError as u,throwIfAborted as _,createResolver as m}from"../../../core/promiseUtils.js";import{initial as g,watch as p}from"../../../core/reactiveUtils.js";import{schedule as f}from"../../../core/scheduling.js";import{isArrayBuffer as b}from"../../../core/typedArrayUtil.js";import{getMetersPerVerticalUnitForSR as y}from"../../../core/unitUtils.js";import{property as v}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as I}from"../../../core/accessorSupport/decorators/subclass.js";import{f as M}from"../../../chunks/mat3.js";import{c as C}from"../../../chunks/mat3f64.js";import{m as O,B as x}from"../../../chunks/mat4.js";import{b as E,c as j}from"../../../chunks/mat4f64.js";import{f as w}from"../../../chunks/quatf64.js";import{m as S,s as A,a as T,t as D,c as R,g as N,b as F}from"../../../chunks/vec3.js";import{c as V}from"../../../chunks/vec3f64.js";import{s as P}from"../../../chunks/vec4.js";import{f as H}from"../../../chunks/vec4f64.js";import{getReferenceEllipsoid as U}from"../../../geometry/ellipsoidUtils.js";import{projectBuffer as G,getProjectorName as L,localLinearScaleFactors as k,projectVectorToVector as B,projectBoundingSphere as q}from"../../../geometry/projection.js";import{create as z,empty as K,expandWithBuffer as W,toRect as $}from"../../../geometry/support/aaBoundingBox.js";import{create as Q,intersects as X}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as Y}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as J}from"../../../geometry/support/FloatArray.js";import{compactIndices as Z}from"../../../geometry/support/Indices.js";import{f as ee}from"../../../chunks/sphere.js";import{newUByteArray as te}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as ie}from"../../../layers/LayerConstants.js";import se from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as re}from"../../../layers/support/fieldUtils.js";import oe from"../../../layers/support/SceneModification.js";import{getColor as ae,getOpacity as ne}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{loadArcade as le}from"../../../support/arcadeOnDemand.js";import de from"../../../symbols/Symbol3D.js";import{getMetersPerUnit as he}from"../../../symbols/support/unitConversionUtils.js";import ce from"./I3SMeshViewLabeler.js";import{I3SMeshWorkerHandle as ue,toWasmModification as _e}from"./I3SMeshWorkerHandle.js";import{ForAllFeaturesReturnType as me,ForAllFeaturesMode as ge}from"./II3SMeshView3D.js";import{initialize as pe,setModificationsSync as fe,filterObbsForModificationsSync as be,interpretObbModificationResults as ye}from"./SceneLayerWorker.js";import{overrideColor as ve}from"./graphics/graphicUtils.js";import{areLabelsVisible as Ie}from"./graphics/Labeler.js";import{TextureUsage as Me,TextureEncoding as Ce}from"./i3s/enums.js";import Oe from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as xe}from"./i3s/I3SAsyncElevationUpdater.js";import{I3SCrossfadeHelper as Ee,NodeCrossfadeMetaData as je}from"./i3s/I3SCrossfadeHelper.js";import we from"./i3s/I3SElevationProvider.js";import{boundingBoxCornerPoints as Se}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Ae}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Te,selectEncoding as De,defaultMaterial as Re,createTexture as Ne,configureMaterial as Fe}from"./i3s/I3SMaterialUtil.js";import{NodeIMModificationImpact as Ve,NodeState as Pe}from"./i3s/I3SNode.js";import{I3SOverrides as He}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as Ue,getLocalOrigin as Ge}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as Le,checkSceneLayerValid as ke,checkSceneLayerCompatibleWithView as Be,getCacheKeySuffix as qe,whenGraphicAttributes as ze,computeVisibilityObb as Ke,filterInPlace as We,getCachedAttributeValue as $e,intersectBoundingRectWithMbs as Qe,MbsIntersectResult as Xe,addWraparound as Ye,getSymbolInfo as Je,transparentEdgeMaterial as Ze,getClipRect as et}from"./i3s/I3SUtil.js";import{IDBCache as tt}from"./i3s/IDBCache.js";import{IDBMockCache as it}from"./i3s/IDBMockCache.js";import{attributeLookup as st}from"./support/attributeUtils.js";import{ColorMixModeEnum as rt}from"./support/symbolColorUtils.js";import ot from"../support/debugFlags.js";import{toBoundingRect as at}from"../support/extentUtils.js";import{create as nt,intersectSphere as lt,clone as dt}from"../support/orientedBoundingBox.js";import{updatingProgress as ht}from"../support/updatingProperties.js";import{glLayout as ct}from"../support/buffer/glUtil.js";import{State as ut}from"../webgl-engine/collections/Component/ComponentObject.js";import{createVertexBufferLayout as _t}from"../webgl-engine/collections/Component/SourceGeometry.js";import{TextureCoordinateAttributeType as mt}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{loadBasis as gt}from"../webgl-engine/lib/BasisUtil.js";import{Transparency as pt}from"../webgl-engine/lib/edgeRendering/interfaces.js";const ft="esri.views.3d.layers.I3SMeshView3D",bt=n.getLogger(ft),yt=[1,1,1,1];class vt extends je{constructor(e,t,i,s,r,o,a,n,l){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=a,this.anchorIds=n,this.anchors=l,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0}}var It;!function(e){e[e.CastShadows=4]="CastShadows",e[e.Pickable=5]="Pickable"}(It||(It={}));const Mt=20,Ct=100*o.MEGABYTES,Ot=t=>{let o=class extends t{constructor(...e){super(e),this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._idbCache=has("enable-feature:idb-mock-cache")?new it:new tt("esri-scenelayer-cache","geometries"),this._hasComponentData=!1,this._hasVertexColors=!1,this.updating=!0,this.holeFilling="auto",this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=new Array,this.ignoresMemoryFactor=!1,this._layerUrl="",this._cacheKeySuffix=null,this._elevationTask=null,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i(null,null,{}),this._crossfadeHelper=new Ee(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerUid(){return this.i3slayer&&this.i3slayer.uid}get sublayerUid(){return null}get layerId(){return this.i3slayer&&this.i3slayer.id}get sublayerId(){return null}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?"yes":"probably-not":"unknown"}get rendererTextureUsage(){return Le(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?Me.AllTexturesPBR:Me.AllTextures:this._usePBR||this._hasLoadedPBRTextures?Me.GeometryTexturesPBR:Me.GeometryTextures}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null!=e&&"absolute-height"===e.mode){const t=y(this.i3slayer.spatialReference),i=he(e.unit);return(e.offset??0)*i/t}return 0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return{mode:kt.Absolute,offset:0};const t=y(this.i3slayer.spatialReference),i=he(e.unit),s=(e.offset??0)*i/t;switch(e.mode){case"absolute-height":return{mode:kt.Absolute,offset:s};case"relative-to-ground":return{mode:kt.RelativeToGround,offset:s};case"on-the-ground":return{mode:kt.OnTheGround,offset:0};default:return{mode:kt.Absolute,offset:0}}}get supportedTextureEncodings(){return Te(this.view._stage.renderView.capabilities)}get uncompressedTextureDownsamplingEnabled(){const e=this.view?.qualitySettings.sceneService.uncompressedTextureDownsamplingEnabled,t=0==(this.supportedTextureEncodings&Ce.DDS_S3TC);return e&&t}get clientGeometry(){return this.i3sOverrides.geometryOverrides}initialize(){this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const e=this.view.resourceController,t=e.memoryController;this.i3sOverrides=new He({view:this.view,layer:this.i3slayer,memoryController:t}),this._worker=new ue(Kt(e)),this.addResolvingPromise(this._worker.promise);const i=this.i3slayer.store;this._worker.setLegacySchema(this.uid,i.defaultGeometrySchema),ke(this.i3slayer),Be(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new se({layerView:this}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view._stage,this._collection=this._stage.renderView.componentObjectCollection,this.resetHighlights();const s=i.defaultGeometrySchema;if(this._isIntegratedMesh||!s)this._hasComponentData=!1;else{const e=s.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(s?.vertexAttributes.color??null)&&(null==this.i3slayer.cachedDrawingInfo||!this.i3slayer.cachedDrawingInfo.color),this._isIntegratedMesh||(this._edgeView=this._stage.renderer.ensureEdgeView());const r=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,(e=>this._deleteComponentObject(e)));this._memCache=r;const o=e=>null!=this._controller.index&&null!=this._controller.index.rootNode?this._controller.index.traverse(this._controller.index.rootNode,(t=>{const i=t.index,s=this._nodeId2Meta.get(i)||this._nodeId2MetaReloading.get(i);return e(t,null!=s?s.objectHandle:null)})):()=>{};this._intersectionHandler=new Ae({layerUid:this.layerUid,sublayerUid:this.sublayerUid,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:o}),this.updatingHandles.add((()=>this.layerUid),(e=>this._intersectionHandler.layerUid=e)),this.updatingHandles.add((()=>this.sublayerUid),(e=>this._intersectionHandler.sublayerUid=e)),this._elevationProvider=new we({layerView:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this.updatingHandles.add((()=>this.view.clippingArea),(()=>this._clippingAreaChanged()),g),this.updatingHandles.add((()=>this.fullOpacity),(e=>this._opacityChange(e))),this.updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this.updatingHandles.add((()=>this.elevationOffset),((e,t)=>{this._reloadAll(t),this._controller.invalidateVisibilityObbs()})),this.updatingHandles.add((()=>this.elevationInfo),((e,t)=>this._elevationInfoChanged(e,t)),g),this.updatingHandles.add((()=>this.contentVisible&&this.elevationInfo.mode!==kt.Absolute),((e,t)=>{e?this.handles.add(this.view.basemapTerrain.on("elevation-change",(({extent:e})=>this._ensureElevationTask().addExtent(e))),zt):t&&this.handles.remove(zt)}),g),this.updatingHandles.add((()=>this._usePBR),(e=>this._updatePBR(e)));const a=()=>{this._reloadAll(),this.clearMemCache()};this.updatingHandles.add((()=>this.rendererTextureUsage),a),this.updatingHandles.add((()=>this.uncompressedTextureDownsamplingEnabled),a),this.updatingHandles.add((()=>this.contentVisible),(e=>this._contentVisibleChanged(e)),g),this.updatingHandles.add((()=>this.i3slayer.labelsVisible),(()=>this._labelingChanged()),g),this.updatingHandles.add((()=>this.i3slayer.labelingInfo),(()=>this._labelingChanged()),g),this.updatingHandles.add((()=>this._modifications),(()=>this._modificationsChanged()),g),this.handles.add([p((()=>ot.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&&ot.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||ot.I3S_TREE_SHOW_TILES||(this._treeDebugger=d(this._treeDebugger))}),g),p((()=>ot.I3S_SHOW_MODIFICATIONS),(()=>this._showModifications()),g)]),this._cacheKeySuffix=qe(this.i3slayer.spatialReference,this.view.renderSpatialReference),this._idbCache.init().catch((e=>bt.warn(`Failed to initialize IndexedDB cache: ${e}`)))}destroy(){this._clearAddTasks(),this._elevationTask=d(this._elevationTask),this.i3sOverrides=d(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.layerChanged(),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._worker;e&&(e.destroyContext(this.uid).then((()=>e.destroy())),this._worker=null),this._removeAllNodeDataFromStage(),this._memCache=d(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=d(this._labeler),this._treeDebugger=d(this._treeDebugger),this._controller=d(this._controller),this._highlights.destroy(),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=d(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null)}_memEstimateTextureAdded(e){const t=e.memoryEstimate;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(null!=e){const t=e.memoryEstimate;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){const t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){const t=this._collection.getObjectGPUMemoryUsage(e);this._gpuMemoryEstimate-=t,this._geoMemoryEstimate-=t}isNodeLoaded(e){return this._nodeId2Meta.has(e)}isNodeReloading(e){return this._nodeId2MetaReloading.has(e)}get usedMemory(){let e=null!=this._labeler?this._labeler.usedMemory:0;return this._nodeId2Meta.forEach((t=>e+=null!=t?t.node.memory:0)),this._nodeId2MetaReloading.forEach((t=>e+=null!=t?t.node.memory:0)),e}get unloadedMemory(){return(null!=this._controller?this._controller.unloadedMemoryEstimate:0)+(null!=this._labeler?this._labeler.unloadedMemoryEstimate:0)}_labelingChanged(){if(!(Ie(this.i3slayer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new ce({view:this.view,layer:this.i3slayer,collection:this._collection});this._nodeId2Meta.forEach((t=>null!=t&&this._addMetaToLabeler(e,t))),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then((e=>(--this._asyncModuleLoading,e)),(e=>{throw--this._asyncModuleLoading,e}))}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=pe().then((()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()})),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=this.uid,t=this.i3slayer.spatialReference;this._worker.setModifications(e,this._layerClippingArea,this._modifications,t);const i=_e(this._layerClippingArea,this._modifications,t);fe({context:e,modifications:i,isGeodetic:t.isGeographic}),this._controller.modificationsChanged();const s=this.hasModifications?new c:null;this._nodeId2Meta.forEach(((e,t)=>{null==e?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):null!=s&&s.push(e.node)})),null!=s&&this._nodeId2MetaReloading.forEach((e=>s.push(e.node))),null!=s&&s.length>0&&(this.updateNodeModificationStatus(s),s.forAll((e=>{if(e.imModificationImpact!==Ve.Culled){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),null!=t?(this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t)):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}}))),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(null!=this._modificationGraphics&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!ot.I3S_SHOW_MODIFICATIONS||0===this._modifications.length)return;const e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={type:"simple-fill",outline:{color:[255,255,255],width:1}};this._modificationGraphics=new Array;for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.i3slayer.spatialReference;const o={...t,color:e[s.type]};this._modificationGraphics.push(new i({geometry:r,symbol:o}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,((e,t)=>this._createAttributes(e,t)))}_contentVisibleChanged(e){e?(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler)):(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){const t=this._nodeId2Meta.get(e);if(null!=t&&null!=t.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(null!=t&&null!=t.attributeInfo)return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);null!=i&&null!=i.attributeInfo&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);null!=s&&(await this.i3sOverrides.applyAttributeOverrides(s.featureIds,t,i),s.attributeInfo=t,this._controller.reschedule((()=>this._attributeValuesChanged(s)),i).catch((e=>{u(e)||bt.warn("Error while updating attribute values. Layer might not display correctly.",e)})))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.filteredIds=null,null!=this._labeler&&this._labeler.setNodeMetaAttributes(e,((e,t)=>this._createAttributes(e,t))),this._updateEngineObject(e)}clearMemCache(){null!=this._memCache&&this._memCache.clear()}getVisibleNodes(){const e=new Array;return this._nodeId2Meta.forEach((t=>null!=t&&e.push(t.node))),e}getNodeComponentObb(e){const t=this._nodeId2Meta.get(e.index)??this._nodeId2MetaReloading.get(e.index);return null!=t?this._collection.getComponentObb(t.objectHandle):null}getLoadedNodeIndices(e){this._nodeId2Meta.forEach(((t,i)=>e.push(i))),this._nodeId2MetaReloading.forEach(((t,i)=>e.push(i)))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&0!=(this.supportedTextureEncodings&Ce.Basis)&&h(this.i3slayer.textureSetDefinitions,(e=>e.some((e=>e.formats.some((e=>"basis"===e.format||"ktx2"===e.format))))))&>()}_getVertexBufferLayout(e,t){const i={hasTexture:Nt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion};return ct(_t(this._getGeometryParameters(i)))}_getObjectIdField(){return this.i3slayer.objectIdField||ie}_getGlobalIdField(){return this.i3slayer.associatedLayer?.globalIdField}_findGraphicNodeAndIndex(e){const t=st(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());let i=null;return l(this._nodeId2Meta,(e=>{if(null==e)return!1;const s=e.featureIds.indexOf(t);return-1!==s&&(i={node:e.node,index:s},!0)})),i}_getGraphicIndices(e,t){const i=this._nodeId2Meta.get(e.index);if(null==i)return[];const s=[],r=this._getObjectIdField(),o=this.i3slayer.fieldsIndex;for(const a of t){const e=st(o,a.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this._getAABB(t.node.index,t.index);return null==i?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this._getAABB(e.nodeIndex,e.componentIndex)}_getAABB(e,t){const i=this._nodeId2Meta.get(e);if(null==i||null==i.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=Se(t,this._collection,s,Y(24)),o=this.view.renderSpatialReference,a=this.view.spatialReference;if(!G(r,o,0,r,a,0,8))return null;const n=K();return W(n,r,0,8),n}whenGraphicAttributes(e,t){return ze(this.i3slayer,e,this._getObjectIdField(),t,(()=>[...this._nodeId2Meta.values()].filter(s)))}getGraphicFromIntersectorTarget(e){if(null==e.nodeIndex||null==e.componentIndex)return null;const t=this._nodeId2Meta.get(e.nodeIndex);return null==t||null==t.featureIds||e.componentIndex>=t.featureIds.length?null:this._createGraphic(e.componentIndex,t)}_getCacheKey(e){return`${this._layerUrl}/v${Mt}/${e}${this._cacheKeySuffix}`}_getMemCacheKey(e,t=this.elevationOffset){return e+"#"+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&0===this.elevationOffset&&null!=this._cacheKeySuffix}loadCachedGPUData(e){return null!=this._memCache?this._memCache.pop(this._getMemCacheKey(e)):null}deleteCachedGPUData(e){null!=e&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(null==this._memCache)return void this._deleteComponentObject(e);const i=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,e.node.memory,i)}loadMissingTextures(e,t,i,s){const r=e?.filter(((e,i)=>{if(0==(e.usage&this.rendererTextureUsage))return!1;if(null==t)return!0;const s=De(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(null==r||null==r.data||s&&r.encoding!==s.encoding)}))??[];return 0===r.length?Promise.resolve(!1):i(r,s).then((i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0}))}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then((s=>null==s?null:s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(this.elevationInfo.mode===kt.Absolute&&(e.geometryObb=s.geometryObb),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then((i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=Pt(s.transformedGeometry,s.textureData),s.textureData.every(Vt)&&Ht(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch((t=>bt.warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`)))),_(t),s)))))):Promise.resolve(null)}addNode(e,t,i){return Ft(t)?null==t.geometryBuffer?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,(()=>this._transformNode(e,t,i).then((s=>this._safeReschedule((()=>{if(null==s)return e.hasModifications=!1,this._addCachedNodeData(e,null,i);e.hasModifications=s.transformedGeometry.hasModifications;const{obb:r,componentOffsets:o,featureIds:a,anchorIds:n,anchors:l,transformedGeometry:d}=s,h=this._controller.crsIndex,c=this.view.renderSpatialReference,u=Ue(e.mbs,this.elevationOffset,h,c),_=nt([r.center.x,r.center.y,r.center.z],[r.extents.x,r.extents.y,r.extents.z],w(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));S(_.center,_.center,u),this.elevationInfo.mode===kt.Absolute&&(e.geometryObb=_),t.geometryData.componentOffsets=o,a&&(t.geometryData.featureIds=Array.from(a)),t.geometryData.anchorIds=n,t.geometryData.anchors=l;const m={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:d,globalTrafo:u,geometryObb:_,byteSize:Pt(d,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&Ht(e,m)){const t=null!=m.textureData?m.textureData.map((e=>Vt(e)?e:null)):null;this._idbCache.put(this._getCacheKey(e.id),{...m,textureData:t}).catch((t=>bt.warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`)))}return this._addCachedNodeData(e,m,i)}),i))))):Promise.reject()}getElevationRange(e){let t=1/0,i=-1/0;const s=U(this.view.renderCoordsHelper.spatialReference);return this._nodeId2Meta.forEach((r=>{if(null!=r&&null!=r.node.geometryObb){const o=r.node.geometryObb;if(lt(o,e)){const e=this._collection.getObjectTransform(r.objectHandle),o=this.view.renderCoordsHelper.getAltitude(e.position);for(let a=0;a<r.featureIds.length;a++){const e=this._collection.getComponentAabb(r.objectHandle,a,qt);if("local"===this.view.viewingMode)t=Math.min(t,o+e[2]),i=Math.max(i,o+e[5]);else{t=Math.min(t,o+e[2]);const r=Math.max(Math.abs(e[3]),Math.abs(e[0])),a=Math.max(Math.abs(e[4]),Math.abs(e[1])),n=o+e[5]+s.radius;i=Math.max(i,Math.sqrt(r*r+a*a+n*n)-s.radius)}}}}})),{min:t,max:i}}computeVisibilityObb(e){return Ke(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let g=0;g<s.length;++g)r[g]=this._getVertexBufferLayout(s[g],t.geometryDescriptor);const o=e.mbs,a=this.elevationOffset,n=this._controller.crsIndex,l=this._controller.crsVertex,d=this.view.renderSpatialReference,h=Ge(o,a,n),c=Ue(o,a,n,d),u=L(n,l),_=L(l,d);if(null==u||null==_)return Promise.resolve(null);const m={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,localOrigin:h,globalTrafo:c,mbs:o,obb:e.serviceObb,elevationOffset:a,needNormals:!this._isIntegratedMesh&&this._controller.isMeshPyramid,normalReferenceFrame:this.i3slayer.normalReferenceFrame||"none",indexToVertexProjector:u,vertexToRenderProjector:_};return this._worker.invoke(m,i)}get _supportsNodeCrossFading(){return!this.view?._stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){const t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,i){if(this.elevationInfo.mode===kt.Absolute&&(e.geometryObb=dt(this._collection.getComponentObb(t.objectHandle))),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);null!=this._labeler&&this._addMetaToLabeler(this._labeler,t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,ut.Visible),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==kt.Absolute&&this._ensureElevationTask().schedule(s),this._updateEngineObject(t),this._highlights.objectCreated(t),null!=this._treeDebugger&&this._treeDebugger.update()}addCachedNodeData(e,t,i,s){return this._addData(e,i,(()=>this._addCachedNodeData(e,t,s)))}async deleteCachedNodeData(e){if(this._idbCacheEnabled)return this._idbCache.remove(this._getCacheKey(e))}async _addCachedNodeData(e,t,i){if(!this.contentVisible||!this._controller.isGeometryVisible(e))return void this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);if(null==t)return void this._addNodeMeta(e.index,null);const s=this._addTasks.get(e.index),{geometryData:r,transformedGeometry:o,globalTrafo:a}=t;await this.i3sOverrides.applyAttributeOverrides(r.featureIds,s.attributeInfo,i);const n=null!=t.textureData?t.textureData.filter((e=>null!=e&&0!=(e.usage&this.rendererTextureUsage))):[];!has("disable-feature:i3s-basis")&&n.some((e=>null!=e&&(e.encoding===Ce.Basis||e.encoding===Ce.KTX2)))&&await gt(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:h,anchorIds:c,anchors:u}=r,_=this._collection,m=d[0],{layout:g,indices:p,interleavedVertexData:f,positionData:b,hasColors:y}=o,v=this._materialParameters(m,g),I=l||new Uint32Array([0,p?p.length:f.byteLength/g[0].stride]),w={vertices:{data:f,count:f.byteLength/g[0].stride,layoutParameters:v.geometryParams},positionData:{positions:J(b.data),indices:Z(b.indices)},indices:p,componentOffsets:I},S=m.transformation?E(m.transformation):j();O(S,a,S);const A=x(V(),S),T=M(C(),S),D=this.view.renderSpatialReference,R=this.view.basemapTerrain.spatialReference,N=V(),F=[1,1,1];k(A,D,F,R)||bt.errorOnce("Unsupported coordinate system for IM overlay"),B(A,D,N,R);const P=_.createObject({toMapSpace:H(N[0],N[1],F[0],F[1]),geometry:w,obb:t.geometryObb,transform:{position:A,rotationScale:T}}),U=v.geometryParams.textureCoordinates===mt.Atlas,{textures:G,texturePromise:L}=this._initMaterialAndTextures(P,v.material,n,U);e.memory+=this._memEstimateGeometryAdded(P),e.memory+=G.reduce(((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0)),0);const q=!!v.material.hasParametersFromSource,z="blend"!==v.material.alphaMode&&v.material.metallicRoughness.baseColorFactor[3]>=1,K=new vt(e,h,P,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:q,isOpaque:z},G,c,u);s.meta=K,!this._hasTextures&&t.requiredTextures?.some((({usage:e})=>0!=(e&Me.ColorTextures)))&&(this._hasTextures=!0),this._hasData=!0,this._hasColors=this._hasColors||y,this._hasTextures=this._hasTextures||!!e.resources.texture,this.notifyChange("hasTexturesOrVertexColors");const W=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(K),L]).then((([t,s])=>(null!=t&&t.updateObjectVisibility(K.objectHandle,!1).catch((e=>xt(e,this.i3slayer.title))),this._safeReschedule((()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,K),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(P,ut.Visible),null!=t&&t.updateObjectVisibility(K.objectHandle,!0).catch((e=>xt(e,this.i3slayer.title))),K.attributeInfo=i.attributeInfo;const s=K.cachedRendererVersion!==this._rendererVersion,r=W!==this.slicePlaneEnabled;this._updateElevationOffsets(K);const o=K.elevationOffsets;this._updateComponentData(K);const a=this._applyFiltersToNode(K);(s||null!=t&&(r||a||o))&&this._addOrUpdateEdgeRendering(K),null!=this._labeler&&this._addMetaToLabeler(this._labeler,K),this._visibleGeometryChanged(K,Et.ADD),this._highlights.objectCreated(K),this._updateMaterial(K),this._setNewNodeOpacity(K),null!=this._treeDebugger&&this._treeDebugger.update()}),i)))).catch((e=>{throw null!=s.meta&&(this._cacheGPUData(s.meta),s.meta=null),e}))}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){bt.error("Removing duplicated node");const t=this._nodeId2Meta.get(e);null!=t&&this._deleteComponentObject(t)}else this._controller.updateLoadStatus(e,!0);null!=t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&Lt(t.cachedEdgeMaterials,0)),this._nodeId2Meta.set(e,t)}_updateElevationOffsets(e){const t=this.view.renderSpatialReference,i=this._controller.crsIndex,s=this.elevationInfo,r=this.view.basemapTerrain,o=r.spatialReference,a=s.mode;if(null==t||null==o||a===kt.Absolute)return void(e.elevationOffsets=null);const n=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const l=Bt,d=qt,h=a===kt.OnTheGround,c=this.view.renderCoordsHelper,u=e.featureIds.length,_=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const s=Y(3*u);e.cachedElevationAnchors=s;for(let r=0;r<u;r++){const a=3*r,h=e.anchorIds?.indexOf(r)??-1;e.anchors&&h>=0?(A(l,e.anchors[3*h],e.anchors[3*h+1],e.anchors[3*h+2]),T(l,l,e.node.mbs),B(l,i,l,o),s[a]=l[0],s[a+1]=l[1],s[a+2]=c.getAltitude(l)):(this._collection.getComponentAabb(e.objectHandle,r,d,!0),A(l,(d[0]+d[3])/2,(d[1]+d[4])/2,d[2]),D(l,l,n.rotationScale),T(l,l,n.position),s[a+2]=c.getAltitude(l),B(l,t,l,o),s[a]=l[0],s[a+1]=l[1])}return s})(),m=s.offset,g=e.elevationOffsets,p=(e,t)=>{const i=h?_[3*e+2]:0;g[e]=m+(null!=t?t-i:0)};r.getElevations(_,u,p)}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new xe(this.view.resourceController.scheduler,(e=>{const t=this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference);return null!=t?t.filterInPlace((e=>null!=this._nodeId2Meta.get(e))):null}),(e=>{const t=this._nodeId2Meta.get(e);this._nodeElevationAlignmentChanged(t)}))),this._elevationTask}_elevationInfoChanged(e,t){const i=e.mode!==kt.Absolute,s=!!t&&t!==e&&t.mode!==kt.Absolute;this._intersectionHandler.updateElevationAlignState(i,this.view.state.viewingMode),i&&!s&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach((e=>this._nodeElevationAlignmentChanged(e)))}_nodeElevationAlignmentChanged(e){null!=e&&(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),null!=this._labeler&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,Et.UPDATE))}_safeReschedule(e,t){return _(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:Re(),s=t.some((e=>"uvRegion"===e.name)),r=t.some((e=>"normalCompressed"===e.name)),o=Nt(i);return{geometryParams:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s){const r=this._stage.renderView,o=i.map((e=>Ne(e,t,s,r)));this._stage.addMany(o);let a=null;return this._collection.updateMaterial(e,(e=>{a=Fe(e,t,o,i,this.view._stage.renderView.textureRepository,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference}),this._updateMaterialOverlay(e)})),{textures:o,texturePromise:a}}_getGeometryParameters(e){return{textureCoordinates:e.hasTexture?e.hasRegions?mt.Atlas:mt.Default:mt.None,colors:this._hasVertexColors,normals:e.hasNormals&&!this._isIntegratedMesh}}_addData(e,t,i){let s=this._addTasks.get(e.index);return s?s.attributeInfo=t:(s={...m(),attributeInfo:t,meta:null},this._addTasks.set(e.index,s),i().then(s.resolve,s.reject).then((()=>this._addTasks.delete(e.index))).catch((t=>{throw this._addTasks.delete(e.index),t}))),s.promise}_clearAddTasks(){this._addTasks.forEach((e=>{null!=e.meta&&(this._cacheGPUData(e.meta),e.meta=null)})),this._addTasks.clear()}_clippingAreaChanged(){const e=this.view.renderSpatialReference,t=this.i3slayer.spatialReference,i=Q();this._renderClippingArea=at(this.view.clippingArea,i,e)?i:null;const s=Q();this._layerClippingArea=at(this.view.clippingArea,s,t)?s:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){const e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e)}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach((e=>{null!=e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Et.UPDATE))}))}getFilters(){const e=[],t=this._renderClippingArea;return null!=t&&e.push(((e,i)=>this._boundingRectFilter(e,i,t))),e}addSqlFilter(e,t,i){if(null!=t){const s=t.fieldNames;e.push(((e,r)=>this._sqlFilter(e,r,t,s,i)))}}_sqlFilter(e,t,i,s,r){const o={},a=this._createLayerGraphic(o),n=this.i3slayer.objectIdField,l=t.featureIds,d=null!=t.attributeInfo&&t.attributeInfo.attributeData;s.every((e=>e===n||d&&null!=d[e]))&&We(e,l,(e=>{o[n]=l[e];for(const i of s)i!==n&&(o[i]=d?$e(d[i],e):null);try{return i.testFeature(a)}catch(t){return r(t),!1}}))}_boundingRectNodeTest(e,t){return q(e.node.mbs,this._controller.crsIndex,Rt,this.view.renderSpatialReference),Qe(t,Rt)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,jt),$(jt,wt),X(i,wt)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(r===Xe.INSIDE)return;if(r===Xe.OUTSIDE)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const a=this._transformClippingArea(St,i,t.objectHandle);We(e,t.featureIds,(e=>this._boundingRectFeatureTest(t,e,a)))}_transformClippingArea(e,t,i){const s=this._collection.getObjectTransform(i),r=s.position,o=s.rotationScale;return e[0]=(t[0]-r[0])/o[0],e[1]=(t[1]-r[1])/o[4],e[2]=(t[2]-r[0])/o[0],e[3]=(t[3]-r[1])/o[4],e}_addOrUpdateEdgeRendering(e,t=!0){const i=this._edgeView;if(null==i)return Promise.resolve(null);const s=e.objectHandle,r=i.hasObject(s),{hasEdges:o,perFeatureEdgeMaterials:a}=this._getFilteredEdgeMaterials(e),n={hasSlicePlane:this.slicePlaneEnabled};if(o&&r){if(this.nodeCrossfadingEnabled){Lt(a,this.getNodeOpacity(e))}return i.updateAllComponentMaterials(s,a,n,t).catch((e=>xt(e,this.i3slayer.title))),i.updateObjectVisibility(s,!0).catch((e=>xt(e,this.i3slayer.title))),i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>xt(e,this.i3slayer.title))),Promise.resolve(i)}return o&&!r?this._collection.addEdges(s,i,a,n).then((t=>(e.edgeMemoryUsage=t,e.node.memory+=t,i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>xt(e,this.i3slayer.title))),i))):(!o&&r&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,i.removeObject(s)),Promise.resolve(null))}_applyFiltersToNode(e){return!!this._applyFiltersToNodeComponents(e)&&(null!=this._labeler&&this._labeler.applyFilterChange(e),!0)}_applyFiltersToNodeComponents(e){const t=this._collection,i=0===t.getComponentCount(e.objectHandle).invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!i;if(this._updateCachedFilteredIds(e),e.filteredIds===e.featureIds)return!i;const s=this._computeFilteredComponentIndices(e);return t.setAllComponentVisibilities(e.objectHandle,s),!0}_updateCachedFilteredIds(e){null!=e.filteredIds&&e.appliedFilters===this._filters||(e.filteredIds=this._computeFilteredIds(e),e.appliedFilters=this._filters)}_computeFilteredIds(e){const t=e.featureIds.slice();for(const i of this._filters)if(i(t,e),0===t.length)break;return t.length===e.featureIds.length?e.featureIds:t}_computeFilteredComponentIndices(e){const t=new Array,i=e.filteredIds;return null!=i&&e.featureIds.forEach(((e,s)=>{i[t.length]===e&&t.push(s)})),t}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach(((t,i)=>this._removeNodeStageData(i,e))),this._nodeId2MetaReloading.forEach(((t,i)=>this._removeNodeStageData(i,e,this._nodeId2MetaReloading))),this._elevationTask=d(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),null!=this._elevationTask&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);null!=s?(this._collection.setObjectVisibility(s.objectHandle,ut.Hidden),null!=this._edgeView&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch((e=>xt(e,this.i3slayer.title))),this._visibleGeometryChanged(s,Et.REMOVE),null!=this._labeler&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights.objectDeleted(s),i===this._nodeId2Meta?(this._cacheGPUData(s,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(s)):this._deleteComponentObject(s),null!=this._treeDebugger&&this._treeDebugger.update()):i.delete(e)}_deleteComponentObject(e){if(null!=this._edgeView&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(const t of e.textures)this._memEstimateTextureRemoved(t),this._stage.remove(t)}updateNodeState(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._collection.updateMaterial(i.objectHandle,(e=>e.polygonOffsetEnabled=t===Pe.Hole))}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){const i=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,i)}const i=this._nodeId2MetaReloading.get(e);i&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,i))}_invalidateAllSymbols(){this._rendererVersion=Ye(this._rendererVersion,1),this._controller&&this._controller.requestUpdate()}_getInvalidRendererVersion(){return Ye(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=Ye(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.i3slayer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&"arcadeRequired"in e&&e.arcadeRequired&&(this._arcade=await le()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:bt.warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.getSymbols())"mesh-3d"!==t.type&&bt.error(`Symbols of type '${t.type}' are not supported for 3D Object Scene Services.`);this._controller&&this._controller.requestUpdate()}_getCachedEdgeMaterials(e){return this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e),e.cachedEdgeMaterials}_getComponentParameters(e){this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e);const t=e.cachedSymbology;return(i,s)=>{const r=5*i;if(P(s.externalColor,t[r]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255),null!=this._stage.renderView.objectAndLayerIdRenderHelper){const t=e.featureIds[i];this._stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(t,t,this.layerId,this.layerUid+"_"+this.sublayerId,this.layerPopupEnabledAndHasTemplate,e.node.resources.attributes,i,this.sublayerId),s.objectAndLayerIdColor=this._stage.renderView.getObjectAndLayerIdColor({graphicUid:t,layerUid:this.layerUid+"_"+this.sublayerId})}s.externalColorMixMode=t[r+4]&(1<<It.CastShadows)-1,s.castShadows=0!=(t[r+4]&1<<It.CastShadows),s.pickable=0!=(t[r+4]&1<<It.Pickable),s.elevationOffset=e.elevationOffsets?.[i]??0}}_getSymbolInfo(e,t){const i=e&&e.getSymbol(t,{arcade:this._arcade});if(!(i instanceof de))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=Je(i);return this._symbolInfos.set(s,r),r}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=null!=this._symbologyOverrideFields&&this._symbologyOverrideFields.length>0?null!=this._rendererFields&&this._rendererFields.length>0?re(this.i3slayer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;const t=this._tmpAttributeOnlyGraphic,i={};t.attributes=i;const s=this._currentRenderer,r=e.attributeInfo?.attributeData,o=null!=e.featureIds?this.i3slayer.objectIdField:null,a=null!=r&&null!=this._symbologyFields&&this._symbologyFields.length>0;let n=null,l=null;if(a&&null!=this._symbologyFields){n=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(n.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=te(5*e.featureIds.length));const d={color:Tt,castShadows:!0,pickable:!0,colorMixMode:rt.Multiply,edgeMaterial:null},h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=pt.OPAQUE,m=Ze,g=0;for(let p=0;p<e.featureIds.length;p++){if(null!=o&&(i[o]=e.featureIds[p]),a&&n)for(let e=0;e<n.length;e++)i[n[e]]=$e(l[e],p);const r=s?this._getSymbolInfo(s,t):null;let h=null,f=null;if(s&&"visualVariables"in s){if(this._colorVariable){const e=ae(this._colorVariable,t,{color:Dt,arcade:this._arcade});e&&(h=Tt,h[0]=e.r/255,h[1]=e.g/255,h[2]=e.b/255,this._opacityVariable||null===e.a||(f=e.a))}this._opacityVariable&&(f=ne(this._opacityVariable,t,{arcade:this._arcade}))}if(r&&r.material){const e=r.material;h=null==h||null==f?ve(h,f,e.color,e.alpha,yt,Tt):ve(h,f,null,null,yt,Tt)}if(null==h&&(h=Tt,h[0]=1,h[1]=1,h[2]=1,h[3]=1),d.pickable=!0,d.castShadows=!r||r.castShadows,d.colorMixMode=r&&r.material?r.material.colorMixMode:rt.Multiply,d.edgeMaterial=r?r.edgeMaterial:null,null!=this._symbologyOverride&&(d.color=h,this._symbologyOverride(t,d),h=d.color),null!=d.edgeMaterial){const t=h[3]<=0?pt.INVISIBLE:h[3]>=1&&(e.material.isOpaque||d.colorMixMode===rt.Replace)?pt.OPAQUE:pt.TRANSPARENT;d.edgeMaterial===u&&t===_||(m={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,_=t),e.cachedEdgeMaterials[p]=m}else e.cachedEdgeMaterials[p]=Ze;e.cachedSymbology[g++]=Math.round(255*h[0]),e.cachedSymbology[g++]=Math.round(255*h[1]),e.cachedSymbology[g++]=Math.round(255*h[2]),e.cachedSymbology[g++]=Math.round(255*h[3]),e.cachedSymbology[g++]=d.colorMixMode|+d.castShadows<<It.CastShadows|+d.pickable<<It.Pickable}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||Lt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some((e=>e!==Ze)),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map(((t,o)=>e.featureIds[o]!==i[s]?Ze:(r=r||t!==Ze,s++,t)));return{hasEdges:r,perFeatureEdgeMaterials:o}}_updateComponentData(e){if(!this._hasComponentData)return;const t=e.objectHandle,i=this._getComponentParameters(e);this._collection.setComponentData(t,i),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),null!=this._controller&&this._controller.restartNodeLoading()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach((t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,(t=>t.objectOpacity=e)),Lt(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))}))}_updateMaterial(e){this._collection.updateMaterial(e.objectHandle,(e=>{e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.usePBR=this._usePBR,this._updateMaterialOverlay(e)}))}_updateMaterialOverlay(e){}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Et.UPDATE)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),null!=this._labeler&&(this._labeler.slicePlaneEnabled=e),this._nodeId2Meta.forEach((t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,(t=>t.commonMaterialParameters.hasSlicePlane=e)),this._updateEdgeRendering(t,!1))}))}_updatePBR(e){this._nodeId2Meta.forEach((t=>{null!=t&&this._collection.updateMaterial(t.objectHandle,(t=>t.usePBR=e))})),this._hasLoadedPBRTextures=!0}get _usePBR(){return!this._isIntegratedMesh&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){null!=this._edgeView&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return 0===this.i3sOverrides._geometryChangedObjectIds.size?e:(t,i,s)=>s.node.index>=0&&this.i3sOverrides._geometryChangedObjectIds.has(t)?me.CONTINUE:e(t,i,s)}_forAllFeatures(e,t,i){l(this._nodeId2Meta,(s=>{if(null==s)return!1;if(null!=t){switch(t(s)){case me.EXIT:return!0;case me.SKIP:return!1}}let r=me.CONTINUE;switch(i){case ge.ALL:r=this._forAllFeaturesOfNode(s,e);break;case ge.VISIBLE_ONLY:r=this._forAllVisibleFeaturesOfNode(s,e);break;case ge.QUERYABLE:r=this._forAllQueryableFeaturesOfNode(s,e)}return r===me.EXIT}))}_forAllFeaturesOfNode(e,t){let i=me.CONTINUE;const s=e.featureIds;for(let r=0;r<s.length;r++)if(i=t(s[r],r,e),i===me.EXIT)return i;return i}_forAllVisibleFeaturesOfNode(e,t){let i=me.CONTINUE;const s=e.featureIds;return this._collection.forEachVisibleComponent(e.objectHandle,(r=>(i=t(s[r],r,e),i===me.CONTINUE))),i}_forAllQueryableFeaturesOfNode(e,t){const i=this._ignoreClientNodeOverriddenFeatures(t);if(null==this._renderClippingArea)return this._forAllFeaturesOfNode(e,i);const s=this._boundingRectNodeTest(e,this._renderClippingArea);if(s===Xe.OUTSIDE)return me.CONTINUE;if(s===Xe.INSIDE)return this._forAllFeaturesOfNode(e,i);const r=me.CONTINUE,o=e.featureIds,a=e.objectHandle,n=et(this._renderClippingArea,this._collection.getObjectTransform(a));for(let l=0;l<o.length;l++){if(!this._boundingRectFeatureTest(e,l,n))continue;const t=i(o[l],l,e);if(t===me.EXIT)return t}return r}_createAttributes(e,t){const i={};null!=t.featureIds&&(i[this._getObjectIdField()]=t.featureIds[e]);const s=t.attributeInfo?.attributeData;if(null!=s)for(const r of Object.keys(s))i[r]=$e(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e){const t=this._highlights;if("number"==typeof e||e instanceof i?e=[e]:e instanceof a&&(e=e.toArray()),Array.isArray(e)&&e.length>0){if(e[0]instanceof i){const i=e,s=this.i3slayer.fieldsIndex,r=this._getObjectIdField(),o=i.map((e=>st(s,e.attributes,r))),{set:a,handle:n}=t.acquireSet();return t.setFeatureIds(a,o),n}if("number"==typeof e[0]){const i=e,{set:s,handle:r}=t.acquireSet();return t.setFeatureIds(s,i),r}}return Gt}resetHighlights(){d(this._highlights),this._highlights=new Oe({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,ge.ALL),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)})}_visibleGeometryChanged(e,t){this._elevationProvider&&(this._elevationProvider.objectChanged(e.node),null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=f((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))),this._updateSnappingSources(e,t))}get performanceInfo(){const e={displayedNumberOfFeatures:0,maximumNumberOfFeatures:0,totalNumberOfFeatures:0,core:null,index:0,nodes:this._nodeId2Meta.size,"Total GPU Memory Estimate":(this._gpuMemoryEstimate/1048576).toFixed(1)+"MB","Geometry Memory Estimate":(this._geoMemoryEstimate/1048576).toFixed(1)+"MB","Texture Memory Estimate":(this._texMemoryEstimate/1048576).toFixed(1)+"MB","Unloaded Memory Estimate":(this.unloadedMemory/1048576).toFixed(1)+"MB"};return null!=this._memCache&&(e.MemCache=Math.round(100*this._memCache.hitRate)+"% hit"),this._controller&&(this._idbCacheEnabled&&(e.IDBCache=Math.round(100*this._idbCache.getHitRate())+"% hit"),this._controller.updateStats(e)),e}get test(){const e=this;return{controller:this._controller,labeler:this._labeler,get visibleObjectIds(){const t=[];return e._forAllFeatures((e=>(t.push(e),me.CONTINUE)),null,ge.VISIBLE_ONLY),t.sort(((e,t)=>e-t)),t},get numNodes(){return e._nodeId2Meta.size},get loadedNodes(){return Array.from(e._nodeId2Meta.keys()).sort(((e,t)=>e-t))}}}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return null!=e?this._collection.getMaterial(e.objectHandle).objectOpacity:0}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(((t,i)=>e(i,t)))}fadeNode(e,t,i){if(!this.nodeCrossfadingEnabled)return;const s=this._nodeId2Meta.get(e);null!=s&&this._crossfadeHelper.fadeNode(e,s,t,i)}setNodeOpacityByIndex(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._setNodeOpacity(i,t)}_setNodeOpacity(e,t){this._collection.updateMaterial(e.objectHandle,(e=>e.objectOpacity=t)),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(null==this._edgeView||!e.cachedEdgeMaterials)return;Lt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch((e=>xt(e,this.i3slayer.title)))}get hasModifications(){return this._isIntegratedMesh&&null!=this._layerClippingArea||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){const t=e.length;if(!this.hasModifications||t<=0||!0!==this._i3sWasmLoaded)return;const i=this.uid,s=Ut(e);if(null!=s){const t={context:i,buffer:s.buffer};be(t);const r=new Float64Array(s.buffer);e.forAll(((e,t)=>{const i=r[t],s=ye(i);e.imModificationImpact=s,s!==Ve.Unmodified&&this._controller.invalidateGeometryVisibility(e.index)}))}}notifyUpdate(){this.notifyChange("updating")}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!(!this._controller||!this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||null!=this._labeler&&this._labeler.updating||this._crossfadeHelper?.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||null!=this._elevationTask&&this._elevationTask.running}trackSnappingSources(e){const t={events:e,fetchEdgeLocations:async(e,t,i)=>{const s=this._nodeId2Meta.get(e);if(null==s)throw new Error("invalid-node");const{origin:r,buffer:o}=await this._collection.extractEdgeInformation(s.objectHandle,t,i);return this._snappingLocationsApplyElevation(s,o,r),{type:"components",objectIds:s.featureIds,locations:o,origin:r}},remove:()=>{r(this._snappingSourcesTrackers,t)}};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach(((t,i)=>{if(null==t)return;const s=this._controller.getRenderMbs(t.node);null!=s&&e.add(i,s)})),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||this.elevationInfo.mode===kt.Absolute)return;const s=t.position0,r=t.position1,o=t.componentIndex,a=V(),n=V(),l=(e,t)=>{T(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,n),T(e,e,N(n,n,t)),F(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,a),l(a,t),s.setVec(d,a),r.getVec(d,a),l(a,t),r.setVec(d,a)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(null!=s)for(const r of this._snappingSourcesTrackers)t!==Et.REMOVE&&t!==Et.UPDATE||r.events.remove(i),t!==Et.ADD&&t!==Et.UPDATE||r.events.add(i,s)}};return e([v()],o.prototype,"_hasLoadedPBRTextures",void 0),e([v()],o.prototype,"_asyncModuleLoading",void 0),e([v()],o.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([v()],o.prototype,"view",void 0),e([v()],o.prototype,"i3slayer",void 0),e([v()],o.prototype,"_controller",void 0),e([v()],o.prototype,"_labeler",void 0),e([v()],o.prototype,"updating",void 0),e([v()],o.prototype,"suspended",void 0),e([v()],o.prototype,"contentVisible",null),e([v({readOnly:!0})],o.prototype,"legendEnabled",null),e([v()],o.prototype,"holeFilling",void 0),e([v(ht)],o.prototype,"updatingProgress",void 0),e([v()],o.prototype,"updatingProgressValue",null),e([v()],o.prototype,"hasTexturesOrVertexColors",null),e([v()],o.prototype,"rendererTextureUsage",null),e([v()],o.prototype,"elevationOffset",null),e([v()],o.prototype,"elevationInfo",null),e([v({type:Boolean})],o.prototype,"slicePlaneEnabled",void 0),e([v()],o.prototype,"supportedTextureEncodings",null),e([v()],o.prototype,"uncompressedTextureDownsamplingEnabled",null),e([v({type:[oe]})],o.prototype,"_modifications",void 0),e([v({readOnly:!0})],o.prototype,"clientGeometry",null),e([v()],o.prototype,"_elevationTask",void 0),e([v({readOnly:!0})],o.prototype,"_usePBR",null),o=e([I(ft)],o),o};function xt(e,t){u(e)||bt.warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}var Et;!function(e){e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE"}(Et||(Et={}));const jt=z(),wt=Q(),St=Q(),At=nt(),Tt=[0,0,0,0],Dt=new t([0,0,0,0]),Rt=ee(0,0,0,0);function Nt(e){if(null==e)return!1;const t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function Ft(e){return"geometryData"in e}function Vt(e){return null!=e&&b(e.data)}function Pt(e,t){let i=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(null!=t)for(const s of t)null!=s&&b(s.data)&&(i+=s.data.byteLength);return i}function Ht(e,t){return t.byteSize>Ct?(bt.warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}function Ut(e){if(0===e.length)return null;const t=10*e.length,i=new Float64Array(t);return e.forAll(((e,t)=>{let s=e.serviceObb;null==s&&(s=At,R(s.center,e.mbs),s.halfSize[0]=s.halfSize[1]=s.halfSize[2]=e.mbs[3]);const r=10*t;i[r]=s.center[0],i[r+1]=s.center[1],i[r+2]=s.center[2],i[r+3]=s.halfSize[0],i[r+4]=s.halfSize[1],i[r+5]=s.halfSize[2],i[r+6]=s.quaternion[0],i[r+7]=s.quaternion[1],i[r+8]=s.quaternion[2],i[r+9]=s.quaternion[3]})),i}const Gt={remove(){},pause(){},resume(){}};function Lt(e,t){e.forEach((e=>e.opacity=t))}var kt;!function(e){e[e.Absolute=0]="Absolute",e[e.RelativeToGround=1]="RelativeToGround",e[e.OnTheGround=2]="OnTheGround"}(kt||(kt={}));const Bt=V(),qt=z(),zt="elevation-change";function Kt(e){return t=>{if(e.immediate)return e.immediate.schedule(t);throw console.error("Error no immediate schudler"),new Error("cant find immediate scheduler")}}export{kt as ElevationMode,Ot as I3SMeshView3D};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../Graphic.js";import{isSome as s,removeUnordered as r}from"../../../core/arrayUtils.js";import{ByteSizeUnit as o}from"../../../core/ByteSizeUnit.js";import a from"../../../core/Collection.js";import has from"../../../core/has.js";import n from"../../../core/Logger.js";import{someMap as l}from"../../../core/MapUtils.js";import{destroyMaybe as d,applySome as h}from"../../../core/maybe.js";import c from"../../../core/PooledArray.js";import{isAbortError as u,throwIfAborted as _,createResolver as m}from"../../../core/promiseUtils.js";import{initial as g,watch as p}from"../../../core/reactiveUtils.js";import{schedule as f}from"../../../core/scheduling.js";import{isArrayBuffer as b}from"../../../core/typedArrayUtil.js";import{getMetersPerVerticalUnitForSR as y}from"../../../core/unitUtils.js";import{property as v}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as I}from"../../../core/accessorSupport/decorators/subclass.js";import{f as M}from"../../../chunks/mat3.js";import{c as C}from"../../../chunks/mat3f64.js";import{m as O,B as x}from"../../../chunks/mat4.js";import{b as E,c as j}from"../../../chunks/mat4f64.js";import{f as w}from"../../../chunks/quatf64.js";import{m as S,s as A,a as T,t as D,c as R,g as N,b as F}from"../../../chunks/vec3.js";import{c as V}from"../../../chunks/vec3f64.js";import{s as P}from"../../../chunks/vec4.js";import{f as H}from"../../../chunks/vec4f64.js";import{getReferenceEllipsoid as U}from"../../../geometry/ellipsoidUtils.js";import{projectBuffer as G,getProjectorName as L,localLinearScaleFactors as k,projectVectorToVector as B,projectBoundingSphere as q}from"../../../geometry/projection.js";import{create as z,empty as K,expandWithBuffer as W,toRect as $}from"../../../geometry/support/aaBoundingBox.js";import{create as Q,intersects as X}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as Y}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as J}from"../../../geometry/support/FloatArray.js";import{compactIndices as Z}from"../../../geometry/support/Indices.js";import{f as ee}from"../../../chunks/sphere.js";import{newUByteArray as te}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as ie}from"../../../layers/LayerConstants.js";import se from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as re}from"../../../layers/support/fieldUtils.js";import oe from"../../../layers/support/SceneModification.js";import{getColor as ae,getOpacity as ne}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{loadArcade as le}from"../../../support/arcadeOnDemand.js";import de from"../../../symbols/Symbol3D.js";import{getMetersPerUnit as he}from"../../../symbols/support/unitConversionUtils.js";import ce from"./I3SMeshViewLabeler.js";import{I3SMeshWorkerHandle as ue,toWasmModification as _e}from"./I3SMeshWorkerHandle.js";import{ForAllFeaturesReturnType as me,ForAllFeaturesMode as ge}from"./II3SMeshView3D.js";import{initialize as pe,setModificationsSync as fe,filterObbsForModificationsSync as be,interpretObbModificationResults as ye}from"./SceneLayerWorker.js";import{overrideColor as ve}from"./graphics/graphicUtils.js";import{areLabelsVisible as Ie}from"./graphics/Labeler.js";import{TextureUsage as Me,TextureEncoding as Ce}from"./i3s/enums.js";import Oe from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as xe}from"./i3s/I3SAsyncElevationUpdater.js";import{I3SCrossfadeHelper as Ee,NodeCrossfadeMetaData as je}from"./i3s/I3SCrossfadeHelper.js";import we from"./i3s/I3SElevationProvider.js";import{boundingBoxCornerPoints as Se}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Ae}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Te,selectEncoding as De,defaultMaterial as Re,createTexture as Ne,configureMaterial as Fe}from"./i3s/I3SMaterialUtil.js";import{NodeIMModificationImpact as Ve,NodeState as Pe}from"./i3s/I3SNode.js";import{I3SOverrides as He}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as Ue,getLocalOrigin as Ge}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as Le,checkSceneLayerValid as ke,checkSceneLayerCompatibleWithView as Be,getCacheKeySuffix as qe,whenGraphicAttributes as ze,computeVisibilityObb as Ke,filterInPlace as We,getCachedAttributeValue as $e,intersectBoundingRectWithMbs as Qe,MbsIntersectResult as Xe,addWraparound as Ye,getSymbolInfo as Je,transparentEdgeMaterial as Ze,getClipRect as et}from"./i3s/I3SUtil.js";import{IDBCache as tt}from"./i3s/IDBCache.js";import{IDBMockCache as it}from"./i3s/IDBMockCache.js";import{attributeLookup as st}from"./support/attributeUtils.js";import{ColorMixModeEnum as rt}from"./support/symbolColorUtils.js";import ot from"../support/debugFlags.js";import{toBoundingRect as at}from"../support/extentUtils.js";import{create as nt,intersectSphere as lt,clone as dt}from"../support/orientedBoundingBox.js";import{updatingProgress as ht}from"../support/updatingProperties.js";import{glLayout as ct}from"../support/buffer/glUtil.js";import{State as ut}from"../webgl-engine/collections/Component/ComponentObject.js";import{createVertexBufferLayout as _t}from"../webgl-engine/collections/Component/SourceGeometry.js";import{TextureCoordinateAttributeType as mt}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{loadBasis as gt}from"../webgl-engine/lib/BasisUtil.js";import{Transparency as pt}from"../webgl-engine/lib/edgeRendering/interfaces.js";const ft="esri.views.3d.layers.I3SMeshView3D",bt=n.getLogger(ft),yt=[1,1,1,1];class vt extends je{constructor(e,t,i,s,r,o,a,n,l){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=a,this.anchorIds=n,this.anchors=l,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0}}var It;!function(e){e[e.CastShadows=4]="CastShadows",e[e.Pickable=5]="Pickable"}(It||(It={}));const Mt=22,Ct=100*o.MEGABYTES,Ot=t=>{let o=class extends t{constructor(...e){super(e),this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._idbCache=has("enable-feature:idb-mock-cache")?new it:new tt("esri-scenelayer-cache","geometries"),this._hasComponentData=!1,this._hasVertexColors=!1,this.updating=!0,this.holeFilling="auto",this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=new Array,this.ignoresMemoryFactor=!1,this._layerUrl="",this._cacheKeySuffix=null,this._elevationTask=null,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i(null,null,{}),this._crossfadeHelper=new Ee(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerUid(){return this.i3slayer&&this.i3slayer.uid}get sublayerUid(){return null}get layerId(){return this.i3slayer&&this.i3slayer.id}get sublayerId(){return null}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?"yes":"probably-not":"unknown"}get rendererTextureUsage(){return Le(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?Me.AllTexturesPBR:Me.AllTextures:this._usePBR||this._hasLoadedPBRTextures?Me.GeometryTexturesPBR:Me.GeometryTextures}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null!=e&&"absolute-height"===e.mode){const t=y(this.i3slayer.spatialReference),i=he(e.unit);return(e.offset??0)*i/t}return 0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return{mode:kt.Absolute,offset:0};const t=y(this.i3slayer.spatialReference),i=he(e.unit),s=(e.offset??0)*i/t;switch(e.mode){case"absolute-height":return{mode:kt.Absolute,offset:s};case"relative-to-ground":return{mode:kt.RelativeToGround,offset:s};case"on-the-ground":return{mode:kt.OnTheGround,offset:0};default:return{mode:kt.Absolute,offset:0}}}get supportedTextureEncodings(){return Te(this.view._stage.renderView.capabilities)}get uncompressedTextureDownsamplingEnabled(){const e=this.view?.qualitySettings.sceneService.uncompressedTextureDownsamplingEnabled,t=0==(this.supportedTextureEncodings&Ce.DDS_S3TC);return e&&t}get clientGeometry(){return this.i3sOverrides.geometryOverrides}initialize(){this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const e=this.view.resourceController,t=e.memoryController;this.i3sOverrides=new He({view:this.view,layer:this.i3slayer,memoryController:t}),this._worker=new ue(Kt(e)),this.addResolvingPromise(this._worker.promise);const i=this.i3slayer.store;this._worker.setLegacySchema(this.uid,i.defaultGeometrySchema),ke(this.i3slayer),Be(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new se({layerView:this,worker:this._worker}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view._stage,this._collection=this._stage.renderView.componentObjectCollection,this.resetHighlights();const s=i.defaultGeometrySchema;if(this._isIntegratedMesh||!s)this._hasComponentData=!1;else{const e=s.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(s?.vertexAttributes.color??null)&&(null==this.i3slayer.cachedDrawingInfo||!this.i3slayer.cachedDrawingInfo.color),this._isIntegratedMesh||(this._edgeView=this._stage.renderer.ensureEdgeView());const r=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,(e=>this._deleteComponentObject(e)));this._memCache=r;const o=e=>null!=this._controller.index&&null!=this._controller.index.rootNode?this._controller.index.traverse(this._controller.index.rootNode,(t=>{const i=t.index,s=this._nodeId2Meta.get(i)||this._nodeId2MetaReloading.get(i);return e(t,null!=s?s.objectHandle:null)})):()=>{};this._intersectionHandler=new Ae({layerUid:this.layerUid,sublayerUid:this.sublayerUid,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:o}),this.updatingHandles.add((()=>this.layerUid),(e=>this._intersectionHandler.layerUid=e)),this.updatingHandles.add((()=>this.sublayerUid),(e=>this._intersectionHandler.sublayerUid=e)),this._elevationProvider=new we({layerView:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this.updatingHandles.add((()=>this.view.clippingArea),(()=>this._clippingAreaChanged()),g),this.updatingHandles.add((()=>this.fullOpacity),(e=>this._opacityChange(e))),this.updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this.updatingHandles.add((()=>this.elevationOffset),((e,t)=>{this._reloadAll(t),this._controller.invalidateVisibilityObbs()})),this.updatingHandles.add((()=>this.elevationInfo),((e,t)=>this._elevationInfoChanged(e,t)),g),this.updatingHandles.add((()=>this.contentVisible&&this.elevationInfo.mode!==kt.Absolute),((e,t)=>{e?this.handles.add(this.view.basemapTerrain.on("elevation-change",(({extent:e})=>this._ensureElevationTask().addExtent(e))),zt):t&&this.handles.remove(zt)}),g),this.updatingHandles.add((()=>this._usePBR),(e=>this._updatePBR(e)));const a=()=>{this._reloadAll(),this.clearMemCache()};this.updatingHandles.add((()=>this.rendererTextureUsage),a),this.updatingHandles.add((()=>this.uncompressedTextureDownsamplingEnabled),a),this.updatingHandles.add((()=>this.contentVisible),(e=>this._contentVisibleChanged(e)),g),this.updatingHandles.add((()=>this.i3slayer.labelsVisible),(()=>this._labelingChanged()),g),this.updatingHandles.add((()=>this.i3slayer.labelingInfo),(()=>this._labelingChanged()),g),this.updatingHandles.add((()=>this._modifications),(()=>this._modificationsChanged()),g),this.handles.add([p((()=>ot.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&&ot.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||ot.I3S_TREE_SHOW_TILES||(this._treeDebugger=d(this._treeDebugger))}),g),p((()=>ot.I3S_SHOW_MODIFICATIONS),(()=>this._showModifications()),g)]),this._cacheKeySuffix=qe(this.i3slayer.spatialReference,this.view.renderSpatialReference),this._idbCache.init().catch((e=>bt.warn(`Failed to initialize IndexedDB cache: ${e}`)))}destroy(){this._clearAddTasks(),this._elevationTask=d(this._elevationTask),this.i3sOverrides=d(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.layerChanged(),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._worker;e&&(e.destroyContext(this.uid).then((()=>e.destroy())),this._worker=null),this._removeAllNodeDataFromStage(),this._memCache=d(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=d(this._labeler),this._treeDebugger=d(this._treeDebugger),this._controller=d(this._controller),this._highlights.destroy(),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=d(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null)}_memEstimateTextureAdded(e){const t=e.memoryEstimate;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(null!=e){const t=e.memoryEstimate;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){const t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){const t=this._collection.getObjectGPUMemoryUsage(e);this._gpuMemoryEstimate-=t,this._geoMemoryEstimate-=t}isNodeLoaded(e){return this._nodeId2Meta.has(e)}isNodeReloading(e){return this._nodeId2MetaReloading.has(e)}get usedMemory(){let e=null!=this._labeler?this._labeler.usedMemory:0;return this._nodeId2Meta.forEach((t=>e+=null!=t?t.node.memory:0)),this._nodeId2MetaReloading.forEach((t=>e+=null!=t?t.node.memory:0)),e}get unloadedMemory(){return(null!=this._controller?this._controller.unloadedMemoryEstimate:0)+(null!=this._labeler?this._labeler.unloadedMemoryEstimate:0)}_labelingChanged(){if(!(Ie(this.i3slayer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new ce({view:this.view,layer:this.i3slayer,collection:this._collection,overrides:this.i3sOverrides});this._nodeId2Meta.forEach((t=>null!=t&&this._addMetaToLabeler(e,t))),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then((e=>(--this._asyncModuleLoading,e)),(e=>{throw--this._asyncModuleLoading,e}))}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=pe().then((()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()})),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=this.uid,t=this.i3slayer.spatialReference;this._worker.setModifications(e,this._layerClippingArea,this._modifications,t);const i=_e(this._layerClippingArea,this._modifications,t);fe({context:e,modifications:i,isGeodetic:t.isGeographic}),this._controller.modificationsChanged();const s=this.hasModifications?new c:null;this._nodeId2Meta.forEach(((e,t)=>{null==e?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):null!=s&&s.push(e.node)})),null!=s&&this._nodeId2MetaReloading.forEach((e=>s.push(e.node))),null!=s&&s.length>0&&(this.updateNodeModificationStatus(s),s.forAll((e=>{if(e.imModificationImpact!==Ve.Culled){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),null!=t?(this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t)):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}}))),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(null!=this._modificationGraphics&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!ot.I3S_SHOW_MODIFICATIONS||0===this._modifications.length)return;const e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={type:"simple-fill",outline:{color:[255,255,255],width:1}};this._modificationGraphics=new Array;for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.i3slayer.spatialReference;const o={...t,color:e[s.type]};this._modificationGraphics.push(new i({geometry:r,symbol:o}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,((e,t)=>this._createAttributes(e,t)))}_contentVisibleChanged(e){e?(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler)):(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){const t=this._nodeId2Meta.get(e);if(null!=t&&null!=t.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(null!=t&&null!=t.attributeInfo)return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);null!=i&&null!=i.attributeInfo&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);null!=s&&(await this.i3sOverrides.applyAttributeOverrides(s.featureIds,t,i),s.attributeInfo=t,this._controller.reschedule((()=>this._attributeValuesChanged(s)),i).catch((e=>{u(e)||bt.warn("Error while updating attribute values. Layer might not display correctly.",e)})))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.filteredIds=null,null!=this._labeler&&this._labeler.setNodeMetaAttributes(e,((e,t)=>this._createAttributes(e,t))),this._updateEngineObject(e)}clearMemCache(){null!=this._memCache&&this._memCache.clear()}getVisibleNodes(){const e=new Array;return this._nodeId2Meta.forEach((t=>null!=t&&e.push(t.node))),e}getNodeComponentObb(e){const t=this._nodeId2Meta.get(e.index)??this._nodeId2MetaReloading.get(e.index);return null!=t?this._collection.getComponentObb(t.objectHandle):null}getLoadedNodeIndices(e){this._nodeId2Meta.forEach(((t,i)=>e.push(i))),this._nodeId2MetaReloading.forEach(((t,i)=>e.push(i)))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&0!=(this.supportedTextureEncodings&Ce.Basis)&&h(this.i3slayer.textureSetDefinitions,(e=>e.some((e=>e.formats.some((e=>"basis"===e.format||"ktx2"===e.format))))))&>()}_getVertexBufferLayout(e,t){const i={hasTexture:Nt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion};return ct(_t(this._getGeometryParameters(i)))}_getObjectIdField(){return this.i3slayer.objectIdField||ie}_getGlobalIdField(){return this.i3slayer.associatedLayer?.globalIdField}_findGraphicNodeAndIndex(e){const t=st(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());let i=null;return l(this._nodeId2Meta,(e=>{if(null==e)return!1;const s=e.featureIds.indexOf(t);return-1!==s&&(i={node:e.node,index:s},!0)})),i}_getGraphicIndices(e,t){const i=this._nodeId2Meta.get(e.index);if(null==i)return[];const s=[],r=this._getObjectIdField(),o=this.i3slayer.fieldsIndex;for(const a of t){const e=st(o,a.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this._getAABB(t.node.index,t.index);return null==i?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this._getAABB(e.nodeIndex,e.componentIndex)}_getAABB(e,t){const i=this._nodeId2Meta.get(e);if(null==i||null==i.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=Se(t,this._collection,s,Y(24),0),o=this.view.renderSpatialReference,a=this.view.spatialReference;if(!G(r,o,0,r,a,0,8))return null;const n=K();return W(n,r,0,8),n}whenGraphicAttributes(e,t){return ze(this.i3slayer,e,this._getObjectIdField(),t,(()=>[...this._nodeId2Meta.values()].filter(s)))}getGraphicFromIntersectorTarget(e){if(null==e.nodeIndex||null==e.componentIndex)return null;const t=this._nodeId2Meta.get(e.nodeIndex);return null==t||null==t.featureIds||e.componentIndex>=t.featureIds.length?null:this._createGraphic(e.componentIndex,t)}_getCacheKey(e){return`${this._layerUrl}/v${Mt}/${e}${this._cacheKeySuffix}`}_getMemCacheKey(e,t=this.elevationOffset){return e+"#"+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&0===this.elevationOffset&&null!=this._cacheKeySuffix}loadCachedGPUData(e){return null!=this._memCache?this._memCache.pop(this._getMemCacheKey(e)):null}deleteCachedGPUData(e){null!=e&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(null==this._memCache)return void this._deleteComponentObject(e);const i=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,e.node.memory,i)}loadMissingTextures(e,t,i,s){const r=e?.filter(((e,i)=>{if(0==(e.usage&this.rendererTextureUsage))return!1;if(null==t)return!0;const s=De(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(null==r||null==r.data||s&&r.encoding!==s.encoding)}))??[];return 0===r.length?Promise.resolve(!1):i(r,s).then((i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0}))}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then((s=>null==s?null:s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(this.elevationInfo.mode===kt.Absolute&&(e.geometryObb=s.geometryObb),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then((i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=Pt(s.transformedGeometry,s.textureData),s.textureData.every(Vt)&&Ht(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch((t=>bt.warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`)))),_(t),s)))))):Promise.resolve(null)}addNode(e,t,i){return Ft(t)?null==t.geometryBuffer?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,(()=>this._transformNode(e,t,i).then((s=>this._safeReschedule((()=>{if(null==s)return e.hasModifications=!1,this._addCachedNodeData(e,null,i);e.hasModifications=s.transformedGeometry.hasModifications;const{obb:r,componentOffsets:o,featureIds:a,anchorIds:n,anchors:l,transformedGeometry:d}=s,h=this._controller.crsIndex,c=this.view.renderSpatialReference,u=Ue(e.mbs,this.elevationOffset,h,c),_=nt([r.center.x,r.center.y,r.center.z],[r.extents.x,r.extents.y,r.extents.z],w(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));S(_.center,_.center,u),this.elevationInfo.mode===kt.Absolute&&(e.geometryObb=_),t.geometryData.componentOffsets=o,a&&(t.geometryData.featureIds=Array.from(a)),t.geometryData.anchorIds=n,t.geometryData.anchors=l;const m={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:d,globalTrafo:u,geometryObb:_,byteSize:Pt(d,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&Ht(e,m)){const t=null!=m.textureData?m.textureData.map((e=>Vt(e)?e:null)):null;this._idbCache.put(this._getCacheKey(e.id),{...m,textureData:t}).catch((t=>bt.warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`)))}return this._addCachedNodeData(e,m,i)}),i))))):Promise.reject()}getElevationRange(e){let t=1/0,i=-1/0;const s=U(this.view.renderCoordsHelper.spatialReference);return this._nodeId2Meta.forEach((r=>{if(null!=r&&null!=r.node.geometryObb){const o=r.node.geometryObb;if(lt(o,e)){const e=this._collection.getObjectTransform(r.objectHandle),o=this.view.renderCoordsHelper.getAltitude(e.position);for(let a=0;a<r.featureIds.length;a++){const e=this._collection.getComponentAabb(r.objectHandle,a,qt);if("local"===this.view.viewingMode)t=Math.min(t,o+e[2]),i=Math.max(i,o+e[5]);else{t=Math.min(t,o+e[2]);const r=Math.max(Math.abs(e[3]),Math.abs(e[0])),a=Math.max(Math.abs(e[4]),Math.abs(e[1])),n=o+e[5]+s.radius;i=Math.max(i,Math.sqrt(r*r+a*a+n*n)-s.radius)}}}}})),{min:t,max:i}}computeVisibilityObb(e){return Ke(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let g=0;g<s.length;++g)r[g]=this._getVertexBufferLayout(s[g],t.geometryDescriptor);const o=e.mbs,a=this.elevationOffset,n=this._controller.crsIndex,l=this._controller.crsVertex,d=this.view.renderSpatialReference,h=Ge(o,a,n),c=Ue(o,a,n,d),u=L(n,l),_=L(l,d);if(null==u||null==_)return Promise.resolve(null);const m={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,localOrigin:h,globalTrafo:c,mbs:o,obb:e.serviceObb,elevationOffset:a,needNormals:!this._isIntegratedMesh&&this._controller.isMeshPyramid,normalReferenceFrame:this.i3slayer.normalReferenceFrame||"none",indexToVertexProjector:u,vertexToRenderProjector:_};return this._worker.invoke(m,i)}get _supportsNodeCrossFading(){return!this.view?._stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){const t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,i){if(this.elevationInfo.mode===kt.Absolute&&(e.geometryObb=dt(this._collection.getComponentObb(t.objectHandle))),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);null!=this._labeler&&this._addMetaToLabeler(this._labeler,t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,ut.Visible),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==kt.Absolute&&this._ensureElevationTask().schedule(s),this._updateEngineObject(t),this._highlights.objectCreated(t),null!=this._treeDebugger&&this._treeDebugger.update()}addCachedNodeData(e,t,i,s){return this._addData(e,i,(()=>this._addCachedNodeData(e,t,s)))}async deleteCachedNodeData(e){if(this._idbCacheEnabled)return this._idbCache.remove(this._getCacheKey(e))}async _addCachedNodeData(e,t,i){if(!this.contentVisible||!this._controller.isGeometryVisible(e))return void this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);if(null==t)return void this._addNodeMeta(e.index,null);const s=this._addTasks.get(e.index),{geometryData:r,transformedGeometry:o,globalTrafo:a}=t;await this.i3sOverrides.applyAttributeOverrides(r.featureIds,s.attributeInfo,i);const n=null!=t.textureData?t.textureData.filter((e=>null!=e&&0!=(e.usage&this.rendererTextureUsage))):[];!has("disable-feature:i3s-basis")&&n.some((e=>null!=e&&(e.encoding===Ce.Basis||e.encoding===Ce.KTX2)))&&await gt(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:h,anchorIds:c,anchors:u}=r,_=this._collection,m=d[0],{layout:g,indices:p,interleavedVertexData:f,positionData:b,hasColors:y}=o,v=this._materialParameters(m,g),I=l||new Uint32Array([0,p?p.length:f.byteLength/g[0].stride]),w={vertices:{data:f,count:f.byteLength/g[0].stride,layoutParameters:v.geometryParams},positionData:{positions:J(b.data),indices:Z(b.indices)},indices:p,componentOffsets:I},S=m.transformation?E(m.transformation):j();O(S,a,S);const A=x(V(),S),T=M(C(),S),D=this.view.renderSpatialReference,R=this.view.basemapTerrain.spatialReference,N=V(),F=[1,1,1];k(A,D,F,R)||bt.errorOnce("Unsupported coordinate system for IM overlay"),B(A,D,N,R);const P=_.createObject({toMapSpace:H(N[0],N[1],F[0],F[1]),geometry:w,obb:t.geometryObb,transform:{position:A,rotationScale:T}}),U=v.geometryParams.textureCoordinates===mt.Atlas,{textures:G,texturePromise:L}=this._initMaterialAndTextures(P,v.material,n,U);e.memory+=this._memEstimateGeometryAdded(P),e.memory+=G.reduce(((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0)),0);const q=!!v.material.hasParametersFromSource,z="blend"!==v.material.alphaMode&&v.material.metallicRoughness.baseColorFactor[3]>=1,K=new vt(e,h,P,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:q,isOpaque:z},G,c,u);s.meta=K,!this._hasTextures&&t.requiredTextures?.some((({usage:e})=>0!=(e&Me.ColorTextures)))&&(this._hasTextures=!0),this._hasData=!0,this._hasColors=this._hasColors||y,this._hasTextures=this._hasTextures||!!e.resources.texture,this.notifyChange("hasTexturesOrVertexColors");const W=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(K),L]).then((([t,s])=>(null!=t&&t.updateObjectVisibility(K.objectHandle,!1).catch((e=>xt(e,this.i3slayer.title))),this._safeReschedule((()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,K),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(P,ut.Visible),null!=t&&t.updateObjectVisibility(K.objectHandle,!0).catch((e=>xt(e,this.i3slayer.title))),K.attributeInfo=i.attributeInfo;const s=K.cachedRendererVersion!==this._rendererVersion,r=W!==this.slicePlaneEnabled;this._updateElevationOffsets(K);const o=K.elevationOffsets;this._updateComponentData(K);const a=this._applyFiltersToNode(K);(s||null!=t&&(r||a||o))&&this._addOrUpdateEdgeRendering(K),null!=this._labeler&&this._addMetaToLabeler(this._labeler,K),this._visibleGeometryChanged(K,Et.ADD),this._highlights.objectCreated(K),this._updateMaterial(K),this._setNewNodeOpacity(K),null!=this._treeDebugger&&this._treeDebugger.update()}),i)))).catch((e=>{throw null!=s.meta&&(this._cacheGPUData(s.meta),s.meta=null),e}))}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){bt.error("Removing duplicated node");const t=this._nodeId2Meta.get(e);null!=t&&this._deleteComponentObject(t)}else this._controller.updateLoadStatus(e,!0);null!=t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&Lt(t.cachedEdgeMaterials,0)),this._nodeId2Meta.set(e,t)}_updateElevationOffsets(e){const t=this.view.renderSpatialReference,i=this._controller.crsIndex,s=this.elevationInfo,r=this.view.basemapTerrain,o=r.spatialReference,a=s.mode;if(null==t||null==o||a===kt.Absolute)return void(e.elevationOffsets=null);const n=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const l=Bt,d=qt,h=a===kt.OnTheGround,c=this.view.renderCoordsHelper,u=e.featureIds.length,_=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const s=Y(3*u);e.cachedElevationAnchors=s;for(let r=0;r<u;r++){const a=3*r,h=e.anchorIds?.indexOf(r)??-1;e.anchors&&h>=0?(A(l,e.anchors[3*h],e.anchors[3*h+1],e.anchors[3*h+2]),T(l,l,e.node.mbs),B(l,i,l,o),s[a]=l[0],s[a+1]=l[1],s[a+2]=c.getAltitude(l)):(this._collection.getComponentAabb(e.objectHandle,r,d,!0),A(l,(d[0]+d[3])/2,(d[1]+d[4])/2,d[2]),D(l,l,n.rotationScale),T(l,l,n.position),s[a+2]=c.getAltitude(l),B(l,t,l,o),s[a]=l[0],s[a+1]=l[1])}return s})(),m=s.offset,g=e.elevationOffsets,p=(e,t)=>{const i=h?_[3*e+2]:0;g[e]=m+(null!=t?t-i:0)};r.getElevations(_,u,p)}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new xe(this.view.resourceController.scheduler,(e=>{const t=this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference);return null!=t?t.filterInPlace((e=>null!=this._nodeId2Meta.get(e))):null}),(e=>{const t=this._nodeId2Meta.get(e);this._nodeElevationAlignmentChanged(t)}))),this._elevationTask}_elevationInfoChanged(e,t){const i=e.mode!==kt.Absolute,s=!!t&&t!==e&&t.mode!==kt.Absolute;this._intersectionHandler.updateElevationAlignState(i,this.view.state.viewingMode),i&&!s&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach((e=>this._nodeElevationAlignmentChanged(e)))}_nodeElevationAlignmentChanged(e){null!=e&&(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),null!=this._labeler&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,Et.UPDATE))}_safeReschedule(e,t){return _(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:Re(),s=t.some((e=>"uvRegion"===e.name)),r=t.some((e=>"normalCompressed"===e.name)),o=Nt(i);return{geometryParams:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s){const r=this._stage.renderView,o=i.map((e=>Ne(e,t,s,r)));this._stage.addMany(o);let a=null;return this._collection.updateMaterial(e,(e=>{a=Fe(e,t,o,i,this.view._stage.renderView.textureRepository,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference}),this._updateMaterialOverlay(e)})),{textures:o,texturePromise:a}}_getGeometryParameters(e){return{textureCoordinates:e.hasTexture?e.hasRegions?mt.Atlas:mt.Default:mt.None,colors:this._hasVertexColors,normals:e.hasNormals&&!this._isIntegratedMesh}}_addData(e,t,i){let s=this._addTasks.get(e.index);return s?s.attributeInfo=t:(s={...m(),attributeInfo:t,meta:null},this._addTasks.set(e.index,s),i().then(s.resolve,s.reject).then((()=>this._addTasks.delete(e.index))).catch((t=>{throw this._addTasks.delete(e.index),t}))),s.promise}_clearAddTasks(){this._addTasks.forEach((e=>{null!=e.meta&&(this._cacheGPUData(e.meta),e.meta=null)})),this._addTasks.clear()}_clippingAreaChanged(){const e=this.view.renderSpatialReference,t=this.i3slayer.spatialReference,i=Q();this._renderClippingArea=at(this.view.clippingArea,i,e)?i:null;const s=Q();this._layerClippingArea=at(this.view.clippingArea,s,t)?s:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){const e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e)}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach((e=>{null!=e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Et.UPDATE))}))}getFilters(){const e=[],t=this._renderClippingArea;return null!=t&&e.push(((e,i)=>this._boundingRectFilter(e,i,t))),e}addSqlFilter(e,t,i){if(null!=t){const s=t.fieldNames;e.push(((e,r)=>this._sqlFilter(e,r,t,s,i)))}}_sqlFilter(e,t,i,s,r){const o={},a=this._createLayerGraphic(o),n=this.i3slayer.objectIdField,l=t.featureIds,d=null!=t.attributeInfo&&t.attributeInfo.attributeData;s.every((e=>e===n||d&&null!=d[e]))&&We(e,l,(e=>{o[n]=l[e];for(const i of s)i!==n&&(o[i]=d?$e(d[i],e):null);try{return i.testFeature(a)}catch(t){return r(t),!1}}))}_boundingRectNodeTest(e,t){return q(e.node.mbs,this._controller.crsIndex,Rt,this.view.renderSpatialReference),Qe(t,Rt)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,jt),$(jt,wt),X(i,wt)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(r===Xe.INSIDE)return;if(r===Xe.OUTSIDE)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const a=this._transformClippingArea(St,i,t.objectHandle);We(e,t.featureIds,(e=>this._boundingRectFeatureTest(t,e,a)))}_transformClippingArea(e,t,i){const s=this._collection.getObjectTransform(i),r=s.position,o=s.rotationScale;return e[0]=(t[0]-r[0])/o[0],e[1]=(t[1]-r[1])/o[4],e[2]=(t[2]-r[0])/o[0],e[3]=(t[3]-r[1])/o[4],e}_addOrUpdateEdgeRendering(e,t=!0){const i=this._edgeView;if(null==i)return Promise.resolve(null);const s=e.objectHandle,r=i.hasObject(s),{hasEdges:o,perFeatureEdgeMaterials:a}=this._getFilteredEdgeMaterials(e),n={hasSlicePlane:this.slicePlaneEnabled};if(o&&r){if(this.nodeCrossfadingEnabled){Lt(a,this.getNodeOpacity(e))}return i.updateAllComponentMaterials(s,a,n,t).catch((e=>xt(e,this.i3slayer.title))),i.updateObjectVisibility(s,!0).catch((e=>xt(e,this.i3slayer.title))),i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>xt(e,this.i3slayer.title))),Promise.resolve(i)}return o&&!r?this._collection.addEdges(s,i,a,n).then((t=>(e.edgeMemoryUsage=t,e.node.memory+=t,i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>xt(e,this.i3slayer.title))),i))):(!o&&r&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,i.removeObject(s)),Promise.resolve(null))}_applyFiltersToNode(e){return!!this._applyFiltersToNodeComponents(e)&&(null!=this._labeler&&this._labeler.applyFilterChange(e),!0)}_applyFiltersToNodeComponents(e){const t=this._collection,i=0===t.getComponentCount(e.objectHandle).invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!i;if(this._updateCachedFilteredIds(e),e.filteredIds===e.featureIds)return!i;const s=this._computeFilteredComponentIndices(e);return t.setAllComponentVisibilities(e.objectHandle,s),!0}_updateCachedFilteredIds(e){null!=e.filteredIds&&e.appliedFilters===this._filters||(e.filteredIds=this._computeFilteredIds(e),e.appliedFilters=this._filters)}_computeFilteredIds(e){const t=e.featureIds.slice();for(const i of this._filters)if(i(t,e),0===t.length)break;return t.length===e.featureIds.length?e.featureIds:t}_computeFilteredComponentIndices(e){const t=new Array,i=e.filteredIds;return null!=i&&e.featureIds.forEach(((e,s)=>{i[t.length]===e&&t.push(s)})),t}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach(((t,i)=>this._removeNodeStageData(i,e))),this._nodeId2MetaReloading.forEach(((t,i)=>this._removeNodeStageData(i,e,this._nodeId2MetaReloading))),this._elevationTask=d(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),null!=this._elevationTask&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);null!=s?(this._collection.setObjectVisibility(s.objectHandle,ut.Hidden),null!=this._edgeView&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch((e=>xt(e,this.i3slayer.title))),this._visibleGeometryChanged(s,Et.REMOVE),null!=this._labeler&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights.objectDeleted(s),i===this._nodeId2Meta?(this._cacheGPUData(s,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(s)):this._deleteComponentObject(s),null!=this._treeDebugger&&this._treeDebugger.update()):i.delete(e)}_deleteComponentObject(e){if(null!=this._edgeView&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(const t of e.textures)this._memEstimateTextureRemoved(t),this._stage.remove(t)}updateNodeState(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._collection.updateMaterial(i.objectHandle,(e=>e.polygonOffsetEnabled=t===Pe.Hole))}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){const i=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,i)}const i=this._nodeId2MetaReloading.get(e);i&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,i))}_invalidateAllSymbols(){this._rendererVersion=Ye(this._rendererVersion,1),this._controller&&this._controller.requestUpdate()}_getInvalidRendererVersion(){return Ye(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=Ye(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.i3slayer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&"arcadeRequired"in e&&e.arcadeRequired&&(this._arcade=await le()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:bt.warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.getSymbols())"mesh-3d"!==t.type&&bt.error(`Symbols of type '${t.type}' are not supported for 3D Object Scene Services.`);this._controller&&this._controller.requestUpdate()}_getCachedEdgeMaterials(e){return this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e),e.cachedEdgeMaterials}_getComponentParameters(e){this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e);const t=e.cachedSymbology;return(i,s)=>{const r=5*i;if(P(s.externalColor,t[r]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255),null!=this._stage.renderView.objectAndLayerIdRenderHelper){const t=e.featureIds[i];this._stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(t,t,this.layerId,this.layerUid+"_"+this.sublayerId,this.layerPopupEnabledAndHasTemplate,e.node.resources.attributes,i,this.sublayerId),s.objectAndLayerIdColor=this._stage.renderView.getObjectAndLayerIdColor({graphicUid:t,layerUid:this.layerUid+"_"+this.sublayerId})}s.externalColorMixMode=t[r+4]&(1<<It.CastShadows)-1,s.castShadows=0!=(t[r+4]&1<<It.CastShadows),s.pickable=0!=(t[r+4]&1<<It.Pickable),s.elevationOffset=e.elevationOffsets?.[i]??0}}_getSymbolInfo(e,t){const i=e&&e.getSymbol(t,{arcade:this._arcade});if(!(i instanceof de))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=Je(i);return this._symbolInfos.set(s,r),r}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=null!=this._symbologyOverrideFields&&this._symbologyOverrideFields.length>0?null!=this._rendererFields&&this._rendererFields.length>0?re(this.i3slayer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;const t=this._tmpAttributeOnlyGraphic,i={};t.attributes=i;const s=this._currentRenderer,r=e.attributeInfo?.attributeData,o=null!=e.featureIds?this.i3slayer.objectIdField:null,a=null!=r&&null!=this._symbologyFields&&this._symbologyFields.length>0;let n=null,l=null;if(a&&null!=this._symbologyFields){n=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(n.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=te(5*e.featureIds.length));const d={color:Tt,castShadows:!0,pickable:!0,colorMixMode:rt.Multiply,edgeMaterial:null},h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=pt.OPAQUE,m=Ze,g=0;for(let p=0;p<e.featureIds.length;p++){if(null!=o&&(i[o]=e.featureIds[p]),a&&n)for(let e=0;e<n.length;e++)i[n[e]]=$e(l[e],p);const r=s?this._getSymbolInfo(s,t):null;let h=null,f=null;if(s&&"visualVariables"in s){if(this._colorVariable){const e=ae(this._colorVariable,t,{color:Dt,arcade:this._arcade});e&&(h=Tt,h[0]=e.r/255,h[1]=e.g/255,h[2]=e.b/255,this._opacityVariable||null===e.a||(f=e.a))}this._opacityVariable&&(f=ne(this._opacityVariable,t,{arcade:this._arcade}))}if(r&&r.material){const e=r.material;h=null==h||null==f?ve(h,f,e.color,e.alpha,yt,Tt):ve(h,f,null,null,yt,Tt)}if(null==h&&(h=Tt,h[0]=1,h[1]=1,h[2]=1,h[3]=1),d.pickable=!0,d.castShadows=!r||r.castShadows,d.colorMixMode=r&&r.material?r.material.colorMixMode:rt.Multiply,d.edgeMaterial=r?r.edgeMaterial:null,null!=this._symbologyOverride&&(d.color=h,this._symbologyOverride(t,d),h=d.color),null!=d.edgeMaterial){const t=h[3]<=0?pt.INVISIBLE:h[3]>=1&&(e.material.isOpaque||d.colorMixMode===rt.Replace)?pt.OPAQUE:pt.TRANSPARENT;d.edgeMaterial===u&&t===_||(m={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,_=t),e.cachedEdgeMaterials[p]=m}else e.cachedEdgeMaterials[p]=Ze;e.cachedSymbology[g++]=Math.round(255*h[0]),e.cachedSymbology[g++]=Math.round(255*h[1]),e.cachedSymbology[g++]=Math.round(255*h[2]),e.cachedSymbology[g++]=Math.round(255*h[3]),e.cachedSymbology[g++]=d.colorMixMode|+d.castShadows<<It.CastShadows|+d.pickable<<It.Pickable}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||Lt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some((e=>e!==Ze)),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map(((t,o)=>e.featureIds[o]!==i[s]?Ze:(r=r||t!==Ze,s++,t)));return{hasEdges:r,perFeatureEdgeMaterials:o}}_updateComponentData(e){if(!this._hasComponentData)return;const t=e.objectHandle,i=this._getComponentParameters(e);this._collection.setComponentData(t,i),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),null!=this._controller&&this._controller.restartNodeLoading()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach((t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,(t=>t.objectOpacity=e)),Lt(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))}))}_updateMaterial(e){this._collection.updateMaterial(e.objectHandle,(e=>{e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.usePBR=this._usePBR,this._updateMaterialOverlay(e)}))}_updateMaterialOverlay(e){}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Et.UPDATE)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),null!=this._labeler&&(this._labeler.slicePlaneEnabled=e),this._nodeId2Meta.forEach((t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,(t=>t.commonMaterialParameters.hasSlicePlane=e)),this._updateEdgeRendering(t,!1))}))}_updatePBR(e){this._nodeId2Meta.forEach((t=>{null!=t&&this._collection.updateMaterial(t.objectHandle,(t=>t.usePBR=e))})),this._hasLoadedPBRTextures=!0}get _usePBR(){return!this._isIntegratedMesh&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){null!=this._edgeView&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?e:(t,i,s)=>s.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?me.CONTINUE:e(t,i,s)}_forAllFeatures(e,t,i){l(this._nodeId2Meta,(s=>{if(null==s)return!1;if(null!=t){switch(t(s)){case me.EXIT:return!0;case me.SKIP:return!1}}let r=me.CONTINUE;switch(i){case ge.ALL:r=this._forAllFeaturesOfNode(s,e);break;case ge.VISIBLE_ONLY:r=this._forAllVisibleFeaturesOfNode(s,e);break;case ge.QUERYABLE:r=this._forAllQueryableFeaturesOfNode(s,e)}return r===me.EXIT}))}_forAllFeaturesOfNode(e,t){let i=me.CONTINUE;const s=e.featureIds;for(let r=0;r<s.length;r++)if(i=t(s[r],r,e),i===me.EXIT)return i;return i}_forAllVisibleFeaturesOfNode(e,t){let i=me.CONTINUE;const s=e.featureIds;return this._collection.forEachVisibleComponent(e.objectHandle,(r=>(i=t(s[r],r,e),i===me.CONTINUE))),i}_forAllQueryableFeaturesOfNode(e,t){const i=this._ignoreClientNodeOverriddenFeatures(t);if(null==this._renderClippingArea)return this._forAllFeaturesOfNode(e,i);const s=this._boundingRectNodeTest(e,this._renderClippingArea);if(s===Xe.OUTSIDE)return me.CONTINUE;if(s===Xe.INSIDE)return this._forAllFeaturesOfNode(e,i);const r=me.CONTINUE,o=e.featureIds,a=e.objectHandle,n=et(this._renderClippingArea,this._collection.getObjectTransform(a));for(let l=0;l<o.length;l++){if(!this._boundingRectFeatureTest(e,l,n))continue;const t=i(o[l],l,e);if(t===me.EXIT)return t}return r}_createAttributes(e,t){const i={};null!=t.featureIds&&(i[this._getObjectIdField()]=t.featureIds[e]);const s=t.attributeInfo?.attributeData;if(null!=s)for(const r of Object.keys(s))i[r]=$e(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e){const t=this._highlights;if("number"==typeof e||e instanceof i?e=[e]:e instanceof a&&(e=e.toArray()),Array.isArray(e)&&e.length>0){if(e[0]instanceof i){const i=e,s=this.i3slayer.fieldsIndex,r=this._getObjectIdField(),o=i.map((e=>st(s,e.attributes,r))),{set:a,handle:n}=t.acquireSet();return t.setFeatureIds(a,o),n}if("number"==typeof e[0]){const i=e,{set:s,handle:r}=t.acquireSet();return t.setFeatureIds(s,i),r}}return Gt}resetHighlights(){d(this._highlights),this._highlights=new Oe({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,ge.ALL),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)})}_visibleGeometryChanged(e,t){this._elevationProvider&&(this._elevationProvider.objectChanged(e.node),null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=f((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))),this._updateSnappingSources(e,t))}get performanceInfo(){const e={displayedNumberOfFeatures:0,maximumNumberOfFeatures:0,totalNumberOfFeatures:0,core:null,index:0,nodes:this._nodeId2Meta.size,"Total GPU Memory Estimate":(this._gpuMemoryEstimate/1048576).toFixed(1)+"MB","Geometry Memory Estimate":(this._geoMemoryEstimate/1048576).toFixed(1)+"MB","Texture Memory Estimate":(this._texMemoryEstimate/1048576).toFixed(1)+"MB","Unloaded Memory Estimate":(this.unloadedMemory/1048576).toFixed(1)+"MB"};return null!=this._memCache&&(e.MemCache=Math.round(100*this._memCache.hitRate)+"% hit"),this._controller&&(this._idbCacheEnabled&&(e.IDBCache=Math.round(100*this._idbCache.getHitRate())+"% hit"),this._controller.updateStats(e)),e}get test(){const e=this;return{controller:this._controller,labeler:this._labeler,get visibleObjectIds(){const t=[];return e._forAllFeatures((e=>(t.push(e),me.CONTINUE)),null,ge.VISIBLE_ONLY),t.sort(((e,t)=>e-t)),t},get numNodes(){return e._nodeId2Meta.size},get loadedNodes(){return Array.from(e._nodeId2Meta.keys()).sort(((e,t)=>e-t))}}}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return null!=e?this._collection.getMaterial(e.objectHandle).objectOpacity:0}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(((t,i)=>e(i,t)))}fadeNode(e,t,i){if(!this.nodeCrossfadingEnabled)return;const s=this._nodeId2Meta.get(e);null!=s&&this._crossfadeHelper.fadeNode(e,s,t,i)}setNodeOpacityByIndex(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._setNodeOpacity(i,t)}_setNodeOpacity(e,t){this._collection.updateMaterial(e.objectHandle,(e=>e.objectOpacity=t)),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(null==this._edgeView||!e.cachedEdgeMaterials)return;Lt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch((e=>xt(e,this.i3slayer.title)))}get hasModifications(){return this._isIntegratedMesh&&null!=this._layerClippingArea||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){const t=e.length;if(!this.hasModifications||t<=0||!0!==this._i3sWasmLoaded)return;const i=this.uid,s=Ut(e);if(null!=s){const t={context:i,buffer:s.buffer};be(t);const r=new Float64Array(s.buffer);e.forAll(((e,t)=>{const i=r[t],s=ye(i);e.imModificationImpact=s,s!==Ve.Unmodified&&this._controller.invalidateGeometryVisibility(e.index)}))}}notifyUpdate(){this.notifyChange("updating")}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!(!this._controller||!this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||null!=this._labeler&&this._labeler.updating||this._crossfadeHelper?.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||null!=this._elevationTask&&this._elevationTask.running}trackSnappingSources(e){const t={events:e,fetchEdgeLocations:async(e,t,i)=>{const s=this._nodeId2Meta.get(e);if(null==s)throw new Error("invalid-node");const{origin:r,buffer:o}=await this._collection.extractEdgeInformation(s.objectHandle,t,i);return this._snappingLocationsApplyElevation(s,o,r),{type:"components",objectIds:s.featureIds,locations:o,origin:r}},remove:()=>{r(this._snappingSourcesTrackers,t)}};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach(((t,i)=>{if(null==t)return;const s=this._controller.getRenderMbs(t.node);null!=s&&e.add(i,s)})),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||this.elevationInfo.mode===kt.Absolute)return;const s=t.position0,r=t.position1,o=t.componentIndex,a=V(),n=V(),l=(e,t)=>{T(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,n),T(e,e,N(n,n,t)),F(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,a),l(a,t),s.setVec(d,a),r.getVec(d,a),l(a,t),r.setVec(d,a)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(null!=s)for(const r of this._snappingSourcesTrackers)t!==Et.REMOVE&&t!==Et.UPDATE||r.events.remove(i),t!==Et.ADD&&t!==Et.UPDATE||r.events.add(i,s)}};return e([v()],o.prototype,"_hasLoadedPBRTextures",void 0),e([v()],o.prototype,"_asyncModuleLoading",void 0),e([v()],o.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([v()],o.prototype,"view",void 0),e([v()],o.prototype,"i3slayer",void 0),e([v()],o.prototype,"_controller",void 0),e([v()],o.prototype,"_labeler",void 0),e([v()],o.prototype,"updating",void 0),e([v()],o.prototype,"suspended",void 0),e([v()],o.prototype,"contentVisible",null),e([v({readOnly:!0})],o.prototype,"legendEnabled",null),e([v()],o.prototype,"holeFilling",void 0),e([v(ht)],o.prototype,"updatingProgress",void 0),e([v()],o.prototype,"updatingProgressValue",null),e([v()],o.prototype,"hasTexturesOrVertexColors",null),e([v()],o.prototype,"rendererTextureUsage",null),e([v()],o.prototype,"elevationOffset",null),e([v()],o.prototype,"elevationInfo",null),e([v({type:Boolean})],o.prototype,"slicePlaneEnabled",void 0),e([v()],o.prototype,"supportedTextureEncodings",null),e([v()],o.prototype,"uncompressedTextureDownsamplingEnabled",null),e([v({type:[oe]})],o.prototype,"_modifications",void 0),e([v({readOnly:!0})],o.prototype,"clientGeometry",null),e([v()],o.prototype,"_elevationTask",void 0),e([v({readOnly:!0})],o.prototype,"_usePBR",null),o=e([I(ft)],o),o};function xt(e,t){u(e)||bt.warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}var Et;!function(e){e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE"}(Et||(Et={}));const jt=z(),wt=Q(),St=Q(),At=nt(),Tt=[0,0,0,0],Dt=new t([0,0,0,0]),Rt=ee(0,0,0,0);function Nt(e){if(null==e)return!1;const t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function Ft(e){return"geometryData"in e}function Vt(e){return null!=e&&b(e.data)}function Pt(e,t){let i=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(null!=t)for(const s of t)null!=s&&b(s.data)&&(i+=s.data.byteLength);return i}function Ht(e,t){return t.byteSize>Ct?(bt.warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}function Ut(e){if(0===e.length)return null;const t=10*e.length,i=new Float64Array(t);return e.forAll(((e,t)=>{let s=e.serviceObb;null==s&&(s=At,R(s.center,e.mbs),s.halfSize[0]=s.halfSize[1]=s.halfSize[2]=e.mbs[3]);const r=10*t;i[r]=s.center[0],i[r+1]=s.center[1],i[r+2]=s.center[2],i[r+3]=s.halfSize[0],i[r+4]=s.halfSize[1],i[r+5]=s.halfSize[2],i[r+6]=s.quaternion[0],i[r+7]=s.quaternion[1],i[r+8]=s.quaternion[2],i[r+9]=s.quaternion[3]})),i}const Gt={remove(){},pause(){},resume(){}};function Lt(e,t){e.forEach((e=>e.opacity=t))}var kt;!function(e){e[e.Absolute=0]="Absolute",e[e.RelativeToGround=1]="RelativeToGround",e[e.OnTheGround=2]="OnTheGround"}(kt||(kt={}));const Bt=V(),qt=z(),zt="elevation-change";function Kt(e){return t=>{if(e.immediate)return e.immediate.schedule(t);throw console.error("Error no immediate schudler"),new Error("cant find immediate scheduler")}}export{kt as ElevationMode,Ot as I3SMeshView3D};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../symbols.js";import t from"../../../core/Accessor.js";import{filterInPlace as r}from"../../../core/arrayUtils.js";import s from"../../../core/Handles.js";import{equalsShallow as o}from"../../../core/lang.js";import{floatEqualUlp as i}from"../../../core/mathUtils.js";import{destroyMaybe as a}from"../../../core/maybe.js";import{watch as n}from"../../../core/reactiveUtils.js";import{generateUID as p}from"../../../core/uid.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{diff as l}from"../../../core/accessorSupport/diffUtils.js";import{projectBuffer as d}from"../../../geometry/projection.js";import{create as u,set as m,NEGATIVE_INFINITY as f,expandWithBuffer as g}from"../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as y}from"../../../geometry/support/DoubleArray.js";import{makeDehydratedPoint as b}from"../../../layers/graphics/dehydratedFeatures.js";import{Graphics3DCore as _}from"./graphics/Graphics3DCore.js";import I from"./graphics/Graphics3DScaleVisibility.js";import{BOUNDING_BOX_CORNERS_POINTS_STRIDE as v,boundingBoxCornerPoints as M}from"./i3s/I3SGeometryUtil.js";import{LimitGraphicsMap as E}from"../support/LimitGraphicsMap.js";import{UpdatePolicy as j}from"../webgl-engine/lib/UpdatePolicy.js";import G from"../../../symbols/PointSymbol3D.js";class w{constructor(e,t){this.meta=e,this.index=t}}class D{constructor(e,t){this.graphic=e,this.geometry=t,this.components=[],this.overridesDirty=!1}}let C=class extends t{get updating(){return this._graphicsCore?.updating??!1}constructor(e){super(e),this.loadedGraphics=new E(5e4),this.slicePlaneEnabled=!1,this._renderingInfo={symbol:new G},this._handles=new s,this._featuresMap=new Map}initialize(){const e=this.view.basemapTerrain;this._graphicsCore=new _({owner:this,layer:this.layer,preferredUpdatePolicy:j.ASYNC,elevationFeatureExpressionEnabled:!1,graphicSymbolSupported:!1,getRenderingInfoWithoutRenderer:!0,hasZ:!0,hasM:!1,componentFactories:{deconflictor:e=>this.view.deconflictor.addGraphicsOwner(e),labeler:(e,t)=>this.view.labeler.addGraphicsOwner(e,t,{emptySymbolLabelSupported:!0,elevationInfoOverride:{mode:"absolute-height",offset:0},disablePlacement:{logEntityDescription:"3D Object Scene Layer features"}}),scaleVisibility:(t,r)=>new I({graphicsCoreOwner:this,layer:this.layer,queryGraphicUIDsInExtent:r,graphicsCore:t,basemapTerrain:e,layerScaleEnabled:!1})}}),this._graphicsCore.initializePromise.then((()=>this._graphicsCore.startCreateGraphics())).catch((()=>{})),this._handles.add(n((()=>this.layer.labelingInfo),((e,t)=>{l(e,t)&&this._graphicsCore.updateLabelingInfo()})))}destroy(){this._handles=a(this._handles),this._graphicsCore=a(this._graphicsCore),this.loadedGraphics=a(this.loadedGraphics),this.view=null}addNodeMeta(e,t){let r=0;const s=e.filteredIds,o=this.view.spatialReference,i=[];for(let a=0;a<e.featureIds.length;a++){const n=e.featureIds[a];let c=null==s;if(s&&r<s.length&&n===s[r]&&(c=!0,r++),!this._enabledForFeatureInNode(e,a))continue;const h=this._featuresMap.get(n);if(h){h.components.push(new w(e,a)),this._updateLabelPosition(n);continue}const l=t(a,e),d=b(0,0,0,o),u={objectId:n,uid:p(),attributes:l,visible:c,geometry:d},m=new D(u,d);m.components.push(new w(e,a)),this._featuresMap.set(n,m),this._updateLabelGeometry(n),i.push(u)}this.loadedGraphics.addMany(i)}updateLabelPositions(e){const t=this.view.renderCoordsHelper;this._forEachGraphic(e,((r,s,o)=>{const i=this._graphicsCore.getGraphics3DGraphicById(s.uid);null!=i&&this._updateLabelGeometry(e.featureIds[r])&&i.alignWithAbsoluteElevation(o.z??0,t,!1)}))}setNodeMetaAttributes(e,t){const r=new Array;this._forEachGraphic(e,((s,i)=>{const a=t(s,e);o(i.attributes,a)||(i.attributes=a,r.push(i.uid))})),this._graphicsCore.updateLabelingInfo(r)}applyFilterChange(e){this._forEachFeature(e,((t,r,s)=>{if(!this._enabledForFeatureInNode(e,t)){const s=e.featureIds[t];switch(this._removeFeature(r,e,t)){case O.REMOVED:this.loadedGraphics.removeManyByObjectId([s]);break;case O.MODIFIED:this._updateLabelPosition(s)}return}const o=r.graphic,i=o.visible;i!==s&&(o.visible=s,F.graphic=o,F.property="visible",F.oldValue=i,F.newValue=s,this._graphicsCore.graphicUpdateHandler(F))}))}removeNodeMeta(e){const t=[];this._forEachGraphic(e,(r=>{const s=e.featureIds[r],o=this._featuresMap.get(s);if(!o)return;switch(this._removeFeature(o,e,r)){case O.MODIFIED:this._updateLabelPosition(s);break;case O.REMOVED:t.push(s)}})),this.loadedGraphics.removeManyByObjectId(t)}_removeFeature(e,t,s){const o=e.components.length;return r(e.components,(e=>!(e.meta===t&&e.index===s))),0===e.components.length?(this._featuresMap.delete(t.featureIds[s]),O.REMOVED):o!==e.components.length?O.MODIFIED:O.UNMODIFIED}getRenderingInfo(){return this._renderingInfo}notifyGraphicGeometryChanged(){}notifyGraphicVisibilityChanged(){}_updateLabelPosition(e){const t=this._featuresMap.get(e);t&&this._updateLabelGeometry(e)&&(this.loadedGraphics.removeManyByObjectId([e]),this.loadedGraphics.addMany([t.graphic]))}_updateLabelGeometry(e){const t=this._featuresMap.get(e);if(!t)return!1;const r=t.geometry,s=this.view.spatialReference,o=this.view.renderCoordsHelper,a=r.x,n=r.y,p=r.z??0,c=t.components.length,h=y(c*v);let l=0;for(const{meta:i,index:d}of t.components)M(d,this.collection,i.objectHandle,h,l),l+=v;return d(h,o.spatialReference,0,h,s,0,h.length/3),m(L,f),g(L,h),r.x=(L[0]+L[3])/2,r.y=(L[1]+L[4])/2,r.z=L[5],!i(r.x,a)||!i(r.y,n)||!i(r.z,p)}_forEachGraphic(e,t){this._forEachFeature(e,((r,{graphic:s,geometry:o},i)=>{this._enabledForFeatureInNode(e,r)&&t(r,s,o,i)}))}_forEachFeature(e,t){let r=0;for(let s=0;s<e.featureIds.length;s++){const o=this._featuresMap.get(e.featureIds[s]);let i=null==e.filteredIds;e.filteredIds&&e.filteredIds[r]===e.featureIds[s]&&(i=!0,r++),o&&t(s,o,i)}}_enabledForFeatureInNode(e,t){return e.node.index<0||!this.overrides?.featureHasGeometryChanges(e.featureIds[t])}get updatePolicy(){return this._graphicsCore.effectiveUpdatePolicy}get usedMemory(){return this._graphicsCore.usedMemory}get unloadedMemoryEstimate(){return this._graphicsCore.unprocessedMemoryEstimate}get test(){return{graphicsCore:this._graphicsCore}}};e([c()],C.prototype,"view",void 0),e([c()],C.prototype,"layer",void 0),e([c()],C.prototype,"collection",void 0),e([c()],C.prototype,"loadedGraphics",void 0),e([c()],C.prototype,"overrides",void 0),e([c()],C.prototype,"updating",null),e([c()],C.prototype,"slicePlaneEnabled",void 0),e([c()],C.prototype,"_graphicsCore",void 0),C=e([h("esri.views.3d.layers.I3SMeshViewLabeler")],C);const F={graphic:null,property:null,oldValue:null,newValue:null};var O;!function(e){e[e.UNMODIFIED=0]="UNMODIFIED",e[e.MODIFIED=1]="MODIFIED",e[e.REMOVED=2]="REMOVED"}(O||(O={}));const L=u(),S=C;export{S as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import s from"../../../core/Logger.js";import{unwrapOrThrow as e}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{WorkerHandle as t}from"../../../core/workers/WorkerHandle.js";import{canProjectWithoutEngine as r,projectVectorToVector as p}from"../../../geometry/projection.js";import{ModificationType as h}from"../../../libs/i3s/enums.js";class i extends t{constructor(s){super("SceneLayerWorker","process",{process:s=>[s.geometryBuffer]},s,{hasInitialize:!0})}setModifications(s,e,o,t){const r={context:s,modifications:a(e,o,t),isGeodetic:t.isGeographic};this.broadcast(r,"setModifications")}setLegacySchema(s,e){const o=JSON.stringify(e);this.broadcast({context:s,jsonSchema:o},"setLegacySchema")}destroyContext(s){return this.broadcast(s,"destroyContext")}}const
|
|
5
|
+
import s from"../../../core/Logger.js";import{unwrapOrThrow as e}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{WorkerHandle as t}from"../../../core/workers/WorkerHandle.js";import{canProjectWithoutEngine as r,projectVectorToVector as p}from"../../../geometry/projection.js";import{ModificationType as h}from"../../../libs/i3s/enums.js";class i extends t{constructor(s){super("SceneLayerWorker","process",{process:s=>[s.geometryBuffer],project:s=>[s.positions.buffer],transformNormals:s=>[s.normals.buffer]},s,{hasInitialize:!0})}setModifications(s,e,o,t){const r={context:s,modifications:a(e,o,t),isGeodetic:t.isGeographic};this.broadcast(r,"setModifications")}setLegacySchema(s,e){const o=JSON.stringify(e);this.broadcast({context:s,jsonSchema:o},"setLegacySchema")}destroyContext(s){return this.broadcast(s,"destroyContext")}project(s,e){return this.invokeMethod("project",s,e)}transformNormals(s,e){return this.invokeMethod("transformNormals",s,e)}}const n=new o({deallocator:null}),u=[0,0,0];function a(o,t,i){n.clear();let a=1/0,c=1/0,f=-1/0,m=-1/0,l=!1;for(const g of t){const o="clip"===g.type?h.Inside:"mask"===g.type?h.Outside:h.Replace,t=e(g.geometry,"modification.geometry");let d=s=>s;if(t.spatialReference){if(!r(t.spatialReference,i)){s.getLogger("esri.views.3d.layers.I3SMeshWorkerHandle").warn("Can't project modification polygon into layer spatial reference, ignoring modification");continue}d=s=>(p(s,t.spatialReference,u,i),u)}else t.hasZ||(u[2]=0,d=s=>(u[0]=s[0],u[1]=s[1],u));l=l||o===h.Outside,n.push(o),n.push(t.rings.length);for(const s of t.rings){n.push(s.length);for(const e of s){const s=d(e);n.push(s[0]),n.push(s[1]),n.push(s[2]),a=Math.min(a,s[0]),c=Math.min(c,s[1]),f=Math.max(f,s[0]),m=Math.max(m,s[1])}}}if(null!=o)if(l){const s=1e-4;n.push(h.Inside),n.push(2),n.push(4),n.push(a-s),n.push(c-s),n.push(0),n.push(f+s),n.push(c-s),n.push(0),n.push(f+s),n.push(m+s),n.push(0),n.push(a-s),n.push(m+s),n.push(0),n.push(4),n.push(o[0]),n.push(o[1]),n.push(0),n.push(o[2]),n.push(o[1]),n.push(0),n.push(o[2]),n.push(o[3]),n.push(0),n.push(o[0]),n.push(o[3]),n.push(0)}else n.push(h.Outside),n.push(1),n.push(4),n.push(o[0]),n.push(o[1]),n.push(0),n.push(o[2]),n.push(o[1]),n.push(0),n.push(o[2]),n.push(o[3]),n.push(0),n.push(o[0]),n.push(o[3]),n.push(0);n.push(h.Finished);const d=new Float64Array(n.length);for(let s=0;s<n.length;++s)d[s]=n.at(s);return d}export{i as I3SMeshWorkerHandle,a as toWasmModification};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{IndexType as
|
|
5
|
+
import e from"../../../geometry/SpatialReference.js";import{toFloat64Array as r}from"../../../geometry/support/DoubleArray.js";import t from"../../../geometry/support/MeshGeoreferencedRelativeVertexSpace.js";import o from"../../../geometry/support/MeshGeoreferencedVertexSpace.js";import n from"../../../geometry/support/MeshLocalVertexSpace.js";import{a as s,n as i}from"../../../chunks/vec32.js";import{IndexType as a}from"../../../libs/i3s/enums.js";import{get as f}from"../../../libs/i3s/I3SModule.js";import{NodeIMModificationImpact as l}from"./i3s/I3SNode.js";async function c(e){await x();const r=[e.geometryBuffer];return{result:A(e,r),transferList:r}}async function u(e){await x();const r=[e.geometryBuffer],{geometryBuffer:t}=e,o=t.byteLength,n=E._malloc(o),s=new Uint8Array(E.HEAPU8.buffer,n,o);s.set(new Uint8Array(t));const i=E.dracoDecompressPointCloudData(n,s.byteLength);if(E._free(n),i.error.length>0)throw new Error(`i3s.wasm: ${i.error}`);const a=i.featureIds?.length>0?i.featureIds.slice():null,f=i.positions.slice();return a&&r.push(a.buffer),r.push(f.buffer),{result:{positions:f,featureIds:a},transferList:r}}async function m(e){await x(),S(e);const r={buffer:e.buffer};return{result:r,transferList:[r.buffer]}}async function y(e){await x(),w(e)}async function p(e){await x(),E.setLegacySchema(e.context,e.jsonSchema)}async function d(s){const{localMatrix:i,origin:a,positions:f,vertexSpace:l,local:c}=s,u=e.fromJSON(s.inSpatialReference),m=e.fromJSON(s.outSpatialReference),y={georeferenced:o,georeferencedRelative:t,local:n}[l.type].fromJSON(l);let p;if("georeferenced"===y.type){const{projectBuffer:e,initializeProjection:r}=await import("../../../geometry/projection.js");await r(u,m),p=new Float64Array(f.length),e(f,u,0,p,m,0,p.length/3)}else{const{project:e}=await import("../../../geometry/support/meshUtils/georeference.js");p=r(e({positions:f,transform:i?{localMatrix:i}:void 0,vertexSpace:y,inSpatialReference:u,outSpatialReference:m,local:c}))}const d=p.length,[b,h,g]=a;for(let e=0;e<d;e+=3)p[e]-=b,p[e+1]-=h,p[e+2]-=g;return{result:[p,f],transferList:[p.buffer,f.buffer]}}async function b({normalMatrix:e,normals:r}){const t=new Float32Array(r.length);return s(t,r,e),i(t,t),{result:[t,r],transferList:[t.buffer,r.buffer]}}function h(e){_(e)}let g,E;function w(e){const r=e.modifications,t=E._malloc(8*r.length),o=new Float64Array(E.HEAPU8.buffer,t,r.length);for(let n=0;n<r.length;++n)o[n]=r[n];E.setModifications(e.context,t,r.length,e.isGeodetic),E._free(t)}function A(e,r){if(!E)return null;const{context:t,localOrigin:o,globalTrafo:n,mbs:s,obb:i,elevationOffset:f,geometryBuffer:l,geometryDescriptor:c,indexToVertexProjector:u,vertexToRenderProjector:m}=e,y=E._malloc(l.byteLength),p=33,d=E._malloc(p*Float64Array.BYTES_PER_ELEMENT),b=new Uint8Array(E.HEAPU8.buffer,y,l.byteLength);b.set(new Uint8Array(l));const h=new Float64Array(E.HEAPU8.buffer,d,p);I(h,o);let g=h.byteOffset+3*h.BYTES_PER_ELEMENT,w=new Float64Array(h.buffer,g);I(w,n),g+=16*h.BYTES_PER_ELEMENT,w=new Float64Array(h.buffer,g),I(w,s),g+=4*h.BYTES_PER_ELEMENT,null!=i&&(w=new Float64Array(h.buffer,g),I(w,i.center),g+=3*h.BYTES_PER_ELEMENT,w=new Float64Array(h.buffer,g),I(w,i.halfSize),g+=3*h.BYTES_PER_ELEMENT,w=new Float64Array(h.buffer,g),I(w,i.quaternion));const A=c,L={isDraco:!1,isLegacy:!1,color:e.layouts.some((e=>e.some((e=>"color"===e.name)))),normal:e.needNormals&&e.layouts.some((e=>e.some((e=>"normalCompressed"===e.name)))),uv0:e.layouts.some((e=>e.some((e=>"uv0"===e.name)))),uvRegion:e.layouts.some((e=>e.some((e=>"uvRegion"===e.name)))),featureIndex:A.featureIndex},S=E.process(t,!!e.obb,y,b.byteLength,A,L,d,f,u,m,e.normalReferenceFrame);if(E._free(d),E._free(y),S.error.length>0)throw new Error(`i3s.wasm: ${S.error}`);if(S.discarded)return null;const _=S.componentOffsets.length>0?S.componentOffsets.slice():null,x=S.featureIds.length>0?S.featureIds.slice():null,T=S.anchorIds.length>0?Array.from(S.anchorIds):null,j=S.anchors.length>0?Array.from(S.anchors):null,M=S.interleavedVertedData.slice().buffer,P=S.indicesType===a.Int16?new Uint16Array(S.indices.buffer,S.indices.byteOffset,S.indices.byteLength/2).slice():new Uint32Array(S.indices.buffer,S.indices.byteOffset,S.indices.byteLength/4).slice(),R=S.positions.slice(),U=S.positionIndicesType===a.Int16?new Uint16Array(S.positionIndices.buffer,S.positionIndices.byteOffset,S.positionIndices.byteLength/2).slice():new Uint32Array(S.positionIndices.buffer,S.positionIndices.byteOffset,S.positionIndices.byteLength/4).slice(),v={layout:e.layouts[0],interleavedVertexData:M,indices:P,hasColors:S.hasColors,hasModifications:S.hasModifications,positionData:{data:R,indices:U}};return x&&r.push(x.buffer),_&&r.push(_.buffer),r.push(M),r.push(P.buffer),r.push(R.buffer),r.push(U.buffer),{componentOffsets:_,featureIds:x,anchorIds:T,anchors:j,transformedGeometry:v,obb:S.obb}}function L(e){return 0===e?l.Unmodified:1===e?l.PotentiallyModified:2===e?l.Culled:l.Unknown}function S(e){const{context:r,buffer:t}=e,o=E._malloc(t.byteLength),n=t.byteLength/Float64Array.BYTES_PER_ELEMENT,s=new Float64Array(E.HEAPU8.buffer,o,n),i=new Float64Array(t);s.set(i),E.filterOBBs(r,o,n),i.set(s),E._free(o)}function _(e){E&&(E.destroy(e),E=null)}function I(e,r){for(let t=0;t<r.length;++t)e[t]=r[t]}function x(){return E?Promise.resolve():(g||(g=f().then((e=>{E=e,g=null}))),g)}const T={transform:A,destroy:_};export{h as destroyContext,u as dracoDecompressPointCloudData,m as filterObbsForModifications,S as filterObbsForModificationsSync,x as initialize,L as interpretObbModificationResults,c as process,d as project,p as setLegacySchema,y as setModifications,w as setModificationsSync,T as test,b as transformNormals};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{f as r,t as o}from"../../../../chunks/mat3.js";import{c as a}from"../../../../chunks/mat3f64.js";import{f as n,m as s,a as i}from"../../../../chunks/mat4.js";import{c as l,I as u,b as c}from"../../../../chunks/mat4f64.js";import{s as m,a as h,g as f,e as p,n as d,b as g,f as x}from"../../../../chunks/vec3.js";import{Z as _,O as T,c as b}from"../../../../chunks/vec3f64.js";import{O as y}from"../../../../chunks/vec4f64.js";import{computeTranslationToOriginAndRotation as v,projectVectorToDehydratedPoint as C,projectBuffer as O,canProjectWithoutEngine as w}from"../../../../geometry/projection.js";import{create as M,empty as j,expandWithBuffer as A,intersectsClippingArea as P}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as I}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as R,getZeroIndexArray as E}from"../../../../geometry/support/Indices.js";import N from"../../../../geometry/support/MeshComponent.js";import F from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import B from"../../../../geometry/support/MeshTextureTransform.js";import{t as S,a as U}from"../../../../chunks/vec32.js";import{transformNormal as L,projectNormalToPCPF as $,transformTangent as G,projectTangentToPCPF as V}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as D}from"../../../../layers/graphics/dehydratedFeatures.js";import{MeshTransformUpdateAction as k}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as H}from"../../../ViewingMode.js";import{isEncodedMeshTexture as q}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as W}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as z}from"./ElevationAligners.js";import{needsElevationUpdates3D as Y,evaluateElevationInfoAtPoint as Z}from"./elevationAlignmentUtils.js";import{ElevationContext as J}from"./ElevationContext.js";import{Graphics3DMeshObject3DGraphicLayer as K}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as Q}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as X}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as ee,MeshFastUpdateProcessor as te}from"./MeshFastUpdateProcessor.js";import{createMaterial as re}from"../support/edgeUtils.js";import{parseColorMixMode as oe,encodeSymbolColor as ae}from"../support/symbolColorUtils.js";import ne from"../../support/debugFlags.js";import{Attribute as se}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as ie,CullFaceOptions as le}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as ue}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as ce}from"../../webgl-engine/lib/Geometry.js";import{Object3D as me}from"../../webgl-engine/lib/Object3D.js";import{Texture as he}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as fe}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as pe}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as de}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as ge,defaultSchematicMRRFactors as xe,defaultAdvancedMRRFactors as _e}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Te}from"../../../webgl/enums.js";const be=["mesh"];class ye extends X{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new ee,this._fastUpdateProcessor=new te,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ne.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new de({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new de({color:[0,1,1,1]}))}destroy(){super.destroy(),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,be,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t,new J),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>{const o=t(e);null!=o&&o.layerOpacityChanged(r,this._context.isAsync)}))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,Y)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>{const r=t(e);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){const a=this._context.renderCoordsHelper.spatialReference,n=Ie,{origin:s,transform:i}=r;switch(v(t,m(Oe,s.x,s.y,s.z??0),n,a),o){case k.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case k.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case k.UpdateFastLocalOrigin:e.updateFastLocalOrigin(n,i,this._context.localOriginFactory)}const{elevationContext:l}=e;l.centerPointInElevationSR=this._getCenterPointInElevationSR(n);const{elevationProvider:u,renderCoordsHelper:c}=this._context,h=(e,t)=>Z(e,u,l,c,t);return e.alignedSampledElevation=z(e,l,u.spatialReference,h,c,n),e.updateTransform(n,i,this._context.isAsync),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_textureTransformUid(e){const{offset:t,scale:r,rotation:o}=e??Ne;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:n,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:u,alphaCutoff:c,alphaMode:m}=t.material,h=this._colorOrTextureUid(a),f=this._colorOrTextureUid(n),p=this._textureTransformUid(s),d=this._colorOrTextureUid(i),g=this._textureTransformUid(l);if(o.color=a,o.colorTexture=n,o.normalTexture=i,o.uid=`${o.uid},cmuid:${h},ctmuid:${f},cttuid:${p},ntmuid:${d},nttuid:${g},ds:${u},ac:${c},am:${m}`,t.material instanceof F){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:n,emissiveColor:i,emissiveTexture:u,emissiveTextureTransform:c,occlusionTexture:m,occlusionTextureTransform:h}=t.material,f=this._colorOrTextureUid(a),p=this._textureTransformUid(n),d=this._colorOrTextureUid(i),g=this._colorOrTextureUid(u),x=this._textureTransformUid(c),_=this._colorOrTextureUid(m),T=this._textureTransformUid(h);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=u,o.occlusionTexture=m,o.colorTextureTransform=this._convertTextureTransform(s),o.normalTextureTransform=this._convertTextureTransform(l),o.emissiveTextureTransform=this._convertTextureTransform(c),o.occlusionTextureTransform=this._convertTextureTransform(h),o.metallicRoughnessTextureTransform=this._convertTextureTransform(n),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${f},mrtt:${p},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_convertTextureTransform(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data?e.data:e.url}_getInternalTextureId(e){const t=this._getInternalTexture(e,ie.Opaque);return null!=t?t.id:null}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let a=this._textures.get(o);return a||(a=new he(q(r)?r.data:r,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:!q(r)&&t!==ie.Opaque,encoding:q(r)&&null!=r.encoding?r.encoding:void 0}),this._textures.set(o,a),this._context.stage.add(a),this._context.stage.loadImmediate(a)),a}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return Te.CLAMP_TO_EDGE;case"mirror":return Te.MIRRORED_REPEAT;default:return Te.REPEAT}}_setInternalMaterialParameters(t,r){if(null!=t.color&&this._setInternalColorValueParameters(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);null!=e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}null!=t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),null!=t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),null!=t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),null!=t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),null!=t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=W(t.colorTextureTransform),r.normalTextureTransformMatrix=W(t.normalTextureTransform),r.occlusionTextureTransformMatrix=W(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=W(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=W(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=null!=this.symbolLayer.material?this.symbolLayer.material.colorMixMode:null;if(r)t.externalColor=y;else{const r=null!=this.symbolLayer.material?this.symbolLayer.material.color:null;null!=r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=y)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(t,r){const o=r.material?.color,a=r.material?.colorTexture,n=r.material?.alphaMode,s="blend"===n,i=!("opaque"===n)&&(this._hasTransparentVertexColors(t)||null!=o&&o.a<1||null!=a&&a.transparent||s),l=this._materialProperties(t,r,i),u=this._materialInfoCache.byUid(l.uid);if(u)return u.material;const c={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=ge({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGBA(l.emissiveColor),occlusionTexture:l.occlusionTexture}),h={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:_,diffuse:T,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:le.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};h.mrrFactors=m?[...xe]:[l.metallic,l.roughness,_e[2]],r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?le.None:le.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,c),this._setInternalMaterialParameters(l,h);const f=new pe(h);return c.material=f,this._materialInfoCache.set(l.uid,c),this._context.stage.add(f),f}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?ie.MaskBlend:ie.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?ie.Opaque:"mask"===t.alphaMode?ie.Mask:ie.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),n=[],s=[],i=[],l=[];for(let p=0;p<r;p++){const e=t[p],r=e.vertexAttributes.get(fe.POSITION),o=e.vertexAttributes.get(fe.NORMAL),u=e.indices.get(fe.POSITION),c=e.indices.get(fe.NORMAL),m=r.data,d=o.data;for(let t=0;t<u.length;t++){const e=3*u[t],r=3*c[t];for(let t=0;t<3;t++)n.push(m[e+t]);for(let t=0;t<3;t++)n.push(m[e+t]+d[r+t]*a);if(s.push(s.length),s.push(s.length),t%3==0){this._calculateFaceNormal(m,u,t,je),this._getFaceVertices(m,u,t,Oe,we,Me),h(Oe,Oe,we),h(Oe,Oe,Me),f(Oe,Oe,1/3);for(let e=0;e<3;e++)i.push(Oe[e]);for(let e=0;e<3;e++)i.push(Oe[e]+je[e]*a);l.push(l.length),l.push(l.length)}}}const u=t[0].transformation,c=new ce(this._debugVertexNormalMaterial,[[fe.POSITION,new se(n,3,!0)]],[[fe.POSITION,s]],null,ue.Line);t.push(c),c.transformation=u;const m=new ce(this._debugFaceNormalMaterial,[[fe.POSITION,new se(i,3,!0)]],[[fe.POSITION,l]],null,ue.Line);m.transformation=u,t.push(m)}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const n=this._createGeometryInfo(a,t,o);if(null==n)return null;const{geometries:s,objectTransformation:i}=n;ne.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,s);const l=new me({geometries:s,layerUid:this._context.layer.uid,graphicUid:o});l.transformation=i;const u=re(this.symbolLayer,{opacity:this._getLayerOpacity()}),c=null!=u?new Q(s[0].material,[u],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new K(this,l,s,null,null,z,r,c);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=Y(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>Z(e,h,r,f,t);return m.alignedSampledElevation=z(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=D(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return C([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,r,o){if(null==t)return this._createComponentNormalsFlat(e,o);let a=!1;if(!r.trustSourceNormals)for(let n=0;n<o.length;n+=3){this._calculateFaceNormal(e,o,n,je);for(let e=0;e<3;e++){const r=3*o[n+e];Oe[0]=t[r],Oe[1]=t[r+1],Oe[2]=t[r+2],p(je,Oe)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new ve(t,o,a)}_createComponentNormalsFlat(e,t){const r=I(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const n=this._calculateFaceNormal(e,t,a,je);for(let e=0;e<3;e++)r[a+e]=n[e],o[a+e]=a/3}return new ve(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let n=0;n<t.length;n+=3){const o=this._calculateFaceNormal(e,t,n,je);for(let e=0;e<3;e++){const a=t[n+e];let s=r[a];s||(s={normal:b(),count:0},r[a]=s),h(s.normal,s.normal,o),s.count++}}const o=I(3*t.length),a=new Array(3*t.length);for(let n=0;n<t.length;n++){const e=r[t[n]];1!==e.count&&(d(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*n+t]=e.normal[t];a[n]=n}return new ve(o,a,!1)}_getFaceVertices(e,t,r,o,a,n){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],n[0]=e[l],n[1]=e[l+1],n[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,Oe,we,Me),g(we,we,Oe),g(Me,Me,Oe),x(Oe,we,Me),d(o,Oe),o}_getOrCreateComponents(e){return e.components??Ee}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===Fe.ECEF?t.transformBeforeProject:null;if(null!=o&&(r=S(new Float64Array(r.length),r,o)),t.reprojection===Fe.NONE)return t.needsBufferCopy?new Float64Array(r):r;const a=null!=o?r:new Float64Array(r.length);return O(r,e.spatialReference,0,a,this._context.renderCoordsHelper.spatialReference,0,r.length/3),a}_createNormalBuffer(e,t,r){let o=e.vertexAttributes.normal;if(null==o)return null;const a=r.reprojection===Fe.ECEF?r.transformBeforeProject:null;null!=a&&(o=L(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Fe.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const n=e.vertexAttributes.position,s=null!=a?o:new Float32Array(o.length);return $(o,n,t,e.spatialReference,s)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const a=r.reprojection===Fe.ECEF?r.transformBeforeProject:null;null!=a&&(o=G(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Fe.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const n=e.vertexAttributes.position,s=null!=a?o:new Float32Array(o.length);return V(o,n,t,e.spatialReference,s)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=oe(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return ae(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,n=e.vertexAttributes.tangent;if(null!=o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=n&&n.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=a&&a.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),i=this._createPositionBuffer(e,s),u=this._createColorBuffer(e),c=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,s),h=this._createTangentBuffer(e,i,s);return{positionBuffer:i,normalBuffer:m,tangentBuffer:h,uvBuffer:a,colorBuffer:u,symbolColorBuffer:c,objectTransformation:s.reprojection===Fe.NONE&&null!=s.objectTransformation?s.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:s.reprojection===Fe.NONE&&null!=s.geometryTransformation?s.geometryTransformation:l()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r=t.isRelative,o=t.isGeoreferenced?this._context.renderCoordsHelper.viewingMode===H.Local?Fe.NONE:Fe.ECEF:Fe.NONE;if(r){const{origin:r}=t,a=l(),i=e.transform?.localMatrix??u;if(o===Fe.NONE){v(e.spatialReference,r,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:o,objectTransformation:a,geometryTransformation:c(i),needsBufferCopy:!1}}const m=n(l(),r);return s(m,m,i),{reprojection:o,transformBeforeProject:m,needsBufferCopy:!0}}return{reprojection:o,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,n){const s=this._context.renderCoordsHelper.spatialReference,u=e.anchor;Ce[0]=u.x,Ce[1]=u.y,Ce[2]=u.z??0;const c=l();return v(e.spatialReference,Ce,c,s),i(Ae,c),S(t,t,Ae),null==a&&null==n||(r(Pe,c),o(Pe,Pe),null!=a&&U(a,a,Pe),null!=n&&U(n,n,Pe,4)),c}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces??R(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes&&e.vertexAttributes.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference;let o;const a=t.length/3;return null==r||e.spatialReference.equals(r)?o=t:(o=new Float64Array(t.length),O(e.vertexAttributes.position,e.spatialReference,0,o,r,0,a)),j(Re),A(Re,o,0,a),!P(Re,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!w(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:a,uvBuffer:n,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:u,objectTransformation:c,geometryTransformation:m}=o,h=this._getOrCreateComponents(e),f=new Array;let p=!1;for(const d of h){if(!this._validateFaces(e,d))return null;const t=this._getOrCreateFaces(e,d);if(0===t.length)continue;const o=this._createComponentNormals(a,l,d,t);o.didFlipNormals&&(p=!0);const c=[[fe.POSITION,new se(a,3,!0)],[fe.NORMAL,new se(o.normals,3,!0)]],h=[[fe.POSITION,t],[fe.NORMAL,o.indices]];null!=s&&(c.push([fe.COLOR,new se(s,4,!0)]),h.push([fe.COLOR,t])),null!=i&&(c.push([fe.SYMBOLCOLOR,new se(i,4,!0)]),h.push([fe.SYMBOLCOLOR,E(t.length)])),null!=n&&(c.push([fe.UV0,new se(n,2,!0)]),h.push([fe.UV0,t])),null!=u&&(c.push([fe.TANGENT,new se(u,4,!0)]),h.push([fe.TANGENT,t]));const g=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),x=this._getOrCreateMaterial(e,d),_=new ce(x,c,h,null,ue.Mesh,g);_.transformation=m,f.push(_)}return p&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:f,objectTransformation:c}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class ve{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const Ce=b(),Oe=b(),we=b(),Me=b(),je=b(),Ae=l(),Pe=a(),Ie=l(),Re=M(),Ee=[new N],Ne=new B;var Fe;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(Fe||(Fe={}));export{ye as Graphics3DMeshFillSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{f as r,t as o}from"../../../../chunks/mat3.js";import{c as a}from"../../../../chunks/mat3f64.js";import{f as n,m as s,a as i}from"../../../../chunks/mat4.js";import{c as l,I as u,b as c}from"../../../../chunks/mat4f64.js";import{s as m,a as h,g as f,e as p,n as d,b as g,f as x}from"../../../../chunks/vec3.js";import{Z as _,O as T,c as b}from"../../../../chunks/vec3f64.js";import{O as y}from"../../../../chunks/vec4f64.js";import{computeTranslationToOriginAndRotation as v,projectVectorToDehydratedPoint as C,projectBuffer as O,canProjectWithoutEngine as w}from"../../../../geometry/projection.js";import{create as M,empty as j,expandWithBuffer as P,intersectsClippingArea as A}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as I}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as R,getZeroIndexArray as E}from"../../../../geometry/support/Indices.js";import N from"../../../../geometry/support/MeshComponent.js";import F from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import B from"../../../../geometry/support/MeshTextureTransform.js";import{t as S,a as U}from"../../../../chunks/vec32.js";import{transformNormal as L,projectNormalToPCPF as $,transformTangent as G,projectTangentToPCPF as V}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as D}from"../../../../layers/graphics/dehydratedFeatures.js";import{MeshTransformUpdateAction as k}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as H}from"../../../ViewingMode.js";import{isEncodedMeshTexture as q}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as W}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as z}from"./ElevationAligners.js";import{needsElevationUpdates3D as Y,evaluateElevationInfoAtPoint as Z}from"./elevationAlignmentUtils.js";import{ElevationContext as J}from"./ElevationContext.js";import{Graphics3DMeshObject3DGraphicLayer as K}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as Q}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as X}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as ee,MeshFastUpdateProcessor as te}from"./MeshFastUpdateProcessor.js";import{createMaterial as re}from"../support/edgeUtils.js";import{parseColorMixMode as oe,encodeSymbolColor as ae}from"../support/symbolColorUtils.js";import ne from"../../support/debugFlags.js";import{Attribute as se}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as ie,CullFaceOptions as le}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as ue}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as ce}from"../../webgl-engine/lib/Geometry.js";import{Object3D as me}from"../../webgl-engine/lib/Object3D.js";import{Texture as he}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as fe}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as pe}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as de}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as ge,defaultSchematicMRRFactors as xe,defaultAdvancedMRRFactors as _e}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Te}from"../../../webgl/enums.js";const be=["mesh"];class ye extends X{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new ee,this._fastUpdateProcessor=new te,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ne.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new de({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new de({color:[0,1,1,1]}))}destroy(){super.destroy(),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,be,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t,new J),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>{const o=t(e);null!=o&&o.layerOpacityChanged(r,this._context.isAsync)}))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,Y)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>{const r=t(e);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){const a=this._context.renderCoordsHelper.spatialReference,n=Ie,{origin:s,transform:i}=r;switch(v(t,m(Oe,s.x,s.y,s.z??0),n,a),o){case k.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case k.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case k.UpdateFastLocalOrigin:e.updateFastLocalOrigin(n,i,this._context.localOriginFactory)}const{elevationContext:l}=e;l.centerPointInElevationSR=this._getCenterPointInElevationSR(n);const{elevationProvider:u,renderCoordsHelper:c}=this._context,h=(e,t)=>Z(e,u,l,c,t);return e.alignedSampledElevation=z(e,l,u.spatialReference,h,c,n),e.updateTransform(n,i,this._context.isAsync),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_textureTransformUid(e){const{offset:t,scale:r,rotation:o}=e??Ne;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:n,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:u,alphaCutoff:c,alphaMode:m}=t.material,h=this._colorOrTextureUid(a),f=this._colorOrTextureUid(n),p=this._textureTransformUid(s),d=this._colorOrTextureUid(i),g=this._textureTransformUid(l);if(o.color=a,o.colorTexture=n,o.normalTexture=i,o.uid=`${o.uid},cmuid:${h},ctmuid:${f},cttuid:${p},ntmuid:${d},nttuid:${g},ds:${u},ac:${c},am:${m}`,t.material instanceof F){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:n,emissiveColor:i,emissiveTexture:u,emissiveTextureTransform:c,occlusionTexture:m,occlusionTextureTransform:h}=t.material,f=this._colorOrTextureUid(a),p=this._textureTransformUid(n),d=this._colorOrTextureUid(i),g=this._colorOrTextureUid(u),x=this._textureTransformUid(c),_=this._colorOrTextureUid(m),T=this._textureTransformUid(h);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=u,o.occlusionTexture=m,o.colorTextureTransform=this._convertTextureTransform(s),o.normalTextureTransform=this._convertTextureTransform(l),o.emissiveTextureTransform=this._convertTextureTransform(c),o.occlusionTextureTransform=this._convertTextureTransform(h),o.metallicRoughnessTextureTransform=this._convertTextureTransform(n),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${f},mrtt:${p},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_convertTextureTransform(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data?e.data:e.url}_getInternalTextureId(e){const t=this._getInternalTexture(e,ie.Opaque);return null!=t?t.id:null}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let a=this._textures.get(o);return a||(a=new he(q(r)?r.data:r,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:!q(r)&&t!==ie.Opaque,encoding:q(r)&&null!=r.encoding?r.encoding:void 0}),this._textures.set(o,a),this._context.stage.add(a),this._context.stage.loadImmediate(a)),a}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return Te.CLAMP_TO_EDGE;case"mirror":return Te.MIRRORED_REPEAT;default:return Te.REPEAT}}_setInternalMaterialParameters(t,r){if(null!=t.color&&this._setInternalColorValueParameters(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);null!=e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}null!=t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),null!=t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),null!=t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),null!=t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),null!=t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=W(t.colorTextureTransform),r.normalTextureTransformMatrix=W(t.normalTextureTransform),r.occlusionTextureTransformMatrix=W(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=W(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=W(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=null!=this.symbolLayer.material?this.symbolLayer.material.colorMixMode:null;if(r)t.externalColor=y;else{const r=null!=this.symbolLayer.material?this.symbolLayer.material.color:null;null!=r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=y)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(t,r){const o=r.material?.color,a=r.material?.colorTexture,n=r.material?.alphaMode,s="blend"===n,i=!("opaque"===n)&&(this._hasTransparentVertexColors(t)||null!=o&&o.a<1||null!=a&&a.transparent||s),l=this._materialProperties(t,r,i),u=this._materialInfoCache.byUid(l.uid);if(u)return u.material;const c={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=ge({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),h={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:_,diffuse:T,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:le.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};h.mrrFactors=m?[...xe]:[l.metallic,l.roughness,_e[2]],r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?le.None:le.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,c),this._setInternalMaterialParameters(l,h);const f=new pe(h);return c.material=f,this._materialInfoCache.set(l.uid,c),this._context.stage.add(f),f}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?ie.MaskBlend:ie.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?ie.Opaque:"mask"===t.alphaMode?ie.Mask:ie.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),n=[],s=[],i=[],l=[];for(let p=0;p<r;p++){const e=t[p],r=e.vertexAttributes.get(fe.POSITION),o=e.vertexAttributes.get(fe.NORMAL),u=e.indices.get(fe.POSITION),c=e.indices.get(fe.NORMAL),m=r.data,d=o.data;for(let t=0;t<u.length;t++){const e=3*u[t],r=3*c[t];for(let t=0;t<3;t++)n.push(m[e+t]);for(let t=0;t<3;t++)n.push(m[e+t]+d[r+t]*a);if(s.push(s.length),s.push(s.length),t%3==0){this._calculateFaceNormal(m,u,t,je),this._getFaceVertices(m,u,t,Oe,we,Me),h(Oe,Oe,we),h(Oe,Oe,Me),f(Oe,Oe,1/3);for(let e=0;e<3;e++)i.push(Oe[e]);for(let e=0;e<3;e++)i.push(Oe[e]+je[e]*a);l.push(l.length),l.push(l.length)}}}const u=t[0].transformation,c=new ce(this._debugVertexNormalMaterial,[[fe.POSITION,new se(n,3,!0)]],[[fe.POSITION,s]],null,ue.Line);t.push(c),c.transformation=u;const m=new ce(this._debugFaceNormalMaterial,[[fe.POSITION,new se(i,3,!0)]],[[fe.POSITION,l]],null,ue.Line);m.transformation=u,t.push(m)}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const n=this._createGeometryInfo(a,t,o);if(null==n)return null;const{geometries:s,objectTransformation:i}=n;ne.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,s);const l=new me({geometries:s,layerUid:this._context.layer.uid,graphicUid:o});l.transformation=i;const u=re(this.symbolLayer,{opacity:this._getLayerOpacity()}),c=null!=u?new Q(s[0].material,[u],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new K(this,l,s,null,null,z,r,c);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=Y(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>Z(e,h,r,f,t);return m.alignedSampledElevation=z(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=D(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return C([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,r,o){if(null==t)return this._createComponentNormalsFlat(e,o);let a=!1;if(!r.trustSourceNormals)for(let n=0;n<o.length;n+=3){this._calculateFaceNormal(e,o,n,je);for(let e=0;e<3;e++){const r=3*o[n+e];Oe[0]=t[r],Oe[1]=t[r+1],Oe[2]=t[r+2],p(je,Oe)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new ve(t,o,a)}_createComponentNormalsFlat(e,t){const r=I(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const n=this._calculateFaceNormal(e,t,a,je);for(let e=0;e<3;e++)r[a+e]=n[e],o[a+e]=a/3}return new ve(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let n=0;n<t.length;n+=3){const o=this._calculateFaceNormal(e,t,n,je);for(let e=0;e<3;e++){const a=t[n+e];let s=r[a];s||(s={normal:b(),count:0},r[a]=s),h(s.normal,s.normal,o),s.count++}}const o=I(3*t.length),a=new Array(3*t.length);for(let n=0;n<t.length;n++){const e=r[t[n]];1!==e.count&&(d(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*n+t]=e.normal[t];a[n]=n}return new ve(o,a,!1)}_getFaceVertices(e,t,r,o,a,n){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],n[0]=e[l],n[1]=e[l+1],n[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,Oe,we,Me),g(we,we,Oe),g(Me,Me,Oe),x(Oe,we,Me),d(o,Oe),o}_getOrCreateComponents(e){return e.components??Ee}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===Fe.ECEF?t.transformBeforeProject:null;if(null!=o&&(r=S(new Float64Array(r.length),r,o)),t.reprojection===Fe.NONE)return t.needsBufferCopy?new Float64Array(r):r;const a=null!=o?r:new Float64Array(r.length);return O(r,e.spatialReference,0,a,this._context.renderCoordsHelper.spatialReference,0,r.length/3),a}_createNormalBuffer(e,t,r){let o=e.vertexAttributes.normal;if(null==o)return null;const a=r.reprojection===Fe.ECEF?r.transformBeforeProject:null;null!=a&&(o=L(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Fe.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const n=e.vertexAttributes.position,s=null!=a?o:new Float32Array(o.length);return $(o,n,t,e.spatialReference,s)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const a=r.reprojection===Fe.ECEF?r.transformBeforeProject:null;null!=a&&(o=G(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Fe.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const n=e.vertexAttributes.position,s=null!=a?o:new Float32Array(o.length);return V(o,n,t,e.spatialReference,s)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=oe(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return ae(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,n=e.vertexAttributes.tangent;if(null!=o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=n&&n.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=a&&a.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),i=this._createPositionBuffer(e,s),u=this._createColorBuffer(e),c=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,s),h=this._createTangentBuffer(e,i,s);return{positionBuffer:i,normalBuffer:m,tangentBuffer:h,uvBuffer:a,colorBuffer:u,symbolColorBuffer:c,objectTransformation:s.reprojection===Fe.NONE&&null!=s.objectTransformation?s.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:s.reprojection===Fe.NONE&&null!=s.geometryTransformation?s.geometryTransformation:l()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r=t.isRelative,o=t.isGeoreferenced?this._context.renderCoordsHelper.viewingMode===H.Local?Fe.NONE:Fe.ECEF:Fe.NONE;if(r){const{origin:r}=t,a=l(),i=e.transform?.localMatrix??u;if(o===Fe.NONE){v(e.spatialReference,r,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:o,objectTransformation:a,geometryTransformation:c(i),needsBufferCopy:!1}}const m=n(l(),r);return s(m,m,i),{reprojection:o,transformBeforeProject:m,needsBufferCopy:!0}}return{reprojection:o,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,n){const s=this._context.renderCoordsHelper.spatialReference,u=e.anchor;Ce[0]=u.x,Ce[1]=u.y,Ce[2]=u.z??0;const c=l();return v(e.spatialReference,Ce,c,s),i(Pe,c),S(t,t,Pe),null==a&&null==n||(r(Ae,c),o(Ae,Ae),null!=a&&U(a,a,Ae),null!=n&&U(n,n,Ae,4)),c}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces??R(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes&&e.vertexAttributes.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference;let o;const a=t.length/3;return null==r||e.spatialReference.equals(r)?o=t:(o=new Float64Array(t.length),O(e.vertexAttributes.position,e.spatialReference,0,o,r,0,a)),j(Re),P(Re,o,0,a),!A(Re,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!w(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:a,uvBuffer:n,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:u,objectTransformation:c,geometryTransformation:m}=o,h=this._getOrCreateComponents(e),f=new Array;let p=!1;for(const d of h){if(!this._validateFaces(e,d))return null;const t=this._getOrCreateFaces(e,d);if(0===t.length)continue;const o=this._createComponentNormals(a,l,d,t);o.didFlipNormals&&(p=!0);const c=[[fe.POSITION,new se(a,3,!0)],[fe.NORMAL,new se(o.normals,3,!0)]],h=[[fe.POSITION,t],[fe.NORMAL,o.indices]];null!=s&&(c.push([fe.COLOR,new se(s,4,!0)]),h.push([fe.COLOR,t])),null!=i&&(c.push([fe.SYMBOLCOLOR,new se(i,4,!0)]),h.push([fe.SYMBOLCOLOR,E(t.length)])),null!=n&&(c.push([fe.UV0,new se(n,2,!0)]),h.push([fe.UV0,t])),null!=u&&(c.push([fe.TANGENT,new se(u,4,!0)]),h.push([fe.TANGENT,t]));const g=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),x=this._getOrCreateMaterial(e,d),_=new ce(x,c,h,null,ue.Mesh,g);_.transformation=m,f.push(_)}return p&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:f,objectTransformation:c}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class ve{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const Ce=b(),Oe=b(),we=b(),Me=b(),je=b(),Pe=l(),Ae=a(),Ie=l(),Re=M(),Ee=[new N],Ne=new B;var Fe;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(Fe||(Fe={}));export{ye as Graphics3DMeshFillSymbolLayer};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import e from"../../../../Color.js";import t from"../../../../core/Error.js";import{loadImageAsync as o}from"../../../../support/requestUtils.js";import{EncodedMeshTexture as r}from"../../glTF/internal/resourceUtils.js";import{TextureUsage as a,TextureEncoding as s}from"./enums.js";import{CullFaceOptions as n}from"../../webgl-engine/lib/basicInterfaces.js";import{useSchematicPBR as l}from"../../webgl-engine/materials/pbrUtils.js";async function i(t){const o=[],r=[];if(null==t){return{material:{alphaMode:"opaque",alphaCutoff:.1,doubleSided:!0,cullFace:0,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[1,1,1,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6000000238418579},wrapTextures:!1,hasParametersFromSource:!0},requiredTextures:o,textureData:r}}const s=d(t);"auto"===t.alphaMode&&console.warn('alphaMode "auto" not supported by I3S PBRMaterial - defaulting to "blend".');return{material:{alphaMode:"auto"===t.alphaMode?"blend":t.alphaMode,alphaCutoff:t.alphaCutoff,doubleSided:t.doubleSided,cullFace:t.doubleSided?n.None:n.Back,normalTextureId:await u(t.normalTexture,o,r,a.Normal),emissiveTextureId:s?await u(t.emissiveTexture,o,r,a.Emissive):-1,occlusionTextureId:s?await u(t.occlusionTexture,o,r,a.Occlusion):-1,emissiveFactor:s&&null!=t.emissiveColor?e.toUnitRGB(t.emissiveColor):[0,0,0],metallicRoughness:{baseColorFactor:null!=t.color?e.toUnitRGBA(t.color):[1,1,1,1],baseColorTextureId:await u(t.colorTexture,o,r,a.Color),metallicRoughnessTextureId:s?await u(t.metallicRoughnessTexture,o,r,a.MetallicRoughness):-1,metallicFactor:s?t.metallic:0,roughnessFactor:s?t.roughness:0},wrapTextures:!0,hasParametersFromSource:l({normalTexture:t.normalTexture,emissiveTexture:s?t.emissiveTexture:null,emissiveFactor:s?e.toUnitRGB(t.emissiveColor):null,occlusionTexture:s?t.occlusionTexture:null,metallicRoughnessTexture:s?t.metallicRoughnessTexture:null,metallicFactor:s?t.metallic:null,roughnessFactor:s?t.roughness:null})},requiredTextures:o,textureData:r}}async function u(e,a,n,l){if(null==e)return-1;const i=n.length,u=e.data,d=e.url;if(null!=u){if(u instanceof HTMLImageElement||u instanceof HTMLCanvasElement){const e=c(u);return n.push({id:i,usage:l,data:e,encoding:s.PNG,downsampled:!1}),a.push({id:i,usage:l,encodings:[{name:void 0,encoding:s.PNG}]}),i}if(u instanceof HTMLVideoElement)return-1;if(u instanceof ImageData)throw new t("ImageData textures not supported yet for client side I3S nodes");if(u instanceof r)throw new t("EncodedMeshTexture textures not supported yet for client side I3S nodes")}else if(null!=d){const e=new Image;e.src=d;const t=c(await o(e,e.src,!1,void 0));return n.push({id:i,usage:l,data:t,encoding:s.PNG,downsampled:!1}),a.push({id:i,usage:l,encodings:[{name:void 0,encoding:s.PNG}]}),i}return-1}function c(e){const t=1048576,o=4096,r=2;let a=e.width*e.height;if(a>=o){let o=e.width,s=e.height;do{o=Math.ceil(o/r),s=Math.ceil(s/r),a=o*s}while(a>t);const n=document.createElement("canvas");n.width=o,n.height=s;return n.getContext("2d").drawImage(e,0,0,o,s),n}return e}function d(e){return e.hasOwnProperty("metallicRoughnessTexture")}export{i as convertMeshMaterialToPBRMaterial};
|