@arcgis/core 4.29.6 → 4.29.8
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/{4984e2b79d862114d6a6.js → 1a8d56e01ddfec2257c3.js} +1 -1
- package/assets/esri/core/workers/chunks/{3afb525a131b6841276b.js → 1e4d779a884f13762601.js} +1 -1
- package/assets/esri/core/workers/chunks/{2447a4d5886aeb0ff72a.js → 205597cd91cb7ff3d2b4.js} +1 -1
- package/assets/esri/core/workers/chunks/{6c50daccd84ba5545bfe.js → 22ebdec0867e44d8d58c.js} +1 -1
- package/assets/esri/core/workers/chunks/{da4616b02dd0c3dd3d5d.js → 321547d796a2ecd72ab4.js} +1 -1
- package/assets/esri/core/workers/chunks/{6c3ae96ec90e9ed7dd50.js → 32be478638e9e643ea32.js} +1 -1
- package/assets/esri/core/workers/chunks/{a61f337802ae963d7f65.js → 59f03847a9eb96e5f65c.js} +1 -1
- package/assets/esri/core/workers/chunks/{7a98d2e026f63a581b1e.js → 5b08309b184f5d8345a0.js} +1 -1
- package/assets/esri/core/workers/chunks/631bda7b99a27f4453c1.js +1 -0
- package/assets/esri/core/workers/chunks/{c527692694688a5b3b07.js → 658a8ee9a4f24bc03f7f.js} +1 -1
- package/assets/esri/core/workers/chunks/99ac2a6a5be0604ee4c2.js +1 -0
- package/assets/esri/core/workers/chunks/{48db6e0bbb1a9c043193.js → b7a78246d25dc07f173d.js} +1 -1
- package/assets/esri/core/workers/chunks/{60ab18c6a04d4b2f1d4c.js → bb05528d2ca12c57a031.js} +1 -1
- package/assets/esri/core/workers/chunks/{5227f9eea6988aadad7f.js → cf0dc0ccbeaf9458de6e.js} +1 -1
- package/assets/esri/core/workers/chunks/{f59b5ea05caca8a1a398.js → d40408be9bbcb0021d18.js} +1 -1
- package/assets/esri/core/workers/chunks/df6fbabbc74a408575fc.js +1 -0
- package/chunks/Laserlines.glsl.js +1 -1
- package/chunks/sphere.js +1 -1
- package/chunks/vec32.js +1 -1
- package/chunks/vec42.js +1 -1
- package/core/libs/gl-matrix-2/math/quat.js +1 -1
- package/core/libs/gl-matrix-2/math/vec3.js +1 -1
- package/core/libs/gl-matrix-2/math/vec4.js +1 -1
- package/geometry/support/sphere.js +1 -1
- package/interfaces.d.ts +8 -2
- package/kernel.js +1 -1
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/layers/mixins/FeatureLayerBase.js +1 -1
- package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
- package/layers/support/SubtypeSublayer.js +1 -1
- package/layers/voxel/VoxelVolume.js +1 -1
- package/networks/UtilityNetwork.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/mesh/MeshData.js +1 -1
- package/views/2d/engine/webgl/mesh/MultiTileMeshData.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
- package/views/2d/layers/features/FeatureContainer.js +1 -1
- package/views/2d/layers/features/Processor.js +1 -1
- package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
- package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/OverrideChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderIndirect.js +1 -1
- package/views/2d/layers/features/support/GraphicsReader.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
- package/views/3d/camera/constraintUtils/distance.js +1 -1
- package/views/3d/camera/constraintUtils/tilt.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/graphics/Deconflictor.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
- package/views/3d/layers/support/makeScheduleFunction.js +5 -0
- package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
- package/views/3d/state/controllers/global/PinchAndPanController.js +1 -1
- package/views/3d/state/controllers/global/ZoomController.js +1 -1
- package/views/3d/state/controllers/global/ZoomStepController.js +1 -1
- package/views/3d/state/controllers/momentum/ZoomSphericalMomentumController.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/support/geometryUtils/sphere.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/PatchRenderData.js +1 -1
- package/views/3d/terrain/SphericalPatch.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/webgl-engine/lib/Camera.js +1 -1
- package/views/3d/webgl-engine/lib/Object3D.js +1 -1
- package/views/3d/webgl-engine/lib/Octree.js +1 -1
- package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
- package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/lib/intersectorUtilsConversions.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/InstanceOctree.js +1 -1
- package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
- package/views/interactive/sketch/constraints.js +1 -1
- package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
- package/views/support/geometry3dUtils.js +1 -1
- package/assets/esri/core/workers/chunks/a068f0c8c1c632e8b2cb.js +0 -1
- package/assets/esri/core/workers/chunks/a28b7d868346e13468bb.js +0 -1
- package/assets/esri/core/workers/chunks/ccd53b81c2688dd11584.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/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 n from"../../../core/Collection.js";import{makeHandle as a}from"../../../core/handleUtils.js";import has from"../../../core/has.js";import l from"../../../core/Logger.js";import{someMap as d}from"../../../core/MapUtils.js";import{destroyMaybe as h}from"../../../core/maybe.js";import c from"../../../core/PooledArray.js";import{isAbortError as u,throwIfAborted as _,createResolver as g}from"../../../core/promiseUtils.js";import{initial as m,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{subclass as I}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as M,invert as C}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as x}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as O,getTranslation as E}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as j,create as w}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as R}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{s as S,e as A,t as D,z as T,g as N,h as V,f as F,D as P}from"../../../chunks/vec32.js";import{create as H}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as U}from"../../../chunks/vec42.js";import{fromValues as G}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as L}from"../../../core/support/UpdatingHandles.js";import{localLinearScaleFactors as k}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as B}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as q}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as z}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as W}from"../../../geometry/projection/projectVectorToVector.js";import{create as K,empty as $,expandWithBuffer as Q,toRect as X}from"../../../geometry/support/aaBoundingBox.js";import{create as Y,intersects as J}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as Z}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as ee}from"../../../geometry/support/FloatArray.js";import{compactIndices as te}from"../../../geometry/support/Indices.js";import{g as ie,f as se,a as re}from"../../../chunks/sphere.js";import{newUByteArray as oe}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as ne}from"../../../layers/LayerConstants.js";import ae from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as le}from"../../../layers/support/fieldUtils.js";import de from"../../../layers/support/SceneModification.js";import{getColor as he,getOpacity as ce}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{loadArcade as ue}from"../../../support/arcadeOnDemand.js";import{isBasemapLayer as _e}from"../../../support/basemapUtils.js";import ge from"../../../symbols/Symbol3D.js";import{getMetersPerUnit as me}from"../../../symbols/support/unitConversionUtils.js";import pe from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as fe}from"./I3SMeshViewPerformanceInfo.js";import{I3SMeshWorkerHandle as be,toWasmModification as ye}from"./I3SMeshWorkerHandle.js";import{ElevationMode as ve,ForAllFeaturesReturnType as Ie,ForAllFeaturesMode as Me}from"./II3SMeshView3D.js";import{initialize as Ce,setModificationsSync as xe,filterObbsForModificationsSync as Oe,interpretObbModificationResults as Ee}from"./SceneLayerWorker.js";import{overrideColor as je}from"./graphics/graphicUtils.js";import{areLabelsVisible as we}from"./graphics/Labeler.js";import{TextureUsage as Re,TextureEncoding as Se}from"./i3s/enums.js";import Ae from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as De}from"./i3s/I3SAsyncElevationUpdater.js";import{I3SCrossfadeHelper as Te,NodeCrossfadeMetaData as Ne}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as Ve}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Fe}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Pe,selectEncoding as He,defaultMaterial as Ue,createTexture as Ge,configureMaterial as Le}from"./i3s/I3SMaterialUtil.js";import{NodeIMModificationImpact as ke,NodeState as Be}from"./i3s/I3SNode.js";import{I3SOverrides as qe}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as ze,getLocalOrigin as We}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as Ke,checkSceneLayerValid as $e,checkSceneLayerCompatibleWithView as Qe,getCacheKeySuffix as Xe,whenGraphicAttributes as Ye,computeVisibilityObb as Je,filterInPlace as Ze,getCachedAttributeValue as et,intersectBoundingRectWithMbs as tt,MbsIntersectResult as it,addWraparound as st,getSymbolInfo as rt,transparentEdgeMaterial as ot,getClipRect as nt}from"./i3s/I3SUtil.js";import{IDBCache as at}from"./i3s/IDBCache.js";import{IDBMockCache as lt}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as dt}from"./i3s/LayerElevationProvider.js";import{attributeLookup as ht}from"./support/attributeUtils.js";import{ColorMixModeEnum as ct}from"./support/symbolColorUtils.js";import{debugFlags as ut}from"../support/debugFlags.js";import{ElevationRange as _t}from"../support/ElevationRange.js";import{toBoundingRect as gt}from"../support/extentUtils.js";import{Obb as mt}from"../support/orientedBoundingBox.js";import{updatingProgress as pt}from"../support/updatingProperties.js";import{glLayout as ft}from"../support/buffer/glUtil.js";import{createVertexBufferLayout as bt}from"../webgl-engine/collections/Component/SourceGeometry.js";import{TextureCoordinateAttributeType as yt}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{loadBasis as vt}from"../webgl-engine/lib/BasisUtil.js";import{Transparency as It}from"../webgl-engine/lib/edgeRendering/interfaces.js";const Mt="esri.views.3d.layers.I3SMeshView3D",Ct=()=>l.getLogger(Mt),xt=[1,1,1,1];class Ot extends Ne{constructor(e,t,i,s,r,o,n,a,l){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=n,this.anchorIds=a,this.anchors=l,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0}}var Et;!function(e){e[e.CastShadows=4]="CastShadows",e[e.Pickable=5]="Pickable"}(Et||(Et={}));const jt=23,wt=100*o.MEGABYTES,Rt=t=>{let o=class extends t{constructor(...e){super(e),this._needsNormals=!0,this._updatingHandles=new L,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._hasComponentData=!1,this._hasVertexColors=!1,this._nodeColorOverride=null,this.updating=!0,this.holeFilling="auto",this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=new Array,this.ignoresMemoryFactor=!1,this._layerUrl="",this._cacheKeySuffix=null,this._planetRadiusInGlobalMode=0,this._elevationTask=null,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i(null,null,{}),this._crossfadeHelper=new Te(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 Ke(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?Re.AllTexturesPBR:Re.AllTextures:this._usePBR||this._hasLoadedPBRTextures?Re.GeometryTexturesPBR:Re.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=me(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 new Wt(ve.Absolute,0);const t=y(this.i3slayer.spatialReference),i=me(e.unit),s=(e.offset??0)*i/t;switch(e.mode){case"absolute-height":return new Wt(ve.Absolute,s);case"relative-to-ground":return new Wt(ve.RelativeToGround,s);case"on-the-ground":return new Wt(ve.OnTheGround,0);default:return new Wt(ve.Absolute,0)}}get supportedTextureEncodings(){return Pe(this.view._stage.renderView.capabilities)}get uncompressedTextureDownsamplingEnabled(){const e=this.view?.qualitySettings.sceneService.uncompressedTextureDownsamplingEnabled,t=0==(this.supportedTextureEncodings&Se.DDS_S3TC);return e&&t}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){const e=this._nodeId2Meta,t=new _t;for(const i of e.values()){if(null==i)continue;const{node:{serviceMbsInIndexSR:e}}=i,[s,r,o,n]=e;t.expandElevationRangeValues(o-n,o+n)}return t.elevationRangeValid?t:null}get fullExtent(){return this.i3slayer.fullExtent}initialize(){const e=has("enable-feature:idb-mock-cache");this._idbCache=e?new lt(this.view,e):new at("esri-scenelayer-cache","geometries"),this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const t=this.view.resourceController,i=t.memoryController;this.i3sOverrides=new qe({view:this.view,layer:this.i3slayer,memoryController:i}),this._worker=new be(Xt(t)),this.addResolvingPromise(this._worker.promise);const s=this.i3slayer.store;this._worker.setLegacySchema(this.uid,s.defaultGeometrySchema),$e(this.i3slayer),Qe(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new ae({layerView:this,worker:this._worker}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view._stage,this._collection=this._stage.renderView.componentObjectCollection,this.resetHighlights();const r=s.defaultGeometrySchema;if(this._isIntegratedMesh||!r)this._hasComponentData=!1;else{const e=r.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(r?.vertexAttributes.color??null)&&!this.i3slayer.cachedDrawingInfo?.color,this._isIntegratedMesh||(this._edgeView=this._stage.renderer.ensureEdgeView());const o=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,(e=>this._deleteComponentObject(e)));this._memCache=o;const n=this._controller,a=this._nodeId2Meta,l=this._nodeId2MetaReloading,d=e=>{const t=n.index;if(!t)return;const i=t.rootNode;if(!i)return;const s=t=>{const i=t.index,s=a.get(i)||l.get(i);return e(t,s?.objectHandle??null)};t.traverse(i,s)};this._intersectionHandler=new Fe({layerUid:this.layerUid,sublayerUid:this.sublayerUid,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:d}),this._updatingHandles.add((()=>this.layerUid),(e=>this._intersectionHandler.layerUid=e)),this._updatingHandles.add((()=>this.sublayerUid),(e=>this._intersectionHandler.sublayerUid=e)),this._elevationProvider=new dt({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add((()=>this.view.clippingArea),(()=>this._clippingAreaChanged()),m),this._updatingHandles.add((()=>this.fullOpacity),(e=>this._opacityChange(e))),this._updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this._updatingHandles.add((()=>this.elevationOffset),((e,t)=>{this._reloadAll(t),this._controller.invalidateVisibilityObbs()})),this._updatingHandles.add((()=>this.elevationInfo),((e,t)=>this._elevationInfoChanged(e,t)),m),this._updatingHandles.add((()=>!this.suspended&&this.elevationInfo.mode!==ve.Absolute),((e,t)=>{e?this.addHandles(this.view.basemapTerrain.on("elevation-change",(({extent:e})=>this._ensureElevationTask().addExtent(e))),Qt):t&&this.removeHandles(Qt)}),m),this._updatingHandles.add((()=>this._usePBR),(e=>this._updatePBR(e)));const c=()=>{this._reloadAll(),this.clearMemCache()};this._updatingHandles.add((()=>this.rendererTextureUsage),c),this._updatingHandles.add((()=>this.uncompressedTextureDownsamplingEnabled),c),this._updatingHandles.add((()=>this.contentVisible),(e=>this._contentVisibleChanged(e)),m),this._updatingHandles.add((()=>this.i3slayer.labelsVisible),(()=>this._labelingChanged()),m),this._updatingHandles.add((()=>this.i3slayer.labelingInfo),(()=>this._labelingChanged()),m),this._updatingHandles.add((()=>this._modifications),(()=>this._modificationsChanged()),m),this.addHandles([p((()=>ut.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&&ut.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||ut.I3S_TREE_SHOW_TILES||(this._treeDebugger=h(this._treeDebugger))}),m),p((()=>ut.I3S_SHOW_MODIFICATIONS),(()=>this._showModifications()),m)]),this._cacheKeySuffix=Xe(this.i3slayer.spatialReference,this.view.renderSpatialReference),this._idbCache.init().catch((e=>Ct().warn(`Failed to initialize IndexedDB cache: ${e}`)));const{view:u}=this,{viewingMode:_,renderCoordsHelper:g}=u;this._planetRadiusInGlobalMode="local"===_?0:g.referenceEllipsoid.radius}destroy(){this._clearAddTasks(),this._elevationTask=h(this._elevationTask),this.i3sOverrides=h(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.objectsChanged(this.getVisibleObbs()),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._worker;e&&(e.destroyContext(this.uid).then((()=>e.destroy())),this._worker=null),this._removeAllNodeDataFromStage(),this._memCache=h(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=h(this._labeler),this._treeDebugger=h(this._treeDebugger),this._controller=h(this._controller),this._highlights.destroy(),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=h(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null),this._updatingHandles=h(this._updatingHandles)}_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(!(we(this.i3slayer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new pe({view:this.view,layer:this.i3slayer,collection:this._collection,overrides:this.i3sOverrides});this._nodeId2Meta.forEach((t=>null!=t&&this._addMetaToLabeler(e,t))),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then((e=>(--this._asyncModuleLoading,e)),(e=>{throw--this._asyncModuleLoading,e}))}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=Ce().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=ye(this._layerClippingArea,this._modifications,t);xe({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)})),this.notifyChange("elevationRange"),null!=s&&this._nodeId2MetaReloading.forEach((e=>s.push(e.node))),null!=s&&s.length>0&&(this.updateNodeModificationStatus(s),s.forAll((e=>{if(e.imModificationImpact!==ke.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.notifyChange("elevationRange")):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}}))),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(null!=this._modificationGraphics&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!ut.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?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);null!=i?.attributeInfo&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);null!=s&&(await this.i3sOverrides.applyAttributeOverrides(s.featureIds,t,i,this._controller.requiredAttributes),s.attributeInfo=t,this._controller.reschedule((()=>this._attributeValuesChanged(s)),i).catch((e=>{u(e)||Ct().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}getVisibleObbs(){const e=new Array;return this._nodeId2Meta.forEach((t=>{if(null!=t){const i=this.getNodeComponentObb(t.node);null!=i&&e.push(i)}})),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&Se.Basis)&&this.i3slayer.textureSetDefinitions?.some((e=>e.formats.some((e=>"basis"===e.format||"ktx2"===e.format))))&&vt()}_getVertexBufferLayout(e,t){const i={hasTexture:Ut(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion};return ft(bt(this._getGeometryParameters(i)))}_getObjectIdField(){return this.i3slayer.objectIdField||ne}_getGlobalIdField(){return this.i3slayer.associatedLayer?.globalIdField}_findGraphicNodeAndIndex(e){const t=ht(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());let i=null;return d(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 n of t){const e=ht(o,n.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this._getAABB(t.node.index,t.index);return null==i?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this._getAABB(e.nodeIndex,e.componentIndex)}_getAABB(e,t){const i=this._nodeId2Meta.get(e);if(null==i?.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=Ve(t,this._collection,s,Z(24),0),o=this.view.renderSpatialReference,n=this.view.spatialReference;if(!q(r,o,0,r,n,0,8))return null;const a=$();return Q(a,r,0,8),a}whenGraphicAttributes(e,t){return Ye(this.i3slayer,e,this._getObjectIdField(),t,(()=>[...this._nodeId2Meta.values()].filter(s)))}getGraphicFromIntersectorTarget(e){if(null==e.nodeIndex||null==e.componentIndex)return null;const t=this._nodeId2Meta.get(e.nodeIndex);return null==t?.featureIds||e.componentIndex>=t.featureIds.length?null:this._createGraphic(e.componentIndex,t)}_getCacheKey(e){return`${this._layerUrl}/v${jt}/${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=He(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(null==r?.data||s&&r.encoding!==s.encoding)}))??[];return 0===r.length?Promise.resolve(!1):i(r,s).then((i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0}))}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then((s=>null==s?null:s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(this.elevationInfo.mode===ve.Absolute&&(e.geometryObbInRenderSR=mt.fromData(s.geometryObbData)),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then((i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=kt(s.transformedGeometry,s.textureData),s.textureData.every(Lt)&&Bt(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch((t=>Ct().warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`)))),_(t),s)))))):Promise.resolve(null)}addNode(e,t,i){return Gt(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:n,anchorIds:a,anchors:l,transformedGeometry:d}=s,h=this._controller.crsIndex,c=this.view.renderSpatialReference,u=ze(e.serviceMbsInIndexSR,this.elevationOffset,h,c),_=S(Kt,r.center.x,r.center.y,r.center.z);A(_,_,u);const g=new mt(_,[r.extents.x,r.extents.y,r.extents.z],R(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));this.elevationInfo.mode===ve.Absolute&&(e.geometryObbInRenderSR=g),t.geometryData.componentOffsets=o,n&&(t.geometryData.featureIds=Array.from(n)),t.geometryData.anchorIds=a,t.geometryData.anchors=l;const m={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:d,globalTrafo:u,geometryObbData:g.data,byteSize:kt(d,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&Bt(e,m)){const t=null!=m.textureData?m.textureData.map((e=>Lt(e)?e:null)):null;this._idbCache.put(this._getCacheKey(e.id),{...m,textureData:t}).catch((t=>Ct().warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`)))}return this._addCachedNodeData(e,m,i)}),i))))):Promise.reject()}getElevationRange(e){const t=new _t,i=this._controller,{index:s}=i;if(!s)return t;const{rootNode:r}=s;if(!r)return t;const o=this._nodeId2Meta,n=e[3],a=i.viewportQueries,l=this._planetRadiusInGlobalMode,{view:d}=this,{renderCoordsHelper:h}=d,c=h.referenceEllipsoid.radius,u=this._collection,_=i=>{const{childrenLoaded:s}=i;if(0===s)return!1;const r=a.getAndUpdateVisibilityObbInRenderSR(i);let d=null,_=-1;if(r){if(_=r.radius,!r.intersectSphereWithMBS(e,_))return!1}else d=a.getServiceMbsInRenderSR(i),d&&(_=d[3]);if(_>=0&&n>=1*_)return null!=r?Zt(t,r,l):null!=d&&d[3]>=0&&ei(t,d,l),!1;const g=Jt;if(g.elevationRangeMin=1/0,g.elevationRangeMax=-1/0,(null!=r||null!=d)&&(null!=r?Zt(g,r,l):null!=d&&ei(g,d,l),g.elevationRangeMin>=t.elevationRangeMin&&g.elevationRangeMax<=t.elevationRangeMax))return!1;const m=o.get(i.index);if(m){const{geometryObbInRenderSR:s}=i;if(!s||s.intersectSphereWithMBS(e)){if(s){if(n>0*s.radius)return Zt(t,s,l),!1}const{objectHandle:e}=m,i=u.getObjectTransform(e),r=h.getAltitude(i.position);u.expandRangeWithComponentObjectElevationRange(e,r,c,t)}}return s-(m?1:0)>0};return s.traverse(r,_),t}computeVisibilityObb(e){return Je(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications,this.view.renderCoordsHelper.sphericalPCPF)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let f=0;f<s.length;++f)r[f]=this._getVertexBufferLayout(s[f],t.geometryDescriptor);const o=e.serviceMbsInIndexSR,n=this.elevationOffset,a=this._controller.crsIndex,l=this._controller.crsVertex,d=this.view.renderSpatialReference,h=We(o,n,a),c=ze(o,n,a,d),u=z(a,l),_=z(l,d);if(null==u||null==_)return Promise.resolve(null);const g=this.i3slayer.normalReferenceFrame,m=t.normalReferenceFrame??g??"none",p={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,localOrigin:h,globalTrafo:c,mbs:o,obbData:e.serviceObbInIndexSR?.data,elevationOffset:n,needNormals:this._needsNormals&&this._controller.isMeshPyramid,normalReferenceFrame:m,indexToVertexProjector:u,vertexToRenderProjector:_};return this._worker.invoke(p,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===ve.Absolute&&(e.geometryObbInRenderSR=this._collection.getComponentObb(t.objectHandle).clone()),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);null!=this._labeler&&this._addMetaToLabeler(this._labeler,t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,!0),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==ve.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:n}=t;await this.i3sOverrides.applyAttributeOverrides(r.featureIds,s.attributeInfo,i,this._controller.requiredAttributes);const a=null!=t.textureData?t.textureData.filter((e=>null!=e&&0!=(e.usage&this.rendererTextureUsage))):[];!has("disable-feature:i3s-basis")&&a.some((e=>null!=e&&(e.encoding===Se.Basis||e.encoding===Se.KTX2)))&&await vt(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:h,anchorIds:c,anchors:u}=r,_=this._collection,g=d[0],{layout:m,indices:p,interleavedVertexData:f,positionData:b,hasColors:y}=o,{material:v,geometryParameters:I}=this._materialParameters(g,m),R=l||new Uint32Array([0,p?p.length:f.byteLength/m[0].stride]),S={vertices:{data:f,count:f.byteLength/m[0].stride,layoutParameters:I},positionData:{positions:ee(b.data),indices:te(b.indices)},indices:p,componentOffsets:R},A=g.transformation?j(g.transformation):w();O(A,n,A);const N=E(H(),A),V=M(x(),A),F=this.view.renderSpatialReference,P=this.view.basemapTerrain.spatialReference,U=mt.fromData(t.geometryObbData).center,L=[1,1,1];k(U,F,L,P)||Ct().errorOnce("Unsupported coordinate system for IM overlay");const B=H();W(U,F,B,P);const q=x();C(q,V);const z=H();D(z,T(z,U,N),q);const K=B[0]-z[0]*L[0],$=B[1]-z[1]*L[1],Q=_.createObject({toMapSpace:G(K,$,L[0],L[1]),geometry:S,obb:mt.fromData(t.geometryObbData),transform:{position:N,rotationScale:V}}),X=I.textureCoordinates===yt.Atlas,{textures:Y,texturePromise:J}=this._initMaterialAndTextures(Q,v,a,X);e.memory+=this._memEstimateGeometryAdded(Q),e.memory+=Y.reduce(((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0)),0);const Z=!!v.hasParametersFromSource,ie="blend"!==v.alphaMode&&v.metallicRoughness.baseColorFactor[3]>=1,se=new Ot(e,h,Q,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:Z,isOpaque:ie},Y,c,u);s.meta=se,!this._hasTextures&&t.requiredTextures?.some((({usage:e})=>0!=(e&Re.ColorTextures)))&&(this._hasTextures=!0),this._hasData=!0,this._hasColors=this._hasColors||y,this._hasTextures=this._hasTextures||!!e.resources.texture,this.notifyChange("hasTexturesOrVertexColors");const re=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(se),J]).then((([t,s])=>(null!=t&&t.updateObjectVisibility(se.objectHandle,!1).catch((e=>St(e,this.i3slayer.title))),this._safeReschedule((()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,se),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(Q,!0),null!=t&&t.updateObjectVisibility(se.objectHandle,!0).catch((e=>St(e,this.i3slayer.title))),se.attributeInfo=i.attributeInfo;const s=se.cachedRendererVersion!==this._rendererVersion,r=re!==this.slicePlaneEnabled;this._updateElevationOffsets(se);const o=se.elevationOffsets;this._updateComponentData(se);const n=this._applyFiltersToNode(se);(s||null!=t&&(r||n||o))&&this._addOrUpdateEdgeRendering(se),null!=this._labeler&&this._addMetaToLabeler(this._labeler,se),this._visibleGeometryChanged(se,At.ADD),this._highlights.objectCreated(se),this._updateMaterial(se),this._setNewNodeOpacity(se),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)){Ct().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&&zt(t.cachedEdgeMaterials,0)),this._nodeId2Meta.set(e,t),this.notifyChange("elevationRange")}_updateElevationOffsets(e){const t=this.view.renderSpatialReference,i=this._controller.crsIndex,s=this.elevationInfo,r=this.view.basemapTerrain,o=r.spatialReference,n=s.mode;if(null==t||null==o||n===ve.Absolute)return void(e.elevationOffsets=null);const a=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const l=Kt,d=$t,h=n===ve.OnTheGround,c=this.view.renderCoordsHelper,u=e.featureIds.length,_=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const s=Z(3*u);e.cachedElevationAnchors=s;for(let r=0;r<u;r++){const n=3*r,h=e.anchorIds?.indexOf(r)??-1;e.anchors&&h>=0?(S(l,e.anchors[3*h],e.anchors[3*h+1],e.anchors[3*h+2]),N(l,l,ie(e.node.serviceMbsInIndexSR)),W(l,i,l,o),s[n]=l[0],s[n+1]=l[1],s[n+2]=c.getAltitude(l)):(this._collection.getComponentAabb(e.objectHandle,r,d,!0),S(l,(d[0]+d[3])/2,(d[1]+d[4])/2,d[2]),D(l,l,a.rotationScale),N(l,l,a.position),s[n+2]=c.getAltitude(l),W(l,t,l,o),s[n]=l[0],s[n+1]=l[1])}return s})(),g=s.offset,m=e.elevationOffsets,p=(e,t)=>{const i=h?_[3*e+2]:0;m[e]=g+(null!=t?t-i:0)};r.getElevations(_,u,p)}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new De(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.elevationInfo?.mode))),this._elevationTask}_elevationInfoChanged(e,t){const i=e.mode!==ve.Absolute,s=!!t&&t!==e&&t.mode!==ve.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,At.UPDATE))}_safeReschedule(e,t){return _(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:Ue(),s=t.some((e=>"uvRegion"===e.name)),r=t.some((e=>"normalCompressed"===e.name)),o=Ut(i);return{geometryParameters:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s){const r=this._stage.renderView,o=i.map((e=>Ge(e,t,s,r)));this._stage.addMany(o);let n=null;return this._collection.updateMaterial(e,(e=>{n=Le(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:n}}_getGeometryParameters(e){return{textureCoordinates:e.hasTexture?e.hasRegions?yt.Atlas:yt.Default:yt.None,colors:this._hasVertexColors,hasNormals:e.hasNormals&&this._needsNormals,needsNormals:this._needsNormals}}_addData(e,t,i){let s=this._addTasks.get(e.index);return s?s.attributeInfo=t:(s={...g(),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=Y();this._renderClippingArea=gt(this.view.clippingArea,i,e)?i:null;const s=Y();this._layerClippingArea=gt(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,At.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={},n=this._createLayerGraphic(o),a=this.i3slayer.objectIdField,l=t.featureIds,d=t.attributeInfo?.attributeData;s.every((e=>e===a||null!=d?.[e]))&&Ze(e,l,(e=>{o[a]=l[e];for(const i of s)i!==a&&(o[i]=d?et(d[i],e):null);try{return i.testFeature(n)}catch(t){return r(t),!1}}))}_boundingRectNodeTest(e,t){return B(e.node.serviceMbsInIndexSR,this._controller.crsIndex,Ht,this.view.renderSpatialReference),tt(t,Ht)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,Dt),X(Dt,Tt),J(i,Tt)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(r===it.INSIDE)return;if(r===it.OUTSIDE)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const n=this._transformClippingArea(Nt,i,t.objectHandle);Ze(e,t.featureIds,(e=>this._boundingRectFeatureTest(t,e,n)))}_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:n}=this._getFilteredEdgeMaterials(e),a={hasSlicePlane:this.slicePlaneEnabled};if(o&&r){if(this.nodeCrossfadingEnabled){zt(n,this.getNodeOpacity(e))}return i.updateAllComponentMaterials(s,n,a,t).catch((e=>St(e,this.i3slayer.title))),i.updateObjectVisibility(s,!0).catch((e=>St(e,this.i3slayer.title))),i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>St(e,this.i3slayer.title))),Promise.resolve(i)}return o&&!r?this._collection.addEdges(s,i,n,a).then((t=>(e.edgeMemoryUsage=t,e.node.memory+=t,i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>St(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=t.getComponentCount(e.objectHandle),s=null!=e.filteredIds,r=0===i.invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!r;if(this._updateCachedFilteredIds(e),s&&e.filteredIds===e.featureIds)return!r;const o=this._computeFilteredComponentIndices(e);return t.setAllComponentVisibilities(e.objectHandle,o),!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=h(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),null!=this._elevationTask&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);null!=s?(this._collection.setObjectVisibility(s.objectHandle,!1),null!=this._edgeView&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch((e=>St(e,this.i3slayer.title))),this._visibleGeometryChanged(s,At.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===Be.Hole))}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){const i=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,i),this.notifyChange("elevationRange")}const i=this._nodeId2MetaReloading.get(e);i&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,i))}_invalidateAllSymbols(){this._rendererVersion=st(this._rendererVersion,1),this._controller&&this._controller.requestUpdate()}_getInvalidRendererVersion(){return st(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=st(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 ue()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:Ct().warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.getSymbols())"mesh-3d"!==t.type&&Ct().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(U(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],r=_e(this.view.map,this.layerUid);this._stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(t,t,this.layerId,this.layerUid+"_"+this.sublayerId,this.layerPopupEnabledAndHasTemplate&&!r,e.node.resources.attributes,i,this.sublayerId),s.objectAndLayerIdColor=this._stage.renderView.getObjectAndLayerIdColor({graphicUid:t,layerUid:this.layerUid+"_"+this.sublayerId})}s.externalColorMixMode=t[r+4]&(1<<Et.CastShadows)-1,s.castShadows=0!=(t[r+4]&1<<Et.CastShadows),s.pickable=0!=(t[r+4]&1<<Et.Pickable),s.elevationOffset=e.elevationOffsets?.[i]??0}}_getSymbolInfo(e,t){const i=e?.getSymbol(t,{arcade:this._arcade});if(!(i instanceof ge))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=rt(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?le(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,n=null!=r&&null!=this._symbologyFields&&this._symbologyFields.length>0;let a=null,l=null;if(n&&null!=this._symbologyFields){a=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(a.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=oe(5*e.featureIds.length));const d={color:Ft,castShadows:!0,pickable:!0,colorMixMode:ct.Multiply,edgeMaterial:null},h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=It.OPAQUE,g=ot,m=0;for(let p=0;p<e.featureIds.length;p++){if(null!=o&&(i[o]=e.featureIds[p]),n&&a)for(let e=0;e<a.length;e++)i[a[e]]=et(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=he(this._colorVariable,t,{color:Pt,arcade:this._arcade});e&&(h=Ft,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=ce(this._opacityVariable,t,{arcade:this._arcade}))}if(r?.material){const e=r.material;h=null==h||null==f?je(h,f,e.color,e.alpha,xt,Ft):je(h,f,null,null,xt,Ft)}if(null==h&&(h=Ft,h[0]=1,h[1]=1,h[2]=1,h[3]=1),d.pickable=!0,d.castShadows=!r||r.castShadows,d.colorMixMode=r?.material?r.material.colorMixMode:ct.Multiply,d.edgeMaterial=r?r.edgeMaterial:null,null!=this._symbologyOverride&&(d.color=h,this._symbologyOverride(t,d),h=d.color),null!=this._nodeColorOverride&&(this._nodeColorOverride(e.node,h),d.colorMixMode=ct.Replace),null!=d.edgeMaterial){const t=h[3]<=0?It.INVISIBLE:h[3]>=1&&(e.material.isOpaque||d.colorMixMode===ct.Replace)?It.OPAQUE:It.TRANSPARENT;d.edgeMaterial===u&&t===_||(g={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,_=t),e.cachedEdgeMaterials[p]=g}else e.cachedEdgeMaterials[p]=ot;e.cachedSymbology[m++]=Math.round(255*h[0]),e.cachedSymbology[m++]=Math.round(255*h[1]),e.cachedSymbology[m++]=Math.round(255*h[2]),e.cachedSymbology[m++]=Math.round(255*h[3]),e.cachedSymbology[m++]=d.colorMixMode|+d.castShadows<<Et.CastShadows|+d.pickable<<Et.Pickable}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||zt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some((e=>e!==ot)),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map(((t,o)=>e.featureIds[o]!==i[s]?ot:(r=r||t!==ot,s++,t)));return{hasEdges:r,perFeatureEdgeMaterials:o}}_updateComponentData(e){if(!this._hasComponentData)return;const t=e.objectHandle,i=this._getComponentParameters(e);this._collection.setComponentData(t,i),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),null!=this._controller&&this._controller.restartNodeLoading()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach((t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,(t=>t.objectOpacity=e)),zt(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))}))}_updateMaterial(e){this._collection.updateMaterial(e.objectHandle,(e=>{e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.usePBR=this._usePBR,this._updateMaterialOverlay(e)}))}_updateMaterialOverlay(e){}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,At.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._needsNormals&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){null!=this._edgeView&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?(t,i,s)=>s.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?Ie.CONTINUE:e(t,i,s):e}_forAllFeatures(e,t,i){d(this._nodeId2Meta,(s=>{if(null==s)return!1;if(null!=t){switch(t(s)){case Ie.EXIT:return!0;case Ie.SKIP:return!1}}let r=Ie.CONTINUE;switch(i){case Me.ALL:r=this._forAllFeaturesOfNode(s,e);break;case Me.VISIBLE_ONLY:r=this._forAllVisibleFeaturesOfNode(s,e);break;case Me.QUERYABLE:r=this._forAllQueryableFeaturesOfNode(s,e)}return r===Ie.EXIT}))}_forAllFeaturesOfNode(e,t){let i=Ie.CONTINUE;const s=e.featureIds;for(let r=0;r<s.length;r++)if(i=t(s[r],r,e),i===Ie.EXIT)return i;return i}_forAllVisibleFeaturesOfNode(e,t){let i=Ie.CONTINUE;const s=e.featureIds;return this._collection.forEachVisibleComponent(e.objectHandle,(r=>(i=t(s[r],r,e),i===Ie.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===it.OUTSIDE)return Ie.CONTINUE;if(s===it.INSIDE)return this._forAllFeaturesOfNode(e,i);const r=Ie.CONTINUE,o=e.featureIds,n=e.objectHandle,a=nt(this._renderClippingArea,this._collection.getObjectTransform(n));for(let l=0;l<o.length;l++){if(!this._boundingRectFeatureTest(e,l,a))continue;const t=i(o[l],l,e);if(t===Ie.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]=et(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e){if("number"==typeof e||e instanceof i?e=[e]:e instanceof n&&(e=e.toArray()),Array.isArray(e)&&e.length>0){if(e[0]instanceof i){const t=e,i=this.i3slayer.fieldsIndex,s=this._getObjectIdField(),r=t.map((e=>ht(i,e.attributes,s))),{set:o,handle:n}=this._highlights.acquireSet();return this._highlights.setFeatureIds(o,r),n}if("number"==typeof e[0]){const t=e,{set:i,handle:s}=this._highlights.acquireSet();return this._highlights.setFeatureIds(i,t),s}}return a()}resetHighlights(){h(this._highlights),this._highlights=new Ae({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,Me.ALL),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)})}_visibleGeometryChanged(e,t){if(!this._elevationProvider)return;const i=this.getNodeComponentObb(e.node);i&&this._elevationProvider.objectChanged(i),null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=f((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))),this._updateSnappingSources(e,t)}get performanceInfo(){return new fe(this.usedMemory,this._nodeId2Meta.size,Math.round(this._gpuMemoryEstimate/1048576),Math.round(this._geoMemoryEstimate/1048576),Math.round(this._texMemoryEstimate/1048576),Math.round(this.unloadedMemory/1048576),this._idbCacheEnabled?Math.round(100*this._idbCache.getHitRate()):0)}get test(){const e=this,t=e=>{this._nodeColorOverride=e,this._invalidateAllSymbols()};return{controller:this._controller,labeler:this._labeler,get visibleObjectIds(){const t=[];return e._forAllFeatures((e=>(t.push(e),Ie.CONTINUE)),null,Me.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))},setNodeColorOverride:t,setNodeColoring:e=>{if("client-nodes"===e)t(((e,t)=>{e.index<0?(t[0]=1,t[1]=0,t[2]=0):(t[0]=1,t[1]=1,t[2]=1)}));else t(null)}}}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return null!=e?this._collection.getMaterial(e.objectHandle).objectOpacity:0}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(e)}fadeNode(e,t,i){if(!this.nodeCrossfadingEnabled)return;const s=this._nodeId2Meta.get(e);null!=s&&this._crossfadeHelper.fadeNode(e,s,t,i)}setNodeOpacityByIndex(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._setNodeOpacity(i,t)}_setNodeOpacity(e,t){this._collection.updateMaterial(e.objectHandle,(e=>e.objectOpacity=t)),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(null==this._edgeView||!e.cachedEdgeMaterials)return;zt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch((e=>St(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=qt(e);if(s){const t={context:i,buffer:s.buffer};Oe(t);const r=new Float64Array(s.buffer);e.forAll(((e,t)=>{const i=r[t],s=Ee(i);e.imModificationImpact=s,s!==ke.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);s&&e.add(i,s)})),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||this.elevationInfo.mode===ve.Absolute)return;const s=t.position0,r=t.position1,o=t.componentIndex,n=H(),a=H(),l=(e,t)=>{N(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,a),N(e,e,V(a,a,t)),F(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,n),l(n,t),s.setVec(d,n),r.getVec(d,n),l(n,t),r.setVec(d,n)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(null!=s)for(const r of this._snappingSourcesTrackers)t!==At.REMOVE&&t!==At.UPDATE||r.events.remove(i),t!==At.ADD&&t!==At.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(pt)],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:[de]})],o.prototype,"_modifications",void 0),e([v({readOnly:!0})],o.prototype,"clientGeometry",null),e([v()],o.prototype,"elevationRange",null),e([v()],o.prototype,"fullExtent",null),e([v()],o.prototype,"_elevationTask",void 0),e([v({readOnly:!0})],o.prototype,"_usePBR",null),o=e([I(Mt)],o),o};function St(e,t){u(e)||Ct().warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}var At;!function(e){e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE"}(At||(At={}));const Dt=K(),Tt=Y(),Nt=Y(),Vt=new mt,Ft=[0,0,0,0],Pt=new t([0,0,0,0]),Ht=se(0,0,0,0);function Ut(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 Gt(e){return"geometryData"in e}function Lt(e){return null!=e&&b(e.data)}function kt(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 Bt(e,t){return t.byteSize>wt?(Ct().warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}function qt(e){if(0===e.length)return;const t=10*e.length,i=new Float64Array(t);let s=0;return e.forAll((e=>{let t=e.serviceObbInIndexSR;null==t&&(t=Vt,t.center=ie(e.serviceMbsInIndexSR),t.halfSize=[e.serviceMbsInIndexSR[3],e.serviceMbsInIndexSR[3],e.serviceMbsInIndexSR[3]]);const r=t.data;i[s++]=r[0],i[s++]=r[1],i[s++]=r[2],i[s++]=r[3],i[s++]=r[4],i[s++]=r[5],i[s++]=r[6],i[s++]=r[7],i[s++]=r[8],i[s++]=r[9]})),i}function zt(e,t){e.forEach((e=>e.opacity=t))}class Wt{constructor(e,t){this.mode=e,this.offset=t}}const Kt=H(),$t=K(),Qt="elevation-change";function Xt(e){return t=>{if(e.immediate)return e.immediate.schedule(t);throw console.error("Error no immediate schudler"),new Error("cant find immediate scheduler")}}const Yt=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],Jt=new _t;function Zt(e,t,i){let s=e.elevationRangeMin,r=e.elevationRangeMax;const o=i;if(o>0){t.getCorners(Yt);for(const e of Yt){const t=P(e)-o;s=Math.min(s,t),r=Math.max(r,t)}}else{t.getCorners(Yt);for(const e of Yt){const t=e[2];s=Math.min(s,t),r=Math.max(r,t)}}e.expandElevationRangeValues(s,r)}function ei(e,t,i){const s=ie(t),r=i>0?P(s)-i:s[2],o=re(t);e.expandElevationRangeValues(r-o,r+o)}export{Rt as I3SMeshView3D,Xt as makeScheduleFunction};
|
|
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 n from"../../../core/Collection.js";import{makeHandle as a}from"../../../core/handleUtils.js";import has from"../../../core/has.js";import l from"../../../core/Logger.js";import{someMap as d}from"../../../core/MapUtils.js";import{destroyMaybe as h}from"../../../core/maybe.js";import c from"../../../core/PooledArray.js";import{isAbortError as u,throwIfAborted as _,createResolver as g}from"../../../core/promiseUtils.js";import{initial as m,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{subclass as I}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as M,invert as C}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as x}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as O,getTranslation as E}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as j,create as R}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as w}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{s as S,e as A,t as D,z as T,g as N,h as V,f as F,H as P}from"../../../chunks/vec32.js";import{create as H}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as U}from"../../../chunks/vec42.js";import{fromValues as G}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as L}from"../../../core/support/UpdatingHandles.js";import{localLinearScaleFactors as k}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as B}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as q}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as z}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as W}from"../../../geometry/projection/projectVectorToVector.js";import{create as K,empty as $,expandWithBuffer as Q,toRect as X}from"../../../geometry/support/aaBoundingBox.js";import{create as Y,intersects as J}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as Z}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as ee}from"../../../geometry/support/FloatArray.js";import{compactIndices as te}from"../../../geometry/support/Indices.js";import{g as ie,f as se,b as re}from"../../../chunks/sphere.js";import{newUByteArray as oe}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as ne}from"../../../layers/LayerConstants.js";import ae from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as le}from"../../../layers/support/fieldUtils.js";import de from"../../../layers/support/SceneModification.js";import{getColor as he,getOpacity as ce}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{loadArcade as ue}from"../../../support/arcadeOnDemand.js";import{isBasemapLayer as _e}from"../../../support/basemapUtils.js";import ge from"../../../symbols/Symbol3D.js";import{getMetersPerUnit as me}from"../../../symbols/support/unitConversionUtils.js";import pe from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as fe}from"./I3SMeshViewPerformanceInfo.js";import{I3SMeshWorkerHandle as be,toWasmModification as ye}from"./I3SMeshWorkerHandle.js";import{ElevationMode as ve,ForAllFeaturesReturnType as Ie,ForAllFeaturesMode as Me}from"./II3SMeshView3D.js";import{initialize as Ce,setModificationsSync as xe,filterObbsForModificationsSync as Oe,interpretObbModificationResults as Ee}from"./SceneLayerWorker.js";import{overrideColor as je}from"./graphics/graphicUtils.js";import{areLabelsVisible as Re}from"./graphics/Labeler.js";import{TextureUsage as we,TextureEncoding as Se}from"./i3s/enums.js";import Ae from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as De}from"./i3s/I3SAsyncElevationUpdater.js";import{I3SCrossfadeHelper as Te,NodeCrossfadeMetaData as Ne}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as Ve}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Fe}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Pe,selectEncoding as He,defaultMaterial as Ue,createTexture as Ge,configureMaterial as Le}from"./i3s/I3SMaterialUtil.js";import{NodeIMModificationImpact as ke,NodeState as Be}from"./i3s/I3SNode.js";import{I3SOverrides as qe}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as ze,getLocalOrigin as We}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as Ke,checkSceneLayerValid as $e,checkSceneLayerCompatibleWithView as Qe,getCacheKeySuffix as Xe,whenGraphicAttributes as Ye,computeVisibilityObb as Je,filterInPlace as Ze,getCachedAttributeValue as et,intersectBoundingRectWithMbs as tt,MbsIntersectResult as it,addWraparound as st,getSymbolInfo as rt,transparentEdgeMaterial as ot,getClipRect as nt}from"./i3s/I3SUtil.js";import{IDBCache as at}from"./i3s/IDBCache.js";import{IDBMockCache as lt}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as dt}from"./i3s/LayerElevationProvider.js";import{attributeLookup as ht}from"./support/attributeUtils.js";import{makeScheduleFunction as ct}from"./support/makeScheduleFunction.js";import{ColorMixModeEnum as ut}from"./support/symbolColorUtils.js";import{debugFlags as _t}from"../support/debugFlags.js";import{ElevationRange as gt}from"../support/ElevationRange.js";import{toBoundingRect as mt}from"../support/extentUtils.js";import{Obb as pt}from"../support/orientedBoundingBox.js";import{updatingProgress as ft}from"../support/updatingProperties.js";import{glLayout as bt}from"../support/buffer/glUtil.js";import{createVertexBufferLayout as yt}from"../webgl-engine/collections/Component/SourceGeometry.js";import{TextureCoordinateAttributeType as vt}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{loadBasis as It}from"../webgl-engine/lib/BasisUtil.js";import{Transparency as Mt}from"../webgl-engine/lib/edgeRendering/interfaces.js";const Ct="esri.views.3d.layers.I3SMeshView3D",xt=()=>l.getLogger(Ct),Ot=[1,1,1,1];class Et extends Ne{constructor(e,t,i,s,r,o,n,a,l){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=n,this.anchorIds=a,this.anchors=l,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0}}var jt;!function(e){e[e.CastShadows=4]="CastShadows",e[e.Pickable=5]="Pickable"}(jt||(jt={}));const Rt=23,wt=100*o.MEGABYTES,St=t=>{let o=class extends t{constructor(...e){super(e),this._needsNormals=!0,this._updatingHandles=new L,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._hasComponentData=!1,this._hasVertexColors=!1,this._nodeColorOverride=null,this.updating=!0,this.holeFilling="auto",this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=new Array,this.ignoresMemoryFactor=!1,this._layerUrl="",this._cacheKeySuffix=null,this._planetRadiusInGlobalMode=0,this._elevationTask=null,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i(null,null,{}),this._crossfadeHelper=new Te(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 Ke(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?we.AllTexturesPBR:we.AllTextures:this._usePBR||this._hasLoadedPBRTextures?we.GeometryTexturesPBR:we.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=me(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 new Kt(ve.Absolute,0);const t=y(this.i3slayer.spatialReference),i=me(e.unit),s=(e.offset??0)*i/t;switch(e.mode){case"absolute-height":return new Kt(ve.Absolute,s);case"relative-to-ground":return new Kt(ve.RelativeToGround,s);case"on-the-ground":return new Kt(ve.OnTheGround,0);default:return new Kt(ve.Absolute,0)}}get supportedTextureEncodings(){return Pe(this.view._stage.renderView.capabilities)}get uncompressedTextureDownsamplingEnabled(){const e=this.view?.qualitySettings.sceneService.uncompressedTextureDownsamplingEnabled,t=0==(this.supportedTextureEncodings&Se.DDS_S3TC);return e&&t}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){const e=this._nodeId2Meta,t=new gt;for(const i of e.values()){if(null==i)continue;const{node:{serviceMbsInIndexSR:e}}=i,[s,r,o,n]=e;t.expandElevationRangeValues(o-n,o+n)}return t.elevationRangeValid?t:null}get fullExtent(){return this.i3slayer.fullExtent}initialize(){const e=has("enable-feature:idb-mock-cache");this._idbCache=e?new lt(this.view,e):new at("esri-scenelayer-cache","geometries"),this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const t=this.view.resourceController,i=t.memoryController;this.i3sOverrides=new qe({view:this.view,layer:this.i3slayer,memoryController:i}),this._worker=new be(ct(t)),this.addResolvingPromise(this._worker.promise);const s=this.i3slayer.store;this._worker.setLegacySchema(this.uid,s.defaultGeometrySchema),$e(this.i3slayer),Qe(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new ae({layerView:this,worker:this._worker}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view._stage,this._collection=this._stage.renderView.componentObjectCollection,this.resetHighlights();const r=s.defaultGeometrySchema;if(this._isIntegratedMesh||!r)this._hasComponentData=!1;else{const e=r.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(r?.vertexAttributes.color??null)&&!this.i3slayer.cachedDrawingInfo?.color,this._isIntegratedMesh||(this._edgeView=this._stage.renderer.ensureEdgeView());const o=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,(e=>this._deleteComponentObject(e)));this._memCache=o;const n=this._controller,a=this._nodeId2Meta,l=this._nodeId2MetaReloading,d=e=>{const t=n.index;if(!t)return;const i=t.rootNode;if(!i)return;const s=t=>{const i=t.index,s=a.get(i)||l.get(i);return e(t,s?.objectHandle??null)};t.traverse(i,s)};this._intersectionHandler=new Fe({layerUid:this.layerUid,sublayerUid:this.sublayerUid,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:d}),this._updatingHandles.add((()=>this.layerUid),(e=>this._intersectionHandler.layerUid=e)),this._updatingHandles.add((()=>this.sublayerUid),(e=>this._intersectionHandler.sublayerUid=e)),this._elevationProvider=new dt({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add((()=>this.view.clippingArea),(()=>this._clippingAreaChanged()),m),this._updatingHandles.add((()=>this.fullOpacity),(e=>this._opacityChange(e))),this._updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this._updatingHandles.add((()=>this.elevationOffset),((e,t)=>{this._reloadAll(t),this._controller.invalidateVisibilityObbs()})),this._updatingHandles.add((()=>this.elevationInfo),((e,t)=>this._elevationInfoChanged(e,t)),m),this._updatingHandles.add((()=>!this.suspended&&this.elevationInfo.mode!==ve.Absolute),((e,t)=>{e?this.addHandles(this.view.basemapTerrain.on("elevation-change",(({extent:e})=>this._ensureElevationTask().addExtent(e))),Xt):t&&this.removeHandles(Xt)}),m),this._updatingHandles.add((()=>this._usePBR),(e=>this._updatePBR(e)));const c=()=>{this._reloadAll(),this.clearMemCache()};this._updatingHandles.add((()=>this.rendererTextureUsage),c),this._updatingHandles.add((()=>this.uncompressedTextureDownsamplingEnabled),c),this._updatingHandles.add((()=>this.contentVisible),(e=>this._contentVisibleChanged(e)),m),this._updatingHandles.add((()=>this.i3slayer.labelsVisible),(()=>this._labelingChanged()),m),this._updatingHandles.add((()=>this.i3slayer.labelingInfo),(()=>this._labelingChanged()),m),this._updatingHandles.add((()=>this._modifications),(()=>this._modificationsChanged()),m),this.addHandles([p((()=>_t.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&&_t.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||_t.I3S_TREE_SHOW_TILES||(this._treeDebugger=h(this._treeDebugger))}),m),p((()=>_t.I3S_SHOW_MODIFICATIONS),(()=>this._showModifications()),m)]),this._cacheKeySuffix=Xe(this.i3slayer.spatialReference,this.view.renderSpatialReference),this._idbCache.init().catch((e=>xt().warn(`Failed to initialize IndexedDB cache: ${e}`)));const{view:u}=this,{viewingMode:_,renderCoordsHelper:g}=u;this._planetRadiusInGlobalMode="local"===_?0:g.referenceEllipsoid.radius}destroy(){this._clearAddTasks(),this._elevationTask=h(this._elevationTask),this.i3sOverrides=h(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.objectsChanged(this.getVisibleObbs()),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._worker;e&&(e.destroyContext(this.uid).then((()=>e.destroy())),this._worker=null),this._removeAllNodeDataFromStage(),this._memCache=h(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=h(this._labeler),this._treeDebugger=h(this._treeDebugger),this._controller=h(this._controller),this._highlights.destroy(),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=h(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null),this._updatingHandles=h(this._updatingHandles)}_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(!(Re(this.i3slayer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new pe({view:this.view,layer:this.i3slayer,collection:this._collection,overrides:this.i3sOverrides});this._nodeId2Meta.forEach((t=>null!=t&&this._addMetaToLabeler(e,t))),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then((e=>(--this._asyncModuleLoading,e)),(e=>{throw--this._asyncModuleLoading,e}))}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=Ce().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=ye(this._layerClippingArea,this._modifications,t);xe({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)})),this.notifyChange("elevationRange"),null!=s&&this._nodeId2MetaReloading.forEach((e=>s.push(e.node))),null!=s&&s.length>0&&(this.updateNodeModificationStatus(s),s.forAll((e=>{if(e.imModificationImpact!==ke.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.notifyChange("elevationRange")):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}}))),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(null!=this._modificationGraphics&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!_t.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?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);null!=i?.attributeInfo&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);null!=s&&(await this.i3sOverrides.applyAttributeOverrides(s.featureIds,t,i,this._controller.requiredAttributes),s.attributeInfo=t,this._controller.reschedule((()=>this._attributeValuesChanged(s)),i).catch((e=>{u(e)||xt().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}getVisibleObbs(){const e=new Array;return this._nodeId2Meta.forEach((t=>{if(null!=t){const i=this.getNodeComponentObb(t.node);null!=i&&e.push(i)}})),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&Se.Basis)&&this.i3slayer.textureSetDefinitions?.some((e=>e.formats.some((e=>"basis"===e.format||"ktx2"===e.format))))&&It()}_getVertexBufferLayout(e,t){const i={hasTexture:Gt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion};return bt(yt(this._getGeometryParameters(i)))}_getObjectIdField(){return this.i3slayer.objectIdField||ne}_getGlobalIdField(){return this.i3slayer.associatedLayer?.globalIdField}_findGraphicNodeAndIndex(e){const t=ht(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());let i=null;return d(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 n of t){const e=ht(o,n.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this._getAABB(t.node.index,t.index);return null==i?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this._getAABB(e.nodeIndex,e.componentIndex)}_getAABB(e,t){const i=this._nodeId2Meta.get(e);if(null==i?.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=Ve(t,this._collection,s,Z(24),0),o=this.view.renderSpatialReference,n=this.view.spatialReference;if(!q(r,o,0,r,n,0,8))return null;const a=$();return Q(a,r,0,8),a}whenGraphicAttributes(e,t){return Ye(this.i3slayer,e,this._getObjectIdField(),t,(()=>[...this._nodeId2Meta.values()].filter(s)))}getGraphicFromIntersectorTarget(e){if(null==e.nodeIndex||null==e.componentIndex)return null;const t=this._nodeId2Meta.get(e.nodeIndex);return null==t?.featureIds||e.componentIndex>=t.featureIds.length?null:this._createGraphic(e.componentIndex,t)}_getCacheKey(e){return`${this._layerUrl}/v${Rt}/${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=He(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(null==r?.data||s&&r.encoding!==s.encoding)}))??[];return 0===r.length?Promise.resolve(!1):i(r,s).then((i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0}))}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then((s=>null==s?null:s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(this.elevationInfo.mode===ve.Absolute&&(e.geometryObbInRenderSR=pt.fromData(s.geometryObbData)),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then((i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=Bt(s.transformedGeometry,s.textureData),s.textureData.every(kt)&&qt(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch((t=>xt().warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`)))),_(t),s)))))):Promise.resolve(null)}addNode(e,t,i){return Lt(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:n,anchorIds:a,anchors:l,transformedGeometry:d}=s,h=this._controller.crsIndex,c=this.view.renderSpatialReference,u=ze(e.serviceMbsInIndexSR,this.elevationOffset,h,c),_=S($t,r.center.x,r.center.y,r.center.z);A(_,_,u);const g=new pt(_,[r.extents.x,r.extents.y,r.extents.z],w(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));this.elevationInfo.mode===ve.Absolute&&(e.geometryObbInRenderSR=g),t.geometryData.componentOffsets=o,n&&(t.geometryData.featureIds=Array.from(n)),t.geometryData.anchorIds=a,t.geometryData.anchors=l;const m={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:d,globalTrafo:u,geometryObbData:g.data,byteSize:Bt(d,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&qt(e,m)){const t=null!=m.textureData?m.textureData.map((e=>kt(e)?e:null)):null;this._idbCache.put(this._getCacheKey(e.id),{...m,textureData:t}).catch((t=>xt().warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`)))}return this._addCachedNodeData(e,m,i)}),i))))):Promise.reject()}getElevationRange(e){const t=new gt,i=this._controller,{index:s}=i;if(!s)return t;const{rootNode:r}=s;if(!r)return t;const o=this._nodeId2Meta,n=e[3],a=i.viewportQueries,l=this._planetRadiusInGlobalMode,{view:d}=this,{renderCoordsHelper:h}=d,c=h.referenceEllipsoid.radius,u=this._collection,_=i=>{const{childrenLoaded:s}=i;if(0===s)return!1;const r=a.getAndUpdateVisibilityObbInRenderSR(i);let d=null,_=-1;if(r){if(_=r.radius,!r.intersectSphereWithMBS(e,_))return!1}else d=a.getServiceMbsInRenderSR(i),d&&(_=d[3]);if(_>=0&&n>=1*_)return null!=r?Zt(t,r,l):null!=d&&d[3]>=0&&ei(t,d,l),!1;const g=Jt;if(g.elevationRangeMin=1/0,g.elevationRangeMax=-1/0,(null!=r||null!=d)&&(null!=r?Zt(g,r,l):null!=d&&ei(g,d,l),g.elevationRangeMin>=t.elevationRangeMin&&g.elevationRangeMax<=t.elevationRangeMax))return!1;const m=o.get(i.index);if(m){const{geometryObbInRenderSR:s}=i;if(!s||s.intersectSphereWithMBS(e)){if(s){if(n>0*s.radius)return Zt(t,s,l),!1}const{objectHandle:e}=m,i=u.getObjectTransform(e),r=h.getAltitude(i.position);u.expandRangeWithComponentObjectElevationRange(e,r,c,t)}}return s-(m?1:0)>0};return s.traverse(r,_),t}computeVisibilityObb(e){return Je(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications,this.view.renderCoordsHelper.sphericalPCPF)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let f=0;f<s.length;++f)r[f]=this._getVertexBufferLayout(s[f],t.geometryDescriptor);const o=e.serviceMbsInIndexSR,n=this.elevationOffset,a=this._controller.crsIndex,l=this._controller.crsVertex,d=this.view.renderSpatialReference,h=We(o,n,a),c=ze(o,n,a,d),u=z(a,l),_=z(l,d);if(null==u||null==_)return Promise.resolve(null);const g=this.i3slayer.normalReferenceFrame,m=t.normalReferenceFrame??g??"none",p={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,localOrigin:h,globalTrafo:c,mbs:o,obbData:e.serviceObbInIndexSR?.data,elevationOffset:n,needNormals:this._needsNormals&&this._controller.isMeshPyramid,normalReferenceFrame:m,indexToVertexProjector:u,vertexToRenderProjector:_};return this._worker.invoke(p,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===ve.Absolute&&(e.geometryObbInRenderSR=this._collection.getComponentObb(t.objectHandle).clone()),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);null!=this._labeler&&this._addMetaToLabeler(this._labeler,t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,!0),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==ve.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:n}=t;await this.i3sOverrides.applyAttributeOverrides(r.featureIds,s.attributeInfo,i,this._controller.requiredAttributes);const a=null!=t.textureData?t.textureData.filter((e=>null!=e&&0!=(e.usage&this.rendererTextureUsage))):[];!has("disable-feature:i3s-basis")&&a.some((e=>null!=e&&(e.encoding===Se.Basis||e.encoding===Se.KTX2)))&&await It(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:h,anchorIds:c,anchors:u}=r,_=this._collection,g=d[0],{layout:m,indices:p,interleavedVertexData:f,positionData:b,hasColors:y}=o,{material:v,geometryParameters:I}=this._materialParameters(g,m),w=l||new Uint32Array([0,p?p.length:f.byteLength/m[0].stride]),S={vertices:{data:f,count:f.byteLength/m[0].stride,layoutParameters:I},positionData:{positions:ee(b.data),indices:te(b.indices)},indices:p,componentOffsets:w},A=g.transformation?j(g.transformation):R();O(A,n,A);const N=E(H(),A),V=M(x(),A),F=this.view.renderSpatialReference,P=this.view.basemapTerrain.spatialReference,U=pt.fromData(t.geometryObbData).center,L=[1,1,1];k(U,F,L,P)||xt().errorOnce("Unsupported coordinate system for IM overlay");const B=H();W(U,F,B,P);const q=x();C(q,V);const z=H();D(z,T(z,U,N),q);const K=B[0]-z[0]*L[0],$=B[1]-z[1]*L[1],Q=_.createObject({toMapSpace:G(K,$,L[0],L[1]),geometry:S,obb:pt.fromData(t.geometryObbData),transform:{position:N,rotationScale:V}}),X=I.textureCoordinates===vt.Atlas,{textures:Y,texturePromise:J}=this._initMaterialAndTextures(Q,v,a,X);e.memory+=this._memEstimateGeometryAdded(Q),e.memory+=Y.reduce(((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0)),0);const Z=!!v.hasParametersFromSource,ie="blend"!==v.alphaMode&&v.metallicRoughness.baseColorFactor[3]>=1,se=new Et(e,h,Q,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:Z,isOpaque:ie},Y,c,u);s.meta=se,!this._hasTextures&&t.requiredTextures?.some((({usage:e})=>0!=(e&we.ColorTextures)))&&(this._hasTextures=!0),this._hasData=!0,this._hasColors=this._hasColors||y,this._hasTextures=this._hasTextures||!!e.resources.texture,this.notifyChange("hasTexturesOrVertexColors");const re=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(se),J]).then((([t,s])=>(null!=t&&t.updateObjectVisibility(se.objectHandle,!1).catch((e=>At(e,this.i3slayer.title))),this._safeReschedule((()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,se),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(Q,!0),null!=t&&t.updateObjectVisibility(se.objectHandle,!0).catch((e=>At(e,this.i3slayer.title))),se.attributeInfo=i.attributeInfo;const s=se.cachedRendererVersion!==this._rendererVersion,r=re!==this.slicePlaneEnabled;this._updateElevationOffsets(se);const o=se.elevationOffsets;this._updateComponentData(se);const n=this._applyFiltersToNode(se);(s||null!=t&&(r||n||o))&&this._addOrUpdateEdgeRendering(se),null!=this._labeler&&this._addMetaToLabeler(this._labeler,se),this._visibleGeometryChanged(se,Dt.ADD),this._highlights.objectCreated(se),this._updateMaterial(se),this._setNewNodeOpacity(se),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)){xt().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&&Wt(t.cachedEdgeMaterials,0)),this._nodeId2Meta.set(e,t),this.notifyChange("elevationRange")}_updateElevationOffsets(e){const t=this.view.renderSpatialReference,i=this._controller.crsIndex,s=this.elevationInfo,r=this.view.basemapTerrain,o=r.spatialReference,n=s.mode;if(null==t||null==o||n===ve.Absolute)return void(e.elevationOffsets=null);const a=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const l=$t,d=Qt,h=n===ve.OnTheGround,c=this.view.renderCoordsHelper,u=e.featureIds.length,_=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const s=Z(3*u);e.cachedElevationAnchors=s;for(let r=0;r<u;r++){const n=3*r,h=e.anchorIds?.indexOf(r)??-1;e.anchors&&h>=0?(S(l,e.anchors[3*h],e.anchors[3*h+1],e.anchors[3*h+2]),N(l,l,ie(e.node.serviceMbsInIndexSR)),W(l,i,l,o),s[n]=l[0],s[n+1]=l[1],s[n+2]=c.getAltitude(l)):(this._collection.getComponentAabb(e.objectHandle,r,d,!0),S(l,(d[0]+d[3])/2,(d[1]+d[4])/2,d[2]),D(l,l,a.rotationScale),N(l,l,a.position),s[n+2]=c.getAltitude(l),W(l,t,l,o),s[n]=l[0],s[n+1]=l[1])}return s})(),g=s.offset,m=e.elevationOffsets,p=(e,t)=>{const i=h?_[3*e+2]:0;m[e]=g+(null!=t?t-i:0)};r.getElevations(_,u,p)}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new De(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.elevationInfo?.mode))),this._elevationTask}_elevationInfoChanged(e,t){const i=e.mode!==ve.Absolute,s=!!t&&t!==e&&t.mode!==ve.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,Dt.UPDATE))}_safeReschedule(e,t){return _(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:Ue(),s=t.some((e=>"uvRegion"===e.name)),r=t.some((e=>"normalCompressed"===e.name)),o=Gt(i);return{geometryParameters:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s){const r=this._stage.renderView,o=i.map((e=>Ge(e,t,s,r)));this._stage.addMany(o);let n=null;return this._collection.updateMaterial(e,(e=>{n=Le(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:n}}_getGeometryParameters(e){return{textureCoordinates:e.hasTexture?e.hasRegions?vt.Atlas:vt.Default:vt.None,colors:this._hasVertexColors,hasNormals:e.hasNormals&&this._needsNormals,needsNormals:this._needsNormals}}_addData(e,t,i){let s=this._addTasks.get(e.index);return s?s.attributeInfo=t:(s={...g(),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=Y();this._renderClippingArea=mt(this.view.clippingArea,i,e)?i:null;const s=Y();this._layerClippingArea=mt(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,Dt.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={},n=this._createLayerGraphic(o),a=this.i3slayer.objectIdField,l=t.featureIds,d=t.attributeInfo?.attributeData;s.every((e=>e===a||null!=d?.[e]))&&Ze(e,l,(e=>{o[a]=l[e];for(const i of s)i!==a&&(o[i]=d?et(d[i],e):null);try{return i.testFeature(n)}catch(t){return r(t),!1}}))}_boundingRectNodeTest(e,t){return B(e.node.serviceMbsInIndexSR,this._controller.crsIndex,Ut,this.view.renderSpatialReference),tt(t,Ut)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,Tt),X(Tt,Nt),J(i,Nt)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(r===it.INSIDE)return;if(r===it.OUTSIDE)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const n=this._transformClippingArea(Vt,i,t.objectHandle);Ze(e,t.featureIds,(e=>this._boundingRectFeatureTest(t,e,n)))}_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:n}=this._getFilteredEdgeMaterials(e),a={hasSlicePlane:this.slicePlaneEnabled};if(o&&r){if(this.nodeCrossfadingEnabled){Wt(n,this.getNodeOpacity(e))}return i.updateAllComponentMaterials(s,n,a,t).catch((e=>At(e,this.i3slayer.title))),i.updateObjectVisibility(s,!0).catch((e=>At(e,this.i3slayer.title))),i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>At(e,this.i3slayer.title))),Promise.resolve(i)}return o&&!r?this._collection.addEdges(s,i,n,a).then((t=>(e.edgeMemoryUsage=t,e.node.memory+=t,i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>At(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=t.getComponentCount(e.objectHandle),s=null!=e.filteredIds,r=0===i.invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!r;if(this._updateCachedFilteredIds(e),s&&e.filteredIds===e.featureIds)return!r;const o=this._computeFilteredComponentIndices(e);return t.setAllComponentVisibilities(e.objectHandle,o),!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=h(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),null!=this._elevationTask&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);null!=s?(this._collection.setObjectVisibility(s.objectHandle,!1),null!=this._edgeView&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch((e=>At(e,this.i3slayer.title))),this._visibleGeometryChanged(s,Dt.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===Be.Hole))}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){const i=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,i),this.notifyChange("elevationRange")}const i=this._nodeId2MetaReloading.get(e);i&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,i))}_invalidateAllSymbols(){this._rendererVersion=st(this._rendererVersion,1),this._controller&&this._controller.requestUpdate()}_getInvalidRendererVersion(){return st(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=st(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 ue()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:xt().warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.getSymbols())"mesh-3d"!==t.type&&xt().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(U(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],r=_e(this.view.map,this.layerUid);this._stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(t,t,this.layerId,this.layerUid+"_"+this.sublayerId,this.layerPopupEnabledAndHasTemplate&&!r,e.node.resources.attributes,i,this.sublayerId),s.objectAndLayerIdColor=this._stage.renderView.getObjectAndLayerIdColor({graphicUid:t,layerUid:this.layerUid+"_"+this.sublayerId})}s.externalColorMixMode=t[r+4]&(1<<jt.CastShadows)-1,s.castShadows=0!=(t[r+4]&1<<jt.CastShadows),s.pickable=0!=(t[r+4]&1<<jt.Pickable),s.elevationOffset=e.elevationOffsets?.[i]??0}}_getSymbolInfo(e,t){const i=e?.getSymbol(t,{arcade:this._arcade});if(!(i instanceof ge))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=rt(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?le(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,n=null!=r&&null!=this._symbologyFields&&this._symbologyFields.length>0;let a=null,l=null;if(n&&null!=this._symbologyFields){a=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(a.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=oe(5*e.featureIds.length));const d={color:Pt,castShadows:!0,pickable:!0,colorMixMode:ut.Multiply,edgeMaterial:null},h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=Mt.OPAQUE,g=ot,m=0;for(let p=0;p<e.featureIds.length;p++){if(null!=o&&(i[o]=e.featureIds[p]),n&&a)for(let e=0;e<a.length;e++)i[a[e]]=et(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=he(this._colorVariable,t,{color:Ht,arcade:this._arcade});e&&(h=Pt,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=ce(this._opacityVariable,t,{arcade:this._arcade}))}if(r?.material){const e=r.material;h=null==h||null==f?je(h,f,e.color,e.alpha,Ot,Pt):je(h,f,null,null,Ot,Pt)}if(null==h&&(h=Pt,h[0]=1,h[1]=1,h[2]=1,h[3]=1),d.pickable=!0,d.castShadows=!r||r.castShadows,d.colorMixMode=r?.material?r.material.colorMixMode:ut.Multiply,d.edgeMaterial=r?r.edgeMaterial:null,null!=this._symbologyOverride&&(d.color=h,this._symbologyOverride(t,d),h=d.color),null!=this._nodeColorOverride&&(this._nodeColorOverride(e.node,h),d.colorMixMode=ut.Replace),null!=d.edgeMaterial){const t=h[3]<=0?Mt.INVISIBLE:h[3]>=1&&(e.material.isOpaque||d.colorMixMode===ut.Replace)?Mt.OPAQUE:Mt.TRANSPARENT;d.edgeMaterial===u&&t===_||(g={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,_=t),e.cachedEdgeMaterials[p]=g}else e.cachedEdgeMaterials[p]=ot;e.cachedSymbology[m++]=Math.round(255*h[0]),e.cachedSymbology[m++]=Math.round(255*h[1]),e.cachedSymbology[m++]=Math.round(255*h[2]),e.cachedSymbology[m++]=Math.round(255*h[3]),e.cachedSymbology[m++]=d.colorMixMode|+d.castShadows<<jt.CastShadows|+d.pickable<<jt.Pickable}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||Wt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some((e=>e!==ot)),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map(((t,o)=>e.featureIds[o]!==i[s]?ot:(r=r||t!==ot,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)),Wt(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,Dt.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._needsNormals&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){null!=this._edgeView&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?(t,i,s)=>s.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?Ie.CONTINUE:e(t,i,s):e}_forAllFeatures(e,t,i){d(this._nodeId2Meta,(s=>{if(null==s)return!1;if(null!=t){switch(t(s)){case Ie.EXIT:return!0;case Ie.SKIP:return!1}}let r=Ie.CONTINUE;switch(i){case Me.ALL:r=this._forAllFeaturesOfNode(s,e);break;case Me.VISIBLE_ONLY:r=this._forAllVisibleFeaturesOfNode(s,e);break;case Me.QUERYABLE:r=this._forAllQueryableFeaturesOfNode(s,e)}return r===Ie.EXIT}))}_forAllFeaturesOfNode(e,t){let i=Ie.CONTINUE;const s=e.featureIds;for(let r=0;r<s.length;r++)if(i=t(s[r],r,e),i===Ie.EXIT)return i;return i}_forAllVisibleFeaturesOfNode(e,t){let i=Ie.CONTINUE;const s=e.featureIds;return this._collection.forEachVisibleComponent(e.objectHandle,(r=>(i=t(s[r],r,e),i===Ie.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===it.OUTSIDE)return Ie.CONTINUE;if(s===it.INSIDE)return this._forAllFeaturesOfNode(e,i);const r=Ie.CONTINUE,o=e.featureIds,n=e.objectHandle,a=nt(this._renderClippingArea,this._collection.getObjectTransform(n));for(let l=0;l<o.length;l++){if(!this._boundingRectFeatureTest(e,l,a))continue;const t=i(o[l],l,e);if(t===Ie.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]=et(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e){if("number"==typeof e||e instanceof i?e=[e]:e instanceof n&&(e=e.toArray()),Array.isArray(e)&&e.length>0){if(e[0]instanceof i){const t=e,i=this.i3slayer.fieldsIndex,s=this._getObjectIdField(),r=t.map((e=>ht(i,e.attributes,s))),{set:o,handle:n}=this._highlights.acquireSet();return this._highlights.setFeatureIds(o,r),n}if("number"==typeof e[0]){const t=e,{set:i,handle:s}=this._highlights.acquireSet();return this._highlights.setFeatureIds(i,t),s}}return a()}resetHighlights(){h(this._highlights),this._highlights=new Ae({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,Me.ALL),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)})}_visibleGeometryChanged(e,t){if(!this._elevationProvider)return;const i=this.getNodeComponentObb(e.node);i&&this._elevationProvider.objectChanged(i),null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=f((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))),this._updateSnappingSources(e,t)}get performanceInfo(){return new fe(this.usedMemory,this._nodeId2Meta.size,Math.round(this._gpuMemoryEstimate/1048576),Math.round(this._geoMemoryEstimate/1048576),Math.round(this._texMemoryEstimate/1048576),Math.round(this.unloadedMemory/1048576),this._idbCacheEnabled?Math.round(100*this._idbCache.getHitRate()):0)}get test(){const e=this,t=e=>{this._nodeColorOverride=e,this._invalidateAllSymbols()};return{controller:this._controller,labeler:this._labeler,get visibleObjectIds(){const t=[];return e._forAllFeatures((e=>(t.push(e),Ie.CONTINUE)),null,Me.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))},setNodeColorOverride:t,setNodeColoring:e=>{if("client-nodes"===e)t(((e,t)=>{e.index<0?(t[0]=1,t[1]=0,t[2]=0):(t[0]=1,t[1]=1,t[2]=1)}));else t(null)}}}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return null!=e?this._collection.getMaterial(e.objectHandle).objectOpacity:0}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(e)}fadeNode(e,t,i){if(!this.nodeCrossfadingEnabled)return;const s=this._nodeId2Meta.get(e);null!=s&&this._crossfadeHelper.fadeNode(e,s,t,i)}setNodeOpacityByIndex(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._setNodeOpacity(i,t)}_setNodeOpacity(e,t){this._collection.updateMaterial(e.objectHandle,(e=>e.objectOpacity=t)),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(null==this._edgeView||!e.cachedEdgeMaterials)return;Wt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch((e=>At(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=zt(e);if(s){const t={context:i,buffer:s.buffer};Oe(t);const r=new Float64Array(s.buffer);e.forAll(((e,t)=>{const i=r[t],s=Ee(i);e.imModificationImpact=s,s!==ke.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);s&&e.add(i,s)})),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||this.elevationInfo.mode===ve.Absolute)return;const s=t.position0,r=t.position1,o=t.componentIndex,n=H(),a=H(),l=(e,t)=>{N(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,a),N(e,e,V(a,a,t)),F(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,n),l(n,t),s.setVec(d,n),r.getVec(d,n),l(n,t),r.setVec(d,n)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(null!=s)for(const r of this._snappingSourcesTrackers)t!==Dt.REMOVE&&t!==Dt.UPDATE||r.events.remove(i),t!==Dt.ADD&&t!==Dt.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(ft)],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:[de]})],o.prototype,"_modifications",void 0),e([v({readOnly:!0})],o.prototype,"clientGeometry",null),e([v()],o.prototype,"elevationRange",null),e([v()],o.prototype,"fullExtent",null),e([v()],o.prototype,"_elevationTask",void 0),e([v({readOnly:!0})],o.prototype,"_usePBR",null),o=e([I(Ct)],o),o};function At(e,t){u(e)||xt().warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}var Dt;!function(e){e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE"}(Dt||(Dt={}));const Tt=K(),Nt=Y(),Vt=Y(),Ft=new pt,Pt=[0,0,0,0],Ht=new t([0,0,0,0]),Ut=se(0,0,0,0);function Gt(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 Lt(e){return"geometryData"in e}function kt(e){return null!=e&&b(e.data)}function Bt(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 qt(e,t){return t.byteSize>wt?(xt().warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}function zt(e){if(0===e.length)return;const t=10*e.length,i=new Float64Array(t);let s=0;return e.forAll((e=>{let t=e.serviceObbInIndexSR;null==t&&(t=Ft,t.center=ie(e.serviceMbsInIndexSR),t.halfSize=[e.serviceMbsInIndexSR[3],e.serviceMbsInIndexSR[3],e.serviceMbsInIndexSR[3]]);const r=t.data;i[s++]=r[0],i[s++]=r[1],i[s++]=r[2],i[s++]=r[3],i[s++]=r[4],i[s++]=r[5],i[s++]=r[6],i[s++]=r[7],i[s++]=r[8],i[s++]=r[9]})),i}function Wt(e,t){e.forEach((e=>e.opacity=t))}class Kt{constructor(e,t){this.mode=e,this.offset=t}}const $t=H(),Qt=K(),Xt="elevation-change",Yt=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],Jt=new gt;function Zt(e,t,i){let s=e.elevationRangeMin,r=e.elevationRangeMax;const o=i;if(o>0){t.getCorners(Yt);for(const e of Yt){const t=P(e)-o;s=Math.min(s,t),r=Math.max(r,t)}}else{t.getCorners(Yt);for(const e of Yt){const t=e[2];s=Math.min(s,t),r=Math.max(r,t)}}e.expandElevationRangeValues(s,r)}function ei(e,t,i){const s=ie(t),r=i>0?P(s)-i:s[2],o=re(t);e.expandElevationRangeValues(r-o,r+o)}export{St 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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as i}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{lerp as s}from"../../../../core/mathUtils.js";import e from"../../../../core/PooledArray.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import{invertOrIdentity as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{e as l,h,s as p,c as u}from"../../../../chunks/vec32.js";import{ZEROS as d,create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as _,t as m,d as b}from"../../../../chunks/vec42.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as v}from"../../../../geometry/ellipsoidUtils.js";import{create as y,empty as G,offset as S,width as D,height as B,expand as N,intersects as w}from"../../../../geometry/support/aaBoundingRect.js";import{a as j,c as I,e as C}from"../../../../chunks/boundedPlane.js";import{create as P}from"../../../../geometry/support/ray.js";import{g as A,e as V,h as x,d as O}from"../../../../chunks/sphere.js";import{drawAccelerationStruct as E,prepare as M,drawPoly as z}from"./deconflictorDebug.js";import{VisibilityGroup as T,VisibilityFlag as F}from"./enums.js";import{Camera as L}from"../../webgl-engine/lib/Camera.js";import{applyPrecomputedScaleFactor as X}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as Y}from"../../webgl-engine/lib/VertexAttribute.js";import{HUDMaterial as R}from"../../webgl-engine/materials/HUDMaterial.js";import{ScaleInfo as W}from"../../webgl-engine/materials/ScaleInfo.js";const U=f(),k=g(),H=g(),q=f(),J=c(),K=O(),Q=P(),Z=f(),$=y();class ii{constructor(){this.aabr=y(),this.distance=0,this.culled=!1,this.visible=!1}}class ti{constructor(i,t){this.graphics3DGraphic=i,this.slicePlaneEnabled=t,this.info={}}}var si;!function(i){i[i.Idle=0]="Idle",i[i.Process=1]="Process",i[i.Sort=2]="Sort",i[i.Deconflict=3]="Deconflict",i[i.NumStates=4]="NumStates"}(si||(si={}));class ei{constructor(){this.camera=new L,this.slicePlane=j(),this.slicePlaneEnabled=!1}copyFrom(i){this.camera.copyFrom(i.camera),I(i.slicePlane,this.slicePlane),this.slicePlaneEnabled=i.slicePlaneEnabled}}let ri=class extends t{get dirty(){return this._dirty}get state(){return this._state}constructor(i){super(i),this._dirty=!1,this._viewState=new ei,this._state=si.Idle,this._active=new Map,this._visible=new Map,this._iterators=new li,this._accBinsNumX=15,this._accBinsNumY=20,this._accBinsSizeX=0,this._accBinsSizeY=0,this._accBins=null,this.accNumTests=0}destroy(){this._active.clear(),this._visible.clear(),this._iterators=null}setDirty(){!this._dirty&&this._active.size>0&&(this._dirty=!0,this.notifyChange("updating"))}get updating(){return this._state!==si.Idle||this._dirty}get updatingProgress(){if(!this.updating)return 1;const i=this._state/si.NumStates;return this._dirty?.5*i:i}get running(){return this.view.ready&&null!=this.view.state&&this.updating}runTask(i){switch(this._state){case si.Idle:this._startUpdate(),i.madeProgress();case si.Process:if(this._state=si.Process,!this._processActiveGraphics(i))return;case si.Sort:if(this._state=si.Sort,!this._sortVisibleGraphics(i))return;case si.Deconflict:if(this._state=si.Deconflict,!this._deconflictVisibleGraphics(i))return;default:E(this,this._visible),this._state=si.Idle,this.notifyChange("updating")}}modifyGraphics(i,t){t?i.forEach((i=>this.addToActiveGraphics(i))):i.forEach((i=>this.removeFromActiveGraphics(i))),this.setDirty()}layerSupportsDeconfliction(i){if(null==i||"object3d"!==i.type)return!1;const t=i.stageObject;if(1!==(t?.geometries.length??0))return!1;const s=t?.geometries[0],e=s?.material;return e instanceof R}_startUpdate(){M(this.view),this._dirty=!1,this._viewState.copyFrom(this.viewState);const{fullWidth:i,fullHeight:t}=this._viewState.camera;this._initBins(i,t),this._resetIterators()}addToActiveGraphics(i){i.info[this.visibilityGroup]=new ii,this._active.set(i.graphics3DGraphic.graphic.uid,i),this.setDirty()}removeFromActiveGraphics(i){this._visible.delete(i.graphics3DGraphic.graphic.uid),ai(i,this.visibilityGroup),delete i.info[this.visibilityGroup],this._active.delete(i.graphics3DGraphic.graphic.uid),this.setDirty()}_processActiveGraphics(i){const t=this._ensureActiveGraphicsIterator(),s=o(J,this._viewState.camera.projectionMatrix),e="global"===this.view.viewingMode&&1===this.view.map.ground.opacity&&this._viewState.camera.relativeElevation>0?K:null;let r=0;for(null!=e&&(l(A(e),d,this._viewState.camera.viewMatrix),e[3]=v(this.view.spatialReference).radius,r=V(e,d));!i.done;){i.madeProgress();const a=t.next();if(!0===a.done)return this._resetActiveGraphicsIterator(),!0;const o=a.value,c=o?.info[this.visibilityGroup];c&&(this._collectGraphics3DGraphics(o,s,e,r),c.culled?this._visible.delete(o.graphics3DGraphic.graphic.uid):this._visible.set(o.graphics3DGraphic.graphic.uid,o))}return!1}_sortVisibleGraphics(i){const t=this._ensureSortGraphicsIterator();for(;!i.done;){const s=t.next();if(i.madeProgress(),!0===s.done)return this._resetSortGraphicsIterator(),!0}return!1}_deconflictVisibleGraphics(i){const t=this._ensureVisibleGraphicsIterator(),s=this.visibilityGroup===T.LABEL;for(;!i.done;){i.madeProgress();const e=t.next();if(!0===e.done)return this._resetVisibleGraphicsIterator(),!0;const r=e.value,a=r.info[this.visibilityGroup];if(!a||a.culled){this._setGraphicVisibility(r,!1);continue}const o=r.graphics3DGraphic,c=!s||o.isVisible();a.visible=c&&!this._isConflicted(r),a.visible&&this._addToBins(r),this._setGraphicVisibility(r,a.visible),z(a,a.visible)}return!1}_resetIterators(){this._iterators.active=null,this._iterators.visible=null,this._iterators.sort=null}_ensureActiveGraphicsIterator(){return this._iterators.active||(this._iterators.active=oi(this._active)),this._iterators.active}_resetActiveGraphicsIterator(){this._iterators.active=null}_ensureVisibleGraphicsIterator(){return this._iterators.visible||(this._iterators.visible=oi(this._visible)),this._iterators.visible}_resetVisibleGraphicsIterator(){this._iterators.visible=null}_ensureSortGraphicsIterator(){return this._iterators.sort||(this._iterators.sort=ci(this._visible,this._iterators.sortArray,this.visibilityGroup)),this._iterators.sort}_resetSortGraphicsIterator(){this._iterators.sort=null}_collectGraphics3DGraphics(i,t,s,e){const r=i.graphics3DGraphic;if(r.destroyed)return;const a=i.info[this.visibilityGroup];if(!r.isVisible(T.GRAPHIC,F.DECONFLICTION))return void(a.culled=!0);const o=this.getGraphicsLayers(r);G(a.aabr);let c=null;for(const n of o){if(!this.layerSupportsDeconfliction(n))continue;const r=n.stageObject.geometries[0].material;if(null==c&&(c=ui,this._getProjectionInfo(n,t,c),c.isOutsideScreen||this._isCulledBySlice(i,U)||null!=s&&this._isCulledByHorizon(c,s,e)))return void(a.culled=!0);this._expandBoundingRect(a,n,r,c)}null==c?a.culled=!0:(a.distance=c.distance,a.culled=!1)}_getProjectionInfo(i,t,s){const e=this._viewState.camera,r=i.stageObject,a=r.geometries[0],o=a.material,c=A(r.boundingVolumeWorldSpace.bounds);l(U,c,e.viewMatrix);const n=a.attributes,u=n.get(Y.NORMAL).data,d=n.get(Y.CENTEROFFSETANDDISTANCE).data;o.applyShaderOffsetsView(U,u,r.transformation,d,e,s.scaleInfo,U),_(k,U[0],U[1],U[2],1),m(H,k,e.projectionMatrix),h(s.positionNDC,H,1/H[3]),o.applyShaderOffsetsNDC(s.positionNDC,d,e,s.positionNDC,q),s.distanceWithoutPolygonOffset=e.depthNDCToWorld(q[2]),s.distance=q[2]===s.positionNDC[2]?s.distanceWithoutPolygonOffset:e.depthNDCToWorld(s.positionNDC[2]),_(H,s.positionNDC[0],s.positionNDC[1],s.positionNDC[2],1),m(k,H,t),b(k,k,1/k[3]),p(s.positionView,U[0],U[1],U[2])}_isCulledByHorizon(i,t,s){return u(Q.direction,i.positionView),p(Q.origin,0,0,0),!!x(t,Q,Z)&&i.distanceWithoutPolygonOffset>s}_isCulledBySlice(i,t){return i.slicePlaneEnabled&&this._viewState.slicePlaneEnabled&&C(this._viewState.slicePlane,t)}_expandBoundingRect(i,t,e,{positionNDC:r,scaleInfo:a}){const o=this._viewState.camera,c=t.getScreenSize(hi);X(c,a.factor,c),c[0]*=o.pixelRatio,c[1]*=o.pixelRatio;const n=S(e.calculateRelativeScreenBounds(c,a.factorAlignment.scale,$),s(0,o.fullWidth,.5+.5*r[0]),s(0,o.fullHeight,.5+.5*r[1])),l=this.marginFactor;if(0!==l){const i=l*Math.min(D(n),B(n));n[0]-=i,n[1]-=i,n[2]+=i,n[3]+=i}N(i.aabr,n,i.aabr)}_isConflicted(i){const t=i.graphics3DGraphic.graphic.uid,s=i.info[this.visibilityGroup];let e=!0;for(let r=Math.floor(s.aabr[0]/this._accBinsSizeX);r<=Math.floor(s.aabr[2]/this._accBinsSizeX);r++)if(!(r<0||r>=this._accBinsNumX))for(let i=Math.floor(s.aabr[1]/this._accBinsSizeY);i<=Math.floor(s.aabr[3]/this._accBinsSizeY);i++){if(i<0||i>=this._accBinsNumY)continue;e=!1;const a=this._accBins[r][i];for(let i=0;i<a.length;i++){const e=a.data[i],r=e.info[this.visibilityGroup];if(r&&r.visible&&e.graphics3DGraphic.graphic.uid!==t&&(this.accNumTests++,w(r.aabr,s.aabr)))return!0}}return e}_initBins(i,t){if(null==this._accBins){this._accBins=[];for(let i=0;i<this._accBinsNumX;i++){this._accBins.push([]);const i=this._accBins[this._accBins.length-1];for(let t=0;t<this._accBinsNumY;t++)i.push(new e)}}else for(let s=0;s<this._accBinsNumX;s++)for(let i=0;i<this._accBinsNumY;i++)this._accBins[s][i].clear();this._accBinsSizeX=i/this._accBinsNumX,this._accBinsSizeY=t/this._accBinsNumY,this.accNumTests=0}_addToBins(i){const t=i.info[this.visibilityGroup],s=Math.floor(t.aabr[0]/this._accBinsSizeX),e=Math.floor(t.aabr[2]/this._accBinsSizeX),r=Math.floor(t.aabr[1]/this._accBinsSizeY),a=Math.floor(t.aabr[3]/this._accBinsSizeY);for(let o=s;o<=e;o++)if(!(o<0||o>=this._accBinsNumX))for(let t=r;t<=a;t++)t<0||t>=this._accBinsNumY||this._accBins[o][t].push(i)}_setGraphicVisibility(i,t){const s=i.graphics3DGraphic;s.destroyed||(s.setVisibilityFlag(this.visibilityGroup,F.DECONFLICTION,t),this.visibilityGroup===T.LABEL&&this.view.labeler.setLabelGraphicVisibility(s,t))}};function ai(i,t){const s=i.graphics3DGraphic;s.destroyed||s.setVisibilityFlag(t,F.DECONFLICTION,!0)}function*oi(i){if(Map.prototype.entries){const t=i.entries();for(let i=t.next();!i.done;i=t.next())yield i.value[1]}else yield*i.values()}function*ci(i,t,s){t.clear(),i.forEach(((i,e)=>{const r=t.pushNew();r.id=e,r.visible=i.graphics3DGraphic.getVisibilityFlag(s,F.DECONFLICTION);const a=i.info?.[s];r.prio=i.graphics3DGraphic.deconflictionPriority,r.distance=a?a.distance:Number.MAX_VALUE})),yield;const e=t.iterableSort(((i,t)=>i.prio!==t.prio?t.prio-i.prio:i.distance!==t.distance?i.distance-t.distance:i.visible!==t.visible?i.visible?-1:1:i.id-t.id));for(let r=e.next();!r.done;r=e.next())yield;t.forAll((t=>{const s=i.get(t.id);s&&(i.delete(t.id),i.set(t.id,s))})),t.clear()}i([r({constructOnly:!0})],ri.prototype,"view",void 0),i([r({type:Boolean,readOnly:!0})],ri.prototype,"updating",null),ri=i([a("esri.views.3d.layers.graphics.Deconflictor")],ri);class ni{constructor(){this.id=0,this.visible=!1,this.prio=0,this.distance=0}}class li{constructor(i=null,t=null,s=null){this.active=i,this.visible=t,this.sort=s,this.sortArray=new e({allocator:i=>i||new ni})}}const hi=n();class pi{constructor(){this.positionView=f(),this.positionNDC=f(),this.distance=0,this.distanceWithoutPolygonOffset=0,this.scaleInfo=new W}get isOutsideScreen(){const i=this.positionNDC;return i[0]<-1||i[1]<-1||i[2]<-1||i[0]>=1||i[1]>=1}}const ui=new pi;export{ri as Deconflictor,ti as DeconflictorGraphic,ei as DeconflictorViewState,si as State};
|
|
5
|
+
import{_ as i}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{lerp as s}from"../../../../core/mathUtils.js";import e from"../../../../core/PooledArray.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import{invertOrIdentity as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{e as l,h,s as p,c as u}from"../../../../chunks/vec32.js";import{ZEROS as d,create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as _,t as m,b}from"../../../../chunks/vec42.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as v}from"../../../../geometry/ellipsoidUtils.js";import{create as y,empty as G,offset as S,width as D,height as B,expand as N,intersects as w}from"../../../../geometry/support/aaBoundingRect.js";import{a as j,c as I,e as C}from"../../../../chunks/boundedPlane.js";import{create as P}from"../../../../geometry/support/ray.js";import{g as A,d as V,i as x,c as O}from"../../../../chunks/sphere.js";import{drawAccelerationStruct as E,prepare as M,drawPoly as z}from"./deconflictorDebug.js";import{VisibilityGroup as T,VisibilityFlag as F}from"./enums.js";import{Camera as L}from"../../webgl-engine/lib/Camera.js";import{applyPrecomputedScaleFactor as X}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as Y}from"../../webgl-engine/lib/VertexAttribute.js";import{HUDMaterial as R}from"../../webgl-engine/materials/HUDMaterial.js";import{ScaleInfo as W}from"../../webgl-engine/materials/ScaleInfo.js";const U=f(),k=g(),H=g(),q=f(),J=c(),K=O(),Q=P(),Z=f(),$=y();class ii{constructor(){this.aabr=y(),this.distance=0,this.culled=!1,this.visible=!1}}class ti{constructor(i,t){this.graphics3DGraphic=i,this.slicePlaneEnabled=t,this.info={}}}var si;!function(i){i[i.Idle=0]="Idle",i[i.Process=1]="Process",i[i.Sort=2]="Sort",i[i.Deconflict=3]="Deconflict",i[i.NumStates=4]="NumStates"}(si||(si={}));class ei{constructor(){this.camera=new L,this.slicePlane=j(),this.slicePlaneEnabled=!1}copyFrom(i){this.camera.copyFrom(i.camera),I(i.slicePlane,this.slicePlane),this.slicePlaneEnabled=i.slicePlaneEnabled}}let ri=class extends t{get dirty(){return this._dirty}get state(){return this._state}constructor(i){super(i),this._dirty=!1,this._viewState=new ei,this._state=si.Idle,this._active=new Map,this._visible=new Map,this._iterators=new li,this._accBinsNumX=15,this._accBinsNumY=20,this._accBinsSizeX=0,this._accBinsSizeY=0,this._accBins=null,this.accNumTests=0}destroy(){this._active.clear(),this._visible.clear(),this._iterators=null}setDirty(){!this._dirty&&this._active.size>0&&(this._dirty=!0,this.notifyChange("updating"))}get updating(){return this._state!==si.Idle||this._dirty}get updatingProgress(){if(!this.updating)return 1;const i=this._state/si.NumStates;return this._dirty?.5*i:i}get running(){return this.view.ready&&null!=this.view.state&&this.updating}runTask(i){switch(this._state){case si.Idle:this._startUpdate(),i.madeProgress();case si.Process:if(this._state=si.Process,!this._processActiveGraphics(i))return;case si.Sort:if(this._state=si.Sort,!this._sortVisibleGraphics(i))return;case si.Deconflict:if(this._state=si.Deconflict,!this._deconflictVisibleGraphics(i))return;default:E(this,this._visible),this._state=si.Idle,this.notifyChange("updating")}}modifyGraphics(i,t){t?i.forEach((i=>this.addToActiveGraphics(i))):i.forEach((i=>this.removeFromActiveGraphics(i))),this.setDirty()}layerSupportsDeconfliction(i){if(null==i||"object3d"!==i.type)return!1;const t=i.stageObject;if(1!==(t?.geometries.length??0))return!1;const s=t?.geometries[0],e=s?.material;return e instanceof R}_startUpdate(){M(this.view),this._dirty=!1,this._viewState.copyFrom(this.viewState);const{fullWidth:i,fullHeight:t}=this._viewState.camera;this._initBins(i,t),this._resetIterators()}addToActiveGraphics(i){i.info[this.visibilityGroup]=new ii,this._active.set(i.graphics3DGraphic.graphic.uid,i),this.setDirty()}removeFromActiveGraphics(i){this._visible.delete(i.graphics3DGraphic.graphic.uid),ai(i,this.visibilityGroup),delete i.info[this.visibilityGroup],this._active.delete(i.graphics3DGraphic.graphic.uid),this.setDirty()}_processActiveGraphics(i){const t=this._ensureActiveGraphicsIterator(),s=o(J,this._viewState.camera.projectionMatrix),e="global"===this.view.viewingMode&&1===this.view.map.ground.opacity&&this._viewState.camera.relativeElevation>0?K:null;let r=0;for(null!=e&&(l(A(e),d,this._viewState.camera.viewMatrix),e[3]=v(this.view.spatialReference).radius,r=V(e,d));!i.done;){i.madeProgress();const a=t.next();if(!0===a.done)return this._resetActiveGraphicsIterator(),!0;const o=a.value,c=o?.info[this.visibilityGroup];c&&(this._collectGraphics3DGraphics(o,s,e,r),c.culled?this._visible.delete(o.graphics3DGraphic.graphic.uid):this._visible.set(o.graphics3DGraphic.graphic.uid,o))}return!1}_sortVisibleGraphics(i){const t=this._ensureSortGraphicsIterator();for(;!i.done;){const s=t.next();if(i.madeProgress(),!0===s.done)return this._resetSortGraphicsIterator(),!0}return!1}_deconflictVisibleGraphics(i){const t=this._ensureVisibleGraphicsIterator(),s=this.visibilityGroup===T.LABEL;for(;!i.done;){i.madeProgress();const e=t.next();if(!0===e.done)return this._resetVisibleGraphicsIterator(),!0;const r=e.value,a=r.info[this.visibilityGroup];if(!a||a.culled){this._setGraphicVisibility(r,!1);continue}const o=r.graphics3DGraphic,c=!s||o.isVisible();a.visible=c&&!this._isConflicted(r),a.visible&&this._addToBins(r),this._setGraphicVisibility(r,a.visible),z(a,a.visible)}return!1}_resetIterators(){this._iterators.active=null,this._iterators.visible=null,this._iterators.sort=null}_ensureActiveGraphicsIterator(){return this._iterators.active||(this._iterators.active=oi(this._active)),this._iterators.active}_resetActiveGraphicsIterator(){this._iterators.active=null}_ensureVisibleGraphicsIterator(){return this._iterators.visible||(this._iterators.visible=oi(this._visible)),this._iterators.visible}_resetVisibleGraphicsIterator(){this._iterators.visible=null}_ensureSortGraphicsIterator(){return this._iterators.sort||(this._iterators.sort=ci(this._visible,this._iterators.sortArray,this.visibilityGroup)),this._iterators.sort}_resetSortGraphicsIterator(){this._iterators.sort=null}_collectGraphics3DGraphics(i,t,s,e){const r=i.graphics3DGraphic;if(r.destroyed)return;const a=i.info[this.visibilityGroup];if(!r.isVisible(T.GRAPHIC,F.DECONFLICTION))return void(a.culled=!0);const o=this.getGraphicsLayers(r);G(a.aabr);let c=null;for(const n of o){if(!this.layerSupportsDeconfliction(n))continue;const r=n.stageObject.geometries[0].material;if(null==c&&(c=ui,this._getProjectionInfo(n,t,c),c.isOutsideScreen||this._isCulledBySlice(i,U)||null!=s&&this._isCulledByHorizon(c,s,e)))return void(a.culled=!0);this._expandBoundingRect(a,n,r,c)}null==c?a.culled=!0:(a.distance=c.distance,a.culled=!1)}_getProjectionInfo(i,t,s){const e=this._viewState.camera,r=i.stageObject,a=r.geometries[0],o=a.material,c=A(r.boundingVolumeWorldSpace.bounds);l(U,c,e.viewMatrix);const n=a.attributes,u=n.get(Y.NORMAL).data,d=n.get(Y.CENTEROFFSETANDDISTANCE).data;o.applyShaderOffsetsView(U,u,r.transformation,d,e,s.scaleInfo,U),_(k,U[0],U[1],U[2],1),m(H,k,e.projectionMatrix),h(s.positionNDC,H,1/H[3]),o.applyShaderOffsetsNDC(s.positionNDC,d,e,s.positionNDC,q),s.distanceWithoutPolygonOffset=e.depthNDCToWorld(q[2]),s.distance=q[2]===s.positionNDC[2]?s.distanceWithoutPolygonOffset:e.depthNDCToWorld(s.positionNDC[2]),_(H,s.positionNDC[0],s.positionNDC[1],s.positionNDC[2],1),m(k,H,t),b(k,k,1/k[3]),p(s.positionView,U[0],U[1],U[2])}_isCulledByHorizon(i,t,s){return u(Q.direction,i.positionView),p(Q.origin,0,0,0),!!x(t,Q,Z)&&i.distanceWithoutPolygonOffset>s}_isCulledBySlice(i,t){return i.slicePlaneEnabled&&this._viewState.slicePlaneEnabled&&C(this._viewState.slicePlane,t)}_expandBoundingRect(i,t,e,{positionNDC:r,scaleInfo:a}){const o=this._viewState.camera,c=t.getScreenSize(hi);X(c,a.factor,c),c[0]*=o.pixelRatio,c[1]*=o.pixelRatio;const n=S(e.calculateRelativeScreenBounds(c,a.factorAlignment.scale,$),s(0,o.fullWidth,.5+.5*r[0]),s(0,o.fullHeight,.5+.5*r[1])),l=this.marginFactor;if(0!==l){const i=l*Math.min(D(n),B(n));n[0]-=i,n[1]-=i,n[2]+=i,n[3]+=i}N(i.aabr,n,i.aabr)}_isConflicted(i){const t=i.graphics3DGraphic.graphic.uid,s=i.info[this.visibilityGroup];let e=!0;for(let r=Math.floor(s.aabr[0]/this._accBinsSizeX);r<=Math.floor(s.aabr[2]/this._accBinsSizeX);r++)if(!(r<0||r>=this._accBinsNumX))for(let i=Math.floor(s.aabr[1]/this._accBinsSizeY);i<=Math.floor(s.aabr[3]/this._accBinsSizeY);i++){if(i<0||i>=this._accBinsNumY)continue;e=!1;const a=this._accBins[r][i];for(let i=0;i<a.length;i++){const e=a.data[i],r=e.info[this.visibilityGroup];if(r&&r.visible&&e.graphics3DGraphic.graphic.uid!==t&&(this.accNumTests++,w(r.aabr,s.aabr)))return!0}}return e}_initBins(i,t){if(null==this._accBins){this._accBins=[];for(let i=0;i<this._accBinsNumX;i++){this._accBins.push([]);const i=this._accBins[this._accBins.length-1];for(let t=0;t<this._accBinsNumY;t++)i.push(new e)}}else for(let s=0;s<this._accBinsNumX;s++)for(let i=0;i<this._accBinsNumY;i++)this._accBins[s][i].clear();this._accBinsSizeX=i/this._accBinsNumX,this._accBinsSizeY=t/this._accBinsNumY,this.accNumTests=0}_addToBins(i){const t=i.info[this.visibilityGroup],s=Math.floor(t.aabr[0]/this._accBinsSizeX),e=Math.floor(t.aabr[2]/this._accBinsSizeX),r=Math.floor(t.aabr[1]/this._accBinsSizeY),a=Math.floor(t.aabr[3]/this._accBinsSizeY);for(let o=s;o<=e;o++)if(!(o<0||o>=this._accBinsNumX))for(let t=r;t<=a;t++)t<0||t>=this._accBinsNumY||this._accBins[o][t].push(i)}_setGraphicVisibility(i,t){const s=i.graphics3DGraphic;s.destroyed||(s.setVisibilityFlag(this.visibilityGroup,F.DECONFLICTION,t),this.visibilityGroup===T.LABEL&&this.view.labeler.setLabelGraphicVisibility(s,t))}};function ai(i,t){const s=i.graphics3DGraphic;s.destroyed||s.setVisibilityFlag(t,F.DECONFLICTION,!0)}function*oi(i){if(Map.prototype.entries){const t=i.entries();for(let i=t.next();!i.done;i=t.next())yield i.value[1]}else yield*i.values()}function*ci(i,t,s){t.clear(),i.forEach(((i,e)=>{const r=t.pushNew();r.id=e,r.visible=i.graphics3DGraphic.getVisibilityFlag(s,F.DECONFLICTION);const a=i.info?.[s];r.prio=i.graphics3DGraphic.deconflictionPriority,r.distance=a?a.distance:Number.MAX_VALUE})),yield;const e=t.iterableSort(((i,t)=>i.prio!==t.prio?t.prio-i.prio:i.distance!==t.distance?i.distance-t.distance:i.visible!==t.visible?i.visible?-1:1:i.id-t.id));for(let r=e.next();!r.done;r=e.next())yield;t.forAll((t=>{const s=i.get(t.id);s&&(i.delete(t.id),i.set(t.id,s))})),t.clear()}i([r({constructOnly:!0})],ri.prototype,"view",void 0),i([r({type:Boolean,readOnly:!0})],ri.prototype,"updating",null),ri=i([a("esri.views.3d.layers.graphics.Deconflictor")],ri);class ni{constructor(){this.id=0,this.visible=!1,this.prio=0,this.distance=0}}class li{constructor(i=null,t=null,s=null){this.active=i,this.visible=t,this.sort=s,this.sortArray=new e({allocator:i=>i||new ni})}}const hi=n();class pi{constructor(){this.positionView=f(),this.positionNDC=f(),this.distance=0,this.distanceWithoutPolygonOffset=0,this.scaleInfo=new W}get isOutsideScreen(){const i=this.positionNDC;return i[0]<-1||i[1]<-1||i[2]<-1||i[0]>=1||i[1]>=1}}const ui=new pi;export{ri as Deconflictor,ti as DeconflictorGraphic,ei as DeconflictorViewState,si as State};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import{result as t,createTask as r}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import{clone as s}from"../../../../core/lang.js";import{abortMaybe as o,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAbortError as n,throwIfAborted as l}from"../../../../core/promiseUtils.js";import{pt2px as c,px2pt as h}from"../../../../core/screenUtils.js";import{numericHash as m}from"../../../../core/string.js";import{dataComponents as u}from"../../../../core/urlUtils.js";import{fromValues as d,create as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as _,fromValues as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as y}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectPointToVector as g}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as x}from"../../../../geometry/support/aaBoundingBox.js";import{createRendererExpression as b}from"../../../../support/arcadeOnDemand.js";import{CIMSymbolHelper as S}from"../../../../symbols/cim/CIMSymbolHelper.js";import{OverrideHelper as v}from"../../../../symbols/cim/OverrideHelper.js";import{evaluateValueOrFunction as P}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as z}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultPrimitive as R}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{Symbol3DAnchorPosition2D as w}from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as M}from"../../../../symbols/support/utils.js";import C from"../../../2d/arcade/callExpressionWithFeature.js";import{transparentUnit as O}from"./constants.js";import{perObjectElevationAligner as j}from"./ElevationAligners.js";import{SymbolUpdateType as I,elevationModeChangeUpdateType as T,needsElevationUpdates2D as E}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as U}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as D}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as F}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as A}from"./graphicUtils.js";import{ApplyRendererDiffResult as L}from"./interfaces.js";import{namedAnchorToHUDMaterialAnchorPos as G}from"./placementUtils.js";import{placePointOnGeometry as V,createStageObject as H,extendPointGraphicElevationContext as k}from"./pointUtils.js";import{initFastSymbolUpdatesState as B,updateFastSymbolUpdatesState as N,evaluateModelTransformScale as W,ConvertOptions as $}from"../support/FastSymbolUpdates.js";import{createTexture as q,requiresHalfTexelOffset as J,defaultSymbolSizeRatio as Z,defaultTexSize as K}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as Q}from"../../terrain/OverlayRenderer.js";import{createPointGeometry as X}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as Y}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as ee}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as te}from"../../webgl-engine/materials/HUDMaterial.js";const re=f(0,0,1),ie=16,se=1.5,oe=Z,ae=[oe/2,oe/2,1-oe/2,1-oe/2],ne=[K*oe,K*oe];class le extends F{getCachedSize(){return{size:this._getIconSize()}}constructor(e,t,r,i){super(e,t,r,i),this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=M(this.symbolLayer),i=u(r);i&&"application/json"===i.mediaType?await this._prepareResourcesCIM(t,JSON.parse(i.data),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=A(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?c(e.size):ie);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e){let t=this._cimData;if(t&&t.symbol||this.logger.error("Can't create texture, CIM data is undefined"),t.primitiveOverrides){t=s(t);const r=t.primitiveOverrides;v.evaluateOverrides(r,e,this._arcadeInfo.geometryType,null,null),v.applyOverrides(t.symbol,r)}const r=m(JSON.stringify(t));let i=this._cimSymbolTextures.get(r);if(i)return i;const o=this._context.sharedResources.cimSymbolRasterizer,a=this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null;a&&v.applyDictionaryTextOverrides(t.symbol,e,a,null);const n=null!=this._cimScaleFactorOrFunction?P(this._cimScaleFactorOrFunction,e):1;1!==n&&t.symbol&&z(t.symbol,n,!0);const l=S.getEnvelope(t,null,o.resourceManager);if(l&&l.width&&l.height){const e=l.x+l.width/2,r=l.y+l.height/2,s=o.rasterize({type:"cim",data:t},l.width,l.height,e,r,1,"esriGeometryPoint"),a=new w({x:-l.x/l.width-.5,y:(l.height+l.y)/l.height-.5});this._cimMaterialParametersInfo.anchorPosition=this._getAnchorPos("relative",a),i=new ee(s,{width:s?.width??1,height:s?.height??1})}else i=new ee(new ImageData(1,1),{width:1,height:1});return this._cimSymbolTextures.set(r,i),this._context.stage.add(i),i}_prepareMaterialParameters(){const e={anchorPosition:this._getAnchorPos(this.symbolLayer.anchor,this.symbolLayer.anchorPosition)},t=this.symbol;if(ce(t)){const{screenLength:r,minWorldLength:i,maxWorldLength:s}=t.verticalOffset;e.verticalOffset={screenLength:c(r),minWorldLength:i||0,maxWorldLength:null!=s?s:1/0}}return this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),e.occlusionTest=!0,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(he(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,(()=>q(t)));this._textureHandle=r,e.textureId=r.texture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=J(t),e.distanceFieldBoundingBox=ae;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/oe,this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesHref(e,r,s){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),a=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await t(this._context.sharedResources.textures.fromUrl(r,a,{signal:s}));if(!1===l.ok){n(l.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${r})`)}this._textureHandle=l.value;const c=l.value.texture;this._size=this._computeSizeFromTexture(c,o),e.textureId=c.id}this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesCIM(e,t,r){if(this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;l(r),this._context.sharedResources.cimSymbolRasterizer||(this._context.sharedResources.cimSymbolRasterizer=new e(this._context.renderCoordsHelper.spatialReference))}const i=this._context.sharedResources.cimSymbolRasterizer,s=[],o=t,a=o?.symbol;S.fetchResources(a,i.resourceManager,s,r),S.fetchFonts(a,i.resourceManager,s);const n=this._context.layer.fields?this._context.layer.fields.map((e=>e.toJSON())):[],c=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:c,fields:n,geometryType:"esriGeometryPoint"},o?.primitiveOverrides&&s.push(v.createRenderExpressions(o.primitiveOverrides,this._arcadeInfo)),s.length>0&&(await Promise.all(s),l(r)),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(e.scaleExpression){const t=e.scaleExpression,r=await b(t,this._context.layer.spatialReference,n);this._cimScaleFactorOrFunction=(e,t,i)=>{const s=C(r,e,{$view:i},"esriGeometryPoint",t);return null!==s?s:1}}}l(r),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return this.symbolLayer.resource&&this.symbolLayer.resource.href?null:this.symbolLayer.resource&&this.symbolLayer.resource.primitive||R}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline?.size)return Math.max(c(t.outline.size),0);return e=he(this._getPrimitive())?se:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,i=r?.outline?.color;if(null!=i){const r=e.toUnitRGB(i),s=i.a*t;return[r[0],r[1],r[2],s]}return[0,0,0,0]}_getFillColor(){if(he(this._getPrimitive()))return O;const e=null==this._getPrimitive(),t=this.symbolLayer?.material?.color;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}_getAnchorPos(e,t){return"relative"===e?d((t.x||0)+.5,.5-(t.y||0)):e in G?G[e]:G.center}_createMaterialAndAddToStage(e,t){if(this._cimData){this._fastUpdates=null;let r=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;return r||(r=new te(e),this._cimSymbolMaterials.set(e.textureId??0,r),t.add(r)),r}return this._fastUpdates=B(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),this._materials[0]=new te(e),t.add(this._materials[0]),this._materials[0]}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial((e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})})),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=o(this._patchTask),this._forEachMaterial((e=>this._context.stage.remove(e))),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach((e=>this._context.stage.remove(e))),this._cimSymbolTextures.clear(),this._textureHandle=a(this._textureHandle)}_getScaleFactor(e,t){if(this._drivenProperties.size&&e.size){for(let t=0;t<3;t++){const r=e.size[t];r&&"symbol-value"!==r&&"proportional"!==r&&(e.size[t]=c(r))}if("symbol-value"===e.size[0])return 1;if(isFinite(+e.size[0]))return+e.size[0]/t;if(isFinite(+e.size[2]))return+e.size[2]/t}return 1}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let r,i=[0,0];if(this._cimData){if(!this._cimData.symbol)return null;const e=this._generateTextureCIM(t),s={textureId:e.id,...this._cimMaterialParametersInfo};r=this._createMaterialAndAddToStage(s,this._context.stage);const o=window.devicePixelRatio||1;i=[e.parameters.width/o,e.parameters.height/o]}else i=this._size,r=this._materials[0];const s=V(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const o=e.renderingInfo,a=this._getVertexOpacityAndColor(o);let n=1;if(!this._fastUpdates?.visualVariables.size){const e=i[0]>i[1]?i[0]:i[1];n=this._getScaleFactor(o,e)}n*=this._symbolTextureRatio;const l=d(i[0]*n,i[1]*n),c=this.setGraphicElevationContext(t);return this.ensureDrapedStatus("on-the-ground"===c.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,s,r,a,l,e.layer.uid):this._createAs3DShape(t,s,r,a,l,c,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial((r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})}))}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=T(le.elevationModeChangeTypes,r,i);if(s!==I.UPDATE)return s;const o=E(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>o))}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial((e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return L.RecreateSymbol;if(!N(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return L.RecreateSymbol;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return L.FastUpdate}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),"partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchResource(e,t)}_preparePatchResource(e,s){if(!s.resource||"partial"!==s.resource.type)return;const c=s.resource.diff;if("complete"!==c?.href?.type)return;const h=c.href.newValue,{textures:m}=this._context.sharedResources;if(null==h||null==m)return;const u=this._getIconSize(),d=u*this._context.graphicsCoreOwner.view.state.pixelRatio;e.symbolLayerStatePatches.push((()=>{this._patchTask=o(this._patchTask),this._patchTask=r((e=>this._context.schedule((async(e,r)=>{const s=await t(m.fromUrl(h,d,{signal:r}));l(r);const o=!s.ok;if(o&&n(s.error),this._textureHandle=a(this._textureHandle),this._patchTask=null,o){this._forEachMaterial((e=>{e.visible=!1,e.setParameters({textureId:null})}));const e=`Failed to load (Request for icon resource failed: ${h})`;return void this.logger.error(new i("graphics3diconsymbollayer:request-failed",e))}this._textureHandle=s.value;const c=s.value.texture;this._size=this._computeSizeFromTexture(c,u),this._forEachMaterial((e=>{e.setParameters({textureId:c.id}),e.visible=!0}))}),e)))})),delete c.href}_defaultElevationInfoNoZ(){return me}_createAs3DShape(e,t,r,i,s,o,a){const n=this.getFastUpdateAttrValues(e),l=this._context.layer.uid,c=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:a,layerUid:l}),h=X(r,re,null,i,s,ue,null,n,c),m=H(this._context,t,h,o,a);if(null==m)return null;const u=new D(this,m.object,[h],null,null,j,o);return u.alignedSampledElevation=m.sampledElevation,u.needsElevationUpdates=E(o.mode)||"absolute-height"===o.mode,u.getScreenSize=this._createScreenSizeGetter(s,n),u.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(u.getScreenSize(),1,e),k(u,t,this._context.elevationProvider),u}_createAsOverlay(e,t,r,i,s,o){r.renderPriority=this._renderPriority;const a=_();g(t,a,this._context.overlaySR),a[2]=Q;const n=this._context.clippingExtent;if(null!=n&&!x(n,a))return null;const l=this.getFastUpdateAttrValues(e),c=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:e.uid,layerUid:this._context.layer.uid}),h=X(r,re,a,i,s,null,null,l,c),m=new Y(h,{layerUid:o,graphicUid:e.uid}),u=new U(this,[m],null,this._context.drapeSourceRenderer);return u.getScreenSize=this._createScreenSizeGetter(s,l),u.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(u.getScreenSize(),1,e),u}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=p())=>{const[o,a]=W(de,this._fastUpdates.materialParameters,t);return e[0]=o*i+r,e[1]=a*s+r,e}}const i=e[0]/this._symbolTextureRatio+r,s=e[1]/this._symbolTextureRatio+r;return(e=p())=>(e[0]=i,e[1]=s,e)}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=f(e,e,e),r=h(1),i=e*r,s=f(i,i,i);return new $({size:!0,color:!0,rotation:!0,opacity:!1},t,s,r)}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(e)}_computeSizeFromTexture({parameters:e},t){const r=(e.width??1)/(e.height??1);return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}test(){return{...super.test(),material:this._materials[0]}}}function ce(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function he(e){return null!=e&&("cross"===e||"x"===e)}le.PRIMITIVE_SIZE=ne,le.elevationModeChangeTypes={definedChanged:I.UPDATE,staysOnTheGround:I.NONE,onTheGroundChanged:I.RECREATE};const me={mode:"relative-to-ground",offset:0},ue=y(0,0,0,1),de=_();export{le as Graphics3DIconSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import{result as t,createTask as r}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import{clone as s}from"../../../../core/lang.js";import{abortMaybe as o,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAbortError as n,throwIfAborted as l}from"../../../../core/promiseUtils.js";import{pt2px as c,px2pt as h}from"../../../../core/screenUtils.js";import{numericHash as m}from"../../../../core/string.js";import{dataComponents as u}from"../../../../core/urlUtils.js";import{fromValues as d,create as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as _,fromValues as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as y}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectPointToVector as g}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as x}from"../../../../geometry/support/aaBoundingBox.js";import{createRendererExpression as b}from"../../../../support/arcadeOnDemand.js";import{CIMSymbolHelper as S}from"../../../../symbols/cim/CIMSymbolHelper.js";import{OverrideHelper as v}from"../../../../symbols/cim/OverrideHelper.js";import{evaluateValueOrFunction as P}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as z}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultPrimitive as R}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{Symbol3DAnchorPosition2D as M}from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as C}from"../../../../symbols/support/utils.js";import w from"../../../2d/arcade/callExpressionWithFeature.js";import{transparentUnit as I}from"./constants.js";import{perObjectElevationAligner as O}from"./ElevationAligners.js";import{SymbolUpdateType as j,elevationModeChangeUpdateType as T,needsElevationUpdates2D as E}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as U}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as D}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as F}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as A}from"./graphicUtils.js";import{ApplyRendererDiffResult as L}from"./interfaces.js";import{namedAnchorToHUDMaterialAnchorPos as G}from"./placementUtils.js";import{placePointOnGeometry as V,createStageObject as H,extendPointGraphicElevationContext as k}from"./pointUtils.js";import{initFastSymbolUpdatesState as B,updateFastSymbolUpdatesState as N,evaluateModelTransformScale as W,ConvertOptions as $}from"../support/FastSymbolUpdates.js";import{createTexture as q,requiresHalfTexelOffset as J,defaultSymbolSizeRatio as Z,defaultTexSize as K}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as Q}from"../../terrain/OverlayRenderer.js";import{createPointGeometry as X}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as Y}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as ee}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as te}from"../../webgl-engine/materials/HUDMaterial.js";const re=f(0,0,1),ie=16,se=1.5,oe=Z,ae=[oe/2,oe/2,1-oe/2,1-oe/2],ne=[K*oe,K*oe];class le extends F{getCachedSize(){return{size:this._getIconSize()}}constructor(e,t,r,i){super(e,t,r,i),this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=C(this.symbolLayer),i=this._getCIMResource(r);null!=i?await this._prepareResourcesCIM(t,JSON.parse(i),e):await this._prepareResourcesHref(t,r,e)}}_getCIMResource(e){const t=u(e);return"application/json"===t?.mediaType?t.data:void 0}_validateOrThrow(){if(this._drivenProperties.size)return;const e=A(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?c(e.size):ie);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e){let t=this._cimData;if(t&&t.symbol||this.logger.error("Can't create texture, CIM data is undefined"),t.primitiveOverrides){t=s(t);const r=t.primitiveOverrides;v.evaluateOverrides(r,e,this._arcadeInfo.geometryType,null,null),v.applyOverrides(t.symbol,r)}const r=m(JSON.stringify(t));let i=this._cimSymbolTextures.get(r);if(i)return i;const o=this._context.sharedResources.cimSymbolRasterizer,a=this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null;a&&v.applyDictionaryTextOverrides(t.symbol,e,a,null);const n=null!=this._cimScaleFactorOrFunction?P(this._cimScaleFactorOrFunction,e):1;1!==n&&t.symbol&&z(t.symbol,n,!0);const l=S.getEnvelope(t,null,o.resourceManager);if(l&&l.width&&l.height){const e=l.x+l.width/2,r=l.y+l.height/2,s=o.rasterize({type:"cim",data:t},l.width,l.height,e,r,1,"esriGeometryPoint"),a=new M({x:-l.x/l.width-.5,y:(l.height+l.y)/l.height-.5});this._cimMaterialParametersInfo.anchorPosition=this._getAnchorPos("relative",a),i=new ee(s,{width:s?.width??1,height:s?.height??1})}else i=new ee(new ImageData(1,1),{width:1,height:1});return this._cimSymbolTextures.set(r,i),this._context.stage.add(i),i}_prepareMaterialParameters(){const e={anchorPosition:this._getAnchorPos(this.symbolLayer.anchor,this.symbolLayer.anchorPosition)},t=this.symbol;if(ce(t)){const{screenLength:r,minWorldLength:i,maxWorldLength:s}=t.verticalOffset;e.verticalOffset={screenLength:c(r),minWorldLength:i||0,maxWorldLength:null!=s?s:1/0}}return this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),e.occlusionTest=!0,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(he(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,(()=>q(t)));this._textureHandle=r,e.textureId=r.texture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=J(t),e.distanceFieldBoundingBox=ae;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/oe,this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesHref(e,r,s){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),a=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await t(this._context.sharedResources.textures.fromUrl(r,a,{signal:s}));if(!1===l.ok){n(l.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${r})`)}this._textureHandle=l.value;const c=l.value.texture;this._size=this._computeSizeFromTexture(c,o),e.textureId=c.id}this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesCIM(e,t,r){if(this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;l(r),this._context.sharedResources.cimSymbolRasterizer||(this._context.sharedResources.cimSymbolRasterizer=new e(this._context.renderCoordsHelper.spatialReference))}const i=this._context.sharedResources.cimSymbolRasterizer,s=[],o=t,a=o?.symbol;S.fetchResources(a,i.resourceManager,s,r),S.fetchFonts(a,i.resourceManager,s);const n=this._context.layer.fields?this._context.layer.fields.map((e=>e.toJSON())):[],c=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:c,fields:n,geometryType:"esriGeometryPoint"},o?.primitiveOverrides&&s.push(v.createRenderExpressions(o.primitiveOverrides,this._arcadeInfo)),s.length>0&&(await Promise.all(s),l(r)),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(e.scaleExpression){const t=e.scaleExpression,r=await b(t,this._context.layer.spatialReference,n);this._cimScaleFactorOrFunction=(e,t,i)=>{const s=w(r,e,{$view:i},"esriGeometryPoint",t);return null!==s?s:1}}}l(r),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return this.symbolLayer.resource&&this.symbolLayer.resource.href?null:this.symbolLayer.resource&&this.symbolLayer.resource.primitive||R}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline?.size)return Math.max(c(t.outline.size),0);return e=he(this._getPrimitive())?se:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,i=r?.outline?.color;if(null!=i){const r=e.toUnitRGB(i),s=i.a*t;return[r[0],r[1],r[2],s]}return[0,0,0,0]}_getFillColor(){if(he(this._getPrimitive()))return I;const e=null==this._getPrimitive(),t=this.symbolLayer?.material?.color;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}_getAnchorPos(e,t){return"relative"===e?d((t.x||0)+.5,.5-(t.y||0)):e in G?G[e]:G.center}_createMaterialAndAddToStage(e,t){if(this._cimData){this._fastUpdates=null;let r=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;return r||(r=new te(e),this._cimSymbolMaterials.set(e.textureId??0,r),t.add(r)),r}return this._fastUpdates=B(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),this._materials[0]=new te(e),t.add(this._materials[0]),this._materials[0]}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial((e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})})),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=o(this._patchTask),this._forEachMaterial((e=>this._context.stage.remove(e))),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach((e=>this._context.stage.remove(e))),this._cimSymbolTextures.clear(),this._textureHandle=a(this._textureHandle)}_getScaleFactor(e,t){if(this._drivenProperties.size&&e.size){for(let t=0;t<3;t++){const r=e.size[t];r&&"symbol-value"!==r&&"proportional"!==r&&(e.size[t]=c(r))}if("symbol-value"===e.size[0])return 1;if(isFinite(+e.size[0]))return+e.size[0]/t;if(isFinite(+e.size[2]))return+e.size[2]/t}return 1}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let r,i=[0,0];if(this._cimData){if(!this._cimData.symbol)return null;const e=this._generateTextureCIM(t),s={textureId:e.id,...this._cimMaterialParametersInfo};r=this._createMaterialAndAddToStage(s,this._context.stage);const o=window.devicePixelRatio||1;i=[e.parameters.width/o,e.parameters.height/o]}else i=this._size,r=this._materials[0];const s=V(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const o=e.renderingInfo,a=this._getVertexOpacityAndColor(o);let n=1;if(!this._fastUpdates?.visualVariables.size){const e=i[0]>i[1]?i[0]:i[1];n=this._getScaleFactor(o,e)}n*=this._symbolTextureRatio;const l=d(i[0]*n,i[1]*n),c=this.setGraphicElevationContext(t);return this.ensureDrapedStatus("on-the-ground"===c.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,s,r,a,l,e.layer.uid):this._createAs3DShape(t,s,r,a,l,c,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial((r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})}))}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=T(le.elevationModeChangeTypes,r,i);if(s!==j.UPDATE)return s;const o=E(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>o))}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial((e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return L.RecreateSymbol;if(!N(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return L.RecreateSymbol;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return L.FastUpdate}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),"partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchResource(e,t)}_preparePatchResource(e,s){if(!s.resource||"partial"!==s.resource.type)return;const c=s.resource.diff;if("complete"!==c?.href?.type)return;const h=c.href.newValue,{textures:m}=this._context.sharedResources;if(null==h||null==m||null!=this._getCIMResource(h))return;const u=this._getIconSize(),d=u*this._context.graphicsCoreOwner.view.state.pixelRatio;e.symbolLayerStatePatches.push((()=>{this._patchTask=o(this._patchTask),this._patchTask=r((e=>this._context.schedule((async(e,r)=>{const s=await t(m.fromUrl(h,d,{signal:r}));l(r);const o=!s.ok;if(o&&n(s.error),this._textureHandle=a(this._textureHandle),this._patchTask=null,o){this._forEachMaterial((e=>{e.visible=!1,e.setParameters({textureId:null})}));const e=`Failed to load (Request for icon resource failed: ${h})`;return void this.logger.error(new i("graphics3diconsymbollayer:request-failed",e))}this._textureHandle=s.value;const c=s.value.texture;this._size=this._computeSizeFromTexture(c,u),this._forEachMaterial((e=>{e.setParameters({textureId:c.id}),e.visible=!0}))}),e)))})),delete c.href}_defaultElevationInfoNoZ(){return me}_createAs3DShape(e,t,r,i,s,o,a){const n=this.getFastUpdateAttrValues(e),l=this._context.layer.uid,c=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:a,layerUid:l}),h=X(r,re,null,i,s,ue,null,n,c),m=H(this._context,t,h,o,a);if(null==m)return null;const u=new D(this,m.object,[h],null,null,O,o);return u.alignedSampledElevation=m.sampledElevation,u.needsElevationUpdates=E(o.mode)||"absolute-height"===o.mode,u.getScreenSize=this._createScreenSizeGetter(s,n),u.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(u.getScreenSize(),1,e),k(u,t,this._context.elevationProvider),u}_createAsOverlay(e,t,r,i,s,o){r.renderPriority=this._renderPriority;const a=_();g(t,a,this._context.overlaySR),a[2]=Q;const n=this._context.clippingExtent;if(null!=n&&!x(n,a))return null;const l=this.getFastUpdateAttrValues(e),c=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:e.uid,layerUid:this._context.layer.uid}),h=X(r,re,a,i,s,null,null,l,c),m=new Y(h,{layerUid:o,graphicUid:e.uid}),u=new U(this,[m],null,this._context.drapeSourceRenderer);return u.getScreenSize=this._createScreenSizeGetter(s,l),u.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(u.getScreenSize(),1,e),u}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=p())=>{const[o,a]=W(de,this._fastUpdates.materialParameters,t);return e[0]=o*i+r,e[1]=a*s+r,e}}const i=e[0]/this._symbolTextureRatio+r,s=e[1]/this._symbolTextureRatio+r;return(e=p())=>(e[0]=i,e[1]=s,e)}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=f(e,e,e),r=h(1),i=e*r,s=f(i,i,i);return new $({size:!0,color:!0,rotation:!0,opacity:!1},t,s,r)}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(e)}_computeSizeFromTexture({parameters:e},t){const r=(e.width??1)/(e.height??1);return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}test(){return{...super.test(),material:this._materials[0]}}}function ce(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function he(e){return null!=e&&("cross"===e||"x"===e)}le.PRIMITIVE_SIZE=ne,le.elevationModeChangeTypes={definedChanged:j.UPDATE,staysOnTheGround:j.NONE,onTheGroundChanged:j.RECREATE};const me={mode:"relative-to-ground",offset:0},ue=y(0,0,0,1),de=_();export{le as Graphics3DIconSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import{getMetersPerUnitForSR as t}from"../../../../core/unitUtils.js";import{e as r}from"../../../../chunks/earcut.js";import{set as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as i,create as s}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{
|
|
5
|
+
import e from"../../../../Color.js";import{getMetersPerUnitForSR as t}from"../../../../core/unitUtils.js";import{e as r}from"../../../../chunks/earcut.js";import{set as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as i,create as s}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{b as n}from"../../../../chunks/vec42.js";import{toRadian as a}from"../../../../core/libs/gl-matrix-2/math/common.js";import{create as l,empty as c,expandWithBuffer as h,intersectsClippingArea as m,expandWithAABB as d}from"../../../../geometry/support/aaBoundingBox.js";import{create as p,empty as u,expandPointInPlace as g}from"../../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as y,doubleSubArray as f}from"../../../../geometry/support/DoubleArray.js";import{perVertexElevationAligner as _}from"./ElevationAligners.js";import{SymbolUpdateType as x,elevationModeChangeUpdateType as v,needsElevationUpdates2D as b}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as C}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as D}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as j}from"./Graphics3DSymbolLayer.js";import{geometryAsPolygon as S,createWaterGeometry as w,PolygonCreationDataBase as G}from"./polygonUtils.js";import{geometryToRenderInfo as A,geometryToRenderInfoDraped as E}from"../../support/renderInfoUtils/polygon.js";import{Object3D as L}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as O}from"../../webgl-engine/lib/RenderGeometry.js";import{WaterMaterialParameters as P,WaterMaterial as T}from"../../webgl-engine/materials/WaterMaterial.js";import{wavePresets as R}from"../../webgl-engine/materials/internal/waterMaterialUtils.js";const U=["polyline","polygon","extent"];class I extends j{constructor(e,t,r,o){super(e,t,r,o)}async doLoad(){}destroy(){super.destroy(),this._context.stage.remove(this._materials[0]),this._materials.length=0}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,U,this.symbolLayer.type))return null;const r=this.setGraphicElevationContext(t);return this.ensureDrapedStatus("on-the-ground"===r.mode),this.ensureMaterial(),this.draped?this._createAsOverlay(t):this._createAs3DShape(t,r,t.uid)}ensureMaterial(){if(this._materials[0])return;const t=new P,r=this.symbolLayer.color;null!=r&&(t.color=e.toUnitRGBA(r));const o=this._getCombinedOpacity(r,{hasIntrinsicColor:!0});t.color=[t.color[0],t.color[1],t.color[2],o],t.transparent=o<1||this.needsDrivenTransparentPass,t.waveDirection=null!=this.symbolLayer.waveDirection?I.headingVectorFromAngle(this.symbolLayer.waveDirection):i(0,0);const s=this.symbolLayer.waveStrength+"-"+this.symbolLayer.waterbodySize,n=R[s];t.waveStrength=n.waveStrength,t.waveTextureRepeat=n.textureRepeat,t.waveVelocity=n.waveVelocity,t.flowStrength=n.perturbationStrength,t.hasSlicePlane=this._context.slicePlaneEnabled,t.draped=this.draped,this._materials[0]=new T(t),this._context.stage.add(this._materials[0])}layerOpacityChanged(){if(null==this._materials[0])return;const e=this._materials[0].parameters.color,t=this._getCombinedOpacity(this.symbolLayer.color,{hasIntrinsicColor:!0}),r=t<1||this.needsDrivenTransparentPass;this._materials[0].setParameters({color:[e[0],e[1],e[2],t],transparent:r})}layerElevationInfoChanged(e,t,r){const o=this._elevationContext.mode,i=v(I.elevationModeChangeTypes,r,o);if(i!==x.UPDATE)return i;const s=b(o);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>s))}slicePlaneEnabledChanged(){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return!0}_createAs3DShape(e,t,r){const o=S(e.geometry);if(null==o)return null;const i=A(o,this._context.elevationProvider,this._context.renderCoordsHelper,t),s=i.position.length/3,n=y(2*s);this._createUVCoordsFromVertices(n,i.mapPositions,s,this._context.elevationProvider.spatialReference);const a=new z(i,n,this._context.layer.uid,e.uid);if(a.objectAndLayerIdColor=this._context.stage.renderView?.getObjectAndLayerIdColor(a),this._create3DShapeGeometries(a),this._logGeometryCreationWarnings(a.renderData,o.rings,"rings","WaterSymbol3DLayer"),0===a.outGeometries.length)return null;const l=new L({geometries:a.outGeometries,castShadow:!1,layerUid:this._context.layer.uid,graphicUid:r}),c=new D(this,l,a.outGeometries,null,null,_,t);return c.alignedSampledElevation=a.renderData.sampledElevation,c.needsElevationUpdates=b(t.mode),c}_createUVCoordsFromVertices(e,r,i,s){const a=t(s);u(B);for(let t=0;t<i;t++)o(M,r[3*t],r[3*t+1]),g(B,M);n(B,B,a);const l=B[0]%I.unitSizeOfTexture,c=B[1]%I.unitSizeOfTexture;V[0]=B[0]-l,V[1]=B[1]-c;for(let t=0;t<i;t++)e[2*t]=(r[3*t]*a-V[0])/I.unitSizeOfTexture,e[2*t+1]=(r[3*t+1]*a-V[1])/I.unitSizeOfTexture}_create3DShapeGeometries(e){const t=e.renderData.polygons,o=e.uvCoords;for(const{count:i,index:s,position:n,mapPositions:a,holeIndices:l}of t){if(null!=this._context.clippingExtent&&(c(W),h(W,a),!m(W,this._context.clippingExtent)))continue;const t=r(a,l,3);if(0===t.length)continue;const d=f(o,2*s,2*i),p=w({material:this._materials[0],indices:t,mapPositions:a,attributeData:{position:n,uv0:d}},e.objectAndLayerIdColor);e.outGeometries.push(p)}}_createAsOverlay(e){const t=S(e.geometry);if(null==t)return null;this._materials[0].renderPriority=this._renderPriority;const r=E(t,this._context.overlaySR),o=r.position.length/3,i=y(2*o);this._createUVCoordsFromVertices(i,r.position,o,this._context.overlaySR);const s=new F(r,i,this._context.layer.uid,e.uid);return s.objectAndLayerIdColor=this._context.stage.renderView?.getObjectAndLayerIdColor(s),s.outBoundingBox=c(),this._createAsOverlayWater(s),this._logGeometryCreationWarnings(s.renderData,t.rings,"rings","WaterSymbol3DLayer"),0===s.outGeometries.length?null:new C(this,s.outGeometries,s.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayWater(e){const t=e.uvCoords,o=e.renderData.polygons;for(const{position:i,holeIndices:s,index:n,count:a}of o){if(c(W),h(W,i),!m(W,this._context.clippingExtent))continue;d(e.outBoundingBox,W);const o=r(i,s,3);if(0===o.length)continue;const l=f(t,2*n,2*a),p=w({material:this._materials[0],indices:o,attributeData:{position:i,uv0:l}},e.objectAndLayerIdColor);e.outGeometries.push(new O(p,e))}}static headingVectorFromAngle(e){const t=s(),r=a(e);return t[0]=Math.sin(r),t[1]=Math.cos(r),t}test(){return{...super.test(),create3DShape:e=>this._createAs3DShape(e.graphic,e.elevationContext,e.graphicUid),ensureMaterial:()=>this.ensureMaterial()}}}I.unitSizeOfTexture=100,I.elevationModeChangeTypes={definedChanged:x.RECREATE,staysOnTheGround:x.NONE,onTheGroundChanged:x.RECREATE};const V=s(),B=p(),M=s(),W=l();class z extends G{constructor(e,t,r,o){super(e,r,o),this.uvCoords=t}}class F extends G{constructor(e,t,r,o){super(e,r,o),this.uvCoords=t}}export{I as Graphics3DWaterSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{adjustStaticAGOUrl as e}from"../../../../core/devEnvironmentUtils.js";import{normalFromMat4 as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as i}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{e as n,f as l,
|
|
5
|
+
import{adjustStaticAGOUrl as e}from"../../../../core/devEnvironmentUtils.js";import{normalFromMat4 as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as i}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{e as n,f as l,D as a,l as u,n as c,m}from"../../../../chunks/vec32.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as d,expandWithVec3 as p}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as g}from"../../../../geometry/support/FloatArray.js";import{BufferViewVec4f as x,BufferViewVec4u8 as b,BufferViewVec4u16 as h,BufferViewVec3f as T,BufferViewVec3u8 as w,BufferViewVec3u16 as y}from"../../../../geometry/support/buffer/BufferView.js";import{a as v,b as R,s as j}from"../../../../chunks/vec3.js";import{t as M,s as B}from"../../../../chunks/vec4.js";import{n as S}from"../../../../chunks/vec2.js";import{c as F}from"../../../../chunks/vec33.js";import{c as A}from"../../../../chunks/vec43.js";import{DefaultLoadingContext as L}from"../../glTF/DefaultLoadingContext.js";import{loadGLTF as E}from"../../glTF/loader.js";import{convertPrimitiveToTriangles as O}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as I}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as C}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as k}from"./ProcessedObjectResource.js";import{load as N,processLoadResult as P}from"./wosrLoader.js";import{NormalType as U}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as D}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as V,DepthTestFunction as _,CullFaceOptions as H}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as q}from"../../webgl-engine/lib/Geometry.js";import{Texture as G}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as W}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as $}from"../../webgl-engine/materials/DefaultMaterial.js";import{colorGamma as z}from"../../webgl-engine/materials/DefaultMaterial_COLOR_GAMMA.js";import{defaultEsriSymbologyMRRFactors as K,defaultAdvancedMRRFactors as Q,useSchematicPBR as J,defaultSchematicMRRFactors as X}from"../../webgl-engine/materials/pbrUtils.js";async function Y(t,r){const o=Z(e(t));if("wosr"===o.fileType){const e=await(r.cache?r.cache.loadWOSR(o.url,r):N(o.url,r)),{engineResources:t,referenceBoundingBox:s}=P(e,r);return{lods:t,referenceBoundingBox:s,isEsriSymbolResource:!1,isWosr:!0}}const s=await(r.cache?r.cache.loadGLTF(o.url,r,!!r.usePBR):E(new L(r.streamDataRequester),o.url,r,r.usePBR)),i=s.model.meta?.ESRI_proxyEllipsoid,n=s.meta.isEsriSymbolResource&&null!=i&&"EsriRealisticTreesStyle"===s.meta.ESRI_webstyle;n&&!s.customMeta.esriTreeRendering&&(s.customMeta.esriTreeRendering=!0,ie(s,i));const l=!!r.usePBR,a=s.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:n,mrrFactors:[...K]}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:[...Q]},u={...r.materialParameters,treeRendering:n},{engineResources:c,referenceBoundingBox:m}=ee(s,a,u,r.skipHighLods&&null==o.specifiedLodIndex?{skipHighLods:!0}:{skipHighLods:!1,singleLodIndex:o.specifiedLodIndex});return{lods:c,referenceBoundingBox:m,isEsriSymbolResource:s.meta.isEsriSymbolResource,isWosr:!1}}function Z(e){const t=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(t)return{fileType:"gltf",url:t[1],specifiedLodIndex:null!=t[4]?Number(t[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function ee(e,t,r,o){const s=e.model,i=new Array,n=new Map,l=new Map,a=s.lods.length,u=d();return s.lods.forEach(((e,c)=>{const m=!0===o.skipHighLods&&(a>1&&0===c||a>3&&1===c)||!1===o.skipHighLods&&null!=o.singleLodIndex&&c!==o.singleLodIndex;if(m&&0!==c)return;const f=new k(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach((e=>{const o=m?new $({}):te(s,e,f,t,r,n,l),{geometry:i,vertexCount:a}=re(e,null!=o?o:new $({})),d=i.boundingInfo;null!=d&&0===c&&(p(u,d.bbMin),p(u,d.bbMax)),null!=o&&(f.stageResources.geometries.push(i),f.numberOfVertices+=a)})),m||i.push(f)})),{engineResources:i,referenceBoundingBox:u}}function te(e,t,r,o,s,n,l){const a=t.material+(t.attributes.normal?"_normal":"")+(t.attributes.color?"_color":"")+(t.attributes.texCoord0?"_texCoord0":"")+(t.attributes.tangent?"_tangent":""),u=e.materials.get(t.material),c=null!=t.attributes.texCoord0,m=null!=t.attributes.normal;if(null==u)return null;const f=se(u.alphaMode);if(!n.has(a)){if(c){const t=(t,r=!1)=>{if(null!=t&&!l.has(t)){const o=e.textures.get(t);if(null!=o){const e=o.data;l.set(t,new G(I(e)?e.data:e,{...o.parameters,preMultiplyAlpha:!I(e)&&r,encoding:I(e)&&null!=e.encoding?e.encoding:void 0}))}}};t(u.textureColor,f!==V.Opaque),t(u.textureNormal),t(u.textureOcclusion),t(u.textureEmissive),t(u.textureMetallicRoughness)}const r=u.color[0]**(1/z),d=u.color[1]**(1/z),p=u.color[2]**(1/z),g=u.emissiveFactor[0]**(1/z),x=u.emissiveFactor[1]**(1/z),b=u.emissiveFactor[2]**(1/z),h=null!=u.textureColor&&c?l.get(u.textureColor):null,T=J({normalTexture:u.textureNormal,metallicRoughnessTexture:u.textureMetallicRoughness,metallicFactor:u.metallicFactor,roughnessFactor:u.roughnessFactor,emissiveTexture:u.textureEmissive,emissiveFactor:u.emissiveFactor,occlusionTexture:u.textureOcclusion}),w=null!=u.normalTextureTransform?.scale?u.normalTextureTransform?.scale:i;n.set(a,new $({...o,transparent:f===V.Blend,customDepthTest:_.Lequal,textureAlphaMode:f,textureAlphaCutoff:u.alphaCutoff,diffuse:[r,d,p],ambient:[r,d,p],opacity:u.opacity,doubleSided:u.doubleSided,doubleSidedType:"winding-order",cullFace:u.doubleSided?H.None:H.Back,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:m?U.Attribute:U.ScreenDerivative,castShadows:!0,receiveShadows:u.receiveShadows,receiveAmbientOcclusion:u.receiveAmbientOcclustion,textureId:null!=h?h.id:void 0,colorMixMode:u.colorMixMode,normalTextureId:null!=u.textureNormal&&c?l.get(u.textureNormal).id:void 0,textureAlphaPremultiplied:null!=h&&!!h.parameters.preMultiplyAlpha,occlusionTextureId:null!=u.textureOcclusion&&c?l.get(u.textureOcclusion).id:void 0,emissiveTextureId:null!=u.textureEmissive&&c?l.get(u.textureEmissive).id:void 0,metallicRoughnessTextureId:null!=u.textureMetallicRoughness&&c?l.get(u.textureMetallicRoughness).id:void 0,emissiveFactor:[g,x,b],mrrFactors:T?[...X]:[u.metallicFactor,u.roughnessFactor,o.mrrFactors[2]],isSchematic:T,colorTextureTransformMatrix:C(u.colorTextureTransform),normalTextureTransformMatrix:C(u.normalTextureTransform),scale:[w[0],w[1]],occlusionTextureTransformMatrix:C(u.occlusionTextureTransform),emissiveTextureTransformMatrix:C(u.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:C(u.metallicRoughnessTextureTransform),...s}))}const d=n.get(a);if(r.stageResources.materials.push(d),c){const e=e=>{null!=e&&r.stageResources.textures.push(l.get(e))};e(u.textureColor),e(u.textureNormal),e(u.textureOcclusion),e(u.textureEmissive),e(u.textureMetallicRoughness)}return d}function re(e,r){const o=e.attributes.position.count,s=O(e.indices||o,e.primitiveType),i=g(3*o),{typedBuffer:n,typedBufferStride:l}=e.attributes.position;v(i,n,e.transform,3,l);const a=[[W.POSITION,new D(i,s,3,!0)]];if(null!=e.attributes.normal){const r=g(3*o),{typedBuffer:i,typedBufferStride:n}=e.attributes.normal;t(oe,e.transform),R(r,i,oe,3,n),a.push([W.NORMAL,new D(r,s,3,!0)])}if(null!=e.attributes.tangent){const r=g(4*o),{typedBuffer:i,typedBufferStride:n}=e.attributes.tangent;t(oe,e.transform),M(r,i,oe,4,n),a.push([W.TANGENT,new D(r,s,4,!0)])}if(null!=e.attributes.texCoord0){const t=g(2*o),{typedBuffer:r,typedBufferStride:i}=e.attributes.texCoord0;S(t,r,2,i),a.push([W.UV0,new D(t,s,2,!0)])}if(null!=e.attributes.color){const t=new Uint8Array(4*o);4===e.attributes.color.elementCount?e.attributes.color instanceof x?B(t,e.attributes.color,255):e.attributes.color instanceof b?A(t,e.attributes.color):e.attributes.color instanceof h&&B(t,e.attributes.color,1/256):(t.fill(255),e.attributes.color instanceof T?j(t,e.attributes.color,255,4):e.attributes.color instanceof w?F(t,e.attributes.color.typedBuffer,4,e.attributes.color.typedBufferStride):e.attributes.color instanceof y&&j(t,e.attributes.color,1/256,4)),a.push([W.COLOR,new D(t,s,4,!0)])}return{geometry:new q(r,a),vertexCount:o}}const oe=r();function se(e){switch(e){case"BLEND":return V.Blend;case"MASK":return V.Mask;case"OPAQUE":case null:case void 0:return V.Opaque}}function ie(e,t){for(let r=0;r<e.model.lods.length;++r){const i=e.model.lods[r];for(const d of i.parts){const i=d.attributes.normal;if(null==i)return;const p=d.attributes.position,g=p.count,x=f(),h=f(),w=f(),y=new Uint8Array(4*g),v=new Float64Array(3*g),R=o(s(),d.transform);let j=0,M=0;for(let o=0;o<g;o++){p.getVec(o,h),i.getVec(o,x),n(h,h,d.transform),l(w,h,t.center),a(w,w,t.radius);const s=w[2],f=u(w),g=Math.min(.45+.55*f*f,1);a(w,w,t.radius),null!==R&&n(w,w,R),c(w,w),r+1!==e.model.lods.length&&e.model.lods.length>1&&m(w,w,x,s>-1?.2:Math.min(-4*s-3.8,1)),v[j]=w[0],v[j+1]=w[1],v[j+2]=w[2],j+=3,y[M]=255*g,y[M+1]=255*g,y[M+2]=255*g,y[M+3]=255,M+=4}d.attributes.normal=new T(v),d.attributes.color=new b(y)}}}export{Y as fetch,ee as gltfToEngineResources,Z as parseUrl};
|