@arcgis/core 4.34.0-next.34 → 4.34.0-next.35
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/Graphic.js +1 -1
- package/arcade/ArcadeDate.js +1 -1
- package/arcade/ArcadeModuleResolver.js +1 -1
- package/arcade/featureset/actions/GroupBy.js +1 -1
- package/arcade/functions/date.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{28e04ef3575f164f611a.js → 00870a35b254295bc408.js} +1 -1
- package/assets/esri/core/workers/chunks/017adbbb77c9c9b4d49f.js +1 -0
- package/assets/esri/core/workers/chunks/{b4b30a7f1b673461dc55.js → 0997e09fe5b0aba1f804.js} +1 -1
- package/assets/esri/core/workers/chunks/{9bc6d974b0fce9db64ef.js → 15a5a89cd228a9364332.js} +1 -1
- package/assets/esri/core/workers/chunks/{847455bf4fc33d6e6efc.js → 1dc410bc070cabb7198d.js} +1 -1
- package/assets/esri/core/workers/chunks/{94a3474e3f45efa4a4fe.js → 2c816d3a737e39e6eb84.js} +1 -1
- package/assets/esri/core/workers/chunks/2de11a8e5d426c381991.js +1 -0
- package/assets/esri/core/workers/chunks/3a7e43675163f7bed6ac.js +1 -0
- package/assets/esri/core/workers/chunks/40b0c5368b8322498189.js +1 -0
- package/assets/esri/core/workers/chunks/{4778acd0cfaf0cebeec7.js → 439128f23fa091633d2d.js} +1 -1
- package/assets/esri/core/workers/chunks/6000a302369799ea42a6.js +1 -0
- package/assets/esri/core/workers/chunks/{5d0c92aaa5891e6cb8f0.js → 641ca71d7c1a07bde66a.js} +1 -1
- package/assets/esri/core/workers/chunks/646227b500b92999f2c8.js +1 -0
- package/assets/esri/core/workers/chunks/{98f6d4ea026ed96fd3f3.js → 773feb0e0fad26df57ef.js} +1 -1
- package/assets/esri/core/workers/chunks/7b1d14a921d30c95d68b.js +1 -0
- package/assets/esri/core/workers/chunks/{b78d00c4e493086741e1.js → 7d25f57299c642e727a6.js} +1 -1
- package/assets/esri/core/workers/chunks/8b7f6f2d1692b6b6dbd5.js +1 -0
- package/assets/esri/core/workers/chunks/91d48c32bf11ad1405c8.js +1 -0
- package/assets/esri/core/workers/chunks/9228f760129e48585b54.js +1 -0
- package/assets/esri/core/workers/chunks/a36be186ad10200c420c.js +1 -0
- package/assets/esri/core/workers/chunks/aa12ba96fb8c91105473.js +1 -0
- package/assets/esri/core/workers/chunks/{ea240d9e594bfbd8af68.js → aaf696a1026de569c82d.js} +1 -1
- package/assets/esri/core/workers/chunks/b331543767c35e5edcc6.js +1 -0
- package/assets/esri/core/workers/chunks/{7d852617e91b51121ea7.js → ba29c535128c4e8ae2d3.js} +1 -1
- package/assets/esri/core/workers/chunks/bf60d4da0dff1e14da8e.js +1 -0
- package/assets/esri/core/workers/chunks/{39bff604d4b4a1295038.js → c038472cb7f60af9426e.js} +1 -1
- package/assets/esri/core/workers/chunks/{ca46f78aac1133d127fa.js → c1e5e2a6e7e2d7a1d63c.js} +1 -1
- package/assets/esri/core/workers/chunks/{a809042fdce7ced2a415.js → cc3ca1729af33688c1e3.js} +1 -1
- package/assets/esri/core/workers/chunks/cde79c3644166d4798a8.js +1 -0
- package/assets/esri/core/workers/chunks/{181f8bbe670b4468307a.js → ce8f0ed9179c0d314df8.js} +1 -1
- package/assets/esri/core/workers/chunks/{ac30cf2f9a94597f7665.js → d6b2ab614f308db50c4a.js} +2 -2
- package/assets/esri/core/workers/chunks/{abe2cdfc2eda46b00812.js → d9045b964f536695840b.js} +1 -1
- package/assets/esri/core/workers/chunks/dde6000aa2f69f6ecad0.js +1 -0
- package/assets/esri/core/workers/chunks/dec9656997683ef01ba6.js +1 -0
- package/assets/esri/core/workers/chunks/e18bb372457cedbf4f8c.js +1 -0
- package/assets/esri/core/workers/chunks/e892ed8b0b990d7eba28.js +1 -0
- package/assets/esri/core/workers/chunks/{dc5a8cf2a44a5ac201c5.js → ed05399f9a07fea66685.js} +1 -1
- package/config.js +1 -1
- package/core/BidiEngine.js +1 -1
- package/core/Promise.js +1 -1
- package/core/promiseUtils.js +1 -1
- package/core/sql/SqlInterval.js +1 -1
- package/core/sql/sqlDateParsingUtils.js +1 -1
- package/core/unitUtils.js +1 -1
- package/geometry/support/coordinateSystem.js +1 -1
- package/graphic/BuildingGraphicOrigin.d.ts +4 -0
- package/graphic/BuildingGraphicOrigin.js +5 -0
- package/graphic/CSVGraphicOrigin.d.ts +4 -0
- package/graphic/CSVGraphicOrigin.js +5 -0
- package/graphic/CatalogGraphicOrigin.d.ts +4 -0
- package/graphic/CatalogGraphicOrigin.js +5 -0
- package/graphic/FeatureGraphicOrigin.d.ts +4 -0
- package/graphic/FeatureGraphicOrigin.js +5 -0
- package/graphic/GeoJSONGraphicOrigin.d.ts +4 -0
- package/graphic/GeoJSONGraphicOrigin.js +5 -0
- package/graphic/GraphicOrigin.d.ts +4 -0
- package/graphic/GraphicOrigin.js +5 -0
- package/graphic/IntegratedMesh3DTilesGraphicOrigin.d.ts +4 -0
- package/graphic/IntegratedMesh3DTilesGraphicOrigin.js +5 -0
- package/graphic/IntegratedMeshGraphicOrigin.d.ts +4 -0
- package/graphic/IntegratedMeshGraphicOrigin.js +5 -0
- package/graphic/OGCFeatureGraphicOrigin.d.ts +4 -0
- package/graphic/OGCFeatureGraphicOrigin.js +5 -0
- package/graphic/PointCloudGraphicOrigin.d.ts +4 -0
- package/graphic/PointCloudGraphicOrigin.js +5 -0
- package/graphic/SceneGraphicOrigin.d.ts +4 -0
- package/graphic/SceneGraphicOrigin.js +5 -0
- package/graphic/StreamGraphicOrigin.d.ts +4 -0
- package/graphic/StreamGraphicOrigin.js +5 -0
- package/graphic/VectorTileGraphicOrigin.d.ts +4 -0
- package/graphic/VectorTileGraphicOrigin.js +5 -0
- package/graphic/VoxelGraphicOrigin.d.ts +4 -0
- package/graphic/VoxelGraphicOrigin.js +5 -0
- package/graphic/WFSGraphicOrigin.d.ts +4 -0
- package/graphic/WFSGraphicOrigin.js +5 -0
- package/graphic/graphicOriginUtils.js +5 -0
- package/graphic/graphicOrigins.d.ts +14 -0
- package/graphic/graphicOrigins.js +5 -0
- package/graphic/isBuildingGraphicOrigin.js +5 -0
- package/graphic/isCSVGraphicOrigin.js +5 -0
- package/graphic/isCatalogGraphicOrigin.js +5 -0
- package/graphic/isFeatureGraphicOrigin.js +5 -0
- package/graphic/isGeoJSONGraphicOrigin.js +5 -0
- package/graphic/isIntegratedMesh3DTilesGraphicOrigin.js +5 -0
- package/graphic/isIntegratedMeshGraphicOrigin.js +5 -0
- package/graphic/isOGCFeatureGraphicOrigin.js +5 -0
- package/graphic/isPointCloudGraphicOrigin.js +5 -0
- package/graphic/isSceneGraphicOrigin.js +5 -0
- package/graphic/isStreamGraphicOrigin.js +5 -0
- package/graphic/isVectorTileGraphicOrigin.js +5 -0
- package/graphic/isVoxelGraphicOrigin.js +5 -0
- package/graphic/isWFSGraphicOrigin.js +5 -0
- package/interfaces.d.ts +354 -13
- package/kernel.js +1 -1
- package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
- package/layers/support/Field.js +1 -1
- package/layers/support/featurePopupQueryUtils.js +1 -1
- package/layers/voxel/NCTimeParser.js +1 -1
- package/package.json +1 -1
- package/rest/knowledgeGraphService.js +1 -1
- package/smartMapping/statistics/support/utils.js +1 -1
- package/support/arcadeExpressionUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/support/svgUtils.js +1 -1
- package/views/2d/engine/vectorTiles/VectorTileFeatureIndex.js +1 -1
- package/views/2d/engine/webgl/FeatureDisplayList.js +1 -1
- package/views/2d/engine/webgl/Painter.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/segmentUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelTechnique.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/VectorTileLayerView2D.js +1 -1
- package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/CutFillVolumeMeasurementComputation.js +5 -0
- package/views/3d/analysis/VolumeMeasurement/CutFillVolumeMeasurementController.js +1 -1
- package/views/3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js +1 -1
- package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
- package/views/3d/layers/CSVLayerView3D.js +1 -1
- package/views/3d/layers/CatalogFootprintLayerView3D.js +1 -1
- package/views/3d/layers/FeatureLayerView3D.js +1 -1
- package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
- package/views/3d/layers/FlowSubView3D.js +1 -1
- package/views/3d/layers/GeoJSONLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
- package/views/3d/layers/OGCFeatureLayerView3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/SceneLayerView3D.js +1 -1
- package/views/3d/layers/StreamLayerView3D.js +1 -1
- package/views/3d/layers/WFSLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
- package/views/3d/layers/graphics/StreamController.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorkerHandle.js +1 -1
- package/views/3d/layers/graphics/pipeline/Tile3DManager.js +1 -1
- package/views/3d/layers/support/FeatureTileDescriptor.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3DContext.js +1 -1
- package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
- package/views/3d/layers/support/FeatureTileTree3D.js +1 -1
- package/views/3d/layers/support/FeatureTileTree3DDebugger.js +1 -1
- package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
- package/views/3d/layers/support/Tiles3DIntersectionHandler.js +1 -1
- package/views/3d/state/ConstraintsManager.js +1 -1
- package/views/3d/support/flow/geometryUtils.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/interactive/Tooltip.js +1 -1
- package/views/layers/FeatureLayerView.js +1 -1
- package/views/layers/support/popupUtils.js +1 -1
- package/widgets/Editor/UpdateFeaturesWorkflow.js +1 -1
- package/assets/esri/core/workers/chunks/07b2cc0f6b064277632f.js +0 -1
- package/assets/esri/core/workers/chunks/13f9e92e7e5d44d9f95c.js +0 -1
- package/assets/esri/core/workers/chunks/140efe4735605258ecc9.js +0 -1
- package/assets/esri/core/workers/chunks/2b76e716f478468b6798.js +0 -1
- package/assets/esri/core/workers/chunks/386ab72a45102c2d47f2.js +0 -1
- package/assets/esri/core/workers/chunks/3fb6146d914f9b410c2e.js +0 -1
- package/assets/esri/core/workers/chunks/432365fcd7becd508541.js +0 -1
- package/assets/esri/core/workers/chunks/439ce953a25b2776cb7f.js +0 -1
- package/assets/esri/core/workers/chunks/4c8d2334fcdb1354ff43.js +0 -1
- package/assets/esri/core/workers/chunks/5f321be63ed5447b04a1.js +0 -1
- package/assets/esri/core/workers/chunks/6006fbdb90c3bfc493a6.js +0 -1
- package/assets/esri/core/workers/chunks/700c641347853b1034d9.js +0 -1
- package/assets/esri/core/workers/chunks/7c35c61e3673cf94cdfd.js +0 -1
- package/assets/esri/core/workers/chunks/7c75876a0c6460585055.js +0 -1
- package/assets/esri/core/workers/chunks/949dc266ac6f3505d357.js +0 -1
- package/assets/esri/core/workers/chunks/a84af1b8b64b86b49bd3.js +0 -1
- package/assets/esri/core/workers/chunks/a9d83a442d8d7a376fc0.js +0 -1
- package/assets/esri/core/workers/chunks/ba1b21a90b257ac9a342.js +0 -1
- package/assets/esri/core/workers/chunks/f9ad37dfbe1d14c6a352.js +0 -1
package/views/3d/terrain/Tile.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{clamp as e}from"../../../core/mathUtils.js";import{abortMaybe as t}from"../../../core/maybe.js";import i from"../../../core/ObjectPool.js";import{d as s,k as n,e as r,g as a,f as l,l as o,c as h}from"../../../chunks/vec32.js";import{create as d,unitZ as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import{create as g,equals as p}from"../../../geometry/support/aaBoundingRect.js";import{c as f,a as _}from"../../../chunks/sphere.js";import{isGroupLayer as m}from"../../../layers/support/layerUtils.js";import{ElevationBounds as y}from"./ElevationBounds.js";import{ElevationTileAgent as v,isElevationTileAgent as M}from"./ElevationTileAgent.js";import{LayerClasses as A}from"./LayerClass.js";import{MapTileAgent as x,isMapTileAgent as D}from"./MapTileAgent.js";import{maxPatchTesselation as b}from"./TerrainConst.js";import{isVectorTile as L,isTileTexture as I,isRasterTile as j,isImageWithType as T}from"./TerrainData.js";import{weakAssert as C,isBlendableLayerView as B,oppositeCorner as U,internalAssert as S,enableTerrainInternalChecks as P,neighborEdgeIndices as w,oppositeEdge as E,neighborCornerIndices as R,almostEquals as q,enableWaterproofTests as V,isNorth as N,isSouth as O,isWest as k,isEast as G,isWestCorner as z,isNorthCorner as F}from"./terrainUtils.js";import{tileAgentDone as W}from"./TileAgent.js";import{TilePerLayerInfo as H}from"./TilePerLayerInfo.js";import{fallsWithinLayerView as J}from"./tileUtils.js";const X=.1;class Y{constructor(){this._lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this._dirty=!0,this._previouslyRendered=!1,this.extent=g(),this._elevationBoundsMin=NaN,this._elevationBoundsMax=0,this.layerInfo=[[],[]],this.extentInRadians=g(),this.centerAtSeaLevel=d(),this._center=[d(),f(),d()],this.up=u(),this._withinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=0,this._rasterTileMemory=0,this._vectorTileMemory=0,this._mapDataRefCount=0,this.screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0,this.onCompressionFinished=()=>{this.setPendingUpdate(16),this.setMemoryDirty()},this.extentMidX=0,this.extentMidY=0,this.distanceToPOI=-1,this._lastPOI=d(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0}get lij(){return this._lij}get spatialReference(){return this._surface.spatialReference??this._surface.tilingScheme.spatialReference}get elevationLevelDelta(){return this._surface.getElevationLevelDelta(this.level)}static prune(){K.prune(0),Z.prune(0),H.prune()}get _cached(){return!this.leaf&&this._mapDataRefCount<=0}get withinClippingArea(){return this._withinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBoundsMin(){return this._elevationBoundsMin}get elevationBoundsMax(){return this._elevationBoundsMax}get level(){return this._lij[0]}get key(){return`${this._lij[0]}/${this._lij[1]}/${this._lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[1][3]}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}computeVisibility(){this._dirty=!1;const e=this.parent,t=e?.frustumVisibility??1;this._frustumVisibility=0===t?0:2===t?2:this._calculateFrustumVisibility(this.surface.frustum);const i=2!==this._frustumVisibility&&this._intersectsClippingArea;i!==this._visible&&(this._visible=i,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setDirty(),this.updateAgentSuspension())}get _loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}init(e,t,i,s,n){this._lij[0]=e,this._lij[1]=t,this._lij[2]=i,this.ellipsoid=c(n.tilingScheme.spatialReference),n.tilingScheme.getExtent(e,t,i,this.extent),n.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this.extentMidX=.5*(this.extent[0]+this.extent[2]),this.extentMidY=.5*(this.extent[1]+this.extent[3]),this._withinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,n.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[1][3]=0,this.elevationLevel=e,s&&!Number.isNaN(s.elevationBoundsMin)?(this._elevationBoundsMin=s.elevationBoundsMin,this._elevationBoundsMax=s.elevationBoundsMax):(this._elevationBoundsMin=0,this._elevationBoundsMax=0),this._pendingUpdates=0,this.renderData=null,this.screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=s,this.clearChildren(),this._surface=n,this.updateVisibility(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0;for(const r of A){const e=n.numLayers(r),t=this.layerInfo[r];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=H.acquire(this._surface.upsampleInfoPool),0===r&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(n.tilingScheme.pixelSize,b)}dispose(){null!=this._surface&&(C(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key),this.layerInfo.forEach(e=>{e.forEach(e=>e.release()),e.length=0}),this._surface=this._parent=null,this.clearChildren(),this.setMemoryDirty())}refMapData(){++this._mapDataRefCount,this._cached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){--this._mapDataRefCount,this._cached&&this.cachedMemory>0&&this._surface.upsampleMapCache.put(this.key,this)}setMemoryDirty(){this._usedMemory=0}get usedMemory(){return this._ensureUsedMemory()+(this._cached?0:this._mapTileMemory)}get cachedMemory(){return this._ensureUsedMemory(),null==this._surface?this.usedMemory:this._cached?this._mapTileMemory:0}get _mapTileMemory(){return this._rasterTileMemory+this._vectorTileMemory}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(this._usedMemory>0)return this._vectorTileMemory=this.layerInfo[1].reduce((e,{data:t})=>e+(L(t)?t.usedMemoryPerReference:0),0),this._usedMemory;this._usedMemory=this._baseUsedMemory,this._rasterTileMemory=0,this._vectorTileMemory=0;for(const{data:e}of this.layerInfo[1])L(e)?this._vectorTileMemory+=e.usedMemoryPerReference:this._rasterTileMemory+=this.getTerrainDataMemory(e);for(const e of this.layerInfo[0])this._usedMemory+=e.data?this._cpuImageMemorySize:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._rasterTileMemory+=this.renderData.texture?.cachedMemory??0),this._cached&&this._surface.upsampleMapCache.updateSize(this.key,this),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?1===e?this._cached?0:this.getTerrainDataMemory(i.data):0===e?this._cpuImageMemorySize:0:0}getTerrainDataMemory(e){return I(e)?e.texture.usedMemory:j(e)?e.memoryUsage:L(e)?e.usedMemoryPerReference:T(e)||e instanceof HTMLImageElement?this._cpuImageMemorySize:0}updateScreenDepth(e){const t=this._center[1],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this.screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,t,i){if(!this.visible)return 0;if(e.frustum&&(!this._intersectsClippingArea||2===this._calculateFrustumVisibility(e.frustum)))return 0;const h=this.level;s(ae,_(this._center[1]),t);let d=n(ae),u=ae,c=_(this._center[1]);s(le,this._center[0],t);const g=n(le);g<d&&(d=g,u=le,c=this._center[0]),s(oe,this._center[2],t);const p=n(oe);if(p<d&&(d=p,u=oe,c=this._center[2]),this._edgeLen2>d&&h<e.maxLod)return 1;const f=Math.sqrt(d),m=e.fovX*f*2,y=this._edgeLen/m,v=()=>{if(h<e.maxLod)return this.elevationLevel=h,0;const t=h+Math.ceil(-Math.log2(e.relativeWidthLimit/y));return t!==this.elevationLevel?(this.elevationLevel=t,2):0},M=null!=i?i-h:1/0;if(M<=.5)return v();const A=r(this.up,ae),x=this._elevationBoundsMax-this._elevationBoundsMin,D=x/this.edgeLen;if(e.aboveGround&&A>0&&D<.001){if(A/f-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-D>0)return 0}const b=null!=i?3-Math.min(M,2):1;if(y*b<e.relativeWidthLimit||h>=e.maxLod)return v();if(h<7)return 1;a(he,this.up,A),s(he,he,u);const L=n(he);if(L<=this.radius*this.radius)return 1;a(he,he,this.radius/Math.sqrt(L)),l(he,he,c),s(he,t,he);const I=Math.min(1,(Math.abs(r(he,this.up))+.5*x+this._curvatureHeight)/o(he)),j=X/e.angledSplitBias,T=e.fovY*f*2;return I*(this._edgeLen/T*b)<j*e.relativeHeightLimit?0:1}createChildren(){const e=this._children,t=this.lij[0]+1,i=2*this.lij[1],s=2*this.lij[2];return e[0]=this.surface.createTile(t,i,s,this),e[1]=this.surface.createTile(t,i,s+1,this),e[2]=this.surface.createTile(t,i+1,s,this),e[3]=this.surface.createTile(t,i+1,s+1,this),e}clearChildren(){this._children[0]=this._children[1]=this._children[2]=this._children[3]=null}get loaded(){return this.renderData?.hasGeometry??!1}load(){this.refMapData();for(const e of A)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(){this.renderData&&this.unrefMapData(),this.surface.renderer.unloadTile(this);for(const e of A){const t=this.layerInfo[e];for(const e of t)e.loadingAgent&&e.loadingAgent!==W&&(Q(e.loadingAgent),e.loadingAgent=null),e.pendingUpdates=0}this.resetPendingUpdate(8),this.resetPendingUpdate(16),this.resetPendingUpdate(32)}unloadMapData(){const e=this.layerInfo[1];for(const t of e)t.loadingAgent&&t.loadingAgent!==W&&(Q(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0,t.invalidateSourceData();this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(p(e,this._clippingArea))return!1;const t=this._intersectsClippingArea,i=this._withinClippingArea;null!=e?(this._intersectsClippingArea=this.intersectsExtent(e),this._withinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._withinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const s=i&&this._withinClippingArea,n=!(i||t||this._withinClippingArea||this._intersectsClippingArea);return!this.renderData||s||n||this.setPendingUpdate(8),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i?.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of A){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==W&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(1)||0!==e&&!this._loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){const t=this._pendingUpdates;return this._pendingUpdates|=e,1===e||4===e?this._surface.setTileTreeDirty():this._surface.requestUpdate(),t!==this._pendingUpdates}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,i,s){const n=this.layerInfo[i][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated){console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e);const t=L(n.data);return s.dataArrived(this,t),!0}if(n.requestPromise)return!0;t(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,i,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get leaf(){return null==this._children[0]}hasLij(e){return this._lij[0]===e[0]&&this._lij[1]===e[1]&&this._lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;const t=this._children;if(!t[0])return null;return t[0].findByLij(e)||t[1].findByLij(e)||t[2].findByLij(e)||t[3].findByLij(e)}distanceToSquared(e){return n(s(he,_(this._center[1]),e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}containsPointXY(e,t){const i=this.extent;return e>=i[0]&&t>=i[1]&&e<=i[2]&&t<=i[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);C(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=L(i),n=this.layerInfo[t][e];n.data=i,n.dataInvalidated=!1,n.waitingAgents.forAll(e=>e.dataArrived(this,s)),n.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t){const i=this.layerInfo[t][e];i.dataMissing=!0,i.waitingAgents.forAll(e=>e.dataMissing()),i.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t,i){switch(i&&this.forEachLoadedNeighbor(i=>i.updateRenderData(e,t)),e){case 1:return this._updateTexture(t);case 0:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(0===e?16:32),this.setPendingUpdate(0===e?32:16))}_updateGeometry(){this.setPendingUpdate(8);for(const e of this.layerInfo[0])e.pendingUpdates|=8}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax;let i=1/0,s=-1/0;const n=this.layerInfo[0];let r=!0;for(const a of n)null!=a.elevationBounds&&(i=Math.min(i,a.elevationBounds.min),s=Math.max(s,a.elevationBounds.max),a.elevationBounds.hasNoDataValues||(r=!1));r&&(i=Math.min(i,0),s=Math.max(s,0)),e===i&&t===s||(this._elevationBoundsMin=i,this._elevationBoundsMax=s,this.updateRadiusAndCenter(),this._surface.setTileTreeDirty())}_updateCenter(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax,i=.5*(e+t),s=this._center;a(he,this.up,i),l(_(s[1]),this.centerAtSeaLevel,he),a(he,this.up,e),l(s[0],this.centerAtSeaLevel,he),a(he,this.up,t),l(s[2],this.centerAtSeaLevel,he)}findElevationBoundsForLayer(e,t){const i=this.layerInfo[0][e],s=this.elevationLevelDelta,n=Math.max(this.elevationLevel-s,0),r=i.elevationBounds;if(null!=r&&r.level>=t&&r.level<=n)return;const a=this._surface.layerViewByIndex(e,0);if(!J(this,a))return;const l=ee;let o=!1;const h=i.data;if(h&&h.level<=n){const e=i.data;l.min=e.samplerData.data.minValue,l.max=e.samplerData.data.maxValue,l.hasNoDataValues=e.samplerData.data.hasNoDataValues,l.level=this.level,o=!0}else{let t,i,r=0;for(let a=this._parent;a&&(!i||r<s)&&(r=this.elevationLevel-a.level,t=i||t,i=a.layerInfo[0][e].data,!(!i&&t&&a.level<=n));a=a.parent);i=i||t,i&&(i.computeMinMaxValue(this._lij[0],this._lij[1],this._lij[2],l),l.min!==1/0&&(l.level=i.level,o=!0))}o&&(null==i.elevationBounds&&(i.elevationBounds=new y),i.elevationBounds.copyFrom(l))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==W&&(Q(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:H.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,0))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===W&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of A){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==W&&(i.loadingAgent.setSuspension(t),i.loadingAgent===W&&this.updateRenderData(e,0))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==W&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=W,i.data||null!=i.upsampleInfo||this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return"normal"!==e.blendMode||m(e.parent)&&this._hasBlendableAncestor(e.parent)}_hasBlendModes(e,t,i){for(let s=e;s<t;++s){const e=this._surface.layerViewByIndex(s,i);if(B(e)&&"normal"!==e?.layer?.blendMode||m(e?.layer?.parent)&&this._hasBlendableAncestor(e?.layer?.parent))return!0}return!1}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=this._isSuspended(t);for(let n=e;n<i.length;++n){const r=i[n],a=this._surface.layerViewByIndex(n,t);let l=!1;if(r.loadingAgent?J(this,a)?(r.loadingAgent!==W&&r.loadingAgent.setSuspension(s),r.loadingAgent!==W&&(l=r.loadingAgent.update())):r.dispose():J(this,a)&&(r.loadingAgent=$(this,n,t,s),l=r.loadingAgent.startLoading(),l?r.loadingAgent===W&&this.setPendingUpdate(8):(Q(r.loadingAgent),r.loadingAgent=W)),r.loadingAgent===W&&this.updateRenderData(t,0),!a.destroyed&&!this._hasBlendModes(e,i.length,t)&&l&&a.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationVerticesPerSide(t){const i=this.elevationLevel-this.level,s=Math.max(this.level-t,this.elevationLevelDelta-i),n=e(1+(this._maxTesselation>>s),2,this._maxTesselation+1),r=this.minimumVerticesPerSide;return Math.max(n,r)}_findLIJ(e,t){if(!e)return null;const i=this.surface.rootTiles;if(null!=i)for(const s of i)if(te(s,e)){let i=s,n=e[0]-i.level-1;for(;n>=0&&!i.leaf&&!t(i);){const t=e[1]>>n&1,s=e[2]>>n&1;i=i.children[2*t+s],n--}return t(i)?i:null}return null}findNeighborTile(e,t){const i=this._lij,s=this._getNeighborLIJ(i,e);return s?ie(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=1===e?1:7===e?0:5===e?2:3;let s=this;for(;s.children[0]&&(!t||!t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,e=>t(e)||e.level===this.level)?.findCorner(U(e),t)||null}forAllSubtreeOnSide(e,t){const i=0===e?[0,1]:1===e?[1]:2===e?[1,3]:3===e?[3]:4===e?[2,3]:5===e?[2]:6===e?[0,2]:[0],s=e=>{const n=e.children;!t(e)&&n[0]&&i.forEach(e=>s(n[e]))};s(this)}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;const i=this.level-t.level;if(S(!P||i>=0),0===i)return 0;const s=2**i,n=!(1&~e),r=n?0:1,a=t.lij[r+1]*s,l=this._lij[r+1],o=l-a,h=n?s-1-o:o;return P&&(S(a<=l&&l<a+s),S(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.loaded;w.forEach(t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(E(t),i=>!!i.loaded&&(e(i,t),!0))}),R.forEach(t=>{const s=this.findNeighborTile(t,i)?.findCorner(U(t),e=>e.loaded);S(!s||se(this,s,t)),s?.loaded&&e(s,t)})}_getNeighborLIJ(e,t){const i=N(t)?-1:O(t)?1:0,s=k(t)?-1:G(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this._wrapLIJ(n):n[2]<0?null:n}_wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}isEdgeNeighbor(e,t){if(null==e)return!1;if(0===this.level&&0===e.level){if(this._eastEnd&&e._westEnd&&2===t)return!0;if(this._westEnd&&e._eastEnd&&6===t)return!0}const i=Math.max(1e-6*(this.extent[2]-this.extent[0]),1);switch(t){case 0:return q(this.extent[3],e.extent[1],i);case 4:return q(this.extent[1],e.extent[3],i);case 2:return q(this.extent[2],e.extent[0],i)||q(this.extent[2],-e.extent[0],i);case 6:return q(this.extent[0],e.extent[2],i)||q(this.extent[0],-e.extent[2],i)}}get _eastEnd(){return this._lij[2]===this.surface.lijEastEnd(this.level)-1}get _westEnd(){return 0===this._lij[2]}checkGeometryWaterproofness(){V&&(S(this.loaded),this.renderData?.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(N(e)&&t[3]+s>=i[3])return!1;if(O(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&k(e)&&t[0]-s<=i[0])&&!(!n&&G(e)&&t[2]+s>=i[2])}updateDistanceToPOI(e){const t=this._lastPOI;if(this.distanceToPOI>=0&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return;h(this._lastPOI,e);const i=this._center[1],s=e[0]-i[0],n=e[1]-i[1],r=e[2]-i[2];this.distanceToPOI=s*s+n*n+r*r}}function $(e,t,i,s){const n=0===i?Z.acquire():K.acquire();return n.init(e,t,i,s),n}function Q(e){e.dispose(),M(e)?Z.release(e):D(e)&&K.release(e)}const K=new i(x),Z=new i(v),ee=new y;function te(e,t){const i=e.lij,s=t[0]-i[0];return!(s<0)&&(t[1]>>s===i[1]&&t[2]>>s===i[2])}function ie(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function se(e,t,i){return null!=e&&null!=t&&t!==e&&(e.level>=t.level?ne(e,t,i):ne(t,e,U(i)))}function ne(e,t,i){S(e.level>=t.level);const s=z(i),n=F(i),r=e.extent,a=t.extent,l=[s?r[0]:r[2],n?r[3]:r[1]],o=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),d=q(l[0],o[0],h)||e.surface.isGlobal&&q(l[0],-o[0],h),u=q(l[1],o[1],h);if(d&&u)return!0;if(e.level===t.level)return S(!1),!1;if(!d&&!u)return S(!1),!1;const c=d?re(a[1],a[3],r[1],r[3],h):re(a[0],a[2],r[0],r[2],h);return S(c),c}function re(e,t,i,s,n){return e-n<=i&&i<=s&&s<=t+n}const ae=d(),le=d(),oe=d(),he=d();export{Y as Tile,se as isCornerNeighbor,ie as lijEquals};
|
|
5
|
+
import{clamp as e}from"../../../core/mathUtils.js";import{abortMaybe as t}from"../../../core/maybe.js";import i from"../../../core/ObjectPool.js";import{d as s,k as n,e as r,g as a,f as l,l as o,c as h}from"../../../chunks/vec32.js";import{create as d,unitZ as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import{create as g,equals as p}from"../../../geometry/support/aaBoundingRect.js";import{c as f,a as _}from"../../../chunks/sphere.js";import{isGroupLayer as m}from"../../../layers/support/layerUtils.js";import{ElevationBounds as y}from"./ElevationBounds.js";import{ElevationTileAgent as v,isElevationTileAgent as M}from"./ElevationTileAgent.js";import{LayerClasses as A}from"./LayerClass.js";import{MapTileAgent as x,isMapTileAgent as D}from"./MapTileAgent.js";import{maxPatchTesselation as b}from"./TerrainConst.js";import{isVectorTile as L,isTileTexture as I,isRasterTile as j,isImageWithType as T}from"./TerrainData.js";import{weakAssert as C,isBlendableLayerView as B,oppositeCorner as U,internalAssert as S,enableTerrainInternalChecks as P,neighborEdgeIndices as w,oppositeEdge as E,neighborCornerIndices as R,almostEquals as q,enableWaterproofTests as V,isNorth as N,isSouth as O,isWest as k,isEast as G,isWestCorner as z,isNorthCorner as F}from"./terrainUtils.js";import{tileAgentDone as W}from"./TileAgent.js";import{TilePerLayerInfo as H}from"./TilePerLayerInfo.js";import{fallsWithinLayerView as J}from"./tileUtils.js";const X=.1;class Y{constructor(){this._lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this._dirty=!0,this._previouslyRendered=!1,this.extent=g(),this._elevationBoundsMin=NaN,this._elevationBoundsMax=0,this.layerInfo=[[],[]],this.extentInRadians=g(),this.centerAtSeaLevel=d(),this._center=[d(),f(),d()],this.up=u(),this._withinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=0,this._rasterTileMemory=0,this._vectorTileMemory=0,this._mapDataRefCount=0,this.screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0,this.onCompressionFinished=()=>{this.setPendingUpdate(16),this.setMemoryDirty()},this.extentMidX=0,this.extentMidY=0,this.distanceToPOI=-1,this._lastPOI=d(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0}get lij(){return this._lij}get spatialReference(){return this._surface.spatialReference??this._surface.tilingScheme.spatialReference}get elevationLevelDelta(){return this._surface.getElevationLevelDelta(this.level)}static prune(){K.prune(0),Z.prune(0),H.prune()}get _cached(){return!this.leaf&&this._mapDataRefCount<=0}get withinClippingArea(){return this._withinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBoundsMin(){return this._elevationBoundsMin}get elevationBoundsMax(){return this._elevationBoundsMax}get level(){return this._lij[0]}get key(){return`${this._lij[0]}/${this._lij[1]}/${this._lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[1][3]}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}computeVisibility(){this._dirty=!1;const e=this.parent,t=e?.frustumVisibility??1;this._frustumVisibility=0===t?0:2===t?2:this._calculateFrustumVisibility(this.surface.frustum);const i=2!==this._frustumVisibility&&this._intersectsClippingArea;i!==this._visible&&(this._visible=i,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setDirty(),this.updateAgentSuspension())}get _loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}init(e,t,i,s,n){this._lij[0]=e,this._lij[1]=t,this._lij[2]=i,this.ellipsoid=c(n.tilingScheme.spatialReference),n.tilingScheme.getExtent(e,t,i,this.extent),n.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this.extentMidX=.5*(this.extent[0]+this.extent[2]),this.extentMidY=.5*(this.extent[1]+this.extent[3]),this._withinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,n.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[1][3]=0,this.elevationLevel=e,s&&!Number.isNaN(s.elevationBoundsMin)?(this._elevationBoundsMin=s.elevationBoundsMin,this._elevationBoundsMax=s.elevationBoundsMax):(this._elevationBoundsMin=0,this._elevationBoundsMax=0),this._pendingUpdates=0,this.renderData=null,this.screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=s,this.clearChildren(),this._surface=n,this.updateVisibility(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0;for(const r of A){const e=n.numLayers(r),t=this.layerInfo[r];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=H.acquire(this._surface.upsampleInfoPool),0===r&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(n.tilingScheme.pixelSize,b)}dispose(){C(!this.renderData,"tile.renderData was not unloaded"),this._surface?.upsampleMapCache.pop(this.key),this.layerInfo.forEach(e=>{e.forEach(e=>e.release()),e.length=0}),this._surface=this._parent=null,this.clearChildren(),this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._cached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){--this._mapDataRefCount,this._cached&&this.cachedMemory>0&&this._surface.upsampleMapCache.put(this.key,this)}setMemoryDirty(){this._usedMemory=0}get usedMemory(){return this._ensureUsedMemory()+(this._cached?0:this._mapTileMemory)}get cachedMemory(){return this._ensureUsedMemory(),null==this._surface?this.usedMemory:this._cached?this._mapTileMemory:0}get _mapTileMemory(){return this._rasterTileMemory+this._vectorTileMemory}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(this._usedMemory>0)return this._vectorTileMemory=this.layerInfo[1].reduce((e,{data:t})=>e+(L(t)?t.usedMemoryPerReference:0),0),this._usedMemory;this._usedMemory=this._baseUsedMemory,this._rasterTileMemory=0,this._vectorTileMemory=0;for(const{data:e}of this.layerInfo[1])L(e)?this._vectorTileMemory+=e.usedMemoryPerReference:this._rasterTileMemory+=this.getTerrainDataMemory(e);for(const e of this.layerInfo[0])this._usedMemory+=e.data?this._cpuImageMemorySize:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._rasterTileMemory+=this.renderData.texture?.cachedMemory??0),this._cached&&this._surface.upsampleMapCache.updateSize(this.key,this),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?1===e?this._cached?0:this.getTerrainDataMemory(i.data):0===e?this._cpuImageMemorySize:0:0}getTerrainDataMemory(e){return I(e)?e.texture.usedMemory:j(e)?e.memoryUsage:L(e)?e.usedMemoryPerReference:T(e)||e instanceof HTMLImageElement?this._cpuImageMemorySize:0}updateScreenDepth(e){const t=this._center[1],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this.screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,t,i){if(!this.visible)return 0;if(e.frustum&&(!this._intersectsClippingArea||2===this._calculateFrustumVisibility(e.frustum)))return 0;const h=this.level;s(ae,_(this._center[1]),t);let d=n(ae),u=ae,c=_(this._center[1]);s(le,this._center[0],t);const g=n(le);g<d&&(d=g,u=le,c=this._center[0]),s(oe,this._center[2],t);const p=n(oe);if(p<d&&(d=p,u=oe,c=this._center[2]),this._edgeLen2>d&&h<e.maxLod)return 1;const f=Math.sqrt(d),m=e.fovX*f*2,y=this._edgeLen/m,v=()=>{if(h<e.maxLod)return this.elevationLevel=h,0;const t=h+Math.ceil(-Math.log2(e.relativeWidthLimit/y));return t!==this.elevationLevel?(this.elevationLevel=t,2):0},M=null!=i?i-h:1/0;if(M<=.5)return v();const A=r(this.up,ae),x=this._elevationBoundsMax-this._elevationBoundsMin,D=x/this.edgeLen;if(e.aboveGround&&A>0&&D<.001){if(A/f-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-D>0)return 0}const b=null!=i?3-Math.min(M,2):1;if(y*b<e.relativeWidthLimit||h>=e.maxLod)return v();if(h<7)return 1;a(he,this.up,A),s(he,he,u);const L=n(he);if(L<=this.radius*this.radius)return 1;a(he,he,this.radius/Math.sqrt(L)),l(he,he,c),s(he,t,he);const I=Math.min(1,(Math.abs(r(he,this.up))+.5*x+this._curvatureHeight)/o(he)),j=X/e.angledSplitBias,T=e.fovY*f*2;return I*(this._edgeLen/T*b)<j*e.relativeHeightLimit?0:1}createChildren(){const e=this._children,t=this.lij[0]+1,i=2*this.lij[1],s=2*this.lij[2];return e[0]=this.surface.createTile(t,i,s,this),e[1]=this.surface.createTile(t,i,s+1,this),e[2]=this.surface.createTile(t,i+1,s,this),e[3]=this.surface.createTile(t,i+1,s+1,this),e}clearChildren(){this._children[0]=this._children[1]=this._children[2]=this._children[3]=null}get loaded(){return this.renderData?.hasGeometry??!1}load(){this.refMapData();for(const e of A)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(){this.renderData&&this.unrefMapData(),this.surface.renderer.unloadTile(this);for(const e of A){const t=this.layerInfo[e];for(const e of t)e.loadingAgent&&e.loadingAgent!==W&&(Q(e.loadingAgent),e.loadingAgent=null),e.pendingUpdates=0}this.resetPendingUpdate(8),this.resetPendingUpdate(16),this.resetPendingUpdate(32)}unloadMapData(){const e=this.layerInfo[1];for(const t of e)t.loadingAgent&&t.loadingAgent!==W&&(Q(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0,t.invalidateSourceData();this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(p(e,this._clippingArea))return!1;const t=this._intersectsClippingArea,i=this._withinClippingArea;null!=e?(this._intersectsClippingArea=this.intersectsExtent(e),this._withinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._withinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const s=i&&this._withinClippingArea,n=!(i||t||this._withinClippingArea||this._intersectsClippingArea);return!this.renderData||s||n||this.setPendingUpdate(8),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i?.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of A){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==W&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(1)||0!==e&&!this._loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){const t=this._pendingUpdates;return this._pendingUpdates|=e,1===e||4===e?this._surface.setTileTreeDirty():this._surface.requestUpdate(),t!==this._pendingUpdates}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,i,s){const n=this.layerInfo[i][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated){console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e);const t=L(n.data);return s.dataArrived(this,t),!0}if(n.requestPromise)return!0;t(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,i,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get leaf(){return null==this._children[0]}hasLij(e){return this._lij[0]===e[0]&&this._lij[1]===e[1]&&this._lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;const t=this._children;if(!t[0])return null;return t[0].findByLij(e)||t[1].findByLij(e)||t[2].findByLij(e)||t[3].findByLij(e)}distanceToSquared(e){return n(s(he,_(this._center[1]),e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}containsPointXY(e,t){const i=this.extent;return e>=i[0]&&t>=i[1]&&e<=i[2]&&t<=i[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);C(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=L(i),n=this.layerInfo[t][e];n.data=i,n.dataInvalidated=!1,n.waitingAgents.forAll(e=>e.dataArrived(this,s)),n.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t){const i=this.layerInfo[t][e];i.dataMissing=!0,i.waitingAgents.forAll(e=>e.dataMissing()),i.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t,i){switch(i&&this.forEachLoadedNeighbor(i=>i.updateRenderData(e,t)),e){case 1:return this._updateTexture(t);case 0:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(0===e?16:32),this.setPendingUpdate(0===e?32:16))}_updateGeometry(){this.setPendingUpdate(8);for(const e of this.layerInfo[0])e.pendingUpdates|=8}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax;let i=1/0,s=-1/0;const n=this.layerInfo[0];let r=!0;for(const a of n)null!=a.elevationBounds&&(i=Math.min(i,a.elevationBounds.min),s=Math.max(s,a.elevationBounds.max),a.elevationBounds.hasNoDataValues||(r=!1));r&&(i=Math.min(i,0),s=Math.max(s,0)),e===i&&t===s||(this._elevationBoundsMin=i,this._elevationBoundsMax=s,this.updateRadiusAndCenter(),this._surface.setTileTreeDirty())}_updateCenter(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax,i=.5*(e+t),s=this._center;a(he,this.up,i),l(_(s[1]),this.centerAtSeaLevel,he),a(he,this.up,e),l(s[0],this.centerAtSeaLevel,he),a(he,this.up,t),l(s[2],this.centerAtSeaLevel,he)}findElevationBoundsForLayer(e,t){const i=this.layerInfo[0][e],s=this.elevationLevelDelta,n=Math.max(this.elevationLevel-s,0),r=i.elevationBounds;if(null!=r&&r.level>=t&&r.level<=n)return;const a=this._surface.layerViewByIndex(e,0);if(!J(this,a))return;const l=ee;let o=!1;const h=i.data;if(h&&h.level<=n){const e=i.data;l.min=e.samplerData.data.minValue,l.max=e.samplerData.data.maxValue,l.hasNoDataValues=e.samplerData.data.hasNoDataValues,l.level=this.level,o=!0}else{let t,i,r=0;for(let a=this._parent;a&&(!i||r<s)&&(r=this.elevationLevel-a.level,t=i||t,i=a.layerInfo[0][e].data,!(!i&&t&&a.level<=n));a=a.parent);i=i||t,i&&(i.computeMinMaxValue(this._lij[0],this._lij[1],this._lij[2],l),l.min!==1/0&&(l.level=i.level,o=!0))}o&&(null==i.elevationBounds&&(i.elevationBounds=new y),i.elevationBounds.copyFrom(l))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==W&&(Q(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:H.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,0))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===W&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of A){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==W&&(i.loadingAgent.setSuspension(t),i.loadingAgent===W&&this.updateRenderData(e,0))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==W&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=W,i.data||null!=i.upsampleInfo||this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return"normal"!==e.blendMode||m(e.parent)&&this._hasBlendableAncestor(e.parent)}_hasBlendModes(e,t,i){for(let s=e;s<t;++s){const e=this._surface.layerViewByIndex(s,i);if(B(e)&&"normal"!==e?.layer?.blendMode||m(e?.layer?.parent)&&this._hasBlendableAncestor(e?.layer?.parent))return!0}return!1}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=this._isSuspended(t);for(let n=e;n<i.length;++n){const r=i[n],a=this._surface.layerViewByIndex(n,t);let l=!1;if(r.loadingAgent?J(this,a)?(r.loadingAgent!==W&&r.loadingAgent.setSuspension(s),r.loadingAgent!==W&&(l=r.loadingAgent.update())):r.dispose():J(this,a)&&(r.loadingAgent=$(this,n,t,s),l=r.loadingAgent.startLoading(),l?r.loadingAgent===W&&this.setPendingUpdate(8):(Q(r.loadingAgent),r.loadingAgent=W)),r.loadingAgent===W&&this.updateRenderData(t,0),!a.destroyed&&!this._hasBlendModes(e,i.length,t)&&l&&a.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationVerticesPerSide(t){const i=this.elevationLevel-this.level,s=Math.max(this.level-t,this.elevationLevelDelta-i),n=e(1+(this._maxTesselation>>s),2,this._maxTesselation+1),r=this.minimumVerticesPerSide;return Math.max(n,r)}_findLIJ(e,t){if(!e)return null;const i=this.surface.rootTiles;if(null!=i)for(const s of i)if(te(s,e)){let i=s,n=e[0]-i.level-1;for(;n>=0&&!i.leaf&&!t(i);){const t=e[1]>>n&1,s=e[2]>>n&1;i=i.children[2*t+s],n--}return t(i)?i:null}return null}findNeighborTile(e,t){const i=this._lij,s=this._getNeighborLIJ(i,e);return s?ie(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=1===e?1:7===e?0:5===e?2:3;let s=this;for(;s.children[0]&&(!t||!t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,e=>t(e)||e.level===this.level)?.findCorner(U(e),t)||null}forAllSubtreeOnSide(e,t){const i=0===e?[0,1]:1===e?[1]:2===e?[1,3]:3===e?[3]:4===e?[2,3]:5===e?[2]:6===e?[0,2]:[0],s=e=>{const n=e.children;!t(e)&&n[0]&&i.forEach(e=>s(n[e]))};s(this)}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;const i=this.level-t.level;if(S(!P||i>=0),0===i)return 0;const s=2**i,n=!(1&~e),r=n?0:1,a=t.lij[r+1]*s,l=this._lij[r+1],o=l-a,h=n?s-1-o:o;return P&&(S(a<=l&&l<a+s),S(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.loaded;w.forEach(t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(E(t),i=>!!i.loaded&&(e(i,t),!0))}),R.forEach(t=>{const s=this.findNeighborTile(t,i)?.findCorner(U(t),e=>e.loaded);S(!s||se(this,s,t)),s?.loaded&&e(s,t)})}_getNeighborLIJ(e,t){const i=N(t)?-1:O(t)?1:0,s=k(t)?-1:G(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this._wrapLIJ(n):n[2]<0?null:n}_wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}isEdgeNeighbor(e,t){if(null==e)return!1;if(0===this.level&&0===e.level){if(this._eastEnd&&e._westEnd&&2===t)return!0;if(this._westEnd&&e._eastEnd&&6===t)return!0}const i=Math.max(1e-6*(this.extent[2]-this.extent[0]),1);switch(t){case 0:return q(this.extent[3],e.extent[1],i);case 4:return q(this.extent[1],e.extent[3],i);case 2:return q(this.extent[2],e.extent[0],i)||q(this.extent[2],-e.extent[0],i);case 6:return q(this.extent[0],e.extent[2],i)||q(this.extent[0],-e.extent[2],i)}}get _eastEnd(){return this._lij[2]===this.surface.lijEastEnd(this.level)-1}get _westEnd(){return 0===this._lij[2]}checkGeometryWaterproofness(){V&&(S(this.loaded),this.renderData?.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(N(e)&&t[3]+s>=i[3])return!1;if(O(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&k(e)&&t[0]-s<=i[0])&&!(!n&&G(e)&&t[2]+s>=i[2])}updateDistanceToPOI(e){const t=this._lastPOI;if(this.distanceToPOI>=0&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return;h(this._lastPOI,e);const i=this._center[1],s=e[0]-i[0],n=e[1]-i[1],r=e[2]-i[2];this.distanceToPOI=s*s+n*n+r*r}}function $(e,t,i,s){const n=0===i?Z.acquire():K.acquire();return n.init(e,t,i,s),n}function Q(e){e.dispose(),M(e)?Z.release(e):D(e)&&K.release(e)}const K=new i(x),Z=new i(v),ee=new y;function te(e,t){const i=e.lij,s=t[0]-i[0];return!(s<0)&&(t[1]>>s===i[1]&&t[2]>>s===i[2])}function ie(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function se(e,t,i){return null!=e&&null!=t&&t!==e&&(e.level>=t.level?ne(e,t,i):ne(t,e,U(i)))}function ne(e,t,i){S(e.level>=t.level);const s=z(i),n=F(i),r=e.extent,a=t.extent,l=[s?r[0]:r[2],n?r[3]:r[1]],o=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),d=q(l[0],o[0],h)||e.surface.isGlobal&&q(l[0],-o[0],h),u=q(l[1],o[1],h);if(d&&u)return!0;if(e.level===t.level)return S(!1),!1;if(!d&&!u)return S(!1),!1;const c=d?re(a[1],a[3],r[1],r[3],h):re(a[0],a[2],r[0],r[2],h);return S(c),c}function re(e,t,i,s,n){return e-n<=i&&i<=s&&s<=t+n}const ae=d(),le=d(),oe=d(),he=d();export{Y as Tile,se as isCornerNeighbor,ie as lijEquals};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/Error.js";import{ManagedColorAttachment as t}from"../../webgl/ManagedColorAttachment.js";import{ManagedDepthTexture as r}from"../../webgl/ManagedDepthTexture.js";import a from"../../webgl/ManagedFBO.js";import{isDepthFormat as c,DepthTextureFormats as h,ColorFormats as i}from"./FBOCacheFormats.js";import{FBOPool as
|
|
5
|
+
import e from"../../../../core/Error.js";import{ManagedColorAttachment as t}from"../../webgl/ManagedColorAttachment.js";import{ManagedDepthTexture as r}from"../../webgl/ManagedDepthTexture.js";import a from"../../webgl/ManagedFBO.js";import{isDepthFormat as c,DepthTextureFormats as h,ColorFormats as i}from"./FBOCacheFormats.js";import{FBOPool as n}from"./FBOPool.js";import{DepthStencilAttachment as o,ColorAttachment0 as s}from"../../../webgl/enums.js";import{FramebufferObject as l}from"../../../webgl/FramebufferObject.js";import{Texture as u}from"../../../webgl/Texture.js";class m{constructor(e){this.rctx=e,this._interactive=!1,this._acquired=new Set,this._cache=new n(e.newCache,"FBOCache"),this._depthCache=new n(e.newCache,"DepthAttachmentCache"),this._colorCache=new n(e.newCache,"ColorAttachmentCache")}destroy(){this._cache.destroy(),this._depthCache.destroy(),this._colorCache.destroy()}clean(){this._cache.clean(),this._colorCache.clean(),this._depthCache.clean()}frameStart(){this._cache.frame(),this._colorCache.frame(),this._depthCache.frame(),this.debugCallback?.()}frameEnd(){const{debugCallback:e}=this;e&&this._acquired.forEach(t=>e(t.name,t.fbo))}get usedMemory(){return Array.from(this._acquired.values()).reduce((e,t)=>e+t.cachedMemory,this._cache.usedMemory+this._colorCache.usedMemory+this._depthCache.usedMemory)}set interactive(e){this._cache.interactive=this._colorCache.interactive=this._depthCache.interactive=e,this._interactive=e}get interactive(){return this._interactive}acquire(t,r,h,i=5){const n=_(i,t,r);let u=this._cache.pop(n);const{rctx:m}=this;if(u){u.retain(),u.setName(h);const t=u.getAttachment(o);t&&(t.name=f(h));const r=u.getAttachment(s);r&&(r.name=d(h,0));const{fbo:a}=u;if(!a)throw new e("renderer","attempt to use a none existing framebuffer");m.temporaryBindFramebufferObject(a,()=>{m.setDrawBuffers([s]),m.unbindTexture(a.colorTexture)})}else{const e=new l(m),p=(e,a,c)=>{a??=5;const h=this._acquireColor(a,t,r,c??d(u.name,e-s));return this.rctx.unbindTexture(h.attachment),u.attachColor(h,e),h.release(),u},_=e=>{e??=11;const a=this.acquireDepth(e,t,r,f(u.name));return u.attachDepth(a),a.release(),u},C=()=>{if(!u)return;this.debugCallback?.(u.name,u.fbo),this._acquired.delete(u);const e=c(i);e&&null!=u.getAttachment(o)||!e&&null!=u.getAttachment(s)?(e?(u.fbo?.invalidateAttachments([o]),u.detachAllColors()):(u.fbo?.invalidateAttachments([s]),u.detachAllButColor0()),this._cache.put(u)):u.dispose()};u=new a(n,h,e,p,_,C),c(i)?u.acquireDepth(i):u.acquireColor(s,i,h)}return this._trackHandle(u)}acquireDepth(e,t,a,c){const i=_(e,t,a);let n=this._depthCache.pop(i);if(n)n.retain(),n.attachment.setShadowFiltering(!1);else{const c=new u(this.rctx,{...h[e],width:t,height:a});n=new r(i,c,()=>this._depthCache.put(n))}return n.name=c,n}_acquireColor(e,r,a,c){const h=_(e,r,a);let n=this._colorCache.pop(h);if(n)n.retain();else{const c=new u(this.rctx,{...i[e],width:r,height:a});n=new t(h,c,()=>this._colorCache.put(n))}return n.name=c,n}_trackHandle(e){return this._acquired.add(e),e}}function d(e,t=0){return`${e}.color${t}`}function f(e){return`${e}.depth`}const p=new a("default","default",null,()=>p,()=>p,()=>{});function _(e,t,r){return`${t}x${r}:${e}`}p.release=()=>!1;export{m as FBOCache,p as defaultWebGLFBO};
|
package/views/SceneView.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../Camera.js";import i from"../Viewpoint.js";import r from"../core/Collection.js";import{byId as s}from"../core/domUtils.js";import n from"../core/Error.js";import{on as a}from"../core/events.js";import{makeHandle as o}from"../core/handleUtils.js";import has from"../core/has.js";import l from"../core/Logger.js";import{destroyMaybe as p,maybeProperty as h}from"../core/maybe.js";import{throwIfAborted as d}from"../core/promiseUtils.js";import{on as u,watch as c,initial as g,sync as m,whenOnce as y,syncAndInitial as f}from"../core/reactiveUtils.js";import{setFrameDuration as w,cleanupScheduling as v}from"../core/scheduling.js";import{createScreenPointArray as _,createScreenPoint as b}from"../core/screenUtils.js";import{cleanupWhereClauseCache as M}from"../core/sql.js";import{getMetersPerUnitForSR as S}from"../core/unitUtils.js";import{initialize as V}from"../core/workers/workers.js";import{property as j}from"../core/accessorSupport/decorators/property.js";import{cast as R}from"../core/accessorSupport/decorators/cast.js";import"../core/RandomLCG.js";import{subclass as C}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as T,ensureClass as x}from"../core/accessorSupport/ensureType.js";import{overrideDefaultsFrom as O}from"../core/accessorSupport/overrideDefaultsFrom.js";import{drainNotificationQueue as A}from"../core/accessorSupport/trackingUtils.js";import{create as E}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import{cleanupPooledRBush as L}from"../core/libs/rbush/PooledRBush.js";import{owningCollectionProperty as H}from"../core/support/OwningCollection.js";import I from"../geometry/Extent.js";import P from"../geometry/HeightModelInfo.js";import D from"../geometry/Point.js";import{project as F,canProjectWithoutEngine as G}from"../geometry/projectionUtils.js";import U from"../geometry/SpatialReference.js";import{cleanupSpatialReferenceEllipsoidUtils as W}from"../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingRect as q}from"../geometry/projection/projectBoundingRect.js";import{projectPointToVector as z}from"../geometry/projection/projectPointToVector.js";import{create as k,toExtent as B}from"../geometry/support/aaBoundingRect.js";import{renderSRFromViewSR as N}from"../geometry/support/coordinateSystem.js";import{getResolutionForScale as Q}from"../geometry/support/scaleUtils.js";import{isImageryTileLayer as Y,isTiledLayer as Z,isVoxelLayer as $,isIntegratedMeshLayer as J}from"../layers/support/layerUtils.js";import{TilemapCache as K}from"../layers/support/TilemapCache.js";import{clearDefaultPortalInstance as X}from"../portal/portalDefault.js";import{AnalysesCollection as ee}from"../support/AnalysesCollection.js";import{WebSceneTag as te}from"../support/tagSymbols.js";import{BreakpointsOwner as ie}from"./BreakpointsOwner.js";import{DOMContainer as re}from"./DOMContainer.js";import se from"./GroundView.js";import{PopupView as ne}from"./PopupView.js";import ae from"./View.js";import oe from"./ViewAnimation.js";import{stringFromViewingMode as le,viewingModeFromString as pe}from"./ViewingMode.js";import{layerView3DImporter as he}from"./3d/layerViewModuleImportUtils.js";import de from"./3d/analysis/AnalysisViewManager3D.js";import{cleanupIntersectionUtils as ue}from"./3d/camera/intersectionUtils.js";import{Constraints as ce}from"./3d/constraints/Constraints.js";import{EnvironmentManager as ge}from"./3d/environment/EnvironmentManager.js";import me from"./3d/environment/SceneViewEnvironment.js";import ye from"./3d/input/SceneInputManager.js";import{GraphicsDeconflictor as fe}from"./3d/layers/graphics/GraphicsDeconflictor.js";import{Labeler as we}from"./3d/layers/graphics/Labeler.js";import ve from"./3d/layers/i3s/I3SLodHandling.js";import{FeatureTileTree3D as _e}from"./3d/layers/support/FeatureTileTree3D.js";import{cleanupStageLayerElevationProvider as be}from"./3d/layers/support/StageLayerElevationProvider.js";import Me from"./3d/state/ViewState.js";import{ViewStateManager as Se,cleanupViewStateManager as Ve}from"./3d/state/ViewStateManager.js";import{cleanupPointToPointAnimationController as je}from"./3d/state/controllers/PointToPointAnimationController.js";import{SceneIntersectionHelper as Re}from"./3d/state/helpers/SceneIntersectionHelper.js";import{cleanupNavigationUtils as Ce}from"./3d/state/utils/navigationUtils.js";import{CombinedElevationProvider as Te}from"./3d/support/CombinedElevationProvider.js";import{debugFlags as xe}from"./3d/support/debugFlags.js";import Oe from"./3d/support/DisplayQualityProfile.js";import{getElevationAtPoint as Ae}from"./3d/support/ElevationProvider.js";import{toMap as Ee,hitTest as Le}from"./3d/support/hitTest.js";import{popupHitTest as He}from"./3d/support/popupHitTest.js";import Ie from"./3d/support/QualitySettings.js";import{RenderCoordsHelper as Pe}from"./3d/support/RenderCoordsHelper.js";import{newResourceController as De}from"./3d/support/ResourceController.js";import Fe from"./3d/support/SceneViewPerformanceInfo.js";import{SharedSymbolResources as Ge}from"./3d/support/SharedSymbolResources.js";import{ViewSlice as Ue}from"./3d/support/ViewSlice.js";import{PointsOfInterest as We}from"./3d/support/pointsOfInterest/PointsOfInterest.js";import qe from"./3d/terrain/TerrainSurface.js";import{isSurfaceLayerView as ze,getTiledLayerInfo as ke,checkIfTileInfoSupportedForView as Be}from"./3d/terrain/terrainUtils.js";import{clearTilePerLayerInfo as Ne}from"./3d/terrain/TilePerLayerInfo.js";import{cleanupTileRenderer as Qe}from"./3d/terrain/TileRenderer.js";import{Stage as Ye}from"./3d/webgl-engine/Stage.js";import{olidEnabled as Ze}from"./3d/webgl-engine/effects/geometry/olidUtils.js";import{cleanupRenderOccluded as $e}from"./3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js";import{defaultTolerance as Je}from"./3d/webgl-engine/lib/Intersector.js";import{cleanupShadowmap as Ke}from"./3d/webgl-engine/lib/ShadowMap.js";import{terrainId as Xe}from"./3d/webgl-engine/lib/verticalOffsetUtils.js";import{cleanupEdgeProcessing as et}from"./3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js";import{cleanupDrapedUtils as tt}from"./support/drapedUtils.js";import{defaultHighlightName as it}from"./support/HighlightDefaults.js";import rt from"./support/HighlightOptions.js";import{occludeesSupported as st}from"./support/layerViewUtils.js";import{isSupportedScreenPointEvent as nt,createScreenPointFromSupportedEvent as at}from"./support/screenUtils.js";import{isSpatialReferenceSupported as ot}from"./support/spatialReferenceSupport.js";import{initializeTextureCompressionWorker as lt,destroyTextureCompressionWorker as pt}from"./support/TextureCompressionHelper.js";import{check as ht}from"./support/WebGLRequirements.js";import dt from"./ui/DefaultUI.js";import ut from"./ui/3d/DefaultUI3D.js";import ct from"../webscene/Environment.js";import{clearVNodeCache as gt}from"../widgets/support/vnodeCache.js";let mt=class extends(ie(ne(re(ae)))){constructor(e){super(e),this._userClippingArea=null,this._clippingArea=null,this._initialDefaultSpatialReference=null,this._overrideDefaultEnvironmentOnly=!0,this._resolveWhenReady=[],this._resourceController=De(this),this.deconflictor=new fe({view:this}),this.labeler=new we({view:this,deconflictor:this.deconflictor.labels}),this.sharedSymbolResources=null,this.analyses=new ee,this.basemapTerrain=null,this.elevationProvider=null,this._canvas=null,this.constraints=new ce,this.environment=new me,this.environmentManager=new ge,this.floors=new r,this.fullOpacity=1,this.graphicsView=null,this.analysisViewManager=new de({view:this}),this.groundView=null,this.map=null,this.screenSizePerspectiveEnabled=!0,this.state=new Me({view:this}),this.slice=new Ue,this.spatialReference=null,this.alphaCompositingEnabled=!1,this.preserveDrawingBufferEnabled=!1,this.supersampleScreenshotsEnabled=!0,this.type="3d",this.ui=new ut,this._numUpdating=0,this._lastUpdateTime=0,this.updatingProgress=.5,this._importControllers=new Map,V();const t=(e=null)=>{null!=e&&4===e.type||(this._updatingChanged(),this.map?.allLayers.forEach(async e=>{try{await e.when()}catch(t){}this._updatingChanged()}))};this.addHandles([u(()=>this.map?.allLayers,"after-changes",e=>t(e),{onListenerAdd:()=>t(),onListenerRemove:()=>t(),sync:!0}),this.allLayerViews.on("after-changes",e=>this._updateUpdatingMonitors(e)),c(()=>this.scene,e=>e?.load().catch(()=>{}))]),this.inputManager=new ye({view:this}),this.stateManager=new Se({view:this})}initialize(){if(has("enable-feature:esri-compress-textures")&&has("wasm-simd")){const e=lt(this,this.resourceController);this.addResolvingPromise(e.promise)}this.groundView=new se({view:this}),this._updateUpdatingMonitors(),this.updatingHandles.add(()=>this.qualitySettings.memoryLimit,e=>{this.resourceController&&(this.resourceController.memoryController.maxMemory=e)},g),this.updatingHandles.add(()=>this.qualitySettings.additionalCacheMemory,e=>{this.resourceController&&(this.resourceController.memoryController.additionalCacheMemory=e)},g),this.updatingHandles.add(()=>this.qualitySettings.frameRate??0,e=>w(e>0?1e3/Math.ceil(e):0),g),this.addHandles([c(()=>this.spatialReference,()=>this.notifyChange("clippingArea"),m),c(()=>({plane:this.slice.plane,isDecoration:this.slice.isDecoration}),()=>this._updateSlice(),m)])}destroy(){this.destroyed||(pt(this),this.updatingHandles.removeAll(),this.basemapTerrain?.clearHandles(),this.ui.removeAllHandles(),this.layerViewManager.clearHandles(),this.invalidate(),this.activeTool=null,this.layerViewManager.clear(),this._set("analysisViewManager",p(this.analysisViewManager)),this._exitSurface(),this._disposeGraphicsView(),this._disposeFocusAreasView(),this.sharedSymbolResources=p(this.sharedSymbolResources),this._set("labeler",p(this.labeler)),this._set("deconflictor",p(this.deconflictor)),this._resourceController=p(this._resourceController),this._set("stateManager",p(this.stateManager)),this._set("inputManager",p(this.inputManager)),this.state.destroy(),this.highlights.destroy(),this.removeHandles("updatingMonitors"),this._set("environmentManager",p(this.environmentManager)),this._set("environment",p(this.environment)),this.groundView=p(this.groundView),this._exitBasemapTerrain(),this.slice.destroy(),this._updatingObjectsWithProgress.length=0,this._updatingObjects.length=0,this.ui?.destroy(),this._set("ui",null),this._set("renderCanvas",null),this._set("canvas",null),this._canvas=null)}get stage(){return this._stage}get renderSpatialReference(){return this.renderCoordsHelper?.spatialReference}get basemapSpatialReference(){return this.basemapTerrain?.spatialReference}get animation(){return this.state?.animation}get camera(){return this.stateManager?.camera}set camera(e){this.stateManager&&(this.stateManager.camera=e)}get contentCamera(){return this.stateManager?.contentCamera}set contentCamera(e){this.stateManager&&(this.stateManager.contentCamera=e)}installContentCameraReset(e={sticky:!1}){return this.stateManager.installContentCameraReset(e)}get canvas(){return this._canvas}get center(){return this.stateManager?.center}set center(e){this.stateManager&&(this.stateManager.center=e)}get clippingArea(){if("global"===this.viewingMode)return null;const e=this.map;let t=this._userClippingArea||h(e,"clippingArea");return!this._userClippingArea&&!h(e,"clippingEnabled")||null==t?(this._clippingArea=null,null):t instanceof I?this.spatialReference&&(t=yt(t,this.spatialReference),null==t)?(l.getLogger(this).error("#clippingArea","setting clippingArea with incompatible SpatialReference"),this._clippingArea):(t=t.clone(),null==t.intersection(this._groundAndLayersExtent)&&(t.xmin=t.xmax,t.ymin=t.ymax),t.zmin=void 0,t.zmax=void 0,t.equals(this._clippingArea)||(this._clippingArea=t),this._clippingArea):(l.getLogger(this).error("#clippingArea","only clippingArea geometries of type Extent are supported"),this._clippingArea)}set clippingArea(e){this.ready&&"global"===this.viewingMode&&null!=e?l.getLogger(this).error("#clippingArea=","Clipping area is only supported in local viewingMode"):this._userClippingArea=e}get renderDataExtent(){if(1===this.state.viewingMode)return null;const e=this.renderSpatialReference,t=this.dataExtent;return null==t||null==e||t.spatialReference.equals(e)?t:yt(t,e)}get tileInfo(){return this.basemapTerrain?.tilingScheme?.toTileInfo()}get dataExtent(){let e=this._groundAndLayersExtent;const t=this.spatialReference||U.WGS84,i=yt(this.clippingArea,t);null!=i&&(e=null!=e?e.intersection(i):i);const r=this._get("dataExtent");return null!=e&&e.equals(r)?r:e}get _groundAndLayersExtent(){const e=this.spatialReference||U.WGS84;let t;const i=i=>{const r=yt(i,e);null!=r&&(null!=t?t.union(r):t=r.clone())},{basemapTerrain:r}=this;if(r?.spatialReference){const e=r.groundExtent;i(new I({xmin:e[0],ymin:e[1],zmin:0,xmax:e[2],ymax:e[3],zmax:0,spatialReference:r.spatialReference}))}const s=e=>{null==e.fullExtent||"graphics"===e.type&&e.internal||i(e.fullExtent)};if(this.map?.allLayers.forEach(e=>s(e)),null==t)return null;t.hasZ?(t.zmin=Math.min(0,t.zmin??0),t.zmax=Math.max(0,t.zmax??0)):(t.zmin=0,t.zmax=0);const n=this._get("_groundAndLayersExtent");return t.equals(n)?n:t}castEnvironment(e){return e?e instanceof me?e:e instanceof ct?this.environment?.cloneWithWebsceneEnvironment(e)??me.fromWebsceneEnvironment(e):T(me,e):new me}get extent(){return this.stateManager?.extent}set extent(e){this.stateManager&&(this.stateManager.extent=e)}get screenCenter(){return this.stateManager?.screenCenter}get frustum(){return this.stateManager?.frustum}get initialExtentRequired(){return this.stateManager&&!this.stateManager.hasInitialView}get defaultsFromMapSettings(){return{required:{tileInfo:!1,heightModelInfo:!0,extent:!1}}}get interacting(){return this.navigating||(this.toolViewManager?.interacting??!1)}get stationary(){return!this.animation&&!this.resizing&&(this.state?.stationary??!0)}get navigating(){return this.state?.navigating??!1}get scene(){return this.map&&te in this.map?this.map:null}get padding(){return this.stateManager?.padding}set padding(e){this.stateManager&&(this.stateManager.padding=e)}set qualityProfile(e){Oe.isValidProfile(e)&&(Oe.apply(e,this.qualitySettings),this.stage?.renderView.updateQualitySettings(this.qualitySettings),this._set("qualityProfile",e))}get qualityProfile(){return this._get("qualityProfile")||Oe.getDefaultProfile()}_updateSlice(){null!=this.stage&&(this.stage.renderer.slice=this.slice)}get typeSpecificPreconditionsReady(){return!!this.viewingMode&&!!this.stateManager?.preinit(this.spatialReference)}get resolution(){return null!=this.spatialReference?Q(this.scale,this.spatialReference):0}get scale(){return this.stateManager?.scale}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get heightModelInfo(){const e=this.getDefaultHeightModelInfo();return null!=e?P.deriveUnitFromSR(e,this.spatialReference):null}get updating(){if(this.destroying||this.destroyed)return!1;let e=0,t=this.layerViewManager.updating,i=t?this.layerViewManager.updatingRemaining:0;this.allLayerViews.forEach(r=>{if(r.isFulfilled()){if(r.updating){if(t=!0,r.suspended||ze(r))return;++i,e+=r.updatingProgress}}else++i});for(const s of this._updatingObjects)if(null!=s&&s.updating){const t=.1;i+=t,e+=.5*t}for(const s of this._updatingObjectsWithProgress)null!=s&&s.updating&&(++i,e+=s.updatingProgress);const r=!this.stateManager.test.updatingIgnoreRenderState&&this.state.updating;if(t=!!(t||i>0||this.updatingHandles.updating||!this.ready||!this.stationary||r||this._importControllers.size>0||this.inputManager?.updating||this.map?.allLayers?.some(e=>!e.isFulfilled())),t?(this._numUpdating=Math.max(i,this._numUpdating),e+=this._numUpdating-i):this._numUpdating=0,this._numUpdating>0?e/=this._numUpdating:e=t?0:1,this._get("updatingProgress")!==e){const i=performance.now();if(e<1){const t=Math.min((i-this._lastUpdateTime)/2e3,1);e=this.updatingProgress*(1-t)+e*t}this._set("updatingProgress",e),this._lastUpdateTime=t&&e<1?i:0}return t}get _updatingObjects(){return[this.graphicsView,this.basemapView,this._resourceController,this.stage,this.featureTiles,this.pointsOfInterest,this.environmentManager,this.overlay,this._featureTreeDebugger,this.toolViewManager,this.analysisViewManager]}get _updatingObjectsWithProgress(){return[this.deconflictor,this.labeler,this.basemapTerrain]}get viewingMode(){const e=this._predeterminedViewingMode;if(null!=e)return le(e);const t=this.spatialReference;return t?null!=this.defaultsFromMap?.viewingMode&&t.equals(this.defaultsFromMap.spatialReference)?le(this.defaultsFromMap.viewingMode):ot(t,1)?"global":"local":"global"}set viewingMode(e){this.ready?l.getLogger(this).error("#viewingMode","viewingMode cannot be set once view is ready"):this._overrideIfSome("viewingMode",e)}get viewpoint(){return this.stateManager?.viewpoint}set viewpoint(e){this.stateManager&&(this.stateManager.viewpoint=e)}get visibleArea(){return this.stateManager?.visibleArea}get zoom(){return this.stateManager.zoom}set zoom(e){this.stateManager&&(this.stateManager.zoom=e)}get highlightOptions(){return this.highlights.find(({name:e})=>e===it)??new rt}set highlightOptions(e){for(let t=0;t<this.highlights.length;++t){if(this.highlights.at(t).name===it)return void this.highlights.items[t].assignFrom(e)}}get resourceController(){return this._resourceController}get quality(){return this._resourceController?.memoryController?.memoryFactor??1}get resolutionScale(){return Math.sqrt(Math.min(1,this.quality/.75))}get performanceInfo(){return new Fe(this)}on(e,t,i,r){const s=this.viewEvents.on(e,t,i,r);return s||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}toMap(e,t){if(!this.ready)return l.getLogger(this).error("#toMap()","Scene view cannot be used before it is ready"),null;const i=nt(e)?at(this,e):e;return Ee(this,i,t,this._defaultToMapOptions)}toScreen(e){if(!this.ready)return l.getLogger(this).error("#toScreen()","Scene view cannot be used before it is ready"),null;const t=(null==e.z?Ae(this.elevationProvider,e):null)??0;return z(e,ft,this.renderSpatialReference,t),this.state.camera.projectToScreen(ft,wt),b(wt[0],wt[1])}pixelSizeAt(e,t){if(!this.ready)return l.getLogger(this).error("#pixelSizeAt()","Scene view cannot be used before it is ready"),null;if(!e)return 0;const i=this.renderSpatialReference;z(e,ft,i);const r=this.state.camera.computeScreenPixelSizeAt(ft);return t&&i!==t?r*S(i)/S(t):r}overlayPixelSizeInMapUnits(e){const t=this.basemapTerrain.overlayManager;return t?t.overlayPixelSizeInMapUnits(e,()=>this.pixelSizeAt(e)):1}hitTest(e,t){if(!this.ready)return l.getLogger(this).error("#hitTest()","Scene view cannot be used before it is ready"),null;const i=nt(e)?at(this,e):e;return Le(this,i,t,this._defaultHitTestOptions)}async popupHitTest(e){return He(this,e)}goTo(e,t){return this.updatingHandles.addPromise(this.stateManager.goTo(e,t))}async whenAnalysisView(e){if(null==e.parent)throw new n("view:no-analysisview-for-analysis","The analysis has not been added to view.analyses",{analysis:e});switch(e.parent.type){case"line-of-sight":case"dimension":case"viewshed":return(await this.whenLayerView(e.parent)).whenAnalysisView();default:return this.analysisViewManager.whenAnalysisView(e)}}whenLayerView(e){return super.whenLayerView(e)}async takeScreenshot(e){const t=await this._completeSettings(e);await this.whenReady();const i=(await this.stage.renderView.takeScreenshot(t))[0];return(await import("./support/screenshotUtils.js")).encode(i,t,this._pixelFormat())}async _takeScreenshot(e){const t=await this._completeSettings(e);await this.whenReady();const i=(await this.stage.renderView.takeScreenshot(t))[0];return(await import("./support/screenshotUtils.js")).encodeData(i,this._pixelFormat())}async _takeScreenshotWithObjectAndLayerId(e){const t=await this._completeSettings(e);t.objectAndLayerIdColor=!0,await this.whenReady();const i=await this.stage.renderView.takeScreenshot(t),{encodeData:r}=await import("./support/screenshotUtils.js");return[r(i[0],this._pixelFormat()),r(i[1],this._pixelFormat())]}async _completeSettings(e){const{toRenderSettings:t,screenshotSuperSampleSettings:i}=await import("./support/screenshotUtils.js"),r=t(e,this);return r.pixelRatio/=this.state.pixelRatio,i(r,this.supersampleScreenshotsEnabled,this.padding)}_pixelFormat(){return{flipY:!0,premultipliedAlpha:this.stage?.renderView.getAlpha()??!1}}get test(){}async takeScreenshotWithObjectAndLayerId(e){if(!Ze())throw new n("360vr:objectAndLayerId-rendering-disabled","has enable-feature:objectAndLayerId-rendering must be true");const{encode:t}=await import("./support/screenshotUtils.js"),i=await this._completeSettings(e);i.objectAndLayerIdColor=!0,await this.whenReady();const r=await this.stage.renderView.takeScreenshot(i),s=t(r[0],i,this._pixelFormat()),a=await this._completeSettings(e);a.format="png";return[s,t(r[1],a,this._pixelFormat())]}getColorToObjectAndLayerIdMapping(){const e=this.stage.renderView.olidRenderHelper;if(e)return e.getColorToObjectAndLayerIdMapping();throw new n("360vr:objectAndLayerId-rendering-disabled","has enable-feature:objectAndLayerId-rendering must be true")}addUpdatingPromise(e){return this.updatingHandles.addPromise(e)}importLayerView(e){return he.importLayerView(e)}hasLayerViewModule(e){return he.hasLayerViewModule(e)}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){return this.scene?.initialViewProperties?.spatialReference||this.defaultsFromMap?.spatialReference||this.defaultsFromMap?.ready&&this._initialDefaultSpatialReference||null}async validate(){let e=ht(this.type);const t=has("safari");if(t&&t<9&&(e=new n("sceneview:browser-not-supported","This browser is not supported by SceneView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:t})),null!=e)throw l.getLogger(this).warn("#validate()",e.message),e}get _predeterminedViewingMode(){const e=this._isOverridden("viewingMode")?this._get("viewingMode"):this.scene?.initialViewProperties?.viewingMode;return null!=e?pe(e):null}getSpatialReferenceSupport(e,t){const i=this._predeterminedViewingMode;if(null!=i)return this._validateSpatialReferenceForViewingMode(e,t,i)?{constraints:this._makeSpatialReferenceConstraints(e,t,i)}:null;const r=this._validateSpatialReferenceForViewingMode(e,t,2),s=this._validateSpatialReferenceForViewingMode(e,t,1);return r||s?r&&s?{constraints:this._makeSpatialReferenceConstraints(e,t,null)}:r?{constraints:this._makeSpatialReferenceConstraints(e,t,2)}:{constraints:this._makeSpatialReferenceConstraints(e,t,1)}:null}_validateSpatialReferenceForViewingMode(e,t,i){return!!ot(e,i)&&(null==t||(!!Y(t)||(!Z(t)||null!=ke(t,e,i))&&(!$(t)||1!==i)))}_makeSpatialReferenceConstraints(e,t,i){if(null==t)return[{spatialReference:e,viewingMode:i}];const{isWebMercator:r,isWGS84:s}=e;if(Y(t)&&(r||s)){return!s||2===i||null===Be(t.tileInfo,t.fullExtent,e,1)?[{spatialReference:e,viewingMode:i},{spatialReference:U.WebMercator,viewingMode:i}]:[{spatialReference:r?U.WGS84:U.WebMercator,viewingMode:i}]}return Z(t)||$(t)||!r&&!s?Z(t)&&r&&1!==i?[{spatialReference:e,viewingMode:i},{spatialReference:U.WGS84,viewingMode:2}]:[{spatialReference:e,viewingMode:i}]:[{spatialReference:e,viewingMode:i},{spatialReference:r?U.WGS84:U.WebMercator,viewingMode:i}]}_validateSpatialReference(e){const t=null!=this.getSpatialReferenceSupport(e),i=this._predeterminedViewingMode;return t||(null!=i?l.getLogger(this).warnOnce(`Spatial reference defined on view not supported in ${le(i)} viewing mode.`):e.isGeographic&&l.getLogger(this).warnOnce("Spatial reference is geographic but not supported.")),t}whenReady(){return new Promise(e=>{this.ready?e(this):this._resolveWhenReady.push(e)})}trackGraphicState(e){if(!e.graphic)return l.getLogger(this).error("trackGraphicState","GraphicState.graphic must not be null or undefined to start tracking"),null;const t=this.getViewForGraphic(e.graphic);let i=null,r=!1;const s=t=>{!r&&null!=t&&"processor"in t&&"graphics-3d"===t.processor?.type&&t.processor.graphicsCore&&(i=t.processor.graphicsCore.trackGraphicState(e))};return null!=t?s(t):this.whenViewForGraphic(e.graphic,{waitForLayer:!0}).then(e=>s(e),()=>{}).catch(()=>{}),o(()=>{r=!0,null!=i&&(i.remove(),i=null)})}maskOccludee(e){if(!e)return l.getLogger(this).error("maskOccludee","GraphicState.graphic must not be null or undefined to mask an occludee"),null;const t=this.getViewForGraphic(e);let i=null,r=!1;const s=t=>{!r&&null!=t&&st(t)&&(i=t.maskOccludee(e))};return null!=t?s(t):this.whenViewForGraphic(e,{waitForLayer:!0}).then(e=>s(e),()=>{}).catch(()=>{}),o(()=>{r=!0,null!=i&&(i.remove(),i=null)})}getViewForGraphic(e){return e.layer===this?this.graphicsView:e.layer?this.allLayerViews.filter(e=>"media-3d"!==e.type).find(t=>t.layer===e.layer):null}graphicChanged(e){null!=this.graphicsView&&this.graphicsView.graphicChanged(e)}async whenViewForGraphic(e,t){return e.layer===this?(await y(()=>this.graphicsView),this.graphicsView):e.layer&&this.map?t&&t.waitForLayer&&!this.map.allLayers.includes(e.layer)?new Promise((t,i)=>{const r=this.map.allLayers.on("change",s=>{s.added.includes(e.layer)&&(r.remove(),this.whenLayerView(e.layer).then(t,i))})}):this.whenLayerView(e.layer):null}async _importModule(e,t){const i=new AbortController;this._importControllers.set(e,i),this._updatingChanged();try{const r=await _t[e]();return t&&(d(i.signal),await t(i.signal)),d(i.signal),this._importControllers.delete(e),r}catch{this._importControllers.delete(e)}return null}_abortImport(e){this._importControllers.get(e)?.abort(),this._importControllers.delete(e),this._updatingChanged()}_initBasemapTerrain(){this._set("basemapTerrain",new qe({view:this})),this._set("elevationProvider",new Te({view:this})),this.elevationProvider.register("ground",this.basemapTerrain)}_exitBasemapTerrain(){const{basemapTerrain:e,elevationProvider:t}=this;e&&(this._set("basemapTerrain",null),this._set("elevationProvider",null),t.unregister(e),t.destroy(),e.destroy())}_initGlobe(){this._initCoordinateSystem(),this.state.createInitialCamera(),this._initBasemapTerrain(),this._set("pointsOfInterest",new We({view:this})),this._set("featureTiles",new _e({renderCoordsHelper:this.renderCoordsHelper,cameraOnSurface:this.pointsOfInterest.cameraOnSurface,focus:this.pointsOfInterest.focus,tilingSchemeOwner:this.basemapTerrain,viewState:this.state,scheduler:this._resourceController.scheduler,terrain:this.basemapTerrain}));const e=()=>{const e=this.basemapTerrain?.extent;if(this.clippingArea||e)if(e&&this.basemapTerrain.spatialReference){const e=null!=this.basemapTerrain.extent&&null!=this.basemapTerrain.spatialReference?F(B(this.basemapTerrain.extent,this.basemapTerrain.spatialReference),this.spatialReference):null;this.clippingArea?this.featureTiles.filterExtent=this.clippingArea.intersection(e):this.featureTiles.filterExtent=e}else this.featureTiles.filterExtent=this.clippingArea;else this.featureTiles.filterExtent=null};this.addHandles([this.updatingHandles.add(()=>xe.FEATURE_TILE_TREE_SHOW_TILES,e=>{e&&this.featureTiles&&!this._featureTreeDebugger?this.updatingHandles.addPromise(import("./3d/layers/support/FeatureTileTree3DDebugger.js")).then(({FeatureTileTree3DDebugger:e})=>{!this._featureTreeDebugger&&xe.FEATURE_TILE_TREE_SHOW_TILES&&(this._featureTreeDebugger=new e({view:this}))}):e||!this._featureTreeDebugger||xe.FEATURE_TILE_TREE_SHOW_TILES||(this._featureTreeDebugger.destroy(),this._featureTreeDebugger=null)},f),this.updatingHandles.add(()=>this.clippingArea,e,f),this.updatingHandles.add(()=>this.basemapTerrain.extent,e,f)],"feature-tiles"),this.stateManager.init()}_exitGlobe(){this.featureTiles&&(this.stateManager.exit(),this.removeHandles("render-coords-helper"),this.removeHandles("feature-tiles"),this._set("featureTiles",p(this.featureTiles)),this._set("pointsOfInterest",p(this.pointsOfInterest)),this._exitBasemapTerrain(),this.state.reset(),this._exitCoordinateSystem())}_initCoordinateSystem(){if(this.spatialReference){const e=this.spatialReference,t=this.state.isGlobal,i=N(t,e);i!==this.renderSpatialReference&&(this._set("renderCoordsHelper",Pe.create(this.state.viewingMode,i)),t||this.addHandles(c(()=>this.basemapTerrain?.extent,e=>{const t=this.renderCoordsHelper.spatialReference;null==e||0===e[0]&&0===e[1]&&0===e[2]&&0===e[3]||!q(e,this.basemapTerrain.spatialReference,vt,t)||(this.renderCoordsHelper.extent=vt)},m),"render-coords-helper"),this.sceneIntersectionHelper&&this.sceneIntersectionHelper.setTolerance(Je/this.renderCoordsHelper.unitInMeters))}else this._set("renderCoordsHelper",null)}_exitCoordinateSystem(){this.removeHandles("render-coords-helper"),this._set("renderCoordsHelper",null)}_updatingChanged(){this.notifyChange("updating")}_updateUpdatingMonitors(e=null){null!=e&&4===e.type||(this.removeHandles("updatingMonitors"),this.allLayerViews.forEach(e=>{e.destroyed||(this.addHandles(c(()=>[e.updating,e.updatingProgress],()=>this._updatingChanged(),m),"updatingMonitors"),e.when(()=>this._updatingChanged(),()=>this._updatingChanged()))}),this._updatingChanged())}async _prepareScreenshotOverlay(){this.overlay&&await this.overlay.prepare()}_renderScreenshotOverlay(e,t,i){if(!this.overlay||!this.overlay.hasVisibleItems)return i;const r=e.getContext("2d",{willReadFrequently:!0});return r.putImageData(i,0,0),this.overlay.renderCanvas(e,{disableDecorations:t}),r.getImageData(0,0,i.width,i.height)}_initStage(){const e={deactivatedWebGLExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions,alpha:this.alphaCompositingEnabled,preserveDrawingBuffer:this.preserveDrawingBufferEnabled,canvas:this.renderCanvas,screenshot:{prepareOverlay:()=>this._prepareScreenshotOverlay(),renderOverlay:(e,t,i)=>this._renderScreenshotOverlay(e,t,i)}},t=new Re(this.state.viewingMode,e=>this.stage.layers.forAll(e),this);this._set("sceneIntersectionHelper",t);const i=s(this.surface);this._stage=new Ye({view:this,options:e,container:i}),this.notifyChange("stage"),this._updateSlice(),this.addHandles([this.updatingHandles.add(()=>this.qualitySettings.highQualityTransparency,e=>this.stage.renderer.setParameters({highQualityTransparency:e}),g),this.on("pointer-move",()=>this.stage?.renderer.resetAnimation()),a(this.stage.renderView.canvas,"webglcontextlost",e=>{this.fatalError=new n("webgl-context-lost",e.statusMessage)})],"stage"),this.renderCoordsHelper&&this.sceneIntersectionHelper.setTolerance(Je/this.renderCoordsHelper.unitInMeters),this._set("canvas",this.stage.renderView.canvas)}_exitStage(){this.sceneIntersectionHelper?.destroy(),this._set("sceneIntersectionHelper",null),this._stage=p(this.stage),this._set("stage",null),this.removeHandles("stage"),this._set("canvas",null)}_initSurface(e){this._exitSurface(),this._initStage(),this._initGlobe(),this.sharedSymbolResources=new Ge({view:this,viewingMode:e,resourceController:this._resourceController,pointsOfInterest:this.pointsOfInterest,viewState:this.state})}_exitSurface(){this.sharedSymbolResources&&(this.sharedSymbolResources.objectResourceCache.destroy(),this.sharedSymbolResources.destroy(),this.sharedSymbolResources=null,this._exitGlobe(),this._exitStage())}async _ensureGraphicsView(){if(this.graphicsView||this._importControllers.has("GraphicsView3D")||0===this.graphics.length)return;this.removeHandles("GraphicsView3D");const e=(await this._importModule("GraphicsView3D",e=>y(()=>this.basemapTerrain?.ready,e)))?.default;e&&this._set("graphicsView",new e({view:this,getGraphics:()=>this.graphics})),this._updatingChanged()}_disposeGraphicsView(){this._abortImport("GraphicsView3D"),this.removeHandles("GraphicsView3D"),this.graphicsView&&(this.removeHandles(this.graphicsView.processor.layer.id),this.graphicsView.destroy(),this._set("graphicsView",null))}_disposeFocusAreasView(){this._abortImport("FocusAreasView"),this.removeHandles("FocusAreasView"),this.focusAreasView=p(this.focusAreasView)}async _ensureFocusAreasView(e){if(this.focusAreasView||this._importControllers.has("FocusAreasView")||0===e)return;this.removeHandles("FocusAreasView");const t=(await this._importModule("FocusAreasView"))?.FocusAreasView;t&&(this.focusAreasView=new t({view:this})),this._updatingChanged()}_startup(){const e=pe(this.viewingMode);1===e&&(this._clippingArea=null),this._initSurface(e),this._set("ready",!0),this.addHandles(u(()=>this.graphics,"after-changes",()=>this._ensureGraphicsView()),"GraphicsView3D"),this._ensureGraphicsView(),this.addHandles(c(()=>this.map?.focusAreas?.areas.length??0,e=>this._ensureFocusAreasView(e),{initial:!0}),"FocusAreasView");const t=this.scene?.initialViewProperties??null,i=t?.environment;i&&(this._overrideDefaultEnvironmentOnly?O(this.environment,i):this.environment=this.environment.cloneWithWebsceneEnvironment(i)),this.timeExtent=t?.timeExtent,t?.analyses.applyTo(this),this.labeler.setup(),this.environmentManager.connectView(this),this.inputManager.connect();const r=this._resolveWhenReady;this._resolveWhenReady=[],r.forEach(e=>e(this))}_teardown(){this._initialDefaultSpatialReference=null,this.inputManager.disconnect(),this.environmentManager.disconnectView(),this._overrideDefaultEnvironmentOnly=!1,this.labeler.dispose(),this._disposeGraphicsView(),this._disposeFocusAreasView(),this._exitSurface(),this._set("ready",!1)}get _defaultToMapOptions(){const e={include:new Set};if(!this.map)return e;this.map.ground&&e.include.add(Xe);for(const t of this.allLayerViews)J(t.layer.type)&&e.include.add(t.uid);return e}get _defaultHitTestOptions(){const e={exclude:new Set};if(!this.map)return e;this.map.ground&&this.map.ground.opacity<1&&e.exclude.add(Xe);for(const t of this.allLayerViews)J(t.layer.type)&&t.layer.opacity<1&&e.exclude.add(t.uid);return e}static{this.type="3d"}static clearStatics(){gt(),A(),M(),et(),Ve(),ue(),be(),W(),tt(),X(),Qe(),Ke(),je(),Ce(),L(),v(),$e(),Ne(),ve.cleanupI3SLodHandling(),K.cleanupTilemapCache(),Me.cleanupViewstate(),qe.cleanupTerrainSurface()}};function yt(e,t){return null!=e&&G(e.spatialReference,t)?F(e,t):null}e([j()],mt.prototype,"_userClippingArea",void 0),e([j()],mt.prototype,"_resourceController",void 0),e([j()],mt.prototype,"stage",null),e([j({readOnly:!0})],mt.prototype,"deconflictor",void 0),e([j({readOnly:!0})],mt.prototype,"labeler",void 0),e([j(H(ee,"analyses"))],mt.prototype,"analyses",void 0),e([j({type:oe,readOnly:!0})],mt.prototype,"animation",null),e([j({readOnly:!0})],mt.prototype,"basemapTerrain",void 0),e([j({readOnly:!0})],mt.prototype,"elevationProvider",void 0),e([j()],mt.prototype,"camera",null),e([j({type:t})],mt.prototype,"contentCamera",null),e([j({readOnly:!0})],mt.prototype,"canvas",null),e([j({type:D})],mt.prototype,"center",null),e([j({type:I})],mt.prototype,"clippingArea",null),e([j({type:ce})],mt.prototype,"constraints",void 0),e([j({type:I,readOnly:!0})],mt.prototype,"renderDataExtent",null),e([j({readOnly:!0})],mt.prototype,"tileInfo",null),e([j({type:I,readOnly:!0})],mt.prototype,"dataExtent",null),e([j({type:I,readOnly:!0})],mt.prototype,"_groundAndLayersExtent",null),e([j({type:me})],mt.prototype,"environment",void 0),e([R("environment")],mt.prototype,"castEnvironment",null),e([j({readOnly:!0})],mt.prototype,"environmentManager",void 0),e([j({type:I})],mt.prototype,"extent",null),e([j({type:r})],mt.prototype,"floors",void 0),e([j()],mt.prototype,"screenCenter",null),e([j()],mt.prototype,"frustum",null),e([j({type:Number,readOnly:!0})],mt.prototype,"fullOpacity",void 0),e([j({readOnly:!0})],mt.prototype,"graphicsView",void 0),e([j({})],mt.prototype,"analysisViewManager",void 0),e([j()],mt.prototype,"groundView",void 0),e([j({type:Boolean})],mt.prototype,"initialExtentRequired",null),e([j()],mt.prototype,"defaultsFromMapSettings",null),e([j()],mt.prototype,"interacting",null),e([j()],mt.prototype,"stationary",null),e([j()],mt.prototype,"navigating",null),e([j()],mt.prototype,"map",void 0),e([j()],mt.prototype,"padding",null),e([j({type:We,readOnly:!0})],mt.prototype,"pointsOfInterest",void 0),e([j({type:_e,readOnly:!0})],mt.prototype,"featureTiles",void 0),e([j()],mt.prototype,"_featureTreeDebugger",void 0),e([j({type:Boolean})],mt.prototype,"screenSizePerspectiveEnabled",void 0),e([j({constructOnly:!0})],mt.prototype,"deactivatedWebGLExtensions",void 0),e([j({constructOnly:!0})],mt.prototype,"debugWebGLExtensions",void 0),e([j({constructOnly:!0})],mt.prototype,"renderCanvas",void 0),e([j({constructOnly:!0})],mt.prototype,"state",void 0),e([j({readOnly:!0})],mt.prototype,"inputManager",void 0),e([j({readOnly:!0})],mt.prototype,"stateManager",void 0),e([j({type:["low","medium","high"]})],mt.prototype,"qualityProfile",null),e([j({type:Ie,get(){let e=this._get("qualitySettings");return e||(e=new Ie,Oe.apply(this.qualityProfile,e)),e}})],mt.prototype,"qualitySettings",void 0),e([j()],mt.prototype,"slice",void 0),e([j({readOnly:!0})],mt.prototype,"typeSpecificPreconditionsReady",null),e([j({readOnly:!0})],mt.prototype,"renderCoordsHelper",void 0),e([j({readOnly:!0})],mt.prototype,"sceneIntersectionHelper",void 0),e([j({type:Number,dependsOn:["scale","spatialReference"],readOnly:!0})],mt.prototype,"resolution",null),e([j({type:Number})],mt.prototype,"scale",null),e([j()],mt.prototype,"heightModelInfo",null),e([j()],mt.prototype,"spatialReference",void 0),e([j({type:Boolean,constructOnly:!0})],mt.prototype,"alphaCompositingEnabled",void 0),e([j({constructOnly:!0})],mt.prototype,"preserveDrawingBufferEnabled",void 0),e([j({type:Boolean})],mt.prototype,"supersampleScreenshotsEnabled",void 0),e([j({readOnly:!0})],mt.prototype,"type",void 0),e([j(),R(e=>e instanceof dt?e:x(ut,e))],mt.prototype,"ui",void 0),e([j({type:Boolean,readOnly:!0,dependsOn:["graphicsView.updating","basemapView.updating","basemapTerrain.updating","layerViewManager.updating","layerViewManager.updatingRemaining","_resourceController.updating","stage.updating","featureTiles.updating","pointsOfInterest.updating","environmentManager.updating","overlay.updating","updatingHandles.updating","featureTreeDebugger.updating","labeler.updating","deconflictor.updating","ready","stationary","inputManager.updating","toolViewManager.updating","analysisViewManager.updating","state.updating","textures.updating"]})],mt.prototype,"updating",null),e([j()],mt.prototype,"_updatingObjects",null),e([j()],mt.prototype,"_updatingObjectsWithProgress",null),e([j({type:Number,readOnly:!0,dependsOn:["updating"]})],mt.prototype,"updatingProgress",void 0),e([j({type:["global","local"]})],mt.prototype,"viewingMode",null),e([j({type:i})],mt.prototype,"viewpoint",null),e([j({readOnly:!0})],mt.prototype,"visibleArea",null),e([j({type:Number})],mt.prototype,"zoom",null),e([j({type:rt})],mt.prototype,"highlightOptions",null),e([j({readOnly:!0})],mt.prototype,"quality",null),e([j({readOnly:!0})],mt.prototype,"resolutionScale",null),e([j()],mt.prototype,"focusAreasView",void 0),e([j()],mt.prototype,"_defaultToMapOptions",null),e([j()],mt.prototype,"_defaultHitTestOptions",null),mt=e([C("esri.views.SceneView")],mt);const ft=E(),wt=_(),vt=k(),_t={GraphicsView3D:()=>import("./3d/layers/GraphicsView3D.js"),FocusAreasView:()=>import("./3d/FocusAreasView.js")},bt=mt;export{bt as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../Camera.js";import i from"../Viewpoint.js";import r from"../core/Collection.js";import{byId as s}from"../core/domUtils.js";import n from"../core/Error.js";import{on as a}from"../core/events.js";import{makeHandle as o}from"../core/handleUtils.js";import has from"../core/has.js";import l from"../core/Logger.js";import{destroyMaybe as p,maybeProperty as h}from"../core/maybe.js";import{throwIfDestroyed as d,throwIfAborted as u,createAbortError as c}from"../core/promiseUtils.js";import g from"../core/ReactiveSet.js";import{on as m,watch as y,initial as f,sync as w,whenOnce as v,syncAndInitial as _}from"../core/reactiveUtils.js";import{setFrameDuration as b,cleanupScheduling as M}from"../core/scheduling.js";import{createScreenPointArray as S,createScreenPoint as V}from"../core/screenUtils.js";import{cleanupWhereClauseCache as j}from"../core/sql.js";import{getMetersPerUnitForSR as C}from"../core/unitUtils.js";import{initialize as T}from"../core/workers/workers.js";import{property as R}from"../core/accessorSupport/decorators/property.js";import{cast as x}from"../core/accessorSupport/decorators/cast.js";import"../core/RandomLCG.js";import{subclass as O}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as A,ensureClass as E}from"../core/accessorSupport/ensureType.js";import{overrideDefaultsFrom as H}from"../core/accessorSupport/overrideDefaultsFrom.js";import{drainNotificationQueue as L}from"../core/accessorSupport/trackingUtils.js";import{create as I}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import{cleanupPooledRBush as P}from"../core/libs/rbush/PooledRBush.js";import{owningCollectionProperty as F}from"../core/support/OwningCollection.js";import D from"../geometry/Extent.js";import G from"../geometry/HeightModelInfo.js";import U from"../geometry/Point.js";import{project as W,canProjectWithoutEngine as q}from"../geometry/projectionUtils.js";import z from"../geometry/SpatialReference.js";import{cleanupSpatialReferenceEllipsoidUtils as k}from"../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingRect as B}from"../geometry/projection/projectBoundingRect.js";import{projectPointToVector as N}from"../geometry/projection/projectPointToVector.js";import{toExtent as Q,create as Y}from"../geometry/support/aaBoundingRect.js";import{renderSRFromViewSR as Z}from"../geometry/support/coordinateSystem.js";import{getResolutionForScale as $}from"../geometry/support/scaleUtils.js";import{isImageryTileLayer as J,isTiledLayer as K,isVoxelLayer as X,isIntegratedMeshLayer as ee}from"../layers/support/layerUtils.js";import{TilemapCache as te}from"../layers/support/TilemapCache.js";import{clearDefaultPortalInstance as ie}from"../portal/portalDefault.js";import{AnalysesCollection as re}from"../support/AnalysesCollection.js";import{WebSceneTag as se}from"../support/tagSymbols.js";import{BreakpointsOwner as ne}from"./BreakpointsOwner.js";import{DOMContainer as ae}from"./DOMContainer.js";import oe from"./GroundView.js";import{PopupView as le}from"./PopupView.js";import pe from"./View.js";import he from"./ViewAnimation.js";import{stringFromViewingMode as de,viewingModeFromString as ue}from"./ViewingMode.js";import{layerView3DImporter as ce}from"./3d/layerViewModuleImportUtils.js";import ge from"./3d/analysis/AnalysisViewManager3D.js";import{cleanupIntersectionUtils as me}from"./3d/camera/intersectionUtils.js";import{Constraints as ye}from"./3d/constraints/Constraints.js";import{EnvironmentManager as fe}from"./3d/environment/EnvironmentManager.js";import we from"./3d/environment/SceneViewEnvironment.js";import ve from"./3d/input/SceneInputManager.js";import{GraphicsDeconflictor as _e}from"./3d/layers/graphics/GraphicsDeconflictor.js";import{Labeler as be}from"./3d/layers/graphics/Labeler.js";import Me from"./3d/layers/i3s/I3SLodHandling.js";import{cleanupStageLayerElevationProvider as Se}from"./3d/layers/support/StageLayerElevationProvider.js";import Ve from"./3d/state/ViewState.js";import{ViewStateManager as je,cleanupViewStateManager as Ce}from"./3d/state/ViewStateManager.js";import{cleanupPointToPointAnimationController as Te}from"./3d/state/controllers/PointToPointAnimationController.js";import{SceneIntersectionHelper as Re}from"./3d/state/helpers/SceneIntersectionHelper.js";import{cleanupNavigationUtils as xe}from"./3d/state/utils/navigationUtils.js";import{CombinedElevationProvider as Oe}from"./3d/support/CombinedElevationProvider.js";import{debugFlags as Ae}from"./3d/support/debugFlags.js";import Ee from"./3d/support/DisplayQualityProfile.js";import{getElevationAtPoint as He}from"./3d/support/ElevationProvider.js";import{toMap as Le,hitTest as Ie}from"./3d/support/hitTest.js";import{popupHitTest as Pe}from"./3d/support/popupHitTest.js";import Fe from"./3d/support/QualitySettings.js";import{RenderCoordsHelper as De}from"./3d/support/RenderCoordsHelper.js";import{newResourceController as Ge}from"./3d/support/ResourceController.js";import Ue from"./3d/support/SceneViewPerformanceInfo.js";import{SharedSymbolResources as We}from"./3d/support/SharedSymbolResources.js";import{ViewSlice as qe}from"./3d/support/ViewSlice.js";import{PointsOfInterest as ze}from"./3d/support/pointsOfInterest/PointsOfInterest.js";import ke from"./3d/terrain/TerrainSurface.js";import{isSurfaceLayerView as Be,getTiledLayerInfo as Ne,checkIfTileInfoSupportedForView as Qe}from"./3d/terrain/terrainUtils.js";import{clearTilePerLayerInfo as Ye}from"./3d/terrain/TilePerLayerInfo.js";import{cleanupTileRenderer as Ze}from"./3d/terrain/TileRenderer.js";import{Stage as $e}from"./3d/webgl-engine/Stage.js";import{olidEnabled as Je}from"./3d/webgl-engine/effects/geometry/olidUtils.js";import{cleanupRenderOccluded as Ke}from"./3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js";import{defaultTolerance as Xe}from"./3d/webgl-engine/lib/Intersector.js";import{cleanupShadowmap as et}from"./3d/webgl-engine/lib/ShadowMap.js";import{terrainId as tt}from"./3d/webgl-engine/lib/verticalOffsetUtils.js";import{cleanupEdgeProcessing as it}from"./3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js";import{cleanupDrapedUtils as rt}from"./support/drapedUtils.js";import{defaultHighlightName as st}from"./support/HighlightDefaults.js";import nt from"./support/HighlightOptions.js";import{occludeesSupported as at}from"./support/layerViewUtils.js";import{isSupportedScreenPointEvent as ot,createScreenPointFromSupportedEvent as lt}from"./support/screenUtils.js";import{isSpatialReferenceSupported as pt}from"./support/spatialReferenceSupport.js";import{initializeTextureCompressionWorker as ht,destroyTextureCompressionWorker as dt}from"./support/TextureCompressionHelper.js";import{check as ut}from"./support/WebGLRequirements.js";import ct from"./ui/DefaultUI.js";import gt from"./ui/3d/DefaultUI3D.js";import mt from"../webscene/Environment.js";import{clearVNodeCache as yt}from"../widgets/support/vnodeCache.js";const ft=Symbol(),wt=Symbol();let vt=class extends(ne(le(ae(pe)))){constructor(e){super(e),this._userClippingArea=null,this._clippingArea=null,this._initialDefaultSpatialReference=null,this._overrideDefaultEnvironmentOnly=!0,this._resolveWhenReady=[],this._resourceController=Ge(this),this.deconflictor=new _e({view:this}),this.labeler=new be({view:this,deconflictor:this.deconflictor.labels}),this.sharedSymbolResources=null,this.analyses=new re,this.basemapTerrain=null,this.elevationProvider=null,this._canvas=null,this.constraints=new ye,this.environment=new we,this.environmentManager=new fe,this.floors=new r,this.fullOpacity=1,this.graphicsView=null,this.analysisViewManager=new ge({view:this}),this.groundView=null,this.map=null,this._featureTileTreeClients=new g,this._featureTiles=null,this._featureTreeDebugger=null,this.screenSizePerspectiveEnabled=!0,this.state=new Ve({view:this}),this.slice=new qe,this.spatialReference=null,this.alphaCompositingEnabled=!1,this.preserveDrawingBufferEnabled=!1,this.supersampleScreenshotsEnabled=!0,this.type="3d",this.ui=new gt,this._numUpdating=0,this._lastUpdateTime=0,this.updatingProgress=.5,this._importControllers=new Map,T();const t=(e=null)=>{null!=e&&4===e.type||(this._updatingChanged(),this.map?.allLayers.forEach(async e=>{try{await e.when()}catch(t){}this._updatingChanged()}))};this.addHandles([m(()=>this.map?.allLayers,"after-changes",e=>t(e),{onListenerAdd:()=>t(),onListenerRemove:()=>t(),sync:!0}),this.allLayerViews.on("after-changes",e=>this._updateUpdatingMonitors(e)),y(()=>this.scene,e=>e?.load().catch(()=>{}))]),this.inputManager=new ve({view:this}),this.stateManager=new je({view:this})}initialize(){if(has("enable-feature:esri-compress-textures")&&has("wasm-simd")){const e=ht(this,this.resourceController);this.addResolvingPromise(e.promise)}this.groundView=new oe({view:this}),this._updateUpdatingMonitors(),this.updatingHandles.add(()=>this.qualitySettings.memoryLimit,e=>{this.resourceController&&(this.resourceController.memoryController.maxMemory=e)},f),this.updatingHandles.add(()=>this.qualitySettings.additionalCacheMemory,e=>{this.resourceController&&(this.resourceController.memoryController.additionalCacheMemory=e)},f),this.updatingHandles.add(()=>this.qualitySettings.frameRate??0,e=>b(e>0?1e3/Math.ceil(e):0),f),this.addHandles([y(()=>this.spatialReference,()=>this.notifyChange("clippingArea"),w),y(()=>({plane:this.slice.plane,isDecoration:this.slice.isDecoration}),()=>this._updateSlice(),w)])}destroy(){this.destroyed||(dt(this),this.updatingHandles.removeAll(),this.basemapTerrain?.clearHandles(),this.ui.removeAllHandles(),this.layerViewManager.clearHandles(),this.invalidate(),this.activeTool=null,this.layerViewManager.clear(),this._set("analysisViewManager",p(this.analysisViewManager)),this._exitSurface(),this._disposeGraphicsView(),this._disposeFocusAreasView(),this.sharedSymbolResources=p(this.sharedSymbolResources),this._set("labeler",p(this.labeler)),this._set("deconflictor",p(this.deconflictor)),this._resourceController=p(this._resourceController),this._set("stateManager",p(this.stateManager)),this._set("inputManager",p(this.inputManager)),this.state.destroy(),this.highlights.destroy(),this.removeHandles("updatingMonitors"),this._set("environmentManager",p(this.environmentManager)),this._set("environment",p(this.environment)),this.groundView=p(this.groundView),this.slice.destroy(),this._updatingObjectsWithProgress.length=0,this._updatingObjects.length=0,this.ui?.destroy(),this._set("ui",null),this._set("renderCanvas",null),this._set("canvas",null),this._canvas=null)}get stage(){return this._stage}get renderSpatialReference(){return this.renderCoordsHelper?.spatialReference}get basemapSpatialReference(){return this.basemapTerrain?.spatialReference}get animation(){return this.state?.animation}get camera(){return this.stateManager?.camera}set camera(e){this.stateManager&&(this.stateManager.camera=e)}get contentCamera(){return this.stateManager?.contentCamera}set contentCamera(e){this.stateManager&&(this.stateManager.contentCamera=e)}installContentCameraReset(e={sticky:!1}){return this.stateManager.installContentCameraReset(e)}get canvas(){return this._canvas}get center(){return this.stateManager?.center}set center(e){this.stateManager&&(this.stateManager.center=e)}get clippingArea(){if("global"===this.viewingMode)return null;const e=this.map;let t=this._userClippingArea||h(e,"clippingArea");return!this._userClippingArea&&!h(e,"clippingEnabled")||null==t?(this._clippingArea=null,null):t instanceof D?this.spatialReference&&(t=_t(t,this.spatialReference),null==t)?(l.getLogger(this).error("#clippingArea","setting clippingArea with incompatible SpatialReference"),this._clippingArea):(t=t.clone(),null==t.intersection(this._groundAndLayersExtent)&&(t.xmin=t.xmax,t.ymin=t.ymax),t.zmin=void 0,t.zmax=void 0,t.equals(this._clippingArea)||(this._clippingArea=t),this._clippingArea):(l.getLogger(this).error("#clippingArea","only clippingArea geometries of type Extent are supported"),this._clippingArea)}set clippingArea(e){this.ready&&"global"===this.viewingMode&&null!=e?l.getLogger(this).error("#clippingArea=","Clipping area is only supported in local viewingMode"):this._userClippingArea=e}get renderDataExtent(){if(1===this.state.viewingMode)return null;const e=this.renderSpatialReference,t=this.dataExtent;return null==t||null==e||t.spatialReference.equals(e)?t:_t(t,e)}get tileInfo(){return this.basemapTerrain?.tilingScheme?.toTileInfo()}get dataExtent(){let e=this._groundAndLayersExtent;const t=this.spatialReference||z.WGS84,i=_t(this.clippingArea,t);null!=i&&(e=null!=e?e.intersection(i):i);const r=this._get("dataExtent");return null!=e&&e.equals(r)?r:e}get _groundAndLayersExtent(){const e=this.spatialReference||z.WGS84;let t;const i=i=>{const r=_t(i,e);null!=r&&(null!=t?t.union(r):t=r.clone())},{basemapTerrain:r}=this;if(r?.spatialReference){const e=r.groundExtent;i(new D({xmin:e[0],ymin:e[1],zmin:0,xmax:e[2],ymax:e[3],zmax:0,spatialReference:r.spatialReference}))}const s=e=>{null==e.fullExtent||"graphics"===e.type&&e.internal||i(e.fullExtent)};if(this.map?.allLayers.forEach(e=>s(e)),null==t)return null;t.hasZ?(t.zmin=Math.min(0,t.zmin??0),t.zmax=Math.max(0,t.zmax??0)):(t.zmin=0,t.zmax=0);const n=this._get("_groundAndLayersExtent");return t.equals(n)?n:t}castEnvironment(e){return e?e instanceof we?e:e instanceof mt?this.environment?.cloneWithWebsceneEnvironment(e)??we.fromWebsceneEnvironment(e):A(we,e):new we}get extent(){return this.stateManager?.extent}set extent(e){this.stateManager&&(this.stateManager.extent=e)}get screenCenter(){return this.stateManager?.screenCenter}get frustum(){return this.stateManager?.frustum}get initialExtentRequired(){return this.stateManager&&!this.stateManager.hasInitialView}get defaultsFromMapSettings(){return{required:{tileInfo:!1,heightModelInfo:!0,extent:!1}}}get interacting(){return this.navigating||(this.toolViewManager?.interacting??!1)}get stationary(){return!this.animation&&!this.resizing&&(this.state?.stationary??!0)}get navigating(){return this.state?.navigating??!1}get scene(){return this.map&&se in this.map?this.map:null}get padding(){return this.stateManager?.padding}set padding(e){this.stateManager&&(this.stateManager.padding=e)}get featureTiles(){return this._featureTiles}set qualityProfile(e){Ee.isValidProfile(e)&&(Ee.apply(e,this.qualitySettings),this.stage?.renderView.updateQualitySettings(this.qualitySettings),this._set("qualityProfile",e))}get qualityProfile(){return this._get("qualityProfile")||Ee.getDefaultProfile()}_updateSlice(){null!=this.stage&&(this.stage.renderer.slice=this.slice)}get typeSpecificPreconditionsReady(){return!!this.viewingMode&&!!this.stateManager?.preinit(this.spatialReference)}get resolution(){return null!=this.spatialReference?$(this.scale,this.spatialReference):0}get scale(){return this.stateManager?.scale}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get heightModelInfo(){const e=this.getDefaultHeightModelInfo();return null!=e?G.deriveUnitFromSR(e,this.spatialReference):null}get updating(){if(this.destroying||this.destroyed)return!1;let e=0,t=this.layerViewManager.updating,i=t?this.layerViewManager.updatingRemaining:0;this.allLayerViews.forEach(r=>{if(r.isFulfilled()){if(r.updating){if(t=!0,r.suspended||Be(r))return;++i,e+=r.updatingProgress}}else++i});for(const s of this._updatingObjects)if(null!=s&&s.updating){const t=.1;i+=t,e+=.5*t}for(const s of this._updatingObjectsWithProgress)null!=s&&s.updating&&(++i,e+=s.updatingProgress);const r=!this.stateManager.test.updatingIgnoreRenderState&&this.state.updating;if(t=!!(t||i>0||this.updatingHandles.updating||!this.ready||!this.stationary||r||this._importControllers.size>0||this.inputManager?.updating||this.map?.allLayers?.some(e=>!e.isFulfilled())),t?(this._numUpdating=Math.max(i,this._numUpdating),e+=this._numUpdating-i):this._numUpdating=0,this._numUpdating>0?e/=this._numUpdating:e=t?0:1,this._get("updatingProgress")!==e){const i=performance.now();if(e<1){const t=Math.min((i-this._lastUpdateTime)/2e3,1);e=this.updatingProgress*(1-t)+e*t}this._set("updatingProgress",e),this._lastUpdateTime=t&&e<1?i:0}return t}get _updatingObjects(){return[this.graphicsView,this.basemapView,this._resourceController,this.stage,this.featureTiles,this.pointsOfInterest,this.environmentManager,this.overlay,this._featureTreeDebugger,this.toolViewManager,this.analysisViewManager]}get _updatingObjectsWithProgress(){return[this.deconflictor,this.labeler,this.basemapTerrain]}get viewingMode(){const e=this._predeterminedViewingMode;if(null!=e)return de(e);const t=this.spatialReference;return t?null!=this.defaultsFromMap?.viewingMode&&t.equals(this.defaultsFromMap.spatialReference)?de(this.defaultsFromMap.viewingMode):pt(t,1)?"global":"local":"global"}set viewingMode(e){this.ready?l.getLogger(this).error("#viewingMode","viewingMode cannot be set once view is ready"):this._overrideIfSome("viewingMode",e)}get viewpoint(){return this.stateManager?.viewpoint}set viewpoint(e){this.stateManager&&(this.stateManager.viewpoint=e)}get visibleArea(){return this.stateManager?.visibleArea}get zoom(){return this.stateManager.zoom}set zoom(e){this.stateManager&&(this.stateManager.zoom=e)}get highlightOptions(){return this.highlights.find(({name:e})=>e===st)??new nt}set highlightOptions(e){for(let t=0;t<this.highlights.length;++t){if(this.highlights.at(t).name===st)return void this.highlights.items[t].assignFrom(e)}}get resourceController(){return this._resourceController}get quality(){return this._resourceController?.memoryController?.memoryFactor??1}get resolutionScale(){return Math.sqrt(Math.min(1,this.quality/.75))}get performanceInfo(){return new Ue(this)}on(e,t,i,r){const s=this.viewEvents.on(e,t,i,r);return s||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}toMap(e,t){if(!this.ready)return l.getLogger(this).error("#toMap()","Scene view cannot be used before it is ready"),null;const i=ot(e)?lt(this,e):e;return Le(this,i,t,this._defaultToMapOptions)}toScreen(e){if(!this.ready)return l.getLogger(this).error("#toScreen()","Scene view cannot be used before it is ready"),null;const t=(null==e.z?He(this.elevationProvider,e):null)??0;return N(e,bt,this.renderSpatialReference,t),this.state.camera.projectToScreen(bt,Mt),V(Mt[0],Mt[1])}pixelSizeAt(e,t){if(!this.ready)return l.getLogger(this).error("#pixelSizeAt()","Scene view cannot be used before it is ready"),null;if(!e)return 0;const i=this.renderSpatialReference;N(e,bt,i);const r=this.state.camera.computeScreenPixelSizeAt(bt);return t&&i!==t?r*C(i)/C(t):r}overlayPixelSizeInMapUnits(e){const t=this.basemapTerrain.overlayManager;return t?t.overlayPixelSizeInMapUnits(e,()=>this.pixelSizeAt(e)):1}hitTest(e,t){if(!this.ready)return l.getLogger(this).error("#hitTest()","Scene view cannot be used before it is ready"),null;const i=ot(e)?lt(this,e):e;return Ie(this,i,t,this._defaultHitTestOptions)}async popupHitTest(e){return Pe(this,e)}goTo(e,t){return this.updatingHandles.addPromise(this.stateManager.goTo(e,t))}async whenAnalysisView(e){if(null==e.parent)throw new n("view:no-analysisview-for-analysis","The analysis has not been added to view.analyses",{analysis:e});switch(e.parent.type){case"line-of-sight":case"dimension":case"viewshed":return(await this.whenLayerView(e.parent)).whenAnalysisView();default:return this.analysisViewManager.whenAnalysisView(e)}}whenLayerView(e){return super.whenLayerView(e)}async takeScreenshot(e){const t=await this._completeSettings(e);await this.whenReady();const i=(await this.stage.renderView.takeScreenshot(t))[0];return(await import("./support/screenshotUtils.js")).encode(i,t,this._pixelFormat())}async _takeScreenshot(e){const t=await this._completeSettings(e);await this.whenReady();const i=(await this.stage.renderView.takeScreenshot(t))[0];return(await import("./support/screenshotUtils.js")).encodeData(i,this._pixelFormat())}async _takeScreenshotWithObjectAndLayerId(e){const t=await this._completeSettings(e);t.objectAndLayerIdColor=!0,await this.whenReady();const i=await this.stage.renderView.takeScreenshot(t),{encodeData:r}=await import("./support/screenshotUtils.js");return[r(i[0],this._pixelFormat()),r(i[1],this._pixelFormat())]}async _completeSettings(e){const{toRenderSettings:t,screenshotSuperSampleSettings:i}=await import("./support/screenshotUtils.js"),r=t(e,this);return r.pixelRatio/=this.state.pixelRatio,i(r,this.supersampleScreenshotsEnabled,this.padding)}_pixelFormat(){return{flipY:!0,premultipliedAlpha:this.stage?.renderView.getAlpha()??!1}}get test(){}async takeScreenshotWithObjectAndLayerId(e){if(!Je())throw new n("360vr:objectAndLayerId-rendering-disabled","has enable-feature:objectAndLayerId-rendering must be true");const{encode:t}=await import("./support/screenshotUtils.js"),i=await this._completeSettings(e);i.objectAndLayerIdColor=!0,await this.whenReady();const r=await this.stage.renderView.takeScreenshot(i),s=t(r[0],i,this._pixelFormat()),a=await this._completeSettings(e);a.format="png";return[s,t(r[1],a,this._pixelFormat())]}getColorToObjectAndLayerIdMapping(){const e=this.stage.renderView.olidRenderHelper;if(e)return e.getColorToObjectAndLayerIdMapping();throw new n("360vr:objectAndLayerId-rendering-disabled","has enable-feature:objectAndLayerId-rendering must be true")}addUpdatingPromise(e){return this.updatingHandles.addPromise(e)}importLayerView(e){return ce.importLayerView(e)}hasLayerViewModule(e){return ce.hasLayerViewModule(e)}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){return this.scene?.initialViewProperties?.spatialReference||this.defaultsFromMap?.spatialReference||this.defaultsFromMap?.ready&&this._initialDefaultSpatialReference||null}async validate(){let e=ut(this.type);const t=has("safari");if(t&&t<9&&(e=new n("sceneview:browser-not-supported","This browser is not supported by SceneView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:t})),null!=e)throw l.getLogger(this).warn("#validate()",e.message),e}get _predeterminedViewingMode(){const e=this._isOverridden("viewingMode")?this._get("viewingMode"):this.scene?.initialViewProperties?.viewingMode;return null!=e?ue(e):null}getSpatialReferenceSupport(e,t){const i=this._predeterminedViewingMode;if(null!=i)return this._validateSpatialReferenceForViewingMode(e,t,i)?{constraints:this._makeSpatialReferenceConstraints(e,t,i)}:null;const r=this._validateSpatialReferenceForViewingMode(e,t,2),s=this._validateSpatialReferenceForViewingMode(e,t,1);return r||s?r&&s?{constraints:this._makeSpatialReferenceConstraints(e,t,null)}:r?{constraints:this._makeSpatialReferenceConstraints(e,t,2)}:{constraints:this._makeSpatialReferenceConstraints(e,t,1)}:null}_validateSpatialReferenceForViewingMode(e,t,i){return!!pt(e,i)&&(null==t||(!!J(t)||(!K(t)||null!=Ne(t,e,i))&&(!X(t)||1!==i)))}_makeSpatialReferenceConstraints(e,t,i){if(null==t)return[{spatialReference:e,viewingMode:i}];const{isWebMercator:r,isWGS84:s}=e;if(J(t)&&(r||s)){return!s||2===i||null===Qe(t.tileInfo,t.fullExtent,e,1)?[{spatialReference:e,viewingMode:i},{spatialReference:z.WebMercator,viewingMode:i}]:[{spatialReference:r?z.WGS84:z.WebMercator,viewingMode:i}]}return K(t)||X(t)||!r&&!s?K(t)&&r&&1!==i?[{spatialReference:e,viewingMode:i},{spatialReference:z.WGS84,viewingMode:2}]:[{spatialReference:e,viewingMode:i}]:[{spatialReference:e,viewingMode:i},{spatialReference:r?z.WGS84:z.WebMercator,viewingMode:i}]}_validateSpatialReference(e){const t=null!=this.getSpatialReferenceSupport(e),i=this._predeterminedViewingMode;return t||(null!=i?l.getLogger(this).warnOnce(`Spatial reference defined on view not supported in ${de(i)} viewing mode.`):e.isGeographic&&l.getLogger(this).warnOnce("Spatial reference is geographic but not supported.")),t}whenReady(){return new Promise(e=>{this.ready?e(this):this._resolveWhenReady.push(e)})}trackGraphicState(e){if(!e.graphic)return l.getLogger(this).error("trackGraphicState","GraphicState.graphic must not be null or undefined to start tracking"),null;const t=this.getViewForGraphic(e.graphic);let i=null,r=!1;const s=t=>{!r&&null!=t&&"processor"in t&&"graphics-3d"===t.processor?.type&&t.processor.graphicsCore&&(i=t.processor.graphicsCore.trackGraphicState(e))};return null!=t?s(t):this.whenViewForGraphic(e.graphic,{waitForLayer:!0}).then(e=>s(e),()=>{}).catch(()=>{}),o(()=>{r=!0,null!=i&&(i.remove(),i=null)})}maskOccludee(e){if(!e)return l.getLogger(this).error("maskOccludee","GraphicState.graphic must not be null or undefined to mask an occludee"),null;const t=this.getViewForGraphic(e);let i=null,r=!1;const s=t=>{!r&&null!=t&&at(t)&&(i=t.maskOccludee(e))};return null!=t?s(t):this.whenViewForGraphic(e,{waitForLayer:!0}).then(e=>s(e),()=>{}).catch(()=>{}),o(()=>{r=!0,null!=i&&(i.remove(),i=null)})}getViewForGraphic(e){return e.layer===this?this.graphicsView:e.layer?this.allLayerViews.filter(e=>"media-3d"!==e.type).find(t=>t.layer===e.layer):null}graphicChanged(e){null!=this.graphicsView&&this.graphicsView.graphicChanged(e)}async whenViewForGraphic(e,t){return e.layer===this?(await v(()=>this.graphicsView),this.graphicsView):e.layer&&this.map?t&&t.waitForLayer&&!this.map.allLayers.includes(e.layer)?new Promise((t,i)=>{const r=this.map.allLayers.on("change",s=>{s.added.includes(e.layer)&&(r.remove(),this.whenLayerView(e.layer).then(t,i))})}):this.whenLayerView(e.layer):null}enableFeatureTiles(){const e=Symbol();return this._featureTileTreeClients.add(e),o(()=>this._featureTileTreeClients.delete(e))}async _importModule(e,t){const i=new AbortController;this._importControllers.set(e,i),this._updatingChanged();try{const r=await Vt[e]();if(t&&(d(this),u(i.signal),await t(i.signal)),this.destroyed)throw c();return u(i.signal),r}catch{return null}finally{this._importControllers.delete(e),this._updatingChanged()}}_abortImport(e){this._importControllers.get(e)?.abort(),this._importControllers.delete(e),this._updatingChanged()}_initBasemapTerrain(){this._set("basemapTerrain",new ke({view:this})),this._set("elevationProvider",new Oe({view:this})),this.elevationProvider.register("ground",this.basemapTerrain)}_exitBasemapTerrain(){const{basemapTerrain:e,elevationProvider:t}=this;e&&(this._set("basemapTerrain",null),this._set("elevationProvider",null),t.unregister(e),t.destroy(),e.destroy())}_initGlobe(){this._initCoordinateSystem(),this.state.createInitialCamera(),this._initBasemapTerrain(),this._set("pointsOfInterest",new ze({view:this})),this.addHandles([this.updatingHandles.add(()=>Ae.FEATURE_TILE_TREE_SHOW_TILES,e=>{e&&!this._featureTreeDebugger?this.updatingHandles.addPromise(import("./3d/layers/support/FeatureTileTree3DDebugger.js")).then(({FeatureTileTree3DDebugger:e})=>{!this._featureTreeDebugger&&Ae.FEATURE_TILE_TREE_SHOW_TILES&&(this._featureTreeDebugger=new e({view:this}))}):e||(this._featureTreeDebugger=p(this._featureTreeDebugger))},_),this.updatingHandles.add(()=>({basemapExtent:this.basemapTerrain?.extent,basemapSpatialReference:this.basemapTerrain?.spatialReference,clippingArea:this.clippingArea,featureTiles:this._featureTiles}),({basemapExtent:e,basemapSpatialReference:t,clippingArea:i,featureTiles:r})=>{if(!r)return;const s=!!e;if(i||s)if(s&&t){const s=e&&t?W(Q(e,t),this.spatialReference):null;r.filterExtent=i?i.intersection(s):s}else r.filterExtent=i;else r.filterExtent=null},_),this.updatingHandles.add(()=>this._featureTileTreeClients.size>0,e=>{e?this._ensureFeatureTileTree():this._featureTiles=p(this._featureTiles)},w)],ft),this.stateManager.init()}async _ensureFeatureTileTree(){if(this._featureTiles||this._importControllers.has("FeatureTileTree3D"))return;const e=(await this.updatingHandles.addPromise(this._importModule("FeatureTileTree3D")))?.FeatureTileTree3D;e&&(this._featureTiles=new e({renderCoordsHelper:this.renderCoordsHelper,pointsOfInterest:this.pointsOfInterest,viewState:this.state,scheduler:this._resourceController.scheduler,terrain:this.basemapTerrain}),this._updatingChanged())}_exitTerrain(){this.stateManager.exit(),this.removeHandles(wt),this.removeHandles(ft),this._featureTiles=p(this.featureTiles),this._set("pointsOfInterest",p(this.pointsOfInterest)),this._exitBasemapTerrain(),this.state.reset(),this._exitCoordinateSystem()}_initCoordinateSystem(){if(this.spatialReference){const e=this.spatialReference,t=this.state.isGlobal,i=Z(t,e);i!==this.renderSpatialReference&&(this._set("renderCoordsHelper",De.create(this.state.viewingMode,i)),t||this.addHandles(y(()=>this.basemapTerrain?.extent,e=>{const t=this.renderCoordsHelper.spatialReference;null==e||0===e[0]&&0===e[1]&&0===e[2]&&0===e[3]||!B(e,this.basemapTerrain.spatialReference,St,t)||(this.renderCoordsHelper.extent=St)},w),wt),this.sceneIntersectionHelper&&this.sceneIntersectionHelper.setTolerance(Xe/this.renderCoordsHelper.unitInMeters))}else this._set("renderCoordsHelper",null)}_exitCoordinateSystem(){this.removeHandles(wt),this._set("renderCoordsHelper",null)}_updatingChanged(){this.notifyChange("updating")}_updateUpdatingMonitors(e=null){null!=e&&4===e.type||(this.removeHandles("updatingMonitors"),this.allLayerViews.forEach(e=>{e.destroyed||(this.addHandles(y(()=>[e.updating,e.updatingProgress],()=>this._updatingChanged(),w),"updatingMonitors"),e.when(()=>this._updatingChanged(),()=>this._updatingChanged()))}),this._updatingChanged())}async _prepareScreenshotOverlay(){this.overlay&&await this.overlay.prepare()}_renderScreenshotOverlay(e,t,i){if(!this.overlay||!this.overlay.hasVisibleItems)return i;const r=e.getContext("2d",{willReadFrequently:!0});return r.putImageData(i,0,0),this.overlay.renderCanvas(e,{disableDecorations:t}),r.getImageData(0,0,i.width,i.height)}_initStage(){const e={deactivatedWebGLExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions,alpha:this.alphaCompositingEnabled,preserveDrawingBuffer:this.preserveDrawingBufferEnabled,canvas:this.renderCanvas,screenshot:{prepareOverlay:()=>this._prepareScreenshotOverlay(),renderOverlay:(e,t,i)=>this._renderScreenshotOverlay(e,t,i)}},t=new Re(this.state.viewingMode,e=>this.stage.layers.forAll(e),this);this._set("sceneIntersectionHelper",t);const i=s(this.surface);this._stage=new $e({view:this,options:e,container:i}),this.notifyChange("stage"),this._updateSlice(),this.addHandles([this.updatingHandles.add(()=>this.qualitySettings.highQualityTransparency,e=>this.stage.renderer.setParameters({highQualityTransparency:e}),f),this.on("pointer-move",()=>this.stage?.renderer.resetAnimation()),a(this.stage.renderView.canvas,"webglcontextlost",e=>{this.fatalError=new n("webgl-context-lost",e.statusMessage)})],"stage"),this.renderCoordsHelper&&this.sceneIntersectionHelper.setTolerance(Xe/this.renderCoordsHelper.unitInMeters),this._set("canvas",this.stage.renderView.canvas)}_exitStage(){this.sceneIntersectionHelper?.destroy(),this._set("sceneIntersectionHelper",null),this._stage=p(this.stage),this._set("stage",null),this.removeHandles("stage"),this._set("canvas",null)}_initSurface(e){this._exitSurface(),this._initStage(),this._initGlobe(),this.sharedSymbolResources=new We({view:this,viewingMode:e,resourceController:this._resourceController,pointsOfInterest:this.pointsOfInterest,viewState:this.state})}_exitSurface(){this.sharedSymbolResources&&(this.sharedSymbolResources.objectResourceCache.destroy(),this.sharedSymbolResources.destroy(),this.sharedSymbolResources=null,this._exitTerrain(),this._exitStage())}async _ensureGraphicsView(){if(this.graphicsView||this._importControllers.has("GraphicsView3D")||0===this.graphics.length)return;this.removeHandles("GraphicsView3D");const e=(await this.updatingHandles.addPromise(this._importModule("GraphicsView3D",e=>v(()=>this.basemapTerrain?.ready,e))))?.default;e&&this._set("graphicsView",new e({view:this,getGraphics:()=>this.graphics})),this._updatingChanged()}_disposeGraphicsView(){this._abortImport("GraphicsView3D"),this.removeHandles("GraphicsView3D"),this.graphicsView&&(this.removeHandles(this.graphicsView.processor.layer.id),this.graphicsView.destroy(),this._set("graphicsView",null))}_disposeFocusAreasView(){this._abortImport("FocusAreasView"),this.removeHandles("FocusAreasView"),this.focusAreasView=p(this.focusAreasView)}async _ensureFocusAreasView(e){if(this.focusAreasView||this._importControllers.has("FocusAreasView")||0===e)return;this.removeHandles("FocusAreasView");const t=(await this.updatingHandles.addPromise(this._importModule("FocusAreasView")))?.FocusAreasView;t&&(this.focusAreasView=new t({view:this})),this._updatingChanged()}_startup(){const e=ue(this.viewingMode);1===e&&(this._clippingArea=null),this._initSurface(e),this._set("ready",!0),this.addHandles(m(()=>this.graphics,"after-changes",()=>this._ensureGraphicsView()),"GraphicsView3D"),this._ensureGraphicsView(),this.addHandles(y(()=>this.map?.focusAreas?.areas.length??0,e=>this._ensureFocusAreasView(e),{initial:!0}),"FocusAreasView");const t=this.scene?.initialViewProperties??null,i=t?.environment;i&&(this._overrideDefaultEnvironmentOnly?H(this.environment,i):this.environment=this.environment.cloneWithWebsceneEnvironment(i)),this.timeExtent=t?.timeExtent,t?.analyses.applyTo(this),this.labeler.setup(),this.environmentManager.connectView(this),this.inputManager.connect();const r=this._resolveWhenReady;this._resolveWhenReady=[],r.forEach(e=>e(this))}_teardown(){this._initialDefaultSpatialReference=null,this.inputManager.disconnect(),this.environmentManager.disconnectView(),this._overrideDefaultEnvironmentOnly=!1,this.labeler.dispose(),this._disposeGraphicsView(),this._disposeFocusAreasView(),this._exitSurface(),this._set("ready",!1)}get _defaultToMapOptions(){const e={include:new Set};if(!this.map)return e;this.map.ground&&e.include.add(tt);for(const t of this.allLayerViews)ee(t.layer.type)&&e.include.add(t.uid);return e}get _defaultHitTestOptions(){const e={exclude:new Set};if(!this.map)return e;this.map.ground&&this.map.ground.opacity<1&&e.exclude.add(tt);for(const t of this.allLayerViews)ee(t.layer.type)&&t.layer.opacity<1&&e.exclude.add(t.uid);return e}static{this.type="3d"}static clearStatics(){yt(),L(),j(),it(),Ce(),me(),Se(),k(),rt(),ie(),Ze(),et(),Te(),xe(),P(),M(),Ke(),Ye(),Me.cleanupI3SLodHandling(),te.cleanupTilemapCache(),Ve.cleanupViewstate(),ke.cleanupTerrainSurface()}};function _t(e,t){return null!=e&&q(e.spatialReference,t)?W(e,t):null}e([R()],vt.prototype,"_userClippingArea",void 0),e([R()],vt.prototype,"_resourceController",void 0),e([R()],vt.prototype,"stage",null),e([R({readOnly:!0})],vt.prototype,"deconflictor",void 0),e([R({readOnly:!0})],vt.prototype,"labeler",void 0),e([R(F(re,"analyses"))],vt.prototype,"analyses",void 0),e([R({type:he,readOnly:!0})],vt.prototype,"animation",null),e([R({readOnly:!0})],vt.prototype,"basemapTerrain",void 0),e([R({readOnly:!0})],vt.prototype,"elevationProvider",void 0),e([R()],vt.prototype,"camera",null),e([R({type:t})],vt.prototype,"contentCamera",null),e([R({readOnly:!0})],vt.prototype,"canvas",null),e([R({type:U})],vt.prototype,"center",null),e([R({type:D})],vt.prototype,"clippingArea",null),e([R({type:ye})],vt.prototype,"constraints",void 0),e([R({type:D,readOnly:!0})],vt.prototype,"renderDataExtent",null),e([R({readOnly:!0})],vt.prototype,"tileInfo",null),e([R({type:D,readOnly:!0})],vt.prototype,"dataExtent",null),e([R({type:D,readOnly:!0})],vt.prototype,"_groundAndLayersExtent",null),e([R({type:we})],vt.prototype,"environment",void 0),e([x("environment")],vt.prototype,"castEnvironment",null),e([R({readOnly:!0})],vt.prototype,"environmentManager",void 0),e([R({type:D})],vt.prototype,"extent",null),e([R({type:r})],vt.prototype,"floors",void 0),e([R()],vt.prototype,"screenCenter",null),e([R()],vt.prototype,"frustum",null),e([R({type:Number,readOnly:!0})],vt.prototype,"fullOpacity",void 0),e([R({readOnly:!0})],vt.prototype,"graphicsView",void 0),e([R({})],vt.prototype,"analysisViewManager",void 0),e([R()],vt.prototype,"groundView",void 0),e([R({type:Boolean})],vt.prototype,"initialExtentRequired",null),e([R()],vt.prototype,"defaultsFromMapSettings",null),e([R()],vt.prototype,"interacting",null),e([R()],vt.prototype,"stationary",null),e([R()],vt.prototype,"navigating",null),e([R()],vt.prototype,"map",void 0),e([R()],vt.prototype,"padding",null),e([R({type:ze,readOnly:!0})],vt.prototype,"pointsOfInterest",void 0),e([R()],vt.prototype,"_featureTiles",void 0),e([R()],vt.prototype,"featureTiles",null),e([R()],vt.prototype,"_featureTreeDebugger",void 0),e([R({type:Boolean})],vt.prototype,"screenSizePerspectiveEnabled",void 0),e([R({constructOnly:!0})],vt.prototype,"deactivatedWebGLExtensions",void 0),e([R({constructOnly:!0})],vt.prototype,"debugWebGLExtensions",void 0),e([R({constructOnly:!0})],vt.prototype,"renderCanvas",void 0),e([R({constructOnly:!0})],vt.prototype,"state",void 0),e([R({readOnly:!0})],vt.prototype,"inputManager",void 0),e([R({readOnly:!0})],vt.prototype,"stateManager",void 0),e([R({type:["low","medium","high"]})],vt.prototype,"qualityProfile",null),e([R({type:Fe,get(){let e=this._get("qualitySettings");return e||(e=new Fe,Ee.apply(this.qualityProfile,e)),e}})],vt.prototype,"qualitySettings",void 0),e([R()],vt.prototype,"slice",void 0),e([R({readOnly:!0})],vt.prototype,"typeSpecificPreconditionsReady",null),e([R({readOnly:!0})],vt.prototype,"renderCoordsHelper",void 0),e([R({readOnly:!0})],vt.prototype,"sceneIntersectionHelper",void 0),e([R({type:Number,dependsOn:["scale","spatialReference"],readOnly:!0})],vt.prototype,"resolution",null),e([R({type:Number})],vt.prototype,"scale",null),e([R()],vt.prototype,"heightModelInfo",null),e([R()],vt.prototype,"spatialReference",void 0),e([R({type:Boolean,constructOnly:!0})],vt.prototype,"alphaCompositingEnabled",void 0),e([R({constructOnly:!0})],vt.prototype,"preserveDrawingBufferEnabled",void 0),e([R({type:Boolean})],vt.prototype,"supersampleScreenshotsEnabled",void 0),e([R({readOnly:!0})],vt.prototype,"type",void 0),e([R(),x(e=>e instanceof ct?e:E(gt,e))],vt.prototype,"ui",void 0),e([R({type:Boolean,readOnly:!0,dependsOn:["graphicsView.updating","basemapView.updating","basemapTerrain.updating","layerViewManager.updating","layerViewManager.updatingRemaining","_resourceController.updating","stage.updating","featureTiles.updating","pointsOfInterest.updating","environmentManager.updating","overlay.updating","updatingHandles.updating","featureTreeDebugger.updating","labeler.updating","deconflictor.updating","ready","stationary","inputManager.updating","toolViewManager.updating","analysisViewManager.updating","state.updating","textures.updating"]})],vt.prototype,"updating",null),e([R()],vt.prototype,"_updatingObjects",null),e([R()],vt.prototype,"_updatingObjectsWithProgress",null),e([R({type:Number,readOnly:!0,dependsOn:["updating"]})],vt.prototype,"updatingProgress",void 0),e([R({type:["global","local"]})],vt.prototype,"viewingMode",null),e([R({type:i})],vt.prototype,"viewpoint",null),e([R({readOnly:!0})],vt.prototype,"visibleArea",null),e([R({type:Number})],vt.prototype,"zoom",null),e([R({type:nt})],vt.prototype,"highlightOptions",null),e([R({readOnly:!0})],vt.prototype,"quality",null),e([R({readOnly:!0})],vt.prototype,"resolutionScale",null),e([R()],vt.prototype,"focusAreasView",void 0),e([R()],vt.prototype,"_defaultToMapOptions",null),e([R()],vt.prototype,"_defaultHitTestOptions",null),vt=e([O("esri.views.SceneView")],vt);const bt=I(),Mt=S(),St=Y(),Vt={GraphicsView3D:()=>import("./3d/layers/GraphicsView3D.js"),FocusAreasView:()=>import("./3d/FocusAreasView.js"),FeatureTileTree3D:()=>import("./3d/layers/support/FeatureTileTree3D.js")},jt=vt;export{jt as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import e from"../../core/Evented.js";import{on as o}from"../../core/events.js";import{destroyMaybe as n}from"../../core/maybe.js";import{watch as i,when as s,syncAndInitial as r,initial as
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../core/Evented.js";import{on as o}from"../../core/events.js";import{destroyMaybe as n}from"../../core/maybe.js";import{watch as i,when as s,syncAndInitial as r,initial as l,sync as c}from"../../core/reactiveUtils.js";import{cloneScreenPoint as a,createScreenPoint as p}from"../../core/screenUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../core/support/UpdatingHandles.js";import{setCalciteModeClass as f}from"../../support/modeUtils.js";import{base as m}from"./tooltip/css.js";import{tooltipContentFactory as g}from"./tooltip/content/tooltipContentFactory.js";import{isRTL as v}from"../../widgets/support/widgetUtils.js";const y={base:`${m}`,ltr:`${m}--ltr`,rtl:`${m}--rtl`,debug:`${m}--debug`},_=20,C=16,b="bottom-end";let P=class extends e.EventedAccessor{constructor(t){super(t),this.info=null,this.options=null,this.position=null,this.content=null,this._focused=!1,this.outerContainer=document.createElement("div"),this.debug=!1,this._updatingHandles=new h,this._lastPosition=null,this._rtl=!1,this._prevXY=[0,0]}initialize(){const{outerContainer:t}=this;this.addHandles([i(()=>this.view.overlay?.surface,e=>{t.remove(),e?.appendChild(t),this._rtl=v(e)},r),i(()=>this.info,(e,o)=>{if(null!=this.content&&null!=e&&null!=o&&e.type===o.type)this.content.info=e;else{n(this.content);const o=g(this,e);o?(this.content=o,o.container&&t.appendChild(o.container),this.exitInputMode()):this.content=null}},r),i(()=>({container:this.outerContainer,style:this._outerContainerStyle}),({container:t,style:e})=>{Object.assign(t.style,e)},l),i(()=>({outerContainer:this.outerContainer,placement:this.effectivePlacement,effectiveOffset:this._effectiveOffset,rtl:this._rtl,debug:this.debug}),({outerContainer:t,placement:e,effectiveOffset:o,rtl:n,debug:i})=>{const{classList:s}=t;s.add(y.base),s.toggle(y.rtl,n),s.toggle(y.ltr,!n),s.toggle(y.debug,i),this.outerContainer.style.setProperty("--offset",`${o}px`),f(t),x(t,e)},l),s(()=>"feedback"===this.mode,()=>{this.position=null,this._clearOverride("effectivePlacement")},c),o(this.outerContainer,"paste",t=>{this.emit("paste",t)}),o(this.outerContainer,["focusin","focusout"],()=>{this._focused=this.content?.container?.contains(document.activeElement)??!1})])}destroy(){this.info=null,this.content=n(this.content),this.outerContainer.remove()}get mode(){return this.content?.mode??"feedback"}get focused(){return this._focused}get visible(){return"none"!==this._outerContainerStyle.display}get contentContainer(){return this.content?.container}get effectivePlacement(){const t=this.options?.placement;return"auto"===t?"bottom-end":t??b}get updating(){return this._updatingHandles.updating}get _screenPoint(){const{inputManager:t}=this.view;return t?.multiTouchActive?null:t?.latestPointerLocation}get _effectiveOffset(){return this.options?.offset??_}get _outerContainerStyle(){const t=this.position??this._screenPoint;if(this._lastPosition=a(t),null!=t&&null!=this.content){return{display:"block",transform:`translate(${Math.round(t.x)}px, ${Math.round(t.y)}px)`}}return{display:"none",transform:"none"}}clear(){this.info=null}async enterInputMode(t){const e=this.position??this._lastPosition??this._screenPoint,o=this.position=a(e),{effectivePlacement:n}=this;this._override("effectivePlacement",n);const i=()=>{o&&(this.position=j(this.contentContainer,o,this._effectiveOffset,this.view),Object.assign(this.outerContainer.style,this._outerContainerStyle))};await this._updatingHandles.addPromise(this.content?.enterInputMode(t,i))}async exitInputMode(t){await this._updatingHandles.addPromise(this.content?.exitInputMode(t))}onDragStart(t,e){this._prevXY=[t,e]}onDrag(t,e){const o=t-this._prevXY[0],n=e-this._prevXY[1];this._prevXY=[t,e];const{position:i}=this;if(i){const{view:s}=this,r=t-s.position[0],l=e-s.position[1];if(r<0||r>s.width||l<0||l>s.height-C)return;this.position=p(i.x+o,i.y+n)}}onDragEnd(){this._prevXY=[0,0]}};function j(t,e,o,n){if(!t||!n.container)return e;const i=t.getBoundingClientRect(),{left:s,top:r}=n.container.getBoundingClientRect();let{x:l,y:c}=e;const a=i.left-s-o;a<0&&(l-=a);const u=i.right-s+o-n.width;u>0&&(l-=u);const d=i.top-r-o;d<0&&(c-=d);const h=i.bottom-r+o-n.height;return h>0&&(c-=h),p(l,c)}t([u({nonNullable:!0})],P.prototype,"view",void 0),t([u()],P.prototype,"info",void 0),t([u()],P.prototype,"options",void 0),t([u()],P.prototype,"position",void 0),t([u()],P.prototype,"content",void 0),t([u({readOnly:!0})],P.prototype,"mode",null),t([u()],P.prototype,"_focused",void 0),t([u({readOnly:!0})],P.prototype,"focused",null),t([u({readOnly:!0})],P.prototype,"outerContainer",void 0),t([u({readOnly:!0})],P.prototype,"contentContainer",null),t([u({readOnly:!0})],P.prototype,"effectivePlacement",null),t([u()],P.prototype,"debug",void 0),t([u()],P.prototype,"updating",null),t([u()],P.prototype,"_lastPosition",void 0),t([u()],P.prototype,"_screenPoint",null),t([u()],P.prototype,"_rtl",void 0),t([u()],P.prototype,"_effectiveOffset",null),t([u()],P.prototype,"_outerContainerStyle",null),P=t([d("esri.views.interactive.Tooltip")],P);const O=["top","bottom","leading","trailing"].flatMap(t=>[w(`${t}-start`),w(t),w(`${t}-end`)]);function w(t){return`${y.base}--${t}`}function x({classList:t},e){O.forEach(e=>t.remove(e)),t.add(w(e))}export{P as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import"../../core/has.js";import t from"../../core/Logger.js";import{throwIfAborted as i}from"../../core/promiseUtils.js";import{watch as r,on as l,syncAndInitial as s}from"../../core/reactiveUtils.js";import{sqlOr as o,sqlIn as n,sqlAnd as a}from"../../core/sql.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import{getFeatureIdInfoFieldNames as d}from"../../layers/graphics/data/FeatureIdInfo.js";import{systemIsSpatialFieldName as f}from"../../layers/knowledgeGraph/constants.js";import{getEffectiveDisplayFilter as y}from"../../layers/support/displayFilterUtils.js";import m from"../../layers/support/FeatureEffect.js";import h from"../../layers/support/FeatureFilter.js";import{getSignedInUser as c}from"../../layers/support/featureLayerUtils.js";import{fetchFeaturePopupFeatures as F,loadFeaturePopupArcadeModules as g}from"../../layers/support/featurePopupQueryUtils.js";import{fixFields as I,unpackFieldNames as b,collectLabelingFields as w,collectElevationFields as v,collectFilterFields as E,collectFeatureReductionFields as x,collectOrderByInfos as q,collectFields as R,collectTrackInfoFields as j,collectDisplayFilterFields as C,collectField as _,featureHasFields as O}from"../../layers/support/fieldUtils.js";import{getFloorFilterClause as T}from"../../layers/support/floorFilterUtils.js";import{getUtilityNetworkFields as k}from"../../networks/support/networkFieldUtils.js";import U from"../../rest/support/Query.js";import{createFeatureIdInfo as P}from"../2d/layers/features/layerAdapters/featureServiceUtils.js";import{getRequiredFields as L,getFetchPopupTemplate as S}from"./support/popupUtils.js";import{WhereClauseVisitor as D}from"./support/WhereClauseVisitor.js";const N=N=>{const Q=N;let G=class extends Q{constructor(...e){super(...e),this._updatingRequiredPromise=null,this.filter=null,this.layer=null,this.requiresCurrentUser=!1,this.requiredFields=[],this.view=null}initialize(){this.addHandles([r(()=>{const e=this.layer,t=this.view;return[e&&"elevationInfo"in e?e.elevationInfo?.featureExpressionInfo:null,e&&"displayField"in e?e.displayField:null,e&&"timeInfo"in e&&e.timeInfo,e&&"renderer"in e&&e.renderer,e&&"labelingInfo"in e&&e.labelingInfo,e&&"floorInfo"in e&&e.floorInfo,t?.requiredFieldsOptions?.featureTitleFields&&e&&"featureTitleFields"in e&&e.featureTitleFields,t?.requiredFieldsOptions?.utilityNetworkFields&&k(t,e),e.displayFilterInfo,this.displayFilterEnabled,this.filter,this.featureEffect,this.timeExtent,"knowledge-graph-sublayer"===e?.type&&"link-chart"===e.parentCompositeLayer.type&&e.parentCompositeLayer.linkChart?.linkChartProperties.nonspatialDataDisplay?.mode,"parquet"===e?.type&&e.popupTemplate]},()=>this._handleChange(),s),l(()=>this.view?.floors,"change",()=>this._handleChange()),l(()=>this.layer.displayFilterInfo?.filters,"change",()=>this._handleChange()),l(()=>this.layer&&"sublayers"in this.layer?this.layer.sublayers:null,"change",()=>this._handleChange())])}get availableFields(){if(!this.layer)return[];const{layer:e,layer:{fieldsIndex:t},requiredFields:i}=this;return"outFields"in e&&e.outFields?I(t,[...b(t,e.outFields),...i]):I(t,i)}get displayFilterEnabled(){return(this.view?.displayFilterEnabled??!0)&&(!("displayFilterEnabled"in this.layer)||(this.layer?.displayFilterEnabled??!0))}get effectiveDisplayFilter(){const e=this.layer;return this.displayFilterEnabled&&e.displayFilterInfo?y(e.displayFilterInfo,this.view):null}get effectiveDisplayFilterClause(){const e=this.effectiveDisplayFilter?.where??null;return e&&this.hasHighlight?o(e,n(this.layer.objectIdField,this.highlightIds)):e}get featureEffect(){return this.layer&&"featureEffect"in this.layer?this.layer.featureEffect:null}set featureEffect(e){this._override("featureEffect",e)}get maximumNumberOfFeatures(){return 0}set maximumNumberOfFeatures(e){t.getLogger(this).error("#maximumNumberOfFeatures=","Setting maximum number of features is not supported")}get maximumNumberOfFeaturesExceeded(){return!1}get signedInUser(){return this.layer?.url?c(this.layer.url):Promise.resolve(null)}highlight(e,t){throw new Error("missing implementation")}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference},t=null!=this.filter?this.filter.createQuery(e):new U(e);return"floorInfo"in this.layer&&this.layer.floorInfo&&(t.where=a(t.where,T(this))),this.displayFilterEnabled&&(t.where=a(t.where,this.effectiveDisplayFilter?.where)),null!=this.timeExtent&&(t.timeExtent=null!=t.timeExtent?t.timeExtent.intersection(this.timeExtent):this.timeExtent.clone()),t}createAggregateQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference};return new U(e)}queryFeatures(e,t){throw new Error("missing implementation")}queryObjectIds(e,t){throw new Error("missing implementation")}queryFeatureCount(e,t){throw new Error("missing implementation")}queryExtent(e,t){throw new Error("missing implementation")}async fetchPopupFeaturesFromGraphics(e,t){const i=await this._createPopupQuery(e.map(e=>e.origin?.layer??e.layer),t);return await F(this.layer,e,i,{getPopupTemplate:e=>e&&"popupTemplate"in e&&e.popupEnabled?S(e,t):null,hasRequiredFields:(e,t)=>this._popupFeatureHasRequiredFields(e,t),...t})}_handleChange(){const e=Promise.all([this._updateRequiredFields(),this._updateClientWhereClauseRequirements()]).then(()=>{});return this._set("_updatingRequiredPromise",e),e.then(()=>{this._updatingRequiredPromise===e&&this._set("_updatingRequiredPromise",null)}),e}async _updateClientWhereClauseRequirements(){if(!this.layer||!this.view)return;const{layer:e}=this,i=new D(e.fieldsIndex);if(i.visitFilter(this.filter),"featureReduction"in e&&i.visitFeatureReduction(e.featureReduction),"labelingInfo"in e&&i.visitLabelingInfo(e.labelsVisible,e.labelingInfo),"trackInfo"in e&&i.visitTrackInfo(e.trackInfo),"2d"===this.view.type&&(i.visitFilter(this.featureEffect?.filter),i.visitDisplayFilter(this.displayFilterEnabled,e.displayFilterInfo),"featureReduction"in e&&i.visitFeatureReduction(e.featureReduction)),"subtype-group"===e.type)for(const t of e.sublayers)i.visitLabelingInfo(t.labelsVisible,t.labelingInfo);try{const e=await i.finish();this._set("requiresCurrentUser",e.requiresCurrentUser)}catch(r){t.getLogger(this).error(r)}}async _updateRequiredFields(){if(!this.layer||!this.view)return;const e="3d"===this.view.type,{layer:i,layer:{fieldsIndex:r}}=this,l="renderer"in i&&i.renderer,s="orderBy"in i&&i.orderBy,o="featureReduction"in i?i.featureReduction:null,n=new Set,a=[l?l.collectRequiredFields(n,r):null,w(n,i),e&&"elevationInfo"in i?v(n,i):null,null!=this.filter?E(n,i,this.filter):null,e||null==this.featureEffect?null:E(n,i,this.featureEffect.filter),!e&&o?x(n,i,o):null,!e&&s?q(n,i,s):null];if("timeInfo"in i&&i.timeInfo&&this.timeExtent&&R(n,i.fieldsIndex,[i.timeInfo.startField,i.timeInfo.endField]),"timeInfo"in i&&i.timeInfo&&"trackInfo"in i&&i.trackInfo){const{trackInfo:e}=i;R(n,i.fieldsIndex,[i.timeInfo.trackIdField]),"feature"!==i.type&&"startTimeField"!==e.timeField||R(n,i.fieldsIndex,[i.timeInfo.startField]),"endTimeField"===e.timeField&&R(n,i.fieldsIndex,[i.timeInfo.endField]),await j(n,i)}if("floorInfo"in i&&i.floorInfo&&R(n,i.fieldsIndex,[i.floorInfo.floorField]),"featureTitleFields"in i&&this.view?.requiredFieldsOptions?.featureTitleFields&&i.featureTitleFields&&R(n,i.fieldsIndex,i.featureTitleFields),"feature"===i.type&&i.globalIdField&&this.view?.requiredFieldsOptions?.globalIdField&&R(n,i.fieldsIndex,[i.globalIdField]),this.displayFilterEnabled&&a.push(C(n,i,i.displayFilterInfo)),"feature"===i.type&&e&&null!=i.infoFor3D&&(null==i.globalIdField&&t.getLogger(this).error("globalIdField missing on 3DObjectFeatureLayer"),R(n,i.fieldsIndex,[i.globalIdField])),"subtype-group"===i.type){_(n,r,i.subtypeField);const e=i.sublayers.map(e=>Promise.all([e.renderer?.collectRequiredFields(n,r),w(n,e)]));a.push(Promise.all(e))}if("catalog-footprint"===i.type&&i.parent){const e=i.parent;R(n,r,[e.itemNameField,e.itemSourceField,e.itemTypeField,e.maxScaleField,e.minScaleField])}"knowledge-graph-sublayer"===i.type&&"link-chart"===i.parentCompositeLayer.type&&_(n,r,f),"parquet"===i.type&&a.push(L(i,i.popupTemplate).then(e=>{for(const t of e)n.add(t)}));const u=await Promise.allSettled(a);if(e)_(n,r,i.objectIdField);else for(const t of d(P(i)))_(n,r,t);e&&"displayField"in i&&i.displayField&&_(n,r,i.displayField);for(const d of u)"rejected"===d.status&&t.getLogger(this).error(d.reason);const p=Array.from(n).sort();this._set("requiredFields",p)}_popupFeatureHasRequiredFields(e,t){return O(e,t)}async _createPopupQuery(e,t){const r=this.layer.createQuery(),l=new Set;let s=!1;const o=e??[this.layer];for(const n of o){if(!("popupTemplate"in n))continue;const e=S(n,t);if(null==e)continue;const r=await g(e);i(t);const o=r&&r.arcadeUtils.hasGeometryOperations(e);s=!("point"!==this.layer.geometryType&&!o);const a=await L(this.layer,e);i(t);for(const t of a)l.add(t)}return r.returnGeometry=s,r.returnZ=s,r.returnM=s,r.outFields=Array.from(l),r.outSpatialReference=this.view.spatialReference,"floorInfo"in this.layer&&this.layer.floorInfo&&(r.where=a(r.where,T(this))),r}canResume(){return!!super.canResume()&&(null==this.timeExtent||!this.timeExtent.isEmpty)}getTest(){}get test(){}};return e([u()],G.prototype,"_updatingRequiredPromise",void 0),e([u({readOnly:!0})],G.prototype,"availableFields",null),e([u({readOnly:!0})],G.prototype,"displayFilterEnabled",null),e([u({readOnly:!0})],G.prototype,"effectiveDisplayFilter",null),e([u({readOnly:!0})],G.prototype,"effectiveDisplayFilterClause",null),e([u({type:m})],G.prototype,"featureEffect",null),e([u({type:h})],G.prototype,"filter",void 0),e([u()],G.prototype,"layer",void 0),e([u({type:Number})],G.prototype,"maximumNumberOfFeatures",null),e([u({readOnly:!0,type:Boolean})],G.prototype,"maximumNumberOfFeaturesExceeded",null),e([u()],G.prototype,"requiresCurrentUser",void 0),e([u({readOnly:!0})],G.prototype,"requiredFields",void 0),e([u({readOnly:!0})],G.prototype,"signedInUser",null),e([u()],G.prototype,"suspended",void 0),e([u()],G.prototype,"view",void 0),G=e([p("esri.views.layers.FeatureLayerView")],G),G};export{N as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import"../../core/has.js";import t from"../../core/Logger.js";import{throwIfAborted as i}from"../../core/promiseUtils.js";import{watch as r,on as l,syncAndInitial as s}from"../../core/reactiveUtils.js";import{sqlOr as o,sqlIn as n,sqlAnd as a}from"../../core/sql.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{getGraphicOriginLayer as p}from"../../graphic/graphicOriginUtils.js";import{getFeatureIdInfoFieldNames as f}from"../../layers/graphics/data/FeatureIdInfo.js";import{systemIsSpatialFieldName as y}from"../../layers/knowledgeGraph/constants.js";import{getEffectiveDisplayFilter as h}from"../../layers/support/displayFilterUtils.js";import m from"../../layers/support/FeatureEffect.js";import c from"../../layers/support/FeatureFilter.js";import{getSignedInUser as F}from"../../layers/support/featureLayerUtils.js";import{fetchFeaturePopupFeatures as g,loadFeaturePopupArcadeModules as I}from"../../layers/support/featurePopupQueryUtils.js";import{fixFields as b,unpackFieldNames as w,collectLabelingFields as v,collectElevationFields as E,collectFilterFields as x,collectFeatureReductionFields as q,collectOrderByInfos as R,collectFields as j,collectTrackInfoFields as C,collectDisplayFilterFields as _,collectField as O,featureHasFields as k}from"../../layers/support/fieldUtils.js";import{getFloorFilterClause as U}from"../../layers/support/floorFilterUtils.js";import{getUtilityNetworkFields as P}from"../../networks/support/networkFieldUtils.js";import T from"../../rest/support/Query.js";import{createFeatureIdInfo as L}from"../2d/layers/features/layerAdapters/featureServiceUtils.js";import{getRequiredFields as S,getFetchPopupTemplate as D}from"./support/popupUtils.js";import{WhereClauseVisitor as N}from"./support/WhereClauseVisitor.js";const Q=Q=>{const G=Q;let A=class extends G{constructor(...e){super(...e),this._updatingRequiredPromise=null,this.filter=null,this.layer=null,this.requiresCurrentUser=!1,this.requiredFields=[],this.view=null}initialize(){this.addHandles([r(()=>{const e=this.layer,t=this.view;return[e&&"elevationInfo"in e?e.elevationInfo?.featureExpressionInfo:null,e&&"displayField"in e?e.displayField:null,e&&"timeInfo"in e&&e.timeInfo,e&&"renderer"in e&&e.renderer,e&&"labelingInfo"in e&&e.labelingInfo,e&&"floorInfo"in e&&e.floorInfo,t?.requiredFieldsOptions?.featureTitleFields&&e&&"featureTitleFields"in e&&e.featureTitleFields,t?.requiredFieldsOptions?.utilityNetworkFields&&P(t,e),e.displayFilterInfo,this.displayFilterEnabled,this.filter,this.featureEffect,this.timeExtent,"knowledge-graph-sublayer"===e?.type&&"link-chart"===e.parentCompositeLayer.type&&e.parentCompositeLayer.linkChart?.linkChartProperties.nonspatialDataDisplay?.mode,"parquet"===e?.type&&e.popupTemplate]},()=>this._handleChange(),s),l(()=>this.view?.floors,"change",()=>this._handleChange()),l(()=>this.layer.displayFilterInfo?.filters,"change",()=>this._handleChange()),l(()=>this.layer&&"sublayers"in this.layer?this.layer.sublayers:null,"change",()=>this._handleChange())])}get availableFields(){if(!this.layer)return[];const{layer:e,layer:{fieldsIndex:t},requiredFields:i}=this;return"outFields"in e&&e.outFields?b(t,[...w(t,e.outFields),...i]):b(t,i)}get displayFilterEnabled(){return(this.view?.displayFilterEnabled??!0)&&(!("displayFilterEnabled"in this.layer)||(this.layer?.displayFilterEnabled??!0))}get effectiveDisplayFilter(){const e=this.layer;return this.displayFilterEnabled&&e.displayFilterInfo?h(e.displayFilterInfo,this.view):null}get effectiveDisplayFilterClause(){const e=this.effectiveDisplayFilter?.where??null;return e&&this.hasHighlight?o(e,n(this.layer.objectIdField,this.highlightIds)):e}get featureEffect(){return this.layer&&"featureEffect"in this.layer?this.layer.featureEffect:null}set featureEffect(e){this._override("featureEffect",e)}get maximumNumberOfFeatures(){return 0}set maximumNumberOfFeatures(e){t.getLogger(this).error("#maximumNumberOfFeatures=","Setting maximum number of features is not supported")}get maximumNumberOfFeaturesExceeded(){return!1}get signedInUser(){return this.layer?.url?F(this.layer.url):Promise.resolve(null)}highlight(e,t){throw new Error("missing implementation")}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference},t=null!=this.filter?this.filter.createQuery(e):new T(e);return"floorInfo"in this.layer&&this.layer.floorInfo&&(t.where=a(t.where,U(this))),this.displayFilterEnabled&&(t.where=a(t.where,this.effectiveDisplayFilter?.where)),null!=this.timeExtent&&(t.timeExtent=null!=t.timeExtent?t.timeExtent.intersection(this.timeExtent):this.timeExtent.clone()),t}createAggregateQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference};return new T(e)}queryFeatures(e,t){throw new Error("missing implementation")}queryObjectIds(e,t){throw new Error("missing implementation")}queryFeatureCount(e,t){throw new Error("missing implementation")}queryExtent(e,t){throw new Error("missing implementation")}async fetchPopupFeaturesFromGraphics(e,t){const i=await this._createPopupQuery(e.map(e=>p(e.origin)??e.layer),t);return await g(this.layer,e,i,{getPopupTemplate:e=>D(e,{...t,checkPopupEnabled:!0}),hasRequiredFields:(e,t)=>this._popupFeatureHasRequiredFields(e,t),...t})}_handleChange(){const e=Promise.all([this._updateRequiredFields(),this._updateClientWhereClauseRequirements()]).then(()=>{});return this._set("_updatingRequiredPromise",e),e.then(()=>{this._updatingRequiredPromise===e&&this._set("_updatingRequiredPromise",null)}),e}async _updateClientWhereClauseRequirements(){if(!this.layer||!this.view)return;const{layer:e}=this,i=new N(e.fieldsIndex);if(i.visitFilter(this.filter),"featureReduction"in e&&i.visitFeatureReduction(e.featureReduction),"labelingInfo"in e&&i.visitLabelingInfo(e.labelsVisible,e.labelingInfo),"trackInfo"in e&&i.visitTrackInfo(e.trackInfo),"2d"===this.view.type&&(i.visitFilter(this.featureEffect?.filter),i.visitDisplayFilter(this.displayFilterEnabled,e.displayFilterInfo),"featureReduction"in e&&i.visitFeatureReduction(e.featureReduction)),"subtype-group"===e.type)for(const t of e.sublayers)i.visitLabelingInfo(t.labelsVisible,t.labelingInfo);try{const e=await i.finish();this._set("requiresCurrentUser",e.requiresCurrentUser)}catch(r){t.getLogger(this).error(r)}}async _updateRequiredFields(){if(!this.layer||!this.view)return;const e="3d"===this.view.type,{layer:i,layer:{fieldsIndex:r}}=this,l="renderer"in i&&i.renderer,s="orderBy"in i&&i.orderBy,o="featureReduction"in i?i.featureReduction:null,n=new Set,a=[l?l.collectRequiredFields(n,r):null,v(n,i),e&&"elevationInfo"in i?E(n,i):null,null!=this.filter?x(n,i,this.filter):null,e||null==this.featureEffect?null:x(n,i,this.featureEffect.filter),!e&&o?q(n,i,o):null,!e&&s?R(n,i,s):null];if("timeInfo"in i&&i.timeInfo&&this.timeExtent&&j(n,i.fieldsIndex,[i.timeInfo.startField,i.timeInfo.endField]),"timeInfo"in i&&i.timeInfo&&"trackInfo"in i&&i.trackInfo){const{trackInfo:e}=i;j(n,i.fieldsIndex,[i.timeInfo.trackIdField]),"feature"!==i.type&&"startTimeField"!==e.timeField||j(n,i.fieldsIndex,[i.timeInfo.startField]),"endTimeField"===e.timeField&&j(n,i.fieldsIndex,[i.timeInfo.endField]),await C(n,i)}if("floorInfo"in i&&i.floorInfo&&j(n,i.fieldsIndex,[i.floorInfo.floorField]),"featureTitleFields"in i&&this.view?.requiredFieldsOptions?.featureTitleFields&&i.featureTitleFields&&j(n,i.fieldsIndex,i.featureTitleFields),"feature"===i.type&&i.globalIdField&&this.view?.requiredFieldsOptions?.globalIdField&&j(n,i.fieldsIndex,[i.globalIdField]),this.displayFilterEnabled&&a.push(_(n,i,i.displayFilterInfo)),"feature"===i.type&&e&&null!=i.infoFor3D&&(null==i.globalIdField&&t.getLogger(this).error("globalIdField missing on 3DObjectFeatureLayer"),j(n,i.fieldsIndex,[i.globalIdField])),"subtype-group"===i.type){O(n,r,i.subtypeField);const e=i.sublayers.map(e=>Promise.all([e.renderer?.collectRequiredFields(n,r),v(n,e)]));a.push(Promise.all(e))}if("catalog-footprint"===i.type&&i.parent){const e=i.parent;j(n,r,[e.itemNameField,e.itemSourceField,e.itemTypeField,e.maxScaleField,e.minScaleField])}"knowledge-graph-sublayer"===i.type&&"link-chart"===i.parentCompositeLayer.type&&O(n,r,y),"parquet"===i.type&&a.push(S(i,i.popupTemplate).then(e=>{for(const t of e)n.add(t)}));const u=await Promise.allSettled(a);if(e)O(n,r,i.objectIdField);else for(const t of f(L(i)))O(n,r,t);e&&"displayField"in i&&i.displayField&&O(n,r,i.displayField);for(const p of u)"rejected"===p.status&&t.getLogger(this).error(p.reason);const d=Array.from(n).sort();this._set("requiredFields",d)}_popupFeatureHasRequiredFields(e,t){return k(e,t)}async _createPopupQuery(e,t){const r=this.layer.createQuery(),l=new Set;let s=!1;const o=e??[this.layer];for(const n of o){const e=D(n,t);if(null==e)continue;const r=await I(e);i(t);const o=r&&r.arcadeUtils.hasGeometryOperations(e);s=!("point"!==this.layer.geometryType&&!o);const a=await S(this.layer,e);i(t);for(const t of a)l.add(t)}return r.returnGeometry=s,r.returnZ=s,r.returnM=s,r.outFields=Array.from(l),r.outSpatialReference=this.view.spatialReference,"floorInfo"in this.layer&&this.layer.floorInfo&&(r.where=a(r.where,U(this))),r}canResume(){return!!super.canResume()&&(null==this.timeExtent||!this.timeExtent.isEmpty)}getTest(){}get test(){}};return e([u()],A.prototype,"_updatingRequiredPromise",void 0),e([u({readOnly:!0})],A.prototype,"availableFields",null),e([u({readOnly:!0})],A.prototype,"displayFilterEnabled",null),e([u({readOnly:!0})],A.prototype,"effectiveDisplayFilter",null),e([u({readOnly:!0})],A.prototype,"effectiveDisplayFilterClause",null),e([u({type:m})],A.prototype,"featureEffect",null),e([u({type:c})],A.prototype,"filter",void 0),e([u()],A.prototype,"layer",void 0),e([u({type:Number})],A.prototype,"maximumNumberOfFeatures",null),e([u({readOnly:!0,type:Boolean})],A.prototype,"maximumNumberOfFeaturesExceeded",null),e([u()],A.prototype,"requiresCurrentUser",void 0),e([u({readOnly:!0})],A.prototype,"requiredFields",void 0),e([u({readOnly:!0})],A.prototype,"signedInUser",null),e([u()],A.prototype,"suspended",void 0),e([u()],A.prototype,"view",void 0),A=e([d("esri.views.layers.FeatureLayerView")],A),A};export{Q as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{getFeatureEditFields as e,fixFields as l}from"../../../layers/support/fieldUtils.js";async function
|
|
5
|
+
import{getFeatureEditFields as e,fixFields as l}from"../../../layers/support/fieldUtils.js";async function p(p,n=p.popupTemplate){if(null==n)return[];const u=await n.getRequiredFields(p.fieldsIndex),{lastEditInfoEnabled:t}=n,{objectIdField:d,typeIdField:a,globalIdField:i,relationships:o}=p;if(u.includes("*"))return["*"];const s=t?e(p):[],f=l(p.fieldsIndex,[...u,...s]);return a&&f.push(a),f&&d&&p.fieldsIndex?.has(d)&&!f.includes(d)&&f.push(d),f&&i&&p.fieldsIndex?.has(i)&&!f.includes(i)&&f.push(i),o&&o.forEach(e=>{const{keyField:l}=e;f&&l&&p.fieldsIndex?.has(l)&&!f.includes(l)&&f.push(l)}),f}function n(e,l){return e&&"object"==typeof e?l?.checkPopupEnabled&&"popupEnabled"in e&&!e.popupEnabled?null:"popupTemplate"in e&&e.popupTemplate?e.popupTemplate:null!=l&&l.defaultPopupTemplateEnabled&&"defaultPopupTemplate"in e&&e.defaultPopupTemplate?e.defaultPopupTemplate:null:null}function u(e,l){return null!=n(e,{defaultPopupTemplateEnabled:l})}export{n as getFetchPopupTemplate,p as getRequiredFields,u as hasPopupTemplate};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import{unique as e,isSome as r}from"../../core/arrayUtils.js";import o from"../../core/Collection.js";import i from"../../core/Error.js";import a from"../../core/Logger.js";import{destroyMaybe as s}from"../../core/maybe.js";import{whenOnce as n}from"../../core/reactiveUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{isTable as u}from"../../layers/support/layerUtils.js";import{hasEffectiveFeatureExpressionInfo as p}from"../../support/elevationInfoUtils.js";import c from"../BatchAttributeForm/BatchAttributeFormViewModel.js";import
|
|
5
|
+
import{__decorate as t}from"tslib";import{unique as e,isSome as r}from"../../core/arrayUtils.js";import o from"../../core/Collection.js";import i from"../../core/Error.js";import a from"../../core/Logger.js";import{destroyMaybe as s}from"../../core/maybe.js";import{whenOnce as n}from"../../core/reactiveUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{isTable as u}from"../../layers/support/layerUtils.js";import{hasEffectiveFeatureExpressionInfo as p}from"../../support/elevationInfoUtils.js";import c from"../BatchAttributeForm/BatchAttributeFormViewModel.js";import f from"./UpdateFeaturesWorkflowData.js";import h from"./Workflow.js";import{whenEditorLayerView as m,makeMultipleSourceLayersError as y}from"./workflowUtils.js";import{SketchController as w}from"./support/SketchController.js";var g;const F=()=>a.getLogger("esri.widgets.Editor.UpdateFeaturesWorkflow");let _=g=class extends h{constructor(t){super(t),this.type="update-features",this._formViewModel=null,this._sketchController=null}async initialize(){this._initializeFormViewModel();try{await this._updatingHandles.addPromise((async()=>{const{fullFeatures:t}=await this.data.when();this._formViewModel.features=new o(t),await this._initializeVisuals(t)})())}catch(t){this.cancel({force:!0,error:new i("update-features-workflow:initialize","Failed to initialize the workflow data.",t)})}}destroy(){this._sketchController=s(this._sketchController),this._formViewModel.destroy()}get features(){return this.data.features}get formViewModel(){return this._formViewModel}get hasPendingEdits(){const{data:t}=this;return t.features.some(e=>!!t.getPendingEditsForFeature(e)?.modified)}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get selectedFeature(){return this.data.selectedFeature}get sketchViewModel(){return this._sketchController?.viewModel}get updating(){return this._updatingHandles.updating||this._formViewModel.updating||!!this._sketchController?.updating}async commit(){const{data:t,_formViewModel:e}=this;for(const r of t.fullFeatures)E(t.getPendingEditsForFeature(r),e.getValues(r));await super.commit()}static create(t){const{applyEdits:o,applyEditsFeatureService:i,...a}=t,s=e(t.features.map(t=>t.sourceLayer??t.layer)).map(e=>t.viewModel.editorItems.find(t=>t.layer===e)).filter(r),n=new g({data:new f({...a,editorItems:s}),onCommit:M(t.applyEdits)});return n._set("steps",b()),n}async deleteAndCommit(){return this.data.stageDelete(),this.commit()}enter(){throw new Error("Method not implemented.")}exit(t){throw new Error("Method not implemented.")}async reset(){}async save(){const{formViewModel:t}=this;t.submit(),t.valid&&await super.save()}async start(){await super.start(),await n(()=>!this.updating)}_initializeFormViewModel(){const{data:t}=this,e=t.viewModel.view,r=t.getEditorItemForLayer(k(t)),o=new c({editType:"UPDATE",map:e?.map,readOnly:!1===r?.capabilities.update.attributes,spatialReference:e?.spatialReference,timeZone:t.timeZone});this._formViewModel=o,this.addHandles(o.on("value-change",e=>{for(const r of e.features)t.getPendingEditsForFeature(r)?.setAttribute(e.fieldName,e.value);this._sketchController?.notifyAttributesChanged(e)}))}async _initializeHighlights(t,e,r){const o=await m(r,e);this.addHandles(o.highlight(t))}async _initializeSketchController(t,e,r){const o=new w({sourceLayer:e,view:r,features:t});this._sketchController=o,await n(()=>!o.updating);const{data:i}=this;await o.startUpdatingFeatures(t,t=>{const e=[];for(const{feature:r,geometry:o}of t)i.getPendingEditsForFeature(r)?.updateGeometry(o),e.push(r);this._formViewModel.notifyGeometriesChanged(e)},()=>{F().warnOnce("editor:batch-update-visual-variables","UpdateFeaturesWorkflow does not currently support modifying visual variables through the scale and rotate tools.")})}async _initializeVisuals(t){const{data:e}=this,{view:r}=e.viewModel;if(!r)return;const o=k(e);if(u(o))return;const i=e.getEditorItemForLayer(o);return!i?.capabilities.update.geometry||"3d"===r?.type&&p(o.elevationInfo)?this._initializeHighlights(t,o,r):this._initializeSketchController(t,o,r)}};t([l()],_.prototype,"features",null),t([l()],_.prototype,"formViewModel",null),t([l()],_.prototype,"hasPendingEdits",null),t([l()],_.prototype,"parent",null),t([l()],_.prototype,"parentLayer",null),t([l()],_.prototype,"selectedFeature",null),t([l()],_.prototype,"sketchViewModel",null),t([l()],_.prototype,"type",void 0),t([l()],_.prototype,"updating",null),t([l()],_.prototype,"_formViewModel",void 0),t([l()],_.prototype,"_sketchController",void 0),_=g=t([d("esri.widgets.Editor.UpdateFeaturesWorkflow")],_);const v=_;function b(){return[{id:"editing-features",async setUp(){},async tearDown(){}}]}function M(t){return async e=>{const r=k(e),o=[],i=[];for(const t of e.fullFeatures){const r=e.getPendingEditsForFeature(t),a=r?.stagedForDelete;if(!r?.modified&&!a)continue;const s=t.clone();if(!r?.attributesModified||a){const e=t.sourceLayer;if(!e){F().warn("Feature has no sourceLayer. It will not be included in any applyEdits payload.");continue}const r=e.objectIdField;if(s.attributes={[r]:t.getAttribute(r)},"scene"===e.type&&null!=e.infoFor3D){const r=e.associatedLayer?.globalIdField;null!=r&&s.setAttribute(r,t.getAttribute(r))}}r?.geometryModified&&!a||(s.geometry=null),a?i.push(s):o.push(s)}if(o.length+i.length===0)return void F().warn("No edits to apply. Workflow will finish without sending an applyEdits request.");const a={updateFeatures:o.length>0?o:void 0,deleteFeatures:i.length>0?i:void 0};await t(r,a)}}function k(t){if(t.layers.length>1)throw y();return t.layers[0]}function E(t,e){if(!t||!t.feature)return;const{attributes:r}=t.feature;Object.keys(e).some(t=>e[t]!==r[t])&&t.updateAttributes(e)}export{v as default};
|