@arcgis/core 5.1.0-next.11 → 5.1.0-next.13
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/WebScene.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/008887a8014b61f837ae.js +1 -0
- package/assets/esri/core/workers/chunks/04f82b740325e3388d23.js +1 -0
- package/assets/esri/core/workers/chunks/09cf8aed89a1ea1f8b28.js +1 -0
- package/assets/esri/core/workers/chunks/{ff2412c5be1ad4edb458.js → 0b59e5be22139387bd84.js} +1 -1
- package/assets/esri/core/workers/chunks/0bf742d48f434c4c575f.js +1 -0
- package/assets/esri/core/workers/chunks/0c8a676599821b9871c2.js +1 -0
- package/assets/esri/core/workers/chunks/11882cbb28710e5f9fc5.js +1 -0
- package/assets/esri/core/workers/chunks/{f0e7207fd2c899b9fe9f.js → 12fd2e26e949d90abfbd.js} +1 -1
- package/assets/esri/core/workers/chunks/{8c5e834c2d243fc369fe.js → 18b0776aef1536867ab8.js} +1 -1
- package/assets/esri/core/workers/chunks/{72ab3ed37ac4da355710.js → 1aa2187597f7c4adb67f.js} +1 -1
- package/assets/esri/core/workers/chunks/2216264b22a605a0f1ce.js +1 -0
- package/assets/esri/core/workers/chunks/22d12c309af9c19a1a48.js +1 -0
- package/assets/esri/core/workers/chunks/{aefc089928ada18bc4d4.js → 2762149a922275136171.js} +2 -2
- package/assets/esri/core/workers/chunks/27aa21da934ecaca381a.js +1 -0
- package/assets/esri/core/workers/chunks/{a5d3dcb490686430c81d.js → 27c8dea6154eb8c36fed.js} +1 -1
- package/assets/esri/core/workers/chunks/27d60fd727e9a68973f6.js +1 -0
- package/assets/esri/core/workers/chunks/{8fbfdd154413a2140180.js → 2a3e82a230b7ee4dfd55.js} +1 -1
- package/assets/esri/core/workers/chunks/{5aab1db039b2b61c6c6b.js → 2bb7bb7901bd343201fc.js} +1 -1
- package/assets/esri/core/workers/chunks/2d1a772abd730b61854f.js +1 -0
- package/assets/esri/core/workers/chunks/2d67ab4927a968d5c8d4.js +1 -0
- package/assets/esri/core/workers/chunks/{ee2ae61fc747b5f9827b.js → 2e7d4a437717606bc39c.js} +1 -1
- package/assets/esri/core/workers/chunks/{02f03297491eef26f113.js → 34207774bc371e95ba3c.js} +1 -1
- package/assets/esri/core/workers/chunks/360b3499e2a671c309ce.js +1 -0
- package/assets/esri/core/workers/chunks/3b0cfe3db8d90e02d6c6.js +1 -0
- package/assets/esri/core/workers/chunks/3d78e9b3c97c0ce21d16.js +1 -0
- package/assets/esri/core/workers/chunks/4550b7620932cd6de20e.js +1 -0
- package/assets/esri/core/workers/chunks/{f3022255054e8d09c38b.js → 455fbddd814e4681f0c0.js} +1 -1
- package/assets/esri/core/workers/chunks/{3db4938b3f89b9b8234e.js → 4742a8c19b86a5f859f0.js} +1 -1
- package/assets/esri/core/workers/chunks/58cf3d35771b87bd74e5.js +1 -0
- package/assets/esri/core/workers/chunks/{d84af069f1057044c879.js → 5c12a9b0db317620dce2.js} +1 -1
- package/assets/esri/core/workers/chunks/65ad8838911a6d71816b.js +1 -0
- package/assets/esri/core/workers/chunks/{7a85e08cb968586f8d74.js → 72acfb74fd9ab9bae923.js} +2 -2
- package/assets/esri/core/workers/chunks/79ee97609f72e4cf989c.js +1 -0
- package/assets/esri/core/workers/chunks/{fba30f2e1d6b364aae79.js → 7b1964255722e756eba3.js} +1 -1
- package/assets/esri/core/workers/chunks/7e6309bfed6692e8d2d7.js +2 -0
- package/assets/esri/core/workers/chunks/804c31973f7d116523cb.js +1 -0
- package/assets/esri/core/workers/chunks/{dc65843654dc25bd8f97.js → 8177e95596b71bf020aa.js} +1 -1
- package/assets/esri/core/workers/chunks/{afffb40cce91e135f092.js → 8374658d17f69bde6b08.js} +1 -1
- package/assets/esri/core/workers/chunks/879e8439a513cb333b61.js +1 -0
- package/assets/esri/core/workers/chunks/{ca767f0e3aa559b13699.js → 90aeef17af12cfbecb36.js} +1 -1
- package/assets/esri/core/workers/chunks/{4bd98d025bcd713eddca.js → 91858b02da40ff251ab2.js} +2 -2
- package/assets/esri/core/workers/chunks/{3114cbf7298239e1269d.js → 956237a2baa30760c256.js} +1 -1
- package/assets/esri/core/workers/chunks/a027da22acdaa6d6baa3.js +1 -0
- package/assets/esri/core/workers/chunks/{c064025d0dc69bb44f0d.js → a115984b794a7f90b2c0.js} +1 -1
- package/assets/esri/core/workers/chunks/a3e8b7185d63a0f85931.js +1 -0
- package/assets/esri/core/workers/chunks/{6be2dc8331ecf944efdc.js → a5af20f3d484d2d3bafe.js} +1 -1
- package/assets/esri/core/workers/chunks/b0b24fb60a21b995b348.js +1 -0
- package/assets/esri/core/workers/chunks/b6e155b42a4a423139e7.js +1 -0
- package/assets/esri/core/workers/chunks/{fb57a07b76580dcdde46.js → bc9997d15ec0a86793c6.js} +1 -1
- package/assets/esri/core/workers/chunks/{4a571a1e897c8ad359c4.js → bf2bfc0d78be8c185d58.js} +1 -1
- package/assets/esri/core/workers/chunks/bf9b2aa2e67ca746ec7c.js +1 -0
- package/assets/esri/core/workers/chunks/c9babe86c00ae69e63ee.js +2 -0
- package/assets/esri/core/workers/chunks/{da40c63408affee86ac4.js → d0d1378e714ff0e43e26.js} +1 -1
- package/assets/esri/core/workers/chunks/{940185f10c2b16612b66.js → d3416e6da0c1cbb53b3a.js} +1 -1
- package/assets/esri/core/workers/chunks/d9c1e1ec5c56f09fb82f.js +1 -0
- package/assets/esri/core/workers/chunks/d9dc3962535616a06e2f.js +1 -0
- package/assets/esri/core/workers/chunks/{4ee618a256b06221ea8f.js → da5deed75e1a170a49b3.js} +8 -8
- package/assets/esri/core/workers/chunks/{bb75ec3727b7ecabca6f.js → e4eb14952b7660feecc7.js} +1 -1
- package/assets/esri/core/workers/chunks/eaf5d55060ffc55aac39.js +1 -0
- package/assets/esri/core/workers/chunks/{9bcf8241c6b4aa42b1c5.js → ed78e19b1e400c0db309.js} +1 -1
- package/assets/esri/core/workers/chunks/f0b8de5b3cfbe9223df6.js +1 -0
- package/assets/esri/core/workers/chunks/fcf6a47f44c917490deb.js +1 -0
- package/assets/esri/core/workers/chunks/fd5a5b05a1551cdb8c87.js +1 -0
- package/assets/esri/themes/base/widgets/_FeatureTable.scss +1 -0
- package/assets/esri/themes/base/widgets/_Grid.scss +8 -1
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/config.js +1 -1
- package/core/Logger.js +1 -1
- package/core/Version.js +1 -1
- package/core/deprecate.js +1 -1
- package/core/has.js +1 -1
- package/core/iteratorUtils.js +1 -1
- package/core/sql/WhereClause.js +1 -1
- package/core/sql/WhereGrammar.js +1 -1
- package/core/sql/sqlVisitor.js +2 -0
- package/core/sql/writeUtils.js +2 -0
- package/core/sql.d.ts +2 -3
- package/core/sql.js +1 -1
- package/kernel.js +1 -1
- package/layers/ImageryLayer.d.ts +1 -1
- package/layers/MapImageLayer.d.ts +1 -1
- package/layers/TileLayer.d.ts +1 -1
- package/layers/WebTileLayer.d.ts +1 -1
- package/layers/graphics/data/QueryEngineCapabilities.js +1 -1
- package/layers/graphics/sources/FeatureLayerSource.js +1 -1
- package/layers/graphics/sources/OGCFeatureSource.js +1 -1
- package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
- package/layers/graphics/sources/support/QueryTask.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/mixins/FeatureLayerBase.js +1 -1
- package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/layers/orientedImagery/transformations/worldToImage.js +1 -1
- package/layers/raster/datasets/ImageServerRaster.js +1 -1
- package/layers/support/Sublayer.js +1 -1
- package/layers/support/arcgisLayerUrl.js +1 -1
- package/layers/support/capabilities.js +1 -1
- package/layers/support/relativeTimeQueryUtils.js +2 -0
- package/layers/support/serviceCapabilitiesUtils.js +1 -1
- package/networks/support/jsonTypes.d.ts +2 -2
- package/package.json +2 -2
- package/renderers/support/rasterRendererHelper.js +1 -1
- package/rest/print.js +1 -1
- package/support/basemapUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/support/Symbol3DEmissive.d.ts +9 -9
- package/symbols/support/Symbol3DMaterial.d.ts +8 -8
- package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
- package/views/2d/layers/features/schema/SourceSchema.js +1 -1
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderPBFHeader.js +1 -1
- package/views/3d/analysis/ShadowCast/ShadowCastTooltip.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
- package/views/3d/environment/Fog.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/VectorTileLayerView3D.js +1 -1
- package/views/3d/layers/support/featureTileQuery3D.js +1 -1
- package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
- package/views/3d/webgl/ManagedFBOResource.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/effects/RenderNodes.js +1 -1
- package/views/3d/webgl-engine/effects/blit/Blit.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
- package/views/3d/webgl-engine/lib/CutFillDepth.js +1 -1
- package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
- package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
- package/views/3d/webgl-engine/parts/renderUtils.js +1 -1
- package/views/Attribution.js +1 -1
- package/views/DOMContainer.js +1 -1
- package/views/SelectionManager.d.ts +242 -0
- package/views/View.d.ts +1 -1
- package/views/draw/DrawTool.js +1 -1
- package/views/draw/plugins/BezierSegmentPlugin.js +1 -1
- package/views/draw/plugins/CircularArcSegmentPlugin.js +2 -0
- package/views/draw/support/EditSession.js +1 -1
- package/views/draw/support/PluginContext.js +1 -1
- package/views/draw/support/managers/TooltipManager.js +1 -1
- package/views/selection/types.d.ts +140 -0
- package/views/support/selectionUtils.js +1 -1
- package/views/ui/DefaultUI.d.ts +5 -12
- package/views/ui/DefaultUI.js +1 -1
- package/views/ui/types.d.ts +1 -1
- package/webscene/SunLighting.d.ts +20 -2
- package/webscene/VirtualLighting.d.ts +20 -2
- package/webscene/support/schemaValidator.js +1 -1
- package/webscene/support/versionUtils.js +1 -1
- package/widgets/Attribution/AttributionViewModel.d.ts +1 -1
- package/widgets/Attribution.d.ts +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.d.ts +48 -0
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
- package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
- package/widgets/Editor/UpdateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/support/SketchController.js +1 -1
- package/widgets/Editor.d.ts +35 -0
- package/widgets/Editor.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.d.ts +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable.d.ts +9 -3
- package/widgets/FeatureTable.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/DataCaptureAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/services/TransformationService.js +1 -1
- package/widgets/OrientedImageryViewer/support/dataCaptureUtils.js +1 -1
- package/widgets/OrientedImageryViewer/support/geometryUtils.js +1 -1
- package/widgets/OrientedImageryViewer/support/urlUtils.js +1 -1
- package/widgets/OrientedImageryViewer/utils.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer/support/PanoramicMedia.js +1 -1
- package/widgets/Sketch/SketchViewModel.d.ts +14 -15
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch/support/OperationHandle.js +1 -1
- package/widgets/Sketch/support/PluginManager.js +1 -1
- package/widgets/Sketch/support/sketchUtils.js +1 -1
- package/widgets/Sketch.d.ts +37 -0
- package/widgets/Sketch.js +1 -1
- package/assets/esri/core/workers/chunks/012992dc3910466ed207.js +0 -1
- package/assets/esri/core/workers/chunks/0485ae33a8b327974751.js +0 -1
- package/assets/esri/core/workers/chunks/0994c12d01fe6f74350e.js +0 -1
- package/assets/esri/core/workers/chunks/13b104cc7925d4423aad.js +0 -1
- package/assets/esri/core/workers/chunks/147d0f7a2e471442c95c.js +0 -2
- package/assets/esri/core/workers/chunks/1a11ac1a34614132fabc.js +0 -1
- package/assets/esri/core/workers/chunks/1f613c599eff3b16c1d2.js +0 -1
- package/assets/esri/core/workers/chunks/2431a5480f0d22f00e00.js +0 -1
- package/assets/esri/core/workers/chunks/319226db47849acbe321.js +0 -1
- package/assets/esri/core/workers/chunks/360dd5cd63d132b5c7d5.js +0 -2
- package/assets/esri/core/workers/chunks/3e4c5cc24bdc1c807125.js +0 -1
- package/assets/esri/core/workers/chunks/504e6868445419b7680e.js +0 -1
- package/assets/esri/core/workers/chunks/545d801c4ba6f49df726.js +0 -1
- package/assets/esri/core/workers/chunks/71879de16a936a079362.js +0 -1
- package/assets/esri/core/workers/chunks/733d4ddb937c51ef3aed.js +0 -1
- package/assets/esri/core/workers/chunks/7352b4129f4875a053b0.js +0 -1
- package/assets/esri/core/workers/chunks/768ee8d940b5eb353ec3.js +0 -1
- package/assets/esri/core/workers/chunks/8556d06f522914e71bb8.js +0 -1
- package/assets/esri/core/workers/chunks/863873ffbed0cbbdfb9b.js +0 -1
- package/assets/esri/core/workers/chunks/88fe7d75dc3b619b8543.js +0 -1
- package/assets/esri/core/workers/chunks/8ac7a552189143ab4f91.js +0 -1
- package/assets/esri/core/workers/chunks/8ba1c7919e898ef4557f.js +0 -1
- package/assets/esri/core/workers/chunks/944b6d230a93add78c0d.js +0 -1
- package/assets/esri/core/workers/chunks/a37a003da59bdaf7ec0e.js +0 -1
- package/assets/esri/core/workers/chunks/ad688eee6a9f2be6df4a.js +0 -1
- package/assets/esri/core/workers/chunks/c0ae85f9c2dbe8611499.js +0 -1
- package/assets/esri/core/workers/chunks/c0cb0c22ee7fd91855cb.js +0 -1
- package/assets/esri/core/workers/chunks/c88101cb8301f095d037.js +0 -1
- package/assets/esri/core/workers/chunks/cb1b16f8bf7c135e14f7.js +0 -1
- package/assets/esri/core/workers/chunks/cc245eb1c5aaaac5916e.js +0 -1
- package/assets/esri/core/workers/chunks/e03bf0ca545dce221ea0.js +0 -1
- package/assets/esri/core/workers/chunks/e880d7738155a4de4b0e.js +0 -1
- package/assets/esri/core/workers/chunks/fb4bcf366ba1b51668f6.js +0 -1
- package/assets/esri/core/workers/chunks/fb58f3ea98bf5e8cf8dd.js +0 -1
- package/views/3d/webgl/utils.js +0 -2
- /package/assets/esri/core/workers/chunks/{aefc089928ada18bc4d4.js.LICENSE.txt → 2762149a922275136171.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{7a85e08cb968586f8d74.js.LICENSE.txt → 72acfb74fd9ab9bae923.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{360dd5cd63d132b5c7d5.js.LICENSE.txt → 7e6309bfed6692e8d2d7.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{4bd98d025bcd713eddca.js.LICENSE.txt → 91858b02da40ff251ab2.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{147d0f7a2e471442c95c.js.LICENSE.txt → c9babe86c00ae69e63ee.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{initial as o,watch as n,when as a}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as c,subclass as d}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as m,fromQuat as u}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as p,IDENTITY as f}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as y}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as g,sub as _,dot as v,add as w,length as j,transformMat3 as x,set as C,abs as M,max as E}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as O,freeze as T,fromValues as R,clone as U,ZEROS as V}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as S,clone as A,fromValues as H}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as L,isMars as k,getReferenceEllipsoid as P,SphericalECEFSpatialReferenceLike as I}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as F}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as D}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as G}from"../../../geometry/projection/projectVectorToVector.js";import{create as B}from"../../../geometry/support/aaBoundingRect.js";import{getContinuousIndexArray as z}from"../../../geometry/support/Indices.js";import{isCGCS2000 as N}from"../../../geometry/support/spatialReferenceUtils.js";import{BufferViewVec2f as q,BufferViewVec4f as W,BufferViewVec4u8 as $,BufferViewVec4u16 as Z,BufferViewVec3f as J,BufferViewVec3u8 as X,BufferViewVec3u16 as Y,BufferViewInt16 as K,BufferViewUint32 as Q,BufferViewUint16 as ee}from"../../../geometry/support/buffer/BufferView.js";import te from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as ie}from"../../../support/elevationInfoUtils.js";import{addNormals as se}from"./IntegratedMeshNormals.js";import{LayerView3D as re}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as oe}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as ne,removeLayerViewFromWasm as ae,getLyr3DWasm as le}from"./Lyr3DWasm.js";import{toWasmModification as ce}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as de}from"./i3s/LayerElevationProvider.js";import{IntegratedMesh3DTilesLayerView3DSymbol as he}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as me,alphaModeConversion as ue,faceCullingConversion as pe,wrapModeConversion as fe,lyr3DTypeToByteSize as be}from"./support/lyr3dTypeConversions.js";import{Tiles3DMeshIntersectionHandler as ye}from"./support/Tiles3DMeshIntersectionHandler.js";import{Frustum as ge}from"../state/Frustum.js";import{ElevationRange as _e}from"../support/ElevationRange.js";import{toBoundingRect as ve}from"../support/extentUtils.js";import{Obb as we,compute as je}from"../support/orientedBoundingBox.js";import{glLayout as xe}from"../support/buffer/glUtil.js";import{VertexBufferLayoutCreationParameters as Ce,createVertexBufferLayout as Me,ComponentGeometryParameters as Ee,SourceGeometry as Oe}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as Te}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Re}from"../webgl-engine/core/material/RenderTexture.js";import{Vertices as Ue,Attribute as Ve}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as Se}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as Ae}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as He}from"../webgl-engine/materials/pbrUtils.js";import{writeAttribute as Le,writeBufferVec2 as ke}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import Pe from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as Ie,isInEffectiveScaleRange as Fe,validateScaleRange as De}from"../../support/layerViewUtils.js";import{TaskPriority as Ge}from"../../support/Scheduler.js";import{TextureCompressionTracker as Be}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as ze}from"../../../webscene/support/AlphaCutoff.js";var Ne;let qe=class extends(re(Pe)){static{Ne=he}constructor(e){super(e),this[Ne]=!0,this.type="integrated-mesh-3dtiles",this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._replacesTerrain=!1,this._isUsedAsGroundLayer=!1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._compressionTracker=new Be,this._dbgFlags=new Set;const t=e.view.resourceController;this._memCache=t.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._replacesTerrain=e.layer.replacesTerrain,this._isUsedAsGroundLayer=e.layer.isUsedAsGroundLayer,this._frameTask=t.scheduler.registerTask(Ge.TILES3D),this._frustum=new ge(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{r(t);const i=this.layer.queryElevationCallback;this.layer=e,this.layer.queryElevationCallback=i}):null}canRecycleWith(e){return e.url===this.layer.url&&"integrated-mesh-3dtiles"===e.type&&e.replacesTerrain===this._replacesTerrain&&e.isUsedAsGroundLayer===this._isUsedAsGroundLayer}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw Ie("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=ne(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new ye(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged()),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),o),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),o),this._elevationProvider=new de({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler});const i=this._replacesTerrain?0:1;e.elevationProvider.register(i,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),a(()=>this.fullOpacity,()=>this._opacityChange()),n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)])});this.layer.queryElevationCallback=(e,t)=>this._wasm.queryElevation(this,e,t),this.addResolvingPromise(t)}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),ae(this),this.layer.queryElevationCallback=null,this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._frameTask.remove(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=s(this._visibleGeometryChangedSchedulerHandle)}get fullOpacity(){return this.layer.replacesTerrain&&has("enable-feature:oit-ground")?this.view.map.ground.opacity:1}get hasModifications(){return this._modifications&&this._modifications.length>0}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateObjectOpacity(t,e))}_cameraChanged(){const e=this._frustum;e.update(this.view.state.contentCamera);const t=this._visibleObjects;let i=!1;this._loadedObjects.forEach(s=>{const r=s.obb?.intersectsFrustum(e)??!1;r!==s.isVisible&&(s.isVisible=r,r?t.add(s):t.delete(s),s.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,r)),i||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(r,s.elevationRange))}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}_modificationsChanged(){const e=this.layer.spatialReference,t=ce(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=B();this._layerClippingArea=ve(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.layer.replacesTerrain),this.forEachComponentObject(t=>this._collection.updateMaterial(t,{slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,ie(e))}get _wasm(){return le(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||Fe(this.layer.effectiveScaleRange,this.view.scale)}canResume(){const e=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.layer.isUsedAsGroundLayer||De(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,r++):(i+=n.textureMemoryUsage,s+=n.vboMemoryUsage,o++)}),new oe(this.usedMemory,r,o,Ze(t),Ze(e),Ze(s),Ze(i))}_canProjectWithoutEngine(){if(this.view.state.isLocal){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return ie(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new _e(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new _e;0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this._forEachRelevantVisibleTile(t=>e.expandElevationRange(t.elevationRange)),e.minElevation===1/0&&e.setElevationRangeValues(0,0));const t=this._get("visibleElevationRange");return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}_forEachRelevantVisibleTile(e){const{view:t}=this,{spatialReference:i}=t,s=i.isWGS84||i.isWebMercator||N(i)||L(i)||k(i);if(this.view.state.isGlobal||!s)return this.forEachVisibleTile(e);const r=P(i).radius,{eye:o,viewForward:n,near:a}=t.state.camera,l=g(O(),n),c=500,d=Math.max(o[2],c),h=d+r,m=Math.sqrt(h**2-r**2),u=Math.abs(Math.atan2(m,r))*r,p=d>.5*r?.5*Math.PI*r:u,f=O();this.forEachVisibleTile(t=>{const{mbsRadius:i,mbsCenter:s}=t;if(i<0)return;_(f,s,o);const r=v(f,l);Math.abs(r)<p&&r+i>a&&r-i<p&&e(t)})}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachTile(e){for(const t of this._loadedObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const{componentObjects:i}of e)for(const e of i)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){return this._frameTask.schedule(()=>this._createRenderable(e))}async _createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw new Error(e)}const{meshData:t}=e;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=T(...t.desc.origin),s=this.view.basemapTerrain.spatialReference;let r=f;if(this.view.state.isGlobal){const e=b();F(I,i,e,s),r=h(p(),e)}const o=O(),n=Ye(t.desc.obb);let a=0;const l={textureMemoryUsage:0},c=new Array,d=new Map,u=t.desc.prims.length,y=new Array,g=new _e;try{const e=this.view.state.isGlobal,h=e?P(this.view.spatialReference).radius:0,b=O();for(let y=0;y<u;y++){const u=t.desc.prims[y];this._dbg(2,JSON.stringify(u));if(null==me[u.ptype]||null==t.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+u.ptype+"). Skipping primitive.");continue}const _=t.desc?.materials&&null!=u.materialId?t.desc.materials[u.materialId]:null,v=null!=_?_.lightingModel:"Unlit",{positionView:M,positionAttr:E,normalsView:T,normalsAttr:V,colorAttr:L,texCoord0Attr:k,indicesView:P}=this.getBufferViews(u,t.data.buffer,r);if(null==E||null==M||null==P)continue;const I=M.count,F=(e,t)=>!e||e.data.length/e.size===I||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!F(k,"numTexcoord")||!F(L,"numColors")||!F(V,"normals"))continue;const B=new Ce(null!=L,null!=T,k?1:0),z=Me(B);for(let t=0;t<M.count;t++){M.getVec(t,o),w(o,o,i);const s=e?j(o)-h:o[2];g.expandElevationRangeValues(s,s)}if(n){et(n,b,new Ue(E.data,3),i)}const N=n?.clone()??Xe(E,i);if(r!==f)for(let e=0;e<M.count;e++)M.getVec(e,o),x(o,o,r),M.setVec(e,o);const W=z.createBuffer(I);if(Le("position",E,null,null,W,0),null!=k){const e=W.getField("uv0",q);ke(k,e,0)}null!=L&&Le("color",L,null,null,W,0),null!=V&&Le("normalCompressed",V,null,null,W,0);const $=new Uint32Array([0,P.typedBuffer.length]),Z=xe(z),J=this._shadeNormals||this.layer.replacesTerrain,X=se(new Uint8Array(W.buffer),P.typedBuffer,Z,J),Y=new Ee(Z,J?2:0,B.textureCoordinateType,r!==f),K=new Oe({interleavedVertexData:X.data,vertexCount:X.data.byteLength/Z[0].stride,indexData:X.indices},{positions:M.typedBuffer,indices:P.typedBuffer},$,Y),Q=this.view.renderSpatialReference,ee=O(),te=[1,1,1];D(i,Q,te,s)||this._dbg(3,"Unsupported coordinate system for IM overlay"),G(i,Q,ee,s);let ie=Promise.resolve(Qe),re=S,oe=ze,ne=null,ae=null,le=null,ce=null,de=null,he=1,fe=!1,be=2,ye=!1,ge=R(0,0,0);const _e=U(He),ve="Pbr"===v;if(_){const e=e=>this._getTexture(e,t,d,l);ne=e(_.baseColorTex),de=ve?e(_.metalTex):null,ae=ve?e(_.emissiveTex):null,ce=ve?e(_.occlusionTex):null,le=ve?e(_.normalTex):null;const i=[ne,de,ae,ce,le].map(e=>e?.loadPromise??null);ie=Promise.all(i),re=A(_.baseColorFactor),oe=_.alphaCutoff??ze,ve&&(C(_e,_.metallicFactor,_.roughnessFactor,0),_.emissiveFactor&&(ge=_.emissiveFactor)),he=ue[_.alphaMode],fe=_.isDoubleSided,be=pe[_.faceCulling??"NotSet"],ye=this.layer.replacesTerrain}const we=ie.then(()=>()=>{if(this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}ne||console.error("No colour texture 1");const e=r===f?f:m(p(),r)??f,t=this._collection.createObject({toMapSpace:H(ee[0],ee[1],te[0],te[1]),transform:new Te(i,e),obb:N,geometry:K,elevationAlignable:!1},{isIntegratedMesh:!0,baseColor:re,textureAlphaCutoff:oe,mrrFactors:_e,baseColorTexture:ne,metallicRoughnessTexture:de,normalTexture:le,occlusionTexture:ce,emissionTexture:ae,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:he,doubleSided:fe,cullFace:be,isGround:ye,emissiveBaseColor:ge,usePBR:ve,slicePlaneEnabled:this.slicePlaneEnabled,opacity:this.fullOpacity,polygonOffsetEnabled:!1,ellipsoidMode:1,applySSAO:this._applySSAO});return l.textureMemoryUsage+=ne?.texture?.usedMemory??0,ve&&(l.textureMemoryUsage+=(de?.texture?.usedMemory??0)+(ae?.texture?.usedMemory??0)+(ce?.texture?.usedMemory??0)+(le?.texture?.usedMemory??0)),a+=this._collection.getObjectGPUMemoryUsage(t),t});c.push(we)}if(y.push(...await Promise.all(c)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(k){throw d.forEach(e=>this._stage.removeTexture(e)),k}const _=y.map(e=>e()),v=new Array;d.forEach(e=>v.push(e));const{fullExtent:M}=this.layer;M?.hasZ&&M.zmax&&M.zmin&&(g.minElevation=Math.max(g.minElevation,M.zmin),g.maxElevation=Math.min(g.maxElevation,M.zmax));const E=_.reduceRight((e,t)=>e+t.intersectionGeometry.usedMemory,0),V=new $e(e.handle,_,v,E,a,l.textureMemoryUsage,n,e.stableNodeId,e.nodeDepth,g);this._lyrHandleToObjects.set(e.handle,V),this._memCache.put(Ke(V.handle),V);const{usedMemory:L}=V;return this._cacheMemory+=L,{memUsageBytes:L}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){const t=Ke(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){if(this.destroyed||this.destroying)return;const s=this._frustum,r=new Array;let o=!1,n=!1;for(let a=0;a<i;++a){if(!t[a])continue;const i=e[a],l=this._lyrHandleToObjects.get(i);if(l){if(l.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${l.stableNodeId}`);continue}o=!0,l.isLoaded=!0,this._loadedObjects.add(l),this._usedMemory+=l.usedMemory,this._cacheMemory-=l.usedMemory;const e=l.obb?.intersectsFrustum(s)??!0;l.isVisible=e,e&&(this._visibleObjects.add(l),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,l.elevationRange)),e&&l.obb&&r.push(l.obb),l.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(Ke(i))}else this._dbg(3,`Tried to mark Non existent object ${i} as loaded`)}for(let a=0;a<i;++a){const i=e[a];if(t[a])continue;const s=this._lyrHandleToObjects.get(i);if(s){if(!s.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${s.stableNodeId}`);continue}const e=this._visibleObjects.delete(s);s.isVisible=!1,s.isLoaded=!1,this._loadedObjects.delete(s),e&&(this._visibleGeometryChanged(),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,s.elevationRange)),this._usedMemory-=s.usedMemory,this._cacheMemory+=s.usedMemory,e&&s.obb&&r.push(s.obb),s.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(Ke(i),s)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),this._elevationProvider.notifyObjectsChanged(r),n&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){const{visibleElevationRange:i}=this,{minElevation:s,maxElevation:r}=t;return e?s<i.minElevation||r>i.maxElevation:s===i.minElevation||r===i.maxElevation}_getTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=i.get(r)??this._createTexture(e,t,i,s);return o?new Re(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!r.mipCount||a>1,c=fe[e.wrapMode??"None"];let d=r.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,r.data.byteOffset,r.data.byteCount);let m=null,u=null,p=null;switch(r.format){case"Raw":"R8"===r.pixelFormat?(m=h,d=6403,u=""):"Rgb8"===r.pixelFormat?(m=h,d=6407,u=""):"Rgba8"===r.pixelFormat&&(m=h,d=6408,u="");break;case"Dxt1":m=h,d=6407,u="image/vnd-ms.dds";break;case"Dxt5":m=h,d=6408,u="image/vnd-ms.dds";break;case"Basis":m=h,d=6407,u="image/ktx2";break;case"Png":u="image/png",p=document.createElement("img");break;case"Jpeg":u="image/jpeg",p=document.createElement("img");break;case"Etc2":u="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&u){const e=new Blob([h],{type:u});p.src=URL.createObjectURL(e),m=p}if(m&&null!=u){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0,t=new Se(m,{mipmap:l,maxAnisotropy:a,encoding:u,wrap:c,pixelFormat:d,compressionOptions:e,noUnpackFlip:!0,width:r.mip0Width,height:r.mip0Height});return this._stage.addTexture(t),i.set(r,t),t}return null}getBufferViews(e,t,i){let s,r,o,n,a,l,c,d=null;for(let m=0;m<e.atrbs.length;m++){const c=e.atrbs[m],{view:u}=c,p=void 0,f=u.byteOffset+u.byteCount,b=u.byteCount/be[u.type],y=z(b);try{switch(c.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(s=new J(t,u.byteOffset,p,f),r=new Ve(s.typedBuffer,y,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new J(t,u.byteOffset,p,f),s=Ae(e.typedBuffer,i);a=new K(s.buffer),l=new Ve(a.typedBuffer,y,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===n&&(n=new Ve(new q(t,u.byteOffset,p,f).typedBuffer,y,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(d=new W(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new $(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new Z(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(d=new J(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new X(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new Y(t,u.byteOffset,p,f))),null==d?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new Ve(d.typedBuffer,y,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":c=new ee(t,i.byteOffset,s,r);break;case"U32":c=new Q(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==c&&null!=s){const e=s.count;c=c=e<65535?new ee(new Uint16Array(e).buffer):new Q(new Uint32Array(e).buffer);for(let t=0;t<e;t++)c.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:n,indicesView:c,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.layer.isUsedAsGroundLayer&&"replace"!==e.type)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info("Ground layers only support replace modifications. Other modification types have been ignored.")},o),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([c()],qe.prototype,"fullOpacity",null),e([c({readOnly:!0})],qe.prototype,"ready",null),e([c({type:[te]})],qe.prototype,"_modifications",void 0),e([c()],qe.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([c()],qe.prototype,"layer",void 0),e([c({readOnly:!0})],qe.prototype,"visibleAtCurrentScale",null),e([c({readOnly:!0})],qe.prototype,"_collection",null),e([c()],qe.prototype,"elevationOffset",null),e([c({readOnly:!0})],qe.prototype,"visibleElevationRange",null),qe=e([d("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],qe);const We=qe;class $e{constructor(e,t,i,s,r,o,n,a,l,c){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.nodeDepth=l,this.elevationRange=c,this.isLoaded=!1,this.isVisible=!1;const d=O();n?.getCenter(d),this._obbCenterX=d[0],this._obbCenterY=d[1],this._obbCenterZ=d[2];const h=n?.radius??-1;this._obbRadius=h,this._obbRadiusSquared=h*h;const m=n?.halfSize;this._obbShortestHalfsize=m?Math.min(m[0],m[1],m[2]):0}get usedMemory(){return this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this.obb?.center??V}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const{_obbCenterX:i,_obbCenterY:s,_obbCenterZ:r}=this,o=i-e[0],n=s-e[1],a=r-e[2],l=o*t[0]+n*t[1]+a*t[2];return o*o+n*n+a*a-l*l<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const t=this._obbRadius;if(t<0)return!0;const i=e.center,s=e.radius,r=t+s,o=this._obbCenterX-i[0];if(o>r)return!1;const n=this._obbCenterY-i[1];if(n>r)return!1;const a=this._obbCenterZ-i[2];if(a>r)return!1;const l=o*o+n*n+a*a;if(l>r*r)return!1;if(l<=(this._obbShortestHalfsize+s)**2)return!0;return Math.sqrt(l)+t<=s||(this.obb?.intersectSphere(e)??!0)}}function Ze(e){return Math.round(e/1048.576)/1e3}const Je=O();function Xe(e,t){const i=je(e);return w(Je,i.center,t),i.center=Je,i}function Ye(e){return e?new we(e.center,e.halfSize,y(...e.quaternion)):null}function Ke(e){return`${e}`}const Qe=new Array;function et(e,t,i,s){const{center:r}=e,o=u(st,e.quaternionConjugate),n=x(tt,r,o),{data:a}=i,l=a.length/i.stride,c=it;for(let d=0;d<l;++d){const e=3*d;for(let t=0;t<3;++t)c[t]=a[e+t]+s[t];x(c,c,o),_(c,c,n),M(c,c),E(t,t,c)}e.halfSize=t}const tt=O(),it=O(),st=p();export{We as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{initial as o,watch as n,when as a}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as c,subclass as d}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as m,fromQuat as u}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as p,IDENTITY as f}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as y}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as g,sub as _,dot as v,add as w,length as j,transformMat3 as x,set as C,abs as M,max as E}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as O,freeze as T,fromValues as R,clone as U,ZEROS as V}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as S,clone as A,fromValues as H}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as L,isMars as k,getReferenceEllipsoid as P,SphericalECEFSpatialReferenceLike as I}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as F}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as D}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as G}from"../../../geometry/projection/projectVectorToVector.js";import{create as B}from"../../../geometry/support/aaBoundingRect.js";import{getContinuousIndexArray as z}from"../../../geometry/support/Indices.js";import{isCGCS2000 as N}from"../../../geometry/support/spatialReferenceUtils.js";import{BufferViewVec2f as q,BufferViewVec4f as W,BufferViewVec4u8 as $,BufferViewVec4u16 as Z,BufferViewVec3f as J,BufferViewVec3u8 as X,BufferViewVec3u16 as Y,BufferViewInt16 as K,BufferViewUint32 as Q,BufferViewUint16 as ee}from"../../../geometry/support/buffer/BufferView.js";import te from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as ie}from"../../../support/elevationInfoUtils.js";import{addNormals as se}from"./IntegratedMeshNormals.js";import{LayerView3D as re}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as oe}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as ne,removeLayerViewFromWasm as ae,getLyr3DWasm as le}from"./Lyr3DWasm.js";import{toWasmModification as ce}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as de}from"./i3s/LayerElevationProvider.js";import{IntegratedMesh3DTilesLayerView3DSymbol as he}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as me,alphaModeConversion as ue,faceCullingConversion as pe,wrapModeConversion as fe,lyr3DTypeToByteSize as be}from"./support/lyr3dTypeConversions.js";import{Tiles3DMeshIntersectionHandler as ye}from"./support/Tiles3DMeshIntersectionHandler.js";import{Frustum as ge}from"../state/Frustum.js";import{ElevationRange as _e}from"../support/ElevationRange.js";import{toBoundingRect as ve}from"../support/extentUtils.js";import{Obb as we,compute as je}from"../support/orientedBoundingBox.js";import{glLayout as xe}from"../support/buffer/glUtil.js";import{VertexBufferLayoutCreationParameters as Ce,createVertexBufferLayout as Me,ComponentGeometryParameters as Ee,SourceGeometry as Oe}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as Te}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Re}from"../webgl-engine/core/material/RenderTexture.js";import{Vertices as Ue,Attribute as Ve}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as Se}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as Ae}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as He}from"../webgl-engine/materials/pbrUtils.js";import{writeAttribute as Le,writeBufferVec2 as ke}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import Pe from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as Ie,isInEffectiveScaleRange as Fe,validateScaleRange as De}from"../../support/layerViewUtils.js";import{TaskPriority as Ge}from"../../support/Scheduler.js";import{TextureCompressionTracker as Be}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as ze}from"../../../webscene/support/AlphaCutoff.js";var Ne;let qe=class extends(re(Pe)){static{Ne=he}constructor(e){super(e),this[Ne]=!0,this.type="integrated-mesh-3dtiles",this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._replacesTerrain=!1,this._isUsedAsGroundLayer=!1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._compressionTracker=new Be,this._dbgFlags=new Set;const t=e.view.resourceController;this._memCache=t.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._replacesTerrain=e.layer.replacesTerrain,this._isUsedAsGroundLayer=e.layer.isUsedAsGroundLayer,this._frameTask=t.scheduler.registerTask(Ge.TILES3D),this._frustum=new ge(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{r(t);const i=this.layer.queryElevationCallback;this.layer=e,this.layer.queryElevationCallback=i}):null}canRecycleWith(e){return e.url===this.layer.url&&"integrated-mesh-3dtiles"===e.type&&e.replacesTerrain===this._replacesTerrain&&e.isUsedAsGroundLayer===this._isUsedAsGroundLayer}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw Ie("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=ne(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new ye(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged()),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),o),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),o),this._elevationProvider=new de({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler});const i=this._replacesTerrain?0:1;e.elevationProvider.register(i,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),a(()=>this.fullOpacity,()=>this._opacityChange()),n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)])});this.layer.queryElevationCallback=(e,t)=>this._wasm.queryElevation(this,e,t),this.addHandles(n(()=>this.view.qualitySettings.memoryLimit,e=>this._memCache.maxSize=Math.ceil(rt*e*1048576),o)),this.addResolvingPromise(t)}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),ae(this),this.layer.queryElevationCallback=null,this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._frameTask.remove(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=s(this._visibleGeometryChangedSchedulerHandle)}get fullOpacity(){return this.layer.replacesTerrain&&has("enable-feature:oit-ground")?this.view.map.ground.opacity:1}get hasModifications(){return this._modifications&&this._modifications.length>0}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateObjectOpacity(t,e))}_cameraChanged(){const e=this._frustum;e.update(this.view.state.contentCamera);const t=this._visibleObjects;let i=!1;this._loadedObjects.forEach(s=>{const r=s.obb?.intersectsFrustum(e)??!1;r!==s.isVisible&&(s.isVisible=r,r?t.add(s):t.delete(s),s.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,r)),i||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(r,s.elevationRange))}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}_modificationsChanged(){const e=this.layer.spatialReference,t=ce(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=B();this._layerClippingArea=ve(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.layer.replacesTerrain),this.forEachComponentObject(t=>this._collection.updateMaterial(t,{slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,ie(e))}get _wasm(){return le(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||Fe(this.layer.effectiveScaleRange,this.view.scale)}canResume(){const e=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.layer.isUsedAsGroundLayer||De(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,r++):(i+=n.textureMemoryUsage,s+=n.vboMemoryUsage,o++)}),new oe(this.usedMemory,r,o,Ze(t),Ze(e),Ze(s),Ze(i))}_canProjectWithoutEngine(){if(this.view.state.isLocal){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return ie(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new _e(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new _e;0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this._forEachRelevantVisibleTile(t=>e.expandElevationRange(t.elevationRange)),e.minElevation===1/0&&e.setElevationRangeValues(0,0));const t=this._get("visibleElevationRange");return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}_forEachRelevantVisibleTile(e){const{view:t}=this,{spatialReference:i}=t,s=i.isWGS84||i.isWebMercator||N(i)||L(i)||k(i);if(this.view.state.isGlobal||!s)return this.forEachVisibleTile(e);const r=P(i).radius,{eye:o,viewForward:n,near:a}=t.state.camera,l=g(O(),n),c=500,d=Math.max(o[2],c),h=d+r,m=Math.sqrt(h**2-r**2),u=Math.abs(Math.atan2(m,r))*r,p=d>.5*r?.5*Math.PI*r:u,f=O();this.forEachVisibleTile(t=>{const{mbsRadius:i,mbsCenter:s}=t;if(i<0)return;_(f,s,o);const r=v(f,l);Math.abs(r)<p&&r+i>a&&r-i<p&&e(t)})}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachTile(e){for(const t of this._loadedObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const{componentObjects:i}of e)for(const e of i)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){return this._frameTask.schedule(()=>this._createRenderable(e))}async _createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw new Error(e)}const{meshData:t}=e;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=T(...t.desc.origin),s=this.view.basemapTerrain.spatialReference;let r=f;if(this.view.state.isGlobal){const e=b();F(I,i,e,s),r=h(p(),e)}const o=O(),n=Ye(t.desc.obb);let a=0;const l={textureMemoryUsage:0},c=new Array,d=new Map,u=t.desc.prims.length,y=new Array,g=new _e;try{const e=this.view.state.isGlobal,h=e?P(this.view.spatialReference).radius:0,b=O();for(let y=0;y<u;y++){const u=t.desc.prims[y];this._dbg(2,JSON.stringify(u));if(null==me[u.ptype]||null==t.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+u.ptype+"). Skipping primitive.");continue}const _=t.desc?.materials&&null!=u.materialId?t.desc.materials[u.materialId]:null,v=null!=_?_.lightingModel:"Unlit",{positionView:M,positionAttr:E,normalsView:T,normalsAttr:V,colorAttr:L,texCoord0Attr:k,indicesView:P}=this.getBufferViews(u,t.data.buffer,r);if(null==E||null==M||null==P)continue;const I=M.count,F=(e,t)=>!e||e.data.length/e.size===I||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!F(k,"numTexcoord")||!F(L,"numColors")||!F(V,"normals"))continue;const B=new Ce(null!=L,null!=T,k?1:0),z=Me(B);for(let t=0;t<M.count;t++){M.getVec(t,o),w(o,o,i);const s=e?j(o)-h:o[2];g.expandElevationRangeValues(s,s)}if(n){et(n,b,new Ue(E.data,3),i)}const N=n?.clone()??Xe(E,i);if(r!==f)for(let e=0;e<M.count;e++)M.getVec(e,o),x(o,o,r),M.setVec(e,o);const W=z.createBuffer(I);if(Le("position",E,null,null,W,0),null!=k){const e=W.getField("uv0",q);ke(k,e,0)}null!=L&&Le("color",L,null,null,W,0),null!=V&&Le("normalCompressed",V,null,null,W,0);const $=new Uint32Array([0,P.typedBuffer.length]),Z=xe(z),J=this._shadeNormals||this.layer.replacesTerrain,X=se(new Uint8Array(W.buffer),P.typedBuffer,Z,J),Y=new Ee(Z,J?2:0,B.textureCoordinateType,r!==f),K=new Oe({interleavedVertexData:X.data,vertexCount:X.data.byteLength/Z[0].stride,indexData:X.indices},{positions:M.typedBuffer,indices:P.typedBuffer},$,Y),Q=this.view.renderSpatialReference,ee=O(),te=[1,1,1];D(i,Q,te,s)||this._dbg(3,"Unsupported coordinate system for IM overlay"),G(i,Q,ee,s);let ie=Promise.resolve(Qe),re=S,oe=ze,ne=null,ae=null,le=null,ce=null,de=null,he=1,fe=!1,be=2,ye=!1,ge=R(0,0,0);const _e=U(He),ve="Pbr"===v;if(_){const e=e=>this._getTexture(e,t,d,l);ne=e(_.baseColorTex),de=ve?e(_.metalTex):null,ae=ve?e(_.emissiveTex):null,ce=ve?e(_.occlusionTex):null,le=ve?e(_.normalTex):null;const i=[ne,de,ae,ce,le].map(e=>e?.loadPromise??null);ie=Promise.all(i),re=A(_.baseColorFactor),oe=_.alphaCutoff??ze,ve&&(C(_e,_.metallicFactor,_.roughnessFactor,0),_.emissiveFactor&&(ge=_.emissiveFactor)),he=ue[_.alphaMode],fe=_.isDoubleSided,be=pe[_.faceCulling??"NotSet"],ye=this.layer.replacesTerrain}const we=ie.then(()=>()=>{if(this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}ne||console.error("No colour texture 1");const e=r===f?f:m(p(),r)??f,t=this._collection.createObject({toMapSpace:H(ee[0],ee[1],te[0],te[1]),transform:new Te(i,e),obb:N,geometry:K,elevationAlignable:!1},{isIntegratedMesh:!0,baseColor:re,textureAlphaCutoff:oe,mrrFactors:_e,baseColorTexture:ne,metallicRoughnessTexture:de,normalTexture:le,occlusionTexture:ce,emissionTexture:ae,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:he,doubleSided:fe,cullFace:be,isGround:ye,emissiveBaseColor:ge,usePBR:ve,slicePlaneEnabled:this.slicePlaneEnabled,opacity:this.fullOpacity,polygonOffsetEnabled:!1,ellipsoidMode:1,applySSAO:this._applySSAO});return l.textureMemoryUsage+=ne?.texture?.usedMemory??0,ve&&(l.textureMemoryUsage+=(de?.texture?.usedMemory??0)+(ae?.texture?.usedMemory??0)+(ce?.texture?.usedMemory??0)+(le?.texture?.usedMemory??0)),a+=this._collection.getObjectGPUMemoryUsage(t),t});c.push(we)}if(y.push(...await Promise.all(c)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(k){throw d.forEach(e=>this._stage.removeTexture(e)),k}const _=y.map(e=>e()),v=new Array;d.forEach(e=>v.push(e));const{fullExtent:M}=this.layer;M?.hasZ&&M.zmax&&M.zmin&&(g.minElevation=Math.max(g.minElevation,M.zmin),g.maxElevation=Math.min(g.maxElevation,M.zmax));const E=_.reduceRight((e,t)=>e+t.intersectionGeometry.usedMemory,0),V=new $e(e.handle,_,v,E,a,l.textureMemoryUsage,n,e.stableNodeId,e.nodeDepth,g);this._lyrHandleToObjects.set(e.handle,V),this._memCache.put(Ke(V.handle),V);const{usedMemory:L}=V;return this._cacheMemory+=L,{memUsageBytes:L}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){const t=Ke(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){if(this.destroyed||this.destroying)return;const s=this._frustum,r=new Array;let o=!1,n=!1;for(let a=0;a<i;++a){if(!t[a])continue;const i=e[a],l=this._lyrHandleToObjects.get(i);if(l){if(l.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${l.stableNodeId}`);continue}o=!0,l.isLoaded=!0,this._loadedObjects.add(l),this._usedMemory+=l.usedMemory,this._cacheMemory-=l.usedMemory;const e=l.obb?.intersectsFrustum(s)??!0;l.isVisible=e,e&&(this._visibleObjects.add(l),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,l.elevationRange)),e&&l.obb&&r.push(l.obb),l.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(Ke(i))}else this._dbg(3,`Tried to mark Non existent object ${i} as loaded`)}for(let a=0;a<i;++a){const i=e[a];if(t[a])continue;const s=this._lyrHandleToObjects.get(i);if(s){if(!s.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${s.stableNodeId}`);continue}const e=this._visibleObjects.delete(s);s.isVisible=!1,s.isLoaded=!1,this._loadedObjects.delete(s),e&&(this._visibleGeometryChanged(),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,s.elevationRange)),this._usedMemory-=s.usedMemory,this._cacheMemory+=s.usedMemory,e&&s.obb&&r.push(s.obb),s.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(Ke(i),s)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),this._elevationProvider.notifyObjectsChanged(r),n&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){const{visibleElevationRange:i}=this,{minElevation:s,maxElevation:r}=t;return e?s<i.minElevation||r>i.maxElevation:s===i.minElevation||r===i.maxElevation}_getTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=i.get(r)??this._createTexture(e,t,i,s);return o?new Re(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!r.mipCount||a>1,c=fe[e.wrapMode??"None"];let d=r.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,r.data.byteOffset,r.data.byteCount);let m=null,u=null,p=null;switch(r.format){case"Raw":"R8"===r.pixelFormat?(m=h,d=6403,u=""):"Rgb8"===r.pixelFormat?(m=h,d=6407,u=""):"Rgba8"===r.pixelFormat&&(m=h,d=6408,u="");break;case"Dxt1":m=h,d=6407,u="image/vnd-ms.dds";break;case"Dxt5":m=h,d=6408,u="image/vnd-ms.dds";break;case"Basis":m=h,d=6407,u="image/ktx2";break;case"Png":u="image/png",p=document.createElement("img");break;case"Jpeg":u="image/jpeg",p=document.createElement("img");break;case"Etc2":u="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&u){const e=new Blob([h],{type:u});p.src=URL.createObjectURL(e),m=p}if(m&&null!=u){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0,t=new Se(m,{mipmap:l,maxAnisotropy:a,encoding:u,wrap:c,pixelFormat:d,compressionOptions:e,noUnpackFlip:!0,width:r.mip0Width,height:r.mip0Height});return this._stage.addTexture(t),i.set(r,t),t}return null}getBufferViews(e,t,i){let s,r,o,n,a,l,c,d=null;for(let m=0;m<e.atrbs.length;m++){const c=e.atrbs[m],{view:u}=c,p=void 0,f=u.byteOffset+u.byteCount,b=u.byteCount/be[u.type],y=z(b);try{switch(c.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(s=new J(t,u.byteOffset,p,f),r=new Ve(s.typedBuffer,y,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new J(t,u.byteOffset,p,f),s=Ae(e.typedBuffer,i);a=new K(s.buffer),l=new Ve(a.typedBuffer,y,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===n&&(n=new Ve(new q(t,u.byteOffset,p,f).typedBuffer,y,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(d=new W(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new $(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new Z(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(d=new J(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new X(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new Y(t,u.byteOffset,p,f))),null==d?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new Ve(d.typedBuffer,y,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":c=new ee(t,i.byteOffset,s,r);break;case"U32":c=new Q(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==c&&null!=s){const e=s.count;c=c=e<65535?new ee(new Uint16Array(e).buffer):new Q(new Uint32Array(e).buffer);for(let t=0;t<e;t++)c.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:n,indicesView:c,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.layer.isUsedAsGroundLayer&&"replace"!==e.type)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info("Ground layers only support replace modifications. Other modification types have been ignored.")},o),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([c()],qe.prototype,"fullOpacity",null),e([c({readOnly:!0})],qe.prototype,"ready",null),e([c({type:[te]})],qe.prototype,"_modifications",void 0),e([c()],qe.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([c()],qe.prototype,"layer",void 0),e([c({readOnly:!0})],qe.prototype,"visibleAtCurrentScale",null),e([c({readOnly:!0})],qe.prototype,"_collection",null),e([c()],qe.prototype,"elevationOffset",null),e([c({readOnly:!0})],qe.prototype,"visibleElevationRange",null),qe=e([d("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],qe);const We=qe;class $e{constructor(e,t,i,s,r,o,n,a,l,c){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.nodeDepth=l,this.elevationRange=c,this.isLoaded=!1,this.isVisible=!1;const d=O();n?.getCenter(d),this._obbCenterX=d[0],this._obbCenterY=d[1],this._obbCenterZ=d[2];const h=n?.radius??-1;this._obbRadius=h,this._obbRadiusSquared=h*h;const m=n?.halfSize;this._obbShortestHalfsize=m?Math.min(m[0],m[1],m[2]):0}get usedMemory(){return this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this.obb?.center??V}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const{_obbCenterX:i,_obbCenterY:s,_obbCenterZ:r}=this,o=i-e[0],n=s-e[1],a=r-e[2],l=o*t[0]+n*t[1]+a*t[2];return o*o+n*n+a*a-l*l<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const t=this._obbRadius;if(t<0)return!0;const i=e.center,s=e.radius,r=t+s,o=this._obbCenterX-i[0];if(o>r)return!1;const n=this._obbCenterY-i[1];if(n>r)return!1;const a=this._obbCenterZ-i[2];if(a>r)return!1;const l=o*o+n*n+a*a;if(l>r*r)return!1;if(l<=(this._obbShortestHalfsize+s)**2)return!0;return Math.sqrt(l)+t<=s||(this.obb?.intersectSphere(e)??!0)}}function Ze(e){return Math.round(e/1048.576)/1e3}const Je=O();function Xe(e,t){const i=je(e);return w(Je,i.center,t),i.center=Je,i}function Ye(e){return e?new we(e.center,e.halfSize,y(...e.quaternion)):null}function Ke(e){return`${e}`}const Qe=new Array;function et(e,t,i,s){const{center:r}=e,o=u(st,e.quaternionConjugate),n=x(tt,r,o),{data:a}=i,l=a.length/i.stride,c=it;for(let d=0;d<l;++d){const e=3*d;for(let t=0;t<3;++t)c[t]=a[e+t]+s[t];x(c,c,o),_(c,c,n),M(c,c),E(t,t,c)}e.halfSize=t}const tt=O(),it=O(),st=p(),rt=.2;export{We as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import has from"../../../core/has.js";import{disposeMaybe as i,abortMaybe as l,destroyMaybe as r}from"../../../core/maybe.js";import{isAborted as s}from"../../../core/promiseUtils.js";import{whenOnce as a,watch as o,
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import has from"../../../core/has.js";import{disposeMaybe as i,abortMaybe as l,destroyMaybe as r}from"../../../core/maybe.js";import{isAborted as s}from"../../../core/promiseUtils.js";import{whenOnce as a,watch as o,initial as n}from"../../../core/reactiveUtils.js";import{property as h,subclass as c}from"../../../core/accessorSupport/decorators.js";import{SchemaHelper as m}from"../../2d/engine/vectorTiles/SchemaHelper.js";import d from"../../2d/engine/vectorTiles/TileHandler3D.js";import p from"../../2d/engine/vectorTiles/VTLPainter3D.js";import y from"../../2d/engine/vectorTiles/style/StyleRepository.js";import{LayerView3D as g}from"./LayerView3D.js";import{TiledLayerView3D as f}from"./TiledLayerView3D.js";import{vtlAssumes256PixelSizeAsDefault as u,test as v}from"../terrain/terrainUtils.js";import S from"../../layers/LayerView.js";let _=class extends(f(g(S))){constructor(){super(...arguments),this._tileHandlerController=null,this.type="vector-tile-3d",this.levelShift=has("disable-feature:vtl-level-shift")?0:1}initialize(){if(null==this.layer.fullExtent)return void this.addResolvingPromise(Promise.reject(new t("vectortilelayerview:full-extent-undefined","This layer view's layer does not define a fullExtent.")));const{basemapTerrain:e,spatialReference:i,state:l,viewingMode:r}=this.view,h="local"===r&&!u(i)||v.force512VTL?this.layer.tileInfo:this.layer.tileInfo.getCompatibleForVTL(256),c=this._getTileInfoSupportError(h,this.layer.fullExtent);if(null!=c)return this.addResolvingPromise(Promise.reject(c));const g=a(()=>this.view?.basemapTerrain?.tilingSchemeLocked).then(()=>{const t=e.tilingScheme,i=t.pixelSize,l=256===i?1:2,r=e.spatialReference?.isGeographic&&256===i?1:0,s=e.spatialReference?.isGeographic||256!==i?0:1;let a;this.schemaHelper=new m(l,r,this.levelShift+s),a=256===i||512===i?this.layer.tileInfo.getCompatibleForVTL(i):this.layer.tileInfo;const o=this._getTileInfoCompatibilityError(a,t);if(o)throw o;this.tileInfo=a});this._tileHandlerController=new AbortController;const f=this.view.resourceController;this._memCache=f.memoryController.newCache(`vtl-${this.layer.uid}`,e=>e.release()),this.addHandles(o(()=>this.view.qualitySettings.memoryLimit,e=>this._memCache.maxSize=Math.ceil(e/10*1048576),n));const S=new y(this.layer.currentStyleInfo.style);this._tileHandler=new d(this.layer,S,l.contentPixelRatio,this._memCache);const _=this._tileHandlerController.signal,H=w(f),C=this._tileHandler.start({signal:_,schedule:H}),R=this._tileHandler.spriteMosaic;R.then(e=>{!s(_)&&this._tileHandler&&(this.painter=new p(e,this._tileHandler.glyphMosaic))}),C.then(()=>this._tileHandlerController=null);const L=()=>{this._tileHandlerController&&this._tileHandlerController.abort(),this._tileHandlerController=new AbortController,this._memCache.clear();const e=this.layer.currentStyleInfo.style,t=this.view.state?.contentPixelRatio??1,i=new y(e),l=new d(this.layer,i,t,this._memCache),r=l.start({signal:this._tileHandlerController.signal,schedule:H}),s=l.spriteMosaic;r.then(()=>this._tileHandlerController=null),this._updatingHandles.consumePromise(Promise.all([r,s]).then(([,e])=>{const t=this._tileHandler,i=this.painter;this.painter=new p(e,l.glyphMosaic),this._tileHandler=l,this.emit("data-changed"),t.destroy(),i&&i.dispose()}))};this._updatingHandles.add(()=>({style:this.layer.currentStyleInfo.style,pixelRatio:this.view.state?.contentPixelRatio}),L),this.addHandles([this.layer.on("paint-change",()=>this.emit("data-changed")),this.layer.on("style-layer-change",L),this.layer.on("delete-style-layer",L),this.layer.on("spriteSource-change",()=>this.emit("data-changed")),this.layer.on("layout-change",()=>this.emit("data-changed")),this.layer.on("style-layer-visibility-change",()=>this.emit("data-changed"))]);const x=Promise.all([g,C,R]);this.addResolvingPromise(x)}destroy(){this.painter=i(this.painter),this._tileHandlerController=l(this._tileHandlerController),this._tileHandler=r(this._tileHandler),this._memCache=r(this._memCache)}get contentZoom(){return has("disable-feature:vtl-level-shift")?1:this.view.qualitySettings.tiledSurface.vtlContentZoom}get displayLevelRange(){const e=this.tileInfo.lods,t=this.layer.minScale||e[0].scale,i=this.layer.maxScale||e[e.length-1].scale,l=this.levelRangeFromScaleRange(t,i);return this.layer.maxScale?l.maxLevel++:l.maxLevel+=this.levelShift,l}get dataScaleRange(){const e=this.tileInfo.lods;return{minScale:e[0].scale,maxScale:e[e.length-1].scale}}get dataLevelRange(){const{minScale:e,maxScale:t}=this.dataScaleRange,i=this.levelRangeFromScaleRange(e,t);return 1===i.minLevel&&256===this.tileInfo.size[0]&&(i.minLevel=0),i.maxLevel+=this.levelShift,i}async fetchTile(e,t){const i=this.schemaHelper.getLevelRowColumn(e);return this._tileHandler.getVectorTile(i,t)}get hasVisibleFeatures(){return!0}};e([h()],_.prototype,"layer",void 0),e([h()],_.prototype,"levelShift",void 0),e([h()],_.prototype,"contentZoom",null),e([h()],_.prototype,"displayLevelRange",null),e([h()],_.prototype,"tileInfo",void 0),e([h()],_.prototype,"dataScaleRange",null),e([h()],_.prototype,"dataLevelRange",null),e([h()],_.prototype,"updatingProgressValue",void 0),_=e([c("esri.views.3d.layers.VectorTileLayerView3D")],_);const H=_;function w(e){return t=>e.immediate.schedule(t)}export{H as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import r from"../../../../core/Accessor.js";import t from"../../../../core/Error.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{throwIfAborted as o,createAbortError as i}from"../../../../core/promiseUtils.js";import{difference as a}from"../../../../core/SetUtils.js";import{property as
|
|
2
|
+
import{__decorate as e}from"tslib";import r from"../../../../core/Accessor.js";import t from"../../../../core/Error.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{throwIfAborted as o,createAbortError as i}from"../../../../core/promiseUtils.js";import{difference as a}from"../../../../core/SetUtils.js";import{parseWhereClause as u}from"../../../../core/sql.js";import{property as l,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{fromFeatureSetJSON as c}from"../../../../layers/graphics/dehydratedFeatures.js";import{canConvertSqlRelativeTime as y,sqlRelativeTimeToAbsolute as p}from"../../../../layers/support/relativeTimeQueryUtils.js";import{queueAutoPriority as d}from"../../../../request/queue.js";import{runQuery as h,executeQuery as m,executeQueryForCount as f}from"../../../../rest/query/operations/query.js";import{PBFDecoder as w}from"../../support/PBFDecoder.js";let F=class extends r{constructor(e){super(e)}get implicitFields(){const e=this.layer.outFields?.includes("*");if(!e)return new Set;const r=new Set(this.layerView.requiredFields),t=new Set(this.layerView.availableFields);return a(t,r)}async queryFeaturesDehydrated(e,r){const{layer:t}=this,s=t.capabilities,a=s?.query?.supportsFormatPBF,l=t.parsedUrl,n=y(e.where)?await p(e.where,s.query.relativeTimeBinWindow):e.where,d=e.where;let f;if(n!==e.where&&((e=e.clone()).where=n),a){null==this._decoder&&(this._decoder=new w(this.controller));const s={sourceSpatialReference:t.spatialReference?.toJSON()??null,applyTransform:!0,maxStringAttributeFields:this.implicitFields,maxStringAttributeLength:v};f=await h(l,e,"pbf",this._createRequestOptions(r)).then(e=>(o(r),null!=this._decoder?this._decoder.invoke({buffer:e,options:s},r.signal):Promise.reject(i())))}else f=await m(l,e,t.spatialReference,this._createRequestOptions(r)).then(e=>c(e,{maxStringAttributeFields:this.implicitFields,maxStringAttributeLength:v}));if(d&&e.where!==d){const e=await this.controller.schedule(()=>u(d,this.layer.fieldsIndex),r.signal);f.features=await this.controller.schedule(()=>f.features.filter(r=>e.testFeatureCompiled(r)),r.signal)}return f}queryFeatureCount(e,r){return f(this.layer.parsedUrl,e,this._createRequestOptions(r))}destroy(){this._decoder=s(this._decoder)}_createRequestOptions(e){return{...d,...e,query:{...this.layer.customParameters,token:this.layer.apiKey,...e?.query}}}};e([l({constructOnly:!0})],F.prototype,"layer",void 0),e([l({constructOnly:!0})],F.prototype,"layerView",void 0),e([l({constructOnly:!0})],F.prototype,"controller",void 0),e([l({readOnly:!0})],F.prototype,"implicitFields",null),F=e([n("esri.views.3d.layers.support.featureTileQuery3D.FeatureTileServiceQuery3D")],F);let q=class extends r{constructor(e){super(e)}queryFeaturesDehydrated(e,r){return this.layer.queryFeatures(e,r)}};e([l({constructOnly:!0})],q.prototype,"layer",void 0),q=e([n("esri.views.3d.layers.support.featureTileQuery3D.FeatureTileOGCServiceQuery3D")],q);let g=class extends r{constructor(e){super(e)}queryFeaturesDehydrated(e,r){return this.layer.source.queryFeaturesJSON(e,r).then(c,t=>{if(t&&"query-features-json:unsupported"===t.name)return this.layer.queryFeatures(e,r);throw t})}queryFeatureCount(e,r){return this.layer.queryFeatureCount(e,r)}};function j(e,r){const{layer:s}=e;switch(s.type){case"feature":switch(s.source.type){case"feature-layer":return new F({layer:s,layerView:e,controller:r});case"memory":return new g({layer:s});case"csv":case"geojson":case"oriented-imagery":case"wfs":case"ogc-feature":case"parquet":break;default:s.source.type}break;case"catalog-footprint":return new F({layer:s,layerView:e,controller:r});case"csv":case"geojson":case"oriented-imagery":case"wfs":return new g({layer:s});case"ogc-feature":return new q({layer:s})}throw new t("feature-layer:unsupported",`Unsupported Feature layer type ${e.layer.type}:${e.layer.source.type}`)}e([l({constructOnly:!0})],g.prototype,"layer",void 0),g=e([n("esri.views.3d.layers.support.featureTileQuery3D.FeatureTileClientQuery3D")],g);const v=1024;export{j as createFeatureTileQuery3D};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import{destroyMaybe as e}from"../../../../core/maybe.js";import{isAbortError as r}from"../../../../core/promiseUtils.js";import{on as
|
|
2
|
+
import{__decorate as t}from"tslib";import{destroyMaybe as e}from"../../../../core/maybe.js";import{isAbortError as r}from"../../../../core/promiseUtils.js";import{on as i}from"../../../../core/reactiveUtils.js";import{property as o,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{distance as n,exactEquals as a,copy as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import c from"../../../../geometry/Point.js";import{distanceToScale as h}from"../cameraUtils.js";import{PointOfInterest as p}from"./PointOfInterest.js";import{PropertiesPool as u}from"../../../support/PropertiesPool.js";import{Yield as m}from"../../../support/Yield.js";let _=class extends p{constructor(t){super(t),this._dirty=!1,this._propertiesPool=new u({location:()=>new c,renderLocation:()=>d()},this),this._estimatedSurfaceAltitude=0,this._elevationQueryController=null,this.renderLocation=d(),this._tmpPoint=new c}initialize(){if(this.scheduler&&this.addHandles(this.scheduler.registerTask(this.task,this)),this.runTask(),this.map){const t=()=>this._setDirty();this.addHandles(i(()=>this.map?.ground?.layers,"change",t,{onListenerAdd:t,onListenerRemove:t}))}this._updateRenderLocation()}destroy(){this._cancelPendingRequest(),this._propertiesPool=e(this._propertiesPool)}get _camera(){return this.state.contentCamera}get location(){const t=this._propertiesPool.get("location");return t.spatialReference=this.state.spatialReference,this.renderCoordsHelper.fromRenderCoords(this.renderLocation,t),t}get scale(){const t=this._camera,e=n(t.eye,this.renderLocation),r={renderCoordsHelper:this.renderCoordsHelper,state:{camera:t}};return h(r,e)}get updating(){return this._dirty||null!=this._elevationQueryController}updateRenderLocation(){this._setDirty(),this._updateRenderLocation()}_setDirty(){this._dirty||(this._dirty=!0,this.notifyChange("updating"))}_cancelPendingRequest(){const t=this._elevationQueryController;t&&(this._elevationQueryController=null,t.abort(),this.notifyChange("updating"))}get readyToRun(){return!this._elevationQueryController&&this._dirty}runTask(){if(this._cancelPendingRequest(),this._dirty=!1,this.notifyChange("updating"),!this.map?.ground)return this._updateSurfaceAltitude(0),m;const t=this.state.spatialReference;this._tmpPoint.spatialReference=t,this.renderCoordsHelper.fromRenderCoords(this._camera.eye,this._tmpPoint);const e=(this._tmpPoint.z??0)>f&&1===this.renderCoordsHelper.viewingMode&&(t.isWGS84||t.isWebMercator);let i=new AbortController;return this.map.ground.queryElevation(this._tmpPoint,{signal:i.signal,cache:this.cache,minDemResolution:e?g:0}).then(t=>this._updateSurfaceAltitude(t.geometry.z??0)).catch(t=>{r(t)||this._updateSurfaceAltitude(0)}).finally(()=>{this._elevationQueryController===i&&(this._elevationQueryController=null,this.notifyChange("updating")),i=null}),this._elevationQueryController=i,this.notifyChange("updating"),m}_updateSurfaceAltitude(t){this._estimatedSurfaceAltitude!==t&&(this._estimatedSurfaceAltitude=t,this._updateRenderLocation())}_updateRenderLocation(){this.renderCoordsHelper.setAltitude(y,this._estimatedSurfaceAltitude,this._camera.eye),a(this._get("renderLocation"),y)||(this._set("renderLocation",l(this._propertiesPool.get("renderLocation"),y)),this.notifyChange("renderLocation"))}};t([o({constructOnly:!0})],_.prototype,"scheduler",void 0),t([o({constructOnly:!0})],_.prototype,"cache",void 0),t([o({constructOnly:!0})],_.prototype,"map",void 0),t([o({constructOnly:!0})],_.prototype,"task",void 0),t([o()],_.prototype,"location",null),t([o()],_.prototype,"renderLocation",void 0),t([o()],_.prototype,"scale",null),t([o()],_.prototype,"updating",null),_=t([s("esri.views.3d.support.pointsOfInterest.CameraOnSurface")],_);const y=d(),f=1e5,g=1e6;export{_ as CameraOnSurface};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{subclass as r}from"../../../core/accessorSupport/decorators.js";let s=class extends t{constructor(e,t){super(),this.key=e,this._free=t,this.incarnation=0,this._refCount=1}retain(e=1){this._refCount+=e}release(){
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{subclass as r}from"../../../core/accessorSupport/decorators.js";let s=class extends t{constructor(e,t){super(),this.key=e,this._free=t,this.incarnation=0,this._refCount=1}retain(e=1){this._refCount+=e}release(){if(0===this._refCount){const e=`Releasing already released FBO attachment "${this.name}" in ${(new Error).stack}`;return console.log(e),!0}return--this._refCount,0===this._refCount&&(this._free(),!0)}get test(){}};s=e([r("esri.views.3d.webgl.ManagedFBOResource")],s);const o=s;export{o as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import"../../../../core/has.js";import e from"../../../../core/Logger.js";import t from"../../webgl/ManagedColorAttachment.js";import{ManagedDepthTexture as a}from"../../webgl/ManagedDepthTexture.js";import r from"../../webgl/ManagedFBO.js";import{isDepthFormat as c,formatString as h,DepthTextureFormats as s,ColorFormats as i}from"./FBOCacheFormats.js";import{FBOPool as o}from"./FBOPool.js";import{DepthStencilAttachment as n,ColorAttachment0 as l}from"../../../webgl/enums.js";import{FramebufferObject as u}from"../../../webgl/FramebufferObject.js";import m from"../../../webgl/Texture.js";class d{constructor(e){this.rctx=e,this._interactive=!1,this._usage=new Map,this._acquired=new Set,this._cache=new o(e.newCache,"FBOCache"),this._depthCache=new o(e.newCache,"DepthAttachmentCache"),this._colorCache=new o(e.newCache,"ColorAttachmentCache")}destroy(){this._cache.destroy(),this._depthCache.destroy(),this._colorCache.destroy()}clean(){this._cache.clean(),this._colorCache.clean(),this._depthCache.clean()}frameStart(){this._cache.frame(),this._colorCache.frame(),this._depthCache.frame(),this.debugCallback?.(),this._usage.clear()}frameEnd(){const{debugCallback:e}=this;e&&this._acquired.forEach(t=>e(t.name,t.fbo,this._usage))}get usedMemory(){return Array.from(this._acquired.values()).reduce((e,t)=>e+t.usedMemory,this._cache.usedMemory+this._colorCache.usedMemory+this._depthCache.usedMemory)}set interactive(e){this._cache.interactive=this._colorCache.interactive=this._depthCache.interactive=e,this._interactive=e}get interactive(){return this._interactive}acquire(t,a,s,i=5){const o=
|
|
2
|
+
import"../../../../core/has.js";import e from"../../../../core/Logger.js";import t from"../../webgl/ManagedColorAttachment.js";import{ManagedDepthTexture as a}from"../../webgl/ManagedDepthTexture.js";import r from"../../webgl/ManagedFBO.js";import{isDepthFormat as c,formatString as h,DepthTextureFormats as s,ColorFormats as i}from"./FBOCacheFormats.js";import{FBOPool as o}from"./FBOPool.js";import{DepthStencilAttachment as n,ColorAttachment0 as l}from"../../../webgl/enums.js";import{FramebufferObject as u}from"../../../webgl/FramebufferObject.js";import m from"../../../webgl/Texture.js";class d{constructor(e){this.rctx=e,this._interactive=!1,this._usage=new Map,this._acquired=new Set,this._cache=new o(e.newCache,"FBOCache"),this._depthCache=new o(e.newCache,"DepthAttachmentCache"),this._colorCache=new o(e.newCache,"ColorAttachmentCache")}destroy(){this._cache.destroy(),this._depthCache.destroy(),this._colorCache.destroy()}clean(){this._cache.clean(),this._colorCache.clean(),this._depthCache.clean()}frameStart(){this._cache.frame(),this._colorCache.frame(),this._depthCache.frame(),this.debugCallback?.(),this._usage.clear()}frameEnd(){const{debugCallback:e}=this;e&&this._acquired.forEach(t=>e(t.name,t.fbo,this._usage))}get usedMemory(){return Array.from(this._acquired.values()).reduce((e,t)=>e+t.usedMemory,this._cache.usedMemory+this._colorCache.usedMemory+this._depthCache.usedMemory)}set interactive(e){this._cache.interactive=this._colorCache.interactive=this._depthCache.interactive=e,this._interactive=e}get interactive(){return this._interactive}acquire(t,a,s,i=5){const o=p(i,t,a);let m=this._cache.pop(o);const{rctx:d}=this;if(m){m.retain(),m.setName(s);const t=m.getAttachment(n);t&&(t.name=g);const a=m.getAttachment(l);a&&(a.name=_(0));const r=m.fbo;r?d.temporaryBindFramebufferObject(r,()=>{d.setDrawBuffers([l]),d.unbindTexture(r.colorTexture)}):e.getLogger("esri.views.3d.webgl-engine.core.FBOCache").errorOnce("Encountered an invalid cached framebuffer")}else{const e=new u(d),h=(e,r,c)=>{r??=5;const h=this._acquireColor(r,t,a,c??_(e-l));return this.rctx.unbindTexture(h.attachment),m.attachColor(h,e),h.release(),m},p=e=>{e??=14;const r=this.acquireDepth(e,t,a,g);return m.attachDepth(r),r.release(),m},f=()=>{if(!m)return;this.debugCallback?.(m.name,m.fbo),this._acquired.delete(m);const e=c(i);e&&null!=m.getAttachment(n)||!e&&null!=m.getAttachment(l)?(e?(m.fbo?.invalidateAttachments([n]),m.detachAllColors()):(m.fbo?.invalidateAttachments([l]),m.detachAllButColor0()),this._cache.put(m)):m.dispose()};m=new r(o,s,e,h,p,f),c(i)?m.acquireDepth(i):m.acquireColor(l,i)}return this._trackUsage(m,"fbo "+h(i),t,a),this._trackHandle(m)}acquireDepth(e,t,r,c){const i=p(e,t,r);let o=this._depthCache.pop(i);if(o)o.retain(),o.attachment.setShadowFiltering(!1);else{const c=new m(this.rctx,{...s[e],width:t,height:r});o=new a(i,c,()=>this._depthCache.put(o))}return o.name=c,this._trackUsage(o,"depth "+h(e),t,r),o}_acquireColor(e,a,r,c){const s=p(e,a,r);let o=this._colorCache.pop(s);if(o)o.retain();else{const c=new m(this.rctx,{...i[e],width:a,height:r,isImmutable:!0});o=new t(s,c,()=>this._colorCache.put(o))}return o.name=c,this._trackUsage(o,"color "+h(e),a,r),o}_trackHandle(e){return this._acquired.add(e),e}_trackUsage(e,t,a,r){this.debugCallback&&(this._usage.has(e)?this._usage.get(e)[2].push(e.name):this._usage.set(e,[t,`${a}x${r}`,[e.name]]))}get test(){return null}}function _(e=0){return`color${e}`}const g="depth";function p(e,t,a){return`${t}x${a}:${e}`}export{d as FBOCache};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import e from"../../../../core/Logger.js";import r from"../../../../core/PooledArray.js";
|
|
2
|
+
import e from"../../../../core/Logger.js";import r from"../../../../core/PooledArray.js";class t{constructor(e){this._context=e,this._nodes=new r}destroy(){this._nodes.forEach(e=>e.destroy()),this._nodes.prune()}add(e){this._nodes.push(e)}remove(e){this._nodes.remove(e)}produces(e){return this._nodes.some(({produces:r})=>r===e)}require(e,...r){const t=this._nodes,o=r=>t.reduce((t,{consumes:o,produces:n})=>t+(!o.required.includes(e)||null!=r&&n!==r?0:1),0);return 0===r.length?o():r.reduce((e,r)=>e+o(r),0)}optional(e,...r){const t=this._nodes,o=r=>t.reduce((t,{consumes:o,produces:n})=>t+(!o.optional?.includes(e)||null!=r&&n!==r?0:1),0);return 0===r.length?o():r.reduce((e,r)=>e+o(r),0)}updateAnimation(e){return this._nodes.reduce((r,t)=>t.updateAnimation(e)||r,!1)}precompile(...e){++this._context.techniques.precompiling;for(const r of e)this._nodes.forEach(e=>{e.produces===r&&e.precompile()});--this._context.techniques.precompiling}render(e,r,t=()=>{}){return this._render(e,r,t)??e}produce(e,r,t=()=>{}){return this._render(e,r,t)}_render(r,t,o=()=>{}){const n="string"==typeof r?r:r.name,s=this._nodes.filter(({produces:e})=>e===n);if(0===s.length)return;let i="string"==typeof r?null:r;return s.some(r=>{const s=i?[i]:[],c=null==i;for(const e of r.consumes.required){if(e===n){if(c)return!1;continue}const r=t.get(e);if(r)s.push(r);else if("emissive"!==e||!t.get(n)?.hasAttachment(e))return o?.(s),!1}if(r.consumes.optional)for(const e of r.consumes.optional){if(e===n)continue;const r=t.get(e);r&&s.push(r)}try{const o=r.doRender(s);o&&o!==i&&(n!==o.name&&(e.getLogger(r).errorOnce(`RenderNode produced ${o.name}, expected ${n}`),o.setName(n)),i?.release(),i=o,t.set(n,i))}catch(u){e.getLogger(r).errorOnce(u)}return o?.(s),c&&null!=i}),this._context.rctx.enforceState(),i}requireGeometryDepth(){return this._nodes.some(e=>"disabled"!==e.produces&&e.requireGeometryDepth)}get test(){return{nodes:this._nodes}}}export{t as RenderNodes};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{C as t}from"../../../../../chunks/Compositing.glsl.js";import{CompositingTechnique as i}from"../../shaders/CompositingTechnique.js";import{CompositingTechniqueConfiguration as e}from"../../shaders/CompositingTechniqueConfiguration.js";class r{constructor(r,s=0){this._techniques=r,this._parameters=new t,this._configuration=new e,this._configuration.blitMode=s,r.precompile(i,this._configuration),this._configuration.hasOpacityFactor=!0,r.precompile(i,this._configuration),this._configuration.hasOpacityFactor=!1}
|
|
2
|
+
import{C as t}from"../../../../../chunks/Compositing.glsl.js";import{CompositingTechnique as i}from"../../shaders/CompositingTechnique.js";import{CompositingTechniqueConfiguration as e}from"../../shaders/CompositingTechniqueConfiguration.js";class r{constructor(r,s=0){this._techniques=r,this._parameters=new t,this._configuration=new e,this._configuration.blitMode=s,r.precompile(i,this._configuration),this._configuration.hasOpacityFactor=!0,r.precompile(i,this._configuration),this._configuration.hasOpacityFactor=!1}toFramebuffer(t,i,e){this.blitTexture(t,i.getTexture(),e)}blitTexture(t,e,r,s){t.bindFramebuffer(s?.fbo),t.setClearColor(0,0,0,1),t.clear(16384),this._parameters.texture=e;const o=this._techniques.get(i,this._configuration);t.bindTechnique(o,r,this._parameters),t.screen.draw()}blend(t,e,r,s,o=1){this._configuration.hasOpacityFactor=o<1;const n=this._techniques.get(i,this._configuration);return!!n.compiled&&(t.bindFramebuffer(r.fbo),this._parameters.texture=e.getTexture(),this._parameters.opacity=o,t.bindTechnique(n,s,this._parameters),t.screen.draw(),!0)}}export{r as Blit};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import r from"../../../../../core/Logger.js";import{abortMaybe as t,disposeMaybe as s}from"../../../../../core/maybe.js";import{throwIfAborted as i,isAbortError as a}from"../../../../../core/promiseUtils.js";import{watch as o,syncAndInitial as n}from"../../../../../core/reactiveUtils.js";import{property as h,subclass as l}from"../../../../../core/accessorSupport/decorators.js";import{requestImage as
|
|
2
|
+
import{__decorate as e}from"tslib";import r from"../../../../../core/Logger.js";import{abortMaybe as t,disposeMaybe as s}from"../../../../../core/maybe.js";import{throwIfAborted as i,isAbortError as a}from"../../../../../core/promiseUtils.js";import{watch as o,syncAndInitial as n}from"../../../../../core/reactiveUtils.js";import{property as h,subclass as l}from"../../../../../core/accessorSupport/decorators.js";import{requestImage as c}from"../../../../../request/image.js";import{InternalRenderCategory as u}from"../../../webgl.js";import m from"../../../webgl/RenderNode.js";import{SMAABlendWeightsTechnique as d}from"./SMAABlendWeightsTechnique.js";import{SMAABlurTechnique as p}from"./SMAABlurTechnique.js";import{SMAAEdgeDetectTechnique as b}from"./SMAAEdgeDetectTechnique.js";import{SMAAPassParameters as f}from"./SMAAPassParameters.js";import T from"../../../../webgl/Texture.js";import{TextureDescriptor as x}from"../../../../webgl/TextureDescriptor.js";let _=class extends m{constructor(e){super(e),this.produces="disabled",this.consumes={required:[u.ANTIALIASING]},this._areaTexture=null,this._searchTexture=null,this._smaaParameters=new f}initialize(){this.addHandles([o(()=>this.isEnabled(),e=>e?this.view.addUpdatingPromise(this.enable()):this.disable(),n)])}async enable(){if(this.destroyed)return;if(this.produces=u.ANTIALIASING,this.requestRender(1),this._abortController||this._areaTexture&&this._searchTexture)return;this._abortController=new AbortController;const e=this._abortController.signal;try{const r=await import("./SMAAData.js");i(e),await this._loadTextures(r,e),i(e),this.requestRender(1)}catch(t){a(t)||r.getLogger(this).errorOnce(t)}this._abortController=null}async _loadTextures(e,r){i(r);const[t,s]=await Promise.allSettled([c(e.areaTexture,{signal:r}),c(e.searchTexure,{signal:r})]);if(i(r),"fulfilled"!==t.status||"fulfilled"!==s.status)return;const a=this.renderingContext;this._areaTexture=g(a,9729,6407,t.value),this._searchTexture=g(a,9728,6409,s.value)}disable(){this.produces="disabled",this.requestRender(1)}destroy(){this._abortController=t(this._abortController),this._searchTexture=s(this._searchTexture),this._areaTexture=s(this._areaTexture)}precompile(){this.techniques.precompile(b),this.techniques.precompile(d),this.techniques.precompile(p)}render(e){const r=e.find(({name:e})=>e===u.ANTIALIASING);if(!this._areaTexture||!this._searchTexture)return this.requestRender(1),r;const t=this.techniques.get(b),s=this.techniques.get(d),i=this.techniques.get(p);if(!t.compiled||!s.compiled||!i.compiled)return this.requestRender(1),r;const{width:a,height:o}=r.fbo,n=this.renderingContext;n.setViewport(0,0,a,o);const h=this.fboCache.acquire(a,o,"smaa edges",2);n.bindFramebuffer(h.fbo),n.setClearColor(0,0,0,1),n.clear(16384),this._smaaParameters.color=r.getTexture();const l=this.bindParameters;n.bindTechnique(t,l,this._smaaParameters),n.screen.draw();const c=this.fboCache.acquire(a,o,"smaa blend");n.bindFramebuffer(c.fbo),n.setClearColor(0,0,1,1),n.clear(16384),this._smaaParameters.inputTexture=h.getTexture(),this._smaaParameters.areaTexture=this._areaTexture,this._smaaParameters.searchTexture=this._searchTexture,n.bindTechnique(s,l,this._smaaParameters),n.screen.draw(),h.release();const m=this.fboCache.acquire(a,o,u.ANTIALIASING);return n.bindFramebuffer(m.fbo),n.setClearColor(0,1,0,1),n.clear(16384),this._smaaParameters.inputTexture=c.getTexture(),n.bindTechnique(i,l,this._smaaParameters),n.screen.draw(),c.release(),m}};function g(e,r,t,s){const i=new x(s.width,s.height);return i.pixelFormat=t,i.wrapMode=33071,i.samplingMode=r,new T(e,i,s)}e([h()],_.prototype,"produces",void 0),e([h()],_.prototype,"consumes",void 0),e([h({constructOnly:!0})],_.prototype,"isEnabled",void 0),e([h()],_.prototype,"_abortController",void 0),_=e([l("esri.views.3d.webgl-engine.effects.smaa.SMAA")],_);export{_ as SMAA};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import has from"../../../../core/has.js";import{nextPowerOfTwo as e}from"../../../../core/mathUtils.js";import{disposeMaybe as i,destroyMaybe as r}from"../../../../core/maybe.js";import{property as s,subclass as h}from"../../../../core/accessorSupport/decorators.js";import{ortho as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{set as n}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UNIT_X as c,ZEROS as l}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderNodeOutput as d,InternalRenderCategory as p}from"../../webgl.js";import{Frustum as _}from"../../state/Frustum.js";import{glLayout as f}from"../../support/buffer/glUtil.js";import{newLayout as m}from"../../support/buffer/InterleavedLayout.js";import g from"../../webgl/RenderCamera.js";import F from"../../webgl/RenderNode.js";import{ShaderOutputConfiguration as C}from"../core/shaderLibrary/ShaderOutputConfiguration.js";import{VertexArrayObject as w}from"./VertexArrayObject.js";import{C as R}from"../../../../chunks/CutFillDepth.glsl.js";import{CutFillDepthTechnique as P}from"../shaders/CutFillDepthTechnique.js";import{CutFillDepthTechniqueConfiguration as T}from"../shaders/CutFillDepthTechniqueConfiguration.js";import{C as b}from"../../../../chunks/CutFillReduction.glsl.js";import{CutFillReductionTechnique as x}from"../shaders/CutFillReductionTechnique.js";import{CutFillReductionTechniqueConfiguration as D}from"../shaders/CutFillReductionTechniqueConfiguration.js";import{C as B}from"../../../../chunks/CutFillTargetDepth.glsl.js";import{CutFillTargetDepthTechnique as y}from"../shaders/CutFillTargetDepthTechnique.js";import{ImmediateTask as j,TaskPriority as q}from"../../../support/Scheduler.js";import{Yield as S}from"../../../support/Yield.js";import{PrimitiveType as v,DataType as E}from"../../../webgl/enums.js";import{Sync as V}from"../../../webgl/Sync.js";import{VertexBuffer as O}from"../../../webgl/VertexBuffer.js";let A=class extends F{constructor(t){super(t),this.consumes={required:[d.TRANSPARENT]},this.produces=p.CUTFILL_DEPTH,this._cutFillTargetDepthConfiguration=new C,this._cutFillDepthConfiguration=new T,this._cutFillReductionConfiguration=new D,this._cutFillTargetDepthParameters=new B,this._cutFillDepthParameters=new R,this._cutFillReductionParameters=new b,this.needsRender=!1,this.readyToRun=!1,this.done=!0,this._frameTask=j,this._results=new k,this._localOrigin=u(),this._maxTextureSize=4096,this._width=0,this._height=0,this._reducedWidth=0,this._reducedHeight=0,this._depthFormat=14,this._colorFormat=11,this._numChannels=2,this._targetVao=null,this._numReductions=3,this._reductionPasses=0,this._pixelBufferSize=0,this._pixelBufferOffset=0,this._perReductionPixelBufferSize=0}initialize(){this._frameTask=this.view.resourceController.scheduler.registerTask(q.VOLUME_MEASUREMENT,this),this.addHandles(this._frameTask),this._maxTextureSize=Math.min(has("esri-mobile")?1024:this._maxTextureSize,this.fboCache.rctx.parameters.maxTextureSize),this._cutFillTargetDepthConfiguration.output=7,this._frustum=new _(this.view.renderCoordsHelper)}destroy(){this._targetVao=i(this._targetVao);const t=this.gl;this._sync=r(this._sync),this._pixelBuffer&&(t.deleteBuffer(this._pixelBuffer),this._pixelBuffer=null,this._pixelBufferSize=0)}precompile(){this.techniques.precompile(y,this._cutFillTargetDepthConfiguration),this._cutFillDepthConfiguration.preparePass=0,this.techniques.precompile(P,this._cutFillDepthConfiguration),this._cutFillDepthConfiguration.preparePass=1,this.techniques.precompile(P,this._cutFillDepthConfiguration),this._cutFillReductionConfiguration.reductionPass=0,this.techniques.precompile(x,this._cutFillReductionConfiguration),this._cutFillReductionConfiguration.reductionPass=1,this.techniques.precompile(x,this._cutFillReductionConfiguration),this._cutFillReductionConfiguration.reductionPass=2,this.techniques.precompile(x,this._cutFillReductionConfiguration),this.view.stage.renderer.precompileCutFill()}render(t){const e=t.find(({name:t})=>t===p.CUTFILL_DEPTH);if(!this._orthographicCamera||!this._targetVao||!this.needsRender||this._sync)return e;const i=this.techniques.get(y,this._cutFillTargetDepthConfiguration);this._cutFillDepthConfiguration.preparePass=0;const r=this.techniques.get(P,this._cutFillDepthConfiguration);this._cutFillDepthConfiguration.preparePass=1;const s=this.techniques.get(P,this._cutFillDepthConfiguration);this._cutFillReductionConfiguration.reductionPass=0;const h=this.techniques.get(x,this._cutFillReductionConfiguration);this._cutFillReductionConfiguration.reductionPass=1;const o=this.techniques.get(x,this._cutFillReductionConfiguration);this._cutFillReductionConfiguration.reductionPass=2;const n=this.techniques.get(x,this._cutFillReductionConfiguration);if(!(i.compiled&&r.compiled&&s.compiled&&h.compiled&&o.compiled&&n.compiled))return this.requestRender(1),e;this.needsRender=!1;const a=this.renderingContext,u=this.fboCache,d=this.gl,_=a.getViewport(),f=u.acquire(this._width,this._height,"cutfill reference depth",this._depthFormat);a.bindFramebuffer(f.fbo),a.setViewport(0,0,this._width,this._height),a.clear(1280),this.view.stage.renderer.renderCutFillReferenceDepth(this._orthographicCamera);const m=u.acquire(this._width,this._height,"cutfill target depth",this._depthFormat);a.bindFramebuffer(m.fbo),a.setViewport(0,0,this._width,this._height),a.setClearDepth(1),a.clear(256),this._cutFillTargetDepthParameters.origin=this._localOrigin,this._cutFillTargetDepthParameters.cutFillCamera=this._orthographicCamera,a.bindTechnique(i,this.bindParameters,this._cutFillTargetDepthParameters),a.bindVAO(this._targetVao),a.drawArrays(v.TRIANGLES,0,this._targetVao.vertexCount("geometry"));const g=u.acquire(this._width,this._height,"cutfill reduction even",this._colorFormat),F=u.acquire(this._width,this._height,"cutfill reduction odd",this._colorFormat);return this._cutFillDepthParameters.referenceDepthTexture=f.depthTexture,this._cutFillDepthParameters.targetDepthTexture=m.depthTexture,this._pixelBuffer||(this._pixelBuffer=d.createBuffer()),d.bindBuffer(d.PIXEL_PACK_BUFFER,this._pixelBuffer),d.bufferData(d.PIXEL_PACK_BUFFER,this._pixelBufferSize,d.STREAM_READ),this._prepareFBO(g,this.width,this.height),a.bindTechnique(r,this.bindParameters,this._cutFillDepthParameters),a.screen.draw(),this._runPyramidReduction(g,F,h),this._prepareFBO(g,this.width,this.height,c),a.bindTechnique(s,this.bindParameters,this._cutFillDepthParameters),a.screen.draw(),this._runPyramidReduction(g,F,o),this._prepareFBO(g,this.width,this.height,l),a.bindTechnique(s,this.bindParameters,this._cutFillDepthParameters),a.screen.draw(),this._runPyramidReduction(g,F,n),f.release(),m.release(),g.release(),F.release(),d.bindBuffer(d.PIXEL_PACK_BUFFER,null),a.setViewport(_.x,_.y,_.width,_.height),this._sync=new V(d),setTimeout(()=>this.readyToRun=!0,0),e}update(t,i){if(!this.done)return;this.done=!1;const r=this.renderingContext,{cameraDimensions:{width:s,height:h},localOriginRenderSpace:o}=t,n=this._maxTextureSize,a=h/s,u=s>h?n:n/a,c=s>h?n*a:n;this._width=e(u),this._height=e(c);const l=[this._width,this._height];this._orthographicCamera=this._createCamera(t,l),this._frustum?.update(this._orthographicCamera),this._updateTargetVao(r,i),this._localOrigin=o,this._reductionPasses=Math.ceil(Math.log2(Math.min(this._width,this._height))),this._reducedWidth=Math.ceil(this._width/2**this._reductionPasses),this._reducedHeight=Math.ceil(this._height/2**this._reductionPasses),this._perReductionPixelBufferSize=this._reducedWidth*this._reducedHeight*this._numChannels*4,this._pixelBufferSize=this._perReductionPixelBufferSize*this._numReductions,this._pixelBufferOffset=0,this.needsRender=!0,this.requestRender(1)}runTask(){if(!this._sync)return void(this.readyToRun=!1);try{if(!this._sync.poll())return S}catch(e){return this.readyToRun=!1,void(this._sync=r(this._sync))}this.readyToRun=!1,this._sync=r(this._sync);const t=this.gl;this._cpuBuffer=new Float32Array(this._pixelBufferSize/4),t.bindBuffer(t.PIXEL_PACK_BUFFER,this._pixelBuffer),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,this._cpuBuffer),t.bindBuffer(t.PIXEL_PACK_BUFFER,null),this._updateResults(this._cpuBuffer),this.done=!0}getResults(){return this._results}get frustum(){return this._frustum}get width(){return this._width}get height(){return this._height}get updating(){return this.readyToRun||!this.done||this._frameTask.updating}_runPyramidReduction(t,e,i){const r=this.renderingContext,s=this.gl;let h=this._width,o=this._height;for(let n=0;n<this._reductionPasses;n++)h=Math.ceil(h/2),o=Math.ceil(o/2),this._cutFillReductionParameters.depthTexture=t.getTexture(),this._prepareFBO(e,h,o),r.bindTechnique(i,this.bindParameters,this._cutFillReductionParameters),r.screen.draw(),[t,e]=[e,t];s.readPixels(0,0,h,o,33319,E.FLOAT,this._pixelBufferOffset),this._pixelBufferOffset+=this._perReductionPixelBufferSize}_updateResults(t){const e=new U(0,1,a()),i=new U(0,0,a());for(let r=0;r<this._reducedWidth;r++)for(let s=0;s<this._reducedHeight;s++){let h=(r+s*this._reducedWidth)*this._numChannels;const o=this._reducedWidth*this._reducedHeight*this._numChannels;e.totalDepth+=t[h],i.totalDepth+=t[h+1],h+=o;const n=t[h];n<e.labelDepth&&(e.labelDepth=n,L(e.labelCoords,t[h+1],this._width)),h+=o;const a=t[h];a>i.labelDepth&&(i.labelDepth=a,L(i.labelCoords,t[h+1],this._width))}this._results=new k(this._width,this._height,e,i)}_prepareFBO(t,e,i,r=l){const s=this.renderingContext;s.bindFramebuffer(t.fbo),s.setViewport(0,0,e,i),s.setClearColor(r[0],r[1],r[2],r[3]),s.clear(16384)}_createCamera(t,e){const{cameraPositionRenderSpace:i,localOriginRenderSpace:r,northVector:s,cameraDimensions:{width:h,height:n},cameraNearFar:{near:a,far:u}}=t,c=new g({eye:i,center:r,up:s,near:a,far:u});return c.viewport=[0,0,e[0],e[1]],o(c.projectionMatrix,-h/2,h/2,-n/2,n/2,a,u),c}_updateTargetVao(t,e){this._targetVao=i(this._targetVao);const r=e.reduce((t,e)=>t+e.indices.length,0),s=z.createBuffer(r),h=s.position;let o=0;for(const i of e){const{positions:t,indices:e}=i;for(let i=0;i<e.length;++i){const r=3*e[i];h.set(o,0,t[r]),h.set(o,1,t[r+1]),h.set(o,2,t[r+2]),o++}}const n=new O(t,f(z),s.buffer);this._targetVao=new w(t,n)}};t([s()],A.prototype,"consumes",void 0),t([s()],A.prototype,"produces",void 0),t([s()],A.prototype,"needsRender",void 0),t([s()],A.prototype,"readyToRun",void 0),t([s()],A.prototype,"done",void 0),t([s()],A.prototype,"updating",null),t([s()],A.prototype,"_frameTask",void 0),A=t([h("esri.views.3d.webgl-engine.lib.CutFillDepth")],A);const z=m().vec3f("position").freeze();function L(t,e,i){const r=e%i,s=Math.floor(e/i);n(t,r,s)}class M{constructor(t,e){this.positions=t,this.indices=e}}class U{constructor(t,e,i){this.totalDepth=t,this.labelDepth=e,this.labelCoords=i}}class k{constructor(t=0,e=0,i=new U(0,1,a()),r=new U(0,0,a())){this.width=t,this.height=e,this.cut=i,this.fill=r}}export{A as CutFillDepth,U as DepthResult,k as RenderResult,M as TargetGeometryRenderInfo};
|
|
2
|
+
import{__decorate as t}from"tslib";import{nextPowerOfTwo as e}from"../../../../core/mathUtils.js";import{disposeMaybe as i,destroyMaybe as r}from"../../../../core/maybe.js";import{property as s,subclass as h}from"../../../../core/accessorSupport/decorators.js";import{ortho as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{set as n}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UNIT_X as c,ZEROS as l}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderNodeOutput as d,InternalRenderCategory as p}from"../../webgl.js";import{Frustum as _}from"../../state/Frustum.js";import{glLayout as f}from"../../support/buffer/glUtil.js";import{newLayout as m}from"../../support/buffer/InterleavedLayout.js";import g from"../../webgl/RenderCamera.js";import F from"../../webgl/RenderNode.js";import{ShaderOutputConfiguration as C}from"../core/shaderLibrary/ShaderOutputConfiguration.js";import{VertexArrayObject as w}from"./VertexArrayObject.js";import{C as R}from"../../../../chunks/CutFillDepth.glsl.js";import{CutFillDepthTechnique as P}from"../shaders/CutFillDepthTechnique.js";import{CutFillDepthTechniqueConfiguration as T}from"../shaders/CutFillDepthTechniqueConfiguration.js";import{C as b}from"../../../../chunks/CutFillReduction.glsl.js";import{CutFillReductionTechnique as x}from"../shaders/CutFillReductionTechnique.js";import{CutFillReductionTechniqueConfiguration as D}from"../shaders/CutFillReductionTechniqueConfiguration.js";import{C as B}from"../../../../chunks/CutFillTargetDepth.glsl.js";import{CutFillTargetDepthTechnique as y}from"../shaders/CutFillTargetDepthTechnique.js";import{ImmediateTask as j,TaskPriority as q}from"../../../support/Scheduler.js";import{Yield as S}from"../../../support/Yield.js";import{PrimitiveType as v,DataType as E}from"../../../webgl/enums.js";import{Sync as V}from"../../../webgl/Sync.js";import{VertexBuffer as O}from"../../../webgl/VertexBuffer.js";let A=class extends F{constructor(t){super(t),this.consumes={required:[d.TRANSPARENT]},this.produces=p.CUTFILL_DEPTH,this._cutFillTargetDepthConfiguration=new C,this._cutFillDepthConfiguration=new T,this._cutFillReductionConfiguration=new D,this._cutFillTargetDepthParameters=new B,this._cutFillDepthParameters=new R,this._cutFillReductionParameters=new b,this.needsRender=!1,this.readyToRun=!1,this.done=!0,this._frameTask=j,this._results=new k,this._localOrigin=u(),this._maxTextureSize=512,this._width=0,this._height=0,this._reducedWidth=0,this._reducedHeight=0,this._depthFormat=14,this._colorFormat=11,this._numChannels=2,this._targetVao=null,this._numReductions=3,this._reductionPasses=0,this._pixelBufferSize=0,this._pixelBufferOffset=0,this._perReductionPixelBufferSize=0}initialize(){this._frameTask=this.view.resourceController.scheduler.registerTask(q.VOLUME_MEASUREMENT,this),this.addHandles(this._frameTask),this._maxTextureSize=Math.min(this._maxTextureSize,this.fboCache.rctx.parameters.maxTextureSize),this._cutFillTargetDepthConfiguration.output=7,this._frustum=new _(this.view.renderCoordsHelper)}destroy(){this._targetVao=i(this._targetVao);const t=this.gl;this._sync=r(this._sync),this._pixelBuffer&&(t.deleteBuffer(this._pixelBuffer),this._pixelBuffer=null,this._pixelBufferSize=0)}precompile(){this.techniques.precompile(y,this._cutFillTargetDepthConfiguration),this._cutFillDepthConfiguration.preparePass=0,this.techniques.precompile(P,this._cutFillDepthConfiguration),this._cutFillDepthConfiguration.preparePass=1,this.techniques.precompile(P,this._cutFillDepthConfiguration),this._cutFillReductionConfiguration.reductionPass=0,this.techniques.precompile(x,this._cutFillReductionConfiguration),this._cutFillReductionConfiguration.reductionPass=1,this.techniques.precompile(x,this._cutFillReductionConfiguration),this._cutFillReductionConfiguration.reductionPass=2,this.techniques.precompile(x,this._cutFillReductionConfiguration),this.view.stage.renderer.precompileCutFill()}render(t){const e=t.find(({name:t})=>t===p.CUTFILL_DEPTH);if(!this._orthographicCamera||!this._targetVao||!this.needsRender||this._sync)return e;const i=this.techniques.get(y,this._cutFillTargetDepthConfiguration);this._cutFillDepthConfiguration.preparePass=0;const r=this.techniques.get(P,this._cutFillDepthConfiguration);this._cutFillDepthConfiguration.preparePass=1;const s=this.techniques.get(P,this._cutFillDepthConfiguration);this._cutFillReductionConfiguration.reductionPass=0;const h=this.techniques.get(x,this._cutFillReductionConfiguration);this._cutFillReductionConfiguration.reductionPass=1;const o=this.techniques.get(x,this._cutFillReductionConfiguration);this._cutFillReductionConfiguration.reductionPass=2;const n=this.techniques.get(x,this._cutFillReductionConfiguration);if(!(i.compiled&&r.compiled&&s.compiled&&h.compiled&&o.compiled&&n.compiled))return this.requestRender(1),e;this.needsRender=!1;const a=this.renderingContext,u=this.fboCache,d=this.gl,_=a.getViewport(),f=u.acquire(this._width,this._height,"cutfill reference depth",this._depthFormat);a.bindFramebuffer(f.fbo),a.setViewport(0,0,this._width,this._height),a.clear(1280),this.view.stage.renderer.renderCutFillReferenceDepth(this._orthographicCamera);const m=u.acquire(this._width,this._height,"cutfill target depth",this._depthFormat);a.bindFramebuffer(m.fbo),a.setViewport(0,0,this._width,this._height),a.setClearDepth(1),a.clear(256),this._cutFillTargetDepthParameters.origin=this._localOrigin,this._cutFillTargetDepthParameters.cutFillCamera=this._orthographicCamera,a.bindTechnique(i,this.bindParameters,this._cutFillTargetDepthParameters),a.bindVAO(this._targetVao),a.drawArrays(v.TRIANGLES,0,this._targetVao.vertexCount("geometry"));const g=u.acquire(this._width,this._height,"cutfill reduction even",this._colorFormat),F=u.acquire(this._width,this._height,"cutfill reduction odd",this._colorFormat);return this._cutFillDepthParameters.referenceDepthTexture=f.depthTexture,this._cutFillDepthParameters.targetDepthTexture=m.depthTexture,this._pixelBuffer||(this._pixelBuffer=d.createBuffer()),d.bindBuffer(d.PIXEL_PACK_BUFFER,this._pixelBuffer),d.bufferData(d.PIXEL_PACK_BUFFER,this._pixelBufferSize,d.STREAM_READ),this._prepareFBO(g,this.width,this.height),a.bindTechnique(r,this.bindParameters,this._cutFillDepthParameters),a.screen.draw(),this._runPyramidReduction(g,F,h),this._prepareFBO(g,this.width,this.height,c),a.bindTechnique(s,this.bindParameters,this._cutFillDepthParameters),a.screen.draw(),this._runPyramidReduction(g,F,o),this._prepareFBO(g,this.width,this.height,l),a.bindTechnique(s,this.bindParameters,this._cutFillDepthParameters),a.screen.draw(),this._runPyramidReduction(g,F,n),f.release(),m.release(),g.release(),F.release(),d.bindBuffer(d.PIXEL_PACK_BUFFER,null),a.setViewport(_.x,_.y,_.width,_.height),this._sync=new V(d),setTimeout(()=>this.readyToRun=!0,0),e}update(t,i){if(!this.done)return;this.done=!1;const r=this.renderingContext,{cameraDimensions:{width:s,height:h},localOriginRenderSpace:o}=t,n=this._maxTextureSize,a=h/s,u=s>h?n:n/a,c=s>h?n*a:n;this._width=e(u),this._height=e(c);const l=[this._width,this._height];this._orthographicCamera=this._createCamera(t,l),this._frustum?.update(this._orthographicCamera),this._updateTargetVao(r,i),this._localOrigin=o,this._reductionPasses=Math.ceil(Math.log2(Math.min(this._width,this._height))),this._reducedWidth=Math.ceil(this._width/2**this._reductionPasses),this._reducedHeight=Math.ceil(this._height/2**this._reductionPasses),this._perReductionPixelBufferSize=this._reducedWidth*this._reducedHeight*this._numChannels*4,this._pixelBufferSize=this._perReductionPixelBufferSize*this._numReductions,this._pixelBufferOffset=0,this.needsRender=!0,this.requestRender(1)}runTask(){if(!this._sync)return void(this.readyToRun=!1);try{if(!this._sync.poll())return S}catch(e){return this.readyToRun=!1,void(this._sync=r(this._sync))}this.readyToRun=!1,this._sync=r(this._sync);const t=this.gl;this._cpuBuffer=new Float32Array(this._pixelBufferSize/4),t.bindBuffer(t.PIXEL_PACK_BUFFER,this._pixelBuffer),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,this._cpuBuffer),t.bindBuffer(t.PIXEL_PACK_BUFFER,null),this._updateResults(this._cpuBuffer),this.done=!0}getResults(){return this._results}get frustum(){return this._frustum}get width(){return this._width}get height(){return this._height}get updating(){return this.readyToRun||!this.done||this._frameTask.updating}_runPyramidReduction(t,e,i){const r=this.renderingContext,s=this.gl;let h=this._width,o=this._height;for(let n=0;n<this._reductionPasses;n++)h=Math.ceil(h/2),o=Math.ceil(o/2),this._cutFillReductionParameters.depthTexture=t.getTexture(),this._prepareFBO(e,h,o),r.bindTechnique(i,this.bindParameters,this._cutFillReductionParameters),r.screen.draw(),[t,e]=[e,t];s.readPixels(0,0,h,o,33319,E.FLOAT,this._pixelBufferOffset),this._pixelBufferOffset+=this._perReductionPixelBufferSize}_updateResults(t){const e=new U(0,1,a()),i=new U(0,0,a());for(let r=0;r<this._reducedWidth;r++)for(let s=0;s<this._reducedHeight;s++){let h=(r+s*this._reducedWidth)*this._numChannels;const o=this._reducedWidth*this._reducedHeight*this._numChannels;e.totalDepth+=t[h],i.totalDepth+=t[h+1],h+=o;const n=t[h];n<e.labelDepth&&(e.labelDepth=n,L(e.labelCoords,t[h+1],this._width)),h+=o;const a=t[h];a>i.labelDepth&&(i.labelDepth=a,L(i.labelCoords,t[h+1],this._width))}this._results=new k(this._width,this._height,e,i)}_prepareFBO(t,e,i,r=l){const s=this.renderingContext;s.bindFramebuffer(t.fbo),s.setViewport(0,0,e,i),s.setClearColor(r[0],r[1],r[2],r[3]),s.clear(16384)}_createCamera(t,e){const{cameraPositionRenderSpace:i,localOriginRenderSpace:r,northVector:s,cameraDimensions:{width:h,height:n},cameraNearFar:{near:a,far:u}}=t,c=new g({eye:i,center:r,up:s,near:a,far:u});return c.viewport=[0,0,e[0],e[1]],o(c.projectionMatrix,-h/2,h/2,-n/2,n/2,a,u),c}_updateTargetVao(t,e){this._targetVao=i(this._targetVao);const r=e.reduce((t,e)=>t+e.indices.length,0),s=z.createBuffer(r),h=s.position;let o=0;for(const i of e){const{positions:t,indices:e}=i;for(let i=0;i<e.length;++i){const r=3*e[i];h.set(o,0,t[r]),h.set(o,1,t[r+1]),h.set(o,2,t[r+2]),o++}}const n=new O(t,f(z),s.buffer);this._targetVao=new w(t,n)}};t([s()],A.prototype,"consumes",void 0),t([s()],A.prototype,"produces",void 0),t([s()],A.prototype,"needsRender",void 0),t([s()],A.prototype,"readyToRun",void 0),t([s()],A.prototype,"done",void 0),t([s()],A.prototype,"updating",null),t([s()],A.prototype,"_frameTask",void 0),A=t([h("esri.views.3d.webgl-engine.lib.CutFillDepth")],A);const z=m().vec3f("position").freeze();function L(t,e,i){const r=e%i,s=Math.floor(e/i);n(t,r,s)}class M{constructor(t,e){this.positions=t,this.indices=e}}class U{constructor(t,e,i){this.totalDepth=t,this.labelDepth=e,this.labelCoords=i}}class k{constructor(t=0,e=0,i=new U(0,1,a()),r=new U(0,0,a())){this.width=t,this.height=e,this.cut=i,this.fill=r}}export{A as CutFillDepth,U as DepthResult,k as RenderResult,M as TargetGeometryRenderInfo};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{releaseMaybe as t}from"../../../../core/maybe.js";import{copy as
|
|
2
|
+
import{releaseMaybe as t}from"../../../../core/maybe.js";import{copy as s}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as i,ZEROS as e}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ViewportSize as r}from"./BindParameters.js";import{ColorAttachment1 as o}from"../../../webgl/enums.js";import{ensureAttachmentMaxSize as h}from"../../../webgl/FramebufferObject.js";class l{constructor(t){this._fbos=t,this._hasEmission=!1,this._size=new r(0,0),this._clearColor=i()}dispose(){this._color=t(this._color),this.releaseDepth()}initialize(t,i,e,r){const o=this._color;return this._color=null,this.releaseDepth(),this._hasEmission=r,this._size.width=t,this._size.height=i,h(this._size,this._fbos.rctx.parameters.maxTextureSize),s(this._clearColor,e),o}releaseDepth(){this._color?.detachDepth(),this._depth=t(this._depth)}update(t){const s=this._ensureColor();return s.attachDepth(this.depth),this._color=t(s),this._color}bind(){const{rctx:t}=this._fbos,s=null==this._color;this.color.attachDepth(this.depth),t.bindFramebuffer(this.color.fbo),s&&(t.setClearStencil(0),t.setClearColor(this._clearColor[0],this._clearColor[1],this._clearColor[2],this._clearColor[3]),t.clear(17664),this._hasEmission&&t.clearBuffer(1,e))}get size(){return this._size}get color(){return this._ensureColor()}get depth(){return this._depth??=this._fbos.acquireDepth(14,this._size.width,this._size.height,"main depth"),this._depth}_ensureColor(){return this._color??=this._hasEmission?this._fbos.acquire(this._size.width,this._size.height,"main color").acquireColor(o,8,"emissive"):this._fbos.acquire(this._size.width,this._size.height,"main color"),this._color}}export{l as MainFramebuffer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import{removeMaybe as s,abortMaybe as i,destroyMaybe as n,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAborted as h}from"../../../../core/promiseUtils.js";import{watch as o,syncAndInitial as d,initial as _,sync as l}from"../../../../core/reactiveUtils.js";import{signal as u}from"../../../../core/signal.js";import{property as p,subclass as c}from"../../../../core/accessorSupport/decorators.js";import{equals as m,invert as f,multiply as g}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as b,create as C}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as P}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as w,ZEROS as T}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as E}from"../../../../geometry/support/Indices.js";import{RenderNodeOutput as A,InternalRenderCategory as x,AllRenderNodeOutputs as S,AllInternalRenderNodeOutputs as D}from"../../webgl.js";import{innerAtmosphereFadeStart as I}from"../../environment/atmosphereUtils.js";import{minNearDistanceInMeters as R}from"../../state/NearFarHeuristic.js";import{debugFlags as y}from"../../support/debugFlags.js";import{FBOCache as H,defaultWebGLFBO as O}from"../core/FBOCache.js";import{RenderPassManager as v}from"../core/renderPasses/RenderPassManager.js";import{isColor as F}from"../core/shaderLibrary/ShaderOutput.js";import{distanceFadeEnd as M}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as N}from"../effects/RenderNodes.js";import{RenderPluginManager as G}from"../effects/RenderPluginManager.js";import{Blit as q}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as L,renderHighlightBuffer as U}from"../effects/highlight/Highlight.js";import{OITBlend as V}from"../effects/transparency/OITBlend.js";import{AnimationTimer as j}from"./AnimationTimer.js";import{AnimationTimeStep as B}from"./AnimationTimeStep.js";import{BoundingInfo as k}from"./BoundingInfo.js";import{DepthRange as z}from"./DepthRange.js";import{depthRangeFromScene as W}from"./depthRangeUtils.js";import{MainFramebuffer as Q}from"./MainFramebuffer.js";import{RenderContext as Y,defaultRenderOccludedMask as J}from"./RenderContext.js";import{RendererBase as K}from"./RendererBase.js";import{setupFeatureDefaults as X}from"./RenderFeature.js";import{RenderPluginInput as Z}from"./RenderPluginInput.js";import{ShadowAccumulator as $}from"./ShadowAccumulator.js";import{ShadowMap as ee}from"./ShadowMap.js";import te from"./SliceHelper.js";import{MergedRenderer as re}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as se}from"../parts/renderUtils.js";import{RendererPerformanceInfo as ie,PerformanceCategory as ne}from"../statistics/RendererPerformanceInfo.js";import{PixelType as ae,ColorAttachment1 as he,ColorAttachment2 as oe,ColorAttachment0 as de}from"../../../webgl/enums.js";let _e=class extends K{constructor(e,t,r,s,i,n){super({stage:e}),this._techniques=r,this._rctx=s,this._compositingHelper=i,this._requestRender=n,this._pluginsHas={occludedHudElements:!1,hudElements:!1,water:!1},this.renderPassManager=new v,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=w(0,0,0,1),this._sliceHelper=new te,this.sceneDepthRange=u(z.Infinite),this._state=u(2),this._hasAnimations=!1,this._animationTimestep=new B,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=u(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new Z,this._oitCallouts=!1,this._releaseNodeInputs=e=>{for(const t of we)e.some(({name:e})=>e===t)&&this._pluginInput.release(t)},this._debugNeedsDepth=!1,this._fboCache=new H(s),this._renderStateFeatures=u(X(e.view.qualityProfile)),this._framebuffer=new Q(this.fboCache),this._performanceInfo=new ie(this._rctx),this._shadowMap=new ee(this.fboCache,e.viewingMode),this._blit=new q(r),this._shadowAccumulator=new $(this.fboCache,r,e,e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t},(t,r,s)=>{const i=e.view.qualitySettings.maximumPixelRatio;t.shadowMap.start(t.camera,r,s,!0,i),this._renderShadowCascades(3,t.shadowMap),t.shadowMap.finish(),t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.contentCamera)},n),this._renderContext=new Y(this._rctx,this._shadowMap,r),this._nodes=new N(this._renderContext),this._plugins=new G({renderContext:this._renderContext,techniques:r,materials:t,requestRender:n,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this.addHandles([o(()=>e.view.state.camera,()=>n(),d),o(()=>y.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES,e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(0):()=>{},n()},_),o(()=>e.view.environment.background?.color,e=>{const t=e?e.toUnitRGBA():T;P(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()},d),o(()=>e.view.state.camera.relativeElevation,e=>this._inGlobeView=(e??1/0)>=M,d),o(()=>this._bindParameters.clouds.fadeFactor,()=>{this._bindParameters.fadeLighting(),this._requestRender(2)},l),o(()=>this._bindParameters.clouds.data?.state,()=>n(),l),o(()=>e.view.state.highlights,e=>{this._bindParameters.highlights=e,n()},_)])}destroy(){this._gpuTimerHandle=s(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.destroy(),this._shadowAccumulator=null,this._loadEdgeViewTask=i(this._loadEdgeViewTask),this._edgeView=n(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this._fboCache.destroy(),this._fboCache=null,this._plugins.destroy(),this._plugins=null,this._pluginInput=null,this._oitBlend=null,this._compositingHelper=null,this._nodes=null,this._framebuffer=null,this._shadowMap=null,this._renderContext=null,this._performanceInfo=null,k.prune(),re.prune(),E()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get performanceInfo(){return this._performanceInfo}updateRenderFeatures(e){this._renderStateFeatures.value=X(e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate(s=>s.set(t,e,r)),this._requestRender()}get _highQualityTransparency(){return this.isFeatureEnabled(1)}get hasReflections(){return this._pluginsHas.water&&this.isFeatureEnabled(6)}get _hasHighlights(){return this._plugins.produces(8,2,4,20,14,15,16)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(8,14,15,16)}get hasSSAO(){return this.isFeatureEnabled(5)&&!this._inGlobeView}get hasSMAA(){return this.isFeatureEnabled(0)}get hasEmitters(){return this._plugins.hasEmitters&&this._hasFloatBufferBlendSupport}get highResolutionAtmosphere(){return this.isFeatureEnabled(4)}get fboCache(){return this._fboCache}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=a(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=a(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=a(this._bindParameters.geometryDepth),this._bindParameters.hudOcclusion=a(this._bindParameters.hudOcclusion)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeBuffers(),this._bindParameters.depth=a(this._bindParameters.depth),this._bindParameters.hudVisibility=a(this._bindParameters.hudVisibility)}get updating(){return this._loadEdgeViewTask&&!this._loadEdgeViewTask.finished||this._edgeView?.updating||this._shadowAccumulator.readyToRun||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=r(async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");h(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this.stage.view.renderSpatialReference,viewingMode:this.stage.view.stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:xe(this.stage.view.resourceController)});return this.addHandles(o(()=>r.updating,()=>this._requestRender(),l)),this._requestRender(),this._edgeViewCallbacks.forEach(e=>e(r)),this._edgeViewCallbacks.length=0,r})),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&m(this._bindParameters.ssr.reprojectionMatrix,b)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:r}=this;if(void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&t.maxCascades!==e.shadowMapMaxCascades&&(t.maxCascades=e.shadowMapMaxCascades,this._requestRender()),e.environment){void 0!==e.environment.weather&&(this._bindParameters.weather=e.environment.weather);const t="virtual"!==e.environment.lighting.type;r.enableFillLights!==t&&(r.enableFillLights=t,this._requestRender())}void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}set slice(e){this._sliceHelper.update(e)&&this._requestRender()}get plugins(){return this._plugins}get _hasFloatBufferBlendSupport(){return this._rctx.driverTest.floatBufferBlend.result}get oitEnabled(){return this.isFeatureEnabled(2)&&this._hasFloatBufferBlendSupport}commit(e,t){return this._isRendering&&console.warn("Renderer.modify called while rendering"),!!super.commit(e,t,this._plugins.context)&&(this.updateHasFlags(),!0)}rendererAdded(e){this._plugins.add(e)}rendererRemoved(e){this._plugins.remove(e)}get occludedRequiresStencil(){return this.occludedRequiresOccludeeStencil||this.occludedRequiresIntegratedMeshStencil}get occludedRequiresOccludeeStencil(){return this._bindParameters.hasOccludees&&!!(8&this.plugins.renderOccludedFlags)}get occludedRequiresIntegratedMeshStencil(){return this._plugins.produces(0,0)&&this._plugins.produces(0,10)}updateHasFlags(){const has=this._pluginsHas;has.occludedHudElements=this._plugins.produces(0,15),has.hudElements=has.occludedHudElements||this._plugins.produces(0,...ge),has.water=this._plugins.produces(2,21),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new j(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const r=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?s(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,r,s=!1){try{return this._isRendering=!0,this._render(e,t,r,s)}catch(i){console.error(`Exception during rendering: ${i}`)}finally{this._isRendering=!1}return new se(this._pluginInput.get(A.FINAL),null)}_render(e,t,r,s){const i=0===r;this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=i,this._disposeBindBuffers();const{camera:n,contentCamera:a,mode:h,alignPixelEnabled:o}=e;this._state.value=h;const d=this._nodes.produces("magnifier-color"),_=this._nodes.produces(A.FINAL);this._renderContext.time=t,this._renderContext.output=0,this._bindParameters.hasEmission=this.hasEmitters,this._bindParameters.oitPass=0,this._bindParameters.alignPixelEnabled=o,this._bindParameters.decorations=!s,this._bindParameters.mainDepth=null;const l=!s||!this._sliceHelper.isDecoration;this._bindParameters.slicePlane=l?this._sliceHelper.plane:null,this._bindParameters.viewshedEnabled=this._nodes.produces(x.VIEWSHED),this._bindParameters.cutFillEnabled=this._nodes.produces(x.CUTFILL_DEPTH),this._renderOverlay(),n.setGLViewport(this._rctx);const u=this._framebuffer,p=u.initialize(n.fullWidth,n.fullHeight,this._backgroundColor,this._bindParameters.hasEmission);this.hasReflections?(p?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=p):p?.release(),this._ensureBindParametersCamera(n,a),this._plugins.sortTestsTransparentOrderedSlots(Ce),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!s;const c=this._plugins.produces(0,...ue);this._precompilePrepasses(),this.performanceInfo.advance(ne.PREPARE);const m=this._computeShadowDepthRange(n);this._renderShadowMap(n,this._bindParameters.lighting.mainLight.direction,m),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(m,n,a,!i),this._oitCallouts=c&&this.oitEnabled,this._ensureBindParametersSSR(t),this._precompileShaders(c),this._renderContext.output=0,u.bind(),this._bindParameters.mainDepth=u.depth.attachment,this._renderOpaque(),this._renderTransparent(c),this._shadowMap.disposeMainBuffer(),this._pluginInput.set(x.FOCUSAREA,this._renderFocusAreaGeometry()),this._pluginInput.set(x.CUTFILL_DEPTH,this._renderCutFillDepth()),u.update(e=>this._renderNodes(x.TRANSPARENT_ENVIRONMENT,e)),u.update(e=>this._renderNodes(x.VIEWSHED,e)),u.update(e=>this._renderNodes(x.LASERLINES,e)),u.update(e=>this._renderNodes(x.FOCUSAREA_COLOR,e)),this._pluginInput.release(x.FOCUSAREA),this._pluginInput.release(x.CUTFILL_DEPTH),u.update(e=>this._renderNodes(x.OCCLUDED,e)),this._pluginInput.set("highlights",this._renderHighlightPrepass()),this._renderHighlightShadowMap(n,this._bindParameters.lighting.mainLight.direction,m);const f=2===r?this._renderObjectAndLayerIdColor():null;u.update(e=>this._renderNodes(A.COMPOSITE,e)),this._shadowMap.disposeBuffers();const g=i&&!_&&!(d&&!s),b=this._pluginInput.get(A.COMPOSITE),C=g?O:this.fboCache.acquire(b.fbo.width,b.fbo.height,x.ANTIALIASING),P=this._nodes.produces(x.ANTIALIASING)?this._renderNodes(x.ANTIALIASING,C):this.blitFBO(b,C,!1);let w;this._pluginInput.set(x.ANTIALIASING,P);const T=this._hasPhotoshopTerrain||!c?1:2;this._bindParameters.hasEmission=!1,this._hasHUDHighlights?(this._renderHUD(T,P),w=this._renderNodes(x.HIGHLIGHT_COLOR,P)):(w=this._renderNodes(x.HIGHLIGHT_COLOR,P),this._renderHUD(T,w)),this._bindParameters.hasEmission=this.hasEmitters;const E=this._renderNodes(x.MAGNIFIER,w);return i&&d&&!s&&!_&&this.blitFBO(E),_?(E.attachDepth(u.depth),this.blitFBO(this._renderNodes(A.FINAL,E)),E.detachDepth()):this._pluginInput.set(A.FINAL,E),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),u.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),i||(this._releaseFBOs(),this._disposeOffscreenBuffers()),this.performanceInfo.finishFrame(),new se(this._pluginInput.get(A.FINAL),f)}_precompileShaders(e){++this._plugins.context.techniques.precompiling,this._renderContext.output=0,this._precompileOpaqueGeometry(),this._nodes.precompile(x.OPAQUE_ENVIRONMENT),this._nodes.precompile(x.GAUSSIAN_SPLAT);const t=this._bindParameters;t.terrainDepthTest=t.cullAboveTerrain=this._needsTerrainDepth,this._renderContext.output=1,this._plugins.precompile(...pe),this._needsTerrainDepth&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._renderContext.output=0,this._plugins.precompile(...pe),e&&(this._precompileTransparentGeometry(),this._hasPhotoshopTerrain&&(t.cullAboveTerrain=!1,this._precompileTransparentGeometry(),t.cullAboveTerrain=this._needsTerrainDepth)),this._nodes.precompile(x.FOCUSAREA),this._needsHUDVisibility&&this._plugins.precompile(13),this._oitCallouts||this._plugins.precompile(17),this._precompileHUD(0),t.terrainDepthTest=t.cullAboveTerrain=!1,this._nodes.precompile(x.VIEWSHED,x.CUTFILL_DEPTH,x.CUTFILL_COLOR,x.LASERLINES,x.FOCUSAREA_COLOR,x.OCCLUDED,x.ANTIALIASING,x.HIGHLIGHT_COLOR),t.highlightMixTexture=t.highlights.length>1?this._rctx.emptyTexture:null,t.hasEmission=!1,this._precompileHUD(1),this.oitEnabled&&this._precompileHUD(0),t.hasEmission=this.hasEmitters,this._hasHighlights&&(t.highlights.forEach((e,r)=>{t.highlightLevel=r,this._precompileAllGeometry(8)}),t.highlightLevel=null),t.highlightMixTexture=null,this._nodes.precompile(A.COMPOSITE,x.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(9),--this._plugins.context.techniques.precompiling}_renderFocusAreaGeometry(){const e=this._nodes.produce(x.FOCUSAREA,this._pluginInput);return e&&this.performanceInfo.advance(ne.FOCUS_AREA_MASK),e}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._renderContext.output;++this._techniques.precompiling;const{width:t,height:r}=this._framebuffer.size;let s=this.fboCache.acquire(t,r,"olid");return s.acquireDepth(14),s=this._nodes.render(s,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(ne.OBJECT_AND_LAYER_ID_COLOR),this._renderContext.output=e,s}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=0===e;if(r||t){const e=r?this.performanceInfo.elapsedTime:0;let s=0;t?s=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const i=Math.max(e,s);this._animationTimestep.frame(i,r)}}readMainDepth(e,t){const{mainDepth:r,camera:s}=this._bindParameters;if(!r)return;const i=this.fboCache.acquire(this._framebuffer.size.width,this._framebuffer.size.height,"linear depth");this._rctx.bindFramebuffer(i.fbo),s.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(T),this._compositingHelper.blitDepthToLinearDepth(this._bindParameters,r),this._rctx.setScissorTestEnabled(!1),this._rctx.setScissorRect(0,0,this._rctx.gl.canvas.width,this._rctx.gl.canvas.width),i.fbo?.readPixels(e[0],e[1],e[2],e[3],6408,ae.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,t,r,s,i){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,s,6408,ae.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const{width:r,height:s}=this._framebuffer.size,i=this.fboCache.acquire(r,s,"edges"),n=this._bindParameters.geometryDepth,a=()=>t.render(this._bindParameters,e);this._renderToTargets(a,i,n??this._framebuffer.depth,T),this._framebuffer.bind(),this._compositingHelper.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(1===e?ne.OPAQUE_EDGES:ne.TRANSPARENT_EDGES)}_renderOverlay(){this._bindParameters.overlay=this.overlay?.render(this._renderContext.time),this._bindParameters.overlay&&this.performanceInfo.advance(ne.OVERLAY)}_renderShadowMap(e,t,r){if(!this.shadowsEnabled)return;const s=this._shadowMap;s.start(e,t,r,this.isFeatureEnabled(7),this.stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(5,this._shadowMap),s.copySnapshot(1),this._renderShadowCascades(4,this._shadowMap)):this._renderShadowCascades(3),s.finish(),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,this._bindParameters.contentCamera),this.performanceInfo.advance(ne.SHADOW_MAP)}_renderHighlightShadowMap(e,t,r){if(!this.shadowsEnabled||!this._needsShadowHighlight)return;const s=this._shadowMap;s.start(e,t,r,this.isFeatureEnabled(7),this.stage.view.qualitySettings.maximumPixelRatio),this._renderShadowCascades(4,this._shadowMap),s.moveSnapshot(0),s.finish(),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,this._bindParameters.contentCamera),this.performanceInfo.advance(ne.SHADOW_MAP)}_renderCutFillDepth(){return this._nodes.produce(x.CUTFILL_DEPTH,this._pluginInput)}_precompileShadowCascades(e){0!==this._shadowMap.cascades.length&&this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){t.bindFbo();for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e)}get _needsDepth(){return this._plugins.consumes(1)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._shadowAccumulator.active||this._debugNeedsDepth}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");e?(this._pluginInput.set(x.SSAO,this._renderSSAO()),this._needsDepth?(this._rctx.bindFramebuffer(e.fbo),this._rctx.clear(1024),this._renderGeometryWithoutNormals(1),this._bindParameters.depth?.release(),this._bindParameters.depth=e.obtainDepthTexture(),this.performanceInfo.advance(ne.DEPTH)):(e.detachDepth(),this._bindParameters.depth=a(this._bindParameters.depth)),this.hasSSAO&&this._pluginInput.release("normals")):this._renderAllGeometryDepth()}_renderAllGeometryDepth(){if(this._bindParameters.depth=a(this._bindParameters.depth),!this._needsDepth)return;const{width:e,height:t}=this._framebuffer.size,r=this.fboCache.acquire(e,t,"geometry depth",14);this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(1280),this.renderAllGeometry(1),this._bindParameters.depth=r.obtainDepthTexture(),r.release(),this.performanceInfo.advance(ne.DEPTH)}_renderTerrainDepth(){if(this._bindParameters.terrainDepth=a(this._bindParameters.terrainDepth),this._bindParameters.terrainDepthTest=this._bindParameters.cullAboveTerrain=this._needsTerrainDepth,!this._needsTerrainDepth)return;const e=this._renderContext.output;this._renderContext.output=1;const{width:t,height:r}=this._framebuffer.size,s=this.fboCache.acquire(t,r,"terrain depth",14);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(1280),this._renderTransparentGround(),this._bindParameters.terrainDepth=s.obtainDepthTexture(),s.release(),this._renderContext.output=e}_renderGeometryDepth(){if(this._bindParameters.geometryDepth=a(this._bindParameters.geometryDepth),!this._needsTerrainDepth)return;const e=this._renderContext.output,{width:t,height:r}=this._framebuffer.size,s=this.fboCache.acquire(t,r,"geometry depth",14);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(1280),this._renderOpaqueAndTransparentGeometry(1),this._renderContext.output=e,this._bindParameters.geometryDepth=s.obtainDepthTexture(),s.release()}get _needsShadowDepthRange(){return this._shadowMap.enabled||this._shadowAccumulator.active}_computeShadowDepthRange(e){if(!this._needsShadowDepthRange)return z.Zero;const t=W(e,this._plugins.plugins,this.stage.layers,0);return t.union(this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}updateSceneDepthRange(e){if(!this.stage.view.state.isGlobal)return void(this.sceneDepthRange.value=z.Infinite);if((this.stage.view.renderCoordsHelper?.getAltitude(e.eye)??0)<I)return void(this.sceneDepthRange.value=z.Infinite);const t=e.clone();t.near=R,t.far=1e10;const r=W(t,this._plugins.plugins,this.stage.layers,1);r.union(this._plugins.queryDepthRange(t)),this.sceneDepthRange.value.equals(r)||(this.sceneDepthRange.value=r)}get _normalsRequired(){const e=this._nodes.require("normals",...S,x.VIEWSHED,x.LASERLINES);return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(2),this._needsDepth&&this._precompileAllGeometry(1),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(4),this._precompileShadowCascades(5)):this._precompileShadowCascades(3)),this._shadowAccumulator.active&&this._precompileAllGeometry(3)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const{width:t,height:r}=this._framebuffer.size,s=this.fboCache.acquire(t,r,"normals",5);s.acquireDepth(14),this._rctx.bindFramebuffer(s.fbo),this._rctx.clearFramebuffer(T,!0,!0),this._renderContext.output=2,this._plugins.render(...ce);const i=this._nodes.optional("normals",...S,x.VIEWSHED);return s.retain(e+i-1),this.performanceInfo.advance(ne.NORMALS),s}_renderSSAO(){const e=this._pluginInput.get("normals");if(this.hasSSAO&&e)return this._bindParameters.ssao=this._nodes.produce(x.SSAO,this._pluginInput),this._bindParameters.ssao&&this.performanceInfo.advance(ne.SSAO),this._bindParameters.ssao}_precompileAllGeometry(e){const t=this._renderContext.output;this._renderContext.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(...pe),this._renderContext.output=t}renderAllGeometry(e){this._renderContext.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentGround()}precompileSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const r of t)this._renderContext.renderOccludedMask=r,this.precompileSlots(e,...fe);this._renderContext.renderOccludedMask=J}renderSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.forAll(e=>{const t=e.acquireTechniques(this._renderContext);t&&e.render(this._renderContext,t)})}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>1&&this._plugins.render(10),this.renderSlots(e,...fe),this._renderContext.renderOccludedMask=J}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(...Pe[e])}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(18),this.renderHUD(e),this._bindParameters.hudRenderStyle=e,this._plugins.render(16)}precompileViewshedShadowMap(){this._precompileAllGeometry(6)}precompileCutFill(){const e=7,t=this._renderContext.output;this._renderContext.output=e,this._plugins.precompile(0,1,...pe),this._renderContext.output=t}renderViewshedShadowMap(e){const{camera:t,contentCamera:r}=this._bindParameters,s=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(6),this._ensureBindParametersCamera(t,r),this._bindParameters.camera.setGLViewport(this._rctx),this._renderContext.output=s}renderCutFillReferenceDepth(e){const{camera:t,contentCamera:r}=this._bindParameters,s=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this._renderContext.output=7,this._plugins.render(0,1,...pe),this._ensureBindParametersCamera(t,r),t.setGLViewport(this._rctx),this._renderContext.output=s}_renderOpaqueAndTransparentGeometry(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithoutNormals(e){this._renderContext.output=e,this._plugins.render(...me)}_precompileOpaqueGeometry(){this._plugins.precompile(...le),this._nodes.precompile("opaque-color")}_renderOpaqueGeometry(){this._plugins.render(...le)}_renderTransparentGeometry(){this._plugins.render(...ue),this._oitCallouts&&this._plugins.render(17)}get _hasPhotoshopTerrain(){return this._plugins.produces(0,6)}get _needsTerrainDepth(){return this._highQualityTransparency&&this._hasPhotoshopTerrain}_renderPhotoshopTerrain(){if(!this._hasPhotoshopTerrain)return null;const{width:e,height:t}=this._framebuffer.size,r=this.fboCache.acquire(e,t,"transparent terrain"),s=()=>this._plugins.render(6);return this._renderToTargets(s,r,this._framebuffer.depth,T),this.performanceInfo.advance(ne.TRANSPARENT_TERRAIN),r}_renderTransparentGround(){this._plugins.render(...pe)}get _needsHUDVisibility(){return this._plugins.produces(this._renderContext.output,13)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=a(this._bindParameters.hudVisibility));const{width:e,height:t}=this._framebuffer.size;let r=this._bindParameters.hudVisibility;r?.fbo?.width===e&&r?.fbo?.height===t||(r?.release(),r=this.fboCache.acquire(e,t,"hud visibility",4),this._bindParameters.hudVisibility=r);const s=this._bindParameters.geometryDepth;r.attachDepth(s||this._framebuffer.depth),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(13),r.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(ne.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,0===e){const e=()=>this._plugins.render(17),{width:t,height:r}=this._framebuffer.size,s=this.fboCache.acquireDepth(13,t,r,"line callouts");this._renderToTargets(e,this._framebuffer.color,s,void 0,!0,!0),s.release()}else this._plugins.render(17)}_precompileHUD(e){if(this._precompileHUDOutput(e),this._hasHighlights){const t=this._renderContext.output;this._renderContext.output=8,this._precompileHUDOutput(e),this._renderContext.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this.oitEnabled&&F(this._renderContext.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...ge),this._bindParameters.oitPass=2,this._plugins.precompile(...ge),this._bindParameters.oitPass=0):this._plugins.precompile(...ge),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t){if(this._pluginsHas.hudElements){if(this.oitEnabled){const r=this._renderOIT(1,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,r.getTexture(),!1),r.release()}else if(this._renderContext.output=0,0===e){const t=()=>this._renderHUDElements(e),{width:r,height:s}=this._framebuffer.size,i=this.fboCache.acquireDepth(13,r,s,"hud");this._renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(13),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(0===e?ne.HUD_OCCLUDED:ne.HUD)}}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(4,2)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:r}=this,{width:s,height:i}=this._framebuffer.size,{highlights:n}=r,a=n.length>L?3:1,h=e.acquire(s,i,"highlights",a);h.acquireDepth(14);const o=this._plugins.produces(8,0);return o&&this._framebuffer.color.fbo&&h.fbo&&t.blitFramebuffer(this._framebuffer.color.fbo,h.fbo,1024),t.bindFramebuffer(h.fbo),t.gl.clearBufferuiv(6144,0,[0,0,0,0]),o||t.clear(1024),this._renderContext.output=8,t.bindFramebuffer(h.fbo),U(t,e,s,i,r,()=>this._renderHighlightGeometries()),h.detachDepth(),this.performanceInfo.advance(ne.HIGHLIGHTS),h.retain(this._nodes.require("highlights",...D)+this._nodes.optional("highlights",...D)-1),h}_renderHighlightGeometries(){this._plugins.render(...be),this._rctx.clear(256),this._renderHUDElements(2)}_renderShadowAccumulation(e,t,r,s){this._shadowAccumulator.updateDepthRange(e),this._shadowAccumulator.accumulating&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,t,r,s)&&this.performanceInfo.advance(ne.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this.oitEnabled&&F(this._renderContext.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...ue),this._oitCallouts&&this._plugins.precompile(17),this._bindParameters.oitPass=2,this._plugins.precompile(...ue),this._oitCallouts&&this._plugins.precompile(17),this._bindParameters.oitPass=0):this._plugins.precompile(...ue)}_renderOIT(e,t=2){const r=1===e,{width:s,height:i}=this._framebuffer.size,n=r?()=>this._renderHUDElements(t):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._renderContext.output;this._renderContext.output=0,h.oitPass=1;const d=r?"oit hud":"oit",_=this.fboCache.acquire(s,i,d,8),l=this._bindParameters.hasEmission&&(0===e||1!==t);l&&_.acquireColor(he,8,"oit emissive");const u=l?oe:he;_.acquireColor(u,7,"oit alpha"),r||_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer([0,0,0,1]),l&&this._rctx.clearBuffer(1,T),n(),_.detachDepth(),h.oitPass=2;const p=this.fboCache.acquire(s,i,r?"oit hud front":"oit front");l&&p.acquireColor(he,8,"oit emissive front"),r?p.acquireDepth(13):p.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(p.fbo),this._rctx.clearFramebuffer(T,r),n(),p.detachDepth();const c=this._pluginsHas.occludedHudElements&&!r;let m;return this._bindParameters.hudOcclusion=a(this._bindParameters.hudOcclusion),h.oitPass=0,r?(m=this.fboCache.acquire(s,i,"oit hud composite"),this._rctx.bindFramebuffer(m.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(16384)):(c&&(this._framebuffer.color.acquireColor(u,0,"hud occlusion"),this._rctx.clearBuffer(u-de,T)),this._framebuffer.bind()),this._oitBlend??=new V(this._techniques),this._oitBlend.blend(this._rctx,_,p,h,l,c,e),m?.detachDepth(),r||(this._rctx.bindFramebuffer(p.fbo),this._framebuffer.bind(),c&&(this._bindParameters.hudOcclusion=this._framebuffer.color.obtainAttachment(u))),p.release(),_.release(),this._renderContext.output=o,m}_renderOpaque(){const e=this.plugins.produces(0,...le);if(e){this._plugins.render(0,1);const e=this._framebuffer;e.update(e=>this._renderNodes(x.CUTFILL_COLOR,e)),e.update(e=>this._renderNodes(x.OPAQUE_TERRAIN,e)),e.bind(),this._plugins.render(2,3)}const t=this._framebuffer;this._renderTerrainDepth(),t.update(t=>this._renderNodes(A.OPAQUE,t,e)),this.fboCache.debugCallback?.(A.OPAQUE,t.color.fbo),t.update(e=>this._renderNodes(x.OPAQUE_ENVIRONMENT,e)),this.fboCache.debugCallback?.(x.OPAQUE_ENVIRONMENT,t.color.fbo),this._renderEdges(1)}_renderTransparent(e){const t=this._framebuffer;t.bind(),this._renderPlugins(22,ne.VOXEL),t.update(e=>this._renderNodes(x.GAUSSIAN_SPLAT,e)),this.fboCache.debugCallback?.(x.GAUSSIAN_SPLAT,t.color.fbo),this._renderHiddenTransparentEdges(),e&&(this.oitEnabled?this._renderOIT(0):this._renderTransparentGeometry()),t.update(t=>this._renderNodes(A.TRANSPARENT,t,e)),this.fboCache.debugCallback?.(A.TRANSPARENT,t.color.fbo),this._renderGeometryDepth(),this._renderHUDVisibility(),this._needsTerrainDepth||this._oitCallouts||this._plugins.render(17),this._renderEdges(0);const r=this._renderPhotoshopTerrain(),s=r?.getTexture();s&&(this._bindParameters.hudVisibility&&(this._needsTerrainDepth?this._renderLineCallouts(0):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositingHelper.compositeHUD(this._bindParameters,s))),this._renderHUD(0,t.color)),this._bindParameters.cullAboveTerrain=!1,s&&(t.bind(),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,s),r?.release(),this._needsTerrainDepth&&(this._renderEdges(1),e&&(this.oitEnabled?this._renderOIT(0):this._renderTransparentGeometry(),this.performanceInfo.advance(ne.TRANSPARENT)),this._renderEdges(0))),this._bindParameters.ssao=a(this._bindParameters.ssao),this._needsTerrainDepth&&this._renderLineCallouts(1),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(ne.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(9),this.performanceInfo.advance(ne.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderPlugins(e,t){this._plugins.produces(this._renderContext.output,e)&&(this._plugins.render(e),this.performanceInfo.advance(t))}_renderNodes(e,t,r=!1){const s=t.name;if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;this._fboCache.debugCallback?.(s,t.fbo);const i=this._nodes.render(t,this._pluginInput,this._releaseNodeInputs);return this.performanceInfo.advance(e),i}blitFBO(e,t=O,r=!0){return this._blit.blit(this._rctx,e,t,this._bindParameters),this._pluginInput.set(e.name,t),r&&e.release(),t}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=b:(f(Ee,this._bindParameters.camera.viewMatrix),f(Te,this._bindParameters.camera.projectionMatrix),g(Ae,Ee,Te),g(Ae,this._renderContext.lastFrameCamera.viewMatrix,Ae),g(Ae,this._renderContext.lastFrameCamera.projectionMatrix,Ae),this._reprojectionMatrix=Ae);const t=this.stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=b,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,r,s){this._bindParameters.updateLighting(e,t,r,s),this._requestRender(1)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}_renderToTargets(e,t,r,s,i=!1,n=!1){t.attachDepth(r),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(s,i,n),e(),t.detachDepth()}get test(){}};e([p({readOnly:!0})],_e.prototype,"highResolutionAtmosphere",null),e([p()],_e.prototype,"_edgeView",void 0),e([p()],_e.prototype,"updating",null),_e=e([c("esri.views.3d.webgl-engine.lib.Renderer")],_e);const le=[0,1,2,3],ue=[7,8,4,5],pe=[6,7,8],ce=[0,1,2,4,...pe],me=[3,5],fe=[2,4,9],ge=[18,14,16,15],be=[4,5,2,3,0,1,...pe],Ce=[4,9,5,12],Pe={0:[15],1:[14],2:[15,14],3:[15,14]},we=["normals","highlights"],Te=C(),Ee=C(),Ae=C();function xe(e){return t=>e.immediate.schedule(t)}export{_e as Renderer};
|
|
2
|
+
import{__decorate as e}from"tslib";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import{removeMaybe as s,abortMaybe as i,destroyMaybe as n,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAborted as h}from"../../../../core/promiseUtils.js";import{watch as o,syncAndInitial as d,initial as _,sync as l}from"../../../../core/reactiveUtils.js";import{signal as u}from"../../../../core/signal.js";import{property as p,subclass as c}from"../../../../core/accessorSupport/decorators.js";import{equals as m,invert as f,multiply as g}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as b,create as P}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as C}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as w,ZEROS as T}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as E}from"../../../../geometry/support/Indices.js";import{RenderNodeOutput as x,InternalRenderCategory as S,AllRenderNodeOutputs as A,AllInternalRenderNodeOutputs as D}from"../../webgl.js";import{innerAtmosphereFadeStart as R}from"../../environment/atmosphereUtils.js";import{minNearDistanceInMeters as I}from"../../state/NearFarHeuristic.js";import{debugFlags as y}from"../../support/debugFlags.js";import{FBOCache as H}from"../core/FBOCache.js";import{RenderPassManager as O}from"../core/renderPasses/RenderPassManager.js";import{isColor as v}from"../core/shaderLibrary/ShaderOutput.js";import{distanceFadeEnd as F}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as M}from"../effects/RenderNodes.js";import{RenderPluginManager as q}from"../effects/RenderPluginManager.js";import{Blit as N}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as G,renderHighlightBuffer as L}from"../effects/highlight/Highlight.js";import{OITBlend as U}from"../effects/transparency/OITBlend.js";import{AnimationTimer as V}from"./AnimationTimer.js";import{AnimationTimeStep as j}from"./AnimationTimeStep.js";import{BoundingInfo as B}from"./BoundingInfo.js";import{DepthRange as k}from"./DepthRange.js";import{depthRangeFromScene as z}from"./depthRangeUtils.js";import{MainFramebuffer as W}from"./MainFramebuffer.js";import{RenderContext as Q,defaultRenderOccludedMask as Y}from"./RenderContext.js";import{RendererBase as J}from"./RendererBase.js";import{setupFeatureDefaults as K}from"./RenderFeature.js";import{RenderPluginInput as X}from"./RenderPluginInput.js";import{ShadowAccumulator as Z}from"./ShadowAccumulator.js";import{ShadowMap as $}from"./ShadowMap.js";import ee from"./SliceHelper.js";import{MergedRenderer as te}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as re}from"../parts/renderUtils.js";import{RendererPerformanceInfo as se,PerformanceCategory as ie}from"../statistics/RendererPerformanceInfo.js";import{PixelType as ne,ColorAttachment1 as ae,ColorAttachment2 as he,ColorAttachment0 as oe}from"../../../webgl/enums.js";let de=class extends J{constructor(e,t,r,s,i,n){super({stage:e}),this._techniques=r,this._rctx=s,this._compositingHelper=i,this._requestRender=n,this._pluginsHas={occludedHudElements:!1,hudElements:!1,water:!1},this.renderPassManager=new O,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=w(0,0,0,1),this._sliceHelper=new ee,this.sceneDepthRange=u(k.Infinite),this._state=u(2),this._hasAnimations=!1,this._animationTimestep=new j,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=u(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new X,this._oitCallouts=!1,this._releaseNodeInputs=e=>{for(const t of Ce)e.some(({name:e})=>e===t)&&this._pluginInput.release(t)},this._debugNeedsDepth=!1,this._fboCache=new H(s),this._renderStateFeatures=u(K(e.view.qualityProfile)),this._framebuffer=new W(this.fboCache),this._performanceInfo=new se(this._rctx),this._shadowMap=new $(this.fboCache,e.viewingMode),this._blit=new N(r),this._shadowAccumulator=new Z(this.fboCache,r,e,e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t},(t,r,s)=>{const i=e.view.qualitySettings.maximumPixelRatio;t.shadowMap.start(t.camera,r,s,!0,i),this._renderShadowCascades(3,t.shadowMap),t.shadowMap.finish(),t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.contentCamera)},n),this._renderContext=new Q(this._rctx,this._shadowMap,r),this._nodes=new M(this._renderContext),this._plugins=new q({renderContext:this._renderContext,techniques:r,materials:t,requestRender:n,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this.addHandles([o(()=>e.view.state.camera,()=>n(),d),o(()=>y.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES,e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(0):()=>{},n()},_),o(()=>e.view.environment.background?.color,e=>{const t=e?e.toUnitRGBA():T;C(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()},d),o(()=>e.view.state.camera.relativeElevation,e=>this._inGlobeView=(e??1/0)>=F,d),o(()=>this._bindParameters.clouds.fadeFactor,()=>{this._bindParameters.fadeLighting(),this._requestRender(2)},l),o(()=>this._bindParameters.clouds.data?.state,()=>n(),l),o(()=>e.view.state.highlights,e=>{this._bindParameters.highlights=e,n()},_)])}destroy(){this._gpuTimerHandle=s(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.destroy(),this._shadowAccumulator=null,this._loadEdgeViewTask=i(this._loadEdgeViewTask),this._edgeView=n(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this._fboCache.destroy(),this._fboCache=null,this._plugins.destroy(),this._plugins=null,this._pluginInput=null,this._oitBlend=null,this._compositingHelper=null,this._nodes=null,this._framebuffer=null,this._shadowMap=null,this._renderContext=null,this._performanceInfo=null,B.prune(),te.prune(),E()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get performanceInfo(){return this._performanceInfo}updateRenderFeatures(e){this._renderStateFeatures.value=K(e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate(s=>s.set(t,e,r)),this._requestRender()}get _highQualityTransparency(){return this.isFeatureEnabled(1)}get hasReflections(){return this._pluginsHas.water&&this.isFeatureEnabled(6)}get _hasHighlights(){return this._plugins.produces(8,2,4,20,14,15,16)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(8,14,15,16)}get hasSSAO(){return this.isFeatureEnabled(5)&&!this._inGlobeView}get hasSMAA(){return this.isFeatureEnabled(0)}get hasEmitters(){return this._plugins.hasEmitters&&this._hasFloatBufferBlendSupport}get highResolutionAtmosphere(){return this.isFeatureEnabled(4)}get fboCache(){return this._fboCache}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=a(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=a(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=a(this._bindParameters.geometryDepth),this._bindParameters.hudOcclusion=a(this._bindParameters.hudOcclusion)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeBuffers(),this._bindParameters.depth=a(this._bindParameters.depth),this._bindParameters.hudVisibility=a(this._bindParameters.hudVisibility)}get updating(){return this._loadEdgeViewTask&&!this._loadEdgeViewTask.finished||this._edgeView?.updating||this._shadowAccumulator.readyToRun||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=r(async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");h(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this.stage.view.renderSpatialReference,viewingMode:this.stage.view.stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:xe(this.stage.view.resourceController)});return this.addHandles(o(()=>r.updating,()=>this._requestRender(),l)),this._requestRender(),this._edgeViewCallbacks.forEach(e=>e(r)),this._edgeViewCallbacks.length=0,r})),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&m(this._bindParameters.ssr.reprojectionMatrix,b)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:r}=this;if(void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&t.maxCascades!==e.shadowMapMaxCascades&&(t.maxCascades=e.shadowMapMaxCascades,this._requestRender()),e.environment){void 0!==e.environment.weather&&(this._bindParameters.weather=e.environment.weather);const t="virtual"!==e.environment.lighting.type;r.enableFillLights!==t&&(r.enableFillLights=t,this._requestRender())}void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}set slice(e){this._sliceHelper.update(e)&&this._requestRender()}get plugins(){return this._plugins}get _hasFloatBufferBlendSupport(){return this._rctx.driverTest.floatBufferBlend.result}get oitEnabled(){return this.isFeatureEnabled(2)&&this._hasFloatBufferBlendSupport}commit(e,t){return this._isRendering&&console.warn("Renderer.modify called while rendering"),!!super.commit(e,t,this._plugins.context)&&(this.updateHasFlags(),!0)}rendererAdded(e){this._plugins.add(e)}rendererRemoved(e){this._plugins.remove(e)}get occludedRequiresStencil(){return this.occludedRequiresOccludeeStencil||this.occludedRequiresIntegratedMeshStencil}get occludedRequiresOccludeeStencil(){return this._bindParameters.hasOccludees&&!!(8&this.plugins.renderOccludedFlags)}get occludedRequiresIntegratedMeshStencil(){return this._plugins.produces(0,0)&&this._plugins.produces(0,10)}updateHasFlags(){const has=this._pluginsHas;has.occludedHudElements=this._plugins.produces(0,15),has.hudElements=has.occludedHudElements||this._plugins.produces(0,...fe),has.water=this._plugins.produces(2,21),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new V(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const r=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?s(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,r,s=!1){try{return this._isRendering=!0,this._render(e,t,r,s)}catch(i){console.error(`Exception during rendering: ${i}`)}finally{this._isRendering=!1}return new re(this._pluginInput.get(x.FINAL),null)}_render(e,t,r,s){const i=0===r;this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=i,this._disposeBindBuffers();const{camera:n,contentCamera:a,mode:h,alignPixelEnabled:o}=e;this._state.value=h,this._renderContext.time=t,this._renderContext.output=0,this._bindParameters.hasEmission=this.hasEmitters,this._bindParameters.oitPass=0,this._bindParameters.alignPixelEnabled=o,this._bindParameters.decorations=!s,this._bindParameters.mainDepth=null;const d=!s||!this._sliceHelper.isDecoration;this._bindParameters.slicePlane=d?this._sliceHelper.plane:null,this._bindParameters.viewshedEnabled=this._nodes.produces(S.VIEWSHED),this._bindParameters.cutFillEnabled=this._nodes.produces(S.CUTFILL_DEPTH),this._renderOverlay(),n.setGLViewport(this._rctx);const _=this._framebuffer,l=_.initialize(n.fullWidth,n.fullHeight,this._backgroundColor,this._bindParameters.hasEmission);this.hasReflections?(l?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=l):l?.release(),this._ensureBindParametersCamera(n,a),this._plugins.sortTestsTransparentOrderedSlots(be),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!s;const u=this._plugins.produces(0,...le);this._precompilePrepasses(),this.performanceInfo.advance(ie.PREPARE);const p=this._computeShadowDepthRange(n);this._renderShadowMap(n,this._bindParameters.lighting.mainLight.direction,p),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(p,n,a,!i),this._oitCallouts=u&&this.oitEnabled,this._ensureBindParametersSSR(t),this._precompileShaders(u),this._renderContext.output=0,_.bind(),this._bindParameters.mainDepth=_.depth.attachment,this._renderOpaque(),this._renderTransparent(u),this._shadowMap.disposeMainBuffer(),this._pluginInput.set(S.FOCUSAREA,this._renderFocusAreaGeometry()),this._pluginInput.set(S.CUTFILL_DEPTH,this._renderCutFillDepth()),_.update(e=>this._renderNodes(S.TRANSPARENT_ENVIRONMENT,e)),_.update(e=>this._renderNodes(S.VIEWSHED,e)),_.update(e=>this._renderNodes(S.LASERLINES,e)),_.update(e=>this._renderNodes(S.FOCUSAREA_COLOR,e)),this._pluginInput.release(S.FOCUSAREA),this._pluginInput.release(S.CUTFILL_DEPTH),_.update(e=>this._renderNodes(S.OCCLUDED,e)),this._pluginInput.set("highlights",this._renderHighlightPrepass()),this._renderHighlightShadowMap(n,this._bindParameters.lighting.mainLight.direction,p);const c=2===r?this._renderObjectAndLayerIdColor():null;_.update(e=>this._renderNodes(x.COMPOSITE,e)),this._shadowMap.disposeBuffers(),_.update(e=>this._renderNodes(S.ANTIALIASING,e));const m=this._hasPhotoshopTerrain||!u?1:2;let f;return this._bindParameters.hasEmission=!1,this._hasHUDHighlights&&_.update(e=>this._renderHUD(m,e)),_.update(e=>this._renderNodes(S.HIGHLIGHT_COLOR,e)),this._hasHUDHighlights||_.update(e=>this._renderHUD(m,e)),this._bindParameters.hasEmission=this.hasEmitters,_.update(e=>this._renderNodes(S.MAGNIFIER,e)),_.update(e=>this._renderNodes(x.FINAL,e)),i&&this._blit.toFramebuffer(this._rctx,_.color,this._bindParameters),this.onPostRender?.(),this._releaseFBOs(),_.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),i||(f=_.color,f.retain(),this._releaseFBOs(),this._disposeOffscreenBuffers()),this.performanceInfo.finishFrame(),new re(f,c)}_precompileShaders(e){++this._plugins.context.techniques.precompiling,this._renderContext.output=0,this._precompileOpaqueGeometry(),this._nodes.precompile(S.OPAQUE_ENVIRONMENT),this._nodes.precompile(S.GAUSSIAN_SPLAT);const t=this._bindParameters;t.terrainDepthTest=t.cullAboveTerrain=this._needsTerrainDepth,this._renderContext.output=1,this._plugins.precompile(...ue),this._needsTerrainDepth&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._renderContext.output=0,this._plugins.precompile(...ue),e&&(this._precompileTransparentGeometry(),this._hasPhotoshopTerrain&&(t.cullAboveTerrain=!1,this._precompileTransparentGeometry(),t.cullAboveTerrain=this._needsTerrainDepth)),this._nodes.precompile(S.FOCUSAREA),this._needsHUDVisibility&&this._plugins.precompile(13),this._oitCallouts||this._plugins.precompile(17),this._precompileHUD(0),t.terrainDepthTest=t.cullAboveTerrain=!1,this._nodes.precompile(S.VIEWSHED,S.CUTFILL_DEPTH,S.CUTFILL_COLOR,S.LASERLINES,S.FOCUSAREA_COLOR,S.OCCLUDED,S.ANTIALIASING,S.HIGHLIGHT_COLOR),t.highlightMixTexture=t.highlights.length>1?this._rctx.emptyTexture:null,t.hasEmission=!1,this._precompileHUD(1),this.oitEnabled&&this._precompileHUD(0),t.hasEmission=this.hasEmitters,this._hasHighlights&&(t.highlights.forEach((e,r)=>{t.highlightLevel=r,this._precompileAllGeometry(8)}),t.highlightLevel=null),t.highlightMixTexture=null,this._nodes.precompile(x.COMPOSITE,S.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(9),--this._plugins.context.techniques.precompiling}_renderFocusAreaGeometry(){const e=this._nodes.produce(S.FOCUSAREA,this._pluginInput);return e&&this.performanceInfo.advance(ie.FOCUS_AREA_MASK),e}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._renderContext.output;++this._techniques.precompiling;const{width:t,height:r}=this._framebuffer.size;let s=this.fboCache.acquire(t,r,"olid");return s.acquireDepth(14),s=this._nodes.render(s,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(ie.OBJECT_AND_LAYER_ID_COLOR),this._renderContext.output=e,s}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=0===e;if(r||t){const e=r?this.performanceInfo.elapsedTime:0;let s=0;t?s=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const i=Math.max(e,s);this._animationTimestep.frame(i,r)}}readMainDepth(e,t){const{mainDepth:r,camera:s}=this._bindParameters;if(!r)return;const i=this.fboCache.acquire(this._framebuffer.size.width,this._framebuffer.size.height,"linear depth");this._rctx.bindFramebuffer(i.fbo),s.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(T),this._compositingHelper.blitDepthToLinearDepth(this._bindParameters,r),this._rctx.setScissorTestEnabled(!1),this._rctx.setScissorRect(0,0,this._rctx.gl.canvas.width,this._rctx.gl.canvas.width),i.fbo?.readPixels(e[0],e[1],e[2],e[3],6408,ne.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,t,r,s,i){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,s,6408,ne.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const{width:r,height:s}=this._framebuffer.size,i=this.fboCache.acquire(r,s,"edges"),n=this._bindParameters.geometryDepth,a=()=>t.render(this._bindParameters,e);this._renderToTargets(a,i,n??this._framebuffer.depth,T),this._framebuffer.bind(),this._compositingHelper.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(1===e?ie.OPAQUE_EDGES:ie.TRANSPARENT_EDGES)}_renderOverlay(){this._bindParameters.overlay=this.overlay?.render(this._renderContext.time),this._bindParameters.overlay&&this.performanceInfo.advance(ie.OVERLAY)}_renderShadowMap(e,t,r){if(!this.shadowsEnabled)return;const s=this._shadowMap;s.start(e,t,r,this.isFeatureEnabled(7),this.stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(5,this._shadowMap),s.copySnapshot(1),this._renderShadowCascades(4,this._shadowMap)):this._renderShadowCascades(3),s.finish(),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,this._bindParameters.contentCamera),this.performanceInfo.advance(ie.SHADOW_MAP)}_renderHighlightShadowMap(e,t,r){if(!this.shadowsEnabled||!this._needsShadowHighlight)return;const s=this._shadowMap;s.start(e,t,r,this.isFeatureEnabled(7),this.stage.view.qualitySettings.maximumPixelRatio),this._renderShadowCascades(4,this._shadowMap),s.moveSnapshot(0),s.finish(),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,this._bindParameters.contentCamera),this.performanceInfo.advance(ie.SHADOW_MAP)}_renderCutFillDepth(){return this._nodes.produce(S.CUTFILL_DEPTH,this._pluginInput)}_precompileShadowCascades(e){0!==this._shadowMap.cascades.length&&this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){t.bindFbo();for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e)}get _needsDepth(){return this._plugins.consumes(1)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._shadowAccumulator.active||this._debugNeedsDepth}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");e?(this._pluginInput.set(S.SSAO,this._renderSSAO()),this._needsDepth?(this._rctx.bindFramebuffer(e.fbo),this._rctx.clear(1024),this._renderGeometryWithoutNormals(1),this._bindParameters.depth?.release(),this._bindParameters.depth=e.obtainDepthTexture(),this.performanceInfo.advance(ie.DEPTH)):(e.detachDepth(),this._bindParameters.depth=a(this._bindParameters.depth)),this.hasSSAO&&this._pluginInput.release("normals")):this._renderAllGeometryDepth()}_renderAllGeometryDepth(){if(this._bindParameters.depth=a(this._bindParameters.depth),!this._needsDepth)return;const{width:e,height:t}=this._framebuffer.size,r=this.fboCache.acquire(e,t,"geometry depth",14);this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(1280),this.renderAllGeometry(1),this._bindParameters.depth=r.obtainDepthTexture(),r.release(),this.performanceInfo.advance(ie.DEPTH)}_renderTerrainDepth(){if(this._bindParameters.terrainDepth=a(this._bindParameters.terrainDepth),this._bindParameters.terrainDepthTest=this._bindParameters.cullAboveTerrain=this._needsTerrainDepth,!this._needsTerrainDepth)return;const e=this._renderContext.output;this._renderContext.output=1;const{width:t,height:r}=this._framebuffer.size,s=this.fboCache.acquire(t,r,"terrain depth",14);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(1280),this._renderTransparentGround(),this._bindParameters.terrainDepth=s.obtainDepthTexture(),s.release(),this._renderContext.output=e}_renderGeometryDepth(){if(this._bindParameters.geometryDepth=a(this._bindParameters.geometryDepth),!this._needsTerrainDepth)return;const e=this._renderContext.output,{width:t,height:r}=this._framebuffer.size,s=this.fboCache.acquire(t,r,"geometry depth",14);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(1280),this._renderOpaqueAndTransparentGeometry(1),this._renderContext.output=e,this._bindParameters.geometryDepth=s.obtainDepthTexture(),s.release()}get _needsShadowDepthRange(){return this._shadowMap.enabled||this._shadowAccumulator.active}_computeShadowDepthRange(e){if(!this._needsShadowDepthRange)return k.Zero;const t=z(e,this._plugins.plugins,this.stage.layers,0);return t.union(this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}updateSceneDepthRange(e){if(!this.stage.view.state.isGlobal)return void(this.sceneDepthRange.value=k.Infinite);if((this.stage.view.renderCoordsHelper?.getAltitude(e.eye)??0)<R)return void(this.sceneDepthRange.value=k.Infinite);const t=e.clone();t.near=I,t.far=1e10;const r=z(t,this._plugins.plugins,this.stage.layers,1);r.union(this._plugins.queryDepthRange(t)),this.sceneDepthRange.value.equals(r)||(this.sceneDepthRange.value=r)}get _normalsRequired(){const e=this._nodes.require("normals",...A,S.VIEWSHED,S.LASERLINES);return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(2),this._needsDepth&&this._precompileAllGeometry(1),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(4),this._precompileShadowCascades(5)):this._precompileShadowCascades(3)),this._shadowAccumulator.active&&this._precompileAllGeometry(3)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const{width:t,height:r}=this._framebuffer.size,s=this.fboCache.acquire(t,r,"normals",5);s.acquireDepth(14),this._rctx.bindFramebuffer(s.fbo),this._rctx.clearFramebuffer(T,!0,!0),this._renderContext.output=2,this._plugins.render(...pe);const i=this._nodes.optional("normals",...A,S.VIEWSHED);return s.retain(e+i-1),this.performanceInfo.advance(ie.NORMALS),s}_renderSSAO(){const e=this._pluginInput.get("normals");if(this.hasSSAO&&e)return this._bindParameters.ssao=this._nodes.produce(S.SSAO,this._pluginInput),this._bindParameters.ssao&&this.performanceInfo.advance(ie.SSAO),this._bindParameters.ssao}_precompileAllGeometry(e){const t=this._renderContext.output;this._renderContext.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(...ue),this._renderContext.output=t}renderAllGeometry(e){this._renderContext.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentGround()}precompileSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const r of t)this._renderContext.renderOccludedMask=r,this.precompileSlots(e,...me);this._renderContext.renderOccludedMask=Y}renderSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.forAll(e=>{const t=e.acquireTechniques(this._renderContext);t&&e.render(this._renderContext,t)})}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>1&&this._plugins.render(10),this.renderSlots(e,...me),this._renderContext.renderOccludedMask=Y}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(...Pe[e])}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(18),this.renderHUD(e),this._bindParameters.hudRenderStyle=e,this._plugins.render(16)}precompileViewshedShadowMap(){this._precompileAllGeometry(6)}precompileCutFill(){const e=7,t=this._renderContext.output;this._renderContext.output=e,this._plugins.precompile(0,1,...ue),this._renderContext.output=t}renderViewshedShadowMap(e){const{camera:t,contentCamera:r}=this._bindParameters,s=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(6),this._ensureBindParametersCamera(t,r),this._bindParameters.camera.setGLViewport(this._rctx),this._renderContext.output=s}renderCutFillReferenceDepth(e){const{camera:t,contentCamera:r}=this._bindParameters,s=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this._renderContext.output=7,this._plugins.render(0,1,...ue),this._ensureBindParametersCamera(t,r),t.setGLViewport(this._rctx),this._renderContext.output=s}_renderOpaqueAndTransparentGeometry(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithoutNormals(e){this._renderContext.output=e,this._plugins.render(...ce)}_precompileOpaqueGeometry(){this._plugins.precompile(..._e),this._nodes.precompile("opaque-color")}_renderOpaqueGeometry(){this._plugins.render(..._e)}_renderTransparentGeometry(){this._plugins.render(...le),this._oitCallouts&&this._plugins.render(17)}get _hasPhotoshopTerrain(){return this._plugins.produces(0,6)}get _needsTerrainDepth(){return this._highQualityTransparency&&this._hasPhotoshopTerrain}_renderPhotoshopTerrain(){if(!this._hasPhotoshopTerrain)return null;const{width:e,height:t}=this._framebuffer.size,r=this.fboCache.acquire(e,t,"transparent terrain"),s=()=>this._plugins.render(6);return this._renderToTargets(s,r,this._framebuffer.depth,T),this.performanceInfo.advance(ie.TRANSPARENT_TERRAIN),r}_renderTransparentGround(){this._plugins.render(...ue)}get _needsHUDVisibility(){return this._plugins.produces(this._renderContext.output,13)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=a(this._bindParameters.hudVisibility));const{width:e,height:t}=this._framebuffer.size;let r=this._bindParameters.hudVisibility;r?.fbo?.width===e&&r?.fbo?.height===t||(r?.release(),r=this.fboCache.acquire(e,t,"hud visibility",4),this._bindParameters.hudVisibility=r);const s=this._bindParameters.geometryDepth;r.attachDepth(s||this._framebuffer.depth),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(13),r.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(ie.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,0===e){const e=()=>this._plugins.render(17),{width:t,height:r}=this._framebuffer.size,s=this.fboCache.acquireDepth(13,t,r,"line callouts");this._renderToTargets(e,this._framebuffer.color,s,void 0,!0,!0),s.release()}else this._plugins.render(17)}_precompileHUD(e){if(this._precompileHUDOutput(e),this._hasHighlights){const t=this._renderContext.output;this._renderContext.output=8,this._precompileHUDOutput(e),this._renderContext.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this.oitEnabled&&v(this._renderContext.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...fe),this._bindParameters.oitPass=2,this._plugins.precompile(...fe),this._bindParameters.oitPass=0):this._plugins.precompile(...fe),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t){if(!this._pluginsHas.hudElements)return t;if(this.oitEnabled){const r=this._renderOIT(1,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,r.getTexture(),!1),r.release()}else if(this._renderContext.output=0,0===e){const t=()=>this._renderHUDElements(e),{width:r,height:s}=this._framebuffer.size,i=this.fboCache.acquireDepth(13,r,s,"hud");this._renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(13),this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(256),this._renderHUDElements(e),t.detachDepth();return this.performanceInfo.advance(0===e?ie.HUD_OCCLUDED:ie.HUD),t}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(4,2)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:r}=this,{width:s,height:i}=this._framebuffer.size,{highlights:n}=r,a=n.length>G?3:1,h=e.acquire(s,i,"highlights",a);h.acquireDepth(14);const o=this._plugins.produces(8,0);return o&&this._framebuffer.color.fbo&&h.fbo&&t.blitFramebuffer(this._framebuffer.color.fbo,h.fbo,1024),t.bindFramebuffer(h.fbo),t.gl.clearBufferuiv(6144,0,[0,0,0,0]),o||t.clear(1024),this._renderContext.output=8,t.bindFramebuffer(h.fbo),L(t,e,s,i,r,()=>this._renderHighlightGeometries()),h.detachDepth(),this.performanceInfo.advance(ie.HIGHLIGHTS),h.retain(this._nodes.require("highlights",...D)+this._nodes.optional("highlights",...D)-1),h}_renderHighlightGeometries(){this._plugins.render(...ge),this._rctx.clear(256),this._renderHUDElements(2)}_renderShadowAccumulation(e,t,r,s){this._shadowAccumulator.updateDepthRange(e),this._shadowAccumulator.accumulating&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,t,r,s)&&this.performanceInfo.advance(ie.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this.oitEnabled&&v(this._renderContext.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...le),this._oitCallouts&&this._plugins.precompile(17),this._bindParameters.oitPass=2,this._plugins.precompile(...le),this._oitCallouts&&this._plugins.precompile(17),this._bindParameters.oitPass=0):this._plugins.precompile(...le)}_renderOIT(e,t=2){const r=1===e,{width:s,height:i}=this._framebuffer.size,n=r?()=>this._renderHUDElements(t):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._renderContext.output;this._renderContext.output=0,h.oitPass=1;const d=r?"oit hud":"oit",_=this.fboCache.acquire(s,i,d,8),l=this._bindParameters.hasEmission&&(0===e||1!==t);l&&_.acquireColor(ae,8,"oit emissive");const u=l?he:ae;_.acquireColor(u,7,"oit alpha"),r||_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer([0,0,0,1]),l&&this._rctx.clearBuffer(1,T),n(),_.detachDepth(),h.oitPass=2;const p=this.fboCache.acquire(s,i,r?"oit hud front":"oit front");l&&p.acquireColor(ae,8,"oit emissive front"),r?p.acquireDepth(13):p.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(p.fbo),this._rctx.clearFramebuffer(T,r),n(),p.detachDepth();const c=this._pluginsHas.occludedHudElements&&!r;let m;return this._bindParameters.hudOcclusion=a(this._bindParameters.hudOcclusion),h.oitPass=0,r?(m=this.fboCache.acquire(s,i,"oit hud composite"),this._rctx.bindFramebuffer(m.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(16384)):(c&&(this._framebuffer.color.acquireColor(u,0,"hud occlusion"),this._rctx.clearBuffer(u-oe,T)),this._framebuffer.bind()),this._oitBlend??=new U(this._techniques),this._oitBlend.blend(this._rctx,_,p,h,l,c,e),m?.detachDepth(),r||(this._rctx.bindFramebuffer(p.fbo),this._framebuffer.bind(),c&&(this._bindParameters.hudOcclusion=this._framebuffer.color.obtainAttachment(u))),p.release(),_.release(),this._renderContext.output=o,m}_renderOpaque(){const e=this.plugins.produces(0,..._e);if(e){this._plugins.render(0,1);const e=this._framebuffer;e.update(e=>this._renderNodes(S.CUTFILL_COLOR,e)),e.update(e=>this._renderNodes(S.OPAQUE_TERRAIN,e)),e.bind(),this._plugins.render(2,3)}const t=this._framebuffer;this._renderTerrainDepth(),t.update(t=>this._renderNodes(x.OPAQUE,t,e)),this.fboCache.debugCallback?.(x.OPAQUE,t.color.fbo),t.update(e=>this._renderNodes(S.OPAQUE_ENVIRONMENT,e)),this.fboCache.debugCallback?.(S.OPAQUE_ENVIRONMENT,t.color.fbo),this._renderEdges(1)}_renderTransparent(e){const t=this._framebuffer;t.bind(),this._renderPlugins(22,ie.VOXEL),t.update(e=>this._renderNodes(S.GAUSSIAN_SPLAT,e)),this.fboCache.debugCallback?.(S.GAUSSIAN_SPLAT,t.color.fbo),this._renderHiddenTransparentEdges(),e&&(this.oitEnabled?this._renderOIT(0):this._renderTransparentGeometry()),t.update(t=>this._renderNodes(x.TRANSPARENT,t,e)),this.fboCache.debugCallback?.(x.TRANSPARENT,t.color.fbo),this._renderGeometryDepth(),this._renderHUDVisibility(),this._needsTerrainDepth||this._oitCallouts||this._plugins.render(17),this._renderEdges(0);const r=this._renderPhotoshopTerrain(),s=r?.getTexture();s&&(this._bindParameters.hudVisibility&&(this._needsTerrainDepth?this._renderLineCallouts(0):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositingHelper.compositeHUD(this._bindParameters,s))),this._renderHUD(0,t.color)),this._bindParameters.cullAboveTerrain=!1,s&&(t.bind(),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,s),r?.release(),this._needsTerrainDepth&&(this._renderEdges(1),e&&(this.oitEnabled?this._renderOIT(0):this._renderTransparentGeometry(),this.performanceInfo.advance(ie.TRANSPARENT)),this._renderEdges(0))),this._bindParameters.ssao=a(this._bindParameters.ssao),this._needsTerrainDepth&&this._renderLineCallouts(1),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(ie.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(9),this.performanceInfo.advance(ie.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderPlugins(e,t){this._plugins.produces(this._renderContext.output,e)&&(this._plugins.render(e),this.performanceInfo.advance(t))}_renderNodes(e,t,r=!1){const s=t.name;if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;this._fboCache.debugCallback?.(s,t.fbo);const i=this._nodes.render(t,this._pluginInput,this._releaseNodeInputs);return this.performanceInfo.advance(e),i}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=b:(f(Te,this._bindParameters.camera.viewMatrix),f(we,this._bindParameters.camera.projectionMatrix),g(Ee,Te,we),g(Ee,this._renderContext.lastFrameCamera.viewMatrix,Ee),g(Ee,this._renderContext.lastFrameCamera.projectionMatrix,Ee),this._reprojectionMatrix=Ee);const t=this.stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=b,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,r,s){this._bindParameters.updateLighting(e,t,r,s),this._requestRender(1)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}_renderToTargets(e,t,r,s,i=!1,n=!1){t.attachDepth(r),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(s,i,n),e(),t.detachDepth()}get test(){}};e([p({readOnly:!0})],de.prototype,"highResolutionAtmosphere",null),e([p()],de.prototype,"_edgeView",void 0),e([p()],de.prototype,"updating",null),de=e([c("esri.views.3d.webgl-engine.lib.Renderer")],de);const _e=[0,1,2,3],le=[7,8,4,5],ue=[6,7,8],pe=[0,1,2,4,...ue],ce=[3,5],me=[2,4,9],fe=[18,14,16,15],ge=[4,5,2,3,0,1,...ue],be=[4,9,5,12],Pe={0:[15],1:[14],2:[15,14],3:[15,14]},Ce=["normals","highlights"],we=P(),Te=P(),Ee=P();function xe(e){return t=>e.immediate.schedule(t)}export{de as Renderer};
|