@arcgis/core 4.34.0-next.14 → 4.34.0-next.16

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 (308) hide show
  1. package/applications/Components/sanitizerUtils.d.ts +3 -0
  2. package/applications/Components/sanitizerUtils.js +5 -0
  3. package/applications/MapViewer/layerUtils.d.ts +3 -0
  4. package/applications/MapViewer/layerUtils.js +5 -0
  5. package/applications/SceneViewer/layerUtils.d.ts +2 -2
  6. package/arcade.js +1 -1
  7. package/assets/esri/core/workers/RemoteClient.js +1 -1
  8. package/assets/esri/core/workers/chunks/{a08ce98672ab94d19613.js → 04e558a970c6a77f243e.js} +1 -1
  9. package/assets/esri/core/workers/chunks/0512ee54f2259a437fdb.js +1 -0
  10. package/assets/esri/core/workers/chunks/0d99579d8cdeddc0fc9c.js +1 -0
  11. package/assets/esri/core/workers/chunks/0f81a2deb656e8b28eae.js +1 -0
  12. package/assets/esri/core/workers/chunks/{ad4f65d764654c70a117.js → 0f8f217aaf42eb1b9699.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{74276044cb75b51967f2.js → 10eb89a93c8e31f03c95.js} +1 -1
  14. package/assets/esri/core/workers/chunks/1443520c9fb23381f8d5.js +1 -0
  15. package/assets/esri/core/workers/chunks/15d3193576f93586674c.js +1 -0
  16. package/assets/esri/core/workers/chunks/1a7570bd2b79194ff94b.js +42 -0
  17. package/assets/esri/core/workers/chunks/243eb8a317333ec2715b.js +1 -0
  18. package/assets/esri/core/workers/chunks/{0ed4ec00ef16aa58a33d.js → 254c4f7e277ae9915dce.js} +1 -1
  19. package/assets/esri/core/workers/chunks/273beed633cc37416ad7.js +1 -0
  20. package/assets/esri/core/workers/chunks/2990145d7ac3af0d68be.js +1 -0
  21. package/assets/esri/core/workers/chunks/{63852887b3f07d50f7c9.js → 2ad538440cfb3ab94787.js} +1 -1
  22. package/assets/esri/core/workers/chunks/2d51d0a24cdc89bafa1c.js +1 -0
  23. package/assets/esri/core/workers/chunks/2d89e354eeadadca4f7f.js +1 -0
  24. package/assets/esri/core/workers/chunks/3f8cc157b65a9d570921.js +1 -0
  25. package/assets/esri/core/workers/chunks/{2254989ca3ff3960f2fe.js → 400a4c9fa62964f8fa1d.js} +1 -1
  26. package/assets/esri/core/workers/chunks/445ddf57d2f503a0b98b.js +1 -0
  27. package/assets/esri/core/workers/chunks/{aaa564c84ee8ea36fbb4.js → 49a57dc1e6d1048fa949.js} +1 -1
  28. package/assets/esri/core/workers/chunks/513dc2467e9b8b8c6df4.js +1 -0
  29. package/assets/esri/core/workers/chunks/52239e958a82ebcd2e7a.js +1 -0
  30. package/assets/esri/core/workers/chunks/53e43798d08ad2075c1f.js +1 -0
  31. package/assets/esri/core/workers/chunks/{8b93cd4132934b0d7d39.js → 54814a269d44855f0673.js} +1 -1
  32. package/assets/esri/core/workers/chunks/55ce214a10fb6fc2e901.js +1 -0
  33. package/assets/esri/core/workers/chunks/{e7589c39b13295af8f1d.js → 604f8094992bb642378b.js} +1 -1
  34. package/assets/esri/core/workers/chunks/66c8816e91e3f9e214d4.js +346 -0
  35. package/assets/esri/core/workers/chunks/6975929fa91c81c8afc0.js +1 -0
  36. package/assets/esri/core/workers/chunks/7716a9fb380d66ba7292.js +1 -0
  37. package/assets/esri/core/workers/chunks/77ad62ed93f713a909f0.js +1 -0
  38. package/assets/esri/core/workers/chunks/7b9eec0090f48e9cdaf1.js +1 -0
  39. package/assets/esri/core/workers/chunks/7c56740cac444419e5b4.js +1 -0
  40. package/assets/esri/core/workers/chunks/{3b63edcd34f832ac7bd8.js → 7c6b9e2c1dada4668c01.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{af0d7a7cbbaad47a49c6.js → 802c6b1a6cb9264b8e4f.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{0b21651eb93efe9ce089.js → 827919fe23e06e40a330.js} +189 -165
  43. package/assets/esri/core/workers/chunks/87986f31061c426e761b.js +1 -0
  44. package/assets/esri/core/workers/chunks/{7ae88c141a5d85e5bb88.js → 87a743df7d8556d5e253.js} +1 -1
  45. package/assets/esri/core/workers/chunks/8855f1a6224ffbd0bb66.js +1 -0
  46. package/assets/esri/core/workers/chunks/885e8e90dfe5dbd5053d.js +1 -0
  47. package/assets/esri/core/workers/chunks/8865bd8f196556441ce3.js +1 -0
  48. package/assets/esri/core/workers/chunks/8b1842f0f94c18652d4e.js +1 -0
  49. package/assets/esri/core/workers/chunks/932808e485f305b6a26a.js +1 -0
  50. package/assets/esri/core/workers/chunks/93c145a738b3f6cf4ee4.js +1 -0
  51. package/assets/esri/core/workers/chunks/93e66d9c49eaeb503bff.js +1 -0
  52. package/assets/esri/core/workers/chunks/9959a91c8de6fef499c2.js +1 -0
  53. package/assets/esri/core/workers/chunks/9d779891d51d196aa8c8.js +1 -0
  54. package/assets/esri/core/workers/chunks/{6cbe8205a4e0f62da519.js → a5a27e2e9b91fbe12da9.js} +1 -1
  55. package/assets/esri/core/workers/chunks/aeac889d95f34b6d3b72.js +1 -0
  56. package/assets/esri/core/workers/chunks/c1a72e1dbd1ba7b41965.js +1 -0
  57. package/assets/esri/core/workers/chunks/c4065934637b820cad5b.js +1 -0
  58. package/assets/esri/core/workers/chunks/cc1328cacc4ac07eb548.js +1 -0
  59. package/assets/esri/core/workers/chunks/d0876a713079c669995a.js +1 -0
  60. package/assets/esri/core/workers/chunks/{3145218abe59b5e99ff8.js → d2139307f62ea8bf999a.js} +1 -1
  61. package/assets/esri/core/workers/chunks/{d5f770302dc686e55ba7.js → daffceecdc71e74d2629.js} +1 -1
  62. package/assets/esri/core/workers/chunks/{3f58da371633967a61ca.js → ddb66fe6fcd0764daa7a.js} +1 -1
  63. package/assets/esri/core/workers/chunks/{0eeb0dce918e4827309a.js → eac7af86166c09c6a9be.js} +1 -1
  64. package/assets/esri/core/workers/chunks/{998819aade3898f52414.js → ec49e2849766402ad5c7.js} +1 -1
  65. package/assets/esri/core/workers/chunks/{7317346ed8d7c5bb859d.js → f537a02dc2fc9e6435a2.js} +1 -1
  66. package/assets/esri/core/workers/chunks/fa3edfbdaa3b716a3a10.js +1 -0
  67. package/assets/esri/core/workers/chunks/fa5715ca3ce95d005b0a.js +1 -0
  68. package/assets/esri/core/workers/chunks/{7e1906d35a764f7f10b0.js → fe1129f03476825a7344.js} +1 -1
  69. package/assets/esri/themes/base/widgets/_SelectionList.scss +31 -28
  70. package/assets/esri/themes/dark/main.css +1 -1
  71. package/assets/esri/themes/light/main.css +1 -1
  72. package/assets/esri/themes/light/view.css +1 -1
  73. package/chunks/DefaultMaterial.glsl.js +30 -28
  74. package/chunks/RealisticTree.glsl.js +25 -22
  75. package/chunks/aiServices.js +1 -1
  76. package/chunks/chartUtilsAm5.js +1 -1
  77. package/config.js +1 -1
  78. package/core/LRUCache.js +1 -1
  79. package/core/MemCache.js +1 -1
  80. package/core/accessorSupport/utils.js +1 -1
  81. package/core/object.js +1 -1
  82. package/core/urlUtils.js +1 -1
  83. package/core/workers/RemoteClient.js +1 -1
  84. package/core/workers/WorkerHandle.js +1 -1
  85. package/editing/sharedTemplates/executor/builders/bufferPolygonToPolygon.js +1 -1
  86. package/interfaces.d.ts +76 -24
  87. package/intl/date.js +1 -1
  88. package/intl/duration.js +1 -1
  89. package/intl/locale.js +1 -1
  90. package/intl/messages.js +1 -1
  91. package/intl/number.js +1 -1
  92. package/intl.d.ts +1 -0
  93. package/intl.js +1 -1
  94. package/kernel.js +1 -1
  95. package/layers/CatalogLayer.js +1 -1
  96. package/layers/FeatureLayer.js +1 -1
  97. package/layers/GeoJSONLayer.js +1 -1
  98. package/layers/WFSLayer.js +1 -1
  99. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  100. package/layers/graphics/data/QueryEngineResult.js +1 -1
  101. package/layers/graphics/data/queryValidationUtils.js +1 -1
  102. package/layers/mixins/FeatureLayerBase.js +1 -1
  103. package/layers/orientedImagery/core/ExposurePoint.js +1 -1
  104. package/layers/support/arcgisLayers.js +1 -1
  105. package/layers/support/featureLayerUtils.js +1 -1
  106. package/layers/support/fetchService.js +1 -1
  107. package/layers/support/layerUtils.js +1 -1
  108. package/layers/support/rasterDatasets/covJSONParser.js +1 -1
  109. package/layers/support/rasterFormats/TiffDecoder.js +1 -1
  110. package/package.json +1 -1
  111. package/portal/support/layersLoader.js +1 -1
  112. package/portal/support/loadUtils.js +1 -1
  113. package/portal/support/portalLayers.js +1 -1
  114. package/renderers/support/DictionaryScriptEvaluator.js +1 -1
  115. package/renderers/visualVariables/support/visualVariableUtils.js +1 -1
  116. package/rest/networks/circuits/support/CircuitVerifyResult.js +1 -1
  117. package/rest/support/DateBinTimeInterval.js +1 -1
  118. package/rest/support/DateBinUtils.js +5 -0
  119. package/rest/support/TranslateParameters.js +1 -1
  120. package/smartMapping/renderers/size.js +1 -1
  121. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  122. package/smartMapping/support/adapters/support/utils.js +1 -1
  123. package/support/ArcadeExpression.js +1 -1
  124. package/support/revision.js +1 -1
  125. package/symbols/WaterSymbol3DLayer.js +1 -1
  126. package/symbols/cim/effects/EffectTaperedPolygon.js +1 -1
  127. package/symbols/support/symbolUtils.js +1 -1
  128. package/symbols/support/utils.js +1 -1
  129. package/views/2d/engine/vectorTiles/style/StyleProperty.js +1 -1
  130. package/views/2d/layers/features/support/FeatureSetReaderIndirect.js +1 -1
  131. package/views/3d/analysis/AreaMeasurementAnalysisView3D.js +1 -1
  132. package/views/3d/analysis/DimensionAnalysisView3D.js +1 -1
  133. package/views/3d/analysis/DirectLineMeasurementAnalysisView3D.js +1 -1
  134. package/views/3d/analysis/LineOfSightAnalysisView3D.js +1 -1
  135. package/views/3d/analysis/SliceAnalysisView3D.js +1 -1
  136. package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
  137. package/views/3d/camera/intersectionUtils.js +1 -1
  138. package/views/3d/layers/I3SMeshView3D.js +1 -1
  139. package/views/3d/layers/I3SMeshViewLabeler.js +1 -1
  140. package/views/3d/layers/I3SMeshWorkerHandle.js +1 -1
  141. package/views/3d/layers/RouteLayerView3D.js +1 -1
  142. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  143. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  144. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  145. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  146. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  147. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  148. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  149. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  150. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  151. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  152. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  153. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  154. package/views/3d/layers/graphics/graphicUtils.js +1 -1
  155. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  156. package/views/3d/layers/i3s/I3SLodHandling.js +1 -1
  157. package/views/3d/layers/support/StageLayerElevationProvider.js +1 -1
  158. package/views/3d/layers/support/makeScheduleFunction.js +1 -1
  159. package/views/3d/layers/support/symbolColorUtils.js +1 -1
  160. package/views/3d/state/controllers/FovController.js +1 -1
  161. package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
  162. package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
  163. package/views/3d/state/controllers/RotateController.js +1 -1
  164. package/views/3d/state/controllers/ZoomControllerGlobal.js +1 -1
  165. package/views/3d/state/controllers/ZoomControllerLocal.js +1 -1
  166. package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
  167. package/views/3d/state/controllers/ZoomStepControllerLocal.js +1 -1
  168. package/views/3d/state/utils/navigationUtils.js +1 -1
  169. package/views/3d/support/StreamDataLoader.js +1 -1
  170. package/views/3d/terrain/OverlayRenderer.js +1 -1
  171. package/views/3d/terrain/TerrainRenderer.js +1 -1
  172. package/views/3d/terrain/TerrainSurface.js +1 -1
  173. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  174. package/views/3d/webgl-engine/collections/Component/RenderSubmitSystem.js +1 -1
  175. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  176. package/views/3d/webgl-engine/core/shaderLibrary/attributes/InstanceColor.glsl.js +11 -0
  177. package/views/3d/webgl-engine/core/shaderLibrary/attributes/MaskedColor.glsl.js +18 -0
  178. package/views/3d/webgl-engine/core/shaderLibrary/attributes/PathVertexPosition.glsl.js +40 -26
  179. package/views/3d/webgl-engine/core/shaderLibrary/attributes/RibbonVertexPosition.glsl.js +35 -24
  180. package/views/3d/webgl-engine/core/shaderLibrary/attributes/SymbolColor.glsl.js +12 -8
  181. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexColor.glsl.js +3 -1
  182. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js +2 -2
  183. package/views/3d/webgl-engine/core/shaderLibrary/shading/VisualVariables.glsl.js +26 -8
  184. package/views/3d/webgl-engine/core/shaderModules/Float2BindUniform.js +1 -1
  185. package/views/3d/webgl-engine/core/shaderModules/Float2DrawUniform.js +1 -1
  186. package/views/3d/webgl-engine/core/shaderModules/Float2PassUniform.js +1 -1
  187. package/views/3d/webgl-engine/core/shaderModules/Float3BindUniform.js +1 -1
  188. package/views/3d/webgl-engine/core/shaderModules/Float3DrawUniform.js +1 -1
  189. package/views/3d/webgl-engine/core/shaderModules/Float3PassUniform.js +1 -1
  190. package/views/3d/webgl-engine/core/shaderModules/Float4BindUniform.js +1 -1
  191. package/views/3d/webgl-engine/core/shaderModules/Float4DrawUniform.js +1 -1
  192. package/views/3d/webgl-engine/core/shaderModules/Float4PassUniform.js +1 -1
  193. package/views/3d/webgl-engine/core/shaderModules/Float4sPassUniform.js +1 -1
  194. package/views/3d/webgl-engine/core/shaderModules/FloatBindUniform.js +1 -1
  195. package/views/3d/webgl-engine/core/shaderModules/FloatDrawUniform.js +1 -1
  196. package/views/3d/webgl-engine/core/shaderModules/FloatPassUniform.js +1 -1
  197. package/views/3d/webgl-engine/core/shaderModules/FloatsPassUniform.js +1 -1
  198. package/views/3d/webgl-engine/core/shaderModules/Matrix3DrawUniform.js +1 -1
  199. package/views/3d/webgl-engine/core/shaderModules/Matrix3PassUniform.js +1 -1
  200. package/views/3d/webgl-engine/core/shaderModules/Matrix4BindUniform.js +1 -1
  201. package/views/3d/webgl-engine/core/shaderModules/Matrix4DrawUniform.js +1 -1
  202. package/views/3d/webgl-engine/core/shaderModules/Matrix4PassUniform.js +1 -1
  203. package/views/3d/webgl-engine/core/shaderModules/Matrix4sDrawUniform.js +1 -1
  204. package/views/3d/webgl-engine/core/shaderModules/Matrix4sPassUniform.js +1 -1
  205. package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +1 -1
  206. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  207. package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
  208. package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
  209. package/views/3d/webgl-engine/lib/Program.js +1 -1
  210. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  211. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  212. package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
  213. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  214. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  215. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  216. package/views/3d/webgl-engine/materials/internal/MaterialUtil.js +1 -1
  217. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  218. package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
  219. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  220. package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
  221. package/views/analysis/analysisViewUtils.js +1 -1
  222. package/views/ui/UI.js +1 -1
  223. package/views/webgl/Program.js +1 -1
  224. package/views/webgl/ShaderBuilder.js +1 -1
  225. package/webscene/Slide.js +1 -1
  226. package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
  227. package/widgets/BatchAttributeForm.js +1 -1
  228. package/widgets/Directions/DirectionsVisibleElements.js +1 -1
  229. package/widgets/Directions.js +1 -1
  230. package/widgets/Editor/EditorViewModel.js +1 -1
  231. package/widgets/Editor/UpdateFeatureWorkflowData.js +1 -1
  232. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  233. package/widgets/Editor/UpdateWorkflow.js +1 -1
  234. package/widgets/Editor/components/PendingFeatureList.js +1 -1
  235. package/widgets/Editor.js +1 -1
  236. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  237. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  238. package/widgets/FeatureTable.js +1 -1
  239. package/widgets/FeatureTemplates.js +1 -1
  240. package/widgets/Features/FeaturesViewModel.js +1 -1
  241. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  242. package/widgets/OrientedImageryViewer/components/ImageViewer.js +1 -1
  243. package/widgets/OrientedImageryViewer/components/NavigationNode.js +1 -1
  244. package/widgets/OrientedImageryViewer/components/NavigationSettings.js +1 -1
  245. package/widgets/OrientedImageryViewer/components/NavigationUI.js +1 -1
  246. package/widgets/OrientedImageryViewer/components/NavigationUI360.js +5 -0
  247. package/widgets/OrientedImageryViewer/components/NavigationUIPanoramicViewModel.js +1 -1
  248. package/widgets/OrientedImageryViewer/components/NavigationUIViewModel.js +1 -1
  249. package/widgets/OrientedImageryViewer/components/imageNavigationUtils.js +1 -1
  250. package/widgets/OrientedImageryViewer/navigation/NavigationManager.js +1 -1
  251. package/widgets/OrientedImageryViewer.js +1 -1
  252. package/widgets/PanoramicViewer.js +1 -1
  253. package/widgets/Print/PrintViewModel.js +1 -1
  254. package/widgets/Print.js +1 -1
  255. package/widgets/ScaleRangeSlider/scalePreviewUtils.js +1 -1
  256. package/widgets/Search/SearchViewModel.js +1 -1
  257. package/widgets/Search/support/layerSearchUtils.js +1 -1
  258. package/widgets/Search.js +1 -1
  259. package/widgets/support/ItemList.js +1 -1
  260. package/widgets/support/SelectionList/FeatureItem.js +1 -1
  261. package/widgets/support/SelectionList/GroupLayerItem.js +1 -1
  262. package/widgets/support/SelectionList/LayerItem.js +1 -1
  263. package/widgets/support/SelectionList/SelectionListViewModel.js +1 -1
  264. package/widgets/support/SelectionList.js +1 -1
  265. package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +1 -1
  266. package/widgets/support/dateUtils.js +1 -1
  267. package/widgets/support/symbolPreviewUtils.js +1 -1
  268. package/widgets/support/timeWidgetUtils.js +1 -1
  269. package/assets/esri/core/workers/chunks/0dbb350ce651bc236ec8.js +0 -1
  270. package/assets/esri/core/workers/chunks/0ff6f15d46d7ddf6fe4d.js +0 -1
  271. package/assets/esri/core/workers/chunks/18011c691e0aca4144dd.js +0 -1
  272. package/assets/esri/core/workers/chunks/183a7dec68c8ba6eb3d6.js +0 -1
  273. package/assets/esri/core/workers/chunks/2ddb776434a93b8d9e63.js +0 -1
  274. package/assets/esri/core/workers/chunks/369978472cc9ee6a00b5.js +0 -346
  275. package/assets/esri/core/workers/chunks/3916879b9ca8c6979011.js +0 -1
  276. package/assets/esri/core/workers/chunks/3cbc498388fb1931a9f8.js +0 -1
  277. package/assets/esri/core/workers/chunks/4079e307a0fce4516aa4.js +0 -1
  278. package/assets/esri/core/workers/chunks/4088f4c25a09932a3eb1.js +0 -1
  279. package/assets/esri/core/workers/chunks/462cc6966d060be59c7c.js +0 -1
  280. package/assets/esri/core/workers/chunks/467cacb501b0417bb4df.js +0 -1
  281. package/assets/esri/core/workers/chunks/49089731ecfe7e8bb2f6.js +0 -1
  282. package/assets/esri/core/workers/chunks/4a805e7a57d25c4b595f.js +0 -66
  283. package/assets/esri/core/workers/chunks/4e0bae3671fe1c7efa76.js +0 -1
  284. package/assets/esri/core/workers/chunks/58f92100b1b2343111c6.js +0 -1
  285. package/assets/esri/core/workers/chunks/5dcc8fa321f0a7c49f36.js +0 -1
  286. package/assets/esri/core/workers/chunks/5df4f2315fae82030e87.js +0 -1
  287. package/assets/esri/core/workers/chunks/5e539ce4751bcfa57145.js +0 -1
  288. package/assets/esri/core/workers/chunks/6194636638b0439fccd8.js +0 -1
  289. package/assets/esri/core/workers/chunks/622c0552ca3cd674d46c.js +0 -1
  290. package/assets/esri/core/workers/chunks/64f5f27e7c5649d79cbc.js +0 -1
  291. package/assets/esri/core/workers/chunks/658e82c9b722852e02d0.js +0 -1
  292. package/assets/esri/core/workers/chunks/679d7baea233faf3fdbc.js +0 -1
  293. package/assets/esri/core/workers/chunks/72ea996b03932c0f004f.js +0 -1
  294. package/assets/esri/core/workers/chunks/7aef81778155be373d3e.js +0 -1
  295. package/assets/esri/core/workers/chunks/97b69fec3e87f11210ba.js +0 -1
  296. package/assets/esri/core/workers/chunks/a1a42b0d7cd47b647f8a.js +0 -1
  297. package/assets/esri/core/workers/chunks/a250a5c6e055e33bd25c.js +0 -1
  298. package/assets/esri/core/workers/chunks/a622ed3f182648ab3ff6.js +0 -1
  299. package/assets/esri/core/workers/chunks/a693cd3af2e995972252.js +0 -1
  300. package/assets/esri/core/workers/chunks/b4273381dc069f4e1fa2.js +0 -1
  301. package/assets/esri/core/workers/chunks/b72137c63b7f2a525d9e.js +0 -1
  302. package/assets/esri/core/workers/chunks/c2264451d12f1fbaad22.js +0 -1
  303. package/assets/esri/core/workers/chunks/c6c86cbe65a58c3093ae.js +0 -1
  304. package/assets/esri/core/workers/chunks/c8856370bae65d9eeb2b.js +0 -1
  305. package/assets/esri/core/workers/chunks/cd4fb107489594c57438.js +0 -1
  306. package/assets/esri/core/workers/chunks/d28d874c1337b69fedc0.js +0 -1
  307. package/assets/esri/core/workers/chunks/ec922f876e1465d36045.js +0 -1
  308. package/assets/esri/core/workers/chunks/fe3703ec198cbfebec30.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{cyclicalPI as t}from"../../../../core/Cyclical.js";import{deg2rad as e,clamp as n,acosClamped as o,asinClamped as r}from"../../../../core/mathUtils.js";import{createScreenPointArray as a}from"../../../../core/screenUtils.js";import{fromRotation as i,exactEquals as s,rotate as c,multiply as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as m,create as u}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as f}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{e as h,l as M,d as g,t as y,f as b,n as d,s as x,c as v,h as j,g as z,m as P,i as w}from"../../../../chunks/vec32.js";import{create as I}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as H,fromPoints as S,axis as A,wrapAxisAngle as E}from"../../../../geometry/support/axisAngle.js";import{coordinateSystemFromOneAxisAndNormalVector as k,vectorCoordinates as T}from"../../../../geometry/support/coordinateSystem.js";import{create as U,fromNormalAndOffset as G,intersectRay as R}from"../../../../geometry/support/plane.js";import{c as q,j as C,i as F,a as V}from"../../../../chunks/sphere.js";import{sm4d as O,sv3d as W}from"../../../../geometry/support/vectorStacks.js";import{fromScreenAtEye as B,fromScreen as D}from"../../support/geometryUtils/ray.js";import{intersectScreen as J}from"../../support/geometryUtils/sphere.js";import K from"../../webgl/RenderCamera.js";import{terrainId as L}from"../../webgl-engine/lib/verticalOffsetUtils.js";var N;!function(t){t[t.Ellipsoid=0]="Ellipsoid",t[t.Silhouette=1]="Silhouette"}(N||(N={}));const Q=30,X=[1,3e8],Y=80,Z=8,$=200,_=1508e5,tt=5,et=50,nt=5,ot=10,rt=90,at={exclude:new Set([L])};function it(t,e,n){return n[0]=e[0]/(t.fullWidth/t.pixelRatio),n[1]=e[1]/(t.fullHeight/t.pixelRatio),n}function st(t){for(;t>Math.PI;)t-=2*Math.PI;for(;t<-Math.PI;)t+=2*Math.PI;return t}function ct(t,e,n){const o=i(O.get(),n[3],A(n));null==o||s(o,m)||(g(re,t.eye,e),y(re,re,o),t.eye=b(re,re,e),g(re,t.center,e),y(re,re,o),t.center=b(re,re,e),t.up=y(re,t.up,o))}function lt(t,e,n,o){return R(t,D(e,n,le),o)}function mt(t,e,n,o){return R(t,B(e,n,le),o)}function ut(t,e,n,o){const r=W.get();let a=1-n;g(r,e,t.eye);const i=M(r);let s=i*(1-a);a>=0&&s<o&&(s=o,a=-(s-i)/i),Math.abs(i-s)<1e-6||(z(r,r,a),t.eye=b(re,t.eye,r),t.center=P(re,t.center,e,a))}function ft(t,e,n){e.getScreenCenter(pt),J(t,e,pt,re)&&(e.center=re);const o=e.distance,r=o*n;if(Math.abs(o-r)<1e-6)return;const a=z(W.get(),e.viewForward,r);e.eye=g(re,e.center,a)}const pt=a();function ht(t,e){w(e,0,0,0);for(const n of t)b(e,e,n);z(e,e,1/t.length)}function Mt(t,e,n,o){return Math.sin(t/M(e))*(n+o.radius)}function gt(t,e,n,o){return Mt(Math.PI/2,e,n,o)+(t-Math.PI/2)}var yt;!function(t){t[t.Vertical=0]="Vertical",t[t.Horizontal=1]="Horizontal"}(yt||(yt={}));const bt={Elevation:3e4,Angle:e(16)},dt=e(80);function xt(t,e,n,o,r,a){const i=I(),s=q();let c=!0,l=!0;return t.intersectScreen(n,i,a)?s[3]=M(i):(l=!1,e.aboveGround&&r!==N.Ellipsoid?s[3]=Math.max(M(e.center),.9*o):s[3]=M(e.eye)-e.relativeElevation,r===N.Silhouette?Pt(s,e,n,i):c=J(s,e,n,i)),{sphere:s,scenePickPoint:c?i:null,hasGeometryIntersection:l}}function vt(t,e,n,o){const r=t.relativeElevation;if(r>bt.Elevation&&"global"===o)return yt.Horizontal;B(t,e,me);const a=Math.sign(r),i=n.worldUpAtPosition(t.eye,re);return-a*h(i,me.direction)<Math.sin(bt.Angle)*M(me.direction)?yt.Vertical:yt.Horizontal}function jt(t,e,n){g(zt,n,e),t.eye=g(re,t.eye,zt),t.center=g(re,t.center,zt)}const zt=I();function Pt(t,e,n,o){const r=B(e,n,le);return null!=r&&(C(t,r,wt),F(t,r,o)?!(x(wt,r.origin)<x(o,r.origin))||(v(o,wt),!1):(g(It,e.eye,e.center),d(It,It),G(It,-h(d(It,It),wt),Ht),R(Ht,r,o),!1))}const wt=I(),It=I(),Ht=U();function St(a,i,s,c,l,m){let u=0;if(j(se,a,i),g(ae,a,i),M(a)<=l||!c.aboveGround){j(s,ae,c.eye);const f=h(a,i)/(M(a)*M(i));if(f<.9999)u=o(f);else{const t=M(j(I(),a,i))/(M(a)*M(i));u=r(t)}const p=Math.cos(n(t.normalize(e(m)),0,dt));u=-u-Math.max(0,M(i)-l)/(p*l)}else g(At,c.eye,c.center),j(s,ae,At),u=-M(ae)/l;return d(s,s),z(s,s,M(se)),u}const At=I();function Et(r,a,i,s){let c,l;const m=Math.cos(n(t.normalize(e(s)),0,dt));return c=a>i?-(a-i)/(m*i):a<-i?Math.PI-(a+i)/(m*i):o(a/i),l=r>i?-(r-i)/(m*i):r<-i?Math.PI-(r+i)/(m*i):o(r/i),(l-c)*i}function kt(t,e,n,o,r,a,i,s,c,l){const m=Et(t[2],e[2],a[3],s),u=c?Et(t[0],e[0],a[3],180):e[0]-t[0],p=Math.sin(i)*u-Math.cos(i)*m,M=Math.cos(i)*u+Math.sin(i)*m;d(re,r);const g=c?p/Math.sqrt(Math.abs(a[3]**2-h(n,re)**2)):p/a[3],y=M/Math.sqrt(Math.abs(a[3]**2-h(n,o)**2));f(l,g,y)}function Tt(t,e,n,o,r,a,i,s,c,l){j(se,t,e),k(a.up,a.eye,Nt,Qt,Xt),k([0,0,1],a.eye,Jt,Kt,Lt),v(n,Kt),v(o,Jt),d(n,n),z(n,n,M(se)),T(t,d(Qt,Qt),d(Xt,Xt),d(Nt,Nt),Yt),T(e,Qt,Xt,Nt,Zt),kt(Yt,Zt,t,Jt,Kt,i,s,c,l,r)}function Ut(t,e,n,o,r,a,s){i(te,r,o),i(ee,s,a),l(ne,te,ee),g(e,t,n),y(e,e,ne),b(e,e,n)}function Gt(t,e,n,o,r,a){i(te,o,n),i(ee,a,r),l(ne,te,ee),g(re,t.eye,e),y(re,re,ne),t.eye=b(re,re,e),g(re,t.center,e),y(re,re,ne),t.center=b(re,re,e),g(re,t.up,e),y(re,re,ne),t.up=b(re,re,e)}const Rt={Pole:.95,Angle:e(18),Tilt:45,TiltHysteresisMargin:1e-7};let qt=!1;function Ct(t,e,n,o,r,a){const i=Math.abs(o)>Math.PI-Rt.Angle||Math.abs(o)<Rt.Angle,s=(Math.abs(t[2])<n*Rt.Pole||Math.abs(e)>n)&&a;return i&&s?!qt&&r<Rt.Tilt-Rt.TiltHysteresisMargin?qt=!0:qt&&r>Rt.Tilt+Rt.TiltHysteresisMargin&&(qt=!1):qt=!1,qt}function Ft(t,e,n,o,r,a){if(a)S(n,o,_t),ct(e,V(t),_t);else{const a=St(n,o,ce,e,t[3],r);ct(e,V(t),E(ce,a))}}function Vt(t,e,n,o,r,a,i){const s=i?20:1,c=1e-12;let l,m;v(oe,o),ie.copyFrom(e);for(let u=0;u<s&&x(n,oe)>c&&(l=x(n,oe),Tt(n,oe,Kt,Jt,$t,ie,t,r,a,i),Gt(ie,V(t),Jt,$t[1],Kt,$t[0]),Ut(oe,oe,V(t),Jt,$t[1],Kt,$t[0]),m=x(n,oe),m<l||0===u);u++)e.copyFrom(ie)}function Ot(n,o,r,a,i,s,c){Ct(r,h(o.up,r),n[3],-t.normalize(e(i)),s,o.aboveGround)?Vt(n,o,r,a,-t.normalize(e(i)),s,c):Ft(n,o,r,a,s,c)}function Wt(t,e,n,o,r,a){const{eye:i}=t;k([0,0,1],i,Jt,Kt,Lt);const s=e.translation[0]*n.pan,l="zoom"===r.mode?0:e.translation[1]*n.pan,m=Math.max(Math.sqrt(Math.abs(1-h(t.center,Jt)**2/M(t.center)**2)),.5),u=(Math.sin(a)*l+Math.cos(a)*s)/m,f=-Math.cos(a)*l+Math.sin(a)*s;switch(c(o.pan.matrix,o.pan.matrix,u,Jt),o.pan.enabled=!0,r.mode){case"pan":c(o.pan.matrix,o.pan.matrix,f,Kt),o.pan.enabled=!0;break;case"zoom":o.zoom=-e.translation[1]*n.zoom}}function Bt(t,e,n,o,r){const{eye:a,viewRight:i}=t,s=j(W.get(),i,a),l=e.translation[0]*n.pan;switch(0!==l&&(c(o.pan.matrix,o.pan.matrix,-l,s),o.pan.enabled=!0),r.mode){case"pan":{const t=e.translation[1]*n.pan;0!==t&&(c(o.pan.matrix,o.pan.matrix,t,i),o.pan.enabled=!0);break}case"zoom":o.zoom=-e.translation[1]*n.zoom}}function Dt(n,o,r,a,i,s,c,l,m){Ct(n.center,h(n.up,n.center),M(n.center),-t.normalize(e(s)),c,o.aboveGround)?Wt(o,r,a,l,m,-t.normalize(e(i))):Bt(o,r,a,l,m)}const Jt=I(),Kt=I(),Lt=I(),Nt=I(),Qt=I(),Xt=I(),Yt=I(),Zt=I(),$t=p(),_t=H(),te=u(),ee=u(),ne=u(),oe=I(),re=I(),ae=I(),ie=new K,se=I(),ce=I(),le={origin:I(),direction:I()},me={origin:I(),direction:I()};export{yt as NavigationMode,N as SpherePickPointFallback,dt as TiltThresholdPanningSpeed,bt as VerticalPanTresholds,jt as applyPanPlanar,Ft as applyPanSphericalDirectRotation,Vt as applyPanSphericalPreserveHeading,ct as applyRotation,Gt as applyRotationWithTwoAxes,ft as applyZoomOnSphere,ut as applyZoomToPoint,ht as centroid,X as distanceClampValues,at as excludeTerrain,lt as intersectPlaneFromScreenPoint,mt as intersectPlaneFromScreenPointAtEye,Et as lengthFromPoints,et as minHeightLimit,vt as navigationMode,it as normalizeCoordinate,st as normalizeRotationDelta,gt as offSurfaceTiltToEyeTiltGlobal,Mt as onSurfaceTiltToEyeTiltGlobal,tt as panDistanceModifier,Dt as panMotionToRotationMatrix,Ot as panToPosition,xt as pickPointAndInitSphere,Q as pivotDistanceModifier,Rt as preservingHeadingThresholds,nt as rotatePivotDistanceModifier,ot as rotatePivotMinDistanceModifier,Ut as rotatePointAroundTwoAxes,rt as rotateScreenPixelArea,St as rotationAngleAndAxisDirectRotation,Tt as rotationAnglesAndAxesHeadingPreserving,kt as rotationAnglesHeadingPreserving,Y as screenPixelArea,Ct as shouldPreserveHeading,Pt as sphereOrPlanePointFromScreenPoint,Z as zoomDistanceModifier,_ as zoomMaxDistanceModifier,$ as zoomMinDistanceModifier};
5
+ import{cyclicalPI as t}from"../../../../core/Cyclical.js";import{deg2rad as e,clamp as n,acosClamped as o,asinClamped as r}from"../../../../core/mathUtils.js";import{createScreenPointArray as a}from"../../../../core/screenUtils.js";import{fromRotation as i,exactEquals as s,rotate as c,multiply as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as m,create as u}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as f}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{e as h,l as M,d as g,t as y,f as b,n as d,s as x,c as v,h as j,g as z,m as P,i as w}from"../../../../chunks/vec32.js";import{create as I}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as H,fromPoints as S,axis as A,wrapAxisAngle as E}from"../../../../geometry/support/axisAngle.js";import{coordinateSystemFromOneAxisAndNormalVector as k,vectorCoordinates as T}from"../../../../geometry/support/coordinateSystem.js";import{create as U,fromNormalAndOffset as G,intersectRay as R}from"../../../../geometry/support/plane.js";import{c as q,j as C,i as F,a as V}from"../../../../chunks/sphere.js";import{sm4d as O,sv3d as W}from"../../../../geometry/support/vectorStacks.js";import{fromScreenAtEye as B,fromScreen as D}from"../../support/geometryUtils/ray.js";import{intersectScreen as J}from"../../support/geometryUtils/sphere.js";import K from"../../webgl/RenderCamera.js";import{terrainId as L}from"../../webgl-engine/lib/verticalOffsetUtils.js";var N;!function(t){t[t.Ellipsoid=0]="Ellipsoid",t[t.Silhouette=1]="Silhouette"}(N||(N={}));const Q=30,X=[1,3e8],Y=8,Z=[200,1508e5],$=5,_=50,tt=5,et=10,nt=80,ot=90,rt={exclude:new Set([L])};function at(t,e,n){return n[0]=e[0]/(t.fullWidth/t.pixelRatio),n[1]=e[1]/(t.fullHeight/t.pixelRatio),n}function it(t){for(;t>Math.PI;)t-=2*Math.PI;for(;t<-Math.PI;)t+=2*Math.PI;return t}function st(t,e,n){const o=i(O.get(),n[3],A(n));null==o||s(o,m)||(g(re,t.eye,e),y(re,re,o),t.eye=b(re,re,e),g(re,t.center,e),y(re,re,o),t.center=b(re,re,e),t.up=y(re,t.up,o))}function ct(t,e,n,o){return R(t,D(e,n,le),o)}function lt(t,e,n,o){return R(t,B(e,n,le),o)}function mt(t,e,n,o){const r=W.get();let a=1-n;g(r,e,t.eye);const i=M(r);let s=i*(1-a);a>=0&&s<o&&(s=o,a=-(s-i)/i),Math.abs(i-s)<1e-6||(z(r,r,a),t.eye=b(re,t.eye,r),t.center=P(re,t.center,e,a))}function ut(t,e,n){e.getScreenCenter(ft),J(t,e,ft,re)&&(e.center=re);const o=e.distance,r=o*n;if(Math.abs(o-r)<1e-6)return;const a=z(W.get(),e.viewForward,r);e.eye=g(re,e.center,a)}const ft=a();function pt(t,e){w(e,0,0,0);for(const n of t)b(e,e,n);z(e,e,1/t.length)}function ht(t,e,n,o){return Math.sin(t/M(e))*(n+o.radius)}function Mt(t,e,n,o){return ht(Math.PI/2,e,n,o)+(t-Math.PI/2)}var gt;!function(t){t[t.Vertical=0]="Vertical",t[t.Horizontal=1]="Horizontal"}(gt||(gt={}));const yt={Elevation:3e4,Angle:e(16)},bt=e(80);function dt(t,e,n,o,r,a){const i=I(),s=q();let c=!0,l=!0;return t.intersectScreen(n,i,a)?s[3]=M(i):(l=!1,e.aboveGround&&r!==N.Ellipsoid?s[3]=Math.max(M(e.center),.9*o):s[3]=M(e.eye)-e.relativeElevation,r===N.Silhouette?zt(s,e,n,i):c=J(s,e,n,i)),{sphere:s,scenePickPoint:c?i:null,hasGeometryIntersection:l}}function xt(t,e,n,o){const r=t.relativeElevation;if(r>yt.Elevation&&"global"===o)return gt.Horizontal;B(t,e,me);const a=Math.sign(r),i=n.worldUpAtPosition(t.eye,re);return-a*h(i,me.direction)<Math.sin(yt.Angle)*M(me.direction)?gt.Vertical:gt.Horizontal}function vt(t,e,n){g(jt,n,e),t.eye=g(re,t.eye,jt),t.center=g(re,t.center,jt)}const jt=I();function zt(t,e,n,o){const r=B(e,n,le);return null!=r&&(C(t,r,Pt),F(t,r,o)?!(x(Pt,r.origin)<x(o,r.origin))||(v(o,Pt),!1):(g(wt,e.eye,e.center),d(wt,wt),G(wt,-h(d(wt,wt),Pt),It),R(It,r,o),!1))}const Pt=I(),wt=I(),It=U();function Ht(a,i,s,c,l,m){let u=0;if(j(se,a,i),g(ae,a,i),M(a)<=l||!c.aboveGround){j(s,ae,c.eye);const f=h(a,i)/(M(a)*M(i));if(f<.9999)u=o(f);else{const t=M(j(I(),a,i))/(M(a)*M(i));u=r(t)}const p=Math.cos(n(t.normalize(e(m)),0,bt));u=-u-Math.max(0,M(i)-l)/(p*l)}else g(St,c.eye,c.center),j(s,ae,St),u=-M(ae)/l;return d(s,s),z(s,s,M(se)),u}const St=I();function At(r,a,i,s){let c,l;const m=Math.cos(n(t.normalize(e(s)),0,bt));return c=a>i?-(a-i)/(m*i):a<-i?Math.PI-(a+i)/(m*i):o(a/i),l=r>i?-(r-i)/(m*i):r<-i?Math.PI-(r+i)/(m*i):o(r/i),(l-c)*i}function Et(t,e,n,o,r,a,i,s,c,l){const m=At(t[2],e[2],a[3],s),u=c?At(t[0],e[0],a[3],180):e[0]-t[0],p=Math.sin(i)*u-Math.cos(i)*m,M=Math.cos(i)*u+Math.sin(i)*m;d(re,r);const g=c?p/Math.sqrt(Math.abs(a[3]**2-h(n,re)**2)):p/a[3],y=M/Math.sqrt(Math.abs(a[3]**2-h(n,o)**2));f(l,g,y)}function kt(t,e,n,o,r,a,i,s,c,l){j(se,t,e),k(a.up,a.eye,Nt,Qt,Xt),k([0,0,1],a.eye,Jt,Kt,Lt),v(n,Kt),v(o,Jt),d(n,n),z(n,n,M(se)),T(t,d(Qt,Qt),d(Xt,Xt),d(Nt,Nt),Yt),T(e,Qt,Xt,Nt,Zt),Et(Yt,Zt,t,Jt,Kt,i,s,c,l,r)}function Tt(t,e,n,o,r,a,s){i(te,r,o),i(ee,s,a),l(ne,te,ee),g(e,t,n),y(e,e,ne),b(e,e,n)}function Ut(t,e,n,o,r,a){i(te,o,n),i(ee,a,r),l(ne,te,ee),g(re,t.eye,e),y(re,re,ne),t.eye=b(re,re,e),g(re,t.center,e),y(re,re,ne),t.center=b(re,re,e),g(re,t.up,e),y(re,re,ne),t.up=b(re,re,e)}const Gt={Pole:.95,Angle:e(18),Tilt:45,TiltHysteresisMargin:1e-7};let Rt=!1;function qt(t,e,n,o,r,a){const i=Math.abs(o)>Math.PI-Gt.Angle||Math.abs(o)<Gt.Angle,s=(Math.abs(t[2])<n*Gt.Pole||Math.abs(e)>n)&&a;return i&&s?!Rt&&r<Gt.Tilt-Gt.TiltHysteresisMargin?Rt=!0:Rt&&r>Gt.Tilt+Gt.TiltHysteresisMargin&&(Rt=!1):Rt=!1,Rt}function Ct(t,e,n,o,r,a){if(a)S(n,o,_t),st(e,V(t),_t);else{const a=Ht(n,o,ce,e,t[3],r);st(e,V(t),E(ce,a))}}function Ft(t,e,n,o,r,a,i){const s=i?20:1,c=1e-12;let l,m;v(oe,o),ie.copyFrom(e);for(let u=0;u<s&&x(n,oe)>c&&(l=x(n,oe),kt(n,oe,Kt,Jt,$t,ie,t,r,a,i),Ut(ie,V(t),Jt,$t[1],Kt,$t[0]),Tt(oe,oe,V(t),Jt,$t[1],Kt,$t[0]),m=x(n,oe),m<l||0===u);u++)e.copyFrom(ie)}function Vt(n,o,r,a,i,s,c){qt(r,h(o.up,r),n[3],-t.normalize(e(i)),s,o.aboveGround)?Ft(n,o,r,a,-t.normalize(e(i)),s,c):Ct(n,o,r,a,s,c)}function Ot(t,e,n,o,r,a){const{eye:i}=t;k([0,0,1],i,Jt,Kt,Lt);const s=e.translation[0]*n.pan,l="zoom"===r.mode?0:e.translation[1]*n.pan,m=Math.max(Math.sqrt(Math.abs(1-h(t.center,Jt)**2/M(t.center)**2)),.5),u=(Math.sin(a)*l+Math.cos(a)*s)/m,f=-Math.cos(a)*l+Math.sin(a)*s;switch(c(o.pan.matrix,o.pan.matrix,u,Jt),o.pan.enabled=!0,r.mode){case"pan":c(o.pan.matrix,o.pan.matrix,f,Kt),o.pan.enabled=!0;break;case"zoom":o.zoom=-e.translation[1]*n.zoom}}function Wt(t,e,n,o,r){const{eye:a,viewRight:i}=t,s=j(W.get(),i,a),l=e.translation[0]*n.pan;switch(0!==l&&(c(o.pan.matrix,o.pan.matrix,-l,s),o.pan.enabled=!0),r.mode){case"pan":{const t=e.translation[1]*n.pan;0!==t&&(c(o.pan.matrix,o.pan.matrix,t,i),o.pan.enabled=!0);break}case"zoom":o.zoom=-e.translation[1]*n.zoom}}function Bt(n,o,r,a,i,s,c,l,m){qt(n.center,h(n.up,n.center),M(n.center),-t.normalize(e(s)),c,o.aboveGround)?Ot(o,r,a,l,m,-t.normalize(e(i))):Wt(o,r,a,l,m)}function Dt(t,e,n=1/0){const o=Math.abs(h(t,e));return Math.min(n,1/o)}const Jt=I(),Kt=I(),Lt=I(),Nt=I(),Qt=I(),Xt=I(),Yt=I(),Zt=I(),$t=p(),_t=H(),te=u(),ee=u(),ne=u(),oe=I(),re=I(),ae=I(),ie=new K,se=I(),ce=I(),le={origin:I(),direction:I()},me={origin:I(),direction:I()};export{gt as NavigationMode,N as SpherePickPointFallback,bt as TiltThresholdPanningSpeed,yt as VerticalPanTresholds,vt as applyPanPlanar,Ct as applyPanSphericalDirectRotation,Ft as applyPanSphericalPreserveHeading,st as applyRotation,Ut as applyRotationWithTwoAxes,ut as applyZoomOnSphere,mt as applyZoomToPoint,pt as centroid,rt as excludeTerrain,Dt as getTiltScaleFactor,ct as intersectPlaneFromScreenPoint,lt as intersectPlaneFromScreenPointAtEye,At as lengthFromPoints,$ as maxPanDistanceModifier,tt as maxRotatePivotDistanceModifier,Q as maxZoomPivotDistanceModifier,Y as maxZoomStepDistanceModifier,_ as minPinchAndPanCameraHeight,et as minRotatePivotDistance,xt as navigationMode,at as normalizeCoordinate,it as normalizeRotationDelta,Mt as offSurfaceTiltToEyeTiltGlobal,ht as onSurfaceTiltToEyeTiltGlobal,Bt as panMotionToRotationMatrix,Vt as panToPosition,dt as pickPointAndInitSphere,nt as pivotSearchAreaSize,Gt as preservingHeadingThresholds,ot as rotatePivotSearchAreaSize,Tt as rotatePointAroundTwoAxes,Ht as rotationAngleAndAxisDirectRotation,kt as rotationAnglesAndAxesHeadingPreserving,Et as rotationAnglesHeadingPreserving,qt as shouldPreserveHeading,zt as sphereOrPlanePointFromScreenPoint,X as zoomPivotDistanceClamp,Z as zoomStepDistanceClamp};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../request.js";import s from"../../../core/Accessor.js";import{removeUnordered as r}from"../../../core/arrayUtils.js";import o from"../../../core/Error.js";import"../../../core/has.js";import{clone as a}from"../../../core/lang.js";import{removeMaybe as n,abortMaybe as i,destroyMaybe as u}from"../../../core/maybe.js";import{createResolver as l,onAbort as h,createAbortError as c,throwIfAborted as d,isAbortError as p}from"../../../core/promiseUtils.js";import{property as m}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import{AsyncWorkerQueue as g,BaseTask as f}from"./AsyncWorkerQueue.js";import{ImageWithType as k}from"./ImageWithType.js";import{isImageWithType as L}from"../terrain/TerrainData.js";import{assert as D}from"../webgl-engine/lib/Util.js";import{TaskPriority as y}from"../../support/Scheduler.js";let b=class extends s{constructor(){super(...arguments),this._tasks=new Map,this._onLoadQueue=new Array,this._doneQueue=new Array,this.updating=!1}setup(e,t,s){this._loadQueue=new g(((e,t)=>this._startLoading(e,t)),((e,t)=>this._doneLoadingCB(e,t)),e,t),s&&(this._frameTask=s.registerTask(y.STREAM_DATA_LOADER,this))}destroy(){this._frameTask=n(this._frameTask),this._tasks.forEach((e=>i(e.abortController))),this._loadQueue=u(this._loadQueue),this._onLoadQueue=null,this._doneQueue=null,this._tasks=null}hasDownloadSlots(e){return this._loadQueue.hasQuota(e)}request(e,t,s,r={}){const o=l();o.__signal=null!=r?r.signal:null;const a=this._createOrUpdateTask(e,t,s,r,o);return h(r,(()=>this._cancelRequest(a,o))),o.promise}_createTask(e,t,s,r,o,a){const n=new O(e,t,s,r,o);return this._updateTask(n,a),this._tasks.set(o,n),1===this._tasks.size&&this._set("updating",!0),this._loadQueue.push(n),n}_cancelRequest(e,t){r(e.resolvers,t),t.reject(c()),0===e.resolvers.length&&(e.status===Q.DOWNLOADING&&(e.status=Q.CANCELLED,this._loadQueue.cancel(e),e.abortController?.abort(),e.request=null,e.abortController=null),e.status=Q.CANCELLED,this._tasks.delete(e.key),0===this._tasks.size&&this._set("updating",!1))}_updateTask(e,t){e.resolvers.push(t)}_createOrUpdateTask(e,t,s,r,o){const a=E(r?.uid||e,t,s),n=this._tasks.get(a);return n?(this._updateTask(n,o),n):this._createTask(e,r,t,s,a,o)}_doneLoadingCB(e,t){this._loadQueue&&(D(e.status===Q.DOWNLOADING),e.status=Q.DOWNLOADED,this._frameTask?this._doneQueue.push({task:e,err:t}):this._doneLoading(e,t))}get running(){return this._doneQueue.length>0||this._onLoadQueue.length>0}runTask(e){for(;!e.done&&this._onLoadQueue.length>0;){const t=this._onLoadQueue.shift();d(t.task.abortController),t.task.abortController=null,t.callback(t.task),e.madeProgress()}for(;!e.done&&this._doneQueue.length>0;){const t=this._doneQueue.shift();t.task.status!==Q.DOWNLOADED&&(t.err=t.err||c()),this._doneLoading(t.task,t.err),e.madeProgress()}}_doneLoading(e,t){if(t&&!p(t)&&e.numRetries>0)return--e.numRetries,void this._loadQueue.push(e);let s=L(e.result)||e.result instanceof HTMLImageElement?0:e.resolvers.length;for(const r of e.resolvers)if(t)p(t)?r.reject(t):r.reject(new o("stream-data-loader:request-error",`Failed to request resource at '${e.url}'. ${t}`,{url:e.url,error:t}));else{--s;const t=s>0?a(e.result):e.result;r.resolve(t)}this._tasks.delete(e.key),0===this._tasks.size&&this._set("updating",!1)}_startLoading(e,s){if(e.status===Q.CANCELLED)return!1;let r,o;switch(e.startTime=performance.now(),e.status=Q.DOWNLOADING,e.docType){case"binary":o="array-buffer",r=0;break;case"image":o="image";break;case"image+type":o="array-buffer";break;default:o="json"}e.abortController=new AbortController;const a=e.abortController.signal;e.request=t(e.url,{...e.options,responseType:o,timeout:r,signal:a});const n=t=>{e.duration=performance.now()-e.startTime,e.size=t instanceof ArrayBuffer?t.byteLength:e.size||0,e.result=t,this._frameTask?this._onLoadQueue.push({callback:s,task:e}):(e.abortController=null,s(e))},i=t=>{e.status===Q.DOWNLOADING&&s(e,t)};return"image+type"!==e.docType?(e.request.then((e=>n(e.data)),i),!0):(e.request.then((s=>{const u=s.data,l=A(u);if(o="image",e.size=u.byteLength,"unknown"===l)return e.request=t(e.url,{responseType:o,timeout:r,signal:a}),void e.request.then((e=>n(e.data)),i);const h=new Blob([u],{type:l}),c=window.URL.createObjectURL(h);e.request=t(c,{responseType:o,timeout:r,signal:a}),e.request.then((e=>n(new k(e.data,l))),i).finally((()=>window.URL.revokeObjectURL(c)))}),i),!0)}get test(){}};e([m({readOnly:!0})],b.prototype,"updating",void 0),b=e([_("esri.views.3d.support.StreamDataLoader")],b);const T={numRetries:0};function A(e){if(e.byteLength<2)return"unknown";const t=new Uint8Array(e,0,e.byteLength);return 137===t[0]&&80===t[1]?"image/png":71===t[0]&&73===t[1]?"image/gif":66===t[0]&&77===t[1]?"image/bmp":255===t[0]&&216===t[1]?"image/jpeg":"unknown"}class O extends f{constructor(e,t,s,r,o){super(r),this.url=e,this.options=t,this.docType=s,this.key=o,this.result=null,this.status=Q.QUEUED,this.request=null,this.abortController=null,this.resolvers=new Array,this.startTime=0,this.numRetries=T.numRetries}}function E(e,t,s){return`${e}:${t}:${s}`}var Q;!function(e){e[e.QUEUED=1]="QUEUED",e[e.DOWNLOADING=2]="DOWNLOADING",e[e.DOWNLOADED=3]="DOWNLOADED",e[e.CANCELLED=4]="CANCELLED"}(Q||(Q={}));export{b as StreamDataLoader,Q as TaskStatus,T as test};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../request.js";import s from"../../../core/Accessor.js";import{removeUnordered as r}from"../../../core/arrayUtils.js";import o from"../../../core/Error.js";import"../../../core/has.js";import{clone as a}from"../../../core/lang.js";import{removeMaybe as n,abortMaybe as i,destroyMaybe as u}from"../../../core/maybe.js";import{createResolver as l,createAbortError as h,onAbort as d,throwIfAborted as c,isAbortError as p}from"../../../core/promiseUtils.js";import{property as m}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import{AsyncWorkerQueue as g,BaseTask as f}from"./AsyncWorkerQueue.js";import{ImageWithType as k}from"./ImageWithType.js";import{isImageWithType as L}from"../terrain/TerrainData.js";import{assert as D}from"../webgl-engine/lib/Util.js";import{TaskPriority as y}from"../../support/Scheduler.js";let b=class extends s{constructor(){super(...arguments),this._tasks=new Map,this._onLoadQueue=new Array,this._doneQueue=new Array,this.updating=!1}setup(e,t,s){this._loadQueue=new g(((e,t)=>this._startLoading(e,t)),((e,t)=>this._doneLoadingCB(e,t)),e,t),s&&(this._frameTask=s.registerTask(y.STREAM_DATA_LOADER,this))}destroy(){this._frameTask=n(this._frameTask),this._tasks.forEach((e=>i(e.abortController))),this._loadQueue=u(this._loadQueue),this._onLoadQueue.length=0,this._onLoadQueue=null,this._doneQueue.length=0,this._doneQueue=null,this._tasks.forEach((e=>e.destroy())),this._tasks.clear(),this._tasks=null}hasDownloadSlots(e){return this._loadQueue.hasQuota(e)}request(e,t,s,r={}){const o=l();return o.__signal=null!=r?r.signal:null,this._createOrUpdateTask(e,t,s,r,o),o.promise}_createTask(e,t,s,r,o,a){const n=new Q(e,t,s,r,o);return this._updateTask(n,a),this._tasks.set(o,n),1===this._tasks.size&&this._set("updating",!0),this._loadQueue.push(n),n}_cancelRequest(e,t){r(e.resolvers,t),t.reject(h()),0===e.resolvers.length&&(e.status===O.DOWNLOADING&&(e.status=O.CANCELLED,this._loadQueue.cancel(e),e.abortController?.abort(),e.request=null,e.abortController=null),e.status=O.CANCELLED,this._tasks.delete(e.key),0===this._tasks.size&&this._set("updating",!1))}_updateTask(e,t){e.resolvers.push(t)}_createOrUpdateTask(e,t,s,r,o){const a=E(r?.uid||e,t,s);let n=this._tasks.get(a);return n?(this._updateTask(n,o),n):(n=this._createTask(e,r,t,s,a,o),d(r,(()=>this._cancelRequest(n,o))),n)}_doneLoadingCB(e,t){this._loadQueue&&(D(e.status===O.DOWNLOADING),e.status=O.DOWNLOADED,this._frameTask?this._doneQueue.push({task:e,err:t}):this._doneLoading(e,t))}get running(){return this._doneQueue.length>0||this._onLoadQueue.length>0}runTask(e){for(;!e.done&&this._onLoadQueue.length>0;){const t=this._onLoadQueue.shift();c(t.task.abortController),t.task.abortController=null,t.callback(t.task),e.madeProgress()}for(;!e.done&&this._doneQueue.length>0;){const t=this._doneQueue.shift();t.task.status!==O.DOWNLOADED&&(t.err=t.err||h()),this._doneLoading(t.task,t.err),e.madeProgress()}}_doneLoading(e,t){if(t&&!p(t)&&e.numRetries>0)return--e.numRetries,void this._loadQueue.push(e);let s=L(e.result)||e.result instanceof HTMLImageElement?0:e.resolvers.length;for(const r of e.resolvers)if(t)p(t)?r.reject(t):r.reject(new o("stream-data-loader:request-error",`Failed to request resource at '${e.url}'. ${t}`,{url:e.url,error:t}));else{--s;const t=s>0?a(e.result):e.result;r.resolve(t)}this._tasks.delete(e.key),0===this._tasks.size&&this._set("updating",!1)}_startLoading(e,s){if(e.status===O.CANCELLED)return!1;let r,o;switch(e.startTime=performance.now(),e.status=O.DOWNLOADING,e.docType){case"binary":o="array-buffer",r=0;break;case"image":o="image";break;case"image+type":o="array-buffer";break;default:o="json"}e.abortController=new AbortController;const a=e.abortController.signal;e.request=t(e.url,{...e.options,responseType:o,timeout:r,signal:a});const n=t=>{e.duration=performance.now()-e.startTime,e.size=t instanceof ArrayBuffer?t.byteLength:e.size||0,e.result=t,this._frameTask?this._onLoadQueue.push({callback:s,task:e}):(e.abortController=null,s(e))},i=t=>{e.status===O.DOWNLOADING&&s(e,t)};return"image+type"!==e.docType?(e.request.then((e=>n(e.data)),i),!0):(e.request.then((s=>{const u=s.data,l=A(u);if(o="image",e.size=u.byteLength,"unknown"===l)return e.request=t(e.url,{responseType:o,timeout:r,signal:a}),void e.request.then((e=>n(e.data)),i);const h=new Blob([u],{type:l}),d=window.URL.createObjectURL(h);e.request=t(d,{responseType:o,timeout:r,signal:a}),e.request.then((e=>n(new k(e.data,l))),i).finally((()=>window.URL.revokeObjectURL(d)))}),i),!0)}get test(){}};e([m({readOnly:!0})],b.prototype,"updating",void 0),b=e([_("esri.views.3d.support.StreamDataLoader")],b);const T={numRetries:0};function A(e){if(e.byteLength<2)return"unknown";const t=new Uint8Array(e,0,e.byteLength);return 137===t[0]&&80===t[1]?"image/png":71===t[0]&&73===t[1]?"image/gif":66===t[0]&&77===t[1]?"image/bmp":255===t[0]&&216===t[1]?"image/jpeg":"unknown"}class Q extends f{constructor(e,t,s,r,o){super(r),this.url=e,this.options=t,this.docType=s,this.key=o,this.result=null,this.status=O.QUEUED,this.request=null,this.abortController=null,this.resolvers=new Array,this.startTime=0,this.numRetries=T.numRetries}destroy(){this.result=null,this.request=null,this.abortController=null,this.resolvers.length=0}}function E(e,t,s){return`${e}:${t}:${s}`}var O;!function(e){e[e.QUEUED=1]="QUEUED",e[e.DOWNLOADING=2]="DOWNLOADING",e[e.DOWNLOADED=3]="DOWNLOADED",e[e.CANCELLED=4]="CANCELLED"}(O||(O={}));export{b as StreamDataLoader,O as TaskStatus,T as test};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as t}from"../../../core/MapUtils.js";import{disposeMaybe as s}from"../../../core/maybe.js";import i from"../../../core/PooledArray.js";import{watch as n,on as o,syncAndInitial as a,initial as h}from"../../../core/reactiveUtils.js";import{someSet as l}from"../../../core/SetUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{ortho as u,fromTranslation as p}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{i as g}from"../../../chunks/vec32.js";import{ones as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{DrapeTargetType as m,DrapeSourceType as f,DrapedRenderGroup as y}from"../layers/interfaces.js";import{debugFlags as R}from"../support/debugFlags.js";import{OverlayIndex as b}from"./interfaces.js";import{Overlay as T}from"./Overlay.js";import{OverlayContent as w}from"./OverlayContent.js";import{OverlayRenderTargets as x}from"./OverlayRenderTargets.js";import D from"../webgl/RenderCamera.js";import{ShaderOutput as v}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as C}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as O}from"../../../chunks/TextureOnly.glsl.js";import{SyncRenderPlugin as S}from"../webgl-engine/effects/RenderPlugin.js";import{trackHighlightOptions as E,renderHighlightBuffer as P}from"../webgl-engine/effects/highlight/Highlight.js";import{RenderRequestType as j}from"../webgl-engine/lib/basicInterfaces.js";import{GLMaterialRepository as A}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as M}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as W}from"../webgl-engine/lib/Material.js";import{OITPass as I}from"../webgl-engine/lib/OITPass.js";import{RenderContext as q,defaultRenderOccludedMask as L}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as N}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as V}from"../webgl-engine/lib/ShadowMap.js";import{TextureTechnique as F}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as H}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{Update as k}from"../webgl-engine/lib/Update.js";import{UpdatePolicy as G}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as U}from"../webgl-engine/lighting/Lightsources.js";import{O as B}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as z}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as Y,noBudget as X}from"../../support/Scheduler.js";import{FramebufferBit as K,TextureSamplingMode as J}from"../../webgl/enums.js";import{Texture as Q}from"../../webgl/Texture.js";import{TextureDescriptor as Z}from"../../webgl/TextureDescriptor.js";let $=class extends S{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new B,this.hasHighlights=!1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new i,this._passParameters=new O,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new D,this.events=new r,this.longitudeCyclical=null,this.produces=new Map([[N.DRAPED_MATERIAL,e=>e!==v.Highlight||this.hasHighlights],[N.DRAPED_WATER,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1}initialize(){const e=this._view,r=e.stage,t=r.renderer.fboCache,{waterTextures:s,techniques:i}=r.renderView;this._renderContext=new q(this._rctx,new V(t,e.state.viewingMode),i),this.addHandles([n((()=>s.updating),(()=>this.events.emit("content-changed")),a),n((()=>this.spatialReference),(e=>this._localOriginFactory=new M(e)),a),o((()=>e.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0)),n((()=>E(e.state.highlights)),(()=>this._sortedDrapeSourceRenderersDirty=!0),h),n((()=>e.state.highlights),(r=>{this._bindParameters.highlights=r,this._bindParameters.highlightOrderMap=e.state.highlightOrderMap}),h),e.resourceController.scheduler.registerTask(Y.OVERLAY_RENDERER,this)]);const{_bindParameters:l,_camera:d}=this;d.near=1,d.far=1e4,d.relativeElevation=null,l.slot=N.DRAPED_MATERIAL,l.mainDepth=null,l.camera=d,l.oitPass=I.NONE,l.updateLighting([new U(_())],0,0,k.Immediate)}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._passParameters.texture=s(this._passParameters.texture),this.disposeOverlays()}get _bindParameters(){return this._renderContext.bind}get _rctx(){return this._stage.renderView.renderingContext}get _view(){return this.parent.view}get _stage(){return this.parent.view.stage}get spatialReference(){return this.parent.spatialReference}get _techniques(){return this._stage.renderView.techniques}get rctx(){return this._rctx}get materials(){return this._pluginContext.materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}get pluginContext(){return this._pluginContext}initializeRenderContext(e){const r=new A(this._view.stage.renderView.textures,this._techniques,(()=>{this.notifyChange("rendersOccludedDraped"),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed")));this._pluginContext={...e,materials:r},this._techniques.precompile(z)}uninitializeRenderContext(){}acquireTechniques(){return[]}render(){}get updating(){return this._sortedDrapeSourceRenderersDirty||t(this._renderers,(e=>e.updating||e.canCompact))}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMaterialRenderer(e){for(const r of this._renderers.values()){const t=r.getMaterialRenderer(e);if(t)return t}return null}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),this._sortedRenderers.map((e=>e.drapeSource.layer)).filter((e=>!!e))}registerDrapeSource(e,r){const t=this._renderers.get(e);null!=t&&t.destroy(),this._renderers.set(e,r),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(n((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e)}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(){this._renderTargets?.dispose()}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&l(e,(e=>e.drapeTargetType===m.WithoutRasterImage))}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=l(e,(e=>e.drapeSourceType===f.Features)),this._hasDrapedRasterSource=l(e,(e=>e.drapeSourceType===f.RasterImage))):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new x(this._stage.renderer.fboCache),this._overlays=[new T,new T]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets=s(this._renderTargets),this.events.emit("textures-disposed")}getTexture(e){return e===w.ColorNoRasterImage&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource?this._renderTargets?.getTexture(w.Color):this._renderTargets?.getTexture(e)}get running(){return this.updating}runTask(e){this._processDrapeSources(e,(()=>!0))}_processDrapeSources(e,r){let s=!1;for(const[t,i]of this._renderers){if(e.done)break;(t.destroyed||r(t))&&(i.commitChanges()&&(s=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,s=!0,this._updateSortedDrapeSourceRenderers(),e.madeProgress()),this.compact(e),s&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this.events.emit("content-changed"),this.hasHighlights=t(this._renderers,(e=>e.hasHighlights)),this.notifyChange("rendersOccludedDraped"))}compact(e){let r=!1;for(const t of this._renderers.values()){if(e.done)break;r=t.compact(e)||r}return r&&this.notifyChange("updating"),r}hasHighlight(e){return t(this._renderers,(r=>r.hasHighlight(e)))}processSyncDrapeSources(){this._processDrapeSources(X,(e=>e.updatePolicy===G.SYNC))}get isEmpty(){return!R.OVERLAY_DRAW_DEBUG_TEXTURE&&!t(this._renderers,(e=>!e.isEmpty))}get hasWater(){const e=t(this._renderers,(({hasWater:e})=>e));return e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water")),this._hasWater}get rendersOccludedDraped(){const e=this._renderContext.renderOccludedMask;this._renderContext.renderOccludedMask=se,++this._techniques.precompiling;const r=this._sortedRenderers.some((({renderer:e})=>e.precompile(this._renderContext)));return--this._techniques.precompiling,this._renderContext.renderOccludedMask=e,r}renders(e){if(R.OVERLAY_DRAW_DEBUG_TEXTURE&&e!==w.Occluded&&e!==w.Highlight)return!0;if(!this._overlays)return!1;const r=this._overlays[b.INNER];for(const i of this._overlays)i.setupGeometryViews(this.longitudeCyclical);if(!r.hasSomeSizedView())return!1;const t=this._renderContext.output;this._renderContext.output=this._renderTargets?.targets.find((r=>r.content===e))?.output??v.Color,++this._techniques.precompiling;const s=this._sortedRenderers.some((({renderer:e})=>e.precompile(this._renderContext)));return--this._techniques.precompiling,this._renderContext.output=t,s}get mode(){return this.isEmpty?C.Disabled:this.hasWater&&this.renders(w.WaterNormal)?C.EnabledWithWater:this._renderTargets?.getTexture(w.Color)?C.Enabled:C.Disabled}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r&&this.parent.requestRender(j.BACKGROUND),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}precompileShaders(e){if(!this._overlays||!this._renderTargets)return;const r=this._bindParameters;r.alignPixelEnabled=e.alignPixelEnabled,++this._techniques.precompiling;for(const t of this._renderTargets.targets){if(t.content===w.ColorNoRasterImage&&!this._needsColorWithoutRasterImage)continue;const e=t.output;this._renderContext.output=e,r.slot=e===v.Normal?N.DRAPED_WATER:N.DRAPED_MATERIAL,e===v.Highlight&&(r.highlightMixTexture=r.highlights.length>1?this._rctx.emptyTexture:null),t.content===w.Occluded&&(this._renderContext.renderOccludedMask=se),this._sortedRenderers.forAll((({drapeSource:e,renderer:r})=>{t.content===w.ColorNoRasterImage&&e.drapeSourceType===f.RasterImage||r.precompile(this._renderContext)})),this._renderContext.renderOccludedMask=L,r.highlightMixTexture=null}--this._techniques.precompiling}drawOverlays(e){if(this._overlays&&this._renderTargets){for(const e of this._overlays)e.setupGeometryViews(this.longitudeCyclical);this._bindParameters.alignPixelEnabled=e.alignPixelEnabled;for(const e of this._renderTargets.targets){if(e.content===w.ColorNoRasterImage&&!this._needsColorWithoutRasterImage)continue;const r=this._drawTarget(b.INNER,e),t=this._drawTarget(b.OUTER,e);(r||t)&&e.fbo.generateMipMap()}}}_drawTarget(e,r){const t=this._overlays[e],s=t.canvasGeometries;if(0===s.numViews)return!1;const i=this._view.state.contentPixelRatio;this._screenToWorldRatio=i*t.mapUnitsPerPixel/this._bindParameters.overlayStretch;const{output:n}=r;if(this.isEmpty||n===v.Normal&&!this.hasWater||!t.hasSomeSizedView())return!1;const{_rctx:o,_camera:a,_renderContext:h,_bindParameters:l}=this;if(a.pixelRatio=t.pixelRatio*i,h.output=n,l.screenToWorldRatio=this._screenToWorldRatio,l.screenToPCSRatio=this._screenToWorldRatio*this.parent.worldToPCSRatio,l.slot=n===v.Normal?N.DRAPED_WATER:N.DRAPED_MATERIAL,r.content===w.Occluded&&(h.renderOccludedMask=se),!this.renders(r.content))return h.renderOccludedMask=L,!1;const{resolution:d}=t,c=e===b.INNER,u=c?0:d;if(o.setViewport(u,0,d,d),this._bindTargetFBO(r),c)if(r.output!==v.Highlight)o.setClearColor(0,0,0,0),o.clear(K.COLOR);else{const{gl:e}=o;e.clearBufferuiv(e.COLOR,0,[0,0,0,0])}if(R.OVERLAY_DRAW_DEBUG_TEXTURE&&r.content!==w.Occluded&&r.content!==w.Highlight){this._techniques.precompile(F,ie);const r=this._techniques.get(F,ie);for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],t),this._ensureDebugPatternResources(t.resolution,re[e]),o.bindTechnique(r,l,this._passParameters),o.screen.draw()}if(r.output===v.Highlight){const{fboCache:t}=this._stage.renderer,s=this._resolution;this._bindTargetFBO(r),P(o,t,{width:s,height:s},l,(()=>this._renderAllGeometry(e,r)),u)}else this._renderAllGeometry(e,r);return o.bindFramebuffer(null),h.renderOccludedMask=L,!0}_renderAllGeometry(e,r){const t=this._overlays[e],s=t.canvasGeometries;this._sortedRenderers.forAll((({drapeSource:i,renderer:n})=>{if(r.content===w.ColorNoRasterImage&&i.drapeSourceType===f.RasterImage)return;const{fullOpacity:o}=i,a=null!=o&&o<1&&r.output===v.Color&&this._bindTemporaryFBO();for(let e=0;e<s.numViews;e++)this._setViewParameters(s.extents[e],t),n.render(this._renderContext);if(a){this._bindTargetFBO(r),this._overlayParameters.texture=a.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const t=this._techniques.get(z);this._rctx.bindTechnique(t,this._bindParameters,this._overlayParameters),this._rctx.screen.draw(),a.release()}}))}_bindTargetFBO(e){const r=this._resolution,t=2*r;e.fbo.bind(this._rctx,t,r)}_bindTemporaryFBO(){const e=this._resolution,r=2*e,t=this._stage.renderer.fboCache,s=t.acquire(r,e,"overlay tmp");return t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(K.COLOR),s}get _resolution(){return this._overlays?.[b.INNER].resolution??0}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:n}of this._sortedRenderers)i=n.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this._view.map.allLayers,r=e.length;this._renderers.forEach(((t,s)=>{const i=e.indexOf(s.layer),n=i>=0,o=s.renderGroup??(n?y.MapLayer:y.ViewLayer),a=s.drapeSourcePriorityOffset??0,h=r*o+(n?i:0)+a;this._sortedRenderers.push(new ee(s,t,h))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],u(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),p(t.viewMatrix,[-e[0],-e[1],0])}_ensureDebugPatternResources(e,r){if(g(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let n=0;n<e;n++)for(let r=0;r<e;r++){const i=Math.floor(r/10),o=Math.floor(n/10);i<2||o<2||10*i>e-20||10*o>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&o?1&r^1&n?0:255:1&i^1&o?0:128)}const i=new Z(e);i.samplingMode=J.NEAREST,this._passParameters.texture=new Q(this._rctx,i,t)}get test(){}};e([d()],$.prototype,"hasHighlights",void 0),e([d()],$.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([d({constructOnly:!0})],$.prototype,"parent",void 0),e([d({readOnly:!0})],$.prototype,"_techniques",null),e([d({type:Boolean,readOnly:!0})],$.prototype,"updating",null),e([d()],$.prototype,"isEmpty",null),e([d({readOnly:!0})],$.prototype,"rendersOccludedDraped",null),$=e([c("esri.views.3d.terrain.OverlayRenderer")],$);class ee{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const re=[[1,.5,.5],[.5,.5,1]],te=-2,se=W.OccludeAndTransparent,ie=new H;ie.hasAlpha=!0;export{$ as OverlayRenderer,te as drapedZ,se as overlayRenderOccludedFlag};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as t}from"../../../core/MapUtils.js";import{disposeMaybe as s}from"../../../core/maybe.js";import i from"../../../core/PooledArray.js";import{watch as n,on as o,syncAndInitial as a,initial as h}from"../../../core/reactiveUtils.js";import{someSet as l}from"../../../core/SetUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{ortho as u,fromTranslation as p}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{i as g}from"../../../chunks/vec32.js";import{ones as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{DrapeTargetType as m,DrapeSourceType as f,DrapedRenderGroup as y}from"../layers/interfaces.js";import{debugFlags as R}from"../support/debugFlags.js";import{OverlayIndex as b}from"./interfaces.js";import{Overlay as T}from"./Overlay.js";import{OverlayContent as x}from"./OverlayContent.js";import{OverlayRenderTargets as w}from"./OverlayRenderTargets.js";import D from"../webgl/RenderCamera.js";import{ShaderOutput as v}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as C}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as O}from"../../../chunks/TextureOnly.glsl.js";import{SyncRenderPlugin as S}from"../webgl-engine/effects/RenderPlugin.js";import{trackHighlightOptions as E,renderHighlightBuffer as P}from"../webgl-engine/effects/highlight/Highlight.js";import{RenderRequestType as j}from"../webgl-engine/lib/basicInterfaces.js";import{GLMaterialRepository as A}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as M}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as W}from"../webgl-engine/lib/Material.js";import{OITPass as I}from"../webgl-engine/lib/OITPass.js";import{RenderContext as q,defaultRenderOccludedMask as L}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as N}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as V}from"../webgl-engine/lib/ShadowMap.js";import{TextureTechnique as F}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as H}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{Update as k}from"../webgl-engine/lib/Update.js";import{UpdatePolicy as G}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as U}from"../webgl-engine/lighting/Lightsources.js";import{O as B}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as z}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as Y,noBudget as X}from"../../support/Scheduler.js";import{FramebufferBit as K,TextureSamplingMode as J}from"../../webgl/enums.js";import{Texture as Q}from"../../webgl/Texture.js";import{TextureDescriptor as Z}from"../../webgl/TextureDescriptor.js";let $=class extends S{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new B,this.hasHighlights=!1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new i,this._passParameters=new O,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new D,this.events=new r,this.longitudeCyclical=null,this.produces=new Map([[N.DRAPED_MATERIAL,e=>e!==v.Highlight||this.hasHighlights],[N.DRAPED_WATER,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1}initialize(){const e=this._view,r=e.stage,t=r.renderer.fboCache,{waterTextures:s,techniques:i}=r.renderView;this._renderContext=new q(this._rctx,new V(t,e.state.viewingMode),i),this.addHandles([n((()=>s.updating),(()=>this.events.emit("content-changed")),a),n((()=>this.spatialReference),(e=>this._localOriginFactory=new M(e)),a),o((()=>e.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0)),n((()=>E(e.state.highlights)),(()=>this._sortedDrapeSourceRenderersDirty=!0),h),n((()=>e.state.highlights),(r=>{this._bindParameters.highlights=r,this._bindParameters.highlightOrderMap=e.state.highlightOrderMap}),h),e.resourceController.scheduler.registerTask(Y.OVERLAY_RENDERER,this)]);const{_bindParameters:l,_camera:d}=this;d.near=1,d.far=1e4,d.relativeElevation=null,l.slot=N.DRAPED_MATERIAL,l.mainDepth=null,l.camera=d,l.oitPass=I.NONE,l.updateLighting([new U(_())],0,0,k.Immediate)}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._passParameters.texture=s(this._passParameters.texture),this.disposeOverlays(),this._renderContext=null,this._sortedRenderers.prune()}get _bindParameters(){return this._renderContext.bind}get _rctx(){return this._stage.renderView.renderingContext}get _view(){return this.parent.view}get _stage(){return this.parent.view.stage}get spatialReference(){return this.parent.spatialReference}get _techniques(){return this._stage.renderView.techniques}get rctx(){return this._rctx}get materials(){return this._pluginContext.materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}get pluginContext(){return this._pluginContext}initializeRenderContext(e){const r=new A(this._view.stage.renderView.textures,this._techniques,(()=>{this.notifyChange("rendersOccludedDraped"),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed")));this._pluginContext={...e,materials:r},this._techniques.precompile(z)}uninitializeRenderContext(){}acquireTechniques(){return[]}render(){}get updating(){return this._sortedDrapeSourceRenderersDirty||t(this._renderers,(e=>e.updating||e.canCompact))}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMaterialRenderer(e){for(const r of this._renderers.values()){const t=r.getMaterialRenderer(e);if(t)return t}return null}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),this._sortedRenderers.map((e=>e.drapeSource.layer)).filter((e=>!!e))}registerDrapeSource(e,r){const t=this._renderers.get(e);null!=t&&t.destroy(),this._renderers.set(e,r),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(n((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e)}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(){this._renderTargets?.dispose()}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&l(e,(e=>e.drapeTargetType===m.WithoutRasterImage))}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=l(e,(e=>e.drapeSourceType===f.Features)),this._hasDrapedRasterSource=l(e,(e=>e.drapeSourceType===f.RasterImage))):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new w(this._stage.renderer.fboCache),this._overlays=[new T,new T]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets=s(this._renderTargets),this.events.emit("textures-disposed")}getTexture(e){return e===x.ColorNoRasterImage&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource?this._renderTargets?.getTexture(x.Color):this._renderTargets?.getTexture(e)}get running(){return this.updating}runTask(e){this._processDrapeSources(e,(()=>!0))}_processDrapeSources(e,r){let s=!1;for(const[t,i]of this._renderers){if(e.done)break;(t.destroyed||r(t))&&(i.commitChanges()&&(s=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,s=!0,this._updateSortedDrapeSourceRenderers(),e.madeProgress()),this.compact(e),s&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this.events.emit("content-changed"),this.hasHighlights=t(this._renderers,(e=>e.hasHighlights)),this.notifyChange("rendersOccludedDraped"))}compact(e){let r=!1;for(const t of this._renderers.values()){if(e.done)break;r=t.compact(e)||r}return r&&this.notifyChange("updating"),r}hasHighlight(e){return t(this._renderers,(r=>r.hasHighlight(e)))}processSyncDrapeSources(){this._processDrapeSources(X,(e=>e.updatePolicy===G.SYNC))}get isEmpty(){return!R.OVERLAY_DRAW_DEBUG_TEXTURE&&!t(this._renderers,(e=>!e.isEmpty))}get hasWater(){const e=t(this._renderers,(({hasWater:e})=>e));return e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water")),this._hasWater}get rendersOccludedDraped(){const e=this._renderContext.renderOccludedMask;this._renderContext.renderOccludedMask=se,++this._techniques.precompiling;const r=this._sortedRenderers.some((({renderer:e})=>e.precompile(this._renderContext)));return--this._techniques.precompiling,this._renderContext.renderOccludedMask=e,r}renders(e){if(R.OVERLAY_DRAW_DEBUG_TEXTURE&&e!==x.Occluded&&e!==x.Highlight)return!0;if(!this._overlays)return!1;const r=this._overlays[b.INNER];for(const i of this._overlays)i.setupGeometryViews(this.longitudeCyclical);if(!r.hasSomeSizedView())return!1;const t=this._renderContext.output;this._renderContext.output=this._renderTargets?.targets.find((r=>r.content===e))?.output??v.Color,++this._techniques.precompiling;const s=this._sortedRenderers.some((({renderer:e})=>e.precompile(this._renderContext)));return--this._techniques.precompiling,this._renderContext.output=t,s}get mode(){return this.isEmpty?C.Disabled:this.hasWater&&this.renders(x.WaterNormal)?C.EnabledWithWater:this._renderTargets?.getTexture(x.Color)?C.Enabled:C.Disabled}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r&&this.parent.requestRender(j.BACKGROUND),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}precompileShaders(e){if(!this._overlays||!this._renderTargets)return;const r=this._bindParameters;r.alignPixelEnabled=e.alignPixelEnabled,++this._techniques.precompiling;for(const t of this._renderTargets.targets){if(t.content===x.ColorNoRasterImage&&!this._needsColorWithoutRasterImage)continue;const e=t.output;this._renderContext.output=e,r.slot=e===v.Normal?N.DRAPED_WATER:N.DRAPED_MATERIAL,e===v.Highlight&&(r.highlightMixTexture=r.highlights.length>1?this._rctx.emptyTexture:null),t.content===x.Occluded&&(this._renderContext.renderOccludedMask=se),this._sortedRenderers.forAll((({drapeSource:e,renderer:r})=>{t.content===x.ColorNoRasterImage&&e.drapeSourceType===f.RasterImage||r.precompile(this._renderContext)})),this._renderContext.renderOccludedMask=L,r.highlightMixTexture=null}--this._techniques.precompiling}drawOverlays(e){if(this._overlays&&this._renderTargets){for(const e of this._overlays)e.setupGeometryViews(this.longitudeCyclical);this._bindParameters.alignPixelEnabled=e.alignPixelEnabled;for(const e of this._renderTargets.targets){if(e.content===x.ColorNoRasterImage&&!this._needsColorWithoutRasterImage)continue;const r=this._drawTarget(b.INNER,e),t=this._drawTarget(b.OUTER,e);(r||t)&&e.fbo.generateMipMap()}}}_drawTarget(e,r){const t=this._overlays[e],s=t.canvasGeometries;if(0===s.numViews)return!1;const i=this._view.state.contentPixelRatio;this._screenToWorldRatio=i*t.mapUnitsPerPixel/this._bindParameters.overlayStretch;const{output:n}=r;if(this.isEmpty||n===v.Normal&&!this.hasWater||!t.hasSomeSizedView())return!1;const{_rctx:o,_camera:a,_renderContext:h,_bindParameters:l}=this;if(a.pixelRatio=t.pixelRatio*i,h.output=n,l.screenToWorldRatio=this._screenToWorldRatio,l.screenToPCSRatio=this._screenToWorldRatio*this.parent.worldToPCSRatio,l.slot=n===v.Normal?N.DRAPED_WATER:N.DRAPED_MATERIAL,r.content===x.Occluded&&(h.renderOccludedMask=se),!this.renders(r.content))return h.renderOccludedMask=L,!1;const{resolution:d}=t,c=e===b.INNER,u=c?0:d;if(o.setViewport(u,0,d,d),this._bindTargetFBO(r),c)if(r.output!==v.Highlight)o.setClearColor(0,0,0,0),o.clear(K.COLOR);else{const{gl:e}=o;e.clearBufferuiv(e.COLOR,0,[0,0,0,0])}if(R.OVERLAY_DRAW_DEBUG_TEXTURE&&r.content!==x.Occluded&&r.content!==x.Highlight){this._techniques.precompile(F,ie);const r=this._techniques.get(F,ie);for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],t),this._ensureDebugPatternResources(t.resolution,re[e]),o.bindTechnique(r,l,this._passParameters),o.screen.draw()}if(r.output===v.Highlight){const{fboCache:t}=this._stage.renderer,s=this._resolution;this._bindTargetFBO(r),P(o,t,{width:s,height:s},l,(()=>this._renderAllGeometry(e,r)),u)}else this._renderAllGeometry(e,r);return o.bindFramebuffer(null),h.renderOccludedMask=L,!0}_renderAllGeometry(e,r){const t=this._overlays[e],s=t.canvasGeometries;this._sortedRenderers.forAll((({drapeSource:i,renderer:n})=>{if(r.content===x.ColorNoRasterImage&&i.drapeSourceType===f.RasterImage)return;const{fullOpacity:o}=i,a=null!=o&&o<1&&r.output===v.Color&&this._bindTemporaryFBO();for(let e=0;e<s.numViews;e++)this._setViewParameters(s.extents[e],t),n.render(this._renderContext);if(a){this._bindTargetFBO(r),this._overlayParameters.texture=a.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const t=this._techniques.get(z);this._rctx.bindTechnique(t,this._bindParameters,this._overlayParameters),this._rctx.screen.draw(),a.release()}}))}_bindTargetFBO(e){const r=this._resolution,t=2*r;e.fbo.bind(this._rctx,t,r)}_bindTemporaryFBO(){const e=this._resolution,r=2*e,t=this._stage.renderer.fboCache,s=t.acquire(r,e,"overlay tmp");return t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(K.COLOR),s}get _resolution(){return this._overlays?.[b.INNER].resolution??0}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:n}of this._sortedRenderers)i=n.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this._view.map.allLayers,r=e.length;this._renderers.forEach(((t,s)=>{const i=e.indexOf(s.layer),n=i>=0,o=s.renderGroup??(n?y.MapLayer:y.ViewLayer),a=s.drapeSourcePriorityOffset??0,h=r*o+(n?i:0)+a;this._sortedRenderers.push(new ee(s,t,h))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],u(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),p(t.viewMatrix,[-e[0],-e[1],0])}_ensureDebugPatternResources(e,r){if(g(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let n=0;n<e;n++)for(let r=0;r<e;r++){const i=Math.floor(r/10),o=Math.floor(n/10);i<2||o<2||10*i>e-20||10*o>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&o?1&r^1&n?0:255:1&i^1&o?0:128)}const i=new Z(e);i.samplingMode=J.NEAREST,this._passParameters.texture=new Q(this._rctx,i,t)}get test(){}};e([d()],$.prototype,"hasHighlights",void 0),e([d()],$.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([d({constructOnly:!0})],$.prototype,"parent",void 0),e([d({readOnly:!0})],$.prototype,"_techniques",null),e([d({type:Boolean,readOnly:!0})],$.prototype,"updating",null),e([d()],$.prototype,"isEmpty",null),e([d({readOnly:!0})],$.prototype,"rendersOccludedDraped",null),$=e([c("esri.views.3d.terrain.OverlayRenderer")],$);class ee{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const re=[[1,.5,.5],[.5,.5,1]],te=-2,se=W.OccludeAndTransparent,ie=new H;ie.hasAlpha=!0;export{$ as OverlayRenderer,te as drapedZ,se as overlayRenderOccludedFlag};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import has from"../../../core/has.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{MemCachePool as r}from"../../../core/MemCachePool.js";import s from"../../../core/ObjectPool.js";import{watch as n,sync as a}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{d as c,i as d,e as h}from"../../../chunks/vec32.js";import{ZEROS as u,create as g,fromValues as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as _,ZEROS as f}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as m,set as b}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as T}from"../../ViewingMode.js";import{TextureUpdate as O}from"./interfaces.js";import{LayerClass as R}from"./LayerClass.js";import{OverlayContent as x}from"./OverlayContent.js";import{overlayRenderOccludedFlag as v}from"./OverlayRenderer.js";import{PatchRenderData as w}from"./PatchRenderData.js";import{RenderOrder as P}from"./RenderOrder.js";import{TerrainAttributesCache as D}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as S}from"./terrainUtils.js";import{TileRenderer as C}from"./TileRenderer.js";import{TileUpdate as E}from"./TileUpdate.js";import{IteratorPreorder as j,sortTiles as A,compareTiles as N}from"./tileUtils.js";import{TransparencyMode as B}from"./TransparencyMode.js";import{componentMinimalSizeForIntersectionData as I,ComponentIntersectionData as U}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as G}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{TileBlendInput as F}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{SyncRenderPlugin as q,ConsumesDepth as M,ConsumesNone as k}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as L}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as z}from"../webgl-engine/lib/basicInterfaces.js";import{StoreResults as V}from"../webgl-engine/lib/IntersectorInterfaces.js";import{IntersectorResult as H}from"../webgl-engine/lib/IntersectorResult.js";import{IntersectorType as Y}from"../webgl-engine/lib/IntersectorType.js";import{RenderOccludedFlag as Q}from"../webgl-engine/lib/Material.js";import{intersectAabbInvDirBefore as W,MeshIntersectionOptions as X,intersectTriangles as K}from"../webgl-engine/lib/RayIntersections.js";import{RenderSlot as Z}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as J}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as $}from"../webgl-engine/lib/VertexAttribute.js";import{terrainId as ee,getVerticalOffsetTerrain as te}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as ie}from"../webgl-engine/materials/DrawParameters.js";import{T as re}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as se}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as ne}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as ae}from"../../webgl/enums.js";const oe=7,le=10,ce=m();let de=class extends q{get _isGlobal(){return this._stage.viewingMode===T.Global}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}constructor(e,t,i,n,a,o){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._ellipsoidRadius=n,this._compressionTracker=a,this.type=Y.TERRAIN,this.isGround=!0,this._passParameters=new re,this._drawParameters=new ie,this._renderDataPool=new s(w),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new j,this._castShadows=!1,this._inViewshed=!1,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=Q.Occlude,this.produces=new Map([[Z.OPAQUE_TERRAIN,()=>this._produces()&&this.transparency===B.Opaque],[Z.TRANSPARENT_TERRAIN,()=>this._produces()&&(this.transparency===B.Transparent||this.transparency===B.InvisibleWithDraped)],[Z.OCCLUDED_GROUND,()=>this._produces()&&this.renderOccludedFlags===v]]),this._tileSize=256,this._configuration=new ne(t.viewingMode===T.Global),this._tileTextureCache=new r(((e,t)=>o.newCache(e,t)),"TileTexture"),this.tileGeometryCache=new D(o)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n((()=>this._overlayRenderer.rendersOccludedDraped),(e=>{this.renderOccludedFlags=e?v:Q.Occlude,this.setNeedsRender()}),a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy()}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(){return this._overlayRenderer.hasWater?M:k}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return this._configuration.visualizeNormals}set visualizeNormals(e){this._configuration.visualizeNormals!==e&&(this._configuration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._configuration.backfaceCullingEnabled}set cullBackFaces(e){this._configuration.backfaceCullingEnabled!==e&&(this._configuration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerViewUid(){return ee}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._configuration.screenSizePerspective!==e&&(this._configuration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,E.TEXTURE_FADING)}reuseTextureFromParent(e){const t=e.parent;if(!t)return!1;const i=_(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===E.TEXTURE_FADING?O.FADING:O.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[R.ELEVATION])i.pendingUpdates&=~E.GEOMETRY;e.resetPendingUpdate(E.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=le-oe,i=Math.max(0,Math.floor((e.level-t)/oe)*oe);if(this._isGlobal&&0===i)return u;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=z.UPDATE){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=z.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=z.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new C(this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=i(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==B.Opaque)return;const s=he,n=ue;c(s,r,i),d(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,o=e.results.max,l=e.results.ground,u=e.options.store===V.MIN,g=!!e.results.ground.target,p=te(e.verticalOffset),_=e.tolerance;let f,m=u&&null!=a.distance?a.distance:1/0;const T=e.options,O=T.normalRequired||!T.backfacesTerrain,R=new X(!1,O),x=d=>{const g=d.renderData;if(!g?.vao)return;const x=g.geometry;b(ce,x.boundingBox);const v=g.localOrigin;null!=p&&(p.localOrigin=v,p.applyToAabb(ce));const w=ce;if(ge[0]=i[0]-v[0],ge[1]=i[1]-v[1],ge[2]=i[2]-v[2],!W(w,ge,n,_,m))return;const P=(e,t,i)=>{e.set(this.type,d,t,i),m=u&&null!=a.distance?a.distance:1/0},D=(n,c,d)=>{if((!O||null!=d)&&n>=0&&(T.backfacesTerrain||h(d,s)<0)&&(T.invisibleTerrain||!T.selectionMode||null==t||t(i,r,n))){if((null==l.distance||n<l.distance)&&P(l,n,d),T.isFiltered)return;T.store===V.ALL&&(null==f?(f=new H(e.ray),P(f,n,d),e.results.all.push(f)):n<f.distance&&P(f,n,d)),(null==a.distance||n<a.distance)&&P(a,n,d),T.store!==V.MIN&&(null==o.distance||n>o.distance)&&P(o,n,d)}},S=pe;c(S,r,v);const{indices:C,indexCount:E}=x,j=x.vertexAttributes,A=j.getField($.POSITION,y),N=new L(A.typedBuffer,3,j.stride/4),B=E/3;if(!p&&B>I){const e=d.renderData;null==e.intersectionData&&(e.intersectionData=new U(C,0,B,N)),e.intersectionData.intersectRay(ge,S,R,D)}else K(ge,S,0,B,C,N,p,R,D)},v=this._rootTiles;if(null!=v){(()=>{const t=this._tileIterator;t.reset(v);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==p&&!e.intersectsRay(i,s,_,m)||g&&this._useStencilForTile(e)?t.skipSubtree():x(e)})()}}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}acquireTechniques(e){const t=!!has("enable-feature:terrain-shadows")&&e.bind.shadowMap.enabled;t!==this._castShadows&&(this._castShadows=t,this._patchesByOriginDirty=!0);const i=e.bind.viewshedEnabled;if(this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),e.bind.slot===Z.OCCLUDED_GROUND){if(0===(e.renderOccludedMask&v))return null}else{const t=this.transparency===B.Opaque?Z.OPAQUE_TERRAIN:Z.TRANSPARENT_TERRAIN;if(e.bind.slot!==t)return null}if(this.transparency===B.Invisible)return null;const r=this._configuration;switch(r.screenSpaceReflections=r.cloudReflections=r.receiveShadows=r.receiveAmbientOcclusion=r.renderOccluded=r.hasHighlightMixTexture=!1,r.overlayMode=this._overlayRenderer.mode,e.output){case G.Color:case G.ColorEmission:{r.screenSpaceReflections=null!=e.bind.ssr.lastFrameColor,r.cloudReflections=null!=e.bind.clouds.data,r.receiveShadows=e.bind.shadowMap.ready;const t=e.bind.slot===Z.OCCLUDED_GROUND;return r.renderOccluded=t,r.receiveAmbientOcclusion=!t&&null!=e.bind.ssao,this._acquireTechnique(e.output)}case G.Shadow:case G.ShadowExcludeHighlight:return this._castShadows?this._acquireTechnique(G.Shadow):null;case G.ViewshedShadow:return this._inViewshed?this._acquireTechnique(G.ViewshedShadow):null;case G.Depth:case G.Normal:return this._acquireTechnique(e.output);case G.ObjectAndLayerIdColor:return this._acquireTechnique(G.ObjectAndLayerIdColor);case G.Highlight:return r.hasHighlightMixTexture=null!=e.bind.highlightMixTexture,this._overlayRenderer.hasHighlights?this._acquireTechnique(G.Highlight):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case G.Color:case G.ColorEmission:{const i=e.bind.slot===Z.OCCLUDED_GROUND?x.Occluded:x.Color;this._renderMaterialPass(e,t,i);break}case G.Depth:case G.Normal:this._renderAuxiliaryPass(e,t,x.Color,this._visiblePatchesByOrigin);break;case G.Highlight:{const i=e.bind.highlight?.name;i&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(x.Highlight)&&this._overlayRenderer.hasHighlight(i)&&this._renderAuxiliaryPass(e,t,x.Highlight,this._visiblePatchesByOrigin);break}case G.Shadow:case G.ShadowExcludeHighlight:case G.ViewshedShadow:this._renderAuxiliaryPass(e,t,null,this._allPatchesByOrigin);break;case G.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,x.ObjectAndLayerIdColor,this._visiblePatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r;if(null!=e){const i=t.toUnitRGBA(e);r=p(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll((e=>i.updateTileTexture(e,O.FADING))),this._configuration.tileBlendInput=i.backgroundIsGrid?F.GridComposite:null!=i.backgroundColor?F.ColorComposite:F.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==P.NONE){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)A(this.renderOrder,i,t);e.sort(((e,t)=>N(e[0],t[0],this.renderOrder))),this._visiblePatchesByOrigin=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i,r){const s=e.rctx;this._passParameters.overlayContent=i,s.bindTechnique(t,e.bind,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;r.forEach((r=>{this._drawParameters.origin=r[0].renderData.localOrigin,t.program.bindDraw(e.bind,this._passParameters,this._drawParameters);for(let s=0;s<r.length;s++)this._renderPatch(e,t,r[s],ae.TRIANGLES,n,i)})),e.rctx.bindVAO(null)}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlayContent=i,r.bindTechnique(t,e.bind,this._passParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const s=e.bind.camera,n=t.program;if(this._configuration.screenSizePerspective&&this.pointsOfInterest){const e=J(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:s.fovY})}const a=this._stencilEnabledLayerExtents.length>0,o=i===x.Occluded;o&&(n.bindTexture("tex",r.emptyTexture),n.setUniform3fv("textureOpacities",u),n.setUniform4fv("texOffsetAndScale",f));const l=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:u;this._configuration.tileBlendInput===F.ColorComposite&&n.setUniform3fv("backgroundColor",l);const c=this.wireframe?ae.LINES:ae.TRIANGLES;this._configuration.textureFadingEnabled&&n.bindTexture("texNext",r.emptyTexture);const d=this._visiblePatchesByOrigin;for(const h of d.values()){const r=h[0].renderData.localOrigin;this._drawParameters.origin=r,t.program.bindDraw(e.bind,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const s of h){const r=s.renderData,l=r.textureReference;if(null!=l){if(!o){n.setUniform4fv("texOffsetAndScale",l.offsetAndScale),n.bindTexture("tex",l.texture.texture);const e=r.textureFadeFactor,t=e<1?r.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(n.setUniform1f("fadeFactor",e),n.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),n.setUniform3fv("nextTexOpacities",t.opacities),n.bindTexture("texNext",t.texture.texture)):n.setUniform1f("fadeFactor",1),r.textureIsFading&&this.setNeedsRender(),n.setUniform3fv("textureOpacities",l.opacities)}this._renderPatch(e,t,s,c,a,i),s.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,i,r,s,n){const a=i.renderData,o=a.vao,l=o?.indexBuffer;if(!o||null==l)return void(S&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;null==n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay),s&&(t.useStencil=this._useStencilForTile(i),e.rctx.setPipelineState(t.getPipeline()));const d=a.geometry.indexCount;e.rctx.bindVAO(o),c.assertCompatibleVertexAttributeLocations(o),e.rctx.drawElements(r,d,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_acquireTechnique(e){return this._configuration.output=e,this._techniques.get(se,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([o({readOnly:!0})],de.prototype,"_isGlobal",null),e([o()],de.prototype,"renderOccludedFlags",void 0),e([o({value:!1})],de.prototype,"renderingDisabled",null),e([o({value:!0})],de.prototype,"visible",null),e([o()],de.prototype,"renderPatchBorders",null),e([o()],de.prototype,"visualizeNormals",null),e([o()],de.prototype,"cullBackFaces",null),e([o({value:P.FRONT_TO_BACK})],de.prototype,"renderOrder",null),e([o()],de.prototype,"wireframe",null),de=e([l("esri.views.3d.terrain.TerrainRenderer")],de);const he=g(),ue=g(),ge=g(),pe=g();export{de as TerrainRenderer};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import has from"../../../core/has.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{MemCachePool as r}from"../../../core/MemCachePool.js";import s from"../../../core/ObjectPool.js";import{watch as n,sync as a}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{d as c,i as d,e as h}from"../../../chunks/vec32.js";import{ZEROS as u,create as g,fromValues as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as _,ZEROS as f}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as m,set as b}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as T}from"../../ViewingMode.js";import{TextureUpdate as R}from"./interfaces.js";import{LayerClass as O}from"./LayerClass.js";import{OverlayContent as x}from"./OverlayContent.js";import{overlayRenderOccludedFlag as v}from"./OverlayRenderer.js";import{PatchRenderData as w}from"./PatchRenderData.js";import{RenderOrder as P}from"./RenderOrder.js";import{TerrainAttributesCache as D}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as S}from"./terrainUtils.js";import{TileRenderer as C}from"./TileRenderer.js";import{TileUpdate as E}from"./TileUpdate.js";import{IteratorPreorder as j,sortTiles as A,compareTiles as N}from"./tileUtils.js";import{TransparencyMode as B}from"./TransparencyMode.js";import{componentMinimalSizeForIntersectionData as I,ComponentIntersectionData as U}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as G}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{TileBlendInput as F}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{SyncRenderPlugin as q,ConsumesDepth as M,ConsumesNone as k}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as L}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as z}from"../webgl-engine/lib/basicInterfaces.js";import{StoreResults as V}from"../webgl-engine/lib/IntersectorInterfaces.js";import{IntersectorResult as H}from"../webgl-engine/lib/IntersectorResult.js";import{IntersectorType as Y}from"../webgl-engine/lib/IntersectorType.js";import{RenderOccludedFlag as Q}from"../webgl-engine/lib/Material.js";import{intersectAabbInvDirBefore as W,MeshIntersectionOptions as X,intersectTriangles as K}from"../webgl-engine/lib/RayIntersections.js";import{RenderSlot as Z}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as J}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as $}from"../webgl-engine/lib/VertexAttribute.js";import{terrainId as ee,getVerticalOffsetTerrain as te}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as ie}from"../webgl-engine/materials/DrawParameters.js";import{T as re}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as se}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as ne}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as ae}from"../../webgl/enums.js";const oe=7,le=10,ce=m();let de=class extends q{get _isGlobal(){return this._stage.viewingMode===T.Global}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}constructor(e,t,i,n,a,o){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._ellipsoidRadius=n,this._compressionTracker=a,this.type=Y.TERRAIN,this.isGround=!0,this._passParameters=new re,this._drawParameters=new ie,this._renderDataPool=new s(w),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new j,this._castShadows=!1,this._inViewshed=!1,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=Q.Occlude,this.produces=new Map([[Z.OPAQUE_TERRAIN,()=>this._produces()&&this.transparency===B.Opaque],[Z.TRANSPARENT_TERRAIN,()=>this._produces()&&(this.transparency===B.Transparent||this.transparency===B.InvisibleWithDraped)],[Z.OCCLUDED_GROUND,()=>this._produces()&&this.renderOccludedFlags===v]]),this._tileSize=256,this._configuration=new ne(t.viewingMode===T.Global),this._tileTextureCache=new r(((e,t)=>o.newCache(e,t)),"TileTexture"),this.tileGeometryCache=new D(o)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n((()=>this._overlayRenderer.rendersOccludedDraped),(e=>{this.renderOccludedFlags=e?v:Q.Occlude,this.setNeedsRender()}),a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(){return this._overlayRenderer.hasWater?M:k}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return this._configuration.visualizeNormals}set visualizeNormals(e){this._configuration.visualizeNormals!==e&&(this._configuration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._configuration.backfaceCullingEnabled}set cullBackFaces(e){this._configuration.backfaceCullingEnabled!==e&&(this._configuration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerViewUid(){return ee}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._configuration.screenSizePerspective!==e&&(this._configuration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,E.TEXTURE_FADING)}reuseTextureFromParent(e){const t=e.parent;if(!t)return!1;const i=_(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===E.TEXTURE_FADING?R.FADING:R.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[O.ELEVATION])i.pendingUpdates&=~E.GEOMETRY;e.resetPendingUpdate(E.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=le-oe,i=Math.max(0,Math.floor((e.level-t)/oe)*oe);if(this._isGlobal&&0===i)return u;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=z.UPDATE){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=z.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=z.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new C(this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=i(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==B.Opaque)return;const s=he,n=ue;c(s,r,i),d(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,o=e.results.max,l=e.results.ground,u=e.options.store===V.MIN,g=!!e.results.ground.target,p=te(e.verticalOffset),_=e.tolerance;let f,m=u&&null!=a.distance?a.distance:1/0;const T=e.options,R=T.normalRequired||!T.backfacesTerrain,O=new X(!1,R),x=d=>{const g=d.renderData;if(!g?.vao)return;const x=g.geometry;b(ce,x.boundingBox);const v=g.localOrigin;null!=p&&(p.localOrigin=v,p.applyToAabb(ce));const w=ce;if(ge[0]=i[0]-v[0],ge[1]=i[1]-v[1],ge[2]=i[2]-v[2],!W(w,ge,n,_,m))return;const P=(e,t,i)=>{e.set(this.type,d,t,i),m=u&&null!=a.distance?a.distance:1/0},D=(n,c,d)=>{if((!R||null!=d)&&n>=0&&(T.backfacesTerrain||h(d,s)<0)&&(T.invisibleTerrain||!T.selectionMode||null==t||t(i,r,n))){if((null==l.distance||n<l.distance)&&P(l,n,d),T.isFiltered)return;T.store===V.ALL&&(null==f?(f=new H(e.ray),P(f,n,d),e.results.all.push(f)):n<f.distance&&P(f,n,d)),(null==a.distance||n<a.distance)&&P(a,n,d),T.store!==V.MIN&&(null==o.distance||n>o.distance)&&P(o,n,d)}},S=pe;c(S,r,v);const{indices:C,indexCount:E}=x,j=x.vertexAttributes,A=j.getField($.POSITION,y),N=new L(A.typedBuffer,3,j.stride/4),B=E/3;if(!p&&B>I){const e=d.renderData;null==e.intersectionData&&(e.intersectionData=new U(C,0,B,N)),e.intersectionData.intersectRay(ge,S,O,D)}else K(ge,S,0,B,C,N,p,O,D)},v=this._rootTiles;if(null!=v){(()=>{const t=this._tileIterator;t.reset(v);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==p&&!e.intersectsRay(i,s,_,m)||g&&this._useStencilForTile(e)?t.skipSubtree():x(e)})()}}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}acquireTechniques(e){const t=!!has("enable-feature:terrain-shadows")&&e.bind.shadowMap.enabled;t!==this._castShadows&&(this._castShadows=t,this._patchesByOriginDirty=!0);const i=e.bind.viewshedEnabled;if(this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),e.bind.slot===Z.OCCLUDED_GROUND){if(0===(e.renderOccludedMask&v))return null}else{const t=this.transparency===B.Opaque?Z.OPAQUE_TERRAIN:Z.TRANSPARENT_TERRAIN;if(e.bind.slot!==t)return null}if(this.transparency===B.Invisible)return null;const r=this._configuration;switch(r.screenSpaceReflections=r.cloudReflections=r.receiveShadows=r.receiveAmbientOcclusion=r.renderOccluded=r.hasHighlightMixTexture=!1,r.overlayMode=this._overlayRenderer.mode,e.output){case G.Color:case G.ColorEmission:{r.screenSpaceReflections=null!=e.bind.ssr.lastFrameColor,r.cloudReflections=null!=e.bind.clouds.data,r.receiveShadows=e.bind.shadowMap.ready;const t=e.bind.slot===Z.OCCLUDED_GROUND;return r.renderOccluded=t,r.receiveAmbientOcclusion=!t&&null!=e.bind.ssao,this._acquireTechnique(e.output)}case G.Shadow:case G.ShadowExcludeHighlight:return this._castShadows?this._acquireTechnique(G.Shadow):null;case G.ViewshedShadow:return this._inViewshed?this._acquireTechnique(G.ViewshedShadow):null;case G.Depth:case G.Normal:return this._acquireTechnique(e.output);case G.ObjectAndLayerIdColor:return this._acquireTechnique(G.ObjectAndLayerIdColor);case G.Highlight:return r.hasHighlightMixTexture=null!=e.bind.highlightMixTexture,this._overlayRenderer.hasHighlights?this._acquireTechnique(G.Highlight):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case G.Color:case G.ColorEmission:{const i=e.bind.slot===Z.OCCLUDED_GROUND?x.Occluded:x.Color;this._renderMaterialPass(e,t,i);break}case G.Depth:case G.Normal:this._renderAuxiliaryPass(e,t,x.Color,this._visiblePatchesByOrigin);break;case G.Highlight:{const i=e.bind.highlight?.name;i&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(x.Highlight)&&this._overlayRenderer.hasHighlight(i)&&this._renderAuxiliaryPass(e,t,x.Highlight,this._visiblePatchesByOrigin);break}case G.Shadow:case G.ShadowExcludeHighlight:case G.ViewshedShadow:this._renderAuxiliaryPass(e,t,null,this._allPatchesByOrigin);break;case G.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,x.ObjectAndLayerIdColor,this._visiblePatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r;if(null!=e){const i=t.toUnitRGBA(e);r=p(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll((e=>i.updateTileTexture(e,R.FADING))),this._configuration.tileBlendInput=i.backgroundIsGrid?F.GridComposite:null!=i.backgroundColor?F.ColorComposite:F.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==P.NONE){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)A(this.renderOrder,i,t);e.sort(((e,t)=>N(e[0],t[0],this.renderOrder))),this._visiblePatchesByOrigin=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i,r){const s=e.rctx;this._passParameters.overlayContent=i,s.bindTechnique(t,e.bind,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;r.forEach((r=>{this._drawParameters.origin=r[0].renderData.localOrigin,t.program.bindDraw(e.bind,this._passParameters,this._drawParameters);for(let s=0;s<r.length;s++)this._renderPatch(e,t,r[s],ae.TRIANGLES,n,i)})),e.rctx.bindVAO(null)}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlayContent=i,r.bindTechnique(t,e.bind,this._passParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const s=e.bind.camera,n=t.program;if(this._configuration.screenSizePerspective&&this.pointsOfInterest){const e=J(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:s.fovY})}const a=this._stencilEnabledLayerExtents.length>0,o=i===x.Occluded;o&&(n.bindTexture("tex",r.emptyTexture),n.setUniform3fv("textureOpacities",u),n.setUniform4fv("texOffsetAndScale",f));const l=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:u;this._configuration.tileBlendInput===F.ColorComposite&&n.setUniform3fv("backgroundColor",l);const c=this.wireframe?ae.LINES:ae.TRIANGLES;this._configuration.textureFadingEnabled&&n.bindTexture("texNext",r.emptyTexture);const d=this._visiblePatchesByOrigin;for(const h of d.values()){const r=h[0].renderData.localOrigin;this._drawParameters.origin=r,t.program.bindDraw(e.bind,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const s of h){const r=s.renderData,l=r.textureReference;if(null!=l){if(!o){n.setUniform4fv("texOffsetAndScale",l.offsetAndScale),n.bindTexture("tex",l.texture.texture);const e=r.textureFadeFactor,t=e<1?r.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(n.setUniform1f("fadeFactor",e),n.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),n.setUniform3fv("nextTexOpacities",t.opacities),n.bindTexture("texNext",t.texture.texture)):n.setUniform1f("fadeFactor",1),r.textureIsFading&&this.setNeedsRender(),n.setUniform3fv("textureOpacities",l.opacities)}this._renderPatch(e,t,s,c,a,i),s.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,i,r,s,n){const a=i.renderData,o=a.vao,l=o?.indexBuffer;if(!o||null==l)return void(S&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;null==n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay),s&&(t.useStencil=this._useStencilForTile(i),e.rctx.setPipelineState(t.getPipeline()));const d=a.geometry.indexCount;e.rctx.bindVAO(o),c.assertCompatibleVertexAttributeLocations(o),e.rctx.drawElements(r,d,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_acquireTechnique(e){return this._configuration.output=e,this._techniques.get(se,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([o({readOnly:!0})],de.prototype,"_isGlobal",null),e([o()],de.prototype,"renderOccludedFlags",void 0),e([o({value:!1})],de.prototype,"renderingDisabled",null),e([o({value:!0})],de.prototype,"visible",null),e([o()],de.prototype,"renderPatchBorders",null),e([o()],de.prototype,"visualizeNormals",null),e([o()],de.prototype,"cullBackFaces",null),e([o({value:P.FRONT_TO_BACK})],de.prototype,"renderOrder",null),e([o()],de.prototype,"wireframe",null),de=e([l("esri.views.3d.terrain.TerrainRenderer")],de);const he=g(),ue=g(),ge=g(),pe=g();export{de as TerrainRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import{toConst as a}from"../../../core/compilerUtils.js";import n from"../../../core/Evented.js";import"../../../core/has.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{destroyMaybe as h}from"../../../core/maybe.js";import{MemCachePool as d}from"../../../core/MemCachePool.js";import p from"../../../core/ObjectPool.js";import u from"../../../core/PooledArray.js";import{throwIfAborted as c,isAbortError as g,isAborted as m}from"../../../core/promiseUtils.js";import{watch as _,syncAndInitial as f,sync as T,initial as y}from"../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as v}from"../../../core/unitUtils.js";import{property as E}from"../../../core/accessorSupport/decorators/property.js";import{subclass as S}from"../../../core/accessorSupport/decorators/subclass.js";import{i as w,c as C}from"../../../chunks/vec32.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as L}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as P}from"../../../geometry/ellipsoidUtils.js";import M from"../../../geometry/SpatialReference.js";import{getProjector as x}from"../../../geometry/projection/projectors.js";import{projectPointToVector as D}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as U}from"../../../geometry/projection/projectVectorToVector.js";import{create as R,equals as I,intersection as j,intersectsSphere as A,empty as V,expand as B}from"../../../geometry/support/aaBoundingRect.js";import{create as k,copy as N}from"../../../geometry/support/frustum.js";import{isPlateCarree as O}from"../../../geometry/support/spatialReferenceUtils.js";import{e as G,c as F,a as q}from"../../../chunks/sphere.js";import{ElevationQueryTileCache as W}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as $}from"../../../layers/support/layerUtils.js";import{debugFlags as H}from"../support/debugFlags.js";import{ElevationRange as Q}from"../support/ElevationRange.js";import{ElevationUpdateEvent as z}from"../support/ElevationUpdateEvent.js";import{toBoundingRect as X}from"../support/extentUtils.js";import{ClientType as Y}from"../support/index.js";import{updatingProgress as K}from"../support/updatingProperties.js";import{ElevationBounds as J}from"./ElevationBounds.js";import{ElevationData as Z,sampleElevation as ee}from"./ElevationData.js";import{create as te}from"./ExtentHelper.js";import{TextureUpdate as ie}from"./interfaces.js";import{LayerClass as re,LayerClasses as se}from"./LayerClass.js";import{OverlayManager as ae}from"./OverlayManager.js";import{PlanarPatch as ne}from"./PlanarPatch.js";import{RenderOrder as le}from"./RenderOrder.js";import{ScaleRangeQueries as oe}from"./ScaleRangeQueries.js";import{SphericalPatch as he}from"./SphericalPatch.js";import{SplitLimits as de}from"./SplitLimits.js";import{maxRootTiles as pe,tooManyRootTilesAfterChangeError as ue,tooManyRootTilesForLayerError as ce,maxTileNeighborLevelDelta as ge,maxMemoryLodBias as me}from"./TerrainConst.js";import{TerrainRenderer as _e}from"./TerrainRenderer.js";import fe from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as Te,isVectorTileLayerView as ye,neighborEdgeIndices as ve,internalAssert as Ee,oppositeEdge as Se,isSurfaceLayerView as we,isGroupLayerView as Ce,isMapTileLayerView as be,isBlendableLayerView as Le,isElevationLayerView as Pe,releaseTerrainData as Me,enableTerrainInternalChecks as xe,oppositeCorner as De,enableWaterproofTests as Ue,enableInternalTerrainChecks as Re,enableTerrainWaterproofChecks as Ie,neighborCornerIndices as je}from"./terrainUtils.js";import{Tile as Ae,lijEquals as Ve}from"./Tile.js";import{printAllocations as Be}from"./TilePerLayerInfo.js";import{TileUpdate as ke}from"./TileUpdate.js";import{IteratorPreorder as Ne,IteratorPostorder as Oe,compareTilesByLij as Ge,hasLoadableSiblings as Fe,sortTilesByPOI as qe}from"./tileUtils.js";import{TilingSchemeLogic as We}from"./TilingSchemeLogic.js";import{TransparencyMode as $e}from"./TransparencyMode.js";import{UpsampleInfo as He}from"./UpsampleInfo.js";import{isCompositeBlendMode as Qe,blendModeFromString as ze}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{PBRMode as Xe}from"../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{RenderRequestType as Ye}from"../webgl-engine/lib/basicInterfaces.js";import{hasLayerBasedScaleVisibility as Ke}from"../../support/layerViewUtils.js";import{RenderState as Je}from"../../support/RenderState.js";import{ImmediateTask as Ze,TaskPriority as et,noBudget as tt}from"../../support/Scheduler.js";import{TextureCompressionTracker as it}from"../../support/TextureCompressionTracker.js";import{Yield as rt}from"../../support/Yield.js";var st;let at=class extends(n.EventedMixin(i)){static{st=this}get allTiles(){return a(this._allTiles)}get demResolution(){const{_allTiles:e,tilingScheme:t}=this;if(0===e.length)return{min:1,max:1};const i=v(t.spatialReference);let r=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(const a of e){const e=t.resolutionAtLevel(a.level)*i;r=Math.min(r,e),s=Math.max(s,e)}return{min:r,max:s}}constructor(e){super(e),this.terrainTextureCompressionTracker=new it,this._iteratorPool=new p(Ne,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new Oe,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._usedMemory=null,this._performanceInfo=new fe,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=b(),this._eyePosSurfaceSR=b(),this._splitLimits=new de,this._frustum=k(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new L,this._frameTask=Ze,this._allTiles=new u,this._upsampleInfoPool=new p(He),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=R(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=M.WebMercator,this._elevationProjectorCache=new Map,this.visibleElevationBounds=new J(1/0,-1/0),this.rootTileElevationBounds=new J(1/0,-1/0),this._projectorCache=new Map,this._radiusModifier=Math.cos(Math.PI/16/16),this._tilingSchemeSpatialReference=null,this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1;const t=e.view;this.overlayManager=new ae({...e,surface:this}),this._isGlobal=!t.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?he:ne,this._ellipsoid=P(t.spatialReference),this._renderer=new _e(this.overlayManager.renderer,t.stage,this._allTiles,this._ellipsoid.radius,this.terrainTextureCompressionTracker,t.resourceController.memoryController),Ke()||(this._scaleRangeQueries=new oe)}initialize(){const e=this.view,t=e.resourceController,i=t.memoryController;this._tileCache=new d(((e,t)=>i.newCache(e,t)),"terrain-tile"),this._upsampleMapCache=i.newCache("terrain-upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new W(i.newCache("elevation-query"));const r=this.overlayManager;this.addHandles([_((()=>r.renderer.isEmpty),(()=>this._evaluateTransparency())),_((()=>this.renderer.visible),(e=>this.suspended=!e)),_((()=>this.heading),(e=>{this._renderer.updateHeading(e),this._updateTileTextures(ie.FADING)})),_((()=>({heading:e.camera?.heading,state:e.state?.mode})),(({heading:e,state:t})=>{if(null==e)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree)return void(this.heading=90*Math.round(e/90)%360);const i=Math.round(e)%360,r=Math.abs(i-this.heading);(t===Je.IDLE||Math.min(r,360-r)>=30)&&(this.heading=i)}))],"overlayManager"),this.addHandles([_((()=>this.baseOpacity),(()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?ie.UNFADED:ie.IMMEDIATE)}),f),_((()=>this.hasCompositeBlendMode),(()=>this._updateTileTextures(this._evaluateTransparency()?ie.UNFADED:ie.IMMEDIATE)),f),_((()=>this.backgroundColor),((e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))}),T),_((()=>this.snapLevel),(()=>this._viewChanged=!0),T),_((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>this._allTilesSorted=!1))})),_((()=>H.TERRAIN_TILE_TREE_SHOW_TILES),(t=>{t&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&H.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))})):t||(this._treeDebugger=h(this._treeDebugger))}),y)]);const{spatialReference:a}=e;this._extentHelper=te(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});const n=new s({getCollections:()=>e.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),l=new We({layers:n,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set("tilingSchemeLogic",l),this._updateTilingScheme(),this._elevationDataRequester=t.createStreamDataRequester(Y.ELEVATION),this._mapDataRequester=t.createStreamDataRequester(Y.BASEMAP);const o=t.scheduler;this._frameTask=o.registerTask(et.TERRAIN_SURFACE,this),this.addHandles([_((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),y),_((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),T),_((()=>this.extent),(()=>this._updateRootTiles()),y),e.on("resize",(()=>this._viewChangeUpdate())),_((()=>{const t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),f),_((()=>e.qualitySettings?.fadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),y),_((()=>e.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._renderer.pbrMode=e?Xe.Simplified:Xe.Disabled),y),_((()=>e.qualitySettings?.tiledSurface.elevationLevelDelta),(()=>this._updateAllTileGeometries())),_((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),T)]),this.addHandles(e.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}destroy(){this._frameTask.remove(),this._watchUpdatingTracking.destroy(),this._removeAllTiles(),this._set("tilingSchemeLogic",h(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",h(this.overlayManager)),this._tileCache=h(this._tileCache),Ae.prune(),this._treeDebugger=h(this._treeDebugger),this._renderer.destroy(),this._iteratorPool=h(this._iteratorPool),this._upsampleMapCache=h(this._upsampleMapCache),this._elevationQueryCache=h(this._elevationQueryCache),this._set("view",null),this._extentHelper=h(this._extentHelper),this._upsampleInfoPool=h(this._upsampleInfoPool),Be()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){if(this.lodSnappingEnabled){const{view:e,tilingScheme:t}=this,i=e.scale;if(t&&i){const r=t.levelAtScale(i)+e.qualitySettings.tiledSurface.lodBias,s=t.getMaxLod();return r<=0?null:Math.min(r,s||1/0)}}return null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return this._extentHelper.stencilEnabledExtents.length>0}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(null==t||null==e)return null;const i=R(),r=X(t,i,e)?i:null,s=this._get("extent");return I(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=j(this.groundExtent,this._userClippingExtent,R()),t=this._get("extent");return I(e,t)?t:e}get groundExtent(){return null!=this._tilingSchemeExtent?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this.running||this._watchUpdatingTracking?.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get running(){return(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.suspended}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return null!=this._rootTiles}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===$e.Opaque}get invisible(){return this._renderer.transparency===$e.Invisible}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}getElevation(e,t,i,r){const s=this._rootTiles;if(!s?.length)return null;if(0===s[0].layerInfo[re.ELEVATION].length)return null;let a=this._elevationProjectorCache.get(r);if(void 0===a&&(a=x(r,this._spatialReference)??null,this._elevationProjectorCache.set(r,a)),null==a)return l.getLogger(this).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;const n=w(lt,e,t,i);a(n,0,n,0);return ut(s,n[0],n[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[re.ELEVATION].length:0;if(r?.length&&0!==s)for(let a=0;a<t;++a){const t=3*a;i(a,ut(r,e[t],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}getScale(e){if(!this.tilingScheme)return null;if(!D(e,lt,this.spatialReference))return l.getLogger(this).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(null!=t)for(const i of t)if(i?.containsPoint(lt)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;lt[0]>t[2]&&(i+=1),lt[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}_ensureProjector(e){const t=this._projectorCache.get(e);if(t)return t;const i=x(e,this._tilingSchemeSpatialReference)??null;return this._projectorCache.set(e,i),i}getSphereElevationBounds(e,t){const i=this._ensureProjector(t);if(null==i)return l.getLogger(this).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;G(e,ot);const r=q(ot);i(r,0,r,0);const s=new Q,a=this._rootTiles;if(null!=a){const e=[];for(const i of a)e.push(i);let t=0;for(;t<e.length;){const i=e[t];if(++t,!A(i.extent,ot))continue;const r=i.children;if(null==r[0]||i.rendered)s.expandElevationRangeValues(i.elevationBoundsMin,i.elevationBoundsMax);else for(const t of r)e.push(t)}}return s}getRootElevationBounds(){return new Q(this.rootTileElevationBounds.min,this.rootTileElevationBounds.max)}getLowerBoundRadius(){const e=(this._ellipsoid.radius+this.visibleElevationBounds.min)*this._radiusModifier;return Math.min(e,this._ellipsoid.radius)}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!D(e,q(ot),this.spatialReference))return l.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;ot[3]=t;let i=null;const r=e=>{if(e&&A(e.extent,ot)){const t=e.children;if(t[0]&&!e.rendered)for(const e of t)r(e);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}}},s=this._rootTiles;if(null!=s)for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){if(!this._scaleRangeQueries)return;const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._isFullyTransparent?t?$e.Invisible:$e.InvisibleWithDraped:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?$e.Opaque:$e.Transparent;return this._renderer.transparency=r,i!==r}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;if(!(e!==this.tilingScheme))return;Te(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??M.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&O(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,this._set("tilingScheme",e),this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference,this._projectorCache.clear(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey="TerrainTileMemcache"}_acquireTile(e,t,i,r){const s=this._tileCache.pop(st._tileMemcacheKey);return s?(s.init(e,t,i,r,this),s):new this._tileConstructor(e,t,i,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=ht;let s=t.rootTilesInExtent(e,i,5*pe);if(null!=this._rootTiles){if(s.length>pe)return void l.getLogger(this).warn(ue);const e=this._rootTiles.map((e=>e.lij)),t=r(e,s,Ve);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter((e=>!(t.removed.findIndex((t=>Ve(t,e.lij)))>-1)||(this._purgeTile(e),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>pe&&(l.getLogger(this).warn(ce),s=t.rootTilesInExtent(e,i,pe)),this._setRootTiles(s.map((e=>this._newRootTile(e))));I(i,this._rootTilesExtent)||(this._rootTilesExtent=R(i)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter((e=>e.loaded&&e.intersectsClippingArea));e.sort(Ge),e.forEach((e=>this._renderer.updateTileGeometryState(e))),e.forEach((e=>e.renderData.updateNeighborData())),this._updateTilesGeometries(e),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){if(0===e.length)return;e.sort(Ge);const t=this.renderer;e.forEach((e=>t.updateGeometryIfNeeded(e))),e.forEach((e=>this._pendingTilesForElevationUpdateEvent.add(e)))}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===ke.SPLIT}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(ke.SPLIT),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),null!=e){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(ke.GEOMETRY)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(null==e)return;const t=Fe(e),i=this.visibleElevationBounds;let r=t?i.min:1/0,s=t?i.max:-1/0;const a=this.extent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(ke.GEOMETRY)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBoundsMin,r),s=Math.max(e.elevationBoundsMax,s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new J(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;null!=i&&i.forEach((({elevationBoundsMin:i,elevationBoundsMax:r})=>{e=Math.min(e,i),t=Math.max(t,r)}));const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new J(e,t))}_updateViewDependentParameters(){const{camera:e,contentCamera:t}=this.view.state,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=N(this._splitLimits.frustum??k(),t.frustum):this._splitLimits.frustum=null,N(this._frustum,e.frustum),C(this._eyePosRenderSR,t.eye),U(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){e.forEachLoadedNeighbor((e=>{this._layerViews[re.MAP].some(ye)&&e.setPendingUpdate(ke.TEXTURE_FADING),this._pendingTilesToUpdate.add(e)}))}_updateTileTexture(e,t){const i=e.resetPendingUpdate(ke.TEXTURE_FADING)?ke.TEXTURE_FADING:!!e.resetPendingUpdate(ke.TEXTURE_NOFADING)&&ke.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;const e=dt.extent;V(e),this._pendingTilesForElevationUpdateEvent.forEach((t=>B(e,t.extent,e))),this._pendingTilesForElevationUpdateEvent.clear(),dt.spatialReference=this.spatialReference,this.emit("elevation-change",dt),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);const t=!this.view.state.fixedContentCamera;if(this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed&&this.requestUpdate(),this.notifyChange("updatingProgressValue"),xe&&this._checkTileInvariant(),!e.hasProgressed)return rt}_checkTileInvariant(){const e=new Map;this._allTiles.forAll((t=>e.set(t,new Set))),this._allTiles.forAll((t=>{if(Te(t.rendered===t.leaf,` rendered ${t.rendered} != ${t.leaf} leaf`),!t.leaf){const e=e=>0===e.unmergableChildCount&&0===e.maxLevelDeltaNeighborCount,i=t.children.reduce(((t,i)=>t+(e(i)?0:1)),0);if(Te(t.unmergableChildCount===i,` Tile[${t.lij.toString()}] unmergeable child count mismatch: actual ${t.unmergableChildCount} vs ${i}`),t.hasPendingUpdate(ke.MERGE)){Te(!t.hasPendingUpdate(ke.SPLIT),"Tile can be both split and merge at the same time");for(const e of t.children)Te(e.leaf||e.hasPendingUpdate(ke.MERGE),"Child of tile to merge must also merge")}}for(let i=0;i<4;++i){if(t.rendered){const e=t.renderData?.geometryState.edgePeerNeighbors[i];if(null!=e){{const r=t.level-e.level<=ge;r||(console.log(`tile level delta [${t.lij.toString()}] vs [${e.lij.toString()}] > ${ge} (edge[${i}])`),Te(r,`tile level delta [${t.level}] vs [${e.level}] > ${ge}`))}Te(t.level-e.level<=ge,`Max tile lod delta exceeded: [${t.lij.toString()}] vs [${e.lij.toString()}]`)}}const r=t.level-ge,s=e=>e.leaf||e.level===t.level,a=t.findNeighborTile(ve[i],s);if(null!=a){if(t.leaf&&t.level>=ge){let i=a;for(;t.level-i.level<ge;)i=i.parent;const s=[r,t.lij[1]>>ge,t.lij[2]>>ge];if(!Ve(s,i.lij)){const r=e.get(i);Te(!r.has(t),"Cannot already have neighbor"),r.add(t)}}Te(a.rendered||a.level===t.level,"Non-same-level-neighbor of rendered must be rendered"),Te(t.level-a.level<=ge,`Tile level delta [${t.level}] vs [${a.level}] > ${ge}`)}}})),this._allTiles.forAll((t=>{const i=t.maxLevelDeltaNeighborCount,r=e.get(t);Te(i===r.size,`Tile[${t.lij.toString()}] merge-blocker mismatch: actual ${i} vs ${r.size}`)}))}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=new ct(this._allTiles.length);t.pushAll(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;this._allTiles.forAll((e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0}));const a=this.view.state.contentCamera.viewProjectionMatrix;for(;!t.empty;){const e=t.pop(),n=e.parent,l=null!=n&&n.hasPendingUpdate(ke.MERGE),o=l?ke.MERGE:e.shouldSplit(r,s,i),h=o===ke.SPLIT;e.leaf?gt(e,h):t.pushAll(e.children),l?(e.resetPendingUpdate(ke.SPLIT),e.leaf||e.setPendingUpdate(ke.MERGE),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(a)):h?(e.resetPendingUpdate(ke.MERGE),e.leaf&&e.setPendingUpdate(ke.SPLIT)):(e.resetPendingUpdate(ke.SPLIT)&&e.updateAgentSuspension(),o===ke.ELEVATION&&e.updateAgents(re.ELEVATION),e.leaf||(e.setPendingUpdate(ke.MERGE),e.resetPendingUpdate(ke.SPLIT)))}this.requestUpdate(),(this._shortBatches||!this._oneBatchPerFrameTask)&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(qe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_markTileToUpdate(e){Ee(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_updatePendingTileGeometries(){const e=this._pendingTilesToUpdate,t=Array.from(e.keys()).filter((e=>e.loaded&&e.intersectsClippingArea));if(0===t.length)return void e.clear();const i=(i,r)=>{!r?.loaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(Ge);const r=t.length;for(let s=0;s<r;++s){const r=t[s];Ee(r.loaded),Ee(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a.dirtyEdgeResolutions,l=a.geometryState,o=e=>{const t=je[e];i(r,l.cornerPeerNeighbors[e]?.findCorner(De(t),(e=>e.loaded)))};for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(Se(ve[t]),(t=>!(!t.loaded||!t.intersectsClippingArea)&&(Ee(e.has(t)||Ge(r,t)<0),i(r,t),!0))),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,xe&&Ue&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1;const r=this.view.state.fixedContentCamera;let s=!1;for(;!e.done;){s=!0;let a=!1;const n=!this._allTiles.some((s=>{if(!i&&!r&&!s.visible)return e.done;let n=s;if(s.hasPendingUpdate(ke.MERGE)){if(!t||s.unmergableChildCount>0)return e.done;for(s.resetPendingUpdate(ke.MERGE);null!=n.parent&&0===n.parent.unmergableChildCount&&n.parent.resetPendingUpdate(ke.MERGE);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else if(s.resetPendingUpdate(ke.SPLIT)){let t=!0;const i=s.level;if(i>=ge){const e=e=>e.leaf||i-e.level<ge;for(let r=0;r<4;++r){const a=s.findNeighborTile(ve[r],e);null!=a&&i-a.level===ge&&(t=!1,xe&&(Ee(a.leaf),Ee(a.hasPendingUpdate(ke.SPLIT))))}}t?(this._splitTile(s),e.madeProgress(),a=!0):s.setPendingUpdate(ke.SPLIT)}return e.done}));if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries()),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some((t=>(t.resetPendingUpdate(ke.GEOMETRY)&&(this._updateTileGeometryState(t),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()),e.done))),!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done)))}_updateClippingExtent(){this.spatialReference&&(this.overlayManager?.updateOverlayParameters(Ye.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.quality;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*me}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=o(e-this._lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){null!=this._rootTiles&&(this._rootTiles.forEach((e=>this._purgeTile(e))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles}),this.renderer.visible=!1}_purgeSubtree(e){const 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?_t(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(st._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){Te(e.leaf,"Tile that is already split should not be split again!"),Te(e.rendered,"Tile marked to split is not rendered"),_t(e);const t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles}),e.updateAgentSuspension(),Te(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=>gt(e,e.hasPendingUpdate(ke.SPLIT)))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){pt.spatialReference=this.spatialReference,pt.extent=e.extent,pt.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",pt)}createTile(e,t,i,r){Te(!!r,"createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(ke.SPLIT),s}get _shortBatches(){return this.view.state.mode!==Je.IDLE}_mergeTile(e){Te(!e.hasPendingUpdate(ke.SPLIT),"_mergeTile sanity check"),Te(!e.leaf,"Cannot merge a leaf"),e.leaf||(this._purgeSubtree(e),Te(!e.renderData,"Merging tile with existing render data?"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),gt(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&this.overlayManager.updateTileOverlayParameters(e)}_handleLayerViewChanges(e=tt){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(let s=this.view.allLayerViews.length-1;s>=0;s--){const e=this.view.allLayerViews.items[s];if(i.add(e.uid),we(e)||Ce(e))if(this._basemapLayerViewHandles.has(e.uid)&&!Ce(e)){const i=this._layerClassFromLayerView(e),s=this.getLayerIndexByUID(i,e.uid);null!=s&&((s<r||null==r)&&(t=!0),r=s)}else this._registerTiledLayerView(e),e.layer.loaded&&(t=!0)}this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(const e of this.view.allLayerViews.items)if(be(e)&&!$(e.layer)&&0!==e.fullOpacity)return!1;return!0}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((Le(e)||Ce(e))&&Qe(ze[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return Pe(e)?re.ELEVATION:re.MAP}_registerTiledLayerView(e){const t=[];if((Le(e)||Ce(e))&&t.push(_((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(ie.UNFADED)}))),!Ce(e)){const i=this._layerClassFromLayerView(e);t.push(_((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(_((()=>e.fullOpacity),(()=>this._updateTileTextures(ie.UNFADED)))),t.push(_((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),t.push(e.on("data-changed",(()=>{const t=this.getLayerIndexByUID(i,e.uid);null!=t&&this._invalidateLayerData(t,i)})))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(const e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!we(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===re.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of se){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this._rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&(this._viewChangeUpdate(),this.notifyChange("tilingScheme"))}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===re.ELEVATION&&i.computeElevationBounds()}this._updateRootTileElevationBounds()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(re.MAP),e===ie.IMMEDIATE?this.renderer.updateTileTexture(t,ke.TEXTURE_NOFADING):t.updateRenderData(re.MAP,e)})),this._evaluateTransparency()}_invalidateLayerData(e,t){this._allTiles.forAll((i=>i.removeLayerAgent(e,t))),this._allTiles.forAll((i=>i.invalidateLayerData(e,t)))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=Ye.UPDATE){this.renderer.setNeedsRender(e)}requestUpdate(){1===++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||ye(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,c(r),g(t)||this._dataMissing(e,i,s),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){if(this.destroying)return Promise.resolve();const s=t===re.ELEVATION;return r.requester??=s?this._elevationDataRequester:this._mapDataRequester,s?Pe(i)?this._requestElevationTileData(e,i,r):Promise.reject():be(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{!m(i)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},s=i=>{g(i)||(l.getLogger(this).error(`Tile ${e.lij.toString()} layer ${re.ELEVATION}/${t.uid} error ${i}`),this._dataMissing(e,re.ELEVATION,t),this.requestUpdate())};return t.fetchElevationTile(e,i).then((e=>this._frameTask.schedule((()=>r(e)))),s).finally((()=>--this._asyncWorkItems))}_elevationDataArrived(e,t,i){const r=this._layerIndexByUid[re.ELEVATION].get(t.uid);if(null==r)return void l.getLogger(this).warn("TerrainSurface: received data from unknown layer %d %s",re.ELEVATION,e.lij.toString());const s=new Z(e.lij,e.extent,i);e.dataArrived(r,re.ELEVATION,s),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:re.ELEVATION});const a=[e],n=e.level,o=this._iteratorPool.acquire();for(o.reset(a);!o.done;){const e=o.next();e.findElevationBoundsForLayer(r,n),e.computeElevationBounds()}0===n&&this._updateRootTileElevationBounds(),o.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{Me(s),m(i)||(console.error(`Tile ${e.lij.toString()} layer ${re.MAP}/${t.uid} error ${r}`),this._dataMissing(e,re.MAP,t),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{this.requestUpdate(),m(i)?Me(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));return t.fetchTile(e.lij,i).then(a,n).finally((()=>--this._asyncWorkItems))}_mapTileDataArrived(e,t,i){const r=this.getLayerIndexByUID(re.MAP,t.uid);if(null==r)return Me(i),void l.getLogger(this).warn("TerrainSurface: received data from unknown layer");e.dataArrived(r,re.MAP,i),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:re.MAP})}_dataMissing(e,t,i){const r=this.getLayerIndexByUID(t,i.uid);null!=r?(e.dataMissing(r,t),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:t})):l.getLogger(this).warn("TerrainSurface: received data from unknown layer")}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.leaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(null==this._usedMemory&&(this._usedMemory=this._recalculateUsedMemory()),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce(((e,t)=>e+t.usedMemory),0)):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(i,e.uid);return null!=r&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get visualizeNormals(){return this._renderer.visualizeNormals}set visualizeNormals(e){this._renderer.visualizeNormals=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(){if(!Ue)return;const e=this._rootTiles;if(null==e)return;const t=e=>e?.renderData?.geometry?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometry&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometry||(e.renderData.geometry.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometry),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.leaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.leaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&0===e[2]}lijEastEnd(e){return 1<<e+(this._isGeographic?1:0)}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this._isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){Re(e)}enableWaterproofnessChecks(e){Ie(e)}};e([E()],at.prototype,"_renderer",void 0),e([E({constructOnly:!0})],at.prototype,"_scaleRangeQueries",void 0),e([E({constructOnly:!0})],at.prototype,"view",void 0),e([E({constructOnly:!0})],at.prototype,"overlayManager",void 0),e([E({constructOnly:!0})],at.prototype,"terrainTextureCompressionTracker",void 0),e([E()],at.prototype,"_hasPendingUpdates",void 0),e([E()],at.prototype,"_asyncWorkItems",void 0),e([E()],at.prototype,"_allTilesDirty",void 0),e([E()],at.prototype,"_allTilesSorted",void 0),e([E()],at.prototype,"_viewChanged",void 0),e([E({type:Number})],at.prototype,"heading",void 0),e([E()],at.prototype,"_splitLimits",void 0),e([E({readOnly:!0})],at.prototype,"_watchUpdatingTracking",void 0),e([E()],at.prototype,"_frameTask",void 0),e([E()],at.prototype,"demResolution",null),e([E({readOnly:!0})],at.prototype,"snapLevel",null),e([E({readOnly:!0})],at.prototype,"lodSnappingEnabled",null),e([E()],at.prototype,"_userClippingExtent",null),e([E()],at.prototype,"_rootTilesExtent",void 0),e([E({readOnly:!0})],at.prototype,"extent",null),e([E({readOnly:!0})],at.prototype,"groundExtent",null),e([E({readOnly:!0})],at.prototype,"_tilingSchemeExtent",null),e([E({readOnly:!0})],at.prototype,"updating",null),e([E({readOnly:!0})],at.prototype,"running",null),e([E(K)],at.prototype,"updatingProgress",void 0),e([E({readOnly:!0})],at.prototype,"updatingProgressValue",null),e([E()],at.prototype,"_maxNumUpdating",void 0),e([E()],at.prototype,"baseOpacity",null),e([E()],at.prototype,"hasCompositeBlendMode",void 0),e([E({readOnly:!0})],at.prototype,"viewingMode",null),e([E()],at.prototype,"maxTextureScale",void 0),e([E({readOnly:!0})],at.prototype,"ready",null),e([E({value:le.FRONT_TO_BACK})],at.prototype,"renderOrder",null),e([E({readOnly:!0})],at.prototype,"rootTiles",null),e([E()],at.prototype,"_rootTiles",void 0),e([E({readOnly:!0})],at.prototype,"spatialReference",null),e([E({type:t})],at.prototype,"backgroundColor",null),e([E({value:!1})],at.prototype,"slicePlaneEnabled",null),e([E({readOnly:!0})],at.prototype,"tilingScheme",void 0),e([E({readOnly:!0})],at.prototype,"tilingSchemeLocked",null),e([E({readOnly:!0})],at.prototype,"tilingSchemeLogic",void 0),e([E()],at.prototype,"wireframe",null),e([E({value:!1})],at.prototype,"suspended",null),e([E()],at.prototype,"fadeDuration",null),e([E()],at.prototype,"visibleElevationBounds",void 0),e([E()],at.prototype,"rootTileElevationBounds",void 0),e([E()],at.prototype,"_layerViewsDirty",void 0),e([E()],at.prototype,"renderPatchBorders",null),e([E()],at.prototype,"visualizeNormals",null),e([E()],at.prototype,"renderingDisabled",null),at=st=e([S("esri.views.3d.terrain.TerrainSurface")],at);const nt=at,lt=b(),ot=F(),ht=R();new u;const dt=new z("ground"),pt={spatialReference:null,extent:null,scale:0};function ut(e,t,i){for(const r of e){if(!r.containsPointXY(t,i))continue;let e=r;for(;e&&!e.renderData;){const r=(t>e.extentMidX?1:0)+(i<e.extentMidY?2:0);e=e.children[r]}const s=e?.renderData?.geometryState.samplerData??null;return ee(t,i,s)}return null}class ct{constructor(e){this.capacity=e,this._head=0,this._tail=0,this._data=new Array(e)}push(e){const t=this._tail;if(!(t<this.capacity))throw new Error("Queue full");this._data[t]=e,this._tail=t+1}pushAll(e){const t=e.length;if(0===t)return;const i=this._tail;if(!(i+t<=this.capacity))throw new Error("Queue full");for(let r=0;r<t;++r)this._data[i+r]=e[r];this._tail=i+t}pop(){const e=this._head;if(e<this._tail){const t=this._data[e];return this._head=e+1,t}}get empty(){return this._head>=this._tail}get full(){return this._tail>=this._data.length}}function gt(e,t){!e.leaf||e.level<ge||Tt(e,(e=>{t&&mt(e);const i=ft(e);if(e.maxLevelDeltaNeighborCount++,i){let t=e.parent;for(;t;){const e=ft(t);if(t.unmergableChildCount++,!e)break;t=t.parent}}}))}function mt(e){if(e.hasPendingUpdate(ke.SPLIT))return;let t=e.parent;for(;t?.resetPendingUpdate(ke.MERGE);)t=t.parent;e.resetPendingUpdate(ke.MERGE),e.leaf&&e.setPendingUpdate(ke.SPLIT),e.level<ge||Tt(e,(e=>{mt(e)}))}function _t(e){e.level<ge||Tt(e,(e=>{if(e.maxLevelDeltaNeighborCount--,0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount){let t=e.parent;for(;t&&(t.unmergableChildCount--,ft(t));)t=t.parent}}))}function ft(e){return 0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount}function Tt(e,t){if(e.level<ge)return;const i=e.level-ge,r=e.lij[1]>>ge,s=e.lij[2]>>ge,a=e=>e.leaf||e.level===i;for(let n=0;n<4;++n){const l=e.findNeighborTile(ve[n],a);if(!l||l.level!==i)continue;const o=l.lij;o[1]===r&&o[2]===s||t(l)}}export{nt as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import{toConst as a}from"../../../core/compilerUtils.js";import n from"../../../core/Evented.js";import"../../../core/has.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{destroyMaybe as h}from"../../../core/maybe.js";import{MemCachePool as d}from"../../../core/MemCachePool.js";import p from"../../../core/ObjectPool.js";import u from"../../../core/PooledArray.js";import{throwIfAborted as c,isAbortError as g,isAborted as m}from"../../../core/promiseUtils.js";import{watch as _,syncAndInitial as f,sync as y,initial as T}from"../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as v}from"../../../core/unitUtils.js";import{property as E}from"../../../core/accessorSupport/decorators/property.js";import{subclass as S}from"../../../core/accessorSupport/decorators/subclass.js";import{i as w,c as C}from"../../../chunks/vec32.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as L}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as P}from"../../../geometry/ellipsoidUtils.js";import M from"../../../geometry/SpatialReference.js";import{getProjector as x}from"../../../geometry/projection/projectors.js";import{projectPointToVector as D}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as U}from"../../../geometry/projection/projectVectorToVector.js";import{create as R,equals as I,intersection as j,intersectsSphere as A,empty as V,expand as B}from"../../../geometry/support/aaBoundingRect.js";import{create as k,copy as N}from"../../../geometry/support/frustum.js";import{isPlateCarree as O}from"../../../geometry/support/spatialReferenceUtils.js";import{e as G,c as F,a as q}from"../../../chunks/sphere.js";import{ElevationQueryTileCache as W}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as $}from"../../../layers/support/layerUtils.js";import{debugFlags as H}from"../support/debugFlags.js";import{ElevationRange as Q}from"../support/ElevationRange.js";import{ElevationUpdateEvent as z}from"../support/ElevationUpdateEvent.js";import{toBoundingRect as X}from"../support/extentUtils.js";import{ClientType as Y}from"../support/index.js";import{updatingProgress as K}from"../support/updatingProperties.js";import{ElevationBounds as J}from"./ElevationBounds.js";import{ElevationData as Z,sampleElevation as ee}from"./ElevationData.js";import{create as te}from"./ExtentHelper.js";import{TextureUpdate as ie}from"./interfaces.js";import{LayerClass as re,LayerClasses as se}from"./LayerClass.js";import{OverlayManager as ae}from"./OverlayManager.js";import{PlanarPatch as ne}from"./PlanarPatch.js";import{RenderOrder as le}from"./RenderOrder.js";import{ScaleRangeQueries as oe}from"./ScaleRangeQueries.js";import{SphericalPatch as he}from"./SphericalPatch.js";import{SplitLimits as de}from"./SplitLimits.js";import{maxRootTiles as pe,tooManyRootTilesAfterChangeError as ue,tooManyRootTilesForLayerError as ce,maxTileNeighborLevelDelta as ge,maxMemoryLodBias as me}from"./TerrainConst.js";import{TerrainRenderer as _e}from"./TerrainRenderer.js";import fe from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as ye,isVectorTileLayerView as Te,neighborEdgeIndices as ve,internalAssert as Ee,oppositeEdge as Se,isSurfaceLayerView as we,isGroupLayerView as Ce,isMapTileLayerView as be,isBlendableLayerView as Le,isElevationLayerView as Pe,releaseTerrainData as Me,enableTerrainInternalChecks as xe,oppositeCorner as De,enableWaterproofTests as Ue,enableInternalTerrainChecks as Re,enableTerrainWaterproofChecks as Ie,neighborCornerIndices as je}from"./terrainUtils.js";import{Tile as Ae,lijEquals as Ve}from"./Tile.js";import{printAllocations as Be}from"./TilePerLayerInfo.js";import{TileUpdate as ke}from"./TileUpdate.js";import{IteratorPreorder as Ne,IteratorPostorder as Oe,compareTilesByLij as Ge,hasLoadableSiblings as Fe,sortTilesByPOI as qe}from"./tileUtils.js";import{TilingSchemeLogic as We}from"./TilingSchemeLogic.js";import{TransparencyMode as $e}from"./TransparencyMode.js";import{UpsampleInfo as He}from"./UpsampleInfo.js";import{isCompositeBlendMode as Qe,blendModeFromString as ze}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{PBRMode as Xe}from"../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{RenderRequestType as Ye}from"../webgl-engine/lib/basicInterfaces.js";import{hasLayerBasedScaleVisibility as Ke}from"../../support/layerViewUtils.js";import{RenderState as Je}from"../../support/RenderState.js";import{ImmediateTask as Ze,TaskPriority as et,noBudget as tt}from"../../support/Scheduler.js";import{TextureCompressionTracker as it}from"../../support/TextureCompressionTracker.js";import{Yield as rt}from"../../support/Yield.js";var st;let at=class extends(n.EventedMixin(i)){static{st=this}get allTiles(){return a(this._allTiles)}get demResolution(){const{_allTiles:e,tilingScheme:t}=this;if(0===e.length)return{min:1,max:1};const i=v(t.spatialReference);let r=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(const a of e){const e=t.resolutionAtLevel(a.level)*i;r=Math.min(r,e),s=Math.max(s,e)}return{min:r,max:s}}constructor(e){super(e),this.terrainTextureCompressionTracker=new it,this._iteratorPool=new p(Ne,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new Oe,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._usedMemory=null,this._performanceInfo=new fe,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=b(),this._eyePosSurfaceSR=b(),this._splitLimits=new de,this._frustum=k(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new L,this._frameTask=Ze,this._allTiles=new u,this._upsampleInfoPool=new p(He),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=R(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=M.WebMercator,this._elevationProjectorCache=new Map,this.visibleElevationBounds=new J(1/0,-1/0),this.rootTileElevationBounds=new J(1/0,-1/0),this._projectorCache=new Map,this._radiusModifier=Math.cos(Math.PI/16/16),this._tilingSchemeSpatialReference=null,this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1;const t=e.view;this.overlayManager=new ae({...e,surface:this}),this._isGlobal=!t.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?he:ne,this._ellipsoid=P(t.spatialReference),this._renderer=new _e(this.overlayManager.renderer,t.stage,this._allTiles,this._ellipsoid.radius,this.terrainTextureCompressionTracker,t.resourceController.memoryController),Ke()||(this._scaleRangeQueries=new oe)}initialize(){const e=this.view,t=e.resourceController,i=t.memoryController;this._tileCache=new d(((e,t)=>i.newCache(e,t)),"terrain-tile"),this._upsampleMapCache=i.newCache("terrain-upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new W(i.newCache("elevation-query"));const r=this.overlayManager;this.addHandles([_((()=>r.renderer.isEmpty),(()=>this._evaluateTransparency())),_((()=>this.renderer.visible),(e=>this.suspended=!e)),_((()=>this.heading),(e=>{this._renderer.updateHeading(e),this._updateTileTextures(ie.FADING)})),_((()=>({heading:e.camera?.heading,state:e.state?.mode})),(({heading:e,state:t})=>{if(null==e)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree)return void(this.heading=90*Math.round(e/90)%360);const i=Math.round(e)%360,r=Math.abs(i-this.heading);(t===Je.IDLE||Math.min(r,360-r)>=30)&&(this.heading=i)}))],"overlayManager"),this.addHandles([_((()=>this.baseOpacity),(()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?ie.UNFADED:ie.IMMEDIATE)}),f),_((()=>this.hasCompositeBlendMode),(()=>this._updateTileTextures(this._evaluateTransparency()?ie.UNFADED:ie.IMMEDIATE)),f),_((()=>this.backgroundColor),((e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))}),y),_((()=>this.snapLevel),(()=>this._viewChanged=!0),y),_((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>this._allTilesSorted=!1))})),_((()=>H.TERRAIN_TILE_TREE_SHOW_TILES),(t=>{t&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&H.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))})):t||(this._treeDebugger=h(this._treeDebugger))}),T)]);const{spatialReference:a}=e;this._extentHelper=te(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});const n=new s({getCollections:()=>e.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),l=new We({layers:n,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set("tilingSchemeLogic",l),this._updateTilingScheme(),this._elevationDataRequester=t.createStreamDataRequester(Y.ELEVATION),this._mapDataRequester=t.createStreamDataRequester(Y.BASEMAP);const o=t.scheduler;this._frameTask=o.registerTask(et.TERRAIN_SURFACE,this),this.addHandles([_((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),T),_((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),y),_((()=>this.extent),(()=>this._updateRootTiles()),T),e.on("resize",(()=>this._viewChangeUpdate())),_((()=>{const t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),f),_((()=>e.qualitySettings?.fadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),T),_((()=>e.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._renderer.pbrMode=e?Xe.Simplified:Xe.Disabled),T),_((()=>e.qualitySettings?.tiledSurface.elevationLevelDelta),(()=>this._updateAllTileGeometries())),_((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),y)]),this.addHandles(e.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}destroy(){this._frameTask.remove(),this._watchUpdatingTracking.destroy(),this._removeAllTiles(),this._set("tilingSchemeLogic",h(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",h(this.overlayManager)),this._tileCache=h(this._tileCache),Ae.prune(),this._treeDebugger=h(this._treeDebugger),this._renderer.destroy(),this._iteratorPool=h(this._iteratorPool),this._upsampleMapCache=h(this._upsampleMapCache),this._elevationQueryCache=h(this._elevationQueryCache),this._set("view",null),this._extentHelper=h(this._extentHelper),this._upsampleInfoPool=h(this._upsampleInfoPool),Be(),this._layerViews.forEach((e=>e.length=0))}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){if(this.lodSnappingEnabled){const{view:e,tilingScheme:t}=this,i=e.scale;if(t&&i){const r=t.levelAtScale(i)+e.qualitySettings.tiledSurface.lodBias,s=t.getMaxLod();return r<=0?null:Math.min(r,s||1/0)}}return null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return this._extentHelper.stencilEnabledExtents.length>0}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(null==t||null==e)return null;const i=R(),r=X(t,i,e)?i:null,s=this._get("extent");return I(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=j(this.groundExtent,this._userClippingExtent,R()),t=this._get("extent");return I(e,t)?t:e}get groundExtent(){return null!=this._tilingSchemeExtent?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this.running||this._watchUpdatingTracking?.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get running(){return(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.suspended}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return null!=this._rootTiles}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===$e.Opaque}get invisible(){return this._renderer.transparency===$e.Invisible}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}getElevation(e,t,i,r){const s=this._rootTiles;if(!s?.length)return null;if(0===s[0].layerInfo[re.ELEVATION].length)return null;let a=this._elevationProjectorCache.get(r);if(void 0===a&&(a=x(r,this._spatialReference)??null,this._elevationProjectorCache.set(r,a)),null==a)return l.getLogger(this).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;const n=w(lt,e,t,i);a(n,0,n,0);return ut(s,n[0],n[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[re.ELEVATION].length:0;if(r?.length&&0!==s)for(let a=0;a<t;++a){const t=3*a;i(a,ut(r,e[t],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}getScale(e){if(!this.tilingScheme)return null;if(!D(e,lt,this.spatialReference))return l.getLogger(this).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(null!=t)for(const i of t)if(i?.containsPoint(lt)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;lt[0]>t[2]&&(i+=1),lt[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}_ensureProjector(e){const t=this._projectorCache.get(e);if(t)return t;const i=x(e,this._tilingSchemeSpatialReference)??null;return this._projectorCache.set(e,i),i}getSphereElevationBounds(e,t){const i=this._ensureProjector(t);if(null==i)return l.getLogger(this).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;G(e,ot);const r=q(ot);i(r,0,r,0);const s=new Q,a=this._rootTiles;if(null!=a){const e=[];for(const i of a)e.push(i);let t=0;for(;t<e.length;){const i=e[t];if(++t,!A(i.extent,ot))continue;const r=i.children;if(null==r[0]||i.rendered)s.expandElevationRangeValues(i.elevationBoundsMin,i.elevationBoundsMax);else for(const t of r)e.push(t)}}return s}getRootElevationBounds(){return new Q(this.rootTileElevationBounds.min,this.rootTileElevationBounds.max)}getLowerBoundRadius(){const e=(this._ellipsoid.radius+this.visibleElevationBounds.min)*this._radiusModifier;return Math.min(e,this._ellipsoid.radius)}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!D(e,q(ot),this.spatialReference))return l.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;ot[3]=t;let i=null;const r=e=>{if(e&&A(e.extent,ot)){const t=e.children;if(t[0]&&!e.rendered)for(const e of t)r(e);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}}},s=this._rootTiles;if(null!=s)for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){if(!this._scaleRangeQueries)return;const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._isFullyTransparent?t?$e.Invisible:$e.InvisibleWithDraped:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?$e.Opaque:$e.Transparent;return this._renderer.transparency=r,i!==r}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;if(!(e!==this.tilingScheme))return;ye(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??M.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&O(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,this._set("tilingScheme",e),this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference,this._projectorCache.clear(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey="TerrainTileMemcache"}_acquireTile(e,t,i,r){const s=this._tileCache.pop(st._tileMemcacheKey);return s?(s.init(e,t,i,r,this),s):new this._tileConstructor(e,t,i,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=ht;let s=t.rootTilesInExtent(e,i,5*pe);if(null!=this._rootTiles){if(s.length>pe)return void l.getLogger(this).warn(ue);const e=this._rootTiles.map((e=>e.lij)),t=r(e,s,Ve);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter((e=>!(t.removed.findIndex((t=>Ve(t,e.lij)))>-1)||(this._purgeTile(e),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>pe&&(l.getLogger(this).warn(ce),s=t.rootTilesInExtent(e,i,pe)),this._setRootTiles(s.map((e=>this._newRootTile(e))));I(i,this._rootTilesExtent)||(this._rootTilesExtent=R(i)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter((e=>e.loaded&&e.intersectsClippingArea));e.sort(Ge),e.forEach((e=>this._renderer.updateTileGeometryState(e))),e.forEach((e=>e.renderData.updateNeighborData())),this._updateTilesGeometries(e),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){if(0===e.length)return;e.sort(Ge);const t=this.renderer;e.forEach((e=>t.updateGeometryIfNeeded(e))),e.forEach((e=>this._pendingTilesForElevationUpdateEvent.add(e)))}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===ke.SPLIT}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(ke.SPLIT),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),null!=e){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(ke.GEOMETRY)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(null==e)return;const t=Fe(e),i=this.visibleElevationBounds;let r=t?i.min:1/0,s=t?i.max:-1/0;const a=this.extent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(ke.GEOMETRY)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBoundsMin,r),s=Math.max(e.elevationBoundsMax,s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new J(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;null!=i&&i.forEach((({elevationBoundsMin:i,elevationBoundsMax:r})=>{e=Math.min(e,i),t=Math.max(t,r)}));const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new J(e,t))}_updateViewDependentParameters(){const{camera:e,contentCamera:t}=this.view.state,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=N(this._splitLimits.frustum??k(),t.frustum):this._splitLimits.frustum=null,N(this._frustum,e.frustum),C(this._eyePosRenderSR,t.eye),U(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){e.forEachLoadedNeighbor((e=>{this._layerViews[re.MAP].some(Te)&&e.setPendingUpdate(ke.TEXTURE_FADING),this._pendingTilesToUpdate.add(e)}))}_updateTileTexture(e,t){const i=e.resetPendingUpdate(ke.TEXTURE_FADING)?ke.TEXTURE_FADING:!!e.resetPendingUpdate(ke.TEXTURE_NOFADING)&&ke.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;const e=dt.extent;V(e),this._pendingTilesForElevationUpdateEvent.forEach((t=>B(e,t.extent,e))),this._pendingTilesForElevationUpdateEvent.clear(),dt.spatialReference=this.spatialReference,this.emit("elevation-change",dt),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);const t=!this.view.state.fixedContentCamera;if(this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed&&this.requestUpdate(),this.notifyChange("updatingProgressValue"),xe&&this._checkTileInvariant(),!e.hasProgressed)return rt}_checkTileInvariant(){const e=new Map;this._allTiles.forAll((t=>e.set(t,new Set))),this._allTiles.forAll((t=>{if(ye(t.rendered===t.leaf,` rendered ${t.rendered} != ${t.leaf} leaf`),!t.leaf){const e=e=>0===e.unmergableChildCount&&0===e.maxLevelDeltaNeighborCount,i=t.children.reduce(((t,i)=>t+(e(i)?0:1)),0);if(ye(t.unmergableChildCount===i,` Tile[${t.lij.toString()}] unmergeable child count mismatch: actual ${t.unmergableChildCount} vs ${i}`),t.hasPendingUpdate(ke.MERGE)){ye(!t.hasPendingUpdate(ke.SPLIT),"Tile can be both split and merge at the same time");for(const e of t.children)ye(e.leaf||e.hasPendingUpdate(ke.MERGE),"Child of tile to merge must also merge")}}for(let i=0;i<4;++i){if(t.rendered){const e=t.renderData?.geometryState.edgePeerNeighbors[i];if(null!=e){{const r=t.level-e.level<=ge;r||(console.log(`tile level delta [${t.lij.toString()}] vs [${e.lij.toString()}] > ${ge} (edge[${i}])`),ye(r,`tile level delta [${t.level}] vs [${e.level}] > ${ge}`))}ye(t.level-e.level<=ge,`Max tile lod delta exceeded: [${t.lij.toString()}] vs [${e.lij.toString()}]`)}}const r=t.level-ge,s=e=>e.leaf||e.level===t.level,a=t.findNeighborTile(ve[i],s);if(null!=a){if(t.leaf&&t.level>=ge){let i=a;for(;t.level-i.level<ge;)i=i.parent;const s=[r,t.lij[1]>>ge,t.lij[2]>>ge];if(!Ve(s,i.lij)){const r=e.get(i);ye(!r.has(t),"Cannot already have neighbor"),r.add(t)}}ye(a.rendered||a.level===t.level,"Non-same-level-neighbor of rendered must be rendered"),ye(t.level-a.level<=ge,`Tile level delta [${t.level}] vs [${a.level}] > ${ge}`)}}})),this._allTiles.forAll((t=>{const i=t.maxLevelDeltaNeighborCount,r=e.get(t);ye(i===r.size,`Tile[${t.lij.toString()}] merge-blocker mismatch: actual ${i} vs ${r.size}`)}))}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=new ct(this._allTiles.length);t.pushAll(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;this._allTiles.forAll((e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0}));const a=this.view.state.contentCamera.viewProjectionMatrix;for(;!t.empty;){const e=t.pop(),n=e.parent,l=null!=n&&n.hasPendingUpdate(ke.MERGE),o=l?ke.MERGE:e.shouldSplit(r,s,i),h=o===ke.SPLIT;e.leaf?gt(e,h):t.pushAll(e.children),l?(e.resetPendingUpdate(ke.SPLIT),e.leaf||e.setPendingUpdate(ke.MERGE),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(a)):h?(e.resetPendingUpdate(ke.MERGE),e.leaf&&e.setPendingUpdate(ke.SPLIT)):(e.resetPendingUpdate(ke.SPLIT)&&e.updateAgentSuspension(),o===ke.ELEVATION&&e.updateAgents(re.ELEVATION),e.leaf||(e.setPendingUpdate(ke.MERGE),e.resetPendingUpdate(ke.SPLIT)))}this.requestUpdate(),(this._shortBatches||!this._oneBatchPerFrameTask)&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(qe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_markTileToUpdate(e){Ee(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_updatePendingTileGeometries(){const e=this._pendingTilesToUpdate,t=Array.from(e.keys()).filter((e=>e.loaded&&e.intersectsClippingArea));if(0===t.length)return void e.clear();const i=(i,r)=>{!r?.loaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(Ge);const r=t.length;for(let s=0;s<r;++s){const r=t[s];Ee(r.loaded),Ee(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a.dirtyEdgeResolutions,l=a.geometryState,o=e=>{const t=je[e];i(r,l.cornerPeerNeighbors[e]?.findCorner(De(t),(e=>e.loaded)))};for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(Se(ve[t]),(t=>!(!t.loaded||!t.intersectsClippingArea)&&(Ee(e.has(t)||Ge(r,t)<0),i(r,t),!0))),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,xe&&Ue&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1;const r=this.view.state.fixedContentCamera;let s=!1;for(;!e.done;){s=!0;let a=!1;const n=!this._allTiles.some((s=>{if(!i&&!r&&!s.visible)return e.done;let n=s;if(s.hasPendingUpdate(ke.MERGE)){if(!t||s.unmergableChildCount>0)return e.done;for(s.resetPendingUpdate(ke.MERGE);null!=n.parent&&0===n.parent.unmergableChildCount&&n.parent.resetPendingUpdate(ke.MERGE);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else if(s.resetPendingUpdate(ke.SPLIT)){let t=!0;const i=s.level;if(i>=ge){const e=e=>e.leaf||i-e.level<ge;for(let r=0;r<4;++r){const a=s.findNeighborTile(ve[r],e);null!=a&&i-a.level===ge&&(t=!1,xe&&(Ee(a.leaf),Ee(a.hasPendingUpdate(ke.SPLIT))))}}t?(this._splitTile(s),e.madeProgress(),a=!0):s.setPendingUpdate(ke.SPLIT)}return e.done}));if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries()),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some((t=>(t.resetPendingUpdate(ke.GEOMETRY)&&(this._updateTileGeometryState(t),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()),e.done))),!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done)))}_updateClippingExtent(){this.spatialReference&&(this.overlayManager?.updateOverlayParameters(Ye.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.quality;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*me}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=o(e-this._lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){null!=this._rootTiles&&(this._rootTiles.forEach((e=>this._purgeTile(e))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles}),this.renderer.visible=!1}_purgeSubtree(e){const 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?_t(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(st._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){ye(e.leaf,"Tile that is already split should not be split again!"),ye(e.rendered,"Tile marked to split is not rendered"),_t(e);const t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles}),e.updateAgentSuspension(),ye(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=>gt(e,e.hasPendingUpdate(ke.SPLIT)))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){pt.spatialReference=this.spatialReference,pt.extent=e.extent,pt.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",pt)}createTile(e,t,i,r){ye(!!r,"createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(ke.SPLIT),s}get _shortBatches(){return this.view.state.mode!==Je.IDLE}_mergeTile(e){ye(!e.hasPendingUpdate(ke.SPLIT),"_mergeTile sanity check"),ye(!e.leaf,"Cannot merge a leaf"),e.leaf||(this._purgeSubtree(e),ye(!e.renderData,"Merging tile with existing render data?"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),gt(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&this.overlayManager.updateTileOverlayParameters(e)}_handleLayerViewChanges(e=tt){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(let s=this.view.allLayerViews.length-1;s>=0;s--){const e=this.view.allLayerViews.items[s];if(i.add(e.uid),we(e)||Ce(e))if(this._basemapLayerViewHandles.has(e.uid)&&!Ce(e)){const i=this._layerClassFromLayerView(e),s=this.getLayerIndexByUID(i,e.uid);null!=s&&((s<r||null==r)&&(t=!0),r=s)}else this._registerTiledLayerView(e),e.layer.loaded&&(t=!0)}this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(const e of this.view.allLayerViews.items)if(be(e)&&!$(e.layer)&&0!==e.fullOpacity)return!1;return!0}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((Le(e)||Ce(e))&&Qe(ze[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return Pe(e)?re.ELEVATION:re.MAP}_registerTiledLayerView(e){const t=[];if((Le(e)||Ce(e))&&t.push(_((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(ie.UNFADED)}))),!Ce(e)){const i=this._layerClassFromLayerView(e);t.push(_((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(_((()=>e.fullOpacity),(()=>this._updateTileTextures(ie.UNFADED)))),t.push(_((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),t.push(e.on("data-changed",(()=>{const t=this.getLayerIndexByUID(i,e.uid);null!=t&&this._invalidateLayerData(t,i)})))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(const e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!we(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===re.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of se){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this._rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&(this._viewChangeUpdate(),this.notifyChange("tilingScheme"))}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===re.ELEVATION&&i.computeElevationBounds()}this._updateRootTileElevationBounds()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(re.MAP),e===ie.IMMEDIATE?this.renderer.updateTileTexture(t,ke.TEXTURE_NOFADING):t.updateRenderData(re.MAP,e)})),this._evaluateTransparency()}_invalidateLayerData(e,t){this._allTiles.forAll((i=>i.removeLayerAgent(e,t))),this._allTiles.forAll((i=>i.invalidateLayerData(e,t)))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=Ye.UPDATE){this.renderer.setNeedsRender(e)}requestUpdate(){1===++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||Te(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,c(r),g(t)||this._dataMissing(e,i,s),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){if(this.destroying)return Promise.resolve();const s=t===re.ELEVATION;return r.requester??=s?this._elevationDataRequester:this._mapDataRequester,s?Pe(i)?this._requestElevationTileData(e,i,r):Promise.reject():be(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{!m(i)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},s=i=>{g(i)||(l.getLogger(this).error(`Tile ${e.lij.toString()} layer ${re.ELEVATION}/${t.uid} error ${i}`),this._dataMissing(e,re.ELEVATION,t),this.requestUpdate())};return t.fetchElevationTile(e,i).then((e=>this._frameTask.schedule((()=>r(e)))),s).finally((()=>--this._asyncWorkItems))}_elevationDataArrived(e,t,i){const r=this._layerIndexByUid[re.ELEVATION].get(t.uid);if(null==r)return void l.getLogger(this).warn("TerrainSurface: received data from unknown layer %d %s",re.ELEVATION,e.lij.toString());const s=new Z(e.lij,e.extent,i);e.dataArrived(r,re.ELEVATION,s),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:re.ELEVATION});const a=[e],n=e.level,o=this._iteratorPool.acquire();for(o.reset(a);!o.done;){const e=o.next();e.findElevationBoundsForLayer(r,n),e.computeElevationBounds()}0===n&&this._updateRootTileElevationBounds(),o.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{Me(s),m(i)||(console.error(`Tile ${e.lij.toString()} layer ${re.MAP}/${t.uid} error ${r}`),this._dataMissing(e,re.MAP,t),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{this.requestUpdate(),m(i)?Me(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));return t.fetchTile(e.lij,i).then(a,n).finally((()=>--this._asyncWorkItems))}_mapTileDataArrived(e,t,i){const r=this.getLayerIndexByUID(re.MAP,t.uid);if(null==r)return Me(i),void l.getLogger(this).warn("TerrainSurface: received data from unknown layer");e.dataArrived(r,re.MAP,i),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:re.MAP})}_dataMissing(e,t,i){const r=this.getLayerIndexByUID(t,i.uid);null!=r?(e.dataMissing(r,t),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:t})):l.getLogger(this).warn("TerrainSurface: received data from unknown layer")}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.leaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(null==this._usedMemory&&(this._usedMemory=this._recalculateUsedMemory()),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce(((e,t)=>e+t.usedMemory),0)):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(i,e.uid);return null!=r&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get visualizeNormals(){return this._renderer.visualizeNormals}set visualizeNormals(e){this._renderer.visualizeNormals=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(){if(!Ue)return;const e=this._rootTiles;if(null==e)return;const t=e=>e?.renderData?.geometry?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometry&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometry||(e.renderData.geometry.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometry),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.leaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.leaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&0===e[2]}lijEastEnd(e){return 1<<e+(this._isGeographic?1:0)}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this._isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){Re(e)}enableWaterproofnessChecks(e){Ie(e)}};e([E()],at.prototype,"_renderer",void 0),e([E({constructOnly:!0})],at.prototype,"_scaleRangeQueries",void 0),e([E({constructOnly:!0})],at.prototype,"view",void 0),e([E({constructOnly:!0})],at.prototype,"overlayManager",void 0),e([E({constructOnly:!0})],at.prototype,"terrainTextureCompressionTracker",void 0),e([E()],at.prototype,"_hasPendingUpdates",void 0),e([E()],at.prototype,"_asyncWorkItems",void 0),e([E()],at.prototype,"_allTilesDirty",void 0),e([E()],at.prototype,"_allTilesSorted",void 0),e([E()],at.prototype,"_viewChanged",void 0),e([E({type:Number})],at.prototype,"heading",void 0),e([E()],at.prototype,"_splitLimits",void 0),e([E({readOnly:!0})],at.prototype,"_watchUpdatingTracking",void 0),e([E()],at.prototype,"_frameTask",void 0),e([E()],at.prototype,"demResolution",null),e([E({readOnly:!0})],at.prototype,"snapLevel",null),e([E({readOnly:!0})],at.prototype,"lodSnappingEnabled",null),e([E()],at.prototype,"_userClippingExtent",null),e([E()],at.prototype,"_rootTilesExtent",void 0),e([E({readOnly:!0})],at.prototype,"extent",null),e([E({readOnly:!0})],at.prototype,"groundExtent",null),e([E({readOnly:!0})],at.prototype,"_tilingSchemeExtent",null),e([E({readOnly:!0})],at.prototype,"updating",null),e([E({readOnly:!0})],at.prototype,"running",null),e([E(K)],at.prototype,"updatingProgress",void 0),e([E({readOnly:!0})],at.prototype,"updatingProgressValue",null),e([E()],at.prototype,"_maxNumUpdating",void 0),e([E()],at.prototype,"baseOpacity",null),e([E()],at.prototype,"hasCompositeBlendMode",void 0),e([E({readOnly:!0})],at.prototype,"viewingMode",null),e([E()],at.prototype,"maxTextureScale",void 0),e([E({readOnly:!0})],at.prototype,"ready",null),e([E({value:le.FRONT_TO_BACK})],at.prototype,"renderOrder",null),e([E({readOnly:!0})],at.prototype,"rootTiles",null),e([E()],at.prototype,"_rootTiles",void 0),e([E({readOnly:!0})],at.prototype,"spatialReference",null),e([E({type:t})],at.prototype,"backgroundColor",null),e([E({value:!1})],at.prototype,"slicePlaneEnabled",null),e([E({readOnly:!0})],at.prototype,"tilingScheme",void 0),e([E({readOnly:!0})],at.prototype,"tilingSchemeLocked",null),e([E({readOnly:!0})],at.prototype,"tilingSchemeLogic",void 0),e([E()],at.prototype,"wireframe",null),e([E({value:!1})],at.prototype,"suspended",null),e([E()],at.prototype,"fadeDuration",null),e([E()],at.prototype,"visibleElevationBounds",void 0),e([E()],at.prototype,"rootTileElevationBounds",void 0),e([E()],at.prototype,"_layerViewsDirty",void 0),e([E()],at.prototype,"renderPatchBorders",null),e([E()],at.prototype,"visualizeNormals",null),e([E()],at.prototype,"renderingDisabled",null),at=st=e([S("esri.views.3d.terrain.TerrainSurface")],at);const nt=at,lt=b(),ot=F(),ht=R();new u;const dt=new z("ground"),pt={spatialReference:null,extent:null,scale:0};function ut(e,t,i){for(const r of e){if(!r.containsPointXY(t,i))continue;let e=r;for(;e&&!e.renderData;){const r=(t>e.extentMidX?1:0)+(i<e.extentMidY?2:0);e=e.children[r]}const s=e?.renderData?.geometryState.samplerData??null;return ee(t,i,s)}return null}class ct{constructor(e){this.capacity=e,this._head=0,this._tail=0,this._data=new Array(e)}push(e){const t=this._tail;if(!(t<this.capacity))throw new Error("Queue full");this._data[t]=e,this._tail=t+1}pushAll(e){const t=e.length;if(0===t)return;const i=this._tail;if(!(i+t<=this.capacity))throw new Error("Queue full");for(let r=0;r<t;++r)this._data[i+r]=e[r];this._tail=i+t}pop(){const e=this._head;if(e<this._tail){const t=this._data[e];return this._head=e+1,t}}get empty(){return this._head>=this._tail}get full(){return this._tail>=this._data.length}}function gt(e,t){!e.leaf||e.level<ge||yt(e,(e=>{t&&mt(e);const i=ft(e);if(e.maxLevelDeltaNeighborCount++,i){let t=e.parent;for(;t;){const e=ft(t);if(t.unmergableChildCount++,!e)break;t=t.parent}}}))}function mt(e){if(e.hasPendingUpdate(ke.SPLIT))return;let t=e.parent;for(;t?.resetPendingUpdate(ke.MERGE);)t=t.parent;e.resetPendingUpdate(ke.MERGE),e.leaf&&e.setPendingUpdate(ke.SPLIT),e.level<ge||yt(e,(e=>{mt(e)}))}function _t(e){e.level<ge||yt(e,(e=>{if(e.maxLevelDeltaNeighborCount--,0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount){let t=e.parent;for(;t&&(t.unmergableChildCount--,ft(t));)t=t.parent}}))}function ft(e){return 0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount}function yt(e,t){if(e.level<ge)return;const i=e.level-ge,r=e.lij[1]>>ge,s=e.lij[2]>>ge,a=e=>e.leaf||e.level===i;for(let n=0;n<4;++n){const l=e.findNeighborTile(ve[n],a);if(!l||l.level!==i)continue;const o=l.lij;o[1]===r&&o[2]===s||t(l)}}export{nt as default};