@arcgis/core 6.0.0-next.48 → 6.0.0-next.49

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.
Files changed (228) hide show
  1. package/Ground.js +1 -1
  2. package/analysis/AreaMeasurementAnalysis.d.ts +12 -10
  3. package/analysis/AreaMeasurementAnalysis.js +1 -1
  4. package/applications/Components/formatUtils.d.ts +3 -2
  5. package/applications/MapViewer/templateUtils.d.ts +4 -1
  6. package/applications/SceneViewer/sceneViewerUtils.d.ts +12 -1
  7. package/applications/SceneViewer/sceneViewerUtils.js +1 -1
  8. package/arcade/featureset/actions/SpatialFilter.js +1 -1
  9. package/arcade/functions/featuresetgeom.js +1 -1
  10. package/arcade/functions/geomasync.js +1 -1
  11. package/arcade/geometry/operatorsWorker.js +1 -1
  12. package/arcade/geometry/operatorsWorkerConnection.js +1 -1
  13. package/arcgisGlobal.d.ts +4 -0
  14. package/assets/esri/core/workers/RemoteClient.js +1 -1
  15. package/assets/esri/core/workers/chunks/063cc462524646cd45e8.js +1 -0
  16. package/assets/esri/core/workers/chunks/119c62e9c9c7440a6129.js +1 -0
  17. package/assets/esri/core/workers/chunks/14c04fde8d33b739b415.js +1 -0
  18. package/assets/esri/core/workers/chunks/27a91b52d1bee92b6f20.js +1 -0
  19. package/assets/esri/core/workers/chunks/31eb09e96f31bced71ad.js +1 -0
  20. package/assets/esri/core/workers/chunks/{056a815273653271bf75.js → 3236e18921955450fc0d.js} +5 -5
  21. package/assets/esri/core/workers/chunks/3ce7120056040af3bab1.js +1 -0
  22. package/assets/esri/core/workers/chunks/435dacf493aec07ff6e3.js +1 -0
  23. package/assets/esri/core/workers/chunks/4c26d6408ee7a3b9d163.js +1 -0
  24. package/assets/esri/core/workers/chunks/{73bf76a3a0418edb26a5.js → 506954fb374ea528d020.js} +1 -1
  25. package/assets/esri/core/workers/chunks/55db28616f810ca063b7.js +1 -0
  26. package/assets/esri/core/workers/chunks/59ae5bd0ee1bae7a9fb3.js +1 -0
  27. package/assets/esri/core/workers/chunks/630a36c4817f33f4cad2.js +1 -0
  28. package/assets/esri/core/workers/chunks/6779afc2d6ee46c301b5.js +1 -0
  29. package/assets/esri/core/workers/chunks/6a509ffb4852d694a097.js +1 -0
  30. package/assets/esri/core/workers/chunks/6d25a7071fceb707858a.js +1 -0
  31. package/assets/esri/core/workers/chunks/7a97eec9823941fd210f.js +29 -0
  32. package/assets/esri/core/workers/chunks/82bbf0c5e18fc1c795f4.js +1 -0
  33. package/assets/esri/core/workers/chunks/91019e9dff63107f8cb4.js +1 -0
  34. package/assets/esri/core/workers/chunks/{1345413ec0b4128849b1.js → 954f9854a9bf4a852b81.js} +1 -1
  35. package/assets/esri/core/workers/chunks/9846abf2d3991a15b2b5.js +1 -0
  36. package/assets/esri/core/workers/chunks/9f74b3f0f453bc957e3a.js +1 -0
  37. package/assets/esri/core/workers/chunks/a0e2a1c6f37454547193.js +1 -0
  38. package/assets/esri/core/workers/chunks/a1c45e8f5bba471b3905.js +1 -0
  39. package/assets/esri/core/workers/chunks/a2825285d46f8cd5d814.js +1 -0
  40. package/assets/esri/core/workers/chunks/{d4f6be8290ad0243e1b8.js → b511b5c68defefccde0b.js} +1 -1
  41. package/assets/esri/core/workers/chunks/bf81b3670b5323621e2d.js +1 -0
  42. package/assets/esri/core/workers/chunks/c4794d692934098988e7.js +1 -0
  43. package/assets/esri/core/workers/chunks/d0900a901197948bd7df.js +1 -0
  44. package/assets/esri/core/workers/chunks/d2ed93bbfa98395bbed7.js +1 -0
  45. package/assets/esri/core/workers/chunks/d486a8a61ff993f8202a.js +1 -0
  46. package/assets/esri/core/workers/chunks/e06036392a982dbf3ae3.js +1 -0
  47. package/assets/esri/core/workers/chunks/{773ba0909ccd3a034c31.js → ed1db6571b0c61fe4f91.js} +1 -1
  48. package/chunks/BlendWeights.glsl.js +4 -5
  49. package/chunks/Blur.glsl.js +10 -7
  50. package/chunks/BlurEmission.glsl.js +27 -7
  51. package/chunks/Clouds.glsl.js +2 -2
  52. package/chunks/Component.glsl.js +1 -1
  53. package/chunks/EdgeDetect.glsl.js +1 -1
  54. package/chunks/EdgeShader.glsl.js +1 -1
  55. package/chunks/EmissionComposite.glsl.js +2 -2
  56. package/chunks/Fog.glsl.js +4 -4
  57. package/chunks/GlobalIlluminationBlur.glsl.js +1 -1
  58. package/chunks/HighlightSharpApply.glsl.js +4 -1
  59. package/chunks/LineMarker.glsl.js +4 -4
  60. package/chunks/Magnifier.glsl.js +1 -1
  61. package/chunks/NoiseTextureAtlas.glsl.js +3 -3
  62. package/chunks/Pattern.glsl.js +35 -32
  63. package/chunks/{ChapmanAtmosphere.glsl.js → RealisticAtmosphere.glsl.js} +18 -9
  64. package/chunks/RealisticAtmosphereCompositing.glsl.js +35 -0
  65. package/chunks/SSAO.glsl.js +2 -2
  66. package/chunks/SimpleAtmosphere.glsl.js +1 -1
  67. package/config.js +1 -1
  68. package/core/accessorSupport/ObservableBase.js +1 -1
  69. package/core/accessorSupport/tracking/ObservationHandle.js +1 -1
  70. package/core/accessorSupport/tracking/SimpleObservable.js +1 -1
  71. package/core/accessorSupport/tracking/SimpleTrackingTarget.js +1 -1
  72. package/core/accessorSupport/tracking/TrackingTarget.js +1 -1
  73. package/core/quantity.js +1 -1
  74. package/core/timeUtils.js +1 -1
  75. package/geometry/coordinateConversion/CoordinateConversionModel.d.ts +258 -0
  76. package/geometry/coordinateConversion/CoordinateConversionModel.js +2 -0
  77. package/geometry/coordinateConversion/support/Conversion.d.ts +73 -0
  78. package/geometry/coordinateConversion/support/Conversion.js +2 -0
  79. package/geometry/coordinateConversion/support/Format.d.ts +131 -0
  80. package/geometry/coordinateConversion/support/Format.js +2 -0
  81. package/geometry/coordinateConversion/support/coordinateConversionUtils.js +2 -0
  82. package/geometry/coordinateConversion/support/formatUtils.js +2 -0
  83. package/geometry/coordinateConversion/types.d.ts +116 -0
  84. package/kernel.js +1 -1
  85. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  86. package/layers/IntegratedMeshLayer.js +1 -1
  87. package/layers/catalog/CatalogFootprintLayer.d.ts +2 -2
  88. package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
  89. package/layers/knowledgeGraph/cypherUtils.js +1 -1
  90. package/layers/mixins/FeatureLayerBase.d.ts +2 -2
  91. package/layers/raster/formats/Lzw.js +1 -1
  92. package/layers/raster/formats/TiffDecoder.js +1 -1
  93. package/layers/raster/formats/tiffParser.js +1 -1
  94. package/layers/raster/formats/tiffTag.js +1 -1
  95. package/layers/support/IntegratedMeshSemantics.js +2 -0
  96. package/layers/support/VideoElement.js +1 -1
  97. package/legend/ActiveLayerInfo.js +1 -1
  98. package/package.json +2 -2
  99. package/symbols/FillSymbol3DLayer.d.ts +1 -4
  100. package/time/daylightUtils.d.ts +29 -0
  101. package/time/daylightUtils.js +2 -0
  102. package/time/timeZoneUtils.js +1 -1
  103. package/time/types.d.ts +57 -1
  104. package/views/2d/analysis/AreaMeasurement/AreaMeasurementTool.js +1 -1
  105. package/views/2d/analysis/AreaMeasurementAnalysisView2D.js +1 -1
  106. package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
  107. package/views/2d/layers/GeospatialPDFLayerView2D.js +1 -1
  108. package/views/2d/layers/MediaLayerView2D.js +1 -1
  109. package/views/2d/layers/TileLayerView2D.js +1 -1
  110. package/views/3d/GroundView3D.js +1 -1
  111. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
  112. package/views/3d/analysis/AreaMeasurementAnalysisView3D.js +1 -1
  113. package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
  114. package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
  115. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementController.js +1 -1
  116. package/views/3d/interactive/Manipulator3D.js +1 -1
  117. package/views/3d/interactive/Manipulator3DBase.js +2 -0
  118. package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
  119. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  120. package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
  121. package/views/3d/layers/I3SMeshView3D.js +1 -1
  122. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  123. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  124. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  125. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  126. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  127. package/views/3d/layers/graphics/Graphics3DSymbol.js +1 -1
  128. package/views/3d/layers/graphics/Graphics3DWebStyleSymbol.js +1 -1
  129. package/views/3d/layers/graphics/SymbolComplexity.js +1 -1
  130. package/views/3d/layers/graphics/webStyleUtils.js +1 -1
  131. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  132. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  133. package/views/3d/layers/support/Tiles3DMeshIntersectionHandler.js +1 -1
  134. package/views/3d/layers/support/patternUtils.js +1 -1
  135. package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
  136. package/views/3d/support/GroundAndIMSurface.js +1 -1
  137. package/views/3d/support/engineContent/line.js +1 -1
  138. package/views/3d/support/hitTest.js +1 -1
  139. package/views/3d/support/pointsOfInterest/StableSurfaceCenter.js +1 -1
  140. package/views/3d/terrain/OverlayRenderer.js +1 -1
  141. package/views/3d/terrain/PatchGeometryFactory.js +1 -1
  142. package/views/3d/terrain/PatchRenderDataWaterproofness.js +1 -1
  143. package/views/3d/terrain/SphericalPatch.js +1 -1
  144. package/views/3d/terrain/TerrainSurface.js +1 -1
  145. package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
  146. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  147. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterialInitParameters.js +1 -1
  148. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterialRepository.js +1 -1
  149. package/views/3d/webgl-engine/core/renderPasses/RenderPass.js +1 -1
  150. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  151. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +2 -2
  152. package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceRayMarching.glsl.js +1 -1
  153. package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterColor.glsl.js +6 -4
  154. package/views/3d/webgl-engine/core/shaderLibrary/util/BlendModes.glsl.js +1 -1
  155. package/views/3d/webgl-engine/core/shaderLibrary/util/CloudsParallaxShading.glsl.js +10 -9
  156. package/views/3d/webgl-engine/core/shaderLibrary/util/GaussianSplatUnpacking.glsl.js +1 -1
  157. package/views/3d/webgl-engine/core/shaderLibrary/util/cameraUniforms.js +1 -1
  158. package/views/3d/webgl-engine/effects/WeatherFader.js +1 -1
  159. package/views/3d/webgl-engine/effects/atmosphere/ChapmanApproximation.glsl.js +3 -3
  160. package/views/3d/webgl-engine/effects/atmosphere/{ChapmanAtmosphere.glsl.js → RealisticAtmosphere.glsl.js} +1 -1
  161. package/views/3d/webgl-engine/effects/atmosphere/RealisticAtmosphere.js +2 -0
  162. package/views/3d/webgl-engine/effects/atmosphere/RealisticAtmosphereCompositing.glsl.js +2 -0
  163. package/views/3d/webgl-engine/effects/atmosphere/RealisticAtmosphereCompositingTechnique.js +2 -0
  164. package/views/3d/webgl-engine/effects/atmosphere/RealisticAtmosphereTechnique.js +2 -0
  165. package/views/3d/webgl-engine/effects/fog/Fog.js +1 -1
  166. package/views/3d/webgl-engine/effects/glow/BlurEmission.glsl.js +1 -1
  167. package/views/3d/webgl-engine/effects/glow/applyEmissiveGlow.glsl.js +87 -41
  168. package/views/3d/webgl-engine/effects/precipitation/Precipitation.js +1 -1
  169. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  170. package/views/3d/webgl-engine/lib/EmissionComposite.glsl.js +1 -1
  171. package/views/3d/webgl-engine/lib/EmissionComposite.js +1 -1
  172. package/views/3d/webgl-engine/lib/ManagedTexture.js +1 -1
  173. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  174. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  175. package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
  176. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  177. package/views/3d/webgl-engine/lib/intersectorUtilsConversions.js +1 -1
  178. package/views/3d/webgl-engine/lib/lodRendering/InstanceOctree.js +1 -1
  179. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  180. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  181. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  182. package/views/3d/webgl-engine/shaders/Pattern.glsl.js +1 -1
  183. package/views/3d/webgl-engine/shaders/PatternLayouts.js +1 -1
  184. package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
  185. package/views/3d/webgl-engine/shaders/PatternTechniqueConfiguration.js +1 -1
  186. package/views/SceneView.js +1 -1
  187. package/views/VideoView.js +1 -1
  188. package/views/interactive/Tooltip.js +1 -1
  189. package/views/interactive/snapping/RightAngleTriangleSnapper.js +1 -1
  190. package/views/interactive/snapping/SnappingAlgorithm.js +1 -1
  191. package/views/interactive/tooltip/content/TooltipContent.js +1 -1
  192. package/widgets/CoordinateConversion/CoordinateConversionViewModel.d.ts +3 -0
  193. package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
  194. package/widgets/CoordinateConversion.js +1 -1
  195. package/widgets/Sketch/SketchViewModel.js +1 -1
  196. package/assets/esri/core/workers/chunks/022565ef98a702ab952f.js +0 -1
  197. package/assets/esri/core/workers/chunks/163e97987e1f75610009.js +0 -1
  198. package/assets/esri/core/workers/chunks/1d57b1445afec89a7941.js +0 -1
  199. package/assets/esri/core/workers/chunks/3654672d772d11484883.js +0 -1
  200. package/assets/esri/core/workers/chunks/3af0ff5a0b82872aac38.js +0 -1
  201. package/assets/esri/core/workers/chunks/3b9415dfd7546aeec261.js +0 -1
  202. package/assets/esri/core/workers/chunks/5109b48666138df14038.js +0 -1
  203. package/assets/esri/core/workers/chunks/6b73dfc9252b32f1eae2.js +0 -1
  204. package/assets/esri/core/workers/chunks/6e4698879e7d8fbc4d12.js +0 -1
  205. package/assets/esri/core/workers/chunks/71295afd21fc5bc5ddbc.js +0 -1
  206. package/assets/esri/core/workers/chunks/794a9f116c4700bb1210.js +0 -1
  207. package/assets/esri/core/workers/chunks/8e0ecc7f55dd8bf2cf16.js +0 -1
  208. package/assets/esri/core/workers/chunks/9dece842ada6278c33ef.js +0 -1
  209. package/assets/esri/core/workers/chunks/a12e29f2cb78fdaa0753.js +0 -1
  210. package/assets/esri/core/workers/chunks/b70af9fb974ef9836efd.js +0 -1
  211. package/assets/esri/core/workers/chunks/c0f2b6a10bcc766318f5.js +0 -1
  212. package/assets/esri/core/workers/chunks/c248db5e4d92cfb3c4d1.js +0 -1
  213. package/assets/esri/core/workers/chunks/ce02adb527389b90223d.js +0 -1
  214. package/assets/esri/core/workers/chunks/d8eea5ffe05c620fac9e.js +0 -1
  215. package/assets/esri/core/workers/chunks/d997d81d0965c05447d4.js +0 -1
  216. package/assets/esri/core/workers/chunks/e1645882f54818c4036a.js +0 -1
  217. package/assets/esri/core/workers/chunks/e44679a0d271c1efb60d.js +0 -1
  218. package/assets/esri/core/workers/chunks/f11f40017ec97a2a6b5f.js +0 -29
  219. package/assets/esri/core/workers/chunks/f7f5d8256e63d303cbcb.js +0 -1
  220. package/assets/esri/core/workers/chunks/f87d5450190896e61ff8.js +0 -1
  221. package/assets/esri/core/workers/chunks/fdee2255f49b43056e9d.js +0 -1
  222. package/assets/esri/core/workers/chunks/ff1e614fde01781360fa.js +0 -1
  223. package/chunks/AtmosphereCompositing.glsl.js +0 -25
  224. package/views/3d/analysis/ShadowCast/sunlightUtils.js +0 -2
  225. package/views/3d/webgl-engine/effects/atmosphere/ChapmanAtmosphere.js +0 -2
  226. package/views/3d/webgl-engine/effects/atmosphere/ChapmanAtmosphereTechnique.js +0 -2
  227. package/views/3d/webgl-engine/shaders/AtmosphereCompositing.glsl.js +0 -2
  228. package/views/3d/webgl-engine/shaders/AtmosphereCompositingTechnique.js +0 -2
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../Color.js";import{filterInPlace as n,difference as r}from"../../../core/arrayUtils.js";import i from"../../../core/CollectionFlattener.js";import{toConst as a}from"../../../core/compilerUtils.js";import{EventedAccessor as o}from"../../../core/Evented.js";import has from"../../../core/has.js";import s from"../../../core/Logger.js";import{clamp as c}from"../../../core/mathUtils.js";import{removeMaybe as l,destroyMaybe as u}from"../../../core/maybe.js";import{MemCachePool as ee}from"../../../core/MemCachePool.js";import d from"../../../core/ObjectPool.js";import f from"../../../core/PooledArray.js";import{throwIfAborted as te,isAbortError as p,isAborted as m}from"../../../core/promiseUtils.js";import{watch as h,syncAndInitial as g,initial as _,sync as v}from"../../../core/reactiveUtils.js";import"../../../core/scheduling.js";import{getMetersPerUnitForSR as ne}from"../../../core/units.js";import{property as y,subclass as re}from"../../../core/accessorSupport/decorators.js";import{exactEquals as ie,set as ae,copy as oe}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as se}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as x,radiusModifier as ce}from"../../../geometry/ellipsoidUtils.js";import{projectWithoutEngine as le}from"../../../geometry/projectionUtils.js";import ue from"../../../geometry/SpatialReference.js";import{projectBoundingSphere as de}from"../../../geometry/projection/projectBoundingSphere.js";import{getProjector as fe}from"../../../geometry/projection/projectors.js";import{projectPointToVector as pe}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as me}from"../../../geometry/projection/projectVectorToVector.js";import{create as S,fromExtent as he,equals as C,intersection as ge,intersectsSphere as _e}from"../../../geometry/support/aaBoundingRect.js";import{copy as ve,create as ye}from"../../../geometry/support/frustumPlanes.js";import{createSpatialReferenceCyclical as be}from"../../../geometry/support/normalizeUtils.js";import{isGeographic as w,isPlateCarree as xe}from"../../../geometry/support/spatialReferenceUtils.js";import{Sphere as Se}from"../../../geometry/support/sphere.js";import{ElevationQueryTileCache as Ce}from"../../../layers/support/ElevationQueryTileCache.js";import{isIntegratedMeshLayer as we,isBaseLayer as Te}from"../../../layers/support/layerUtils.js";import{queueHighPriority as Ee}from"../../../request/queue.js";import{debugFlags as T}from"../support/debugFlags.js";import{ElevationRange as E}from"../support/ElevationRange.js";import{ElevationUpdateEvent as De}from"../support/ElevationUpdateEvent.js";import{calculateElevationUpdateExtents as Oe}from"../support/elevationUpdateExtentUtils.js";import{toBoundingRect as ke}from"../support/extentUtils.js";import{geographicMbsToGeographicExtent as Ae,mbsToGeographicExtent as je,intersectsGeographicExtent as Me}from"../support/sphereExtentUtils.js";import{isSupportedGCSOnGlobe as D}from"../support/supportedSpatialReference.js";import{updatingProgress as Ne}from"../support/updatingProperties.js";import{ElevationBounds as Pe}from"./ElevationBounds.js";import{ElevationData as Fe,sampleElevation as Ie}from"./ElevationData.js";import{create as Le}from"./ExtentHelper.js";import{LayerClasses as Re}from"./LayerClass.js";import{OverlayManager as ze}from"./OverlayManager.js";import{PlanarPatch as Be}from"./PlanarPatch.js";import{Queue as Ve}from"./Queue.js";import{ScaleRangeQueries as He}from"./ScaleRangeQueries.js";import{SphericalPatch as Ue}from"./SphericalPatch.js";import{SplitLimits as We}from"./SplitLimits.js";import{maxRootTiles as O,tooManyRootTilesAfterChangeError as Ge,tooManyRootTilesForLayerError as Ke,maxTileNeighborLevelDelta as k,maxMemoryLodBias as qe}from"./TerrainConst.js";import{TerrainRenderer as Je}from"./TerrainRenderer.js";import Ye from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as A,isVectorTileLayerView as j,internalAssert as M,oppositeEdge as Xe,neighborEdgeIndices as N,isSurfaceLayerView as P,isGroupLayerView as F,isMapTileLayerView as I,isBlendableLayerView as L,isElevationLayerView as R,releaseTerrainData as z,oppositeCorner as Ze,enableTerrainInternalChecks as B,enableWaterproofTests as Qe,enableInternalTerrainChecks as $e,enableTerrainWaterproofChecks as et,neighborCornerIndices as tt}from"./terrainUtils.js";import{Tile as nt,lijEquals as V}from"./Tile.js";import{printAllocations as rt}from"./TilePerLayerInfo.js";import{sortTiles as it,IteratorPreorder as at,IteratorPostorder as ot,compareTilesByLij as H,sortTilesByPOI as st,traverseTilesPreorder as U}from"./tileUtils.js";import{TilingSchemeLogic as ct}from"./TilingSchemeLogic.js";import{getGroundTransparencyModeFromOpacity as lt}from"./TransparencyMode.js";import{UpsampleInfo as ut}from"./UpsampleInfo.js";import{isCompositeBlendMode as dt,blendModeFromString as ft}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{hasLayerBasedScaleVisibility as pt}from"../../support/layerViewUtils.js";import{ImmediateTask as mt,TaskPriority as ht,noBudget as gt}from"../../support/Scheduler.js";import{TextureCompressionTracker as _t}from"../../support/TextureCompressionTracker.js";import{Yield as vt}from"../../support/Yield.js";var W;let G=class extends o{static{W=this}get allTilesCreated(){return this._allTilesCreated}get allTiles(){return a(this._allTiles)}get renderedTiles(){return it(n(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get _tileConstructor(){return this.view.state.isGlobal?Ue:Be}get _ellipsoid(){return x(this.view.spatialReference)}get demResolution(){let{_allTiles:e,tilingScheme:t}=this;if(e.length===0)return{min:1,max:1};let n=ne(t.spatialReference),r=1/0,i=-1/0;for(let a of e){let e=t.resolutionAtLevel(a.level)*n;r=Math.min(r,e),i=Math.max(i,e)}return{min:r,max:i}}constructor(e){super(e),this.terrainTextureCompressionTracker=new _t,this._iteratorPool=new d(()=>new at,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new ot,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._allTilesCreated=!1,this._usedMemory=null,this._performanceInfo=new Ye,this._waterproofnessErrorHandle=null,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=b(),this._eyePosSurfaceSR=b(),this._splitLimits=new We,this._layerViews=[[],[]],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._updatingHandles=new se,this._poiWatchHandle=null,this._frameTask=mt,this._allTiles=new f,this._upsampleInfoPool=new d(()=>new ut),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=S(),this.updatingProgress=.5,this._maxNumUpdating=1,this.hasCompositeBlendMode=!1,this.maxTextureScale=1.2,this._elevationProjectorCache=new Map,this._rootTileElevationRange=new E(1/0,-1/0),this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this.enabled=!0,this.overlayManager=new ze({...e,terrainSurface:this}),this._renderer=new Je(this,this.overlayManager.renderer,this._allTiles,this.terrainTextureCompressionTracker,e.view),pt()||(this._scaleRangeQueries=new He)}initialize(){let{view:e}=this,{resourceController:t}=e,{memoryController:n}=t;e.stage.addRenderPlugin(this._renderer),this._tileCache=new ee((e,t)=>n.newCache(e,t),`terrain-tile`),this._upsampleMapCache=n.newCache(`terrain-upsample`,({tile:e})=>e.unloadMapData()),this._elevationQueryCache=new Ce(n.newCache(`elevation-query`));let r=this.overlayManager;this.addHandles([h(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),h(()=>this.renderer.visible,e=>this.freeze=!e),h(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)},g)],`overlayManager`),this._updatingHandles.add(()=>({heading:e.camera?.heading,state:e.state?.mode}),({heading:e,state:t})=>{if(e==null)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree){this.heading=Math.round(e/90)*90%360;return}let n=Math.round(e)%360,r=Math.abs(n-this.heading);(t===2||Math.min(r,360-r)>=30)&&(this.heading=n)},_),this.addHandles([h(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},g),h(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),g),h(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},v),h(()=>this.snapLevel,()=>this._viewChanged=!0,v),h(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._poiWatchHandle=l(this._poiWatchHandle),e&&(this._poiWatchHandle=this._updatingHandles.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:ie}))}),h(()=>T.TERRAIN_TILE_TREE_SHOW_TILES,t=>{t&&!this._treeDebugger?import(`../layers/support/TerrainTileTree3DDebugger.js`).then(({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&T.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))}):t||(this._treeDebugger=u(this._treeDebugger))},_),h(()=>this.tilingScheme,e=>this._updateTilingScheme(e),v)]);let{spatialReference:a}=e;this._extentHelper=Le(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});let o=new i({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&`layers`in e?e.layers:null}),s=new ct({layers:o,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set(`tilingSchemeLogic`,s);let c=t.scheduler;this._frameTask=c.registerTask(ht.TERRAIN_SURFACE,this),this.addHandles([h(()=>this._stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),_),h(()=>this.groundExtent,()=>this._updateRootTiles(),_),e.on(`resize`,()=>this._viewChangeUpdate()),h(()=>{let t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),g),h(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,_),h(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,_),h(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>{this._allTiles.forAll(e=>this.updateElevationSources(e)),this._updateAllTileGeometries()}),e.allLayerViews.on(`after-changes`,()=>this._layerViewsDirty=!0)]),this._updatingHandles.add(()=>this.userClippingExtent,()=>this._updateClippingExtent()),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}clearHandles(){this._updatingHandles?.removeAll(),this.removeAllHandles(),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear()}destroy(){this._waterproofnessErrorHandle?.remove(),this._waterproofnessErrorHandle=null,this._frameTask.remove(),this._frameTask=mt,this._updatingHandles?.destroy(),this._removeAllTiles(),this._set(`tilingSchemeLogic`,u(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._set(`overlayManager`,u(this.overlayManager)),this._tileCache=u(this._tileCache),this._allTiles.prune(),nt.prune(),this._treeDebugger=u(this._treeDebugger),this._renderer.destroyed||(this.view.stage.removeRenderPlugin(this._renderer),this._renderer.destroy()),this._renderer=null,this._iteratorPool=u(this._iteratorPool),this._upsampleMapCache=u(this._upsampleMapCache),this._elevationQueryCache=u(this._elevationQueryCache),this._set(`view`,null),this._extentHelper=u(this._extentHelper),this._upsampleInfoPool=u(this._upsampleInfoPool),rt(),this._layerViews.forEach(e=>e.length=0),this._performanceInfo=null}get renderer(){return this._renderer}get frustum(){return this.view.state.camera.frustum}get snapLevel(){return this.lodSnappingEnabled?this.view.terrainLevel:null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return!!this._stencilEnabledExtents?.length}get _stencilEnabledExtents(){let e=this.spatialReference,t=!!has(`enable-feature:im-as-ground`);return e==null?null:Iterator.from(this.view.allLayerViews).map(n=>{let{layer:r}=n;if(!we(r)||t&&!r.isUsedAsGroundLayer)return null;let{fullExtent:i}=r,a=i==null||i.spatialReference.equals(e)?i:le(i,i.spatialReference,e);return a?he(a):null}).filter(e=>e!=null).toArray()}get userClippingExtent(){let{spatialReference:e}=this,t=this.view?.clippingArea;if(t==null||e==null)return null;let n=S(),r=ke(t,n,e)?n:null,i=this._get(`userClippingExtent`);return C(r,i)?i:r}get rootTilesExtent(){return this._rootTilesExtent}get groundExtent(){let e=ge(this.fullGroundExtent,this.userClippingExtent,S()),t=this._get(`groundExtent`);return C(e,t)?t:e}get fullGroundExtent(){return this._tilingSchemeExtent==null?this._rootTilesExtent:this._tilingSchemeExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),this.enabled&&!!((this.readyToRun||this._updatingHandles?.updating||this._asyncWorkItems>0)&&this.ready&&!this.freeze||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get readyToRun(){return this.enabled&&(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.freeze}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 isGlobal(){return this.view.state.isGlobal}get ready(){return!this.enabled||this._rootTiles!=null}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??ue.WebMercator}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 tilingScheme(){return this.tilingSchemeLogic?.tilingScheme}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===0}get invisible(){return this._renderer.transparency===3}set freeze(e){this._set(`freeze`,e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,n,r){this._renderer.intersectRay(e,t,n,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}get _xNormalizer(){return be(this.spatialReference)}getElevation(e,t,n,r){let i=this._rootTiles;if(!i?.length||!this.enabled||i[0].layerInfo[0].length===0)return null;let a=this._elevationProjectorCache.get(r);if(a===void 0&&(a=fe(r,this.spatialReference)??null,this._elevationProjectorCache.set(r,a)),a==null)return s.getLogger(this).error(`TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system`),null;let o=ae(K,e,t,n);return a(o,0,o,0),Y(i,this._xNormalizer?.normalize(o[0])??o[0],o[1])}getElevations(e,t,n){let r=this._rootTiles,i=r?r[0].layerInfo[0].length:0;if(!r?.length||i===0||!this.enabled)for(let e=0;e<t;++e)n(e,null);else for(let i=0;i<t;++i){let t=i*3,a=Y(r,e[t],e[t+1]);n(i,a)}}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}get visibleElevationRange(){let e=1/0,t=-1/0;for(let n of this._allTiles)n.renderData&&(e=Math.min(e,n.elevationBoundsMin),t=Math.max(t,n.elevationBoundsMax));let n=this._get(`visibleElevationRange`);return n?.minElevation===e&&n.maxElevation===t?n:new E(e,t)}invalidateElevationRange(){this.notifyChange(`visibleElevationRange`)}tileElevationRangeChanged(e,t=1/0,n=-1/0){let r=this._get(`visibleElevationRange`);(!r||t===r.minElevation||n===r.maxElevation||e.renderData&&(e.elevationBoundsMin<r.minElevation||e.elevationBoundsMax>r.maxElevation))&&this.invalidateElevationRange()}getScale(e){if(!this.tilingScheme)return null;if(!pe(e,K,this.spatialReference))return s.getLogger(this).error(`TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system`),null;let t=this._rootTiles;if(t!=null){for(let e of t)if(e?.containsPoint(K)){let t=e;for(;t.children[0]&&!t.rendered;){let e=t.children[0].extent,n=0;K[0]>e[2]&&(n+=1),K[1]<e[1]&&(n+=2),t=t.children[n]}return this._getLodBiasCorrectedScale(t.level)}}return 1/0}getSphereElevationRange(e,t){if(!this.enabled)return null;let n=this._rootTiles,r=this.spatialReference;if(n==null||r==null||n.length===0)return null;let i=w(r);if(i){let n=w(t)&&D(t),i=x(t);if(n&&D(r)&&i===x(r))Ae(e,q,i.radius);else if(!je(e,t,q,r))return s.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project the query sphere`),null}else if(!de(e,t,bt,r))return s.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project the query sphere`),null;let a=new E,o=[];for(let e of n)o.push(e);let c=0;for(;c<o.length;){let e=o[c];if(++c,!(i?Me(e.extent,q,r):_e(e.extent,bt)))continue;let t=e.children;if(t[0]==null||e.rendered)a.expandElevationRangeValues(e.elevationBoundsMin,e.elevationBoundsMax);else for(let e of t)o.push(e)}return a}getRootElevationRange(){return this.enabled&&this._rootTiles?new E(this._rootTileElevationRange.minElevation,this._rootTileElevationRange.maxElevation):null}getLowerBoundRadius(){let e=this.visibleElevationRange,t=(this._ellipsoid.radius+(e.isEmpty?0:e.minElevation))*ce;return Math.min(t,this._ellipsoid.radius)}queryVisibleScaleRange(e,t,n,r){if(!this._scaleRangeQueries)return;let i=t?this.tilingScheme.levelAtScale(t):0,a=n?this.tilingScheme.levelAtScale(n):1/0,o=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,i+o,a+o,r)}_evaluateTransparency(){let e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,n=this._renderer.transparency,r=this._isFullyTransparent?lt(0,t):e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?0:1;return this._renderer.transparency=r,n!==r&&(this.notifyChange(`opaque`),this.notifyChange(`invisible`),!0)}_updateTilingScheme(e){A(!!e,`tiling scheme cannot be reset to undefined`),e&&this._removeAllTiles(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey=`TerrainTileMemcache`}_acquireTile(e,t,n,r){let i=this._tileCache.pop(W._tileMemcacheKey);return i?(i.init(e,t,n,r,this),i):new this._tileConstructor(e,t,n,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){let{groundExtent:e,tilingScheme:t}=this;if(!t)return;if(!this.enabled){this._setRootTiles(null);return}let n=xt,i=t.rootTilesInExtent(e,n,O*5);if(this._rootTiles!=null){if(i.length>O){s.getLogger(this).warn(Ge);return}let e=this._rootTiles.map(e=>e.lij),t=r(e,i,V);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){let e=this._rootTiles.filter(e=>t.removed.findIndex(t=>V(t,e.lij))>-1?(this._purgeTile(e),!1):!0);t.added.forEach(t=>e.push(this._newRootTile(t))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,i.length>O&&(s.getLogger(this).warn(Ke),i=t.rootTilesInExtent(e,n,O)),this._setRootTiles(i.map(e=>this._newRootTile(e)));C(n,this._rootTilesExtent)||(this._rootTilesExtent=S(n)),this.renderer.visible=!0,this.overlayManager.setPlacementDirty(),this.notifyChange(`ready`),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this._viewChangeUpdate(),this.checkAllTilesWaterproofness(`root-tiles-updated`)}_updateAllTileGeometries(){let e=this._allTiles.filter(e=>this._canUpdateTileGeometry(e));e.length===0||(e.sort(H),e.forEach(e=>this._renderer.updateTileGeometryState(e)),e.forEach(e=>e.renderData.updateNeighborData()),this._updateTilesGeometries(e)),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){let t=e.filter(e=>this._canUpdateTileGeometry(e));if(t.length===0)return;let n=this.renderer;for(let e of t)n.updateGeometryIfNeeded(e);for(let e of t)this._pendingTilesForElevationUpdateEvent.add(e)}_canUpdateTileGeometry(e){return e.loaded&&e.intersectsClippingArea&&e.hasGeometryState}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===1}_newRootTile(e){let t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(1),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationRange(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),e!=null){let t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this.invalidateElevationRange(),this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.freeze&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask||this._updatingRootTiles?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.groundExtent)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(e==null)return;let t=this.groundExtent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty(!1);let r=this._iteratorPool.acquire();for(r.reset(e);!r.done;){let e=r.next();e.updateClippingStatus(t)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n)}r.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries()}_updateRootTileElevationRange(){let e=1/0,t=-1/0;this._rootTiles?.forEach(({elevationBoundsMin:n,elevationBoundsMax:r})=>{e=Math.min(e,n),t=Math.max(t,r)});let n=this._rootTileElevationRange;(n.minElevation!==e||n.maxElevation!==t)&&(this._rootTileElevationRange=new Pe(e,t))}_updateViewDependentParameters(){let{camera:e,contentCamera:t}=this.view.state,n=Math.tan(t.fovX*.5),r=Math.tan(t.fovY*.5),i=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=n,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=i/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=i/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=ve(this._splitLimits.frustum??ye(),t.frustum):this._splitLimits.frustum=null,oe(this._eyePosRenderSR,t.eye),me(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility(),this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){let t;e.forEachLoadedNeighbor(e=>{t??=this._layerViews[1].some(j),t&&e.setPendingUpdate(32),this._pendingTilesToUpdate.add(e)})}_updateTileTexture(e,t){let n=e.hasPendingUpdate(32)?32:e.hasPendingUpdate(16)?16:!1;if(n){let r=this._renderer.updateTileTexture(e,n);return this._usedMemory=null,r&&e.resetPendingUpdate(n),t.madeProgress(),r}return!0}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;let e=this._pendingTilesForElevationUpdateEvent;if(e.size>0){let t=new Float64Array(4*e.size),n=0;for(let r of e)t.set(r.extent,4*n),++n;e.clear();for(let e of Oe(t,this.spatialReference)){let t=new De(this.spatialReference,e,`ground`);this.emit(`elevation-change`,t)}}this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);let t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),this._updateElevation(e);let n=this._updateTextures(e);t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty();let r=this._pendingTilesToUpdate.size>0,i=r&&this._hasPendingGeometryWithoutIndices();if((!e.done||i)&&this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&(e.hasProgressed||r&&!i)&&this.requestUpdate(),this.notifyChange(`updatingProgressValue`),!n||!e.hasProgressed)return vt}_checkTileInvariant(){}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;let t=!1,n=new Ve(this._allTiles.length);n.pushAll(this._rootTiles);let r=this.snapLevel,i=this._splitLimits,a=this._eyePosRenderSR;this._allTiles.forAll(e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0});let o=this.view.state.contentCamera.viewProjectionMatrix;for(;!n.empty;){let e=n.pop(),s=e.parent?.hasPendingUpdate(4),c=e.elevationLevel,l=s?4:e.shouldSplit(i,a,r),u=l===1;e.leaf?X(e,u):n.pushAll(e.children),s?(e.resetPendingUpdate(1),e.leaf||(e.setPendingUpdate(4),t=!0),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(o)):(u?(e.resetPendingUpdate(4),e.leaf&&(e.setPendingUpdate(1),t=!0)):(e.resetPendingUpdate(1)&&e.updateAgentSuspension(),l===2&&e.updateAgents(0),e.leaf||(e.setPendingUpdate(4),e.resetPendingUpdate(1),t=!0)),e.elevationLevel!==c&&this.updateElevationSources(e))}this._allTilesDirty=t,this.requestUpdate(),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){!e.done&&!this._allTilesSorted&&this.view.pointsOfInterest?.focus&&(st(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger?.update(),e.madeProgress())}_markTileToUpdate(e){M(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_hasPendingGeometryWithoutIndices(){for(let e of this._pendingTilesToUpdate)if(e.loaded&&e.intersectsClippingArea&&e.renderData?.vao?.indexBuffer==null)return!0;return!1}_updatePendingTileGeometries(){let e=this._pendingTilesToUpdate,t=[];if(e.forEach(e=>{this._canUpdateTileGeometry(e)&&t.push(e)}),t.length===0){e.clear();return}let n=(n,r)=>{!r||!this._canUpdateTileGeometry(r)||r.level<n.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(H);let r=t.length;for(let i=0;i<r;++i){let r=t[i];M(r.loaded),M(r.intersectsClippingArea);let a=r.renderData;if(!a?.geometryState)continue;a.updateNeighborData();let o=a.dirtyEdgeResolutions,s=a.geometryState,c=e=>{let t=tt[e];n(r,s.cornerPeerNeighbors[e]?.findCorner(Ze(t),e=>e.loaded))};for(let t=0;t<4;++t)if(o&1<<t){let i=a.geometryState.edgePeerNeighbors[t];i&&i?.level>=r.level&&i.forAllSubtreeOnSide(Xe(N[t]),t=>this._canUpdateTileGeometry(t)?(M(e.has(t)||H(r,t)<0),n(r,t),!0):!1),c((t+1)%4),c(t)}}e.clear(),t.sort(H),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,B&&Qe&&this.checkAllTilesWaterproofness(`pending-geometries-updated`)}_mergeAndSplit(e,t){if(this.freeze||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let n=!1,r=this.view.state.fixedContentCamera,i=!1;for(;!e.done;){i=!0;let a=!1,o=!this._allTiles.some(i=>{if(!n&&!r&&!i.visible)return e.done;let o=i;if(i.hasPendingUpdate(4)){if(!t||i.unmergableChildCount>0)return e.done;for(i.resetPendingUpdate(4);o.parent!=null&&o.parent.unmergableChildCount===0&&o.parent.resetPendingUpdate(4);)o=o.parent;this._mergeTile(o),a=!0,e.madeProgress()}else if(i.resetPendingUpdate(1)){let t=!0,n=i.level;if(n>=k){let e=e=>e.leaf||n-e.level<k;for(let r=0;r<4;++r){let a=i.findNeighborTile(N[r],e);a!=null&&n-a.level===k&&(t=!1,B&&(M(a.leaf),M(a.hasPendingUpdate(1))))}}t?(this._splitTile(i),e.madeProgress(),a=!0):i.setPendingUpdate(1)}return e.done});if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0),o){if(!n){n=!0;continue}if(!a)break}else this._allTilesDirty=!0}i?e.madeProgress():this._allTilesDirty=!0,this._allTilesCreated=!this.allTiles.some(e=>e.hasPendingUpdate(1)||e.hasPendingUpdate(4)&&e.unmergableChildCount===0),this._sortTiles(e)}_updateElevation(e){e.done||this._allTiles.some(t=>(t.resetPendingUpdate(8)&&(this._updateTileGeometryState(t),e.madeProgress()),e.done))}updateElevationSources(e){e.needsElevationSourceUpdate()&&(e.updateAgents(0),e.markElevationSourceUpdateRequested(),this.requestUpdate())}_updateTextures(e){if(e.done)return!0;let t=!0;return this._allTiles.some(n=>(this._updateTileTexture(n,e)||(t=!1),e.done)),t}_updateClippingExtent(){this.spatialReference&&(this.updateOverlayParameters(),this.requestRender(1),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){return this.view.qualitySettings.tiledSurface.lodBias-(1-this.view.quality)*qe}_getLodBiasCorrectedScale(e){let t=this.tilingScheme.levels,n=c(e-this._lodBias,0,t.length-1),r=n-Math.floor(n),i=t[Math.floor(n)].scale,a=t[Math.ceil(n)].scale;return i*(1-r)+a*r}_removeAllTiles(){this.renderer.visible=!1,this._pendingTilesToUpdate.clear(),this._pendingTilesForElevationUpdateEvent.clear(),this._rootTiles!=null&&(this._rootTiles.forEach(e=>this._purgeTile(e)),this._setRootTiles(null),this.notifyChange(`ready`)),this._allTiles.clear(),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_purgeSubtree(e){let t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?Z(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(W._tileMemcacheKey,e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){A(e.leaf,`Tile that is already split should not be split again!`),A(e.rendered,`Tile marked to split is not rendered`),Z(e);let t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles}),e.updateAgentSuspension(),A(e.rendered,`parent should be rendered`),t.forEach(e=>this._loadTile(e)),t.forEach(e=>this._pendingTilesToUpdate.add(e)),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach(e=>X(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){J.spatialReference=this.spatialReference,J.extent=e.extent,J.scale=this._getLodBiasCorrectedScale(t),this.emit(`scale-change`,J)}createTile(e,t,n,r){A(!!r,`createTile sanity check`);let i=this._acquireTile(e,t,n,r);return i.updateClippingStatus(this.groundExtent),i.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(i)&&i.setPendingUpdate(1),i}get _shortBatches(){return this.view.state.mode!==2}_mergeTile(e){A(!e.hasPendingUpdate(1),`_mergeTile sanity check`),A(!e.leaf,`Cannot merge a leaf`),e.leaf||(this._purgeSubtree(e),A(!e.renderData,`Merging tile with existing render data?`),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),X(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&e.updateOverlayParameters(this.overlayManager)}_handleLayerViewChanges(e=gt){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1,n=new Set,r=-1;for(let e=this.view.allLayerViews.length-1;e>=0;e--){let i=this.view.allLayerViews.items[e];if(n.add(i.uid),P(i)||F(i)){if(this._basemapLayerViewHandles.has(i.uid)&&!F(i)){let e=this._layerClassFromLayerView(i),n=this.getLayerIndexByUID(e,i.uid);n!=null&&((n<r||r==null)&&(t=!0),r=n)}else this._registerTiledLayerView(i),i.layer.loaded&&(t=!0)}}this._basemapLayerViewHandles.forEach((e,r)=>{n.has(r)||(this._unregisterTiledLayerView(r),t=!0)}),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(let e of this.view.allLayerViews.items)if(I(e)&&!Te(e.layer)&&e.fullOpacity!==0)return!1;return!0}_hasCompositeBlendMode(){for(let e of this.view.allLayerViews.items)if((L(e)||F(e))&&dt(ft[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return+!R(e)}_registerTiledLayerView(e){let t=[];if((L(e)||F(e))&&t.push(h(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!F(e)){let n=this._layerClassFromLayerView(e);t.push(h(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(h(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));let{layer:r}=e;`effectiveScaleRange`in r&&t.push(h(()=>!e.destroyed&&r.effectiveScaleRange,()=>this._restartAllAgents(n))),t.push(e.on(`data-changed`,()=>{let t=this.getLayerIndexByUID(n,e.uid);t!=null&&this._invalidateLayerData(t,n)}))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){let t=this._basemapLayerViewHandles.get(e);if(t){for(let e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;let e=this.view.allLayerViews,t=[[],[]],n=null;e.forEach(e=>{if(!e.layer||e.suspended||!P(e)||!e.fullExtent)return;let r=this._layerClassFromLayerView(e);if(r===1){let t=e.displayLevelRange.maxLevel;t!==1/0&&(n===null||t>n)&&(n=t)}t[r].push(e)});for(let e of Re){let n=this._layerViews[e],r=t[e];r.reverse();let i=r.length,a=n.length!==i,o=Array(i),s=Array(n.length);this._layerIndexByUid[e].clear();for(let t=0;t<i;t++){let i=r[t].uid;this._layerIndexByUid[e].set(i,t);let c=n.indexOf(r[t]);o[t]=c,t!==c&&(a=!0),c>-1&&(s[c]=t)}if(a){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;)t.next().modifyLayers(s,o,e);this._layerViews[e]=r,this._restartAllAgents(e),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(n)&&(this._viewChangeUpdate(),this.notifyChange(`tilingScheme`))}_restartAllAgents(e){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){let n=t.next();n.restartAgents(e),e===0&&n.computeElevationBounds()}this._updateRootTileElevationRange()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll(t=>{t.updateAgents(1),e===1?this.renderer.updateTileTexture(t,16):t.updateRenderData(1,e)}),this._evaluateTransparency()}_invalidateLayerData(e,t){this._rootTiles!=null&&(U(this._rootTiles,n=>n.removeLayerAgent(e,t)),U(this._rootTiles,n=>{n.invalidateLayerData(e,t),n.restartAgents(t)}))}setTileTreeDirty(e){this._allTilesDirty=!0,e&&(this._allTilesCreated=!1)}requestRender(e=1){this.renderer.requestRender(e)}requestUpdate(){++this._pendingUpdates===1&&(this._hasPendingUpdates=!0)}requestTileData(e,t,n,r){let i=this.layerViewByIndex(t,n),{tilemapCache:a}=i;return!a||j(i)?this._requestTileData(e,n,i,r):(++this._asyncWorkItems,a.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).catch(t=>{throw te(r),p(t)||this._dataMissing(e,n,i),t}).then(()=>this._frameTask.schedule(()=>this._requestTileData(e,n,i,r),r.signal)).finally(()=>--this._asyncWorkItems))}_requestTileData(e,t,n,r){return this.destroying?Promise.resolve():t===0?R(n)?this._requestElevationTileData(e,n,r):Promise.reject():I(n)?this._requestMapTileData(e,n,r):Promise.reject()}_requestElevationTileData(e,t,n){++this._asyncWorkItems;let r=r=>{!m(n)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},i=n=>{p(n)||(s.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${n}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,{...Ee,...n}).then(e=>this._frameTask.schedule(()=>r(e)),i).finally(()=>--this._asyncWorkItems)}_elevationDataArrived(e,t,n){let r=this._layerIndexByUid[0].get(t.uid);if(r==null){s.getLogger(this).warn(`TerrainSurface: received data from unknown layer %d %s`,0,e.lij.toString());return}let i=new Fe(e.lij,e.extent,n);e.dataArrived(r,0,i),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:0});let a=[e],o=e.level,c=this._iteratorPool.acquire();for(c.reset(a);!c.done;){let e=c.next();e.findElevationBoundsForLayer(r,o),e.computeElevationBounds()}o===0&&this._updateRootTileElevationRange(),c.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,n){++this._asyncWorkItems;let r=(r,i)=>{z(i),m(n)||(console.error(`Tile ${e.lij.toString()} layer 1/${t.uid} error ${r}`),this._dataMissing(e,1,t),this.requestUpdate())},i=e=>t=>r(t,e);return t.fetchTile(e.lij,n).then(r=>this._frameTask.schedule(()=>{this.requestUpdate(),m(n)?z(r):this._mapTileDataArrived(e,t,r)},n.signal,i(r)).catch(i(r)),(e,t=null)=>this._frameTask.schedule(()=>r(e,t))).finally(()=>--this._asyncWorkItems)}_mapTileDataArrived(e,t,n){let r=this.getLayerIndexByUID(1,t.uid);r==null?(z(n),s.getLogger(this).warn(`TerrainSurface: received data from unknown layer`)):(e.dataArrived(r,1,n),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:1}))}_dataMissing(e,t,n){let r=this.getLayerIndexByUID(t,n.uid);r==null?s.getLogger(this).warn(`TerrainSurface: received data from unknown layer`):(e.dataMissing(r,t),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:t}))}get performanceInfo(){let e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll(t=>{t.leaf&&e.numLeaves++;let n=t.level;t.renderData&&(e.numLoadedPerLevel[n]=(e.numLoadedPerLevel[n]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[n]=(e.numRenderedPerLevel[n]||0)+1,e.numRendered++))}),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(this._usedMemory??=this._recalculateUsedMemory(),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce((e,t)=>e+t.usedMemory,0)):null}getUsedMemoryForLayerView(e){let t=0,n=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(n,e.uid);return r!=null&&this._allTiles.forAll(e=>t+=e.getUsedMemoryForLayer(n,r)),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(e=`render-patch-groups`){}get isGeographic(){return this.spatialReference?.isGeographic??!1}get isWebMercator(){return this.spatialReference?.isWebMercator??!1}get isWebMercatorOnPlateCarree(){return this.isWebMercator&&xe(this.view?.renderSpatialReference)}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&e[2]===0}lijEastEnd(e){return 1<<e+ +!!this.isGeographic}wrapEastWest(e){let t=this.lijEastEnd(e[0]),n=e[2];if(0<=n&&n<t)return e;if(!this.isGlobal)return null;let r=(n+(n<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){$e(e)}enableWaterproofnessChecks(e){et(e)}static cleanupTerrainSurface(){St.prune()}enable(e){e!==this.enabled&&(this._set(`enabled`,e),e?(this._updateRootTiles(),this.freeze=!1,this.view.elevationProvider.register(0,this)):(this.view.elevationProvider.unregister(this),this.freeze=!0,this._removeAllTiles(),this._setRootTiles(null)),this.notifyChange(`ready`))}updateOverlayParameters(){let{overlayManager:e}=this;this.allTiles.forAll(t=>t.updateOverlayParameters(e))}};e([y()],G.prototype,`_renderer`,void 0),e([y({constructOnly:!0})],G.prototype,`_scaleRangeQueries`,void 0),e([y({constructOnly:!0})],G.prototype,`view`,void 0),e([y({constructOnly:!0})],G.prototype,`overlayManager`,void 0),e([y()],G.prototype,`_hasPendingUpdates`,void 0),e([y()],G.prototype,`_asyncWorkItems`,void 0),e([y()],G.prototype,`_allTilesDirty`,void 0),e([y()],G.prototype,`_allTilesSorted`,void 0),e([y()],G.prototype,`allTilesCreated`,null),e([y()],G.prototype,`_allTilesCreated`,void 0),e([y()],G.prototype,`_viewChanged`,void 0),e([y({type:Number})],G.prototype,`heading`,void 0),e([y()],G.prototype,`_splitLimits`,void 0),e([y()],G.prototype,`_frameTask`,void 0),e([y()],G.prototype,`_tileConstructor`,null),e([y()],G.prototype,`_ellipsoid`,null),e([y()],G.prototype,`demResolution`,null),e([y({readOnly:!0})],G.prototype,`snapLevel`,null),e([y({readOnly:!0})],G.prototype,`lodSnappingEnabled`,null),e([y()],G.prototype,`_stencilEnabledExtents`,null),e([y({readOnly:!0})],G.prototype,`userClippingExtent`,null),e([y()],G.prototype,`_rootTilesExtent`,void 0),e([y({readOnly:!0})],G.prototype,`groundExtent`,null),e([y({readOnly:!0})],G.prototype,`fullGroundExtent`,null),e([y({readOnly:!0})],G.prototype,`_tilingSchemeExtent`,null),e([y({readOnly:!0})],G.prototype,`updating`,null),e([y({readOnly:!0})],G.prototype,`readyToRun`,null),e([y(Ne)],G.prototype,`updatingProgress`,void 0),e([y({readOnly:!0})],G.prototype,`updatingProgressValue`,null),e([y()],G.prototype,`_maxNumUpdating`,void 0),e([y()],G.prototype,`baseOpacity`,null),e([y()],G.prototype,`hasCompositeBlendMode`,void 0),e([y({readOnly:!0})],G.prototype,`viewingMode`,null),e([y()],G.prototype,`maxTextureScale`,void 0),e([y({readOnly:!0})],G.prototype,`ready`,null),e([y({readOnly:!0})],G.prototype,`rootTiles`,null),e([y()],G.prototype,`_rootTiles`,void 0),e([y()],G.prototype,`spatialReference`,null),e([y({type:t})],G.prototype,`backgroundColor`,null),e([y({value:!1})],G.prototype,`slicePlaneEnabled`,null),e([y()],G.prototype,`tilingScheme`,null),e([y({readOnly:!0})],G.prototype,`tilingSchemeLocked`,null),e([y({readOnly:!0})],G.prototype,`tilingSchemeLogic`,void 0),e([y()],G.prototype,`wireframe`,null),e([y()],G.prototype,`opaque`,null),e([y()],G.prototype,`invisible`,null),e([y({value:!1})],G.prototype,`freeze`,null),e([y()],G.prototype,`fadeDuration`,null),e([y()],G.prototype,`_xNormalizer`,null),e([y()],G.prototype,`visibleElevationRange`,null),e([y()],G.prototype,`_rootTileElevationRange`,void 0),e([y()],G.prototype,`_layerViewsDirty`,void 0),e([y()],G.prototype,`renderPatchBorders`,null),e([y()],G.prototype,`renderingDisabled`,null),e([y()],G.prototype,`isGeographic`,null),e([y()],G.prototype,`isWebMercator`,null),e([y()],G.prototype,`isWebMercatorOnPlateCarree`,null),e([y({readOnly:!0})],G.prototype,`enabled`,void 0),G=W=e([re(`esri.views.3d.terrain.TerrainSurface`)],G);const yt=G,K=b(),bt=new Se,q=S(),xt=S(),St=new f,J={spatialReference:null,extent:null,scale:0};function Y(e,t,n){for(let r of e){if(!r.containsPointXY(t,n))continue;let e=r;for(;e&&!e.renderData;){let r=+(t>e.extentMidX)+(n<e.extentMidY?2:0);e=e.children[r]}let i=e?.renderData?.geometryState.samplerData??null;return Ie(t,n,i)}return null}function X(e,t){!e.leaf||e.level<k||$(e,e=>{t&&Ct(e);let n=Q(e);if(e.maxLevelDeltaNeighborCount++,n){let t=e.parent;for(;t;){let e=Q(t);if(t.unmergableChildCount++,e)t=t.parent;else break}}})}function Ct(e){if(e.hasPendingUpdate(1))return;let t=e.parent;for(;t?.resetPendingUpdate(4);)t=t.parent;e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1),e.level<k||$(e,e=>{Ct(e)})}function Z(e){e.level<k||$(e,e=>{if(e.maxLevelDeltaNeighborCount--,e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0){let t=e.parent;for(;t&&(t.unmergableChildCount--,Q(t));)t=t.parent}})}function Q(e){return e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0}function $(e,t){if(e.level<k)return;let n=e.level-k,r=e.lij[1]>>k,i=e.lij[2]>>k,a=e=>e.leaf||e.level===n;for(let o=0;o<4;++o){let s=e.findNeighborTile(N[o],a);if(!s||s.level!==n)continue;let c=s.lij;(c[1]!==r||c[2]!==i)&&t(s)}}export{yt as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../Color.js";import{filterInPlace as n,difference as r}from"../../../core/arrayUtils.js";import i from"../../../core/CollectionFlattener.js";import{toConst as a}from"../../../core/compilerUtils.js";import{EventedAccessor as o}from"../../../core/Evented.js";import"../../../core/has.js";import s from"../../../core/Logger.js";import{clamp as c}from"../../../core/mathUtils.js";import{removeMaybe as l,destroyMaybe as u}from"../../../core/maybe.js";import{MemCachePool as ee}from"../../../core/MemCachePool.js";import d from"../../../core/ObjectPool.js";import f from"../../../core/PooledArray.js";import{throwIfAborted as te,isAbortError as p,isAborted as m}from"../../../core/promiseUtils.js";import{watch as h,syncAndInitial as g,initial as _,sync as v}from"../../../core/reactiveUtils.js";import"../../../core/scheduling.js";import{getMetersPerUnitForSR as ne}from"../../../core/units.js";import{property as y,subclass as re}from"../../../core/accessorSupport/decorators.js";import{exactEquals as ie,set as ae,copy as oe}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as se}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as x,radiusModifier as ce}from"../../../geometry/ellipsoidUtils.js";import{projectWithoutEngine as le}from"../../../geometry/projectionUtils.js";import ue from"../../../geometry/SpatialReference.js";import{projectBoundingSphere as de}from"../../../geometry/projection/projectBoundingSphere.js";import{getProjector as fe}from"../../../geometry/projection/projectors.js";import{projectPointToVector as pe}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as me}from"../../../geometry/projection/projectVectorToVector.js";import{create as S,fromExtent as he,equals as C,intersection as ge,intersectsSphere as _e}from"../../../geometry/support/aaBoundingRect.js";import{copy as ve,create as ye}from"../../../geometry/support/frustumPlanes.js";import{createSpatialReferenceCyclical as be}from"../../../geometry/support/normalizeUtils.js";import{isGeographic as w,isPlateCarree as xe}from"../../../geometry/support/spatialReferenceUtils.js";import{Sphere as Se}from"../../../geometry/support/sphere.js";import{ElevationQueryTileCache as Ce}from"../../../layers/support/ElevationQueryTileCache.js";import{IntegratedMeshSemantics as we}from"../../../layers/support/IntegratedMeshSemantics.js";import{isIntegratedMeshLayer as Te,isBaseLayer as Ee}from"../../../layers/support/layerUtils.js";import{queueHighPriority as De}from"../../../request/queue.js";import{debugFlags as T}from"../support/debugFlags.js";import{ElevationRange as E}from"../support/ElevationRange.js";import{ElevationUpdateEvent as Oe}from"../support/ElevationUpdateEvent.js";import{calculateElevationUpdateExtents as ke}from"../support/elevationUpdateExtentUtils.js";import{toBoundingRect as Ae}from"../support/extentUtils.js";import{geographicMbsToGeographicExtent as je,mbsToGeographicExtent as Me,intersectsGeographicExtent as Ne}from"../support/sphereExtentUtils.js";import{isSupportedGCSOnGlobe as D}from"../support/supportedSpatialReference.js";import{updatingProgress as Pe}from"../support/updatingProperties.js";import{ElevationBounds as Fe}from"./ElevationBounds.js";import{ElevationData as Ie,sampleElevation as Le}from"./ElevationData.js";import{create as Re}from"./ExtentHelper.js";import{LayerClasses as ze}from"./LayerClass.js";import{OverlayManager as Be}from"./OverlayManager.js";import{PlanarPatch as Ve}from"./PlanarPatch.js";import{Queue as He}from"./Queue.js";import{ScaleRangeQueries as Ue}from"./ScaleRangeQueries.js";import{SphericalPatch as We}from"./SphericalPatch.js";import{SplitLimits as Ge}from"./SplitLimits.js";import{maxRootTiles as O,tooManyRootTilesAfterChangeError as Ke,tooManyRootTilesForLayerError as qe,maxTileNeighborLevelDelta as k,maxMemoryLodBias as Je}from"./TerrainConst.js";import{TerrainRenderer as Ye}from"./TerrainRenderer.js";import Xe from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as A,isVectorTileLayerView as j,internalAssert as M,oppositeEdge as Ze,neighborEdgeIndices as N,isSurfaceLayerView as P,isGroupLayerView as F,isMapTileLayerView as I,isBlendableLayerView as L,isElevationLayerView as R,releaseTerrainData as z,oppositeCorner as Qe,enableTerrainInternalChecks as B,enableWaterproofTests as $e,enableInternalTerrainChecks as et,enableTerrainWaterproofChecks as tt,neighborCornerIndices as nt}from"./terrainUtils.js";import{Tile as rt,lijEquals as V}from"./Tile.js";import{printAllocations as it}from"./TilePerLayerInfo.js";import{sortTiles as at,IteratorPreorder as ot,IteratorPostorder as st,compareTilesByLij as H,sortTilesByPOI as ct,traverseTilesPreorder as U}from"./tileUtils.js";import{TilingSchemeLogic as lt}from"./TilingSchemeLogic.js";import{getGroundTransparencyModeFromOpacity as ut}from"./TransparencyMode.js";import{UpsampleInfo as dt}from"./UpsampleInfo.js";import{isCompositeBlendMode as ft,blendModeFromString as pt}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{hasLayerBasedScaleVisibility as mt}from"../../support/layerViewUtils.js";import{ImmediateTask as W,TaskPriority as ht,noBudget as gt}from"../../support/Scheduler.js";import{TextureCompressionTracker as _t}from"../../support/TextureCompressionTracker.js";import{Yield as vt}from"../../support/Yield.js";var G;let K=class extends o{static{G=this}get allTilesCreated(){return this._allTilesCreated}get allTiles(){return a(this._allTiles)}get renderedTiles(){return at(n(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get _tileConstructor(){return this.view.state.isGlobal?We:Ve}get _ellipsoid(){return x(this.view.spatialReference)}get demResolution(){let{_allTiles:e,tilingScheme:t}=this;if(e.length===0)return{min:1,max:1};let n=ne(t.spatialReference),r=1/0,i=-1/0;for(let a of e){let e=t.resolutionAtLevel(a.level)*n;r=Math.min(r,e),i=Math.max(i,e)}return{min:r,max:i}}constructor(e){super(e),this.terrainTextureCompressionTracker=new _t,this._iteratorPool=new d(()=>new ot,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new st,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._allTilesCreated=!1,this._usedMemory=null,this._performanceInfo=new Xe,this._waterproofnessErrorHandle=null,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=b(),this._eyePosSurfaceSR=b(),this._splitLimits=new Ge,this._layerViews=[[],[]],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._updatingHandles=new se,this._poiWatchHandle=null,this._frameTask=W,this._allTiles=new f,this._upsampleInfoPool=new d(()=>new dt),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=S(),this.updatingProgress=.5,this._maxNumUpdating=1,this.hasCompositeBlendMode=!1,this.maxTextureScale=1.2,this._elevationProjectorCache=new Map,this._rootTileElevationRange=new E(1/0,-1/0),this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this.enabled=!0,this.overlayManager=new Be({...e,terrainSurface:this}),this._renderer=new Ye(this,this.overlayManager.renderer,this._allTiles,this.terrainTextureCompressionTracker,e.view),mt()||(this._scaleRangeQueries=new Ue)}initialize(){let{view:e}=this,{resourceController:t}=e,{memoryController:n}=t;e.stage.addRenderPlugin(this._renderer),this._tileCache=new ee((e,t)=>n.newCache(e,t),`terrain-tile`),this._upsampleMapCache=n.newCache(`terrain-upsample`,({tile:e})=>e.unloadMapData()),this._elevationQueryCache=new Ce(n.newCache(`elevation-query`));let r=this.overlayManager;this.addHandles([h(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),h(()=>this.renderer.visible,e=>this.freeze=!e),h(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)},g)],`overlayManager`),this._updatingHandles.add(()=>({heading:e.camera?.heading,state:e.state?.mode}),({heading:e,state:t})=>{if(e==null)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree){this.heading=Math.round(e/90)*90%360;return}let n=Math.round(e)%360,r=Math.abs(n-this.heading);(t===2||Math.min(r,360-r)>=30)&&(this.heading=n)},_),this.addHandles([h(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},g),h(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),g),h(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},v),h(()=>this.snapLevel,()=>this._viewChanged=!0,v),h(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._poiWatchHandle=l(this._poiWatchHandle),e&&(this._poiWatchHandle=this._updatingHandles.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:ie}))}),h(()=>T.TERRAIN_TILE_TREE_SHOW_TILES,t=>{t&&!this._treeDebugger?import(`../layers/support/TerrainTileTree3DDebugger.js`).then(({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&T.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))}):t||(this._treeDebugger=u(this._treeDebugger))},_),h(()=>this.tilingScheme,e=>this._updateTilingScheme(e),v)]);let{spatialReference:a}=e;this._extentHelper=Re(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});let o=new i({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&`layers`in e?e.layers:null}),s=new lt({layers:o,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set(`tilingSchemeLogic`,s);let c=t.scheduler;this._frameTask=c.registerTask(ht.TERRAIN_SURFACE,this),this.addHandles([h(()=>this._stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),_),h(()=>this.groundExtent,()=>this._updateRootTiles(),_),e.on(`resize`,()=>this._viewChangeUpdate()),h(()=>{let t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),g),h(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,_),h(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,_),h(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>{this._allTiles.forAll(e=>this.updateElevationSources(e)),this._updateAllTileGeometries()}),e.allLayerViews.on(`after-changes`,()=>this._layerViewsDirty=!0)]),this._updatingHandles.add(()=>this.userClippingExtent,()=>this._updateClippingExtent()),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}clearHandles(){this._updatingHandles?.removeAll(),this.removeAllHandles(),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear()}destroy(){this._waterproofnessErrorHandle?.remove(),this._waterproofnessErrorHandle=null,this._frameTask.remove(),this._frameTask=W,this._updatingHandles?.destroy(),this._removeAllTiles(),this._set(`tilingSchemeLogic`,u(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._set(`overlayManager`,u(this.overlayManager)),this._tileCache=u(this._tileCache),this._allTiles.prune(),rt.prune(),this._treeDebugger=u(this._treeDebugger),this._renderer.destroyed||(this.view.stage.removeRenderPlugin(this._renderer),this._renderer.destroy()),this._renderer=null,this._iteratorPool=u(this._iteratorPool),this._upsampleMapCache=u(this._upsampleMapCache),this._elevationQueryCache=u(this._elevationQueryCache),this._set(`view`,null),this._extentHelper=u(this._extentHelper),this._upsampleInfoPool=u(this._upsampleInfoPool),it(),this._layerViews.forEach(e=>e.length=0),this._performanceInfo=null}get renderer(){return this._renderer}get frustum(){return this.view.state.camera.frustum}get snapLevel(){return this.lodSnappingEnabled?this.view.terrainLevel:null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return!!this._stencilEnabledExtents?.length}get _stencilEnabledExtents(){let e=this.spatialReference;return e==null?null:Iterator.from(this.view.allLayerViews).map(t=>{let{layer:n}=t;if(!Te(n)||!we.shouldStencilTerrain(n))return null;let{fullExtent:r}=n,i=r==null||r.spatialReference.equals(e)?r:le(r,r.spatialReference,e);return i?he(i):null}).filter(e=>e!=null).toArray()}get userClippingExtent(){let{spatialReference:e}=this,t=this.view?.clippingArea;if(t==null||e==null)return null;let n=S(),r=Ae(t,n,e)?n:null,i=this._get(`userClippingExtent`);return C(r,i)?i:r}get rootTilesExtent(){return this._rootTilesExtent}get groundExtent(){let e=ge(this.fullGroundExtent,this.userClippingExtent,S()),t=this._get(`groundExtent`);return C(e,t)?t:e}get fullGroundExtent(){return this._tilingSchemeExtent==null?this._rootTilesExtent:this._tilingSchemeExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),this.enabled&&!!((this.readyToRun||this._updatingHandles?.updating||this._asyncWorkItems>0)&&this.ready&&!this.freeze||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get readyToRun(){return this.enabled&&(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.freeze}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 isGlobal(){return this.view.state.isGlobal}get ready(){return!this.enabled||this._rootTiles!=null}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??ue.WebMercator}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 tilingScheme(){return this.tilingSchemeLogic?.tilingScheme}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===0}get invisible(){return this._renderer.transparency===3}set freeze(e){this._set(`freeze`,e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,n,r){this._renderer.intersectRay(e,t,n,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}get _xNormalizer(){return be(this.spatialReference)}getElevation(e,t,n,r){let i=this._rootTiles;if(!i?.length||!this.enabled||i[0].layerInfo[0].length===0)return null;let a=this._elevationProjectorCache.get(r);if(a===void 0&&(a=fe(r,this.spatialReference)??null,this._elevationProjectorCache.set(r,a)),a==null)return s.getLogger(this).error(`TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system`),null;let o=ae(q,e,t,n);return a(o,0,o,0),St(i,this._xNormalizer?.normalize(o[0])??o[0],o[1])}getElevations(e,t,n){let r=this._rootTiles,i=r?r[0].layerInfo[0].length:0;if(!r?.length||i===0||!this.enabled)for(let e=0;e<t;++e)n(e,null);else for(let i=0;i<t;++i){let t=i*3,a=St(r,e[t],e[t+1]);n(i,a)}}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}get visibleElevationRange(){let e=1/0,t=-1/0;for(let n of this._allTiles)n.renderData&&(e=Math.min(e,n.elevationBoundsMin),t=Math.max(t,n.elevationBoundsMax));let n=this._get(`visibleElevationRange`);return n?.minElevation===e&&n.maxElevation===t?n:new E(e,t)}invalidateElevationRange(){this.notifyChange(`visibleElevationRange`)}tileElevationRangeChanged(e,t=1/0,n=-1/0){let r=this._get(`visibleElevationRange`);(!r||t===r.minElevation||n===r.maxElevation||e.renderData&&(e.elevationBoundsMin<r.minElevation||e.elevationBoundsMax>r.maxElevation))&&this.invalidateElevationRange()}getScale(e){if(!this.tilingScheme)return null;if(!pe(e,q,this.spatialReference))return s.getLogger(this).error(`TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system`),null;let t=this._rootTiles;if(t!=null){for(let e of t)if(e?.containsPoint(q)){let t=e;for(;t.children[0]&&!t.rendered;){let e=t.children[0].extent,n=0;q[0]>e[2]&&(n+=1),q[1]<e[1]&&(n+=2),t=t.children[n]}return this._getLodBiasCorrectedScale(t.level)}}return 1/0}getSphereElevationRange(e,t){if(!this.enabled)return null;let n=this._rootTiles,r=this.spatialReference;if(n==null||r==null||n.length===0)return null;let i=w(r);if(i){let n=w(t)&&D(t),i=x(t);if(n&&D(r)&&i===x(r))je(e,Y,i.radius);else if(!Me(e,t,Y,r))return s.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project the query sphere`),null}else if(!de(e,t,J,r))return s.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project the query sphere`),null;let a=new E,o=[];for(let e of n)o.push(e);let c=0;for(;c<o.length;){let e=o[c];if(++c,!(i?Ne(e.extent,Y,r):_e(e.extent,J)))continue;let t=e.children;if(t[0]==null||e.rendered)a.expandElevationRangeValues(e.elevationBoundsMin,e.elevationBoundsMax);else for(let e of t)o.push(e)}return a}getRootElevationRange(){return this.enabled&&this._rootTiles?new E(this._rootTileElevationRange.minElevation,this._rootTileElevationRange.maxElevation):null}getLowerBoundRadius(){let e=this.visibleElevationRange,t=(this._ellipsoid.radius+(e.isEmpty?0:e.minElevation))*ce;return Math.min(t,this._ellipsoid.radius)}queryVisibleScaleRange(e,t,n,r){if(!this._scaleRangeQueries)return;let i=t?this.tilingScheme.levelAtScale(t):0,a=n?this.tilingScheme.levelAtScale(n):1/0,o=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,i+o,a+o,r)}_evaluateTransparency(){let e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,n=this._renderer.transparency,r=this._isFullyTransparent?ut(0,t):e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?0:1;return this._renderer.transparency=r,n!==r&&(this.notifyChange(`opaque`),this.notifyChange(`invisible`),!0)}_updateTilingScheme(e){A(!!e,`tiling scheme cannot be reset to undefined`),e&&this._removeAllTiles(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey=`TerrainTileMemcache`}_acquireTile(e,t,n,r){let i=this._tileCache.pop(G._tileMemcacheKey);return i?(i.init(e,t,n,r,this),i):new this._tileConstructor(e,t,n,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){let{groundExtent:e,tilingScheme:t}=this;if(!t)return;if(!this.enabled){this._setRootTiles(null);return}let n=bt,i=t.rootTilesInExtent(e,n,O*5);if(this._rootTiles!=null){if(i.length>O){s.getLogger(this).warn(Ke);return}let e=this._rootTiles.map(e=>e.lij),t=r(e,i,V);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){let e=this._rootTiles.filter(e=>t.removed.findIndex(t=>V(t,e.lij))>-1?(this._purgeTile(e),!1):!0);t.added.forEach(t=>e.push(this._newRootTile(t))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,i.length>O&&(s.getLogger(this).warn(qe),i=t.rootTilesInExtent(e,n,O)),this._setRootTiles(i.map(e=>this._newRootTile(e)));C(n,this._rootTilesExtent)||(this._rootTilesExtent=S(n)),this.renderer.visible=!0,this.overlayManager.setPlacementDirty(),this.notifyChange(`ready`),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this._viewChangeUpdate(),this.checkAllTilesWaterproofness(`root-tiles-updated`)}_updateAllTileGeometries(){let e=this._allTiles.filter(e=>this._canUpdateTileGeometry(e));e.length===0||(e.sort(H),e.forEach(e=>this._renderer.updateTileGeometryState(e)),e.forEach(e=>e.renderData.updateNeighborData()),this._updateTilesGeometries(e)),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){let t=e.filter(e=>this._canUpdateTileGeometry(e));if(t.length===0)return;let n=this.renderer;for(let e of t)n.updateGeometryIfNeeded(e);for(let e of t)this._pendingTilesForElevationUpdateEvent.add(e)}_canUpdateTileGeometry(e){return e.loaded&&e.intersectsClippingArea&&e.hasGeometryState}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===1}_newRootTile(e){let t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(1),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationRange(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),e!=null){let t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this.invalidateElevationRange(),this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.freeze&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask||this._updatingRootTiles?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.groundExtent)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(e==null)return;let t=this.groundExtent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty(!1);let r=this._iteratorPool.acquire();for(r.reset(e);!r.done;){let e=r.next();e.updateClippingStatus(t)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n)}r.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries()}_updateRootTileElevationRange(){let e=1/0,t=-1/0;this._rootTiles?.forEach(({elevationBoundsMin:n,elevationBoundsMax:r})=>{e=Math.min(e,n),t=Math.max(t,r)});let n=this._rootTileElevationRange;(n.minElevation!==e||n.maxElevation!==t)&&(this._rootTileElevationRange=new Fe(e,t))}_updateViewDependentParameters(){let{camera:e,contentCamera:t}=this.view.state,n=Math.tan(t.fovX*.5),r=Math.tan(t.fovY*.5),i=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=n,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=i/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=i/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=ve(this._splitLimits.frustum??ye(),t.frustum):this._splitLimits.frustum=null,oe(this._eyePosRenderSR,t.eye),me(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility(),this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){let t;e.forEachLoadedNeighbor(e=>{t??=this._layerViews[1].some(j),t&&e.setPendingUpdate(32),this._pendingTilesToUpdate.add(e)})}_updateTileTexture(e,t){let n=e.hasPendingUpdate(32)?32:e.hasPendingUpdate(16)?16:!1;if(n){let r=this._renderer.updateTileTexture(e,n);return this._usedMemory=null,r&&e.resetPendingUpdate(n),t.madeProgress(),r}return!0}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;let e=this._pendingTilesForElevationUpdateEvent;if(e.size>0){let t=new Float64Array(4*e.size),n=0;for(let r of e)t.set(r.extent,4*n),++n;e.clear();for(let e of ke(t,this.spatialReference)){let t=new Oe(this.spatialReference,e,`ground`);this.emit(`elevation-change`,t)}}this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);let t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),this._updateElevation(e);let n=this._updateTextures(e);t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty();let r=this._pendingTilesToUpdate.size>0,i=r&&this._hasPendingGeometryWithoutIndices();if((!e.done||i)&&this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&(e.hasProgressed||r&&!i)&&this.requestUpdate(),this.notifyChange(`updatingProgressValue`),!n||!e.hasProgressed)return vt}_checkTileInvariant(){}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;let t=!1,n=new He(this._allTiles.length);n.pushAll(this._rootTiles);let r=this.snapLevel,i=this._splitLimits,a=this._eyePosRenderSR;this._allTiles.forAll(e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0});let o=this.view.state.contentCamera.viewProjectionMatrix;for(;!n.empty;){let e=n.pop(),s=e.parent?.hasPendingUpdate(4),c=e.elevationLevel,l=s?4:e.shouldSplit(i,a,r),u=l===1;e.leaf?Z(e,u):n.pushAll(e.children),s?(e.resetPendingUpdate(1),e.leaf||(e.setPendingUpdate(4),t=!0),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(o)):(u?(e.resetPendingUpdate(4),e.leaf&&(e.setPendingUpdate(1),t=!0)):(e.resetPendingUpdate(1)&&e.updateAgentSuspension(),l===2&&e.updateAgents(0),e.leaf||(e.setPendingUpdate(4),e.resetPendingUpdate(1),t=!0)),e.elevationLevel!==c&&this.updateElevationSources(e))}this._allTilesDirty=t,this.requestUpdate(),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){!e.done&&!this._allTilesSorted&&this.view.pointsOfInterest?.focus&&(ct(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger?.update(),e.madeProgress())}_markTileToUpdate(e){M(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_hasPendingGeometryWithoutIndices(){for(let e of this._pendingTilesToUpdate)if(e.loaded&&e.intersectsClippingArea&&e.renderData?.vao?.indexBuffer==null)return!0;return!1}_updatePendingTileGeometries(){let e=this._pendingTilesToUpdate,t=[];if(e.forEach(e=>{this._canUpdateTileGeometry(e)&&t.push(e)}),t.length===0){e.clear();return}let n=(n,r)=>{!r||!this._canUpdateTileGeometry(r)||r.level<n.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(H);let r=t.length;for(let i=0;i<r;++i){let r=t[i];M(r.loaded),M(r.intersectsClippingArea);let a=r.renderData;if(!a?.geometryState)continue;a.updateNeighborData();let o=a.dirtyEdgeResolutions,s=a.geometryState,c=e=>{let t=nt[e];n(r,s.cornerPeerNeighbors[e]?.findCorner(Qe(t),e=>e.loaded))};for(let t=0;t<4;++t)if(o&1<<t){let i=a.geometryState.edgePeerNeighbors[t];i&&i?.level>=r.level&&i.forAllSubtreeOnSide(Ze(N[t]),t=>this._canUpdateTileGeometry(t)?(M(e.has(t)||H(r,t)<0),n(r,t),!0):!1),c((t+1)%4),c(t)}}e.clear(),t.sort(H),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,B&&$e&&this.checkAllTilesWaterproofness(`pending-geometries-updated`)}_mergeAndSplit(e,t){if(this.freeze||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let n=!1,r=this.view.state.fixedContentCamera,i=!1;for(;!e.done;){i=!0;let a=!1,o=!this._allTiles.some(i=>{if(!n&&!r&&!i.visible)return e.done;let o=i;if(i.hasPendingUpdate(4)){if(!t||i.unmergableChildCount>0)return e.done;for(i.resetPendingUpdate(4);o.parent!=null&&o.parent.unmergableChildCount===0&&o.parent.resetPendingUpdate(4);)o=o.parent;this._mergeTile(o),a=!0,e.madeProgress()}else if(i.resetPendingUpdate(1)){let t=!0,n=i.level;if(n>=k){let e=e=>e.leaf||n-e.level<k;for(let r=0;r<4;++r){let a=i.findNeighborTile(N[r],e);a!=null&&n-a.level===k&&(t=!1,B&&(M(a.leaf),M(a.hasPendingUpdate(1))))}}t?(this._splitTile(i),e.madeProgress(),a=!0):i.setPendingUpdate(1)}return e.done});if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0),o){if(!n){n=!0;continue}if(!a)break}else this._allTilesDirty=!0}i?e.madeProgress():this._allTilesDirty=!0,this._allTilesCreated=!this.allTiles.some(e=>e.hasPendingUpdate(1)||e.hasPendingUpdate(4)&&e.unmergableChildCount===0),this._sortTiles(e)}_updateElevation(e){e.done||this._allTiles.some(t=>(t.resetPendingUpdate(8)&&(this._updateTileGeometryState(t),e.madeProgress()),e.done))}updateElevationSources(e){e.needsElevationSourceUpdate()&&(e.updateAgents(0),e.markElevationSourceUpdateRequested(),this.requestUpdate())}_updateTextures(e){if(e.done)return!0;let t=!0;return this._allTiles.some(n=>(this._updateTileTexture(n,e)||(t=!1),e.done)),t}_updateClippingExtent(){this.spatialReference&&(this.updateOverlayParameters(),this.requestRender(1),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){return this.view.qualitySettings.tiledSurface.lodBias-(1-this.view.quality)*Je}_getLodBiasCorrectedScale(e){let t=this.tilingScheme.levels,n=c(e-this._lodBias,0,t.length-1),r=n-Math.floor(n),i=t[Math.floor(n)].scale,a=t[Math.ceil(n)].scale;return i*(1-r)+a*r}_removeAllTiles(){this.renderer.visible=!1,this._pendingTilesToUpdate.clear(),this._pendingTilesForElevationUpdateEvent.clear(),this._rootTiles!=null&&(this._rootTiles.forEach(e=>this._purgeTile(e)),this._setRootTiles(null),this.notifyChange(`ready`)),this._allTiles.clear(),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_purgeSubtree(e){let t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?wt(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(G._tileMemcacheKey,e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){A(e.leaf,`Tile that is already split should not be split again!`),A(e.rendered,`Tile marked to split is not rendered`),wt(e);let t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles}),e.updateAgentSuspension(),A(e.rendered,`parent should be rendered`),t.forEach(e=>this._loadTile(e)),t.forEach(e=>this._pendingTilesToUpdate.add(e)),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach(e=>Z(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){X.spatialReference=this.spatialReference,X.extent=e.extent,X.scale=this._getLodBiasCorrectedScale(t),this.emit(`scale-change`,X)}createTile(e,t,n,r){A(!!r,`createTile sanity check`);let i=this._acquireTile(e,t,n,r);return i.updateClippingStatus(this.groundExtent),i.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(i)&&i.setPendingUpdate(1),i}get _shortBatches(){return this.view.state.mode!==2}_mergeTile(e){A(!e.hasPendingUpdate(1),`_mergeTile sanity check`),A(!e.leaf,`Cannot merge a leaf`),e.leaf||(this._purgeSubtree(e),A(!e.renderData,`Merging tile with existing render data?`),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),Z(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&e.updateOverlayParameters(this.overlayManager)}_handleLayerViewChanges(e=gt){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1,n=new Set,r=-1;for(let e=this.view.allLayerViews.length-1;e>=0;e--){let i=this.view.allLayerViews.items[e];if(n.add(i.uid),P(i)||F(i)){if(this._basemapLayerViewHandles.has(i.uid)&&!F(i)){let e=this._layerClassFromLayerView(i),n=this.getLayerIndexByUID(e,i.uid);n!=null&&((n<r||r==null)&&(t=!0),r=n)}else this._registerTiledLayerView(i),i.layer.loaded&&(t=!0)}}this._basemapLayerViewHandles.forEach((e,r)=>{n.has(r)||(this._unregisterTiledLayerView(r),t=!0)}),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(let e of this.view.allLayerViews.items)if(I(e)&&!Ee(e.layer)&&e.fullOpacity!==0)return!1;return!0}_hasCompositeBlendMode(){for(let e of this.view.allLayerViews.items)if((L(e)||F(e))&&ft(pt[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return+!R(e)}_registerTiledLayerView(e){let t=[];if((L(e)||F(e))&&t.push(h(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!F(e)){let n=this._layerClassFromLayerView(e);t.push(h(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(h(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));let{layer:r}=e;`effectiveScaleRange`in r&&t.push(h(()=>!e.destroyed&&r.effectiveScaleRange,()=>this._restartAllAgents(n))),t.push(e.on(`data-changed`,()=>{let t=this.getLayerIndexByUID(n,e.uid);t!=null&&this._invalidateLayerData(t,n)}))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){let t=this._basemapLayerViewHandles.get(e);if(t){for(let e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;let e=this.view.allLayerViews,t=[[],[]],n=null;e.forEach(e=>{if(!e.layer||e.suspended||!P(e)||!e.fullExtent)return;let r=this._layerClassFromLayerView(e);if(r===1){let t=e.displayLevelRange.maxLevel;t!==1/0&&(n===null||t>n)&&(n=t)}t[r].push(e)});for(let e of ze){let n=this._layerViews[e],r=t[e];r.reverse();let i=r.length,a=n.length!==i,o=Array(i),s=Array(n.length);this._layerIndexByUid[e].clear();for(let t=0;t<i;t++){let i=r[t].uid;this._layerIndexByUid[e].set(i,t);let c=n.indexOf(r[t]);o[t]=c,t!==c&&(a=!0),c>-1&&(s[c]=t)}if(a){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;)t.next().modifyLayers(s,o,e);this._layerViews[e]=r,this._restartAllAgents(e),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(n)&&(this._viewChangeUpdate(),this.notifyChange(`tilingScheme`))}_restartAllAgents(e){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){let n=t.next();n.restartAgents(e),e===0&&n.computeElevationBounds()}this._updateRootTileElevationRange()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll(t=>{t.updateAgents(1),e===1?this.renderer.updateTileTexture(t,16):t.updateRenderData(1,e)}),this._evaluateTransparency()}_invalidateLayerData(e,t){this._rootTiles!=null&&(U(this._rootTiles,n=>n.removeLayerAgent(e,t)),U(this._rootTiles,n=>{n.invalidateLayerData(e,t),n.restartAgents(t)}))}setTileTreeDirty(e){this._allTilesDirty=!0,e&&(this._allTilesCreated=!1)}requestRender(e=1){this.renderer.requestRender(e)}requestUpdate(){++this._pendingUpdates===1&&(this._hasPendingUpdates=!0)}requestTileData(e,t,n,r){let i=this.layerViewByIndex(t,n),{tilemapCache:a}=i;return!a||j(i)?this._requestTileData(e,n,i,r):(++this._asyncWorkItems,a.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).catch(t=>{throw te(r),p(t)||this._dataMissing(e,n,i),t}).then(()=>this._frameTask.schedule(()=>this._requestTileData(e,n,i,r),r.signal)).finally(()=>--this._asyncWorkItems))}_requestTileData(e,t,n,r){return this.destroying?Promise.resolve():t===0?R(n)?this._requestElevationTileData(e,n,r):Promise.reject():I(n)?this._requestMapTileData(e,n,r):Promise.reject()}_requestElevationTileData(e,t,n){++this._asyncWorkItems;let r=r=>{!m(n)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},i=n=>{p(n)||(s.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${n}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,{...De,...n}).then(e=>this._frameTask.schedule(()=>r(e)),i).finally(()=>--this._asyncWorkItems)}_elevationDataArrived(e,t,n){let r=this._layerIndexByUid[0].get(t.uid);if(r==null){s.getLogger(this).warn(`TerrainSurface: received data from unknown layer %d %s`,0,e.lij.toString());return}let i=new Ie(e.lij,e.extent,n);e.dataArrived(r,0,i),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:0});let a=[e],o=e.level,c=this._iteratorPool.acquire();for(c.reset(a);!c.done;){let e=c.next();e.findElevationBoundsForLayer(r,o),e.computeElevationBounds()}o===0&&this._updateRootTileElevationRange(),c.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,n){++this._asyncWorkItems;let r=(r,i)=>{z(i),m(n)||(console.error(`Tile ${e.lij.toString()} layer 1/${t.uid} error ${r}`),this._dataMissing(e,1,t),this.requestUpdate())},i=e=>t=>r(t,e);return t.fetchTile(e.lij,n).then(r=>this._frameTask.schedule(()=>{this.requestUpdate(),m(n)?z(r):this._mapTileDataArrived(e,t,r)},n.signal,i(r)).catch(i(r)),(e,t=null)=>this._frameTask.schedule(()=>r(e,t))).finally(()=>--this._asyncWorkItems)}_mapTileDataArrived(e,t,n){let r=this.getLayerIndexByUID(1,t.uid);r==null?(z(n),s.getLogger(this).warn(`TerrainSurface: received data from unknown layer`)):(e.dataArrived(r,1,n),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:1}))}_dataMissing(e,t,n){let r=this.getLayerIndexByUID(t,n.uid);r==null?s.getLogger(this).warn(`TerrainSurface: received data from unknown layer`):(e.dataMissing(r,t),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:t}))}get performanceInfo(){let e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll(t=>{t.leaf&&e.numLeaves++;let n=t.level;t.renderData&&(e.numLoadedPerLevel[n]=(e.numLoadedPerLevel[n]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[n]=(e.numRenderedPerLevel[n]||0)+1,e.numRendered++))}),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(this._usedMemory??=this._recalculateUsedMemory(),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce((e,t)=>e+t.usedMemory,0)):null}getUsedMemoryForLayerView(e){let t=0,n=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(n,e.uid);return r!=null&&this._allTiles.forAll(e=>t+=e.getUsedMemoryForLayer(n,r)),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(e=`render-patch-groups`){}get isGeographic(){return this.spatialReference?.isGeographic??!1}get isWebMercator(){return this.spatialReference?.isWebMercator??!1}get isWebMercatorOnPlateCarree(){return this.isWebMercator&&xe(this.view?.renderSpatialReference)}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&e[2]===0}lijEastEnd(e){return 1<<e+ +!!this.isGeographic}wrapEastWest(e){let t=this.lijEastEnd(e[0]),n=e[2];if(0<=n&&n<t)return e;if(!this.isGlobal)return null;let r=(n+(n<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){et(e)}enableWaterproofnessChecks(e){tt(e)}static cleanupTerrainSurface(){xt.prune()}enable(e){e!==this.enabled&&(this._set(`enabled`,e),e?(this._updateRootTiles(),this.freeze=!1,this.view.elevationProvider.register(0,this)):(this.view.elevationProvider.unregister(this),this.freeze=!0,this._removeAllTiles(),this._setRootTiles(null)),this.notifyChange(`ready`))}updateOverlayParameters(){let{overlayManager:e}=this;this.allTiles.forAll(t=>t.updateOverlayParameters(e))}};e([y()],K.prototype,`_renderer`,void 0),e([y({constructOnly:!0})],K.prototype,`_scaleRangeQueries`,void 0),e([y({constructOnly:!0})],K.prototype,`view`,void 0),e([y({constructOnly:!0})],K.prototype,`overlayManager`,void 0),e([y()],K.prototype,`_hasPendingUpdates`,void 0),e([y()],K.prototype,`_asyncWorkItems`,void 0),e([y()],K.prototype,`_allTilesDirty`,void 0),e([y()],K.prototype,`_allTilesSorted`,void 0),e([y()],K.prototype,`allTilesCreated`,null),e([y()],K.prototype,`_allTilesCreated`,void 0),e([y()],K.prototype,`_viewChanged`,void 0),e([y({type:Number})],K.prototype,`heading`,void 0),e([y()],K.prototype,`_splitLimits`,void 0),e([y()],K.prototype,`_frameTask`,void 0),e([y()],K.prototype,`_tileConstructor`,null),e([y()],K.prototype,`_ellipsoid`,null),e([y()],K.prototype,`demResolution`,null),e([y({readOnly:!0})],K.prototype,`snapLevel`,null),e([y({readOnly:!0})],K.prototype,`lodSnappingEnabled`,null),e([y()],K.prototype,`_stencilEnabledExtents`,null),e([y({readOnly:!0})],K.prototype,`userClippingExtent`,null),e([y()],K.prototype,`_rootTilesExtent`,void 0),e([y({readOnly:!0})],K.prototype,`groundExtent`,null),e([y({readOnly:!0})],K.prototype,`fullGroundExtent`,null),e([y({readOnly:!0})],K.prototype,`_tilingSchemeExtent`,null),e([y({readOnly:!0})],K.prototype,`updating`,null),e([y({readOnly:!0})],K.prototype,`readyToRun`,null),e([y(Pe)],K.prototype,`updatingProgress`,void 0),e([y({readOnly:!0})],K.prototype,`updatingProgressValue`,null),e([y()],K.prototype,`_maxNumUpdating`,void 0),e([y()],K.prototype,`baseOpacity`,null),e([y()],K.prototype,`hasCompositeBlendMode`,void 0),e([y({readOnly:!0})],K.prototype,`viewingMode`,null),e([y()],K.prototype,`maxTextureScale`,void 0),e([y({readOnly:!0})],K.prototype,`ready`,null),e([y({readOnly:!0})],K.prototype,`rootTiles`,null),e([y()],K.prototype,`_rootTiles`,void 0),e([y()],K.prototype,`spatialReference`,null),e([y({type:t})],K.prototype,`backgroundColor`,null),e([y({value:!1})],K.prototype,`slicePlaneEnabled`,null),e([y()],K.prototype,`tilingScheme`,null),e([y({readOnly:!0})],K.prototype,`tilingSchemeLocked`,null),e([y({readOnly:!0})],K.prototype,`tilingSchemeLogic`,void 0),e([y()],K.prototype,`wireframe`,null),e([y()],K.prototype,`opaque`,null),e([y()],K.prototype,`invisible`,null),e([y({value:!1})],K.prototype,`freeze`,null),e([y()],K.prototype,`fadeDuration`,null),e([y()],K.prototype,`_xNormalizer`,null),e([y()],K.prototype,`visibleElevationRange`,null),e([y()],K.prototype,`_rootTileElevationRange`,void 0),e([y()],K.prototype,`_layerViewsDirty`,void 0),e([y()],K.prototype,`renderPatchBorders`,null),e([y()],K.prototype,`renderingDisabled`,null),e([y()],K.prototype,`isGeographic`,null),e([y()],K.prototype,`isWebMercator`,null),e([y()],K.prototype,`isWebMercatorOnPlateCarree`,null),e([y({readOnly:!0})],K.prototype,`enabled`,void 0),K=G=e([re(`esri.views.3d.terrain.TerrainSurface`)],K);const yt=K,q=b(),J=new Se,Y=S(),bt=S(),xt=new f,X={spatialReference:null,extent:null,scale:0};function St(e,t,n){for(let r of e){if(!r.containsPointXY(t,n))continue;let e=r;for(;e&&!e.renderData;){let r=+(t>e.extentMidX)+(n<e.extentMidY?2:0);e=e.children[r]}let i=e?.renderData?.geometryState.samplerData??null;return Le(t,n,i)}return null}function Z(e,t){!e.leaf||e.level<k||$(e,e=>{t&&Ct(e);let n=Q(e);if(e.maxLevelDeltaNeighborCount++,n){let t=e.parent;for(;t;){let e=Q(t);if(t.unmergableChildCount++,e)t=t.parent;else break}}})}function Ct(e){if(e.hasPendingUpdate(1))return;let t=e.parent;for(;t?.resetPendingUpdate(4);)t=t.parent;e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1),e.level<k||$(e,e=>{Ct(e)})}function wt(e){e.level<k||$(e,e=>{if(e.maxLevelDeltaNeighborCount--,e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0){let t=e.parent;for(;t&&(t.unmergableChildCount--,Q(t));)t=t.parent}})}function Q(e){return e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0}function $(e,t){if(e.level<k)return;let n=e.level-k,r=e.lij[1]>>k,i=e.lij[2]>>k,a=e=>e.leaf||e.level===n;for(let o=0;o<4;++o){let s=e.findNeighborTile(N[o],a);if(!s||s.level!==n)continue;let c=s.lij;(c[1]!==r||c[2]!==i)&&t(s)}}export{yt as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import has from"../../../../../core/has.js";import{destroyMaybe as e}from"../../../../../core/maybe.js";import{set as t}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as r}from"../../../../../geometry/support/aaBoundingBox.js";import{encodeSymbolColor as i}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as a}from"../../../support/orientedBoundingBox.js";import{ComponentParametersUniform as o,ComponentParametersVarying as s}from"./ComponentDrawParameters.js";import{UniformComponentParameters as c}from"./UniformComponentParameters.js";import{olidEnabled as l}from"../../effects/geometry/olidUtils.js";import{defaultHighlightName as u}from"../../../../support/HighlightDefaults.js";class d{constructor(e,t,n,r,i,a,o=null){this._collection=e,this.transform=t,this.obb=n,this._componentData=r,this._renderable=i,this._intersectionGeometry=a,this._aabbInWorldCoordinates=o,this.visible=!1,this.offsetObb=null}destroy(){this._collection.materials.release(this._renderable.material),this._intersectionGeometry=e(this._intersectionGeometry),this._renderable=e(this._renderable),this._componentData=e(this._componentData)}get componentData(){return this._componentData}get renderable(){return this._renderable}get intersectionGeometry(){return this._intersectionGeometry}get emissions(){return this.renderable.material.emissions}updateMaterial(e,t){let{_renderable:n}=this,r=n.material,{opacity:i,useFloatBlend:a,...o}=e,s=i??n.opacity,c=this._collection.materials.acquire({...r.parameters,...o,groundTransparencyMode:e.groundTransparencyMode??r.parameters.groundTransparencyMode,isObjectTransparent:s<1},n.geometry.parameters,t??n.drawParameters.componentParameters);this._collection.materials.release(r),c!==r&&n.updateMaterial(c)}updatePolygonOffset(e){this._renderable.material.parameters.polygonOffset!==e&&this.updateMaterial({polygonOffset:e})}get opacity(){return this.renderable.opacity}updateOpacity(e,t){if(this.opacity===e){if(t===void 0||t===this.renderable.material.parameters.groundTransparencyMode)return}else this._renderable.updateOpacity(e);this.updateMaterial({opacity:e,groundTransparencyMode:t})}updateCameraDerivedParameters(e){let{eye:t}=e,{centerX:n,centerY:r,centerZ:i}=this.obb;this._renderable.meta.cameraDepthSquared=(t[0]-n)**2+(t[1]-r)**2+(t[2]-i)**2}setComponentData(e,t){let n=this._componentData,{materialDataBuffer:r,materialDataIndices:u}=n,d=new c,p=r.textureBuffer,m=p.getVec4Field(`colorAndCastShadows`),h=p.getScalarField(`elevationOffset`),g=p.getScalarField(`emissiveStrength`),_=p.getScalarField(`emissiveSourceMode`),v=p.getVec4Field(`olidColor`),y=new Uint8Array(4),b=new Uint32Array(y.buffer),x=0,S=0,C=0,w=0,T=0,E=n.verticalOffsets,D=1/0,O=-1/0,k=!1,A=!1,j=!1,M=0;for(let t=0;t<n.count;t++){e(t,d),x+=+(d.externalColor[3]<1),S+=+(d.externalColorMixMode===3&&d.externalColor[3]===1),w+=+(d.emissiveStrength>0),T+=+(d.emissiveSource===1),A||=d.emissiveStrength!==1,C+=+d.castShadows,i(d.externalColor,d.externalColorMixMode,y),y[2]=y[2]&254|d.castShadows,m.setArray(u[t],y),k||=t>0&&M!==b[0],M=b[0],j||=d.elevationOffset!==0,j&&E==null&&(E=Array(t).fill(0)),E!=null&&(E[t]=d.elevationOffset),D=Math.min(D,d.elevationOffset),O=Math.max(O,d.elevationOffset),h.set(u[t],d.elevationOffset),g.set(u[t],d.emissiveStrength),_.set(u[t],d.emissiveSource===0?0:255);let r=d.olidColor;r!=null&&v.setArray(u[t],r),d.pickable!==n.isPickable(t)&&n.updatePickabilityWithCount(t,d.pickable)}n.verticalOffsets=j?E:null,this.offsetObb=j?a(this.obb,D,O,t,this.offsetObb??this.obb.clone()):null;let N;if(k||j||l()||(A||T>0)&&w>0){let{count:e}=n;N=new s(f(x,e),f(S,e),f(w,e),f(T,e),f(C,e)),p.updateTexture(),this._renderable.updateComponentParametersVarying(N,p)}else N=new o(d.externalColor,d.externalColorMixMode,d.emissiveStrength,d.emissiveSource,d.castShadows?0:2),this._renderable.updateComponentParametersUniform(N);this.updateMaterial({},N)}addHighlight(e,t){return this._componentData.addComponentHighlight(e,t)}removeHighlight(e,t){return this._componentData.removeComponentHighlight(e,t)}clearHighlights(){this._componentData.clearHighlights()}get aabbInWorldCoordinates(){let e=this._aabbInWorldCoordinates;return e||(e=this._computeAabbInWorldCoordinates(),this._aabbInWorldCoordinates=e),e}_computeAabbInWorldCoordinates(){let e=r(),{positions:n}=this._intersectionGeometry;if(Math.floor(n.length/3)>0){let{transform:r}=this,i=1/0,a=1/0,o=1/0,s=-1/0,c=-1/0,l=-1/0,u=h;for(let e=0;e<n.length;e+=3)t(u,n[e+0],n[e+1],n[e+2]),r.applyVec3(u,u),i=Math.min(i,u[0]),a=Math.min(a,u[1]),o=Math.min(o,u[2]),s=Math.max(s,u[0]),c=Math.max(c,u[1]),l=Math.max(l,u[2]);e[0]=i,e[1]=a,e[2]=o,e[3]=s,e[4]=c,e[5]=l}return e}submit(e,t){let{componentData:n,renderable:r}=this;if(r.drawParameters.opacity<=0)return;let{geometry:i,drawParameters:a,material:o}=r,s=r.meta.cameraDepthSquared,{geometryRanges:c,highlightRangesMap:l,shadowmapRanges:d}=n,f=e=>e.submitDraw(o,a,i,c,s);switch(o.materialPass){case 0:f(e.opaque);break;case 1:f(e.transparent);break;case 2:f(e.opaque),f(e.transparent);break;case 3:f(e.integratedMesh),p(t)&&f(e.occludedGround),(!has(`enable-feature:im-as-ground`)||o.isGround)&&m(t)&&f(e.highlightIntegratedMesh);break;case 4:f(e.transparentIntegratedMesh)}if(a.castAnyShadows){if(l!=null)for(let t of l)t[0]===u&&e.highlightShadowMap.submitDraw(o,a,i,t[1],s,t[0]);d!=null&&e.defaultShadowMap.submitDraw(o,a,i,d,s),f(e.shadowMap)}if(l!=null)for(let t of l)e.highlight.submitDraw(o,a,i,t[1],s,t[0]);t.viewshedEnabled&&f(e.viewshedShadowMap)}}function f(e,t){return e===t?0:e===0?2:1}function p(e){return e.overlay?.getTexture(e.overlay?.allSourcesOccluders?1:4)!=null}function m(e){return e.overlay?.getTexture(2)!=null}const h=n();export{d as ComponentObject};
2
+ import{destroyMaybe as e}from"../../../../../core/maybe.js";import{set as t}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as r}from"../../../../../geometry/support/aaBoundingBox.js";import{encodeSymbolColor as i}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as a}from"../../../support/orientedBoundingBox.js";import{ComponentParametersUniform as o,ComponentParametersVarying as s}from"./ComponentDrawParameters.js";import{UniformComponentParameters as c}from"./UniformComponentParameters.js";import{olidEnabled as l}from"../../effects/geometry/olidUtils.js";import{defaultHighlightName as u}from"../../../../support/HighlightDefaults.js";class d{constructor(e,t,n,r,i,a,o=null){this._collection=e,this.transform=t,this.obb=n,this._componentData=r,this._renderable=i,this._intersectionGeometry=a,this._aabbInWorldCoordinates=o,this.visible=!1,this.offsetObb=null}destroy(){this._collection.materials.release(this._renderable.material),this._intersectionGeometry=e(this._intersectionGeometry),this._renderable=e(this._renderable),this._componentData=e(this._componentData)}get componentData(){return this._componentData}get renderable(){return this._renderable}get intersectionGeometry(){return this._intersectionGeometry}get emissions(){return this.renderable.material.emissions}updateMaterial(e,t){let{_renderable:n}=this,r=n.material,{opacity:i,useFloatBlend:a,...o}=e,s=i??n.opacity,c=this._collection.materials.acquire({...r.parameters,...o,groundTransparencyMode:e.groundTransparencyMode??r.parameters.groundTransparencyMode,isObjectTransparent:s<1},n.geometry.parameters,t??n.drawParameters.componentParameters);this._collection.materials.release(r),c!==r&&n.updateMaterial(c)}updatePolygonOffset(e){this._renderable.material.parameters.polygonOffset!==e&&this.updateMaterial({polygonOffset:e})}get opacity(){return this.renderable.opacity}updateOpacity(e,t){if(this.opacity===e){if(t===void 0||t===this.renderable.material.parameters.groundTransparencyMode)return}else this._renderable.updateOpacity(e);this.updateMaterial({opacity:e,groundTransparencyMode:t})}updateCameraDerivedParameters(e){let{eye:t}=e,{centerX:n,centerY:r,centerZ:i}=this.obb;this._renderable.meta.cameraDepthSquared=(t[0]-n)**2+(t[1]-r)**2+(t[2]-i)**2}setComponentData(e,t){let n=this._componentData,{materialDataBuffer:r,materialDataIndices:u}=n,d=new c,p=r.textureBuffer,m=p.getVec4Field(`colorAndCastShadows`),h=p.getScalarField(`elevationOffset`),g=p.getScalarField(`emissiveStrength`),_=p.getScalarField(`emissiveSourceMode`),v=p.getVec4Field(`olidColor`),y=new Uint8Array(4),b=new Uint32Array(y.buffer),x=0,S=0,C=0,w=0,T=0,E=n.verticalOffsets,D=1/0,O=-1/0,k=!1,A=!1,j=!1,M=0;for(let t=0;t<n.count;t++){e(t,d),x+=+(d.externalColor[3]<1),S+=+(d.externalColorMixMode===3&&d.externalColor[3]===1),w+=+(d.emissiveStrength>0),T+=+(d.emissiveSource===1),A||=d.emissiveStrength!==1,C+=+d.castShadows,i(d.externalColor,d.externalColorMixMode,y),y[2]=y[2]&254|d.castShadows,m.setArray(u[t],y),k||=t>0&&M!==b[0],M=b[0],j||=d.elevationOffset!==0,j&&E==null&&(E=Array(t).fill(0)),E!=null&&(E[t]=d.elevationOffset),D=Math.min(D,d.elevationOffset),O=Math.max(O,d.elevationOffset),h.set(u[t],d.elevationOffset),g.set(u[t],d.emissiveStrength),_.set(u[t],d.emissiveSource===0?0:255);let r=d.olidColor;r!=null&&v.setArray(u[t],r),d.pickable!==n.isPickable(t)&&n.updatePickabilityWithCount(t,d.pickable)}n.verticalOffsets=j?E:null,this.offsetObb=j?a(this.obb,D,O,t,this.offsetObb??this.obb.clone()):null;let N;if(k||j||l()||(A||T>0)&&w>0){let{count:e}=n;N=new s(f(x,e),f(S,e),f(w,e),f(T,e),f(C,e)),p.updateTexture(),this._renderable.updateComponentParametersVarying(N,p)}else N=new o(d.externalColor,d.externalColorMixMode,d.emissiveStrength,d.emissiveSource,d.castShadows?0:2),this._renderable.updateComponentParametersUniform(N);this.updateMaterial({},N)}addHighlight(e,t){return this._componentData.addComponentHighlight(e,t)}removeHighlight(e,t){return this._componentData.removeComponentHighlight(e,t)}clearHighlights(){this._componentData.clearHighlights()}get aabbInWorldCoordinates(){let e=this._aabbInWorldCoordinates;return e||(e=this._computeAabbInWorldCoordinates(),this._aabbInWorldCoordinates=e),e}_computeAabbInWorldCoordinates(){let e=r(),{positions:n}=this._intersectionGeometry;if(Math.floor(n.length/3)>0){let{transform:r}=this,i=1/0,a=1/0,o=1/0,s=-1/0,c=-1/0,l=-1/0,u=h;for(let e=0;e<n.length;e+=3)t(u,n[e+0],n[e+1],n[e+2]),r.applyVec3(u,u),i=Math.min(i,u[0]),a=Math.min(a,u[1]),o=Math.min(o,u[2]),s=Math.max(s,u[0]),c=Math.max(c,u[1]),l=Math.max(l,u[2]);e[0]=i,e[1]=a,e[2]=o,e[3]=s,e[4]=c,e[5]=l}return e}submit(e,t){let{componentData:n,renderable:r}=this;if(r.drawParameters.opacity<=0)return;let{geometry:i,drawParameters:a,material:o}=r,s=r.meta.cameraDepthSquared,{geometryRanges:c,highlightRangesMap:l,shadowmapRanges:d}=n;switch(o.materialPass){case 0:e.opaque.submitDraw(o,a,i,c,s);break;case 1:e.transparent.submitDraw(o,a,i,c,s);break;case 2:e.opaque.submitDraw(o,a,i,c,s),e.transparent.submitDraw(o,a,i,c,s);break;case 3:e.integratedMesh.submitDraw(o,a,i,c,s),p(t)&&e.occludedGround.submitDraw(o,a,i,c,s),o.parameters.integratedMeshSemantics.shouldDrapeFeatures&&m(t)&&e.highlightIntegratedMesh.submitDraw(o,a,i,c,s);break;case 4:e.transparentIntegratedMesh.submitDraw(o,a,i,c,s)}if(a.castAnyShadows){if(l!=null)for(let t of l)t[0]===u&&e.highlightShadowMap.submitDraw(o,a,i,t[1],s,t[0]);d!=null&&e.defaultShadowMap.submitDraw(o,a,i,d,s),e.shadowMap.submitDraw(o,a,i,c,s)}if(l!=null)for(let t of l)e.highlight.submitDraw(o,a,i,t[1],s,t[0]);t.viewshedEnabled&&e.viewshedShadowMap.submitDraw(o,a,i,c,s)}}function f(e,t){return e===t?0:e===0?2:1}function p(e){return e.overlay?.getTexture(e.overlay?.allSourcesOccluders?1:4)!=null}function m(e){return e.overlay?.getTexture(2)!=null}const h=n();export{d as ComponentObject};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import has from"../../../../../../core/has.js";import{ComponentTechnique as e}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as t}from"./ComponentTechniqueConfiguration.js";import{MaterialBase as n}from"../../../core/material/MaterialBase.js";import{isColor as r}from"../../../core/shaderLibrary/ShaderOutput.js";import{hasShadowHighlights as i}from"../../../shaders/ReceiveShadowsConfiguration.js";import{isSphereDepthInterpolateActive as a}from"../../../shaders/SphereDepthInterpolate.glsl.js";class o extends n{constructor(e,n,r,i,a){super(),this.parameters=e,this.key=a;let o=l(e,r);this.usePBR=e.usePBR,this.hasParametersFromSource=e.hasParametersFromSource,this.isGround=e.isGround,this.slicePlaneEnabled=e.slicePlaneEnabled,this.isIntegratedMesh=e.isIntegratedMesh,this.applySSAO=e.applySSAO,this._emissions=o!==0,this.materialPass=s(e,r),this._configuration=new t(i),this._supportsSphereDepthInterpolate=e.sphereDepthInterpolate&&this._configuration.spherical,this._initializeMaterialConfiguration(e,n,r)}destroy(){}get emissions(){if(!this._emissions)return 0;switch(this.materialPass){case 0:case 3:return 1;case 1:case 4:return 2;case 2:return 3}}acquireTechnique(t,n,r,i){let o=this._updateConfiguration(n,r);if(this._supportsSphereDepthInterpolate&&t.precompiling>0){o.sphereDepthInterpolate=!1;let n=t.get(e,o,i.layout);o.sphereDepthInterpolate=!0;let s=t.get(e,o,i.layout);return a(r.camera,o)?s:n}return t.get(e,o,i.layout)}_initializeMaterialConfiguration(e,t,n){let r=this._configuration;r.hasMetallicRoughnessTexture=e.hasMetallicRoughnessTexture,r.hasOcclusionTexture=e.hasOcclusionTexture,r.hasNormalTexture=e.hasNormalTexture;let i=t.textureCoordinateType!==0;r.hasColorTextureTransform=i&&e.hasBaseColorTexture&&e.hasColorTextureTransform,r.hasNormalTextureTransform=i&&e.hasNormalTexture&&e.hasNormalTextureTransform,r.hasEmissiveTextureTransform=i&&e.hasEmissionTexture&&e.hasEmissiveTextureTransform,r.hasOcclusionTextureTransform=i&&e.hasOcclusionTexture&&e.hasOcclusionTextureTransform,r.hasMetallicRoughnessTextureTransform=i&&e.hasMetallicRoughnessTexture&&e.hasMetallicRoughnessTextureTransform,r.sphereDepthInterpolate=!1,r.ellipsoidMode=e.ellipsoidMode,r.doubleSidedMode=+!!e.doubleSided,r.hasColorTexture=e.hasBaseColorTexture,r.cullFace=e.cullFace,r.alphaDiscardMode=e.alphaDiscardMode,r.hasVertexColors=t.hasVertexColors,r.textureCoordinateType=t.textureCoordinateType,r.shadeNormals=t.shadeNormals,r.normalType=t.hasNormals?1:2,r.polygonOffset=e.polygonOffset,r.vertexPositionRotationType=t.vertexPositionRotationType,r.componentDataType=n.componentDataType,r.emissionSource=l(e,n),r.groundTransparencyMode=e.groundTransparencyMode}_updateConfiguration(e,t){let n=this._configuration,{identifier:o}=e,s=o===0;n.output=t.output,n.enableOITOffset=t.enableOITOffset,n.isGround=this.isGround,n.sphereDepthInterpolate=this._supportsSphereDepthInterpolate&&a(t.camera,n),n.hasEmission=t.hasEmission,n.renderOccluded=t.slot===9;let c=this.isIntegratedMesh&&(!has(`enable-feature:im-as-ground`)||this.isGround)?d(t)?u(t)?3:2:1:0;n.integratedMeshMode=c,n.pbrMode=c===3?4:this.usePBR?this.hasParametersFromSource?n.shadeNormals!==0&&this.isIntegratedMesh?0:2:1:0,n.hasSlicePlane=t.slicePlane!=null&&this.slicePlaneEnabled,n.isGroundSlice=n.hasSlicePlane&&this.isGround;let{materialPass:l}=this;n.transparent=s&&(l===1||l===2&&e.transparent||l===4)||n.isGroundSlice,n.hasHighlightMixTexture=o===2&&t.highlightMixTexture!=null,n.snowCover=s&&t.snowCover>0,n.vertexDiscardMode=s&&l===2?e.transparent?2:1:0;let f=r(t.output);return n.receiveAmbientOcclusion=f&&this.applySSAO&&!n.renderOccluded&&t.ssao?.getTexture()!=null,n.receiveGlobalIllumination=f&&this.applySSAO&&!n.renderOccluded&&t.globalIlluminationEnabled,n.hasOccludees=f&&t.hasOccludees,n.receiveShadows=f&&t.shadowMap.ready,n.hasShadowHighlights=i(n,t),n.screenSpaceReflections=t.hasScreenSpaceReflections,n.cloudReflections=f&&t.clouds.data?.cubeMap?.colorTexture!=null,n}}function s(e,t){let{alphaDiscardMode:n,isIntegratedMesh:r,slicePlaneEnabled:i}=e,{transparent:a,opaqueOverride:o}=t,s=e.isObjectTransparent,c=e.hasBaseColorTransparency;if(r)return s||i&&(!has(`enable-feature:im-as-ground`)||e.isGround)?4:3;if(s)return 1;if(o===0)return 0;if(c||n===0||n===3)return 1;switch(a){case 2:return 0;case 0:return 1;case 1:return 2}}function c(e){return e.hasEmissionTexture||e.hasEmissiveBaseColor}function l(e,{emissiveSourceOverride:t,emissiveOverride:n}){let r=e.hasEmissionTexture,i=n!==2&&(c(e)||t!==2),a=t===1,o=t===2;return i?c(e)?o?r?4:2:a?r?5:7:6:a?7:6:0}function u(e){return e.overlay?.getTexture(3)!=null}function d(e){return e.overlay?.getTexture(1)!=null}export{o as ComponentMaterial,s as computeMaterialPass,l as getEmissionSource};
2
+ import{ComponentTechnique as e}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as t}from"./ComponentTechniqueConfiguration.js";import{MaterialBase as n}from"../../../core/material/MaterialBase.js";import{isColor as r}from"../../../core/shaderLibrary/ShaderOutput.js";import{getIMOverlayColorContent as i}from"../../../core/shaderLibrary/terrain/Overlay.glsl.js";import{hasShadowHighlights as a}from"../../../shaders/ReceiveShadowsConfiguration.js";import{isSphereDepthInterpolateActive as o}from"../../../shaders/SphereDepthInterpolate.glsl.js";class s extends n{constructor(e,n,r,i,a){super(),this.parameters=e,this.key=a;let o=u(e,r);this.usePBR=e.usePBR,this.hasParametersFromSource=e.hasParametersFromSource,this.slicePlaneEnabled=e.slicePlaneEnabled,this.isIntegratedMesh=e.isIntegratedMesh,this.applySSAO=e.applySSAO,this._emissions=o!==0,this.materialPass=c(e,r),this._configuration=new t(i),this._supportsSphereDepthInterpolate=e.sphereDepthInterpolate&&this._configuration.spherical,this._initializeMaterialConfiguration(e,n,r)}destroy(){}get emissions(){if(!this._emissions)return 0;switch(this.materialPass){case 0:case 3:return 1;case 1:case 4:return 2;case 2:return 3}}acquireTechnique(t,n,r,i){let a=this._updateConfiguration(n,r);if(this._supportsSphereDepthInterpolate&&t.precompiling>0){a.sphereDepthInterpolate=!1;let n=t.get(e,a,i.layout);a.sphereDepthInterpolate=!0;let s=t.get(e,a,i.layout);return o(r.camera,a)?s:n}return t.get(e,a,i.layout)}_initializeMaterialConfiguration(e,t,n){let r=this._configuration;r.hasMetallicRoughnessTexture=e.hasMetallicRoughnessTexture,r.hasOcclusionTexture=e.hasOcclusionTexture,r.hasNormalTexture=e.hasNormalTexture;let i=t.textureCoordinateType!==0;r.hasColorTextureTransform=i&&e.hasBaseColorTexture&&e.hasColorTextureTransform,r.hasNormalTextureTransform=i&&e.hasNormalTexture&&e.hasNormalTextureTransform,r.hasEmissiveTextureTransform=i&&e.hasEmissionTexture&&e.hasEmissiveTextureTransform,r.hasOcclusionTextureTransform=i&&e.hasOcclusionTexture&&e.hasOcclusionTextureTransform,r.hasMetallicRoughnessTextureTransform=i&&e.hasMetallicRoughnessTexture&&e.hasMetallicRoughnessTextureTransform,r.sphereDepthInterpolate=!1,r.ellipsoidMode=e.ellipsoidMode,r.doubleSidedMode=+!!e.doubleSided,r.hasColorTexture=e.hasBaseColorTexture,r.cullFace=e.cullFace,r.alphaDiscardMode=e.alphaDiscardMode,r.hasVertexColors=t.hasVertexColors,r.textureCoordinateType=t.textureCoordinateType,r.shadeNormals=t.shadeNormals,r.normalType=t.hasNormals?1:2,r.polygonOffset=e.polygonOffset,r.vertexPositionRotationType=t.vertexPositionRotationType,r.componentDataType=n.componentDataType,r.emissionSource=u(e,n),r.groundTransparencyMode=e.groundTransparencyMode}_updateConfiguration(e,t){let n=this._configuration,{identifier:i}=e,s=i===0;n.output=t.output,n.enableOITOffset=t.enableOITOffset,n.isGround=this.parameters.integratedMeshSemantics.shouldDrapeRaster,n.sphereDepthInterpolate=this._supportsSphereDepthInterpolate&&o(t.camera,n),n.hasEmission=t.hasEmission,n.renderOccluded=t.slot===9;let c=this.isIntegratedMesh&&this.parameters.integratedMeshSemantics.shouldDrapeFeatures?f(t,this.parameters.integratedMeshSemantics.shouldDrapeRaster)?d(t)?3:2:1:0;n.integratedMeshMode=c,n.pbrMode=c===3?4:this.usePBR?this.hasParametersFromSource?n.shadeNormals!==0&&this.isIntegratedMesh?0:2:1:0,n.hasSlicePlane=t.slicePlane!=null&&this.slicePlaneEnabled,n.isGroundSlice=n.hasSlicePlane&&this.parameters.integratedMeshSemantics.shouldFadeSlicedSurface;let{materialPass:l}=this;n.transparent=s&&(l===1||l===2&&e.transparent||l===4)||n.isGroundSlice,n.hasHighlightMixTexture=i===2&&t.highlightMixTexture!=null,n.snowCover=s&&t.snowCover>0,n.vertexDiscardMode=s&&l===2?e.transparent?2:1:0;let u=r(t.output);return n.receiveAmbientOcclusion=u&&this.applySSAO&&!n.renderOccluded&&t.ssao?.getTexture()!=null,n.receiveGlobalIllumination=u&&this.applySSAO&&!n.renderOccluded&&t.globalIlluminationEnabled,n.hasOccludees=u&&t.hasOccludees,n.receiveShadows=u&&t.shadowMap.ready,n.hasShadowHighlights=a(n,t),n.screenSpaceReflections=t.hasScreenSpaceReflections,n.cloudReflections=u&&t.clouds.data?.cubeMap?.colorTexture!=null,n}}function c(e,t){let{alphaDiscardMode:n,isIntegratedMesh:r,slicePlaneEnabled:i}=e,{transparent:a,opaqueOverride:o}=t,s=e.isObjectTransparent,c=e.hasBaseColorTransparency;if(r)return s||i&&e.integratedMeshSemantics.shouldRenderSliceAsTransparent?4:3;if(s)return 1;if(o===0)return 0;if(c||n===0||n===3)return 1;switch(a){case 2:return 0;case 0:return 1;case 1:return 2}}function l(e){return e.hasEmissionTexture||e.hasEmissiveBaseColor}function u(e,{emissiveSourceOverride:t,emissiveOverride:n}){let r=e.hasEmissionTexture,i=n!==2&&(l(e)||t!==2),a=t===1,o=t===2;return i?l(e)?o?r?4:2:a?r?5:7:6:a?7:6:0}function d(e){return e.overlay?.getTexture(3)!=null}function f(e,t){return e.overlay?.getTexture(i(t))!=null}export{s as ComponentMaterial,c as computeMaterialPass,u as getEmissionSource};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- class e{constructor(e){this.usePBR=e.usePBR,this.hasParametersFromSource=e.hasParametersFromSource,this.sphereDepthInterpolate=e.sphereDepthInterpolate,this.doubleSided=e.doubleSided,this.cullFace=e.cullFace,this.isGround=e.isGround,this.slicePlaneEnabled=e.slicePlaneEnabled,this.alphaDiscardMode=e.alphaDiscardMode,this.isIntegratedMesh=e.isIntegratedMesh,this.polygonOffset=e.polygonOffset,this.ellipsoidMode=e.ellipsoidMode,this.applySSAO=e.applySSAO,this.groundTransparencyMode=e.groundTransparencyMode??1}}class t extends e{constructor(e){super(e),this.hasBaseColorTransparency=e.baseColor[3]<1,this.hasEmissiveBaseColor=e.emissiveBaseColor[0]!==0||e.emissiveBaseColor[1]!==0||e.emissiveBaseColor[2]!==0,this.isObjectTransparent=e.opacity<1,this.hasBaseColorTexture=e.baseColorTexture!=null,this.hasMetallicRoughnessTexture=e.metallicRoughnessTexture!=null,this.hasNormalTexture=e.normalTexture!=null,this.hasOcclusionTexture=e.occlusionTexture!=null,this.hasEmissionTexture=e.emissionTexture!=null,this.hasColorTextureTransform=!!e.textureTransforms?.color,this.hasNormalTextureTransform=!!e.textureTransforms?.normal,this.hasEmissiveTextureTransform=!!e.textureTransforms?.emissive,this.hasOcclusionTextureTransform=!!e.textureTransforms?.occlusion,this.hasMetallicRoughnessTextureTransform=!!e.textureTransforms?.metallicRoughness}}export{e as ComponentMaterialBaseParameters,t as ComponentMaterialParameters};
2
+ class e{constructor(e){this.usePBR=e.usePBR,this.hasParametersFromSource=e.hasParametersFromSource,this.sphereDepthInterpolate=e.sphereDepthInterpolate,this.doubleSided=e.doubleSided,this.cullFace=e.cullFace,this.slicePlaneEnabled=e.slicePlaneEnabled,this.alphaDiscardMode=e.alphaDiscardMode,this.isIntegratedMesh=e.isIntegratedMesh,this.integratedMeshSemantics=e.integratedMeshSemantics,this.polygonOffset=e.polygonOffset,this.ellipsoidMode=e.ellipsoidMode,this.applySSAO=e.applySSAO,this.groundTransparencyMode=e.groundTransparencyMode??1}}class t extends e{constructor(e){super(e),this.hasBaseColorTransparency=e.baseColor[3]<1,this.hasEmissiveBaseColor=e.emissiveBaseColor[0]!==0||e.emissiveBaseColor[1]!==0||e.emissiveBaseColor[2]!==0,this.isObjectTransparent=e.opacity<1,this.hasBaseColorTexture=e.baseColorTexture!=null,this.hasMetallicRoughnessTexture=e.metallicRoughnessTexture!=null,this.hasNormalTexture=e.normalTexture!=null,this.hasOcclusionTexture=e.occlusionTexture!=null,this.hasEmissionTexture=e.emissionTexture!=null,this.hasColorTextureTransform=!!e.textureTransforms?.color,this.hasNormalTextureTransform=!!e.textureTransforms?.normal,this.hasEmissiveTextureTransform=!!e.textureTransforms?.emissive,this.hasOcclusionTextureTransform=!!e.textureTransforms?.occlusion,this.hasMetallicRoughnessTextureTransform=!!e.textureTransforms?.metallicRoughness}}export{e as ComponentMaterialBaseParameters,t as ComponentMaterialParameters};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import"../../../../../../core/has.js";import"../../../../../../core/Logger.js";import{ComponentMaterial as e,computeMaterialPass as t,getEmissionSource as n}from"./ComponentMaterial.js";import{ComponentMaterialGlobalParameters as r}from"./ComponentMaterialGlobalParameters.js";class i{constructor(e,t){this._store=new Map,this.globals=new r(e,t)}destroy(){this._store.forEach(({material:e})=>e.destroy()),this._store.clear()}acquire(t,n,r){let i=this.globals,o=a(t,n,r,i),s=this._store.get(o);if(s)return s.refCount++,s.material.key,s.material;let c=new e(t,n,r,i,o);return this._store.set(o,{material:c,refCount:1}),c}release(e){let{key:t}=e,n=this._store.get(t);if(!n||n.refCount<1)throw Error(`Internal error in material repository`);n.refCount===1?this._store.delete(t):n.refCount--}}function a(e,r,i,a){let o=t(e,i),s=n(e,i);return`|${+a.useFloatBlend}|${+e.usePBR}|${+e.hasParametersFromSource}|${+e.isGround}|${+e.groundTransparencyMode}|${+e.slicePlaneEnabled}|${+e.isIntegratedMesh}|${+e.applySSAO}|${+o}|${+i.componentDataType}|${+s}|${+e.sphereDepthInterpolate}|${+e.ellipsoidMode}|${+e.doubleSided}|${+e.cullFace}|${+e.alphaDiscardMode}|${+r.hasVertexColors}|${+r.textureCoordinateType}|${+r.shadeNormals}|${+r.hasNormals}|${e.polygonOffset}|${+r.vertexPositionRotationType}|${+e.hasBaseColorTexture}|${+e.hasEmissionTexture}|${+e.hasMetallicRoughnessTexture}|${+e.hasOcclusionTexture}|${+e.hasNormalTexture}|${+e.hasColorTextureTransform}|${+e.hasNormalTextureTransform}|${+e.hasEmissiveTextureTransform}|${+e.hasOcclusionTextureTransform}|${+e.hasMetallicRoughnessTextureTransform}|${+i.emissiveOverride}`}export{i as ComponentMaterialRepository,a as makeMaterialKey};
2
+ import"../../../../../../core/has.js";import"../../../../../../core/Logger.js";import{ComponentMaterial as e,computeMaterialPass as t,getEmissionSource as n}from"./ComponentMaterial.js";import{ComponentMaterialGlobalParameters as r}from"./ComponentMaterialGlobalParameters.js";class i{constructor(e,t){this._store=new Map,this.globals=new r(e,t)}destroy(){this._store.forEach(({material:e})=>e.destroy()),this._store.clear()}acquire(t,n,r){let i=this.globals,o=a(t,n,r,i),s=this._store.get(o);if(s)return s.refCount++,s.material.key,s.material;let c=new e(t,n,r,i,o);return this._store.set(o,{material:c,refCount:1}),c}release(e){let{key:t}=e,n=this._store.get(t);if(!n||n.refCount<1)throw Error(`Internal error in material repository`);n.refCount===1?this._store.delete(t):n.refCount--}}function a(e,r,i,a){let o=t(e,i),s=n(e,i);return`|${+a.useFloatBlend}|${+e.usePBR}|${+e.hasParametersFromSource}|${+e.integratedMeshSemantics.shouldDrapeRaster}|${+e.integratedMeshSemantics.shouldFadeSlicedSurface}|${+e.integratedMeshSemantics.shouldDrapeFeatures}|${+e.integratedMeshSemantics.shouldRenderSliceAsTransparent}|${+e.groundTransparencyMode}|${+e.slicePlaneEnabled}|${+e.isIntegratedMesh}|${+e.applySSAO}|${+o}|${+i.componentDataType}|${+s}|${+e.sphereDepthInterpolate}|${+e.ellipsoidMode}|${+e.doubleSided}|${+e.cullFace}|${+e.alphaDiscardMode}|${+r.hasVertexColors}|${+r.textureCoordinateType}|${+r.shadeNormals}|${+r.hasNormals}|${e.polygonOffset}|${+r.vertexPositionRotationType}|${+e.hasBaseColorTexture}|${+e.hasEmissionTexture}|${+e.hasMetallicRoughnessTexture}|${+e.hasOcclusionTexture}|${+e.hasNormalTexture}|${+e.hasColorTextureTransform}|${+e.hasNormalTextureTransform}|${+e.hasEmissiveTextureTransform}|${+e.hasOcclusionTextureTransform}|${+e.hasMetallicRoughnessTextureTransform}|${+i.emissiveOverride}`}export{i as ComponentMaterialRepository,a as makeMaterialKey};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{getOrCreateMapValue as e}from"../../../../../core/MapUtils.js";import{DataType as t}from"../../../../webgl/enums.js";class n{constructor(e,t,n,r=0){this._owner=e,this._rctx=t,this._techniques=n,this._sorting=r,this._draws=[],this._previouslyBoundDraw=new Map}destroy(){this._draws.length=0,this._previouslyBoundDraw.clear()}submitDraw(e,t,n,i,a,o){let s=(n.indexed?n.vao.indexBuffer.indexType:null)??0;this._owner.registerDrawParameters(t);let c=new r(e,t,n,i,a,n.geometrySizeHint,s,o);this._draws.push(c)}acquire(t,n){let r=new Map;return this._draws.map(i=>e(r,i.material,()=>i.material.acquireTechnique(this._techniques,t,n,i.geometry.parameters)))}dispatch(e,t,n){let r=this._rctx;this._previouslyBoundDraw.clear();let a=null,o=this._draws.length,s=t.highlight?.name;if(o===0)return;let c=this._sorting===1?-1:1,l=c===1?0:o-1,u=c===1?o:-1;for(let o=l;o!==u;o+=c){let c=this._draws[o];if(e.identifier===2){let e=c.highlightName;if(e){if(e!==s)continue}else if(!s||!t.overlay?.hasHighlight(s))continue}let l=n[o];l!==a&&(r.bindTechnique(l,t,e),a=l);let{geometryRanges:u,indexType:d,geometry:f,drawParameters:p}=c;r.bindVAO(f.vao),this._previouslyBoundDraw.get(l)!==p&&(l.program.bindDraw(t,e,p),this._previouslyBoundDraw.set(l,p));let m=u.length,{primitiveType:h}=f;for(let e=0;e<m;e+=2){let t=u[e],n=u[e+1];if(d!==0){let e=i.get(d);r.drawElements(h,n,d,t*e)}else r.drawArrays(h,t,n)}}}prepareSubmit(){this._draws.length=0}finishSubmit(){let e=this._sorting===0?1:-1;this._draws.sort((t,n)=>e*(t.depthSquaredHint-n.depthSquaredHint)||t.geometry.vao.usedMemory-n.geometry.vao.usedMemory)}get count(){return this._draws.length}}class r{constructor(e,t,n,r,i,a,o,s){this.material=e,this.drawParameters=t,this.geometry=n,this.geometryRanges=r,this.depthSquaredHint=i,this.geometrySizeHint=a,this.indexType=o,this.highlightName=s}}const i=new Map;i.set(t.UNSIGNED_BYTE,1),i.set(t.UNSIGNED_SHORT,2),i.set(t.UNSIGNED_INT,4);export{n as RenderPass};
2
+ import{DataType as e}from"../../../../webgl/enums.js";class t{constructor(e,t,n,r=0){this._owner=e,this._rctx=t,this._techniques=n,this._sorting=r,this._draws=[],this._previouslyBoundDraw=new Map}destroy(){this._draws.length=0,this._previouslyBoundDraw.clear()}submitDraw(e,t,r,i,a,o){let s=(r.indexed?r.vao.indexBuffer.indexType:null)??0;this._owner.registerDrawParameters(t);let c=new n(e,t,r,i,a,r.geometrySizeHint,s,o);this._draws.push(c)}acquire(e,t){let n=new Map,r=[];for(let i of this._draws){let a=n.get(i.material);a??(a=i.material.acquireTechnique(this._techniques,e,t,i.geometry.parameters),n.set(i.material,a)),r.push(a)}return r}dispatch(e,t,n){let i=this._rctx;this._previouslyBoundDraw.clear();let a=null,o=this._draws.length,s=t.highlight?.name;if(o===0)return;let c=this._sorting===1?-1:1,l=c===1?0:o-1,u=c===1?o:-1;for(let o=l;o!==u;o+=c){let c=this._draws[o];if(e.identifier===2){let e=c.highlightName;if(e){if(e!==s)continue}else if(!s||!t.overlay?.hasHighlight(s))continue}let l=n[o];l!==a&&(i.bindTechnique(l,t,e),a=l);let{geometryRanges:u,indexType:d,geometry:f,drawParameters:p}=c;i.bindVAO(f.vao),this._previouslyBoundDraw.get(l)!==p&&(l.program.bindDraw(t,e,p),this._previouslyBoundDraw.set(l,p));let m=u.length,{primitiveType:h}=f;for(let e=0;e<m;e+=2){let t=u[e],n=u[e+1];if(d!==0){let e=r.get(d);i.drawElements(h,n,d,t*e)}else i.drawArrays(h,t,n)}}}prepareSubmit(){this._draws.length=0}finishSubmit(){let e=this._sorting===0?1:-1;this._draws.sort((t,n)=>{let r=e*(t.depthSquaredHint-n.depthSquaredHint)||t.geometry.vao.usedMemory-n.geometry.vao.usedMemory;return r<0?-1:+(r>0)})}get count(){return this._draws.length}}class n{constructor(e,t,n,r,i,a,o,s){this.material=e,this.drawParameters=t,this.geometry=n,this.geometryRanges=r,this.depthSquaredHint=i,this.geometrySizeHint=a,this.indexType=o,this.highlightName=s}}const r=new Map;r.set(e.UNSIGNED_BYTE,1),r.set(e.UNSIGNED_SHORT,2),r.set(e.UNSIGNED_INT,4);export{t as RenderPass};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{disposeMaybe as t}from"../../../../../core/maybe.js";import{subclass as n}from"../../../../../core/accessorSupport/decorators.js";import{fromMat4 as r,transpose as i,invert as a}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{set as s,copy as c}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as l}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{MaterialPassParameters as u,ShadowMapPassParameters as d,HighlightPassParameters as f,ViewshedShadowMapPassParameters as p,AllRenderPasses as m}from"./AllRenderPasses.js";import{TwoVectorPosition as h}from"../util/TwoVectorPosition.js";import{SyncRenderPlugin as g}from"../../effects/RenderPlugin.js";import{getEmissions as _}from"../../effects/emissive/emissions.js";import{DepthRange as v}from"../../lib/DepthRange.js";import{SizedPixelFormat as y,DataType as b}from"../../../../webgl/enums.js";import{Texture as x}from"../../../../webgl/Texture.js";import{TextureDescriptor as S}from"../../../../webgl/TextureDescriptor.js";let C=class extends g{constructor(){super(...arguments),this.produces=new Map([[2,e=>this._produces(e,2)],[4,e=>this._produces(e,4)],[0,e=>this._produces(e,0)],[6,e=>this._produces(e,6)],[9,e=>this._produces(e,9)]]),this._drawParametersArray=[],this._drawParametersSet=new Set,this._materialPassParameters=new u,this._shadowPassParameters=new d,this._highlightPassParameters=new f,this._viewshedPassParameters=new p,this._systems=[]}initializeRenderContext(e){this._context=e,this._passes=new m(e,this)}get rctx(){return this._context.renderContext.rctx}get bind(){return this._context.renderContext.bind}uninitializeRenderContext(){}dispose(){this._context=null,this._systems.length=0,this._transformationTexture=t(this._transformationTexture),Object.values(this._passes).forEach(e=>e.destroy())}register(e){this._systems.push(e)}_produces(e,t){return!!this._invoke(e,t,e=>e.count>0)}prepareRender(e){let{_systems:n,_passes:r}=this;n.length!==0&&(this._drawParametersSet.clear(),this._drawParametersArray.length=0,this._transformationTexture=t(this._transformationTexture),Object.values(this._passes).forEach(e=>e.prepareSubmit()),n.forEach(t=>t.submit(r,e.bind)),this._updateTransformationTexture(),Object.values(this._passes).forEach(e=>e.finishSubmit()),this._context.techniques.frameUpdate())}acquireTechniques(e){if(this._systems.length===0)return null;let{output:t,bind:n}=e;return this._invoke(t,n.slot,(t,r)=>(this._updateParameters(n.camera,r,n.slot),r.transformationTexture=this._transformationTexture,t.acquire(r,e.bind)))}render(e,t){this._invoke(e.output,e.bind.slot,(n,r)=>n.dispatch(r,e.bind,t))}_invoke(e,t,n){switch(t){case 2:switch(e){case 0:case 1:case 2:case 3:case 4:case 11:return n(this._passes.opaque,this._materialPassParameters);case 10:return n(this._passes.highlight,this._highlightPassParameters);case 5:return n(this._passes.shadowMap,this._shadowPassParameters);case 6:return n(this._passes.highlightShadowMap,this._shadowPassParameters);case 7:return n(this._passes.defaultShadowMap,this._shadowPassParameters);case 8:return n(this._passes.viewshedShadowMap,this._viewshedPassParameters)}break;case 4:switch(e){case 0:case 1:case 2:case 3:case 4:case 11:return n(this._passes.transparent,this._materialPassParameters)}break;case 0:switch(e){case 0:case 1:case 2:case 3:case 4:case 11:case 9:return n(this._passes.integratedMesh,this._materialPassParameters);case 10:return n(this._passes.highlightIntegratedMesh,this._highlightPassParameters)}break;case 6:switch(e){case 0:case 1:case 2:return n(this._passes.transparentIntegratedMesh,this._materialPassParameters)}break;case 9:switch(e){case 0:case 1:case 2:case 3:case 4:case 11:return n(this._passes.occludedGround,this._materialPassParameters)}}return null}requestRender(){this._context.requestRender()}queryDepthRange(e){return this._systems.reduce((t,n)=>t.union(n.queryDepthRange(e)),new v)}get emissions(){return _(this._systems)}_updateParameters(e,t,n){let o=e.viewInverseTransposeMatrix,l=n===4,u=n===9;s(w,o[3],o[7],o[11]),E.set(w),c(t.transformWorldFromViewTH,E.high),c(t.transformWorldFromViewTL,E.low),c(t.slicePlaneLocalOrigin,w),r(t.transformViewFromCameraRelativeRS,e.viewMatrix),t.identifier===0&&(this._materialPassParameters.transparent=l,this._materialPassParameters.occludedGround=u,i(T,t.transformViewFromCameraRelativeRS),a(t.transformNormalViewFromGlobal,T))}hasHighlight(e){return this._systems.some(t=>t.hasHighlight(e))}registerDrawParameters(e){if(!this._drawParametersSet.has(e)){this._drawParametersSet.add(e);let t=this._drawParametersArray.length;this._drawParametersArray.push(e),e.setTransformationDrawId(t)}}_updateTransformationTexture(){let e=this._drawParametersArray.length;if(e===0)return;let t=2**Math.ceil(Math.log2(e)),n=new Float32Array(t*15);for(let t=0;t<e;t++){let e=this._drawParametersArray[t];e.setTransformationDrawId(t);let r=t*15;n.set(e.transformationFloats,r)}if(this._transformationTexture&&this._transformationTexture.descriptor.height>=e)this._transformationTexture.updateData(0,0,0,5,e,n);else{this._transformationTexture?.dispose();let e=new S(5,t);e.internalFormat=y.RGB32F,e.dataType=b.FLOAT,e.hasMipmap=!1,e.isImmutable=!0,e.pixelFormat=6407,e.samplingMode=9728,this._transformationTexture=new x(this.rctx,e,n)}}};C=e([n(`esri.views.3d.webgl-engine.core.renderPasses.RenderPassManager`)],C);const w=l(),T=o(),E=new h;export{C as RenderPassManager};
2
+ import{__decorate as e}from"tslib";import{disposeMaybe as t}from"../../../../../core/maybe.js";import{subclass as n}from"../../../../../core/accessorSupport/decorators.js";import{fromMat4 as r,transpose as i,invert as a}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{set as s,copy as c}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as l}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{MaterialPassParameters as u,ShadowMapPassParameters as d,HighlightPassParameters as f,ViewshedShadowMapPassParameters as p,AllRenderPasses as m}from"./AllRenderPasses.js";import{TwoVectorPosition as h}from"../util/TwoVectorPosition.js";import{SyncRenderPlugin as g}from"../../effects/RenderPlugin.js";import{getEmissions as _}from"../../effects/emissive/emissions.js";import{DepthRange as v}from"../../lib/DepthRange.js";import{SizedPixelFormat as y,DataType as b}from"../../../../webgl/enums.js";import{Texture as x}from"../../../../webgl/Texture.js";import{TextureDescriptor as S}from"../../../../webgl/TextureDescriptor.js";let C=class extends g{constructor(){super(...arguments),this.produces=new Map([[2,e=>this._produces(e,2)],[4,e=>this._produces(e,4)],[0,e=>this._produces(e,0)],[6,e=>this._produces(e,6)],[9,e=>this._produces(e,9)]]),this._drawParametersArray=[],this._drawParametersSet=new Set,this._materialPassParameters=new u,this._shadowPassParameters=new d,this._highlightPassParameters=new f,this._viewshedPassParameters=new p,this._systems=[]}initializeRenderContext(e){this._context=e,this._passes=new m(e,this)}get rctx(){return this._context.renderContext.rctx}get bind(){return this._context.renderContext.bind}uninitializeRenderContext(){this._transformationTexture=t(this._transformationTexture),this._transformationData=null}dispose(){this._context=null,this._systems.length=0,this.uninitializeRenderContext(),Object.values(this._passes).forEach(e=>e.destroy())}register(e){this._systems.push(e)}_produces(e,t){return!!this._invoke(e,t,e=>e.count>0)}prepareRender(e){let{_systems:t,_passes:n}=this;t.length!==0&&(this._drawParametersSet.clear(),this._drawParametersArray.length=0,Object.values(this._passes).forEach(e=>e.prepareSubmit()),t.forEach(t=>t.submit(n,e.bind)),this._updateTransformationTexture(),Object.values(this._passes).forEach(e=>e.finishSubmit()),this._context.techniques.frameUpdate())}acquireTechniques(e){if(this._systems.length===0)return null;let{output:t,bind:n}=e;return this._invoke(t,n.slot,(t,r)=>(this._updateParameters(n.camera,r,n.slot),r.transformationTexture=this._transformationTexture,t.acquire(r,e.bind)))}render(e,t){this._invoke(e.output,e.bind.slot,(n,r)=>n.dispatch(r,e.bind,t))}_invoke(e,t,n){switch(t){case 2:switch(e){case 0:case 1:case 2:case 3:case 4:case 11:return n(this._passes.opaque,this._materialPassParameters);case 10:return n(this._passes.highlight,this._highlightPassParameters);case 5:return n(this._passes.shadowMap,this._shadowPassParameters);case 6:return n(this._passes.highlightShadowMap,this._shadowPassParameters);case 7:return n(this._passes.defaultShadowMap,this._shadowPassParameters);case 8:return n(this._passes.viewshedShadowMap,this._viewshedPassParameters)}break;case 4:switch(e){case 0:case 1:case 2:case 3:case 4:case 11:return n(this._passes.transparent,this._materialPassParameters)}break;case 0:switch(e){case 0:case 1:case 2:case 3:case 4:case 11:case 9:return n(this._passes.integratedMesh,this._materialPassParameters);case 10:return n(this._passes.highlightIntegratedMesh,this._highlightPassParameters)}break;case 6:switch(e){case 0:case 1:case 2:return n(this._passes.transparentIntegratedMesh,this._materialPassParameters)}break;case 9:switch(e){case 0:case 1:case 2:case 3:case 4:case 11:return n(this._passes.occludedGround,this._materialPassParameters)}}return null}requestRender(){this._context.requestRender()}queryDepthRange(e){return this._systems.reduce((t,n)=>t.union(n.queryDepthRange(e)),new v)}get emissions(){return _(this._systems)}_updateParameters(e,t,n){let o=e.viewInverseTransposeMatrix,l=n===4,u=n===9;s(w,o[3],o[7],o[11]),E.set(w),c(t.transformWorldFromViewTH,E.high),c(t.transformWorldFromViewTL,E.low),c(t.slicePlaneLocalOrigin,w),r(t.transformViewFromCameraRelativeRS,e.viewMatrix),t.identifier===0&&(this._materialPassParameters.transparent=l,this._materialPassParameters.occludedGround=u,i(T,t.transformViewFromCameraRelativeRS),a(t.transformNormalViewFromGlobal,T))}hasHighlight(e){return this._systems.some(t=>t.hasHighlight(e))}registerDrawParameters(e){if(!this._drawParametersSet.has(e)){this._drawParametersSet.add(e);let t=this._drawParametersArray.length;this._drawParametersArray.push(e),e.setTransformationDrawId(t)}}_updateTransformationTexture(){let e=this._drawParametersArray.length;if(e===0){this._transformationTexture=t(this._transformationTexture),this._transformationData=null;return}let n=2**Math.ceil(Math.log2(e)),r=n*15;(!this._transformationData||this._transformationData.length<r)&&(this._transformationData=new Float32Array(r));let i=this._transformationData;for(let t=0;t<e;t++){let e=this._drawParametersArray[t];e.setTransformationDrawId(t);let n=t*15;i.set(e.transformationFloats,n)}if(this._transformationTexture&&this._transformationTexture.descriptor.height>=e)this._transformationTexture.updateData(0,0,0,5,e,i);else{this._transformationTexture?.dispose();let e=new S(5,n);e.internalFormat=y.RGB32F,e.dataType=b.FLOAT,e.hasMipmap=!1,e.isImmutable=!0,e.pixelFormat=6407,e.samplingMode=9728,this._transformationTexture=new x(this.rctx,e,i)}}};C=e([n(`esri.views.3d.webgl-engine.core.renderPasses.RenderPassManager`)],C);const w=l(),T=o(),E=new h;export{C as RenderPassManager};
@@ -1,5 +1,5 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{EvaluateAmbientLighting as e}from"./EvaluateAmbientLighting.glsl.js";import{EvaluateAmbientOcclusion as t}from"./EvaluateAmbientOcclusion.glsl.js";import{Gamma as n}from"./Gamma.glsl.js";import{getLocalUp as r}from"./getLocalUp.glsl.js";import{mainLightDirection as i,lightingGlobalFactor as a,mainLightIntensity as o,lightingSpecularStrength as s,lightingEnvironmentStrength as c}from"./lightingUniforms.js";import{applyShading as l}from"./MainLighting.glsl.js";import{PhysicallyBasedRendering as u}from"./PhysicallyBasedRendering.glsl.js";import{PiUtils as d}from"./PiUtils.glsl.js";import{ReadGlobalIllumination as f}from"./ReadGlobalIllumination.glsl.js";import{BooleanBindUniform as p}from"../../shaderModules/BooleanBindUniform.js";import{glsl as m,If as h}from"../../shaderModules/glsl.js";import{ambientBoost as g}from"../../../lighting/SceneLighting.js";import{BlackLevelLightSoftCompression as _}from"../../../shaders/BlackLevelLightSoftCompression.glsl.js";import{ToneMapping as v}from"../../../shaders/ToneMapping.glsl.js";function y(e){e.constants.add(`ambientBoostFactor`,`float`,g)}function b(g,b){let{pbrMode:x,hasColorTexture:S,receiveGlobalIllumination:C}=b;g.include(r,b),g.include(n),g.include(f,b),g.include(t,b),x!==0&&g.include(u,b),g.include(e),g.include(d),g.include(v,b);let w=!(x===2&&!S);w&&g.include(_),y(g),g.uniforms.add(i,a).code.add(m`float additionalDirectedAmbientLight(float lightAlignment) {
2
+ import{EvaluateAmbientLighting as e}from"./EvaluateAmbientLighting.glsl.js";import{EvaluateAmbientOcclusion as t}from"./EvaluateAmbientOcclusion.glsl.js";import{Gamma as n}from"./Gamma.glsl.js";import{getLocalUp as r}from"./getLocalUp.glsl.js";import{mainLightDirection as i,lightingGlobalFactor as a,mainLightIntensity as o,lightingSpecularStrength as s,lightingEnvironmentStrength as c}from"./lightingUniforms.js";import{applyShading as l}from"./MainLighting.glsl.js";import{PhysicallyBasedRendering as u}from"./PhysicallyBasedRendering.glsl.js";import{PiUtils as d}from"./PiUtils.glsl.js";import{ReadGlobalIllumination as f}from"./ReadGlobalIllumination.glsl.js";import{BooleanBindUniform as p}from"../../shaderModules/BooleanBindUniform.js";import{glsl as m,If as h}from"../../shaderModules/glsl.js";import{ambientBoost as g}from"../../../lighting/SceneLighting.js";import{BlackLevelLightSoftCompression as _}from"../../../shaders/BlackLevelLightSoftCompression.glsl.js";import{ToneMapping as v}from"../../../shaders/ToneMapping.glsl.js";function y(e){e.constants.add(`ambientBoostFactor`,`float`,g)}function b(g,b){let{pbrMode:x,hasColorTexture:S,receiveGlobalIllumination:C}=b;g.include(r,b),g.include(n),g.include(f,b),g.include(t,b),x!==0&&g.include(u,b),g.include(e),g.include(d),g.include(v);let w=!(x===2&&!S);w&&g.include(_),y(g),g.uniforms.add(i,a).code.add(m`float additionalDirectedAmbientLight(float lightAlignment) {
3
3
  return smoothstep(0.0, 1.0, clamp(lightAlignment * 2.5, 0.0, 1.0));
4
4
  }
5
5
  float additionalDirectedAmbientLight(vec3 vPosWorld) {
@@ -26,7 +26,7 @@ return mix(emission, compressedEmission, globalIlluminationEmissionCompressionWe
26
26
 
27
27
  vec3 totalLight = mainLighting + ambientLighting + additionalLight;
28
28
  totalLight = min(totalLight, vec3(PI));
29
- vec3 linearColor = vec3((albedoLinear / PI) * totalLight);
29
+ vec3 linearColor = (albedoLinear / PI) * totalLight;
30
30
  ${h(C,`linearColor += evaluateGlobalIlluminationEmission(albedoLinear);`)}
31
31
  return delinearizeGamma(linearColor);
32
32
  }
@@ -64,7 +64,7 @@ import{depthMap as e}from"../bindUniforms.js";import{ReadDepth as t}from"../outp
64
64
  vec2 projectedCoordDirection = (projectedCoordEnd.xy - projectedCoordStart.xy);
65
65
  vec2 vanishingPointScreenOffset = (projectedCoordVanishingPoint.xy - projectedCoordStart.xy);
66
66
 
67
- float rayMarchDistance = ${l.useProjectedRayLength?`length(vanishingPointScreenOffset.xy)`:`abs(vanishingPointScreenOffset.y)`};
67
+ float rayMarchDistance = ${l.useProjectedRayLength?`length(vanishingPointScreenOffset)`:`abs(vanishingPointScreenOffset.y)`};
68
68
  float clampedRayMarchDistance = min(rayMarchDistance, rayMarchMaxReach);
69
69
 
70
70
  float projectedCoordDirectionLength = length(projectedCoordDirection);
@@ -1,5 +1,5 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{lastFrameColorTexture as e}from"../lastFrameUniforms.js";import{FoamColor as t}from"./FoamRendering.glsl.js";import{Gamma as n}from"./Gamma.glsl.js";import{lightingSpecularStrength as r,lightingEnvironmentStrength as i}from"./lightingUniforms.js";import{PhysicallyBasedRenderingWater as a}from"./PhysicallyBasedRendering.glsl.js";import{distanceFadeStart as o,distanceFadeEnd as s}from"./ScreenSpaceConstants.js";import{ScreenSpaceRayMarching as c}from"./ScreenSpaceRayMarching.glsl.js";import{viewMatrix as l}from"../util/cameraUniforms.js";import{CloudsParallaxShading as u,cloudsOpacity as d}from"../util/CloudsParallaxShading.glsl.js";import{FloatBindUniform as f}from"../../shaderModules/FloatBindUniform.js";import{glsl as p}from"../../shaderModules/glsl.js";import{ToneMapping as m}from"../../../shaders/ToneMapping.glsl.js";function h(h,g){let _=h.fragment;_.include(a,g),_.include(n),_.include(t),g.cloudReflections&&h.include(u),g.screenSpaceReflections&&h.include(c,g),_.include(m,g),_.constants.add(`fresnelSky`,`vec3`,[.02,1,15]),_.constants.add(`fresnelMaterial`,`vec2`,[.02,.1]),_.constants.add(`roughness`,`float`,.015),_.constants.add(`foamIntensityExternal`,`float`,1.7),_.constants.add(`ssrIntensity`,`float`,.65),_.constants.add(`ssrHeightFadeStart`,`float`,o),_.constants.add(`ssrHeightFadeEnd`,`float`,s),_.constants.add(`waterDiffusion`,`float`,.92),_.constants.add(`waterSeaColorMod`,`float`,.8),_.constants.add(`correctionViewingPowerFactor`,`float`,.4),_.constants.add(`skyZenitColor`,`vec3`,[.52,.68,.9]),_.constants.add(`skyColor`,`vec3`,[.67,.79,.9]),_.constants.add(`cloudFresnelModifier`,`vec2`,[1.2,.01]),_.code.add(p`PBRShadingWater shadingInfo;
2
+ import{lastFrameColorTexture as e}from"../lastFrameUniforms.js";import{FoamColor as t}from"./FoamRendering.glsl.js";import{Gamma as n}from"./Gamma.glsl.js";import{lightingSpecularStrength as r,lightingEnvironmentStrength as i}from"./lightingUniforms.js";import{PhysicallyBasedRenderingWater as a}from"./PhysicallyBasedRendering.glsl.js";import{distanceFadeStart as o,distanceFadeEnd as s}from"./ScreenSpaceConstants.js";import{ScreenSpaceRayMarching as c}from"./ScreenSpaceRayMarching.glsl.js";import{viewMatrix as l}from"../util/cameraUniforms.js";import{CloudsParallaxShading as u,cloudsOpacity as d}from"../util/CloudsParallaxShading.glsl.js";import{FloatBindUniform as f}from"../../shaderModules/FloatBindUniform.js";import{glsl as p}from"../../shaderModules/glsl.js";import{ToneMapping as m}from"../../../shaders/ToneMapping.glsl.js";function h(h,g){let _=h.fragment;_.include(a,g),_.include(n),_.include(t),g.cloudReflections&&h.include(u),g.screenSpaceReflections&&h.include(c,g),_.include(m),_.constants.add(`fresnelSky`,`vec3`,[.02,1,15]),_.constants.add(`fresnelMaterial`,`vec2`,[.02,.1]),_.constants.add(`roughness`,`float`,.015),_.constants.add(`foamIntensityExternal`,`float`,1.7),_.constants.add(`ssrIntensity`,`float`,.65),_.constants.add(`ssrHeightFadeStart`,`float`,o),_.constants.add(`ssrHeightFadeEnd`,`float`,s),_.constants.add(`waterDiffusion`,`float`,.92),_.constants.add(`waterSeaColorMod`,`float`,.8),_.constants.add(`correctionViewingPowerFactor`,`float`,.4),_.constants.add(`skyZenitColor`,`vec3`,[.52,.68,.9]),_.constants.add(`skyColor`,`vec3`,[.67,.79,.9]),_.constants.add(`cloudFresnelModifier`,`vec2`,[1.2,.01]),_.code.add(p`PBRShadingWater shadingInfo;
3
3
  vec3 getSkyGradientColor(in float cosTheta, in vec3 horizon, in vec3 zenit) {
4
4
  float exponent = pow((1.0 - cosTheta), fresnelSky[2]);
5
5
  return mix(zenit, horizon, exponent);
@@ -37,9 +37,11 @@ foam = foamIntensity2FoamColor(foamIntensityExternal, foamIntensity, skyZenitCol
37
37
  }
38
38
  float correctionViewingFactor = pow(max(dot(v, localUp), 0.0), correctionViewingPowerFactor);
39
39
  vec3 normalCorrectedClouds = mix(localUp, n, correctionViewingFactor);
40
- vec3 reflectedWorld = normalize(reflect(-v, normalCorrectedClouds));`),g.cloudReflections&&_.uniforms.add(d).code.add(p`vec3 emission = vec3(0.0);
41
- vec4 cloudsColor = renderClouds(reflectedWorld, position, emission);
42
- cloudsColor.rgb += emission;
40
+ vec3 reflectedWorld = normalize(reflect(-v, normalCorrectedClouds));`),g.cloudReflections&&_.uniforms.add(d).code.add(p`vec3 rimLight = vec3(0.0);
41
+ vec4 cloudsColor = renderClouds(reflectedWorld, position, rimLight);
42
+ vec3 colorWithRim = tonemapKhronosNeutral(cloudsColor.rgb + rimLight);
43
+ vec3 colorWithoutRim = tonemapKhronosNeutral(cloudsColor.rgb);
44
+ cloudsColor.rgb += colorWithRim - colorWithoutRim;
43
45
  cloudsColor.a = 1.0 - cloudsColor.a;
44
46
  cloudsColor = pow(cloudsColor, vec4(GAMMA));
45
47
  cloudsColor *= clamp(fresnelModifier.y * cloudFresnelModifier[0] - cloudFresnelModifier[1], 0.0, 1.0) * cloudsOpacity;`),g.screenSpaceReflections?_.uniforms.add(l,e,new f(`fadeFactorSSR`,e=>e.screenSpaceReflections.fadeFactor)).code.add(p`vec3 viewDir = normalize(viewPosition);
@@ -58,7 +58,7 @@ return setLum(sbase > 0.0 ? (cbase - minbase) * ssat / sbase : vec3(0.0), clum);
58
58
  vec4 applyBlendMode(vec3 cl, float ol, vec3 cb, float ob) {
59
59
  ${n(i)}
60
60
  }
61
- `)}function n(e){switch(e){case 8:return`return vec4(cl * ol * cb * ob + cl * ol * (1.0 - ob) + cb * ob * (1.0 - ol), mix(ob, 1.0, ol));`;case 1:return`return vec4((cb + cl) * 0.5 * ol * ob + cl * ol * (1.0 - ob) + cb * ob * (1.0 - ol), mix(ob, 1.0, ol));`;case 2:return`return vec4(max(cb, cl) * ol * ob + cl * ol * (1.0 - ob) + cb * ob * (1.0 - ol), mix(ob, 1.0, ol));`;case 7:return`return vec4(min(cl, cb) * ol * ob + cl * ol * (1.0 - ob) + cb * ob * (1.0 - ol), mix(ob, 1.0, ol));`;case 3:return`return vec4(cl * ol + cb * ob, ol + ob);`;case 4:return`return clamp(vec4(cl.rgb + cb.rgb, ol + ob), 0.0, 1.0);`;case 28:return`return vec4(clamp(vec3(cb.rgb - cl.rgb), 0.0, 1.0), ob * ol);`;case 5:return`return vec4((cl + cb - cl * cb) * ol * ob + cl * ol * (1.0 - ob) + cb * ob * (1.0 - ol), mix(ob, 1.0, ol));`;case 26:return`return vec4(abs(cb - cl) * ol * ob + cl * ol * (1.0 - ob) + cb * ob * (1.0 - ol), mix(ob, 1.0, ol));`;case 29:return`return vec4((1.0 - cb) * ol * ob + cb * ob * (1.0 - ol), ob);`;case 18:return`return vec4(cl * ol * (1.0 - ob) + cb * ob, ol + ob - ol * ob);`;case 19:return`return vec4(cl * ol * (1.0 - ob) + cb * ob * ol, ol);`;case 21:return`return vec4(cb * ob * (1.0 - ol), ob * (1.0 - ol));`;case 22:return`return vec4(cl * ol * ob + cb * ob * (1.0 - ol), ob);`;case 24:return`return vec4(cl * ol * (1.0 - ob), ol * (1.0 - ob));`;case 25:return`return vec4(cl * ol * (1.0 - ob) + cb * ob * (1.0 - ol), ol * (1.0 - ob) + ob * (1.0 - ol));`;case 20:return`return vec4(cb * ob * ol, ol * ob);`;case 23:return`return vec4(cl * ol * ob, ol * ob);`;case 14:return`
61
+ `)}function n(e){switch(e){case 8:return`return vec4(cl * ol * cb * ob + cl * ol * (1.0 - ob) + cb * ob * (1.0 - ol), mix(ob, 1.0, ol));`;case 1:return`return vec4((cb + cl) * 0.5 * ol * ob + cl * ol * (1.0 - ob) + cb * ob * (1.0 - ol), mix(ob, 1.0, ol));`;case 2:return`return vec4(max(cb, cl) * ol * ob + cl * ol * (1.0 - ob) + cb * ob * (1.0 - ol), mix(ob, 1.0, ol));`;case 7:return`return vec4(min(cl, cb) * ol * ob + cl * ol * (1.0 - ob) + cb * ob * (1.0 - ol), mix(ob, 1.0, ol));`;case 3:return`return vec4(cl * ol + cb * ob, ol + ob);`;case 4:return`return clamp(vec4(cl + cb, ol + ob), 0.0, 1.0);`;case 28:return`return vec4(clamp(cb - cl, 0.0, 1.0), ob * ol);`;case 5:return`return vec4((cl + cb - cl * cb) * ol * ob + cl * ol * (1.0 - ob) + cb * ob * (1.0 - ol), mix(ob, 1.0, ol));`;case 26:return`return vec4(abs(cb - cl) * ol * ob + cl * ol * (1.0 - ob) + cb * ob * (1.0 - ol), mix(ob, 1.0, ol));`;case 29:return`return vec4((1.0 - cb) * ol * ob + cb * ob * (1.0 - ol), ob);`;case 18:return`return vec4(cl * ol * (1.0 - ob) + cb * ob, ol + ob - ol * ob);`;case 19:return`return vec4(cl * ol * (1.0 - ob) + cb * ob * ol, ol);`;case 21:return`return vec4(cb * ob * (1.0 - ol), ob * (1.0 - ol));`;case 22:return`return vec4(cl * ol * ob + cb * ob * (1.0 - ol), ob);`;case 24:return`return vec4(cl * ol * (1.0 - ob), ol * (1.0 - ob));`;case 25:return`return vec4(cl * ol * (1.0 - ob) + cb * ob * (1.0 - ol), ol * (1.0 - ob) + ob * (1.0 - ol));`;case 20:return`return vec4(cb * ob * ol, ol * ob);`;case 23:return`return vec4(cl * ol * ob, ol * ob);`;case 14:return`
62
62
  vec3 f = setLumSat(cl, cb, cb);
63
63
  return vec4(f * ol * ob + cl * ol * (1.0 - ob) + cb * ob * (1.0 - ol), mix(ob, 1.0, ol));`;case 15:return`
64
64
  vec3 f = setLumSat(cb, cl, cb);
@@ -10,39 +10,40 @@ dir.z = dir.z * (1.0 - radiusCurvatureCorrection) + radiusCurvatureCorrection;
10
10
  return dir;
11
11
  }`),n.code.add(f`vec3 rotateDirectionToAnchorPoint(mat4 rotMat, vec3 inVec) {
12
12
  return (rotMat * vec4(inVec, 0.0)).xyz;
13
- }`),n.include(r),n.include(s),n.include(i),n.constants.add(`rimColor`,`vec3`,e(.28,.175,.035)),n.constants.add(`sunsetTransitionFactor`,`float`,.3),n.constants.add(`rimScattering`,`float`,140),n.constants.add(`backlightFactor`,`float`,.2),n.constants.add(`backlightScattering`,`float`,10),n.constants.add(`backlightTransition`,`float`,.3),n.uniforms.add(a,o).code.add(f`vec3 calculateCloudColor(vec3 cameraPosition, vec3 worldSpaceRay, vec4 clouds, out vec3 emission) {
13
+ }`),n.include(r),n.include(s),n.include(i),n.constants.add(`rimColor`,`vec3`,e(.5,.4,.3)),n.constants.add(`sunsetTransitionFactor`,`float`,.3),n.constants.add(`rimScattering`,`float`,140),n.constants.add(`backlightFactor`,`float`,.2),n.constants.add(`backlightScattering`,`float`,10),n.constants.add(`backlightTransition`,`float`,.3),n.uniforms.add(a,o).code.add(f`vec3 calculateCloudColor(vec3 cameraPosition, vec3 worldSpaceRay, vec4 clouds, out vec3 rimLight) {
14
14
  float upDotLight = dot(cameraPosition, mainLightDirection);
15
15
  float dirDotLight = max(dot(worldSpaceRay, mainLightDirection), 0.0);
16
16
  float sunsetTransition = clamp(pow(max(upDotLight, 0.0), sunsetTransitionFactor), 0.0, 1.0);
17
17
  vec3 ambientLight = calculateAmbientIrradiance(cameraPosition);
18
18
  vec3 combinedLight = clamp((mainLightIntensity + ambientLight )/PI, vec3(0.0), vec3(1.0));
19
19
  vec3 baseCloudColor = pow(combinedLight * pow(clouds.xyz, vec3(GAMMA)), vec3(INV_GAMMA));
20
- float scatteringMod = max(clouds.a < 0.5 ? clouds.a / 0.5 : - clouds.a / 0.5 + 2.0, 0.0);
20
+ float scatteringMod = max(clouds.a < 0.5 ? clouds.a * 2.0 : 2.0 - clouds.a * 2.0, 0.0);
21
21
  float rimLightIntensity = 0.5 + 0.5 * pow(max(upDotLight, 0.0), 0.35);
22
- emission = rimColor * rimLightIntensity * (pow(dirDotLight, rimScattering)) * scatteringMod;
23
- float additionalLight = backlightFactor * pow(dirDotLight, backlightScattering) * (1. - pow(sunsetTransition, backlightTransition)) ;
22
+ rimLight = rimColor * rimLightIntensity * pow(dirDotLight, rimScattering) * scatteringMod;
23
+ float additionalLight = backlightFactor * pow(dirDotLight, backlightScattering) *
24
+ (1.0 - pow(sunsetTransition, backlightTransition));
24
25
  return baseCloudColor * (1.0 + additionalLight);
25
26
  }`),t.include(c),n.uniforms.add(new l(`readChannelsRG`,e=>e.clouds.readChannels===0),new m(`cubeMap`,e=>e.clouds.data?.cubeMap?.colorTexture)).code.add(f`vec4 sampleCloud(vec3 rayDir, bool readOtherChannel) {
26
27
  vec4 s = lookupCloudsFromTextureArray(cubeMap, rayDir);
27
28
  bool readRG = readChannelsRG ^^ readOtherChannel;
28
29
  s = readRG ? vec4(vec3(s.r), s.g) : vec4(vec3(s.b), s.a);
29
30
  return length(s) == 0.0 ? vec4(s.rgb, 1.0) : s;
30
- }`),n.uniforms.add(_,new u(`anchorPoint`,e=>e.clouds.parallax.anchorPoint),new u(`anchorPointNew`,e=>e.clouds.parallaxNew.anchorPoint),new p(`rotationClouds`,e=>e.clouds.parallax.transform),new p(`rotationCloudsNew`,e=>e.clouds.parallaxNew.transform),new d(`fadeFactor`,e=>e.clouds.fadeFactor),new l(`crossFade`,e=>e.clouds.fadeState===3)).code.add(f`vec4 renderClouds(vec3 worldRay, vec3 cameraPosition, out vec3 emission) {
31
+ }`),n.uniforms.add(_,new u(`anchorPoint`,e=>e.clouds.parallax.anchorPoint),new u(`anchorPointNew`,e=>e.clouds.parallaxNew.anchorPoint),new p(`rotationClouds`,e=>e.clouds.parallax.transform),new p(`rotationCloudsNew`,e=>e.clouds.parallaxNew.transform),new d(`fadeFactor`,e=>e.clouds.fadeFactor),new l(`crossFade`,e=>e.clouds.fadeState===3)).code.add(f`vec4 renderClouds(vec3 worldRay, vec3 cameraPosition, out vec3 rimLight) {
31
32
  vec3 intersectionPoint = intersectWithCloudLayer(worldRay, cameraPosition, anchorPoint);
32
33
  vec3 worldRayRotated = rotateDirectionToAnchorPoint(rotationClouds, normalize(intersectionPoint));
33
34
  vec3 worldRayRotatedCorrected = correctForPlanetCurvature(worldRayRotated);
34
35
  vec4 cloudData = sampleCloud(worldRayRotatedCorrected, crossFade);
35
36
  vec3 cameraPositionN = normalize(cameraPosition);
36
- vec4 cloudColor = vec4(calculateCloudColor(cameraPositionN, worldRay, cloudData, emission), cloudData.a);
37
+ vec4 cloudColor = vec4(calculateCloudColor(cameraPositionN, worldRay, cloudData, rimLight), cloudData.a);
37
38
  if(crossFade) {
38
39
  intersectionPoint = intersectWithCloudLayer(worldRay, cameraPosition, anchorPointNew);
39
40
  worldRayRotated = rotateDirectionToAnchorPoint(rotationCloudsNew, normalize(intersectionPoint));
40
41
  worldRayRotatedCorrected = correctForPlanetCurvature(worldRayRotated);
41
42
  cloudData = sampleCloud(worldRayRotatedCorrected, false);
42
- vec3 emissionNew = vec3(0.0);
43
- vec4 cloudColorNew = vec4(calculateCloudColor(cameraPositionN, worldRay, cloudData, emissionNew), cloudData.a);
43
+ vec3 rimLightNew = vec3(0.0);
44
+ vec4 cloudColorNew = vec4(calculateCloudColor(cameraPositionN, worldRay, cloudData, rimLightNew), cloudData.a);
44
45
  cloudColor = mix(cloudColor, cloudColorNew, fadeFactor);
45
- emission = mix(emission, emissionNew, fadeFactor);
46
+ rimLight = mix(rimLight, rimLightNew, fadeFactor);
46
47
  }
47
48
  float totalTransmittance = length(cloudColor.rgb) == 0.0 ?
48
49
  1.0 : clamp(cloudColor.a * cloudsOpacity + (1.0 - cloudsOpacity), 0.0 , 1.0);
@@ -42,7 +42,7 @@ return vec3(float(x), float(y), float(z));
42
42
  // Unpack the header
43
43
  vec3 tileOrigin = uintBitsToFloat(packedHeader.xyz);
44
44
  float invPosScale = 1.0 / exp2(float(packedHeader.w & 0xfu));
45
- vec3 delta = tileOrigin.xyz - tileCameraPosition;
45
+ vec3 delta = tileOrigin - tileCameraPosition;
46
46
  vec3 cameraRelativePosition = position * invPosScale + delta * ${r.float(t)} - cameraDelta;
47
47
 
48
48
  return cameraRelativePosition;
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{set as e}from"../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as t}from"../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{normalize as n,set as r}from"../../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as i}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Float2BindUniform as a}from"../../shaderModules/Float2BindUniform.js";import{Float3BindUniform as o}from"../../shaderModules/Float3BindUniform.js";import{Float4BindUniform as s}from"../../shaderModules/Float4BindUniform.js";import{FloatBindUniform as c}from"../../shaderModules/FloatBindUniform.js";import{Matrix4BindUniform as l}from"../../shaderModules/Matrix4BindUniform.js";const u=new l(`view`,({camera:e})=>e.viewMatrix),d=new l(`inverseViewMatrix`,({camera:e})=>e.inverseViewMatrix),f=new l(`proj`,({camera:e})=>e.projectionMatrix),p=new l(`inverseProjectionMatrix`,({camera:e})=>e.inverseProjectionMatrix),m=new o(`cameraPosition`,({camera:e})=>e.eye),h=new l(`viewNormal`,({camera:e})=>e.viewInverseTransposeMatrix),g=new o(`localUpView`,({camera:e})=>{let t=e.viewInverseTransposeMatrix;return n(D,r(D,t[8],t[9],t[10]))}),_=new a(`nearFar`,({camera:e})=>e.nearFar),v=new s(`viewport`,({camera:e})=>e.fullViewport),y=new c(`pixelRatio`,e=>e.camera.pixelRatio/e.overlayStretch),b=new c(`screenPixelSizePerDistance`,({camera:e})=>e.screenPixelSizePerDistance),x=new c(`worldToScreenPerDistanceRatio`,({camera:e})=>1/e.screenPixelSizePerDistance),S=new c(`renderPixelSizePerDistance`,({camera:e})=>e.renderPixelSizePerDistance),C=new c(`metersPerRenderUnit`,e=>e.metersPerRenderUnit),w=new a(`inverseScreenSize`,({camera:t})=>e(E,1/t.fullWidth,1/t.fullHeight)),T=new a(`pixelToNDC`,({camera:t})=>e(E,2/t.fullViewport[2],2/t.fullViewport[3])),E=t(),D=i();export{m as cameraPosition,p as inverseProjectionMatrix,w as inverseScreenSize,d as inverseViewMatrix,g as localUpView,C as metersPerRenderUnit,_ as nearFar,y as pixelRatio,T as pixelToNDC,f as projMatrix,S as renderPixelSizePerDistance,b as screenPixelSizePerDistance,u as viewMatrix,h as viewNormal,v as viewport,x as worldToScreenPerDistanceRatio};
2
+ import{set as e}from"../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as t}from"../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{normalize as n,set as r}from"../../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as i}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Float2BindUniform as a}from"../../shaderModules/Float2BindUniform.js";import{Float3BindUniform as o}from"../../shaderModules/Float3BindUniform.js";import{Float4BindUniform as s}from"../../shaderModules/Float4BindUniform.js";import{FloatBindUniform as c}from"../../shaderModules/FloatBindUniform.js";import{Matrix4BindUniform as l}from"../../shaderModules/Matrix4BindUniform.js";const u=new l(`view`,({camera:e})=>e.viewMatrix),d=new l(`inverseViewMatrix`,({camera:e})=>e.inverseViewMatrix),f=new l(`proj`,({camera:e})=>e.projectionMatrix),p=new l(`inverseProjectionMatrix`,({camera:e})=>e.inverseProjectionMatrix),m=new o(`cameraPosition`,({camera:e})=>e.eye),h=new l(`viewNormal`,({camera:e})=>e.viewInverseTransposeMatrix),g=new o(`localUpView`,({camera:e})=>{let t=e.viewInverseTransposeMatrix;return n(D,r(D,t[8],t[9],t[10]))}),_=new a(`nearFar`,({camera:e})=>e.nearFar),v=new s(`viewport`,({camera:e})=>e.fullViewport),y=new c(`pixelRatio`,e=>e.camera.pixelRatio/e.overlayStretch),b=new c(`screenPixelSizePerDistance`,({camera:e})=>e.screenPixelSizePerDistance),x=new c(`worldToScreenPerDistanceRatio`,({viewCamera:e})=>1/e.screenPixelSizePerDistance),S=new c(`renderPixelSizePerDistance`,({camera:e})=>e.renderPixelSizePerDistance),C=new c(`metersPerRenderUnit`,e=>e.metersPerRenderUnit),w=new a(`inverseScreenSize`,({camera:t})=>e(E,1/t.fullWidth,1/t.fullHeight)),T=new a(`pixelToNDC`,({camera:t})=>e(E,2/t.fullViewport[2],2/t.fullViewport[3])),E=t(),D=i();export{m as cameraPosition,p as inverseProjectionMatrix,w as inverseScreenSize,d as inverseViewMatrix,g as localUpView,C as metersPerRenderUnit,_ as nearFar,y as pixelRatio,T as pixelToNDC,f as projMatrix,S as renderPixelSizePerDistance,b as screenPixelSizePerDistance,u as viewMatrix,h as viewNormal,v as viewport,x as worldToScreenPerDistanceRatio};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import"../../../../core/has.js";import{destroyMaybe as n}from"../../../../core/maybe.js";import{watch as r,sync as i}from"../../../../core/reactiveUtils.js";import{signal as a}from"../../../../core/signal.js";import{property as o,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{cloudPresets as c}from"./clouds/CloudsPresets.js";import{CloudsRenderer as l}from"./clouds/CloudsRenderer.js";import{Precipitation as u}from"./precipitation/Precipitation.js";let d=class extends t{constructor(e){super(e),this._clouds=a(null)}initialize(){let e=()=>this._requestRender();this.addHandles([r(()=>this._precipitation,e,i),r(()=>this._clouds.value,e,i),r(()=>this._clouds.value?.state,e,i),r(()=>this.view.state.mode,e,i),r(()=>this.view.state.stationary&&!!this.context.bind.clouds.data&&this.context.bind.clouds.needsStationaryAnchorUpdate(this.view.state.camera),t=>{t&&e()},i),r(()=>[this._weather?.type,f(this._weather)],([e,t])=>this._updateClouds(e,t)),r(()=>this._weather?.type,e=>this._updatePrecipitation(e))])}destroy(){this.removeHandles(),this._clouds.value=n(this._clouds.value),this._precipitation=null,this._precipitationOutgoing=null}get readyToRun(){return!!this._clouds.value?.readyToRun||this.view.state.stationary&&!!this.context.bind.clouds.data&&this.context.bind.clouds.needsStationaryAnchorUpdate(this.view.state.camera)}get usedMemory(){return this._clouds.value?.usedMemory??0}get _weather(){return this.view.environmentView.weatherEnabled?this.view.environment.weather:null}_fadeOutPrecipitation(){this._precipitation&&=(this._precipitationOutgoing?.destroy(),this._precipitationOutgoing=this._precipitation,this._precipitationOutgoing.fadeOut(()=>this._precipitationOutgoing=n(this._precipitationOutgoing)),null)}get snowCover(){return this._precipitationOutgoing?.snowCover??this._precipitation?.snowCover??0}cleanupCubemap(){let e=this._clouds.value;e?.state===0&&e.coverage===0&&!e.readyToRun&&e.destroyCubeMap()}_requestRender(){this.view.stage.renderView.requestRender()}_updateClouds(e,t){!e||!this.context?this._clouds.value=n(this._clouds.value):(this._clouds.value??=new l({context:this.context,view:this.view,requestRender:()=>this._requestRender()}),this._clouds.value.applyPreset(c[e],t))}_updatePrecipitation(e){e!==this._precipitation?.type&&(this._fadeOutPrecipitation(),(e===`rainy`||e===`snowy`)&&(this._precipitation=new u({view:this.view,type:e})))}get test(){}};e([o({constructOnly:!0})],d.prototype,`view`,void 0),e([o({constructOnly:!0})],d.prototype,`context`,void 0),e([o()],d.prototype,`_precipitation`,void 0),d=e([s(`esri.views.3d.webgl-engine.effects.WeatherFader`)],d);function f(e){switch(e?.type){case`rainy`:case`snowy`:case`cloudy`:case`sunny`:return e.cloudCover;case`foggy`:return e.fogStrength;case void 0:return-1}}export{d as WeatherFader};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import"../../../../core/has.js";import{destroyMaybe as n}from"../../../../core/maybe.js";import{watch as r,sync as i}from"../../../../core/reactiveUtils.js";import{signal as a}from"../../../../core/signal.js";import{property as o,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{cloudPresets as c}from"./clouds/CloudsPresets.js";import{CloudsRenderer as l}from"./clouds/CloudsRenderer.js";import{Precipitation as u}from"./precipitation/Precipitation.js";let d=class extends t{constructor(e){super(e),this._clouds=a(null)}initialize(){let e=()=>this._requestRender();this.addHandles([r(()=>this._precipitation,e,i),r(()=>this._clouds.value,e,i),r(()=>this._clouds.value?.state,e,i),r(()=>this.view.state.mode,e,i),r(()=>this.view.state.stationary&&!!this.context.bind.clouds.data&&this.context.bind.clouds.needsStationaryAnchorUpdate(this.view.state.camera),t=>{t&&e()},i),r(()=>[this._weather?.type,f(this._weather)],([e,t])=>this._updateClouds(e,t)),r(()=>this._weather?.type,e=>this._updatePrecipitation(e))])}destroy(){this.removeHandles(),this._clouds.value=n(this._clouds.value),this._precipitation=null,this._precipitationOutgoing=null}get updating(){return!!this._clouds.value?.readyToRun||this.view.state.stationary&&!!this.context.bind.clouds.data&&this.context.bind.clouds.needsStationaryAnchorUpdate(this.view.state.camera)}get usedMemory(){return this._clouds.value?.usedMemory??0}get _weather(){return this.view.environmentView.weatherEnabled?this.view.environment.weather:null}_fadeOutPrecipitation(){this._precipitation&&=(this._precipitationOutgoing?.destroy(),this._precipitationOutgoing=this._precipitation,this._precipitationOutgoing.fadeOut(()=>this._precipitationOutgoing=n(this._precipitationOutgoing)),null)}get snowCover(){return this._precipitationOutgoing?.snowCover??this._precipitation?.snowCover??0}cleanupCubemap(){let e=this._clouds.value;e?.state===0&&e.coverage===0&&!e.readyToRun&&e.destroyCubeMap()}_requestRender(){this.view.stage.renderView.requestRender()}_updateClouds(e,t){!e||!this.context?this._clouds.value=n(this._clouds.value):(this._clouds.value??=new l({context:this.context,view:this.view,requestRender:()=>this._requestRender()}),this._clouds.value.applyPreset(c[e],t))}_updatePrecipitation(e){e!==this._precipitation?.type&&(this._fadeOutPrecipitation(),(e===`rainy`||e===`snowy`)&&(this._precipitation=new u({view:this.view,type:e})))}get test(){}};e([o({constructOnly:!0})],d.prototype,`view`,void 0),e([o({constructOnly:!0})],d.prototype,`context`,void 0),e([o()],d.prototype,`_precipitation`,void 0),d=e([s(`esri.views.3d.webgl-engine.effects.WeatherFader`)],d);function f(e){switch(e?.type){case`rainy`:case`snowy`:case`cloudy`:case`sunny`:return e.cloudCover;case`foggy`:return e.fogStrength;case void 0:return-1}}export{d as WeatherFader};
@@ -1,5 +1,5 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{clamp as e}from"../../../../../core/mathUtils.js";import{create as t}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{squaredLength as n,lerp as r}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as i}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{earth as a}from"../../../../../geometry/support/Ellipsoid.js";import{cameraPosition as o}from"../../core/shaderLibrary/util/cameraUniforms.js";import{Float2PassUniform as s}from"../../core/shaderModules/Float2PassUniform.js";import{FloatsPassUniform as c}from"../../core/shaderModules/FloatsPassUniform.js";import{glsl as l}from"../../core/shaderModules/glsl.js";import{betaRayleigh as u,betaCombined as d}from"./atmosphereUtils.js";import{maxEmissiveStrength as f}from"../../shaders/floatBlendScale.glsl.js";import{SphereIntersect as p}from"../../shaders/SphereIntersect.glsl.js";import{NoParameters as m}from"../../../../webgl/NoParameters.js";class h extends m{constructor(){super(...arguments),this.radii=t()}}function g(e){e.code.add(l`float chapmanApproximation(float thickness, float height, float cosZenith) {
2
+ import{clamp as e}from"../../../../../core/mathUtils.js";import{create as t}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{lerp as n,squaredLength as r}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as i}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{earth as a}from"../../../../../geometry/support/Ellipsoid.js";import{cameraPosition as o}from"../../core/shaderLibrary/util/cameraUniforms.js";import{Float2PassUniform as s}from"../../core/shaderModules/Float2PassUniform.js";import{FloatsPassUniform as c}from"../../core/shaderModules/FloatsPassUniform.js";import{glsl as l}from"../../core/shaderModules/glsl.js";import{betaRayleigh as u,betaCombined as d}from"./atmosphereUtils.js";import{maxEmissiveStrength as f}from"../../shaders/floatBlendScale.glsl.js";import{SphereIntersect as p}from"../../shaders/SphereIntersect.glsl.js";import{NoParameters as m}from"../../../../webgl/NoParameters.js";class h extends m{constructor(){super(...arguments),this.radii=t()}}function g(e){e.code.add(l`float chapmanApproximation(float thickness, float height, float cosZenith) {
3
3
  float c = sqrt(thickness + height);
4
4
  float cExpH = c * exp(-height);
5
5
  if (cosZenith >= 0.0) {
@@ -11,7 +11,7 @@ return 2.0 * c0 * exp(thickness - x0) - cExpH / (1.0 - c * cosZenith);
11
11
  }
12
12
  }`),e.constants.add(`scaleHeight`,`float`,a.scaleHeight*a.atmosphereHeight).code.add(l`float getOpticalDepth(vec3 position, vec3 dir, float h) {
13
13
  return scaleHeight * chapmanApproximation(radii[0] / scaleHeight, h, dot(normalize(position), dir));
14
- }`),e.constants.add(`maxEmissiveStrength`,`float`,f).constants.add(`betaMix`,`vec3`,r(b,d,u,.5)).uniforms.add(o,new s(`radii`,e=>e.radii)).code.add(l`float getGlow(float dist, float radius, float intensity) {
14
+ }`),e.constants.add(`maxEmissiveStrength`,`float`,f).constants.add(`betaMix`,`vec3`,n(b,d,u,.5)).uniforms.add(o,new s(`radii`,e=>e.radii)).code.add(l`float getGlow(float dist, float radius, float intensity) {
15
15
  return pow(radius / max(dist, 1e-6), intensity);
16
16
  }
17
17
  vec3 getSun(vec3 rayDir, vec3 lightDir){
@@ -40,4 +40,4 @@ start = rayPlanetIntersect.y;
40
40
  }
41
41
  float end = hitsPlanet ? rayPlanetIntersect.x : rayAtmosphereIntersect.y;
42
42
  return vec4(0.0, hitsPlanet ? 1.0 : 0.0, start, end);
43
- }`)}function _({camera:t},{radii:r}){let i=n(t.eye),o=Math.sqrt(i);return y[0]=o,y[1]=i-r[1]**2,y[2]=e((o-r[0])/a.atmosphereHeight,0,1),y[3]=i-r[0]**2,y[4]=i-(r[0]-v)**2,y}const v=2e4,y=[],b=i();export{g as ChapmanApproximation,h as ChapmanApproximationPassParameters,_ as getHeightParameters};
43
+ }`)}function _({camera:t},{radii:n}){let i=r(t.eye),o=Math.sqrt(i);return y[0]=o,y[1]=i-n[1]**2,y[2]=e((o-n[0])/a.atmosphereHeight,0,1),y[3]=i-n[0]**2,y[4]=i-(n[0]-v)**2,y}const v=2e4,y=[],b=i();export{g as ChapmanApproximation,h as ChapmanApproximationPassParameters,_ as getHeightParameters};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import"../../core/shaderLibrary/bindUniforms.js";import"../../core/shaderLibrary/shading/Gamma.glsl.js";import"../../core/shaderLibrary/shading/lightingUniforms.js";import"../../core/shaderLibrary/util/cameraUniforms.js";import"../../core/shaderLibrary/util/CloudsParallaxShading.glsl.js";import"../../core/shaderModules/BooleanPassUniform.js";import"../../core/shaderModules/Float3PassUniform.js";import"../../core/shaderModules/Float4PassUniform.js";import"../../core/shaderModules/FloatBindUniform.js";import"../../core/shaderModules/FloatPassUniform.js";import"../../core/shaderModules/FloatsPassUniform.js";import"../../core/shaderModules/glsl.js";import"./ChapmanApproximation.glsl.js";import"./ChapmanRaymarching.glsl.js";import"../../shaders/ditherNoise.glsl.js";import"../../shaders/floatBlendScale.glsl.js";import"../../shaders/ScreenSpacePassAtmosphere.glsl.js";import"../../shaders/SphereIntersect.glsl.js";import"../../shaders/ToneMapping.glsl.js";import"../../../../webgl/ShaderBuilder.js";export{b as build}from"../../../../../chunks/ChapmanAtmosphere.glsl.js";
2
+ import"../../core/shaderLibrary/bindUniforms.js";import"../../core/shaderLibrary/shading/Gamma.glsl.js";import"../../core/shaderLibrary/shading/lightingUniforms.js";import"../../core/shaderLibrary/util/cameraUniforms.js";import"../../core/shaderLibrary/util/CloudsParallaxShading.glsl.js";import"../../core/shaderModules/BooleanPassUniform.js";import"../../core/shaderModules/Float3PassUniform.js";import"../../core/shaderModules/Float4PassUniform.js";import"../../core/shaderModules/FloatBindUniform.js";import"../../core/shaderModules/FloatPassUniform.js";import"../../core/shaderModules/FloatsPassUniform.js";import"../../core/shaderModules/glsl.js";import"./ChapmanApproximation.glsl.js";import"./ChapmanRaymarching.glsl.js";import"../../shaders/ditherNoise.glsl.js";import"../../shaders/floatBlendScale.glsl.js";import"../../shaders/ScreenSpacePassAtmosphere.glsl.js";import"../../shaders/SphereIntersect.glsl.js";import"../../shaders/ToneMapping.glsl.js";import"../../../../webgl/ShaderBuilder.js";export{b as build}from"../../../../../chunks/RealisticAtmosphere.glsl.js";