@arcgis/core 5.1.0-next.30 → 5.1.0-next.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{dcdddbc02b7d7febc56d.js → 005fe95c3329cfe74219.js} +1 -1
- package/assets/esri/core/workers/chunks/00947268b6de12329146.js +1 -0
- package/assets/esri/core/workers/chunks/{2563ce0f18eb84a9971a.js → 0337138d3702a1a52ce0.js} +1 -1
- package/assets/esri/core/workers/chunks/0554f310066937098099.js +1 -0
- package/assets/esri/core/workers/chunks/087403b53f15eb4d375c.js +1 -0
- package/assets/esri/core/workers/chunks/0d156e14fc34d0600fd5.js +1 -0
- package/assets/esri/core/workers/chunks/{eb4934d3a3b82316c7c6.js → 0d196cf72cd8bef8d91d.js} +1 -1
- package/assets/esri/core/workers/chunks/{764d080f77dec5e7a02c.js → 0e7d3f3479fcb366cc6f.js} +1 -1
- package/assets/esri/core/workers/chunks/0efe90bd43ab29dab8ae.js +1 -0
- package/assets/esri/core/workers/chunks/122ff8d0d428f31fc5d1.js +1 -0
- package/assets/esri/core/workers/chunks/{37d943d3f2c40468438c.js → 144acac9bb1aa78f1170.js} +1 -1
- package/assets/esri/core/workers/chunks/14e05d37e10ebba8cf10.js +1 -0
- package/assets/esri/core/workers/chunks/19722dfef06028ab399b.js +1 -0
- package/assets/esri/core/workers/chunks/1ff40e6057916e8482b3.js +1 -0
- package/assets/esri/core/workers/chunks/209d8ee81cc3ebb18b27.js +1 -0
- package/assets/esri/core/workers/chunks/22aeab5c363645c04806.js +1 -0
- package/assets/esri/core/workers/chunks/283ce37403c5e7a76e95.js +1 -0
- package/assets/esri/core/workers/chunks/29687aae97dc01f33fa6.js +1 -0
- package/assets/esri/core/workers/chunks/2d6165796af522858e56.js +1 -0
- package/assets/esri/core/workers/chunks/2f0e850ebea0ffd2708f.js +1 -0
- package/assets/esri/core/workers/chunks/34cdcee6d0ea595d7aed.js +1 -0
- package/assets/esri/core/workers/chunks/34f2e9d7466abc0919e7.js +1 -0
- package/assets/esri/core/workers/chunks/36f91b5c4345a179b8b1.js +1 -0
- package/assets/esri/core/workers/chunks/380bb57bccc266d6442a.js +1 -0
- package/assets/esri/core/workers/chunks/3b86e8eb553122d3b68d.js +1 -0
- package/assets/esri/core/workers/chunks/3b9de873f87f0feeb20b.js +1 -0
- package/assets/esri/core/workers/chunks/{f0bb986dce9cf75c890c.js → 3c597d8ef898627b8f93.js} +1 -1
- package/assets/esri/core/workers/chunks/3ca7f5cedf3cb747c0cf.js +1 -0
- package/assets/esri/core/workers/chunks/3dcb4ee8b862689a141b.js +1 -0
- package/assets/esri/core/workers/chunks/{c814abf3e67d9eadbc6b.js → 414a802b6365688d31cb.js} +1 -1
- package/assets/esri/core/workers/chunks/446bc8461403ed1ac7b2.js +1 -0
- package/assets/esri/core/workers/chunks/{84073653ff50e5d3c47a.js → 4a9596bb70690b673a1b.js} +17 -7
- package/assets/esri/core/workers/chunks/4bfc6f8c2d13ca4d2082.js +1 -0
- package/assets/esri/core/workers/chunks/4ceba469398ef55de8ea.js +1 -0
- package/assets/esri/core/workers/chunks/54c1d31e1efab765ee7a.js +1 -0
- package/assets/esri/core/workers/chunks/582d45a41e29005f6c63.js +1 -0
- package/assets/esri/core/workers/chunks/586bc903e2c285649bf2.js +1 -0
- package/assets/esri/core/workers/chunks/{aa3bdfd00f666c6cc521.js → 5b12865ac53d984d8149.js} +1 -1
- package/assets/esri/core/workers/chunks/5e5b358e603b13b4d7d7.js +1 -0
- package/assets/esri/core/workers/chunks/5f3b25b30acd7a07f5c0.js +1 -0
- package/assets/esri/core/workers/chunks/620965d2e1a9ccf81d43.js +1 -0
- package/assets/esri/core/workers/chunks/623bfacf4b9c9a5387cc.js +1 -0
- package/assets/esri/core/workers/chunks/63722607fbf8d411188d.js +1 -0
- package/assets/esri/core/workers/chunks/64870f555fefa85a5c59.js +1 -0
- package/assets/esri/core/workers/chunks/{0df585420c9cec6a7265.js → 666db81085bc97831b18.js} +1 -1
- package/assets/esri/core/workers/chunks/67de5225b2c66c9c7bc9.js +1 -0
- package/assets/esri/core/workers/chunks/696f645349249f26090c.js +1 -0
- package/assets/esri/core/workers/chunks/{57e375d8a8db9fa57193.js → 6e8cfe69617876ee0dac.js} +1 -1
- package/assets/esri/core/workers/chunks/6f3f7f785241edacdb8b.js +1 -0
- package/assets/esri/core/workers/chunks/{ee6f7c5d3c2f187645ff.js → 7411ca5e1876aaa0228e.js} +1 -1
- package/assets/esri/core/workers/chunks/{94563b007647a9c4ad76.js → 75cde632887a95ea20f2.js} +1 -1
- package/assets/esri/core/workers/chunks/776a7179d32fe62a37e3.js +1 -0
- package/assets/esri/core/workers/chunks/7ddb11a127b9458e9eac.js +1 -0
- package/assets/esri/core/workers/chunks/7ebd836b98d14c7d3ecf.js +1 -0
- package/assets/esri/core/workers/chunks/80f0810527743833b4b7.js +1 -0
- package/assets/esri/core/workers/chunks/828998d33a48be161782.js +1 -0
- package/assets/esri/core/workers/chunks/8bd24534ed185afcb124.js +1 -0
- package/assets/esri/core/workers/chunks/8d4ddaace906dd09de2c.js +1 -0
- package/assets/esri/core/workers/chunks/8e10e4c25869af9da5ba.js +1 -0
- package/assets/esri/core/workers/chunks/8eed5b6cac937099102c.js +1 -0
- package/assets/esri/core/workers/chunks/{71be4833a260714d3b2c.js → 917474f9dd2039b82e9d.js} +1 -1
- package/assets/esri/core/workers/chunks/{c3a0b38abf0a12a466fa.js → 965b8fa54d0cfafd4a70.js} +1 -1
- package/assets/esri/core/workers/chunks/9813f25192ea27084754.js +1 -0
- package/assets/esri/core/workers/chunks/9a3e5053e95db36f26dc.js +1 -0
- package/assets/esri/core/workers/chunks/9cc1b44c5a325a840307.js +1 -0
- package/assets/esri/core/workers/chunks/9cd548ea00b641d8e65d.js +1 -0
- package/assets/esri/core/workers/chunks/a2d045217a42ecc36308.js +1 -0
- package/assets/esri/core/workers/chunks/a52a8254577840a23aba.js +1 -0
- package/assets/esri/core/workers/chunks/{1cbe564cfc9eb0723827.js → aa367ca7f8326fd67881.js} +1 -1
- package/assets/esri/core/workers/chunks/aa742f847d77bb03ff60.js +1 -0
- package/assets/esri/core/workers/chunks/ad9194335902c687bb96.js +1 -0
- package/assets/esri/core/workers/chunks/ae72c530d52a6d4461be.js +1 -0
- package/assets/esri/core/workers/chunks/af601eb8c938c0720406.js +1 -0
- package/assets/esri/core/workers/chunks/b2cf19a28aa5c32a99e3.js +1 -0
- package/assets/esri/core/workers/chunks/b2f497339493926d4c9e.js +1 -0
- package/assets/esri/core/workers/chunks/b7a3a7f7fb747f9689d7.js +1 -0
- package/assets/esri/core/workers/chunks/b81780e5e7cd9a1a010a.js +1 -0
- package/assets/esri/core/workers/chunks/bb7e0334f438daa665da.js +1 -0
- package/assets/esri/core/workers/chunks/{5690b49f355a5e2083a9.js → c17c3453d014dc73fe0b.js} +1 -1
- package/assets/esri/core/workers/chunks/c1be9c4e59925a897a91.js +1 -0
- package/assets/esri/core/workers/chunks/{0389ebb63510dd7024de.js → c24ce19ab8580364c703.js} +2 -2
- package/assets/esri/core/workers/chunks/c2882a9e67124b7c18be.js +1 -0
- package/assets/esri/core/workers/chunks/c6112dcd6b36e256d7b5.js +1 -0
- package/assets/esri/core/workers/chunks/c8ae8d1b456ace0b383b.js +1 -0
- package/assets/esri/core/workers/chunks/{3a018c78859b5edec4fd.js → ca700e9e1bced9f99899.js} +1 -1
- package/assets/esri/core/workers/chunks/cc8e6d1eb90221103023.js +1 -0
- package/assets/esri/core/workers/chunks/d0d836502321e7a80e61.js +1 -0
- package/assets/esri/core/workers/chunks/d2fa8bd3f4cd3cf6b436.js +1 -0
- package/assets/esri/core/workers/chunks/d4b97ca16d79809ed6f2.js +1 -0
- package/assets/esri/core/workers/chunks/e00000468fb8ec2b3d43.js +1 -0
- package/assets/esri/core/workers/chunks/e0d6292aaa3f8a796de3.js +1 -0
- package/assets/esri/core/workers/chunks/ee582bbe7365b678ec54.js +1 -0
- package/assets/esri/core/workers/chunks/f4053e4e2d6e678db48a.js +1 -0
- package/assets/esri/core/workers/chunks/f5dbda08d7fd4bed1c62.js +1 -0
- package/assets/esri/core/workers/chunks/{a7dbd38bc216713044fc.js → fe21b2d31fbf83224e6b.js} +1 -1
- package/assets/esri/core/workers/chunks/ff8de370abf661768380.js +1 -0
- package/config.js +1 -1
- package/core/timeUtils.js +1 -1
- package/editing/sharedTemplates/executor/support/createFeatureServiceEdit.js +1 -1
- package/kernel.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/package.json +2 -2
- package/rest/query/operations/pbfFeatureServiceParser.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/CIMSymbol.d.ts +3 -3
- package/symbols/ExtrudeSymbol3DLayer.d.ts +1 -1
- package/symbols/FillSymbol.d.ts +1 -1
- package/symbols/FillSymbol3DLayer.d.ts +1 -1
- package/symbols/IconSymbol3DLayer.d.ts +1 -1
- package/symbols/LabelSymbol3D.d.ts +1 -1
- package/symbols/LineSymbol.d.ts +1 -1
- package/symbols/LineSymbol3D.d.ts +1 -1
- package/symbols/LineSymbol3DLayer.d.ts +1 -1
- package/symbols/LineSymbolMarker.d.ts +1 -1
- package/symbols/MarkerSymbol.d.ts +1 -1
- package/symbols/MeshSymbol3D.d.ts +1 -1
- package/symbols/ObjectSymbol3DLayer.d.ts +1 -1
- package/symbols/PathSymbol3DLayer.d.ts +1 -1
- package/symbols/PictureFillSymbol.d.ts +1 -1
- package/symbols/PictureMarkerSymbol.d.ts +1 -1
- package/symbols/PointSymbol3D.d.ts +1 -1
- package/symbols/PolygonSymbol3D.d.ts +1 -1
- package/symbols/SimpleFillSymbol.d.ts +1 -1
- package/symbols/SimpleLineSymbol.d.ts +1 -1
- package/symbols/SimpleMarkerSymbol.d.ts +1 -1
- package/symbols/Symbol.d.ts +1 -1
- package/symbols/Symbol3D.d.ts +1 -1
- package/symbols/Symbol3DLayer.d.ts +1 -1
- package/symbols/TextSymbol.d.ts +1 -1
- package/symbols/TextSymbol3DLayer.d.ts +1 -1
- package/symbols/WebStyleSymbol.d.ts +1 -1
- package/time/TimeExtent.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueFill.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueLine.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/3d/layers/IntegratedMeshNormals.js +1 -1
- package/views/3d/layers/VoxelLayerView3D.js +1 -1
- package/views/3d/webgl/RenderNode.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentDrawParameters.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/AllRenderPasses.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPass.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexNormal.glsl.js +13 -3
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexPosition.glsl.js +27 -9
- package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/HighlightApplyTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/HighlightBlurTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/HighlightDownsampleTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/HighlightToSingleTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/ssao/SSAOBlurTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/transparency/OITBlend.js +1 -1
- package/views/3d/webgl-engine/effects/transparency/OITBlendTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/transparency/OITDimTechnique.js +1 -1
- package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/statistics/RendererPerformanceInfo.js +1 -1
- package/views/3d/webgl.js +1 -1
- package/views/draw/DrawTool.js +1 -1
- package/views/webgl/RenderingContext.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileInteraction.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/support/geometryUtils.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/TimeSlider/TimeSliderViewModel.js +1 -1
- package/widgets/TimeSlider.js +1 -1
- package/assets/esri/core/workers/chunks/011b31df019b3ce2277e.js +0 -1
- package/assets/esri/core/workers/chunks/018859b79f9ce7528ac7.js +0 -1
- package/assets/esri/core/workers/chunks/05e5b9082c0a396df7e5.js +0 -1
- package/assets/esri/core/workers/chunks/0711c856144cd8700e7e.js +0 -1
- package/assets/esri/core/workers/chunks/0ca9953afaea7c7e11e0.js +0 -1
- package/assets/esri/core/workers/chunks/1482262d0788ee65ddf7.js +0 -1
- package/assets/esri/core/workers/chunks/15d7c9f5a55985ed00b4.js +0 -1
- package/assets/esri/core/workers/chunks/16b9ac49d13057b3aff5.js +0 -1
- package/assets/esri/core/workers/chunks/172137cc98be03de1436.js +0 -1
- package/assets/esri/core/workers/chunks/179b3385c24ad8a05e1d.js +0 -1
- package/assets/esri/core/workers/chunks/18a40606e4c39f244ecd.js +0 -1
- package/assets/esri/core/workers/chunks/19cb4720e92ac3c0478c.js +0 -1
- package/assets/esri/core/workers/chunks/1d697642fb2a6332b7f9.js +0 -1
- package/assets/esri/core/workers/chunks/2003dae2d7f6d52ea643.js +0 -1
- package/assets/esri/core/workers/chunks/209acb3ad16c99bb506c.js +0 -1
- package/assets/esri/core/workers/chunks/2e06baf6469820697f17.js +0 -1
- package/assets/esri/core/workers/chunks/2ecfd6edab796194bf88.js +0 -1
- package/assets/esri/core/workers/chunks/2f3aeaa25a76ab94b8e5.js +0 -1
- package/assets/esri/core/workers/chunks/33de1d899a4fa9ab6ab1.js +0 -1
- package/assets/esri/core/workers/chunks/359d3ba9d6e3b1de05d1.js +0 -1
- package/assets/esri/core/workers/chunks/36fd18a05ba503e6f3b5.js +0 -1
- package/assets/esri/core/workers/chunks/38d5dd4d457428244302.js +0 -1
- package/assets/esri/core/workers/chunks/3a8f2f6ac3c3e7e71c00.js +0 -1
- package/assets/esri/core/workers/chunks/3ad1edf199e7159f3cc2.js +0 -1
- package/assets/esri/core/workers/chunks/452d71789a1b77cff48d.js +0 -1
- package/assets/esri/core/workers/chunks/48a56b19bf825f05cc6e.js +0 -1
- package/assets/esri/core/workers/chunks/48e66b78274b82478bae.js +0 -1
- package/assets/esri/core/workers/chunks/48fb1520cb8c5ce248d9.js +0 -1
- package/assets/esri/core/workers/chunks/4e9b3b4b3dcce94c99a5.js +0 -1
- package/assets/esri/core/workers/chunks/5028de543cc1b8e60e65.js +0 -1
- package/assets/esri/core/workers/chunks/544bfa97837770a8792f.js +0 -1
- package/assets/esri/core/workers/chunks/55d4483b1862077e3732.js +0 -1
- package/assets/esri/core/workers/chunks/561484ab6ed564e4b90f.js +0 -1
- package/assets/esri/core/workers/chunks/592f6bf0283152481f21.js +0 -1
- package/assets/esri/core/workers/chunks/5b70ee8122262de5bbdf.js +0 -1
- package/assets/esri/core/workers/chunks/6138a528c3820af81bc6.js +0 -1
- package/assets/esri/core/workers/chunks/72cd450b24fdfcef6547.js +0 -1
- package/assets/esri/core/workers/chunks/75fd96fd9557ac1f8e10.js +0 -1
- package/assets/esri/core/workers/chunks/777b0e07f72c42470d36.js +0 -1
- package/assets/esri/core/workers/chunks/7b297a2f712361bfae2e.js +0 -1
- package/assets/esri/core/workers/chunks/7d274a077bdfa8c485e8.js +0 -1
- package/assets/esri/core/workers/chunks/7dd1e93469d0b1d652bc.js +0 -1
- package/assets/esri/core/workers/chunks/835a929e37811d0f82cb.js +0 -1
- package/assets/esri/core/workers/chunks/843c505148ed728d3c30.js +0 -1
- package/assets/esri/core/workers/chunks/8dcc8df5925f66e45b8c.js +0 -1
- package/assets/esri/core/workers/chunks/8eae33c4d8932b7a6bc1.js +0 -1
- package/assets/esri/core/workers/chunks/91e56959b2fddf1a9743.js +0 -1
- package/assets/esri/core/workers/chunks/925980d26d71987ac80c.js +0 -1
- package/assets/esri/core/workers/chunks/9bd5c56f879eb935d906.js +0 -1
- package/assets/esri/core/workers/chunks/aa9c11f25d95372998a3.js +0 -1
- package/assets/esri/core/workers/chunks/aec33bdb355bd04f28ae.js +0 -1
- package/assets/esri/core/workers/chunks/af618a1c55c15e17189b.js +0 -1
- package/assets/esri/core/workers/chunks/b35ea099334c867bde02.js +0 -1
- package/assets/esri/core/workers/chunks/b4254fcb2051c873f2ba.js +0 -1
- package/assets/esri/core/workers/chunks/b730131e52f9220db031.js +0 -1
- package/assets/esri/core/workers/chunks/b81824d62be92ab595f7.js +0 -1
- package/assets/esri/core/workers/chunks/b9d68a5dcb50999d3a90.js +0 -1
- package/assets/esri/core/workers/chunks/bae7376b554cac4a8f96.js +0 -1
- package/assets/esri/core/workers/chunks/bcd701892ee120e13a18.js +0 -1
- package/assets/esri/core/workers/chunks/c1c006c86cf31f934684.js +0 -1
- package/assets/esri/core/workers/chunks/cb6a7ca4ba2cf0b5ced7.js +0 -1
- package/assets/esri/core/workers/chunks/d70678598f4080adfb39.js +0 -1
- package/assets/esri/core/workers/chunks/d72d5031887373d35610.js +0 -1
- package/assets/esri/core/workers/chunks/d8896c57a414f2450190.js +0 -1
- package/assets/esri/core/workers/chunks/da780342f16e65b55ac8.js +0 -1
- package/assets/esri/core/workers/chunks/db005d9419bb718b3962.js +0 -1
- package/assets/esri/core/workers/chunks/e063cce778944fe97dd3.js +0 -1
- package/assets/esri/core/workers/chunks/e2bdb0e87422e222646e.js +0 -1
- package/assets/esri/core/workers/chunks/e4faccd48060349b8da1.js +0 -1
- package/assets/esri/core/workers/chunks/ea245d3a6fd601fffd88.js +0 -1
- package/assets/esri/core/workers/chunks/efb2a8879011d2d77a81.js +0 -1
- package/assets/esri/core/workers/chunks/f6c9742691ccdaed44a2.js +0 -1
- package/assets/esri/core/workers/chunks/f82a95c46f0d579d5bf5.js +0 -1
- package/assets/esri/core/workers/chunks/fd9ef90e2ebb7fed62b1.js +0 -1
- package/assets/esri/core/workers/chunks/feac196493ccd087de35.js +0 -1
- /package/assets/esri/core/workers/chunks/{0389ebb63510dd7024de.js.LICENSE.txt → c24ce19ab8580364c703.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{update as t}from"../../../../core/arrayUtils.js";import{createTask as s}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import{removeMaybe as i,abortMaybe as r,destroyMaybe as a,releaseMaybe as n}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 w}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as E,ZEROS as T}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as C}from"../../../../geometry/support/Indices.js";import{RenderNodeOutput as x,InternalRenderCategory as A,AllRenderNodeOutputs as D,AllInternalRenderNodeOutputs as S}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 O}from"../core/FBOCache.js";import{RenderPassManager as H}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 N}from"../effects/RenderPluginManager.js";import{Blit as q}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{Compositor as k}from"./Compositor.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 se}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as ie}from"../parts/renderUtils.js";import{RendererPerformanceInfo as re,PerformanceCategory as ae}from"../statistics/RendererPerformanceInfo.js";import{PixelType as ne,ColorAttachment1 as he,ColorAttachment2 as oe,ColorAttachment0 as de}from"../../../webgl/enums.js";let _e=class extends K{constructor(e,t,s,i,r){super({stage:e}),this._techniques=s,this._rctx=i,this._requestRender=r,this._pluginsHas={occludedHudElements:!1,hudElements:!1,water:!1},this.renderPassManager=new H,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=E(0,0,0,1),this._sliceHelper=new te,this.sceneDepthRange=u(z.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 Z,this._oitCallouts=!1,this._releaseNodeInputs=e=>{for(const t of Ee)e.some(({name:e})=>e===t)&&this._pluginInput.release(t)},this._debugNeedsDepth=!1,this._fboCache=new O(i),this._compositor=new k(i,s),this._renderStateFeatures=u(X(e.view.qualityProfile)),this._framebuffer=new Q(this.fboCache),this._performanceInfo=new re(this._rctx),this._shadowMap=new ee(this.fboCache,e.viewingMode),this._blit=new q(s),this._shadowAccumulator=new $(this.fboCache,s,e,e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t},(t,s,i)=>{const r=e.view.qualitySettings.maximumPixelRatio;t.shadowMap.start(t.camera,s,i,!0,r),this._renderShadowCascades(3,t.shadowMap),t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.contentCamera)},r),this._renderContext=new Y(this._rctx,this._shadowMap,s),this._nodes=new M(this._renderContext),this._plugins=new N({renderContext:this._renderContext,techniques:s,materials:t,requestRender:r,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this.addHandles([o(()=>e.view.state.camera,()=>r(),d),o(()=>y.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES,e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(0):()=>{},r()},_),o(()=>e.view.environment.background?.color,e=>{const t=e?e.toUnitRGBA():T;w(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),r()},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,()=>r(),l),o(()=>e.view.state.highlights,e=>{this._bindParameters.highlights=e,r()},_)])}destroy(){this._gpuTimerHandle=i(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.destroy(),this._shadowAccumulator=null,this._loadEdgeViewTask=r(this._loadEdgeViewTask),this._edgeView=a(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._oitBlendOrNil=null,this._nodes=null,this._framebuffer=null,this._shadowMap=null,this._renderContext=null,this._performanceInfo=null,B.prune(),se.prune(),C()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _oitBlend(){return this._oitBlendOrNil??=new U(this._techniques),this._oitBlendOrNil}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,s){this._renderStateFeatures.mutate(i=>i.set(t,e,s)),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 _hasEmission(){return this._plugins.hasEmitters&&this._hasFloatBufferBlendSupport}get highResolutionAtmosphere(){return this.isFeatureEnabled(4)}get fboCache(){return this._fboCache}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=n(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=n(this._bindParameters.geometryDepth),this._bindParameters.hudOcclusion=n(this._bindParameters.hudOcclusion)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOutputs(),this._bindParameters.depth=n(this._bindParameters.depth),this._bindParameters.hudVisibility=n(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=s(async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");h(e);const s=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:Ae(this.stage.view.resourceController)});return this.addHandles(o(()=>s.updating,()=>this._requestRender(),l)),this._requestRender(),this._edgeViewCallbacks.forEach(e=>e(s)),this._edgeViewCallbacks.length=0,s})),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:s}=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;s.enableFillLights!==t&&(s.enableFillLights=t,this._requestRender())}e.shadowCast&&this._shadowAccumulator.setParameters(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 V(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const s=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==s&&(this._gpuTimerHandle=s?i(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,s,i=!1){try{return this._isRendering=!0,this._render(e,t,s,i)}catch(r){console.error(`Exception during rendering: ${r}`)}finally{this._isRendering=!1}return new ie(this._pluginInput.get(x.FINAL),null)}_render(e,t,s,i){const r=0===s;this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=r,this._disposeBindBuffers();const{camera:a,contentCamera:n,mode:h,alignPixelEnabled:o}=e;this._state.value=h,this._renderContext.time=t,this._rctx.output=0,this._bindParameters.hasEmission=this._hasEmission,this._bindParameters.oitPass=0,this._bindParameters.alignPixelEnabled=o,this._bindParameters.decorations=!i,this._bindParameters.mainDepth=null;const d=!i||!this._sliceHelper.isDecoration;this._bindParameters.slicePlane=d?this._sliceHelper.plane:null,this._bindParameters.viewshedEnabled=this._nodes.produces(A.VIEWSHED),this._bindParameters.cutFillEnabled=this._nodes.produces(A.CUTFILL_DEPTH),this._renderOverlay(),a.setGLViewport(this._rctx);const _=this._framebuffer,l=_.initialize(a.fullWidth,a.fullHeight,this._backgroundColor,this._bindParameters.hasEmission);this.hasReflections?(l?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=l):l?.release(),this._ensureBindParametersCamera(a,n),this._plugins.sortTestsTransparentOrderedSlots(Pe),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!i;const u=this._plugins.produces(0,...ue);this._precompilePrepasses(),this.performanceInfo.advance(ae.PREPARE);const p=this._computeShadowDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,p),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(p,!r),this._oitCallouts=u&&this.oitEnabled,this._ensureBindParametersSSR(t),this._precompileShaders(u),this._rctx.output=0,_.bind(),this._bindParameters.mainDepth=_.depth.attachment,this._renderOpaque(),this._renderTransparent(u),this._shadowMap.disposeOutput(3),this._pluginInput.set(A.FOCUSAREA,this._renderFocusAreaGeometry()),this._pluginInput.set(A.CUTFILL_DEPTH,this._renderCutFillDepth()),_.update(e=>this._renderNodes(A.TRANSPARENT_ENVIRONMENT,e)),_.update(e=>this._renderNodes(A.VIEWSHED,e)),_.update(e=>this._renderNodes(A.LASERLINES,e)),_.update(e=>this._renderNodes(A.FOCUSAREA_COLOR,e)),this._pluginInput.release(A.FOCUSAREA),this._pluginInput.release(A.CUTFILL_DEPTH),_.update(e=>this._renderNodes(A.OCCLUDED,e)),this._pluginInput.set("highlights",this._renderHighlightPrepass());const c=2===s?this._renderObjectAndLayerIdColor():null;_.update(e=>this._renderNodes(x.COMPOSITE,e)),this._shadowMap.disposeOutputs(),_.update(e=>this._renderNodes(A.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(A.HIGHLIGHT_COLOR,e)),this._hasHUDHighlights||_.update(e=>this._renderHUD(m,e)),this._bindParameters.hasEmission=this._hasEmission,_.update(e=>this._renderNodes(A.MAGNIFIER,e)),_.update(e=>this._renderNodes(x.FINAL,e)),r&&this._blit.toFramebuffer(this._rctx,_.color,this._bindParameters),this.onPostRender?.(),this._releaseFBOs(),_.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),r||(f=_.color,f.retain(),this._releaseFBOs(),this._disposeOffscreenBuffers()),this.performanceInfo.finishFrame(),new ie(f,c)}_precompileShaders(e){++this._plugins.context.techniques.precompiling,this._rctx.output=0;const t=this._bindParameters.hasEmission;this._precompileOpaqueGeometry(),this._nodes.precompile(t,A.OPAQUE_ENVIRONMENT),this._nodes.precompile(t,A.GAUSSIAN_SPLAT);const s=this._bindParameters;s.terrainDepthTest=s.cullAboveTerrain=this._needsTerrainDepth,this._rctx.output=1,this._plugins.precompile(...pe),this._needsTerrainDepth&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._rctx.output=0,this._plugins.precompile(...pe);const i=this._pluginsHas.hudElements&&this.oitEnabled,r=this._pluginsHas.occludedHudElements;this._oitBlend.precompile(t,r,i),i&&this._oitBlend.precompile(!1,r,i),e&&(this._precompileTransparentGeometry(),this._hasPhotoshopTerrain&&(s.cullAboveTerrain=!1,this._precompileTransparentGeometry(),s.cullAboveTerrain=this._needsTerrainDepth)),this._nodes.precompile(t,A.FOCUSAREA);const a=this._hasPhotoshopTerrain&&!this._needsTerrainDepth;this._compositor.precompile(this._usesPremultipliedAlphaBlit,!!this._needsEdges,a,t),this._needsHUDVisibility&&this._plugins.precompile(13),this._oitCallouts||this._plugins.precompile(17),this._precompileHUD(0),s.terrainDepthTest=s.cullAboveTerrain=!1,this._nodes.precompile(t,A.TRANSPARENT_ENVIRONMENT,A.VIEWSHED,A.CUTFILL_DEPTH,A.CUTFILL_COLOR,A.LASERLINES,A.FOCUSAREA_COLOR,A.OCCLUDED,A.ANTIALIASING,A.HIGHLIGHT_COLOR),s.highlightMixTexture=s.highlights.length>1?this._rctx.emptyTexture:null,s.hasEmission=!1,this._precompileHUD(1),this.oitEnabled&&this._precompileHUD(0),s.hasEmission=this._hasEmission,this._hasHighlights&&(s.highlights.forEach((e,t)=>{s.highlightLevel=t,this._precompileAllGeometry(8),this._hasHUDHighlights&&this._plugins.precompile(15,14)}),s.highlightLevel=null,this._nodes.precompile(t,A.HIGHLIGHT_COLOR)),s.highlightMixTexture=null,this._nodes.precompile(t,x.COMPOSITE,A.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(9),--this._plugins.context.techniques.precompiling}_renderFocusAreaGeometry(){const e=this._nodes.produce(A.FOCUSAREA,this._pluginInput);return e&&this.performanceInfo.advance(ae.FOCUS_AREA_MASK),e}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._rctx.output;++this._techniques.precompiling;const{width:t,height:s}=this._framebuffer.size;let i=this.fboCache.acquire(t,s,"olid");return i.acquireDepth(13),i=this._nodes.render(i,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(ae.OBJECT_AND_LAYER_ID_COLOR),this._rctx.output=e,i}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,s=0===e;if(s||t){const e=s?this.performanceInfo.elapsedTime:0;let i=0;t?i=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const r=Math.max(e,i);this._animationTimestep.frame(r,s)}}readMainDepth(e,t){const{mainDepth:s,camera:i}=this._bindParameters;if(!s)return;const r=this.fboCache.acquire(this._framebuffer.size.width,this._framebuffer.size.height,"linear depth");this._rctx.bindFramebuffer(r.fbo),i.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(T),this._compositor.blitDepthToLinearDepth(this._bindParameters,s),this._rctx.setScissorTestEnabled(!1),this._rctx.setScissorRect(0,0,this._rctx.gl.canvas.width,this._rctx.gl.canvas.width),r.fbo?.readPixels(e[0],e[1],e[2],e[3],6408,ne.UNSIGNED_BYTE,t),r.release()}readHUDVisibility(e,t,s,i,r){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,s,i,6408,ne.UNSIGNED_BYTE,r)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}get _needsEdges(){return this._edgeView?.shouldRender()?this._edgeView:null}_renderEdges(e){const t=this._needsEdges;if(!t)return;const{width:s,height:i}=this._framebuffer.size,r=this.fboCache.acquire(s,i,"edges"),a=this._bindParameters.geometryDepth,n=()=>t.render(this._bindParameters,e);this._renderToTargets(n,r,a??this._framebuffer.depth,T),this._framebuffer.bind(),this._compositor.composite(this._bindParameters,r.getTexture()),r.release(),this.performanceInfo.advance(1===e?ae.OPAQUE_EDGES:ae.TRANSPARENT_EDGES)}_renderOverlay(){this._bindParameters.overlay=this.overlay?.render(this._renderContext.time),this._bindParameters.overlay&&this.performanceInfo.advance(ae.OVERLAY)}_renderShadowMap(e,t,s){if(!this.shadowsEnabled)return;const i=this._shadowMap;i.start(e,t,s,this.isFeatureEnabled(7),this.stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(5,this._shadowMap),i.clear(),this._renderShadowCascades(4,this._shadowMap)):this._renderShadowCascades(3),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,this._bindParameters.contentCamera),this.performanceInfo.advance(ae.SHADOW_MAP)}_renderCutFillDepth(){return this._nodes.produce(A.CUTFILL_DEPTH,this._pluginInput)}_precompileShadowCascades(e){0!==this._shadowMap.cascades.length&&this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){const s=this._rctx.output;t.bindFramebuffer();for(const i of t.cascades)i.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(i.camera,i.camera),this.renderAllGeometry(e);t.finish(e),this._rctx.output=s}get _needsDepth(){return this._plugins.consumes(1)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._shadowAccumulator.active||this._debugNeedsDepth}get _usesPremultipliedAlphaBlit(){return this._pluginsHas.hudElements&&this.oitEnabled||this._hasPhotoshopTerrain}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");e?(this._pluginInput.set(A.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(ae.DEPTH)):(e.detachDepth(),this._bindParameters.depth=n(this._bindParameters.depth)),this.hasSSAO&&this._pluginInput.release("normals")):this._renderAllGeometryDepth()}_renderAllGeometryDepth(){if(this._bindParameters.depth=n(this._bindParameters.depth),!this._needsDepth)return;const{width:e,height:t}=this._framebuffer.size,s=this.fboCache.acquire(e,t,"geometry depth",13);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(1280),this.renderAllGeometry(1),this._bindParameters.depth=s.obtainDepthTexture(),s.release(),this.performanceInfo.advance(ae.DEPTH)}_renderTerrainDepth(){if(this._bindParameters.terrainDepth=n(this._bindParameters.terrainDepth),this._bindParameters.terrainDepthTest=this._bindParameters.cullAboveTerrain=this._needsTerrainDepth,!this._needsTerrainDepth)return;const e=this._rctx.output;this._rctx.output=1;const{width:t,height:s}=this._framebuffer.size,i=this.fboCache.acquire(t,s,"terrain depth",13);this._rctx.bindFramebuffer(i.fbo),this._rctx.clear(1280),this._renderTransparentGround(),this._bindParameters.terrainDepth=i.obtainDepthTexture(),i.release(),this._rctx.output=e}_renderGeometryDepth(){if(this._bindParameters.geometryDepth=n(this._bindParameters.geometryDepth),!this._needsTerrainDepth)return;const e=this._rctx.output,{width:t,height:s}=this._framebuffer.size,i=this.fboCache.acquire(t,s,"geometry depth",13);this._rctx.bindFramebuffer(i.fbo),this._rctx.clear(1280),this._renderOpaqueAndTransparentGeometry(1),this._rctx.output=e,this._bindParameters.geometryDepth=i.obtainDepthTexture(),i.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)<R)return void(this.sceneDepthRange.value=z.Infinite);const t=e.clone();t.near=I,t.far=1e10;const s=W(t,this._plugins.plugins,this.stage.layers,1);s.union(this._plugins.queryDepthRange(t)),this.sceneDepthRange.value.equals(s)||(this.sceneDepthRange.value=s)}get _normalsRequired(){const e=this._nodes.require("normals",...D,A.VIEWSHED,A.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),this.hasSSAO&&this._normalsRequired&&this._nodes.precompile(this._bindParameters.hasEmission,A.SSAO)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const{width:t,height:s}=this._framebuffer.size,i=this.fboCache.acquire(t,s,"normals",5);i.acquireDepth(13),this._rctx.bindFramebuffer(i.fbo),this._rctx.clearFramebuffer(T,!0,!0),this._rctx.output=2,this._plugins.render(...ce);const r=this._nodes.optional("normals",...D,A.VIEWSHED);return i.retain(e+r-1),this.performanceInfo.advance(ae.NORMALS),i}_renderSSAO(){const e=this._pluginInput.get("normals");if(this.hasSSAO&&e)return this._bindParameters.ssao=this._nodes.produce(A.SSAO,this._pluginInput),this._bindParameters.ssao&&this.performanceInfo.advance(ae.SSAO),this._bindParameters.ssao}_precompileAllGeometry(e){const t=this._rctx.output;this._rctx.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(...pe),this._rctx.output=t}renderAllGeometry(e){this._rctx.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentGround()}precompileSlots(e,...t){for(const s of t)this._bindParameters.slot=s,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const s of t)this._renderContext.renderOccludedMask=s,this.precompileSlots(e,...fe);this._renderContext.renderOccludedMask=J}renderSlots(e,...t){for(const s of t)this._bindParameters.slot=s,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(...we[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._rctx.output;this._rctx.output=e,this._plugins.precompile(0,1,...pe),this._rctx.output=t}renderViewshedShadowMap(e){const{camera:t,contentCamera:s}=this._bindParameters,i=this._rctx.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(6),this._ensureBindParametersCamera(t,s),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.output=i}renderCutFillReferenceDepth(e){const{camera:t,contentCamera:s}=this._bindParameters,i=this._rctx.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this._rctx.output=7,this._plugins.render(0,1,...pe),this._ensureBindParametersCamera(t,s),t.setGLViewport(this._rctx),this._rctx.output=i}_renderOpaqueAndTransparentGeometry(e){this._rctx.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithoutNormals(e){this._rctx.output=e,this._plugins.render(...me)}_precompileOpaqueGeometry(){this._plugins.precompile(...le),this._nodes.precompile(this._bindParameters.hasEmission,"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,s=this.fboCache.acquire(e,t,"transparent terrain"),i=()=>this._plugins.render(6);return this._renderToTargets(i,s,this._framebuffer.depth,T),this.performanceInfo.advance(ae.TRANSPARENT_TERRAIN),s}_renderTransparentGround(){this._plugins.render(...pe)}get _needsHUDVisibility(){return this._plugins.produces(this._rctx.output,13)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility));const{width:e,height:t}=this._framebuffer.size;let s=this._bindParameters.hudVisibility;s?.fbo?.width===e&&s?.fbo?.height===t||(s?.release(),s=this.fboCache.acquire(e,t,"hud visibility",4),this._bindParameters.hudVisibility=s);const i=this._bindParameters.geometryDepth;s.attachDepth(i||this._framebuffer.depth),this._rctx.bindFramebuffer(s.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(13),s.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(ae.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,0===e){const e=()=>this._plugins.render(17),{width:t,height:s}=this._framebuffer.size,i=this.fboCache.acquireDepth(12,t,s,"line callouts");this._renderToTargets(e,this._framebuffer.color,i,void 0,!0,!0),i.release()}else this._plugins.render(17)}_precompileHUD(e){if(this._pluginsHas.hudElements&&(this._precompileHUDOutput(e),this._hasHighlights)){const t=this._rctx.output;this._rctx.output=8,this._precompileHUDOutput(e),this._rctx.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this.oitEnabled&&v(this._rctx.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)return t;if(this.oitEnabled){const s=this._renderOIT(1,e);this._rctx.bindFramebuffer(t.fbo);const i=!!t.getTexture(he);this._compositor.compositePreMultipliedAlpha(this._bindParameters,s.getTexture(),i),s.release()}else if(this._rctx.output=0,0===e){const t=()=>this._renderHUDElements(e),{width:s,height:i}=this._framebuffer.size,r=this.fboCache.acquireDepth(12,s,i,"hud");this._renderToTargets(t,this._framebuffer.color,r,void 0,!0,!0),r.release()}else t.acquireDepth(12),this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(256),this._renderHUDElements(e),t.detachDepth();return this.performanceInfo.advance(0===e?ae.HUD_OCCLUDED:ae.HUD),t}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(4,2)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:s}=this,{width:i,height:r}=this._framebuffer.size,{highlights:a}=s,n=a.length>G?3:1,h=e.acquire(i,r,"highlights",n);h.acquireDepth(13);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._rctx.output=8,t.bindFramebuffer(h.fbo),L(t,e,i,r,s,()=>this._renderHighlightGeometries()),h.detachDepth(),this.performanceInfo.advance(ae.HIGHLIGHTS),h.retain(this._nodes.require("highlights",...S)+this._nodes.optional("highlights",...S)-1),h}_renderHighlightGeometries(){this._plugins.render(...be),this._rctx.clear(256),this._renderHUDElements(2)}_renderShadowAccumulation(e,t){this._shadowAccumulator.updateDepthRange(e);const{depth:s,camera:i,contentCamera:r}=this._bindParameters;this._rctx.output=0,this._shadowAccumulator.accumulating&&s&&this._shadowAccumulator.renderAccumulation(s,i,r,t)&&this.performanceInfo.advance(ae.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this.oitEnabled&&v(this._rctx.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 s=1===e,{width:i,height:r}=this._framebuffer.size,a=s?()=>this._renderHUDElements(t):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._rctx.output;this._rctx.output=0,h.oitPass=1;const d=s?"oit hud":"oit",_=this.fboCache.acquire(i,r,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"),s||_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer([0,0,0,1]),l&&this._rctx.clearBuffer(1,T),a(),_.detachDepth(),h.oitPass=2;const p=this.fboCache.acquire(i,r,s?"oit hud front":"oit front");l&&p.acquireColor(he,8,"oit emissive front"),s?p.acquireDepth(12):p.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(p.fbo),this._rctx.clearFramebuffer(T,s),a(),p.detachDepth();const c=this._pluginsHas.occludedHudElements&&!s;let m;return this._bindParameters.hudOcclusion=n(this._bindParameters.hudOcclusion),h.oitPass=0,s?(m=this.fboCache.acquire(i,r,"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.blend(this._rctx,_,p,h,l,c,e),m?.detachDepth(),s||(this._rctx.bindFramebuffer(p.fbo),this._framebuffer.bind(),c&&(this._bindParameters.hudOcclusion=this._framebuffer.color.obtainAttachment(u))),p.release(),_.release(),this._rctx.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(A.CUTFILL_COLOR,e)),e.update(e=>this._renderNodes(A.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(A.OPAQUE_ENVIRONMENT,e)),this.fboCache.debugCallback?.(A.OPAQUE_ENVIRONMENT,t.color.fbo),this._renderEdges(1)}_renderTransparent(e){const t=this._framebuffer;t.bind(),this._renderPlugins(22,ae.VOXEL),t.update(e=>this._renderNodes(A.GAUSSIAN_SPLAT,e)),this.fboCache.debugCallback?.(A.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 s=this._renderPhotoshopTerrain(),i=s?.getTexture();i&&(this._bindParameters.hudVisibility&&(this._needsTerrainDepth?this._renderLineCallouts(0):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositor.compositeHUD(this._bindParameters,i))),this._renderHUD(0,t.color)),this._bindParameters.cullAboveTerrain=!1,i&&(t.bind(),this._compositor.compositePreMultipliedAlpha(this._bindParameters,i),s?.release(),this._needsTerrainDepth&&(this._renderEdges(1),e&&(this.oitEnabled?this._renderOIT(0):this._renderTransparentGeometry(),this.performanceInfo.advance(ae.TRANSPARENT)),this._renderEdges(0))),this._bindParameters.ssao=n(this._bindParameters.ssao),this._needsTerrainDepth&&this._renderLineCallouts(1),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(ae.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(9),this.performanceInfo.advance(ae.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderPlugins(e,t){this._plugins.produces(this._rctx.output,e)&&(this._plugins.render(e),this.performanceInfo.advance(t))}_renderNodes(e,t,s=!1){const i=t.name;if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return s&&this.performanceInfo.advance(e),t;this._fboCache.debugCallback?.(i,t.fbo);const r=this._nodes.render(t,this._pluginInput,this._releaseNodeInputs);return this.performanceInfo.advance(e),r}_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(Ce,this._bindParameters.camera.viewMatrix),f(Te,this._bindParameters.camera.projectionMatrix),g(xe,Ce,Te),g(xe,this._renderContext.lastFrameCamera.viewMatrix,xe),g(xe,this._renderContext.lastFrameCamera.projectionMatrix,xe),this._reprojectionMatrix=xe);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,s,i){this._bindParameters.updateLighting(e,t,s,i),this._requestRender(1)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}_renderToTargets(e,t,s,i,r=!1,a=!1){t.attachDepth(s),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(i,r,a),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],Pe=[4,9,5,12],we={0:[15],1:[14],2:[15,14],3:[15,14]},Ee=["normals","highlights"],Te=P(),Ce=P(),xe=P();function Ae(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 s}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import{removeMaybe as r,abortMaybe as i,destroyMaybe as a,releaseMaybe as n}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 E}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 C}from"../../../../geometry/support/Indices.js";import{RenderNodeOutput as x,InternalRenderCategory as D,AllRenderNodeOutputs as A,AllInternalRenderNodeOutputs as S}from"../../webgl.js";import{innerAtmosphereFadeStart as R}from"../../environment/atmosphereUtils.js";import{minNearDistanceInMeters as y}from"../../state/NearFarHeuristic.js";import{debugFlags as I}from"../../support/debugFlags.js";import{FBOCache as O}from"../core/FBOCache.js";import{RenderPassManager as H}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 N}from"../effects/RenderPluginManager.js";import{Blit as q}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as G,renderHighlightBuffer as V}from"../effects/highlight/Highlight.js";import{OITBlend as U}from"../effects/transparency/OITBlend.js";import{AnimationTimer as L}from"./AnimationTimer.js";import{AnimationTimeStep as j}from"./AnimationTimeStep.js";import{BoundingInfo as B}from"./BoundingInfo.js";import{Compositor as k}from"./Compositor.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 Z}from"./RenderFeature.js";import{RenderPluginInput as $}from"./RenderPluginInput.js";import{ShadowAccumulator as X}from"./ShadowAccumulator.js";import{ShadowMap as ee}from"./ShadowMap.js";import te from"./SliceHelper.js";import{MergedRenderer as se}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as re}from"../parts/renderUtils.js";import{RendererPerformanceInfo as ie,PerformanceCategory as ae}from"../statistics/RendererPerformanceInfo.js";import{PixelType as ne,ColorAttachment1 as he,ColorAttachment2 as oe,ColorAttachment0 as de}from"../../../webgl/enums.js";let _e=class extends K{constructor(e,t,s,r,i){super({stage:e}),this._techniques=s,this._rctx=r,this._requestRender=i,this._pluginsHas={occludedHudElements:!1,hudElements:!1,water:!1},this.renderPassManager=new H,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 j,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=u(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new $,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 O(r),this._compositor=new k(r,s),this._renderStateFeatures=u(Z(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(s),this._shadowAccumulator=new X(this.fboCache,s,e,e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t},(t,s,r)=>{const i=e.view.qualitySettings.maximumPixelRatio;t.shadowMap.start(t.camera,s,r,!0,i),this._renderShadowCascades(3,t.shadowMap),t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.contentCamera)},i),this._renderContext=new Y(this._rctx,this._shadowMap,s),this._nodes=new M(this._renderContext),this._plugins=new N({renderContext:this._renderContext,techniques:s,materials:t,requestRender:i,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this.addHandles([o(()=>e.view.state.camera,()=>i(),d),o(()=>I.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES,e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(0):()=>{},i()},_),o(()=>e.view.environment.background?.color,e=>{const t=e?e.toUnitRGBA():T;E(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),i()},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,()=>i(),l),o(()=>e.view.state.highlights,e=>{this._bindParameters.highlights=e,i()},_)])}destroy(){this._gpuTimerHandle=r(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.destroy(),this._shadowAccumulator=null,this._loadEdgeViewTask=i(this._loadEdgeViewTask),this._edgeView=a(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._oitBlendOrNil=null,this._nodes=null,this._framebuffer=null,this._shadowMap=null,this._renderContext=null,this._performanceInfo=null,B.prune(),se.prune(),C()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _oitBlend(){return this._oitBlendOrNil??=new U(this._techniques),this._oitBlendOrNil}get performanceInfo(){return this._performanceInfo}updateRenderFeatures(e){this._renderStateFeatures.value=Z(e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,s){this._renderStateFeatures.mutate(r=>r.set(t,e,s)),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 _hasEmission(){return this._plugins.hasEmitters&&this._hasFloatBufferBlendSupport}get highResolutionAtmosphere(){return this.isFeatureEnabled(4)}get fboCache(){return this._fboCache}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=n(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=n(this._bindParameters.geometryDepth),this._bindParameters.hudOcclusion=n(this._bindParameters.hudOcclusion)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOutputs(),this._bindParameters.depth=n(this._bindParameters.depth),this._bindParameters.hudVisibility=n(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=s(async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");h(e);const s=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:De(this.stage.view.resourceController)});return this.addHandles(o(()=>s.updating,()=>this._requestRender(),l)),this._requestRender(),this._edgeViewCallbacks.forEach(e=>e(s)),this._edgeViewCallbacks.length=0,s})),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:s}=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;s.enableFillLights!==t&&(s.enableFillLights=t,this._requestRender())}e.shadowCast&&this._shadowAccumulator.setParameters(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 L(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const s=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==s&&(this._gpuTimerHandle=s?r(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,s,r=!1){try{return this._isRendering=!0,this._render(e,t,s,r)}catch(i){console.error(`Exception during rendering: ${i}`)}finally{this._isRendering=!1}return new re(this._pluginInput.get(x.FINAL),null)}_render(e,t,s,r){const i=0===s;this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=i,this._disposeBindBuffers();const{camera:a,contentCamera:n,mode:h,alignPixelEnabled:o}=e;this._state.value=h,this._renderContext.time=t,this._rctx.output=0,this._bindParameters.hasEmission=this._hasEmission,this._bindParameters.oitPass=0,this._bindParameters.alignPixelEnabled=o,this._bindParameters.decorations=!r,this._bindParameters.mainDepth=null;const d=!r||!this._sliceHelper.isDecoration;this._bindParameters.slicePlane=d?this._sliceHelper.plane:null,this._bindParameters.viewshedEnabled=this._nodes.produces(D.VIEWSHED),this._bindParameters.cutFillEnabled=this._nodes.produces(D.CUTFILL_DEPTH),this._renderOverlay(),a.setGLViewport(this._rctx);const _=this._framebuffer,l=_.initialize(a.fullWidth,a.fullHeight,this._backgroundColor,this._bindParameters.hasEmission);this.hasReflections?(l?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=l):l?.release(),this._ensureBindParametersCamera(a,n),this._plugins.sortTestsTransparentOrderedSlots(Pe),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!r;const u=this._plugins.produces(0,...ue);this._precompilePrepasses(),this.performanceInfo.advance(ae.PREPARE);const p=this._computeShadowDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,p),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(p,!i),this._oitCallouts=u&&this.oitEnabled,this._ensureBindParametersSSR(t),this._precompileShaders(u),this._rctx.output=0,_.bind(),this._bindParameters.mainDepth=_.depth.attachment,this._renderOpaque(),this._renderTransparent(u),this._shadowMap.disposeOutput(3),this._pluginInput.set(D.FOCUSAREA,this._renderFocusAreaGeometry()),this._pluginInput.set(D.CUTFILL_DEPTH,this._renderCutFillDepth()),_.update(e=>this._renderNodes(D.TRANSPARENT_ENVIRONMENT,e)),_.update(e=>this._renderNodes(D.VIEWSHED,e)),_.update(e=>this._renderNodes(D.LASERLINES,e)),_.update(e=>this._renderNodes(D.FOCUSAREA_COLOR,e)),this._pluginInput.release(D.FOCUSAREA),this._pluginInput.release(D.CUTFILL_DEPTH),_.update(e=>this._renderNodes(D.OCCLUDED,e)),this._pluginInput.set("highlights",this._renderHighlightPrepass());const c=2===s?this._renderObjectAndLayerIdColor():null;_.update(e=>this._renderNodes(x.COMPOSITE,e)),this._shadowMap.disposeOutputs(),_.update(e=>this._renderNodes(D.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(D.HIGHLIGHT_COLOR,e)),this._hasHUDHighlights||_.update(e=>this._renderHUD(m,e)),this._bindParameters.hasEmission=this._hasEmission,_.update(e=>this._renderNodes(D.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._rctx.output=0;const t=this._bindParameters.hasEmission;this._precompileOpaqueGeometry(),this._nodes.precompile(t,D.OPAQUE_ENVIRONMENT,D.PRE_TRANSPARENT);const s=this._bindParameters;s.terrainDepthTest=s.cullAboveTerrain=this._needsTerrainDepth,this._rctx.output=1,this._plugins.precompile(...pe),this._needsTerrainDepth&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._rctx.output=0,this._plugins.precompile(...pe),e&&this.oitEnabled&&this._oitBlend.precompile(t,this._pluginsHas.occludedHudElements,0),this._pluginsHas.hudElements&&this._oitBlend.precompile(t,!1,1),e&&(this._precompileTransparentGeometry(),this._hasPhotoshopTerrain&&(s.cullAboveTerrain=!1,this._precompileTransparentGeometry(),s.cullAboveTerrain=this._needsTerrainDepth)),this._nodes.precompile(t,D.FOCUSAREA);const r=this._hasPhotoshopTerrain&&!this._needsTerrainDepth;this._compositor.precompile(this._usesPremultipliedAlphaBlit,!!this._needsEdges,r,t),this._needsHUDVisibility&&this._plugins.precompile(13),this._oitCallouts||this._plugins.precompile(17),this._precompileHUD(0),s.terrainDepthTest=s.cullAboveTerrain=!1,this._nodes.precompile(t,D.TRANSPARENT_ENVIRONMENT,D.VIEWSHED,D.CUTFILL_DEPTH,D.CUTFILL_COLOR,D.LASERLINES,D.FOCUSAREA_COLOR,D.OCCLUDED,D.ANTIALIASING),s.highlightMixTexture=s.highlights.length>1?this._rctx.emptyTexture:null,s.hasEmission=!1,this._precompileHUD(1),this.oitEnabled&&this._precompileHUD(0),s.hasEmission=this._hasEmission,this._hasHighlights&&(s.highlights.forEach((e,t)=>{s.highlightLevel=t,this._precompileAllGeometry(8),this._hasHUDHighlights&&this._plugins.precompile(15,14)}),s.highlightLevel=null,this._nodes.precompile(t,D.HIGHLIGHT_COLOR)),s.highlightMixTexture=null,this._nodes.precompile(t,x.COMPOSITE,D.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(9),--this._plugins.context.techniques.precompiling}_renderFocusAreaGeometry(){const e=this._nodes.produce(D.FOCUSAREA,this._pluginInput);return e&&this.performanceInfo.advance(ae.FOCUS_AREA_MASK),e}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._rctx.output;++this._techniques.precompiling;const{width:t,height:s}=this._framebuffer.size;let r=this.fboCache.acquire(t,s,"olid");return r.acquireDepth(13),r=this._nodes.render(r,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(ae.OBJECT_AND_LAYER_ID_COLOR),this._rctx.output=e,r}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,s=0===e;if(s||t){const e=s?this.performanceInfo.elapsedTime:0;let r=0;t?r=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const i=Math.max(e,r);this._animationTimestep.frame(i,s)}}readMainDepth(e,t){const{mainDepth:s,camera:r}=this._bindParameters;if(!s)return;const i=this.fboCache.acquire(this._framebuffer.size.width,this._framebuffer.size.height,"linear depth");this._rctx.bindFramebuffer(i.fbo),r.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(T),this._compositor.blitDepthToLinearDepth(this._bindParameters,s),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,s,r,i){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,s,r,6408,ne.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}get _needsEdges(){return this._edgeView?.shouldRender()?this._edgeView:null}_renderEdges(e){const t=this._needsEdges;if(!t)return;const{width:s,height:r}=this._framebuffer.size,i=this.fboCache.acquire(s,r,"edges"),a=this._bindParameters.geometryDepth,n=()=>t.render(this._bindParameters,e);this._renderToTargets(n,i,a??this._framebuffer.depth,T),this._framebuffer.bind(),this._compositor.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(1===e?ae.OPAQUE_EDGES:ae.TRANSPARENT_EDGES)}_renderOverlay(){this._bindParameters.overlay=this.overlay?.render(this._renderContext.time),this._bindParameters.overlay&&this.performanceInfo.advance(ae.OVERLAY)}_renderShadowMap(e,t,s){if(!this.shadowsEnabled)return;const r=this._shadowMap;r.start(e,t,s,this.isFeatureEnabled(7),this.stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(5,this._shadowMap),r.clear(),this._renderShadowCascades(4,this._shadowMap)):this._renderShadowCascades(3),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,this._bindParameters.contentCamera),this.performanceInfo.advance(ae.SHADOW_MAP)}_renderCutFillDepth(){return this._nodes.produce(D.CUTFILL_DEPTH,this._pluginInput)}_precompileShadowCascades(e){0!==this._shadowMap.cascades.length&&this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){const s=this._rctx.output;t.bindFramebuffer();for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e);t.finish(e),this._rctx.output=s}get _needsDepth(){return this._plugins.consumes(1)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._shadowAccumulator.active||this._debugNeedsDepth}get _usesPremultipliedAlphaBlit(){return this._pluginsHas.hudElements&&this.oitEnabled||this._hasPhotoshopTerrain}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");e?(this._pluginInput.set(D.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(ae.DEPTH)):(e.detachDepth(),this._bindParameters.depth=n(this._bindParameters.depth)),this.hasSSAO&&this._pluginInput.release("normals")):this._renderAllGeometryDepth()}_renderAllGeometryDepth(){if(this._bindParameters.depth=n(this._bindParameters.depth),!this._needsDepth)return;const{width:e,height:t}=this._framebuffer.size,s=this.fboCache.acquire(e,t,"geometry depth",13);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(1280),this.renderAllGeometry(1),this._bindParameters.depth=s.obtainDepthTexture(),s.release(),this.performanceInfo.advance(ae.DEPTH)}_renderTerrainDepth(){if(this._bindParameters.terrainDepth=n(this._bindParameters.terrainDepth),this._bindParameters.terrainDepthTest=this._bindParameters.cullAboveTerrain=this._needsTerrainDepth,!this._needsTerrainDepth)return;const e=this._rctx.output;this._rctx.output=1;const{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquire(t,s,"terrain depth",13);this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(1280),this._renderTransparentGround(),this._bindParameters.terrainDepth=r.obtainDepthTexture(),r.release(),this._rctx.output=e}_renderGeometryDepth(){if(this._bindParameters.geometryDepth=n(this._bindParameters.geometryDepth),!this._needsTerrainDepth)return;const e=this._rctx.output,{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquire(t,s,"geometry depth",13);this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(1280),this._renderOpaqueAndTransparentGeometry(1),this._rctx.output=e,this._bindParameters.geometryDepth=r.obtainDepthTexture(),r.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)<R)return void(this.sceneDepthRange.value=z.Infinite);const t=e.clone();t.near=y,t.far=1e10;const s=W(t,this._plugins.plugins,this.stage.layers,1);s.union(this._plugins.queryDepthRange(t)),this.sceneDepthRange.value.equals(s)||(this.sceneDepthRange.value=s)}get _normalsRequired(){const e=this._nodes.require("normals",...A,D.VIEWSHED,D.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),this.hasSSAO&&this._normalsRequired&&this._nodes.precompile(this._bindParameters.hasEmission,D.SSAO)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquire(t,s,"normals",5);r.acquireDepth(13),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(T,!0,!0),this._rctx.output=2,this._plugins.render(...ce);const i=this._nodes.optional("normals",...A,D.VIEWSHED);return r.retain(e+i-1),this.performanceInfo.advance(ae.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(this.hasSSAO&&e)return this._bindParameters.ssao=this._nodes.produce(D.SSAO,this._pluginInput),this._bindParameters.ssao&&this.performanceInfo.advance(ae.SSAO),this._bindParameters.ssao}_precompileAllGeometry(e){const t=this._rctx.output;this._rctx.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(...pe),this._rctx.output=t}renderAllGeometry(e){this._rctx.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentGround()}precompileSlots(e,...t){for(const s of t)this._bindParameters.slot=s,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const s of t)this._renderContext.renderOccludedMask=s,this.precompileSlots(e,...fe);this._renderContext.renderOccludedMask=J}renderSlots(e,...t){for(const s of t)this._bindParameters.slot=s,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(...Ee[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._rctx.output;this._rctx.output=e,this._plugins.precompile(0,1,...pe),this._rctx.output=t}renderViewshedShadowMap(e){const{camera:t,contentCamera:s}=this._bindParameters,r=this._rctx.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(6),this._ensureBindParametersCamera(t,s),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.output=r}renderCutFillReferenceDepth(e){const{camera:t,contentCamera:s}=this._bindParameters,r=this._rctx.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this._rctx.output=7,this._plugins.render(0,1,...pe),this._ensureBindParametersCamera(t,s),t.setGLViewport(this._rctx),this._rctx.output=r}_renderOpaqueAndTransparentGeometry(e){this._rctx.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithoutNormals(e){this._rctx.output=e,this._plugins.render(...me)}_precompileOpaqueGeometry(){this._plugins.precompile(...le),this._nodes.precompile(this._bindParameters.hasEmission,"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,s=this.fboCache.acquire(e,t,"transparent terrain"),r=()=>this._plugins.render(6);return this._renderToTargets(r,s,this._framebuffer.depth,T),this.performanceInfo.advance(ae.TRANSPARENT_TERRAIN),s}_renderTransparentGround(){this._plugins.render(...pe)}get _needsHUDVisibility(){return this._plugins.produces(this._rctx.output,13)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility));const{width:e,height:t}=this._framebuffer.size;let s=this._bindParameters.hudVisibility;s?.fbo?.width===e&&s?.fbo?.height===t||(s?.release(),s=this.fboCache.acquire(e,t,"hud visibility",4),this._bindParameters.hudVisibility=s);const r=this._bindParameters.geometryDepth;s.attachDepth(r||this._framebuffer.depth),this._rctx.bindFramebuffer(s.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(13),s.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(ae.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,0===e){const e=()=>this._plugins.render(17),{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquireDepth(12,t,s,"line callouts");this._renderToTargets(e,this._framebuffer.color,r,void 0,!0,!0),r.release()}else this._plugins.render(17)}_precompileHUD(e){if(this._pluginsHas.hudElements&&(this._precompileHUDOutput(e),this._hasHighlights)){const t=this._rctx.output;this._rctx.output=8,this._precompileHUDOutput(e),this._rctx.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this.oitEnabled&&v(this._rctx.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)return t;if(this.oitEnabled){const s=this._renderOIT(1,e);this._rctx.bindFramebuffer(t.fbo);const r=!!t.getTexture(he);this._compositor.compositePreMultipliedAlpha(this._bindParameters,s.getTexture(),r),s.release()}else if(this._rctx.output=0,0===e){const t=()=>this._renderHUDElements(e),{width:s,height:r}=this._framebuffer.size,i=this.fboCache.acquireDepth(12,s,r,"hud");this._renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(12),this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(256),this._renderHUDElements(e),t.detachDepth();return this.performanceInfo.advance(0===e?ae.HUD_OCCLUDED:ae.HUD),t}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(4,2)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:s}=this,{width:r,height:i}=this._framebuffer.size,{highlights:a}=s,n=a.length>G?3:1,h=e.acquire(r,i,"highlights",n);h.acquireDepth(13);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._rctx.output=8,t.bindFramebuffer(h.fbo),V(t,e,r,i,s,()=>this._renderHighlightGeometries()),h.detachDepth(),this.performanceInfo.advance(ae.HIGHLIGHTS),h.retain(this._nodes.require("highlights",...S)+this._nodes.optional("highlights",...S)-1),h}_renderHighlightGeometries(){this._plugins.render(...be),this._rctx.clear(256),this._renderHUDElements(2)}_renderShadowAccumulation(e,t){this._shadowAccumulator.updateDepthRange(e);const{depth:s,camera:r,contentCamera:i}=this._bindParameters;this._rctx.output=0,this._shadowAccumulator.accumulating&&s&&this._shadowAccumulator.renderAccumulation(s,r,i,t)&&this.performanceInfo.advance(ae.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this.oitEnabled&&v(this._rctx.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 s=1===e,{width:r,height:i}=this._framebuffer.size,a=s?()=>this._renderHUDElements(t):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._rctx.output;this._rctx.output=0,h.oitPass=1;const d=s?"oit hud":"oit",_=this.fboCache.acquire(r,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"),s||_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer([0,0,0,1]),l&&this._rctx.clearBuffer(1,T),a(),_.detachDepth(),h.oitPass=2;const p=this.fboCache.acquire(r,i,s?"oit hud front":"oit front");l&&p.acquireColor(he,8,"oit emissive front"),s?p.acquireDepth(12):p.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(p.fbo),this._rctx.clearFramebuffer(T,s),a(),p.detachDepth();const c=this._pluginsHas.occludedHudElements&&!s;let m;return this._bindParameters.hudOcclusion=n(this._bindParameters.hudOcclusion),h.oitPass=0,s?(m=this.fboCache.acquire(r,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.blend(this._rctx,_,p,h,l,c,e),m?.detachDepth(),s||(this._rctx.bindFramebuffer(p.fbo),this._framebuffer.bind(),c&&(this._bindParameters.hudOcclusion=this._framebuffer.color.obtainAttachment(u))),p.release(),_.release(),this._rctx.output=o,m}_renderOpaque(){const e=this.plugins.produces(0,...le);e&&(this._plugins.render(0,1),this._framebuffer.update(e=>this._renderNodes(D.CUTFILL_COLOR,e)),this._framebuffer.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(D.OPAQUE_ENVIRONMENT,e)),this.fboCache.debugCallback?.(D.OPAQUE_ENVIRONMENT,t.color.fbo),this._renderEdges(1)}_renderTransparent(e){const t=this._framebuffer;t.bind(),t.update(e=>this._renderNodes(D.PRE_TRANSPARENT,e)),this.fboCache.debugCallback?.(D.PRE_TRANSPARENT,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 s=this._renderPhotoshopTerrain(),r=s?.getTexture();r&&(this._bindParameters.hudVisibility&&(this._needsTerrainDepth?this._renderLineCallouts(0):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositor.compositeHUD(this._bindParameters,r))),this._renderHUD(0,t.color)),this._bindParameters.cullAboveTerrain=!1,r&&(t.bind(),this._compositor.compositePreMultipliedAlpha(this._bindParameters,r),s?.release(),this._needsTerrainDepth&&(this._renderEdges(1),e&&(this.oitEnabled?this._renderOIT(0):this._renderTransparentGeometry(),this.performanceInfo.advance(ae.TRANSPARENT)),this._renderEdges(0))),this._bindParameters.ssao=n(this._bindParameters.ssao),this._needsTerrainDepth&&this._renderLineCallouts(1),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(ae.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(9),this.performanceInfo.advance(ae.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderNodes(e,t,s=!1){const r=t.name;if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return s&&this.performanceInfo.advance(e),t;this._fboCache.debugCallback?.(r,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(Ce,this._bindParameters.camera.viewMatrix),f(Te,this._bindParameters.camera.projectionMatrix),g(xe,Ce,Te),g(xe,this._renderContext.lastFrameCamera.viewMatrix,xe),g(xe,this._renderContext.lastFrameCamera.projectionMatrix,xe),this._reprojectionMatrix=xe);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,s,r){this._bindParameters.updateLighting(e,t,s,r),this._requestRender(1)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}_renderToTargets(e,t,s,r,i=!1,a=!1){t.attachDepth(s),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(r,i,a),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],Pe=[4,9,5,12],Ee={0:[15],1:[14],2:[15,14],3:[15,14]},we=["normals","highlights"],Te=P(),Ce=P(),xe=P();function De(e){return t=>e.immediate.schedule(t)}export{_e as Renderer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{disposeMaybe as t}from"../../../../core/maybe.js";import{recordPerformance as e}from"../../../../core/performance.js";import r from"../../../../core/PerformanceSampler.js";import{Milliseconds as i}from"../../../../core/time.js";import{RenderNodeOutput as s,InternalRenderCategory as a}from"../../webgl.js";import{createElapsedTimerPool as m}from"../../../webgl/TimerPool.js";const o={OVERLAY:"overlay",PREPARE:"prepare",SHADOW_MAP:"shadow map",DEPTH:"depth",ACCUMULATED_SHADOWS:"accumulated shadows",APPLY_ACCUMULATED_SHADOWS:"apply accumulated shadows",OBJECT_AND_LAYER_ID_COLOR:"object/layer id color",NORMALS:"normals",SSAO:"SSAO",HIGHLIGHTS:"highlights",OPAQUE_EDGES:"opaque edges",
|
|
2
|
+
import{disposeMaybe as t}from"../../../../core/maybe.js";import{recordPerformance as e}from"../../../../core/performance.js";import r from"../../../../core/PerformanceSampler.js";import{Milliseconds as i}from"../../../../core/time.js";import{RenderNodeOutput as s,InternalRenderCategory as a}from"../../webgl.js";import{createElapsedTimerPool as m}from"../../../webgl/TimerPool.js";const o={OVERLAY:"overlay",PREPARE:"prepare",SHADOW_MAP:"shadow map",DEPTH:"depth",ACCUMULATED_SHADOWS:"accumulated shadows",APPLY_ACCUMULATED_SHADOWS:"apply accumulated shadows",OBJECT_AND_LAYER_ID_COLOR:"object/layer id color",NORMALS:"normals",SSAO:"SSAO",HIGHLIGHTS:"highlights",OPAQUE_EDGES:"opaque edges",TRANSPARENT:"transparent",TRANSPARENT_EDGES:"transparent edges",HUD_VISIBILITY:"HUD visibility",TRANSPARENT_TERRAIN:"transparent terrain",TRANSPARENT_MATERIAL_WITHOUT_DEPTH:"transparent material without depth",OPAQUE_ENVIRONMENT:"opaque environment",TRANSPARENT_ENVIRONMENT:"transparent environment",OCCLUDED:"occluded",HUD:"HUD",HUD_OCCLUDED:"HUD occluded",FINISH:"finish",FOCUS_AREA_MASK:"focus area mask"},p=Object.values(s).concat(Object.values(a)).concat(Object.values(o)),l="Total";class T{constructor(t){this._rctx=t,this._startTimeStampCPU=i(0),this._lastTimeStampCPU=i(0),this._totalCPUTime=new r(l),this._cpuTimeSamplers=new Map(p.map(t=>[t,new r(t)])),this._enableGPUTimer=0,this._totalGPUTime=new r("GPU"),this._gpuTimeSamplers=new Map(p.map(t=>[t,new r(t)])),this._totalTime=i(0),this._totalFrameCount=0}get totalCPUTimeSampler(){return this._totalCPUTime}get cpuTimeSamplers(){return Array.from(this._cpuTimeSamplers.values())}get totalGPUTimeSampler(){return this._totalGPUTime}get gpuTimeSamplers(){return Array.from(this._gpuTimeSamplers.values())}get gpuSamplingEnabled(){return null!=this._gpuTimerPool}get totalTime(){return this._totalTime}get totalFrameCount(){return this._totalFrameCount}get elapsedTime(){return i(performance.now()-this._startTimeStampCPU)}enableGPUPerformanceInfo(){if(null==this._gpuTimerPool){const t=[...p,l];this._gpuTimerPool=m(this._rctx,t)}if(null==this._gpuTimerPool)return{hasGPUTimerSupport:!1,remove:()=>{}};++this._enableGPUTimer;let e=!1;return{hasGPUTimerSupport:!0,remove:()=>{e||(e=!0,--this._enableGPUTimer,0===this._enableGPUTimer&&(this._gpuTimerPool=t(this._gpuTimerPool)))}}}startFrame(){this._startTimeStampCPU=this._lastTimeStampCPU=i(performance.now()),this._gpuTimerPool&&(this._gpuTimeSamplers.forEach(t=>t.push(0)),this._gpuTimerPool.start())}advance(t){const r=i(performance.now());if(this._cpuTimeSamplers.get(t).push(r-this._lastTimeStampCPU),e(t,this._lastTimeStampCPU,r,"Maps SDK","Scheduling"),this._lastTimeStampCPU=r,this._gpuTimerPool){const e=this._gpuTimerPool.stop(t);this._gpuTimeSamplers.get(t).set(e),this._gpuTimerPool.start()}}finishFrame(){if(this._gpuTimerPool){const t=this._gpuTimerPool.stop(o.FINISH);this._gpuTimeSamplers.get(o.FINISH).set(t),this._rctx.gl.flush()}const t=i(performance.now()-this._startTimeStampCPU);this._totalTime=i(this._totalTime+t),this._totalCPUTime.push(t),this._gpuTimerPool&&this._totalGPUTime.push(this.gpuTimeSamplers.reduce((t,e)=>t+(e.last||0),0)),++this._totalFrameCount}}export{p as PerformanceCategories,o as PerformanceCategory,T as RendererPerformanceInfo};
|
package/views/3d/webgl.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import o from"../../Camera.js";import{rad2deg as e,deg2rad as r}from"../../core/mathUtils.js";import{create as t}from"../../core/libs/gl-matrix-2/factories/mat4f64.js";import{scale as i,add as n}from"../../core/libs/gl-matrix-2/math/vec3.js";import{create as c}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import l from"../../geometry/Point.js";import a from"../../geometry/SpatialReference.js";import{computeTranslationToOriginAndRotation as s}from"../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as m}from"../../geometry/projection/projectBuffer.js";import{projectPointToVector as p}from"../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as f}from"../../geometry/projection/projectVectorToVector.js";import{cameraOnContentAlongViewDirection as u}from"./camera/intersectionUtils.js";import{directionToHeadingTilt as R,viewModeDependentUtil as
|
|
2
|
+
import o from"../../Camera.js";import{rad2deg as e,deg2rad as r}from"../../core/mathUtils.js";import{create as t}from"../../core/libs/gl-matrix-2/factories/mat4f64.js";import{scale as i,add as n}from"../../core/libs/gl-matrix-2/math/vec3.js";import{create as c}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import l from"../../geometry/Point.js";import a from"../../geometry/SpatialReference.js";import{computeTranslationToOriginAndRotation as s}from"../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as m}from"../../geometry/projection/projectBuffer.js";import{projectPointToVector as p}from"../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as f}from"../../geometry/projection/projectVectorToVector.js";import{cameraOnContentAlongViewDirection as u}from"./camera/intersectionUtils.js";import{directionToHeadingTilt as R,viewModeDependentUtil as d}from"./support/viewingModeUtils.js";const A={OPAQUE:"opaque-color",TRANSPARENT:"transparent-color",COMPOSITE:"composite-color",FINAL:"final-color"},E=[A.FINAL,A.COMPOSITE,A.OPAQUE,A.TRANSPARENT],T={ANTIALIASING:"aa-color",CUTFILL_COLOR:"cutfill-color",CUTFILL_DEPTH:"cutfill-depth",FOCUSAREA_COLOR:"focusarea-color",FOCUSAREA:"focusarea",PRE_TRANSPARENT:"pre-transparent-color",HIGHLIGHT_COLOR:"highlight-color",LASERLINES:"laserline-color",MAGNIFIER:"magnifier-color",OCCLUDED:"occluded-color",OPAQUE_ENVIRONMENT:"opaque-environment-color",SSAO:"ssao",TRANSPARENT_ENVIRONMENT:"transparent-environment-color",VIEWSHED:"viewshed-color"},j=Array.from(Object.values(T)).concat(E);function O(o,e,r,t,i,n,c){return t=t||o.spatialReference,m(e,t,r,i,o.renderCoordsHelper.spatialReference,n,c)?i:null}function g(o,e,r,t,i,n,c){return n=n||o.spatialReference,m(e,o.renderCoordsHelper.spatialReference,r,t,n,i,c)?t:null}function N(o,e,r,i){return i||(i=t()),r=r||o.spatialReference,s(r,e,i,o.renderCoordsHelper.spatialReference)?i:null}function y(r,t,i){const n=r.renderSpatialReference,c=R(r,t.eye,t.viewForward,t.up,C);let s=r.spatialReference;return f(t.eye,n,I,s)||(s=a.WGS84,f(t.eye,n,I,s)),null==i?i=new o(new l(I,s),c.heading,c.tilt,e(t.fov)):(i.position.x=I[0],i.position.y=I[1],i.position.z=I[2],i.position.spatialReference=s,i.heading=c.heading,i.tilt=c.tilt,i.fov=e(t.fov)),i.layout.row=t.row,i.layout.rows=t.rows,i.layout.column=t.column,i.layout.columns=t.columns,i}function S(o,e){if(!e)return null;const t=o.renderSpatialReference,l=d(o).headingTiltToDirectionUp,a=c();if(!p(e.position,a,t))return null;const s=l(a,e.heading,e.tilt);i(s.direction,s.direction,o.state.camera.distance),n(s.direction,s.direction,a);const m=u(o,a,s.direction,s.up);return m.fov=r(e.fov),m.row=e.layout.row,m.rows=e.layout.rows,m.column=e.layout.column,m.columns=e.layout.columns,m}const I=c(),C={heading:0,tilt:0};export{j as AllInternalRenderNodeOutputs,E as AllRenderNodeOutputs,T as InternalRenderCategory,A as RenderNodeOutput,y as fromRenderCamera,g as fromRenderCoordinates,N as renderCoordinateTransformAt,S as toRenderCamera,O as toRenderCoordinates};
|
package/views/draw/DrawTool.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__addDisposableResource as e,__disposeResources as t,__decorate as i}from"tslib";import{disposable as a}from"../../core/handleUtils.js";import n from"../../core/Logger.js";import{getOrCreateMapValue as r}from"../../core/MapUtils.js";import{destroyMaybe as o}from"../../core/maybe.js";import{when as s,initial as l,on as d,sync as p,watch as c}from"../../core/reactiveUtils.js";import{screenPointEqual as g,createScreenPoint as u}from"../../core/screenUtils.js";import{diff as h}from"../../core/accessorSupport/diffUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as y}from"../../core/support/UpdatingHandles.js";import f from"../../geometry/Polygon.js";import{i as M,e as _}from"../../chunks/simplifyOperator.js";import{isExtent as w}from"../../geometry/support/jsonTypeUtils.js";import{isPolygon as C}from"../../geometry/support/typeUtils.js";import{isCurvedGeometry as H}from"../../geometry/support/curves/curveUtils.js";import{densifyCurvedGeometry as P}from"../../geometry/support/curves/densifyCurvedGeometry.js";import{getMaxDeviationInPixels as S,getMinSegmentsPerCurve as x}from"../2d/layers/graphics/densificationConstants.js";import{createSnappingVisualizer as b}from"./support/createSnappingVisualizer.js";import{multipointFromGeometry as j,markHandled as T,getPointerType as G}from"./support/drawToolUtils.js";import{PluginContext as k}from"./support/PluginContext.js";import{viewEventToCommand as I}from"./support/input/drawToolInput.js";import{EditSessionManager as O}from"./support/managers/EditSessionManager.js";import{GlobalStateManager as A}from"./support/managers/GlobalStateManager.js";import{InteractiveHandleManager as U}from"./support/managers/InteractiveHandleManager.js";import{MeasurementManager as V}from"./support/managers/MeasurementManager.js";import{PluginLifecycleManager as E}from"./support/managers/PluginLifecycleManager.js";import{SurfaceManager as D}from"./support/managers/SurfaceManager.js";import{TooltipManager as R}from"./support/managers/TooltipManager.js";import{ViewEventPriorities as L}from"../input/InputManager.js";import{createCoordinateHelper as Z}from"../interactive/coordinateHelper.js";import{InteractiveToolBase as F}from"../interactive/InteractiveToolBase.js";import{KeyBindings as B,mediaKeys as z,sketchKeys as q,advancedSketchKeys as K,tooltipKeys as N}from"../interactive/keybindings.js";import{isInputModeAvailable as $}from"../interactive/tooltip/tooltipCommonUtils.js";const J=Symbol();let Q=class extends F{constructor(e){super(e),this._shapeVisualId=Symbol(),this._vertexVisualId=Symbol(),this._pluginContexts=new Map,this._snappingVisualizer=null,this._updatingHandles=new y,this._keybindings=this._makeKeyBindings(),this._pendingBeginRequest=null,this.type="draw-2.0",this.automaticManipulatorSelection=!0,this.snappingManager=null,this.sketchOptions=null,this.elevationInfo=null,this.hasZ=!1,this.defaultZ=0,this.lastScreenPosition=null,this.measurementManager=new V,this.globalStateManager=new A({getPluginStack:()=>this.pluginStack}),this.editSessionManager=new O({getContext:()=>this._editSessionManagerContext}),this.lifecycleManager=new E({getContext:this._getContextForPlugin.bind(this),editSessionManager:this.editSessionManager,afterAttach:this._afterAttach.bind(this),afterDetach:this._afterDetach.bind(this),beforeResume:this._beforeResume.bind(this)}),this.surfaceManager=null,this.interactiveHandleManager=null,this.renderer=null}initialize(){const{view:e}=this;this.interactiveHandleManager=new U({view:e,renderer:this.renderer}),this._override("manipulators",this.interactiveHandleManager.manipulators),this.tooltipManager=new R({getDependencies:()=>this._tooltipDependencies,getLastScreenPosition:()=>this.lastScreenPosition}),this.addHandles(s(()=>this.renderer,t=>{t.addOrUpdateVisual(this._shapeVisualId,{role:"outputGeometry"}),t.addOrUpdateVisual(this._vertexVisualId,{role:"vertex"}),this._updatingHandles.addPromise(b(e,t).then(e=>this._snappingVisualizer=e))},l)),this.addHandles([s(()=>this.view,e=>{this.surfaceManager?.destroy(),this.surfaceManager=new D({spatialReference:this.coordinateHelper.spatialReference,excludedGraphicsLayer:null,defaultZ:this.defaultZ,hasZ:this.hasZ,view:e,elevationInfo:this.elevationInfo,getContext:()=>({drawAtFixedElevation:this.globalStateManager.drawAtFixedElevation,elevationConstraint:this.tooltipManager?.elevationConstraint,constraintsEnabled:this.tooltipManager?.constraintsEnabled??!1})})},l),s(()=>this.sketchOptions?.tooltips.effectiveEnabled,()=>this.measurementManager.preloadMeasurementUtils(),{once:!0,initial:!0}),d(()=>this.editSessionManager,"cancelPlugin",({plugin:e})=>{this._suspendPlugin(e)},p),d(()=>this.editSessionManager,"restartPlugin",({restartInfo:e})=>{this._resumePlugin(e)},p),d(()=>this.editGeometryOperations,["vertex-add","vertex-update","vertex-remove"],e=>{const t=e.vertices.map(e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)})),i=t.map(e=>e.coordinates);switch(e.type){case"vertex-add":this.emit(e.type,{...e,added:i,vertices:t});break;case"vertex-update":this.emit(e.type,{...e,updated:i,vertices:t});break;case"vertex-remove":this.emit(e.type,{...e,removed:i,vertices:t})}})])}destroy(){this.active&&this.onDeactivate(),this.editSessionManager.destroy(),this.lifecycleManager.destroy(),this.measurementManager.destroy(),this.globalStateManager.destroy();for(const e of this._pluginContexts.values())e.destroy();this._pluginContexts.clear(),this.surfaceManager=o(this.surfaceManager),this.interactiveHandleManager=o(this.interactiveHandleManager),this.tooltipManager=o(this.tooltipManager)}get _tooltipDependencies(){const{defaultZ:e,editGeometryOperations:t,sketchOptions:i,directionOptions:a,view:n}=this;return t&&i&&n?{defaultZ:e,directionOptions:a,editGeometryOperations:t,sketchOptions:i,view:n,getActiveHandle:()=>this.interactiveHandleManager?.focusedHandle,getAllHandles:()=>this.interactiveHandleManager?.allhandles,getHelpMessageKey:()=>this.helpMessageKey,notifyTooltipsChanged:()=>{const{interactiveHandleManager:e,movementCommandContext:t}=this;e&&t&&e.reapplyPositions(t)}}:null}get _editSessionManagerContext(){const{coordinateHelper:e,view:t}=this;if(!t)return null;return{coordinateHelper:e,viewingMode:"3d"===t.type&&"global"===t.viewingMode?1:2}}get _densificationParameters(){const{view:e,coordinateHelper:t}=this,i=t.spatialReference,a=e?.spatialReference,n=e.resolution;if(!(i&&a&&n&&Number.isFinite(n)))return null;const r=a.metersPerUnit/i.metersPerUnit;return{maxDeviation:2**Math.round(Math.log2(n))*S()*r,minSegmentsPerCurve:x()}}get test(){return{densificationParameters:this._densificationParameters}}get updating(){return this._updatingHandles.updating||this.lifecycleManager.updating}get coordinateHelper(){return Z(this.hasZ,!1,this.view.spatialReference)}get editGeometry(){return this.editGeometryOperations?.data}get editGeometryOperations(){return this.editSessionManager.editGeometryOperations}get unprocessedGeometry(){return this.editSessionManager.outputGeometry}get simplifiedGeometryPreview(){const e=this.editSessionManager.outputGeometry;if(e&&C(e))try{const t=this._densificationParameters,i=H(e)&&t?new f({...P(e,t)}):e;if(!M(i))return _(i)}catch(t){return e}return e}get canUndo(){return this.editSessionManager.canUndo}get canRedo(){return this.editSessionManager.canRedo}get pluginStack(){return this.lifecycleManager.pluginStack}get mostDownstreamPlugin(){return this.pluginStack.at(-1)}get mostUpstreamPlugin(){return this.pluginStack.at(0)}get positionOfLastUserInput(){return this.lastScreenPosition?this.view.toMap(this.lastScreenPosition):this.view.center}get movementCommandContext(){const{editGeometryOperations:e,tooltipManager:t,surfaceManager:i,snappingManager:a,interactiveHandleManager:n,_snappingVisualizer:r,defaultZ:o,hasZ:s,globalStateManager:{drawAtFixedElevation:l},view:d}=this;return{tooltipManager:t,editGeometryOperations:e,surfaceManager:i,interactiveHandleManager:n,snappingManager:a,snappingVisualizer:r,pointerType:"mouse",hasZ:s,defaultZ:o,view:d,drawAtFixedElevation:l}}get tooltip(){return this.tooltipManager?.tooltip}get activeTooltipInfo(){return this.tooltipManager?.tooltipInfo}get helpMessageKey(){return this.pluginStack.items.findLast(e=>e.helpMessageKey)?.helpMessageKey??"noTool"}begin(e){this.active?(this.lifecycleManager.begin(e),this._pendingBeginRequest=null):this._pendingBeginRequest=e}complete(e){const t=this.lifecycleManager;e&&t.complete(e),0===t.pluginStack.length&&(this._finalizeAndSimplifyGeometryResult(),this.emit("complete",{geometry:this.finalGeometry,aborted:!1,type:"complete",vertices:[]}),this.view?.activeTool===this&&(this.view.activeTool=null))}cancelFirstUserLeafPlugin(){const e=this.pluginStack.toArray().findLast(e=>!0!==e.configuration?.hidden);e&&this.lifecycleManager.cancel(e)}replaceLeaf(e){const t=this.lifecycleManager;t.updating?n.getLogger(this).info("Ignoring command; arrived while updating:","replaceLeaf"):t.replaceLeaf(e)}finishPart(){const e=this.mostUpstreamPlugin,t=e?.configuration;if(this.editGeometryOperations&&t&&t.kind?.includes("multipart")){const e=this.pluginStack.at(1);e&&this.complete(e)}}undo(){this._guardCommand({action:"undo"},()=>this.editSessionManager.undo())}redo(){this._guardCommand({action:"redo"},()=>this.editSessionManager.redo())}executeCommand(e){return this._handleCommand(e)}addPromise(e){return this._updatingHandles.addPromise(e)}getGeometryIfCompleted(){const e=this.lifecycleManager.gatherCompletablePlugins();return this.editSessionManager?.generatePreviewGeometryForPlugins(e)}onActivate(){super.onActivate();const{view:e}=this;this.lastScreenPosition=e?.inputManager.latestPointerInfo?.location,this.renderer?.activate(),this._pendingBeginRequest&&(this.begin(this._pendingBeginRequest),this._pendingBeginRequest=null),this.addHandles([c(()=>this.unprocessedGeometry,e=>{this.renderer?.addOrUpdateVisual(this._vertexVisualId,{geometry:e?j(e):null})},l),c(()=>this.simplifiedGeometryPreview,e=>{this.renderer?.addOrUpdateVisual(this._shapeVisualId,{geometry:e})},l),s(()=>this.interactiveHandleManager?.capturingHandle?.screenPosition,e=>this.lastScreenPosition=e,{initial:!0,equals:g}),c(()=>this.interactiveHandleManager?.capturingHandle?.outputMapPosition,(e,t)=>{const i=this.interactiveHandleManager?.capturingHandle?.editSession?.endVertex;e&&t&&i&&this.emit("cursor-update",{updated:i.pos,type:"vertex-update",operation:"apply",vertices:[{componentIndex:i.part.index,vertexIndex:i.index,coordinates:i.pos}]})},p),this._keybindings.register(e,L.TOOL),c(()=>e.viewpoint,(e,t)=>{e&&t&&h(e,t)&&this._handleCommand({action:"viewpoint-moved"})})],J)}onDeactivate(){super.onDeactivate(),this.removeHandles(J),this.renderer?.deactivate(),this.snappingManager?.doneSnapping(),this.lifecycleManager.cancelAll(),this._pendingBeginRequest=null}onInputEvent(e){const t=I(e);t&&this._handleCommand(t)}async _handleCommand(e){if(this.lifecycleManager.updating)n.getLogger(this).info("Ignoring command; arrived while updating:",e.action);else switch(e.action){case"view-drag":return await this._handleViewDragCommand(e);case"vertex-add":return this._guardCommand(e,()=>{T(e),this._commitNext()});case"vertex-add-and-finish-part":return this._handleVertexAddAndFinishPartCommand(e);case"cancel":return this._guardCommand(e,()=>this.cancel());case"complete":return this._guardCommand(e,()=>{this.mostUpstreamPlugin&&(T(e),this.complete(this.mostUpstreamPlugin))});case"finish-part":return this._guardCommand(e,()=>this.finishPart());case"undo":return this._guardCommand(e,()=>this.editSessionManager.undo());case"redo":return this._guardCommand(e,()=>this.editSessionManager.redo());case"next-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("forward"));case"previous-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("backward"));case"toggle-manipulator-follow":this.interactiveHandleManager?.toggleFollow()&&T(e);break;case"viewpoint-moved":return await this._handleViewpointMovedCommand(e);case"manipulator-move-to":return await this._handleManipulatorMoveToCommand(e);case"manipulator-drag-to":return await this._handleManipulatorDragToCommand(e);case"vertex-add-at-point":return await this._handleVertexAddAtPointCommand(e);case"show-tooltip":return this._guardCommand(e,async()=>{const t=this.tooltipManager?.tooltip;t&&$(t.info)&&(await t.enterInputMode(),T(e))});case"constraint-center":this.globalStateManager.setCentered(e.enabled);break;case"constraint-aspect":this.globalStateManager.setPreserveAspectRatio(e.enabled)}}async _handleViewDragCommand(e){if(!this.editable)return;const t=e.originalEvent,i=this.interactiveHandleManager?.capturingHandle;(!t||!("pointerType"in t)||"touch"!==t.pointerType||"capture-always"!==i?.captureMode&&"capture-when-engaged"!==i?.captureMode)&&"capture-when-engaged"!==this.interactiveHandleManager?.capturingHandle?.captureMode?this._before(e)&&T(e):T(e)}_handleVertexAddAndFinishPartCommand(e){this._before(e)||(T(e),this._commitNext(),this.finishPart())}async _handleViewpointMovedCommand(e){this.editable&&(await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(null,{...this.movementCommandContext,pointerType:G(e.originalEvent)})),this.interactiveHandleManager?.updateAllScreenPositions())}async _handleManipulatorMoveToCommand(e){if(!this.editable)return;const t=this._updateLastScreenPosition(e);this.interactiveHandleManager?.capturingHandle&&T(e),await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(t,{...this.movementCommandContext,pointerType:G(e.originalEvent)}))}async _handleManipulatorDragToCommand(e){if(!this.editable)return;const t=G(e.originalEvent),i=this._updateLastScreenPosition(e),a=this.interactiveHandleManager?.findHandleByManipulator(i);"touch"===t&&a&&"start"===e.state&&this.interactiveHandleManager?.releaseHandle();const n=this.interactiveHandleManager?.findHandleDragging(),r=this.interactiveHandleManager?.capturingHandle,o=n??r??a;o&&!a&&T(e),"capture-when-engaged"===o?.captureMode||"capture-always"===o?.captureMode&&"touch"===t?"end"===e.state?await this._updatingHandles.addPromise(o.noteDragEnd(i,{...this.movementCommandContext,pointerType:t}).then(()=>{o&&"touch"===G(e.originalEvent)&&"grabbable-object"!==o.captureMode&&"capture-when-engaged"!==o.defaultCaptureMode&&"primary"===o.role&&(1===this.interactiveHandleManager?.handleCount?this._handleCommand({action:"vertex-add"}):this.interactiveHandleManager?.releaseHandle())})):"start"===e.state?await this._updatingHandles.addPromise(o.noteDragStart(i,{...this.movementCommandContext,pointerType:t}).then(()=>{o&&"touch"===G(e.originalEvent)&&"grabbable-object"!==o.captureMode&&"capture-when-engaged"!==o.defaultCaptureMode&&!o.editSession?.lastPointAddedBySession&&this._handleCommand({action:"vertex-add"})})):await this._updatingHandles.addPromise(o?.moveTo(i,{...this.movementCommandContext,pointerType:G(e.originalEvent)})):"grabbable-object"===o?.captureMode&&(this.interactiveHandleManager?.releaseHandle(r),await this._updatingHandles.addPromise(o.moveTo(i,{...this.movementCommandContext,pointerType:t})))}async _handleVertexAddAtPointCommand(e){const t=this._updateLastScreenPosition(e),i=this.interactiveHandleManager?.capturingHandle??this.interactiveHandleManager?.findHandleByManipulator(t);this.editable&&i&&(this._before(e)||(T(e),await this._updatingHandles.addPromise(i.moveTo(t,{...this.movementCommandContext,skipSnapping:!0,pointerType:G(e.originalEvent)}).finally(()=>this._commitNext()))))}_makeKeyBindings(){const e=new B,t=(t,i)=>{e.addToggle(t,e=>this._handleCommand({action:i,originalEvent:e,enabled:"key-down"===e.type}))},i=(t,i)=>{e.add(t,e=>this._handleCommand({action:i,originalEvent:e}))};return t(z.preserveAspectRatio,"constraint-aspect"),t(q.center,"constraint-center"),i(K.toggleFollowManipulator,"toggle-manipulator-follow"),i(q.undo,"undo"),i(q.redo,"redo"),i(q.complete,"complete"),i(q.vertexAdd,"vertex-add"),i({key:N.enterInputMode,continuePropagation:!0,repeats:!0},"show-tooltip"),e}_afterAttach(){}_afterDetach(e){this.interactiveHandleManager?.unregisterCustomConstraint(e),this.interactiveHandleManager?.unregisterHandle(e),this.tooltipManager?.unregisterPluginFields(e),this.globalStateManager.clearPluginOverrides(e);const t=this._pluginContexts.get(e);t&&(t.destroy(),this._pluginContexts.delete(e))}_beforeResume(e,t){this.interactiveHandleManager?.replaceEditSessions(e,t)}_commitNext(){const i={stack:[],error:void 0,hasError:!1};try{const t=this.mostDownstreamPlugin;if(!t)return;this.tooltipManager?.storeConstraintSnapshot();let n=!1;const r=this.editGeometryOperations;e(i,r?a(r.on("vertex-add",()=>n=!0)):null,!1);t.completeStep?t.completeStep():this.complete(t),n&&this.tooltipManager?.unlockOnVertexPlacement()}catch(n){i.error=n,i.hasError=!0}finally{t(i)}}_suspendPlugin(e){this.lifecycleManager.suspend(e),this.measurementManager.suspendPlugin(e)}_resumePlugin(e){this.lifecycleManager.resume(e)}_updateLastScreenPosition(e){const t=u(e.x,e.y);return this.lastScreenPosition=t,t}_getContextForPlugin(e,t){const i=r(this._pluginContexts,e,()=>new k({drawTool:this,plugin:e,session:t}));return i.session=t,i}_finalizeAndSimplifyGeometryResult(){const e=this.unprocessedGeometry;try{const t=e?_(e):e;t&&!w(t)?this.finalGeometry=t:this.finalGeometry=e}catch(t){n.getLogger(this).error("draw-tool:complete","geometry simplification failed",t)}}_before(e){if(!this.hasEventListener(`before-${e.action}`))return!1;const t=new CustomEvent(`before-${e.action}`,{detail:e,cancelable:!0});return this.emit(`before-${e.action}`,t),t.defaultPrevented}_guardCommand(e,t,i){return this._before(e)?i?.():t()}};i([m()],Q.prototype,"_snappingVisualizer",void 0),i([m()],Q.prototype,"_tooltipDependencies",null),i([m()],Q.prototype,"_editSessionManagerContext",null),i([m()],Q.prototype,"_densificationParameters",null),i([m({constructOnly:!0,nonNullable:!0})],Q.prototype,"view",void 0),i([m()],Q.prototype,"automaticManipulatorSelection",void 0),i([m()],Q.prototype,"updating",null),i([m()],Q.prototype,"coordinateHelper",null),i([m()],Q.prototype,"editGeometry",null),i([m()],Q.prototype,"editGeometryOperations",null),i([m()],Q.prototype,"unprocessedGeometry",null),i([m()],Q.prototype,"finalGeometry",void 0),i([m()],Q.prototype,"simplifiedGeometryPreview",null),i([m()],Q.prototype,"snappingManager",void 0),i([m()],Q.prototype,"sketchOptions",void 0),i([m()],Q.prototype,"elevationInfo",void 0),i([m()],Q.prototype,"hasZ",void 0),i([m()],Q.prototype,"defaultZ",void 0),i([m()],Q.prototype,"directionOptions",void 0),i([m()],Q.prototype,"canUndo",null),i([m()],Q.prototype,"canRedo",null),i([m()],Q.prototype,"pluginStack",null),i([m()],Q.prototype,"mostDownstreamPlugin",null),i([m()],Q.prototype,"mostUpstreamPlugin",null),i([m()],Q.prototype,"lastScreenPosition",void 0),i([m()],Q.prototype,"positionOfLastUserInput",null),i([m()],Q.prototype,"tooltipManager",void 0),i([m()],Q.prototype,"measurementManager",void 0),i([m()],Q.prototype,"globalStateManager",void 0),i([m()],Q.prototype,"editSessionManager",void 0),i([m()],Q.prototype,"lifecycleManager",void 0),i([m()],Q.prototype,"surfaceManager",void 0),i([m()],Q.prototype,"interactiveHandleManager",void 0),i([m()],Q.prototype,"renderer",void 0),i([m()],Q.prototype,"movementCommandContext",null),i([m()],Q.prototype,"tooltip",null),i([m()],Q.prototype,"activeTooltipInfo",null),i([m()],Q.prototype,"helpMessageKey",null),Q=i([v("esri.views.draw.DrawTool")],Q);export{Q as DrawTool};
|
|
2
|
+
import{__addDisposableResource as e,__disposeResources as t,__decorate as i}from"tslib";import{disposable as a}from"../../core/handleUtils.js";import n from"../../core/Logger.js";import{getOrCreateMapValue as r}from"../../core/MapUtils.js";import{destroyMaybe as o}from"../../core/maybe.js";import{when as s,initial as d,on as l,sync as p,watch as c}from"../../core/reactiveUtils.js";import{screenPointEqual as u,createScreenPoint as h}from"../../core/screenUtils.js";import{diff as g}from"../../core/accessorSupport/diffUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as y}from"../../core/support/UpdatingHandles.js";import f from"../../geometry/Polygon.js";import{i as M,e as _}from"../../chunks/simplifyOperator.js";import{isExtent as w}from"../../geometry/support/jsonTypeUtils.js";import{isPolygon as b}from"../../geometry/support/typeUtils.js";import{isCurvedGeometry as C}from"../../geometry/support/curves/curveUtils.js";import{densifyCurvedGeometry as H}from"../../geometry/support/curves/densifyCurvedGeometry.js";import{getMaxDeviationInPixels as P,getMinSegmentsPerCurve as S}from"../2d/layers/graphics/densificationConstants.js";import{createSnappingVisualizer as x}from"./support/createSnappingVisualizer.js";import{multipointFromGeometry as k,markHandled as j,getPointerType as E}from"./support/drawToolUtils.js";import{PluginContext as T}from"./support/PluginContext.js";import{viewEventToCommand as G}from"./support/input/drawToolInput.js";import{EditSessionManager as O}from"./support/managers/EditSessionManager.js";import{GlobalStateManager as V}from"./support/managers/GlobalStateManager.js";import{InteractiveHandleManager as I}from"./support/managers/InteractiveHandleManager.js";import{MeasurementManager as A}from"./support/managers/MeasurementManager.js";import{PluginLifecycleManager as U}from"./support/managers/PluginLifecycleManager.js";import{SurfaceManager as R}from"./support/managers/SurfaceManager.js";import{TooltipManager as F}from"./support/managers/TooltipManager.js";import{ViewEventPriorities as D}from"../input/InputManager.js";import{createCoordinateHelper as L}from"../interactive/coordinateHelper.js";import{InteractiveToolBase as Z}from"../interactive/InteractiveToolBase.js";import{KeyBindings as q,mediaKeys as B,sketchKeys as z,advancedSketchKeys as K,tooltipKeys as Q}from"../interactive/keybindings.js";import{isInputModeAvailable as N}from"../interactive/tooltip/tooltipCommonUtils.js";const W=Symbol();let $=class extends Z{constructor(e){super(e),this._shapeVisualId=Symbol(),this._vertexVisualId=Symbol(),this._pluginContexts=new Map,this._queuedFeedbackEvents=[],this._flushingQueuedFeedbackEvents=!1,this._snappingVisualizer=null,this._updatingHandles=new y,this._keybindings=this._makeKeyBindings(),this._pendingBeginRequest=null,this.type="draw-2.0",this.automaticManipulatorSelection=!0,this.snappingManager=null,this.sketchOptions=null,this.elevationInfo=null,this.hasZ=!1,this.defaultZ=0,this.lastScreenPosition=null,this.measurementManager=new A,this.globalStateManager=new V({getPluginStack:()=>this.pluginStack}),this.editSessionManager=new O({getContext:()=>this._editSessionManagerContext}),this.lifecycleManager=new U({getContext:this._getContextForPlugin.bind(this),editSessionManager:this.editSessionManager,afterAttach:this._afterAttach.bind(this),afterDetach:this._afterDetach.bind(this),beforeResume:this._beforeResume.bind(this)}),this.surfaceManager=null,this.interactiveHandleManager=null,this.renderer=null,this.enableVertexVisuals=!0}initialize(){const{view:e}=this;this.interactiveHandleManager=new I({view:e,renderer:this.renderer}),this._override("manipulators",this.interactiveHandleManager.manipulators),this.tooltipManager=new F({getDependencies:()=>this._tooltipDependencies,getLastScreenPosition:()=>this.lastScreenPosition}),this.addHandles(s(()=>this.renderer,t=>{t.addOrUpdateVisual(this._shapeVisualId,{role:"outputGeometry"}),t.addOrUpdateVisual(this._vertexVisualId,{role:"vertex"}),this._updatingHandles.addPromise(x(e,t).then(e=>this._snappingVisualizer=e))},d)),this.addHandles([s(()=>this.view,e=>{this.surfaceManager?.destroy(),this.surfaceManager=new R({spatialReference:this.coordinateHelper.spatialReference,excludedGraphicsLayer:null,defaultZ:this.defaultZ,hasZ:this.hasZ,view:e,elevationInfo:this.elevationInfo,getContext:()=>({drawAtFixedElevation:this.globalStateManager.drawAtFixedElevation,elevationConstraint:this.tooltipManager?.elevationConstraint,constraintsEnabled:this.tooltipManager?.constraintsEnabled??!1})})},d),s(()=>this.sketchOptions?.tooltips.effectiveEnabled,()=>this.measurementManager.preloadMeasurementUtils(),{once:!0,initial:!0}),l(()=>this.editSessionManager,"cancelPlugin",({plugin:e})=>{this._suspendPlugin(e)},p),l(()=>this.editSessionManager,"restartPlugin",({restartInfo:e})=>{this._resumePlugin(e)},p),c(()=>this.lifecycleManager.updating,e=>{e||this._emitQueuedFeedbackEvents()},p),l(()=>this.editGeometryOperations,["vertex-add","vertex-update","vertex-remove"],e=>{const t=e.vertices.map(e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)})),i=t.map(e=>e.coordinates);switch(e.type){case"vertex-add":this._emitWhenReady(e.type,{...e,added:i,vertices:t});break;case"vertex-update":this._emitWhenReady(e.type,{...e,updated:i,vertices:t});break;case"vertex-remove":this._emitWhenReady(e.type,{...e,removed:i,vertices:t})}})])}destroy(){this.active&&this.onDeactivate(),this.editSessionManager.destroy(),this.lifecycleManager.destroy(),this.measurementManager.destroy(),this.globalStateManager.destroy();for(const e of this._pluginContexts.values())e.destroy();this._pluginContexts.clear(),this.surfaceManager=o(this.surfaceManager),this.interactiveHandleManager=o(this.interactiveHandleManager),this.tooltipManager=o(this.tooltipManager)}get _tooltipDependencies(){const{defaultZ:e,editGeometryOperations:t,sketchOptions:i,directionOptions:a,view:n}=this;return t&&i&&n?{defaultZ:e,directionOptions:a,editGeometryOperations:t,sketchOptions:i,view:n,getActiveHandle:()=>this.interactiveHandleManager?.focusedHandle,getAllHandles:()=>this.interactiveHandleManager?.allhandles,getHelpMessageKey:()=>this.helpMessageKey,notifyTooltipsChanged:()=>{const{interactiveHandleManager:e,movementCommandContext:t}=this;e&&t&&e.reapplyPositions(t)}}:null}get _editSessionManagerContext(){const{coordinateHelper:e,view:t}=this;if(!t)return null;return{coordinateHelper:e,viewingMode:"3d"===t.type&&"global"===t.viewingMode?1:2}}get _densificationParameters(){const{view:e,coordinateHelper:t}=this,i=t.spatialReference,a=e?.spatialReference,n=e.resolution;if(!(i&&a&&n&&Number.isFinite(n)))return null;const r=a.metersPerUnit/i.metersPerUnit;return{maxDeviation:2**Math.round(Math.log2(n))*P()*r,minSegmentsPerCurve:S()}}get test(){return{densificationParameters:this._densificationParameters}}get updating(){return this._updatingHandles.updating||this.lifecycleManager.updating}get coordinateHelper(){return L(this.hasZ,!1,this.view.spatialReference)}get editGeometry(){return this.editGeometryOperations?.data}get editGeometryOperations(){return this.editSessionManager.editGeometryOperations}get unprocessedGeometry(){return this.editSessionManager.outputGeometry}get simplifiedGeometryPreview(){const e=this.editSessionManager.outputGeometry;if(e&&b(e))try{const t=this._densificationParameters,i=C(e)&&t?new f({...H(e,t)}):e;if(!M(i))return _(i)}catch(t){return e}return e}get canUndo(){return this.editSessionManager.canUndo}get canRedo(){return this.editSessionManager.canRedo}get pluginStack(){return this.lifecycleManager.pluginStack}get mostDownstreamPlugin(){return this.pluginStack.at(-1)}get mostUpstreamPlugin(){return this.pluginStack.at(0)}get positionOfLastUserInput(){return this.lastScreenPosition?this.view.toMap(this.lastScreenPosition):this.view.center}get movementCommandContext(){const{editGeometryOperations:e,tooltipManager:t,surfaceManager:i,snappingManager:a,interactiveHandleManager:n,_snappingVisualizer:r,defaultZ:o,hasZ:s,globalStateManager:{drawAtFixedElevation:d},view:l}=this;return{tooltipManager:t,editGeometryOperations:e,surfaceManager:i,interactiveHandleManager:n,snappingManager:a,snappingVisualizer:r,pointerType:"mouse",hasZ:s,defaultZ:o,view:l,drawAtFixedElevation:d}}get tooltip(){return this.tooltipManager?.tooltip}get activeTooltipInfo(){return this.tooltipManager?.tooltipInfo}get helpMessageKey(){return this.pluginStack.items.findLast(e=>e.helpMessageKey)?.helpMessageKey??"noTool"}begin(e){this.active?(this.lifecycleManager.begin(e),this._pendingBeginRequest=null):this._pendingBeginRequest=e}complete(e){const t=this.lifecycleManager;e&&t.complete(e),0===t.pluginStack.length&&(this._finalizeAndSimplifyGeometryResult(),this.emit("complete",{geometry:this.finalGeometry,aborted:!1,type:"complete",vertices:[]}),this.view?.activeTool===this&&(this.view.activeTool=null))}cancelFirstUserLeafPlugin(){const e=this.pluginStack.toArray().findLast(e=>!0!==e.configuration?.hidden);e&&this.lifecycleManager.cancel(e)}replaceLeaf(e){const t=this.lifecycleManager;t.updating?n.getLogger(this).info("Ignoring command; arrived while updating:","replaceLeaf"):t.replaceLeaf(e)}finishPart(){const e=this.mostUpstreamPlugin,t=e?.configuration;if(this.editGeometryOperations&&t&&t.kind?.includes("multipart")){const e=this.pluginStack.at(1);e&&this.complete(e)}}undo(){this._guardCommand({action:"undo"},()=>this.editSessionManager.undo())}redo(){this._guardCommand({action:"redo"},()=>this.editSessionManager.redo())}executeCommand(e){return this._handleCommand(e)}addPromise(e){return this._updatingHandles.addPromise(e)}getGeometryIfCompleted(){const e=this.lifecycleManager.gatherCompletablePlugins();return this.editSessionManager?.generatePreviewGeometryForPlugins(e)}onActivate(){super.onActivate();const{view:e}=this;this.lastScreenPosition=e?.inputManager.latestPointerInfo?.location,this.renderer?.activate(),this._pendingBeginRequest&&(this.begin(this._pendingBeginRequest),this._pendingBeginRequest=null),this.enableVertexVisuals&&this.addHandles(c(()=>this.unprocessedGeometry,e=>{this.renderer?.addOrUpdateVisual(this._vertexVisualId,{geometry:e?k(e):null})},d)),this.addHandles([c(()=>this.simplifiedGeometryPreview,e=>{this.renderer?.addOrUpdateVisual(this._shapeVisualId,{geometry:e})},d),s(()=>this.interactiveHandleManager?.capturingHandle?.screenPosition,e=>this.lastScreenPosition=e,{initial:!0,equals:u}),c(()=>this.interactiveHandleManager?.capturingHandle?.outputMapPosition,(e,t)=>{const i=this.interactiveHandleManager?.capturingHandle?.editSession?.endVertex;e&&t&&i&&this._emitWhenReady("cursor-update",{updated:i.pos,type:"vertex-update",operation:"apply",vertices:[{componentIndex:i.part.index,vertexIndex:i.index,coordinates:i.pos}]})},p),this._keybindings.register(e,D.TOOL),c(()=>e.viewpoint,(e,t)=>{e&&t&&g(e,t)&&this._handleCommand({action:"viewpoint-moved"})})],W)}onDeactivate(){super.onDeactivate(),this.removeHandles(W),this.renderer?.deactivate(),this.snappingManager?.doneSnapping(),this.lifecycleManager.cancelAll(),this._pendingBeginRequest=null}onInputEvent(e){const t=G(e);t&&this._handleCommand(t)}_emitWhenReady(e,t){if(this.destroyed)return;const i=()=>{this.emit(e,t)};this.lifecycleManager.updating||this._flushingQueuedFeedbackEvents?this._queuedFeedbackEvents.push(i):i()}_emitQueuedFeedbackEvents(){if(!(this.destroyed||this._flushingQueuedFeedbackEvents||this.lifecycleManager.updating||0===this._queuedFeedbackEvents.length)){this._flushingQueuedFeedbackEvents=!0;try{for(;!this.destroyed&&!this.lifecycleManager.updating&&this._queuedFeedbackEvents.length>0;)this._queuedFeedbackEvents.shift()?.()}finally{this._flushingQueuedFeedbackEvents=!1}}}async _handleCommand(e){if(this.lifecycleManager.updating)n.getLogger(this).info("Ignoring command; arrived while updating:",e.action);else switch(e.action){case"view-drag":return await this._handleViewDragCommand(e);case"vertex-add":return this._guardCommand(e,()=>{j(e),this._commitNext()});case"vertex-add-and-finish-part":return this._handleVertexAddAndFinishPartCommand(e);case"cancel":return this._guardCommand(e,()=>this.cancel());case"complete":return this._guardCommand(e,()=>{this.mostUpstreamPlugin&&(j(e),this.complete(this.mostUpstreamPlugin))});case"finish-part":return this._guardCommand(e,()=>this.finishPart());case"undo":return this._guardCommand(e,()=>this.editSessionManager.undo());case"redo":return this._guardCommand(e,()=>this.editSessionManager.redo());case"next-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("forward"));case"previous-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("backward"));case"toggle-manipulator-follow":this.interactiveHandleManager?.toggleFollow()&&j(e);break;case"viewpoint-moved":return await this._handleViewpointMovedCommand(e);case"manipulator-move-to":return await this._handleManipulatorMoveToCommand(e);case"manipulator-drag-to":return await this._handleManipulatorDragToCommand(e);case"vertex-add-at-point":return await this._handleVertexAddAtPointCommand(e);case"show-tooltip":return this._guardCommand(e,async()=>{const t=this.tooltipManager?.tooltip;t&&N(t.info)&&(await t.enterInputMode(),j(e))});case"constraint-center":this.globalStateManager.setCentered(e.enabled);break;case"constraint-aspect":this.globalStateManager.setPreserveAspectRatio(e.enabled)}}async _handleViewDragCommand(e){if(!this.editable)return;const t=e.originalEvent,i=this.interactiveHandleManager?.capturingHandle;(!t||!("pointerType"in t)||"touch"!==t.pointerType||"capture-always"!==i?.captureMode&&"capture-when-engaged"!==i?.captureMode)&&"capture-when-engaged"!==this.interactiveHandleManager?.capturingHandle?.captureMode?this._before(e)&&j(e):j(e)}_handleVertexAddAndFinishPartCommand(e){this._before(e)||(j(e),this._commitNext(),this.finishPart())}async _handleViewpointMovedCommand(e){this.editable&&(await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(null,{...this.movementCommandContext,pointerType:E(e.originalEvent)})),this.interactiveHandleManager?.updateAllScreenPositions())}async _handleManipulatorMoveToCommand(e){if(!this.editable)return;const t=this._updateLastScreenPosition(e);this.interactiveHandleManager?.capturingHandle&&j(e),await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(t,{...this.movementCommandContext,pointerType:E(e.originalEvent)}))}async _handleManipulatorDragToCommand(e){if(!this.editable)return;const t=E(e.originalEvent),i=this._updateLastScreenPosition(e),a=this.interactiveHandleManager?.findHandleByManipulator(i);"touch"===t&&a&&"start"===e.state&&this.interactiveHandleManager?.releaseHandle();const n=this.interactiveHandleManager?.findHandleDragging(),r=this.interactiveHandleManager?.capturingHandle,o=n??r??a;o&&!a&&j(e),"capture-when-engaged"===o?.captureMode||"capture-always"===o?.captureMode&&"touch"===t?"end"===e.state?await this._updatingHandles.addPromise(o.noteDragEnd(i,{...this.movementCommandContext,pointerType:t}).then(()=>{o&&"touch"===E(e.originalEvent)&&"grabbable-object"!==o.captureMode&&"capture-when-engaged"!==o.defaultCaptureMode&&"primary"===o.role&&(1===this.interactiveHandleManager?.handleCount?this._handleCommand({action:"vertex-add"}):this.interactiveHandleManager?.releaseHandle())})):"start"===e.state?await this._updatingHandles.addPromise(o.noteDragStart(i,{...this.movementCommandContext,pointerType:t}).then(()=>{o&&"touch"===E(e.originalEvent)&&"grabbable-object"!==o.captureMode&&"capture-when-engaged"!==o.defaultCaptureMode&&!o.editSession?.lastPointAddedBySession&&this._handleCommand({action:"vertex-add"})})):await this._updatingHandles.addPromise(o?.moveTo(i,{...this.movementCommandContext,pointerType:E(e.originalEvent)})):"grabbable-object"===o?.captureMode&&(this.interactiveHandleManager?.releaseHandle(r),await this._updatingHandles.addPromise(o.moveTo(i,{...this.movementCommandContext,pointerType:t})))}async _handleVertexAddAtPointCommand(e){const t=this._updateLastScreenPosition(e),i=this.interactiveHandleManager?.capturingHandle??this.interactiveHandleManager?.findHandleByManipulator(t);this.editable&&i&&(this._before(e)||(j(e),await this._updatingHandles.addPromise(i.moveTo(t,{...this.movementCommandContext,skipSnapping:!0,pointerType:E(e.originalEvent)}).finally(()=>this._commitNext()))))}_makeKeyBindings(){const e=new q,t=(t,i)=>{e.addToggle(t,e=>this._handleCommand({action:i,originalEvent:e,enabled:"key-down"===e.type}))},i=(t,i)=>{e.add(t,e=>this._handleCommand({action:i,originalEvent:e}))};return t(B.preserveAspectRatio,"constraint-aspect"),t(z.center,"constraint-center"),i(K.toggleFollowManipulator,"toggle-manipulator-follow"),i(z.undo,"undo"),i(z.redo,"redo"),i(z.complete,"complete"),i(z.vertexAdd,"vertex-add"),i({key:Q.enterInputMode,continuePropagation:!0,repeats:!0},"show-tooltip"),e}_afterAttach(){}_afterDetach(e){this.interactiveHandleManager?.unregisterCustomConstraint(e),this.interactiveHandleManager?.unregisterHandle(e),this.tooltipManager?.unregisterPluginFields(e),this.globalStateManager.clearPluginOverrides(e);const t=this._pluginContexts.get(e);t&&(t.destroy(),this._pluginContexts.delete(e))}_beforeResume(e,t){this.interactiveHandleManager?.replaceEditSessions(e,t)}_commitNext(){const i={stack:[],error:void 0,hasError:!1};try{const t=this.mostDownstreamPlugin;if(!t)return;this.tooltipManager?.storeConstraintSnapshot();let n=!1;const r=this.editGeometryOperations;e(i,r?a(r.on("vertex-add",()=>n=!0)):null,!1);t.completeStep?t.completeStep():this.complete(t),n&&this.tooltipManager?.unlockOnVertexPlacement()}catch(n){i.error=n,i.hasError=!0}finally{t(i)}}_suspendPlugin(e){this.lifecycleManager.suspend(e),this.measurementManager.suspendPlugin(e)}_resumePlugin(e){this.lifecycleManager.resume(e)}_updateLastScreenPosition(e){const t=h(e.x,e.y);return this.lastScreenPosition=t,t}_getContextForPlugin(e,t){const i=r(this._pluginContexts,e,()=>new T({drawTool:this,plugin:e,session:t}));return i.session=t,i}_finalizeAndSimplifyGeometryResult(){const e=this.unprocessedGeometry;try{const t=e?_(e):e;t&&!w(t)?this.finalGeometry=t:this.finalGeometry=e}catch(t){n.getLogger(this).error("draw-tool:complete","geometry simplification failed",t)}}_before(e){if(!this.hasEventListener(`before-${e.action}`))return!1;const t=new CustomEvent(`before-${e.action}`,{detail:e,cancelable:!0});return this.emit(`before-${e.action}`,t),t.defaultPrevented}_guardCommand(e,t,i){return this._before(e)?i?.():t()}};i([m()],$.prototype,"_snappingVisualizer",void 0),i([m()],$.prototype,"_tooltipDependencies",null),i([m()],$.prototype,"_editSessionManagerContext",null),i([m()],$.prototype,"_densificationParameters",null),i([m({constructOnly:!0,nonNullable:!0})],$.prototype,"view",void 0),i([m()],$.prototype,"automaticManipulatorSelection",void 0),i([m()],$.prototype,"updating",null),i([m()],$.prototype,"coordinateHelper",null),i([m()],$.prototype,"editGeometry",null),i([m()],$.prototype,"editGeometryOperations",null),i([m()],$.prototype,"unprocessedGeometry",null),i([m()],$.prototype,"finalGeometry",void 0),i([m()],$.prototype,"simplifiedGeometryPreview",null),i([m()],$.prototype,"snappingManager",void 0),i([m()],$.prototype,"sketchOptions",void 0),i([m()],$.prototype,"elevationInfo",void 0),i([m()],$.prototype,"hasZ",void 0),i([m()],$.prototype,"defaultZ",void 0),i([m()],$.prototype,"directionOptions",void 0),i([m()],$.prototype,"canUndo",null),i([m()],$.prototype,"canRedo",null),i([m()],$.prototype,"pluginStack",null),i([m()],$.prototype,"mostDownstreamPlugin",null),i([m()],$.prototype,"mostUpstreamPlugin",null),i([m()],$.prototype,"lastScreenPosition",void 0),i([m()],$.prototype,"positionOfLastUserInput",null),i([m()],$.prototype,"tooltipManager",void 0),i([m()],$.prototype,"measurementManager",void 0),i([m()],$.prototype,"globalStateManager",void 0),i([m()],$.prototype,"editSessionManager",void 0),i([m()],$.prototype,"lifecycleManager",void 0),i([m()],$.prototype,"surfaceManager",void 0),i([m()],$.prototype,"interactiveHandleManager",void 0),i([m()],$.prototype,"renderer",void 0),i([m()],$.prototype,"movementCommandContext",null),i([m()],$.prototype,"tooltip",null),i([m()],$.prototype,"activeTooltipInfo",null),i([m()],$.prototype,"helpMessageKey",null),i([m({constructOnly:!0})],$.prototype,"enableVertexVisuals",void 0),$=i([v("esri.views.draw.DrawTool")],$);export{$ as DrawTool};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import has from"../../core/has.js";import t from"../../core/Logger.js";import{disposeMaybe as e}from"../../core/maybe.js";import{after as s}from"../../core/promiseUtils.js";import{Milliseconds as i}from"../../core/time.js";import{webglDebugEnabled as a,checkWebGLError as r,getErrorMessage as n,webglValidateShadersEnabled as l}from"./checkWebGLError.js";import{ContextState as h}from"./ContextState.js";import{baseTextureUnit as f,DrawBufferBack as o,DrawBufferNone as u,ResourceType as c,ColorAttachment0 as d,PrimitiveType as _}from"./enums.js";import{InstanceCounter as b}from"./InstanceCounter.js";import{Parameters as g}from"./Parameters.js";import{ProgramCache as p}from"./ProgramCache.js";import{StateTracker as m}from"./renderState.js";import B from"./Texture.js";import{WebGLDriverTest as F}from"./WebGLDriverTest.js";import{Capabilities as T}from"./capabilities/Capabilities.js";const x=()=>t.getLogger("esri.views.webgl.RenderingContext");let k=class{constructor(t,e){this.gl=t,this.instanceCounter=new b,this._programCache=new p(this),this._transformFeedbackRequestInfo=null,this._state=new h,this._numOfDrawCalls=0,this._numOfTriangles=0,this._options=e,this.configure(e)}configure(t){this._options=t,this._capabilities=new T(this.gl,t),this._parameters=new g(this.gl,this._capabilities,t),B.TEXTURE_UNIT_FOR_UPDATES=this._parameters.maxTextureImageUnits-1;const s=this.gl.getParameter(this.gl.VIEWPORT);this._state=new h,this._state.viewport={x:s[0],y:s[1],width:s[2],height:s[3]},this._stateTracker=new m({setBlending:t=>{if(t){this.setBlendingEnabled(!0),this.setBlendEquationSeparate(t.opRgb,t.opAlpha),this.setBlendFunctionSeparate(t.srcRgb,t.dstRgb,t.srcAlpha,t.dstAlpha);const e=t.color;this.setBlendColor(e.r,e.g,e.b,e.a)}else this.setBlendingEnabled(!1)},setCulling:t=>{t?(this.setFaceCullingEnabled(!0),this.setCullFace(t.face),this.setFrontFace(t.mode)):this.setFaceCullingEnabled(!1)},setPolygonOffset:t=>{t?(this.setPolygonOffsetFillEnabled(!0),this.setPolygonOffset(t.factor,t.units)):this.setPolygonOffsetFillEnabled(!1)},setDepthTest:t=>{t?(this.setDepthTestEnabled(!0),this.setDepthFunction(t.func)):this.setDepthTestEnabled(!1)},setStencilTest:t=>{if(t){this.setStencilTestEnabled(!0);const e=t.function;this.setStencilFunction(e.func,e.ref,e.mask);const s=t.operation;this.setStencilOp(s.fail,s.zFail,s.zPass)}else this.setStencilTestEnabled(!1)},setDepthWrite:t=>{t?(this.setDepthWriteEnabled(!0),this.setDepthRange(t.zNear,t.zFar)):this.setDepthWriteEnabled(!1)},setColorWrite:t=>{t?this.setColorMask(t.r,t.g,t.b,t.a):this.setColorMask(!1,!1,!1,!1)},setStencilWrite:t=>{t?this.setStencilWriteMask(t.mask):this.setStencilWriteMask(0)}}),this.enforceState(),e(this._driverTest),this._driverTest=new F(this)}updateOptions(t){this._options={...this._options,...t},this._parameters=new g(this.gl,this._capabilities,this._options)}dispose(){this._driverTest=e(this._driverTest),this._programCache=e(this._programCache),this.bindVAO(null),this.unbindBuffer(34962),this.unbindBuffer(34963),this.unbindBuffer(35345),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(35051),this.unbindBuffer(35052),this.unbindBuffer(36662),this.unbindBuffer(36663),this._state.textureUnitMap.length=0,this._state=null,this._capabilities=null,this._stateTracker=null,a()&&console.log(this.instanceCounter.resourceInformation)}get driverTest(){return this._driverTest}get contextAttributes(){return this.gl.getContextAttributes()}get parameters(){return this._parameters}get programCache(){return this._programCache}setPipelineState(t){this._stateTracker.setPipeline(t)}getPipelineState(){return this._stateTracker.getPipelineState()}setBlendingEnabled(t){this._state.blend!==t&&(!0===t?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND),this._state.blend=t,this._stateTracker.invalidateBlending())}externalProgramUpdate(){this._state.program?.stop(),this._state.program=null}externalTextureUnitUpdate(t,e){for(let s=0;s<t.length;++s)this._state.textureUnitMap[t[s]]=null;e>=0&&(this._state.activeTexture=e)}externalVertexArrayObjectUpdate(){this.gl.bindVertexArray(null),this._state.vertexArrayObject=null,this._state.vertexBuffer=null,this._state.indexBuffer=null}externalVertexBufferUpdate(){this._state.vertexBuffer=null}externalIndexBufferUpdate(){this._state.indexBuffer=null}setBlendColor(t,e,s,i){t===this._state.blendColor.r&&e===this._state.blendColor.g&&s===this._state.blendColor.b&&i===this._state.blendColor.a||(this.gl.blendColor(t,e,s,i),this._state.blendColor.r=t,this._state.blendColor.g=e,this._state.blendColor.b=s,this._state.blendColor.a=i,this._stateTracker.invalidateBlending())}setBlendFunction(t,e){t===this._state.blendFunction.srcRGB&&e===this._state.blendFunction.dstRGB||(this.gl.blendFunc(t,e),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=t,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=e,this._stateTracker.invalidateBlending())}setBlendFunctionSeparate(t,e,s,i){this._state.blendFunction.srcRGB===t&&this._state.blendFunction.srcAlpha===s&&this._state.blendFunction.dstRGB===e&&this._state.blendFunction.dstAlpha===i||(this.gl.blendFuncSeparate(t,e,s,i),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=s,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=i,this._stateTracker.invalidateBlending())}setBlendEquation(t){this._state.blendEquation.mode!==t&&(this.gl.blendEquation(t),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=t,this._stateTracker.invalidateBlending())}setBlendEquationSeparate(t,e){this._state.blendEquation.mode===t&&this._state.blendEquation.modeAlpha===e||(this.gl.blendEquationSeparate(t,e),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=e,this._stateTracker.invalidateBlending())}setColorMask(t,e,s,i){this._state.colorMask.r===t&&this._state.colorMask.g===e&&this._state.colorMask.b===s&&this._state.colorMask.a===i||(this.gl.colorMask(t,e,s,i),this._state.colorMask.r=t,this._state.colorMask.g=e,this._state.colorMask.b=s,this._state.colorMask.a=i,this._stateTracker.invalidateColorWrite())}setClearColor(t,e,s,i){this._state.clearColor.r===t&&this._state.clearColor.g===e&&this._state.clearColor.b===s&&this._state.clearColor.a===i||(this.gl.clearColor(t,e,s,i),this._state.clearColor.r=t,this._state.clearColor.g=e,this._state.clearColor.b=s,this._state.clearColor.a=i)}setFaceCullingEnabled(t){this._state.faceCulling!==t&&(!0===t?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this._state.faceCulling=t,this._stateTracker.invalidateCulling())}setPolygonOffsetFillEnabled(t){this._state.polygonOffsetFill!==t&&(!0===t?this.gl.enable(this.gl.POLYGON_OFFSET_FILL):this.gl.disable(this.gl.POLYGON_OFFSET_FILL),this._state.polygonOffsetFill=t,this._stateTracker.invalidatePolygonOffset())}setPolygonOffset(t,e){this._state.polygonOffset[0]===t&&this._state.polygonOffset[1]===e||(this._state.polygonOffset[0]=t,this._state.polygonOffset[1]=e,this.gl.polygonOffset(t,e),this._stateTracker.invalidatePolygonOffset())}setCullFace(t){this._state.cullFace!==t&&(this.gl.cullFace(t),this._state.cullFace=t,this._stateTracker.invalidateCulling())}setFrontFace(t){this._state.frontFace!==t&&(this.gl.frontFace(t),this._state.frontFace=t,this._stateTracker.invalidateCulling())}setScissorTestEnabled(t){this._state.scissorTest!==t&&(!0===t?this.gl.enable(this.gl.SCISSOR_TEST):this.gl.disable(this.gl.SCISSOR_TEST),this._state.scissorTest=t)}setScissorRect(t,e,s,i){this._state.scissorRect.x===t&&this._state.scissorRect.y===e&&this._state.scissorRect.width===s&&this._state.scissorRect.height===i||(this.gl.scissor(t,e,s,i),this._state.scissorRect.x=t,this._state.scissorRect.y=e,this._state.scissorRect.width=s,this._state.scissorRect.height=i)}setDepthTestEnabled(t){this._state.depthTest!==t&&(!0===t?this.gl.enable(this.gl.DEPTH_TEST):this.gl.disable(this.gl.DEPTH_TEST),this._state.depthTest=t,this._stateTracker.invalidateDepthTest())}setClearDepth(t){this._state.clearDepth!==t&&(this.gl.clearDepth(t),this._state.clearDepth=t)}setDepthFunction(t){this._state.depthFunction!==t&&(this.gl.depthFunc(t),this._state.depthFunction=t,this._stateTracker.invalidateDepthTest())}setDepthWriteEnabled(t){this._state.depthWrite!==t&&(this.gl.depthMask(t),this._state.depthWrite=t,this._stateTracker.invalidateDepthWrite())}setDepthRange(t,e){this._state.depthRange.zNear===t&&this._state.depthRange.zFar===e||(this.gl.depthRange(t,e),this._state.depthRange.zNear=t,this._state.depthRange.zFar=e,this._stateTracker.invalidateDepthWrite())}setStencilTestEnabled(t){this._state.stencilTest!==t&&(!0===t?this.gl.enable(this.gl.STENCIL_TEST):this.gl.disable(this.gl.STENCIL_TEST),this._state.stencilTest=t,this._stateTracker.invalidateStencilTest())}setClearStencil(t){t!==this._state.clearStencil&&(this.gl.clearStencil(t),this._state.clearStencil=t)}setStencilFunction(t,e,s){this._state.stencilFunction.func===t&&this._state.stencilFunction.ref===e&&this._state.stencilFunction.mask===s||(this.gl.stencilFunc(t,e,s),this._state.stencilFunction.face=1032,this._state.stencilFunction.func=t,this._state.stencilFunction.ref=e,this._state.stencilFunction.mask=s,this._stateTracker.invalidateStencilTest())}setStencilFunctionSeparate(t,e,s,i){this._state.stencilFunction.face===t&&this._state.stencilFunction.func===e&&this._state.stencilFunction.ref===s&&this._state.stencilFunction.mask===i||(this.gl.stencilFuncSeparate(t,e,s,i),this._state.stencilFunction.face=t,this._state.stencilFunction.func=e,this._state.stencilFunction.ref=s,this._state.stencilFunction.mask=i,this._stateTracker.invalidateStencilTest())}setStencilWriteMask(t){this._state.stencilWriteMask!==t&&(this.gl.stencilMask(t),this._state.stencilWriteMask=t,this._stateTracker.invalidateStencilWrite())}setStencilOp(t,e,s){1032===this._state.stencilOperation.face&&this._state.stencilOperation.fail===t&&this._state.stencilOperation.zFail===e&&this._state.stencilOperation.zPass===s||(this.gl.stencilOp(t,e,s),this._state.stencilOperation.face=1032,this._state.stencilOperation.fail=t,this._state.stencilOperation.zFail=e,this._state.stencilOperation.zPass=s,this._stateTracker.invalidateStencilTest())}setStencilOpSeparate(t,e,s,i){this._state.stencilOperation.face===t&&this._state.stencilOperation.fail===e&&this._state.stencilOperation.zFail===s&&this._state.stencilOperation.zPass===i||(this.gl.stencilOpSeparate(t,e,s,i),this._state.stencilOperation.face=t,this._state.stencilOperation.fail=e,this._state.stencilOperation.zFail=s,this._state.stencilOperation.zPass=i,this._stateTracker.invalidateStencilTest())}setActiveTexture(t,e=!1){const s=this._state.activeTexture;return t>=0&&(e||t!==this._state.activeTexture)&&(this.gl.activeTexture(f+t),this._state.activeTexture=t),s}setDrawBuffers(t){const{drawFramebuffer:e}=this._state,s=null===e,i=s?this._state.drawBuffers.defaultFramebuffer:this._state.drawBuffers.fbos.get(e)??[];if(i?.length===t.length&&i.every((e,s)=>e===t[s]))return i;if(t.length>this.parameters.maxDrawBuffers)return x().error(`Setting more active draw buffers (${t.length}) than GL.MAX_DRAW_BUFFERS allows ( ${this.parameters.maxDrawBuffers}).`),i;if(s){if(t.length>1)return x().error(`The default framebuffer can only have 1 active draw buffer but was requested with ${t.length}.`),i;if(t[0]!==o&&t[0]!==u)return x().error(`The default framebuffer can only use the constants GL.BACK or GL.NONE as draw buffers but got ${t[0]}`),i}else if(t.includes(o))return x().error("A framebuffer object can only use the constants GL.COLOR_ATTACHMENTx or GL.NONE as draw buffers."),i;return this.gl.drawBuffers(t),r(this.gl),s?this._state.drawBuffers.defaultFramebuffer=t:this._state.drawBuffers.fbos.set(e,t),i}clear(t,e=255){t&&(16384&t&&this.setColorMask(!0,!0,!0,!0),256&t&&this.setDepthWriteEnabled(!0),1024&t&&this.setStencilWriteMask(e),this.gl.clear(t))}clearFramebuffer(t,e=!1,s=!1){let i=0;if(t){const e=1e-13,s=Math.max(e,t[3]);this.setClearColor(t[0],t[1],t[2],s),i|=16384}e&&(i|=256),!1===s?s=0:(!0===s&&(s=255),i|=1024),i&&this.clear(i,s)}clearBuffer(t,e,s=6144,i=void 0){this.gl.clearBufferfv(s,t,e,i)}clearBufferInteger(t,e,s=6144,i=void 0){this.gl.clearBufferiv(s,t,e,i)}clearBufferUnsignedInteger(t,e,s=6144,i=void 0){this.gl.clearBufferuiv(s,t,e,i)}drawArrays(t,e,s){if(this._transformFeedbackRequestInfo){if(t!==this._transformFeedbackRequestInfo.primitiveType)throw new Error("DrawArrays called during transform feedback, but primitiveType does not match that of the current transform feedback request");if(null==this._state.program?.hasTransformFeedbackVaryings)throw new Error("DrawArrays called during transform feedback, but the shader program was not linked with a transform feedback varying")}if(a()&&(this._numOfDrawCalls++,this._numOfTriangles+=E(t,s),has("enable-feature:webgl-debug:textureReadWrite"))){const t=this._state.textureUnitMap;for(let e=0;e<t.length;e++){const s=t[e];if(null!=s&&s===this._state.drawFramebuffer?.colorTexture)throw new Error(`Detected readWrite. Texture already bound at index ${e}`)}}this.gl.drawArrays(t,e,s),r(this.gl)}drawArraysInstanced(t,e,s,i){this.gl.drawArraysInstanced(t,e,s,i),r(this.gl)}drawElements(t,e,s,i){if(this._transformFeedbackRequestInfo)throw new Error("Cannot called drawElements during a transform feedback request");if(a()&&(this._numOfDrawCalls++,this._numOfTriangles+=E(t,e)),this.gl.drawElements(t,e,s,i),a()){const a=n(this.gl);if(a){const r=this.getBoundVAO(),n=r?.indexBuffer,l=r?.buffers,h={indexBuffer:n,vertexBuffers:l},f={mode:t,count:e,type:s,offset:i},o=n?.size??0,u=i+e,c=o<u?`. Buffer is too small. Attempted to draw index ${u} of ${o}`:"";x().error(`drawElements: ${a}${c}`,{args:f,vao:h})}}}drawElementsInstanced(t,e,s,i,a){this.gl.drawElementsInstanced(t,e,s,i,a),r(this.gl)}logInfo(){a()&&console.log(`DrawCalls: ${this._numOfDrawCalls}, Triangles: ${this._numOfTriangles}`)}resetInfo(){a()&&(this._numOfDrawCalls=0,this._numOfTriangles=0)}get capabilities(){return this._capabilities}setViewport(t,e,s,i){s=Math.max(Math.round(s),1),i=Math.max(Math.round(i),1);const a=this._state.viewport;a.x===t&&a.y===e&&a.width===s&&a.height===i||(a.x=t,a.y=e,a.width=s,a.height=i,this.gl.viewport(t,e,s,i))}setViewport4fv(t){this.setViewport(t[0],t[1],t[2],t[3])}restoreViewport({x:t,y:e,width:s,height:i}){this.setViewport(t,e,s,i)}getViewport(){const t=this._state.viewport;return{x:t.x,y:t.y,width:t.width,height:t.height}}useProgram(t){if(this._state.program!==t){if(t&&null==t.glName&&l())throw new Error("Attempting to use disposed or invalid Program");this._state.program?.stop(),this._state.program=t,this.gl.useProgram(t?.glName??null)}}bindTexture(t,e,s=!1){(e>=this.parameters.maxTextureImageUnits||e<0)&&x().error(`Input texture unit (${e}) is out of range of available units (0...${this.parameters.maxTextureImageUnits})\n `);const i=this._state.textureUnitMap[e];return null==t?.glName?(null!=i&&(this.setActiveTexture(e,s),this.gl.bindTexture(i.descriptor.target,null)),this._state.textureUnitMap[e]=null,i):s||i!==t?(this.setActiveTexture(e,s),this.gl.bindTexture(t.descriptor.target,t.glName),t.applyChanges(),this._state.textureUnitMap[e]=t,i):(t.isDirty&&(this.setActiveTexture(e,s),t.applyChanges()),i)}unbindTexture(t){if(null!=t)for(let e=0;e<this.parameters.maxTextureImageUnits;e++)this._state.textureUnitMap[e]===t&&(this.bindTexture(null,e),this._state.textureUnitMap[e]=null)}bindFramebuffer(t,e=!1){const s=C(t);if(e||this._state.readFramebuffer!==t||this._state.drawFramebuffer!==t){if(null==t)return this.gl.bindFramebuffer(36160,null),this._state.readFramebuffer=this._state.drawFramebuffer=null,void this.setDrawBuffers(s);t.initializeAndBind(36160),this._state.readFramebuffer=t,this._state.drawFramebuffer=t,this.setDrawBuffers(s)}else this.setDrawBuffers(s)}bindFramebufferSeparate(t,e,s=!1){const i=36008===e,a=i?this._state.readFramebuffer:this._state.drawFramebuffer;(s||a!==t)&&(null==t?this.gl.bindFramebuffer(e,null):t.initializeAndBind(e),i?this._state.readFramebuffer=t??null:(this._state.drawFramebuffer=t??null,this.setDrawBuffers(C(t))))}blitFramebuffer(t,e,s=16384,i=9728,a=0,r=0,n=t.width,l=t.height,h=0,f=0,o=e.width,u=e.height){this.bindFramebufferSeparate(t,36008,!0),this.bindFramebufferSeparate(e,36009,!0),this.gl.blitFramebuffer(a,r,n,l,h,f,o,u,s,i)}bindBuffer(t,e){if(t)switch(e??=t.bufferType,e){case 34962:this._state.vertexBuffer=w(this.gl,t,e,this._state.vertexBuffer);break;case 34963:this._state.indexBuffer=w(this.gl,t,e,this._state.indexBuffer);break;case 35345:this._state.uniformBuffer=w(this.gl,t,e,this._state.uniformBuffer);break;case 35051:this._state.pixelPackBuffer=w(this.gl,t,e,this._state.pixelPackBuffer);break;case 35052:this._state.pixelUnpackBuffer=w(this.gl,t,e,this._state.pixelUnpackBuffer);break;case 36662:this._state.copyReadBuffer=w(this.gl,t,e,this._state.copyReadBuffer);break;case 36663:this._state.copyWriteBuffer=w(this.gl,t,e,this._state.copyWriteBuffer);break;case 35982:this._state.transformFeedbackBuffer=w(this.gl,t,e,this._state.transformFeedbackBuffer)}}bindRenderbuffer(t){const e=this.gl;t||(e.bindRenderbuffer(e.RENDERBUFFER,null),this._state.renderbuffer=null),this._state.renderbuffer!==t&&(e.bindRenderbuffer(e.RENDERBUFFER,t.glName),this._state.renderbuffer=t)}_getBufferBinding(t,e){if(e>=this.parameters.maxUniformBufferBindings||e<0)return x().error(`Uniform buffer binding point (${e}) is out of range (0...${this.parameters.maxUniformBufferBindings})\n `),null;const s=35345===t?this._state.uniformBufferBindingPoints:this._state.transformBufferBindingPoints;let i=s[e];return null==i&&(i={buffer:null,offset:0,size:0},s[e]=i),i}bindBufferBase(t,e,s){const i=this._getBufferBinding(t,e);null!=i&&(i.buffer===s&&0===i.offset&&0===i.size||(this.gl.bindBufferBase(t,e,s?s.glName:null),i.buffer=s,i.offset=0,i.size=0))}bindBufferRange(t,e,s,i,a){const r=this._getBufferBinding(t,e);null!=r&&(r.buffer===s&&r.offset===i&&r.size===a||(i%this._parameters.uniformBufferOffsetAlignment===0?(this.gl.bindBufferRange(t,e,s.glName,i,a),r.buffer=s,r.offset=i,r.size=a):x().error("Uniform buffer binding offset is not a multiple of the context offset alignment")))}bindUBO(t,e,s,i){null!=e?(a()&&(i??e.byteLength)>this._parameters.maxUniformBlockSize&&x().error("Attempting to bind more data than the maximum uniform block size"),e.initialize(),void 0!==s&&void 0!==i?this.bindBufferRange(35345,t,e.buffer,s,i):this.bindBufferBase(35345,t,e.buffer)):this.bindBufferBase(35345,t,null)}unbindUBO(t){for(let e=0,s=this._state.uniformBufferBindingPoints.length;e<s;e++){const s=this._state.uniformBufferBindingPoints[e];null!=s&&s.buffer===t.buffer&&this.bindBufferBase(35345,e,null)}}unbindBuffer(t){switch(t){case 34962:this._state.vertexBuffer=w(this.gl,null,t,this._state.vertexBuffer);break;case 34963:this._state.indexBuffer=w(this.gl,null,t,this._state.indexBuffer);break;case 35345:this._state.uniformBuffer=w(this.gl,null,t,this._state.uniformBuffer);break;case 35051:this._state.pixelPackBuffer=w(this.gl,null,t,this._state.pixelPackBuffer);break;case 35052:this._state.pixelUnpackBuffer=w(this.gl,null,t,this._state.pixelUnpackBuffer);break;case 36662:this._state.copyReadBuffer=w(this.gl,null,t,this._state.copyReadBuffer);break;case 36663:this._state.copyWriteBuffer=w(this.gl,null,t,this._state.copyWriteBuffer)}}bindVAO(t,e){if(null==t)return this._state.vertexArrayObject?.unbind(),void(this._state.vertexArrayObject=null);this._state.vertexArrayObject!==t&&(t.bind(e),this._state.vertexArrayObject=t)}bindTransformFeedback(t){const{gl:e}=this;e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,t.glName)}beginTransformFeedback(t,e){if(this._transformFeedbackRequestInfo)throw new Error("Already in a transform feedback request");const{gl:s}=this;s.bindTransformFeedback(s.TRANSFORM_FEEDBACK,t.glName),s.beginTransformFeedback(e),this._transformFeedbackRequestInfo={primitiveType:e}}endTransformFeedback(){if(!this._transformFeedbackRequestInfo)throw new Error("Not in a transform feedback request");const{gl:t}=this;t.endTransformFeedback(),t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null),this._transformFeedbackRequestInfo=null}async clientWaitAsync(t=i(10)){const{gl:e}=this,a=e.fenceSync(37143,0);if(!a)throw new Error("Client wait failed, could not create sync object");let r;this.instanceCounter.increment(c.Sync,a),e.flush();do{await s(t),r=e.clientWaitSync(a,0,0)}while(37147===r);if(this.instanceCounter.decrement(c.Sync,a),e.deleteSync(a),37149===r)throw new Error("Client wait failed")}getBoundFramebufferObject(t=36160){return 36008===t?this._state.readFramebuffer:this._state.drawFramebuffer}temporaryBindFramebufferObject(t,e,s=!1){const i=this.getBoundFramebufferObject();try{this.bindFramebuffer(t,s),e()}finally{this.bindFramebuffer(i,s)}}getBoundVAO(){return this._state.vertexArrayObject}resetState(){this.useProgram(null),this.bindVAO(null),this.bindFramebuffer(null,!0),this.unbindBuffer(34962),this.unbindBuffer(34963),this.unbindBuffer(35345),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(35051),this.unbindBuffer(35052),this.unbindBuffer(36662),this.unbindBuffer(36663);for(let t=0;t<this.parameters.maxTextureImageUnits;++t)this.bindTexture(null,t);this.setBlendingEnabled(!1),this.setBlendFunction(1,0),this.setBlendEquation(32774),this.setBlendColor(0,0,0,0),this.setFaceCullingEnabled(!1),this.setCullFace(1029),this.setFrontFace(2305),this.setPolygonOffsetFillEnabled(!1),this.setPolygonOffset(0,0),this.setScissorTestEnabled(!1),this.setScissorRect(0,0,this.gl.canvas.width,this.gl.canvas.height),this.setDepthTestEnabled(!1),this.setDepthFunction(513),this.setDepthRange(0,1),this.setStencilTestEnabled(!1),this.setStencilFunction(519,0,0),this.setStencilOp(7680,7680,7680),this.setClearColor(0,0,0,0),this.setClearDepth(1),this.setClearStencil(0),this.setColorMask(!0,!0,!0,!0),this.setStencilWriteMask(4294967295),this.setDepthWriteEnabled(!0),this.setViewport(0,0,this.gl.canvas.width,this.gl.canvas.height)}enforceState(){const{gl:t}=this;t.bindVertexArray(null);for(let s=0;s<this.parameters.maxVertexAttributes;s++)t.disableVertexAttribArray(s);this._state.vertexBuffer?t.bindBuffer(this._state.vertexBuffer.bufferType,this._state.vertexBuffer.glName):t.bindBuffer(34962,null),this._state.indexBuffer?t.bindBuffer(this._state.indexBuffer.bufferType,this._state.indexBuffer.glName):t.bindBuffer(34963,null),this._state.uniformBuffer?t.bindBuffer(this._state.uniformBuffer.bufferType,this._state.uniformBuffer.glName):t.bindBuffer(35345,null);for(let s=0;s<this._parameters.maxUniformBufferBindings;s++){const e=this._state.uniformBufferBindingPoints[s];if(null!=e){const{buffer:i,offset:a,size:r}=e;null!==i?0===a&&0===r?t.bindBufferBase(35345,s,i.glName):t.bindBufferRange(35345,s,i.glName,a,r):t.bindBufferBase(35345,s,null)}}if(this._state.pixelPackBuffer?t.bindBuffer(this._state.pixelPackBuffer.bufferType,this._state.pixelPackBuffer.glName):t.bindBuffer(35051,null),this._state.pixelUnpackBuffer?t.bindBuffer(this._state.pixelUnpackBuffer.bufferType,this._state.pixelUnpackBuffer.glName):t.bindBuffer(35052,null),this._state.copyReadBuffer?t.bindBuffer(this._state.copyReadBuffer.bufferType,this._state.copyReadBuffer.glName):t.bindBuffer(36662,null),this._state.copyWriteBuffer?t.bindBuffer(this._state.copyWriteBuffer.bufferType,this._state.copyWriteBuffer.glName):t.bindBuffer(36663,null),t.bindFramebuffer(36008,null),t.readBuffer(t.BACK),this._state.readFramebuffer&&(t.bindFramebuffer(36008,this._state.readFramebuffer.glName),t.readBuffer(d)),t.bindFramebuffer(36009,this._state.drawFramebuffer?.glName??null),null===this._state.drawFramebuffer){const e=this._state.drawBuffers.defaultFramebuffer;t.drawBuffers(e??[o])}else{const e=this._state.drawBuffers.fbos.get(this._state.drawFramebuffer);t.drawBuffers(e??[d])}if(this._state.vertexArrayObject){const t=this._state.vertexArrayObject;this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null),this.bindVAO(t)}t.useProgram(this._state.program?.glName??null),t.blendColor(this._state.blendColor.r,this._state.blendColor.g,this._state.blendColor.b,this._state.blendColor.a),t.bindRenderbuffer(t.RENDERBUFFER,this._state.renderbuffer?.glName??null),!0===this._state.blend?t.enable(this.gl.BLEND):t.disable(this.gl.BLEND),t.blendEquationSeparate(this._state.blendEquation.mode,this._state.blendEquation.modeAlpha),t.blendFuncSeparate(this._state.blendFunction.srcRGB,this._state.blendFunction.dstRGB,this._state.blendFunction.srcAlpha,this._state.blendFunction.dstAlpha),t.clearColor(this._state.clearColor.r,this._state.clearColor.g,this._state.clearColor.b,this._state.clearColor.a),t.clearDepth(this._state.clearDepth),t.clearStencil(this._state.clearStencil),t.colorMask(this._state.colorMask.r,this._state.colorMask.g,this._state.colorMask.b,this._state.colorMask.a),t.cullFace(this._state.cullFace),t.depthFunc(this._state.depthFunction),t.depthRange(this._state.depthRange.zNear,this._state.depthRange.zFar),!0===this._state.depthTest?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),t.depthMask(this._state.depthWrite),t.frontFace(this._state.frontFace),t.lineWidth(1),!0===this._state.faceCulling?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),t.polygonOffset(this._state.polygonOffset[0],this._state.polygonOffset[1]),!0===this._state.polygonOffsetFill?t.enable(t.POLYGON_OFFSET_FILL):t.disable(t.POLYGON_OFFSET_FILL),t.scissor(this._state.scissorRect.x,this._state.scissorRect.y,this._state.scissorRect.width,this._state.scissorRect.height),!0===this._state.scissorTest?t.enable(t.SCISSOR_TEST):t.disable(t.SCISSOR_TEST),t.stencilFunc(this._state.stencilFunction.func,this._state.stencilFunction.ref,this._state.stencilFunction.mask),t.stencilOpSeparate(this._state.stencilOperation.face,this._state.stencilOperation.fail,this._state.stencilOperation.zFail,this._state.stencilOperation.zPass),!0===this._state.stencilTest?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),t.stencilMask(this._state.stencilWriteMask);for(let s=0;s<this.parameters.maxTextureImageUnits;s++){t.activeTexture(f+s),t.bindTexture(3553,null),t.bindTexture(34067,null),t.bindTexture(32879,null),t.bindTexture(35866,null);const e=this._state.textureUnitMap[s];null!=e&&t.bindTexture(e.descriptor.target,e.glName)}t.activeTexture(f+this._state.activeTexture);const e=this._state.viewport;t.viewport(e.x,e.y,e.width,e.height),this.resetInfo()}};function w(t,e,s,i){return e?i!==e&&t.bindBuffer(s,e.glName):t.bindBuffer(s,null),e}function E(t,e){switch(t){case _.POINTS:return 2*e;case _.TRIANGLES:return e/3;case _.TRIANGLE_STRIP:case _.TRIANGLE_FAN:return e-2;default:return 0}}function C(t){return t?t.colorAttachments.length>0?t.colorAttachments:[u]:[o]}export{k as RenderingContext,C as getFramebufferDrawBuffers};
|
|
2
|
+
import has from"../../core/has.js";import t from"../../core/Logger.js";import{disposeMaybe as e}from"../../core/maybe.js";import{after as s}from"../../core/promiseUtils.js";import{Milliseconds as i}from"../../core/time.js";import{webglDebugEnabled as a,checkWebGLError as r,getErrorMessage as n,webglValidateShadersEnabled as l}from"./checkWebGLError.js";import{ContextState as h}from"./ContextState.js";import{DrawBufferNone as f,DrawBufferBack as o,baseTextureUnit as u,ResourceType as c,ColorAttachment0 as d,PrimitiveType as _}from"./enums.js";import{InstanceCounter as b}from"./InstanceCounter.js";import{Parameters as g}from"./Parameters.js";import{ProgramCache as p}from"./ProgramCache.js";import{StateTracker as m}from"./renderState.js";import B from"./Texture.js";import{WebGLDriverTest as F}from"./WebGLDriverTest.js";import{Capabilities as T}from"./capabilities/Capabilities.js";const x=()=>t.getLogger("esri.views.webgl.RenderingContext");let k=class{constructor(t,e){this.gl=t,this.instanceCounter=new b,this._programCache=new p(this),this._transformFeedbackRequestInfo=null,this._state=new h,this._numOfDrawCalls=0,this._numOfTriangles=0,this._options=e,this.configure(e)}configure(t){this._options=t,this._capabilities=new T(this.gl,t),this._parameters=new g(this.gl,this._capabilities,t),B.TEXTURE_UNIT_FOR_UPDATES=this._parameters.maxTextureImageUnits-1;const s=this.gl.getParameter(this.gl.VIEWPORT);this._state=new h,this._state.viewport={x:s[0],y:s[1],width:s[2],height:s[3]},this._stateTracker=new m({setBlending:t=>{if(t){this.setBlendingEnabled(!0),this.setBlendEquationSeparate(t.opRgb,t.opAlpha),this.setBlendFunctionSeparate(t.srcRgb,t.dstRgb,t.srcAlpha,t.dstAlpha);const e=t.color;this.setBlendColor(e.r,e.g,e.b,e.a)}else this.setBlendingEnabled(!1)},setCulling:t=>{t?(this.setFaceCullingEnabled(!0),this.setCullFace(t.face),this.setFrontFace(t.mode)):this.setFaceCullingEnabled(!1)},setPolygonOffset:t=>{t?(this.setPolygonOffsetFillEnabled(!0),this.setPolygonOffset(t.factor,t.units)):this.setPolygonOffsetFillEnabled(!1)},setDepthTest:t=>{t?(this.setDepthTestEnabled(!0),this.setDepthFunction(t.func)):this.setDepthTestEnabled(!1)},setStencilTest:t=>{if(t){this.setStencilTestEnabled(!0);const e=t.function;this.setStencilFunction(e.func,e.ref,e.mask);const s=t.operation;this.setStencilOp(s.fail,s.zFail,s.zPass)}else this.setStencilTestEnabled(!1)},setDepthWrite:t=>{t?(this.setDepthWriteEnabled(!0),this.setDepthRange(t.zNear,t.zFar)):this.setDepthWriteEnabled(!1)},setColorWrite:t=>{t?this.setColorMask(t.r,t.g,t.b,t.a):this.setColorMask(!1,!1,!1,!1)},setStencilWrite:t=>{t?this.setStencilWriteMask(t.mask):this.setStencilWriteMask(0)}}),this.enforceState(),e(this._driverTest),this._driverTest=new F(this)}updateOptions(t){this._options={...this._options,...t},this._parameters=new g(this.gl,this._capabilities,this._options)}dispose(){this._driverTest=e(this._driverTest),this._programCache=e(this._programCache),this.bindVAO(null),this.unbindBuffer(34962),this.unbindBuffer(34963),this.unbindBuffer(35345),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(35051),this.unbindBuffer(35052),this.unbindBuffer(36662),this.unbindBuffer(36663),this._state.textureUnitMap.length=0,this._state=null,this._capabilities=null,this._stateTracker=null,a()&&this.instanceCounter.resourceInformation&&console.log(this.instanceCounter.resourceInformation)}get driverTest(){return this._driverTest}get contextAttributes(){return this.gl.getContextAttributes()}get parameters(){return this._parameters}get programCache(){return this._programCache}setPipelineState(t){this._stateTracker.setPipeline(t)}getPipelineState(){return this._stateTracker.getPipelineState()}setBlendingEnabled(t){this._state.blend!==t&&(!0===t?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND),this._state.blend=t,this._stateTracker.invalidateBlending())}externalProgramUpdate(){this._state.program?.stop(),this._state.program=null}externalTextureUnitUpdate(t,e){for(let s=0;s<t.length;++s)this._state.textureUnitMap[t[s]]=null;e>=0&&(this._state.activeTexture=e)}externalVertexArrayObjectUpdate(){this.gl.bindVertexArray(null),this._state.vertexArrayObject=null,this._state.vertexBuffer=null,this._state.indexBuffer=null}externalVertexBufferUpdate(){this._state.vertexBuffer=null}externalIndexBufferUpdate(){this._state.indexBuffer=null}setBlendColor(t,e,s,i){t===this._state.blendColor.r&&e===this._state.blendColor.g&&s===this._state.blendColor.b&&i===this._state.blendColor.a||(this.gl.blendColor(t,e,s,i),this._state.blendColor.r=t,this._state.blendColor.g=e,this._state.blendColor.b=s,this._state.blendColor.a=i,this._stateTracker.invalidateBlending())}setBlendFunction(t,e){t===this._state.blendFunction.srcRGB&&e===this._state.blendFunction.dstRGB||(this.gl.blendFunc(t,e),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=t,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=e,this._stateTracker.invalidateBlending())}setBlendFunctionSeparate(t,e,s,i){this._state.blendFunction.srcRGB===t&&this._state.blendFunction.srcAlpha===s&&this._state.blendFunction.dstRGB===e&&this._state.blendFunction.dstAlpha===i||(this.gl.blendFuncSeparate(t,e,s,i),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=s,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=i,this._stateTracker.invalidateBlending())}setBlendEquation(t){this._state.blendEquation.mode!==t&&(this.gl.blendEquation(t),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=t,this._stateTracker.invalidateBlending())}setBlendEquationSeparate(t,e){this._state.blendEquation.mode===t&&this._state.blendEquation.modeAlpha===e||(this.gl.blendEquationSeparate(t,e),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=e,this._stateTracker.invalidateBlending())}setColorMask(t,e,s,i){this._state.colorMask.r===t&&this._state.colorMask.g===e&&this._state.colorMask.b===s&&this._state.colorMask.a===i||(this.gl.colorMask(t,e,s,i),this._state.colorMask.r=t,this._state.colorMask.g=e,this._state.colorMask.b=s,this._state.colorMask.a=i,this._stateTracker.invalidateColorWrite())}setClearColor(t,e,s,i){this._state.clearColor.r===t&&this._state.clearColor.g===e&&this._state.clearColor.b===s&&this._state.clearColor.a===i||(this.gl.clearColor(t,e,s,i),this._state.clearColor.r=t,this._state.clearColor.g=e,this._state.clearColor.b=s,this._state.clearColor.a=i)}setFaceCullingEnabled(t){this._state.faceCulling!==t&&(!0===t?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this._state.faceCulling=t,this._stateTracker.invalidateCulling())}setPolygonOffsetFillEnabled(t){this._state.polygonOffsetFill!==t&&(!0===t?this.gl.enable(this.gl.POLYGON_OFFSET_FILL):this.gl.disable(this.gl.POLYGON_OFFSET_FILL),this._state.polygonOffsetFill=t,this._stateTracker.invalidatePolygonOffset())}setPolygonOffset(t,e){this._state.polygonOffset[0]===t&&this._state.polygonOffset[1]===e||(this._state.polygonOffset[0]=t,this._state.polygonOffset[1]=e,this.gl.polygonOffset(t,e),this._stateTracker.invalidatePolygonOffset())}setCullFace(t){this._state.cullFace!==t&&(this.gl.cullFace(t),this._state.cullFace=t,this._stateTracker.invalidateCulling())}setFrontFace(t){this._state.frontFace!==t&&(this.gl.frontFace(t),this._state.frontFace=t,this._stateTracker.invalidateCulling())}setScissorTestEnabled(t){this._state.scissorTest!==t&&(!0===t?this.gl.enable(this.gl.SCISSOR_TEST):this.gl.disable(this.gl.SCISSOR_TEST),this._state.scissorTest=t)}setScissorRect(t,e,s,i){this._state.scissorRect.x===t&&this._state.scissorRect.y===e&&this._state.scissorRect.width===s&&this._state.scissorRect.height===i||(this.gl.scissor(t,e,s,i),this._state.scissorRect.x=t,this._state.scissorRect.y=e,this._state.scissorRect.width=s,this._state.scissorRect.height=i)}setDepthTestEnabled(t){this._state.depthTest!==t&&(!0===t?this.gl.enable(this.gl.DEPTH_TEST):this.gl.disable(this.gl.DEPTH_TEST),this._state.depthTest=t,this._stateTracker.invalidateDepthTest())}setClearDepth(t){this._state.clearDepth!==t&&(this.gl.clearDepth(t),this._state.clearDepth=t)}setDepthFunction(t){this._state.depthFunction!==t&&(this.gl.depthFunc(t),this._state.depthFunction=t,this._stateTracker.invalidateDepthTest())}setDepthWriteEnabled(t){this._state.depthWrite!==t&&(this.gl.depthMask(t),this._state.depthWrite=t,this._stateTracker.invalidateDepthWrite())}setDepthRange(t,e){this._state.depthRange.zNear===t&&this._state.depthRange.zFar===e||(this.gl.depthRange(t,e),this._state.depthRange.zNear=t,this._state.depthRange.zFar=e,this._stateTracker.invalidateDepthWrite())}setStencilTestEnabled(t){this._state.stencilTest!==t&&(!0===t?this.gl.enable(this.gl.STENCIL_TEST):this.gl.disable(this.gl.STENCIL_TEST),this._state.stencilTest=t,this._stateTracker.invalidateStencilTest())}setClearStencil(t){t!==this._state.clearStencil&&(this.gl.clearStencil(t),this._state.clearStencil=t)}setStencilFunction(t,e,s){this._state.stencilFunction.func===t&&this._state.stencilFunction.ref===e&&this._state.stencilFunction.mask===s||(this.gl.stencilFunc(t,e,s),this._state.stencilFunction.face=1032,this._state.stencilFunction.func=t,this._state.stencilFunction.ref=e,this._state.stencilFunction.mask=s,this._stateTracker.invalidateStencilTest())}setStencilFunctionSeparate(t,e,s,i){this._state.stencilFunction.face===t&&this._state.stencilFunction.func===e&&this._state.stencilFunction.ref===s&&this._state.stencilFunction.mask===i||(this.gl.stencilFuncSeparate(t,e,s,i),this._state.stencilFunction.face=t,this._state.stencilFunction.func=e,this._state.stencilFunction.ref=s,this._state.stencilFunction.mask=i,this._stateTracker.invalidateStencilTest())}setStencilWriteMask(t){this._state.stencilWriteMask!==t&&(this.gl.stencilMask(t),this._state.stencilWriteMask=t,this._stateTracker.invalidateStencilWrite())}setStencilOp(t,e,s){1032===this._state.stencilOperation.face&&this._state.stencilOperation.fail===t&&this._state.stencilOperation.zFail===e&&this._state.stencilOperation.zPass===s||(this.gl.stencilOp(t,e,s),this._state.stencilOperation.face=1032,this._state.stencilOperation.fail=t,this._state.stencilOperation.zFail=e,this._state.stencilOperation.zPass=s,this._stateTracker.invalidateStencilTest())}setStencilOpSeparate(t,e,s,i){this._state.stencilOperation.face===t&&this._state.stencilOperation.fail===e&&this._state.stencilOperation.zFail===s&&this._state.stencilOperation.zPass===i||(this.gl.stencilOpSeparate(t,e,s,i),this._state.stencilOperation.face=t,this._state.stencilOperation.fail=e,this._state.stencilOperation.zFail=s,this._state.stencilOperation.zPass=i,this._stateTracker.invalidateStencilTest())}setActiveTexture(t,e=!1){const s=this._state.activeTexture;return t>=0&&(e||t!==this._state.activeTexture)&&(this.gl.activeTexture(u+t),this._state.activeTexture=t),s}setDrawBuffers(t){const{drawFramebuffer:e}=this._state,s=null===e,i=s?this._state.drawBuffers.defaultFramebuffer:this._state.drawBuffers.fbos.get(e)??[];if(i?.length===t.length&&i.every((e,s)=>e===t[s]))return i;if(t.length>this.parameters.maxDrawBuffers)return x().error(`Setting more active draw buffers (${t.length}) than GL.MAX_DRAW_BUFFERS allows ( ${this.parameters.maxDrawBuffers}).`),i;if(s){if(t.length>1)return x().error(`The default framebuffer can only have 1 active draw buffer but was requested with ${t.length}.`),i;if(t[0]!==o&&t[0]!==f)return x().error(`The default framebuffer can only use the constants GL.BACK or GL.NONE as draw buffers but got ${t[0]}`),i}else if(t.includes(o))return x().error("A framebuffer object can only use the constants GL.COLOR_ATTACHMENTx or GL.NONE as draw buffers."),i;return this.gl.drawBuffers(t),r(this.gl),s?this._state.drawBuffers.defaultFramebuffer=t:this._state.drawBuffers.fbos.set(e,t),i}clear(t,e=255){t&&(16384&t&&this.setColorMask(!0,!0,!0,!0),256&t&&this.setDepthWriteEnabled(!0),1024&t&&this.setStencilWriteMask(e),this.gl.clear(t))}clearFramebuffer(t,e=!1,s=!1){let i=0;if(t){const e=1e-13,s=Math.max(e,t[3]);this.setClearColor(t[0],t[1],t[2],s),i|=16384}e&&(i|=256),!1===s?s=0:(!0===s&&(s=255),i|=1024),i&&this.clear(i,s)}clearBuffer(t,e,s=6144,i=void 0){this.gl.clearBufferfv(s,t,e,i)}clearBufferInteger(t,e,s=6144,i=void 0){this.gl.clearBufferiv(s,t,e,i)}clearBufferUnsignedInteger(t,e,s=6144,i=void 0){this.gl.clearBufferuiv(s,t,e,i)}drawArrays(t,e,s){if(this._transformFeedbackRequestInfo){if(t!==this._transformFeedbackRequestInfo.primitiveType)throw new Error("DrawArrays called during transform feedback, but primitiveType does not match that of the current transform feedback request");if(null==this._state.program?.hasTransformFeedbackVaryings)throw new Error("DrawArrays called during transform feedback, but the shader program was not linked with a transform feedback varying")}if(a()&&(this._numOfDrawCalls++,this._numOfTriangles+=E(t,s),has("enable-feature:webgl-debug:textureReadWrite"))){const t=this._state.textureUnitMap;for(let e=0;e<t.length;e++){const s=t[e];if(null!=s&&s===this._state.drawFramebuffer?.colorTexture)throw new Error(`Detected readWrite. Texture already bound at index ${e}`)}}this.gl.drawArrays(t,e,s),r(this.gl)}drawArraysInstanced(t,e,s,i){this.gl.drawArraysInstanced(t,e,s,i),r(this.gl)}drawElements(t,e,s,i){if(this._transformFeedbackRequestInfo)throw new Error("Cannot called drawElements during a transform feedback request");if(a()&&(this._numOfDrawCalls++,this._numOfTriangles+=E(t,e)),this.gl.drawElements(t,e,s,i),a()){const a=n(this.gl);if(a){const r=this.getBoundVAO(),n=r?.indexBuffer,l=r?.buffers,h={indexBuffer:n,vertexBuffers:l},f={mode:t,count:e,type:s,offset:i},o=n?.size??0,u=i+e,c=o<u?`. Buffer is too small. Attempted to draw index ${u} of ${o}`:"";x().error(`drawElements: ${a}${c}`,{args:f,vao:h})}}}drawElementsInstanced(t,e,s,i,a){this.gl.drawElementsInstanced(t,e,s,i,a),r(this.gl)}logInfo(){a()&&console.log(`DrawCalls: ${this._numOfDrawCalls}, Triangles: ${this._numOfTriangles}`)}resetInfo(){a()&&(this._numOfDrawCalls=0,this._numOfTriangles=0)}get capabilities(){return this._capabilities}setViewport(t,e,s,i){s=Math.max(Math.round(s),1),i=Math.max(Math.round(i),1);const a=this._state.viewport;a.x===t&&a.y===e&&a.width===s&&a.height===i||(a.x=t,a.y=e,a.width=s,a.height=i,this.gl.viewport(t,e,s,i))}setViewport4fv(t){this.setViewport(t[0],t[1],t[2],t[3])}restoreViewport({x:t,y:e,width:s,height:i}){this.setViewport(t,e,s,i)}getViewport(){const t=this._state.viewport;return{x:t.x,y:t.y,width:t.width,height:t.height}}useProgram(t){if(this._state.program!==t){if(t&&null==t.glName&&l())throw new Error("Attempting to use disposed or invalid Program");this._state.program?.stop(),this._state.program=t,this.gl.useProgram(t?.glName??null)}}bindTexture(t,e,s=!1){(e>=this.parameters.maxTextureImageUnits||e<0)&&x().error(`Input texture unit (${e}) is out of range of available units (0...${this.parameters.maxTextureImageUnits})\n `);const i=this._state.textureUnitMap[e];return null==t?.glName?(null!=i&&(this.setActiveTexture(e,s),this.gl.bindTexture(i.descriptor.target,null)),this._state.textureUnitMap[e]=null,i):s||i!==t?(this.setActiveTexture(e,s),this.gl.bindTexture(t.descriptor.target,t.glName),t.applyChanges(),this._state.textureUnitMap[e]=t,i):(t.isDirty&&(this.setActiveTexture(e,s),t.applyChanges()),i)}unbindTexture(t){if(null!=t)for(let e=0;e<this.parameters.maxTextureImageUnits;e++)this._state.textureUnitMap[e]===t&&(this.bindTexture(null,e),this._state.textureUnitMap[e]=null)}bindFramebuffer(t,e=!1){const s=C(t);if(e||this._state.readFramebuffer!==t||this._state.drawFramebuffer!==t){if(null==t)return this.gl.bindFramebuffer(36160,null),this._state.readFramebuffer=this._state.drawFramebuffer=null,void this.setDrawBuffers(s);t.initializeAndBind(36160),this._state.readFramebuffer=t,this._state.drawFramebuffer=t,this.setDrawBuffers(s)}else this.setDrawBuffers(s)}bindFramebufferSeparate(t,e,s=!1){const i=36008===e,a=i?this._state.readFramebuffer:this._state.drawFramebuffer;(s||a!==t)&&(null==t?this.gl.bindFramebuffer(e,null):t.initializeAndBind(e),i?this._state.readFramebuffer=t??null:(this._state.drawFramebuffer=t??null,this.setDrawBuffers(C(t))))}blitFramebuffer(t,e,s=16384,i=9728,a=0,r=0,n=t.width,l=t.height,h=0,f=0,o=e.width,u=e.height){this.bindFramebufferSeparate(t,36008,!0),this.bindFramebufferSeparate(e,36009,!0),this.gl.blitFramebuffer(a,r,n,l,h,f,o,u,s,i)}bindBuffer(t,e){if(t)switch(e??=t.bufferType,e){case 34962:this._state.vertexBuffer=w(this.gl,t,e,this._state.vertexBuffer);break;case 34963:this._state.indexBuffer=w(this.gl,t,e,this._state.indexBuffer);break;case 35345:this._state.uniformBuffer=w(this.gl,t,e,this._state.uniformBuffer);break;case 35051:this._state.pixelPackBuffer=w(this.gl,t,e,this._state.pixelPackBuffer);break;case 35052:this._state.pixelUnpackBuffer=w(this.gl,t,e,this._state.pixelUnpackBuffer);break;case 36662:this._state.copyReadBuffer=w(this.gl,t,e,this._state.copyReadBuffer);break;case 36663:this._state.copyWriteBuffer=w(this.gl,t,e,this._state.copyWriteBuffer);break;case 35982:this._state.transformFeedbackBuffer=w(this.gl,t,e,this._state.transformFeedbackBuffer)}}bindRenderbuffer(t){const e=this.gl;t||(e.bindRenderbuffer(e.RENDERBUFFER,null),this._state.renderbuffer=null),this._state.renderbuffer!==t&&(e.bindRenderbuffer(e.RENDERBUFFER,t.glName),this._state.renderbuffer=t)}_getBufferBinding(t,e){if(e>=this.parameters.maxUniformBufferBindings||e<0)return x().error(`Uniform buffer binding point (${e}) is out of range (0...${this.parameters.maxUniformBufferBindings})\n `),null;const s=35345===t?this._state.uniformBufferBindingPoints:this._state.transformBufferBindingPoints;let i=s[e];return null==i&&(i={buffer:null,offset:0,size:0},s[e]=i),i}bindBufferBase(t,e,s){const i=this._getBufferBinding(t,e);null!=i&&(i.buffer===s&&0===i.offset&&0===i.size||(this.gl.bindBufferBase(t,e,s?s.glName:null),i.buffer=s,i.offset=0,i.size=0))}bindBufferRange(t,e,s,i,a){const r=this._getBufferBinding(t,e);null!=r&&(r.buffer===s&&r.offset===i&&r.size===a||(i%this._parameters.uniformBufferOffsetAlignment===0?(this.gl.bindBufferRange(t,e,s.glName,i,a),r.buffer=s,r.offset=i,r.size=a):x().error("Uniform buffer binding offset is not a multiple of the context offset alignment")))}bindUBO(t,e,s,i){null!=e?(a()&&(i??e.byteLength)>this._parameters.maxUniformBlockSize&&x().error("Attempting to bind more data than the maximum uniform block size"),e.initialize(),void 0!==s&&void 0!==i?this.bindBufferRange(35345,t,e.buffer,s,i):this.bindBufferBase(35345,t,e.buffer)):this.bindBufferBase(35345,t,null)}unbindUBO(t){for(let e=0,s=this._state.uniformBufferBindingPoints.length;e<s;e++){const s=this._state.uniformBufferBindingPoints[e];null!=s&&s.buffer===t.buffer&&this.bindBufferBase(35345,e,null)}}unbindBuffer(t){switch(t){case 34962:this._state.vertexBuffer=w(this.gl,null,t,this._state.vertexBuffer);break;case 34963:this._state.indexBuffer=w(this.gl,null,t,this._state.indexBuffer);break;case 35345:this._state.uniformBuffer=w(this.gl,null,t,this._state.uniformBuffer);break;case 35051:this._state.pixelPackBuffer=w(this.gl,null,t,this._state.pixelPackBuffer);break;case 35052:this._state.pixelUnpackBuffer=w(this.gl,null,t,this._state.pixelUnpackBuffer);break;case 36662:this._state.copyReadBuffer=w(this.gl,null,t,this._state.copyReadBuffer);break;case 36663:this._state.copyWriteBuffer=w(this.gl,null,t,this._state.copyWriteBuffer)}}bindVAO(t,e){if(null==t)return this._state.vertexArrayObject?.unbind(),void(this._state.vertexArrayObject=null);this._state.vertexArrayObject!==t&&(t.bind(e),this._state.vertexArrayObject=t)}bindTransformFeedback(t){const{gl:e}=this;e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,t.glName)}beginTransformFeedback(t,e){if(this._transformFeedbackRequestInfo)throw new Error("Already in a transform feedback request");const{gl:s}=this;s.bindTransformFeedback(s.TRANSFORM_FEEDBACK,t.glName),s.beginTransformFeedback(e),this._transformFeedbackRequestInfo={primitiveType:e}}endTransformFeedback(){if(!this._transformFeedbackRequestInfo)throw new Error("Not in a transform feedback request");const{gl:t}=this;t.endTransformFeedback(),t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null),this._transformFeedbackRequestInfo=null}async clientWaitAsync(t=i(10)){const{gl:e}=this,a=e.fenceSync(37143,0);if(!a)throw new Error("Client wait failed, could not create sync object");let r;this.instanceCounter.increment(c.Sync,a),e.flush();do{await s(t),r=e.clientWaitSync(a,0,0)}while(37147===r);if(this.instanceCounter.decrement(c.Sync,a),e.deleteSync(a),37149===r)throw new Error("Client wait failed")}getBoundFramebufferObject(t=36160){return 36008===t?this._state.readFramebuffer:this._state.drawFramebuffer}temporaryBindFramebufferObject(t,e,s=!1){const i=this.getBoundFramebufferObject();try{this.bindFramebuffer(t,s),e()}finally{this.bindFramebuffer(i,s)}}getBoundVAO(){return this._state.vertexArrayObject}resetState(){this.useProgram(null),this.bindVAO(null),this.bindFramebuffer(null,!0),this.unbindBuffer(34962),this.unbindBuffer(34963),this.unbindBuffer(35345),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(35051),this.unbindBuffer(35052),this.unbindBuffer(36662),this.unbindBuffer(36663);for(let t=0;t<this.parameters.maxTextureImageUnits;++t)this.bindTexture(null,t);this.setBlendingEnabled(!1),this.setBlendFunction(1,0),this.setBlendEquation(32774),this.setBlendColor(0,0,0,0),this.setFaceCullingEnabled(!1),this.setCullFace(1029),this.setFrontFace(2305),this.setPolygonOffsetFillEnabled(!1),this.setPolygonOffset(0,0),this.setScissorTestEnabled(!1),this.setScissorRect(0,0,this.gl.canvas.width,this.gl.canvas.height),this.setDepthTestEnabled(!1),this.setDepthFunction(513),this.setDepthRange(0,1),this.setStencilTestEnabled(!1),this.setStencilFunction(519,0,0),this.setStencilOp(7680,7680,7680),this.setClearColor(0,0,0,0),this.setClearDepth(1),this.setClearStencil(0),this.setColorMask(!0,!0,!0,!0),this.setStencilWriteMask(4294967295),this.setDepthWriteEnabled(!0),this.setViewport(0,0,this.gl.canvas.width,this.gl.canvas.height)}enforceState(){const{gl:t}=this;t.bindVertexArray(null);for(let s=0;s<this.parameters.maxVertexAttributes;s++)t.disableVertexAttribArray(s);this._state.vertexBuffer?t.bindBuffer(this._state.vertexBuffer.bufferType,this._state.vertexBuffer.glName):t.bindBuffer(34962,null),this._state.indexBuffer?t.bindBuffer(this._state.indexBuffer.bufferType,this._state.indexBuffer.glName):t.bindBuffer(34963,null),this._state.uniformBuffer?t.bindBuffer(this._state.uniformBuffer.bufferType,this._state.uniformBuffer.glName):t.bindBuffer(35345,null);for(let s=0;s<this._parameters.maxUniformBufferBindings;s++){const e=this._state.uniformBufferBindingPoints[s];if(null!=e){const{buffer:i,offset:a,size:r}=e;null!==i?0===a&&0===r?t.bindBufferBase(35345,s,i.glName):t.bindBufferRange(35345,s,i.glName,a,r):t.bindBufferBase(35345,s,null)}}if(this._state.pixelPackBuffer?t.bindBuffer(this._state.pixelPackBuffer.bufferType,this._state.pixelPackBuffer.glName):t.bindBuffer(35051,null),this._state.pixelUnpackBuffer?t.bindBuffer(this._state.pixelUnpackBuffer.bufferType,this._state.pixelUnpackBuffer.glName):t.bindBuffer(35052,null),this._state.copyReadBuffer?t.bindBuffer(this._state.copyReadBuffer.bufferType,this._state.copyReadBuffer.glName):t.bindBuffer(36662,null),this._state.copyWriteBuffer?t.bindBuffer(this._state.copyWriteBuffer.bufferType,this._state.copyWriteBuffer.glName):t.bindBuffer(36663,null),t.bindFramebuffer(36008,null),t.readBuffer(t.BACK),this._state.readFramebuffer&&(t.bindFramebuffer(36008,this._state.readFramebuffer.glName),t.readBuffer(d)),t.bindFramebuffer(36009,this._state.drawFramebuffer?.glName??null),null===this._state.drawFramebuffer){const e=this._state.drawBuffers.defaultFramebuffer;t.drawBuffers(e??[o])}else{const e=this._state.drawBuffers.fbos.get(this._state.drawFramebuffer);t.drawBuffers(e??[d])}if(this._state.vertexArrayObject){const t=this._state.vertexArrayObject;this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null),this.bindVAO(t)}t.useProgram(this._state.program?.glName??null),t.blendColor(this._state.blendColor.r,this._state.blendColor.g,this._state.blendColor.b,this._state.blendColor.a),t.bindRenderbuffer(t.RENDERBUFFER,this._state.renderbuffer?.glName??null),!0===this._state.blend?t.enable(this.gl.BLEND):t.disable(this.gl.BLEND),t.blendEquationSeparate(this._state.blendEquation.mode,this._state.blendEquation.modeAlpha),t.blendFuncSeparate(this._state.blendFunction.srcRGB,this._state.blendFunction.dstRGB,this._state.blendFunction.srcAlpha,this._state.blendFunction.dstAlpha),t.clearColor(this._state.clearColor.r,this._state.clearColor.g,this._state.clearColor.b,this._state.clearColor.a),t.clearDepth(this._state.clearDepth),t.clearStencil(this._state.clearStencil),t.colorMask(this._state.colorMask.r,this._state.colorMask.g,this._state.colorMask.b,this._state.colorMask.a),t.cullFace(this._state.cullFace),t.depthFunc(this._state.depthFunction),t.depthRange(this._state.depthRange.zNear,this._state.depthRange.zFar),!0===this._state.depthTest?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),t.depthMask(this._state.depthWrite),t.frontFace(this._state.frontFace),t.lineWidth(1),!0===this._state.faceCulling?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),t.polygonOffset(this._state.polygonOffset[0],this._state.polygonOffset[1]),!0===this._state.polygonOffsetFill?t.enable(t.POLYGON_OFFSET_FILL):t.disable(t.POLYGON_OFFSET_FILL),t.scissor(this._state.scissorRect.x,this._state.scissorRect.y,this._state.scissorRect.width,this._state.scissorRect.height),!0===this._state.scissorTest?t.enable(t.SCISSOR_TEST):t.disable(t.SCISSOR_TEST),t.stencilFunc(this._state.stencilFunction.func,this._state.stencilFunction.ref,this._state.stencilFunction.mask),t.stencilOpSeparate(this._state.stencilOperation.face,this._state.stencilOperation.fail,this._state.stencilOperation.zFail,this._state.stencilOperation.zPass),!0===this._state.stencilTest?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),t.stencilMask(this._state.stencilWriteMask);for(let s=0;s<this.parameters.maxTextureImageUnits;s++){t.activeTexture(u+s),t.bindTexture(3553,null),t.bindTexture(34067,null),t.bindTexture(32879,null),t.bindTexture(35866,null);const e=this._state.textureUnitMap[s];null!=e&&t.bindTexture(e.descriptor.target,e.glName)}t.activeTexture(u+this._state.activeTexture);const e=this._state.viewport;t.viewport(e.x,e.y,e.width,e.height),this.resetInfo()}};function w(t,e,s,i){return e?i!==e&&t.bindBuffer(s,e.glName):t.bindBuffer(s,null),e}function E(t,e){switch(t){case _.POINTS:return 2*e;case _.TRIANGLES:return e/3;case _.TRIANGLE_STRIP:case _.TRIANGLE_FAN:return e-2;default:return 0}}function C(t){return t?t.colorAttachments.length>0?t.colorAttachments:[f]:[o]}export{k as RenderingContext,C as getFramebufferDrawBuffers};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import e from"../../Graphic.js";import i from"../../core/Accessor.js";import{createTask as s}from"../../core/asyncUtils.js";import{makeHandle as o}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as n,abortMaybe as a}from"../../core/maybe.js";import{ignoreAbortErrors as r,throwIfAborted as l}from"../../core/promiseUtils.js";import{watch as h,syncAndInitial as
|
|
2
|
+
import{__decorate as t}from"tslib";import e from"../../Graphic.js";import i from"../../core/Accessor.js";import{createTask as s}from"../../core/asyncUtils.js";import{makeHandle as o}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as n,abortMaybe as a}from"../../core/maybe.js";import{ignoreAbortErrors as r,throwIfAborted as l}from"../../core/promiseUtils.js";import{watch as h,syncAndInitial as p,when as c}from"../../core/reactiveUtils.js";import{property as d,subclass as u}from"../../core/accessorSupport/decorators.js";import _ from"../../layers/GraphicsLayer.js";import m from"../../symbols/CIMSymbol.js";import v from"../../symbols/SimpleLineSymbol.js";import{ViewEventPriorities as g}from"../../views/input/InputManager.js";import{isPolyline as y}from"./support/geometryUtils.js";import f from"../Sketch/SketchViewModel.js";function b(t){return"2d"===t?new m({data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",effects:[{type:"CIMGeometricEffectDashes",dashTemplate:[5,4],lineDashEnding:"FullGap",controlPointEnding:"NoConstraint"}],enable:!0,capStyle:"Butt",joinStyle:"Round",width:1.5,color:[0,0,0,255]},{type:"CIMSolidStroke",enable:!0,capStyle:"Butt",joinStyle:"Round",width:1.5,color:[255,255,255,255]}]}}}):new v({color:[0,0,0,0]})}let I=class extends i{constructor(t){super(t),this.state="ready",this._pendingStartOptions=null,this._previousInputInfo=null,this._shouldRemoveLastPoint=!1,this._sketchedGraphics=new WeakSet,this._creationToolPromise=null,this._updateToolPromise=null,this._updateDisabled=!1}initialize(){this.addHandles(h(()=>({view:this.tool.viewModel.view,visible:this.tool.visible}),({view:t,visible:e})=>{null!=t&&e?this._attach(t):this._detach()},p),"view")}destroy(){this._detach()}get canStopCreating(){const t=this._geometry,e=this._shouldRemoveLastPoint?3:2;return y(t)&&t.paths.length>0&&t.paths[0].length>=e}get updating(){return!!this._sketchVM?.updating}get _input(){return this.tool.viewModel.input}set _input(t){this.tool.viewModel.input=t}get _geometry(){return this._input?.geometry}get _visibleAndEditable(){return this.tool.visible&&this.tool.editable}get _view(){return this.tool.viewModel.view}get test(){}start(t={mode:"sketch"}){if(!this.tool.editable)return;const e=this._view;if(null!=e&&e.ready)switch(this._pendingStartOptions=null,this._stopInteraction(),null==this._previousInputInfo&&this._storePreviousInput(this._input),this._setSketchedGraphic(null),t.mode){case"sketch":this._set("state","creating"),this._startCreationInteraction();break;case"select":this._set("state","selecting"),this._startSelectionInteraction()}else this._pendingStartOptions=t}stop(){this._pendingStartOptions=null,this._stopInteractionAndUpdate(),this._clearPreviousInput()}cancel(){this._pendingStartOptions=null,this._stopInteractionAndUpdate(),this._restorePreviousInput()}clear(){this._stopInteractionAndUpdate(),this._set("state","ready"),this._clearPreviousInput(),this._input=null,this._pendingStartOptions=null}isSketchedGraphic(t){return null!=t&&this._sketchedGraphics.has(t)}_attach(t){this._detach();const e={mode:"3d"===t.type?"relative-to-ground":"on-the-ground",offset:null};this._graphicsLayer=new _({listMode:"hide",internal:!0,elevationInfo:e,title:"Elevation info"});const i=b(t.type);this._sketchVM=new f({layer:this._graphicsLayer,view:t,defaultCreateOptions:{mode:"click",hasZ:!1},updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{shapeOperation:"none"},enableRotation:!1,enableScaling:!1,enableMoveAllGraphics:!1,enableZ:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"reshape"},polylineSymbol:i,activeLineSymbol:i}),this.addHandles([c(()=>t.ready,()=>{const t=this._pendingStartOptions;t&&this.start(t)},p),h(()=>[this._input,this._visibleAndEditable],()=>this._update(),p),h(()=>({map:t.map,graphicsLayer:this._graphicsLayer}),({map:t,graphicsLayer:e})=>{null!=t&&null!=e&&t.add(e),this._update()},p)],"main")}_detach(){this.removeHandles("main"),this._sketchVM=n(this._sketchVM),this._creationToolPromise=null,this._updateToolPromise=null;const t=this._view?.map,e=this._graphicsLayer;null!=t&&null!=e&&t.remove(e),this._graphicsLayer=n(this._graphicsLayer),this._shouldRemoveLastPoint=!1,this._set("state","ready")}_startCreationInteraction(){this._stopInteractionAndUpdate();const t=this._view,i=this._sketchVM;if(null==t||null==i)return;this._shouldRemoveLastPoint=!1;const s=i.on("create",t=>{const e=t.graphic;switch(t.state){case"complete":this._shouldRemoveLastPoint=!1,this._setSketchedGraphic(e),this._stopInteractionAndUpdate(),this._clearPreviousInput();break;case"cancel":this.cancel();break;case"active":this._setSketchedGraphic(e),"cursor-update"===t.toolEventInfo?.type&&(this._shouldRemoveLastPoint=!0);break;case"start":this._setSketchedGraphic(e)}}),n=()=>{s.remove();const t=this.canStopCreating,o=this._geometry?.clone();i.cancel(),this._creationToolPromise=null,null!=o&&t?this._shouldRemoveLastPoint&&this._setSketchedGraphic(new e({geometry:S(o)})):this._input=null};this.removeHandles("interaction"),this.addHandles(o(n),"interaction"),this._creationToolPromise=r(i.create("polyline"))}_startReshapeInteraction(){this._stopInteraction();const t=this._view,e=this._sketchVM;if(null==t||null==e)return;const i=e.on("update",t=>{const e=t.graphics[0];switch(t.state){case"complete":this._setSketchedGraphic(e),this._stopInteractionAndUpdate(),this._clearPreviousInput();break;case"active":case"start":this._setSketchedGraphic(e)}}),s=()=>{i.remove(),e.cancel(),this._updateToolPromise=null};this.removeHandles("interaction"),this.addHandles(o(s),"interaction");const n=this._input;n&&(n.visible=!0,this._updateToolPromise=r(e.update(n,{tool:"reshape"})))}_startSelectionInteraction(){this._stopInteraction();const t=this._view;if(null==t)return;const e=t.acquireCursor("crosshair","high");t.closePopup();let i=null;const n=o(()=>a(i)),r=t.on("immediate-click",e=>{e.defer(async()=>{a(i),i=s(async i=>{const{results:s}=await t.hitTest(e);l(i);const o=s.filter(t=>"graphic"===t.type).map(t=>t.graphic).find(t=>null!=t.geometry&&"polyline"===t.geometry.type);o&&(e.preventDefault(),e.stopPropagation(),this._input=o,this._clearPreviousInput(),this._stopInteractionAndUpdate())}),await i.promise})},g.TOOL),h=t.on("key-down",t=>{"Escape"===t.key&&this.cancel()});this.removeHandles("interaction"),this.addHandles([r,h,n,e],"interaction"),t.ready&&t.focus()}_stopInteraction(){this.removeHandles("interaction")}_stopInteractionAndUpdate(){this.hasHandles("interaction")&&(this._updateDisabled=!0,this._stopInteraction(),this._updateDisabled=!1,this._triggerUpdate())}_triggerUpdate(){this._set("state","ready"),this._update()}_update(){if(this._updateDisabled)return;const t=this.state;if("selecting"!==t){if(this._visibleAndEditable){if("creating"===t||"reshaping"===t&&this.isSketchedGraphic(this._input))return}else this.cancel();this._set("state",this._getNextState()),this._updateVisuals()}else this.stop()}_getNextState(){return null==this._input?"ready":this.isSketchedGraphic(this._input)?"creating"===this.state?"creating":this._visibleAndEditable?"reshaping":"reshaping-disabled":"selected"}_updateVisuals(){switch(this.state){case"creating":break;case"reshaping":this._startReshapeInteraction();break;case"reshaping-disabled":{this._stopInteractionAndUpdate();const t=this._input;null!=t&&this.isSketchedGraphic(t)&&(t.visible=!1);break}case"ready":case"selected":this._stopInteractionAndUpdate()}this._updateSketchedGraphic()}_storePreviousInput(t){this._previousInputInfo={graphic:t}}_restorePreviousInput(){const t=this._previousInputInfo;null!=t&&(this._clearPreviousInput(),this._input=t.graphic,this._triggerUpdate())}_clearPreviousInput(){this._previousInputInfo=null}_updateSketchedGraphic(){const t=this._graphicsLayer;if(null==t)return;const e=t.graphics,i=this._input;if(null==i||!this.isSketchedGraphic(i))return void e.removeAll();if(-1===e.indexOf(i))e.removeAll(),e.add(i);else if(1!==e.length){const t=e.filter(t=>t!==i);e.removeMany(t)}}_setSketchedGraphic(t){null!=t&&this._sketchedGraphics.add(t),this._input=t,this._updateSketchedGraphic()}};function S(t){if(y(t)){const e=t.clone();return e.paths=[e.paths[0].slice(0,-1)],e}return t}t([d({nonNullable:!0})],I.prototype,"state",void 0),t([d({nonNullable:!0})],I.prototype,"tool",void 0),t([d()],I.prototype,"canStopCreating",null),t([d()],I.prototype,"updating",null),t([d()],I.prototype,"_graphicsLayer",void 0),t([d()],I.prototype,"_sketchVM",void 0),t([d()],I.prototype,"_input",null),t([d()],I.prototype,"_geometry",null),t([d()],I.prototype,"_visibleAndEditable",null),t([d()],I.prototype,"_view",null),t([d()],I.prototype,"_shouldRemoveLastPoint",void 0),I=t([u("esri.widgets.ElevationProfile.ElevationProfileInteraction")],I);export{I as ElevationProfileInteraction};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import e from"../../Graphic.js";import i from"../../core/Accessor.js";import{isSome as r,min as o}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import{referenceSetter as l}from"../../core/collectionUtils.js";import{deprecateUnnecessaryViewModel as n}from"../../core/deprecate.js";import a from"../../core/Logger.js";import{LRUCache as u}from"../../core/LRUCache.js";import{destroyMaybe as p}from"../../core/maybe.js";import{memoize as h}from"../../core/memoize.js";import{watch as c,syncAndInitial as d}from"../../core/reactiveUtils.js";import{adaptiveLengthUnit as f,adaptiveVerticalLengthUnit as m,measurementLengthUnits as v}from"../../core/units.js";import{property as g,subclass as y}from"../../core/accessorSupport/decorators.js";import{ElevationQueryTileCache as b}from"../../layers/support/ElevationQueryTileCache.js";import{defaultUnitPropertyMetadata as _}from"../../properties/defaultUnit.js";import{ElevationProfileController as U}from"./ElevationProfileController.js";import P from"./ElevationProfileLineGround.js";import{ElevationProfileLineCollection as w}from"./elevationProfileLineTypes.js";import{ElevationProfileTool as j}from"./ElevationProfileTool.js";import{isPolyline as O,isValidInputPath as C}from"./support/geometryUtils.js";import{isProfileGenerationError as E}from"./support/ProfileGenerationError.js";import{createProfileQueue as S}from"./support/profileUtils.js";import{getBoundsInMeters as T,mergeStatistics as D}from"./support/statisticsUtils.js";let L=class extends i{constructor(t){super(t),this.view=null,this.input=null,this._getEffectiveUnitsMemoized=h((t,e)=>({distance:t,elevation:e})),this.hoveredChartPosition=null,this.uniformChartScaling=!1,this.defaultUnit=null,this.queue=null,this._currentTileCache=null,this.error=null,this._defaultProfileLineGround=new P({isDefaultLine:!0}),this._userUnitOptions=null,this._userUnit=null,t?.suppressDeprecationWarning||n(a.getLogger(this),"Elevation Profile","arcgis-elevation-profile",{version:"5.0"}),t?.profiles||(this.profiles=new s([this._defaultProfileLineGround]))}normalizeCtorArgs(t){const{suppressDeprecationWarning:e,...i}=t??{};return i}initialize(){this.addHandles(c(()=>this.view,t=>{if(null==t)return void a.getLogger(this).warnOnce("no view. Widget will be disabled until a view is provided.");this.removeHandles(G);const e="3d"===t.type?t.resourceController:void 0;this.queue?.destroy(),this.queue=S(e?.scheduler);const i=e?.addUpdatingObject(this);i&&this.addHandles(i,G)},d)),this.tool=new j({viewModel:this}),this._controller=new U({viewModel:this})}destroy(){this._defaultProfileLineGround=p(this._defaultProfileLineGround),this._controller=p(this._controller),this._currentTileCache=p(this._currentTileCache),this.tool=p(this.tool),this.queue=p(this.queue)}get profiles(){return this._get("profiles")}set profiles(t){const e=this._get("profiles"),i=t??new s;this._set("profiles",l(i,e))}get state(){const t=this.view;return null!=t&&t.ready?this.tool.state:"disabled"}get progress(){let t=0,e=0;for(const i of this.visibleProfiles)t++,e+=i.progress;return t>0?e/t:0}set unitOptions(t){this._userUnitOptions=t,this._set("unitOptions",this._filteredOrAllUnits(this._userUnitOptions))}get unitOptions(){return this._filteredOrAllUnits(this._userUnitOptions)}set unit(t){this._userUnit=t?this._findSelectableUnit(t,this._userUnit):null,this.notifyChange("unit")}get unit(){return this._userUnit?(this._userUnit=this._findSelectableUnit(this._userUnit,this.defaultUnit),this._userUnit):this._findSelectableUnit(this.defaultUnit)}get effectiveUnits(){const t=T(this.visibleProfiles.map(t=>t.result)),e=f(t.maxDistance,"meters",this.unit),i=m(t.maxElevation,"meters",this.unit);return this._getEffectiveUnitsMemoized(e,i)}get highlightEnabled(){return this.tool.highlightEnabled}set highlightEnabled(t){this.tool.highlightEnabled=t}get hasVertices(){const t=this.input?.geometry;return O(t)&&t.paths.reduce((t,e)=>t+e.length,0)>0}get hoveredPoints(){return null!=this.input&&this.visible&&this.tool.editable?this.visibleProfiles.map(t=>{const e=t.hoveredPoint;return null!=e?{hoveredPoint:e,color:t.color}:null}).filter(r):[]}get statistics(){return D(this.visibleProfiles.map(t=>t.statistics))}get chartData(){if(null==this.input)return null;const{effectiveUnits:t,progress:e,statistics:i,visibleProfiles:r,uniformChartScaling:o}=this,s=r.filter(t=>t.hasZ).map(t=>({id:t.id,type:t.type,title:t.title,color:t.color,samples:t.samples,progress:t.progress,chartFillEnabled:t.chartFillEnabled,chartStrokeWidth:t.chartStrokeWidth,chartStrokeOffsetY:t.chartStrokeOffsetY,viewVisualizationEnabled:t.viewVisualizationEnabled}));return 0===s.length?null:{lines:s,effectiveUnits:t,statistics:i,refined:1===e,dynamicElevationRange:r.some(t=>"view"===t.type),uniformScaling:o}}get visibleProfiles(){return this.profiles.toArray().filter(t=>t.available&&t.visible)}get minDemResolutions(){const t=[];for(const{minDemResolution:e}of this.visibleProfiles)null!=e&&t.push(e);return t}get minDemResolution(){return o(this.minDemResolutions)}get errorState(){const t=this.input?.geometry;if(!C(t))return"no-valid-input";if(null!=this.error){if(E(this.error))switch(this.error.cause){case"too-complex":return"too-complex";case"invalid-geometry":return"invalid-geometry";case"invalid-elevation-info":return"invalid-elevation-info";case"elevation-query-error":return"no-valid-input"}return"unknown-error"}return 0===this.visibleProfiles.length?"no-visible-profiles":null==this.chartData&&1===this.progress?"refined-but-no-chart-data":"none"}get tileCache(){this._currentTileCache=p(this._currentTileCache);const t=this.view;if(null!=t&&"3d"===t?.type){const e=t.basemapTerrain?.elevationQueryCache;if(null!=e)return e}return null==this._currentTileCache&&(this._currentTileCache=new b(new u(20971520))),this._currentTileCache}get visible(){return this.tool.visible}set visible(t){this.tool.visible=t}get selectAvailable(){for(const t of this.view?.map?.allLayers??[]){if("graphics"===t.type&&!t.internal&&t.graphics.some(t=>"polyline"===t.geometry?.type))return!0;if("geometryType"in t&&"polyline"===t.geometryType)return!0}return!!this.view?.graphics?.some(t=>"polyline"===t.geometry?.type)}get inputIsSketched(){return this.tool.interaction.isSketchedGraphic(this.input)}get elevationProvider(){const t=this.view;return null!=t&&"3d"===t.type?t.elevationProvider:null}get updating(){const{progress:t}=this,e=!!this.queue?.updating;return t>0&&t<1||e}start(t){this.tool.interaction.start(t)}stop(){this.tool.interaction.stop()}cancel(){this.tool.interaction.cancel()}clear(){this.tool.interaction.clear()}_findSelectableUnit(t,e){const i=this.unitOptions;return null!=t&&i.includes(t)?t:e?this._findSelectableUnit(e):i[0]}_filteredOrAllUnits(t){const e=(null!=t?t:[]).filter(t=>v.includes(t));return 0===e.length?v.slice():e}};t([g()],L.prototype,"view",void 0),t([g({type:e})],L.prototype,"input",void 0),t([g({type:w,nonNullable:!0})],L.prototype,"profiles",null),t([g({readOnly:!0})],L.prototype,"state",null),t([g({readOnly:!0})],L.prototype,"progress",null),t([g()],L.prototype,"unitOptions",null),t([g()],L.prototype,"unit",null),t([g({readOnly:!0})],L.prototype,"effectiveUnits",null),t([g()],L.prototype,"hoveredChartPosition",void 0),t([g()],L.prototype,"uniformChartScaling",void 0),t([g()],L.prototype,"highlightEnabled",null),t([g({readOnly:!0})],L.prototype,"hoveredPoints",null),t([g({readOnly:!0})],L.prototype,"statistics",null),t([g()],L.prototype,"chartData",null),t([g()],L.prototype,"visibleProfiles",null),t([g()],L.prototype,"minDemResolutions",null),t([g({readOnly:!0})],L.prototype,"minDemResolution",null),t([g({readOnly:!0})],L.prototype,"errorState",null),t([g(_)],L.prototype,"defaultUnit",void 0),t([g()],L.prototype,"queue",void 0),t([g()],L.prototype,"tileCache",null),t([g()],L.prototype,"tool",void 0),t([g()],L.prototype,"visible",null),t([g()],L.prototype,"error",void 0),t([g()],L.prototype,"selectAvailable",null),t([g()],L.prototype,"inputIsSketched",null),t([g()],L.prototype,"elevationProvider",null),t([g()],L.prototype,"updating",null),t([g()],L.prototype,"_defaultProfileLineGround",void 0),t([g()],L.prototype,"_userUnitOptions",void 0),t([g()],L.prototype,"_controller",void 0),t([g()],L.prototype,"_userUnit",void 0),L=t([y("esri.widgets.ElevationProfile.ElevationProfileViewModel")],L);const G=Symbol("updating-object"),k=L;export{k as default};
|
|
2
|
+
import{__decorate as t}from"tslib";import e from"../../Graphic.js";import i from"../../core/Accessor.js";import{isSome as r,min as o}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import{referenceSetter as l}from"../../core/collectionUtils.js";import{deprecateUnnecessaryViewModel as n}from"../../core/deprecate.js";import a from"../../core/Logger.js";import{LRUCache as u}from"../../core/LRUCache.js";import{destroyMaybe as p}from"../../core/maybe.js";import{memoize as h}from"../../core/memoize.js";import{watch as c,syncAndInitial as d}from"../../core/reactiveUtils.js";import{adaptiveLengthUnit as f,adaptiveVerticalLengthUnit as m,measurementLengthUnits as v}from"../../core/units.js";import{property as g,subclass as y}from"../../core/accessorSupport/decorators.js";import{ElevationQueryTileCache as b}from"../../layers/support/ElevationQueryTileCache.js";import{defaultUnitPropertyMetadata as _}from"../../properties/defaultUnit.js";import{ElevationProfileController as U}from"./ElevationProfileController.js";import P from"./ElevationProfileLineGround.js";import{ElevationProfileLineCollection as w}from"./elevationProfileLineTypes.js";import{ElevationProfileTool as j}from"./ElevationProfileTool.js";import{isPolyline as O,isValidInputPath as C}from"./support/geometryUtils.js";import{isProfileGenerationError as E}from"./support/ProfileGenerationError.js";import{createProfileQueue as S}from"./support/profileUtils.js";import{getBoundsInMeters as T,mergeStatistics as D}from"./support/statisticsUtils.js";let L=class extends i{constructor(t){super(t),this.view=null,this.input=null,this._getEffectiveUnitsMemoized=h((t,e)=>({distance:t,elevation:e})),this.hoveredChartPosition=null,this.uniformChartScaling=!1,this.defaultUnit=null,this.queue=null,this._currentTileCache=null,this.error=null,this._defaultProfileLineGround=new P({isDefaultLine:!0}),this._userUnitOptions=null,this._userUnit=null,t?.suppressDeprecationWarning||n(a.getLogger(this),"Elevation Profile","arcgis-elevation-profile",{version:"5.0"}),t?.profiles||(this.profiles=new s([this._defaultProfileLineGround]))}normalizeCtorArgs(t){const{suppressDeprecationWarning:e,...i}=t??{};return i}initialize(){this.addHandles(c(()=>this.view,t=>{if(null==t)return void a.getLogger(this).warnOnce("no view. Widget will be disabled until a view is provided.");this.removeHandles(G);const e="3d"===t.type?t.resourceController:void 0;this.queue?.destroy(),this.queue=S(e?.scheduler);const i=e?.addUpdatingObject(this);i&&this.addHandles(i,G)},d)),this.tool=new j({viewModel:this}),this._controller=new U({viewModel:this})}destroy(){this._defaultProfileLineGround=p(this._defaultProfileLineGround),this._controller=p(this._controller),this._currentTileCache=p(this._currentTileCache),this.tool=p(this.tool),this.queue=p(this.queue)}get profiles(){return this._get("profiles")}set profiles(t){const e=this._get("profiles"),i=t??new s;this._set("profiles",l(i,e))}get state(){const t=this.view;return null!=t&&t.ready?this.tool.state:"disabled"}get progress(){let t=0,e=0;for(const i of this.visibleProfiles)t++,e+=i.progress;return t>0?e/t:0}set unitOptions(t){this._userUnitOptions=t,this._set("unitOptions",this._filteredOrAllUnits(this._userUnitOptions))}get unitOptions(){return this._filteredOrAllUnits(this._userUnitOptions)}set unit(t){this._userUnit=t?this._findSelectableUnit(t,this._userUnit):null,this.notifyChange("unit")}get unit(){return this._userUnit?(this._userUnit=this._findSelectableUnit(this._userUnit,this.defaultUnit),this._userUnit):this._findSelectableUnit(this.defaultUnit)}get effectiveUnits(){const t=T(this.visibleProfiles.map(t=>t.result)),e=f(t.maxDistance,"meters",this.unit),i=m(t.maxElevation,"meters",this.unit);return this._getEffectiveUnitsMemoized(e,i)}get highlightEnabled(){return this.tool.highlightEnabled}set highlightEnabled(t){this.tool.highlightEnabled=t}get hasVertices(){const t=this.input?.geometry;return O(t)&&t.paths.reduce((t,e)=>t+e.length,0)>0}get hoveredPoints(){return null!=this.input&&this.visible&&this.tool.editable?this.visibleProfiles.map(t=>{const e=t.hoveredPoint;return null!=e?{hoveredPoint:e,color:t.color}:null}).filter(r):[]}get statistics(){return D(this.visibleProfiles.map(t=>t.statistics))}get chartData(){if(null==this.input)return null;const{effectiveUnits:t,progress:e,statistics:i,visibleProfiles:r,uniformChartScaling:o}=this,s=r.filter(t=>t.hasZ).map(t=>({id:t.id,type:t.type,title:t.title,color:t.color,samples:t.samples,progress:t.progress,chartFillEnabled:t.chartFillEnabled,chartStrokeWidth:t.chartStrokeWidth,chartStrokeOffsetY:t.chartStrokeOffsetY,viewVisualizationEnabled:t.viewVisualizationEnabled}));return 0===s.length?null:{lines:s,effectiveUnits:t,statistics:i,refined:1===e,dynamicElevationRange:r.some(t=>"view"===t.type),uniformScaling:o}}get visibleProfiles(){return this.profiles.toArray().filter(t=>t.available&&t.visible)}get minDemResolutions(){const t=[];for(const{minDemResolution:e}of this.visibleProfiles)null!=e&&t.push(e);return t}get minDemResolution(){return o(this.minDemResolutions)}get errorState(){const t=this.input?.geometry;if(!C(t))return"no-valid-input";if(null!=this.error){if(E(this.error))switch(this.error.cause){case"too-complex":return"too-complex";case"invalid-geometry":return"invalid-geometry";case"invalid-elevation-info":return"invalid-elevation-info";case"elevation-query-error":return"no-valid-input"}return"unknown-error"}return 0===this.visibleProfiles.length?"no-visible-profiles":null==this.chartData&&1===this.progress?"refined-but-no-chart-data":"none"}get tileCache(){this._currentTileCache=p(this._currentTileCache);const t=this.view;if(null!=t&&"3d"===t?.type){const e=t.basemapTerrain?.elevationQueryCache;if(null!=e)return e}return null==this._currentTileCache&&(this._currentTileCache=new b(new u(20971520))),this._currentTileCache}get visible(){return this.tool.visible}set visible(t){this.tool.visible=t}get selectAvailable(){for(const t of this.view?.map?.allLayers??[]){if("graphics"===t.type&&!t.internal&&t.graphics.some(t=>"polyline"===t.geometry?.type))return!0;if("geometryType"in t&&"polyline"===t.geometryType)return!0}return!!this.view?.graphics?.some(t=>"polyline"===t.geometry?.type)}get inputIsSketched(){return this.tool.interaction.isSketchedGraphic(this.input)}get elevationProvider(){const t=this.view;return null!=t&&"3d"===t.type?t.elevationProvider:null}get updating(){const{progress:t}=this,e=!!this.queue?.updating;return t>0&&t<1||e||this.tool.interaction.updating}start(t){this.tool.interaction.start(t)}stop(){this.tool.interaction.stop()}cancel(){this.tool.interaction.cancel()}clear(){this.tool.interaction.clear()}_findSelectableUnit(t,e){const i=this.unitOptions;return null!=t&&i.includes(t)?t:e?this._findSelectableUnit(e):i[0]}_filteredOrAllUnits(t){const e=(null!=t?t:[]).filter(t=>v.includes(t));return 0===e.length?v.slice():e}};t([g()],L.prototype,"view",void 0),t([g({type:e})],L.prototype,"input",void 0),t([g({type:w,nonNullable:!0})],L.prototype,"profiles",null),t([g({readOnly:!0})],L.prototype,"state",null),t([g({readOnly:!0})],L.prototype,"progress",null),t([g()],L.prototype,"unitOptions",null),t([g()],L.prototype,"unit",null),t([g({readOnly:!0})],L.prototype,"effectiveUnits",null),t([g()],L.prototype,"hoveredChartPosition",void 0),t([g()],L.prototype,"uniformChartScaling",void 0),t([g()],L.prototype,"highlightEnabled",null),t([g({readOnly:!0})],L.prototype,"hoveredPoints",null),t([g({readOnly:!0})],L.prototype,"statistics",null),t([g()],L.prototype,"chartData",null),t([g()],L.prototype,"visibleProfiles",null),t([g()],L.prototype,"minDemResolutions",null),t([g({readOnly:!0})],L.prototype,"minDemResolution",null),t([g({readOnly:!0})],L.prototype,"errorState",null),t([g(_)],L.prototype,"defaultUnit",void 0),t([g()],L.prototype,"queue",void 0),t([g()],L.prototype,"tileCache",null),t([g()],L.prototype,"tool",void 0),t([g()],L.prototype,"visible",null),t([g()],L.prototype,"error",void 0),t([g()],L.prototype,"selectAvailable",null),t([g()],L.prototype,"inputIsSketched",null),t([g()],L.prototype,"elevationProvider",null),t([g()],L.prototype,"updating",null),t([g()],L.prototype,"_defaultProfileLineGround",void 0),t([g()],L.prototype,"_userUnitOptions",void 0),t([g()],L.prototype,"_controller",void 0),t([g()],L.prototype,"_userUnit",void 0),L=t([y("esri.widgets.ElevationProfile.ElevationProfileViewModel")],L);const G=Symbol("updating-object"),k=L;export{k as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import e from"../../../geometry/Point.js";import n from"../../../geometry/SpatialReference.js";import{convertPixelLocationToSphereVertex as t,convertSphereVertexToPixelLocation as r}from"../../../layers/orientedImagery/transformations/utils.js";function
|
|
2
|
+
import e from"../../../geometry/Point.js";import n from"../../../geometry/SpatialReference.js";import{convertPixelLocationToSphereVertex as t,convertSphereVertexToPixelLocation as r}from"../../../layers/orientedImagery/transformations/utils.js";function a(r,a,o){const[i,s]=a;return new e(t(r,i,s,o),n.WebMercator)}function o(e){return{x:e.x-.5,y:.5-e.y}}function i(t){return new e({...o(t),spatialReference:n.WebMercator})}function s(e,n,t,r){switch(n){case"default":return i(e);case"panoramic":return a(e,t,r);default:throw new Error(`Unsupported image mode: ${n}`)}}function c(e){return{x:e.x+.5,y:.5-e.y}}function p(e,n,t){const[a,o]=n;return r({x:e.x,y:e.y,z:e.z},a,o,t)}function m(e,n,t,r){return"panoramic"===n?p(e,t,r):c(e)}function u(e){if(e&&"hasZ"in e&&e.hasZ)switch(e.type){case"point":e.z=void 0,e.hasZ=!1;break;case"polyline":e.paths=e.paths.map(e=>e.map(e=>3===e.length?[e[0],e[1]]:e)),e.hasZ=!1;break;case"polygon":e.rings=e.rings.map(e=>e.map(e=>3===e.length?[e[0],e[1]]:e)),e.hasZ=!1;break;case"multipoint":e.points=e.points.map(e=>3===e.length?[e[0],e[1]]:e),e.hasZ=!1;break;case"extent":e.zmax=void 0,e.zmin=void 0}}export{i as imageSpaceTo2DPoint,a as imageSpaceTo3DPoint,s as imageSpaceToPoint,o as pixelTo2D,m as pointToImageSpace,u as removeZFromGeometry,c as toImageSpace,p as toImageSpace3D};
|