@arcgis/core 4.28.0-next.20230713 → 4.28.0-next.20230715
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/Basemap.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{0b28b5eec6dc67be8ce9.js → 0121bfc81b794745e024.js} +1 -1
- package/assets/esri/core/workers/chunks/067d3d45caeaaba18d81.js +1 -0
- package/assets/esri/core/workers/chunks/080a13dc08a8db498ffa.js +1 -0
- package/assets/esri/core/workers/chunks/0dccbc6c2559fdc0c2ad.js +1 -0
- package/assets/esri/core/workers/chunks/{c912466351e37db68b6c.js → 14ab33573bb02d6c6b1a.js} +1 -1
- package/assets/esri/core/workers/chunks/{c4b066760e9aa85b7607.js → 1b948f8429d8f9b1bbfb.js} +1 -1
- package/assets/esri/core/workers/chunks/204ed2ebd2d3da659791.js +1 -0
- package/assets/esri/core/workers/chunks/{5d5d4a4fdf5ca8d7837f.js → 239d4176ff2d5142b7f1.js} +1 -1
- package/assets/esri/core/workers/chunks/23bb98aaa20b180ee680.js +1 -0
- package/assets/esri/core/workers/chunks/27cf3ef9566d5226b0df.js +1 -0
- package/assets/esri/core/workers/chunks/{1c86f80d73dee1a4d9b7.js → 2f1695e4807a534e1743.js} +1 -1
- package/assets/esri/core/workers/chunks/{60b422009f58d7bbb8c4.js → 3164b862a6b3f654fade.js} +1 -1
- package/assets/esri/core/workers/chunks/35f60625ada14eb801fd.js +1 -0
- package/assets/esri/core/workers/chunks/{4e4e62462deec25e82ce.js → 3a04bf1cdce263fe2191.js} +1 -1
- package/assets/esri/core/workers/chunks/41011207b6cc5eb6232f.js +1 -0
- package/assets/esri/core/workers/chunks/{8d50449c029c73136204.js → 432e3558db53574d21b4.js} +1 -1
- package/assets/esri/core/workers/chunks/4767f69b81d36dde9550.js +1 -0
- package/assets/esri/core/workers/chunks/{08ee2bd914867fd2cbd5.js → 490629c6f9fee501c9cd.js} +1 -1
- package/assets/esri/core/workers/chunks/{044b15794b6403792f04.js → 4f079d0e69189c1d8bd9.js} +1 -1
- package/assets/esri/core/workers/chunks/4f1f4cc82fea0d1f79ec.js +1 -0
- package/assets/esri/core/workers/chunks/503a393327df755d8843.js +1 -0
- package/assets/esri/core/workers/chunks/50e05f479c7d414fc06b.js +1 -0
- package/assets/esri/core/workers/chunks/{3835a76c017431f19422.js → 51da3c5c50b153ce6bc7.js} +1 -1
- package/assets/esri/core/workers/chunks/54b97ca5f2164b941f5b.js +1 -0
- package/assets/esri/core/workers/chunks/5a3fb63dab89cf3418f7.js +1 -0
- package/assets/esri/core/workers/chunks/5ceaf1f05b219034a10c.js +1 -0
- package/assets/esri/core/workers/chunks/70aabffaaa0a1da8e609.js +1 -0
- package/assets/esri/core/workers/chunks/78cb95d1594a0cb0dd7a.js +1 -0
- package/assets/esri/core/workers/chunks/7f391ae5e0ea7812baca.js +1 -0
- package/assets/esri/core/workers/chunks/{1d2b8b937bbda91a6549.js → 82dfbc175b52c7a10475.js} +1 -1
- package/assets/esri/core/workers/chunks/{036cd65514eab1749363.js → 8467d05626a3a72462c9.js} +1 -1
- package/assets/esri/core/workers/chunks/9038b1317f1252e31f09.js +1 -0
- package/assets/esri/core/workers/chunks/929ddc4d9975ed893767.js +1 -0
- package/assets/esri/core/workers/chunks/{e86dcc239c6a57000afc.js → 94633cc9cfb089ef010e.js} +1 -1
- package/assets/esri/core/workers/chunks/{2f5f398374ff77fb17f0.js → 975eef6d20c17a0ed07b.js} +1 -1
- package/assets/esri/core/workers/chunks/{8913bddc76b82cb24664.js → 98cf4e744e8f2c3fc536.js} +1 -1
- package/assets/esri/core/workers/chunks/a00414550fa21c5662f3.js +1 -0
- package/assets/esri/core/workers/chunks/a3a1d4f32e518e97d071.js +1 -0
- package/assets/esri/core/workers/chunks/{4e2029c8cc8a5afe5759.js → a5348f117dacdcae99ee.js} +1 -1
- package/assets/esri/core/workers/chunks/b0f0a3178d88fa600a11.js +1 -0
- package/assets/esri/core/workers/chunks/b4446ce010bc4a5aa917.js +1 -0
- package/assets/esri/core/workers/chunks/b8a45b28a915a423d09d.js +1 -0
- package/assets/esri/core/workers/chunks/{fb97d39b25b0b009d2f0.js → bd9e6f38c9ec4195322a.js} +1 -1
- package/assets/esri/core/workers/chunks/{30deb5a8e9a82186991d.js → c15c4bd52d4472ed50bc.js} +1 -1
- package/assets/esri/core/workers/chunks/{55109f141c9f120833f6.js → c3d773c93efb41088c54.js} +1 -1
- package/assets/esri/core/workers/chunks/c518410b1214ffc58017.js +1 -0
- package/assets/esri/core/workers/chunks/d55faafe2ac914a3ebd1.js +1 -0
- package/assets/esri/core/workers/chunks/d5fd4780d57173f3e303.js +1 -0
- package/assets/esri/core/workers/chunks/da01e520a1ae0048e73e.js +1 -0
- package/assets/esri/core/workers/chunks/dd7603c9e5fd178c88f7.js +1 -0
- package/assets/esri/core/workers/chunks/ddcf58937924ab5a3d76.js +1 -0
- package/assets/esri/core/workers/chunks/e03a0f52d438f53a3057.js +1 -0
- package/assets/esri/core/workers/chunks/e433440fecd0114cb23d.js +1 -0
- package/assets/esri/core/workers/chunks/ea1560129e426980a4e2.js +1 -0
- package/assets/esri/core/workers/chunks/f73e2143f8d053aef092.js +1 -0
- package/assets/esri/core/workers/chunks/{0a0af540f4fe64c3d292.js → fa14238f1c308a74f843.js} +1 -1
- package/assets/esri/themes/base/widgets/_ElevationProfile.scss +3 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/RibbonLine.glsl.js +57 -72
- package/chunks/ar.js +1 -1
- package/chunks/ar2.js +1 -1
- package/chunks/bg_BG.js +1 -1
- package/chunks/bg_BG2.js +1 -1
- package/chunks/bs_BA.js +1 -1
- package/chunks/bs_BA2.js +1 -1
- package/chunks/ca_ES.js +1 -1
- package/chunks/ca_ES2.js +1 -1
- package/chunks/chartUtilsAm5.js +1 -1
- package/chunks/cs_CZ.js +1 -1
- package/chunks/cs_CZ2.js +1 -1
- package/chunks/da_DK.js +1 -1
- package/chunks/da_DK2.js +1 -1
- package/chunks/de_CH.js +1 -1
- package/chunks/de_CH2.js +1 -1
- package/chunks/de_DE.js +1 -1
- package/chunks/de_DE2.js +1 -1
- package/chunks/el_GR.js +1 -1
- package/chunks/el_GR2.js +1 -1
- package/chunks/en_CA.js +1 -1
- package/chunks/en_CA2.js +1 -1
- package/chunks/en_US.js +1 -1
- package/chunks/en_US2.js +1 -1
- package/chunks/es_ES.js +1 -1
- package/chunks/es_ES2.js +1 -1
- package/chunks/et_EE.js +1 -1
- package/chunks/et_EE2.js +1 -1
- package/chunks/fi_FI.js +1 -1
- package/chunks/fi_FI2.js +1 -1
- package/chunks/fr_FR.js +1 -1
- package/chunks/fr_FR2.js +1 -1
- package/chunks/he_IL.js +1 -1
- package/chunks/he_IL2.js +1 -1
- package/chunks/hr_HR.js +1 -1
- package/chunks/hr_HR2.js +1 -1
- package/chunks/hu_HU.js +1 -1
- package/chunks/hu_HU2.js +1 -1
- package/chunks/id_ID.js +1 -1
- package/chunks/id_ID2.js +1 -1
- package/chunks/it_IT.js +1 -1
- package/chunks/it_IT2.js +1 -1
- package/chunks/ja_JP.js +1 -1
- package/chunks/ja_JP2.js +1 -1
- package/chunks/ko_KR.js +1 -1
- package/chunks/ko_KR2.js +1 -1
- package/chunks/lt_LT.js +1 -1
- package/chunks/lt_LT2.js +1 -1
- package/chunks/lv_LV.js +1 -1
- package/chunks/lv_LV2.js +1 -1
- package/chunks/nb_NO.js +1 -1
- package/chunks/nb_NO2.js +1 -1
- package/chunks/nl_NL.js +1 -1
- package/chunks/nl_NL2.js +1 -1
- package/chunks/pl_PL.js +1 -1
- package/chunks/pl_PL2.js +1 -1
- package/chunks/pt_BR.js +1 -1
- package/chunks/pt_BR2.js +1 -1
- package/chunks/pt_PT.js +1 -1
- package/chunks/pt_PT2.js +1 -1
- package/chunks/ro_RO.js +1 -1
- package/chunks/ro_RO2.js +1 -1
- package/chunks/ru_RU.js +1 -1
- package/chunks/ru_RU2.js +1 -1
- package/chunks/sk_SK.js +1 -1
- package/chunks/sk_SK2.js +1 -1
- package/chunks/sl_SL.js +1 -1
- package/chunks/sl_SL2.js +1 -1
- package/chunks/sr_RS.js +1 -1
- package/chunks/sr_RS2.js +1 -1
- package/chunks/sv_SE.js +1 -1
- package/chunks/sv_SE2.js +1 -1
- package/chunks/th_TH.js +1 -1
- package/chunks/th_TH2.js +1 -1
- package/chunks/tr_TR.js +1 -1
- package/chunks/tr_TR2.js +1 -1
- package/chunks/uk_UA.js +1 -1
- package/chunks/uk_UA2.js +1 -1
- package/chunks/vi_VN.js +1 -1
- package/chunks/vi_VN2.js +1 -1
- package/chunks/zh_Hans.js +1 -1
- package/chunks/zh_Hans2.js +1 -1
- package/chunks/zh_Hant.js +1 -1
- package/chunks/zh_Hant2.js +1 -1
- package/config.js +1 -1
- package/core/colorUtils.js +1 -1
- package/core/image/apng.js +1 -1
- package/core/image/gif.js +1 -1
- package/core/urlUtils.js +1 -1
- package/core/workers/WorkerOwner.js +1 -1
- package/core/workers/staticWorkerMessages.js +5 -0
- package/geometry/projection.js +1 -1
- package/interfaces.d.ts +42 -2
- package/kernel.js +1 -1
- package/layers/support/ImageElement.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/package.json +1 -1
- package/portal/Portal.js +1 -1
- package/support/BasemapStyle.js +5 -0
- package/support/basemapUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/support/previewSymbol2D.js +1 -1
- package/views/2d/GoToManager.js +5 -0
- package/views/2d/engine/Stage.js +1 -1
- package/views/2d/engine/webgl/Overlay.js +1 -1
- package/views/2d/engine/webgl/animatedFormats/utils.js +1 -1
- package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
- package/views/2d/interactive/editingTools/TransformTool.js +1 -1
- package/views/2d/layers/BaseLayerViewGL2D.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/support/engineHelpers.js +1 -1
- package/views/2d/support/screenshotUtils.js +5 -0
- package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
- package/views/3d/analysis/Dimension/DimensionTool.js +1 -1
- package/views/3d/analysis/Dimension/DimensionVisualization.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionVisualization.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionConstraintUtils.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
- package/views/3d/analysis/Dimension/settings.js +1 -1
- package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementVisualization.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightToolConfiguration.js +1 -1
- package/views/3d/analysis/Slice/SliceTool.js +1 -1
- package/views/3d/analysis/Slice/SliceVisualization.js +1 -1
- package/views/3d/analysis/Slice/settings.js +1 -1
- package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
- package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
- package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
- package/views/3d/interactive/editingTools/lineGraphicVisualElementUtils.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveXYAxisManipulation.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveXYDiscManipulation.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
- package/views/3d/interactive/editingTools/originGraphicVisualElementUtils.js +1 -1
- package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
- package/views/3d/interactive/editingTools/settings.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/GraphicScaleRotateTransform.js +1 -1
- package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
- package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DView.js +1 -1
- package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/terrain/TileTexture.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +12 -13
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBuffer.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/strokes.js +1 -1
- package/views/3d/webgl-engine/lib/glUtil3D.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/internal/WaterTextureRepository.js +1 -1
- package/views/3d/webgl-engine/shaders/HUDMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/statistics/RendererPerformanceInfo.js +1 -1
- package/views/MapView.js +1 -1
- package/views/Theme.js +5 -0
- package/views/View.js +1 -1
- package/views/interactive/SegmentLabels.js +1 -1
- package/views/support/colorUtils.js +1 -1
- package/views/webgl/Texture.js +1 -1
- package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
- package/widgets/Attachments.js +1 -1
- package/widgets/DistanceMeasurement2D/DistanceMeasurement2DTool.js +1 -1
- package/widgets/ElevationProfile/support/InputRepresentation3D.js +1 -1
- package/widgets/ElevationProfile/support/chartUtils.js +1 -1
- package/widgets/Feature/FeatureMedia/chartCommon.js +1 -1
- package/widgets/Feature/FeatureMedia.js +1 -1
- package/widgets/support/chartUtils.js +1 -1
- package/widgets/support/chartUtilsAm5.js +1 -1
- package/assets/esri/core/workers/chunks/05f3374114bce72d3560.js +0 -1
- package/assets/esri/core/workers/chunks/10028df973ef7f9531c8.js +0 -1
- package/assets/esri/core/workers/chunks/1cbb03eec9dc23ef043b.js +0 -1
- package/assets/esri/core/workers/chunks/289061552a2a64bebd76.js +0 -1
- package/assets/esri/core/workers/chunks/308eeeaec591b4eea1de.js +0 -1
- package/assets/esri/core/workers/chunks/3155c750fc5a4e04a785.js +0 -1
- package/assets/esri/core/workers/chunks/346f67995b327bca8ee0.js +0 -1
- package/assets/esri/core/workers/chunks/3736e17dd6461f74cfaf.js +0 -1
- package/assets/esri/core/workers/chunks/37e60f9ca86f9d4bf4ea.js +0 -1
- package/assets/esri/core/workers/chunks/3a0b45ecc48e23a3a5d5.js +0 -1
- package/assets/esri/core/workers/chunks/417377c8e76944f428a7.js +0 -1
- package/assets/esri/core/workers/chunks/498dca81073e1fb477b9.js +0 -1
- package/assets/esri/core/workers/chunks/536962375ce4f1394481.js +0 -1
- package/assets/esri/core/workers/chunks/64bb4093c019a02d5309.js +0 -1
- package/assets/esri/core/workers/chunks/69de4733173ee2dee6e1.js +0 -1
- package/assets/esri/core/workers/chunks/6dcffe6683a798a42c78.js +0 -1
- package/assets/esri/core/workers/chunks/7a898d167029ee11a680.js +0 -1
- package/assets/esri/core/workers/chunks/7a973d70e6bc42d804ee.js +0 -1
- package/assets/esri/core/workers/chunks/7d9d2629af373c84624f.js +0 -1
- package/assets/esri/core/workers/chunks/885cb0da78e6853b23a4.js +0 -1
- package/assets/esri/core/workers/chunks/8e28862296972e9e6f82.js +0 -1
- package/assets/esri/core/workers/chunks/928431e1c449c6054547.js +0 -1
- package/assets/esri/core/workers/chunks/afdf30439d71a7cc19ae.js +0 -1
- package/assets/esri/core/workers/chunks/b1fa1571fd98d3b8dffe.js +0 -1
- package/assets/esri/core/workers/chunks/b20167d9163d0ee74b65.js +0 -1
- package/assets/esri/core/workers/chunks/b2a0e3e1dfccda7ed12e.js +0 -1
- package/assets/esri/core/workers/chunks/c09db831248054600e16.js +0 -1
- package/assets/esri/core/workers/chunks/dcccc9760998271254b5.js +0 -1
- package/assets/esri/core/workers/chunks/ddea45acae89759e57fa.js +0 -1
- package/assets/esri/core/workers/chunks/e039108eb3a592f6d8e3.js +0 -1
- package/assets/esri/core/workers/chunks/e70314ac10cc1f8f9f86.js +0 -1
- package/assets/esri/core/workers/chunks/f2d399b394a1a9156214.js +0 -1
- package/assets/esri/core/workers/chunks/f74d4e1eecec06f84ee2.js +0 -1
- package/assets/esri/core/workers/chunks/fb7eff7f76386f81d57b.js +0 -1
- package/assets/esri/core/workers/chunks/fe277d33b5b8a11c76df.js +0 -1
- package/core/analysisThemeUtils.js +0 -5
- package/views/support/createScreenshotPlan.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../../geometry.js";import e from"../../../../core/Error.js";import{px2pt as t,pt2px as r}from"../../../../core/screenUtils.js";import{f as i,d as a}from"../../../../chunks/vec4f64.js";import{create as l,empty as s,expandWithBuffer as n,intersectsClippingArea as o,expandWithAABB as h}from"../../../../geometry/support/aaBoundingBox.js";import{getDriverAxisSizeValueAny as c}from"../../../../renderers/support/renderingInfoUtils.js";import{sharedGeometryElevationAligner as p}from"./ElevationAligners.js";import{SymbolUpdateType as m,elevationModeChangeUpdateType as d,needsElevationUpdates2D as y}from"./elevationAlignmentUtils.js";import _ from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as u}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as g}from"./Graphics3DSymbolLayer.js";import{ApplyRendererDiffResult as f}from"./interfaces.js";import{parseCapType as M,parseLineMarkerStyle as C}from"./lineUtils.js";import{ConvertOptions as b,initFastSymbolUpdatesState as P,updateFastSymbolUpdatesState as E,getAttributeValue as L}from"../support/FastSymbolUpdates.js";import w from"../../support/debugFlags.js";import{createGeometry as v}from"../../support/engineContent/line.js";import{geometryToRenderInfo as x,geometryToRenderInfoDraped as R}from"../../support/renderInfoUtils/line.js";import{Object3D as k}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as D}from"../../webgl-engine/lib/RenderGeometry.js";import{LineMarkerMaterial as j}from"../../webgl-engine/materials/LineMarkerMaterial.js";import{getStipplePatternForLinePattern as A}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as S}from"../../webgl-engine/materials/RibbonLineMaterial.js";import U from"../../../../geometry/Extent.js";import G from"../../../../geometry/Polygon.js";const z=["polyline","polygon","extent"],O=new b({size:!0,color:!0,rotation:!1,opacity:!0});class V extends g{constructor(e,t,r,i){super(e,t,r,i)}async doLoad(){if(this._fastUpdates=P(this._context.renderer,O),!this._drivenProperties.size){if((null!=this.symbolLayer.size?this.symbolLayer.size:t(1))<0)throw new e("graphics3dlinesymbollayer:invalid-size","Symbol sizes may not be negative values")}}_getMaterialParameters(e,t=!1){const r=this._getCombinedOpacityAndColor(t&&this._markerColor||this._materialColor);this._patternHidesLine&&!t&&(r[3]=0);const i={width:this._computeMaterialWidth(this.symbolLayer?.size),color:r,hasPolygonOffset:!0,join:this.symbolLayer.join||"miter",cap:M(this.symbolLayer.cap||"butt"),hasSlicePlane:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:A(this.symbolLayer.pattern),stippleScaleWithLineWidth:!0};return this._fastUpdates?.visualVariables?{...i,...this._fastUpdates.materialParameters}:i}get _materialColor(){return this.symbolLayer.material?.color}get _markerColor(){return this.symbolLayer.marker?.color}get _lineMaterial(){return null==this._lineMaterialCached&&(this._lineMaterialCached=new S(this._getMaterialParameters(!1)),this._context.stage.add(this._lineMaterialCached)),this._lineMaterialCached}get _ringMaterial(){return null==this._ringMaterialCached&&(this._ringMaterialCached=new S(this._getMaterialParameters(!0)),this._context.stage.add(this._ringMaterialCached)),this._ringMaterialCached}get _wireframeLineMaterial(){return null==this._wireframeLineMaterialCached&&(this._wireframeLineMaterialCached=new S({...this._getMaterialParameters(!1),wireframe:!0}),this._context.stage.add(this._wireframeLineMaterialCached)),this._wireframeLineMaterialCached}get _wireframeRingMaterial(){return null==this._wireframeRingMaterialCached&&(this._wireframeRingMaterialCached=new S({...this._getMaterialParameters(!0),wireframe:!0}),this._context.stage.add(this._wireframeRingMaterialCached)),this._wireframeRingMaterialCached}get _markerMaterial(){return null==this._markerMaterialCached&&null!=this.symbolLayer.marker&&(this._markerMaterialCached=new j({...this._getMaterialParameters(!1,!0),placement:this.symbolLayer.marker.placement,markerPrimitive:C(this.symbolLayer.marker.style)}),this._context.stage.add(this._markerMaterialCached)),this._markerMaterialCached}destroy(){super.destroy(),this._forEachMaterial((e=>this._context.stage.remove(e))),this._lineMaterialCached=null,this._ringMaterialCached=null,this._wireframeLineMaterialCached=null,this._wireframeRingMaterialCached=null,this._markerMaterialCached=null}_getDrivenSize(e){return this._drivenProperties.size&&e.size?r(c(e.size)):1}_getDrivenColor(e){const t=i(1,1,1,1);return this._drivenProperties.color&&e.color&&(t[0]=e.color[0],t[1]=e.color[1],t[2]=e.color[2],e.color.length>0&&(t[3]=e.color[3])),this._drivenProperties.opacity&&e.opacity&&(t[3]=e.opacity),t}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,z,this.symbolLayer.type))return null;const r=this.setGraphicElevationContext(t);return this.ensureDrapedStatus("on-the-ground"===r.mode),this.draped?this._createAsOverlay(e,this._context.layer.uid):this._createAs3DShape(e,r,t.uid)}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return f.RecreateSymbol;{const e=this._fastUpdates;if(!E(e,t,O))return f.RecreateSymbol;this._forEachMaterial((t=>t.setParameters(e.materialParameters)))}}return f.FastUpdate}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff,r={};"complete"===t.size?.type&&(r.width=this._computeMaterialWidth(t.size.newValue),delete t.size),"complete"===t.cap?.type&&(r.cap=M(t.cap.newValue??"butt"),delete t.cap);const i=this._prepareMarkerPatch(e,t);this._prepareMaterialPatch(e,t,i),e.symbolLayerStatePatches.push((()=>this._forEachMaterial((e=>e.setParameters(r)))))}layerOpacityChanged(){this._forEachMaterial(((e,t)=>this._updateMaterialLayerOpacity(e,t)))}_forEachMaterial(e){null!=this._lineMaterialCached&&e(this._lineMaterialCached),null!=this._ringMaterialCached&&e(this._ringMaterialCached),null!=this._wireframeLineMaterialCached&&e(this._wireframeLineMaterialCached),null!=this._wireframeRingMaterialCached&&e(this._wireframeRingMaterialCached),null!=this._markerMaterialCached&&e(this._markerMaterialCached,!0)}_updateMaterialLayerOpacity(e,t=!1){const r=e.parameters.color,a=this.symbolLayer?.material?.color,l=this._patternHidesLine&&!t?0:this._getCombinedOpacity(a),s=i(r[0],r[1],r[2],l);e.setParameters({color:s})}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,a=d(V.elevationModeChangeTypes,r,i);if(a!==m.UPDATE)return a;const l=y(i);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>l))}slicePlaneEnabledChanged(){const e={hasSlicePlane:this._context.slicePlaneEnabled};return this._forEachMaterial((t=>t.setParameters(e))),!0}physicalBasedRenderingChanged(){return!0}_getGeometryAsPolygonOrPolyline(e){switch(e.type){case"extent":if(e instanceof U)return G.fromExtent(e);break;case"polygon":case"polyline":return e}return null}_createAs3DShape(e,t,r){const i=e.graphic,a=this._getGeometryAsPolygonOrPolyline(i.geometry),h="polygon"===a.type?a.rings:a.paths,c=new Array,m=l(),d=x(a,this._context.elevationProvider,this._context.renderCoordsHelper,t),_="polygon"===a.type?"rings":"paths";this._logGeometryCreationWarnings(d,h,_,"LineSymbol3DLayer");for(let l=0;l<d.lines.length;l++){const t=d.lines[l],i=t.position,h=t.mapPositions;if(null!=this._context.clippingExtent&&(s(m),n(m,h),!o(m,this._context.clippingExtent)))continue;const p=this._createGeometry("polygon"===a.type?this._ringMaterial:this._lineMaterial,e,i,h,a.type,I.ELEVATED,r);c.push(p),w.LINE_WIREFRAMES&&c.push(p.instantiate({material:"polygon"===a.type?this._wireframeRingMaterial:this._wireframeLineMaterial})),null!=this._markerMaterial&&c.push(p.instantiate({material:this._markerMaterial}))}if(0===c.length)return null;const g=new k({geometries:c,castShadow:!1,layerUid:this._context.layer.uid,graphicUid:r}),f=new u(this,g,c,null,null,p,t);return f.alignedSampledElevation=d.sampledElevation,f.needsElevationUpdates=y(t.mode),f}_createGeometry(e,t,r,i,a,l,s){const n=l===I.DRAPED?{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper}:null,o="polygon"===a,h=this._fastUpdates?.visualVariables.color,c=this._fastUpdates?.visualVariables.size,p=this._fastUpdates?.visualVariables.opacity,m=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:s,layerUid:this._context.layer.uid}),d={position:r,size:c?null:this._getDrivenSize(t.renderingInfo),color:h?null:this._getDrivenColor(t.renderingInfo),sizeFeature:c?L(c.field,t.graphic):null,colorFeature:h?L(h.field,t.graphic):null,opacityFeature:p?L(p.field,t.graphic):null};return v(e,{overlayInfo:n,removeDuplicateStartEnd:o,mapPositions:i,attributeData:d},m)}_createAsOverlay(e,t){const r=e.graphic,i=this._getGeometryAsPolygonOrPolyline(r.geometry),a="polygon"===i.type?i.rings:i.paths,c="polygon"===i.type?this._ringMaterial:this._lineMaterial;c.renderPriority=this._renderPriority;const p=w.LINE_WIREFRAMES?"polygon"===i.type?this._wireframeRingMaterial:this._wireframeLineMaterial:null,m=this._markerMaterial;null!=p&&(p.renderPriority=this._renderPriority-.001),null!=m&&(m.renderPriority=this._renderPriority-.002);const d=new Array,y=l(),u=s(),g=R(i,this._context.overlaySR),f="polygon"===i.type?"rings":"paths";this._logGeometryCreationWarnings(g,a,f,"LineSymbol3DLayer");for(const l of g.lines){if(s(y),n(y,l.position),!o(y,this._context.clippingExtent))continue;h(u,y);const a=a=>{const s=this._createGeometry(a,e,l.position,void 0,i.type,I.DRAPED,r.uid),n=new D(s,{layerUid:t,graphicUid:r.uid});d.push(n)};if(null!=m){a(m);const e=this.symbolLayer.marker.placement;"begin"!==e&&"begin-end"!==e||n(y,l.position,0,1),"end"!==e&&"begin-end"!==e||n(y,l.position,l.position.length-3,1)}a(c),w.LINE_WIREFRAMES&&a(p)}return new _(this,d,u,this._context.drapeSourceRenderer)}get _patternHidesLine(){const e=this.symbolLayer.pattern;return null!=e&&"style"===e.type&&"none"===e.style}_computeMaterialWidth(e){return e=e??t(1),this._drivenProperties.size?this._fastUpdates?.visualVariables.size?r(1):1:r(e)}_prepareMaterialPatch(e,t,r){const i=t.material;if(null==i)return void(r.changed&&r.useMaterialColor&&this._patchMaterialColor(this._getCombinedOpacityAndColor(this._materialColor),this._markerMaterialCached,e));if("collection"===i.type)return;const l="complete"===i.type?i.newValue?.color:"complete"===i.diff.color?.type?i.diff.color.newValue:null,s=this._getCombinedOpacityAndColor(l);r.useMaterialColor&&this._patchMaterialColor(a(s),this._markerMaterialCached,e),this._patternHidesLine&&(s[3]=0),this._patchMaterialColor(s,this._lineMaterialCached,e),delete t.material}_prepareMarkerPatch(e,t){const r=t.marker,i=this._markerMaterial;if(null==r||"partial"!==r.type||null==r.diff||null!=r.diff.placement||null!=r.diff.style&&"complete"!==r.diff.style.type||null!=r.diff.color&&"complete"!==r.diff.color.type||null==i)return{changed:!1,useMaterialColor:null==this._markerColor};const a=r.diff.color,l=null!=a,s=l?a.newValue:null,n=null==s&&null==this._markerColor;s&&this._patchMaterialColor(this._getCombinedOpacityAndColor(s),i,e);const o=r.diff.style?.newValue;return o&&e.symbolLayerStatePatches.push((()=>i.setParameters({markerPrimitive:C(o)}))),delete t.marker,{changed:l,useMaterialColor:n}}_patchMaterialColor(e,t,r){null!=t&&r.symbolLayerStatePatches.push((()=>t.setParameters({color:e})))}}var I;V.elevationModeChangeTypes={definedChanged:m.RECREATE,staysOnTheGround:m.NONE,onTheGroundChanged:m.RECREATE},function(e){e[e.DRAPED=0]="DRAPED",e[e.ELEVATED=1]="ELEVATED"}(I||(I={}));export{V as Graphics3DLineSymbolLayer};
|
|
5
|
+
import"../../../../geometry.js";import e from"../../../../core/Error.js";import{px2pt as t,pt2px as r}from"../../../../core/screenUtils.js";import{f as i,d as a}from"../../../../chunks/vec4f64.js";import{create as l,empty as s,expandWithBuffer as n,intersectsClippingArea as o,expandWithAABB as h}from"../../../../geometry/support/aaBoundingBox.js";import{getDriverAxisSizeValueAny as c}from"../../../../renderers/support/renderingInfoUtils.js";import{sharedGeometryElevationAligner as p}from"./ElevationAligners.js";import{SymbolUpdateType as m,elevationModeChangeUpdateType as d,needsElevationUpdates2D as y}from"./elevationAlignmentUtils.js";import _ from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as u}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as g}from"./Graphics3DSymbolLayer.js";import{ApplyRendererDiffResult as f}from"./interfaces.js";import{parseCapType as M,parseLineMarkerStyle as C}from"./lineUtils.js";import{ConvertOptions as b,initFastSymbolUpdatesState as P,updateFastSymbolUpdatesState as E,getAttributeValue as w}from"../support/FastSymbolUpdates.js";import L from"../../support/debugFlags.js";import{createGeometry as v}from"../../support/engineContent/line.js";import{geometryToRenderInfo as x,geometryToRenderInfoDraped as R}from"../../support/renderInfoUtils/line.js";import{Object3D as k}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as D}from"../../webgl-engine/lib/RenderGeometry.js";import{LineMarkerMaterial as j}from"../../webgl-engine/materials/LineMarkerMaterial.js";import{getStipplePatternForLinePattern as A}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as S}from"../../webgl-engine/materials/RibbonLineMaterial.js";import U from"../../../../geometry/Extent.js";import G from"../../../../geometry/Polygon.js";const z=["polyline","polygon","extent"],O=new b({size:!0,color:!0,rotation:!1,opacity:!0});class V extends g{constructor(e,t,r,i){super(e,t,r,i)}async doLoad(){if(this._fastUpdates=P(this._context.renderer,O),!this._drivenProperties.size){if((null!=this.symbolLayer.size?this.symbolLayer.size:t(1))<0)throw new e("graphics3dlinesymbollayer:invalid-size","Symbol sizes may not be negative values")}}_getMaterialParameters(e,t=!1){const r=this._getCombinedOpacityAndColor(t&&this._markerColor||this._materialColor);this._patternHidesLine&&!t&&(r[3]=0);const i={width:this._computeMaterialWidth(this.symbolLayer?.size),color:r,hasPolygonOffset:!0,join:this.symbolLayer.join||"miter",cap:M(this.symbolLayer.cap||"butt"),hasSlicePlane:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:A(this.symbolLayer.pattern)};return this._fastUpdates?.visualVariables?{...i,...this._fastUpdates.materialParameters}:i}get _materialColor(){return this.symbolLayer.material?.color}get _markerColor(){return this.symbolLayer.marker?.color}get _lineMaterial(){return null==this._lineMaterialCached&&(this._lineMaterialCached=new S(this._getMaterialParameters(!1)),this._context.stage.add(this._lineMaterialCached)),this._lineMaterialCached}get _ringMaterial(){return null==this._ringMaterialCached&&(this._ringMaterialCached=new S(this._getMaterialParameters(!0)),this._context.stage.add(this._ringMaterialCached)),this._ringMaterialCached}get _wireframeLineMaterial(){return null==this._wireframeLineMaterialCached&&(this._wireframeLineMaterialCached=new S({...this._getMaterialParameters(!1),wireframe:!0}),this._context.stage.add(this._wireframeLineMaterialCached)),this._wireframeLineMaterialCached}get _wireframeRingMaterial(){return null==this._wireframeRingMaterialCached&&(this._wireframeRingMaterialCached=new S({...this._getMaterialParameters(!0),wireframe:!0}),this._context.stage.add(this._wireframeRingMaterialCached)),this._wireframeRingMaterialCached}get _markerMaterial(){return null==this._markerMaterialCached&&null!=this.symbolLayer.marker&&(this._markerMaterialCached=new j({...this._getMaterialParameters(!1,!0),placement:this.symbolLayer.marker.placement,markerPrimitive:C(this.symbolLayer.marker.style)}),this._context.stage.add(this._markerMaterialCached)),this._markerMaterialCached}destroy(){super.destroy(),this._forEachMaterial((e=>this._context.stage.remove(e))),this._lineMaterialCached=null,this._ringMaterialCached=null,this._wireframeLineMaterialCached=null,this._wireframeRingMaterialCached=null,this._markerMaterialCached=null}_getDrivenSize(e){return this._drivenProperties.size&&e.size?r(c(e.size)):1}_getDrivenColor(e){const t=i(1,1,1,1);return this._drivenProperties.color&&e.color&&(t[0]=e.color[0],t[1]=e.color[1],t[2]=e.color[2],e.color.length>0&&(t[3]=e.color[3])),this._drivenProperties.opacity&&e.opacity&&(t[3]=e.opacity),t}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,z,this.symbolLayer.type))return null;const r=this.setGraphicElevationContext(t);return this.ensureDrapedStatus("on-the-ground"===r.mode),this.draped?this._createAsOverlay(e,this._context.layer.uid):this._createAs3DShape(e,r,t.uid)}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return f.RecreateSymbol;{const e=this._fastUpdates;if(!E(e,t,O))return f.RecreateSymbol;this._forEachMaterial((t=>t.setParameters(e.materialParameters)))}}return f.FastUpdate}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff,r={};"complete"===t.size?.type&&(r.width=this._computeMaterialWidth(t.size.newValue),delete t.size),"complete"===t.cap?.type&&(r.cap=M(t.cap.newValue??"butt"),delete t.cap);const i=this._prepareMarkerPatch(e,t);this._prepareMaterialPatch(e,t,i),e.symbolLayerStatePatches.push((()=>this._forEachMaterial((e=>e.setParameters(r)))))}layerOpacityChanged(){this._forEachMaterial(((e,t)=>this._updateMaterialLayerOpacity(e,t)))}_forEachMaterial(e){null!=this._lineMaterialCached&&e(this._lineMaterialCached),null!=this._ringMaterialCached&&e(this._ringMaterialCached),null!=this._wireframeLineMaterialCached&&e(this._wireframeLineMaterialCached),null!=this._wireframeRingMaterialCached&&e(this._wireframeRingMaterialCached),null!=this._markerMaterialCached&&e(this._markerMaterialCached,!0)}_updateMaterialLayerOpacity(e,t=!1){const r=e.parameters.color,a=this.symbolLayer?.material?.color,l=this._patternHidesLine&&!t?0:this._getCombinedOpacity(a),s=i(r[0],r[1],r[2],l);e.setParameters({color:s})}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,a=d(V.elevationModeChangeTypes,r,i);if(a!==m.UPDATE)return a;const l=y(i);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>l))}slicePlaneEnabledChanged(){const e={hasSlicePlane:this._context.slicePlaneEnabled};return this._forEachMaterial((t=>t.setParameters(e))),!0}physicalBasedRenderingChanged(){return!0}_getGeometryAsPolygonOrPolyline(e){switch(e.type){case"extent":if(e instanceof U)return G.fromExtent(e);break;case"polygon":case"polyline":return e}return null}_createAs3DShape(e,t,r){const i=e.graphic,a=this._getGeometryAsPolygonOrPolyline(i.geometry),h="polygon"===a.type?a.rings:a.paths,c=new Array,m=l(),d=x(a,this._context.elevationProvider,this._context.renderCoordsHelper,t),_="polygon"===a.type?"rings":"paths";this._logGeometryCreationWarnings(d,h,_,"LineSymbol3DLayer");for(let l=0;l<d.lines.length;l++){const t=d.lines[l],i=t.position,h=t.mapPositions;if(null!=this._context.clippingExtent&&(s(m),n(m,h),!o(m,this._context.clippingExtent)))continue;const p=this._createGeometry("polygon"===a.type?this._ringMaterial:this._lineMaterial,e,i,h,a.type,I.ELEVATED,r);c.push(p),L.LINE_WIREFRAMES&&c.push(p.instantiate({material:"polygon"===a.type?this._wireframeRingMaterial:this._wireframeLineMaterial})),null!=this._markerMaterial&&c.push(p.instantiate({material:this._markerMaterial}))}if(0===c.length)return null;const g=new k({geometries:c,castShadow:!1,layerUid:this._context.layer.uid,graphicUid:r}),f=new u(this,g,c,null,null,p,t);return f.alignedSampledElevation=d.sampledElevation,f.needsElevationUpdates=y(t.mode),f}_createGeometry(e,t,r,i,a,l,s){const n=l===I.DRAPED?{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper}:null,o="polygon"===a,h=this._fastUpdates?.visualVariables.color,c=this._fastUpdates?.visualVariables.size,p=this._fastUpdates?.visualVariables.opacity,m=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:s,layerUid:this._context.layer.uid}),d={position:r,size:c?null:this._getDrivenSize(t.renderingInfo),color:h?null:this._getDrivenColor(t.renderingInfo),sizeFeature:c?w(c.field,t.graphic):null,colorFeature:h?w(h.field,t.graphic):null,opacityFeature:p?w(p.field,t.graphic):null};return v(e,{overlayInfo:n,removeDuplicateStartEnd:o,mapPositions:i,attributeData:d},m)}_createAsOverlay(e,t){const r=e.graphic,i=this._getGeometryAsPolygonOrPolyline(r.geometry),a="polygon"===i.type?i.rings:i.paths,c="polygon"===i.type?this._ringMaterial:this._lineMaterial;c.renderPriority=this._renderPriority;const p=L.LINE_WIREFRAMES?"polygon"===i.type?this._wireframeRingMaterial:this._wireframeLineMaterial:null,m=this._markerMaterial;null!=p&&(p.renderPriority=this._renderPriority-.001),null!=m&&(m.renderPriority=this._renderPriority-.002);const d=new Array,y=l(),u=s(),g=R(i,this._context.overlaySR),f="polygon"===i.type?"rings":"paths";this._logGeometryCreationWarnings(g,a,f,"LineSymbol3DLayer");for(const l of g.lines){if(s(y),n(y,l.position),!o(y,this._context.clippingExtent))continue;h(u,y);const a=a=>{const s=this._createGeometry(a,e,l.position,void 0,i.type,I.DRAPED,r.uid),n=new D(s,{layerUid:t,graphicUid:r.uid});d.push(n)};if(null!=m){a(m);const e=this.symbolLayer.marker.placement;"begin"!==e&&"begin-end"!==e||n(y,l.position,0,1),"end"!==e&&"begin-end"!==e||n(y,l.position,l.position.length-3,1)}a(c),L.LINE_WIREFRAMES&&a(p)}return new _(this,d,u,this._context.drapeSourceRenderer)}get _patternHidesLine(){const e=this.symbolLayer.pattern;return null!=e&&"style"===e.type&&"none"===e.style}_computeMaterialWidth(e){return e=e??t(1),this._drivenProperties.size?this._fastUpdates?.visualVariables.size?r(1):1:r(e)}_prepareMaterialPatch(e,t,r){const i=t.material;if(null==i)return void(r.changed&&r.useMaterialColor&&this._patchMaterialColor(this._getCombinedOpacityAndColor(this._materialColor),this._markerMaterialCached,e));if("collection"===i.type)return;const l="complete"===i.type?i.newValue?.color:"complete"===i.diff.color?.type?i.diff.color.newValue:null,s=this._getCombinedOpacityAndColor(l);r.useMaterialColor&&this._patchMaterialColor(a(s),this._markerMaterialCached,e),this._patternHidesLine&&(s[3]=0),this._patchMaterialColor(s,this._lineMaterialCached,e),delete t.material}_prepareMarkerPatch(e,t){const r=t.marker,i=this._markerMaterial;if(null==r||"partial"!==r.type||null==r.diff||null!=r.diff.placement||null!=r.diff.style&&"complete"!==r.diff.style.type||null!=r.diff.color&&"complete"!==r.diff.color.type||null==i)return{changed:!1,useMaterialColor:null==this._markerColor};const a=r.diff.color,l=null!=a,s=l?a.newValue:null,n=null==s&&null==this._markerColor;s&&this._patchMaterialColor(this._getCombinedOpacityAndColor(s),i,e);const o=r.diff.style?.newValue;return o&&e.symbolLayerStatePatches.push((()=>i.setParameters({markerPrimitive:C(o)}))),delete t.marker,{changed:l,useMaterialColor:n}}_patchMaterialColor(e,t,r){null!=t&&r.symbolLayerStatePatches.push((()=>t.setParameters({color:e})))}}var I;V.elevationModeChangeTypes={definedChanged:m.RECREATE,staysOnTheGround:m.NONE,onTheGroundChanged:m.RECREATE},function(e){e[e.DRAPED=0]="DRAPED",e[e.ELEVATED=1]="ELEVATED"}(I||(I={}));export{V as Graphics3DLineSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import{pt2px as t}from"../../../../core/screenUtils.js";import{e as i}from"../../../../chunks/earcut.js";import{create as r,empty as
|
|
5
|
+
import e from"../../../../Color.js";import{pt2px as t}from"../../../../core/screenUtils.js";import{e as i}from"../../../../chunks/earcut.js";import{create as r,empty as o,expandWithBuffer as n,intersectsClippingArea as s,expandWithAABB as a}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as l,doubleSubArray as c}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as h,floatSubArray as p}from"../../../../geometry/support/FloatArray.js";import{SymbolUpdateType as u,elevationModeChangeUpdateType as d,needsElevationUpdates2D as m}from"./elevationAlignmentUtils.js";import _ from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as y}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as g}from"./Graphics3DSymbolLayer.js";import{mixinColorAndOpacity as f}from"./graphicUtils.js";import{ApplyRendererDiffResult as b}from"./interfaces.js";import{parseCapType as x}from"./lineUtils.js";import{geometryAsPolygon as v,createIndices3D as O,createColorGeometry as D,PolygonCreationDataBase as C}from"./polygonUtils.js";import{ConvertOptions as S,initFastSymbolUpdatesState as j,updateFastSymbolUpdatesState as A,getAttributeValue as M}from"../support/FastSymbolUpdates.js";import{createMaterial as P,uvElevationAligner as U}from"../support/patternUtils.js";import{createMapSpaceUVCoords as E,createMapSpaceUVCoordsDraped as G}from"../support/uvUtils.js";import{createGeometry as L}from"../../support/engineContent/line.js";import{geometryToRenderInfo as w,geometryToRenderInfoDraped as R}from"../../support/renderInfoUtils/polygon.js";import{Object3D as I}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as V}from"../../webgl-engine/lib/RenderGeometry.js";import{getStipplePatternForLinePattern as F}from"../../webgl-engine/materials/lineStippleUtils.js";import{PatternMaterial as B}from"../../webgl-engine/materials/PatternMaterial.js";import{RibbonLineMaterial as T}from"../../webgl-engine/materials/RibbonLineMaterial.js";const z=["polyline","polygon","extent"],H=new S({size:!1,color:!0,rotation:!1,opacity:!1});class N extends g{constructor(e,t,i,r){super(e,t,i,r),this._needsUV=!1,this._hasOutline=!1}async doLoad(){this._fastUpdates=j(this._context.renderer,H)}_ensureMaterials(){this._ensureFillMaterial(),this._ensureOutlineMaterial()}_ensureFillMaterial(){if(null!=this._material)return;const e=this.symbolLayer?.material?.color,t=this._getCombinedOpacityAndColor(e);this._material=P(this.symbolLayer,{color:t,transparent:t[3]<1||this.needsDrivenTransparentPass,polygonOffset:!1,hasVertexColors:!0,writeLinearDepth:!0,draped:this.draped,hasSlicePlane:this._context.slicePlaneEnabled,...this._fastUpdates?.materialParameters}),this._needsUV=this._material instanceof B,this._context.stage.add(this._material)}_ensureOutlineMaterial(){const e=this.symbolLayer.outline;if(this._outlineMaterial||!this._isValidOutline(e))return;this._hasOutline=!0;const i=t=>{const i=F(e.pattern);return new T({width:t,color:this._getOutlineColor(),hasPolygonOffset:!0,hasSlicePlane:this._context.slicePlaneEnabled,isClosed:!0,stipplePattern:i,cap:x(e.patternCap||"butt")})};this._outlineMaterial=i(t(e.size)),this._context.stage.add(this._outlineMaterial)}_isValidOutline(e){return null!=e&&null!=e.size&&e.size>0&&null!=e.color&&(null==e.pattern||"style"!==e.pattern.type||"none"!==e.pattern.style)}destroy(){super.destroy(),this._context.stage.remove(this._material),this._material=null,this._context.stage.remove(this._outlineMaterial),this._outlineMaterial=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,z,this.symbolLayer.type))return null;const i=this._getVertexOpacityAndColor(e.renderingInfo,255),r=this.setGraphicElevationContext(t);return this.ensureDrapedStatus("on-the-ground"===r.mode),this._ensureMaterials(),this.draped?this._createAsOverlay(t,i):this._createAs3DShape(t,i,r)}applyRendererDiff(e,t){for(const i in e.diff){if("visualVariables"!==i)return b.RecreateSymbol;if(!A(this._fastUpdates,t,H))return b.RecreateSymbol;this._material&&this._material.setParameters(this._fastUpdates.materialParameters)}return b.FastUpdate}layerOpacityChanged(){if(null!=this._material){const e=this._material.parameters.color,t=this.symbolLayer?.material?.color,i=this._getCombinedOpacity(t);this._material.setParameters({color:[e[0],e[1],e[2],i],transparent:i<1||this.needsDrivenTransparentPass})}if(null!=this._outlineMaterial){const e=this._outlineMaterial.parameters.color;this._outlineMaterial.setParameters({color:[e[0],e[1],e[2],this._getOutlineOpacity()]})}}layerElevationInfoChanged(e,t,i){const r=this._elevationContext.mode,o=d(N.elevationModeChangeTypes,i,r);if(o!==u.UPDATE)return o;const n=m(r);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>n))}slicePlaneEnabledChanged(){if(this._material&&this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._outlineMaterial){const e={hasSlicePlane:this._context.slicePlaneEnabled};this._outlineMaterial.setParameters(e)}return!0}physicalBasedRenderingChanged(){return!0}_createAs3DShape(e,t,i){const r=v(e.geometry);if(!r)return null;const o=w(r,this._context.elevationProvider,this._context.renderCoordsHelper,i),n=new k(o,t,this._context.layer.uid,e.uid),s=n.renderData.position.length/3;if(this._needsUV&&(n.uvMapSpace=h(4*s,!0),n.boundingRect=l(9*s,!0),E(n.uvMapSpace,n.boundingRect,n.renderData.position,this._context.renderCoordsHelper)),n.objectAndLayerIdColor=this._context.stage.renderView?.getObjectAndLayerIdColor(n),this._createAs3DShapeFill(e,n),this._hasOutline&&this._createAs3DShapeOutline(n),this._logGeometryCreationWarnings(n.renderData,r.rings,"rings","FillSymbol3DLayer"),0===n.outGeometries.length)return null;const a=new I({geometries:n.outGeometries,castShadow:!1,layerUid:this._context.layer.uid,graphicUid:e.uid}),c=new y(this,a,n.outGeometries,null,null,U,i);return c.alignedSampledElevation=n.renderData.sampledElevation,c.needsElevationUpdates=m(i.mode),c}_createAs3DShapeFill(e,t){const i=t.renderData.polygons;for(const{position:r,mapPositions:a,holeIndices:l,index:h,count:u}of i){if(null!=this._context.clippingExtent&&(o(W),n(W,a),!s(W,this._context.clippingExtent)))continue;const i=O(a,l,this._context.elevationProvider.spatialReference);if(0===i.length)continue;const d=this._fastUpdates?.visualVariables.color,m=D({material:this._material,indices:i,mapPositions:a,attributeData:{position:r,color:d?null:t.color,colorFeature:d?M(d.field,e):null,uvMapSpace:this._needsUV?p(t.uvMapSpace,4*h,4*u):null,boundingRect:this._needsUV?c(t.boundingRect,9*h,9*u):null,objectAndLayerIdColor:t.objectAndLayerIdColor}});t.outGeometries.push(m)}}_createAs3DShapeOutline(e){if(!this._hasOutline)return;const t=e.renderData.outlines;for(let i=0;i<t.length;++i){const{mapPositions:r,position:a}=t[i];if(null!=this._context.clippingExtent&&(o(W),n(W,r),!s(W,this._context.clippingExtent)))continue;const l=L(this._outlineMaterial,{overlayInfo:null,removeDuplicateStartEnd:!0,mapPositions:r,attributeData:{position:a}},e.objectAndLayerIdColor);e.outGeometries.push(l)}}_createAsOverlay(e,t){const i=v(e.geometry);if(null==i)return null;this._material.renderPriority=this._renderPriority+this._renderPriorityStep/2,null!=this._outlineMaterial&&(this._outlineMaterial.renderPriority=this._renderPriority);const r=R(i,this._context.overlaySR),n=new q(r,t,this._context.layer.uid,e.uid),s=n.renderData.position.length/3;return this._needsUV&&(n.uvMapSpace=h(4*s,!0),G(n.uvMapSpace,n.renderData.position,this._context.overlaySR,this._context.graphicsCoreOwner.view.state.viewingMode)),n.outBoundingBox=o(),n.objectAndLayerIdColor=this._context.stage.renderView?.getObjectAndLayerIdColor(n),this._createAsOverlayFill(e,n),this._hasOutline&&this._createAsOverlayOutline(n),this._logGeometryCreationWarnings(n.renderData,i.rings,"rings","FillSymbol3DLayer"),0===n.outGeometries.length?null:new _(this,n.outGeometries,n.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayFill(e,t){const r=t.renderData.polygons;for(const{position:l,holeIndices:c,index:h,count:u}of r){const r=o(W);if(n(r,l),!s(r,this._context.clippingExtent))continue;const d=i(l,c,3);if(0===d.length)continue;a(t.outBoundingBox,r);const m=this._fastUpdates?.visualVariables.color,_=D({material:this._material,indices:d,attributeData:{position:l,color:m?null:t.color,colorFeature:m?M(m.field,e):null,uvMapSpace:this._needsUV?p(t.uvMapSpace,4*h,4*u):null,objectAndLayerIdColor:t.objectAndLayerIdColor}});t.outGeometries.push(new V(_,t))}}_createAsOverlayOutline(e){if(!this._hasOutline)return;const t=e.renderData.outlines;for(let i=0;i<t.length;++i){const{position:r}=t[i];if(o(W),n(W,r),!s(W,this._context.clippingExtent))continue;a(e.outBoundingBox,W);const l=L(this._outlineMaterial,{overlayInfo:{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper},removeDuplicateStartEnd:!0,attributeData:{position:r}},e.objectAndLayerIdColor);e.outGeometries.push(new V(l,e))}}_getOutlineOpacity(){const e=this.symbolLayer?.outline?.color;return(this.draped?1:this._getLayerOpacity())*(null!=e?e.a:0)}_getOutlineColor(){const t=this.symbolLayer?.outline?.color,i=this._getOutlineOpacity();return f(null!=t?e.toUnitRGB(t):null,i)}test(){return{...super.test(),createAsOverlay:(e,t)=>this._createAsOverlay(e,t),createAs3DShape:(e,t,i)=>this._createAs3DShape(e,t,i)}}}N.elevationModeChangeTypes={definedChanged:u.RECREATE,staysOnTheGround:u.NONE,onTheGroundChanged:u.RECREATE};const W=r();class k extends C{constructor(e,t,i,r){super(e,i,r),this.color=t}}class q extends C{constructor(e,t,i,r){super(e,i,r),this.color=t}}export{N as Graphics3DPolygonFillSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{disposeMaybe as r}from"../../../core/maybe.js";import s from"../../../core/ObjectPool.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{I as a}from"../../../chunks/mat4f64.js";import{b as l,s as h,e as u}from"../../../chunks/vec3.js";import{Z as c,f as d,c as p}from"../../../chunks/vec3f64.js";import{Z as _}from"../../../chunks/vec4f64.js";import{create as f,set as m}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as g}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as b}from"../../ViewingMode.js";import{TextureUpdate as y}from"./interfaces.js";import{LayerClass as T}from"./LayerClass.js";import{OverlaySource as R}from"./Overlay.js";import{overlayRenderOccludedFlag as O}from"./OverlayRenderer.js";import{clearCaches as x}from"./PatchGeometry.js";import{PatchRenderData as C}from"./PatchRenderData.js";import{RenderOrder as v}from"./RenderOrder.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as D}from"./terrainUtils.js";import{TileRenderer as P}from"./TileRenderer.js";import{TileUpdate as S}from"./TileUpdate.js";import{IteratorPreorder as E,sortTiles as q,compareTiles as A}from"./tileUtils.js";import{componentMinimalSizeForIntersectionData as w,ComponentIntersectionData as N}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as j}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as G}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as I}from"../../../chunks/Terrain.glsl.js";import{TileBlendInput as L}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{Attribute as F}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as U}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as k}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as B}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as M,StoreResults as z}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as V}from"../webgl-engine/lib/Material.js";import{RenderSlot as H}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as W}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as Y}from"../webgl-engine/lib/VertexAttribute.js";import{TERRAIN_ID as Q,getVerticalOffsetTerrain as X}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as Z}from"../webgl-engine/materials/DrawParameters.js";import{intersectAabbInvDirBefore as K,intersectTriangles as J}from"../webgl-engine/materials/internal/MaterialUtil.js";import{TerrainTechnique as $}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as ee}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as te}from"../../webgl/enums.js";const ie=7,re=10,se=f();var ne;!function(e){e[e.Opaque=0]="Opaque",e[e.Semitransparent=1]="Semitransparent",e[e.TransparentWithDraped=2]="TransparentWithDraped",e[e.Empty=3]="Empty"}(ne||(ne={}));let oe=class extends i{get _isGlobal(){return this._stage.viewingMode===b.Global}constructor(e){super(e),this.type=M.TERRAIN,this.isGround=!0,this.renderSlots=[H.OPAQUE_TERRAIN,H.TRANSPARENT_TERRAIN,H.OCCLUDED_TERRAIN],this._tileSize=256,this._techniqueConfiguration=new ee,this._passParameters=new I,this._rctx=null,this._renderDataPool=new s(C),this._patchGroups=new Map,this._patchGroupsDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new E,this._highestVisibleLODTile=null,this._visible=!0,this._transparencyState=ne.Opaque,this._castShadows=!0,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.needsHighlight=!1,this.renderOccludedFlags=V.Occlude}initialize(){this._stage.addRenderPlugin(this)}destroy(){this._stage.removeRenderPlugin(this),x()}canRender(){return this._visible&&!!this._rootTiles&&!this.renderingDisabled}requiresOutput(e){return e===j.Depth&&this._overlayRenderer.hasWater||e===j.Highlight&&this.needsHighlight}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set transparency(e){this._transparencyState!==e&&(this._techniqueConfiguration.invisible=e===ne.TransparentWithDraped||e===ne.Empty,this._transparencyState=e,this.setNeedsRender())}get transparency(){return this._transparencyState}get renderPatchBorders(){return!!this._techniqueConfiguration.tileBorders}set renderPatchBorders(e){this._techniqueConfiguration.tileBorders!==e&&(this._techniqueConfiguration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return!!this._techniqueConfiguration.visualizeNormals}set visualizeNormals(e){this._techniqueConfiguration.visualizeNormals!==e&&(this._techniqueConfiguration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._techniqueConfiguration.backfaceCullingEnabled}set cullBackFaces(e){this._techniqueConfiguration.backfaceCullingEnabled!==e&&(this._techniqueConfiguration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return Q}get slicePlaneEnabled(){return this._techniqueConfiguration.hasSlicePlane}set slicePlaneEnabled(e){this._techniqueConfiguration.hasSlicePlane!==e&&(this._techniqueConfiguration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._techniqueConfiguration.textureFadingEnabled!==e&&(this._techniqueConfiguration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._techniqueConfiguration.pbrMode!==e&&(this._techniqueConfiguration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._techniqueConfiguration.screenSizePerspective!==e&&(this._techniqueConfiguration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setNeedsHighlight(e){this.needsHighlight=e,this.setNeedsRender()}setRenderOccludedOverlay(e){this.renderOccludedFlags=e?O:V.Occlude,this.setNeedsRender()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}setTileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}_prepareTileForLoading(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e),e.renderData.localOrigin=this._getLocalOriginOfTile(e))}loadTile(e){this._prepareTileForLoading(e),this.updateTileGeometryState(e),this.updateTileTexture(e,S.TEXTURE_FADING)}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===S.TEXTURE_FADING?y.FADING:y.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[T.ELEVATION])i.pendingUpdates&=~S.GEOMETRY;e.resetPendingUpdate(S.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.isLoaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=re-ie,i=Math.max(0,Math.floor((e.level-t)/ie)*ie);if(this._isGlobal&&0===i)return c;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}setVisibility(e){this._visible=e,this.setDirty()}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=U.UPDATE){this._patchGroupsDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=U.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=U.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._rctx=e.renderContext.rctx,this._techniqueRepository=e.techniqueRepository,this._tileRenderer=new P(this._rctx,this._tileSize,this._techniqueRepository),this.updateTileBackground(),this._emptyTex=k(this._rctx)}uninitializeRenderContext(){this._emptyTex=r(this._emptyTex),this._tileRenderer=r(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==ne.Opaque)return;const s=ae,n=le;l(s,r,i),h(n,1/s[0],1/s[1],1/s[2]);const o=e.results.min,c=e.results.max,d=e.results.ground,p=e.options.store===z.MIN,_=!!e.results.ground.target,f=X(e.verticalOffset),b=e.tolerance;let y,T=p&&null!=o.dist?o.dist:1/0;const R=h=>{const _=h.renderData;if(!_?.vao)return;const R=_.geometry;m(se,R.boundingBox);const O=_.localOrigin;null!=f&&(f.localOrigin=O,f.applyToAabb(se));const x=se;if(he[0]=i[0]-O[0],he[1]=i[1]-O[1],he[2]=i[2]-O[2],!K(x,he,n,b,T))return;const C=(e,t,i)=>{e.set(this.type,h,t,i,a),T=p&&null!=o.dist?o.dist:1/0},v=(n,a)=>{if(null!=a&&n>=0&&(e.options.backfacesTerrain||u(a,s)<0)&&(e.options.invisibleTerrain||!e.options.selectionMode||null==t||t(i,r,n))){if((null==d.dist||n<d.dist)&&C(d,n,a),e.options.isFiltered)return;e.options.store===z.ALL&&(null==y?(y=B(e.ray),C(y,n,a),e.results.all.push(y)):n<y.dist&&C(y,n,a)),(null==o.dist||n<o.dist)&&C(o,n,a),e.options.store!==z.MIN&&(null==c.dist||n>c.dist)&&C(c,n,a)}},D=ue;l(D,r,O);const P=R.indices,S=R.vertexAttributes,E=S.getField(Y.POSITION,g),q=new F(E.typedBuffer,3,!1,S.stride/4),A=R.indexCount/3;if(!f&&A>w){const e=h.renderData;null==e.intersectionData&&(e.intersectionData=new N(P,0,A,q)),e.intersectionData.intersectRay({r0:he,r1:D},v)}else J(he,D,0,A,P,q,null,f,v)},O=this._rootTiles;if(null!=O){(()=>{const t=this._tileIterator;t.reset(O);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==f&&!e.intersectsRay(i,s,b,T)||_&&this._useStencilForTile(e)?t.skipSubtree():R(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._patchGroups.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}prepareTechnique(e){if(e.bindParameters.slot===H.OCCLUDED_TERRAIN){if(0==(e.renderOccludedMask&O))return null}else{const t=this.transparency===ne.Opaque?H.OPAQUE_TERRAIN:H.TRANSPARENT_TERRAIN;if(e.bindParameters.slot!==t)return null}switch(e.output){case j.Color:return this.transparency===ne.Empty?null:(this._techniqueConfiguration.hasScreenSpaceReflections=null!=e.bindParameters.ssr.lastFrameColor,this._techniqueConfiguration.hasCloudsReflections=null!=e.bindParameters.cloudsFade.data,this._techniqueConfiguration.receiveShadows=e.bindParameters.shadowMap.ready,this._techniqueConfiguration.receiveAmbientOcclusion=e.bindParameters.ssaoHelper.active,this._techniqueConfiguration.overlayMode=this._overlayRenderer.isEmpty?G.Disabled:this._overlayRenderer.hasWater?G.EnabledWithWater:G.Enabled,this._updateTechnique(j.Color,e.bindParameters.slot===H.OCCLUDED_TERRAIN));case j.Shadow:case j.ShadowExcludeHighlight:return this._castShadows&&1===e.bindParameters.lighting.globalFactor?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Shadow,!1)):null;case j.Depth:return this.transparency===ne.Empty?null:(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Depth,!1));case j.Normal:return this.transparency===ne.Empty?null:(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Normal,!1));case j.ObjectAndLayerIdColor:return this.transparency===ne.Empty?null:this._updateTechnique(j.ObjectAndLayerIdColor,!1);case j.Highlight:return this.transparency!==ne.Empty&&this.needsHighlight?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Highlight,!1)):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case j.Color:{const i=e.bindParameters.slot===H.OCCLUDED_TERRAIN?R.Occluded:R.ColorAndWater;this._renderMaterialPass(e,t,i);break}case j.Depth:case j.Normal:this._renderAuxiliaryPass(e,t,R.ColorAndWater);break;case j.Highlight:this._renderAuxiliaryPass(e,t,R.Highlight);break;case j.Shadow:case j.ShadowExcludeHighlight:this._renderAuxiliaryPass(e,t,R.None);break;case j.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,R.ObjectAndLayerIdColor)}}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlaySource=i,r.bindTechnique(t,this._passParameters,e.bindParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this._renderPatchGroups(e,t,i)}_renderAuxiliaryPass(e,t,i){const r=e.rctx;this._passParameters.overlaySource=i,r.bindTechnique(t,this._passParameters,e.bindParameters),this._renderPatchGroupsAuxiliary(e,t,i)}updateTileBackground(e=null){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r=null;if(null!=e){const i=t.toUnitRGBA(e);r=d(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll((e=>i.updateTileTexture(e,y.FADING))),this._techniqueConfiguration.tileBlendInput=i.backgroundIsGrid?L.GridComposite:null!=i.backgroundColor?L.ColorComposite:L.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchGroupsDirty&&(this._highestVisibleLODTile=null,this._rebuildPatchGroups(),this._patchGroupsDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==v.NONE){const e=Array.from(this._patchGroups.values()),t=this._stencilEnabledLayerExtents;for(const i of e)q(this.renderOrder,i,t);e.sort(((e,t)=>A(e[0],t[0],this.renderOrder))),this._patchGroups=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._patchGroups.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}const r=i.localOrigin;let s=this._patchGroups.get(r);s||(s=new Array,this._patchGroups.set(r,s)),s.push(e),(!this._highestVisibleLODTile||e.elevationLevel>this._highestVisibleLODTile.elevationLevel)&&(this._highestVisibleLODTile=e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderPatchGroupsAuxiliary(e,t,i){const r=this._stencilEnabledLayerExtents.length>0;this._patchGroups.forEach((s=>{const n=s[0].renderData.localOrigin;t.program.bindDraw(new Z(n),e.bindParameters,this._passParameters);for(let o=0;o<s.length;o++)this._renderPatch(e,t,s[o],te.TRIANGLES,r,i)})),e.rctx.bindVAO(null)}_renderPatchGroups(e,t,i){const r=e.bindParameters.camera,s=t.program;if(this._techniqueConfiguration.screenSizePerspective&&this.pointsOfInterest){const e=W(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:r.fovY})}const n=this._stencilEnabledLayerExtents.length>0,o=i===R.Occluded;o&&(s.bindTexture("tex",this._emptyTex),s.setUniform3fv("textureOpacities",c),s.setUniform4fv("texOffsetAndScale",_));const a=null!=this._tileRenderer&&null!=this._tileRenderer.backgroundColor?this._tileRenderer.backgroundColor:c;this._techniqueConfiguration.tileBlendInput===L.ColorComposite&&s.setUniform3fv("backgroundColor",a);const l=this.wireframe?te.LINES:te.TRIANGLES;this._techniqueConfiguration.textureFadingEnabled&&s.bindTexture("texNext",this._emptyTex);const h=this._patchGroups;for(const u of h.values()){const r=u[0].renderData.localOrigin;t.program.bindDraw(new Z(r),e.bindParameters,this._passParameters),this._numOriginsRendered++;for(const a of u){const r=a.renderData,h=r.textureReference;if(null!=h){if(!o){s.setUniform4fv("texOffsetAndScale",h.offsetAndScale),s.bindTexture("tex",h.texture.texture);const e=r.textureFadeFactor,t=e<1?r.nextTextureReference:null;this._techniqueConfiguration.textureFadingEnabled&&null!=t&&e<1?(s.setUniform1f("fadeFactor",e),s.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),s.setUniform3fv("nextTexOpacities",t.opacities),s.bindTexture("texNext",t.texture.texture)):s.setUniform1f("fadeFactor",1),r.textureIsFading&&this.setNeedsRender(),s.setUniform3fv("textureOpacities",h.opacities)}this._renderPatch(e,t,a,l,n,i),a.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,i,r,s,n){const o=i.renderData,a=o.vao,l=a.indexBuffer;if(null==l)return void(D&&console.error("Rendered tile with no indices: ",i.lij," : ",o));const h=t.program;n===R.None||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(h,o.overlay),s&&(t.useStencil=this._useStencilForTile(i),t.bindPipelineState(e.rctx,e.bindParameters.slot));const u=o.geometry.indexCount;e.rctx.bindVAO(a),h.assertCompatibleVertexAttributeLocations(a),e.rctx.drawElements(r,u,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_updateTechnique(e,t){return this._techniqueConfiguration.output=e,this._techniqueConfiguration.renderOccluded=t,this._shaderTechnique=this._techniqueRepository.releaseAndAcquire($,this._techniqueConfiguration,this._shaderTechnique),this._shaderTechnique}get test(){return{tileRenderer:this._tileRenderer}}};e([n({constructOnly:!0})],oe.prototype,"_overlayRenderer",void 0),e([n({constructOnly:!0})],oe.prototype,"_stage",void 0),e([n({readOnly:!0})],oe.prototype,"_isGlobal",null),e([n({constructOnly:!0})],oe.prototype,"_allTiles",void 0),e([n({constructOnly:!0})],oe.prototype,"_ellipsoidRadius",void 0),e([n({value:!1})],oe.prototype,"renderingDisabled",null),e([n()],oe.prototype,"renderPatchBorders",null),e([n()],oe.prototype,"visualizeNormals",null),e([n()],oe.prototype,"cullBackFaces",null),e([n({value:v.FRONT_TO_BACK})],oe.prototype,"renderOrder",null),e([n()],oe.prototype,"wireframe",null),oe=e([o("esri.views.3d.terrain.TerrainRenderer")],oe);const ae=p(),le=p(),he=p(),ue=p();export{oe as TerrainRenderer,ne as TransparencyMode};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import r from"../../../core/Accessor.js";import{disposeMaybe as i}from"../../../core/maybe.js";import s from"../../../core/ObjectPool.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{I as a}from"../../../chunks/mat4f64.js";import{b as l,s as h,e as c}from"../../../chunks/vec3.js";import{Z as u,f as d,c as p}from"../../../chunks/vec3f64.js";import{Z as _}from"../../../chunks/vec4f64.js";import{create as f,set as m}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as g}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as b}from"../../ViewingMode.js";import{TextureUpdate as y}from"./interfaces.js";import{LayerClass as T}from"./LayerClass.js";import{OverlaySource as R}from"./Overlay.js";import{overlayRenderOccludedFlag as O}from"./OverlayRenderer.js";import{clearCaches as x}from"./PatchGeometry.js";import{PatchRenderData as C}from"./PatchRenderData.js";import{RenderOrder as v}from"./RenderOrder.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as D}from"./terrainUtils.js";import{TileRenderer as P}from"./TileRenderer.js";import{TileUpdate as S}from"./TileUpdate.js";import{IteratorPreorder as E,sortTiles as q,compareTiles as A}from"./tileUtils.js";import{componentMinimalSizeForIntersectionData as w,ComponentIntersectionData as N}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as j}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as G}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as I}from"../../../chunks/Terrain.glsl.js";import{TileBlendInput as L}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{Attribute as F}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as U}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as k}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as B}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as M,StoreResults as z}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as V}from"../webgl-engine/lib/Material.js";import{RenderSlot as H}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as W}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as Y}from"../webgl-engine/lib/VertexAttribute.js";import{TERRAIN_ID as Q,getVerticalOffsetTerrain as X}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as Z}from"../webgl-engine/materials/DrawParameters.js";import{intersectAabbInvDirBefore as K,intersectTriangles as J}from"../webgl-engine/materials/internal/MaterialUtil.js";import{TerrainTechnique as $}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as ee}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as te}from"../../webgl/enums.js";const re=7,ie=10,se=f();var ne;!function(e){e[e.Opaque=0]="Opaque",e[e.Semitransparent=1]="Semitransparent",e[e.TransparentWithDraped=2]="TransparentWithDraped",e[e.Empty=3]="Empty"}(ne||(ne={}));let oe=class extends r{get _isGlobal(){return this._stage.viewingMode===b.Global}get _techniques(){return this._context.techniqueRepository}get _rctx(){return this._context.renderContext.rctx}constructor(e){super(e),this.type=M.TERRAIN,this.isGround=!0,this.renderSlots=[H.OPAQUE_TERRAIN,H.TRANSPARENT_TERRAIN,H.OCCLUDED_TERRAIN],this._tileSize=256,this._techniqueConfiguration=new ee,this._passParameters=new I,this._renderDataPool=new s(C),this._patchGroups=new Map,this._patchGroupsDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new E,this._highestVisibleLODTile=null,this._visible=!0,this._transparencyState=ne.Opaque,this._castShadows=!0,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.needsHighlight=!1,this.renderOccludedFlags=V.Occlude}initialize(){this._stage.addRenderPlugin(this)}destroy(){this._stage.removeRenderPlugin(this),x()}canRender(){return this._visible&&!!this._rootTiles&&!this.renderingDisabled}requiresOutput(e){return e===j.Depth&&this._overlayRenderer.hasWater||e===j.Highlight&&this.needsHighlight}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set transparency(e){this._transparencyState!==e&&(this._techniqueConfiguration.invisible=e===ne.TransparentWithDraped||e===ne.Empty,this._transparencyState=e,this.setNeedsRender())}get transparency(){return this._transparencyState}get renderPatchBorders(){return!!this._techniqueConfiguration.tileBorders}set renderPatchBorders(e){this._techniqueConfiguration.tileBorders!==e&&(this._techniqueConfiguration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return!!this._techniqueConfiguration.visualizeNormals}set visualizeNormals(e){this._techniqueConfiguration.visualizeNormals!==e&&(this._techniqueConfiguration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._techniqueConfiguration.backfaceCullingEnabled}set cullBackFaces(e){this._techniqueConfiguration.backfaceCullingEnabled!==e&&(this._techniqueConfiguration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return Q}get slicePlaneEnabled(){return this._techniqueConfiguration.hasSlicePlane}set slicePlaneEnabled(e){this._techniqueConfiguration.hasSlicePlane!==e&&(this._techniqueConfiguration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._techniqueConfiguration.textureFadingEnabled!==e&&(this._techniqueConfiguration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._techniqueConfiguration.pbrMode!==e&&(this._techniqueConfiguration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._techniqueConfiguration.screenSizePerspective!==e&&(this._techniqueConfiguration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setNeedsHighlight(e){this.needsHighlight=e,this.setNeedsRender()}setRenderOccludedOverlay(e){this.renderOccludedFlags=e?O:V.Occlude,this.setNeedsRender()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}setTileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}_prepareTileForLoading(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e),e.renderData.localOrigin=this._getLocalOriginOfTile(e))}loadTile(e){this._prepareTileForLoading(e),this.updateTileGeometryState(e),this.updateTileTexture(e,S.TEXTURE_FADING)}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===S.TEXTURE_FADING?y.FADING:y.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const r of e.layerInfo[T.ELEVATION])r.pendingUpdates&=~S.GEOMETRY;e.resetPendingUpdate(S.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.isLoaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=ie-re,r=Math.max(0,Math.floor((e.level-t)/re)*re);if(this._isGlobal&&0===r)return u;for(;e.parent&&e.level>r;)e=e.parent;return e.centerAtSeaLevel}setVisibility(e){this._visible=e,this.setDirty()}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=U.UPDATE){this._patchGroupsDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=U.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=U.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new P(this._rctx,this._tileSize,this._techniques,this._cache),this.updateTileBackground(),this._emptyTex=k(this._rctx)}uninitializeRenderContext(){this._emptyTex=i(this._emptyTex),this._tileRenderer=i(this._tileRenderer)}intersect(e,t,r,i){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==ne.Opaque)return;const s=ae,n=le;l(s,i,r),h(n,1/s[0],1/s[1],1/s[2]);const o=e.results.min,u=e.results.max,d=e.results.ground,p=e.options.store===z.MIN,_=!!e.results.ground.target,f=X(e.verticalOffset),b=e.tolerance;let y,T=p&&null!=o.dist?o.dist:1/0;const R=h=>{const _=h.renderData;if(!_?.vao)return;const R=_.geometry;m(se,R.boundingBox);const O=_.localOrigin;null!=f&&(f.localOrigin=O,f.applyToAabb(se));const x=se;if(he[0]=r[0]-O[0],he[1]=r[1]-O[1],he[2]=r[2]-O[2],!K(x,he,n,b,T))return;const C=(e,t,r)=>{e.set(this.type,h,t,r,a),T=p&&null!=o.dist?o.dist:1/0},v=(n,a)=>{if(null!=a&&n>=0&&(e.options.backfacesTerrain||c(a,s)<0)&&(e.options.invisibleTerrain||!e.options.selectionMode||null==t||t(r,i,n))){if((null==d.dist||n<d.dist)&&C(d,n,a),e.options.isFiltered)return;e.options.store===z.ALL&&(null==y?(y=B(e.ray),C(y,n,a),e.results.all.push(y)):n<y.dist&&C(y,n,a)),(null==o.dist||n<o.dist)&&C(o,n,a),e.options.store!==z.MIN&&(null==u.dist||n>u.dist)&&C(u,n,a)}},D=ce;l(D,i,O);const P=R.indices,S=R.vertexAttributes,E=S.getField(Y.POSITION,g),q=new F(E.typedBuffer,3,!1,S.stride/4),A=R.indexCount/3;if(!f&&A>w){const e=h.renderData;null==e.intersectionData&&(e.intersectionData=new N(P,0,A,q)),e.intersectionData.intersectRay({r0:he,r1:D},v)}else J(he,D,0,A,P,q,null,f,v)},O=this._rootTiles;if(null!=O){(()=>{const t=this._tileIterator;t.reset(O);const i=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||i&&e.intersectsClippingArea)||null==f&&!e.intersectsRay(r,s,b,T)||_&&this._useStencilForTile(e)?t.skipSubtree():R(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._patchGroups.values())for(const r of t)null!=r.renderData?.textureReference&&e.queriesForTile(r);e.process(),t.madeProgress()}}prepareTechnique(e){if(e.bindParameters.slot===H.OCCLUDED_TERRAIN){if(0==(e.renderOccludedMask&O))return null}else{const t=this.transparency===ne.Opaque?H.OPAQUE_TERRAIN:H.TRANSPARENT_TERRAIN;if(e.bindParameters.slot!==t)return null}switch(e.output){case j.Color:return this.transparency===ne.Empty?null:(this._techniqueConfiguration.hasScreenSpaceReflections=null!=e.bindParameters.ssr.lastFrameColor,this._techniqueConfiguration.hasCloudsReflections=null!=e.bindParameters.cloudsFade.data,this._techniqueConfiguration.receiveShadows=e.bindParameters.shadowMap.ready,this._techniqueConfiguration.receiveAmbientOcclusion=e.bindParameters.ssaoHelper.active,this._techniqueConfiguration.overlayMode=this._overlayRenderer.isEmpty?G.Disabled:this._overlayRenderer.hasWater?G.EnabledWithWater:G.Enabled,this._updateTechnique(j.Color,e.bindParameters.slot===H.OCCLUDED_TERRAIN));case j.Shadow:case j.ShadowExcludeHighlight:return this._castShadows&&1===e.bindParameters.lighting.globalFactor?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Shadow,!1)):null;case j.Depth:return this.transparency===ne.Empty?null:(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Depth,!1));case j.Normal:return this.transparency===ne.Empty?null:(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Normal,!1));case j.ObjectAndLayerIdColor:return this.transparency===ne.Empty?null:this._updateTechnique(j.ObjectAndLayerIdColor,!1);case j.Highlight:return this.transparency!==ne.Empty&&this.needsHighlight?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Highlight,!1)):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case j.Color:{const r=e.bindParameters.slot===H.OCCLUDED_TERRAIN?R.Occluded:R.ColorAndWater;this._renderMaterialPass(e,t,r);break}case j.Depth:case j.Normal:this._renderAuxiliaryPass(e,t,R.ColorAndWater);break;case j.Highlight:this._renderAuxiliaryPass(e,t,R.Highlight);break;case j.Shadow:case j.ShadowExcludeHighlight:this._renderAuxiliaryPass(e,t,R.None);break;case j.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,R.ObjectAndLayerIdColor)}}_renderMaterialPass(e,t,r){const{rctx:i}=e;this._passParameters.overlaySource=r,i.bindTechnique(t,this._passParameters,e.bindParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this._renderPatchGroups(e,t,r)}_renderAuxiliaryPass(e,t,r){const i=e.rctx;this._passParameters.overlaySource=r,i.bindTechnique(t,this._passParameters,e.bindParameters),this._renderPatchGroupsAuxiliary(e,t,r)}updateTileBackground(e=null){if(null==this._tileRenderer)return;const r=this._tileRenderer;let i=null;if(null!=e){const r=t.toUnitRGBA(e);i=d(r[0]||0,r[1]||0,r[2]||0)}r.setBackground(i),this._allTiles.forAll((e=>r.updateTileTexture(e,y.FADING))),this._techniqueConfiguration.tileBlendInput=r.backgroundIsGrid?L.GridComposite:null!=r.backgroundColor?L.ColorComposite:L.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchGroupsDirty&&(this._highestVisibleLODTile=null,this._rebuildPatchGroups(),this._patchGroupsDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==v.NONE){const e=Array.from(this._patchGroups.values()),t=this._stencilEnabledLayerExtents;for(const r of e)q(this.renderOrder,r,t);e.sort(((e,t)=>A(e[0],t[0],this.renderOrder))),this._patchGroups=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._patchGroups.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),r=e.renderData;if(!r){this._numTilesCulled++;continue}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}const i=r.localOrigin;let s=this._patchGroups.get(i);s||(s=new Array,this._patchGroups.set(i,s)),s.push(e),(!this._highestVisibleLODTile||e.elevationLevel>this._highestVisibleLODTile.elevationLevel)&&(this._highestVisibleLODTile=e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderPatchGroupsAuxiliary(e,t,r){const i=this._stencilEnabledLayerExtents.length>0;this._patchGroups.forEach((s=>{const n=s[0].renderData.localOrigin;t.program.bindDraw(new Z(n),e.bindParameters,this._passParameters);for(let o=0;o<s.length;o++)this._renderPatch(e,t,s[o],te.TRIANGLES,i,r)})),e.rctx.bindVAO(null)}_renderPatchGroups(e,t,r){const i=e.bindParameters.camera,s=t.program;if(this._techniqueConfiguration.screenSizePerspective&&this.pointsOfInterest){const e=W(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:i.fovY})}const n=this._stencilEnabledLayerExtents.length>0,o=r===R.Occluded;o&&(s.bindTexture("tex",this._emptyTex),s.setUniform3fv("textureOpacities",u),s.setUniform4fv("texOffsetAndScale",_));const a=null!=this._tileRenderer&&null!=this._tileRenderer.backgroundColor?this._tileRenderer.backgroundColor:u;this._techniqueConfiguration.tileBlendInput===L.ColorComposite&&s.setUniform3fv("backgroundColor",a);const l=this.wireframe?te.LINES:te.TRIANGLES;this._techniqueConfiguration.textureFadingEnabled&&s.bindTexture("texNext",this._emptyTex);const h=this._patchGroups;for(const c of h.values()){const i=c[0].renderData.localOrigin;t.program.bindDraw(new Z(i),e.bindParameters,this._passParameters),this._numOriginsRendered++;for(const a of c){const i=a.renderData,h=i.textureReference;if(null!=h){if(!o){s.setUniform4fv("texOffsetAndScale",h.offsetAndScale),s.bindTexture("tex",h.texture.texture);const e=i.textureFadeFactor,t=e<1?i.nextTextureReference:null;this._techniqueConfiguration.textureFadingEnabled&&null!=t&&e<1?(s.setUniform1f("fadeFactor",e),s.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),s.setUniform3fv("nextTexOpacities",t.opacities),s.bindTexture("texNext",t.texture.texture)):s.setUniform1f("fadeFactor",1),i.textureIsFading&&this.setNeedsRender(),s.setUniform3fv("textureOpacities",h.opacities)}this._renderPatch(e,t,a,l,n,r),a.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,r,i,s,n){const o=r.renderData,a=o.vao,l=a.indexBuffer;if(null==l)return void(D&&console.error("Rendered tile with no indices: ",r.lij," : ",o));const h=t.program;n===R.None||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(h,o.overlay),s&&(t.useStencil=this._useStencilForTile(r),t.bindPipelineState(e.rctx,e.bindParameters.slot));const c=o.geometry.indexCount;e.rctx.bindVAO(a),h.assertCompatibleVertexAttributeLocations(a),e.rctx.drawElements(i,c,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_updateTechnique(e,t){return this._techniqueConfiguration.output=e,this._techniqueConfiguration.renderOccluded=t,this._shaderTechnique=this._techniques.releaseAndAcquire($,this._techniqueConfiguration,this._shaderTechnique),this._shaderTechnique}get test(){return{tileRenderer:this._tileRenderer}}};e([n({constructOnly:!0})],oe.prototype,"_overlayRenderer",void 0),e([n({constructOnly:!0})],oe.prototype,"_stage",void 0),e([n({readOnly:!0})],oe.prototype,"_isGlobal",null),e([n({constructOnly:!0})],oe.prototype,"_allTiles",void 0),e([n({constructOnly:!0})],oe.prototype,"_cache",void 0),e([n({constructOnly:!0})],oe.prototype,"_ellipsoidRadius",void 0),e([n({value:!1})],oe.prototype,"renderingDisabled",null),e([n()],oe.prototype,"renderPatchBorders",null),e([n()],oe.prototype,"visualizeNormals",null),e([n()],oe.prototype,"cullBackFaces",null),e([n({value:v.FRONT_TO_BACK})],oe.prototype,"renderOrder",null),e([n()],oe.prototype,"wireframe",null),oe=e([o("esri.views.3d.terrain.TerrainRenderer")],oe);const ae=p(),le=p(),he=p(),ce=p();export{oe as TerrainRenderer,ne as TransparencyMode};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{clamp as l}from"../../../core/mathUtils.js";import{releaseMaybe as o,destroyMaybe as h}from"../../../core/maybe.js";import d from"../../../core/ObjectPool.js";import p from"../../../core/PooledArray.js";import{throwIfAborted as u,isAbortError as c,isAborted as _,createAbortError as g}from"../../../core/promiseUtils.js";import{watch as m,syncAndInitial as T,sync as y,initial as f}from"../../../core/reactiveUtils.js";import{property as v}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/has.js";import{subclass as w}from"../../../core/accessorSupport/decorators/subclass.js";import{m as E}from"../../../chunks/mat4.js";import{c as S}from"../../../chunks/mat4f64.js";import{c as L}from"../../../chunks/vec3.js";import{c as D}from"../../../chunks/vec3f64.js";import{c as P}from"../../../chunks/vec4f64.js";import{UpdatingHandles as b}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as U}from"../../../geometry/ellipsoidUtils.js";import{projectVectorToVector as x,projectPointToVector as R}from"../../../geometry/projection.js";import C from"../../../geometry/SpatialReference.js";import{create as M,equals as j,intersection as A,empty as I,expand as O,intersectsSphere as V}from"../../../geometry/support/aaBoundingRect.js";import{create as B,copy as k}from"../../../geometry/support/frustum.js";import{isPlateCarree as N}from"../../../geometry/support/spatialReferenceUtils.js";import{isRefreshableLayer as q}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as F}from"../../../layers/support/ElevationQueryTileCache.js";import{ElevationTileData as G}from"../../../layers/support/ElevationTileData.js";import{isBaseLayer as W}from"../../../layers/support/layerUtils.js";import{acquireDecoder as H}from"../../../layers/support/LercDecoder.js";import{printAllocations as Q}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as z}from"../support/cameraUtils.js";import X from"../support/debugFlags.js";import{toBoundingRect as Y}from"../support/extentUtils.js";import{ClientType as $}from"../support/index.js";import{updatingProgress as K}from"../support/updatingProperties.js";import{ElevationBounds as J}from"./ElevationBounds.js";import{ElevationData as Z,sampleElevation as ee}from"./ElevationData.js";import{create as te}from"./ExtentHelper.js";import{LODSnapping as ie,TextureUpdate as re}from"./interfaces.js";import{LayerClass as se,LayerClasses as ae}from"./LayerClass.js";import{OverlayManager as ne}from"./OverlayManager.js";import{PlanarPatch as le}from"./PlanarPatch.js";import{RenderOrder as oe}from"./RenderOrder.js";import{ScaleRangeQueries as he}from"./ScaleRangeQueries.js";import{SphericalPatch as de}from"./SphericalPatch.js";import{SplitLimits as pe}from"./SplitLimits.js";import{MAX_ROOT_TILES as ue,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as ce,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as _e,MAX_MEMORY_LOD_BIAS as ge,ELEVATION_NODATA_VALUE as me}from"./TerrainConst.js";import{TerrainRenderer as Te,TransparencyMode as ye}from"./TerrainRenderer.js";import fe from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as ve,internalAssert as we,oppositeEdge as Ee,isSurfaceLayerView as Se,isGroupLayerView as Le,isMapTileLayerView as De,isBlendableLayerView as Pe,isElevationLayerView as be,isVectorTileLayerView as Ue,useFetchTileForLayer as xe,isImageryTileLayerView as Re,isTileLayerView as Ce,releaseTileData as Me,neighborCornerIndices as je,oppositeCorner as Ae,neighborEdgeIndices as Ie,ENABLE_TERRAIN_INTERNAL_CHECKS as Oe,ENABLE_WATERPROOFNESS_TESTS as Ve,enableTerrainInternalChecks as Be,enableTerrainWaterproofnessChecks as ke}from"./terrainUtils.js";import{Tile as Ne}from"./Tile.js";import{printAllocations as qe}from"./TilePerLayerInfo.js";import{TileUpdate as Fe}from"./TileUpdate.js";import{IteratorPreorder as Ge,IteratorPostorder as We,compareTilesByLij as He,hasLoadableSiblings as Qe,sortTilesByPOI as ze,sortTiles as Xe}from"./tileUtils.js";import{TilingSchemeLogic as Ye}from"./TilingSchemeLogic.js";import{UpsampleInfo as $e}from"./UpsampleInfo.js";import{isCompositeBlendMode as Ke,blendModeFromString as Je}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{PBRMode as Ze}from"../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{RenderRequestType as et}from"../webgl-engine/lib/basicInterfaces.js";import{RenderState as tt}from"../../support/RenderState.js";import{ImmediateTask as it,TaskPriority as rt,noBudget as st}from"../../support/Scheduler.js";let at=class extends(a.EventedMixin(i)){constructor(e){super(e),this._scaleRangeQueries=new he,this._iteratorPool=new d(Ge,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new We,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._visibleCached=!1,this._usedMemory=null,this._performanceInfo=new fe,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=D(),this._eyePosSurfaceSR=D(),this._splitLimits=new pe,this._frustum=B(),this._viewProjectionMatrix=S(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new b,this._frameTask=it,this._allTiles=new p,this._upsampleInfoPool=new d($e),this._rootTilesExtent=M(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=C.WebMercator,this.visibleElevationBounds=new J(1/0,-1/0),this.rootTileElevationBounds=new J(1/0,-1/0),this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this.oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateeCarree=!1,this.overlayManager=new ne({...e,surface:this}),this._isGlobal=!e.view?.state?.isLocal}initialize(){this._lercDecoder=H(this.view.resourceController),this._tilePool=this.view.state.isLocal?new d(le):new d(de);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("terrain-upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new F(e.newCache("elevation-query")),this.addHandles([m((()=>this.overlayManager.hasHighlights),(e=>this._renderer.setNeedsHighlight(e))),m((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e))),m((()=>this.overlayManager.renderer.isEmpty),(()=>this._evaluateTransparency()))],"overlayManager"),this._renderer=new Te({_overlayRenderer:this.overlayManager.renderer,_ellipsoidRadius:U(this.view.spatialReference).radius,_stage:this.view._stage,_allTiles:this._allTiles}),this.addHandles([m((()=>this.baseOpacity),(()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?re.UNFADED:re.IMMEDIATE)}),T),m((()=>this.hasCompositeBlendMode),(()=>this._updateTileTextures(this._evaluateTransparency()?re.UNFADED:re.IMMEDIATE)),T),m((()=>this.renderingDisabled),(()=>this.view?._stage?.renderer.setParameters({terrainRenderingEnabled:!this.renderingDisabled})),y),m((()=>this.backgroundColor),(e=>{this._handleLayerViewChanges(),this._renderer.updateTileBackground(e)}),T),m((()=>this.snapLevel),(()=>this._viewChanged=!0),y),m((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>this._allTilesSorted=!1))})),m((()=>X.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&X.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=h(this._treeDebugger))}),f)]);const{spatialReference:t}=this.view;this._extentHelper=te(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:t});const i=new s({getCollections:()=>this.view?.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),r=new Ye({layers:i,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:t});this._set("tilingSchemeLogic",r),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester($.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester($.BASEMAP);const a=this.view.resourceController.scheduler;this._frameTask=a.registerTask(rt.TERRAIN_SURFACE,this),this.addHandles([m((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),f),m((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),y),m((()=>this.extent),(()=>this._updateRootTiles()),f),this.view.on("resize",(()=>this._viewChangeUpdate())),m((()=>{const e=this.view,t=e.state;return[this._lodBias,this.lodSnapping,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),T),m((()=>this.view.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),f),m((()=>this.view.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._renderer.pbrMode=e?Ze.Terrain:Ze.Disabled),f),m((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),y)]),this.addHandles(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._watchUpdatingTracking.destroy(),this._lercDecoder=o(this._lercDecoder),this._removeAllTiles(),this._upsampleMapCache=h(this._upsampleMapCache),this._elevationQueryCache=h(this._elevationQueryCache),this._set("tilingSchemeLogic",h(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",h(this.overlayManager)),this._tilePool=h(this._tilePool),Ne.prune(),this._treeDebugger=h(this._treeDebugger),this._renderer=h(this._renderer),this._iteratorPool=h(this._iteratorPool),this._set("view",null),this._extentHelper=h(this._extentHelper),this._upsampleInfoPool=h(this._upsampleInfoPool),Q(),qe()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){if(this.lodSnapping===ie.ON){const e=this.view,t=this.tilingScheme,i=e.pointsOfInterest?.cameraOnSurface?.scale;if(t&&i){const r=e.state.contentCamera;let s=z(e,r.eye,r.viewForward,r.up).tilt;s>90&&(s=180-s);const a=2*(s/90)**2,n=t.levelAtScale(i)-a,l=Math.min(n+e.qualitySettings.tiledSurface.lodBias,this._splitLimits.maxLod||1/0);return l<=0?null:l}}return null}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?ie.ON:ie.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(null==t||null==e)return null;const i=M(),r=Y(t,i,e)?i:null,s=this._get("extent");return j(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=A(this.groundExtent,this._userClippingExtent,M()),t=this._get("extent");return j(e,t)?t:e}get groundExtent(){return null!=this._tilingSchemeExtent?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this.running||this._watchUpdatingTracking?.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager?.updating)}get running(){return(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries.updating||this._frameTask.updating)&&this.ready&&!this.suspended}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return null!=this._rootTiles}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}set _visible(e){e!==this._visibleCached&&(this._visibleCached=e,this._renderer.setVisibility(e),this.suspended=!e)}get opaque(){return this._renderer.transparency===ye.Opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get textureFadeDuration(){return this.view.qualitySettings.tiledSurface.textureFadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this._rootTiles;if(null==s||!s.length)return null;if(0===s[0].layerInfo[se.ELEVATION].length)return null;const a=dt;if(a[0]=e,a[1]=t,a[2]=i,!x(a,r,a,this._spatialReference))return n.getLogger(this).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;return mt(s,a[0],a[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[se.ELEVATION].length:0;if(null!=r&&r.length&&0!==s)for(let a=0;a<t;++a){const t=3*a;i(a,mt(r,e[t],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getScale(e){if(!this.tilingScheme)return null;if(!R(e,dt,this.spatialReference))return n.getLogger(this).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(null!=t)for(const i of t)if(i?.containsPoint(dt)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;dt[0]>t[2]&&(i+=1),dt[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}getSphereElevationBounds(e,t){if(dt[0]=e[0],dt[1]=e[1],dt[2]=e[2],dt[3]=e[3],!x(dt,t,dt,this.tilingScheme?.spatialReference))return n.getLogger(this).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;let i=1/0,r=-1/0;const s=e=>{if(e&&V(e.extent,dt))if(e.isLeaf||e.rendered)i=Math.min(i,e.elevationBounds[0]),r=Math.max(r,e.elevationBounds[1]);else for(const t of e.children)s(t)},a=this._rootTiles;if(null!=a)for(const n of a)s(n);return{min:i,max:r}}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!R(e,dt,this.spatialReference))return n.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;dt[3]=t;let i=null;const r=e=>{if(e&&V(e.extent,dt)){const t=e.children;if(t[0]&&!e.rendered)for(const e of t)r(e);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}}},s=this._rootTiles;if(null!=s)for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._allSurfaceLayersTransparent()?t?ye.Empty:ye.TransparentWithDraped:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?ye.Opaque:ye.Semitransparent,s=i!==r;return s&&(this._renderer.transparency=r,this.view?._stage?.renderer.setParameters({terrainTransparency:this._renderer.transparency})),s}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;if(!(e!==this.tilingScheme))return;ve(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??C.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateeCarree=this._isWebMercator&&N(this.view?.renderSpatialReference),this._set("tilingScheme",e),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles())}_acquireTile(e,t,i,r){const s=this._tilePool.acquire();return ut[0]=e,ut[1]=t,ut[2]=i,s.init(ut,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=pt;let s=t.rootTilesInExtent(e,i,5*ue);if(null!=this._rootTiles){if(s.length>ue)return void n.getLogger(this).warn(ce);const e=this._rootTiles.map((e=>e.lij)),t=r(e,s,lt);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter((e=>!(t.removed.findIndex((t=>lt(t,e.lij)))>-1)||(this._purgeTile(e),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>ue&&(n.getLogger(this).warn(_e),s=t.rootTilesInExtent(e,i,ue)),this._setRootTiles(s.map((e=>this._newRootTile(e))));j(i,this._rootTilesExtent)||(this._rootTilesExtent=M(i)),this._visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter((e=>e.isLoaded&&e.intersectsClippingArea));e.forEach((e=>this._renderer.updateTileGeometryState(e))),e.forEach((e=>e.renderData.updateNeighborData())),this._updateTilesGeometries(e),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){if(0===e.length)return;e.sort(He);const t=this.renderer;e.forEach((e=>t.updateGeometryIfNeeded(e))),e.forEach((e=>this._pendingTilesForElevationUpdateEvent.add(e)))}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===Fe.SPLIT}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(Fe.SPLIT),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),null!=e){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this._visibleCached&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Fe.GEOMETRY)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(null==e)return;const t=Qe(e),i=this.visibleElevationBounds;let r=t?i.min:1/0,s=t?i.max:-1/0;const a=this.extent,n=this._viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(Fe.GEOMETRY)&&this._updateTileGeometryState(e),e.setPendingUpdate(Fe.RENDERDATA),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBounds[0],r),s=Math.max(e.elevationBounds[1],s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._batchUpdatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new J(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;null!=i&&i.forEach((({elevationBounds:i})=>{e=Math.min(e,i[0]),t=Math.max(t,i[1])}));const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new J(e,t))}_updateViewDependentParameters(){const{camera:e,contentCamera:t}=this.view.state,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?(null==this._splitLimits.frustum&&(this._splitLimits.frustum=B()),k(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,k(this._frustum,e.frustum),E(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),L(this._eyePosRenderSR,t.eye),x(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(ot(e)?this._loadChildren(e):ht(e)&&this._loadParent(e))}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this._usedMemory=null}_markAllTileNeighborsForGeometryUpdate(e){const t=this._pendingTilesToUpdate;e.forEachLoadedNeighbor((e=>{t.add(e)}))}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Fe.TEXTURE_FADING)?Fe.TEXTURE_FADING:!!e.resetPendingUpdate(Fe.TEXTURE_NOFADING)&&Fe.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){const e=_t.extent;I(e),this._pendingTilesForElevationUpdateEvent.forEach((t=>O(e,t.extent,e))),this._pendingTilesForElevationUpdateEvent.clear(),_t.spatialReference=this.spatialReference,this.emit("elevation-change",_t)}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._batchUpdatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed&&this.requestUpdate(),this.notifyChange("updatingProgressValue")}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();t.reset(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;for(;!t.done;){const e=t.next(),a=e.shouldSplit(r,s,i);if(a!==Fe.SPLIT){if(e.resetPendingUpdate(Fe.SPLIT)&&e.updateAgentSuspension(),a===Fe.ELEVATION&&e.updateAgents(se.ELEVATION),t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(Fe.MERGE),e.resetPendingUpdate(Fe.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);const i=this._viewProjectionMatrix;for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(i);t.remove()}}else e.resetPendingUpdate(Fe.MERGE),e.isLeaf&&(e.setPendingUpdate(Fe.SPLIT),t.skipSubtree()),e.rendered&&e.setPendingUpdate(Fe.RENDERDATA)}t.remove(),this.requestUpdate(),(this.shortBatches||!this.oneBatchPerFrameTask)&&this._batchUpdatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(ze(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_markTileToUpdate(e){we(e.isLoaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForGeometryUpdate(e))}_batchUpdatePendingTileGeometries(){const e=this._pendingTilesToUpdate;if(0===e.size)return;const t=Array.from(this._pendingTilesToUpdate.keys()).filter((e=>e.isLoaded&&e.intersectsClippingArea)),i=(i,r)=>{!r?.isLoaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(He);const r=t.length;for(let s=0;s<r;++s){const r=t[s];we(r.isLoaded),we(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a._dirtyEdgeResolutions,l=a.geometryState.neighborData.cornerPeerNeighbors,o=e=>{const t=je[e];i(r,l[e]?.findCorner(Ae(t),(e=>e.isLoaded)))};for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.neighborData.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(Ee(Ie[t]),(t=>!(!t.isLoaded||!t.intersectsClippingArea)&&(we(e.has(t)||He(r,t)<0),i(r,t),!0))),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),Oe&&Ve&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1;const r=this.view.state.fixedContentCamera;let s=!1;for(;!e.done;){s=!0;let a=!1;const n=!this._allTiles.some((s=>{if(!i&&!r&&!s.visible)return e.done;let n=s;if(s.resetPendingUpdate(Fe.MERGE)){if(!t)return s.setPendingUpdate(Fe.MERGE),e.done;for(;n.parent?.resetPendingUpdate(Fe.MERGE);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else s.resetPendingUpdate(Fe.SPLIT)&&(this._splitTile(s),a=!0,e.madeProgress());return!e.done&&n===s&&s.resetPendingUpdate(Fe.RENDERDATA)&&(this._updateRenderData(s),e.madeProgress()),e.done}));if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some((t=>(t.resetPendingUpdate(Fe.GEOMETRY)&&(this._updateTileGeometryState(t),this._updateTileTexture(t,e),this.shortBatches&&this._batchUpdatePendingTileGeometries(),e.madeProgress()),e.done))),!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done)))}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(et.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.quality;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*ge}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=l(e-this._lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){null!=this._rootTiles&&(this._rootTiles.forEach((e=>this._purgeTile(e))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this._visible=!1}_purgeDescendantTiles(e){if(!e.children[0])return!1;let t=!1;for(let i=0;i<4;++i)t=this._purgeTile(e.children[i])||t;return e.unsetChildren(),t}_purgeTile(e){const t=this._purgeDescendantTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),this._unloadTile(e),this._tilePool.release(e),t}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload(this._renderer)}_splitTile(e){ve(e.isLeaf,"tile that is already split should not be split again!");const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2];e.setChildren(this._createTile(t,i,r,e),this._createTile(t,i,r+1,e),this._createTile(t,i+1,r,e),this._createTile(t,i+1,r+1,e)),e.setPendingUpdate(Fe.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){gt.spatialReference=this.spatialReference,gt.extent=e.extent,gt.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",gt)}_createTile(e,t,i,r){ve(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this._viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(Fe.SPLIT),s}get shortBatches(){return this.view.state.mode!==tt.IDLE}_mergeTile(e){ve(!e.hasPendingUpdate(Fe.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(ve(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this.shortBatches&&this._batchUpdatePendingTileGeometries()),this._allTilesDirty=!0,++this._performanceInfo.numMerged}_loadChildren(e){ve(e.rendered,"parent should be rendered"),this._unloadTile(e);const t=e.children;t.forEach((e=>this._loadTile(e))),t.forEach((e=>this._pendingTilesToUpdate.add(e))),this._markAllTileNeighborsForGeometryUpdate(e),this._emitTileScaleChange(e,e.level+1),this.shortBatches&&this._batchUpdatePendingTileGeometries()}_loadParent(e){const t=e.parent;this._unloadChildren(t),this._loadTile(t),this._markTileToUpdate(t),this._emitTileScaleChange(t,t.level),this.shortBatches&&this._batchUpdatePendingTileGeometries()}_unloadChildren(e){const t=e.children;if(t[0])for(let i=0;i<4;++i){const e=t[i];this._unloadChildren(e),this._unloadTile(e)}}_loadTile(e){e.load(),e.setPendingUpdate(Fe.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e)}_elevationDataArrived(e,t,i){const r=new Z(e.lij,e.extent,i);e.dataArrived(t,se.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}0===a&&this._updateRootTileElevationBounds(),n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=st){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(const s of this.view.allLayerViews.items)if(i.add(s.uid),Se(s)||Le(s))if(this._basemapLayerViewHandles.has(s.uid)&&!Le(s)){const e=this._layerClassFromLayerView(s),i=this._getLayerIdxByUID(e,s.uid);null!=i&&((i<r||null==r)&&(t=!0),r=i)}else this._registerTiledLayerView(s),s.layer.loaded&&(t=!0);this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(De(t)&&!W(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((Pe(e)||Le(e))&&Ke(Je[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return be(e)?se.ELEVATION:se.MAP}_registerTiledLayerView(e){const t=[];if((Pe(e)||Le(e))&&t.push(m((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(re.UNFADED)}))),!Le(e)){const i=this._layerClassFromLayerView(e);t.push(m((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(m((()=>e.fullOpacity),(()=>this._updateTileTextures(re.UNFADED)))),t.push(m((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),t.push(e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);null!=t&&this._invalidateLayerData(t,i)})))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(const e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!Se(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===se.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of ae){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this._rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&this._viewChangeUpdate()}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===se.ELEVATION&&i.computeElevationBounds()}this._updateRootTileElevationBounds()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(se.MAP),e===re.IMMEDIATE?this.renderer.updateTileTexture(t,Fe.TEXTURE_NOFADING):t.updateRenderData(se.MAP,e)})),this._evaluateTransparency()}_invalidateLayerData(e,t){this._allTiles.forAll((i=>i.removeLayerAgent(e,t))),this._allTiles.forAll((i=>i.invalidateLayerData(e,t)))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=et.UPDATE){this.renderer.setNeedsRender(e)}requestUpdate(){1==++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||Ue(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.lij[0],e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,u(r),c(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===se.ELEVATION?be(i)?this._requestElevationTileData(e,i,r):Promise.reject():De(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(_(i))return;const s=this._layerIndexByUid[se.ELEVATION].get(t.uid);null!=s?(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,s,r)):n.getLogger(this).warn("TerrainSurface: received data from unknown layer %d %s",se.ELEVATION,e.lij.toString())},s=i=>{c(i)||(this._dataMissing(e,se.ELEVATION,t,i),this.requestUpdate())};if(xe(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:me,signal:i.signal}).then((e=>{if(!_(i))return this._frameTask.schedule((()=>r(e)),i.signal,s);n.getLogger(this).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true.")}),s).finally((()=>{--this._asyncWorkItems}));const a=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);return this._elevationDataRequester.request(a,"binary",i).then((e=>this._lercDecoder.decode(e,{noDataValue:me},i.signal))).then((e=>{e?r(new G(e)):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,Me(s),_(i)||(this._dataMissing(e,se.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),_(i)?Me(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),l=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(Ue(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,l)}if(Re(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,l);if(Ce(t)&&xe(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(_(i))return n.getLogger(this).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void l(g());a(e)}),l);let o=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);q(t.layer)&&t.layer.refreshTimestamp&&(o+=`${o.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const h=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(o,h,i).then(a,l)}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(se.MAP,t.uid);null!=r?e.dataArrived(r,se.MAP,i):(Me(i),n.getLogger(this).warn("TerrainSurface: received data from unknown layer"))}_getLayerIdxByUID(e,t){return this._layerIndexByUid[e].get(t)}_dataMissing(e,t,i,r){const s=this._getLayerIdxByUID(t,i.uid);null!=s?e.dataMissing(s,t,r):n.getLogger(this).warn("TerrainSurface: received data from unknown layer")}updateTileOverlayParams(e){this._rootTiles&&this.overlayManager&&(this._allTiles.forAll((e=>{e.renderData&&this.overlayManager.setTileParameters(e)})),this._renderer.setNeedsRender(e))}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.isLeaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}get usedMemory(){return this.tilingScheme?(null==this._usedMemory&&(this._usedMemory=this._recalculateUsedMemory()),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce(((e,t)=>e+t.usedMemory),this.overlayManager.usedMemory)):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return null!=r&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(null==e||null==this._rootTiles)return null;const t=e.split("/").map((e=>+e));if(0===t[0])return this._rootTiles.find((e=>e.lij[1]===t[1]&&e.lij[2]===t[2]));const i=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(t[2]/i);let a;if(this._rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return ve(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get visualizeNormals(){return this._renderer.visualizeNormals}set visualizeNormals(e){this._renderer.visualizeNormals=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){const e=this;return{renderer:e._renderer,lercDecoder:e._lercDecoder,forceReload:()=>{null!=e._rootTiles&&e._rootTiles.length>0&&(e._mergeTile(e._rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){ct.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&ct.push(e)}));const t=ct.toArray();return Xe(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTilesWaterproofness(){if(!Ve)return;const e=this._rootTiles;if(null==e)return;const t=e=>e?.renderData?.geometry?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometry&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometry||(e.renderData.geometry.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometry),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.isLeaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.isLeaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateeCarree(){return this._isWebMercatorOnPlateeCarree}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&0===e[2]}lijEastEnd(e){return 2**(e+(null!=this.spatialReference&&this.spatialReference.isGeographic?1:0))}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this.isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){Be(e)}enableWaterproofnessChecks(e){ke(e)}};e([v()],at.prototype,"_renderer",void 0),e([v({constructOnly:!0})],at.prototype,"_scaleRangeQueries",void 0),e([v({constructOnly:!0})],at.prototype,"view",void 0),e([v({constructOnly:!0})],at.prototype,"overlayManager",void 0),e([v()],at.prototype,"_hasPendingUpdates",void 0),e([v()],at.prototype,"_asyncWorkItems",void 0),e([v()],at.prototype,"_allTilesDirty",void 0),e([v()],at.prototype,"_allTilesSorted",void 0),e([v()],at.prototype,"_viewChanged",void 0),e([v()],at.prototype,"_splitLimits",void 0),e([v({readOnly:!0})],at.prototype,"_watchUpdatingTracking",void 0),e([v()],at.prototype,"_frameTask",void 0),e([v({readOnly:!0})],at.prototype,"snapLevel",null),e([v({readOnly:!0})],at.prototype,"lodSnapping",null),e([v()],at.prototype,"_userClippingExtent",null),e([v()],at.prototype,"_rootTilesExtent",void 0),e([v({readOnly:!0})],at.prototype,"extent",null),e([v({readOnly:!0})],at.prototype,"groundExtent",null),e([v({readOnly:!0})],at.prototype,"_tilingSchemeExtent",null),e([v({readOnly:!0})],at.prototype,"updating",null),e([v({readOnly:!0})],at.prototype,"running",null),e([v(K)],at.prototype,"updatingProgress",void 0),e([v({readOnly:!0})],at.prototype,"updatingProgressValue",null),e([v()],at.prototype,"_maxNumUpdating",void 0),e([v()],at.prototype,"baseOpacity",null),e([v()],at.prototype,"hasCompositeBlendMode",void 0),e([v({readOnly:!0})],at.prototype,"viewingMode",null),e([v()],at.prototype,"maxTextureScale",void 0),e([v({readOnly:!0})],at.prototype,"ready",null),e([v({value:oe.FRONT_TO_BACK})],at.prototype,"renderOrder",null),e([v({readOnly:!0})],at.prototype,"rootTiles",null),e([v()],at.prototype,"_rootTiles",void 0),e([v({readOnly:!0})],at.prototype,"spatialReference",null),e([v({type:t})],at.prototype,"backgroundColor",null),e([v({value:!1})],at.prototype,"slicePlaneEnabled",null),e([v({readOnly:!0})],at.prototype,"tilingScheme",void 0),e([v({readOnly:!0})],at.prototype,"tilingSchemeLocked",null),e([v({readOnly:!0})],at.prototype,"tilingSchemeLogic",void 0),e([v()],at.prototype,"wireframe",null),e([v({value:!1})],at.prototype,"suspended",null),e([v()],at.prototype,"textureFadeDuration",null),e([v()],at.prototype,"visibleElevationBounds",void 0),e([v()],at.prototype,"rootTileElevationBounds",void 0),e([v()],at.prototype,"_layerViewsDirty",void 0),e([v()],at.prototype,"renderPatchBorders",null),e([v()],at.prototype,"visualizeNormals",null),e([v()],at.prototype,"renderingDisabled",null),at=e([w("esri.views.3d.terrain.TerrainSurface")],at);const nt=at;function lt(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function ot(e){const t=e.children;if(!t[0])return!1;for(const i of t)if(i.shouldLoad)return!0;for(const i of t)if(ot(i))return!0;return!1}function ht(e){return e.isLeaf&&(e.parent?.shouldLoad??!1)}const dt=P(),pt=M(),ut=[0,0,0],ct=new p,_t={spatialReference:null,extent:M(),context:"ground"},gt={spatialReference:null,extent:null,scale:0};function mt(e,t,i){for(const r of e){if(!r.containsPointXY(t,i))continue;let e=r;for(;e&&!e.renderData;){const r=(t>e.extentMidX?1:0)+(i<e.extentMidY?2:0);e=e.children[r]}const s=e?.renderData?.geometryState.samplerData??null;return ee(t,i,s)}return null}export{nt as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{clamp as l}from"../../../core/mathUtils.js";import{releaseMaybe as o,destroyMaybe as h}from"../../../core/maybe.js";import{MemCachePool as d}from"../../../core/MemCachePool.js";import p from"../../../core/ObjectPool.js";import u from"../../../core/PooledArray.js";import{throwIfAborted as c,isAbortError as _,isAborted as g,createAbortError as m}from"../../../core/promiseUtils.js";import{watch as T,syncAndInitial as y,sync as f,initial as v}from"../../../core/reactiveUtils.js";import{property as w}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/has.js";import{subclass as E}from"../../../core/accessorSupport/decorators/subclass.js";import{m as S}from"../../../chunks/mat4.js";import{c as L}from"../../../chunks/mat4f64.js";import{c as D}from"../../../chunks/vec3.js";import{c as P}from"../../../chunks/vec3f64.js";import{c as b}from"../../../chunks/vec4f64.js";import{UpdatingHandles as x}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as U}from"../../../geometry/ellipsoidUtils.js";import{projectVectorToVector as R,projectPointToVector as C}from"../../../geometry/projection.js";import M from"../../../geometry/SpatialReference.js";import{create as j,equals as A,intersection as I,empty as O,expand as V,intersectsSphere as B}from"../../../geometry/support/aaBoundingRect.js";import{create as k,copy as N}from"../../../geometry/support/frustum.js";import{isPlateCarree as q}from"../../../geometry/support/spatialReferenceUtils.js";import{isRefreshableLayer as F}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as G}from"../../../layers/support/ElevationQueryTileCache.js";import{ElevationTileData as W}from"../../../layers/support/ElevationTileData.js";import{isBaseLayer as H}from"../../../layers/support/layerUtils.js";import{acquireDecoder as Q}from"../../../layers/support/LercDecoder.js";import{printAllocations as z}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as X}from"../support/cameraUtils.js";import Y from"../support/debugFlags.js";import{toBoundingRect as $}from"../support/extentUtils.js";import{ClientType as K}from"../support/index.js";import{updatingProgress as J}from"../support/updatingProperties.js";import{ElevationBounds as Z}from"./ElevationBounds.js";import{ElevationData as ee,sampleElevation as te}from"./ElevationData.js";import{create as ie}from"./ExtentHelper.js";import{LODSnapping as re,TextureUpdate as se}from"./interfaces.js";import{LayerClass as ae,LayerClasses as ne}from"./LayerClass.js";import{OverlayManager as le}from"./OverlayManager.js";import{PlanarPatch as oe}from"./PlanarPatch.js";import{RenderOrder as he}from"./RenderOrder.js";import{ScaleRangeQueries as de}from"./ScaleRangeQueries.js";import{SphericalPatch as pe}from"./SphericalPatch.js";import{SplitLimits as ue}from"./SplitLimits.js";import{MAX_ROOT_TILES as ce,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as _e,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as ge,MAX_MEMORY_LOD_BIAS as me,ELEVATION_NODATA_VALUE as Te}from"./TerrainConst.js";import{TerrainRenderer as ye,TransparencyMode as fe}from"./TerrainRenderer.js";import ve from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as we,internalAssert as Ee,oppositeEdge as Se,isSurfaceLayerView as Le,isGroupLayerView as De,isMapTileLayerView as Pe,isBlendableLayerView as be,isElevationLayerView as xe,isVectorTileLayerView as Ue,useFetchTileForLayer as Re,isImageryTileLayerView as Ce,isTileLayerView as Me,releaseTileData as je,neighborCornerIndices as Ae,oppositeCorner as Ie,neighborEdgeIndices as Oe,ENABLE_TERRAIN_INTERNAL_CHECKS as Ve,ENABLE_WATERPROOFNESS_TESTS as Be,enableTerrainInternalChecks as ke,enableTerrainWaterproofnessChecks as Ne}from"./terrainUtils.js";import{Tile as qe}from"./Tile.js";import{printAllocations as Fe}from"./TilePerLayerInfo.js";import{TileUpdate as Ge}from"./TileUpdate.js";import{IteratorPreorder as We,IteratorPostorder as He,compareTilesByLij as Qe,hasLoadableSiblings as ze,sortTilesByPOI as Xe,sortTiles as Ye}from"./tileUtils.js";import{TilingSchemeLogic as $e}from"./TilingSchemeLogic.js";import{UpsampleInfo as Ke}from"./UpsampleInfo.js";import{isCompositeBlendMode as Je,blendModeFromString as Ze}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{PBRMode as et}from"../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{RenderRequestType as tt}from"../webgl-engine/lib/basicInterfaces.js";import{RenderState as it}from"../../support/RenderState.js";import{ImmediateTask as rt,TaskPriority as st,noBudget as at}from"../../support/Scheduler.js";let nt=class extends(a.EventedMixin(i)){constructor(e){super(e),this._scaleRangeQueries=new de,this._iteratorPool=new p(We,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new He,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._visibleCached=!1,this._usedMemory=null,this._performanceInfo=new ve,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=P(),this._eyePosSurfaceSR=P(),this._splitLimits=new ue,this._frustum=k(),this._viewProjectionMatrix=L(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new x,this._frameTask=rt,this._allTiles=new u,this._upsampleInfoPool=new p(Ke),this._rootTilesExtent=j(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=M.WebMercator,this.visibleElevationBounds=new Z(1/0,-1/0),this.rootTileElevationBounds=new Z(1/0,-1/0),this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this.oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateeCarree=!1,this.overlayManager=new le({...e,surface:this}),this._isGlobal=!e.view?.state?.isLocal}initialize(){this._lercDecoder=Q(this.view.resourceController),this._tilePool=this.view.state.isLocal?new p(oe):new p(pe);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("terrain-upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new G(e.newCache("elevation-query")),this._tileTextureCache=new d(((t,i)=>e.newCache(t,i)),"TileTexture"),this.addHandles([T((()=>this.overlayManager.hasHighlights),(e=>this._renderer.setNeedsHighlight(e))),T((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e))),T((()=>this.overlayManager.renderer.isEmpty),(()=>this._evaluateTransparency()))],"overlayManager"),this._renderer=new ye({_overlayRenderer:this.overlayManager.renderer,_ellipsoidRadius:U(this.view.spatialReference).radius,_stage:this.view._stage,_allTiles:this._allTiles,_cache:this._tileTextureCache}),this.addHandles([T((()=>this.baseOpacity),(()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?se.UNFADED:se.IMMEDIATE)}),y),T((()=>this.hasCompositeBlendMode),(()=>this._updateTileTextures(this._evaluateTransparency()?se.UNFADED:se.IMMEDIATE)),y),T((()=>this.renderingDisabled),(()=>this.view?._stage?.renderer.setParameters({terrainRenderingEnabled:!this.renderingDisabled})),f),T((()=>this.backgroundColor),(e=>{this._handleLayerViewChanges(),this._renderer.updateTileBackground(e)}),y),T((()=>this.snapLevel),(()=>this._viewChanged=!0),f),T((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>this._allTilesSorted=!1))})),T((()=>Y.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&Y.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=h(this._treeDebugger))}),v)]);const{spatialReference:t}=this.view;this._extentHelper=ie(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:t});const i=new s({getCollections:()=>this.view?.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),r=new $e({layers:i,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:t});this._set("tilingSchemeLogic",r),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester(K.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester(K.BASEMAP);const a=this.view.resourceController.scheduler;this._frameTask=a.registerTask(st.TERRAIN_SURFACE,this),this.addHandles([T((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),v),T((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),f),T((()=>this.extent),(()=>this._updateRootTiles()),v),this.view.on("resize",(()=>this._viewChangeUpdate())),T((()=>{const e=this.view,t=e.state;return[this._lodBias,this.lodSnapping,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),y),T((()=>this.view.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),v),T((()=>this.view.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._renderer.pbrMode=e?et.Terrain:et.Disabled),v),T((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),f)]),this.addHandles(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._watchUpdatingTracking.destroy(),this._lercDecoder=o(this._lercDecoder),this._removeAllTiles(),this._set("tilingSchemeLogic",h(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",h(this.overlayManager)),this._tilePool=h(this._tilePool),qe.prune(),this._treeDebugger=h(this._treeDebugger),this._renderer=h(this._renderer),this._iteratorPool=h(this._iteratorPool),this._upsampleMapCache=h(this._upsampleMapCache),this._elevationQueryCache=h(this._elevationQueryCache),this._tileTextureCache=h(this._tileTextureCache),this._set("view",null),this._extentHelper=h(this._extentHelper),this._upsampleInfoPool=h(this._upsampleInfoPool),z(),Fe()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){if(this.lodSnapping===re.ON){const e=this.view,t=this.tilingScheme,i=e.pointsOfInterest?.cameraOnSurface?.scale;if(t&&i){const r=e.state.contentCamera;let s=X(e,r.eye,r.viewForward,r.up).tilt;s>90&&(s=180-s);const a=2*(s/90)**2,n=t.levelAtScale(i)-a,l=Math.min(n+e.qualitySettings.tiledSurface.lodBias,this._splitLimits.maxLod||1/0);return l<=0?null:l}}return null}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?re.ON:re.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(null==t||null==e)return null;const i=j(),r=$(t,i,e)?i:null,s=this._get("extent");return A(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=I(this.groundExtent,this._userClippingExtent,j()),t=this._get("extent");return A(e,t)?t:e}get groundExtent(){return null!=this._tilingSchemeExtent?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this.running||this._watchUpdatingTracking?.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager?.updating)}get running(){return(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries.updating||this._frameTask.updating)&&this.ready&&!this.suspended}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return null!=this._rootTiles}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}set _visible(e){e!==this._visibleCached&&(this._visibleCached=e,this._renderer.setVisibility(e),this.suspended=!e)}get opaque(){return this._renderer.transparency===fe.Opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get textureFadeDuration(){return this.view.qualitySettings.tiledSurface.textureFadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this._rootTiles;if(null==s||!s.length)return null;if(0===s[0].layerInfo[ae.ELEVATION].length)return null;const a=pt;if(a[0]=e,a[1]=t,a[2]=i,!R(a,r,a,this._spatialReference))return n.getLogger(this).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;return Tt(s,a[0],a[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[ae.ELEVATION].length:0;if(null!=r&&r.length&&0!==s)for(let a=0;a<t;++a){const t=3*a;i(a,Tt(r,e[t],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getScale(e){if(!this.tilingScheme)return null;if(!C(e,pt,this.spatialReference))return n.getLogger(this).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(null!=t)for(const i of t)if(i?.containsPoint(pt)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;pt[0]>t[2]&&(i+=1),pt[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}getSphereElevationBounds(e,t){if(pt[0]=e[0],pt[1]=e[1],pt[2]=e[2],pt[3]=e[3],!R(pt,t,pt,this.tilingScheme?.spatialReference))return n.getLogger(this).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;let i=1/0,r=-1/0;const s=e=>{if(e&&B(e.extent,pt))if(e.isLeaf||e.rendered)i=Math.min(i,e.elevationBounds[0]),r=Math.max(r,e.elevationBounds[1]);else for(const t of e.children)s(t)},a=this._rootTiles;if(null!=a)for(const n of a)s(n);return{min:i,max:r}}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!C(e,pt,this.spatialReference))return n.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;pt[3]=t;let i=null;const r=e=>{if(e&&B(e.extent,pt)){const t=e.children;if(t[0]&&!e.rendered)for(const e of t)r(e);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}}},s=this._rootTiles;if(null!=s)for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._allSurfaceLayersTransparent()?t?fe.Empty:fe.TransparentWithDraped:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?fe.Opaque:fe.Semitransparent,s=i!==r;return s&&(this._renderer.transparency=r,this.view?._stage?.renderer.setParameters({terrainTransparency:this._renderer.transparency})),s}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;if(!(e!==this.tilingScheme))return;we(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??M.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateeCarree=this._isWebMercator&&q(this.view?.renderSpatialReference),this._set("tilingScheme",e),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles())}_acquireTile(e,t,i,r){const s=this._tilePool.acquire();return ct[0]=e,ct[1]=t,ct[2]=i,s.init(ct,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=ut;let s=t.rootTilesInExtent(e,i,5*ce);if(null!=this._rootTiles){if(s.length>ce)return void n.getLogger(this).warn(_e);const e=this._rootTiles.map((e=>e.lij)),t=r(e,s,ot);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter((e=>!(t.removed.findIndex((t=>ot(t,e.lij)))>-1)||(this._purgeTile(e),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>ce&&(n.getLogger(this).warn(ge),s=t.rootTilesInExtent(e,i,ce)),this._setRootTiles(s.map((e=>this._newRootTile(e))));A(i,this._rootTilesExtent)||(this._rootTilesExtent=j(i)),this._visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter((e=>e.isLoaded&&e.intersectsClippingArea));e.forEach((e=>this._renderer.updateTileGeometryState(e))),e.forEach((e=>e.renderData.updateNeighborData())),this._updateTilesGeometries(e),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){if(0===e.length)return;e.sort(Qe);const t=this.renderer;e.forEach((e=>t.updateGeometryIfNeeded(e))),e.forEach((e=>this._pendingTilesForElevationUpdateEvent.add(e)))}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===Ge.SPLIT}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(Ge.SPLIT),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),null!=e){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this._visibleCached&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Ge.GEOMETRY)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(null==e)return;const t=ze(e),i=this.visibleElevationBounds;let r=t?i.min:1/0,s=t?i.max:-1/0;const a=this.extent,n=this._viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(Ge.GEOMETRY)&&this._updateTileGeometryState(e),e.setPendingUpdate(Ge.RENDERDATA),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBounds[0],r),s=Math.max(e.elevationBounds[1],s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._batchUpdatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new Z(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;null!=i&&i.forEach((({elevationBounds:i})=>{e=Math.min(e,i[0]),t=Math.max(t,i[1])}));const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new Z(e,t))}_updateViewDependentParameters(){const{camera:e,contentCamera:t}=this.view.state,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?(null==this._splitLimits.frustum&&(this._splitLimits.frustum=k()),N(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,N(this._frustum,e.frustum),S(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),D(this._eyePosRenderSR,t.eye),R(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(ht(e)?this._loadChildren(e):dt(e)&&this._loadParent(e))}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this._usedMemory=null}_markAllTileNeighborsForGeometryUpdate(e){const t=this._pendingTilesToUpdate;e.forEachLoadedNeighbor((e=>{t.add(e)}))}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Ge.TEXTURE_FADING)?Ge.TEXTURE_FADING:!!e.resetPendingUpdate(Ge.TEXTURE_NOFADING)&&Ge.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){const e=gt.extent;O(e),this._pendingTilesForElevationUpdateEvent.forEach((t=>V(e,t.extent,e))),this._pendingTilesForElevationUpdateEvent.clear(),gt.spatialReference=this.spatialReference,this.emit("elevation-change",gt)}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._batchUpdatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed&&this.requestUpdate(),this.notifyChange("updatingProgressValue")}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();t.reset(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;for(;!t.done;){const e=t.next(),a=e.shouldSplit(r,s,i);if(a!==Ge.SPLIT){if(e.resetPendingUpdate(Ge.SPLIT)&&e.updateAgentSuspension(),a===Ge.ELEVATION&&e.updateAgents(ae.ELEVATION),t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(Ge.MERGE),e.resetPendingUpdate(Ge.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);const i=this._viewProjectionMatrix;for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(i);t.remove()}}else e.resetPendingUpdate(Ge.MERGE),e.isLeaf&&(e.setPendingUpdate(Ge.SPLIT),t.skipSubtree()),e.rendered&&e.setPendingUpdate(Ge.RENDERDATA)}t.remove(),this.requestUpdate(),(this.shortBatches||!this.oneBatchPerFrameTask)&&this._batchUpdatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Xe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_markTileToUpdate(e){Ee(e.isLoaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForGeometryUpdate(e))}_batchUpdatePendingTileGeometries(){const e=this._pendingTilesToUpdate;if(0===e.size)return;const t=Array.from(this._pendingTilesToUpdate.keys()).filter((e=>e.isLoaded&&e.intersectsClippingArea)),i=(i,r)=>{!r?.isLoaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(Qe);const r=t.length;for(let s=0;s<r;++s){const r=t[s];Ee(r.isLoaded),Ee(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a._dirtyEdgeResolutions,l=a.geometryState.neighborData.cornerPeerNeighbors,o=e=>{const t=Ae[e];i(r,l[e]?.findCorner(Ie(t),(e=>e.isLoaded)))};for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.neighborData.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(Se(Oe[t]),(t=>!(!t.isLoaded||!t.intersectsClippingArea)&&(Ee(e.has(t)||Qe(r,t)<0),i(r,t),!0))),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),Ve&&Be&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1;const r=this.view.state.fixedContentCamera;let s=!1;for(;!e.done;){s=!0;let a=!1;const n=!this._allTiles.some((s=>{if(!i&&!r&&!s.visible)return e.done;let n=s;if(s.resetPendingUpdate(Ge.MERGE)){if(!t)return s.setPendingUpdate(Ge.MERGE),e.done;for(;n.parent?.resetPendingUpdate(Ge.MERGE);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else s.resetPendingUpdate(Ge.SPLIT)&&(this._splitTile(s),a=!0,e.madeProgress());return!e.done&&n===s&&s.resetPendingUpdate(Ge.RENDERDATA)&&(this._updateRenderData(s),e.madeProgress()),e.done}));if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some((t=>(t.resetPendingUpdate(Ge.GEOMETRY)&&(this._updateTileGeometryState(t),this._updateTileTexture(t,e),this.shortBatches&&this._batchUpdatePendingTileGeometries(),e.madeProgress()),e.done))),!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done)))}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(tt.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.quality;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*me}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=l(e-this._lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){null!=this._rootTiles&&(this._rootTiles.forEach((e=>this._purgeTile(e))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this._visible=!1}_purgeDescendantTiles(e){if(!e.children[0])return!1;let t=!1;for(let i=0;i<4;++i)t=this._purgeTile(e.children[i])||t;return e.unsetChildren(),t}_purgeTile(e){const t=this._purgeDescendantTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),this._unloadTile(e),this._tilePool.release(e),t}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload(this._renderer)}_splitTile(e){we(e.isLeaf,"tile that is already split should not be split again!");const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2];e.setChildren(this._createTile(t,i,r,e),this._createTile(t,i,r+1,e),this._createTile(t,i+1,r,e),this._createTile(t,i+1,r+1,e)),e.setPendingUpdate(Ge.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){mt.spatialReference=this.spatialReference,mt.extent=e.extent,mt.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",mt)}_createTile(e,t,i,r){we(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this._viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(Ge.SPLIT),s}get shortBatches(){return this.view.state.mode!==it.IDLE}_mergeTile(e){we(!e.hasPendingUpdate(Ge.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(we(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this.shortBatches&&this._batchUpdatePendingTileGeometries()),this._allTilesDirty=!0,++this._performanceInfo.numMerged}_loadChildren(e){we(e.rendered,"parent should be rendered"),this._unloadTile(e);const t=e.children;t.forEach((e=>this._loadTile(e))),t.forEach((e=>this._pendingTilesToUpdate.add(e))),this._markAllTileNeighborsForGeometryUpdate(e),this._emitTileScaleChange(e,e.level+1),this.shortBatches&&this._batchUpdatePendingTileGeometries()}_loadParent(e){const t=e.parent;this._unloadChildren(t),this._loadTile(t),this._markTileToUpdate(t),this._emitTileScaleChange(t,t.level),this.shortBatches&&this._batchUpdatePendingTileGeometries()}_unloadChildren(e){const t=e.children;if(t[0])for(let i=0;i<4;++i){const e=t[i];this._unloadChildren(e),this._unloadTile(e)}}_loadTile(e){e.load(),e.setPendingUpdate(Ge.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e)}_elevationDataArrived(e,t,i){const r=new ee(e.lij,e.extent,i);e.dataArrived(t,ae.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}0===a&&this._updateRootTileElevationBounds(),n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=at){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(const s of this.view.allLayerViews.items)if(i.add(s.uid),Le(s)||De(s))if(this._basemapLayerViewHandles.has(s.uid)&&!De(s)){const e=this._layerClassFromLayerView(s),i=this._getLayerIdxByUID(e,s.uid);null!=i&&((i<r||null==r)&&(t=!0),r=i)}else this._registerTiledLayerView(s),s.layer.loaded&&(t=!0);this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(Pe(t)&&!H(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((be(e)||De(e))&&Je(Ze[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return xe(e)?ae.ELEVATION:ae.MAP}_registerTiledLayerView(e){const t=[];if((be(e)||De(e))&&t.push(T((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(se.UNFADED)}))),!De(e)){const i=this._layerClassFromLayerView(e);t.push(T((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(T((()=>e.fullOpacity),(()=>this._updateTileTextures(se.UNFADED)))),t.push(T((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),t.push(e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);null!=t&&this._invalidateLayerData(t,i)})))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(const e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!Le(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===ae.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of ne){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this._rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&this._viewChangeUpdate()}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===ae.ELEVATION&&i.computeElevationBounds()}this._updateRootTileElevationBounds()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(ae.MAP),e===se.IMMEDIATE?this.renderer.updateTileTexture(t,Ge.TEXTURE_NOFADING):t.updateRenderData(ae.MAP,e)})),this._evaluateTransparency()}_invalidateLayerData(e,t){this._allTiles.forAll((i=>i.removeLayerAgent(e,t))),this._allTiles.forAll((i=>i.invalidateLayerData(e,t)))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=tt.UPDATE){this.renderer.setNeedsRender(e)}requestUpdate(){1==++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||Ue(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.lij[0],e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,c(r),_(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===ae.ELEVATION?xe(i)?this._requestElevationTileData(e,i,r):Promise.reject():Pe(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(g(i))return;const s=this._layerIndexByUid[ae.ELEVATION].get(t.uid);null!=s?(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,s,r)):n.getLogger(this).warn("TerrainSurface: received data from unknown layer %d %s",ae.ELEVATION,e.lij.toString())},s=i=>{_(i)||(this._dataMissing(e,ae.ELEVATION,t,i),this.requestUpdate())};if(Re(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:Te,signal:i.signal}).then((e=>{if(!g(i))return this._frameTask.schedule((()=>r(e)),i.signal,s);n.getLogger(this).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true.")}),s).finally((()=>{--this._asyncWorkItems}));const a=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);return this._elevationDataRequester.request(a,"binary",i).then((e=>this._lercDecoder.decode(e,{noDataValue:Te},i.signal))).then((e=>{e?r(new W(e)):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,je(s),g(i)||(this._dataMissing(e,ae.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),g(i)?je(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),l=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(Ue(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,l)}if(Ce(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,l);if(Me(t)&&Re(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(g(i))return n.getLogger(this).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void l(m());a(e)}),l);let o=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);F(t.layer)&&t.layer.refreshTimestamp&&(o+=`${o.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const h=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(o,h,i).then(a,l)}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(ae.MAP,t.uid);null!=r?e.dataArrived(r,ae.MAP,i):(je(i),n.getLogger(this).warn("TerrainSurface: received data from unknown layer"))}_getLayerIdxByUID(e,t){return this._layerIndexByUid[e].get(t)}_dataMissing(e,t,i,r){const s=this._getLayerIdxByUID(t,i.uid);null!=s?e.dataMissing(s,t,r):n.getLogger(this).warn("TerrainSurface: received data from unknown layer")}updateTileOverlayParams(e){this._rootTiles&&this.overlayManager&&(this._allTiles.forAll((e=>{e.renderData&&this.overlayManager.setTileParameters(e)})),this._renderer.setNeedsRender(e))}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.isLeaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}get usedMemory(){return this.tilingScheme?(null==this._usedMemory&&(this._usedMemory=this._recalculateUsedMemory()),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce(((e,t)=>e+t.usedMemory),this.overlayManager.usedMemory)):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return null!=r&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(null==e||null==this._rootTiles)return null;const t=e.split("/").map((e=>+e));if(0===t[0])return this._rootTiles.find((e=>e.lij[1]===t[1]&&e.lij[2]===t[2]));const i=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(t[2]/i);let a;if(this._rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return we(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get visualizeNormals(){return this._renderer.visualizeNormals}set visualizeNormals(e){this._renderer.visualizeNormals=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){const e=this;return{renderer:e._renderer,lercDecoder:e._lercDecoder,forceReload:()=>{null!=e._rootTiles&&e._rootTiles.length>0&&(e._mergeTile(e._rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){_t.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&_t.push(e)}));const t=_t.toArray();return Ye(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTilesWaterproofness(){if(!Be)return;const e=this._rootTiles;if(null==e)return;const t=e=>e?.renderData?.geometry?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometry&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometry||(e.renderData.geometry.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometry),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.isLeaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.isLeaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateeCarree(){return this._isWebMercatorOnPlateeCarree}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&0===e[2]}lijEastEnd(e){return 2**(e+(null!=this.spatialReference&&this.spatialReference.isGeographic?1:0))}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this.isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){ke(e)}enableWaterproofnessChecks(e){Ne(e)}};e([w()],nt.prototype,"_renderer",void 0),e([w({constructOnly:!0})],nt.prototype,"_scaleRangeQueries",void 0),e([w({constructOnly:!0})],nt.prototype,"view",void 0),e([w({constructOnly:!0})],nt.prototype,"overlayManager",void 0),e([w()],nt.prototype,"_hasPendingUpdates",void 0),e([w()],nt.prototype,"_asyncWorkItems",void 0),e([w()],nt.prototype,"_allTilesDirty",void 0),e([w()],nt.prototype,"_allTilesSorted",void 0),e([w()],nt.prototype,"_viewChanged",void 0),e([w()],nt.prototype,"_splitLimits",void 0),e([w({readOnly:!0})],nt.prototype,"_watchUpdatingTracking",void 0),e([w()],nt.prototype,"_frameTask",void 0),e([w({readOnly:!0})],nt.prototype,"snapLevel",null),e([w({readOnly:!0})],nt.prototype,"lodSnapping",null),e([w()],nt.prototype,"_userClippingExtent",null),e([w()],nt.prototype,"_rootTilesExtent",void 0),e([w({readOnly:!0})],nt.prototype,"extent",null),e([w({readOnly:!0})],nt.prototype,"groundExtent",null),e([w({readOnly:!0})],nt.prototype,"_tilingSchemeExtent",null),e([w({readOnly:!0})],nt.prototype,"updating",null),e([w({readOnly:!0})],nt.prototype,"running",null),e([w(J)],nt.prototype,"updatingProgress",void 0),e([w({readOnly:!0})],nt.prototype,"updatingProgressValue",null),e([w()],nt.prototype,"_maxNumUpdating",void 0),e([w()],nt.prototype,"baseOpacity",null),e([w()],nt.prototype,"hasCompositeBlendMode",void 0),e([w({readOnly:!0})],nt.prototype,"viewingMode",null),e([w()],nt.prototype,"maxTextureScale",void 0),e([w({readOnly:!0})],nt.prototype,"ready",null),e([w({value:he.FRONT_TO_BACK})],nt.prototype,"renderOrder",null),e([w({readOnly:!0})],nt.prototype,"rootTiles",null),e([w()],nt.prototype,"_rootTiles",void 0),e([w({readOnly:!0})],nt.prototype,"spatialReference",null),e([w({type:t})],nt.prototype,"backgroundColor",null),e([w({value:!1})],nt.prototype,"slicePlaneEnabled",null),e([w({readOnly:!0})],nt.prototype,"tilingScheme",void 0),e([w({readOnly:!0})],nt.prototype,"tilingSchemeLocked",null),e([w({readOnly:!0})],nt.prototype,"tilingSchemeLogic",void 0),e([w()],nt.prototype,"wireframe",null),e([w({value:!1})],nt.prototype,"suspended",null),e([w()],nt.prototype,"textureFadeDuration",null),e([w()],nt.prototype,"visibleElevationBounds",void 0),e([w()],nt.prototype,"rootTileElevationBounds",void 0),e([w()],nt.prototype,"_layerViewsDirty",void 0),e([w()],nt.prototype,"renderPatchBorders",null),e([w()],nt.prototype,"visualizeNormals",null),e([w()],nt.prototype,"renderingDisabled",null),nt=e([E("esri.views.3d.terrain.TerrainSurface")],nt);const lt=nt;function ot(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function ht(e){const t=e.children;if(!t[0])return!1;for(const i of t)if(i.shouldLoad)return!0;for(const i of t)if(ht(i))return!0;return!1}function dt(e){return e.isLeaf&&(e.parent?.shouldLoad??!1)}const pt=b(),ut=j(),ct=[0,0,0],_t=new u,gt={spatialReference:null,extent:j(),context:"ground"},mt={spatialReference:null,extent:null,scale:0};function Tt(e,t,i){for(const r of e){if(!r.containsPointXY(t,i))continue;let e=r;for(;e&&!e.renderData;){const r=(t>e.extentMidX?1:0)+(i<e.extentMidY?2:0);e=e.children[r]}const s=e?.renderData?.geometryState.samplerData??null;return te(t,i,s)}return null}export{lt as default};
|
package/views/3d/terrain/Tile.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{clamp as e}from"../../../core/mathUtils.js";import{abortMaybe as t}from"../../../core/maybe.js";import i from"../../../core/ObjectPool.js";import{j as s,s as n}from"../../../chunks/vec2.js";import{a as r}from"../../../chunks/vec2f64.js";import{b as a,p as o,e as l,g as h,a as u,l as d,c}from"../../../chunks/vec3.js";import{c as g,u as p}from"../../../chunks/vec3f64.js";import{g as f}from"../../../chunks/common.js";import{getReferenceEllipsoid as m}from"../../../geometry/ellipsoidUtils.js";import{create as _,equals as y}from"../../../geometry/support/aaBoundingRect.js";import{c as A}from"../../../chunks/sphere.js";import{isGroupLayer as T}from"../../../layers/support/layerUtils.js";import{VectorTile as E}from"../../2d/engine/vectorTiles/VectorTile.js";import{ImageWithType as v}from"../support/StreamDataLoader.js";import{ElevationBounds as I}from"./ElevationBounds.js";import{ElevationTileAgent as M}from"./ElevationTileAgent.js";import{TextureUpdate as D}from"./interfaces.js";import{TileFrustumVisibility as L,NeighborIndex as x}from"./ITile.js";import{LayerClasses as S,LayerClass as O}from"./LayerClass.js";import{MapTileAgent as N}from"./MapTileAgent.js";import{RasterTile as j}from"./RasterTile.js";import{MAX_PATCH_TESSELATION as b,getElevationDesiredResolutionLevel as U}from"./TerrainConst.js";import{weakAssert as C,getLayerWithExtentRange as P,isBlendableLayerView as B,oppositeCorner as R,neighborCornerIndices as V,neighborEdgeIndices as w,oppositeEdge as G,internalAssert as W,ENABLE_TERRAIN_INTERNAL_CHECKS as q,isNorth as F,isSouth as H,isWest as k,isEast as X,ENABLE_WATERPROOFNESS_TESTS as Y,almostEquals as z,isWestCorner as $,isNorthCorner as J}from"./terrainUtils.js";import{TILE_AGENT_DONE as Q}from"./TileAgent.js";import{TilePerLayerInfo as K}from"./TilePerLayerInfo.js";import Z from"./TileTexture.js";import{TileUpdate as ee}from"./TileUpdate.js";import{fallsWithinLayer as te}from"./tileUtils.js";const ie=.1;class se{constructor(){this.lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this.renderData=null,this._dirty=!0,this._previouslyRendered=!1,this.extent=_(),this._elevationBounds=r(),this.layerInfo=[[],[]],this.extentInRadians=_(),this.centerAtSeaLevel=g(),this._center=[g(),A(),g()],this.up=p(),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=null,this._mapTileMemoryInternal=0,this._mapDataRefCount=0,this.screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0,this.extentMidX=0,this.extentMidY=0,this.distanceToPOI=-1,this._lastPOI=g()}static prune(){ae.prune(0),oe.prune(0),K.prune()}get _isCached(){return!this.shouldLoad&&this._mapDataRefCount<=0}get maxTesselation(){return this._maxTesselation}get isWithinClippingArea(){return this._isWithinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBounds(){return this._elevationBounds}get level(){return this.lij[0]}get key(){return`${this.lij[0]}/${this.lij[1]}/${this.lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[he.MIDDLE][3]}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}computeVisibility(){this._dirty=!1;const e=this.parent,t=e?.frustumVisibility??L.INTERSECTS;this._frustumVisibility=t===L.INSIDE?L.INSIDE:t===L.OUTSIDE?L.OUTSIDE:this._calculateFrustumVisibilityStatus(this.surface.frustum);const i=this._frustumVisibility!==L.OUTSIDE&&this._intersectsClippingArea;i!==this._visible&&(this._visible=i,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setDirty(),this.updateAgentSuspension())}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}get shouldLoad(){return this.isLeaf}init(e,t,i){this.lij[0]=e[0],this.lij[1]=e[1],this.lij[2]=e[2],this.ellipsoid=m(i.tilingScheme.spatialReference),i.tilingScheme.getExtent(e[0],e[1],e[2],this.extent),i.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this.extentMidX=.5*(this.extent[0]+this.extent[2]),this.extentMidY=.5*(this.extent[1]+this.extent[3]),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,i.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[he.MIDDLE][3]=0,this.elevationLevel=e?e[0]:0,t&&t.elevationBounds?s(this._elevationBounds,t.elevationBounds):n(this._elevationBounds,0,0),this._pendingUpdates=0,this.renderData=null,this.screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=t,this.unsetChildren(),this._surface=i,this.updateVisibility();for(const s of S){const e=i.numLayers(s),t=this.layerInfo[s];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=K.acquire(this._surface.upsampleInfoPool),s===O.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(i.tilingScheme.pixelSize,b)}release(){C(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key);for(const e of S){for(const t of this.layerInfo[e])t.release();this.layerInfo[e].length=0}this._parent=null;for(let e=0;e<4;++e)this._children[e]=null;this._surface=null,this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._isCached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){if(--this._mapDataRefCount,this._isCached){this.setMemoryDirty();const e=this._cachedMemory;e>0&&this._surface.upsampleMapCache.put(this.key,this,e)}}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this._ensureUsedMemory()+(this._isCached?0:this._mapTileMemoryInternal)}get _cachedMemory(){return this._isCached?this._mapTileMemory:0}get _mapTileMemory(){return this._ensureUsedMemory(),this.layerInfo[O.MAP].reduce(((e,t)=>e+(t instanceof E?t.memoryUsed/t.referenced:0)),this._mapTileMemoryInternal)}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(null!=this._usedMemory)return this._usedMemory;this._usedMemory=0,this._mapTileMemoryInternal=0;let e=0;for(const{data:i}of this.layerInfo[O.MAP])i instanceof E?e+=this._getTerrainDataMemory(i):this._mapTileMemoryInternal+=this._getTerrainDataMemory(i);const t=this._cpuImageMemorySize;for(const i of this.layerInfo[O.ELEVATION])this._usedMemory+=i.data?t:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._mapTileMemoryInternal+=this.renderData.texture?.gpuMemoryUsage??0),this._isCached&&this._surface.upsampleMapCache.updateSize(this.key,this,this._mapTileMemoryInternal+e),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?e===O.MAP?this._isCached?0:this._getTerrainDataMemory(i.data):e===O.ELEVATION?this._cpuImageMemorySize:0:0}_getTerrainDataMemory(e){return e instanceof Z?e.texture.gpuMemoryUsage:e instanceof HTMLImageElement||e instanceof v?this._cpuImageMemorySize:e instanceof j?e.memoryUsage:e instanceof E?e.memoryUsed/e.referenced:0}updateScreenDepth(e){const t=this._center[he.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this.screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,t,i){if(!this.visible)return ee.NONE;if(null!=e.frustum&&(!this._intersectsClippingArea||this._calculateFrustumVisibilityStatus(e.frustum)===L.OUTSIDE))return ee.NONE;const s=this.level;a(me,this._center[he.MIDDLE],t);let n=o(me),r=me,c=he.MIDDLE;a(_e,this._center[he.TOP],t);const g=o(_e);g<n&&(n=g,r=_e,c=he.TOP),a(ye,this._center[he.BOTTOM],t);const p=o(ye);if(p<n&&(n=p,r=ye,c=he.BOTTOM),this._edgeLen2>n&&s<e.maxLod)return ee.SPLIT;const f=null!=i?i-s:1/0,m=Math.sqrt(n),_=e.fovX*m*2,y=this._edgeLen/_,A=()=>{if(s<e.maxLod)return this.elevationLevel=s,ee.NONE;const t=s+Math.ceil(-Math.log2(e.relativeWidthLimit/y));return t!==this.elevationLevel?(this.elevationLevel=t,ee.ELEVATION):ee.NONE};if(f<=.5)return A();const T=l(this.up,me),E=this._elevationBounds[1]-this._elevationBounds[0],v=E/this.edgeLen;if(e.aboveGround&&T>0&&v<.001){if(T/m-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-v>0)return ee.NONE}const I=null!=i?3-Math.min(f,2):1;if(y*I<e.relativeWidthLimit||s>=e.maxLod)return A();if(s<7)return ee.SPLIT;h(Ae,this.up,T),a(Ae,Ae,r);const M=o(Ae);if(M<=this.radius*this.radius)return ee.SPLIT;h(Ae,Ae,this.radius/Math.sqrt(M)),u(Ae,Ae,this._center[c]),a(Ae,t,Ae);const D=Math.min(1,(Math.abs(l(Ae,this.up))+.5*E+this._curvatureHeight)/d(Ae)),x=ie/e.angledSplitBias,S=e.fovY*m*2;return D*(this._edgeLen/S*I)<x*e.relativeHeightLimit?ee.NONE:ee.SPLIT}setChildren(e,t,i,s){C(!!(e&&t&&i&&s),"Null child passed"),this._children[0]=e,this._children[1]=t,this._children[2]=i,this._children[3]=s}unsetChildren(){this._children[0]=null,this._children[1]=null,this._children[2]=null,this._children[3]=null}get isLoaded(){return this.renderData?.hasGeometry??!1}load(){this.refMapData();for(const e of S)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(e){e.unloadTile(this);for(const t of S){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==Q&&(re(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(ee.GEOMETRY),this.resetPendingUpdate(ee.TEXTURE_NOFADING),this.resetPendingUpdate(ee.TEXTURE_FADING),this.unrefMapData()}unloadMapData(){const e=this.layerInfo[O.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==Q&&(re(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0;this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(y(e,this._clippingArea))return!1;const t=this._intersectsClippingArea,i=this._isWithinClippingArea;null!=e?(this._intersectsClippingArea=this.intersectsExtent(e),this._isWithinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._isWithinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const s=i&&this._isWithinClippingArea,n=!(i||t||this._isWithinClippingArea||this._intersectsClippingArea);return!this.renderData||s||n||this.setPendingUpdate(ee.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i||!i.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of S){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==Q&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(ee.SPLIT)||e!==O.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){this._pendingUpdates|=e,e===ee.SPLIT||e===ee.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate()}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,i,s){const n=this.layerInfo[i][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),s.tile.lij.toString(),i,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated){console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),s.tile.lij.toString(),i,e);const t=n.data&&"type"in n.data&&"vector-tile"===n.data.type;return s.dataArrived(this,t),!0}if(n.requestPromise)return!0;t(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,i,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get isLeaf(){return null==this._children[0]}hasLij(e){return this.lij[0]===e[0]&&this.lij[1]===e[1]&&this.lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;const t=this._children;if(!t[0])return null;return t[0].findByLij(e)||t[1].findByLij(e)||t[2].findByLij(e)||t[3].findByLij(e)}distanceToSquared(e){return o(a(Ae,this._center[he.MIDDLE],e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}containsPointXY(e,t){const i=this.extent;return e>=i[0]&&t>=i[1]&&e<=i[2]&&t<=i[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);C(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=null!=i&&"type"in i&&"vector-tile"===i.type,n=this.layerInfo[t][e];n.data=i,n.dataInvalidated=!1,n.waitingAgents.forAll((e=>e.dataArrived(this,s))),n.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t,i){i.notInTilemap||console.error(`Tile ${this.lij.toString()} layer ${t}/${e} error ${i}`);const s=this.layerInfo[t][e];s.dataMissing=!0,s.waitingAgents.forAll((e=>e.dataMissing())),s.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t,i){switch(i&&this.forEachLoadedNeighbor((i=>i.updateRenderData(e,t))),e){case O.MAP:return this._updateTexture(t);case O.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===D.FADING?ee.TEXTURE_NOFADING:ee.TEXTURE_FADING),this.setPendingUpdate(e===D.FADING?ee.TEXTURE_FADING:ee.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(ee.GEOMETRY);for(const e of this.layerInfo[O.ELEVATION])e.pendingUpdates|=ee.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBounds,t=e[0],i=e[1];n(e,1/0,-1/0);const s=this.layerInfo[O.ELEVATION];let r=!0;for(const n of s)null!=n.elevationBounds&&(e[0]=Math.min(e[0],n.elevationBounds.min),e[1]=Math.max(e[1],n.elevationBounds.max),n.elevationBounds.hasNoDataValues||(r=!1));r&&(e[0]=Math.min(e[0],0),e[1]=Math.max(e[1],0)),t===e[0]&&i===e[1]||(this.updateRadiusAndCenter(),this._surface.setTileTreeDirty())}_updateCenter(){const e=this._elevationBounds,t=.5*(e[0]+e[1]),i=this._center;h(Ae,this.up,t),u(i[he.MIDDLE],this.centerAtSeaLevel,Ae),h(Ae,this.up,e[0]),u(i[he.TOP],this.centerAtSeaLevel,Ae),h(Ae,this.up,e[1]),u(i[he.BOTTOM],this.centerAtSeaLevel,Ae)}findElevationBoundsForLayer(e,t){const i=this.layerInfo[O.ELEVATION][e],s=U(this.level),n=Math.max(this.elevationLevel-s,0),r=i.elevationBounds;if(null!=r&&r.level>=t&&r.level<=n)return;const a=this._surface.layerViewByIndex(e,O.ELEVATION),o=P(a);if(!te(this,o,!1))return;const l=le;let h=!1;const u=i.data;if(u&&u.level<=n){const e=i.data;l.min=e.samplerData.data.minValue,l.max=e.samplerData.data.maxValue,l.hasNoDataValues=e.samplerData.data.hasNoDataValues,l.level=this.level,h=!0}else{let t,i,r=0;for(let a=this._parent;a&&(!i||r<s)&&(r=this.elevationLevel-a.level,t=i||t,i=a.layerInfo[O.ELEVATION][e].data,!(!i&&t&&a.level<=n));a=a.parent);i=i||t,i&&(i.computeMinMaxValue(this.lij[0],this.lij[1],this.lij[2],l),l.min!==1/0&&(l.level=i.level,h=!0))}h&&(null==i.elevationBounds&&(i.elevationBounds=new I),i.elevationBounds.copyFrom(l))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==Q&&(re(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:K.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,D.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===Q&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of S){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==Q&&(i.loadingAgent.setSuspension(t),i.loadingAgent===Q&&this.updateRenderData(e,D.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==Q&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=Q,i.data||null!=i.upsampleInfo||this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return"normal"!==e.blendMode||T(e.parent)&&this._hasBlendableAncestor(e.parent)}_hasBlendModes(e,t,i){for(let s=e;s<t;++s){const e=this._surface.layerViewByIndex(s,i);if(B(e)&&"normal"!==e?.layer?.blendMode||T(e?.layer?.parent)&&this._hasBlendableAncestor(e?.layer?.parent))return!0}return!1}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=this._isSuspended(t);for(let n=e;n<i.length;++n){const r=i[n];let a=!1;const o=this._surface.layerViewByIndex(n,t),l=P(o);if(r.loadingAgent?te(this,l,!1)?(r.loadingAgent!==Q&&r.loadingAgent.setSuspension(s),r.loadingAgent!==Q&&(a=r.loadingAgent.update())):r.dispose():te(this,l,!1)&&(r.loadingAgent=ne(this,n,t,s),a=r.loadingAgent.startLoading(),a?r.loadingAgent===Q&&this.setPendingUpdate(ee.GEOMETRY):(re(r.loadingAgent),r.loadingAgent=Q)),r.loadingAgent===Q&&this.updateRenderData(t,D.FADING),!this._hasBlendModes(e,i.length,t)&&a&&o.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationVerticesPerSide(t){const i=this.elevationLevel-this.level,s=Math.max(this.level-t,U(this.level)-i),n=e(1+(this.maxTesselation>>s),2,this.maxTesselation+1),r=this.getDefaultVerticesPerSide();return Math.max(n,r)}get test(){return{cachedMemory:this._cachedMemory}}_findLIJ(e,t){if(!e)return null;const i=this.surface.rootTiles;if(null!=i)for(const s of i)if(ue(s,e)){let i=s,n=e[0]-i.level-1;for(;n>=0&&!i.isLeaf&&!t(i);){const t=e[1]>>n&1,s=e[2]>>n&1;i=i.children[2*t+s],n--}return t(i)?i:null}return null}findNeighborTile(e,t){const i=this.lij,s=this.getNeighborLIJ(i,e);return s?de(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===x.NORTH_EAST?1:e===x.NORTH_WEST?0:e===x.SOUTH_WEST?2:3;let s=this;for(;s.children[0]&&(!t||!t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,(e=>t(e)||e.level===this.level))?.findCorner(R(e),t)||null}forAllSubtreeOnSide(e,t){const i=e===x.NORTH?[0,1]:e===x.NORTH_EAST?[1]:e===x.EAST?[1,3]:e===x.SOUTH_EAST?[3]:e===x.SOUTH?[2,3]:e===x.SOUTH_WEST?[2]:e===x.WEST?[0,2]:[0],s=e=>{const n=e.children;!t(e)&&n[0]&&i.forEach((e=>s(n[e])))};s(this)}forallNeighbors(e){V.forEach((t=>this.findNeighborCornerTileExact(t,e))),w.forEach((t=>this.findNeighborTile(t,(t=>t.level===this.level||e(t)))?.forAllSubtreeOnSide(G(t),e)))}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;const i=this.level-t.level;if(W(!q||i>=0),0===i)return 0;const s=2**i,n=1==(1&e),r=n?0:1,a=t.lij[r+1]*s,o=this.lij[r+1],l=o-a,h=n?s-1-l:l;return q&&(W(a<=o&&o<a+s),W(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.isLoaded;w.forEach((t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(G(t),(i=>!!i.isLoaded&&(e(i,t),!0)))})),V.forEach((t=>{const s=this.findNeighborTile(t,i)?.findCorner(R(t),(e=>e.isLoaded));W(!s||ge(this,s,t)),s?.isLoaded&&e(s,t)}))}getNeighborLIJ(e,t){const i=F(t)?-1:H(t)?1:0,s=k(t)?-1:X(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this.wrapLIJ(n):n[2]<0?null:n}wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}get westNeighborWestExtent(){return this.extent[0]*(this.isWestEnd?-1:1)}get eastNeighborEastExtent(){return this.extent[2]*(this.isEastEnd?-1:1)}get isEastEnd(){return this.lij[2]===this.surface.lijEastEnd(this.level)-1}get isWestEnd(){return 0===this.lij[2]}get isNorthEnd(){return 0===this.lij[1]}get isSouthEnd(){const e=this.surface.extent,t=e?.[1]??null;return null!=t&&this.extent[1]+f()>=t}checkGeometryWaterproofness(){Y&&(W(this.isLoaded),this.renderData?.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(F(e)&&t[3]+s>=i[3])return!1;if(H(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&k(e)&&t[0]-s<=i[0])&&!(!n&&X(e)&&t[2]+s>=i[2])}updateDistanceToPOI(e){const t=this._lastPOI;if(this.distanceToPOI>=0&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return;c(this._lastPOI,e);const i=this._center[he.MIDDLE],s=e[0]-i[0],n=e[1]-i[1],r=e[2]-i[2];this.distanceToPOI=s*s+n*n+r*r}}function ne(e,t,i,s){const n=i===O.ELEVATION?oe.acquire():ae.acquire();return n.init(e,t,i,s),n}function re(e){e.dispose(),e instanceof M?oe.release(e):e instanceof N&&ae.release(e)}const ae=new i(N),oe=new i(M),le=new I;var he;function ue(e,t){const i=e.level,s=t[0];if(i>s)return!1;const n=s-i,r=Math.floor(t[1]/2**n),a=Math.floor(t[2]/2**n);return r===e.lij[1]&&a===e.lij[2]}function de(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function ce(e,t,i){if(null==e||null==t)return!1;if(0===e.level&&0===t.level){if(e.isEastEnd&&t.isWestEnd&&i===x.EAST)return!0;if(e.isWestEnd&&t.isEastEnd&&i===x.WEST)return!0}const s=Math.max(1e-6*(e.extent[2]-e.extent[0]),1);switch(i){case x.NORTH:return z(e.extent[3],t.extent[1],s);case x.SOUTH:return z(e.extent[1],t.extent[3],s);case x.EAST:return z(e.extent[2],t.extent[0],s)||z(e.extent[2],-t.extent[0],s);case x.WEST:return z(e.extent[0],t.extent[2],s)||z(e.extent[0],-t.extent[2],s)}}function ge(e,t,i){return null!=e&&null!=t&&t!==e&&(e.level>=t.level?pe(e,t,i):pe(t,e,R(i)))}function pe(e,t,i){W(e.level>=t.level);const s=$(i),n=J(i),r=e.extent,a=t.extent,o=[s?r[0]:r[2],n?r[3]:r[1]],l=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),u=z(o[0],l[0],h)||e.surface.isGlobal&&z(o[0],-l[0],h),d=z(o[1],l[1],h);if(u&&d)return!0;if(e.level===t.level)return W(!1),!1;if(!u&&!d)return W(!1),!1;const c=u?fe(a[1],a[3],r[1],r[3],h):fe(a[0],a[2],r[0],r[2],h);return W(c),c}function fe(e,t,i,s,n){return e-n<=i&&i<=s&&s<=t+n}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(he||(he={}));const me=g(),_e=g(),ye=g(),Ae=g();export{he as CenterPosition,se as Tile,ge as isCornerNeighbor,ce as isEdgeNeighbor};
|
|
5
|
+
import{clamp as e}from"../../../core/mathUtils.js";import{abortMaybe as t}from"../../../core/maybe.js";import i from"../../../core/ObjectPool.js";import{j as s,s as n}from"../../../chunks/vec2.js";import{a as r}from"../../../chunks/vec2f64.js";import{b as a,p as o,e as l,g as h,a as u,l as d,c}from"../../../chunks/vec3.js";import{c as g,u as p}from"../../../chunks/vec3f64.js";import{g as f}from"../../../chunks/common.js";import{getReferenceEllipsoid as m}from"../../../geometry/ellipsoidUtils.js";import{create as _,equals as y}from"../../../geometry/support/aaBoundingRect.js";import{c as A}from"../../../chunks/sphere.js";import{isGroupLayer as T}from"../../../layers/support/layerUtils.js";import{VectorTile as E}from"../../2d/engine/vectorTiles/VectorTile.js";import{ImageWithType as v}from"../support/StreamDataLoader.js";import{ElevationBounds as I}from"./ElevationBounds.js";import{ElevationTileAgent as M}from"./ElevationTileAgent.js";import{TextureUpdate as D}from"./interfaces.js";import{TileFrustumVisibility as L,NeighborIndex as x}from"./ITile.js";import{LayerClasses as S,LayerClass as O}from"./LayerClass.js";import{MapTileAgent as N}from"./MapTileAgent.js";import{RasterTile as j}from"./RasterTile.js";import{MAX_PATCH_TESSELATION as b,getElevationDesiredResolutionLevel as U}from"./TerrainConst.js";import{weakAssert as C,getLayerWithExtentRange as P,isBlendableLayerView as B,oppositeCorner as R,neighborCornerIndices as V,neighborEdgeIndices as w,oppositeEdge as G,internalAssert as W,ENABLE_TERRAIN_INTERNAL_CHECKS as q,isNorth as F,isSouth as H,isWest as k,isEast as X,ENABLE_WATERPROOFNESS_TESTS as Y,almostEquals as z,isWestCorner as $,isNorthCorner as J}from"./terrainUtils.js";import{TILE_AGENT_DONE as Q}from"./TileAgent.js";import{TilePerLayerInfo as K}from"./TilePerLayerInfo.js";import Z from"./TileTexture.js";import{TileUpdate as ee}from"./TileUpdate.js";import{fallsWithinLayer as te}from"./tileUtils.js";const ie=.1;class se{constructor(){this.lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this.renderData=null,this._dirty=!0,this._previouslyRendered=!1,this.extent=_(),this._elevationBounds=r(),this.layerInfo=[[],[]],this.extentInRadians=_(),this.centerAtSeaLevel=g(),this._center=[g(),A(),g()],this.up=p(),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=null,this._mapTileMemoryInternal=0,this._mapDataRefCount=0,this.screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0,this.extentMidX=0,this.extentMidY=0,this.distanceToPOI=-1,this._lastPOI=g()}static prune(){ae.prune(0),oe.prune(0),K.prune()}get _isCached(){return!this.shouldLoad&&this._mapDataRefCount<=0}get maxTesselation(){return this._maxTesselation}get isWithinClippingArea(){return this._isWithinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBounds(){return this._elevationBounds}get level(){return this.lij[0]}get key(){return`${this.lij[0]}/${this.lij[1]}/${this.lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[he.MIDDLE][3]}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}computeVisibility(){this._dirty=!1;const e=this.parent,t=e?.frustumVisibility??L.INTERSECTS;this._frustumVisibility=t===L.INSIDE?L.INSIDE:t===L.OUTSIDE?L.OUTSIDE:this._calculateFrustumVisibilityStatus(this.surface.frustum);const i=this._frustumVisibility!==L.OUTSIDE&&this._intersectsClippingArea;i!==this._visible&&(this._visible=i,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setDirty(),this.updateAgentSuspension())}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}get shouldLoad(){return this.isLeaf}init(e,t,i){this.lij[0]=e[0],this.lij[1]=e[1],this.lij[2]=e[2],this.ellipsoid=m(i.tilingScheme.spatialReference),i.tilingScheme.getExtent(e[0],e[1],e[2],this.extent),i.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this.extentMidX=.5*(this.extent[0]+this.extent[2]),this.extentMidY=.5*(this.extent[1]+this.extent[3]),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,i.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[he.MIDDLE][3]=0,this.elevationLevel=e?e[0]:0,t&&t.elevationBounds?s(this._elevationBounds,t.elevationBounds):n(this._elevationBounds,0,0),this._pendingUpdates=0,this.renderData=null,this.screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=t,this.unsetChildren(),this._surface=i,this.updateVisibility();for(const s of S){const e=i.numLayers(s),t=this.layerInfo[s];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=K.acquire(this._surface.upsampleInfoPool),s===O.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(i.tilingScheme.pixelSize,b)}release(){C(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key);for(const e of S){for(const t of this.layerInfo[e])t.release();this.layerInfo[e].length=0}this._parent=null;for(let e=0;e<4;++e)this._children[e]=null;this._surface=null,this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._isCached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){if(--this._mapDataRefCount,this._isCached){this.setMemoryDirty();const e=this._cachedMemory;e>0&&this._surface.upsampleMapCache.put(this.key,this,e)}}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this._ensureUsedMemory()+(this._isCached?0:this._mapTileMemoryInternal)}get _cachedMemory(){return this._isCached?this._mapTileMemory:0}get _mapTileMemory(){return this._ensureUsedMemory(),this.layerInfo[O.MAP].reduce(((e,t)=>e+(t instanceof E?t.memoryUsed/t.referenced:0)),this._mapTileMemoryInternal)}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(null!=this._usedMemory)return this._usedMemory;this._usedMemory=0,this._mapTileMemoryInternal=0;let e=0;for(const{data:i}of this.layerInfo[O.MAP])i instanceof E?e+=this._getTerrainDataMemory(i):this._mapTileMemoryInternal+=this._getTerrainDataMemory(i);const t=this._cpuImageMemorySize;for(const i of this.layerInfo[O.ELEVATION])this._usedMemory+=i.data?t:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._mapTileMemoryInternal+=this.renderData.texture?.memoryUsage??0),this._isCached&&this._surface.upsampleMapCache.updateSize(this.key,this,this._mapTileMemoryInternal+e),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?e===O.MAP?this._isCached?0:this._getTerrainDataMemory(i.data):e===O.ELEVATION?this._cpuImageMemorySize:0:0}_getTerrainDataMemory(e){return e instanceof Z?e.texture.gpuMemoryUsage:e instanceof HTMLImageElement||e instanceof v?this._cpuImageMemorySize:e instanceof j?e.memoryUsage:e instanceof E?e.memoryUsed/e.referenced:0}updateScreenDepth(e){const t=this._center[he.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this.screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,t,i){if(!this.visible)return ee.NONE;if(null!=e.frustum&&(!this._intersectsClippingArea||this._calculateFrustumVisibilityStatus(e.frustum)===L.OUTSIDE))return ee.NONE;const s=this.level;a(me,this._center[he.MIDDLE],t);let n=o(me),r=me,c=he.MIDDLE;a(_e,this._center[he.TOP],t);const g=o(_e);g<n&&(n=g,r=_e,c=he.TOP),a(ye,this._center[he.BOTTOM],t);const p=o(ye);if(p<n&&(n=p,r=ye,c=he.BOTTOM),this._edgeLen2>n&&s<e.maxLod)return ee.SPLIT;const f=null!=i?i-s:1/0,m=Math.sqrt(n),_=e.fovX*m*2,y=this._edgeLen/_,A=()=>{if(s<e.maxLod)return this.elevationLevel=s,ee.NONE;const t=s+Math.ceil(-Math.log2(e.relativeWidthLimit/y));return t!==this.elevationLevel?(this.elevationLevel=t,ee.ELEVATION):ee.NONE};if(f<=.5)return A();const T=l(this.up,me),E=this._elevationBounds[1]-this._elevationBounds[0],v=E/this.edgeLen;if(e.aboveGround&&T>0&&v<.001){if(T/m-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-v>0)return ee.NONE}const I=null!=i?3-Math.min(f,2):1;if(y*I<e.relativeWidthLimit||s>=e.maxLod)return A();if(s<7)return ee.SPLIT;h(Ae,this.up,T),a(Ae,Ae,r);const M=o(Ae);if(M<=this.radius*this.radius)return ee.SPLIT;h(Ae,Ae,this.radius/Math.sqrt(M)),u(Ae,Ae,this._center[c]),a(Ae,t,Ae);const D=Math.min(1,(Math.abs(l(Ae,this.up))+.5*E+this._curvatureHeight)/d(Ae)),x=ie/e.angledSplitBias,S=e.fovY*m*2;return D*(this._edgeLen/S*I)<x*e.relativeHeightLimit?ee.NONE:ee.SPLIT}setChildren(e,t,i,s){C(!!(e&&t&&i&&s),"Null child passed"),this._children[0]=e,this._children[1]=t,this._children[2]=i,this._children[3]=s}unsetChildren(){this._children[0]=null,this._children[1]=null,this._children[2]=null,this._children[3]=null}get isLoaded(){return this.renderData?.hasGeometry??!1}load(){this.refMapData();for(const e of S)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(e){e.unloadTile(this);for(const t of S){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==Q&&(re(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(ee.GEOMETRY),this.resetPendingUpdate(ee.TEXTURE_NOFADING),this.resetPendingUpdate(ee.TEXTURE_FADING),this.unrefMapData()}unloadMapData(){const e=this.layerInfo[O.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==Q&&(re(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0;this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(y(e,this._clippingArea))return!1;const t=this._intersectsClippingArea,i=this._isWithinClippingArea;null!=e?(this._intersectsClippingArea=this.intersectsExtent(e),this._isWithinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._isWithinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const s=i&&this._isWithinClippingArea,n=!(i||t||this._isWithinClippingArea||this._intersectsClippingArea);return!this.renderData||s||n||this.setPendingUpdate(ee.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i||!i.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of S){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==Q&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(ee.SPLIT)||e!==O.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){this._pendingUpdates|=e,e===ee.SPLIT||e===ee.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate()}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,i,s){const n=this.layerInfo[i][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),s.tile.lij.toString(),i,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated){console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),s.tile.lij.toString(),i,e);const t=n.data&&"type"in n.data&&"vector-tile"===n.data.type;return s.dataArrived(this,t),!0}if(n.requestPromise)return!0;t(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,i,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get isLeaf(){return null==this._children[0]}hasLij(e){return this.lij[0]===e[0]&&this.lij[1]===e[1]&&this.lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;const t=this._children;if(!t[0])return null;return t[0].findByLij(e)||t[1].findByLij(e)||t[2].findByLij(e)||t[3].findByLij(e)}distanceToSquared(e){return o(a(Ae,this._center[he.MIDDLE],e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}containsPointXY(e,t){const i=this.extent;return e>=i[0]&&t>=i[1]&&e<=i[2]&&t<=i[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);C(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=null!=i&&"type"in i&&"vector-tile"===i.type,n=this.layerInfo[t][e];n.data=i,n.dataInvalidated=!1,n.waitingAgents.forAll((e=>e.dataArrived(this,s))),n.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t,i){i.notInTilemap||console.error(`Tile ${this.lij.toString()} layer ${t}/${e} error ${i}`);const s=this.layerInfo[t][e];s.dataMissing=!0,s.waitingAgents.forAll((e=>e.dataMissing())),s.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t,i){switch(i&&this.forEachLoadedNeighbor((i=>i.updateRenderData(e,t))),e){case O.MAP:return this._updateTexture(t);case O.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===D.FADING?ee.TEXTURE_NOFADING:ee.TEXTURE_FADING),this.setPendingUpdate(e===D.FADING?ee.TEXTURE_FADING:ee.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(ee.GEOMETRY);for(const e of this.layerInfo[O.ELEVATION])e.pendingUpdates|=ee.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBounds,t=e[0],i=e[1];n(e,1/0,-1/0);const s=this.layerInfo[O.ELEVATION];let r=!0;for(const n of s)null!=n.elevationBounds&&(e[0]=Math.min(e[0],n.elevationBounds.min),e[1]=Math.max(e[1],n.elevationBounds.max),n.elevationBounds.hasNoDataValues||(r=!1));r&&(e[0]=Math.min(e[0],0),e[1]=Math.max(e[1],0)),t===e[0]&&i===e[1]||(this.updateRadiusAndCenter(),this._surface.setTileTreeDirty())}_updateCenter(){const e=this._elevationBounds,t=.5*(e[0]+e[1]),i=this._center;h(Ae,this.up,t),u(i[he.MIDDLE],this.centerAtSeaLevel,Ae),h(Ae,this.up,e[0]),u(i[he.TOP],this.centerAtSeaLevel,Ae),h(Ae,this.up,e[1]),u(i[he.BOTTOM],this.centerAtSeaLevel,Ae)}findElevationBoundsForLayer(e,t){const i=this.layerInfo[O.ELEVATION][e],s=U(this.level),n=Math.max(this.elevationLevel-s,0),r=i.elevationBounds;if(null!=r&&r.level>=t&&r.level<=n)return;const a=this._surface.layerViewByIndex(e,O.ELEVATION),o=P(a);if(!te(this,o,!1))return;const l=le;let h=!1;const u=i.data;if(u&&u.level<=n){const e=i.data;l.min=e.samplerData.data.minValue,l.max=e.samplerData.data.maxValue,l.hasNoDataValues=e.samplerData.data.hasNoDataValues,l.level=this.level,h=!0}else{let t,i,r=0;for(let a=this._parent;a&&(!i||r<s)&&(r=this.elevationLevel-a.level,t=i||t,i=a.layerInfo[O.ELEVATION][e].data,!(!i&&t&&a.level<=n));a=a.parent);i=i||t,i&&(i.computeMinMaxValue(this.lij[0],this.lij[1],this.lij[2],l),l.min!==1/0&&(l.level=i.level,h=!0))}h&&(null==i.elevationBounds&&(i.elevationBounds=new I),i.elevationBounds.copyFrom(l))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==Q&&(re(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:K.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,D.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===Q&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of S){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==Q&&(i.loadingAgent.setSuspension(t),i.loadingAgent===Q&&this.updateRenderData(e,D.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==Q&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=Q,i.data||null!=i.upsampleInfo||this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return"normal"!==e.blendMode||T(e.parent)&&this._hasBlendableAncestor(e.parent)}_hasBlendModes(e,t,i){for(let s=e;s<t;++s){const e=this._surface.layerViewByIndex(s,i);if(B(e)&&"normal"!==e?.layer?.blendMode||T(e?.layer?.parent)&&this._hasBlendableAncestor(e?.layer?.parent))return!0}return!1}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=this._isSuspended(t);for(let n=e;n<i.length;++n){const r=i[n];let a=!1;const o=this._surface.layerViewByIndex(n,t),l=P(o);if(r.loadingAgent?te(this,l,!1)?(r.loadingAgent!==Q&&r.loadingAgent.setSuspension(s),r.loadingAgent!==Q&&(a=r.loadingAgent.update())):r.dispose():te(this,l,!1)&&(r.loadingAgent=ne(this,n,t,s),a=r.loadingAgent.startLoading(),a?r.loadingAgent===Q&&this.setPendingUpdate(ee.GEOMETRY):(re(r.loadingAgent),r.loadingAgent=Q)),r.loadingAgent===Q&&this.updateRenderData(t,D.FADING),!this._hasBlendModes(e,i.length,t)&&a&&o.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationVerticesPerSide(t){const i=this.elevationLevel-this.level,s=Math.max(this.level-t,U(this.level)-i),n=e(1+(this.maxTesselation>>s),2,this.maxTesselation+1),r=this.getDefaultVerticesPerSide();return Math.max(n,r)}get test(){return{cachedMemory:this._cachedMemory}}_findLIJ(e,t){if(!e)return null;const i=this.surface.rootTiles;if(null!=i)for(const s of i)if(ue(s,e)){let i=s,n=e[0]-i.level-1;for(;n>=0&&!i.isLeaf&&!t(i);){const t=e[1]>>n&1,s=e[2]>>n&1;i=i.children[2*t+s],n--}return t(i)?i:null}return null}findNeighborTile(e,t){const i=this.lij,s=this.getNeighborLIJ(i,e);return s?de(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===x.NORTH_EAST?1:e===x.NORTH_WEST?0:e===x.SOUTH_WEST?2:3;let s=this;for(;s.children[0]&&(!t||!t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,(e=>t(e)||e.level===this.level))?.findCorner(R(e),t)||null}forAllSubtreeOnSide(e,t){const i=e===x.NORTH?[0,1]:e===x.NORTH_EAST?[1]:e===x.EAST?[1,3]:e===x.SOUTH_EAST?[3]:e===x.SOUTH?[2,3]:e===x.SOUTH_WEST?[2]:e===x.WEST?[0,2]:[0],s=e=>{const n=e.children;!t(e)&&n[0]&&i.forEach((e=>s(n[e])))};s(this)}forallNeighbors(e){V.forEach((t=>this.findNeighborCornerTileExact(t,e))),w.forEach((t=>this.findNeighborTile(t,(t=>t.level===this.level||e(t)))?.forAllSubtreeOnSide(G(t),e)))}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;const i=this.level-t.level;if(W(!q||i>=0),0===i)return 0;const s=2**i,n=1==(1&e),r=n?0:1,a=t.lij[r+1]*s,o=this.lij[r+1],l=o-a,h=n?s-1-l:l;return q&&(W(a<=o&&o<a+s),W(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.isLoaded;w.forEach((t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(G(t),(i=>!!i.isLoaded&&(e(i,t),!0)))})),V.forEach((t=>{const s=this.findNeighborTile(t,i)?.findCorner(R(t),(e=>e.isLoaded));W(!s||ge(this,s,t)),s?.isLoaded&&e(s,t)}))}getNeighborLIJ(e,t){const i=F(t)?-1:H(t)?1:0,s=k(t)?-1:X(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this.wrapLIJ(n):n[2]<0?null:n}wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}get westNeighborWestExtent(){return this.extent[0]*(this.isWestEnd?-1:1)}get eastNeighborEastExtent(){return this.extent[2]*(this.isEastEnd?-1:1)}get isEastEnd(){return this.lij[2]===this.surface.lijEastEnd(this.level)-1}get isWestEnd(){return 0===this.lij[2]}get isNorthEnd(){return 0===this.lij[1]}get isSouthEnd(){const e=this.surface.extent,t=e?.[1]??null;return null!=t&&this.extent[1]+f()>=t}checkGeometryWaterproofness(){Y&&(W(this.isLoaded),this.renderData?.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(F(e)&&t[3]+s>=i[3])return!1;if(H(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&k(e)&&t[0]-s<=i[0])&&!(!n&&X(e)&&t[2]+s>=i[2])}updateDistanceToPOI(e){const t=this._lastPOI;if(this.distanceToPOI>=0&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return;c(this._lastPOI,e);const i=this._center[he.MIDDLE],s=e[0]-i[0],n=e[1]-i[1],r=e[2]-i[2];this.distanceToPOI=s*s+n*n+r*r}}function ne(e,t,i,s){const n=i===O.ELEVATION?oe.acquire():ae.acquire();return n.init(e,t,i,s),n}function re(e){e.dispose(),e instanceof M?oe.release(e):e instanceof N&&ae.release(e)}const ae=new i(N),oe=new i(M),le=new I;var he;function ue(e,t){const i=e.level,s=t[0];if(i>s)return!1;const n=s-i,r=Math.floor(t[1]/2**n),a=Math.floor(t[2]/2**n);return r===e.lij[1]&&a===e.lij[2]}function de(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function ce(e,t,i){if(null==e||null==t)return!1;if(0===e.level&&0===t.level){if(e.isEastEnd&&t.isWestEnd&&i===x.EAST)return!0;if(e.isWestEnd&&t.isEastEnd&&i===x.WEST)return!0}const s=Math.max(1e-6*(e.extent[2]-e.extent[0]),1);switch(i){case x.NORTH:return z(e.extent[3],t.extent[1],s);case x.SOUTH:return z(e.extent[1],t.extent[3],s);case x.EAST:return z(e.extent[2],t.extent[0],s)||z(e.extent[2],-t.extent[0],s);case x.WEST:return z(e.extent[0],t.extent[2],s)||z(e.extent[0],-t.extent[2],s)}}function ge(e,t,i){return null!=e&&null!=t&&t!==e&&(e.level>=t.level?pe(e,t,i):pe(t,e,R(i)))}function pe(e,t,i){W(e.level>=t.level);const s=$(i),n=J(i),r=e.extent,a=t.extent,o=[s?r[0]:r[2],n?r[3]:r[1]],l=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),u=z(o[0],l[0],h)||e.surface.isGlobal&&z(o[0],-l[0],h),d=z(o[1],l[1],h);if(u&&d)return!0;if(e.level===t.level)return W(!1),!1;if(!u&&!d)return W(!1),!1;const c=u?fe(a[1],a[3],r[1],r[3],h):fe(a[0],a[2],r[0],r[2],h);return W(c),c}function fe(e,t,i,s,n){return e-n<=i&&i<=s&&s<=t+n}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(he||(he={}));const me=g(),_e=g(),ye=g(),Ae=g();export{he as CenterPosition,se as Tile,ge as isCornerNeighbor,ce as isEdgeNeighbor};
|