@arcgis/core 6.0.0-next.23 → 6.0.0-next.24
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.d.ts +47 -14
- package/PopupTemplate.js +1 -1
- package/WebScene.d.ts +3 -0
- package/arcade/functions/string.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{db9921fbda556f142c4a.js → 04d55ed51e8b2683c4b4.js} +1 -1
- package/assets/esri/core/workers/chunks/{435b90168f79c5587a07.js → 04ecf15524ff3838c01c.js} +1 -1
- package/assets/esri/core/workers/chunks/{e2f42aec02bff33b25dd.js → 09300e74e5b014ce6269.js} +1 -1
- package/assets/esri/core/workers/chunks/{fcb86d24fc7e0666b564.js → 096b2bf1c0d69d27f20c.js} +1 -1
- package/assets/esri/core/workers/chunks/{612345f17f5eeb99ea8f.js → 0d9c4c6c571ce26d356b.js} +1 -1
- package/assets/esri/core/workers/chunks/{0f725cf79ce00e790a7d.js → 1168bc5c9f0a7e1f63a2.js} +1 -1
- package/assets/esri/core/workers/chunks/{12a7997a40c77f5c9160.js → 151e5799ede763a03ee2.js} +1 -1
- package/assets/esri/core/workers/chunks/{a64446a3328a7323e307.js → 173f89c55a5c79ff065b.js} +1 -1
- package/assets/esri/core/workers/chunks/{8715661a838361d4211a.js → 1b24a40c0fa197014873.js} +1 -1
- package/assets/esri/core/workers/chunks/{ca0d4ce453d8eb35467d.js → 277263466837e1673f56.js} +1 -1
- package/assets/esri/core/workers/chunks/{b1d989b72203113a06fe.js → 2a36fe3f3f257a779a1b.js} +1 -1
- package/assets/esri/core/workers/chunks/{ffcb99693182a621a93e.js → 2cf8172be83b10b11bdc.js} +1 -1
- package/assets/esri/core/workers/chunks/{fcaf9450642fcef83286.js → 3048e74e6246324ce6fc.js} +1 -1
- package/assets/esri/core/workers/chunks/{95b82cbbe355266c65d7.js → 30af63b3b750142faadb.js} +1 -1
- package/assets/esri/core/workers/chunks/30dcf2cfb31cb70de7df.js +1 -0
- package/assets/esri/core/workers/chunks/{9f0a973a0dd28953ce25.js → 371e2ddb88cc6b9a41e8.js} +1 -1
- package/assets/esri/core/workers/chunks/3fd5c3cd8457ddc68798.js +1 -0
- package/assets/esri/core/workers/chunks/{62fec1816907f070f079.js → 3fe04f13215474accb09.js} +1 -1
- package/assets/esri/core/workers/chunks/{f47fe4433b05fca5c3ad.js → 42f6194633c2d879c8da.js} +1 -1
- package/assets/esri/core/workers/chunks/{cddc3e285f763ccf33c2.js → 4869e097261ded90b8bb.js} +1 -1
- package/assets/esri/core/workers/chunks/{d8a7eba588d374b2f961.js → 4bb9a5f4ca944d3fc206.js} +1 -1
- package/assets/esri/core/workers/chunks/{8052da8be251c3ff2176.js → 4d93bed14945e3d34d5c.js} +1 -1
- package/assets/esri/core/workers/chunks/{65cb5e39c467a35621ca.js → 56e903ccef66cbe18f92.js} +1 -1
- package/assets/esri/core/workers/chunks/{44d5508042cacdfcac47.js → 58da3f8cf0f7f6a7e4fa.js} +1 -1
- package/assets/esri/core/workers/chunks/{bc915fb182d463d804e6.js → 5c04835b0b52461183cd.js} +1 -1
- package/assets/esri/core/workers/chunks/{7e8611cb709f105946f5.js → 6061232c96e11eb7b25d.js} +1 -1
- package/assets/esri/core/workers/chunks/{1e514e1c9aabefa04201.js → 64382363d6dc04ff1eac.js} +1 -1
- package/assets/esri/core/workers/chunks/{c82daefb193aae895bc0.js → 67e06d606c7fd2064adf.js} +1 -1
- package/assets/esri/core/workers/chunks/{434a8ba841a59e0deab9.js → 67e533748435253aaba6.js} +1 -1
- package/assets/esri/core/workers/chunks/{feb41abc03d677df6f73.js → 6b9961261241fdce0e94.js} +1 -1
- package/assets/esri/core/workers/chunks/{949bee7b304e625a7891.js → 6db0f8fe1402643fbe1a.js} +1 -1
- package/assets/esri/core/workers/chunks/{96c4ea9cfa3930f1c3fb.js → 6f1d6453184e0a1530ad.js} +1 -1
- package/assets/esri/core/workers/chunks/6f897b4e7ddd1dd1672b.js +1 -0
- package/assets/esri/core/workers/chunks/{0049b66ccbfb168caa76.js → 7124ad8dc5ad40dc66f3.js} +1 -1
- package/assets/esri/core/workers/chunks/{6e107ce73633de8ac257.js → 72f4dad65e16a7d7c58f.js} +1 -1
- package/assets/esri/core/workers/chunks/{0df9a906f7823c23d426.js → 7566321c6a2913f2852b.js} +1 -1
- package/assets/esri/core/workers/chunks/{c4ddac23bd649d24f3f2.js → 75d551a449bba61ce238.js} +1 -1
- package/assets/esri/core/workers/chunks/{af349c7bc8ef41a0e1bd.js → 7748c2886d0122b40eeb.js} +1 -1
- package/assets/esri/core/workers/chunks/{b4c3ec081874b49ff89b.js → 78fbe330f16bdbdb886e.js} +1 -1
- package/assets/esri/core/workers/chunks/79483c05867ba1386f5a.js +1 -0
- package/assets/esri/core/workers/chunks/7b482afb9fd1229f5707.js +1 -0
- package/assets/esri/core/workers/chunks/7c631e2947243e2c9bde.js +1 -0
- package/assets/esri/core/workers/chunks/7db9e615e60d824eac1b.js +1 -0
- package/assets/esri/core/workers/chunks/{8a7b02037151767542f1.js → 7dbf4c7480bf9c72820d.js} +1 -1
- package/assets/esri/core/workers/chunks/{64b360625c68cb863a08.js → 84940d8e14caf5a27e04.js} +1 -1
- package/assets/esri/core/workers/chunks/{1b1d3f6916d2cb751435.js → 87177e0f82e8a6ae3189.js} +1 -1
- package/assets/esri/core/workers/chunks/{5cb26bbaa08114aec5ce.js → 89cc1a5539b82fb46216.js} +1 -1
- package/assets/esri/core/workers/chunks/{9d40786c5ceface786ba.js → 8a485130781b49dbf608.js} +1 -1
- package/assets/esri/core/workers/chunks/8b5dcc4282772bf6b675.js +1 -0
- package/assets/esri/core/workers/chunks/{8c12269d26f5a4c753cb.js → 8ebaf5754e86a45b0497.js} +1 -1
- package/assets/esri/core/workers/chunks/{542e5640ea1b80ef801a.js → 9189dfe19a2a2ccd5173.js} +1 -1
- package/assets/esri/core/workers/chunks/{67a35155b8b4d36f171e.js → 926e0a3827eaf16ca8b4.js} +1 -1
- package/assets/esri/core/workers/chunks/{dc1761cba0454fda3cf9.js → 9630234267098115de4d.js} +1 -1
- package/assets/esri/core/workers/chunks/{10d80e793019dfb45ca2.js → 987424121cf30b0f3c50.js} +1 -1
- package/assets/esri/core/workers/chunks/9afc87474cef1fc4fe4a.js +1 -0
- package/assets/esri/core/workers/chunks/{facd1ff23203fed67686.js → 9b048f80c2d28d527373.js} +1 -1
- package/assets/esri/core/workers/chunks/9dd48e75b4e8d9811d81.js +1 -0
- package/assets/esri/core/workers/chunks/{ee08ae5b73439a1ff666.js → a163c6005aba3378edaa.js} +1 -1
- package/assets/esri/core/workers/chunks/{517106048980a3cbe072.js → a4b822ee45810c4c292a.js} +1 -1
- package/assets/esri/core/workers/chunks/{092e311cb7aea92a6a26.js → acb265a22be5e12f38e5.js} +1 -1
- package/assets/esri/core/workers/chunks/{1a411ddae7a47015370c.js → acf4737ba509cbd73cce.js} +1 -1
- package/assets/esri/core/workers/chunks/{d247dd53788d512b9c9f.js → af3c6794334626b94f00.js} +1 -1
- package/assets/esri/core/workers/chunks/{532e9cda8ac3601d8892.js → b12acf1f694f82e00df9.js} +1 -1
- package/assets/esri/core/workers/chunks/{636cd05abfbdff19029e.js → ba3d5abff65aefcb8dee.js} +1 -1
- package/assets/esri/core/workers/chunks/{504184828048310a052c.js → bdc221d94300c225665a.js} +1 -1
- package/assets/esri/core/workers/chunks/c0eb27263f608dc3684b.js +1 -0
- package/assets/esri/core/workers/chunks/c2318c014e97ba519be8.js +1 -0
- package/assets/esri/core/workers/chunks/{7f8e327acad48c9e75ea.js → c62237c344e341619341.js} +1 -1
- package/assets/esri/core/workers/chunks/{a2ad3e620c98e2b2eb06.js → cd355baab983033c3ef0.js} +1 -1
- package/assets/esri/core/workers/chunks/{7be6d621a0d1e33dfff4.js → d070fcb73ce274ab80e4.js} +1 -1
- package/assets/esri/core/workers/chunks/{6d41444b46677aa762a7.js → db41490bd39d863305bf.js} +1 -1
- package/assets/esri/core/workers/chunks/{fc5a36e54929e03efa86.js → dba5f44c4e4a3f075df2.js} +1 -1
- package/assets/esri/core/workers/chunks/{3e30b96a8c75bd5b9ae2.js → ddc95cdac6c06fc4794c.js} +1 -1
- package/assets/esri/core/workers/chunks/{a5c8f9f5be4ef5063b42.js → df26ec0b508cf4716e0a.js} +1 -1
- package/assets/esri/core/workers/chunks/{f426da2210888cc264b4.js → e83f9abee611c5b80009.js} +1 -1
- package/assets/esri/core/workers/chunks/{8487727f1197cf7dbf50.js → ef12fa3574d4cbf8b084.js} +1 -1
- package/assets/esri/core/workers/chunks/f10c883eb26330e3421c.js +1 -0
- package/assets/esri/core/workers/chunks/f46e92c67986c8c09bdd.js +1 -0
- package/assets/esri/core/workers/chunks/{709e019885822b1f6f3e.js → f905f1a1aa4c123cbe83.js} +1 -1
- package/assets/esri/core/workers/chunks/{5b91e2dffdc84c006539.js → fb37f0848196c28b7fd7.js} +1 -1
- package/assets/esri/libs/librust-parquet/pkg/parquet_bg.wasm +0 -0
- package/assets/esri/libs/librust-text/pkg/text_bg.wasm +0 -0
- package/chunks/MultiPathImpl.js +1 -1
- package/chunks/OperatorProximityGeodesic.js +1 -1
- package/chunks/basis_encoder.js +1 -1
- package/chunks/basis_transcoder.js +1 -1
- package/chunks/draco_mesh_decoder.js +1 -1
- package/chunks/dxt_encoder.js +1 -1
- package/chunks/i3s.js +1 -1
- package/chunks/lclayout.js +1 -1
- package/chunks/lerc-wasm.js +1 -1
- package/chunks/libtess-f32.js +1 -1
- package/chunks/libtess-f64.js +1 -1
- package/chunks/lyr3DMain.js +1 -1
- package/chunks/lyr3DWorker.js +1 -1
- package/chunks/parquet.js +1 -1
- package/chunks/qb3-wasm.js +1 -1
- package/chunks/rbush.js +1 -1
- package/chunks/text.js +1 -1
- package/chunks/vxlLayer.js +1 -1
- package/config.js +1 -1
- package/core/workers/WorkerFallback.js +4 -2
- package/core/workers/workerFactory.js +1 -1
- package/core/workers/workers.js +4 -2
- package/geometry/support/labelPoint.js +1 -1
- package/graphic/AnnotationFeatureGraphicOrigin.d.ts +49 -9
- package/graphic/BuildingGraphicOrigin.d.ts +49 -0
- package/graphic/CSVGraphicOrigin.d.ts +42 -9
- package/graphic/CatalogGraphicOrigin.d.ts +42 -9
- package/graphic/DimensionFeatureGraphicOrigin.d.ts +42 -9
- package/graphic/FeatureGraphicOrigin.d.ts +42 -9
- package/graphic/GeoJSONGraphicOrigin.d.ts +42 -9
- package/graphic/GeoRSSGraphicOrigin.d.ts +42 -9
- package/graphic/GraphicOrigin.d.ts +52 -12
- package/graphic/ImageryGraphicOrigin.d.ts +42 -9
- package/graphic/ImageryTileGraphicOrigin.d.ts +42 -9
- package/graphic/KMLGraphicOrigin.d.ts +47 -10
- package/graphic/KnowledgeGraphGraphicOrigin.d.ts +49 -1
- package/graphic/LinkChartGraphicOrigin.d.ts +49 -1
- package/graphic/MapImageGraphicOrigin.d.ts +49 -1
- package/graphic/MapNotesGraphicOrigin.d.ts +48 -1
- package/graphic/OGCFeatureGraphicOrigin.d.ts +42 -9
- package/graphic/OrientedImageryGraphicOrigin.d.ts +42 -9
- package/graphic/ParquetGraphicOrigin.d.ts +42 -9
- package/graphic/PointCloudGraphicOrigin.d.ts +43 -0
- package/graphic/SceneGraphicOrigin.d.ts +43 -0
- package/graphic/SketchGraphicOrigin.d.ts +43 -0
- package/graphic/StreamGraphicOrigin.d.ts +43 -0
- package/graphic/SubtypeGroupGraphicOrigin.d.ts +49 -1
- package/graphic/TileGraphicOrigin.d.ts +49 -1
- package/graphic/VectorTileGraphicOrigin.d.ts +43 -14
- package/graphic/VoxelGraphicOrigin.d.ts +43 -0
- package/graphic/WCSGraphicOrigin.d.ts +43 -0
- package/graphic/WFSGraphicOrigin.d.ts +42 -9
- package/graphic/getGraphicOriginTitle.d.ts +21 -3
- package/kernel.js +1 -1
- package/layers/GaussianSplatLayer.d.ts +2 -1
- package/layers/ParquetLayer.d.ts +24 -1
- package/layers/ParquetLayer.js +1 -1
- package/layers/mixins/ReloadableLayer.js +1 -1
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/layers/save/featureLayerUtils.js +1 -1
- package/layers/save/imageryUtils.js +1 -1
- package/layers/save/mapImageLayerUtils.js +1 -1
- package/layers/save/mediaLayerUtils.js +1 -1
- package/layers/save/parquetLayerUtils.js +2 -0
- package/layers/save/streamLayerUtils.js +1 -1
- package/layers/support/LabelClass.d.ts +8 -2
- package/layers/support/layersMapping.js +1 -1
- package/layers/support/rasterJobHelper.js +1 -1
- package/layers/video/VideoController.js +5 -5
- package/package.json +2 -2
- package/popup/content.js +1 -1
- package/portal/schemas/definitions.js +1 -1
- package/portal/schemas/webScene.js +1 -1
- package/rest/query/operations/pbfDehydratedFeatureSet.js +1 -1
- package/rest/query/operations/pbfFlatFeatureSet.js +1 -1
- package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
- package/undoredo/support/ApplySet.js +1 -1
- package/views/2d/engine/flow/ProcessingTimeEstimate.js +1 -1
- package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
- package/views/2d/engine/vectorTiles/buckets/SymbolBucket.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
- package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/graphics/Deconflictor.js +1 -1
- package/views/3d/layers/graphics/ElevationAligners.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/LabelParameters.js +1 -1
- package/views/3d/layers/graphics/Labeler.js +1 -1
- package/views/3d/layers/graphics/elevationAlignmentUtils.js +1 -1
- package/views/3d/layers/graphics/pointUtils.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/layers/support/Tiles3DBVH.js +1 -1
- package/views/3d/layers/support/featureTileQuery3D.js +1 -1
- package/views/3d/state/controllers/ZoomControllerLocal.js +1 -1
- package/views/3d/state/controllers/ZoomStepControllerLocal.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/state/utils/groundNavigationUtils.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
- package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowCastRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
- package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
- package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
- package/views/3d/webgl-engine/lib/screenPolygonTriangleIntersections.js +1 -1
- package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/TriangleMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/internal/worldSizedRibbonLineIntersectionUtils.js +1 -1
- package/views/DOMContainer.js +1 -1
- package/views/draw/SegmentDrawAction.js +1 -1
- package/views/interactive/snapping/SnappingManagerPool.js +1 -1
- package/views/interactive/tooltip/content/TooltipContent.js +1 -1
- package/views/interactive/tooltip/fields/TooltipField.js +1 -1
- package/views/support/LayerViewManager.js +1 -1
- package/views/support/ScheduledQueueProcessor.js +1 -1
- package/views/support/screenshotUtils.js +1 -1
- package/views/ui/UI.js +1 -1
- package/webdoc/support/webdocSaveUtils.js +1 -1
- package/webscene/Slide.d.ts +1 -2
- package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
- package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
- package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
- package/widgets/FeatureTable/RelationshipColumn.js +1 -1
- package/widgets/OrientedImageryViewer/ImageMeasurementWorker.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
- package/widgets/OrientedImageryViewer/services/ImageMeasurementService.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/14d5d219e7fe017f23f0.js +0 -1
- package/assets/esri/core/workers/chunks/42753cf4965a94bc91ca.js +0 -1
- package/assets/esri/core/workers/chunks/42e985a576d7aaeed0cf.js +0 -1
- package/assets/esri/core/workers/chunks/5046214dd32029cb733d.js +0 -1
- package/assets/esri/core/workers/chunks/58865772bed48141a56a.js +0 -1
- package/assets/esri/core/workers/chunks/72e6d594b7262430ae55.js +0 -1
- package/assets/esri/core/workers/chunks/7d11710e1586a3d75887.js +0 -1
- package/assets/esri/core/workers/chunks/8f74d92ac69714b9fd4e.js +0 -1
- package/assets/esri/core/workers/chunks/947674b2ca8be65b9bcc.js +0 -1
- package/assets/esri/core/workers/chunks/9e7c4eda135c4911b268.js +0 -1
- package/assets/esri/core/workers/chunks/a09d2e1e2540921e4717.js +0 -1
- package/assets/esri/core/workers/chunks/dfa5f1311806473e473f.js +0 -1
- package/assets/esri/core/workers/chunks/fc76aff0f7d95e517d8f.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{disposeMaybe as t}from"../../../core/maybe.js";import{MemCachePool as n}from"../../../core/MemCachePool.js";import r from"../../../core/ObjectPool.js";import{watch as i,sync as a}from"../../../core/reactiveUtils.js";import{property as o,subclass as s}from"../../../core/accessorSupport/decorators.js";import{subtract as c,set as l,dot as u}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as d,fromValues as f,create as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as m,ZEROS as h}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as g,set as _}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as v}from"../../../geometry/support/buffer/BufferView.js";import{overlayRenderOccludedFlag as y}from"./OverlayRenderer.js";import{PatchRenderData as b}from"./PatchRenderData.js";import{TerrainAttributesCache as x}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as S}from"./terrainUtils.js";import{TileRenderer as C}from"./TileRenderer.js";import{IteratorPreorder as w,fallsWithinLayerView as T,sortTiles as E,compareTiles as D}from"./tileUtils.js";import{getOverlayContentForOutputTerrain as O}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as k}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as A}from"../webgl-engine/lib/Attribute.js";import{IntersectorResultRay as j}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as M,MeshIntersectionOptions as N,intersectTriangles as P}from"../webgl-engine/lib/RayIntersections.js";import{TriangleIntersectionData as F}from"../webgl-engine/lib/TriangleIntersectionData.js";import{terrainId as I,getVerticalOffsetTerrain as L}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as R}from"../webgl-engine/materials/DrawParameters.js";import{hasShadowHighlights as z}from"../webgl-engine/shaders/ReceiveShadowsConfiguration.js";import{T as B}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as V}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as H}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as U}from"../../webgl/enums.js";const W=g();let G=class extends k{get visibleTiles(){return Array.from(this._visiblePatchesByOrigin.values()).flat()}get _isGlobal(){return this._stage.viewingMode===1}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}get renderOccludedFlags(){return this._overlayRenderer.renderOccludedFlags}constructor(e,t,i,a,o){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._compressionTracker=a,this.type=7,this.isGround=!0,this._passParameters=new B,this._drawParameters=new R,this._renderDataPool=new r(()=>new b),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new w,this._castShadows=!1,this._inViewshed=!1,this._cutFillEnabled=!1,this._tileRenderer=null,this._stencilEnabledLayerExtents=[],this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.produces=new Map([[1,()=>this._desiredSlot===1],[7,()=>this._desiredSlot===7],[9,()=>this._produces()&&this.renderOccludedFlags===y]]),this._tileSize=256,this._configuration=new H(t.viewingMode===1),this._tileTextureCache=new n((e,t)=>o.newCache(e,t),`TileTexture`),this.tileGeometryCache=new x(o)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(i(()=>this._overlayRenderer.renderOccludedFlags,()=>this.setNeedsRender(),a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set(`renderingDisabled`,!!e),this.setDirty()}set visible(e){this._set(`visible`,!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange(`renderPatchBorders`))}get layerViewUid(){return I}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,this._tileRenderer!=null&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),!this.reuseTextureFromParent(e)&&this.updateTileTexture(e,32)}reuseTextureFromParent(e){let{parent:t}=e;if(!this._canReuseTextureFromParent(t,e))return!1;let n=m(e.lij[2]&1?.5:0,e.lij[1]&1?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,n)??!1}_canReuseTextureFromParent(e,t){if(!e)return!1;let{layerInfo:n,surface:r}=t;for(let i=0;i<n[1].length;i++){let n=r.layerViewByIndex(i,1);if(T(e,n)!==T(t,n))return!1}return!0}updateTileTexture(e,t){this._tileRenderer!=null&&(this._tileRenderer.updateTileTexture(e,t===32?0:2),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(let t of e.layerInfo[0])t.pendingUpdates&=-9;e.resetPendingUpdate(8);let t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){let t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){let t=Math.max(0,Math.floor((e.level-3)/7)*7);if(this._isGlobal&&t===0)return d;for(;e.parent&&e.level>t;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get(`wireframe`)!==e&&(this._set(`wireframe`,e),this.setNeedsRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new C(this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=t(this._tileRenderer)}intersectRay(e,t,n,r){let i=this._rootTiles;if(!i||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==0)return;let a=K,o=q;c(a,r,n),l(o,1/a[0],1/a[1],1/a[2]);let s=e.results.min,d=e.results.max,f=e.results.ground,p=e.options.store===0,m=!!e.results.ground.target,h=L(e.verticalOffset),g=e.tolerance,y,b=p&&s.distance!=null?s.distance:1/0,x=e.options,S=x.normalRequired||!x.backfacesTerrain,C=new N(g,!1,S),w=i=>{let l=i.renderData;if(!l?.vao)return;let m=l.geometry;_(W,m.boundingBox);let w=l.localOrigin;if(h!=null&&(h.localOrigin=w,h.applyToAabb(W)),J[0]=n[0]-w[0],J[1]=n[1]-w[1],J[2]=n[2]-w[2],!M(W,J,o,g,b))return;let T=(e,t,n,r)=>{e.set(this.type,i,t,n,r),b=p&&s.renderDistance!=null?s.renderDistance:1/0},E=(i,o,c)=>{(!S||c!=null)&&o>=0&&(x.backfacesTerrain||u(c,a)<0)&&(x.invisibleTerrain||!x.selectionMode||t==null||t(n,r,o))&&((f.renderDistance==null||o<f.renderDistance)&&T(f,i,o,c),!x.isFiltered&&(x.store===2&&(y==null?(y=new j(e.ray),T(y,i,o,c),e.results.all.push(y)):o<y.renderDistance&&T(y,i,o,c)),(s.renderDistance==null||o<s.renderDistance)&&T(s,i,o,c),x.store!==0&&(d.renderDistance==null||o>d.renderDistance)&&T(d,i,o,c)))},D=Y;c(D,r,w);let{indices:O,indexCount:k}=m,N=m.vertexAttributes,I=N.getField(`position`,v),L=new A(I.typedBuffer,3,N.stride/4),R=k/3;!h&&R>200?(l.intersectionData??=new F(O,R,L),l.intersectionData.intersectRay(J,D,C,E)):P(J,D,0,R,(e,t)=>I.getVec(O[t],e),h,C,E)},T=this._tileIterator;T.reset(i);let E=e.options.invisibleTerrain;for(let e=T.next();e;e=T.next())(e.visible||E&&e.intersectsClippingArea)&&(h!=null||e.intersectsRay(n,a,g,b))&&(!m||!this._useStencilForTile(e))?w(e):T.skipSubtree()}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(let t of this._visiblePatchesByOrigin.values())for(let n of t)n.renderData?.textureReference!=null&&e.queriesForTile(n);e.process(),t.madeProgress()}}get _desiredSlot(){if(!this._produces())return null;switch(this.transparency){case 0:return 1;case 1:case 2:return 7;case 3:case 4:return null}}acquireTechniques(e){let{shadowMap:t,viewshedEnabled:n,cutFillComputationEnabled:r,slot:i,hasEmission:a,useFloatBlend:o}=e.bind,s=!!has(`enable-feature:terrain-shadows`)&&t.enabled;if(s!==this._castShadows&&(this._castShadows=s,this._patchesByOriginDirty=!0),this._inViewshed!==n&&(this._inViewshed=n,this._patchesByOriginDirty=!0),this._cutFillEnabled!==r&&(this._cutFillEnabled=r,this._patchesByOriginDirty=!0),this.transparency===3)return null;if(i===9){if((e.renderOccludedMask&y)===0)return null}else if(i!==this._desiredSlot)return null;let c=this._configuration;switch(c.receiveGlobalIllumination=c.screenSpaceReflections=c.cloudReflections=c.receiveShadows=c.hasShadowHighlights=c.receiveAmbientOcclusion=c.renderOccluded=c.hasHighlightMixTexture=!1,c.hasEmission=a,c.overlayMode=this._overlayRenderer.mode,c.useFloatBlend=o.value,e.output){case 0:case 1:case 2:{let n=e.bind;c.screenSpaceReflections=n.hasScreenSpaceReflections,c.cloudReflections=n.clouds.data!=null;let r=i===9;return c.receiveShadows=t.ready&&!r,c.hasShadowHighlights=z(c,e.bind),c.renderOccluded=r,c.receiveAmbientOcclusion=!r&&n.ssao!=null,c.receiveGlobalIllumination=!r&&n.globalIlluminationEnabled,this._acquireTechnique(e.output)}case 5:case 7:return this._castShadows?this._acquireTechnique(5):null;case 8:return this._inViewshed?this._acquireTechnique(8):null;case 9:return this._cutFillEnabled?this._acquireTechnique(9):null;case 3:case 4:case 11:return this._acquireTechnique(e.output);case 10:return c.hasHighlightMixTexture=e.bind.highlightMixTexture!=null,this._overlayRenderer.hasHighlights?this._acquireTechnique(10):null}return null}render(e,t){switch(this._updatePatchGroups(),this._passParameters.useStencil=!1,this._passParameters.overlayContent=O(e.output,e.bind),e.output){case 0:case 1:case 2:return this._renderMaterialPass(e,t);case 3:case 4:case 11:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 10:{let n=e.bind.highlight?.name;n&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(n)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 5:case 7:case 8:case 9:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(this._tileRenderer==null)return;let t=this._tileRenderer,n;if(e!=null){let t=e.toUnitRGBA();n=f(t[0]||0,t[1]||0,t[2]||0)}t.setBackground(n),this._allTiles.forAll(e=>t.updateTileTexture(e,0)),this._configuration.tileBlendInput=t.backgroundIsGrid?2:t.backgroundColor==null?0:1,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty){let e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(let n of e)E(n,t);e.sort((e,t)=>D(e[0],t[0])),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this.notifyChange(`visibleTiles`),this._patchSortingDirty=!1}}_rebuildPatchGroups(){let e=this._rootTiles;if(e!=null){e[0]?.surface.checkAllTilesWaterproofness(`render-patch-groups`),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(let t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){let t=this._tileIterator;for(t.resetOne(e);!t.done;){let e=t.next(),n=e.renderData;if(!n){this._numTilesCulled++;continue}let r=n.localOrigin;if(this._castShadows||this._inViewshed||this._cutFillEnabled){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let i=this._visiblePatchesByOrigin.get(r);i||(i=[],this._visiblePatchesByOrigin.set(r,i)),i.push(e),t.skipSubtree()}}_useStencilForTile(e){for(let t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,n){let{rctx:r,bind:i}=e;r.bindTechnique(t,i,this._passParameters);let a=this._stencilEnabledLayerExtents.length>0;n.forEach(n=>{this._drawParameters.origin=n[0].renderData.localOrigin,t.program.bindDraw(i,this._passParameters,this._drawParameters);for(let r=0;r<n.length;r++)this._renderPatch(e,t,n[r],U.TRIANGLES,a,this._passParameters.overlayContent===null)}),r.bindVAO(null)}_renderMaterialPass(e,t){let{rctx:n,bind:r}=e,i=n.bindTechnique(t,r,this._passParameters);this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;let a=r.slot===9;a&&(i.bindTexture(`tex`,n.emptyTexture),i.setUniform3fv(`textureOpacities`,d),i.setUniform4fv(`texOffsetAndScale`,h));let o=this._tileRenderer?.backgroundColor==null?d:this._tileRenderer.backgroundColor;this._configuration.tileBlendInput===1&&i.setUniform3fv(`backgroundColor`,o);let s=this._stencilEnabledLayerExtents.length>0,c=this.wireframe?U.LINES:U.TRIANGLES;this._configuration.textureFadingEnabled&&i.bindTexture(`texNext`,n.emptyTexture);for(let n of this._visiblePatchesByOrigin.values()){this._drawParameters.origin=n[0].renderData.localOrigin,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(let r of n){let n=r.renderData,o=n.textureReference;if(o!=null){if(!a){i.setUniform4fv(`texOffsetAndScale`,o.offsetAndScale),i.bindTexture(`tex`,o.texture.texture);let e=n.textureFadeFactor,t=e<1?n.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(i.setUniform1f(`fadeFactor`,e),i.setUniform4fv(`nextTexOffsetAndScale`,t.offsetAndScale),i.setUniform3fv(`nextTexOpacities`,t.opacities),i.bindTexture(`texNext`,t.texture.texture)):i.setUniform1f(`fadeFactor`,1),n.textureIsFading&&this.setNeedsRender(2),i.setUniform3fv(`textureOpacities`,o.opacities)}this._renderPatch(e,t,r,c,s),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}n.bindVAO(null)}_renderPatch(e,t,n,r,i,a=!1){let o=n.renderData,s=o.vao,c=s?.indexBuffer;if(!s||c==null){S&&console.error(`Rendered tile with no indices: `,n.lij,` : `,o);return}let l=t.program;!a&&!this._overlayRenderer.isEmpty&&this._bindOverlayPatchData(l,o.overlay);let{rctx:u,bind:d}=e;i&&(this._passParameters.useStencil=this._useStencilForTile(n),u.setPipelineState(t.getPipeline(d,this._passParameters)));let f=o.geometry.indexCount;u.bindVAO(s),l.assertCompatibleVertexAttributeLocations(s),u.drawElements(r,f,c.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv(`overlayTexOffset`,t.offsets),e.setUniform4fv(`overlayTexScale`,t.scales)}_acquireTechnique(e){return this._configuration.output=e,this._techniques.get(V,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([o({readOnly:!0})],G.prototype,`visibleTiles`,null),e([o({readOnly:!0})],G.prototype,`_isGlobal`,null),e([o()],G.prototype,`renderOccludedFlags`,null),e([o({value:!1})],G.prototype,`renderingDisabled`,null),e([o({value:!0})],G.prototype,`visible`,null),e([o()],G.prototype,`renderPatchBorders`,null),e([o()],G.prototype,`wireframe`,null),G=e([s(`esri.views.3d.terrain.TerrainRenderer`)],G);const K=p(),q=p(),J=p(),Y=p();export{G as TerrainRenderer};
|
|
2
|
+
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{disposeMaybe as t}from"../../../core/maybe.js";import{MemCachePool as n}from"../../../core/MemCachePool.js";import r from"../../../core/ObjectPool.js";import{watch as i,sync as a}from"../../../core/reactiveUtils.js";import{property as o,subclass as s}from"../../../core/accessorSupport/decorators.js";import{subtract as c,set as l,dot as u}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as d,fromValues as f,create as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as m,ZEROS as h}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as g,set as _}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as v}from"../../../geometry/support/buffer/BufferView.js";import{overlayRenderOccludedFlag as y}from"./OverlayRenderer.js";import{PatchRenderData as b}from"./PatchRenderData.js";import{TerrainAttributesCache as x}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as S}from"./terrainUtils.js";import{TileRenderer as C}from"./TileRenderer.js";import{IteratorPreorder as w,fallsWithinLayerView as T,sortTiles as E,compareTiles as D}from"./tileUtils.js";import{getOverlayContentForOutputTerrain as O}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as k}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as A}from"../webgl-engine/lib/Attribute.js";import{IntersectorResultRay as j}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as M,MeshIntersectionOptions as N,intersectTriangles as P}from"../webgl-engine/lib/RayIntersections.js";import{TriangleIntersectionData as F}from"../webgl-engine/lib/TriangleIntersectionData.js";import{terrainId as I,getVerticalOffsetTerrain as L}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as R}from"../webgl-engine/materials/DrawParameters.js";import{hasShadowHighlights as z}from"../webgl-engine/shaders/ReceiveShadowsConfiguration.js";import{T as B}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as V}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as H}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as U}from"../../webgl/enums.js";const W=g();let G=class extends k{get visibleTiles(){return Array.from(this._visiblePatchesByOrigin.values()).flat()}get _isGlobal(){return this._stage.viewingMode===1}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}get renderOccludedFlags(){return this._overlayRenderer.renderOccludedFlags}constructor(e,t,i,a,o){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._compressionTracker=a,this.type=7,this.isGround=!0,this._passParameters=new B,this._drawParameters=new R,this._renderDataPool=new r(()=>new b),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new w,this._castShadows=!1,this._inViewshed=!1,this._cutFillEnabled=!1,this._tileRenderer=null,this._stencilEnabledLayerExtents=[],this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.produces=new Map([[1,()=>this._desiredSlot===1],[7,()=>this._desiredSlot===7],[9,()=>this._produces()&&this.renderOccludedFlags===y]]),this._tileSize=256,this._configuration=new H(t.viewingMode===1),this._tileTextureCache=new n((e,t)=>o.newCache(e,t),`TileTexture`),this.tileGeometryCache=new x(o)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(i(()=>this._overlayRenderer.renderOccludedFlags,()=>this.setNeedsRender(),a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set(`renderingDisabled`,!!e),this.setDirty()}set visible(e){this._set(`visible`,!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange(`renderPatchBorders`))}get layerViewUid(){return I}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,this._tileRenderer!=null&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,32)}reuseTextureFromParent(e){let{parent:t}=e;if(!this._canReuseTextureFromParent(t,e))return!1;let n=m(e.lij[2]&1?.5:0,e.lij[1]&1?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,n)??!1}_canReuseTextureFromParent(e,t){if(!e)return!1;let{layerInfo:n,surface:r}=t;for(let i=0;i<n[1].length;i++){let n=r.layerViewByIndex(i,1);if(T(e,n)!==T(t,n))return!1}return!0}updateTileTexture(e,t){this._tileRenderer!=null&&(this._tileRenderer.updateTileTexture(e,t===32?0:2),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(let t of e.layerInfo[0])t.pendingUpdates&=-9;e.resetPendingUpdate(8);let t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){let t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){let t=Math.max(0,Math.floor((e.level-3)/7)*7);if(this._isGlobal&&t===0)return d;for(;e.parent&&e.level>t;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get(`wireframe`)!==e&&(this._set(`wireframe`,e),this.setNeedsRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new C(this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=t(this._tileRenderer)}intersectRay(e,t,n,r){let i=this._rootTiles;if(!i||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==0)return;let a=K,o=q;c(a,r,n),l(o,1/a[0],1/a[1],1/a[2]);let s=e.results.min,d=e.results.max,f=e.results.ground,p=e.options.store===0,m=!!e.results.ground.target,h=L(e.verticalOffset),g=e.tolerance,y,b=p&&s.distance!=null?s.distance:1/0,x=e.options,S=x.normalRequired||!x.backfacesTerrain,C=new N(g,!1,S),w=i=>{let l=i.renderData;if(!l?.vao)return;let m=l.geometry;_(W,m.boundingBox);let w=l.localOrigin;if(h!=null&&(h.localOrigin=w,h.applyToAabb(W)),J[0]=n[0]-w[0],J[1]=n[1]-w[1],J[2]=n[2]-w[2],!M(W,J,o,g,b))return;let T=(e,t,n,r)=>{e.set(this.type,i,t,n,r),b=p&&s.renderDistance!=null?s.renderDistance:1/0},E=(i,o,c)=>{(!S||c!=null)&&o>=0&&(x.backfacesTerrain||u(c,a)<0)&&(x.invisibleTerrain||!x.selectionMode||t==null||t(n,r,o))&&((f.renderDistance==null||o<f.renderDistance)&&T(f,i,o,c),x.isFiltered||(x.store===2&&(y==null?(y=new j(e.ray),T(y,i,o,c),e.results.all.push(y)):o<y.renderDistance&&T(y,i,o,c)),(s.renderDistance==null||o<s.renderDistance)&&T(s,i,o,c),x.store!==0&&(d.renderDistance==null||o>d.renderDistance)&&T(d,i,o,c)))},D=Y;c(D,r,w);let{indices:O,indexCount:k}=m,N=m.vertexAttributes,I=N.getField(`position`,v),L=new A(I.typedBuffer,3,N.stride/4),R=k/3;!h&&R>200?(l.intersectionData??=new F(O,R,L),l.intersectionData.intersectRay(J,D,C,E)):P(J,D,0,R,(e,t)=>I.getVec(O[t],e),h,C,E)},T=this._tileIterator;T.reset(i);let E=e.options.invisibleTerrain;for(let e=T.next();e;e=T.next())(e.visible||E&&e.intersectsClippingArea)&&(h!=null||e.intersectsRay(n,a,g,b))&&(!m||!this._useStencilForTile(e))?w(e):T.skipSubtree()}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(let t of this._visiblePatchesByOrigin.values())for(let n of t)n.renderData?.textureReference!=null&&e.queriesForTile(n);e.process(),t.madeProgress()}}get _desiredSlot(){if(!this._produces())return null;switch(this.transparency){case 0:return 1;case 1:case 2:return 7;case 3:case 4:return null}}acquireTechniques(e){let{shadowMap:t,viewshedEnabled:n,cutFillComputationEnabled:r,slot:i,hasEmission:a,useFloatBlend:o}=e.bind,s=!!has(`enable-feature:terrain-shadows`)&&t.enabled;if(s!==this._castShadows&&(this._castShadows=s,this._patchesByOriginDirty=!0),this._inViewshed!==n&&(this._inViewshed=n,this._patchesByOriginDirty=!0),this._cutFillEnabled!==r&&(this._cutFillEnabled=r,this._patchesByOriginDirty=!0),this.transparency===3)return null;if(i===9){if((e.renderOccludedMask&y)===0)return null}else if(i!==this._desiredSlot)return null;let c=this._configuration;switch(c.receiveGlobalIllumination=c.screenSpaceReflections=c.cloudReflections=c.receiveShadows=c.hasShadowHighlights=c.receiveAmbientOcclusion=c.renderOccluded=c.hasHighlightMixTexture=!1,c.hasEmission=a,c.overlayMode=this._overlayRenderer.mode,c.useFloatBlend=o.value,e.output){case 0:case 1:case 2:{let n=e.bind;c.screenSpaceReflections=n.hasScreenSpaceReflections,c.cloudReflections=n.clouds.data!=null;let r=i===9;return c.receiveShadows=t.ready&&!r,c.hasShadowHighlights=z(c,e.bind),c.renderOccluded=r,c.receiveAmbientOcclusion=!r&&n.ssao!=null,c.receiveGlobalIllumination=!r&&n.globalIlluminationEnabled,this._acquireTechnique(e.output)}case 5:case 7:return this._castShadows?this._acquireTechnique(5):null;case 8:return this._inViewshed?this._acquireTechnique(8):null;case 9:return this._cutFillEnabled?this._acquireTechnique(9):null;case 3:case 4:case 11:return this._acquireTechnique(e.output);case 10:return c.hasHighlightMixTexture=e.bind.highlightMixTexture!=null,this._overlayRenderer.hasHighlights?this._acquireTechnique(10):null}return null}render(e,t){switch(this._updatePatchGroups(),this._passParameters.useStencil=!1,this._passParameters.overlayContent=O(e.output,e.bind),e.output){case 0:case 1:case 2:return this._renderMaterialPass(e,t);case 3:case 4:case 11:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 10:{let n=e.bind.highlight?.name;n&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(n)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 5:case 7:case 8:case 9:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(this._tileRenderer==null)return;let t=this._tileRenderer,n;if(e!=null){let t=e.toUnitRGBA();n=f(t[0]||0,t[1]||0,t[2]||0)}t.setBackground(n),this._allTiles.forAll(e=>t.updateTileTexture(e,0)),this._configuration.tileBlendInput=t.backgroundIsGrid?2:t.backgroundColor==null?0:1,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty){let e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(let n of e)E(n,t);e.sort((e,t)=>D(e[0],t[0])),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this.notifyChange(`visibleTiles`),this._patchSortingDirty=!1}}_rebuildPatchGroups(){let e=this._rootTiles;if(e!=null){e[0]?.surface.checkAllTilesWaterproofness(`render-patch-groups`),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(let t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){let t=this._tileIterator;for(t.resetOne(e);!t.done;){let e=t.next(),n=e.renderData;if(!n){this._numTilesCulled++;continue}let r=n.localOrigin;if(this._castShadows||this._inViewshed||this._cutFillEnabled){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let i=this._visiblePatchesByOrigin.get(r);i||(i=[],this._visiblePatchesByOrigin.set(r,i)),i.push(e),t.skipSubtree()}}_useStencilForTile(e){for(let t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,n){let{rctx:r,bind:i}=e;r.bindTechnique(t,i,this._passParameters);let a=this._stencilEnabledLayerExtents.length>0;n.forEach(n=>{this._drawParameters.origin=n[0].renderData.localOrigin,t.program.bindDraw(i,this._passParameters,this._drawParameters);for(let r=0;r<n.length;r++)this._renderPatch(e,t,n[r],U.TRIANGLES,a,this._passParameters.overlayContent===null)}),r.bindVAO(null)}_renderMaterialPass(e,t){let{rctx:n,bind:r}=e,i=n.bindTechnique(t,r,this._passParameters);this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;let a=r.slot===9;a&&(i.bindTexture(`tex`,n.emptyTexture),i.setUniform3fv(`textureOpacities`,d),i.setUniform4fv(`texOffsetAndScale`,h));let o=this._tileRenderer?.backgroundColor==null?d:this._tileRenderer.backgroundColor;this._configuration.tileBlendInput===1&&i.setUniform3fv(`backgroundColor`,o);let s=this._stencilEnabledLayerExtents.length>0,c=this.wireframe?U.LINES:U.TRIANGLES;this._configuration.textureFadingEnabled&&i.bindTexture(`texNext`,n.emptyTexture);for(let n of this._visiblePatchesByOrigin.values()){this._drawParameters.origin=n[0].renderData.localOrigin,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(let r of n){let n=r.renderData,o=n.textureReference;if(o!=null){if(!a){i.setUniform4fv(`texOffsetAndScale`,o.offsetAndScale),i.bindTexture(`tex`,o.texture.texture);let e=n.textureFadeFactor,t=e<1?n.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(i.setUniform1f(`fadeFactor`,e),i.setUniform4fv(`nextTexOffsetAndScale`,t.offsetAndScale),i.setUniform3fv(`nextTexOpacities`,t.opacities),i.bindTexture(`texNext`,t.texture.texture)):i.setUniform1f(`fadeFactor`,1),n.textureIsFading&&this.setNeedsRender(2),i.setUniform3fv(`textureOpacities`,o.opacities)}this._renderPatch(e,t,r,c,s),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}n.bindVAO(null)}_renderPatch(e,t,n,r,i,a=!1){let o=n.renderData,s=o.vao,c=s?.indexBuffer;if(!s||c==null){S&&console.error(`Rendered tile with no indices: `,n.lij,` : `,o);return}let l=t.program;!a&&!this._overlayRenderer.isEmpty&&this._bindOverlayPatchData(l,o.overlay);let{rctx:u,bind:d}=e;i&&(this._passParameters.useStencil=this._useStencilForTile(n),u.setPipelineState(t.getPipeline(d,this._passParameters)));let f=o.geometry.indexCount;u.bindVAO(s),l.assertCompatibleVertexAttributeLocations(s),u.drawElements(r,f,c.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv(`overlayTexOffset`,t.offsets),e.setUniform4fv(`overlayTexScale`,t.scales)}_acquireTechnique(e){return this._configuration.output=e,this._techniques.get(V,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([o({readOnly:!0})],G.prototype,`visibleTiles`,null),e([o({readOnly:!0})],G.prototype,`_isGlobal`,null),e([o()],G.prototype,`renderOccludedFlags`,null),e([o({value:!1})],G.prototype,`renderingDisabled`,null),e([o({value:!0})],G.prototype,`visible`,null),e([o()],G.prototype,`renderPatchBorders`,null),e([o()],G.prototype,`wireframe`,null),G=e([s(`esri.views.3d.terrain.TerrainRenderer`)],G);const K=p(),q=p(),J=p(),Y=p();export{G as TerrainRenderer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../Color.js";import{filterInPlace as n,difference as r}from"../../../core/arrayUtils.js";import i from"../../../core/CollectionFlattener.js";import{toConst as a}from"../../../core/compilerUtils.js";import{EventedAccessor as o}from"../../../core/Evented.js";import"../../../core/has.js";import s from"../../../core/Logger.js";import{clamp as c}from"../../../core/mathUtils.js";import{removeMaybe as l,destroyMaybe as u}from"../../../core/maybe.js";import{MemCachePool as ee}from"../../../core/MemCachePool.js";import d from"../../../core/ObjectPool.js";import f from"../../../core/PooledArray.js";import{throwIfAborted as te,isAbortError as p,isAborted as m}from"../../../core/promiseUtils.js";import{watch as h,syncAndInitial as g,initial as _,sync as v}from"../../../core/reactiveUtils.js";import"../../../core/scheduling.js";import{getMetersPerUnitForSR as ne}from"../../../core/units.js";import{property as y,subclass as re}from"../../../core/accessorSupport/decorators.js";import{exactEquals as ie,set as ae,copy as oe}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as se}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as ce,radiusModifier as le}from"../../../geometry/ellipsoidUtils.js";import x from"../../../geometry/SpatialReference.js";import{getProjector as S}from"../../../geometry/projection/projectors.js";import{projectPointToVector as C}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as ue}from"../../../geometry/projection/projectVectorToVector.js";import{create as w,equals as T,intersection as de,intersectsSphere as fe}from"../../../geometry/support/aaBoundingRect.js";import{copy as pe,create as me}from"../../../geometry/support/frustumPlanes.js";import{createSpatialReferenceCyclical as he}from"../../../geometry/support/normalizeUtils.js";import{isPlateCarree as ge}from"../../../geometry/support/spatialReferenceUtils.js";import{Sphere as _e}from"../../../geometry/support/sphere.js";import{ElevationQueryTileCache as ve}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as ye}from"../../../layers/support/layerUtils.js";import{queueHighPriority as be}from"../../../request/queue.js";import{debugFlags as E}from"../support/debugFlags.js";import{ElevationRange as D}from"../support/ElevationRange.js";import{ElevationUpdateEvent as xe}from"../support/ElevationUpdateEvent.js";import{calculateElevationUpdateExtents as Se}from"../support/elevationUpdateExtentUtils.js";import{toBoundingRect as Ce}from"../support/extentUtils.js";import{updatingProgress as we}from"../support/updatingProperties.js";import{ElevationBounds as O}from"./ElevationBounds.js";import{ElevationData as Te,sampleElevation as Ee}from"./ElevationData.js";import{create as De}from"./ExtentHelper.js";import{LayerClasses as Oe}from"./LayerClass.js";import{OverlayManager as ke}from"./OverlayManager.js";import{PlanarPatch as Ae}from"./PlanarPatch.js";import{Queue as je}from"./Queue.js";import{ScaleRangeQueries as Me}from"./ScaleRangeQueries.js";import{SphericalPatch as Ne}from"./SphericalPatch.js";import{SplitLimits as Pe}from"./SplitLimits.js";import{maxRootTiles as k,tooManyRootTilesAfterChangeError as Fe,tooManyRootTilesForLayerError as Ie,maxTileNeighborLevelDelta as A,maxMemoryLodBias as Le}from"./TerrainConst.js";import{TerrainRenderer as Re}from"./TerrainRenderer.js";import ze from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as j,isVectorTileLayerView as M,internalAssert as N,oppositeEdge as Be,neighborEdgeIndices as P,isSurfaceLayerView as F,isGroupLayerView as I,isMapTileLayerView as L,isBlendableLayerView as R,isElevationLayerView as z,releaseTerrainData as B,oppositeCorner as Ve,enableTerrainInternalChecks as V,enableWaterproofTests as He,enableInternalTerrainChecks as Ue,enableTerrainWaterproofChecks as We,neighborCornerIndices as Ge}from"./terrainUtils.js";import{Tile as Ke,lijEquals as H}from"./Tile.js";import{printAllocations as qe}from"./TilePerLayerInfo.js";import{sortTiles as Je,IteratorPreorder as Ye,IteratorPostorder as Xe,compareTilesByLij as U,hasLoadableSiblings as Ze,sortTilesByPOI as Qe,traverseTilesPreorder as W}from"./tileUtils.js";import{TilingSchemeLogic as $e}from"./TilingSchemeLogic.js";import{getGroundTransparencyModeFromOpacity as et}from"./TransparencyMode.js";import{UpsampleInfo as tt}from"./UpsampleInfo.js";import{isCompositeBlendMode as nt,blendModeFromString as rt}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{hasLayerBasedScaleVisibility as it}from"../../support/layerViewUtils.js";import{ImmediateTask as G,TaskPriority as at,noBudget as ot}from"../../support/Scheduler.js";import{TextureCompressionTracker as st}from"../../support/TextureCompressionTracker.js";import{Yield as ct}from"../../support/Yield.js";var K;let q=class extends o{static{K=this}get allTilesCreated(){return this._allTilesCreated}get allTiles(){return a(this._allTiles)}get renderedTiles(){return Je(n(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get demResolution(){let{_allTiles:e,tilingScheme:t}=this;if(e.length===0)return{min:1,max:1};let n=ne(t.spatialReference),r=1/0,i=-1/0;for(let a of e){let e=t.resolutionAtLevel(a.level)*n;r=Math.min(r,e),i=Math.max(i,e)}return{min:r,max:i}}constructor(e){super(e),this.terrainTextureCompressionTracker=new st,this._iteratorPool=new d(()=>new Ye,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new Xe,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._allTilesCreated=!1,this._usedMemory=null,this._performanceInfo=new ze,this._waterproofnessErrorHandle=null,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=b(),this._eyePosSurfaceSR=b(),this._splitLimits=new Pe,this._layerViews=[[],[]],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._updatingHandles=new se,this._poiWatchHandle=null,this._frameTask=G,this._allTiles=new f,this._upsampleInfoPool=new d(()=>new tt),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=w(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=x.WebMercator,this._elevationProjectorCache=new Map,this.visibleElevationRange=new D(1/0,-1/0),this._rootTileElevationRange=new D(1/0,-1/0),this._projectorCache=new Map,this._tilingSchemeSpatialReference=null,this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1,this.enabled=!0;let{view:t}=e;this.overlayManager=new ke({...e,terrainSurface:this}),this._isGlobal=!t.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?Ne:Ae,this._ellipsoid=ce(t.spatialReference),this._renderer=new Re(this.overlayManager.renderer,t.stage,this._allTiles,this.terrainTextureCompressionTracker,t.resourceController.memoryController),it()||(this._scaleRangeQueries=new Me)}initialize(){let{view:e}=this,{resourceController:t}=e,{memoryController:n}=t;this._tileCache=new ee((e,t)=>n.newCache(e,t),`terrain-tile`),this._upsampleMapCache=n.newCache(`terrain-upsample`,({tile:e})=>e.unloadMapData()),this._elevationQueryCache=new ve(n.newCache(`elevation-query`));let r=this.overlayManager;this.addHandles([h(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),h(()=>this.renderer.visible,e=>this.freeze=!e),h(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)},g)],`overlayManager`),this._updatingHandles.add(()=>({heading:e.camera?.heading,state:e.state?.mode}),({heading:e,state:t})=>{if(e==null)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree){this.heading=Math.round(e/90)*90%360;return}let n=Math.round(e)%360,r=Math.abs(n-this.heading);(t===2||Math.min(r,360-r)>=30)&&(this.heading=n)},_),this.addHandles([h(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},g),h(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),g),h(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},v),h(()=>this.snapLevel,()=>this._viewChanged=!0,v),h(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._poiWatchHandle=l(this._poiWatchHandle),e&&(this._poiWatchHandle=this._updatingHandles.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:ie}))}),h(()=>E.TERRAIN_TILE_TREE_SHOW_TILES,t=>{t&&!this._treeDebugger?import(`../layers/support/TerrainTileTree3DDebugger.js`).then(({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&E.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))}):t||(this._treeDebugger=u(this._treeDebugger))},_)]);let{spatialReference:a}=e;this._extentHelper=De(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});let o=new i({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&`layers`in e?e.layers:null}),s=new $e({layers:o,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set(`tilingSchemeLogic`,s),this._updateTilingScheme();let c=t.scheduler;this._frameTask=c.registerTask(at.TERRAIN_SURFACE,this),this.addHandles([h(()=>this._extentHelper.stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),_),h(()=>this.tilingSchemeLogic.tilingScheme,()=>this._updateTilingScheme(),v),h(()=>this.groundExtent,()=>this._updateRootTiles(),_),e.on(`resize`,()=>this._viewChangeUpdate()),h(()=>{let t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),g),h(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,_),h(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,_),h(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>this._updateAllTileGeometries()),h(()=>this.userClippingExtent,()=>this._updateClippingExtent(),v)]),this.addHandles(e.allLayerViews.on(`after-changes`,()=>this._layerViewsDirty=!0)),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}clearHandles(){this._updatingHandles?.removeAll(),this.removeAllHandles(),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear()}destroy(){this._waterproofnessErrorHandle?.remove(),this._waterproofnessErrorHandle=null,this._frameTask.remove(),this._frameTask=G,this._updatingHandles?.destroy(),this._removeAllTiles(),this._set(`tilingSchemeLogic`,u(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._set(`overlayManager`,u(this.overlayManager)),this._tileCache=u(this._tileCache),this._allTiles.prune(),Ke.prune(),this._treeDebugger=u(this._treeDebugger),this._renderer.destroyed||this._renderer.destroy(),this._renderer=null,this._iteratorPool=u(this._iteratorPool),this._upsampleMapCache=u(this._upsampleMapCache),this._elevationQueryCache=u(this._elevationQueryCache),this._set(`view`,null),this._extentHelper=u(this._extentHelper),this._upsampleInfoPool=u(this._upsampleInfoPool),qe(),this._layerViews.forEach(e=>e.length=0),this._performanceInfo=null}get renderer(){return this._renderer}get frustum(){return this.view.state.camera.frustum}get snapLevel(){return this.lodSnappingEnabled?this.view.terrainLevel:null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return this._extentHelper.stencilEnabledExtents.length>0}get userClippingExtent(){let{spatialReference:e}=this,t=this.view?.clippingArea;if(t==null||e==null)return null;let n=w(),r=Ce(t,n,e)?n:null,i=this._get(`userClippingExtent`);return T(r,i)?i:r}get rootTilesExtent(){return this._rootTilesExtent}get groundExtent(){let e=de(this.fullGroundExtent,this.userClippingExtent,w()),t=this._get(`groundExtent`);return T(e,t)?t:e}get fullGroundExtent(){return this._tilingSchemeExtent==null?this._rootTilesExtent:this._tilingSchemeExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),this.enabled&&!!((this.readyToRun||this._updatingHandles?.updating||this._asyncWorkItems>0)&&this.ready&&!this.freeze||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get readyToRun(){return this.enabled&&(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._hasElevationSourceUpdates||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.freeze}get _hasElevationSourceUpdates(){return this._allTiles.some(e=>e.needsElevationSourceUpdate())}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return!this.enabled||this._rootTiles!=null}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set(`slicePlaneEnabled`,e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===0}get invisible(){return this._renderer.transparency===3}set freeze(e){this._set(`freeze`,e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,n,r){this._renderer.intersectRay(e,t,n,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}get _xNormalizer(){return he(this._spatialReference)}getElevation(e,t,n,r){let i=this._rootTiles;if(!i?.length||!this.enabled||i[0].layerInfo[0].length===0)return null;let a=this._elevationProjectorCache.get(r);if(a===void 0&&(a=S(r,this._spatialReference)??null,this._elevationProjectorCache.set(r,a)),a==null)return s.getLogger(this).error(`TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system`),null;let o=ae(J,e,t,n);a(o,0,o,0);let c=this._xNormalizer?.normalize(o[0])??o[0],l=o[1];return ft(i,c,l)}getElevations(e,t,n){let r=this._rootTiles,i=r?r[0].layerInfo[0].length:0;if(!r?.length||i===0||!this.enabled)for(let e=0;e<t;++e)n(e,null);else for(let i=0;i<t;++i){let t=i*3,a=e[t],o=e[t+1],s=ft(r,a,o);n(i,s)}}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}getScale(e){if(!this.tilingScheme)return null;if(!C(e,J,this.spatialReference))return s.getLogger(this).error(`TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system`),null;let t=this._rootTiles;if(t!=null){for(let e of t)if(e?.containsPoint(J)){let t=e;for(;t.children[0]&&!t.rendered;){let e=t.children[0].extent,n=0;J[0]>e[2]&&(n+=1),J[1]<e[1]&&(n+=2),t=t.children[n]}return this._getLodBiasCorrectedScale(t.level)}}return 1/0}_ensureProjector(e){let t=this._projectorCache.get(e);if(t)return t;let n=S(e,this._tilingSchemeSpatialReference)??null;return this._projectorCache.set(e,n),n}getSphereElevationRange(e,t){if(!this.enabled||this._rootTiles==null)return null;let n=this._ensureProjector(t);if(n==null)return s.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project given point to tiling scheme coordinate system`),null;Y.copyFrom(e),n(Y.center,0,Y.center,0);let r=new D,i=this._rootTiles;if(i!=null){let e=[];for(let t of i)e.push(t);let t=0;for(;t<e.length;){let n=e[t];if(++t,!fe(n.extent,Y))continue;let i=n.children;if(i[0]==null||n.rendered)r.expandElevationRangeValues(n.elevationBoundsMin,n.elevationBoundsMax);else for(let t of i)e.push(t)}}return r}getRootElevationRange(){return this.enabled&&this._rootTiles!=null?new D(this._rootTileElevationRange.minElevation,this._rootTileElevationRange.maxElevation):null}getLowerBoundRadius(){let e=(this._ellipsoid.radius+this.visibleElevationRange.minElevation)*le;return Math.min(e,this._ellipsoid.radius)}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!C(e,Y.center,this.spatialReference))return s.getLogger(this).error(`TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system`),null;Y.radius=t;let n=null,r=e=>{if(e&&fe(e.extent,Y)){let t=e.children;if(t[0]&&!e.rendered)for(let e of t)r(e);else{let t=this._getLodBiasCorrectedScale(e.level);n=n==null?t:Math.min(n,t)}}},i=this._rootTiles;if(i!=null)for(let e of i)r(e);return n}queryVisibleScaleRange(e,t,n,r){if(!this._scaleRangeQueries)return;let i=t?this.tilingScheme.levelAtScale(t):0,a=n?this.tilingScheme.levelAtScale(n):1/0,o=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,i+o,a+o,r)}_evaluateTransparency(){let e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,n=this._renderer.transparency,r=this._isFullyTransparent?et(0,t):e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?0:1;return this._renderer.transparency=r,n!==r&&(this.notifyChange(`opaque`),this.notifyChange(`invisible`),!0)}_updateTilingScheme(){let{tilingScheme:e}=this.tilingSchemeLogic;if(e===this.tilingScheme)return;j(!!e,`tiling scheme cannot be reset to undefined`),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();let t=e?.spatialReference??x.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&ge(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,this._set(`tilingScheme`,e),this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference,this._projectorCache.clear(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey=`TerrainTileMemcache`}_acquireTile(e,t,n,r){let i=this._tileCache.pop(K._tileMemcacheKey);return i?(i.init(e,t,n,r,this),i):new this._tileConstructor(e,t,n,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){let{groundExtent:e,tilingScheme:t}=this;if(!t)return;if(!this.enabled){this._setRootTiles(null);return}let n=ut,i=t.rootTilesInExtent(e,n,k*5);if(this._rootTiles!=null){if(i.length>k){s.getLogger(this).warn(Fe);return}let e=this._rootTiles.map(e=>e.lij),t=r(e,i,H);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){let e=this._rootTiles.filter(e=>t.removed.findIndex(t=>H(t,e.lij))>-1?(this._purgeTile(e),!1):!0);t.added.forEach(t=>e.push(this._newRootTile(t))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,i.length>k&&(s.getLogger(this).warn(Ie),i=t.rootTilesInExtent(e,n,k)),this._setRootTiles(i.map(e=>this._newRootTile(e)));T(n,this._rootTilesExtent)||(this._rootTilesExtent=w(n)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange(`ready`),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness(`root-tiles-updated`)}_updateAllTileGeometries(){let e=this._allTiles.filter(e=>this._canUpdateTileGeometry(e));e.length===0||(e.sort(U),e.forEach(e=>this._renderer.updateTileGeometryState(e)),e.forEach(e=>e.renderData.updateNeighborData()),this._updateTilesGeometries(e)),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){let t=e.filter(e=>this._canUpdateTileGeometry(e));if(t.length===0)return;let n=this.renderer;for(let e of t)n.updateGeometryIfNeeded(e);for(let e of t)this._pendingTilesForElevationUpdateEvent.add(e)}_canUpdateTileGeometry(e){return e.loaded&&e.intersectsClippingArea&&e.hasGeometryState}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===1}_newRootTile(e){let t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(1),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationRange(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),e!=null){let t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.freeze&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.groundExtent)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(e==null)return;let t=Ze(e),n=this.visibleElevationRange,r=t?n.minElevation:1/0,i=t?n.maxElevation:-1/0,a=this.groundExtent,o=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty(!1);let s=this._iteratorPool.acquire();for(s.reset(e);!s.done;){let e=s.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(o),e.renderData&&(r=Math.min(e.elevationBoundsMin,r),i=Math.max(e.elevationBoundsMax,i))}s.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(i)&&(n.minElevation!==r||n.maxElevation!==i)&&(this.visibleElevationRange=new O(r,i))}_updateRootTileElevationRange(){let e=1/0,t=-1/0;this._rootTiles?.forEach(({elevationBoundsMin:n,elevationBoundsMax:r})=>{e=Math.min(e,n),t=Math.max(t,r)});let n=this._rootTileElevationRange;(n.minElevation!==e||n.maxElevation!==t)&&(this._rootTileElevationRange=new O(e,t))}_updateViewDependentParameters(){let{camera:e,contentCamera:t}=this.view.state,n=Math.tan(t.fovX*.5),r=Math.tan(t.fovY*.5),i=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=n,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=i/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=i/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=pe(this._splitLimits.frustum??me(),t.frustum):this._splitLimits.frustum=null,oe(this._eyePosRenderSR,t.eye),ue(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility();let t=this._renderer.updateTileGeometryState(e);e.needsElevationSourceUpdate()&&(e.updateAgents(0),e.markElevationSourceUpdateRequested(),this.requestUpdate()),t&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){e.forEachLoadedNeighbor(e=>{this._layerViews[1].some(M)&&e.setPendingUpdate(32),this._pendingTilesToUpdate.add(e)})}_updateTileTexture(e,t){let n=e.resetPendingUpdate(32)?32:e.resetPendingUpdate(16)?16:!1;n&&(this._renderer.updateTileTexture(e,n),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;let e=this._pendingTilesForElevationUpdateEvent;if(e.size>0){let t=new Float64Array(4*e.size),n=0;for(let r of e)t.set(r.extent,4*n),++n;e.clear();for(let e of Se(t,this.spatialReference)){let t=new xe(this.spatialReference,e,`ground`);this.emit(`elevation-change`,t)}}this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);let t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),this._updateElevation(e),this._updateElevationSources(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty();let n=this._pendingTilesToUpdate.size>0,r=n&&this._hasPendingGeometryWithoutIndices();if((!e.done||r)&&this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&(e.hasProgressed||n&&!r)&&this.requestUpdate(),this.notifyChange(`updatingProgressValue`),!e.hasProgressed)return ct}_checkTileInvariant(){}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;let t=!1,n=new je(this._allTiles.length);n.pushAll(this._rootTiles);let r=this.snapLevel,i=this._splitLimits,a=this._eyePosRenderSR;this._allTiles.forAll(e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0});let o=this.view.state.contentCamera.viewProjectionMatrix;for(;!n.empty;){let e=n.pop(),s=e.parent?.hasPendingUpdate(4),c=s?4:e.shouldSplit(i,a,r),l=c===1;e.leaf?Z(e,l):n.pushAll(e.children),s?(e.resetPendingUpdate(1),e.leaf||(e.setPendingUpdate(4),t=!0),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(o)):l?(e.resetPendingUpdate(4),e.leaf&&(e.setPendingUpdate(1),t=!0)):(e.resetPendingUpdate(1)&&e.updateAgentSuspension(),c===2&&e.updateAgents(0),e.leaf||(e.setPendingUpdate(4),e.resetPendingUpdate(1),t=!0))}this._allTilesDirty=t,this.requestUpdate(),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){!e.done&&!this._allTilesSorted&&this.view.pointsOfInterest?.focus&&(Qe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger?.update(),e.madeProgress())}_markTileToUpdate(e){N(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_hasPendingGeometryWithoutIndices(){for(let e of this._pendingTilesToUpdate)if(e.loaded&&e.intersectsClippingArea&&e.renderData?.vao?.indexBuffer==null)return!0;return!1}_updatePendingTileGeometries(){let e=this._pendingTilesToUpdate,t=[];if(e.forEach(e=>{this._canUpdateTileGeometry(e)&&t.push(e)}),t.length===0){e.clear();return}let n=(n,r)=>{!r||!this._canUpdateTileGeometry(r)||r.level<n.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(U);let r=t.length;for(let i=0;i<r;++i){let r=t[i];N(r.loaded),N(r.intersectsClippingArea);let a=r.renderData;if(!a?.geometryState)continue;a.updateNeighborData();let o=a.dirtyEdgeResolutions,s=a.geometryState,c=e=>{let t=Ge[e];n(r,s.cornerPeerNeighbors[e]?.findCorner(Ve(t),e=>e.loaded))};for(let t=0;t<4;++t)if(o&1<<t){let i=a.geometryState.edgePeerNeighbors[t];i&&i?.level>=r.level&&i.forAllSubtreeOnSide(Be(P[t]),t=>this._canUpdateTileGeometry(t)?(N(e.has(t)||U(r,t)<0),n(r,t),!0):!1),c((t+1)%4),c(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,V&&He&&this.checkAllTilesWaterproofness(`pending-geometries-updated`)}_mergeAndSplit(e,t){if(this.freeze||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let n=!1,r=this.view.state.fixedContentCamera,i=!1;for(;!e.done;){i=!0;let a=!1,o=!this._allTiles.some(i=>{if(!n&&!r&&!i.visible)return e.done;let o=i;if(i.hasPendingUpdate(4)){if(!t||i.unmergableChildCount>0)return e.done;for(i.resetPendingUpdate(4);o.parent!=null&&o.parent.unmergableChildCount===0&&o.parent.resetPendingUpdate(4);)o=o.parent;this._mergeTile(o),a=!0,e.madeProgress()}else if(i.resetPendingUpdate(1)){let t=!0,n=i.level;if(n>=A){let e=e=>e.leaf||n-e.level<A;for(let r=0;r<4;++r){let a=i.findNeighborTile(P[r],e);a!=null&&n-a.level===A&&(t=!1,V&&(N(a.leaf),N(a.hasPendingUpdate(1))))}}t?(this._splitTile(i),e.madeProgress(),a=!0):i.setPendingUpdate(1)}return e.done});if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0),o){if(!n){n=!0;continue}if(!a)break}else this._allTilesDirty=!0}i?e.madeProgress():this._allTilesDirty=!0,this._allTilesCreated=!this.allTiles.some(e=>e.hasPendingUpdate(1)||e.hasPendingUpdate(4)&&e.unmergableChildCount===0),this._sortTiles(e)}_updateElevation(e){e.done||this._allTiles.some(t=>(t.resetPendingUpdate(8)&&(this._updateTileGeometryState(t),e.madeProgress()),e.done))}_updateElevationSources(e){e.done||this._allTiles.some(t=>(t.needsElevationSourceUpdate()&&(t.updateAgents(0),t.markElevationSourceUpdateRequested(),e.madeProgress()),e.done))}_updateTextures(e){e.done||this._allTiles.some(t=>(this._updateTileTexture(t,e),e.done))}_updateClippingExtent(){this.spatialReference&&(this.updateOverlayParameters(),this.requestRender(1),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){return this.view.qualitySettings.tiledSurface.lodBias-(1-this.view.quality)*Le}_getLodBiasCorrectedScale(e){let t=this.tilingScheme.levels,n=c(e-this._lodBias,0,t.length-1),r=n-Math.floor(n),i=t[Math.floor(n)].scale,a=t[Math.ceil(n)].scale;return i*(1-r)+a*r}_removeAllTiles(){this._pendingTilesToUpdate.clear(),this._pendingTilesForElevationUpdateEvent.clear(),this._rootTiles!=null&&(this._rootTiles.forEach(e=>this._purgeTile(e)),this._setRootTiles(null),this.notifyChange(`ready`)),this._allTiles.clear(),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles}),this.renderer.visible=!1}_purgeSubtree(e){let t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?mt(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(K._tileMemcacheKey,e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){j(e.leaf,`Tile that is already split should not be split again!`),j(e.rendered,`Tile marked to split is not rendered`),mt(e);let t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles}),e.updateAgentSuspension(),j(e.rendered,`parent should be rendered`),t.forEach(e=>this._loadTile(e)),t.forEach(e=>this._pendingTilesToUpdate.add(e)),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach(e=>Z(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){X.spatialReference=this.spatialReference,X.extent=e.extent,X.scale=this._getLodBiasCorrectedScale(t),this.emit(`scale-change`,X)}createTile(e,t,n,r){j(!!r,`createTile sanity check`);let i=this._acquireTile(e,t,n,r);return i.updateClippingStatus(this.groundExtent),i.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(i)&&i.setPendingUpdate(1),i}get _shortBatches(){return this.view.state.mode!==2}_mergeTile(e){j(!e.hasPendingUpdate(1),`_mergeTile sanity check`),j(!e.leaf,`Cannot merge a leaf`),!e.leaf&&(this._purgeSubtree(e),j(!e.renderData,`Merging tile with existing render data?`),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),Z(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&e.updateOverlayParameters(this.overlayManager)}_handleLayerViewChanges(e=ot){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1,n=new Set,r=-1;for(let e=this.view.allLayerViews.length-1;e>=0;e--){let i=this.view.allLayerViews.items[e];if(n.add(i.uid),F(i)||I(i)){if(this._basemapLayerViewHandles.has(i.uid)&&!I(i)){let e=this._layerClassFromLayerView(i),n=this.getLayerIndexByUID(e,i.uid);n!=null&&((n<r||r==null)&&(t=!0),r=n)}else this._registerTiledLayerView(i),i.layer.loaded&&(t=!0)}}this._basemapLayerViewHandles.forEach((e,r)=>{n.has(r)||(this._unregisterTiledLayerView(r),t=!0)}),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(let e of this.view.allLayerViews.items)if(L(e)&&!ye(e.layer)&&e.fullOpacity!==0)return!1;return!0}_hasCompositeBlendMode(){for(let e of this.view.allLayerViews.items)if((R(e)||I(e))&&nt(rt[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return+!z(e)}_registerTiledLayerView(e){let t=[];if((R(e)||I(e))&&t.push(h(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!I(e)){let n=this._layerClassFromLayerView(e);t.push(h(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(h(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));let{layer:r}=e;`effectiveScaleRange`in r&&t.push(h(()=>!e.destroyed&&r.effectiveScaleRange,()=>this._restartAllAgents(n))),t.push(e.on(`data-changed`,()=>{let t=this.getLayerIndexByUID(n,e.uid);t!=null&&this._invalidateLayerData(t,n)}))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){let t=this._basemapLayerViewHandles.get(e);if(t){for(let e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;let e=this.view.allLayerViews,t=[[],[]],n=null;e.forEach(e=>{if(!e.layer||e.suspended||!F(e)||!e.fullExtent)return;let r=this._layerClassFromLayerView(e);if(r===1){let t=e.displayLevelRange.maxLevel;t!==1/0&&(n===null||t>n)&&(n=t)}t[r].push(e)});for(let e of Oe){let n=this._layerViews[e],r=t[e];r.reverse();let i=r.length,a=n.length!==i,o=Array(i),s=Array(n.length);this._layerIndexByUid[e].clear();for(let t=0;t<i;t++){let i=r[t].uid;this._layerIndexByUid[e].set(i,t);let c=n.indexOf(r[t]);o[t]=c,t!==c&&(a=!0),c>-1&&(s[c]=t)}if(a){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;)t.next().modifyLayers(s,o,e);this._layerViews[e]=r,this._restartAllAgents(e),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(n)&&(this._viewChangeUpdate(),this.notifyChange(`tilingScheme`))}_restartAllAgents(e){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){let n=t.next();n.restartAgents(e),e===0&&n.computeElevationBounds()}this._updateRootTileElevationRange()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll(t=>{t.updateAgents(1),e===1?this.renderer.updateTileTexture(t,16):t.updateRenderData(1,e)}),this._evaluateTransparency()}_invalidateLayerData(e,t){this._rootTiles!=null&&(W(this._rootTiles,n=>n.removeLayerAgent(e,t)),W(this._rootTiles,n=>{n.invalidateLayerData(e,t),n.restartAgents(t)}))}setTileTreeDirty(e){this._allTilesDirty=!0,e&&(this._allTilesCreated=!1)}requestRender(e=1){this.renderer.setNeedsRender(e)}requestUpdate(){++this._pendingUpdates===1&&(this._hasPendingUpdates=!0)}requestTileData(e,t,n,r){let i=this.layerViewByIndex(t,n),{tilemapCache:a}=i;return!a||M(i)?this._requestTileData(e,n,i,r):(++this._asyncWorkItems,a.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).catch(t=>{throw te(r),p(t)||this._dataMissing(e,n,i),t}).then(()=>this._frameTask.schedule(()=>this._requestTileData(e,n,i,r),r.signal)).finally(()=>--this._asyncWorkItems))}_requestTileData(e,t,n,r){return this.destroying?Promise.resolve():t===0?z(n)?this._requestElevationTileData(e,n,r):Promise.reject():L(n)?this._requestMapTileData(e,n,r):Promise.reject()}_requestElevationTileData(e,t,n){++this._asyncWorkItems;let r=r=>{!m(n)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},i=n=>{p(n)||(s.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${n}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,{...be,...n}).then(e=>this._frameTask.schedule(()=>r(e)),i).finally(()=>--this._asyncWorkItems)}_elevationDataArrived(e,t,n){let r=this._layerIndexByUid[0].get(t.uid);if(r==null){s.getLogger(this).warn(`TerrainSurface: received data from unknown layer %d %s`,0,e.lij.toString());return}let i=new Te(e.lij,e.extent,n);e.dataArrived(r,0,i),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:0});let a=[e],o=e.level,c=this._iteratorPool.acquire();for(c.reset(a);!c.done;){let e=c.next();e.findElevationBoundsForLayer(r,o),e.computeElevationBounds()}o===0&&this._updateRootTileElevationRange(),c.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,n){++this._asyncWorkItems;let r=(r,i)=>{B(i),m(n)||(console.error(`Tile ${e.lij.toString()} layer 1/${t.uid} error ${r}`),this._dataMissing(e,1,t),this.requestUpdate())},i=e=>t=>r(t,e);return t.fetchTile(e.lij,n).then(r=>this._frameTask.schedule(()=>{this.requestUpdate(),m(n)?B(r):this._mapTileDataArrived(e,t,r)},n.signal,i(r)).catch(i(r)),(e,t=null)=>this._frameTask.schedule(()=>r(e,t))).finally(()=>--this._asyncWorkItems)}_mapTileDataArrived(e,t,n){let r=this.getLayerIndexByUID(1,t.uid);r==null?(B(n),s.getLogger(this).warn(`TerrainSurface: received data from unknown layer`)):(e.dataArrived(r,1,n),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:1}))}_dataMissing(e,t,n){let r=this.getLayerIndexByUID(t,n.uid);r==null?s.getLogger(this).warn(`TerrainSurface: received data from unknown layer`):(e.dataMissing(r,t),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:t}))}get performanceInfo(){let e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll(t=>{t.leaf&&e.numLeaves++;let n=t.level;t.renderData&&(e.numLoadedPerLevel[n]=(e.numLoadedPerLevel[n]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[n]=(e.numRenderedPerLevel[n]||0)+1,e.numRendered++))}),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(this._usedMemory??=this._recalculateUsedMemory(),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce((e,t)=>e+t.usedMemory,0)):null}getUsedMemoryForLayerView(e){let t=0,n=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(n,e.uid);return r!=null&&this._allTiles.forAll(e=>t+=e.getUsedMemoryForLayer(n,r)),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(e=`render-patch-groups`){}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&e[2]===0}lijEastEnd(e){return 1<<e+ +!!this._isGeographic}wrapEastWest(e){let t=this.lijEastEnd(e[0]),n=e[2];if(0<=n&&n<t)return e;if(!this._isGlobal)return null;let r=(n+(n<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){Ue(e)}enableWaterproofnessChecks(e){We(e)}static cleanupTerrainSurface(){dt.prune()}enable(e){e!==this.enabled&&(this._set(`enabled`,e),e?(this._updateRootTiles(),this.freeze=!1,this.view.elevationProvider.register(0,this)):(this.view.elevationProvider.unregister(this),this.freeze=!0,this._removeAllTiles(),this._setRootTiles(null)),this.notifyChange(`ready`))}updateOverlayParameters(){let{overlayManager:e}=this;this.allTiles.forAll(t=>t.updateOverlayParameters(e))}};e([y()],q.prototype,`_renderer`,void 0),e([y({constructOnly:!0})],q.prototype,`_scaleRangeQueries`,void 0),e([y({constructOnly:!0})],q.prototype,`view`,void 0),e([y({constructOnly:!0})],q.prototype,`overlayManager`,void 0),e([y({constructOnly:!0})],q.prototype,`terrainTextureCompressionTracker`,void 0),e([y()],q.prototype,`_hasPendingUpdates`,void 0),e([y()],q.prototype,`_asyncWorkItems`,void 0),e([y()],q.prototype,`_allTilesDirty`,void 0),e([y()],q.prototype,`_allTilesSorted`,void 0),e([y()],q.prototype,`allTilesCreated`,null),e([y()],q.prototype,`_allTilesCreated`,void 0),e([y()],q.prototype,`_viewChanged`,void 0),e([y({type:Number})],q.prototype,`heading`,void 0),e([y()],q.prototype,`_splitLimits`,void 0),e([y()],q.prototype,`_frameTask`,void 0),e([y()],q.prototype,`demResolution`,null),e([y({readOnly:!0})],q.prototype,`snapLevel`,null),e([y({readOnly:!0})],q.prototype,`lodSnappingEnabled`,null),e([y({readOnly:!0})],q.prototype,`userClippingExtent`,null),e([y()],q.prototype,`_rootTilesExtent`,void 0),e([y({readOnly:!0})],q.prototype,`groundExtent`,null),e([y({readOnly:!0})],q.prototype,`fullGroundExtent`,null),e([y({readOnly:!0})],q.prototype,`_tilingSchemeExtent`,null),e([y({readOnly:!0})],q.prototype,`updating`,null),e([y({readOnly:!0})],q.prototype,`readyToRun`,null),e([y(we)],q.prototype,`updatingProgress`,void 0),e([y({readOnly:!0})],q.prototype,`updatingProgressValue`,null),e([y()],q.prototype,`_maxNumUpdating`,void 0),e([y()],q.prototype,`baseOpacity`,null),e([y()],q.prototype,`hasCompositeBlendMode`,void 0),e([y({readOnly:!0})],q.prototype,`viewingMode`,null),e([y()],q.prototype,`maxTextureScale`,void 0),e([y({readOnly:!0})],q.prototype,`ready`,null),e([y({readOnly:!0})],q.prototype,`rootTiles`,null),e([y()],q.prototype,`_rootTiles`,void 0),e([y({readOnly:!0})],q.prototype,`spatialReference`,null),e([y({type:t})],q.prototype,`backgroundColor`,null),e([y({value:!1})],q.prototype,`slicePlaneEnabled`,null),e([y({readOnly:!0})],q.prototype,`tilingScheme`,void 0),e([y({readOnly:!0})],q.prototype,`tilingSchemeLocked`,null),e([y({readOnly:!0})],q.prototype,`tilingSchemeLogic`,void 0),e([y()],q.prototype,`wireframe`,null),e([y()],q.prototype,`opaque`,null),e([y()],q.prototype,`invisible`,null),e([y({value:!1})],q.prototype,`freeze`,null),e([y()],q.prototype,`fadeDuration`,null),e([y()],q.prototype,`_xNormalizer`,null),e([y()],q.prototype,`visibleElevationRange`,void 0),e([y()],q.prototype,`_rootTileElevationRange`,void 0),e([y()],q.prototype,`_layerViewsDirty`,void 0),e([y()],q.prototype,`renderPatchBorders`,null),e([y()],q.prototype,`renderingDisabled`,null),e([y({readOnly:!0})],q.prototype,`enabled`,void 0),q=K=e([re(`esri.views.3d.terrain.TerrainSurface`)],q);const lt=q,J=b(),Y=new _e,ut=w(),dt=new f,X={spatialReference:null,extent:null,scale:0};function ft(e,t,n){for(let r of e){if(!r.containsPointXY(t,n))continue;let e=r;for(;e&&!e.renderData;){let r=+(t>e.extentMidX)+(n<e.extentMidY?2:0);e=e.children[r]}let i=e?.renderData?.geometryState.samplerData??null;return Ee(t,n,i)}return null}function Z(e,t){!e.leaf||e.level<A||$(e,e=>{t&&pt(e);let n=Q(e);if(e.maxLevelDeltaNeighborCount++,n){let t=e.parent;for(;t;){let e=Q(t);if(t.unmergableChildCount++,e)t=t.parent;else break}}})}function pt(e){if(e.hasPendingUpdate(1))return;let t=e.parent;for(;t?.resetPendingUpdate(4);)t=t.parent;e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1),!(e.level<A)&&$(e,e=>{pt(e)})}function mt(e){e.level<A||$(e,e=>{if(e.maxLevelDeltaNeighborCount--,e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0){let t=e.parent;for(;t&&(t.unmergableChildCount--,Q(t));)t=t.parent}})}function Q(e){return e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0}function $(e,t){if(e.level<A)return;let n=e.level-A,r=e.lij[1]>>A,i=e.lij[2]>>A,a=e=>e.leaf||e.level===n;for(let o=0;o<4;++o){let s=e.findNeighborTile(P[o],a);if(!s||s.level!==n)continue;let c=s.lij;(c[1]!==r||c[2]!==i)&&t(s)}}export{lt as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../Color.js";import{filterInPlace as n,difference as r}from"../../../core/arrayUtils.js";import i from"../../../core/CollectionFlattener.js";import{toConst as a}from"../../../core/compilerUtils.js";import{EventedAccessor as o}from"../../../core/Evented.js";import"../../../core/has.js";import s from"../../../core/Logger.js";import{clamp as c}from"../../../core/mathUtils.js";import{removeMaybe as l,destroyMaybe as u}from"../../../core/maybe.js";import{MemCachePool as ee}from"../../../core/MemCachePool.js";import d from"../../../core/ObjectPool.js";import f from"../../../core/PooledArray.js";import{throwIfAborted as te,isAbortError as p,isAborted as m}from"../../../core/promiseUtils.js";import{watch as h,syncAndInitial as g,initial as _,sync as v}from"../../../core/reactiveUtils.js";import"../../../core/scheduling.js";import{getMetersPerUnitForSR as ne}from"../../../core/units.js";import{property as y,subclass as re}from"../../../core/accessorSupport/decorators.js";import{exactEquals as ie,set as ae,copy as oe}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as se}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as ce,radiusModifier as le}from"../../../geometry/ellipsoidUtils.js";import x from"../../../geometry/SpatialReference.js";import{getProjector as S}from"../../../geometry/projection/projectors.js";import{projectPointToVector as C}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as ue}from"../../../geometry/projection/projectVectorToVector.js";import{create as w,equals as T,intersection as de,intersectsSphere as fe}from"../../../geometry/support/aaBoundingRect.js";import{copy as pe,create as me}from"../../../geometry/support/frustumPlanes.js";import{createSpatialReferenceCyclical as he}from"../../../geometry/support/normalizeUtils.js";import{isPlateCarree as ge}from"../../../geometry/support/spatialReferenceUtils.js";import{Sphere as _e}from"../../../geometry/support/sphere.js";import{ElevationQueryTileCache as ve}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as ye}from"../../../layers/support/layerUtils.js";import{queueHighPriority as be}from"../../../request/queue.js";import{debugFlags as E}from"../support/debugFlags.js";import{ElevationRange as D}from"../support/ElevationRange.js";import{ElevationUpdateEvent as xe}from"../support/ElevationUpdateEvent.js";import{calculateElevationUpdateExtents as Se}from"../support/elevationUpdateExtentUtils.js";import{toBoundingRect as Ce}from"../support/extentUtils.js";import{updatingProgress as we}from"../support/updatingProperties.js";import{ElevationBounds as O}from"./ElevationBounds.js";import{ElevationData as Te,sampleElevation as Ee}from"./ElevationData.js";import{create as De}from"./ExtentHelper.js";import{LayerClasses as Oe}from"./LayerClass.js";import{OverlayManager as ke}from"./OverlayManager.js";import{PlanarPatch as Ae}from"./PlanarPatch.js";import{Queue as je}from"./Queue.js";import{ScaleRangeQueries as Me}from"./ScaleRangeQueries.js";import{SphericalPatch as Ne}from"./SphericalPatch.js";import{SplitLimits as Pe}from"./SplitLimits.js";import{maxRootTiles as k,tooManyRootTilesAfterChangeError as Fe,tooManyRootTilesForLayerError as Ie,maxTileNeighborLevelDelta as A,maxMemoryLodBias as Le}from"./TerrainConst.js";import{TerrainRenderer as Re}from"./TerrainRenderer.js";import ze from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as j,isVectorTileLayerView as M,internalAssert as N,oppositeEdge as Be,neighborEdgeIndices as P,isSurfaceLayerView as F,isGroupLayerView as I,isMapTileLayerView as L,isBlendableLayerView as R,isElevationLayerView as z,releaseTerrainData as B,oppositeCorner as Ve,enableTerrainInternalChecks as V,enableWaterproofTests as He,enableInternalTerrainChecks as Ue,enableTerrainWaterproofChecks as We,neighborCornerIndices as Ge}from"./terrainUtils.js";import{Tile as Ke,lijEquals as H}from"./Tile.js";import{printAllocations as qe}from"./TilePerLayerInfo.js";import{sortTiles as Je,IteratorPreorder as Ye,IteratorPostorder as Xe,compareTilesByLij as U,hasLoadableSiblings as Ze,sortTilesByPOI as Qe,traverseTilesPreorder as W}from"./tileUtils.js";import{TilingSchemeLogic as $e}from"./TilingSchemeLogic.js";import{getGroundTransparencyModeFromOpacity as et}from"./TransparencyMode.js";import{UpsampleInfo as tt}from"./UpsampleInfo.js";import{isCompositeBlendMode as nt,blendModeFromString as rt}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{hasLayerBasedScaleVisibility as it}from"../../support/layerViewUtils.js";import{ImmediateTask as G,TaskPriority as at,noBudget as ot}from"../../support/Scheduler.js";import{TextureCompressionTracker as st}from"../../support/TextureCompressionTracker.js";import{Yield as ct}from"../../support/Yield.js";var K;let q=class extends o{static{K=this}get allTilesCreated(){return this._allTilesCreated}get allTiles(){return a(this._allTiles)}get renderedTiles(){return Je(n(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get demResolution(){let{_allTiles:e,tilingScheme:t}=this;if(e.length===0)return{min:1,max:1};let n=ne(t.spatialReference),r=1/0,i=-1/0;for(let a of e){let e=t.resolutionAtLevel(a.level)*n;r=Math.min(r,e),i=Math.max(i,e)}return{min:r,max:i}}constructor(e){super(e),this.terrainTextureCompressionTracker=new st,this._iteratorPool=new d(()=>new Ye,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new Xe,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._allTilesCreated=!1,this._usedMemory=null,this._performanceInfo=new ze,this._waterproofnessErrorHandle=null,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=b(),this._eyePosSurfaceSR=b(),this._splitLimits=new Pe,this._layerViews=[[],[]],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._updatingHandles=new se,this._poiWatchHandle=null,this._frameTask=G,this._allTiles=new f,this._upsampleInfoPool=new d(()=>new tt),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=w(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=x.WebMercator,this._elevationProjectorCache=new Map,this.visibleElevationRange=new D(1/0,-1/0),this._rootTileElevationRange=new D(1/0,-1/0),this._projectorCache=new Map,this._tilingSchemeSpatialReference=null,this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1,this.enabled=!0;let{view:t}=e;this.overlayManager=new ke({...e,terrainSurface:this}),this._isGlobal=!t.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?Ne:Ae,this._ellipsoid=ce(t.spatialReference),this._renderer=new Re(this.overlayManager.renderer,t.stage,this._allTiles,this.terrainTextureCompressionTracker,t.resourceController.memoryController),it()||(this._scaleRangeQueries=new Me)}initialize(){let{view:e}=this,{resourceController:t}=e,{memoryController:n}=t;this._tileCache=new ee((e,t)=>n.newCache(e,t),`terrain-tile`),this._upsampleMapCache=n.newCache(`terrain-upsample`,({tile:e})=>e.unloadMapData()),this._elevationQueryCache=new ve(n.newCache(`elevation-query`));let r=this.overlayManager;this.addHandles([h(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),h(()=>this.renderer.visible,e=>this.freeze=!e),h(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)},g)],`overlayManager`),this._updatingHandles.add(()=>({heading:e.camera?.heading,state:e.state?.mode}),({heading:e,state:t})=>{if(e==null)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree){this.heading=Math.round(e/90)*90%360;return}let n=Math.round(e)%360,r=Math.abs(n-this.heading);(t===2||Math.min(r,360-r)>=30)&&(this.heading=n)},_),this.addHandles([h(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},g),h(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),g),h(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},v),h(()=>this.snapLevel,()=>this._viewChanged=!0,v),h(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._poiWatchHandle=l(this._poiWatchHandle),e&&(this._poiWatchHandle=this._updatingHandles.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:ie}))}),h(()=>E.TERRAIN_TILE_TREE_SHOW_TILES,t=>{t&&!this._treeDebugger?import(`../layers/support/TerrainTileTree3DDebugger.js`).then(({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&E.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))}):t||(this._treeDebugger=u(this._treeDebugger))},_)]);let{spatialReference:a}=e;this._extentHelper=De(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});let o=new i({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&`layers`in e?e.layers:null}),s=new $e({layers:o,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set(`tilingSchemeLogic`,s),this._updateTilingScheme();let c=t.scheduler;this._frameTask=c.registerTask(at.TERRAIN_SURFACE,this),this.addHandles([h(()=>this._extentHelper.stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),_),h(()=>this.tilingSchemeLogic.tilingScheme,()=>this._updateTilingScheme(),v),h(()=>this.groundExtent,()=>this._updateRootTiles(),_),e.on(`resize`,()=>this._viewChangeUpdate()),h(()=>{let t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),g),h(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,_),h(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,_),h(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>this._updateAllTileGeometries()),h(()=>this.userClippingExtent,()=>this._updateClippingExtent(),v)]),this.addHandles(e.allLayerViews.on(`after-changes`,()=>this._layerViewsDirty=!0)),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}clearHandles(){this._updatingHandles?.removeAll(),this.removeAllHandles(),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear()}destroy(){this._waterproofnessErrorHandle?.remove(),this._waterproofnessErrorHandle=null,this._frameTask.remove(),this._frameTask=G,this._updatingHandles?.destroy(),this._removeAllTiles(),this._set(`tilingSchemeLogic`,u(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._set(`overlayManager`,u(this.overlayManager)),this._tileCache=u(this._tileCache),this._allTiles.prune(),Ke.prune(),this._treeDebugger=u(this._treeDebugger),this._renderer.destroyed||this._renderer.destroy(),this._renderer=null,this._iteratorPool=u(this._iteratorPool),this._upsampleMapCache=u(this._upsampleMapCache),this._elevationQueryCache=u(this._elevationQueryCache),this._set(`view`,null),this._extentHelper=u(this._extentHelper),this._upsampleInfoPool=u(this._upsampleInfoPool),qe(),this._layerViews.forEach(e=>e.length=0),this._performanceInfo=null}get renderer(){return this._renderer}get frustum(){return this.view.state.camera.frustum}get snapLevel(){return this.lodSnappingEnabled?this.view.terrainLevel:null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return this._extentHelper.stencilEnabledExtents.length>0}get userClippingExtent(){let{spatialReference:e}=this,t=this.view?.clippingArea;if(t==null||e==null)return null;let n=w(),r=Ce(t,n,e)?n:null,i=this._get(`userClippingExtent`);return T(r,i)?i:r}get rootTilesExtent(){return this._rootTilesExtent}get groundExtent(){let e=de(this.fullGroundExtent,this.userClippingExtent,w()),t=this._get(`groundExtent`);return T(e,t)?t:e}get fullGroundExtent(){return this._tilingSchemeExtent==null?this._rootTilesExtent:this._tilingSchemeExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),this.enabled&&!!((this.readyToRun||this._updatingHandles?.updating||this._asyncWorkItems>0)&&this.ready&&!this.freeze||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get readyToRun(){return this.enabled&&(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._hasElevationSourceUpdates||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.freeze}get _hasElevationSourceUpdates(){return this._allTiles.some(e=>e.needsElevationSourceUpdate())}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return!this.enabled||this._rootTiles!=null}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set(`slicePlaneEnabled`,e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===0}get invisible(){return this._renderer.transparency===3}set freeze(e){this._set(`freeze`,e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,n,r){this._renderer.intersectRay(e,t,n,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}get _xNormalizer(){return he(this._spatialReference)}getElevation(e,t,n,r){let i=this._rootTiles;if(!i?.length||!this.enabled||i[0].layerInfo[0].length===0)return null;let a=this._elevationProjectorCache.get(r);if(a===void 0&&(a=S(r,this._spatialReference)??null,this._elevationProjectorCache.set(r,a)),a==null)return s.getLogger(this).error(`TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system`),null;let o=ae(J,e,t,n);a(o,0,o,0);let c=this._xNormalizer?.normalize(o[0])??o[0],l=o[1];return ft(i,c,l)}getElevations(e,t,n){let r=this._rootTiles,i=r?r[0].layerInfo[0].length:0;if(!r?.length||i===0||!this.enabled)for(let e=0;e<t;++e)n(e,null);else for(let i=0;i<t;++i){let t=i*3,a=e[t],o=e[t+1],s=ft(r,a,o);n(i,s)}}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}getScale(e){if(!this.tilingScheme)return null;if(!C(e,J,this.spatialReference))return s.getLogger(this).error(`TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system`),null;let t=this._rootTiles;if(t!=null){for(let e of t)if(e?.containsPoint(J)){let t=e;for(;t.children[0]&&!t.rendered;){let e=t.children[0].extent,n=0;J[0]>e[2]&&(n+=1),J[1]<e[1]&&(n+=2),t=t.children[n]}return this._getLodBiasCorrectedScale(t.level)}}return 1/0}_ensureProjector(e){let t=this._projectorCache.get(e);if(t)return t;let n=S(e,this._tilingSchemeSpatialReference)??null;return this._projectorCache.set(e,n),n}getSphereElevationRange(e,t){if(!this.enabled||this._rootTiles==null)return null;let n=this._ensureProjector(t);if(n==null)return s.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project given point to tiling scheme coordinate system`),null;Y.copyFrom(e),n(Y.center,0,Y.center,0);let r=new D,i=this._rootTiles;if(i!=null){let e=[];for(let t of i)e.push(t);let t=0;for(;t<e.length;){let n=e[t];if(++t,!fe(n.extent,Y))continue;let i=n.children;if(i[0]==null||n.rendered)r.expandElevationRangeValues(n.elevationBoundsMin,n.elevationBoundsMax);else for(let t of i)e.push(t)}}return r}getRootElevationRange(){return this.enabled&&this._rootTiles!=null?new D(this._rootTileElevationRange.minElevation,this._rootTileElevationRange.maxElevation):null}getLowerBoundRadius(){let e=(this._ellipsoid.radius+this.visibleElevationRange.minElevation)*le;return Math.min(e,this._ellipsoid.radius)}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!C(e,Y.center,this.spatialReference))return s.getLogger(this).error(`TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system`),null;Y.radius=t;let n=null,r=e=>{if(e&&fe(e.extent,Y)){let t=e.children;if(t[0]&&!e.rendered)for(let e of t)r(e);else{let t=this._getLodBiasCorrectedScale(e.level);n=n==null?t:Math.min(n,t)}}},i=this._rootTiles;if(i!=null)for(let e of i)r(e);return n}queryVisibleScaleRange(e,t,n,r){if(!this._scaleRangeQueries)return;let i=t?this.tilingScheme.levelAtScale(t):0,a=n?this.tilingScheme.levelAtScale(n):1/0,o=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,i+o,a+o,r)}_evaluateTransparency(){let e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,n=this._renderer.transparency,r=this._isFullyTransparent?et(0,t):e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?0:1;return this._renderer.transparency=r,n!==r&&(this.notifyChange(`opaque`),this.notifyChange(`invisible`),!0)}_updateTilingScheme(){let{tilingScheme:e}=this.tilingSchemeLogic;if(e===this.tilingScheme)return;j(!!e,`tiling scheme cannot be reset to undefined`),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();let t=e?.spatialReference??x.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&ge(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,this._set(`tilingScheme`,e),this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference,this._projectorCache.clear(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey=`TerrainTileMemcache`}_acquireTile(e,t,n,r){let i=this._tileCache.pop(K._tileMemcacheKey);return i?(i.init(e,t,n,r,this),i):new this._tileConstructor(e,t,n,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){let{groundExtent:e,tilingScheme:t}=this;if(!t)return;if(!this.enabled){this._setRootTiles(null);return}let n=ut,i=t.rootTilesInExtent(e,n,k*5);if(this._rootTiles!=null){if(i.length>k){s.getLogger(this).warn(Fe);return}let e=this._rootTiles.map(e=>e.lij),t=r(e,i,H);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){let e=this._rootTiles.filter(e=>t.removed.findIndex(t=>H(t,e.lij))>-1?(this._purgeTile(e),!1):!0);t.added.forEach(t=>e.push(this._newRootTile(t))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,i.length>k&&(s.getLogger(this).warn(Ie),i=t.rootTilesInExtent(e,n,k)),this._setRootTiles(i.map(e=>this._newRootTile(e)));T(n,this._rootTilesExtent)||(this._rootTilesExtent=w(n)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange(`ready`),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness(`root-tiles-updated`)}_updateAllTileGeometries(){let e=this._allTiles.filter(e=>this._canUpdateTileGeometry(e));e.length===0||(e.sort(U),e.forEach(e=>this._renderer.updateTileGeometryState(e)),e.forEach(e=>e.renderData.updateNeighborData()),this._updateTilesGeometries(e)),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){let t=e.filter(e=>this._canUpdateTileGeometry(e));if(t.length===0)return;let n=this.renderer;for(let e of t)n.updateGeometryIfNeeded(e);for(let e of t)this._pendingTilesForElevationUpdateEvent.add(e)}_canUpdateTileGeometry(e){return e.loaded&&e.intersectsClippingArea&&e.hasGeometryState}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===1}_newRootTile(e){let t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(1),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationRange(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),e!=null){let t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.freeze&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.groundExtent)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(e==null)return;let t=Ze(e),n=this.visibleElevationRange,r=t?n.minElevation:1/0,i=t?n.maxElevation:-1/0,a=this.groundExtent,o=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty(!1);let s=this._iteratorPool.acquire();for(s.reset(e);!s.done;){let e=s.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(o),e.renderData&&(r=Math.min(e.elevationBoundsMin,r),i=Math.max(e.elevationBoundsMax,i))}s.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(i)&&(n.minElevation!==r||n.maxElevation!==i)&&(this.visibleElevationRange=new O(r,i))}_updateRootTileElevationRange(){let e=1/0,t=-1/0;this._rootTiles?.forEach(({elevationBoundsMin:n,elevationBoundsMax:r})=>{e=Math.min(e,n),t=Math.max(t,r)});let n=this._rootTileElevationRange;(n.minElevation!==e||n.maxElevation!==t)&&(this._rootTileElevationRange=new O(e,t))}_updateViewDependentParameters(){let{camera:e,contentCamera:t}=this.view.state,n=Math.tan(t.fovX*.5),r=Math.tan(t.fovY*.5),i=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=n,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=i/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=i/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=pe(this._splitLimits.frustum??me(),t.frustum):this._splitLimits.frustum=null,oe(this._eyePosRenderSR,t.eye),ue(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility();let t=this._renderer.updateTileGeometryState(e);e.needsElevationSourceUpdate()&&(e.updateAgents(0),e.markElevationSourceUpdateRequested(),this.requestUpdate()),t&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){e.forEachLoadedNeighbor(e=>{this._layerViews[1].some(M)&&e.setPendingUpdate(32),this._pendingTilesToUpdate.add(e)})}_updateTileTexture(e,t){let n=e.resetPendingUpdate(32)?32:e.resetPendingUpdate(16)?16:!1;n&&(this._renderer.updateTileTexture(e,n),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;let e=this._pendingTilesForElevationUpdateEvent;if(e.size>0){let t=new Float64Array(4*e.size),n=0;for(let r of e)t.set(r.extent,4*n),++n;e.clear();for(let e of Se(t,this.spatialReference)){let t=new xe(this.spatialReference,e,`ground`);this.emit(`elevation-change`,t)}}this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);let t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),this._updateElevation(e),this._updateElevationSources(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty();let n=this._pendingTilesToUpdate.size>0,r=n&&this._hasPendingGeometryWithoutIndices();if((!e.done||r)&&this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&(e.hasProgressed||n&&!r)&&this.requestUpdate(),this.notifyChange(`updatingProgressValue`),!e.hasProgressed)return ct}_checkTileInvariant(){}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;let t=!1,n=new je(this._allTiles.length);n.pushAll(this._rootTiles);let r=this.snapLevel,i=this._splitLimits,a=this._eyePosRenderSR;this._allTiles.forAll(e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0});let o=this.view.state.contentCamera.viewProjectionMatrix;for(;!n.empty;){let e=n.pop(),s=e.parent?.hasPendingUpdate(4),c=s?4:e.shouldSplit(i,a,r),l=c===1;e.leaf?Z(e,l):n.pushAll(e.children),s?(e.resetPendingUpdate(1),e.leaf||(e.setPendingUpdate(4),t=!0),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(o)):l?(e.resetPendingUpdate(4),e.leaf&&(e.setPendingUpdate(1),t=!0)):(e.resetPendingUpdate(1)&&e.updateAgentSuspension(),c===2&&e.updateAgents(0),e.leaf||(e.setPendingUpdate(4),e.resetPendingUpdate(1),t=!0))}this._allTilesDirty=t,this.requestUpdate(),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){!e.done&&!this._allTilesSorted&&this.view.pointsOfInterest?.focus&&(Qe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger?.update(),e.madeProgress())}_markTileToUpdate(e){N(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_hasPendingGeometryWithoutIndices(){for(let e of this._pendingTilesToUpdate)if(e.loaded&&e.intersectsClippingArea&&e.renderData?.vao?.indexBuffer==null)return!0;return!1}_updatePendingTileGeometries(){let e=this._pendingTilesToUpdate,t=[];if(e.forEach(e=>{this._canUpdateTileGeometry(e)&&t.push(e)}),t.length===0){e.clear();return}let n=(n,r)=>{!r||!this._canUpdateTileGeometry(r)||r.level<n.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(U);let r=t.length;for(let i=0;i<r;++i){let r=t[i];N(r.loaded),N(r.intersectsClippingArea);let a=r.renderData;if(!a?.geometryState)continue;a.updateNeighborData();let o=a.dirtyEdgeResolutions,s=a.geometryState,c=e=>{let t=Ge[e];n(r,s.cornerPeerNeighbors[e]?.findCorner(Ve(t),e=>e.loaded))};for(let t=0;t<4;++t)if(o&1<<t){let i=a.geometryState.edgePeerNeighbors[t];i&&i?.level>=r.level&&i.forAllSubtreeOnSide(Be(P[t]),t=>this._canUpdateTileGeometry(t)?(N(e.has(t)||U(r,t)<0),n(r,t),!0):!1),c((t+1)%4),c(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,V&&He&&this.checkAllTilesWaterproofness(`pending-geometries-updated`)}_mergeAndSplit(e,t){if(this.freeze||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let n=!1,r=this.view.state.fixedContentCamera,i=!1;for(;!e.done;){i=!0;let a=!1,o=!this._allTiles.some(i=>{if(!n&&!r&&!i.visible)return e.done;let o=i;if(i.hasPendingUpdate(4)){if(!t||i.unmergableChildCount>0)return e.done;for(i.resetPendingUpdate(4);o.parent!=null&&o.parent.unmergableChildCount===0&&o.parent.resetPendingUpdate(4);)o=o.parent;this._mergeTile(o),a=!0,e.madeProgress()}else if(i.resetPendingUpdate(1)){let t=!0,n=i.level;if(n>=A){let e=e=>e.leaf||n-e.level<A;for(let r=0;r<4;++r){let a=i.findNeighborTile(P[r],e);a!=null&&n-a.level===A&&(t=!1,V&&(N(a.leaf),N(a.hasPendingUpdate(1))))}}t?(this._splitTile(i),e.madeProgress(),a=!0):i.setPendingUpdate(1)}return e.done});if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0),o){if(!n){n=!0;continue}if(!a)break}else this._allTilesDirty=!0}i?e.madeProgress():this._allTilesDirty=!0,this._allTilesCreated=!this.allTiles.some(e=>e.hasPendingUpdate(1)||e.hasPendingUpdate(4)&&e.unmergableChildCount===0),this._sortTiles(e)}_updateElevation(e){e.done||this._allTiles.some(t=>(t.resetPendingUpdate(8)&&(this._updateTileGeometryState(t),e.madeProgress()),e.done))}_updateElevationSources(e){e.done||this._allTiles.some(t=>(t.needsElevationSourceUpdate()&&(t.updateAgents(0),t.markElevationSourceUpdateRequested(),e.madeProgress()),e.done))}_updateTextures(e){e.done||this._allTiles.some(t=>(this._updateTileTexture(t,e),e.done))}_updateClippingExtent(){this.spatialReference&&(this.updateOverlayParameters(),this.requestRender(1),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){return this.view.qualitySettings.tiledSurface.lodBias-(1-this.view.quality)*Le}_getLodBiasCorrectedScale(e){let t=this.tilingScheme.levels,n=c(e-this._lodBias,0,t.length-1),r=n-Math.floor(n),i=t[Math.floor(n)].scale,a=t[Math.ceil(n)].scale;return i*(1-r)+a*r}_removeAllTiles(){this._pendingTilesToUpdate.clear(),this._pendingTilesForElevationUpdateEvent.clear(),this._rootTiles!=null&&(this._rootTiles.forEach(e=>this._purgeTile(e)),this._setRootTiles(null),this.notifyChange(`ready`)),this._allTiles.clear(),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles}),this.renderer.visible=!1}_purgeSubtree(e){let t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?mt(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(K._tileMemcacheKey,e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){j(e.leaf,`Tile that is already split should not be split again!`),j(e.rendered,`Tile marked to split is not rendered`),mt(e);let t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles}),e.updateAgentSuspension(),j(e.rendered,`parent should be rendered`),t.forEach(e=>this._loadTile(e)),t.forEach(e=>this._pendingTilesToUpdate.add(e)),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach(e=>Z(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){X.spatialReference=this.spatialReference,X.extent=e.extent,X.scale=this._getLodBiasCorrectedScale(t),this.emit(`scale-change`,X)}createTile(e,t,n,r){j(!!r,`createTile sanity check`);let i=this._acquireTile(e,t,n,r);return i.updateClippingStatus(this.groundExtent),i.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(i)&&i.setPendingUpdate(1),i}get _shortBatches(){return this.view.state.mode!==2}_mergeTile(e){j(!e.hasPendingUpdate(1),`_mergeTile sanity check`),j(!e.leaf,`Cannot merge a leaf`),e.leaf||(this._purgeSubtree(e),j(!e.renderData,`Merging tile with existing render data?`),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),Z(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&e.updateOverlayParameters(this.overlayManager)}_handleLayerViewChanges(e=ot){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1,n=new Set,r=-1;for(let e=this.view.allLayerViews.length-1;e>=0;e--){let i=this.view.allLayerViews.items[e];if(n.add(i.uid),F(i)||I(i)){if(this._basemapLayerViewHandles.has(i.uid)&&!I(i)){let e=this._layerClassFromLayerView(i),n=this.getLayerIndexByUID(e,i.uid);n!=null&&((n<r||r==null)&&(t=!0),r=n)}else this._registerTiledLayerView(i),i.layer.loaded&&(t=!0)}}this._basemapLayerViewHandles.forEach((e,r)=>{n.has(r)||(this._unregisterTiledLayerView(r),t=!0)}),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(let e of this.view.allLayerViews.items)if(L(e)&&!ye(e.layer)&&e.fullOpacity!==0)return!1;return!0}_hasCompositeBlendMode(){for(let e of this.view.allLayerViews.items)if((R(e)||I(e))&&nt(rt[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return+!z(e)}_registerTiledLayerView(e){let t=[];if((R(e)||I(e))&&t.push(h(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!I(e)){let n=this._layerClassFromLayerView(e);t.push(h(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(h(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));let{layer:r}=e;`effectiveScaleRange`in r&&t.push(h(()=>!e.destroyed&&r.effectiveScaleRange,()=>this._restartAllAgents(n))),t.push(e.on(`data-changed`,()=>{let t=this.getLayerIndexByUID(n,e.uid);t!=null&&this._invalidateLayerData(t,n)}))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){let t=this._basemapLayerViewHandles.get(e);if(t){for(let e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;let e=this.view.allLayerViews,t=[[],[]],n=null;e.forEach(e=>{if(!e.layer||e.suspended||!F(e)||!e.fullExtent)return;let r=this._layerClassFromLayerView(e);if(r===1){let t=e.displayLevelRange.maxLevel;t!==1/0&&(n===null||t>n)&&(n=t)}t[r].push(e)});for(let e of Oe){let n=this._layerViews[e],r=t[e];r.reverse();let i=r.length,a=n.length!==i,o=Array(i),s=Array(n.length);this._layerIndexByUid[e].clear();for(let t=0;t<i;t++){let i=r[t].uid;this._layerIndexByUid[e].set(i,t);let c=n.indexOf(r[t]);o[t]=c,t!==c&&(a=!0),c>-1&&(s[c]=t)}if(a){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;)t.next().modifyLayers(s,o,e);this._layerViews[e]=r,this._restartAllAgents(e),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(n)&&(this._viewChangeUpdate(),this.notifyChange(`tilingScheme`))}_restartAllAgents(e){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){let n=t.next();n.restartAgents(e),e===0&&n.computeElevationBounds()}this._updateRootTileElevationRange()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll(t=>{t.updateAgents(1),e===1?this.renderer.updateTileTexture(t,16):t.updateRenderData(1,e)}),this._evaluateTransparency()}_invalidateLayerData(e,t){this._rootTiles!=null&&(W(this._rootTiles,n=>n.removeLayerAgent(e,t)),W(this._rootTiles,n=>{n.invalidateLayerData(e,t),n.restartAgents(t)}))}setTileTreeDirty(e){this._allTilesDirty=!0,e&&(this._allTilesCreated=!1)}requestRender(e=1){this.renderer.setNeedsRender(e)}requestUpdate(){++this._pendingUpdates===1&&(this._hasPendingUpdates=!0)}requestTileData(e,t,n,r){let i=this.layerViewByIndex(t,n),{tilemapCache:a}=i;return!a||M(i)?this._requestTileData(e,n,i,r):(++this._asyncWorkItems,a.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).catch(t=>{throw te(r),p(t)||this._dataMissing(e,n,i),t}).then(()=>this._frameTask.schedule(()=>this._requestTileData(e,n,i,r),r.signal)).finally(()=>--this._asyncWorkItems))}_requestTileData(e,t,n,r){return this.destroying?Promise.resolve():t===0?z(n)?this._requestElevationTileData(e,n,r):Promise.reject():L(n)?this._requestMapTileData(e,n,r):Promise.reject()}_requestElevationTileData(e,t,n){++this._asyncWorkItems;let r=r=>{!m(n)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},i=n=>{p(n)||(s.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${n}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,{...be,...n}).then(e=>this._frameTask.schedule(()=>r(e)),i).finally(()=>--this._asyncWorkItems)}_elevationDataArrived(e,t,n){let r=this._layerIndexByUid[0].get(t.uid);if(r==null){s.getLogger(this).warn(`TerrainSurface: received data from unknown layer %d %s`,0,e.lij.toString());return}let i=new Te(e.lij,e.extent,n);e.dataArrived(r,0,i),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:0});let a=[e],o=e.level,c=this._iteratorPool.acquire();for(c.reset(a);!c.done;){let e=c.next();e.findElevationBoundsForLayer(r,o),e.computeElevationBounds()}o===0&&this._updateRootTileElevationRange(),c.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,n){++this._asyncWorkItems;let r=(r,i)=>{B(i),m(n)||(console.error(`Tile ${e.lij.toString()} layer 1/${t.uid} error ${r}`),this._dataMissing(e,1,t),this.requestUpdate())},i=e=>t=>r(t,e);return t.fetchTile(e.lij,n).then(r=>this._frameTask.schedule(()=>{this.requestUpdate(),m(n)?B(r):this._mapTileDataArrived(e,t,r)},n.signal,i(r)).catch(i(r)),(e,t=null)=>this._frameTask.schedule(()=>r(e,t))).finally(()=>--this._asyncWorkItems)}_mapTileDataArrived(e,t,n){let r=this.getLayerIndexByUID(1,t.uid);r==null?(B(n),s.getLogger(this).warn(`TerrainSurface: received data from unknown layer`)):(e.dataArrived(r,1,n),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:1}))}_dataMissing(e,t,n){let r=this.getLayerIndexByUID(t,n.uid);r==null?s.getLogger(this).warn(`TerrainSurface: received data from unknown layer`):(e.dataMissing(r,t),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:t}))}get performanceInfo(){let e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll(t=>{t.leaf&&e.numLeaves++;let n=t.level;t.renderData&&(e.numLoadedPerLevel[n]=(e.numLoadedPerLevel[n]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[n]=(e.numRenderedPerLevel[n]||0)+1,e.numRendered++))}),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(this._usedMemory??=this._recalculateUsedMemory(),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce((e,t)=>e+t.usedMemory,0)):null}getUsedMemoryForLayerView(e){let t=0,n=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(n,e.uid);return r!=null&&this._allTiles.forAll(e=>t+=e.getUsedMemoryForLayer(n,r)),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(e=`render-patch-groups`){}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&e[2]===0}lijEastEnd(e){return 1<<e+ +!!this._isGeographic}wrapEastWest(e){let t=this.lijEastEnd(e[0]),n=e[2];if(0<=n&&n<t)return e;if(!this._isGlobal)return null;let r=(n+(n<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){Ue(e)}enableWaterproofnessChecks(e){We(e)}static cleanupTerrainSurface(){dt.prune()}enable(e){e!==this.enabled&&(this._set(`enabled`,e),e?(this._updateRootTiles(),this.freeze=!1,this.view.elevationProvider.register(0,this)):(this.view.elevationProvider.unregister(this),this.freeze=!0,this._removeAllTiles(),this._setRootTiles(null)),this.notifyChange(`ready`))}updateOverlayParameters(){let{overlayManager:e}=this;this.allTiles.forAll(t=>t.updateOverlayParameters(e))}};e([y()],q.prototype,`_renderer`,void 0),e([y({constructOnly:!0})],q.prototype,`_scaleRangeQueries`,void 0),e([y({constructOnly:!0})],q.prototype,`view`,void 0),e([y({constructOnly:!0})],q.prototype,`overlayManager`,void 0),e([y({constructOnly:!0})],q.prototype,`terrainTextureCompressionTracker`,void 0),e([y()],q.prototype,`_hasPendingUpdates`,void 0),e([y()],q.prototype,`_asyncWorkItems`,void 0),e([y()],q.prototype,`_allTilesDirty`,void 0),e([y()],q.prototype,`_allTilesSorted`,void 0),e([y()],q.prototype,`allTilesCreated`,null),e([y()],q.prototype,`_allTilesCreated`,void 0),e([y()],q.prototype,`_viewChanged`,void 0),e([y({type:Number})],q.prototype,`heading`,void 0),e([y()],q.prototype,`_splitLimits`,void 0),e([y()],q.prototype,`_frameTask`,void 0),e([y()],q.prototype,`demResolution`,null),e([y({readOnly:!0})],q.prototype,`snapLevel`,null),e([y({readOnly:!0})],q.prototype,`lodSnappingEnabled`,null),e([y({readOnly:!0})],q.prototype,`userClippingExtent`,null),e([y()],q.prototype,`_rootTilesExtent`,void 0),e([y({readOnly:!0})],q.prototype,`groundExtent`,null),e([y({readOnly:!0})],q.prototype,`fullGroundExtent`,null),e([y({readOnly:!0})],q.prototype,`_tilingSchemeExtent`,null),e([y({readOnly:!0})],q.prototype,`updating`,null),e([y({readOnly:!0})],q.prototype,`readyToRun`,null),e([y(we)],q.prototype,`updatingProgress`,void 0),e([y({readOnly:!0})],q.prototype,`updatingProgressValue`,null),e([y()],q.prototype,`_maxNumUpdating`,void 0),e([y()],q.prototype,`baseOpacity`,null),e([y()],q.prototype,`hasCompositeBlendMode`,void 0),e([y({readOnly:!0})],q.prototype,`viewingMode`,null),e([y()],q.prototype,`maxTextureScale`,void 0),e([y({readOnly:!0})],q.prototype,`ready`,null),e([y({readOnly:!0})],q.prototype,`rootTiles`,null),e([y()],q.prototype,`_rootTiles`,void 0),e([y({readOnly:!0})],q.prototype,`spatialReference`,null),e([y({type:t})],q.prototype,`backgroundColor`,null),e([y({value:!1})],q.prototype,`slicePlaneEnabled`,null),e([y({readOnly:!0})],q.prototype,`tilingScheme`,void 0),e([y({readOnly:!0})],q.prototype,`tilingSchemeLocked`,null),e([y({readOnly:!0})],q.prototype,`tilingSchemeLogic`,void 0),e([y()],q.prototype,`wireframe`,null),e([y()],q.prototype,`opaque`,null),e([y()],q.prototype,`invisible`,null),e([y({value:!1})],q.prototype,`freeze`,null),e([y()],q.prototype,`fadeDuration`,null),e([y()],q.prototype,`_xNormalizer`,null),e([y()],q.prototype,`visibleElevationRange`,void 0),e([y()],q.prototype,`_rootTileElevationRange`,void 0),e([y()],q.prototype,`_layerViewsDirty`,void 0),e([y()],q.prototype,`renderPatchBorders`,null),e([y()],q.prototype,`renderingDisabled`,null),e([y({readOnly:!0})],q.prototype,`enabled`,void 0),q=K=e([re(`esri.views.3d.terrain.TerrainSurface`)],q);const lt=q,J=b(),Y=new _e,ut=w(),dt=new f,X={spatialReference:null,extent:null,scale:0};function ft(e,t,n){for(let r of e){if(!r.containsPointXY(t,n))continue;let e=r;for(;e&&!e.renderData;){let r=+(t>e.extentMidX)+(n<e.extentMidY?2:0);e=e.children[r]}let i=e?.renderData?.geometryState.samplerData??null;return Ee(t,n,i)}return null}function Z(e,t){!e.leaf||e.level<A||$(e,e=>{t&&pt(e);let n=Q(e);if(e.maxLevelDeltaNeighborCount++,n){let t=e.parent;for(;t;){let e=Q(t);if(t.unmergableChildCount++,e)t=t.parent;else break}}})}function pt(e){if(e.hasPendingUpdate(1))return;let t=e.parent;for(;t?.resetPendingUpdate(4);)t=t.parent;e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1),e.level<A||$(e,e=>{pt(e)})}function mt(e){e.level<A||$(e,e=>{if(e.maxLevelDeltaNeighborCount--,e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0){let t=e.parent;for(;t&&(t.unmergableChildCount--,Q(t));)t=t.parent}})}function Q(e){return e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0}function $(e,t){if(e.level<A)return;let n=e.level-A,r=e.lij[1]>>A,i=e.lij[2]>>A,a=e=>e.leaf||e.level===n;for(let o=0;o<4;++o){let s=e.findNeighborTile(P[o],a);if(!s||s.level!==n)continue;let c=s.lij;(c[1]!==r||c[2]!==i)&&t(s)}}export{lt as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{createTask as t}from"../../../../../core/asyncUtils.js";import{clamp as n}from"../../../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../../../core/maybe.js";import{watch as i,syncAndInitial as a}from"../../../../../core/reactiveUtils.js";import{createScreenPointArray as o,createRenderScreenPointArray as s,screenPointObjectToArray as c}from"../../../../../core/screenUtils.js";import{isSVG as l}from"../../../../../core/urlUtils.js";import{property as u,subclass as d}from"../../../../../core/accessorSupport/decorators.js";import{requestImage as f}from"../../../../../request/image.js";import{InternalRenderCategory as p}from"../../../webgl.js";import m from"../../../webgl/RenderNode.js";import{M as h}from"../../../../../chunks/Magnifier.glsl.js";import{MagnifierTechnique as g}from"./MagnifierTechnique.js";import{createQuadVAO as _}from"../../lib/glUtil3D.js";import{loadMagnifierResources as v}from"../../../../magnifier/resources.js";import{ColorAttachment0 as y,PrimitiveType as b}from"../../../../webgl/enums.js";import x from"../../../../webgl/Texture.js";import{TextureDescriptor as S}from"../../../../webgl/TextureDescriptor.js";let C=class extends m{constructor(){super(...arguments),this.consumes={required:[p.MAGNIFIER]},this.produces=p.MAGNIFIER,this._imageSources=null,this._imageLoadTask=null,this._passParameters=new h,this._magnifier=null,this._tmpScreenPoint=o(),this._tmpRenderPoint=s()}initialize(){this.addHandles([i(()=>this.view.magnifier,e=>this._update(e),a)])}_update(e){if(e===this._magnifier)return;this.removeAllHandles(),this._magnifier=e;let t=()=>{let e=this._validMagnifier;e?(this._loadResources(e),this.produces=p.MAGNIFIER):this.produces=`disabled`,this.requestRender()};this._magnifier&&this.addHandles(i(()=>this._magnifier?.version,t)),t()}get _validMagnifier(){return this._magnifier?.visible&&this._magnifier?.position&&this._magnifier?.size>0?this._magnifier:null}get _factor(){return this._magnifier?.factor||1}destroy(){this._magnifier=null,this._imageLoadTask!=null&&(this._imageLoadTask.task.abort(),this._imageLoadTask=null),this._disposeTextures(),this._vao=r(this._vao)}_disposeTextures(){this._passParameters.mask=r(this._passParameters.mask),this._passParameters.overlay=r(this._passParameters.overlay),this._passParameters.input=r(this._passParameters.input)}render(){let e=this._validMagnifier,t=this.input;if(e==null)return t;if(this._imageSources==null)return this.requestRender(1),t;let r=this.renderingContext,i=this.camera.pixelRatio,a=Math.ceil(i*e.size);this._vao??=_(r,0,0,1);let o=this.techniques.getCompiled(g);if(this._ensureTextureResources(r,a),!o||!this._passParameters.input)return this.requestRender(1),t;let s=Math.ceil(1/this._factor*a),l=this._passParameters.input;l.resize(s,s),c(e.position,this._tmpScreenPoint);let u=this.camera.screenToRender(this._tmpScreenPoint,this._tmpRenderPoint),d=this.camera.fullWidth,f=this.camera.fullHeight,p=.5*s,m=.5*s;u[0]=n(u[0],p,d-p-1),u[1]=n(u[1],m,f-m-1);let h=Math.floor(u[0]-p),v=Math.floor(u[1]-m);return r.bindFramebuffer(t.fbo),o.program.bindTexture(`textureInput`,l),r.gl.copyTexImage2D(l.descriptor.target,0,l.descriptor.pixelFormat,h,v,s,s,0),this._passParameters.magnifier=e,r.bindTechnique(o,this.bindParameters,this._passParameters),r.setDrawBuffers([y]),r.bindVAO(this._vao),r.drawArrays(b.TRIANGLE_STRIP,0,4),t}_loadResources(e){let{maskUrl:n,overlayUrl:r}=e;(this._imageLoadTask?.maskUrl!==n||this._imageLoadTask?.overlayUrl!==r)&&(this._imageLoadTask?.task.abort(),this._imageLoadTask=this._imageSources=null)
|
|
2
|
+
import{__decorate as e}from"tslib";import{createTask as t}from"../../../../../core/asyncUtils.js";import{clamp as n}from"../../../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../../../core/maybe.js";import{watch as i,syncAndInitial as a}from"../../../../../core/reactiveUtils.js";import{createScreenPointArray as o,createRenderScreenPointArray as s,screenPointObjectToArray as c}from"../../../../../core/screenUtils.js";import{isSVG as l}from"../../../../../core/urlUtils.js";import{property as u,subclass as d}from"../../../../../core/accessorSupport/decorators.js";import{requestImage as f}from"../../../../../request/image.js";import{InternalRenderCategory as p}from"../../../webgl.js";import m from"../../../webgl/RenderNode.js";import{M as h}from"../../../../../chunks/Magnifier.glsl.js";import{MagnifierTechnique as g}from"./MagnifierTechnique.js";import{createQuadVAO as _}from"../../lib/glUtil3D.js";import{loadMagnifierResources as v}from"../../../../magnifier/resources.js";import{ColorAttachment0 as y,PrimitiveType as b}from"../../../../webgl/enums.js";import x from"../../../../webgl/Texture.js";import{TextureDescriptor as S}from"../../../../webgl/TextureDescriptor.js";let C=class extends m{constructor(){super(...arguments),this.consumes={required:[p.MAGNIFIER]},this.produces=p.MAGNIFIER,this._imageSources=null,this._imageLoadTask=null,this._passParameters=new h,this._magnifier=null,this._tmpScreenPoint=o(),this._tmpRenderPoint=s()}initialize(){this.addHandles([i(()=>this.view.magnifier,e=>this._update(e),a)])}_update(e){if(e===this._magnifier)return;this.removeAllHandles(),this._magnifier=e;let t=()=>{let e=this._validMagnifier;e?(this._loadResources(e),this.produces=p.MAGNIFIER):this.produces=`disabled`,this.requestRender()};this._magnifier&&this.addHandles(i(()=>this._magnifier?.version,t)),t()}get _validMagnifier(){return this._magnifier?.visible&&this._magnifier?.position&&this._magnifier?.size>0?this._magnifier:null}get _factor(){return this._magnifier?.factor||1}destroy(){this._magnifier=null,this._imageLoadTask!=null&&(this._imageLoadTask.task.abort(),this._imageLoadTask=null),this._disposeTextures(),this._vao=r(this._vao)}_disposeTextures(){this._passParameters.mask=r(this._passParameters.mask),this._passParameters.overlay=r(this._passParameters.overlay),this._passParameters.input=r(this._passParameters.input)}render(){let e=this._validMagnifier,t=this.input;if(e==null)return t;if(this._imageSources==null)return this.requestRender(1),t;let r=this.renderingContext,i=this.camera.pixelRatio,a=Math.ceil(i*e.size);this._vao??=_(r,0,0,1);let o=this.techniques.getCompiled(g);if(this._ensureTextureResources(r,a),!o||!this._passParameters.input)return this.requestRender(1),t;let s=Math.ceil(1/this._factor*a),l=this._passParameters.input;l.resize(s,s),c(e.position,this._tmpScreenPoint);let u=this.camera.screenToRender(this._tmpScreenPoint,this._tmpRenderPoint),d=this.camera.fullWidth,f=this.camera.fullHeight,p=.5*s,m=.5*s;u[0]=n(u[0],p,d-p-1),u[1]=n(u[1],m,f-m-1);let h=Math.floor(u[0]-p),v=Math.floor(u[1]-m);return r.bindFramebuffer(t.fbo),o.program.bindTexture(`textureInput`,l),r.gl.copyTexImage2D(l.descriptor.target,0,l.descriptor.pixelFormat,h,v,s,s,0),this._passParameters.magnifier=e,r.bindTechnique(o,this.bindParameters,this._passParameters),r.setDrawBuffers([y]),r.bindVAO(this._vao),r.drawArrays(b.TRIANGLE_STRIP,0,4),t}_loadResources(e){let{maskUrl:n,overlayUrl:r}=e;(this._imageLoadTask?.maskUrl!==n||this._imageLoadTask?.overlayUrl!==r)&&(this._imageLoadTask?.task.abort(),this._imageLoadTask=this._imageSources=null),this._imageSources||this._imageLoadTask||(this._imageLoadTask={maskUrl:n,overlayUrl:r,task:t(async e=>{let t=n==null||r==null?v(e):null,i=n==null?t.then(e=>e.mask):f(n,{signal:e}),a=r==null?t.then(e=>e.overlay):f(r,{signal:e});this._imageSources={mask:await i,overlay:await a}})})}_ensureTextureResources(e,t){this._imageSources==null||this._passParameters.size===t&&this._passParameters.input&&this._passParameters.mask&&this._passParameters.overlay||(this._disposeTextures(),this._imageSources.overlay.width=this._imageSources.mask.width=t,this._imageSources.overlay.height=this._imageSources.mask.height=t,this._passParameters.overlay=new x(e,this._createTextureDescriptor(t,6408,this._imageSources.overlay),this._imageSources.overlay),this._passParameters.mask=new x(e,this._createTextureDescriptor(t,6406,this._imageSources.mask),this._imageSources.mask),this._passParameters.input=new x(e,this._createTextureDescriptor(t,6408,null)))}_createTextureDescriptor(e,t,n){let r=this.renderingContext,i=new S(e);return i.pixelFormat=i.internalFormat=t,i.wrapMode=33071,i.flipped=!!n,i.preMultiplyAlpha=!(t!==6408||!n||l(n.src)&&r.driverTest.svgPremultipliesAlpha.result),i}};e([u()],C.prototype,`consumes`,void 0),e([u()],C.prototype,`produces`,void 0),e([u()],C.prototype,`_imageSources`,void 0),e([u()],C.prototype,`_imageLoadTask`,void 0),C=e([d(`esri.views.3d.webgl-engine.effects.magnifier.Magnifier`)],C);export{C as Magnifier};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{equals as t}from"../../../../../core/arrayUtils.js";import{smoothstep as n}from"../../../../../core/mathUtils.js";import{watch as r,syncAndInitial as i}from"../../../../../core/reactiveUtils.js";import{property as a,subclass as o}from"../../../../../core/accessorSupport/decorators.js";import{exactEquals as s,copy as c,equals as l}from"../../../../../core/libs/gl-matrix-2/math/vec4.js";import{InternalRenderCategory as u}from"../../../webgl.js";import d from"../../../webgl/RenderNode.js";import{S as f}from"../../../../../chunks/ShadowCastVisualize.glsl.js";import{ShadowCastVisualizeTechnique as p}from"./ShadowCastVisualizeTechnique.js";import{ShadowCastVisualizeTechniqueConfiguration as m}from"./ShadowCastVisualizeTechniqueConfiguration.js";import{vvColorNumber as h}from"../../materials/VisualVariablePassParameters.js";import{ColorAttachment0 as g}from"../../../../webgl/enums.js";let _=class extends d{constructor(e){super(e),this.produces=u.TRANSPARENT_NO_DEPTH,this.consumes={required:[u.TRANSPARENT_NO_DEPTH]},this.enabled=!1,this._configuration=new m,this._stencilMask=null,this._disableElevation={min:4e4,max:5e4,threshold:1/512},this._passParameters=new f(e.data)}initialize(){this.addHandles([r(()=>this.enabled,e=>{this.produces=e?u.TRANSPARENT_NO_DEPTH:`disabled`,this.requestRender(1)},i)])}precompile(){this._showVisualization&&this.techniques.precompile(p,this._configuration)}render(){let e=this.input;if(!this._showVisualization)return e;let[t,n]=this.data.computedSamples;this._passParameters.sampleScale=[t?1/t:0,n?1/n:0];let r=this.techniques.get(p,this._configuration),i=this._stencilMask!=null,a=this.renderingContext,o=this.bindParameters,s=a.boundFramebuffer,c=null;return i&&(c=this.fboCache.acquire(o.camera.width,o.camera.height,`shadow cast masked draw`),c.attachDepth(this._stencilMask),a.bindFramebuffer(c.fbo),a.blitFramebuffer(s,c.fbo,16384)),a.bindTechnique(r,o,this._passParameters),a.setDrawBuffers([g]),a.screen.draw(),c!=null&&(a.bindFramebuffer(s),a.blitFramebuffer(c.fbo,s,16384),c.detachDepth(),c.release()),e}setStencilMask(e){this._stencilMask=e}setOptions(e){e.enabled!==void 0&&(this.enabled=e.enabled),e.thresholdColor!==void 0&&(s(this._passParameters.thresholdColor,e.thresholdColor)||(c(this._passParameters.thresholdColor,e.thresholdColor),this._requestRenderIfEnabled())),e.gradientColorRamp!==void 0&&this._modifyGradientColorRamp(e.gradientColorRamp),e.bandedGradientColorRamp!==void 0&&this._modifyGradientColorRamp(e.bandedGradientColorRamp,!0),e.threshold!==void 0&&this._passParameters.threshold!==e.threshold&&(this._passParameters.threshold=e.threshold,this._requestRenderIfEnabled()),e.rendersSunlight!==void 0&&this._configuration.rendersSunlight!==e.rendersSunlight&&(this._configuration.rendersSunlight=e.rendersSunlight,this._requestRenderIfEnabled()),e.visualization!==void 0&&this._configuration.visualization!==e.visualization&&(this._configuration.visualization=e.visualization,this._requestRenderIfEnabled()),e.bandSize!==void 0&&this._passParameters.bandSize!==e.bandSize&&(this._passParameters.bandSize=e.bandSize,this._requestRenderIfEnabled()),e.analysisVolume!==void 0&&(this._configuration.useMask=e.analysisVolume!==null)}get isAboveElevationThreshold(){return this._passParameters.opacityFromElevation>this._disableElevation.threshold}setOpacityFromElevation(e){this._passParameters.opacityFromElevation=1-n(this._disableElevation.min,this._disableElevation.max,e)}get _showVisualization(){return this.enabled&&(this.data.computedSamples[0]>0||this.data.computedSamples[1]>0)&&this.isAboveElevationThreshold}_modifyGradientColorRamp(e,t=!1){e.length>h&&(e=e.slice(0,h))
|
|
2
|
+
import{__decorate as e}from"tslib";import{equals as t}from"../../../../../core/arrayUtils.js";import{smoothstep as n}from"../../../../../core/mathUtils.js";import{watch as r,syncAndInitial as i}from"../../../../../core/reactiveUtils.js";import{property as a,subclass as o}from"../../../../../core/accessorSupport/decorators.js";import{exactEquals as s,copy as c,equals as l}from"../../../../../core/libs/gl-matrix-2/math/vec4.js";import{InternalRenderCategory as u}from"../../../webgl.js";import d from"../../../webgl/RenderNode.js";import{S as f}from"../../../../../chunks/ShadowCastVisualize.glsl.js";import{ShadowCastVisualizeTechnique as p}from"./ShadowCastVisualizeTechnique.js";import{ShadowCastVisualizeTechniqueConfiguration as m}from"./ShadowCastVisualizeTechniqueConfiguration.js";import{vvColorNumber as h}from"../../materials/VisualVariablePassParameters.js";import{ColorAttachment0 as g}from"../../../../webgl/enums.js";let _=class extends d{constructor(e){super(e),this.produces=u.TRANSPARENT_NO_DEPTH,this.consumes={required:[u.TRANSPARENT_NO_DEPTH]},this.enabled=!1,this._configuration=new m,this._stencilMask=null,this._disableElevation={min:4e4,max:5e4,threshold:1/512},this._passParameters=new f(e.data)}initialize(){this.addHandles([r(()=>this.enabled,e=>{this.produces=e?u.TRANSPARENT_NO_DEPTH:`disabled`,this.requestRender(1)},i)])}precompile(){this._showVisualization&&this.techniques.precompile(p,this._configuration)}render(){let e=this.input;if(!this._showVisualization)return e;let[t,n]=this.data.computedSamples;this._passParameters.sampleScale=[t?1/t:0,n?1/n:0];let r=this.techniques.get(p,this._configuration),i=this._stencilMask!=null,a=this.renderingContext,o=this.bindParameters,s=a.boundFramebuffer,c=null;return i&&(c=this.fboCache.acquire(o.camera.width,o.camera.height,`shadow cast masked draw`),c.attachDepth(this._stencilMask),a.bindFramebuffer(c.fbo),a.blitFramebuffer(s,c.fbo,16384)),a.bindTechnique(r,o,this._passParameters),a.setDrawBuffers([g]),a.screen.draw(),c!=null&&(a.bindFramebuffer(s),a.blitFramebuffer(c.fbo,s,16384),c.detachDepth(),c.release()),e}setStencilMask(e){this._stencilMask=e}setOptions(e){e.enabled!==void 0&&(this.enabled=e.enabled),e.thresholdColor!==void 0&&(s(this._passParameters.thresholdColor,e.thresholdColor)||(c(this._passParameters.thresholdColor,e.thresholdColor),this._requestRenderIfEnabled())),e.gradientColorRamp!==void 0&&this._modifyGradientColorRamp(e.gradientColorRamp),e.bandedGradientColorRamp!==void 0&&this._modifyGradientColorRamp(e.bandedGradientColorRamp,!0),e.threshold!==void 0&&this._passParameters.threshold!==e.threshold&&(this._passParameters.threshold=e.threshold,this._requestRenderIfEnabled()),e.rendersSunlight!==void 0&&this._configuration.rendersSunlight!==e.rendersSunlight&&(this._configuration.rendersSunlight=e.rendersSunlight,this._requestRenderIfEnabled()),e.visualization!==void 0&&this._configuration.visualization!==e.visualization&&(this._configuration.visualization=e.visualization,this._requestRenderIfEnabled()),e.bandSize!==void 0&&this._passParameters.bandSize!==e.bandSize&&(this._passParameters.bandSize=e.bandSize,this._requestRenderIfEnabled()),e.analysisVolume!==void 0&&(this._configuration.useMask=e.analysisVolume!==null)}get isAboveElevationThreshold(){return this._passParameters.opacityFromElevation>this._disableElevation.threshold}setOpacityFromElevation(e){this._passParameters.opacityFromElevation=1-n(this._disableElevation.min,this._disableElevation.max,e)}get _showVisualization(){return this.enabled&&(this.data.computedSamples[0]>0||this.data.computedSamples[1]>0)&&this.isAboveElevationThreshold}_modifyGradientColorRamp(e,t=!1){e.length>h&&(e=e.slice(0,h)),v(t?this._passParameters.bandedGradientColorRamp:this._passParameters.gradientColorRamp,e)||(t?this._passParameters.bandedGradientColorRamp=e:this._passParameters.gradientColorRamp=e,this._requestRenderIfEnabled())}_requestRenderIfEnabled(){this.enabled&&this.requestRender(1)}};e([a()],_.prototype,`produces`,void 0),e([a()],_.prototype,`consumes`,void 0),e([a()],_.prototype,`enabled`,void 0),e([a({constructOnly:!0})],_.prototype,`data`,void 0),_=e([o(`esri.views.3d.webgl-engine.effects.shadowAccumulation.ShadowCastRenderer`)],_);function v(e,n){return t(e,n,([e,t],[n,r])=>e===n&&l(t,r))}export{_ as ShadowCastRenderer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import has from"../../../../core/has.js";import{disposeMaybe as e}from"../../../../core/maybe.js";import{ScreenSpaceGeometry as t}from"../effects/ScreenSpaceGeometry.js";import{createEmptyTexture as n}from"./glUtil3D.js";import{IndexBufferCache as r}from"../materials/renderers/IndexBufferCache.js";import{TextureBufferCache as i}from"../materials/renderers/TextureBufferCache.js";import{VaoCache as a}from"../materials/renderers/VaoCache.js";import{VboCache as o}from"../materials/renderers/VboCache.js";import{RenderingContext as s}from"../../../webgl/RenderingContext.js";class c extends s{constructor(e,r){super(e,r),this.emptyTexture=n(this),this._vaoCaches=new Map,this._vboCaches=new Map,this._indexBufferCache=null,this._textureBufferCaches=new Map,this.debugBoundTechnique=``,this._refCount=1,this._newCache=r.newCache,this._screen=new t(this)}configure(e){super.configure(e),this._newCache=e.newCache,this._isAssumedMetalDriver=null}destroy(){this._vaoCaches.forEach(e=>e.dispose()),this._vaoCaches.clear(),this._vboCaches.forEach(e=>e.dispose()),this._vboCaches.clear(),this._indexBufferCache=e(this._indexBufferCache),this._textureBufferCaches.forEach(e=>e.dispose()),this._textureBufferCaches.clear()
|
|
2
|
+
import has from"../../../../core/has.js";import{disposeMaybe as e}from"../../../../core/maybe.js";import{ScreenSpaceGeometry as t}from"../effects/ScreenSpaceGeometry.js";import{createEmptyTexture as n}from"./glUtil3D.js";import{IndexBufferCache as r}from"../materials/renderers/IndexBufferCache.js";import{TextureBufferCache as i}from"../materials/renderers/TextureBufferCache.js";import{VaoCache as a}from"../materials/renderers/VaoCache.js";import{VboCache as o}from"../materials/renderers/VboCache.js";import{RenderingContext as s}from"../../../webgl/RenderingContext.js";class c extends s{constructor(e,r){super(e,r),this.emptyTexture=n(this),this._vaoCaches=new Map,this._vboCaches=new Map,this._indexBufferCache=null,this._textureBufferCaches=new Map,this.debugBoundTechnique=``,this._refCount=1,this._newCache=r.newCache,this._screen=new t(this)}configure(e){super.configure(e),this._newCache=e.newCache,this._isAssumedMetalDriver=null}destroy(){this._vaoCaches.forEach(e=>e.dispose()),this._vaoCaches.clear(),this._vboCaches.forEach(e=>e.dispose()),this._vboCaches.clear(),this._indexBufferCache=e(this._indexBufferCache),this._textureBufferCaches.forEach(e=>e.dispose()),this._textureBufferCaches.clear(),--this._refCount>0||this.dispose()}ref(){++this._refCount}get refCount(){return this._refCount}dispose(){this.emptyTexture.dispose(),this._screen.destroy(),this._screen=null,super.dispose(),this._vaoCaches.forEach(e=>e.dispose()),this._vaoCaches.clear(),this._vboCaches.forEach(e=>e.dispose()),this._vboCaches.clear(),this._indexBufferCache?.dispose(),this._indexBufferCache=null,this._textureBufferCaches.forEach(e=>e.dispose()),this._textureBufferCaches.clear()}get newCache(){return this._newCache}get screen(){return this._screen}getVaoCache(e){let t=JSON.stringify(e),n=this._vaoCaches.get(t);if(n)return n;let r=new a(this,e);return this._vaoCaches.set(t,r),r}getVboCache(e){let t=JSON.stringify(e),n=this._vboCaches.get(t);if(n)return n;let r=new o(this,e);return this._vboCaches.set(t,r),r}get indexBufferCache(){return this._indexBufferCache??=new r(this),this._indexBufferCache}getTextureBufferCache(e){let t=JSON.stringify(e),n=this._textureBufferCaches.get(t);if(n)return n;let r=new i(this,e);return this._textureBufferCaches.set(t,r),r}bindTechnique(e,t,n,r){return this.debugBoundTechnique=e.declaredClass,this.useProgram(e.program),this.setPipelineState(e.getPipeline(t,n)),e.program.bind(t),e.program.bindPass(t,n),r&&e.program.bindDraw(t,n,r),e.program}get isAssumedMetalDriver(){if(this._isAssumedMetalDriver==null&&(this._isAssumedMetalDriver=!!has(`ios`)||!!has(`safari`),!this._isAssumedMetalDriver&&has(`mac`)&&has(`chrome`))){let e=this.capabilities.rendererInfo?.getUnmaskedRenderer().toLowerCase(),t=e?.includes(`angle`)&&e?.includes(`metal`);this._isAssumedMetalDriver=t??!0}return this._isAssumedMetalDriver}get test(){}}export{c as RenderingContext};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{EventEmitter as n}from"../../../../core/Evented.js";import r from"../../../../core/Logger.js";import{isPromiseLike as i,isAbortError as a}from"../../../../core/promiseUtils.js";import{property as o,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{isUpdatableTexture as c}from"./IManagedTexture.js";import{TextureUpdater as l}from"./TextureUpdater.js";import{TaskPriority as u}from"../../../support/Scheduler.js";let d=class extends t{constructor(e){super({}),this._stage=e,this._textures=new Map,this._loadingCount=0,this.events=new n,this.updater=new l,this._frameTask=e.view.resourceController.scheduler.registerTask(u.TEXTURE_UNLOAD)}normalizeCtorArgs(){return{}}destroy(){this._frameTask.remove(),this.updater.destroy(),this._textures.forEach(e=>e.unload())}get updating(){return this._loadingCount>0||this._frameTask.updating}acquire(e){let t=this._textures.get(e);return t?(t.ref(),t.loadingPromise??t):this._createNewRef(e)}update(){this.updater.run()&&this.events.emit(`changed`,0)}_createNewRef(e){let t=this._stage.getTexture(e);if(t==null)return null;let n=t.events.on(`unloaded`,()=>{n.remove(),this._onTextureUnloaded(t)}),o=new f(t,()=>{this._frameTask.schedule(()=>{o.isUnreferenced&&t.unload()})});return this._textures.set(e,o),o.ref(),t.loaded?(this._updateGLTexture(o,t.texture),c(t)&&this.updater.add(t),o):(this._loadingCount++,o.loadingPromise=this._stage.schedule(()=>{let e=t.load(this._stage.renderView.renderingContext),n=e=>(this._loadingCount--,o.loadingPromise=null,this._updateGLTexture(o,e),c(t)&&this.updater.add(t),o);return i(e)?e.then(n,e=>(t.unload(),this._loadingCount--,o.loadingPromise=null,a(e)||r.getLogger(this).error(e),null)):n(e)}),o.loadingPromise)}_updateGLTexture(e,t){e.texture=t,this.events.emit(`changed`,1)}_onTextureUnloaded(e){this._textures.delete(e.id),this.updater.remove(e)}};e([o()],d.prototype,`_loadingCount`,void 0),e([o()],d.prototype,`_frameTask`,void 0),e([o()],d.prototype,`updating`,null),d=e([s(`esri.views.3d.webgl-engine.lib.TextureRepository`)],d);class f{constructor(e,t){this._texture=e,this._release=t,this._refCount=0}get id(){return this._texture.id}get isUnreferenced(){return this._refCount===0}ref(){++this._refCount}release(){--this._refCount
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{EventEmitter as n}from"../../../../core/Evented.js";import r from"../../../../core/Logger.js";import{isPromiseLike as i,isAbortError as a}from"../../../../core/promiseUtils.js";import{property as o,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{isUpdatableTexture as c}from"./IManagedTexture.js";import{TextureUpdater as l}from"./TextureUpdater.js";import{TaskPriority as u}from"../../../support/Scheduler.js";let d=class extends t{constructor(e){super({}),this._stage=e,this._textures=new Map,this._loadingCount=0,this.events=new n,this.updater=new l,this._frameTask=e.view.resourceController.scheduler.registerTask(u.TEXTURE_UNLOAD)}normalizeCtorArgs(){return{}}destroy(){this._frameTask.remove(),this.updater.destroy(),this._textures.forEach(e=>e.unload())}get updating(){return this._loadingCount>0||this._frameTask.updating}acquire(e){let t=this._textures.get(e);return t?(t.ref(),t.loadingPromise??t):this._createNewRef(e)}update(){this.updater.run()&&this.events.emit(`changed`,0)}_createNewRef(e){let t=this._stage.getTexture(e);if(t==null)return null;let n=t.events.on(`unloaded`,()=>{n.remove(),this._onTextureUnloaded(t)}),o=new f(t,()=>{this._frameTask.schedule(()=>{o.isUnreferenced&&t.unload()})});return this._textures.set(e,o),o.ref(),t.loaded?(this._updateGLTexture(o,t.texture),c(t)&&this.updater.add(t),o):(this._loadingCount++,o.loadingPromise=this._stage.schedule(()=>{let e=t.load(this._stage.renderView.renderingContext),n=e=>(this._loadingCount--,o.loadingPromise=null,this._updateGLTexture(o,e),c(t)&&this.updater.add(t),o);return i(e)?e.then(n,e=>(t.unload(),this._loadingCount--,o.loadingPromise=null,a(e)||r.getLogger(this).error(e),null)):n(e)}),o.loadingPromise)}_updateGLTexture(e,t){e.texture=t,this.events.emit(`changed`,1)}_onTextureUnloaded(e){this._textures.delete(e.id),this.updater.remove(e)}};e([o()],d.prototype,`_loadingCount`,void 0),e([o()],d.prototype,`_frameTask`,void 0),e([o()],d.prototype,`updating`,null),d=e([s(`esri.views.3d.webgl-engine.lib.TextureRepository`)],d);class f{constructor(e,t){this._texture=e,this._release=t,this._refCount=0}get id(){return this._texture.id}get isUnreferenced(){return this._refCount===0}ref(){++this._refCount}release(){--this._refCount,this._refCount>0||(this._refCount===0?this._release():(r.getLogger(`esri.views.3d.webgl-engine.lib.TextureRepository.RefCountedTextureImpl`).error(`Cannot dereference texture that has no references!`),this._refCount=0))}unload(){this._texture.unload()}}export{d as TextureRepository};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import e from"../../../../core/PooledArray.js";import{fromTranslation as t,multiply as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{transformMat4Z as i,transformMat4 as a}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{lerp as o}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{intersectsSphere as c}from"../../../../geometry/support/frustumPlanes.js";import{Sphere as l}from"../../../../geometry/support/sphere.js";import{maxScale as u}from"../../support/mathUtils.js";import{DepthRange as d}from"./DepthRange.js";import{assert as f}from"./Util.js";function p(e,t,n,r){let i=0;if(!t.some(e=>e.material?(i+=e.numGeometries,i>=1e4):!1))return j.compute(e,t,r);let a=new d;return n.forEach(t=>a.union(m(e,t))),a}function m(e,t){if(!t.visible)return;let n=new d,r=t.getSpatialQueryAccelerator();return r?h(n,e,r):g(n,e,t.objects),n}function h(e,t,n){let{eye:r,viewForward:i,frustum:a}=t,o=e=>e.visible,s=n.objectCount;if(s<500)k.set(t.near,Math.min(e.near,t.far)),n.forEachInDepthRange(r,i,1,k,(n,r)=>{_(e,t,n),k.far=e.near,r.setRange(k)},a,o),k.set(Math.max(e.far,t.near),t.far),n.forEachInDepthRange(r,i,-1,k,(n,r)=>{_(e,t,n),k.near=e.far,r.setRange(k)},a,o);else{let r=Math.max(Math.min(s,500),Math.ceil(s*.1)),c=n.findClosest(i,1,a,o,r),l=n.findClosest(i,-1,a,o,r);c&&l&&(y(e,t,c.boundingVolumeWorldSpace.sphere),y(e,t,l.boundingVolumeWorldSpace.sphere))}}function g(e,t,n){A.clear(),n.forEach(e=>{e.visible&&e.geometries.length!==0&&A.add(e,t)})
|
|
2
|
+
import e from"../../../../core/PooledArray.js";import{fromTranslation as t,multiply as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{transformMat4Z as i,transformMat4 as a}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{lerp as o}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{intersectsSphere as c}from"../../../../geometry/support/frustumPlanes.js";import{Sphere as l}from"../../../../geometry/support/sphere.js";import{maxScale as u}from"../../support/mathUtils.js";import{DepthRange as d}from"./DepthRange.js";import{assert as f}from"./Util.js";function p(e,t,n,r){let i=0;if(!t.some(e=>e.material?(i+=e.numGeometries,i>=1e4):!1))return j.compute(e,t,r);let a=new d;return n.forEach(t=>a.union(m(e,t))),a}function m(e,t){if(!t.visible)return;let n=new d,r=t.getSpatialQueryAccelerator();return r?h(n,e,r):g(n,e,t.objects),n}function h(e,t,n){let{eye:r,viewForward:i,frustum:a}=t,o=e=>e.visible,s=n.objectCount;if(s<500)k.set(t.near,Math.min(e.near,t.far)),n.forEachInDepthRange(r,i,1,k,(n,r)=>{_(e,t,n),k.far=e.near,r.setRange(k)},a,o),k.set(Math.max(e.far,t.near),t.far),n.forEachInDepthRange(r,i,-1,k,(n,r)=>{_(e,t,n),k.near=e.far,r.setRange(k)},a,o);else{let r=Math.max(Math.min(s,500),Math.ceil(s*.1)),c=n.findClosest(i,1,a,o,r),l=n.findClosest(i,-1,a,o,r);c&&l&&(y(e,t,c.boundingVolumeWorldSpace.sphere),y(e,t,l.boundingVolumeWorldSpace.sphere))}}function g(e,t,n){A.clear(),n.forEach(e=>{e.visible&&e.geometries.length!==0&&A.add(e,t)}),A.empty||(A.sort(),k.set(t.near,Math.min(e.near,t.far)),A.forEachInDepthRange(k,1,(n,r)=>{r<e.near&&_(e,t,n)}),k.set(Math.max(e.far,t.near),t.far),A.forEachInDepthRange(k,-1,(t,n,r)=>{e.far=Math.max(e.far,r)}))}function _(e,r,i){if(!i.visible||!c(r.frustum,i.boundingVolumeWorldSpace.sphere))return;let a=i.transformation,o=O;i.geometries.forEach(i=>{i.type===0?n(o,a,i.transformation):t(o,i.localOrigin.vec3);let s=u(o);v(e,r,i.boundingInfo,o,s)})}function v(e,t,n,r,i){if(n==null)return;a(D.center,n.sphere.center,r);let{eye:o,viewForward:s}=t,l=s[0]*(D.center[0]-o[0])+s[1]*(D.center[1]-o[1])+s[2]*(D.center[2]-o[2]);if(D.radius=n.sphere.radius*i,!(l-D.radius>e.near&&l+D.radius<e.far)&&c(t.frustum,D)){if(n.sphere.radius>100&&n.children)for(let a of n.children)v(e,t,a,r,i);else M.unionDepthRangeWithAABB(e,t.viewProjectionMatrix,r,n.box)}}function y(e,t,n){let r=t.eye,i=t.viewForward,a=(n.center[0]-r[0])*i[0]+(n.center[1]-r[1])*i[1]+(n.center[2]-r[2])*i[2];e.near=Math.min(e.near,a-n.radius),e.far=Math.max(e.far,a+n.radius)}class b{constructor(){this._items=new e({allocator:e=>e||{object:null,distance:0,near:0,far:0},deallocator:e=>(e.object=null,e.distance=0,e.near=0,e.far=0,e)})}get length(){return this._items.length}get empty(){return this._items.length===0}clear(){this._items.clear()}add(e,t){let n=t.eye,r=t.viewForward,i=e.boundingVolumeWorldSpace.sphere,a=(i.center[0]-n[0])*r[0]+(i.center[1]-n[1])*r[1]+(i.center[2]-n[2])*r[2];if(!Number.isFinite(a))return;let o=this._items.pushNew();o.object=e,o.distance=a,o.near=a-i.radius,o.far=a+i.radius}sort(){this._items.sort((e,t)=>e.distance-t.distance)}forEachInDepthRange(e,t,n){if(t===1)for(let t=0;t<this._items.length;++t){let r=this._items.data[t];r.far<e.near||r.near>e.far||n(r.object,r.near,r.far)}else for(let t=this._items.length-1;t>=0;--t){let r=this._items.data[t];r.far<e.near||r.near>e.far||n(r.object,r.near,r.far)}}}class x{constructor(){this._geometries=[],this._near=[],this._far=[],this._nearCandidates=[],this._farCandidates=[],this._looseRange=new d(0,0)}compute(e,n,r){this._reset();let{viewMatrix:a}=e;n.forEach(e=>{e.forEachGeometry(e=>{if(!e.visible||r===0&&!e.castShadow)return;let t=e.boundingSphere,n=i(t.center,a),o=n-t.radius,s=n+t.radius;this._geometries.push(e),this._near.push(-s),this._far.push(-o)})});let o=new d;if(this._geometries.length===0)return o;for(let e=0;e<this._geometries.length;++e)this._near[e]>o.far&&(o.far=this._near[e]),this._near[e]>2&&this._far[e]<o.near&&(o.near=this._far[e]);let s=this._looseRange;s.near=Math.max(o.near*.5,2),s.far=o.far*2;let c=0,l=0;for(let e=0;e<this._geometries.length;++e)this._near[e]<o.near&&(this._near[e]>=s.near?o.near=this._near[e]:this._nearCandidates[c++]=e),this._far[e]>o.far&&(this._far[e]<=s.far?o.far=this._far[e]:this._farCandidates[l++]=e);if(this._nearCandidates.length===0&&this._farCandidates.length===0)return o;this._nearCandidates.sort((e,t)=>this._near[e]<this._near[t]?-1:+(this._near[e]>this._near[t])),this._farCandidates.sort((e,t)=>this._far[e]<this._far[t]?1:this._far[e]>this._far[t]?-1:0);for(let n=0;n<this._nearCandidates.length;++n){let r=this._nearCandidates[n];if(this._near[r]<o.near){let n=this._geometries[r],{boundingInfo:i}=n,a=n.type===0?n.shaderTransformation:t(O,n.localOrigin.vec3);this._includeNearBoundingInfoRec(e,i,a,o)}}for(let n=0;n<this._farCandidates.length;++n){let r=this._farCandidates[n];if(this._far[r]>o.far){let n=this._geometries[r],{boundingInfo:i}=n,a=n.type===0?n.shaderTransformation:t(O,n.localOrigin.vec3);this._includeFarBoundingInfoRec(e,i,a,o)}}return this._reset(),o}_reset(){this._geometries.length=0,this._near.length=0,this._far.length=0,this._nearCandidates.length=0,this._farCandidates.length=0}_isOutsideSidePlanes(e,t){let{center:n,radius:r}=e;return t[0][0]*n[0]+t[0][1]*n[1]+t[0][2]*n[2]+t[0][3]>r||t[1][0]*n[0]+t[1][1]*n[1]+t[1][2]*n[2]+t[1][3]>r||t[2][0]*n[0]+t[2][1]*n[1]+t[2][2]*n[2]+t[2][3]>r||t[3][0]*n[0]+t[3][1]*n[1]+t[3][2]*n[2]+t[3][3]>r}_includeNearBoundingInfoRec(e,t,n,r){if(t==null)return;a(D.center,t.sphere.center,n),D.radius=t.sphere.radius*u(n);let{frustum:o}=e;if(this._isOutsideSidePlanes(D,o))return;let s=D.radius,{viewMatrix:c}=e,l=i(D.center,c),d=l-s,f=l+s;if(!(-d<2)&&!(-f>=r.near)){if(-f>this._looseRange.near)r.near=-f;else{if(s>100){let i=t.children;if(i!==void 0){for(let t of i)this._includeNearBoundingInfoRec(e,t,n,r);return}}M.unionDepthRangeWithAABB(r,e.viewProjectionMatrix,n,t.box)}}}_includeFarBoundingInfoRec(e,t,n,r){if(t==null)return;a(D.center,t.sphere.center,n),D.radius=t.sphere.radius*u(n);let{frustum:o}=e;if(this._isOutsideSidePlanes(D,o))return;let{viewMatrix:s,viewProjectionMatrix:c}=e,l=i(D.center,s)-D.radius;if(!(-l<=r.far)){if(-l<this._looseRange.far)r.far=-l;else{if(D.radius>100){let i=t.children;if(i!==void 0){for(let t of i)this._includeFarBoundingInfoRec(e,t,n,r);return}}M.unionDepthRangeWithAABB(r,c,n,t.box)}}}}class S{constructor(){this._modelViewProj=r(),this._clipPosition=[s(),s(),s(),s(),s(),s(),s(),s()]}unionDepthRangeWithAABB(e,t,r,i){let a=this._modelViewProj;n(a,t,r);let o=!1;for(let e=0;e<8;++e){let t=this._clipPosition[e],n=e===0||e===3||e===4||e===7?i[0]:i[3],r=e===0||e===1||e===4||e===5?i[1]:i[4],o=e<4?i[2]:i[5];t[0]=a[0]*n+a[4]*r+a[8]*o+a[12],t[1]=a[1]*n+a[5]*r+a[9]*o+a[13],t[2]=a[2]*n+a[6]*r+a[10]*o+a[14],t[3]=a[3]*n+a[7]*r+a[11]*o+a[15]}for(let t=0;t<12;++t){let n=this._clipPosition[E[t][0]],r=this._clipPosition[E[t][1]],i=this._clipPosition[E[t][2]],a=C(n,r,i),s=!0;for(let e=0;e<a.length;++e)if(a[e][3]>=2){s=!1;break}if(!s){o=!0;for(let t=0;t<a.length;++t){let n=a[t][3];Number.isFinite(n)&&(e.near=Math.min(n,e.near),e.far=Math.max(n,e.far))}}}return o}}function C(e,t,n){let r=[e,t,n];for(let e=0;e<4;++e){let t=r;r=[];for(let n=0;n<t.length;++n){let i=t[n],a=t[(n+1)%t.length];w(a,e)?(w(i,e)||r.push(T(i,a,e)),r.push(a)):w(i,e)&&r.push(T(i,a,e))}}return r}function w(e,t){if(t===0)return e[0]>=-e[3];if(t===1)return e[1]>=-e[3];if(t===2)return e[0]<=e[3];if(t===3)return e[1]<=e[3];f(!1)}function T(e,t,n){let r=0;return n===0?r=(-e[3]-e[0])/(t[0]-e[0]+t[3]-e[3]):n===1?r=(-e[3]-e[1])/(t[1]-e[1]+t[3]-e[3]):n===2?r=(e[3]-e[0])/(t[0]-e[0]-t[3]+e[3]):n===3&&(r=(e[3]-e[1])/(t[1]-e[1]-t[3]+e[3])),o(s(),e,t,r)}const E=[[0,1,3],[2,3,1],[1,5,2],[6,2,5],[5,4,6],[7,6,4],[4,0,7],[3,7,0],[3,2,7],[6,7,2],[4,5,0],[1,0,5]],D=new l,O=r(),k=new d,A=new b,j=new x,M=new S;export{p as depthRangeFromScene};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import e from"../../../../core/PooledArray.js";import{createScreenPointArray as t}from"../../../../core/screenUtils.js";import{distance as n,copy as r,set as i,transformMat4 as a,squaredDistance as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as c,create as l}from"../../../../geometry/support/aaBoundingBox.js";import{intersectsTransformedAabb as u}from"../../../../geometry/support/frustumPlanes.js";import{clipPolygon as d}from"../../../../geometry/support/plane.js";import{normalFromValues as f,closestPointFromValues as p}from"../../../../geometry/support/triangle.js";import{boundingInfoSubdivisionThreshold as m}from"./intersectionConstants.js";import{screenPolygonIntersectsTriangle as h}from"./screenPolygonOverlapUtils.js";class g{constructor(e){this.primitiveIndex=e}}class _{constructor(e){this.type=e,this.distance=1/0,this.renderDistance=1/0,this.primitiveIndex=0,this.hasNormal=!1,this.point=s(),this.normal=s()}reset(){this.distance=1/0,this.renderDistance=1/0,this.hasNormal=!1}update(e,t,n,i,a=e){this.distance=e,this.renderDistance=a,this.primitiveIndex=t,r(this.point,n),this.hasNormal=i!=null,i!=null&&r(this.normal,i)}updateIfCloserFromValues(e,t,n,r,i=e){i<this.renderDistance&&this.update(e,t,n,r,i)}updateIfCloser(e){let{distance:t,renderDistance:n,primitiveIndex:r,point:i,normal:a}=e;this.updateIfCloserFromValues(t,r,i,e.hasNormal?a:null,n)}get valid(){return Number.isFinite(this.distance)}}function v(e,t,n,r,i){if(!e.visible)return null;let a=new _(4),o;o=e.boundingInfo?b(e.readPrimitivePosition,e.boundingInfo,t,n,r,i):y(t,n,r,0,e.faceCount,e.readPrimitivePosition,i,null,0);for(let e of o)a.updateIfCloser(e);return a.valid?a:null}function*y(e,t,r,i,a,o,s,c=null,l=0){if(e.camera==null)return;let{camera:u,screenPolygonPrimitiveProcessor:
|
|
2
|
+
import e from"../../../../core/PooledArray.js";import{createScreenPointArray as t}from"../../../../core/screenUtils.js";import{distance as n,copy as r,set as i,transformMat4 as a,squaredDistance as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as c,create as l}from"../../../../geometry/support/aaBoundingBox.js";import{intersectsTransformedAabb as u}from"../../../../geometry/support/frustumPlanes.js";import{clipPolygon as d}from"../../../../geometry/support/plane.js";import{normalFromValues as f,closestPointFromValues as p}from"../../../../geometry/support/triangle.js";import{boundingInfoSubdivisionThreshold as m}from"./intersectionConstants.js";import{screenPolygonIntersectsTriangle as h}from"./screenPolygonOverlapUtils.js";class g{constructor(e){this.primitiveIndex=e}}class _{constructor(e){this.type=e,this.distance=1/0,this.renderDistance=1/0,this.primitiveIndex=0,this.hasNormal=!1,this.point=s(),this.normal=s()}reset(){this.distance=1/0,this.renderDistance=1/0,this.hasNormal=!1}update(e,t,n,i,a=e){this.distance=e,this.renderDistance=a,this.primitiveIndex=t,r(this.point,n),this.hasNormal=i!=null,i!=null&&r(this.normal,i)}updateIfCloserFromValues(e,t,n,r,i=e){i<this.renderDistance&&this.update(e,t,n,r,i)}updateIfCloser(e){let{distance:t,renderDistance:n,primitiveIndex:r,point:i,normal:a}=e;this.updateIfCloserFromValues(t,r,i,e.hasNormal?a:null,n)}get valid(){return Number.isFinite(this.distance)}}function v(e,t,n,r,i){if(!e.visible)return null;let a=new _(4),o;o=e.boundingInfo?b(e.readPrimitivePosition,e.boundingInfo,t,n,r,i):y(t,n,r,0,e.faceCount,e.readPrimitivePosition,i,null,0);for(let e of o)a.updateIfCloser(e);return a.valid?a:null}function*y(e,t,r,i,a,o,s,c=null,l=0){if(e.camera==null)return;let{camera:u,screenPolygonPrimitiveProcessor:d}=e;for(let e=i;e<a;++e){let i=(c?.[e]??e)+l,a=c==null?i:e,p=i*3;x(T[0],o,p+0,s,a,t),x(T[1],o,p+1,s,a,t),x(T[2],o,p+2,s,a,t);let m=j,h;N.reset();let g=E;for(let e of d.processTriangle(T))S(r,e,u,g)&&(C(u.eye,g,A),h??=f(j,T[0],T[1],T[2]),N.updateIfCloserFromValues(n(u.eye,A),i,A,h?m:null));N.valid&&(yield N)}}function*b(e,t,n,r,i,a){let o;if(a==null?o=u(i.broadPhaseFrustum,t.box,r):(c(w,t.box),a.applyToAabb(w),o=u(i.broadPhaseFrustum,w,r)),!o)return;let{primitiveIndices:s}=t,l=s.length;if(l>m){let o=t.children;if(o!==void 0){for(let t of o)yield*b(e,t,n,r,i,a);return}}yield*y(n,r,i,0,l,e,a,s,0)}function x(e,t,n,r,o,s){let[c,l,u]=t(e,n);r==null?i(e,c,l,u):r.applyToVertex(e,c,l,u,o),s&&a(e,e,s)}function S(e,t,n,r){if(r.length=0,d(n.frustum[4],t,()=>r.pushNew()),r.length<3)return!1;let i=D,a=O,o=k;n.projectToScreen(r.data[0],i),n.projectToScreen(r.data[1],a);for(let t=2;t<r.length;t++){if(n.projectToScreen(r.data[t],o),h(e,i,a,o))return!0;let s=a;a=o,o=s}return!1}function C(e,t,n){let i=1/0,a=t.at(0);for(let s=1;s<t.length-1;s++){p(M,e,a,t.at(s),t.at(s+1));let c=o(e,M);c<i&&(i=c,r(n,M))}}const w=l(),T=[s(),s(),s()],E=new e({allocator:e=>e??s()}),D=t(),O=t(),k=t(),A=s(),j=s(),M=s(),N=new _(4);export{g as DrapedHit,_ as Hit,y as forEachTriangleRangeScreenPolygonHit,S as intersectConvexPolygonWithScreenPolygon,v as intersectTriangleGeometryWithScreenPolygon};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{set as e,scale as t,add as n}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as r,create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as a,fromValues as o}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{center as s,scale as c}from"../../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as l}from"../../../../geometry/support/buffer/BufferView.js";import{isColorOrOLID as u,isDepth as d,is2DGeometryOutput as f}from"../core/shaderLibrary/ShaderOutput.js";import p from"../lib/GLMaterial.js";import{intersectTriangleGeometry as m}from"../lib/RayIntersections.js";import{
|
|
2
|
+
import{set as e,scale as t,add as n}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as r,create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as a,fromValues as o}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{center as s,scale as c}from"../../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as l}from"../../../../geometry/support/buffer/BufferView.js";import{isColorOrOLID as u,isDepth as d,is2DGeometryOutput as f}from"../core/shaderLibrary/ShaderOutput.js";import p from"../lib/GLMaterial.js";import{intersectTriangleGeometry as m}from"../lib/RayIntersections.js";import{intersectTriangleGeometryWithScreenPolygon as h}from"../lib/screenPolygonTriangleIntersections.js";import{assert as g}from"../lib/Util.js";import{applyPolygonOffsetToHit as _,intersectWithPolygonOffset as v}from"./intersectWithPolygonOffset.js";import{TriangleMaterial as y}from"./TriangleMaterial.js";import{VisualVariablePassParameters as b}from"./VisualVariablePassParameters.js";import{writeAttributes as x,writePosition as S}from"./internal/bufferWriterUtils.js";import{getLayout as C,ColorMaterialTechnique as w}from"../shaders/ColorMaterialTechnique.js";import{ColorMaterialTechniqueConfiguration as T}from"../shaders/ColorMaterialTechniqueConfiguration.js";import{alphaCutoff as E}from"../../../../webscene/support/AlphaCutoff.js";class D extends y{constructor(e){super(e,k),this._configuration=new T,this.supportsEdges=!0,this._pp0=r(0,0,1),this._pp1=r(0,0,0),this.produces=new Map([[2,e=>this._isOpaqueMaterialPass(e)],[3,e=>!this.parameters.shadingEnabled&&this._isOpaqueNoSSAODepthPass(e)],[4,e=>u(e)&&this.transparent&&this.parameters.writeDepth],[5,e=>!this.parameters.shadingEnabled&&d(e)&&this.transparent&&this.parameters.writeDepth],[8,e=>u(e)&&this.transparent&&!this.parameters.writeDepth],[18,e=>f(e)]])}updateConfiguration(e){super.updateConfiguration(e),this._configuration.cullFace=this.parameters.cullFace,this._configuration.hasVertexColors=this.parameters.hasVertexColors&&!this.parameters.vvColor,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.hasOccludees=e.hasOccludees,this._configuration.hasVVColor=!!this.parameters.vvColor,this._configuration.draped=this.parameters.draped,this._configuration.shadingEnabled=this.parameters.shadingEnabled,this._configuration.screenSizeEnabled=this.parameters.screenSizeEnabled,this._configuration.emissionSource=+!!this.emissions}get visible(){return this.parameters.color[3]>=E}get transparent(){return this.parameters.color[3]<1||this.parameters.forceTransparentMode}get emissions(){return this.parameters.emissiveStrength>0?this.transparent?2:1:0}intersectRay(e,t,n,r,i,a){if(!this.parameters.screenSizeEnabled)return super.intersectRay(e,t,n,r,i,a);this._intersectScreenSizeRay(e,n,r,i,a)}intersectRayDraped(e,t,n,r){if(!this.parameters.screenSizeEnabled)return super.intersectRayDraped(e,t,n,r);this._pp0[0]=this._pp1[0]=n[0],this._pp0[1]=this._pp1[1]=n[1],this._intersectScreenSizeRay(e,t,this._pp0,this._pp1,r)}intersectScreenPolygon(e,t,n,r){return this.parameters.screenSizeEnabled?_(h(e,n,t,r,this._createScreenSizeVertexDisplacement(e,n)),this._configuration,n.camera.eye):super.intersectScreenPolygon(e,t,n,r)}_intersectScreenSizeRay(e,t,n,r,i){m(e,t,n,r,this._createScreenSizeVertexDisplacement(e,t),v(i,this._configuration,n,r))}_createScreenSizeVertexDisplacement(r,i){let a=r.attributes.get(`offset`).data;return{applyToVertex:(r,o,s,c,l)=>{let u=e(j,a[l*3],a[l*3+1],a[l*3+2]);e(r,o,s,c);let d=this.parameters.screenSizeScale*(i.camera?.computeScreenPixelSizeAt(u)??1);return t(u,u,d),n(r,r,u),r},applyToAabb:e=>{let t=s(e,j);return c(e,this.parameters.screenSizeScale*(i.camera?.computeScreenPixelSizeAt(t)??1))}}}_isOpaqueMaterialPass(e){return e===10||u(e)&&!this.transparent}_isOpaqueNoSSAODepthPass(e){return d(e)&&this.parameters.writeDepth&&!this.transparent}createGLMaterial(e){return new O(e)}createBufferWriter(){return new A(C(this.parameters))}}class O extends p{beginSlot(e){return this.getTechnique(w,e)}}class k extends b{constructor(){super(...arguments),this.color=a,this.shadingTint=o(0,0,0,.25),this.forceTransparentMode=!1,this.writeDepth=!0,this.hasVertexColors=!1,this.polygonOffset=0,this.hasSlicePlane=!1,this.cullFace=0,this.draped=!1,this.shadingEnabled=!1,this.screenSizeEnabled=!1,this.screenSizeScale=14,this.useIndexing=!1}}class A{constructor(e){this.layout=e}elementCount(e){return e.get(`position`).indices.length}write(e,t,n,r){if(r==null)return;x(n,this.layout,e,t,r);let i=r.buffer.getField(`offset`,l);if(i&&n.has(`offset`)){let e=n.get(`offset`);g(e.size===3),S(e,t,i,r.offset)}}}const j=i();export{D as ColorMaterial,k as Parameters};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{exactEquals as e,subtract as t,add as n,set as r,copy as i,normalize as a,length as o,scale as s,dot as c,transformMat3 as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as u,create as d,fromValues as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{setMin as p,getMin as m,setMax as h,getMax as g}from"../../../../geometry/support/aaBoundingBox.js";import{is3DGeometryOrShadowLike as _,isColor as v}from"../core/shaderLibrary/ShaderOutput.js";import{GLTextureMaterial as y}from"../lib/GLTextureMaterial.js";import{Material as b}from"../lib/Material.js";import{intersectTriangleGeometry as x}from"../lib/RayIntersections.js";import{
|
|
2
|
+
import{exactEquals as e,subtract as t,add as n,set as r,copy as i,normalize as a,length as o,scale as s,dot as c,transformMat3 as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as u,create as d,fromValues as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{setMin as p,getMin as m,setMax as h,getMax as g}from"../../../../geometry/support/aaBoundingBox.js";import{is3DGeometryOrShadowLike as _,isColor as v}from"../core/shaderLibrary/ShaderOutput.js";import{GLTextureMaterial as y}from"../lib/GLTextureMaterial.js";import{Material as b}from"../lib/Material.js";import{intersectTriangleGeometry as x}from"../lib/RayIntersections.js";import{intersectTriangleGeometryWithScreenPolygon as S}from"../lib/screenPolygonTriangleIntersections.js";import{getVerticalOffsetObject3D as C}from"../lib/verticalOffsetUtils.js";import{DefaultBufferWriter as w}from"./DefaultBufferWriter.js";import{intersectWithPolygonOffset as T,applyPolygonOffsetToHit as E}from"./intersectWithPolygonOffset.js";import{verticalOffsetAtDistance as D}from"./internal/MaterialUtil.js";import{getLayout as O,DefaultMaterialPassParameters as k,DefaultMaterialTechnique as A}from"../shaders/DefaultMaterialTechnique.js";import{DefaultMaterialTechniqueConfiguration as j}from"../shaders/DefaultMaterialTechniqueConfiguration.js";import{RealisticTreeTechnique as M}from"../shaders/RealisticTreeTechnique.js";import{hasShadowHighlights as N}from"../shaders/ReceiveShadowsConfiguration.js";import{alphaCutoff as P}from"../../../../webscene/support/AlphaCutoff.js";class F extends b{constructor(e,t){super(e,L),this.materialType=`default`,this.supportsEdges=!0,this.intersectRayDraped=void 0,this.intersectScreenPolygonDraped=void 0,this.produces=new Map([[2,e=>_(e)&&!this.transparent],[4,e=>_(e)&&this.transparent]]),this._layout=O(this.parameters),this._configuration=new j(t.spherical)}isVisibleForOutput(e){return e===5||e===7||e===6?this.parameters.castShadows:!0}get visible(){let{layerOpacity:e,colorMixMode:t,opacity:n,externalColor:r}=this.parameters,i=t===`replace`?1:n,a=t===`ignore`||isNaN(r[3])?1:r[3];return e*i*a>=P}get _hasEmissiveBase(){return!!this.parameters.emissiveTextureId||!e(this.parameters.emissiveBaseColor,u)}get emissions(){return this.parameters.emissiveStrength>0&&(this.parameters.emissiveSource===0&&this._hasEmissiveBase||this.parameters.emissiveSource===1)?this.transparent?2:1:0}updateConfiguration(e){super.updateConfiguration(e);let{parameters:t,_configuration:n}=this;n.hasNormalTexture=t.hasNormalTexture,n.hasColorTexture=t.hasColorTexture,n.hasMetallicRoughnessTexture=t.hasMetallicRoughnessTexture,n.hasOcclusionTexture=t.hasOcclusionTexture;let{treeRendering:r,doubleSided:i,doubleSidedType:a}=t;n.hasVertexTangents=!r&&t.hasVertexTangents,n.instanced=t.instanced,n.instancedDoublePrecision=t.instancedDoublePrecision,n.hasVVColor=!!t.vvColor,n.hasVVSize=!!t.vvSize,n.hasVerticalOffset=t.verticalOffset!=null,n.hasScreenSizePerspective=t.screenSizePerspective!=null,n.hasSlicePlane=t.hasSlicePlane,n.alphaDiscardMode=t.textureAlphaMode,n.normalType=r?0:t.normalType,n.transparent=this.transparent,n.enableOITOffset=e.enableOITOffset,n.customDepthTest=t.customDepthTest??0,n.hasOccludees=e.hasOccludees,n.cullFace=t.hasSlicePlane?0:t.cullFace,n.hasModelTransformation=!r&&t.modelTransformation!=null,n.hasVertexColors=t.hasVertexColors,n.hasSymbolColors=t.hasSymbolColors,n.doubleSidedMode=r?2:i&&a===`normal`?1:i&&a===`winding-order`?2:0,n.instancedFeatureAttribute=t.instancedFeatureAttribute,n.instancedColor=t.instancedColor,v(e.output)?(n.receiveShadows=t.receiveShadows,n.hasShadowHighlights=N(n,e),n.receiveAmbientOcclusion=t.receiveAmbientOcclusion&&e.ssao!=null,n.receiveGlobalIllumination=t.receiveAmbientOcclusion&&e.globalIlluminationEnabled):n.receiveShadows=n.hasShadowHighlights=n.receiveAmbientOcclusion=n.receiveGlobalIllumination=!1,n.textureAlphaPremultiplied=!!t.textureAlphaPremultiplied,n.pbrMode=t.usePBR?t.unlit?7:t.isSchematic?2:1:0,n.emissionSource=t.emissionSource,n.offsetBackfaces=!!(this.transparent&&t.offsetTransparentBackfaces),n.snowCover=e.snowCover>0,n.hasColorTextureTransform=!!t.colorTextureTransformMatrix,n.hasNormalTextureTransform=!!t.normalTextureTransformMatrix,n.hasEmissionTextureTransform=!!t.emissiveTextureTransformMatrix,n.hasOcclusionTextureTransform=!!t.occlusionTextureTransformMatrix,n.hasMetallicRoughnessTextureTransform=!!t.metallicRoughnessTextureTransformMatrix}intersectRay(e,n,r,i,a,o){let s=this._getMaterialVerticalOffset(n,r);s!=null&&(i=t(R,i,s),a=t(z,a,s)),o=T(o,this._configuration,i,a),x(e,r,i,a,C(r.verticalOffset),o)}intersectScreenPolygon(e,t,n,r){return E(S(e,n,t,r,this._createScreenPolygonVertexDisplacement(t,n)),this._configuration,n.camera.eye)}createGLMaterial(e){return new I(e)}createBufferWriter(){return new w(this._layout)}get transparent(){let{drivenOpacity:e,opacity:t,externalColor:n,layerOpacity:r,texture:i,textureId:a,textureAlphaMode:o,colorMixMode:s}=this.parameters,c=n[3];return e||t<1&&s!==`replace`||c<1&&s!==`ignore`||r<1||(i!=null||a!=null)&&o!==1&&o!==2&&s!==`replace`}_createScreenPolygonVertexDisplacement(e,t){let r=this._getMaterialVerticalOffset(e,t);return r==null?null:{applyToVertex:(e,t,n,i)=>(e[0]=t+r[0],e[1]=n+r[1],e[2]=i+r[2],e),applyToAabb:e=>(p(e,n(G,m(e,G),r)),h(e,n(G,g(e,G),r)),e)}}_getMaterialVerticalOffset(e,n){if(this.parameters.verticalOffset==null)return null;let u=n.camera;r(H,e[12],e[13],e[14]);let d=null;switch(n.viewingMode){case 1:d=a(V,H);break;case 2:d=i(V,B)}let f=t(U,H,u.eye),p=o(f),m=s(f,f,1/p),h=null;this.parameters.screenSizePerspective&&(h=c(d,m));let g=D(u,p,this.parameters.verticalOffset,h??0,this.parameters.screenSizePerspective,null);return s(d,d,g),l(W,d,n.transform.inverseRotation)}}class I extends y{constructor(e){super({...e,...e.material.parameters})}beginSlot(e){this._material.setParameters({receiveShadows:e.shadowMap.enabled});let t=this._material.parameters;this.updateTexture(t.textureId);let n=e.camera.viewInverseTransposeMatrix;return r(t.origin,n[3],n[7],n[11]),this._material.setParameters(this.textureBindParameters),this.getTechnique(t.treeRendering?M:A,e)}}class L extends k{constructor(){super(...arguments),this.treeRendering=!1,this.useIndexing=!1,this.hasVertexTangents=!1,this.unlit=!1}get hasNormalTexture(){return!this.treeRendering&&!!this.normalTextureId}get hasColorTexture(){return!!this.textureId}get hasMetallicRoughnessTexture(){return!this.treeRendering&&!!this.metallicRoughnessTextureId}get hasOcclusionTexture(){return!this.treeRendering&&!!this.occlusionTextureId}get emissionSource(){return this.emissiveTextureId!=null&&this.emissiveSource===0?3:this.emissiveSource===0?2:1}get hasTextures(){return this.hasColorTexture||this.hasNormalTexture||this.hasMetallicRoughnessTexture||this.emissionSource===3||this.hasOcclusionTexture}}const R=d(),z=d(),B=f(0,0,1),V=d(),H=d(),U=d(),W=d(),G=d();export{I as DefaultGLMaterial,F as DefaultMaterial,L as DefaultMaterialParameters};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{BufferViewUint32 as e,BufferViewVec3f as t,BufferViewVec2Snorm16 as n,BufferViewSnorm16 as r,BufferViewFloat16 as i,BufferViewFloat as a,BufferViewVec2f as o,BufferViewVec4Unorm8 as s,BufferViewUnorm8 as c}from"../../../../geometry/support/buffer/BufferView.js";import{maxPathFrameIndex as l}from"../../layers/graphics/Graphics3DPathSymbolLayerConstants.js";import{isShadowLike as u,is3DGeometry as d,isColor as f}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as p}from"../effects/geometry/olidUtils.js";import m from"../lib/GLMaterial.js";import{offsetPathVertexInfoFrameIndex as h}from"../lib/PathVertexInfo.js";import{intersectTriangleGeometry as g}from"../lib/RayIntersections.js";import{
|
|
2
|
+
import{BufferViewUint32 as e,BufferViewVec3f as t,BufferViewVec2Snorm16 as n,BufferViewSnorm16 as r,BufferViewFloat16 as i,BufferViewFloat as a,BufferViewVec2f as o,BufferViewVec4Unorm8 as s,BufferViewUnorm8 as c}from"../../../../geometry/support/buffer/BufferView.js";import{maxPathFrameIndex as l}from"../../layers/graphics/Graphics3DPathSymbolLayerConstants.js";import{isShadowLike as u,is3DGeometry as d,isColor as f}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as p}from"../effects/geometry/olidUtils.js";import m from"../lib/GLMaterial.js";import{offsetPathVertexInfoFrameIndex as h}from"../lib/PathVertexInfo.js";import{intersectTriangleGeometry as g}from"../lib/RayIntersections.js";import{intersectTriangleGeometryWithScreenPolygon as _}from"../lib/screenPolygonTriangleIntersections.js";import{assert as v}from"../lib/Util.js";import{applyPolygonOffsetToHit as y}from"./intersectWithPolygonOffset.js";import{getLayout as b,getTextureLayout as x}from"./PathLayouts.js";import{PathPassParameters as S,PathTechnique as C}from"./PathTechnique.js";import{PathTechniqueConfiguration as w}from"./PathTechniqueConfiguration.js";import{TriangleMaterial as T}from"./TriangleMaterial.js";import{writeAttributes as E,writePosition as D,writeBufferVec2 as O,writeBufferInt16 as k,writeBufferFloat16 as A,writeBufferFloat as j,writeColor as M,writeBufferUint8 as N}from"./internal/bufferWriterUtils.js";import{hasShadowHighlights as P}from"../shaders/ReceiveShadowsConfiguration.js";import{alphaCutoff as F}from"../../../../webscene/support/AlphaCutoff.js";class I extends T{constructor(e,t){super(e,R),this.supportsEdges=!0,this.produces=new Map([[2,e=>(this.parameters.castShadows&&u(e)||d(e))&&!this.transparent],[4,e=>(this.parameters.castShadows&&u(e)||d(e))&&this.transparent]]),this._configuration=new w(t.spherical)}get emissions(){return this.parameters.emissiveStrength>0?this.transparent?2:1:0}updateConfiguration(e){super.updateConfiguration(e),this._configuration.hasVVSize=this.parameters.hasVVSize,this._configuration.hasVVColor=this.parameters.hasVVColor,this._configuration.hasVVOpacity=this.parameters.hasVVOpacity,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.transparent=this.transparent,this._configuration.hasOccludees=e.hasOccludees,this._configuration.cullFace=this.parameters.hasSlicePlane?0:this.parameters.cullFace,this._configuration.pathJoinType=this.parameters.pathJoinType,this._configuration.offsetBackfaces=this.transparent,f(e.output)?(this._configuration.receiveShadows=e.shadowMap.enabled,this._configuration.hasShadowHighlights=P(this._configuration,e),this._configuration.receiveAmbientOcclusion=e.ssao!=null,this._configuration.receiveGlobalIllumination=e.globalIlluminationEnabled):this._configuration.receiveShadows=this._configuration.hasShadowHighlights=this._configuration.receiveAmbientOcclusion=this._configuration.receiveGlobalIllumination=!1,this._configuration.pbrMode=this.parameters.usePBR?2:0,this._configuration.emissionSource=+!!this.emissions,this._configuration.snowCover=e.snowCover>0,this._configuration.upVectorAlignment=this.parameters.upVectorAlignment,this._configuration.pathCapType=this.parameters.pathCapType,this._configuration.pathProfileType=this.parameters.profile.type,this._configuration.hasPathSize=this.parameters.hasPathSize,this._configuration.hasPathColor=this.parameters.hasPathColor,this._configuration.hasPathOpacity=this.parameters.hasPathOpacity}isVisibleForOutput(e){return e===5||e===7||e===6?this.parameters.castShadows:!0}get visible(){return this.parameters.opacity>=F}intersectRay(e,t,n,r,i,a){g(e,n,r,i,null,a)}intersectRayDraped(){}intersectScreenPolygonDraped(){return null}intersectScreenPolygon(e,t,n,r){return y(_(e,n,t,r,null),this._configuration,n.camera.eye)}createBufferWriter(){return new z(b(),x(this.parameters))}createGLMaterial(e){return new L(e)}get transparent(){return this.parameters.drivenOpacity||this.parameters.opacity<1}}class L extends m{beginSlot(e){return this.getTechnique(C,e)}}class R extends S{constructor(){super(...arguments),this.polygonOffset=0,this.castShadows=!0,this.hasSlicePlane=!1,this.drivenOpacity=!1,this.usePBR=!1,this.upVectorAlignment=0,this.pathCapType=1,this.cullFace=2,this.pathJoinType=1}}class z{constructor(e,t){this.layout=e,this.textureBufferLayout=t,this.maxTextureBufferItemIndex=l}elementCount(e){return e.get(`pathVertexInfo`)?.indices.length??0}elementCountTextureBuffer(e){return e.get(`position`)?.indices.length??0}write(e,t,n,r,i,a){r!=null&&this._writeVertexBuffer(e,t,n,r,i),a!=null&&this._writeTextureBuffer(e,n,a)}_writeVertexBuffer(t,n,r,i,a){E(r,this.layout,t,n,i);let o=a?.from??0,s=i.buffer.getField(`pathVertexInfo`,e),c=r.get(`pathVertexInfo`);if(s&&c){v(c.size===1);let{data:e,stride:t,indices:n}=c;for(let r=0;r<n.length;++r){let a=e[t*n[r]];s.set(i.offset+r,h(a,o))}}}_writeTextureBuffer(e,l,u){let d=u.offset,f=u.buffer.getField(`position`,t),m=l.get(`position`);f&&m&&(v(m.size===3),D(m,e,f,d));let h=u.buffer.getField(`profileRight`,n),g=l.get(`profileRight`);h&&g&&(v(g.size===2),O(g,h,d));let _=u.buffer.getField(`profileUp`,n),y=l.get(`profileUp`);_&&y&&(v(y.size===2),O(y,_,d));let b=u.buffer.getField(`profileRotation`,r),x=l.get(`profileRotation`);b&&x&&(v(x.size===1),k(x,b,d));let S=u.buffer.getField(`pathRotationUp`,n),C=l.get(`pathRotationUp`);S&&C&&(v(C.size===2),O(C,S,d));let w=u.buffer.getField(`pathMaxStretchDistance`,i),T=l.get(`pathMaxStretchDistance`);w&&T&&(v(T.size===1),A(T,w,d));let E=u.buffer.getField(`sizeFeatureAttribute`,a),P=l.get(`sizeFeatureAttribute`);E&&P&&j(P,E,d);let F=u.buffer.getField(`size`,o),I=l.get(`size`);F&&I&&(v(I.size===2),O(I,F,d));let L=u.buffer.getField(`colorFeatureAttribute`,a),R=l.get(`colorFeatureAttribute`);L&&R&&j(R,L,d);let z=u.buffer.getField(`color`,s),B=l.get(`color`);z&&B&&M(B,4,z,d);let V=u.buffer.getField(`opacityFeatureAttribute`,a),H=l.get(`opacityFeatureAttribute`);V&&H&&j(H,V,d);let U=u.buffer.getField(`opacity`,c),W=l.get(`opacity`);if(U&&W&&(v(W.size===1),N(W,U,d)),p()){let e=u.buffer.getField(`olidColor`,s),t=m?.indices.length??0,n=l.get(`olidColor`);n&&e&&t&&M(n,4,e,d)}}}export{R as Parameters,z as PathBufferWriter,I as PathMaterial};
|