@arcgis/core 6.0.0-next.55 → 6.0.0-next.57

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 (298) hide show
  1. package/arcgisGlobal.d.ts +1 -0
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/00c227bcecc28fe278bb.js +1 -0
  4. package/assets/esri/core/workers/chunks/033b9fcd9833db3b6e7d.js +1 -0
  5. package/assets/esri/core/workers/chunks/0978e12dd6a1cbc50b80.js +1 -0
  6. package/assets/esri/core/workers/chunks/{88df1b8b295d3aed649f.js → 10499abb7678e95d9f05.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{e956845255bce0910944.js → 1507297550c3cd1268e2.js} +1 -1
  8. package/assets/esri/core/workers/chunks/1afc8820c283ef785729.js +1 -0
  9. package/assets/esri/core/workers/chunks/1c0f5c42331fb6fc26cb.js +1 -0
  10. package/assets/esri/core/workers/chunks/1c874f86bfd0963aa3d2.js +1 -0
  11. package/assets/esri/core/workers/chunks/2a84c9a81ec2bed3d4e5.js +1 -0
  12. package/assets/esri/core/workers/chunks/2cd2fcf4a37d180d5d5c.js +1 -0
  13. package/assets/esri/core/workers/chunks/2f31766bc0f9d1d70c5a.js +1 -0
  14. package/assets/esri/core/workers/chunks/2f9adf0b809ce8797ebf.js +1 -0
  15. package/assets/esri/core/workers/chunks/35109db6a6be66f895f7.js +1 -0
  16. package/assets/esri/core/workers/chunks/373b140f92eda3857f82.js +1 -0
  17. package/assets/esri/core/workers/chunks/38bba952c38af5a150e7.js +1 -0
  18. package/assets/esri/core/workers/chunks/3982409149571a827390.js +1 -0
  19. package/assets/esri/core/workers/chunks/3aea09191b737dc1de70.js +1 -0
  20. package/assets/esri/core/workers/chunks/3d851710f7fcc27c5b60.js +2 -0
  21. package/assets/esri/core/workers/chunks/3e8d70039800f2395d66.js +1 -0
  22. package/assets/esri/core/workers/chunks/3fc4b7d0ee460fc96176.js +1 -0
  23. package/assets/esri/core/workers/chunks/457bd1bd37c67b61efe8.js +1 -0
  24. package/assets/esri/core/workers/chunks/4d8539674fc2e4fea03c.js +1 -0
  25. package/assets/esri/core/workers/chunks/{e61082f56c08abe54b3a.js → 5954f02c3901b28d8e73.js} +1 -1
  26. package/assets/esri/core/workers/chunks/5ba6007c3c49a8153256.js +1 -0
  27. package/assets/esri/core/workers/chunks/5bdd95eeb8f34dbf26f2.js +2 -0
  28. package/assets/esri/core/workers/chunks/{ced5dfb2bf46fc5eac8c.js → 5e47026c681238038955.js} +2 -2
  29. package/assets/esri/core/workers/chunks/{2baf35b1b19482d603b5.js → 5f7505ada0991cfbdd84.js} +1 -1
  30. package/assets/esri/core/workers/chunks/601d668e70c5d72fe58c.js +1 -0
  31. package/assets/esri/core/workers/chunks/651e33be8bb3995d749f.js +1 -0
  32. package/assets/esri/core/workers/chunks/{542a9c414c99d84d52ab.js → 6a202ef9ba9b89e09153.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{0826feebdca8a31eb630.js → 6ba6fece5c11fe2a6ace.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{5eb69e2895e5aec81051.js → 6fd10891506925560443.js} +1 -1
  35. package/assets/esri/core/workers/chunks/721f43554b9654481de7.js +1 -0
  36. package/assets/esri/core/workers/chunks/75274ac3ddf7c45f47d7.js +1 -0
  37. package/assets/esri/core/workers/chunks/7b6fd287e7043ad50f4e.js +1 -0
  38. package/assets/esri/core/workers/chunks/7baa49055bc31618b56e.js +1 -0
  39. package/assets/esri/core/workers/chunks/80d1267606383ae537f2.js +1 -0
  40. package/assets/esri/core/workers/chunks/8570e3df90fb76a8741a.js +1 -0
  41. package/assets/esri/core/workers/chunks/{c3c0f24a9e0047232ae1.js → 8679dfc0c53355b6feb0.js} +1 -1
  42. package/assets/esri/core/workers/chunks/8920d0b11951b57d6a66.js +1 -0
  43. package/assets/esri/core/workers/chunks/8a636dc51372e14c98f5.js +1 -0
  44. package/assets/esri/core/workers/chunks/{14259910f44c08fd5bbd.js → 9117c9b720c9ba6e7a6e.js} +1 -1
  45. package/assets/esri/core/workers/chunks/92d97e0fcc20dd5f5ac4.js +1 -0
  46. package/assets/esri/core/workers/chunks/9ca84fa9423654061d05.js +1 -0
  47. package/assets/esri/core/workers/chunks/9e372af03d62fa5ad10e.js +1 -0
  48. package/assets/esri/core/workers/chunks/a22458e5272332d86cb9.js +1 -0
  49. package/assets/esri/core/workers/chunks/{3ea480cebf8ee56228a5.js → a7dfca326883384d2751.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{723d8316f5d4b6ce2942.js → a9539393e2f1812a973a.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{be0b8bb4f09aae6ff5de.js → ab784764ddf9d7f693a1.js} +1 -1
  52. package/assets/esri/core/workers/chunks/b10c534cbe311d17b7d5.js +1 -0
  53. package/assets/esri/core/workers/chunks/b38b6fe08a367e9de4f5.js +1 -0
  54. package/assets/esri/core/workers/chunks/{4e651869e9a196494694.js → b6e628b5d2643af4c19b.js} +1 -1
  55. package/assets/esri/core/workers/chunks/{b37ab6b1cb4cfc85cd9d.js → b7828d7e2c5b75644057.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{ec465abb0344ad719e9d.js → bd8e329ec74d921d311a.js} +1 -1
  57. package/assets/esri/core/workers/chunks/{9e508f930086d2ef5f22.js → be0133fa63c5d6545a7f.js} +40 -41
  58. package/assets/esri/core/workers/chunks/{56e6e70aa40e51827290.js → c3f94024c6c9eed9f273.js} +1 -1
  59. package/assets/esri/core/workers/chunks/{6d17b45022dfd2548098.js → c5ddf8b347c31fe772a3.js} +1 -1
  60. package/assets/esri/core/workers/chunks/{ee9af58ae202b803bba7.js → c7a0c4ca37ebd1d98cf1.js} +1 -1
  61. package/assets/esri/core/workers/chunks/cb0e3614b78c78040662.js +1 -0
  62. package/assets/esri/core/workers/chunks/d22e3b5d836dffdf91cc.js +1 -0
  63. package/assets/esri/core/workers/chunks/d7763c42754152510e13.js +2 -0
  64. package/assets/esri/core/workers/chunks/e0341def2d81e679a200.js +1 -0
  65. package/assets/esri/core/workers/chunks/e42e9dd3c933f5f864ab.js +1 -0
  66. package/assets/esri/core/workers/chunks/e566102c7ed7a8ebf89e.js +1 -0
  67. package/assets/esri/core/workers/chunks/e74586b074d0fa6abb4b.js +1 -0
  68. package/assets/esri/core/workers/chunks/e7dff025780726d5feae.js +1 -0
  69. package/assets/esri/core/workers/chunks/e96fa029acba59c04e4e.js +2 -0
  70. package/assets/esri/core/workers/chunks/f4fcf87da4495584223d.js +1 -0
  71. package/assets/esri/core/workers/chunks/f989588dfdbb69056491.js +1 -0
  72. package/assets/esri/core/workers/chunks/fc5b920f9756e11c2f88.js +1 -0
  73. package/assets/esri/core/workers/chunks/fdfbd201be372d3796bf.js +2 -0
  74. package/assets/esri/core/workers/chunks/ff0a0819bba5e8264c47.js +1 -0
  75. package/chunks/BlendLayers.glsl.js +1 -1
  76. package/chunks/ColorMaterial.glsl.js +14 -14
  77. package/chunks/Component.glsl.js +38 -37
  78. package/chunks/DefaultMaterial.glsl.js +15 -15
  79. package/chunks/GlobalIllumination.glsl.js +12 -11
  80. package/chunks/GlobalIlluminationBlur.glsl.js +6 -4
  81. package/chunks/HUDMaterial.glsl.js +3 -3
  82. package/chunks/Path.glsl.js +15 -15
  83. package/chunks/Pattern.glsl.js +20 -20
  84. package/chunks/RasterColorizer.glsl.js +1 -1
  85. package/chunks/ShadowHighlight.glsl.js +1 -1
  86. package/chunks/Terrain.glsl.js +28 -27
  87. package/chunks/Water.glsl.js +30 -20
  88. package/chunks/pdf.js +57 -0
  89. package/config.js +1 -1
  90. package/core/accessorSupport/write.js +1 -1
  91. package/core/memoryEstimations.js +1 -1
  92. package/core/scheduling.js +1 -1
  93. package/interfaces.d.ts +0 -1
  94. package/kernel.js +1 -1
  95. package/layers/LinkChartLayer.js +1 -1
  96. package/layers/VoxelWasmPerSceneView.js +1 -1
  97. package/layers/geospatialPDF/GeospatialPDFFrame.js +1 -1
  98. package/layers/geospatialPDF/GeospatialPDFLayerWorker.js +1 -56
  99. package/layers/geospatialPDF/GeospatialPDFWorkerClient.js +1 -1
  100. package/layers/geospatialPDF/parserUtils.js +2 -0
  101. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  102. package/layers/graphics/dehydratedFeatures.js +1 -1
  103. package/layers/graphics/transferFeatures.js +1 -1
  104. package/layers/support/ControlPoint.js +1 -1
  105. package/layers/support/ControlPointsGeoreference.js +1 -1
  106. package/layers/support/commonProperties.js +1 -1
  107. package/layers/support/fieldUtils.d.ts +129 -57
  108. package/layers/support/fieldUtils.js +1 -1
  109. package/layers/support/geospatialPDFUtils.d.ts +63 -0
  110. package/layers/support/geospatialPDFUtils.js +2 -0
  111. package/networks/Network.js +1 -1
  112. package/networks/support/TopologyValidationJobInfo.js +1 -1
  113. package/package.json +5 -5
  114. package/symbols/CIMSymbol.d.ts +9 -9
  115. package/symbols/PathSymbol3DLayer.d.ts +1 -1
  116. package/symbols/WaterSymbol3DLayer.d.ts +13 -1
  117. package/symbols/WaterSymbol3DLayer.js +1 -1
  118. package/views/3d/GroundView3D.js +1 -1
  119. package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
  120. package/views/3d/analysis/Viewshed/ViewshedObserverManipulatedObject3D.js +1 -1
  121. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  122. package/views/3d/camera/intersectionUtils.js +1 -1
  123. package/views/3d/environment/EnvironmentView.js +1 -1
  124. package/views/3d/input/handlers/ground/GroundNavigation.js +1 -1
  125. package/views/3d/interactive/Manipulator3D.js +1 -1
  126. package/views/3d/interactive/Manipulator3DBase.js +1 -1
  127. package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
  128. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DView.js +1 -1
  129. package/views/3d/interactive/visualElements/Object3DVisualElement.js +1 -1
  130. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  131. package/views/3d/layers/BuildingSceneLayerView3D.js +1 -1
  132. package/views/3d/layers/DrapedSubView3D.js +1 -1
  133. package/views/3d/layers/DynamicLayerView3D.js +1 -1
  134. package/views/3d/layers/FeatureLikeLayerViewBase3D.js +1 -1
  135. package/views/3d/layers/FlowSubView3D.js +1 -1
  136. package/views/3d/layers/GraphicsLayerView3D.js +1 -1
  137. package/views/3d/layers/I3SMeshView3D.js +1 -1
  138. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  139. package/views/3d/layers/RouteLayerView3D.js +1 -1
  140. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  141. package/views/3d/layers/VectorTileLayerView3D.js +1 -1
  142. package/views/3d/layers/VoxelLayerView3D.js +1 -1
  143. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  144. package/views/3d/layers/graphics/Graphics3DFrustumVisibility.js +1 -1
  145. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  146. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  147. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  148. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  149. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  150. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  151. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  152. package/views/3d/layers/support/Tiles3DBVH.js +1 -1
  153. package/views/3d/layers/support/Tiles3DMeshIntersectionHandler.js +1 -1
  154. package/views/3d/layers/support/createTileBVHForLayer.js +1 -1
  155. package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
  156. package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
  157. package/views/3d/state/controllers/RotateController.js +1 -1
  158. package/views/3d/state/controllers/ZoomControllerGlobal.js +1 -1
  159. package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
  160. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  161. package/views/3d/state/utils/groundNavigationUtils.js +1 -1
  162. package/views/3d/state/utils/navigationUtils.js +1 -1
  163. package/views/3d/support/GroundAndIMSurface.js +1 -1
  164. package/views/3d/support/QualityProfile.js +1 -1
  165. package/views/3d/support/QualitySettings.js +1 -1
  166. package/views/3d/support/flow/StreamlineResources3DShape.js +1 -1
  167. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  168. package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
  169. package/views/3d/terrain/BlendLayersTechniqueConfiguration.js +1 -1
  170. package/views/3d/terrain/OverlayManager.js +1 -1
  171. package/views/3d/terrain/PatchGeometryFactory.js +1 -1
  172. package/views/3d/terrain/RasterColorizerTechniqueConfiguration.js +1 -1
  173. package/views/3d/terrain/TerrainRenderer.js +1 -1
  174. package/views/3d/terrain/TerrainSurface.js +1 -1
  175. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  176. package/views/3d/webgl-engine/collections/Component/ComponentObjectFixedBVH.js +1 -1
  177. package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
  178. package/views/3d/webgl-engine/collections/Component/Material/Component.glsl.js +1 -1
  179. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  180. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  181. package/views/3d/webgl-engine/core/shaderLibrary/clampShadowPosition.glsl.js +2 -0
  182. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +14 -14
  183. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUD.glsl.js +1 -1
  184. package/views/3d/webgl-engine/core/shaderLibrary/lastFrameUniforms.js +1 -1
  185. package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +15 -12
  186. package/views/3d/webgl-engine/core/shaderLibrary/terrain/TileComposite.glsl.js +2 -3
  187. package/views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js +1 -1
  188. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.glsl.js +1 -1
  189. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
  190. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationBlur.glsl.js +1 -1
  191. package/views/3d/webgl-engine/effects/globalIllumination/globalIlluminationUniforms.js +1 -1
  192. package/views/3d/webgl-engine/lib/BufferGeometry.js +1 -1
  193. package/views/3d/webgl-engine/lib/BufferObject3D.js +1 -1
  194. package/views/3d/webgl-engine/lib/GridLocalOriginFactory.js +1 -1
  195. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  196. package/views/3d/webgl-engine/lib/Program.js +1 -1
  197. package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
  198. package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
  199. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  200. package/views/3d/webgl-engine/lib/TriangleIntersectionData.js +1 -1
  201. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  202. package/views/3d/webgl-engine/materials/DefaultLayouts.js +1 -1
  203. package/views/3d/webgl-engine/materials/Path.glsl.js +1 -1
  204. package/views/3d/webgl-engine/materials/Water.glsl.js +1 -1
  205. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  206. package/views/3d/webgl-engine/materials/WaterTechniqueConfiguration.js +1 -1
  207. package/views/3d/webgl-engine/materials/getWaterColor.glsl.js +89 -0
  208. package/views/3d/webgl-engine/parts/Model.js +1 -1
  209. package/views/3d/webgl-engine/shaders/ColorMaterial.glsl.js +1 -1
  210. package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
  211. package/views/3d/webgl-engine/shaders/Pattern.glsl.js +1 -1
  212. package/views/3d/webgl-engine/shaders/Terrain.glsl.js +1 -1
  213. package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
  214. package/views/Attribution.js +5 -5
  215. package/views/DOMContainer.d.ts +2 -1
  216. package/views/SceneView.js +1 -1
  217. package/views/draw/DrawGraphicTool.js +1 -1
  218. package/views/draw/support/surfaceCoordinateSystems.js +1 -1
  219. package/views/webgl/Program.js +3 -3
  220. package/views/webgl/ShaderBuilder.js +23 -23
  221. package/webscene/Slide.js +1 -1
  222. package/webscene/VirtualLighting.d.ts +2 -4
  223. package/widgets/BatchAttributeForm/inputs/FieldInput.d.ts +17 -1
  224. package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
  225. package/widgets/BatchAttributeForm/inputs/support/inputUtils.d.ts +7 -0
  226. package/widgets/BatchAttributeForm/inputs/support/inputUtils.js +1 -1
  227. package/widgets/BatchAttributeForm.js +1 -1
  228. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  229. package/widgets/Sketch/SketchViewModel.js +1 -1
  230. package/widgets/Weather/WeatherViewModel.js +1 -1
  231. package/widgets/support/ContingentValuesManager.js +1 -1
  232. package/widgets/support/forms/types.d.ts +23 -1
  233. package/assets/esri/core/workers/chunks/144f18a3dd2c8cf07cf7.js +0 -1
  234. package/assets/esri/core/workers/chunks/193a73a2c7f4f8482c21.js +0 -1
  235. package/assets/esri/core/workers/chunks/20acb6f3ed5140b6c6c6.js +0 -1
  236. package/assets/esri/core/workers/chunks/23fc1c1ed483ed3b2298.js +0 -1
  237. package/assets/esri/core/workers/chunks/249a687ce1b6d0815242.js +0 -1
  238. package/assets/esri/core/workers/chunks/2634927d26cb1139c6d0.js +0 -1
  239. package/assets/esri/core/workers/chunks/2d1b8154ee40afc9d40b.js +0 -1
  240. package/assets/esri/core/workers/chunks/2d4788be418a4e5f6606.js +0 -1
  241. package/assets/esri/core/workers/chunks/333140b18aeb5a50b654.js +0 -1
  242. package/assets/esri/core/workers/chunks/4401b3f8ebb658abe789.js +0 -1
  243. package/assets/esri/core/workers/chunks/4761cd436abceee858bf.js +0 -1
  244. package/assets/esri/core/workers/chunks/4a41bf3d1e2e9bb79771.js +0 -2
  245. package/assets/esri/core/workers/chunks/4de08ead94660025075b.js +0 -1
  246. package/assets/esri/core/workers/chunks/56f227e1a9e51d1fd742.js +0 -1
  247. package/assets/esri/core/workers/chunks/5bd451c7db17ee8f0315.js +0 -1
  248. package/assets/esri/core/workers/chunks/5c34d49a6c9cc34b7626.js +0 -1
  249. package/assets/esri/core/workers/chunks/5f324d88785ffcb73ae0.js +0 -1
  250. package/assets/esri/core/workers/chunks/703373f529c1c334cfad.js +0 -1
  251. package/assets/esri/core/workers/chunks/70695e0fb53018d48e7b.js +0 -2
  252. package/assets/esri/core/workers/chunks/723c9ad4c25be2b82476.js +0 -1
  253. package/assets/esri/core/workers/chunks/733c32d8091427d84de7.js +0 -1
  254. package/assets/esri/core/workers/chunks/766a1357be2ed7f4e125.js +0 -1
  255. package/assets/esri/core/workers/chunks/844c593754b2692257f4.js +0 -1
  256. package/assets/esri/core/workers/chunks/846248697c398468d8e6.js +0 -1
  257. package/assets/esri/core/workers/chunks/860552f49f17de2f3353.js +0 -1
  258. package/assets/esri/core/workers/chunks/89e55895683369b5277a.js +0 -1
  259. package/assets/esri/core/workers/chunks/8c94e987754b3919181e.js +0 -1
  260. package/assets/esri/core/workers/chunks/919115788da38049aea7.js +0 -2
  261. package/assets/esri/core/workers/chunks/976303f47c342b9d1cc0.js +0 -1
  262. package/assets/esri/core/workers/chunks/9b727f45dfea84357b57.js +0 -1
  263. package/assets/esri/core/workers/chunks/a05a2c2aaf0c288f9681.js +0 -1
  264. package/assets/esri/core/workers/chunks/a116dd204921e7464944.js +0 -1
  265. package/assets/esri/core/workers/chunks/ab76170c374fd67ce8cd.js +0 -1
  266. package/assets/esri/core/workers/chunks/aebd12488b4004e207a3.js +0 -1
  267. package/assets/esri/core/workers/chunks/b33e7e74cf8fa3926617.js +0 -1
  268. package/assets/esri/core/workers/chunks/bb2af16e55cb39163827.js +0 -1
  269. package/assets/esri/core/workers/chunks/c7b1c6d57603fa385c54.js +0 -1
  270. package/assets/esri/core/workers/chunks/cd8181600623e18f511c.js +0 -1
  271. package/assets/esri/core/workers/chunks/cef537fa9705dd1cf685.js +0 -1
  272. package/assets/esri/core/workers/chunks/d33403d578fbeecaf844.js +0 -1
  273. package/assets/esri/core/workers/chunks/d5bb9f9b7b341c671525.js +0 -1
  274. package/assets/esri/core/workers/chunks/d96e63d66f7b1f4ea54a.js +0 -2
  275. package/assets/esri/core/workers/chunks/ddbfa664e69612295785.js +0 -1
  276. package/assets/esri/core/workers/chunks/ded81c504bf44806ca7d.js +0 -1
  277. package/assets/esri/core/workers/chunks/e0466387b2ab54d706ca.js +0 -1
  278. package/assets/esri/core/workers/chunks/e3bcd2e356f75afc316a.js +0 -1
  279. package/assets/esri/core/workers/chunks/e80526571f1a34de3278.js +0 -1
  280. package/assets/esri/core/workers/chunks/ea71850ba87ae6038000.js +0 -1
  281. package/assets/esri/core/workers/chunks/ee70be138831cc2a0f56.js +0 -1
  282. package/assets/esri/core/workers/chunks/f23c4fd014126ea7abc6.js +0 -1
  283. package/assets/esri/core/workers/chunks/f537a5e808dc546813c7.js +0 -1
  284. package/assets/esri/core/workers/chunks/f6e40f3faf0c80cf1b3a.js +0 -1
  285. package/assets/esri/core/workers/chunks/fe811d651d201f698b8f.js +0 -2
  286. package/chunks/NativeLine.glsl.js +0 -8
  287. package/layers/geospatialPDF/geospatialPDFParserUtils.js +0 -2
  288. package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterColor.glsl.js +0 -70
  289. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +0 -2
  290. package/views/3d/webgl-engine/shaders/NativeLine.glsl.js +0 -2
  291. package/views/3d/webgl-engine/shaders/NativeLineTechnique.js +0 -2
  292. package/views/3d/webgl-engine/shaders/NativeLineTechniqueConfiguration.js +0 -2
  293. /package/assets/esri/core/workers/chunks/{919115788da38049aea7.js.LICENSE.txt → 3d851710f7fcc27c5b60.js.LICENSE.txt} +0 -0
  294. /package/assets/esri/core/workers/chunks/{fe811d651d201f698b8f.js.LICENSE.txt → 5bdd95eeb8f34dbf26f2.js.LICENSE.txt} +0 -0
  295. /package/assets/esri/core/workers/chunks/{ced5dfb2bf46fc5eac8c.js.LICENSE.txt → 5e47026c681238038955.js.LICENSE.txt} +0 -0
  296. /package/assets/esri/core/workers/chunks/{4a41bf3d1e2e9bb79771.js.LICENSE.txt → d7763c42754152510e13.js.LICENSE.txt} +0 -0
  297. /package/assets/esri/core/workers/chunks/{d96e63d66f7b1f4ea54a.js.LICENSE.txt → e96fa029acba59c04e4e.js.LICENSE.txt} +0 -0
  298. /package/assets/esri/core/workers/chunks/{70695e0fb53018d48e7b.js.LICENSE.txt → fdfbd201be372d3796bf.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../../core/accessorSupport/decorators.js";import has from"../../../core/has.js";import{subtract as r,set as i,dot as a}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as o,fromValues as s,create as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as l,ZEROS as u}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{disposeMaybe as d}from"../../../core/maybe.js";import{MemCachePool as f}from"../../../core/MemCachePool.js";import p from"../../../core/ObjectPool.js";import{watch as m,sync as h}from"../../../core/reactiveUtils.js";import{create as g,set as _}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as v}from"../../../geometry/support/buffer/BufferView.js";import{noBudget as y}from"../../support/Scheduler.js";import{PrimitiveType as b}from"../../webgl/enums.js";import{getOverlayContentForOutputTerrain as x}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as S}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as C}from"../webgl-engine/lib/Attribute.js";import{IntersectorResultRay as w}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as T,MeshIntersectionOptions as E,intersectTriangles as D}from"../webgl-engine/lib/RayIntersections.js";import{TriangleRangeBVH as O}from"../webgl-engine/lib/TriangleRangeBVH.js";import{terrainId as k,getVerticalOffsetTerrain as A}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as j}from"../webgl-engine/materials/DrawParameters.js";import{hasShadowHighlights as M}from"../webgl-engine/shaders/ReceiveShadowsConfiguration.js";import{T as N}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as P}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as F}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{overlayRenderOccludedFlag as I}from"./OverlayRenderer.js";import{PatchRenderData as L}from"./PatchRenderData.js";import{TerrainAttributesCache as R}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as z}from"./terrainUtils.js";import{TileRenderer as B}from"./TileRenderer.js";import{IteratorPreorder as V,fallsWithinLayerView as H,usesStencil as U,sortTiles as W,compareTiles as G}from"./tileUtils.js";const K=g();let q=class extends S{get visibleTiles(){return Array.from(this._visiblePatchesByOrigin.values()).flat()}get _isGlobal(){return this._view.stage.isGlobal}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}get renderOccludedFlags(){return this._overlayRenderer.renderOccludedFlags}constructor(e,t,n,r,i){super(),this._surface=e,this._overlayRenderer=t,this._allTiles=n,this._compressionTracker=r,this.type=7,this.isGround=!0,this._passParameters=new N,this._drawParameters=new j,this._renderDataPool=new p(()=>new L),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new V,this._castShadows=!1,this._inViewshed=!1,this._cutFillEnabled=!1,this._tileRenderer=null,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.produces=new Map([[1,()=>this._desiredSlot===1],[7,()=>this._desiredSlot===7],[9,()=>this._produces()&&this.renderOccludedFlags===I]]),this._tileSize=256,this._configuration=new F(i.state.isGlobal),this._tileTextureCache=new f((e,t)=>i.resourceController.memoryController.newCache(e,t),`TileTexture`),this.tileGeometryCache=new R(i.resourceController.memoryController)}initialize(){this.addHandles(m(()=>this._overlayRenderer.renderOccludedFlags,()=>this.requestRender(),h))}destroy(){this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}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.requestRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.requestRender(),this.notifyChange(`renderPatchBorders`))}get layerViewUid(){return k}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.requestRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.requestRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.requestRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,this._tileRenderer!=null&&(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)),e.surface.tileElevationRangeChanged(e))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,32)}reuseTextureFromParent(e){let{parent:t}=e;if(!this._canReuseTextureFromParent(t,e))return!1;let n=l(e.lij[2]&1?.5:0,e.lij[1]&1?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,n)??!1}_canReuseTextureFromParent(e,t){if(!e)return!1;let{layerInfo:n,surface:r}=t;for(let i=0;i<n[1].length;i++){let n=r.layerViewByIndex(i,1);if(H(e,n)!==H(t,n))return!1}return!0}updateTileTexture(e,t){if(this._tileRenderer!=null){let n=t===32?0:2;if(!this._tileRenderer.updateTileTexture(e,n))return e.updateRenderData(1,n),!1;this.requestRender(),e.resetPendingUpdate(t)}return!0}updateTileGeometryState(e){for(let t of e.layerInfo[0])t.pendingUpdates&=-9;e.resetPendingUpdate(8);let t=e.renderData.updateGeometryState();return this._surface.updateElevationSources(e),t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){let t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.dispose(),e.renderData=null,e.surface.tileElevationRangeChanged(e,e.elevationBoundsMin,e.elevationBoundsMax),e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){let t=Math.max(0,Math.floor((e.level-3)/7)*7);if(this._isGlobal&&t===0)return o;for(;e.parent&&e.level>t;)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.requestRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}requestRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new B(this._surface,this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=d(this._tileRenderer)}intersectRay(e,t,n,r){this.intersectRayBudgeted(e,t,n,r,y)}intersectRayBudgeted(e,t,n,o,s){let c=this._rootTiles;if(!c||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==0)return!0;let l=J,u=Y;r(l,o,n),i(u,1/l[0],1/l[1],1/l[2]);let d=e.results.min,f=e.results.max,p=e.results.ground,m=e.options.store===0,h=!!e.results.ground.target,g=A(e.verticalOffset),y=e.tolerance,b,x=m&&d.distance!=null?d.distance:1/0,S=e.options,k=S.normalRequired||!S.backfacesTerrain,j=new E(y,!1,k),M=i=>{let c=i.renderData;if(!c?.vao)return!0;let h=c.geometry;_(K,h.boundingBox);let E=c.localOrigin;if(g!=null&&(g.localOrigin=E,g.applyToAabb(K)),X[0]=n[0]-E[0],X[1]=n[1]-E[1],X[2]=n[2]-E[2],!T(K,X,u,y,x))return!0;let A=(e,t,n,r)=>{e.set(this.type,i,t,n,r),x=m&&d.renderDistance!=null?d.renderDistance:1/0},M=(r,i,s)=>{(!k||s!=null)&&i>=0&&(S.backfacesTerrain||a(s,l)<0)&&(S.invisibleTerrain||!S.selectionMode||t==null||t(n,o,i))&&((p.renderDistance==null||i<p.renderDistance)&&A(p,r,i,s),S.isFiltered||(S.store===2&&(b==null?(b=new w(e.ray),A(b,r,i,s),e.results.all.push(b)):i<b.renderDistance&&A(b,r,i,s)),(d.renderDistance==null||i<d.renderDistance)&&A(d,r,i,s),S.store!==0&&(f.renderDistance==null||i>f.renderDistance)&&A(f,r,i,s)))},N=Z;r(N,o,E);let{indices:P,indexCount:F}=h,I=h.vertexAttributes,L=I.getField(`position`,v),R=new C(L.typedBuffer,3,I.stride/4),z=F/3;if(!g&&z>200){if(c.intersectionData??=new O(P,z,R,!0,[h.poleIndicesStartIndex/3,h.edgeIndicesStartIndex/3]),c.intersectionData.advance(s),!c.intersectionData.ready||s.done)return!1;c.intersectionData.intersectRay(X,N,j,M)}else D(X,N,0,z,(e,t)=>L.getVec(P[t],e),g,j,M);return!0},N=this._tileIterator;N.reset(c);let P=e.options.invisibleTerrain;for(let e=N.next();e;e=N.next()){if(s.done)return!1;if((e.visible||P&&e.intersectsClippingArea)&&(g!=null||e.intersectsRay(n,l,y,x))&&(!h||!U(e,this._stencilEnabledLayerExtents))){if(!M(e))return!1}else N.skipSubtree()}return s.madeProgress(),!0}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(let t of this._visiblePatchesByOrigin.values())for(let n of t)n.renderData?.textureReference!=null&&e.queriesForTile(n);e.process(),t.madeProgress()}}get _view(){return this._surface.view}get _desiredSlot(){if(!this._produces())return null;switch(this.transparency){case 0:return 1;case 1:case 2:return 7;case 3:case 4:return null}}acquireTechniques(e){let{shadowMap:t,viewshedEnabled:n,cutFillComputationEnabled:r,slot:i,hasEmission:a,useFloatBlend:o}=e.bind,s=!!has(`enable-feature:terrain-shadows`)&&t.enabled;if(s!==this._castShadows&&(this._castShadows=s,this._patchesByOriginDirty=!0),this._inViewshed!==n&&(this._inViewshed=n,this._patchesByOriginDirty=!0),this._cutFillEnabled!==r&&(this._cutFillEnabled=r,this._patchesByOriginDirty=!0),this.transparency===3)return null;if(i===9){if((e.renderOccludedMask&I)===0)return null}else if(i!==this._desiredSlot)return null;let c=this._configuration;switch(c.receiveGlobalIllumination=c.screenSpaceReflections=c.cloudReflections=c.receiveShadows=c.hasShadowHighlights=c.receiveAmbientOcclusion=c.renderOccluded=c.hasHighlightMixTexture=!1,c.hasEmission=a,c.overlayMode=this._overlayRenderer.mode,c.useFloatBlend=o.value,e.output){case 0:case 1:case 2:{let n=e.bind;c.screenSpaceReflections=n.hasScreenSpaceReflections,c.cloudReflections=n.clouds.data!=null;let r=i===9;return c.receiveShadows=t.ready&&!r,c.hasShadowHighlights=M(c,e.bind),c.renderOccluded=r,c.receiveAmbientOcclusion=!r&&n.ssao!=null,c.receiveGlobalIllumination=!r&&n.globalIlluminationEnabled,this._acquireTechnique(e.output)}case 5:case 7:return this._castShadows?this._acquireTechnique(5):null;case 8:return this._inViewshed?this._acquireTechnique(8):null;case 9:return this._cutFillEnabled?this._acquireTechnique(9):null;case 3:case 4:case 11:return this._acquireTechnique(e.output);case 10:return c.hasHighlightMixTexture=e.bind.highlightMixTexture!=null,this._overlayRenderer.hasHighlights?this._acquireTechnique(10):null}return null}render(e,t){switch(this._updatePatchGroups(),this._passParameters.useStencil=!1,this._passParameters.overlayContent=x(e.output,e.bind),e.output){case 0:case 1:case 2:return this._renderMaterialPass(e,t);case 3:case 4:case 11:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 10:{let n=e.bind.highlight?.name;n&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(n)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 5:case 7:case 8:case 9:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(this._tileRenderer==null)return;let t=this._tileRenderer,n;if(e!=null){let t=e.toUnitRGBA();n=s(t[0]||0,t[1]||0,t[2]||0)}t.setBackground(n),this._allTiles.forAll(e=>{t.updateTileTexture(e,0)||e.updateRenderData(1,0)}),this._configuration.tileBlendInput=t.backgroundIsGrid?2:t.backgroundColor==null?0:1,this.requestRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty){let e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(let n of e)W(n,t);e.sort((e,t)=>G(e[0],t[0])),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this.notifyChange(`visibleTiles`),this._patchSortingDirty=!1}}_rebuildPatchGroups(){let e=this._rootTiles;if(e!=null){e[0]?.surface.checkAllTilesWaterproofness(`render-patch-groups`),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(let t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){let t=this._tileIterator;for(t.resetOne(e);!t.done;){let e=t.next(),n=e.renderData;if(!n){this._numTilesCulled++;continue}let r=n.localOrigin;if(this._castShadows||this._inViewshed||this._cutFillEnabled){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 i=this._visiblePatchesByOrigin.get(r);i||(i=[],this._visiblePatchesByOrigin.set(r,i)),i.push(e),t.skipSubtree()}}_renderAuxiliaryPass(e,t,n){let{rctx:r,bind:i}=e;r.bindTechnique(t,i,this._passParameters);let a=!!this._stencilEnabledLayerExtents?.length;n.forEach(n=>{this._drawParameters.origin=n[0].renderData.localOrigin,t.program.bindDraw(i,this._passParameters,this._drawParameters);for(let r=0;r<n.length;r++)this._renderPatch(e,t,n[r],b.TRIANGLES,a,this._passParameters.overlayContent===null)}),r.bindVAO(null)}_renderMaterialPass(e,t){let{rctx:n,bind:r}=e,i=n.bindTechnique(t,r,this._passParameters);this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;let a=r.slot===9;a&&(i.bindTexture(`tex`,n.emptyTexture),i.setUniform3fv(`textureOpacities`,o),i.setUniform4fv(`texOffsetAndScale`,u));let s=this._tileRenderer?.backgroundColor==null?o:this._tileRenderer.backgroundColor;this._configuration.tileBlendInput===1&&i.setUniform3fv(`backgroundColor`,s);let c=!!this._stencilEnabledLayerExtents?.length,l=this.wireframe?b.LINES:b.TRIANGLES;this._configuration.textureFadingEnabled&&i.bindTexture(`texNext`,n.emptyTexture);for(let n of this._visiblePatchesByOrigin.values()){this._drawParameters.origin=n[0].renderData.localOrigin,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(let r of n){let n=r.renderData,o=n.textureReference;if(o!=null){if(!a){i.setUniform4fv(`texOffsetAndScale`,o.offsetAndScale),i.bindTexture(`tex`,o.texture.texture);let e=n.textureFadeFactor,t=e<1?n.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(i.setUniform1f(`fadeFactor`,e),i.setUniform4fv(`nextTexOffsetAndScale`,t.offsetAndScale),i.setUniform3fv(`nextTexOpacities`,t.opacities),i.bindTexture(`texNext`,t.texture.texture)):i.setUniform1f(`fadeFactor`,1),n.textureIsFading&&this.requestRender(2),i.setUniform3fv(`textureOpacities`,o.opacities)}this._renderPatch(e,t,r,l,c),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}n.bindVAO(null)}_renderPatch(e,t,n,r,i,a=!1){let o=n.renderData,s=o.vao,c=s?.indexBuffer;if(!s||c==null){z&&console.error(`Rendered tile with no indices: `,n.lij,` : `,o);return}let l=t.program;!a&&!this._overlayRenderer.isEmpty&&this._bindOverlayPatchData(l,o.overlay);let{rctx:u,bind:d}=e;i&&(this._passParameters.useStencil=U(n,this._stencilEnabledLayerExtents),u.setPipelineState(t.getPipeline(d,this._passParameters)));let f=o.geometry.indexCount;u.bindVAO(s),l.assertCompatibleVertexAttributeLocations(s),u.drawElements(r,f,c.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(P,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([t({readOnly:!0})],q.prototype,`visibleTiles`,null),e([t({readOnly:!0})],q.prototype,`_isGlobal`,null),e([t()],q.prototype,`renderOccludedFlags`,null),e([t({value:!1})],q.prototype,`renderingDisabled`,null),e([t({value:!0})],q.prototype,`visible`,null),e([t()],q.prototype,`renderPatchBorders`,null),e([t()],q.prototype,`wireframe`,null),q=e([n(`esri.views.3d.terrain.TerrainRenderer`)],q);const J=c(),Y=c(),X=c(),Z=c();export{q as TerrainRenderer};
2
+ import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../../core/accessorSupport/decorators.js";import has from"../../../core/has.js";import{subtract as r,set as i,dot as a}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as o,fromValues as s,create as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as l,ZEROS as u}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{disposeMaybe as d}from"../../../core/maybe.js";import{MemCachePool as f}from"../../../core/MemCachePool.js";import p from"../../../core/ObjectPool.js";import{watch as m,sync as h}from"../../../core/reactiveUtils.js";import{create as g,set as _}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as v}from"../../../geometry/support/buffer/BufferView.js";import{noBudget as y}from"../../support/Scheduler.js";import{PrimitiveType as b}from"../../webgl/enums.js";import{getOverlayContentForOutputTerrain as x}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as S}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as C}from"../webgl-engine/lib/Attribute.js";import{IntersectorResultRay as w}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as T,MeshIntersectionOptions as E,intersectTriangles as D}from"../webgl-engine/lib/RayIntersections.js";import{TriangleRangeBVH as O}from"../webgl-engine/lib/TriangleRangeBVH.js";import{terrainId as k,getVerticalOffsetTerrain as A}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as j}from"../webgl-engine/materials/DrawParameters.js";import{hasShadowHighlights as M}from"../webgl-engine/shaders/ReceiveShadowsConfiguration.js";import{T as N}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as P}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as F}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{overlayRenderOccludedFlag as I}from"./OverlayRenderer.js";import{PatchRenderData as L}from"./PatchRenderData.js";import{TerrainAttributesCache as R}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as z}from"./terrainUtils.js";import{TileRenderer as B}from"./TileRenderer.js";import{IteratorPreorder as V,fallsWithinLayerView as H,usesStencil as U,sortTiles as W,compareTiles as G}from"./tileUtils.js";const K=g();let q=class extends S{get visibleTiles(){return Array.from(this._visiblePatchesByOrigin.values()).flat()}get _isGlobal(){return this._view.stage.isGlobal}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}get renderOccludedFlags(){return this._overlayRenderer.renderOccludedFlags}constructor(e,t,n,r,i){super(),this._surface=e,this._overlayRenderer=t,this._allTiles=n,this._compressionTracker=r,this.type=7,this.isGround=!0,this._passParameters=new N,this._drawParameters=new j,this._renderDataPool=new p(()=>new L),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new V,this._castShadows=!1,this._inViewshed=!1,this._cutFillEnabled=!1,this._tileRenderer=null,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.produces=new Map([[1,()=>this._desiredSlot===1],[7,()=>this._desiredSlot===7],[9,()=>this._produces()&&this.renderOccludedFlags===I]]),this._tileSize=256,this._configuration=new F(i.state.isGlobal),this._tileTextureCache=new f((e,t)=>i.resourceController.memoryController.newCache(e,t),`TileTexture`),this.tileGeometryCache=new R(i.resourceController.memoryController)}initialize(){this.addHandles(m(()=>this._overlayRenderer.renderOccludedFlags,()=>this.requestRender(),h))}destroy(){this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}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.requestRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.requestRender(),this.notifyChange(`renderPatchBorders`))}get layerViewUid(){return k}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.requestRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.requestRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.requestRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,this._tileRenderer!=null&&(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)),e.surface.tileElevationRangeChanged(e))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,32)}reuseTextureFromParent(e){let{parent:t}=e;if(!this._canReuseTextureFromParent(t,e))return!1;let n=l(e.lij[2]&1?.5:0,e.lij[1]&1?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,n)??!1}_canReuseTextureFromParent(e,t){if(!e)return!1;let{layerInfo:n,surface:r}=t;for(let i=0;i<n[1].length;i++){let n=r.layerViewByIndex(i,1);if(H(e,n)!==H(t,n))return!1}return!0}updateTileTexture(e,t){if(this._tileRenderer!=null){let n=t===32?0:2;if(!this._tileRenderer.updateTileTexture(e,n))return e.updateRenderData(1,n),!1;this.requestRender(),e.resetPendingUpdate(t)}return!0}updateTileGeometryState(e){for(let t of e.layerInfo[0])t.pendingUpdates&=-9;e.resetPendingUpdate(8);let t=e.renderData.updateGeometryState();return this._surface.updateElevationSources(e),t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){let t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.dispose(),e.renderData=null,e.surface.tileElevationRangeChanged(e,e.elevationBoundsMin,e.elevationBoundsMax),e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){let t=Math.max(0,Math.floor((e.level-3)/7)*7);if(this._isGlobal&&t===0)return o;for(;e.parent&&e.level>t;)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.requestRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}requestRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new B(this._surface,this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=d(this._tileRenderer)}intersectRay(e,t,n,r){this.intersectRayBudgeted(e,t,n,r,y)}intersectRayBudgeted(e,t,n,o,s){let c=this._rootTiles;if(!c||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==0)return!0;let l=J,u=Y;r(l,o,n),i(u,1/l[0],1/l[1],1/l[2]);let d=e.results.min,f=e.results.max,p=e.results.ground,m=e.options.store===0,h=!!e.results.ground.target,g=A(e.verticalOffset),y=e.tolerance,b,x=m&&d.distance!=null?d.distance:1/0,S=e.options,k=S.normalRequired||!S.backfacesTerrain,j=new E(y,!1,k),M=i=>{let c=i.renderData;if(!c?.vao)return!0;let h=c.geometry;_(K,h.boundingBox);let E=c.localOrigin;if(g!=null&&(g.localOrigin=E,g.applyToAabb(K)),X[0]=n[0]-E[0],X[1]=n[1]-E[1],X[2]=n[2]-E[2],!T(K,X,u,y,x))return!0;let A=(e,t,n,r)=>{e.set(this.type,i,t,n,r),x=m&&d.renderDistance!=null?d.renderDistance:1/0},M=(r,i,s)=>{(!k||s!=null)&&i>=0&&(S.backfacesTerrain||a(s,l)<0)&&(S.invisibleTerrain||!S.selectionMode||t==null||t(n,o,i))&&((p.renderDistance==null||i<p.renderDistance)&&A(p,r,i,s),S.isFiltered||(S.store===2&&(b==null?(b=new w(e.ray),A(b,r,i,s),e.results.all.push(b)):i<b.renderDistance&&A(b,r,i,s)),(d.renderDistance==null||i<d.renderDistance)&&A(d,r,i,s),S.store!==0&&(f.renderDistance==null||i>f.renderDistance)&&A(f,r,i,s)))},N=Z;r(N,o,E);let{indices:P,indexCount:F}=h,I=h.vertexAttributes,L=I.getField(`position`,v),R=new C(L.typedBuffer,3,I.stride/4),z=F/3;if(!g&&z>200){if(c.intersectionData??=new O(P,z,R,!0,[h.poleIndicesStartIndex/3,h.edgeIndicesStartIndex/3]),c.intersectionData.advance(s),!c.intersectionData.ready||s.done)return!1;c.intersectionData.intersectRay(X,N,j,M)}else D(X,N,0,z,(e,t)=>L.getVec(P[t],e),g,j,M);return!0},N=this._tileIterator;N.reset(c);let P=e.options.invisibleTerrain;for(let e=N.next();e;e=N.next()){if(s.done)return!1;if((e.visible||P&&e.intersectsClippingArea)&&(g!=null||e.intersectsRay(n,l,y,x))&&(!h||!U(e,this._stencilEnabledLayerExtents))){if(!M(e))return!1}else N.skipSubtree()}return s.madeProgress(),!0}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(let t of this._visiblePatchesByOrigin.values())for(let n of t)n.renderData?.textureReference!=null&&e.queriesForTile(n);e.process(),t.madeProgress()}}get _view(){return this._surface.view}get _desiredSlot(){if(!this._produces())return null;switch(this.transparency){case 0:return 1;case 1:case 2:return 7;case 3:case 4:return null}}acquireTechniques(e){let{shadowMap:t,viewshedEnabled:n,cutFillComputationEnabled:r,slot:i,hasEmission:a,useFloatBlend:o}=e.bind,s=!!has(`enable-feature:terrain-shadows`)&&t.enabled;if(s!==this._castShadows&&(this._castShadows=s,this._patchesByOriginDirty=!0),this._inViewshed!==n&&(this._inViewshed=n,this._patchesByOriginDirty=!0),this._cutFillEnabled!==r&&(this._cutFillEnabled=r,this._patchesByOriginDirty=!0),this.transparency===3)return null;if(i===9){if((e.renderOccludedMask&I)===0)return null}else if(i!==this._desiredSlot)return null;let c=this._configuration;switch(c.receiveGlobalIllumination=c.screenSpaceReflections=c.cloudReflections=c.receiveShadows=c.hasShadowHighlights=c.receiveAmbientOcclusion=c.renderOccluded=c.hasHighlightMixTexture=!1,c.hasEmission=a,c.overlayMode=this._overlayRenderer.mode,c.useFloatBlend=o.value,e.output){case 0:case 1:case 2:{let n=e.bind;c.screenSpaceReflections=n.hasScreenSpaceReflections,c.cloudReflections=n.clouds.data!=null,c.emissionReflections=c.screenSpaceReflections&&a&&n.reprojection.lastFrameEmission!=null;let r=i===9;return c.receiveShadows=t.ready&&!r,c.hasShadowHighlights=M(c,e.bind),c.renderOccluded=r,c.receiveAmbientOcclusion=!r&&n.ssao!=null,c.receiveGlobalIllumination=!r&&n.globalIlluminationEnabled,this._acquireTechnique(e.output)}case 5:case 7:return this._castShadows?this._acquireTechnique(5):null;case 8:return this._inViewshed?this._acquireTechnique(8):null;case 9:return this._cutFillEnabled?this._acquireTechnique(9):null;case 3:case 4:case 11:return this._acquireTechnique(e.output);case 10:return c.hasHighlightMixTexture=e.bind.highlightMixTexture!=null,this._overlayRenderer.hasHighlights?this._acquireTechnique(10):null}return null}render(e,t){switch(this._updatePatchGroups(),this._passParameters.useStencil=!1,this._passParameters.overlayContent=x(e.output,e.bind),e.output){case 0:case 1:case 2:return this._renderMaterialPass(e,t);case 3:case 4:case 11:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 10:{let n=e.bind.highlight?.name;n&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(n)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 5:case 7:case 8:case 9:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(this._tileRenderer==null)return;let t=this._tileRenderer,n;if(e!=null){let t=e.toUnitRGBA();n=s(t[0]||0,t[1]||0,t[2]||0)}t.setBackground(n),this._allTiles.forAll(e=>{t.updateTileTexture(e,0)||e.updateRenderData(1,0)}),this._configuration.tileBlendInput=t.backgroundIsGrid?2:t.backgroundColor==null?0:1,this.requestRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty){let e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(let n of e)W(n,t);e.sort((e,t)=>G(e[0],t[0])),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this.notifyChange(`visibleTiles`),this._patchSortingDirty=!1}}_rebuildPatchGroups(){let e=this._rootTiles;if(e!=null){e[0]?.surface.checkAllTilesWaterproofness(`render-patch-groups`),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(let t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){let t=this._tileIterator;for(t.resetOne(e);!t.done;){let e=t.next(),n=e.renderData;if(!n){this._numTilesCulled++;continue}let r=n.localOrigin;if(this._castShadows||this._inViewshed||this._cutFillEnabled){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 i=this._visiblePatchesByOrigin.get(r);i||(i=[],this._visiblePatchesByOrigin.set(r,i)),i.push(e),t.skipSubtree()}}_renderAuxiliaryPass(e,t,n){let{rctx:r,bind:i}=e;r.bindTechnique(t,i,this._passParameters);let a=!!this._stencilEnabledLayerExtents?.length;n.forEach(n=>{this._drawParameters.origin=n[0].renderData.localOrigin,t.program.bindDraw(i,this._passParameters,this._drawParameters);for(let r=0;r<n.length;r++)this._renderPatch(e,t,n[r],b.TRIANGLES,a,this._passParameters.overlayContent===null)}),r.bindVAO(null)}_renderMaterialPass(e,t){let{rctx:n,bind:r}=e,i=n.bindTechnique(t,r,this._passParameters);this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;let a=r.slot===9;a&&(i.bindTexture(`tex`,n.emptyTexture),i.setUniform3fv(`textureOpacities`,o),i.setUniform4fv(`texOffsetAndScale`,u));let s=this._tileRenderer?.backgroundColor==null?o:this._tileRenderer.backgroundColor;this._configuration.tileBlendInput===1&&i.setUniform3fv(`backgroundColor`,s);let c=!!this._stencilEnabledLayerExtents?.length,l=this.wireframe?b.LINES:b.TRIANGLES;this._configuration.textureFadingEnabled&&i.bindTexture(`texNext`,n.emptyTexture);for(let n of this._visiblePatchesByOrigin.values()){this._drawParameters.origin=n[0].renderData.localOrigin,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(let r of n){let n=r.renderData,o=n.textureReference;if(o!=null){if(!a){i.setUniform4fv(`texOffsetAndScale`,o.offsetAndScale),i.bindTexture(`tex`,o.texture.texture);let e=n.textureFadeFactor,t=e<1?n.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(i.setUniform1f(`fadeFactor`,e),i.setUniform4fv(`nextTexOffsetAndScale`,t.offsetAndScale),i.setUniform3fv(`nextTexOpacities`,t.opacities),i.bindTexture(`texNext`,t.texture.texture)):i.setUniform1f(`fadeFactor`,1),n.textureIsFading&&this.requestRender(2),i.setUniform3fv(`textureOpacities`,o.opacities)}this._renderPatch(e,t,r,l,c),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}n.bindVAO(null)}_renderPatch(e,t,n,r,i,a=!1){let o=n.renderData,s=o.vao,c=s?.indexBuffer;if(!s||c==null){z&&console.error(`Rendered tile with no indices: `,n.lij,` : `,o);return}let l=t.program;!a&&!this._overlayRenderer.isEmpty&&this._bindOverlayPatchData(l,o.overlay);let{rctx:u,bind:d}=e;i&&(this._passParameters.useStencil=U(n,this._stencilEnabledLayerExtents),u.setPipelineState(t.getPipeline(d,this._passParameters)));let f=o.geometry.indexCount;u.bindVAO(s),l.assertCompatibleVertexAttributeLocations(s),u.drawElements(r,f,c.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(P,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([t({readOnly:!0})],q.prototype,`visibleTiles`,null),e([t({readOnly:!0})],q.prototype,`_isGlobal`,null),e([t()],q.prototype,`renderOccludedFlags`,null),e([t({value:!1})],q.prototype,`renderingDisabled`,null),e([t({value:!0})],q.prototype,`visible`,null),e([t()],q.prototype,`renderPatchBorders`,null),e([t()],q.prototype,`wireframe`,null),q=e([n(`esri.views.3d.terrain.TerrainRenderer`)],q);const J=c(),Y=c(),X=c(),Z=c();export{q as TerrainRenderer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../Color.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{filterInPlace as i,difference as a}from"../../../core/arrayUtils.js";import o from"../../../core/CollectionFlattener.js";import{toConst as s}from"../../../core/compilerUtils.js";import{EventedAccessor as c}from"../../../core/Evented.js";import"../../../core/has.js";import{set as l,copy as u,exactEquals as ee}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import f from"../../../core/Logger.js";import{clamp as te}from"../../../core/mathUtils.js";import{destroyMaybe as p,removeMaybe as ne}from"../../../core/maybe.js";import{MemCachePool as re}from"../../../core/MemCachePool.js";import m from"../../../core/ObjectPool.js";import ie from"../../../core/PooledArray.js";import{throwIfAborted as ae,isAbortError as h,isAborted as g}from"../../../core/promiseUtils.js";import{watch as _,syncAndInitial as v,initial as y,sync as b}from"../../../core/reactiveUtils.js";import"../../../core/scheduling.js";import{UpdatingHandles as oe}from"../../../core/support/UpdatingHandles.js";import{getMetersPerUnitForSR as se}from"../../../core/units.js";import{getReferenceEllipsoid as x,radiusModifier as ce}from"../../../geometry/ellipsoidUtils.js";import{projectBoundingSphere as le}from"../../../geometry/projection/projectBoundingSphere.js";import{getProjector as ue}from"../../../geometry/projection/projectors.js";import{projectPointToVector as de}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as fe}from"../../../geometry/projection/projectVectorToVector.js";import{projectWithoutEngine as pe}from"../../../geometry/projectionUtils.js";import me from"../../../geometry/SpatialReference.js";import{create as S,fromExtent as he,equals as C,intersection as ge,intersectsSphere as _e}from"../../../geometry/support/aaBoundingRect.js";import{copy as ve,create as ye}from"../../../geometry/support/frustumPlanes.js";import{createSpatialReferenceCyclical as be}from"../../../geometry/support/normalizeUtils.js";import{isGeographic as w,isPlateCarree as xe}from"../../../geometry/support/spatialReferenceUtils.js";import{Sphere as Se}from"../../../geometry/support/sphere.js";import{ElevationQueryTileCache as Ce}from"../../../layers/support/ElevationQueryTileCache.js";import{IntegratedMeshSemantics as we}from"../../../layers/support/IntegratedMeshSemantics.js";import{isIntegratedMeshLayer as Te,isBaseLayer as Ee}from"../../../layers/support/layerUtils.js";import{queueHighPriority as De}from"../../../request/queue.js";import{hasLayerBasedScaleVisibility as Oe}from"../../support/layerViewUtils.js";import{ImmediateTask as T,TaskPriority as ke,noBudget as Ae}from"../../support/Scheduler.js";import{TextureCompressionTracker as je}from"../../support/TextureCompressionTracker.js";import{Yield as Me}from"../../support/Yield.js";import{debugFlags as E}from"../support/debugFlags.js";import{ElevationRange as D}from"../support/ElevationRange.js";import{ElevationUpdateEvent as Ne}from"../support/ElevationUpdateEvent.js";import{calculateElevationUpdateExtents as Pe}from"../support/elevationUpdateExtentUtils.js";import{toBoundingRect as Fe}from"../support/extentUtils.js";import{geographicMbsToGeographicExtent as Ie,mbsToGeographicExtent as Le,intersectsGeographicExtent as Re}from"../support/sphereExtentUtils.js";import{isSupportedGCSOnGlobe as O}from"../support/supportedSpatialReference.js";import{updatingProgress as ze}from"../support/updatingProperties.js";import{isCompositeBlendMode as Be,blendModeFromString as Ve}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{ElevationBounds as He}from"./ElevationBounds.js";import{ElevationData as Ue,sampleElevation as We}from"./ElevationData.js";import{create as Ge}from"./ExtentHelper.js";import{LayerClasses as Ke}from"./LayerClass.js";import{OverlayManager as qe}from"./OverlayManager.js";import{PlanarPatch as Je}from"./PlanarPatch.js";import{Queue as Ye}from"./Queue.js";import{ScaleRangeQueries as Xe}from"./ScaleRangeQueries.js";import{SphericalPatch as Ze}from"./SphericalPatch.js";import{SplitLimits as Qe}from"./SplitLimits.js";import{maxRootTiles as k,tooManyRootTilesAfterChangeError as $e,tooManyRootTilesForLayerError as et,maxTileNeighborLevelDelta as A,maxMemoryLodBias as tt}from"./TerrainConst.js";import{TerrainRenderer as nt}from"./TerrainRenderer.js";import rt from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as j,isVectorTileLayerView as M,internalAssert as N,oppositeEdge as it,neighborEdgeIndices as P,isSurfaceLayerView as F,isGroupLayerView as I,isMapTileLayerView as L,isBlendableLayerView as R,isElevationLayerView as z,releaseTerrainData as B,oppositeCorner as at,enableTerrainInternalChecks as V,enableWaterproofTests as ot,enableInternalTerrainChecks as st,enableTerrainWaterproofChecks as ct,neighborCornerIndices as lt}from"./terrainUtils.js";import{Tile as ut,lijEquals as H}from"./Tile.js";import{printAllocations as dt}from"./TilePerLayerInfo.js";import{sortTiles as ft,IteratorPreorder as pt,IteratorPostorder as mt,compareTilesByLij as U,sortTilesByPOI as ht,traverseTilesPreorder as W}from"./tileUtils.js";import{TilingSchemeLogic as gt}from"./TilingSchemeLogic.js";import{getGroundTransparencyModeFromOpacity as _t}from"./TransparencyMode.js";import{UpsampleInfo as vt}from"./UpsampleInfo.js";var G;let K=class extends c{static{G=this}get allTilesCreated(){return this._allTilesCreated}get allTiles(){return s(this._allTiles)}get renderedTiles(){return ft(i(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get _tileConstructor(){return this.view.state.isGlobal?Ze:Je}get _ellipsoid(){return x(this.view.spatialReference)}get demResolution(){let{_allTiles:e,tilingScheme:t}=this;if(e.length===0)return{min:1,max:1};let n=se(t.spatialReference),r=1/0,i=-1/0;for(let a of e){let e=t.resolutionAtLevel(a.level)*n;r=Math.min(r,e),i=Math.max(i,e)}return{min:r,max:i}}constructor(e){super(e),this.terrainTextureCompressionTracker=new je,this._iteratorPool=new m(()=>new pt,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new mt,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._allTilesCreated=!1,this._usedMemory=null,this._performanceInfo=new rt,this._waterproofnessErrorHandle=null,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=d(),this._eyePosSurfaceSR=d(),this._splitLimits=new Qe,this._layerViews=[[],[]],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._updatingHandles=new oe,this._poiWatchHandle=null,this._frameTask=T,this._allTiles=new ie,this._upsampleInfoPool=new m(()=>new vt),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=S(),this.updatingProgress=.5,this._maxNumUpdating=1,this.hasCompositeBlendMode=!1,this.maxTextureScale=1.2,this._elevationProjectorCache=new Map,this._rootTileElevationRange=new D(1/0,-1/0),this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this.enabled=!0,this.overlayManager=new qe({...e,terrainSurface:this}),this._renderer=new nt(this,this.overlayManager.renderer,this._allTiles,this.terrainTextureCompressionTracker,e.view),Oe()||(this._scaleRangeQueries=new Xe)}initialize(){let{view:e}=this,{resourceController:t}=e,{memoryController:n}=t;e.stage.addRenderPlugin(this._renderer),this._tileCache=new re((e,t)=>n.newCache(e,t),`terrain-tile`),this._upsampleMapCache=n.newCache(`terrain-upsample`,({tile:e})=>e.unloadMapData()),this._elevationQueryCache=new Ce(n.newCache(`elevation-query`));let r=this.overlayManager;this.addHandles([_(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),_(()=>this.renderer.visible,e=>this.freeze=!e),_(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)},v)],`overlayManager`),this._updatingHandles.add(()=>({heading:e.camera?.heading,state:e.state?.mode}),({heading:e,state:t})=>{if(e==null)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree){this.heading=Math.round(e/90)*90%360;return}let n=Math.round(e)%360,r=Math.abs(n-this.heading);(t===2||Math.min(r,360-r)>=30)&&(this.heading=n)},y),this.addHandles([_(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},v),_(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),v),_(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},b),_(()=>this.snapLevel,()=>this._viewChanged=!0,b),_(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._poiWatchHandle=ne(this._poiWatchHandle),e&&(this._poiWatchHandle=this._updatingHandles.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:ee}))}),_(()=>E.TERRAIN_TILE_TREE_SHOW_TILES,t=>{t&&!this._treeDebugger?import(`../layers/support/TerrainTileTree3DDebugger.js`).then(({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&E.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))}):t||(this._treeDebugger=p(this._treeDebugger))},y),_(()=>this.tilingScheme,e=>this._updateTilingScheme(e),b)]);let{spatialReference:i}=e;this._extentHelper=Ge(this.isGlobal,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:i});let a=new o({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&`layers`in e?e.layers:null}),s=new gt({layers:a,extentHelper:this._extentHelper,isGlobal:this.isGlobal,viewSpatialReference:i});this._set(`tilingSchemeLogic`,s);let c=t.scheduler;this._frameTask=c.registerTask(ke.TERRAIN_SURFACE,this),this.addHandles([_(()=>this._stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),y),_(()=>this.groundExtent,()=>this._updateRootTiles(),y),e.on(`resize`,()=>this._viewChangeUpdate()),_(()=>{let t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),v),_(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,y),_(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,y),_(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>{this._allTiles.forAll(e=>this.updateElevationSources(e)),this._updateAllTileGeometries()}),e.allLayerViews.on(`after-changes`,()=>this._layerViewsDirty=!0)]),this._updatingHandles.add(()=>this.userClippingExtent,()=>this._updateClippingExtent()),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}clearHandles(){this._updatingHandles?.removeAll(),this.removeAllHandles(),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear()}destroy(){this._waterproofnessErrorHandle?.remove(),this._waterproofnessErrorHandle=null,this._frameTask.remove(),this._frameTask=T,this._updatingHandles?.destroy(),this._removeAllTiles(),this._set(`tilingSchemeLogic`,p(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._set(`overlayManager`,p(this.overlayManager)),this._tileCache=p(this._tileCache),this._allTiles.prune(),ut.prune(),this._treeDebugger=p(this._treeDebugger),this._renderer.destroyed||(this.view.stage.removeRenderPlugin(this._renderer),this._renderer.destroy()),this._renderer=null,this._iteratorPool=p(this._iteratorPool),this._upsampleMapCache=p(this._upsampleMapCache),this._elevationQueryCache=p(this._elevationQueryCache),this._set(`view`,null),this._extentHelper=p(this._extentHelper),this._upsampleInfoPool=p(this._upsampleInfoPool),dt(),this._layerViews.forEach(e=>e.length=0),this._performanceInfo=null}get renderer(){return this._renderer}get frustum(){return this.view.state.camera.frustum}get snapLevel(){return this.lodSnappingEnabled?this.view.terrainLevel:null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return!!this._stencilEnabledExtents?.length}get _stencilEnabledExtents(){let e=this.spatialReference;return e==null?null:Iterator.from(this.view.allLayerViews).map(t=>{let{layer:n}=t;if(!Te(n)||!we.shouldStencilTerrain(n))return null;let{fullExtent:r}=n,i=r==null||r.spatialReference.equals(e)?r:pe(r,r.spatialReference,e);return i?he(i):null}).filter(e=>e!=null).toArray()}get userClippingExtent(){let{spatialReference:e}=this,t=this.view?.clippingArea;if(t==null||e==null)return null;let n=S(),r=Fe(t,n,e)?n:null,i=this._get(`userClippingExtent`);return C(r,i)?i:r}get rootTilesExtent(){return this._rootTilesExtent}get groundExtent(){let e=ge(this.fullGroundExtent,this.userClippingExtent,S()),t=this._get(`groundExtent`);return C(e,t)?t:e}get fullGroundExtent(){return this._tilingSchemeExtent==null?this._rootTilesExtent:this._tilingSchemeExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),this.enabled&&!!((this.readyToRun||this._updatingHandles?.updating||this._asyncWorkItems>0)&&this.ready&&!this.freeze||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get readyToRun(){return this.enabled&&(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.freeze}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get isGlobal(){return this.view.state.isGlobal}get ready(){return!this.enabled||this._rootTiles!=null}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??me.WebMercator}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set(`slicePlaneEnabled`,e),this._evaluateTransparency()}get tilingScheme(){return this.tilingSchemeLogic?.tilingScheme}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===0}get invisible(){return this._renderer.transparency===3}set freeze(e){this._set(`freeze`,e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,n,r){this._renderer.intersectRay(e,t,n,r)}intersectBudgeted(e,t,n,r,i){return this._renderer.intersectRayBudgeted(e,t,n,r,i)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}get _xNormalizer(){return be(this.spatialReference)}getElevation(e,t,n,r){let i=this._rootTiles;if(!i?.length||!this.enabled||i[0].layerInfo[0].length===0)return null;let a=this._elevationProjectorCache.get(r);if(a===void 0&&(a=ue(r,this.spatialReference)??null,this._elevationProjectorCache.set(r,a)),a==null)return f.getLogger(this).error(`TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system`),null;let o=l(q,e,t,n);return a(o,0,o,0),Ct(i,this._xNormalizer?.normalize(o[0])??o[0],o[1])}getElevations(e,t,n){let r=this._rootTiles,i=r?r[0].layerInfo[0].length:0;if(!r?.length||i===0||!this.enabled)for(let e=0;e<t;++e)n(e,null);else for(let i=0;i<t;++i){let t=i*3,a=Ct(r,e[t],e[t+1]);n(i,a)}}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}get visibleElevationRange(){let e=1/0,t=-1/0;for(let n of this._allTiles)n.renderData&&(e=Math.min(e,n.elevationBoundsMin),t=Math.max(t,n.elevationBoundsMax));let n=this._get(`visibleElevationRange`);return n?.minElevation===e&&n.maxElevation===t?n:new D(e,t)}invalidateElevationRange(){this.notifyChange(`visibleElevationRange`)}tileElevationRangeChanged(e,t=1/0,n=-1/0){let r=this._get(`visibleElevationRange`);(!r||t===r.minElevation||n===r.maxElevation||e.renderData&&(e.elevationBoundsMin<r.minElevation||e.elevationBoundsMax>r.maxElevation))&&this.invalidateElevationRange()}getScale(e){if(!this.tilingScheme)return null;if(!de(e,q,this.spatialReference))return f.getLogger(this).error(`TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system`),null;let t=this._rootTiles;if(t!=null){for(let e of t)if(e?.containsPoint(q)){let t=e;for(;t.children[0]&&!t.rendered;){let e=t.children[0].extent,n=0;q[0]>e[2]&&(n+=1),q[1]<e[1]&&(n+=2),t=t.children[n]}return this._getLodBiasCorrectedScale(t.level)}}return 1/0}getSphereElevationRange(e,t){if(!this.enabled)return null;let n=this._rootTiles,r=this.spatialReference;if(n==null||r==null||n.length===0)return null;let i=w(r);if(i){let n=w(t)&&O(t),i=x(t);if(n&&O(r)&&i===x(r))Ie(e,J,i.radius);else if(!Le(e,t,J,r))return f.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project the query sphere`),null}else if(!le(e,t,bt,r))return f.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project the query sphere`),null;let a=new D,o=[];for(let e of n)o.push(e);let s=0;for(;s<o.length;){let e=o[s];if(++s,!(i?Re(e.extent,J,r):_e(e.extent,bt)))continue;let t=e.children;if(t[0]==null||e.rendered)a.expandElevationRangeValues(e.elevationBoundsMin,e.elevationBoundsMax);else for(let e of t)o.push(e)}return a}getRootElevationRange(){return this.enabled&&this._rootTiles?new D(this._rootTileElevationRange.minElevation,this._rootTileElevationRange.maxElevation):null}getLowerBoundRadius(){let e=this.visibleElevationRange,t=(this._ellipsoid.radius+(e.isEmpty?0:e.minElevation))*ce;return Math.min(t,this._ellipsoid.radius)}queryVisibleScaleRange(e,t,n,r){if(!this._scaleRangeQueries)return;let i=t?this.tilingScheme.levelAtScale(t):0,a=n?this.tilingScheme.levelAtScale(n):1/0,o=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,i+o,a+o,r)}_evaluateTransparency(){let e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,n=this._renderer.transparency,r=this._isFullyTransparent?_t(0,t):e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?0:1;return this._renderer.transparency=r,n!==r&&(this.notifyChange(`opaque`),this.notifyChange(`invisible`),!0)}_updateTilingScheme(e){j(!!e,`tiling scheme cannot be reset to undefined`),e&&this._removeAllTiles(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey=`TerrainTileMemcache`}_acquireTile(e,t,n,r){let i=this._tileCache.pop(G._tileMemcacheKey);return i?(i.init(e,t,n,r,this),i):new this._tileConstructor(e,t,n,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){let{groundExtent:e,tilingScheme:t}=this;if(!t)return;if(!this.enabled){this._setRootTiles(null);return}let n=xt,r=t.rootTilesInExtent(e,n,k*5);if(this._rootTiles!=null){if(r.length>k){f.getLogger(this).warn($e);return}let e=this._rootTiles.map(e=>e.lij),t=a(e,r,H);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){let e=this._rootTiles.filter(e=>t.removed.findIndex(t=>H(t,e.lij))>-1?(this._purgeTile(e),!1):!0);t.added.forEach(t=>e.push(this._newRootTile(t))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,r.length>k&&(f.getLogger(this).warn(et),r=t.rootTilesInExtent(e,n,k)),this._setRootTiles(r.map(e=>this._newRootTile(e)));C(n,this._rootTilesExtent)||(this._rootTilesExtent=S(n)),this.renderer.visible=!0,this.overlayManager.setPlacementDirty(),this.notifyChange(`ready`),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this._viewChangeUpdate(),this.checkAllTilesWaterproofness(`root-tiles-updated`)}_updateAllTileGeometries(){let e=this._allTiles.filter(e=>this._canUpdateTileGeometry(e));e.length===0||(e.sort(U),e.forEach(e=>this._renderer.updateTileGeometryState(e)),e.forEach(e=>e.renderData.updateNeighborData()),this._updateTilesGeometries(e)),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){let t=e.filter(e=>this._canUpdateTileGeometry(e));if(t.length===0)return;let n=this.renderer;for(let e of t)n.updateGeometryIfNeeded(e);for(let e of t)this._pendingTilesForElevationUpdateEvent.add(e)}_canUpdateTileGeometry(e){return e.loaded&&e.intersectsClippingArea&&e.hasGeometryState}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===1}_newRootTile(e){let t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(1),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationRange(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),e!=null){let t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this.invalidateElevationRange(),this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.freeze&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask||this._updatingRootTiles?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.groundExtent)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(e==null)return;let t=this.groundExtent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty(!1);let r=this._iteratorPool.acquire();for(r.reset(e);!r.done;){let e=r.next();e.updateClippingStatus(t)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n)}r.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries()}_updateRootTileElevationRange(){let e=1/0,t=-1/0;this._rootTiles?.forEach(({elevationBoundsMin:n,elevationBoundsMax:r})=>{e=Math.min(e,n),t=Math.max(t,r)});let n=this._rootTileElevationRange;(n.minElevation!==e||n.maxElevation!==t)&&(this._rootTileElevationRange=new He(e,t))}_updateViewDependentParameters(){let{camera:e,contentCamera:t}=this.view.state,n=Math.tan(t.fovX*.5),r=Math.tan(t.fovY*.5),i=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=n,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=i/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=i/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=ve(this._splitLimits.frustum??ye(),t.frustum):this._splitLimits.frustum=null,u(this._eyePosRenderSR,t.eye),fe(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility(),this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){let t;e.forEachLoadedNeighbor(e=>{t??=this._layerViews[1].some(M),t&&e.setPendingUpdate(32),this._pendingTilesToUpdate.add(e)})}_updateTileTexture(e,t){let n=e.hasPendingUpdate(32)?32:e.hasPendingUpdate(16)?16:!1;if(n){let r=this._renderer.updateTileTexture(e,n);return this._usedMemory=null,r&&e.resetPendingUpdate(n),t.madeProgress(),r}return!0}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;let e=this._pendingTilesForElevationUpdateEvent;if(e.size>0){let t=new Float64Array(4*e.size),n=0;for(let r of e)t.set(r.extent,4*n),++n;e.clear();for(let e of Pe(t,this.spatialReference)){let t=new Ne(this.spatialReference,e,`ground`);this.emit(`elevation-change`,t)}}this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);let t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),this._updateElevation(e);let n=this._updateTextures(e);t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty();let r=this._pendingTilesToUpdate.size>0,i=r&&this._hasPendingGeometryWithoutIndices();if((!e.done||i)&&this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&(e.hasProgressed||r&&!i)&&this.requestUpdate(),this.notifyChange(`updatingProgressValue`),!n||!e.hasProgressed)return Me}_checkTileInvariant(){}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;let t=!1,n=new Ye(this._allTiles.length);n.pushAll(this._rootTiles);let r=this.snapLevel,i=this._splitLimits,a=this._eyePosRenderSR;this._allTiles.forAll(e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0});let o=this.view.state.contentCamera.viewProjectionMatrix;for(;!n.empty;){let e=n.pop(),s=e.parent?.hasPendingUpdate(4),c=e.elevationLevel,l=s?4:e.shouldSplit(i,a,r),u=l===1;e.leaf?X(e,u):n.pushAll(e.children),s?(e.resetPendingUpdate(1),e.leaf||(e.setPendingUpdate(4),t=!0),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(o)):(u?(e.resetPendingUpdate(4),e.leaf&&(e.setPendingUpdate(1),t=!0)):(e.resetPendingUpdate(1)&&e.updateAgentSuspension(),l===2&&e.updateAgents(0),e.leaf||(e.setPendingUpdate(4),e.resetPendingUpdate(1),t=!0)),e.elevationLevel!==c&&this.updateElevationSources(e))}this._allTilesDirty=t,this.requestUpdate(),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){!e.done&&!this._allTilesSorted&&this.view.pointsOfInterest?.focus&&(ht(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger?.update(),e.madeProgress())}_markTileToUpdate(e){N(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_hasPendingGeometryWithoutIndices(){for(let e of this._pendingTilesToUpdate)if(e.loaded&&e.intersectsClippingArea&&e.renderData?.vao?.indexBuffer==null)return!0;return!1}_updatePendingTileGeometries(){let e=this._pendingTilesToUpdate,t=[];if(e.forEach(e=>{this._canUpdateTileGeometry(e)&&t.push(e)}),t.length===0){e.clear();return}let n=(n,r)=>{!r||!this._canUpdateTileGeometry(r)||r.level<n.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(U);let r=t.length;for(let i=0;i<r;++i){let r=t[i];N(r.loaded),N(r.intersectsClippingArea);let a=r.renderData;if(!a?.geometryState)continue;a.updateNeighborData();let o=a.dirtyEdgeResolutions,s=a.geometryState,c=e=>{let t=lt[e];n(r,s.cornerPeerNeighbors[e]?.findCorner(at(t),e=>e.loaded))};for(let t=0;t<4;++t)if(o&1<<t){let i=a.geometryState.edgePeerNeighbors[t];i&&i?.level>=r.level&&i.forAllSubtreeOnSide(it(P[t]),t=>this._canUpdateTileGeometry(t)?(N(e.has(t)||U(r,t)<0),n(r,t),!0):!1),c((t+1)%4),c(t)}}e.clear(),t.sort(U),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,V&&ot&&this.checkAllTilesWaterproofness(`pending-geometries-updated`)}_mergeAndSplit(e,t){if(this.freeze||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let n=!1,r=this.view.state.fixedContentCamera,i=!1;for(;!e.done;){i=!0;let a=!1,o=!this._allTiles.some(i=>{if(!n&&!r&&!i.visible)return e.done;let o=i;if(i.hasPendingUpdate(4)){if(!t||i.unmergableChildCount>0)return e.done;for(i.resetPendingUpdate(4);o.parent!=null&&o.parent.unmergableChildCount===0&&o.parent.resetPendingUpdate(4);)o=o.parent;this._mergeTile(o),a=!0,e.madeProgress()}else if(i.resetPendingUpdate(1)){let t=!0,n=i.level;if(n>=A){let e=e=>e.leaf||n-e.level<A;for(let r=0;r<4;++r){let a=i.findNeighborTile(P[r],e);a!=null&&n-a.level===A&&(t=!1,V&&(N(a.leaf),N(a.hasPendingUpdate(1))))}}t?(this._splitTile(i),e.madeProgress(),a=!0):i.setPendingUpdate(1)}return e.done});if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0),o){if(!n){n=!0;continue}if(!a)break}else this._allTilesDirty=!0}i?e.madeProgress():this._allTilesDirty=!0,this._allTilesCreated=!this.allTiles.some(e=>e.hasPendingUpdate(1)||e.hasPendingUpdate(4)&&e.unmergableChildCount===0),this._sortTiles(e)}_updateElevation(e){e.done||this._allTiles.some(t=>(t.resetPendingUpdate(8)&&(this._updateTileGeometryState(t),e.madeProgress()),e.done))}updateElevationSources(e){e.needsElevationSourceUpdate()&&(e.updateAgents(0),e.markElevationSourceUpdateRequested(),this.requestUpdate())}_updateTextures(e){if(e.done)return!0;let t=!0;return this._allTiles.some(n=>(this._updateTileTexture(n,e)||(t=!1),e.done)),t}_updateClippingExtent(){this.spatialReference&&(this.updateOverlayParameters(),this.requestRender(1),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){return this.view.qualitySettings.tiledSurface.lodBias-(1-this.view.quality)*tt}_getLodBiasCorrectedScale(e){let t=this.tilingScheme.levels,n=te(e-this._lodBias,0,t.length-1),r=n-Math.floor(n),i=t[Math.floor(n)].scale,a=t[Math.ceil(n)].scale;return i*(1-r)+a*r}_removeAllTiles(){this.renderer.visible=!1,this._pendingTilesToUpdate.clear(),this._pendingTilesForElevationUpdateEvent.clear(),this._rootTiles!=null&&(this._rootTiles.forEach(e=>this._purgeTile(e)),this._setRootTiles(null),this.notifyChange(`ready`)),this._allTiles.clear(),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_purgeSubtree(e){let t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?Z(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(G._tileMemcacheKey,e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){j(e.leaf,`Tile that is already split should not be split again!`),j(e.rendered,`Tile marked to split is not rendered`),Z(e);let t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles}),e.updateAgentSuspension(),j(e.rendered,`parent should be rendered`),t.forEach(e=>this._loadTile(e)),t.forEach(e=>this._pendingTilesToUpdate.add(e)),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach(e=>X(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){Y.spatialReference=this.spatialReference,Y.extent=e.extent,Y.scale=this._getLodBiasCorrectedScale(t),this.emit(`scale-change`,Y)}createTile(e,t,n,r){j(!!r,`createTile sanity check`);let i=this._acquireTile(e,t,n,r);return i.updateClippingStatus(this.groundExtent),i.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(i)&&i.setPendingUpdate(1),i}get _shortBatches(){return this.view.state.mode!==2}_mergeTile(e){j(!e.hasPendingUpdate(1),`_mergeTile sanity check`),j(!e.leaf,`Cannot merge a leaf`),e.leaf||(this._purgeSubtree(e),j(!e.renderData,`Merging tile with existing render data?`),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),X(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&e.updateOverlayParameters(this.overlayManager)}_handleLayerViewChanges(e=Ae){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1,n=new Set,r=-1;for(let e=this.view.allLayerViews.length-1;e>=0;e--){let i=this.view.allLayerViews.items[e];if(n.add(i.uid),F(i)||I(i)){if(this._basemapLayerViewHandles.has(i.uid)&&!I(i)){let e=this._layerClassFromLayerView(i),n=this.getLayerIndexByUID(e,i.uid);n!=null&&((n<r||r==null)&&(t=!0),r=n)}else this._registerTiledLayerView(i),i.layer.loaded&&(t=!0)}}this._basemapLayerViewHandles.forEach((e,r)=>{n.has(r)||(this._unregisterTiledLayerView(r),t=!0)}),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(let e of this.view.allLayerViews.items)if(L(e)&&!Ee(e.layer)&&e.fullOpacity!==0)return!1;return!0}_hasCompositeBlendMode(){for(let e of this.view.allLayerViews.items)if((R(e)||I(e))&&Be(Ve[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return+!z(e)}_registerTiledLayerView(e){let t=[];if((R(e)||I(e))&&t.push(_(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!I(e)){let n=this._layerClassFromLayerView(e);t.push(_(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(_(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));let{layer:r}=e;`effectiveScaleRange`in r&&t.push(_(()=>!e.destroyed&&r.effectiveScaleRange,()=>this._restartAllAgents(n))),t.push(e.on(`data-changed`,()=>{let t=this.getLayerIndexByUID(n,e.uid);t!=null&&this._invalidateLayerData(t,n)}))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){let t=this._basemapLayerViewHandles.get(e);if(t){for(let e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;let e=this.view.allLayerViews,t=[[],[]],n=null;e.forEach(e=>{if(!e.layer||e.suspended||!F(e)||!e.fullExtent)return;let r=this._layerClassFromLayerView(e);if(r===1){let t=e.displayLevelRange.maxLevel;t!==1/0&&(n===null||t>n)&&(n=t)}t[r].push(e)});for(let e of Ke){let n=this._layerViews[e],r=t[e];r.reverse();let i=r.length,a=n.length!==i,o=Array(i),s=Array(n.length);this._layerIndexByUid[e].clear();for(let t=0;t<i;t++){let i=r[t].uid;this._layerIndexByUid[e].set(i,t);let c=n.indexOf(r[t]);o[t]=c,t!==c&&(a=!0),c>-1&&(s[c]=t)}if(a){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;)t.next().modifyLayers(s,o,e);this._layerViews[e]=r,this._restartAllAgents(e),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(n)&&(this._viewChangeUpdate(),this.notifyChange(`tilingScheme`))}_restartAllAgents(e){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){let n=t.next();n.restartAgents(e),e===0&&n.computeElevationBounds()}this._updateRootTileElevationRange()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll(t=>{t.updateAgents(1),e===1?this.renderer.updateTileTexture(t,16):t.updateRenderData(1,e)}),this._evaluateTransparency()}_invalidateLayerData(e,t){this._rootTiles!=null&&(W(this._rootTiles,n=>n.removeLayerAgent(e,t)),W(this._rootTiles,n=>{n.invalidateLayerData(e,t),n.restartAgents(t)}))}setTileTreeDirty(e){this._allTilesDirty=!0,e&&(this._allTilesCreated=!1)}requestRender(e=1){this.renderer.requestRender(e)}requestUpdate(){++this._pendingUpdates===1&&(this._hasPendingUpdates=!0)}requestTileData(e,t,n,r){let i=this.layerViewByIndex(t,n),{tilemapCache:a}=i;return!a||M(i)?this._requestTileData(e,n,i,r):(++this._asyncWorkItems,a.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).catch(t=>{throw ae(r),h(t)||this._dataMissing(e,n,i),t}).then(()=>this._frameTask.schedule(()=>this._requestTileData(e,n,i,r),r.signal)).finally(()=>--this._asyncWorkItems))}_requestTileData(e,t,n,r){return this.destroying?Promise.resolve():t===0?z(n)?this._requestElevationTileData(e,n,r):Promise.reject():L(n)?this._requestMapTileData(e,n,r):Promise.reject()}_requestElevationTileData(e,t,n){++this._asyncWorkItems;let r=r=>{!g(n)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},i=n=>{h(n)||(f.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${n}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,{...De,...n}).then(e=>this._frameTask.schedule(()=>r(e)),i).finally(()=>--this._asyncWorkItems)}_elevationDataArrived(e,t,n){let r=this._layerIndexByUid[0].get(t.uid);if(r==null){f.getLogger(this).warn(`TerrainSurface: received data from unknown layer %d %s`,0,e.lij.toString());return}let i=new Ue(e.lij,e.extent,n);e.dataArrived(r,0,i),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:0});let a=[e],o=e.level,s=this._iteratorPool.acquire();for(s.reset(a);!s.done;){let e=s.next();e.findElevationBoundsForLayer(r,o),e.computeElevationBounds()}o===0&&this._updateRootTileElevationRange(),s.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,n){++this._asyncWorkItems;let r=(r,i)=>{B(i),g(n)||(console.error(`Tile ${e.lij.toString()} layer 1/${t.uid} error ${r}`),this._dataMissing(e,1,t),this.requestUpdate())},i=e=>t=>r(t,e);return t.fetchTile(e.lij,n).then(r=>this._frameTask.schedule(()=>{this.requestUpdate(),g(n)?B(r):this._mapTileDataArrived(e,t,r)},n.signal,i(r)).catch(i(r)),(e,t=null)=>this._frameTask.schedule(()=>r(e,t))).finally(()=>--this._asyncWorkItems)}_mapTileDataArrived(e,t,n){let r=this.getLayerIndexByUID(1,t.uid);r==null?(B(n),f.getLogger(this).warn(`TerrainSurface: received data from unknown layer`)):(e.dataArrived(r,1,n),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:1}))}_dataMissing(e,t,n){let r=this.getLayerIndexByUID(t,n.uid);r==null?f.getLogger(this).warn(`TerrainSurface: received data from unknown layer`):(e.dataMissing(r,t),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:t}))}get performanceInfo(){let e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll(t=>{t.leaf&&e.numLeaves++;let n=t.level;t.renderData&&(e.numLoadedPerLevel[n]=(e.numLoadedPerLevel[n]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[n]=(e.numRenderedPerLevel[n]||0)+1,e.numRendered++))}),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(this._usedMemory??=this._recalculateUsedMemory(),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce((e,t)=>e+t.usedMemory,0)):null}getUsedMemoryForLayerView(e){let t=0,n=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(n,e.uid);return r!=null&&this._allTiles.forAll(e=>t+=e.getUsedMemoryForLayer(n,r)),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(e=`render-patch-groups`){}get isGeographic(){return this.spatialReference?.isGeographic??!1}get isWebMercator(){return this.spatialReference?.isWebMercator??!1}get isWebMercatorOnPlateCarree(){return this.isWebMercator&&xe(this.view?.renderSpatialReference)}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&e[2]===0}lijEastEnd(e){return 1<<e+ +!!this.isGeographic}wrapEastWest(e){let t=this.lijEastEnd(e[0]),n=e[2];if(0<=n&&n<t)return e;if(!this.isGlobal)return null;let r=(n+(n<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){st(e)}enableWaterproofnessChecks(e){ct(e)}static cleanupTerrainSurface(){St.prune()}enable(e){e!==this.enabled&&(this._set(`enabled`,e),e?(this._updateRootTiles(),this.freeze=!1,this.view.elevationProvider.register(0,this)):(this.view.elevationProvider.unregister(this),this.freeze=!0,this._removeAllTiles(),this._setRootTiles(null)),this.notifyChange(`ready`))}updateOverlayParameters(){let{overlayManager:e}=this;this.allTiles.forAll(t=>t.updateOverlayParameters(e))}};e([n()],K.prototype,`_renderer`,void 0),e([n({constructOnly:!0})],K.prototype,`_scaleRangeQueries`,void 0),e([n({constructOnly:!0})],K.prototype,`view`,void 0),e([n({constructOnly:!0})],K.prototype,`overlayManager`,void 0),e([n()],K.prototype,`_hasPendingUpdates`,void 0),e([n()],K.prototype,`_asyncWorkItems`,void 0),e([n()],K.prototype,`_allTilesDirty`,void 0),e([n()],K.prototype,`_allTilesSorted`,void 0),e([n()],K.prototype,`allTilesCreated`,null),e([n()],K.prototype,`_allTilesCreated`,void 0),e([n()],K.prototype,`_viewChanged`,void 0),e([n({type:Number})],K.prototype,`heading`,void 0),e([n()],K.prototype,`_splitLimits`,void 0),e([n()],K.prototype,`_frameTask`,void 0),e([n()],K.prototype,`_tileConstructor`,null),e([n()],K.prototype,`_ellipsoid`,null),e([n()],K.prototype,`demResolution`,null),e([n({readOnly:!0})],K.prototype,`snapLevel`,null),e([n({readOnly:!0})],K.prototype,`lodSnappingEnabled`,null),e([n()],K.prototype,`_stencilEnabledExtents`,null),e([n({readOnly:!0})],K.prototype,`userClippingExtent`,null),e([n()],K.prototype,`_rootTilesExtent`,void 0),e([n({readOnly:!0})],K.prototype,`groundExtent`,null),e([n({readOnly:!0})],K.prototype,`fullGroundExtent`,null),e([n({readOnly:!0})],K.prototype,`_tilingSchemeExtent`,null),e([n({readOnly:!0})],K.prototype,`updating`,null),e([n({readOnly:!0})],K.prototype,`readyToRun`,null),e([n(ze)],K.prototype,`updatingProgress`,void 0),e([n({readOnly:!0})],K.prototype,`updatingProgressValue`,null),e([n()],K.prototype,`_maxNumUpdating`,void 0),e([n()],K.prototype,`baseOpacity`,null),e([n()],K.prototype,`hasCompositeBlendMode`,void 0),e([n()],K.prototype,`maxTextureScale`,void 0),e([n({readOnly:!0})],K.prototype,`ready`,null),e([n({readOnly:!0})],K.prototype,`rootTiles`,null),e([n()],K.prototype,`_rootTiles`,void 0),e([n()],K.prototype,`spatialReference`,null),e([n({type:t})],K.prototype,`backgroundColor`,null),e([n({value:!1})],K.prototype,`slicePlaneEnabled`,null),e([n()],K.prototype,`tilingScheme`,null),e([n({readOnly:!0})],K.prototype,`tilingSchemeLocked`,null),e([n({readOnly:!0})],K.prototype,`tilingSchemeLogic`,void 0),e([n()],K.prototype,`wireframe`,null),e([n()],K.prototype,`opaque`,null),e([n()],K.prototype,`invisible`,null),e([n({value:!1})],K.prototype,`freeze`,null),e([n()],K.prototype,`fadeDuration`,null),e([n()],K.prototype,`_xNormalizer`,null),e([n()],K.prototype,`visibleElevationRange`,null),e([n()],K.prototype,`_rootTileElevationRange`,void 0),e([n()],K.prototype,`_layerViewsDirty`,void 0),e([n()],K.prototype,`renderPatchBorders`,null),e([n()],K.prototype,`renderingDisabled`,null),e([n()],K.prototype,`isGeographic`,null),e([n()],K.prototype,`isWebMercator`,null),e([n()],K.prototype,`isWebMercatorOnPlateCarree`,null),e([n({readOnly:!0})],K.prototype,`enabled`,void 0),K=G=e([r(`esri.views.3d.terrain.TerrainSurface`)],K);const yt=K,q=d(),bt=new Se,J=S(),xt=S(),St=new ie,Y={spatialReference:null,extent:null,scale:0};function Ct(e,t,n){for(let r of e){if(!r.containsPointXY(t,n))continue;let e=r;for(;e&&!e.renderData;){let r=+(t>e.extentMidX)+(n<e.extentMidY?2:0);e=e.children[r]}let i=e?.renderData?.geometryState.samplerData??null;return We(t,n,i)}return null}function X(e,t){!e.leaf||e.level<A||$(e,e=>{t&&wt(e);let n=Q(e);if(e.maxLevelDeltaNeighborCount++,n){let t=e.parent;for(;t;){let e=Q(t);if(t.unmergableChildCount++,e)t=t.parent;else break}}})}function wt(e){if(e.hasPendingUpdate(1))return;let t=e.parent;for(;t?.resetPendingUpdate(4);)t=t.parent;e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1),e.level<A||$(e,e=>{wt(e)})}function Z(e){e.level<A||$(e,e=>{if(e.maxLevelDeltaNeighborCount--,e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0){let t=e.parent;for(;t&&(t.unmergableChildCount--,Q(t));)t=t.parent}})}function Q(e){return e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0}function $(e,t){if(e.level<A)return;let n=e.level-A,r=e.lij[1]>>A,i=e.lij[2]>>A,a=e=>e.leaf||e.level===n;for(let o=0;o<4;++o){let s=e.findNeighborTile(P[o],a);if(!s||s.level!==n)continue;let c=s.lij;(c[1]!==r||c[2]!==i)&&t(s)}}export{yt as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../Color.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{filterInPlace as i,difference as a}from"../../../core/arrayUtils.js";import o from"../../../core/CollectionFlattener.js";import{toConst as s}from"../../../core/compilerUtils.js";import{EventedAccessor as c}from"../../../core/Evented.js";import"../../../core/has.js";import{set as l,copy as u,exactEquals as ee}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import f from"../../../core/Logger.js";import{clamp as te}from"../../../core/mathUtils.js";import{destroyMaybe as p,removeMaybe as ne}from"../../../core/maybe.js";import{MemCachePool as re}from"../../../core/MemCachePool.js";import m from"../../../core/ObjectPool.js";import ie from"../../../core/PooledArray.js";import{throwIfAborted as ae,isAbortError as h,isAborted as g}from"../../../core/promiseUtils.js";import{watch as _,syncAndInitial as v,initial as y,sync as b}from"../../../core/reactiveUtils.js";import"../../../core/scheduling.js";import{UpdatingHandles as oe}from"../../../core/support/UpdatingHandles.js";import{getMetersPerUnitForSR as se}from"../../../core/units.js";import{getReferenceEllipsoid as x,radiusModifier as ce}from"../../../geometry/ellipsoidUtils.js";import{projectBoundingSphere as le}from"../../../geometry/projection/projectBoundingSphere.js";import{getProjector as ue}from"../../../geometry/projection/projectors.js";import{projectPointToVector as de}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as fe}from"../../../geometry/projection/projectVectorToVector.js";import{projectWithoutEngine as pe}from"../../../geometry/projectionUtils.js";import me from"../../../geometry/SpatialReference.js";import{create as S,fromExtent as he,equals as C,intersection as ge,intersectsSphere as _e}from"../../../geometry/support/aaBoundingRect.js";import{copy as ve,create as ye}from"../../../geometry/support/frustumPlanes.js";import{createSpatialReferenceCyclical as be}from"../../../geometry/support/normalizeUtils.js";import{isGeographic as w,isPlateCarree as xe}from"../../../geometry/support/spatialReferenceUtils.js";import{Sphere as Se}from"../../../geometry/support/sphere.js";import{ElevationQueryTileCache as Ce}from"../../../layers/support/ElevationQueryTileCache.js";import{IntegratedMeshSemantics as we}from"../../../layers/support/IntegratedMeshSemantics.js";import{isIntegratedMeshLayer as Te,isBaseLayer as Ee}from"../../../layers/support/layerUtils.js";import{queueHighPriority as De}from"../../../request/queue.js";import{hasLayerBasedScaleVisibility as Oe}from"../../support/layerViewUtils.js";import{ImmediateTask as T,TaskPriority as ke,noBudget as Ae}from"../../support/Scheduler.js";import{TextureCompressionTracker as je}from"../../support/TextureCompressionTracker.js";import{Yield as Me}from"../../support/Yield.js";import{debugFlags as E}from"../support/debugFlags.js";import{ElevationRange as D}from"../support/ElevationRange.js";import{ElevationUpdateEvent as Ne}from"../support/ElevationUpdateEvent.js";import{calculateElevationUpdateExtents as Pe}from"../support/elevationUpdateExtentUtils.js";import{toBoundingRect as Fe}from"../support/extentUtils.js";import{geographicMbsToGeographicExtent as Ie,mbsToGeographicExtent as Le,intersectsGeographicExtent as Re}from"../support/sphereExtentUtils.js";import{isSupportedGCSOnGlobe as O}from"../support/supportedSpatialReference.js";import{updatingProgress as ze}from"../support/updatingProperties.js";import{isCompositeBlendMode as Be,blendModeFromString as Ve}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{ElevationBounds as He}from"./ElevationBounds.js";import{ElevationData as Ue,sampleElevation as We}from"./ElevationData.js";import{create as Ge}from"./ExtentHelper.js";import{LayerClasses as Ke}from"./LayerClass.js";import{OverlayManager as qe}from"./OverlayManager.js";import{PlanarPatch as Je}from"./PlanarPatch.js";import{Queue as Ye}from"./Queue.js";import{ScaleRangeQueries as Xe}from"./ScaleRangeQueries.js";import{SphericalPatch as Ze}from"./SphericalPatch.js";import{SplitLimits as Qe}from"./SplitLimits.js";import{maxRootTiles as k,tooManyRootTilesAfterChangeError as $e,tooManyRootTilesForLayerError as et,maxTileNeighborLevelDelta as A,maxMemoryLodBias as tt}from"./TerrainConst.js";import{TerrainRenderer as nt}from"./TerrainRenderer.js";import rt from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as j,isVectorTileLayerView as M,internalAssert as N,oppositeEdge as it,neighborEdgeIndices as P,isSurfaceLayerView as F,isGroupLayerView as I,isMapTileLayerView as L,isBlendableLayerView as R,isElevationLayerView as z,releaseTerrainData as B,oppositeCorner as at,enableTerrainInternalChecks as V,enableWaterproofTests as ot,enableInternalTerrainChecks as st,enableTerrainWaterproofChecks as ct,neighborCornerIndices as lt}from"./terrainUtils.js";import{Tile as ut,lijEquals as H}from"./Tile.js";import{printAllocations as dt}from"./TilePerLayerInfo.js";import{sortTiles as ft,IteratorPreorder as pt,IteratorPostorder as mt,compareTilesByLij as U,sortTilesByPOI as ht,traverseTilesPreorder as W}from"./tileUtils.js";import{TilingSchemeLogic as gt}from"./TilingSchemeLogic.js";import{getGroundTransparencyModeFromOpacity as _t}from"./TransparencyMode.js";import{UpsampleInfo as vt}from"./UpsampleInfo.js";var G;let K=class extends c{static{G=this}get allTilesCreated(){return this._allTilesCreated}get allTiles(){return s(this._allTiles)}get renderedTiles(){return ft(i(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get _tileConstructor(){return this.view.state.isGlobal?Ze:Je}get _ellipsoid(){return x(this.view.spatialReference)}get demResolution(){let{_allTiles:e,tilingScheme:t}=this;if(e.length===0)return{min:1,max:1};let n=se(t.spatialReference),r=1/0,i=-1/0;for(let a of e){let e=t.resolutionAtLevel(a.level)*n;r=Math.min(r,e),i=Math.max(i,e)}return{min:r,max:i}}constructor(e){super(e),this.terrainTextureCompressionTracker=new je,this._iteratorPool=new m(()=>new pt,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new mt,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._allTilesCreated=!1,this._usedMemory=null,this._performanceInfo=new rt,this._waterproofnessErrorHandle=null,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=d(),this._eyePosSurfaceSR=d(),this._splitLimits=new Qe,this._layerViews=[[],[]],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._updatingHandles=new oe,this._poiWatchHandle=null,this._frameTask=T,this._allTiles=new ie,this._upsampleInfoPool=new m(()=>new vt),this._shouldEmitChangeEvent=!1,this._lodSnappingEnabled=!0,this._rootTilesExtent=S(),this.updatingProgress=.5,this._maxNumUpdating=1,this.hasCompositeBlendMode=!1,this.maxTextureScale=1.2,this._elevationProjectorCache=new Map,this._rootTileElevationRange=new D(1/0,-1/0),this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this.enabled=!0,this.overlayManager=new qe({...e,terrainSurface:this}),this._renderer=new nt(this,this.overlayManager.renderer,this._allTiles,this.terrainTextureCompressionTracker,e.view),Oe()||(this._scaleRangeQueries=new Xe)}initialize(){let{view:e}=this,{resourceController:t}=e,{memoryController:n}=t;e.stage.addRenderPlugin(this._renderer),this._tileCache=new re((e,t)=>n.newCache(e,t),`terrain-tile`),this._upsampleMapCache=n.newCache(`terrain-upsample`,({tile:e})=>e.unloadMapData()),this._elevationQueryCache=new Ce(n.newCache(`elevation-query`));let r=this.overlayManager;this.addHandles([_(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),_(()=>this.renderer.visible,e=>this.freeze=!e),_(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)},v)],`overlayManager`),this._updatingHandles.add(()=>({heading:e.camera?.heading,state:e.state?.mode}),({heading:e,state:t})=>{if(e==null)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree){this.heading=Math.round(e/90)*90%360;return}let n=Math.round(e)%360,r=Math.abs(n-this.heading);(t===2||Math.min(r,360-r)>=30)&&(this.heading=n)},y),this.addHandles([_(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},v),_(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),v),_(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},b),_(()=>this.snapLevel,()=>this._viewChanged=!0,b),_(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._poiWatchHandle=ne(this._poiWatchHandle),e&&(this._poiWatchHandle=this._updatingHandles.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:ee}))}),_(()=>E.TERRAIN_TILE_TREE_SHOW_TILES,t=>{t&&!this._treeDebugger?import(`../layers/support/TerrainTileTree3DDebugger.js`).then(({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&E.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))}):t||(this._treeDebugger=p(this._treeDebugger))},y),_(()=>this.tilingScheme,e=>this._updateTilingScheme(e),b)]);let{spatialReference:i}=e;this._extentHelper=Ge(this.isGlobal,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:i});let a=new o({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&`layers`in e?e.layers:null}),s=new gt({layers:a,extentHelper:this._extentHelper,isGlobal:this.isGlobal,viewSpatialReference:i});this._set(`tilingSchemeLogic`,s);let c=t.scheduler;this._frameTask=c.registerTask(ke.TERRAIN_SURFACE,this),this.addHandles([_(()=>this._stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),y),_(()=>this.groundExtent,()=>this._updateRootTiles(),y),e.on(`resize`,()=>this._viewChangeUpdate()),_(()=>{let t=e.state;return[this._lodBias,this._lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),v),_(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,y),_(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,y),_(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>{this._allTiles.forAll(e=>this.updateElevationSources(e)),this._updateAllTileGeometries()}),e.allLayerViews.on(`after-changes`,()=>this._layerViewsDirty=!0)]),this._updatingHandles.add(()=>this.userClippingExtent,()=>this._updateClippingExtent()),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}clearHandles(){this._updatingHandles?.removeAll(),this.removeAllHandles(),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear()}destroy(){this._waterproofnessErrorHandle?.remove(),this._waterproofnessErrorHandle=null,this._frameTask.remove(),this._frameTask=T,this._updatingHandles?.destroy(),this._removeAllTiles(),this._set(`tilingSchemeLogic`,p(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._set(`overlayManager`,p(this.overlayManager)),this._tileCache=p(this._tileCache),this._allTiles.prune(),ut.prune(),this._treeDebugger=p(this._treeDebugger),this._renderer.destroyed||(this.view.stage.removeRenderPlugin(this._renderer),this._renderer.destroy()),this._renderer=null,this._iteratorPool=p(this._iteratorPool),this._upsampleMapCache=p(this._upsampleMapCache),this._elevationQueryCache=p(this._elevationQueryCache),this._set(`view`,null),this._extentHelper=p(this._extentHelper),this._upsampleInfoPool=p(this._upsampleInfoPool),dt(),this._layerViews.forEach(e=>e.length=0),this._performanceInfo=null}get renderer(){return this._renderer}get frustum(){return this.view.state.camera.frustum}get snapLevel(){return this._lodSnappingEnabled?this.view.terrainLevel:null}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return!!this._stencilEnabledExtents?.length}get _stencilEnabledExtents(){let e=this.spatialReference;return e==null?null:Iterator.from(this.view.allLayerViews).map(t=>{let{layer:n}=t;if(!Te(n)||!we.shouldStencilTerrain(n))return null;let{fullExtent:r}=n,i=r==null||r.spatialReference.equals(e)?r:pe(r,r.spatialReference,e);return i?he(i):null}).filter(e=>e!=null).toArray()}get userClippingExtent(){let{spatialReference:e}=this,t=this.view?.clippingArea;if(t==null||e==null)return null;let n=S(),r=Fe(t,n,e)?n:null,i=this._get(`userClippingExtent`);return C(r,i)?i:r}get rootTilesExtent(){return this._rootTilesExtent}get groundExtent(){let e=ge(this.fullGroundExtent,this.userClippingExtent,S()),t=this._get(`groundExtent`);return C(e,t)?t:e}get fullGroundExtent(){return this._tilingSchemeExtent==null?this._rootTilesExtent:this._tilingSchemeExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),this.enabled&&!!((this.readyToRun||this._updatingHandles?.updating||this._asyncWorkItems>0)&&this.ready&&!this.freeze||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get readyToRun(){return this.enabled&&(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.freeze}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get isGlobal(){return this.view.state.isGlobal}get ready(){return!this.enabled||this._rootTiles!=null}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??me.WebMercator}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set(`slicePlaneEnabled`,e),this._evaluateTransparency()}get tilingScheme(){return this.tilingSchemeLogic?.tilingScheme}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===0}get invisible(){return this._renderer.transparency===3}set freeze(e){this._set(`freeze`,e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,n,r){this._renderer.intersectRay(e,t,n,r)}intersectBudgeted(e,t,n,r,i){return this._renderer.intersectRayBudgeted(e,t,n,r,i)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}get _xNormalizer(){return be(this.spatialReference)}getElevation(e,t,n,r){let i=this._rootTiles;if(!i?.length||!this.enabled||i[0].layerInfo[0].length===0)return null;let a=this._elevationProjectorCache.get(r);if(a===void 0&&(a=ue(r,this.spatialReference)??null,this._elevationProjectorCache.set(r,a)),a==null)return f.getLogger(this).error(`TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system`),null;let o=l(q,e,t,n);return a(o,0,o,0),Ct(i,this._xNormalizer?.normalize(o[0])??o[0],o[1])}getElevations(e,t,n){let r=this._rootTiles,i=r?r[0].layerInfo[0].length:0;if(!r?.length||i===0||!this.enabled)for(let e=0;e<t;++e)n(e,null);else for(let i=0;i<t;++i){let t=i*3,a=Ct(r,e[t],e[t+1]);n(i,a)}}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}get visibleElevationRange(){let e=1/0,t=-1/0;for(let n of this._allTiles)n.renderData&&(e=Math.min(e,n.elevationBoundsMin),t=Math.max(t,n.elevationBoundsMax));let n=this._get(`visibleElevationRange`);return n?.minElevation===e&&n.maxElevation===t?n:new D(e,t)}invalidateElevationRange(){this.notifyChange(`visibleElevationRange`)}tileElevationRangeChanged(e,t=1/0,n=-1/0){let r=this._get(`visibleElevationRange`);(!r||t===r.minElevation||n===r.maxElevation||e.renderData&&(e.elevationBoundsMin<r.minElevation||e.elevationBoundsMax>r.maxElevation))&&this.invalidateElevationRange()}getScale(e){if(!this.tilingScheme)return null;if(!de(e,q,this.spatialReference))return f.getLogger(this).error(`TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system`),null;let t=this._rootTiles;if(t!=null){for(let e of t)if(e?.containsPoint(q)){let t=e;for(;t.children[0]&&!t.rendered;){let e=t.children[0].extent,n=0;q[0]>e[2]&&(n+=1),q[1]<e[1]&&(n+=2),t=t.children[n]}return this._getLodBiasCorrectedScale(t.level)}}return 1/0}getSphereElevationRange(e,t){if(!this.enabled)return null;let n=this._rootTiles,r=this.spatialReference;if(n==null||r==null||n.length===0)return null;let i=w(r);if(i){let n=w(t)&&O(t),i=x(t);if(n&&O(r)&&i===x(r))Ie(e,J,i.radius);else if(!Le(e,t,J,r))return f.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project the query sphere`),null}else if(!le(e,t,bt,r))return f.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project the query sphere`),null;let a=new D,o=[];for(let e of n)o.push(e);let s=0;for(;s<o.length;){let e=o[s];if(++s,!(i?Re(e.extent,J,r):_e(e.extent,bt)))continue;let t=e.children;if(t[0]==null||e.rendered)a.expandElevationRangeValues(e.elevationBoundsMin,e.elevationBoundsMax);else for(let e of t)o.push(e)}return a}getRootElevationRange(){return this.enabled&&this._rootTiles?new D(this._rootTileElevationRange.minElevation,this._rootTileElevationRange.maxElevation):null}getLowerBoundRadius(){let e=this.visibleElevationRange,t=(this._ellipsoid.radius+(e.isEmpty?0:e.minElevation))*ce;return Math.min(t,this._ellipsoid.radius)}queryVisibleScaleRange(e,t,n,r){if(!this._scaleRangeQueries)return;let i=t?this.tilingScheme.levelAtScale(t):0,a=n?this.tilingScheme.levelAtScale(n):1/0,o=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,i+o,a+o,r)}_evaluateTransparency(){let e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,n=this._renderer.transparency,r=this._isFullyTransparent?_t(0,t):e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?0:1;return this._renderer.transparency=r,n!==r&&(this.notifyChange(`opaque`),this.notifyChange(`invisible`),!0)}_updateTilingScheme(e){j(!!e,`tiling scheme cannot be reset to undefined`),e&&this._removeAllTiles(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey=`TerrainTileMemcache`}_acquireTile(e,t,n,r){let i=this._tileCache.pop(G._tileMemcacheKey);return i?(i.init(e,t,n,r,this),i):new this._tileConstructor(e,t,n,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){let{groundExtent:e,tilingScheme:t}=this;if(!t)return;if(!this.enabled){this._setRootTiles(null);return}let n=xt,r=t.rootTilesInExtent(e,n,k*5);if(this._rootTiles!=null){if(r.length>k){f.getLogger(this).warn($e);return}let e=this._rootTiles.map(e=>e.lij),t=a(e,r,H);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){let e=this._rootTiles.filter(e=>t.removed.findIndex(t=>H(t,e.lij))>-1?(this._purgeTile(e),!1):!0);t.added.forEach(t=>e.push(this._newRootTile(t))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,r.length>k&&(f.getLogger(this).warn(et),r=t.rootTilesInExtent(e,n,k)),this._setRootTiles(r.map(e=>this._newRootTile(e)));C(n,this._rootTilesExtent)||(this._rootTilesExtent=S(n)),this.renderer.visible=!0,this.overlayManager.setPlacementDirty(),this.notifyChange(`ready`),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this._viewChangeUpdate(),this.checkAllTilesWaterproofness(`root-tiles-updated`)}_updateAllTileGeometries(){let e=this._allTiles.filter(e=>this._canUpdateTileGeometry(e));e.length===0||(e.sort(U),e.forEach(e=>this._renderer.updateTileGeometryState(e)),e.forEach(e=>e.renderData.updateNeighborData()),this._updateTilesGeometries(e)),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){let t=e.filter(e=>this._canUpdateTileGeometry(e));if(t.length===0)return;let n=this.renderer;for(let e of t)n.updateGeometryIfNeeded(e);for(let e of t)this._pendingTilesForElevationUpdateEvent.add(e)}_canUpdateTileGeometry(e){return e.loaded&&e.intersectsClippingArea&&e.hasGeometryState}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===1}_newRootTile(e){let t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(1),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationRange(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),e!=null){let t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this.invalidateElevationRange(),this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.freeze&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask||this._updatingRootTiles?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.groundExtent)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(e==null)return;let t=this.groundExtent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty(!1);let r=this._iteratorPool.acquire();for(r.reset(e);!r.done;){let e=r.next();e.updateClippingStatus(t)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n)}r.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries()}_updateRootTileElevationRange(){let e=1/0,t=-1/0;this._rootTiles?.forEach(({elevationBoundsMin:n,elevationBoundsMax:r})=>{e=Math.min(e,n),t=Math.max(t,r)});let n=this._rootTileElevationRange;(n.minElevation!==e||n.maxElevation!==t)&&(this._rootTileElevationRange=new He(e,t))}_updateViewDependentParameters(){let{camera:e,contentCamera:t}=this.view.state,n=Math.tan(t.fovX*.5),r=Math.tan(t.fovY*.5),i=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=n,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=i/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=i/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=ve(this._splitLimits.frustum??ye(),t.frustum):this._splitLimits.frustum=null,u(this._eyePosRenderSR,t.eye),fe(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility(),this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){let t;e.forEachLoadedNeighbor(e=>{t??=this._layerViews[1].some(M),t&&e.setPendingUpdate(32),this._pendingTilesToUpdate.add(e)})}_updateTileTexture(e,t){let n=e.hasPendingUpdate(32)?32:e.hasPendingUpdate(16)?16:!1;if(n){let r=this._renderer.updateTileTexture(e,n);return this._usedMemory=null,r&&e.resetPendingUpdate(n),t.madeProgress(),r}return!0}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;let e=this._pendingTilesForElevationUpdateEvent;if(e.size>0){let t=new Float64Array(4*e.size),n=0;for(let r of e)t.set(r.extent,4*n),++n;e.clear();for(let e of Pe(t,this.spatialReference)){let t=new Ne(this.spatialReference,e,`ground`);this.emit(`elevation-change`,t)}}this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);let t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),this._updateElevation(e);let n=this._updateTextures(e);t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty();let r=this._pendingTilesToUpdate.size>0,i=r&&this._hasPendingGeometryWithoutIndices();if((!e.done||i)&&this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&(e.hasProgressed||r&&!i)&&this.requestUpdate(),this.notifyChange(`updatingProgressValue`),!n||!e.hasProgressed)return Me}_checkTileInvariant(){}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;let t=!1,n=new Ye(this._allTiles.length);n.pushAll(this._rootTiles);let r=this.snapLevel,i=this._splitLimits,a=this._eyePosRenderSR;this._allTiles.forAll(e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0});let o=this.view.state.contentCamera.viewProjectionMatrix;for(;!n.empty;){let e=n.pop(),s=e.parent?.hasPendingUpdate(4),c=e.elevationLevel,l=s?4:e.shouldSplit(i,a,r),u=l===1;e.leaf?X(e,u):n.pushAll(e.children),s?(e.resetPendingUpdate(1),e.leaf||(e.setPendingUpdate(4),t=!0),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(o)):(u?(e.resetPendingUpdate(4),e.leaf&&(e.setPendingUpdate(1),t=!0)):(e.resetPendingUpdate(1)&&e.updateAgentSuspension(),l===2&&e.updateAgents(0),e.leaf||(e.setPendingUpdate(4),e.resetPendingUpdate(1),t=!0)),e.elevationLevel!==c&&this.updateElevationSources(e))}this._allTilesDirty=t,this.requestUpdate(),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){!e.done&&!this._allTilesSorted&&this.view.pointsOfInterest?.focus&&(ht(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger?.update(),e.madeProgress())}_markTileToUpdate(e){N(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_hasPendingGeometryWithoutIndices(){for(let e of this._pendingTilesToUpdate)if(e.loaded&&e.intersectsClippingArea&&e.renderData?.vao?.indexBuffer==null)return!0;return!1}_updatePendingTileGeometries(){let e=this._pendingTilesToUpdate,t=[];if(e.forEach(e=>{this._canUpdateTileGeometry(e)&&t.push(e)}),t.length===0){e.clear();return}let n=(n,r)=>{!r||!this._canUpdateTileGeometry(r)||r.level<n.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(U);let r=t.length;for(let i=0;i<r;++i){let r=t[i];N(r.loaded),N(r.intersectsClippingArea);let a=r.renderData;if(!a?.geometryState)continue;a.updateNeighborData();let o=a.dirtyEdgeResolutions,s=a.geometryState,c=e=>{let t=lt[e];n(r,s.cornerPeerNeighbors[e]?.findCorner(at(t),e=>e.loaded))};for(let t=0;t<4;++t)if(o&1<<t){let i=a.geometryState.edgePeerNeighbors[t];i&&i?.level>=r.level&&i.forAllSubtreeOnSide(it(P[t]),t=>this._canUpdateTileGeometry(t)?(N(e.has(t)||U(r,t)<0),n(r,t),!0):!1),c((t+1)%4),c(t)}}e.clear(),t.sort(U),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,V&&ot&&this.checkAllTilesWaterproofness(`pending-geometries-updated`)}_mergeAndSplit(e,t){if(this.freeze||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let n=!1,r=this.view.state.fixedContentCamera,i=!1;for(;!e.done;){i=!0;let a=!1,o=!this._allTiles.some(i=>{if(!n&&!r&&!i.visible)return e.done;let o=i;if(i.hasPendingUpdate(4)){if(!t||i.unmergableChildCount>0)return e.done;for(i.resetPendingUpdate(4);o.parent!=null&&o.parent.unmergableChildCount===0&&o.parent.resetPendingUpdate(4);)o=o.parent;this._mergeTile(o),a=!0,e.madeProgress()}else if(i.resetPendingUpdate(1)){let t=!0,n=i.level;if(n>=A){let e=e=>e.leaf||n-e.level<A;for(let r=0;r<4;++r){let a=i.findNeighborTile(P[r],e);a!=null&&n-a.level===A&&(t=!1,V&&(N(a.leaf),N(a.hasPendingUpdate(1))))}}t?(this._splitTile(i),e.madeProgress(),a=!0):i.setPendingUpdate(1)}return e.done});if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0),o){if(!n){n=!0;continue}if(!a)break}else this._allTilesDirty=!0}i?e.madeProgress():this._allTilesDirty=!0,this._allTilesCreated=!this.allTiles.some(e=>e.hasPendingUpdate(1)||e.hasPendingUpdate(4)&&e.unmergableChildCount===0),this._sortTiles(e)}_updateElevation(e){e.done||this._allTiles.some(t=>(t.resetPendingUpdate(8)&&(this._updateTileGeometryState(t),e.madeProgress()),e.done))}updateElevationSources(e){e.needsElevationSourceUpdate()&&(e.updateAgents(0),e.markElevationSourceUpdateRequested(),this.requestUpdate())}_updateTextures(e){if(e.done)return!0;let t=!0;return this._allTiles.some(n=>(this._updateTileTexture(n,e)||(t=!1),e.done)),t}_updateClippingExtent(){this.spatialReference&&(this.updateOverlayParameters(),this.requestRender(1),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){return this.view.qualitySettings.tiledSurface.lodBias-(1-this.view.quality)*tt}_getLodBiasCorrectedScale(e){let t=this.tilingScheme.levels,n=te(e-this._lodBias,0,t.length-1),r=n-Math.floor(n),i=t[Math.floor(n)].scale,a=t[Math.ceil(n)].scale;return i*(1-r)+a*r}_removeAllTiles(){this.renderer.visible=!1,this._pendingTilesToUpdate.clear(),this._pendingTilesForElevationUpdateEvent.clear(),this._rootTiles!=null&&(this._rootTiles.forEach(e=>this._purgeTile(e)),this._setRootTiles(null),this.notifyChange(`ready`)),this._allTiles.clear(),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_purgeSubtree(e){let t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?Z(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(G._tileMemcacheKey,e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){j(e.leaf,`Tile that is already split should not be split again!`),j(e.rendered,`Tile marked to split is not rendered`),Z(e);let t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles}),e.updateAgentSuspension(),j(e.rendered,`parent should be rendered`),t.forEach(e=>this._loadTile(e)),t.forEach(e=>this._pendingTilesToUpdate.add(e)),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach(e=>X(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){Y.spatialReference=this.spatialReference,Y.extent=e.extent,Y.scale=this._getLodBiasCorrectedScale(t),this.emit(`scale-change`,Y)}createTile(e,t,n,r){j(!!r,`createTile sanity check`);let i=this._acquireTile(e,t,n,r);return i.updateClippingStatus(this.groundExtent),i.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(i)&&i.setPendingUpdate(1),i}get _shortBatches(){return this.view.state.mode!==2}_mergeTile(e){j(!e.hasPendingUpdate(1),`_mergeTile sanity check`),j(!e.leaf,`Cannot merge a leaf`),e.leaf||(this._purgeSubtree(e),j(!e.renderData,`Merging tile with existing render data?`),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),X(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&e.updateOverlayParameters(this.overlayManager)}_handleLayerViewChanges(e=Ae){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1,n=new Set,r=-1;for(let e=this.view.allLayerViews.length-1;e>=0;e--){let i=this.view.allLayerViews.items[e];if(n.add(i.uid),F(i)||I(i)){if(this._basemapLayerViewHandles.has(i.uid)&&!I(i)){let e=this._layerClassFromLayerView(i),n=this.getLayerIndexByUID(e,i.uid);n!=null&&((n<r||r==null)&&(t=!0),r=n)}else this._registerTiledLayerView(i),i.layer.loaded&&(t=!0)}}this._basemapLayerViewHandles.forEach((e,r)=>{n.has(r)||(this._unregisterTiledLayerView(r),t=!0)}),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(let e of this.view.allLayerViews.items)if(L(e)&&!Ee(e.layer)&&e.fullOpacity!==0)return!1;return!0}_hasCompositeBlendMode(){for(let e of this.view.allLayerViews.items)if((R(e)||I(e))&&Be(Ve[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return+!z(e)}_registerTiledLayerView(e){let t=[];if((R(e)||I(e))&&t.push(_(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!I(e)){let n=this._layerClassFromLayerView(e);t.push(_(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(_(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));let{layer:r}=e;`effectiveScaleRange`in r&&t.push(_(()=>!e.destroyed&&r.effectiveScaleRange,()=>this._restartAllAgents(n))),t.push(e.on(`data-changed`,()=>{let t=this.getLayerIndexByUID(n,e.uid);t!=null&&this._invalidateLayerData(t,n)}))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){let t=this._basemapLayerViewHandles.get(e);if(t){for(let e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;let e=this.view.allLayerViews,t=[[],[]],n=null;e.forEach(e=>{if(!e.layer||e.suspended||!F(e)||!e.fullExtent)return;let r=this._layerClassFromLayerView(e);if(r===1){let t=e.displayLevelRange.maxLevel;t!==1/0&&(n===null||t>n)&&(n=t)}t[r].push(e)});for(let e of Ke){let n=this._layerViews[e],r=t[e];r.reverse();let i=r.length,a=n.length!==i,o=Array(i),s=Array(n.length);this._layerIndexByUid[e].clear();for(let t=0;t<i;t++){let i=r[t].uid;this._layerIndexByUid[e].set(i,t);let c=n.indexOf(r[t]);o[t]=c,t!==c&&(a=!0),c>-1&&(s[c]=t)}if(a){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;)t.next().modifyLayers(s,o,e);this._layerViews[e]=r,this._restartAllAgents(e),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(n)&&(this._viewChangeUpdate(),this.notifyChange(`tilingScheme`))}_restartAllAgents(e){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){let n=t.next();n.restartAgents(e),e===0&&n.computeElevationBounds()}this._updateRootTileElevationRange()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll(t=>{t.updateAgents(1),e===1?this.renderer.updateTileTexture(t,16):t.updateRenderData(1,e)}),this._evaluateTransparency()}_invalidateLayerData(e,t){this._rootTiles!=null&&(W(this._rootTiles,n=>n.removeLayerAgent(e,t)),W(this._rootTiles,n=>{n.invalidateLayerData(e,t),n.restartAgents(t)}))}setTileTreeDirty(e){this._allTilesDirty=!0,e&&(this._allTilesCreated=!1)}requestRender(e=1){this.renderer.requestRender(e)}requestUpdate(){++this._pendingUpdates===1&&(this._hasPendingUpdates=!0)}requestTileData(e,t,n,r){let i=this.layerViewByIndex(t,n),{tilemapCache:a}=i;return!a||M(i)?this._requestTileData(e,n,i,r):(++this._asyncWorkItems,a.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).catch(t=>{throw ae(r),h(t)||this._dataMissing(e,n,i),t}).then(()=>this._frameTask.schedule(()=>this._requestTileData(e,n,i,r),r.signal)).finally(()=>--this._asyncWorkItems))}_requestTileData(e,t,n,r){return this.destroying?Promise.resolve():t===0?z(n)?this._requestElevationTileData(e,n,r):Promise.reject():L(n)?this._requestMapTileData(e,n,r):Promise.reject()}_requestElevationTileData(e,t,n){++this._asyncWorkItems;let r=r=>{!g(n)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},i=n=>{h(n)||(f.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${n}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,{...De,...n}).then(e=>this._frameTask.schedule(()=>r(e)),i).finally(()=>--this._asyncWorkItems)}_elevationDataArrived(e,t,n){let r=this._layerIndexByUid[0].get(t.uid);if(r==null){f.getLogger(this).warn(`TerrainSurface: received data from unknown layer %d %s`,0,e.lij.toString());return}let i=new Ue(e.lij,e.extent,n);e.dataArrived(r,0,i),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:0});let a=[e],o=e.level,s=this._iteratorPool.acquire();for(s.reset(a);!s.done;){let e=s.next();e.findElevationBoundsForLayer(r,o),e.computeElevationBounds()}o===0&&this._updateRootTileElevationRange(),s.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,n){++this._asyncWorkItems;let r=(r,i)=>{B(i),g(n)||(console.error(`Tile ${e.lij.toString()} layer 1/${t.uid} error ${r}`),this._dataMissing(e,1,t),this.requestUpdate())},i=e=>t=>r(t,e);return t.fetchTile(e.lij,n).then(r=>this._frameTask.schedule(()=>{this.requestUpdate(),g(n)?B(r):this._mapTileDataArrived(e,t,r)},n.signal,i(r)).catch(i(r)),(e,t=null)=>this._frameTask.schedule(()=>r(e,t))).finally(()=>--this._asyncWorkItems)}_mapTileDataArrived(e,t,n){let r=this.getLayerIndexByUID(1,t.uid);r==null?(B(n),f.getLogger(this).warn(`TerrainSurface: received data from unknown layer`)):(e.dataArrived(r,1,n),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:1}))}_dataMissing(e,t,n){let r=this.getLayerIndexByUID(t,n.uid);r==null?f.getLogger(this).warn(`TerrainSurface: received data from unknown layer`):(e.dataMissing(r,t),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:t}))}get performanceInfo(){let e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll(t=>{t.leaf&&e.numLeaves++;let n=t.level;t.renderData&&(e.numLoadedPerLevel[n]=(e.numLoadedPerLevel[n]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[n]=(e.numRenderedPerLevel[n]||0)+1,e.numRendered++))}),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(this._usedMemory??=this._recalculateUsedMemory(),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce((e,t)=>e+t.usedMemory,0)):null}getUsedMemoryForLayerView(e){let t=0,n=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(n,e.uid);return r!=null&&this._allTiles.forAll(e=>t+=e.getUsedMemoryForLayer(n,r)),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(e=`render-patch-groups`){}get isGeographic(){return this.spatialReference?.isGeographic??!1}get isWebMercator(){return this.spatialReference?.isWebMercator??!1}get isWebMercatorOnPlateCarree(){return this.isWebMercator&&xe(this.view?.renderSpatialReference)}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&e[2]===0}lijEastEnd(e){return 1<<e+ +!!this.isGeographic}wrapEastWest(e){let t=this.lijEastEnd(e[0]),n=e[2];if(0<=n&&n<t)return e;if(!this.isGlobal)return null;let r=(n+(n<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){st(e)}enableWaterproofnessChecks(e){ct(e)}static cleanupTerrainSurface(){St.prune()}enable(e){e!==this.enabled&&(this._set(`enabled`,e),e?(this._updateRootTiles(),this.freeze=!1,this.view.elevationProvider.register(0,this)):(this.view.elevationProvider.unregister(this),this.freeze=!0,this._removeAllTiles(),this._setRootTiles(null)),this.notifyChange(`ready`))}updateOverlayParameters(){let{overlayManager:e}=this;this.allTiles.forAll(t=>t.updateOverlayParameters(e))}};e([n()],K.prototype,`_renderer`,void 0),e([n({constructOnly:!0})],K.prototype,`_scaleRangeQueries`,void 0),e([n({constructOnly:!0})],K.prototype,`view`,void 0),e([n({constructOnly:!0})],K.prototype,`overlayManager`,void 0),e([n()],K.prototype,`_hasPendingUpdates`,void 0),e([n()],K.prototype,`_asyncWorkItems`,void 0),e([n()],K.prototype,`_allTilesDirty`,void 0),e([n()],K.prototype,`_allTilesSorted`,void 0),e([n()],K.prototype,`allTilesCreated`,null),e([n()],K.prototype,`_allTilesCreated`,void 0),e([n()],K.prototype,`_viewChanged`,void 0),e([n({type:Number})],K.prototype,`heading`,void 0),e([n()],K.prototype,`_splitLimits`,void 0),e([n()],K.prototype,`_frameTask`,void 0),e([n()],K.prototype,`_tileConstructor`,null),e([n()],K.prototype,`_ellipsoid`,null),e([n()],K.prototype,`demResolution`,null),e([n({readOnly:!0})],K.prototype,`snapLevel`,null),e([n()],K.prototype,`_lodSnappingEnabled`,void 0),e([n()],K.prototype,`_stencilEnabledExtents`,null),e([n({readOnly:!0})],K.prototype,`userClippingExtent`,null),e([n()],K.prototype,`_rootTilesExtent`,void 0),e([n({readOnly:!0})],K.prototype,`groundExtent`,null),e([n({readOnly:!0})],K.prototype,`fullGroundExtent`,null),e([n({readOnly:!0})],K.prototype,`_tilingSchemeExtent`,null),e([n({readOnly:!0})],K.prototype,`updating`,null),e([n({readOnly:!0})],K.prototype,`readyToRun`,null),e([n(ze)],K.prototype,`updatingProgress`,void 0),e([n({readOnly:!0})],K.prototype,`updatingProgressValue`,null),e([n()],K.prototype,`_maxNumUpdating`,void 0),e([n()],K.prototype,`baseOpacity`,null),e([n()],K.prototype,`hasCompositeBlendMode`,void 0),e([n()],K.prototype,`maxTextureScale`,void 0),e([n({readOnly:!0})],K.prototype,`ready`,null),e([n({readOnly:!0})],K.prototype,`rootTiles`,null),e([n()],K.prototype,`_rootTiles`,void 0),e([n()],K.prototype,`spatialReference`,null),e([n({type:t})],K.prototype,`backgroundColor`,null),e([n({value:!1})],K.prototype,`slicePlaneEnabled`,null),e([n()],K.prototype,`tilingScheme`,null),e([n({readOnly:!0})],K.prototype,`tilingSchemeLocked`,null),e([n({readOnly:!0})],K.prototype,`tilingSchemeLogic`,void 0),e([n()],K.prototype,`wireframe`,null),e([n()],K.prototype,`opaque`,null),e([n()],K.prototype,`invisible`,null),e([n({value:!1})],K.prototype,`freeze`,null),e([n()],K.prototype,`fadeDuration`,null),e([n()],K.prototype,`_xNormalizer`,null),e([n()],K.prototype,`visibleElevationRange`,null),e([n()],K.prototype,`_rootTileElevationRange`,void 0),e([n()],K.prototype,`_layerViewsDirty`,void 0),e([n()],K.prototype,`renderPatchBorders`,null),e([n()],K.prototype,`renderingDisabled`,null),e([n()],K.prototype,`isGeographic`,null),e([n()],K.prototype,`isWebMercator`,null),e([n()],K.prototype,`isWebMercatorOnPlateCarree`,null),e([n({readOnly:!0})],K.prototype,`enabled`,void 0),K=G=e([r(`esri.views.3d.terrain.TerrainSurface`)],K);const yt=K,q=d(),bt=new Se,J=S(),xt=S(),St=new ie,Y={spatialReference:null,extent:null,scale:0};function Ct(e,t,n){for(let r of e){if(!r.containsPointXY(t,n))continue;let e=r;for(;e&&!e.renderData;){let r=+(t>e.extentMidX)+(n<e.extentMidY?2:0);e=e.children[r]}let i=e?.renderData?.geometryState.samplerData??null;return We(t,n,i)}return null}function X(e,t){!e.leaf||e.level<A||$(e,e=>{t&&wt(e);let n=Q(e);if(e.maxLevelDeltaNeighborCount++,n){let t=e.parent;for(;t;){let e=Q(t);if(t.unmergableChildCount++,e)t=t.parent;else break}}})}function wt(e){if(e.hasPendingUpdate(1))return;let t=e.parent;for(;t?.resetPendingUpdate(4);)t=t.parent;e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1),e.level<A||$(e,e=>{wt(e)})}function Z(e){e.level<A||$(e,e=>{if(e.maxLevelDeltaNeighborCount--,e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0){let t=e.parent;for(;t&&(t.unmergableChildCount--,Q(t));)t=t.parent}})}function Q(e){return e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0}function $(e,t){if(e.level<A)return;let n=e.level-A,r=e.lij[1]>>A,i=e.lij[2]>>A,a=e=>e.leaf||e.level===n;for(let o=0;o<4;++o){let s=e.findNeighborTile(P[o],a);if(!s||s.level!==n)continue;let c=s.lij;(c[1]!==r||c[2]!==i)&&t(s)}}export{yt as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{subclass as n}from"../../../../../core/accessorSupport/decorators/subclass.js";import"../../../../../core/has.js";import{clone as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import i from"../../../../../core/Logger.js";import a from"../../../../../core/PooledArray.js";import{watch as o,sync as s}from"../../../../../core/reactiveUtils.js";import{isTypedArray as c}from"../../../../../core/typedArrayUtil.js";import{create as l}from"../../../../../geometry/support/aaBoundingBox.js";import{d as u}from"../../../../../chunks/vec3.js";import{c as d}from"../../../../../chunks/vec32.js";import{compactIndices as f}from"../../../../../geometry/support/Indices.js";import{BufferObject as p}from"../../../../webgl/BufferObject.js";import{PrimitiveType as m}from"../../../../webgl/enums.js";import{VertexBuffer as h}from"../../../../webgl/VertexBuffer.js";import{SamplerRepository as g}from"../../lib/SamplerRepository.js";import{BufferManager as _}from"../../lib/TextureBackedBuffer/BufferManager.js";import{VertexArrayObject as v}from"../../lib/VertexArrayObject.js";import{getVerticalOffsetI3S as y}from"../../lib/verticalOffsetUtils.js";import{getComponentDataLayout as b,IndexGlLayout as x}from"../../materials/DefaultLayouts.js";import{ComponentData as S}from"./ComponentData.js";import{defaultComponentParameters as C,ComponentDrawParametersImplementation as w}from"./ComponentDrawParameters.js";import{ComponentObject as T}from"./ComponentObject.js";import{IntersectionGeometry as E}from"./IntersectionGeometry.js";import{ComponentMaterialParameters as D}from"./Material/ComponentMaterialInitParameters.js";import{ComponentMaterialRepository as O}from"./Material/ComponentMaterialRepository.js";import{RenderableMeta as k,Renderable as A}from"./Renderable.js";import{RenderGeometry as j}from"./RenderGeometry.js";import{RenderSubmitSystem as M}from"./RenderSubmitSystem.js";const N=()=>i.getLogger(`esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection`);let P=class extends t{constructor(e,t,n){super(),this._renderPassManager=e,this._isGlobal=t,this._elevationRangeCacheVerticalOffset=NaN,this._elevationRangeCacheMin=NaN,this._elevationRangeCacheMax=NaN,this._highlightsInOrder=[],this._highlights=null,this._activeHighlightOptions=new Map,this._visible=new a,this._hidden=new a,this._renderSubmit=new M(this),this._renderPassManager.register(this._renderSubmit);let{rctx:r,bind:i}=e;this._componentBufferManager=new _(r,b());let c=this._isGlobal?n?1:2:0;this.materials=new O(i,c),this.samplers=new g(r.gl),this.addHandles(o(()=>i.useFloatBlend.value,()=>{this._visible.forAll(e=>e.updateMaterial(this.materials.globals)),this._hidden.forAll(e=>e.updateMaterial(this.materials.globals)),this._requestRender()},s))}destroy(){this._componentBufferManager.destroy(),this._componentBufferManager=null,this._visible.forAll(e=>e.destroy()),this._visible.prune(),this._hidden.forAll(e=>e.destroy()),this._hidden.prune(),this._renderSubmit.destroy(),this.samplers.dispose(),this.materials.destroy()}createObject(e,t){let{geometry:n}=e,r=new S(this._componentBufferManager,f(n.componentOffsets)),i=this._createRenderable(e,t,r),a=new E(this._isGlobal,n.positions,r,e.elevationAlignable),o=new T(this,e.transform,e.obb.clone(),r,i,a,e.aabbInWorldCoordinates);return(o.visible?this._visible:this._hidden).push(o),o}destroyObject(e){let t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._requestRender()}setObjectVisibility(e,t){let n=e;t!==n.visible&&(t?(this._hidden.removeUnordered(n),this._visible.push(n)):(this._visible.removeUnordered(n),this._hidden.push(n)),n.visible=t,this._requestRender())}preSubmit(e){let{camera:t,highlights:n}=e;this._updateHighlightsInOrder(n),this._componentBufferManager.updateTextures(),this.visibleObjects.forAll(e=>e.updateCameraDerivedParameters(t))}getObjectOpacity(e){return e.renderable.drawParameters.opacity}updateObjectOpacity(e,t,n){let r=e;(r.opacity!==t||n!==void 0&&n!==r.renderable.material.parameters.groundTransparencyMode)&&(r.updateOpacity(t,n),this._requestRender())}isSliceplaneEnabled(e){return e.renderable.material.slicePlaneEnabled}setAllComponentVisibilities(e,t){let n=e;n.componentData.visibility.reset(t),n.componentData.markVisibilityDirty(),this._requestRender()}forEachVisibleComponent(e,t){return e.componentData.visibility.forEachComponent(t)}getComponentCount(e){let{componentData:t}=e,n=t.visibility.componentCount;return{visible:n,invisible:t.count-n}}setComponentData(e,t){e.setComponentData(t,this._isGlobal),this._elevationRangeCacheVerticalOffset=NaN,this._requestRender()}getComponentAabb(e,t,n,r=!1){e.intersectionGeometry.getComponentAabb(t,n);let i=e,a=i.componentData.verticalOffsets;if(r||a==null)return n;let o=a[t];if(!this._isGlobal||o===0)return n[2]+=o,n[5]+=o,n;let s=y(o);return s.localOrigin=i.transform.position,s.applyToAabb(n)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,n){return e.intersectionGeometry.getComponentPositions(t,n)}_updateHighlightsInOrder(e){if(this._highlights===e)return;let{_highlightsInOrder:t}=this,n=Math.min(e.length,8),r=t.length!==n;for(let i=0;i<n;++i)if(t[i]!==e[i].name){r=!0;break}if(this._highlights=e,r){t.length=n;for(let r=0;r<n;++r)t[r]=e[r].name;this._syncHighlightedObjectHighlightOrder()}}_syncHighlightedObjectHighlightOrder(){let e=this._highlightsInOrder,t=t=>{t.componentData.componentHighlights.size>0&&t.componentData.setHighlightsInOrder(e)};this._visible.forAll(t),this._hidden.forAll(t)}expandRangeWithComponentObjectElevationRange(e,t,n,r){!Number.isNaN(this._elevationRangeCacheVerticalOffset)&&this._elevationRangeCacheVerticalOffset===t&&r.expandElevationRangeValues(this._elevationRangeCacheMin,this._elevationRangeCacheMax);let i=e,{componentData:a}=i,o=a.count,{verticalOffsets:s}=a,{intersectionGeometry:c}=i,l=c.getComponentAabbs(),u=F,d=1/0,f=-1/0;for(let e=0;e<o;e++){let a=e*6,o=s?.[e]??0,c=1/0,p=-1/0;if(this._isGlobal){if(u[0]=l[a],u[1]=l[a+1],u[2]=l[a+2],u[3]=l[a+3],u[4]=l[a+4],u[5]=l[a+5],o!==0){let e=y(o);e.localOrigin=i.transform.position,e.applyToAabb(u)}let e=Math.max(Math.abs(u[3]),Math.abs(u[0])),s=Math.max(Math.abs(u[4]),Math.abs(u[1])),c=t+u[5]+n;r.expandElevationRangeValues(t+u[2],Math.sqrt(e*e+s*s+c*c)-n)}else c=l[a+2]+o+t,p=l[a+5]+o+t;r.expandElevationRangeValues(c,p),d=Math.min(d,c),f=Math.max(f,p)}this._elevationRangeCacheVerticalOffset=t,this._elevationRangeCacheMin=d,this._elevationRangeCacheMax=f}intersectRay(e,t,n,r,i,a){let{transform:o,componentData:s,intersectionGeometry:c}=e;r!=null&&(r.localOrigin=o.position),c.intersectRay(t,n,r,s.verticalOffsets,o,i,a)}*intersectScreenPolygon(e,t,n,r,i){let{transform:a,componentData:o,intersectionGeometry:s}=e;r!=null&&(r.localOrigin=a.position),yield*s.intersectScreenPolygon(t,n,r,o.verticalOffsets,a,i)}addEdges(e,t,n,r,i){let a=e,{indices:o,positions:s}=a.intersectionGeometry,c=a.componentData.offsets;return t.addComponentObject(a,s,o,c,n,r,i)}async extractEdgeInformation(e,t,n){let i=e,a=i.componentData.visibility;if(a.allInvisible()){let{extractComponentsEdgeLocationsLayout:e}=await import(`../../lib/edgeRendering/edgeProcessing.js`);return{buffer:e.createBuffer(0),origin:[0,0,0]}}let{indices:o,positions:s}=i.intersectionGeometry,c=i.componentData.offsets,{EdgeInputBufferLayout:l}=await import(`../../lib/edgeRendering/bufferLayouts.js`),f=l.createBuffer(s.length/3);d(f.position.typedBuffer,s,f.position.typedBufferStride,3),u(f.position,f.position,i.transform.rotationScale),this._setComponentIndices(f.componentIndex,o,c);let p=f.count,m=this._computeVisibilityIndices(o,a,c,p);return{origin:r(i.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:m,indicesLength:m.length,skipDeduplicate:!0,data:f,writerSettings:{reducedPrecision:!1,variants:0}},n)}}_setComponentIndices(e,t,n){let r=0;for(let i=0;i<n.length-1;i++){let a=n[i],o=n[i+1];for(let n=a;n<o;n++){let i=t?t[n]:n;e.set(i,r)}r++}}_computeVisibilityIndices(e,t,n,r){if(e&&t.allVisible())return e;let i=0;t.forEachComponentRange((e,t)=>(i+=n[t]-n[e],!0));let a=c(e)?e?.BYTES_PER_ELEMENT===2||r<=65536?new Uint16Array(i):new Uint32Array(i):Array(i),o=0;return t.forEachComponentRange((t,r)=>{let i=n[t],s=n[r];for(let t=i;t<s;t++)a[o++]=e?e[t]:t;return!0}),a}addHighlight(e,t,n){let r=e,i=this._activeHighlightOptions.get(n)??0;this._activeHighlightOptions.set(n,i+1),r.componentData.setHighlightsInOrder(this._highlightsInOrder),r.addHighlight(t,n)&&this._requestRender()}removeHighlight(e,t,n){let r=e.removeHighlight(t,n);r!==`notfound`&&(this._removeActiveHighlight(n),r&&this._requestRender())}_removeActiveHighlight(e,t=1){let n=this._activeHighlightOptions.get(e);if(n===void 0)N().warn(`Removing non-existing highlight "${e}".`);else{let r=n-t;r<0&&N().warn(`Removing non-existing highlight "${e}".`),r<=0?this._activeHighlightOptions.delete(e):this._activeHighlightOptions.set(e,r)}}clearHighlights(e){let t=e,{componentData:n}=t,{componentHighlights:r}=t.componentData;if(r.size>0){for(let e of r)this._removeActiveHighlight(e[0],e[1][n.count]);t.clearHighlights(),this._requestRender()}}hasHighlight(e){return this._activeHighlightOptions.has(e)}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t,n){let r=this._renderPassManager.rctx,i=e.geometry,a=i.parameters.layout,{interleavedVertexData:o,indexData:s,vertexCount:c}=i.renderGeometryData,l=new h(r,a,o),u=s?p.createIndex(r,35044,s):null,d=0,f=[[`geometry`,l]];if(!t.isIntegratedMesh){let e=new Uint16Array(c);for(let t=0;t<n.count;t++){let r=n.offsets[t],i=n.offsets[t+1],a=n.materialDataIndices[t];if(s!=null)for(let t=r;t<i;t++){let n=s[t];e[n]=a}else for(let t=r;t<i;t++)e[t]=a}let t=new h(r,x,e.buffer);d+=t.usedMemory,f.push([`componentIndices`,t])}let g=new v(r,new Map(f),u),_=s?.length??c,y=new j(g,m.TRIANGLES,i.parameters,u!=null,_),b=new D(t),S=this.materials.acquire(b,y.parameters,C),T=new k(l.usedMemory+d+(u?.usedMemory??0)),E=this.samplers.addFromTexture(t.baseColorTexture?.texture),O=new w(e,t,E);return new A(S,O,y,T)}_requestRender(){this._renderPassManager.requestRender()}};P=e([n(`esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection`)],P);const F=l();export{P as ComponentObjectCollection};
2
+ import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{subclass as n}from"../../../../../core/accessorSupport/decorators/subclass.js";import"../../../../../core/has.js";import{clone as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import i from"../../../../../core/Logger.js";import a from"../../../../../core/PooledArray.js";import{watch as o,sync as s}from"../../../../../core/reactiveUtils.js";import{isTypedArray as c}from"../../../../../core/typedArrayUtil.js";import{create as l}from"../../../../../geometry/support/aaBoundingBox.js";import{d as u}from"../../../../../chunks/vec3.js";import{c as d}from"../../../../../chunks/vec32.js";import{compactIndices as f}from"../../../../../geometry/support/Indices.js";import{BufferObject as p}from"../../../../webgl/BufferObject.js";import{PrimitiveType as m}from"../../../../webgl/enums.js";import{VertexBuffer as h}from"../../../../webgl/VertexBuffer.js";import{SamplerRepository as g}from"../../lib/SamplerRepository.js";import{BufferManager as _}from"../../lib/TextureBackedBuffer/BufferManager.js";import{VertexArrayObject as v}from"../../lib/VertexArrayObject.js";import{getVerticalOffsetI3S as y}from"../../lib/verticalOffsetUtils.js";import{getComponentDataLayout as b,IndexGlLayout as x}from"../../materials/DefaultLayouts.js";import{ComponentData as S}from"./ComponentData.js";import{defaultComponentParameters as C,ComponentDrawParametersImplementation as w}from"./ComponentDrawParameters.js";import{ComponentObject as T}from"./ComponentObject.js";import{IntersectionGeometry as E}from"./IntersectionGeometry.js";import{ComponentMaterialParameters as D}from"./Material/ComponentMaterialInitParameters.js";import{ComponentMaterialRepository as O}from"./Material/ComponentMaterialRepository.js";import{RenderableMeta as k,Renderable as A}from"./Renderable.js";import{RenderGeometry as j}from"./RenderGeometry.js";import{RenderSubmitSystem as M}from"./RenderSubmitSystem.js";const N=()=>i.getLogger(`esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection`);let P=class extends t{constructor(e,t,n){super(),this._renderPassManager=e,this._isGlobal=t,this._elevationRangeCacheVerticalOffset=NaN,this._elevationRangeCacheMin=NaN,this._elevationRangeCacheMax=NaN,this._highlightsInOrder=[],this._highlights=null,this._activeHighlightOptions=new Map,this._visible=new a,this._hidden=new a,this._renderSubmit=new M(this),this._renderPassManager.register(this._renderSubmit);let{rctx:r,bind:i}=e;this._componentBufferManager=new _(r,b());let c=this._isGlobal?n?1:2:0;this.materials=new O(i,c),this.samplers=new g(r.gl),this.addHandles(o(()=>i.useFloatBlend.value,()=>{this._visible.forAll(e=>e.updateMaterial(this.materials.globals)),this._hidden.forAll(e=>e.updateMaterial(this.materials.globals)),this._requestRender()},s))}destroy(){this._componentBufferManager.destroy(),this._componentBufferManager=null,this._visible.forAll(e=>e.destroy()),this._visible.prune(),this._hidden.forAll(e=>e.destroy()),this._hidden.prune(),this._renderSubmit.destroy(),this.samplers.dispose(),this.materials.destroy()}createObject(e,t){let{geometry:n}=e,r=new S(this._componentBufferManager,f(n.componentOffsets)),i=this._createRenderable(e,t,r),a=new E(this._isGlobal,n.positions,r,e.elevationAlignable),o=new T(this,e.transform,e.obb.clone(),r,i,a,e.aabbInWorldCoordinates);return(o.visible?this._visible:this._hidden).push(o),o}destroyObject(e){let t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._requestRender()}setObjectVisibility(e,t){let n=e;t!==n.visible&&(t?(this._hidden.removeUnordered(n),this._visible.push(n)):(this._visible.removeUnordered(n),this._hidden.push(n)),n.visible=t,this._requestRender())}preSubmit(e){let{camera:t,highlights:n}=e;this._updateHighlightsInOrder(n),this._componentBufferManager.updateTextures(),this.visibleObjects.forAll(e=>e.updateCameraDerivedParameters(t))}getObjectOpacity(e){return e.renderable.drawParameters.opacity}updateObjectOpacity(e,t,n){let r=e;(r.opacity!==t||n!==void 0&&n!==r.renderable.material.parameters.groundTransparencyMode)&&(r.updateOpacity(t,n),this._requestRender())}isSliceplaneEnabled(e){return e.renderable.material.slicePlaneEnabled}setAllComponentVisibilities(e,t){let n=e;n.componentData.visibility.reset(t),n.componentData.markVisibilityDirty(),this._requestRender()}forEachVisibleComponent(e,t){return e.componentData.visibility.forEachComponent(t)}getComponentCount(e){let{componentData:t}=e,n=t.visibility.componentCount;return{visible:n,invisible:t.count-n}}setComponentData(e,t){e.setComponentData(t,this._isGlobal),this._elevationRangeCacheVerticalOffset=NaN,this._requestRender()}getComponentAabb(e,t,n,r=!1){e.intersectionGeometry.getComponentAabb(t,n);let i=e,a=i.componentData.verticalOffsets;if(r||a==null)return n;let o=a[t];if(!this._isGlobal||o===0)return n[2]+=o,n[5]+=o,n;let s=y(o);return s.localOrigin=i.transform.position,s.applyToAabb(n)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,n){return e.intersectionGeometry.getComponentPositions(t,n)}_updateHighlightsInOrder(e){if(this._highlights===e)return;let{_highlightsInOrder:t}=this,n=Math.min(e.length,8),r=t.length!==n;for(let i=0;i<n;++i)if(t[i]!==e[i].name){r=!0;break}if(this._highlights=e,r){t.length=n;for(let r=0;r<n;++r)t[r]=e[r].name;this._syncHighlightedObjectHighlightOrder()}}_syncHighlightedObjectHighlightOrder(){let e=this._highlightsInOrder,t=t=>{t.componentData.componentHighlights.size>0&&t.componentData.setHighlightsInOrder(e)};this._visible.forAll(t),this._hidden.forAll(t)}expandRangeWithComponentObjectElevationRange(e,t,n,r){!Number.isNaN(this._elevationRangeCacheVerticalOffset)&&this._elevationRangeCacheVerticalOffset===t&&r.expandElevationRangeValues(this._elevationRangeCacheMin,this._elevationRangeCacheMax);let i=e,{componentData:a}=i,o=a.count,{verticalOffsets:s}=a,{intersectionGeometry:c}=i,l=c.getComponentAabbs(),u=F,d=1/0,f=-1/0;for(let e=0;e<o;e++){let a=e*6,o=s?.[e]??0,c=1/0,p=-1/0;if(this._isGlobal){if(u[0]=l[a],u[1]=l[a+1],u[2]=l[a+2],u[3]=l[a+3],u[4]=l[a+4],u[5]=l[a+5],o!==0){let e=y(o);e.localOrigin=i.transform.position,e.applyToAabb(u)}let e=Math.max(Math.abs(u[3]),Math.abs(u[0])),s=Math.max(Math.abs(u[4]),Math.abs(u[1])),c=t+u[5]+n;r.expandElevationRangeValues(t+u[2],Math.sqrt(e*e+s*s+c*c)-n)}else c=l[a+2]+o+t,p=l[a+5]+o+t;r.expandElevationRangeValues(c,p),d=Math.min(d,c),f=Math.max(f,p)}this._elevationRangeCacheVerticalOffset=t,this._elevationRangeCacheMin=d,this._elevationRangeCacheMax=f}intersectRay(e,t,n,r,i,a){let{transform:o,componentData:s,intersectionGeometry:c}=e;return r!=null&&(r.localOrigin=o.position),c.intersectRay(t,n,r,s.verticalOffsets,o,i,a)}*intersectScreenPolygon(e,t,n,r,i){let{transform:a,componentData:o,intersectionGeometry:s}=e;r!=null&&(r.localOrigin=a.position),yield*s.intersectScreenPolygon(t,n,r,o.verticalOffsets,a,i)}addEdges(e,t,n,r,i){let a=e,{indices:o,positions:s}=a.intersectionGeometry,c=a.componentData.offsets;return t.addComponentObject(a,s,o,c,n,r,i)}async extractEdgeInformation(e,t,n){let i=e,a=i.componentData.visibility;if(a.allInvisible()){let{extractComponentsEdgeLocationsLayout:e}=await import(`../../lib/edgeRendering/edgeProcessing.js`);return{buffer:e.createBuffer(0),origin:[0,0,0]}}let{indices:o,positions:s}=i.intersectionGeometry,c=i.componentData.offsets,{EdgeInputBufferLayout:l}=await import(`../../lib/edgeRendering/bufferLayouts.js`),f=l.createBuffer(s.length/3);d(f.position.typedBuffer,s,f.position.typedBufferStride,3),u(f.position,f.position,i.transform.rotationScale),this._setComponentIndices(f.componentIndex,o,c);let p=f.count,m=this._computeVisibilityIndices(o,a,c,p);return{origin:r(i.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:m,indicesLength:m.length,skipDeduplicate:!0,data:f,writerSettings:{reducedPrecision:!1,variants:0}},n)}}_setComponentIndices(e,t,n){let r=0;for(let i=0;i<n.length-1;i++){let a=n[i],o=n[i+1];for(let n=a;n<o;n++){let i=t?t[n]:n;e.set(i,r)}r++}}_computeVisibilityIndices(e,t,n,r){if(e&&t.allVisible())return e;let i=0;t.forEachComponentRange((e,t)=>(i+=n[t]-n[e],!0));let a=c(e)?e?.BYTES_PER_ELEMENT===2||r<=65536?new Uint16Array(i):new Uint32Array(i):Array(i),o=0;return t.forEachComponentRange((t,r)=>{let i=n[t],s=n[r];for(let t=i;t<s;t++)a[o++]=e?e[t]:t;return!0}),a}addHighlight(e,t,n){let r=e,i=this._activeHighlightOptions.get(n)??0;this._activeHighlightOptions.set(n,i+1),r.componentData.setHighlightsInOrder(this._highlightsInOrder),r.addHighlight(t,n)&&this._requestRender()}removeHighlight(e,t,n){let r=e.removeHighlight(t,n);r!==`notfound`&&(this._removeActiveHighlight(n),r&&this._requestRender())}_removeActiveHighlight(e,t=1){let n=this._activeHighlightOptions.get(e);if(n===void 0)N().warn(`Removing non-existing highlight "${e}".`);else{let r=n-t;r<0&&N().warn(`Removing non-existing highlight "${e}".`),r<=0?this._activeHighlightOptions.delete(e):this._activeHighlightOptions.set(e,r)}}clearHighlights(e){let t=e,{componentData:n}=t,{componentHighlights:r}=t.componentData;if(r.size>0){for(let e of r)this._removeActiveHighlight(e[0],e[1][n.count]);t.clearHighlights(),this._requestRender()}}hasHighlight(e){return this._activeHighlightOptions.has(e)}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t,n){let r=this._renderPassManager.rctx,i=e.geometry,a=i.parameters.layout,{interleavedVertexData:o,indexData:s,vertexCount:c}=i.renderGeometryData,l=new h(r,a,o),u=s?p.createIndex(r,35044,s):null,d=0,f=[[`geometry`,l]];if(!t.isIntegratedMesh){let e=new Uint16Array(c);for(let t=0;t<n.count;t++){let r=n.offsets[t],i=n.offsets[t+1],a=n.materialDataIndices[t];if(s!=null)for(let t=r;t<i;t++){let n=s[t];e[n]=a}else for(let t=r;t<i;t++)e[t]=a}let t=new h(r,x,e.buffer);d+=t.usedMemory,f.push([`componentIndices`,t])}let g=new v(r,new Map(f),u),_=s?.length??c,y=new j(g,m.TRIANGLES,i.parameters,u!=null,_),b=new D(t),S=this.materials.acquire(b,y.parameters,C),T=new k(l.usedMemory+d+(u?.usedMemory??0)),E=this.samplers.addFromTexture(t.baseColorTexture?.texture),O=new w(e,t,E);return new A(S,O,y,T)}_requestRender(){this._renderPassManager.requestRender()}};P=e([n(`esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection`)],P);const F=l();export{P as ComponentObjectCollection};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{Vertices as e}from"../../lib/Attribute.js";import{TriangleIntersectionData as t}from"../../lib/TriangleIntersectionData.js";class n{constructor(n,r,i,a,o){this._componentOffsets=o,this._intersectionData=new t(i,a,new e(n,3,r))}intersectRay(e,t,n,i){this._intersectionData.intersectRay(e,t,n,(e,t,n,a)=>{i(e,t,n,a,r(this._componentOffsets,a))})}*intersectScreenPolygon(e,t,n,i){this._intersectionData.forEachScreenPolygonHit(e,n,t,null,(e,t,n)=>{let a=r(this._componentOffsets,t);a<0||a>=this._componentOffsets.length-1||i(e,t,a,n)}),yield}}function r(e,t){let{length:n}=e;if(n===0||t<e[0])return-1;if(t>e[n-1])return n;let r=0,i=n-1;for(;i-r>1;){let n=Math.round(.5*(r+i));t<=e[n]?i=n:r=n}return r}export{n as ComponentObjectFixedBVH};
2
+ import{Vertices as e}from"../../lib/Attribute.js";import{TriangleIntersectionData as t}from"../../lib/TriangleIntersectionData.js";class n{constructor(n,r,i,a,o){this._componentOffsets=o,this._intersectionData=new t(i,a,new e(n,3,r),!0)}intersectRay(e,t,n,i){return n.budget&&(this._intersectionData.advance(n.budget),!this._intersectionData.ready)?!1:(this._intersectionData.intersectRay(e,t,n,(e,t,n,a)=>{i(e,t,n,a,r(this._componentOffsets,a))}),!0)}*intersectScreenPolygon(e,t,n,i){this._intersectionData.forEachScreenPolygonHit(e,n,t,null,(e,t,n)=>{let a=r(this._componentOffsets,t);a<0||a>=this._componentOffsets.length-1||i(e,t,a,n)}),yield}}function r(e,t){let{length:n}=e;if(n===0||t<e[0])return-1;if(t>e[n-1])return n;let r=0,i=n-1;for(;i-r>1;){let n=Math.round(.5*(r+i));t<=e[n]?i=n:r=n}return r}export{n as ComponentObjectFixedBVH};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{transpose as e,invert as t}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as r}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{sub as i,transformMat3 as a,negate as o}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as c}from"../../../../../geometry/support/aaBoundingBox.js";import{floatArrayFrom as l,floatArrayByteSize as u,newFloatArray as d}from"../../../../../geometry/support/FloatArray.js";import{indexArrayFrom as f,getContinuousIndexArray as p,indexArrayByteSize as m}from"../../../../../geometry/support/Indices.js";import{ComponentObjectElevationAgnosticComponentBVH as h}from"./ComponentObjectElevationAgnosticBVH.js";import{ComponentObjectFixedBVH as g}from"./ComponentObjectFixedBVH.js";class _{constructor(e,t,n,r){this.isGlobal=e,this._components=n,this._needsElevationAlignment=r,this.verticalOffset=null,this.componentVerticalOffsets=null,this._planetCenter=s(),this._componentBvh=null,this._aabb=c();let{indices:i,positions:a}=t,o=a.length/3;this._indices=i?f(i,o):p(o),this._positions=l(a)}get usedMemory(){return u(this._positions)+m(this._indices)}destroy(){this._positions=null,this._indices=null,this._perComponentAabbs=null,this._componentBvh=null}getComponentAabb(e,t){let n=this._ensureComponentAabbs(),r=e*6;return t[0]=n[r],t[1]=n[r+1],t[2]=n[r+2],t[3]=n[r+3],t[4]=n[r+4],t[5]=n[r+5],t}getComponentAabbs(){return this._ensureComponentAabbs()}_ensureComponentAabbs(){return this._perComponentAabbs||=this._computePerComponentAabbs(),this._perComponentAabbs}getComponentPositions(e,t){t.indices=this._indices,t.data=this._positions,t.stride=3,t.startIndex=this._components.offsets[e],t.endIndex=this._components.offsets[e+1]}intersectRay(t,n,r,s,c,l,u){let d=b;this._setupIntersect(r,s,c,d);let{position:f}=c,p=i(v,t,f),m=i(y,n,f);a(p,p,d),a(m,m,d);let h=e(C,d);if(this.isGlobal){let e=this._planetCenter;o(e,f),a(e,e,d)}this._intersectComponents(p,m,s,r,(e,t,n,r,i)=>{u(e,t,n?a(S,n,h):null,r,i)},l)}*intersectScreenPolygon(e,t,n,r,i,a){this._setupIntersect(n,r,i),yield*this._ensureComponentBvh().intersectScreenPolygon(e,t,i.toMat4(x),(e,t,n,r)=>a(n,e,r,t),r??void 0,n??void 0)}_setupIntersect(e,n,r,i=b){if(this.verticalOffset=e,this.componentVerticalOffsets=n,t(i,r.rotationScale),this.isGlobal){let e=this._planetCenter;o(e,r.position),a(e,e,i)}}_computePerComponentAabbs(){let e=this._aabb,t=.5*(e[0]+e[3]),n=.5*(e[1]+e[4]),r=.5*(e[2]+e[5]),i=this._components.count,a=d(i*6),o=this._indices,s=this._positions,c=this._components.offsets,l=0,u=1/0,f=1/0,p=1/0,m=-1/0,h=-1/0,g=-1/0;for(let e=0;e<i;e++){let i=c[e],d=c[e+1],_=1/0,v=1/0,y=1/0,b=-1/0,x=-1/0,S=-1/0;if(i<d)for(let e=i;e<d;e++){let t=o[e]*3,n=s[t],r=s[t+1],i=s[t+2];_=Math.min(_,n),v=Math.min(v,r),y=Math.min(y,i),b=Math.max(b,n),x=Math.max(x,r),S=Math.max(S,i)}else _=t,v=n,y=r,b=t,x=n,S=r;a[l++]=_,a[l++]=v,a[l++]=y,a[l++]=b,a[l++]=x,a[l++]=S,u=Math.min(u,_),f=Math.min(f,v),p=Math.min(p,y),m=Math.max(m,b),h=Math.max(h,x),g=Math.max(g,S)}return this._aabb[0]=u,this._aabb[1]=f,this._aabb[2]=p,this._aabb[3]=m,this._aabb[4]=h,this._aabb[5]=g,a}_intersectComponents(e,t,n,r,i,a){this._ensureComponentBvh().intersectRay(e,t,a,i,n??void 0,r??void 0)}_ensureComponentBvh(){let e=this._componentBvh;return e??(e=this._needsElevationAlignment?new h(this._positions,w,this._indices,this._components,this._ensureComponentAabbs(),this.geometryMinZ,this.planetCenterZ,this.isGlobal):new g(this._positions,w,this._indices,this.numTriangles,this._components.offsets),this._componentBvh=e),e}get geometryMinZ(){return this._aabb[2]}get planetCenterZ(){return this._planetCenter[2]}get numTriangles(){return this._indices.length/3}get positions(){return this._positions}get indices(){return this._indices}get aabb(){return this._ensureComponentAabbs(),this._aabb}}const v=s(),y=s(),b=n(),x=r(),S=s(),C=n(),w=3;export{_ as IntersectionGeometry};
2
+ import{transpose as e,invert as t}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as r}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{sub as i,transformMat3 as a,negate as o}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as c}from"../../../../../geometry/support/aaBoundingBox.js";import{floatArrayFrom as l,floatArrayByteSize as u,newFloatArray as d}from"../../../../../geometry/support/FloatArray.js";import{indexArrayFrom as f,getContinuousIndexArray as p,indexArrayByteSize as m}from"../../../../../geometry/support/Indices.js";import{ComponentObjectElevationAgnosticComponentBVH as h}from"./ComponentObjectElevationAgnosticBVH.js";import{ComponentObjectFixedBVH as g}from"./ComponentObjectFixedBVH.js";class _{constructor(e,t,n,r){this.isGlobal=e,this._components=n,this._needsElevationAlignment=r,this.verticalOffset=null,this.componentVerticalOffsets=null,this._planetCenter=s(),this._componentBvh=null,this._aabb=c();let{indices:i,positions:a}=t,o=a.length/3;this._indices=i?f(i,o):p(o),this._positions=l(a)}get usedMemory(){return u(this._positions)+m(this._indices)}destroy(){this._positions=null,this._indices=null,this._perComponentAabbs=null,this._componentBvh=null}getComponentAabb(e,t){let n=this._ensureComponentAabbs(),r=e*6;return t[0]=n[r],t[1]=n[r+1],t[2]=n[r+2],t[3]=n[r+3],t[4]=n[r+4],t[5]=n[r+5],t}getComponentAabbs(){return this._ensureComponentAabbs()}_ensureComponentAabbs(){return this._perComponentAabbs||=this._computePerComponentAabbs(),this._perComponentAabbs}getComponentPositions(e,t){t.indices=this._indices,t.data=this._positions,t.stride=3,t.startIndex=this._components.offsets[e],t.endIndex=this._components.offsets[e+1]}intersectRay(t,n,r,s,c,l,u){let d=b;this._setupIntersect(r,s,c,d);let{position:f}=c,p=i(v,t,f),m=i(y,n,f);a(p,p,d),a(m,m,d);let h=e(C,d);if(this.isGlobal){let e=this._planetCenter;o(e,f),a(e,e,d)}return this._intersectComponents(p,m,s,r,(e,t,n,r,i)=>{u(e,t,n?a(S,n,h):null,r,i)},l)}*intersectScreenPolygon(e,t,n,r,i,a){this._setupIntersect(n,r,i),yield*this._ensureComponentBvh().intersectScreenPolygon(e,t,i.toMat4(x),(e,t,n,r)=>a(n,e,r,t),r??void 0,n??void 0)}_setupIntersect(e,n,r,i=b){if(this.verticalOffset=e,this.componentVerticalOffsets=n,t(i,r.rotationScale),this.isGlobal){let e=this._planetCenter;o(e,r.position),a(e,e,i)}}_computePerComponentAabbs(){let e=this._aabb,t=.5*(e[0]+e[3]),n=.5*(e[1]+e[4]),r=.5*(e[2]+e[5]),i=this._components.count,a=d(i*6),o=this._indices,s=this._positions,c=this._components.offsets,l=0,u=1/0,f=1/0,p=1/0,m=-1/0,h=-1/0,g=-1/0;for(let e=0;e<i;e++){let i=c[e],d=c[e+1],_=1/0,v=1/0,y=1/0,b=-1/0,x=-1/0,S=-1/0;if(i<d)for(let e=i;e<d;e++){let t=o[e]*3,n=s[t],r=s[t+1],i=s[t+2];_=Math.min(_,n),v=Math.min(v,r),y=Math.min(y,i),b=Math.max(b,n),x=Math.max(x,r),S=Math.max(S,i)}else _=t,v=n,y=r,b=t,x=n,S=r;a[l++]=_,a[l++]=v,a[l++]=y,a[l++]=b,a[l++]=x,a[l++]=S,u=Math.min(u,_),f=Math.min(f,v),p=Math.min(p,y),m=Math.max(m,b),h=Math.max(h,x),g=Math.max(g,S)}return this._aabb[0]=u,this._aabb[1]=f,this._aabb[2]=p,this._aabb[3]=m,this._aabb[4]=h,this._aabb[5]=g,a}_intersectComponents(e,t,n,r,i,a){return this._ensureComponentBvh().intersectRay(e,t,a,i,n??void 0,r??void 0)!==!1}_ensureComponentBvh(){let e=this._componentBvh;return e??(e=this._needsElevationAlignment?new h(this._positions,w,this._indices,this._components,this._ensureComponentAabbs(),this.geometryMinZ,this.planetCenterZ,this.isGlobal):new g(this._positions,w,this._indices,this.numTriangles,this._components.offsets),this._componentBvh=e),e}get geometryMinZ(){return this._aabb[2]}get planetCenterZ(){return this._planetCenter[2]}get numTriangles(){return this._indices.length/3}get positions(){return this._positions}get indices(){return this._indices}get aabb(){return this._ensureComponentAabbs(),this._aabb}}const v=s(),y=s(),b=n(),x=r(),S=s(),C=n(),w=3;export{_ as IntersectionGeometry};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import"../../../../../webgl/ShaderBuilder.js";import"../../../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import"../../../core/shaderLibrary/attributes/VertexColor.glsl.js";import"../../../core/shaderLibrary/attributes/VertexNormal.glsl.js";import"../../../core/shaderLibrary/attributes/VertexPosition.glsl.js";import"../../../core/shaderLibrary/bindUniforms.js";import"../../../core/shaderLibrary/forwardLinearDepthToWriteShadow.glsl.js";import"../../../core/shaderLibrary/output/DepthConversion.glsl.js";import"../../../core/shaderLibrary/output/OutputDepth.glsl.js";import"../../../core/shaderLibrary/output/OutputHighlight.glsl.js";import"../../../core/shaderLibrary/output/OutputHighlightOverlay.js";import"../../../core/shaderLibrary/ShaderOutput.js";import"../../../core/shaderLibrary/shading/ComputeFragmentNormals.glsl.js";import"../../../core/shaderLibrary/shading/ComputeMaterialColor.glsl.js";import"../../../core/shaderLibrary/shading/ComputeNormalTexture.glsl.js";import"../../../core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import"../../../core/shaderLibrary/shading/getLocalUp.glsl.js";import"../../../core/shaderLibrary/shading/lightingUniforms.js";import"../../../core/shaderLibrary/shading/NormalUtils.glsl.js";import"../../../core/shaderLibrary/shading/pbrGlobals.glsl.js";import"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import"../../../core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js";import"../../../core/shaderLibrary/shading/readShadow.glsl.js";import"../../../core/shaderLibrary/Slice.glsl.js";import"../../../core/shaderLibrary/terrain/Overlay.glsl.js";import"../../../core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js";import"../../../core/shaderModules/BooleanDrawUniform.js";import"../../../core/shaderModules/FloatDrawUniform.js";import"../../../core/shaderModules/glsl.js";import"../../../core/shaderModules/Matrix3DrawUniform.js";import"../../../effects/snowcover/applySnow.glsl.js";import"../../../shaders/alphaCutoff.glsl.js";import"../../../shaders/OutputColorHighlightOLID.glsl.js";import"../../../shaders/SphereDepthInterpolate.glsl.js";import"./ComponentData.glsl.js";export{b as build}from"../../../../../../chunks/Component.glsl.js";
2
+ import"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import"../../../../../webgl/ShaderBuilder.js";import"../../../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import"../../../core/shaderLibrary/attributes/VertexColor.glsl.js";import"../../../core/shaderLibrary/attributes/VertexNormal.glsl.js";import"../../../core/shaderLibrary/attributes/VertexPosition.glsl.js";import"../../../core/shaderLibrary/bindUniforms.js";import"../../../core/shaderLibrary/clampShadowPosition.glsl.js";import"../../../core/shaderLibrary/forwardLinearDepthToWriteShadow.glsl.js";import"../../../core/shaderLibrary/output/DepthConversion.glsl.js";import"../../../core/shaderLibrary/output/OutputDepth.glsl.js";import"../../../core/shaderLibrary/output/OutputHighlight.glsl.js";import"../../../core/shaderLibrary/output/OutputHighlightOverlay.js";import"../../../core/shaderLibrary/ShaderOutput.js";import"../../../core/shaderLibrary/shading/ComputeFragmentNormals.glsl.js";import"../../../core/shaderLibrary/shading/ComputeMaterialColor.glsl.js";import"../../../core/shaderLibrary/shading/ComputeNormalTexture.glsl.js";import"../../../core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import"../../../core/shaderLibrary/shading/getLocalUp.glsl.js";import"../../../core/shaderLibrary/shading/lightingUniforms.js";import"../../../core/shaderLibrary/shading/NormalUtils.glsl.js";import"../../../core/shaderLibrary/shading/pbrGlobals.glsl.js";import"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import"../../../core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js";import"../../../core/shaderLibrary/shading/readShadow.glsl.js";import"../../../core/shaderLibrary/Slice.glsl.js";import"../../../core/shaderLibrary/terrain/Overlay.glsl.js";import"../../../core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js";import"../../../core/shaderModules/BooleanDrawUniform.js";import"../../../core/shaderModules/FloatDrawUniform.js";import"../../../core/shaderModules/glsl.js";import"../../../core/shaderModules/Matrix3DrawUniform.js";import"../../../effects/snowcover/applySnow.glsl.js";import"../../../shaders/alphaCutoff.glsl.js";import"../../../shaders/OutputColorHighlightOLID.glsl.js";import"../../../shaders/SphereDepthInterpolate.glsl.js";import"./ComponentData.glsl.js";export{b as build}from"../../../../../../chunks/Component.glsl.js";
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{MaterialBase as e}from"../../../core/material/MaterialBase.js";import{isColor as t}from"../../../core/shaderLibrary/ShaderOutput.js";import{getIMOverlayColorContent as n}from"../../../core/shaderLibrary/terrain/Overlay.glsl.js";import{hasShadowHighlights as r}from"../../../shaders/ReceiveShadowsConfiguration.js";import{isSphereDepthInterpolateActive as i}from"../../../shaders/SphereDepthInterpolate.glsl.js";import{ComponentTechnique as a}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as o}from"./ComponentTechniqueConfiguration.js";class s extends e{constructor(e,t,n,r,i){super(),this.parameters=e,this.key=i;let a=u(e,n);this.usePBR=e.usePBR,this.hasParametersFromSource=e.hasParametersFromSource,this.slicePlaneEnabled=e.slicePlaneEnabled,this.isIntegratedMesh=e.isIntegratedMesh,this.applySSAO=e.applySSAO,this._emissions=a!==0,this.materialPass=c(e,n),this._configuration=new o(r),this._supportsSphereDepthInterpolate=e.sphereDepthInterpolate&&this._configuration.spherical,this._initializeMaterialConfiguration(e,t,n)}destroy(){}get emissions(){if(!this._emissions)return 0;switch(this.materialPass){case 0:case 3:return 1;case 1:case 4:return 2;case 2:return 3}}acquireTechnique(e,t,n,r){let o=this._updateConfiguration(t,n);if(this._supportsSphereDepthInterpolate&&e.precompiling>0){o.sphereDepthInterpolate=!1;let t=e.get(a,o,r.layout);o.sphereDepthInterpolate=!0;let s=e.get(a,o,r.layout);return i(n.camera,o)?s:t}return e.get(a,o,r.layout)}_initializeMaterialConfiguration(e,t,n){let r=this._configuration;r.hasMetallicRoughnessTexture=e.hasMetallicRoughnessTexture,r.hasOcclusionTexture=e.hasOcclusionTexture,r.hasNormalTexture=e.hasNormalTexture;let i=t.textureCoordinateType!==0;r.hasColorTextureTransform=i&&e.hasBaseColorTexture&&e.hasColorTextureTransform,r.hasNormalTextureTransform=i&&e.hasNormalTexture&&e.hasNormalTextureTransform,r.hasEmissiveTextureTransform=i&&e.hasEmissionTexture&&e.hasEmissiveTextureTransform,r.hasOcclusionTextureTransform=i&&e.hasOcclusionTexture&&e.hasOcclusionTextureTransform,r.hasMetallicRoughnessTextureTransform=i&&e.hasMetallicRoughnessTexture&&e.hasMetallicRoughnessTextureTransform,r.sphereDepthInterpolate=!1,r.ellipsoidMode=e.ellipsoidMode,r.doubleSidedMode=+!!e.doubleSided,r.hasColorTexture=e.hasBaseColorTexture,r.cullFace=e.cullFace,r.alphaDiscardMode=e.alphaDiscardMode,r.hasVertexColors=t.hasVertexColors,r.textureCoordinateType=t.textureCoordinateType,r.shadeNormals=t.shadeNormals,r.normalType=t.hasNormals?1:2,r.polygonOffset=e.polygonOffset,r.vertexPositionRotationType=t.vertexPositionRotationType,r.componentDataType=n.componentDataType,r.emissionSource=u(e,n),r.groundTransparencyMode=e.groundTransparencyMode}_updateConfiguration(e,n){let a=this._configuration,{identifier:o}=e,s=o===0;a.output=n.output,a.enableOITOffset=n.enableOITOffset,a.shouldDrapeRaster=this.parameters.integratedMeshSemantics.shouldDrapeRaster,a.sphereDepthInterpolate=this._supportsSphereDepthInterpolate&&i(n.camera,a),a.hasEmission=n.hasEmission,a.renderOccluded=n.slot===9;let c=this.parameters.integratedMeshSemantics.shouldStencilTerrain?this.parameters.integratedMeshSemantics.shouldDrape&&f(n,this.parameters.integratedMeshSemantics.shouldDrapeRaster)?d(n)?3:2:1:0;a.integratedMeshMode=c,a.pbrMode=c===3?4:this.usePBR?this.hasParametersFromSource?a.shadeNormals!==0&&this.isIntegratedMesh?0:2:1:0,a.hasSlicePlane=n.slicePlane!=null&&this.slicePlaneEnabled,a.isGroundSlice=a.hasSlicePlane&&this.parameters.integratedMeshSemantics.shouldFadeSlicedSurface;let{materialPass:l}=this;a.transparent=s&&(l===1||l===2&&e.transparent||l===4)||a.isGroundSlice,a.hasHighlightMixTexture=o===2&&n.highlightMixTexture!=null,a.snowCover=s&&n.snowCover>0,a.vertexDiscardMode=s&&l===2?e.transparent?2:1:0;let u=t(n.output);return a.receiveAmbientOcclusion=u&&this.applySSAO&&!a.renderOccluded&&n.ssao?.getTexture()!=null,a.receiveGlobalIllumination=u&&this.applySSAO&&!a.renderOccluded&&n.globalIlluminationEnabled,a.hasOccludees=u&&n.hasOccludees,a.receiveShadows=u&&n.shadowMap.ready,a.hasShadowHighlights=r(a,n),a.screenSpaceReflections=n.hasScreenSpaceReflections,a.cloudReflections=u&&n.clouds.data?.cubeMap?.colorTexture!=null,a}}function c(e,t){let{alphaDiscardMode:n,isIntegratedMesh:r,slicePlaneEnabled:i}=e,{transparent:a,opaqueOverride:o}=t,s=e.isObjectTransparent,c=e.hasBaseColorTransparency;if(r)return s||i&&e.integratedMeshSemantics.shouldRenderSliceAsTransparent?4:3;if(s)return 1;if(o===0)return 0;if(c||n===0||n===3)return 1;switch(a){case 2:return 0;case 0:return 1;case 1:return 2}}function l(e){return e.hasEmissionTexture||e.hasEmissiveBaseColor}function u(e,{emissiveSourceOverride:t,emissiveOverride:n}){let r=e.hasEmissionTexture,i=n!==2&&(l(e)||t!==2),a=t===1,o=t===2;return i?l(e)?o?r?4:2:a?r?5:7:6:a?7:6:0}function d(e){return e.overlay?.getTexture(3)!=null}function f(e,t){return e.overlay?.getTexture(n(t))!=null}export{s as ComponentMaterial,c as computeMaterialPass,u as getEmissionSource};
2
+ import{MaterialBase as e}from"../../../core/material/MaterialBase.js";import{isColor as t}from"../../../core/shaderLibrary/ShaderOutput.js";import{getIMOverlayColorContent as n}from"../../../core/shaderLibrary/terrain/Overlay.glsl.js";import{hasShadowHighlights as r}from"../../../shaders/ReceiveShadowsConfiguration.js";import{isSphereDepthInterpolateActive as i}from"../../../shaders/SphereDepthInterpolate.glsl.js";import{ComponentTechnique as a}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as o}from"./ComponentTechniqueConfiguration.js";class s extends e{constructor(e,t,n,r,i){super(),this.parameters=e,this.key=i;let a=u(e,n);this.usePBR=e.usePBR,this.hasParametersFromSource=e.hasParametersFromSource,this.slicePlaneEnabled=e.slicePlaneEnabled,this.isIntegratedMesh=e.isIntegratedMesh,this.applySSAO=e.applySSAO,this._emissions=a!==0,this.materialPass=c(e,n),this._configuration=new o(r),this._supportsSphereDepthInterpolate=e.sphereDepthInterpolate&&this._configuration.spherical,this._initializeMaterialConfiguration(e,t,n)}destroy(){}get emissions(){if(!this._emissions)return 0;switch(this.materialPass){case 0:case 3:return 1;case 1:case 4:return 2;case 2:return 3}}acquireTechnique(e,t,n,r){let o=this._updateConfiguration(t,n);if(this._supportsSphereDepthInterpolate&&e.precompiling>0){o.sphereDepthInterpolate=!1;let t=e.get(a,o,r.layout);o.sphereDepthInterpolate=!0;let s=e.get(a,o,r.layout);return i(n.camera,o)?s:t}return e.get(a,o,r.layout)}_initializeMaterialConfiguration(e,t,n){let r=this._configuration;r.hasMetallicRoughnessTexture=e.hasMetallicRoughnessTexture,r.hasOcclusionTexture=e.hasOcclusionTexture,r.hasNormalTexture=e.hasNormalTexture;let i=t.textureCoordinateType!==0;r.hasColorTextureTransform=i&&e.hasBaseColorTexture&&e.hasColorTextureTransform,r.hasNormalTextureTransform=i&&e.hasNormalTexture&&e.hasNormalTextureTransform,r.hasEmissiveTextureTransform=i&&e.hasEmissionTexture&&e.hasEmissiveTextureTransform,r.hasOcclusionTextureTransform=i&&e.hasOcclusionTexture&&e.hasOcclusionTextureTransform,r.hasMetallicRoughnessTextureTransform=i&&e.hasMetallicRoughnessTexture&&e.hasMetallicRoughnessTextureTransform,r.sphereDepthInterpolate=!1,r.ellipsoidMode=e.ellipsoidMode,r.doubleSidedMode=+!!e.doubleSided,r.hasColorTexture=e.hasBaseColorTexture,r.cullFace=e.cullFace,r.alphaDiscardMode=e.alphaDiscardMode,r.hasVertexColors=t.hasVertexColors,r.textureCoordinateType=t.textureCoordinateType,r.shadeNormals=t.shadeNormals,r.normalType=t.hasNormals?1:2,r.polygonOffset=e.polygonOffset,r.vertexPositionRotationType=t.vertexPositionRotationType,r.componentDataType=n.componentDataType,r.emissionSource=u(e,n),r.groundTransparencyMode=e.groundTransparencyMode}_updateConfiguration(e,n){let a=this._configuration,{identifier:o}=e,s=o===0;a.output=n.output,a.enableOITOffset=n.enableOITOffset,a.shouldDrapeRaster=this.parameters.integratedMeshSemantics.shouldDrapeRaster,a.sphereDepthInterpolate=this._supportsSphereDepthInterpolate&&i(n.camera,a),a.hasEmission=n.hasEmission,a.renderOccluded=n.slot===9;let c=this.parameters.integratedMeshSemantics.shouldStencilTerrain?this.parameters.integratedMeshSemantics.shouldDrape&&f(n,this.parameters.integratedMeshSemantics.shouldDrapeRaster)?d(n)?3:2:1:0;a.integratedMeshMode=c,a.pbrMode=c===3?4:this.usePBR?this.hasParametersFromSource?a.shadeNormals!==0&&this.isIntegratedMesh?0:2:1:0,a.hasSlicePlane=n.slicePlane!=null&&this.slicePlaneEnabled,a.isGroundSlice=a.hasSlicePlane&&this.parameters.integratedMeshSemantics.shouldFadeSlicedSurface;let{materialPass:l}=this;a.transparent=s&&(l===1||l===2&&e.transparent||l===4)||a.isGroundSlice,a.hasHighlightMixTexture=o===2&&n.highlightMixTexture!=null,a.snowCover=s&&n.snowCover>0,a.vertexDiscardMode=s&&l===2?e.transparent?2:1:0;let u=t(n.output);return a.receiveAmbientOcclusion=u&&this.applySSAO&&!a.renderOccluded&&n.ssao?.getTexture()!=null,a.receiveGlobalIllumination=u&&this.applySSAO&&!a.renderOccluded&&n.globalIlluminationEnabled,a.hasOccludees=u&&n.hasOccludees,a.receiveShadows=u&&n.shadowMap.ready,a.hasShadowHighlights=u&&r(a,n),a.screenSpaceReflections=u&&n.hasScreenSpaceReflections,a.cloudReflections=u&&n.clouds.data?.cubeMap?.colorTexture!=null,a.emissionReflections=u&&a.screenSpaceReflections&&a.hasEmission&&n.reprojection.lastFrameEmission!=null,a}}function c(e,t){let{alphaDiscardMode:n,isIntegratedMesh:r,slicePlaneEnabled:i}=e,{transparent:a,opaqueOverride:o}=t,s=e.isObjectTransparent,c=e.hasBaseColorTransparency;if(r)return s||i&&e.integratedMeshSemantics.shouldRenderSliceAsTransparent?4:3;if(s)return 1;if(o===0)return 0;if(c||n===0||n===3)return 1;switch(a){case 2:return 0;case 0:return 1;case 1:return 2}}function l(e){return e.hasEmissionTexture||e.hasEmissiveBaseColor}function u(e,{emissiveSourceOverride:t,emissiveOverride:n}){let r=e.hasEmissionTexture,i=n!==2&&(l(e)||t!==2),a=t===1,o=t===2;return i?l(e)?o?r?4:2:a?r?5:7:6:a?7:6:0}function d(e){return e.overlay?.getTexture(3)!=null}function f(e,t){return e.overlay?.getTexture(n(t))!=null}export{s as ComponentMaterial,c as computeMaterialPass,u as getEmissionSource};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{isColorHighlightOrOLID as t}from"../../../core/shaderLibrary/ShaderOutput.js";import{parameter as n}from"../../../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{SphereDepthInterpolateConfiguration as r}from"../../../shaders/SphereDepthInterpolate.glsl.js";class i extends r{constructor(e){super(),this.output=0,this.textureCoordinateType=0,this.componentDataType=0,this.cullFace=2,this.vertexDiscardMode=0,this.doubleSidedMode=2,this.alphaDiscardMode=1,this.integratedMeshMode=0,this.pbrMode=0,this.normalType=0,this.emissionSource=0,this.shadeNormals=1,this.polygonOffset=0,this.vertexPositionRotationType=1,this.hasEmission=!1,this.hasVertexColors=!1,this.hasSlicePlane=!1,this.shouldDrapeRaster=!1,this.isGroundSlice=!1,this.hasColorTexture=!1,this.hasHighlightMixTexture=!1,this.emissionDimmingPass=!1,this.receiveAmbientOcclusion=!0,this.receiveGlobalIllumination=!1,this.receiveShadows=!0,this.hasShadowHighlights=!1,this.transparent=!0,this.groundTransparencyMode=1,this.screenSpaceReflections=!1,this.hasMetallicRoughnessTexture=!1,this.hasOcclusionTexture=!1,this.hasNormalTexture=!1,this.hasOccludees=!1,this.terrainDepthTest=!1,this.cullAboveTerrain=!1,this.hasNormalTextureTransform=!1,this.hasColorTextureTransform=!1,this.hasEmissiveTextureTransform=!1,this.hasOcclusionTextureTransform=!1,this.hasMetallicRoughnessTextureTransform=!1,this.cloudReflections=!0,this.snowCover=!1,this.renderOccluded=!1,this.enableOITOffset=!1,this.sphereDepthInterpolate=!1,this.writeDepth=!0,this.oitPremultipliedAlpha=!1,this.occlusionPass=!1,this.bindType=2,this.useCustomDTRExponentForWater=!1,this.hasVertexTangents=!1,this.hasSliceTranslatedView=!1,this.rayMarchMaxReach=1,this.rayMarchMaxSteps=75,this.useProjectedRayLength=!1,this.clampRayToScreen=!0,this.instanced=!1,this.instancedDoublePrecision=!1,this.hasModelTransformation=!1,this.useFillLights=!0,this.draped=!1,this.useTransformationTexture=!0,this.sphericalSR=e.sphericalSR,this.useFloatBlend=e.useFloatBlend}get spherical(){return this.sphericalSR!==0}get overlayEnabled(){return(this.integratedMeshMode===2||this.integratedMeshMode===3)&&t(this.output)}get hasWater(){return this.pbrMode===3||this.pbrMode===4||this.pbrMode===6}}e([n()],i.prototype,`useFloatBlend`,void 0),e([n({count:12})],i.prototype,`output`,void 0),e([n({count:3})],i.prototype,`textureCoordinateType`,void 0),e([n({count:2})],i.prototype,`componentDataType`,void 0),e([n({count:3})],i.prototype,`cullFace`,void 0),e([n({count:3})],i.prototype,`vertexDiscardMode`,void 0),e([n({count:3})],i.prototype,`doubleSidedMode`,void 0),e([n({count:4})],i.prototype,`alphaDiscardMode`,void 0),e([n({count:4})],i.prototype,`integratedMeshMode`,void 0),e([n({count:8})],i.prototype,`pbrMode`,void 0),e([n({count:3})],i.prototype,`normalType`,void 0),e([n({count:8})],i.prototype,`emissionSource`,void 0),e([n({count:3})],i.prototype,`shadeNormals`,void 0),e([n({count:5})],i.prototype,`polygonOffset`,void 0),e([n({count:3})],i.prototype,`vertexPositionRotationType`,void 0),e([n()],i.prototype,`hasEmission`,void 0),e([n()],i.prototype,`hasVertexColors`,void 0),e([n()],i.prototype,`hasSlicePlane`,void 0),e([n()],i.prototype,`shouldDrapeRaster`,void 0),e([n()],i.prototype,`isGroundSlice`,void 0),e([n()],i.prototype,`hasColorTexture`,void 0),e([n()],i.prototype,`hasHighlightMixTexture`,void 0),e([n()],i.prototype,`emissionDimmingPass`,void 0),e([n()],i.prototype,`receiveAmbientOcclusion`,void 0),e([n()],i.prototype,`receiveGlobalIllumination`,void 0),e([n()],i.prototype,`receiveShadows`,void 0),e([n()],i.prototype,`hasShadowHighlights`,void 0),e([n()],i.prototype,`transparent`,void 0),e([n({count:4})],i.prototype,`groundTransparencyMode`,void 0),e([n()],i.prototype,`screenSpaceReflections`,void 0),e([n()],i.prototype,`hasMetallicRoughnessTexture`,void 0),e([n()],i.prototype,`hasOcclusionTexture`,void 0),e([n()],i.prototype,`hasNormalTexture`,void 0),e([n()],i.prototype,`hasOccludees`,void 0),e([n()],i.prototype,`terrainDepthTest`,void 0),e([n()],i.prototype,`cullAboveTerrain`,void 0),e([n()],i.prototype,`hasNormalTextureTransform`,void 0),e([n()],i.prototype,`hasColorTextureTransform`,void 0),e([n()],i.prototype,`hasEmissiveTextureTransform`,void 0),e([n()],i.prototype,`hasOcclusionTextureTransform`,void 0),e([n()],i.prototype,`hasMetallicRoughnessTextureTransform`,void 0),e([n()],i.prototype,`cloudReflections`,void 0),e([n()],i.prototype,`snowCover`,void 0),e([n()],i.prototype,`renderOccluded`,void 0),e([n()],i.prototype,`enableOITOffset`,void 0),e([n()],i.prototype,`sphereDepthInterpolate`,void 0);export{i as ComponentTechniqueConfiguration};
2
+ import{__decorate as e}from"tslib";import{isColorHighlightOrOLID as t}from"../../../core/shaderLibrary/ShaderOutput.js";import{parameter as n}from"../../../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{SphereDepthInterpolateConfiguration as r}from"../../../shaders/SphereDepthInterpolate.glsl.js";class i extends r{constructor(e){super(),this.output=0,this.textureCoordinateType=0,this.componentDataType=0,this.cullFace=2,this.vertexDiscardMode=0,this.doubleSidedMode=2,this.alphaDiscardMode=1,this.integratedMeshMode=0,this.pbrMode=0,this.normalType=0,this.emissionSource=0,this.shadeNormals=1,this.polygonOffset=0,this.vertexPositionRotationType=1,this.hasEmission=!1,this.hasVertexColors=!1,this.hasSlicePlane=!1,this.shouldDrapeRaster=!1,this.isGroundSlice=!1,this.hasColorTexture=!1,this.hasHighlightMixTexture=!1,this.emissionDimmingPass=!1,this.receiveAmbientOcclusion=!0,this.receiveGlobalIllumination=!1,this.receiveShadows=!0,this.hasShadowHighlights=!1,this.transparent=!0,this.groundTransparencyMode=1,this.screenSpaceReflections=!1,this.hasMetallicRoughnessTexture=!1,this.hasOcclusionTexture=!1,this.hasNormalTexture=!1,this.hasOccludees=!1,this.terrainDepthTest=!1,this.cullAboveTerrain=!1,this.hasNormalTextureTransform=!1,this.hasColorTextureTransform=!1,this.hasEmissiveTextureTransform=!1,this.hasOcclusionTextureTransform=!1,this.hasMetallicRoughnessTextureTransform=!1,this.cloudReflections=!1,this.emissionReflections=!1,this.snowCover=!1,this.renderOccluded=!1,this.enableOITOffset=!1,this.sphereDepthInterpolate=!1,this.writeDepth=!0,this.oitPremultipliedAlpha=!1,this.occlusionPass=!1,this.bindType=2,this.useCustomDTRExponentForWater=!1,this.hasVertexTangents=!1,this.hasSliceTranslatedView=!1,this.rayMarchMaxReach=1,this.rayMarchMaxSteps=75,this.useProjectedRayLength=!1,this.clampRayToScreen=!0,this.instanced=!1,this.instancedDoublePrecision=!1,this.hasModelTransformation=!1,this.useFillLights=!0,this.draped=!1,this.useTransformationTexture=!0,this.sphericalSR=e.sphericalSR,this.useFloatBlend=e.useFloatBlend}get spherical(){return this.sphericalSR!==0}get overlayEnabled(){return(this.integratedMeshMode===2||this.integratedMeshMode===3)&&t(this.output)}get hasWater(){return this.pbrMode===3||this.pbrMode===4||this.pbrMode===6}}e([n()],i.prototype,`useFloatBlend`,void 0),e([n({count:12})],i.prototype,`output`,void 0),e([n({count:3})],i.prototype,`textureCoordinateType`,void 0),e([n({count:2})],i.prototype,`componentDataType`,void 0),e([n({count:3})],i.prototype,`cullFace`,void 0),e([n({count:3})],i.prototype,`vertexDiscardMode`,void 0),e([n({count:3})],i.prototype,`doubleSidedMode`,void 0),e([n({count:4})],i.prototype,`alphaDiscardMode`,void 0),e([n({count:4})],i.prototype,`integratedMeshMode`,void 0),e([n({count:8})],i.prototype,`pbrMode`,void 0),e([n({count:3})],i.prototype,`normalType`,void 0),e([n({count:8})],i.prototype,`emissionSource`,void 0),e([n({count:3})],i.prototype,`shadeNormals`,void 0),e([n({count:5})],i.prototype,`polygonOffset`,void 0),e([n({count:3})],i.prototype,`vertexPositionRotationType`,void 0),e([n()],i.prototype,`hasEmission`,void 0),e([n()],i.prototype,`hasVertexColors`,void 0),e([n()],i.prototype,`hasSlicePlane`,void 0),e([n()],i.prototype,`shouldDrapeRaster`,void 0),e([n()],i.prototype,`isGroundSlice`,void 0),e([n()],i.prototype,`hasColorTexture`,void 0),e([n()],i.prototype,`hasHighlightMixTexture`,void 0),e([n()],i.prototype,`emissionDimmingPass`,void 0),e([n()],i.prototype,`receiveAmbientOcclusion`,void 0),e([n()],i.prototype,`receiveGlobalIllumination`,void 0),e([n()],i.prototype,`receiveShadows`,void 0),e([n()],i.prototype,`hasShadowHighlights`,void 0),e([n()],i.prototype,`transparent`,void 0),e([n({count:4})],i.prototype,`groundTransparencyMode`,void 0),e([n()],i.prototype,`screenSpaceReflections`,void 0),e([n()],i.prototype,`hasMetallicRoughnessTexture`,void 0),e([n()],i.prototype,`hasOcclusionTexture`,void 0),e([n()],i.prototype,`hasNormalTexture`,void 0),e([n()],i.prototype,`hasOccludees`,void 0),e([n()],i.prototype,`terrainDepthTest`,void 0),e([n()],i.prototype,`cullAboveTerrain`,void 0),e([n()],i.prototype,`hasNormalTextureTransform`,void 0),e([n()],i.prototype,`hasColorTextureTransform`,void 0),e([n()],i.prototype,`hasEmissiveTextureTransform`,void 0),e([n()],i.prototype,`hasOcclusionTextureTransform`,void 0),e([n()],i.prototype,`hasMetallicRoughnessTextureTransform`,void 0),e([n()],i.prototype,`cloudReflections`,void 0),e([n()],i.prototype,`emissionReflections`,void 0),e([n()],i.prototype,`snowCover`,void 0),e([n()],i.prototype,`renderOccluded`,void 0),e([n()],i.prototype,`enableOITOffset`,void 0),e([n()],i.prototype,`sphereDepthInterpolate`,void 0);export{i as ComponentTechniqueConfiguration};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
+ import{isShadow as e}from"./ShaderOutput.js";function t(t,n){e(n.output)&&t.vertex.main.add(`gl_Position.z = 0.0;`)}export{t as clampShadowPosition};
@@ -1,21 +1,21 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{glsl as e,If as t}from"../../shaderModules/glsl.js";import{Texture2DPassUniform as n}from"../../shaderModules/Texture2DPassUniform.js";import{NormalAttribute as r}from"../attributes/NormalAttribute.glsl.js";import{ObjectAndLayerIdColor as i}from"../attributes/ObjectAndLayerIdColor.glsl.js";import{TextureCoordinateAttribute as a}from"../attributes/TextureCoordinateAttribute.glsl.js";import{outputDepth as o}from"../output/OutputDepth.glsl.js";import{OutputHighlight as s}from"../output/OutputHighlight.glsl.js";import{VisualVariables as c}from"../shading/VisualVariables.glsl.js";import{sliceDraw as l}from"../Slice.glsl.js";import{Transform as u}from"../Transform.glsl.js";import{nearFar as d}from"../util/cameraUniforms.js";import{DiscardOrAdjustAlphaPass as f}from"../util/DiscardOrAdjustAlpha.glsl.js";import{addProjViewLocalOrigin as p}from"../util/View.glsl.js";import{DefaultMaterialExternalColor as m}from"./DefaultMaterialExternalColor.glsl.js";function h(h,g){let{vertex:_,fragment:v,varyings:y}=h,{hasColorTexture:b,alphaDiscardMode:x}=g,S=b&&x!==1,{output:C,normalType:w,hasColorTextureTransform:T}=g;switch(C){case 3:p(_,g),h.include(u),v.include(l,g),h.include(a,g),S&&v.uniforms.add(new n(`tex`,e=>e.texture)),_.main.add(e`vpos = getVertexInLocalOriginSpace();
2
+ import{glsl as e,If as t}from"../../shaderModules/glsl.js";import{Texture2DPassUniform as n}from"../../shaderModules/Texture2DPassUniform.js";import{NormalAttribute as r}from"../attributes/NormalAttribute.glsl.js";import{ObjectAndLayerIdColor as i}from"../attributes/ObjectAndLayerIdColor.glsl.js";import{TextureCoordinateAttribute as a}from"../attributes/TextureCoordinateAttribute.glsl.js";import{clampShadowPosition as o}from"../clampShadowPosition.glsl.js";import{outputDepth as s}from"../output/OutputDepth.glsl.js";import{OutputHighlight as c}from"../output/OutputHighlight.glsl.js";import{VisualVariables as l}from"../shading/VisualVariables.glsl.js";import{sliceDraw as u}from"../Slice.glsl.js";import{Transform as d}from"../Transform.glsl.js";import{nearFar as f}from"../util/cameraUniforms.js";import{DiscardOrAdjustAlphaPass as p}from"../util/DiscardOrAdjustAlpha.glsl.js";import{addProjViewLocalOrigin as m}from"../util/View.glsl.js";import{DefaultMaterialExternalColor as h}from"./DefaultMaterialExternalColor.glsl.js";function g(g,_){let{vertex:v,fragment:y,varyings:b}=g,{hasColorTexture:x,alphaDiscardMode:S}=_,C=x&&S!==1,{output:w,normalType:T,hasColorTextureTransform:E}=_;switch(w){case 3:m(v,_),g.include(d),y.include(u,_),g.include(a,_),C&&y.uniforms.add(new n(`tex`,e=>e.texture)),v.main.add(e`vpos = getVertexInLocalOriginSpace();
3
3
  vpos = subtractOrigin(vpos);
4
4
  vpos = addVerticalOffset(vpos, localOrigin);
5
5
  gl_Position = transformPosition(proj, view, vpos);
6
- forwardTextureCoordinates();`),h.include(f,g),v.main.add(e`
6
+ forwardTextureCoordinates();`),g.include(p,_),y.main.add(e`
7
7
  discardBySlice(vpos);
8
- ${t(S,e`vec4 texColor = texture(tex, ${T?`colorUV`:`vuv0`});
9
- discardOrAdjustAlpha(texColor);`)}`);break;case 5:case 6:case 7:case 8:case 11:p(_,g),h.include(u),h.include(a,g),h.include(c,g),h.include(o,g),v.include(l,g),h.include(i,g),y.add(`depth`,`float`,{invariant:!0}),S&&v.uniforms.add(new n(`tex`,e=>e.texture)),_.uniforms.add(d).main.add(e`vpos = getVertexInLocalOriginSpace();
8
+ ${t(C,e`vec4 texColor = texture(tex, ${E?`colorUV`:`vuv0`});
9
+ discardOrAdjustAlpha(texColor);`)}`);break;case 5:case 6:case 7:case 8:case 11:m(v,_),g.include(d),g.include(a,_),g.include(l,_),g.include(s,_),y.include(u,_),g.include(i,_),b.add(`depth`,`float`,{invariant:!0}),C&&y.uniforms.add(new n(`tex`,e=>e.texture)),v.uniforms.add(f).main.add(e`vpos = getVertexInLocalOriginSpace();
10
10
  vpos = subtractOrigin(vpos);
11
11
  vpos = addVerticalOffset(vpos, localOrigin);
12
12
  gl_Position = transformPositionWithDepth(proj, view, vpos, nearFar, depth);
13
13
  forwardTextureCoordinates();
14
- forwardObjectAndLayerIdColor();`),h.include(f,g),v.main.add(e`
14
+ forwardObjectAndLayerIdColor();`),g.include(o,_),g.include(p,_),y.main.add(e`
15
15
  discardBySlice(vpos);
16
- ${t(S,e`vec4 texColor = texture(tex, ${T?`colorUV`:`vuv0`});
16
+ ${t(C,e`vec4 texColor = texture(tex, ${E?`colorUV`:`vuv0`});
17
17
  discardOrAdjustAlpha(texColor);`)}
18
- ${C===11?e`outputObjectAndLayerIdColor();`:e`outputDepth(depth);`}`);break;case 4:{p(_,g),h.include(u),h.include(r,g),h.include(a,g),h.include(c,g),h.include(m,g),S&&v.uniforms.add(new n(`tex`,e=>e.texture)),w===2&&y.add(`vPositionView`,`vec3`,{invariant:!0});let i=w===0||w===1;i&&y.add(`vNormalWorld`,`vec3`),_.main.add(e`
18
+ ${w===11?e`outputObjectAndLayerIdColor();`:e`outputDepth(depth);`}`);break;case 4:{m(v,_),g.include(d),g.include(r,_),g.include(a,_),g.include(l,_),g.include(h,_),C&&y.uniforms.add(new n(`tex`,e=>e.texture)),T===2&&b.add(`vPositionView`,`vec3`,{invariant:!0});let i=T===0||T===1;i&&b.add(`vNormalWorld`,`vec3`),v.main.add(e`
19
19
  forwardDefaultMaterialExternalColor();
20
20
 
21
21
  if (shouldCullByOpacity()) {
@@ -28,22 +28,22 @@ forwardObjectAndLayerIdColor();`),h.include(f,g),v.main.add(e`
28
28
  vpos = subtractOrigin(vpos);
29
29
  vpos = addVerticalOffset(vpos, localOrigin);
30
30
  gl_Position = transformPosition(proj, view, vpos);
31
- forwardTextureCoordinates();`),v.include(l,g),h.include(f,g),v.main.add(e`
31
+ forwardTextureCoordinates();`),y.include(u,_),g.include(p,_),y.main.add(e`
32
32
  discardBySlice(vpos);
33
- ${t(S,e`vec4 texColor = texture(tex, ${T?`colorUV`:`vuv0`});
33
+ ${t(C,e`vec4 texColor = texture(tex, ${E?`colorUV`:`vuv0`});
34
34
  discardOrAdjustAlpha(texColor);`,e`vec4 texColor = vec4(1.0);`)}
35
35
  float opacity = getDefaultMaterialOpacity(texColor.a);
36
36
 
37
- ${w===2?e`vec3 normal = screenDerivativeNormal(vPositionView);`:e`vec3 normal = normalize(vNormalWorld);
37
+ ${T===2?e`vec3 normal = screenDerivativeNormal(vPositionView);`:e`vec3 normal = normalize(vNormalWorld);
38
38
  if (gl_FrontFacing == false){
39
39
  normal = -normal;
40
40
  }`}
41
- fragColor = vec4(0.5 + 0.5 * normal, opacity);`);break}case 10:p(_,g),h.include(u),h.include(a,g),h.include(c,g),S&&v.uniforms.add(new n(`tex`,e=>e.texture)),_.main.add(e`vpos = getVertexInLocalOriginSpace();
41
+ fragColor = vec4(0.5 + 0.5 * normal, opacity);`);break}case 10:m(v,_),g.include(d),g.include(a,_),g.include(l,_),C&&y.uniforms.add(new n(`tex`,e=>e.texture)),v.main.add(e`vpos = getVertexInLocalOriginSpace();
42
42
  vpos = subtractOrigin(vpos);
43
43
  vpos = addVerticalOffset(vpos, localOrigin);
44
44
  gl_Position = transformPosition(proj, view, vpos);
45
- forwardTextureCoordinates();`),v.include(l,g),h.include(f,g),h.include(s,g),v.main.add(e`
45
+ forwardTextureCoordinates();`),y.include(u,_),g.include(p,_),g.include(c,_),y.main.add(e`
46
46
  discardBySlice(vpos);
47
- ${t(S,e`vec4 texColor = texture(tex, ${T?`colorUV`:`vuv0`});
47
+ ${t(C,e`vec4 texColor = texture(tex, ${E?`colorUV`:`vuv0`});
48
48
  discardOrAdjustAlpha(texColor);`)}
49
- calculateOcclusionAndOutputHighlight();`)}}export{h as DefaultMaterialAuxiliaryPasses};
49
+ calculateOcclusionAndOutputHighlight();`)}}export{g as DefaultMaterialAuxiliaryPasses};
@@ -1,5 +1,5 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{FloatBindUniform as e}from"../../shaderModules/FloatBindUniform.js";import{FloatPassUniform as t}from"../../shaderModules/FloatPassUniform.js";import{glsl as n}from"../../shaderModules/glsl.js";import{addVerticalOffset as r}from"../attributes/VerticalOffset.glsl.js";import{viewport as i,viewNormal as a,pixelRatio as o}from"../util/cameraUniforms.js";import{ScreenSizePerspective as s,addScreenSizePerspectiveAlignment as c}from"../util/ScreenSizePerspective.glsl.js";import{addProjViewLocalOrigin as l,addCameraPosition as u}from"../util/View.glsl.js";const d=.5;function f(f,p){let m=f.vertex;f.include(s),f.attributes.add(`position`,`vec3`),f.vertex.inputs.add(`position`,()=>`position`),f.attributes.add(`normal`,`vec3`),p.hasVertexCenterOffset?f.attributes.add(`centerOffset`,`vec3`):m.constants.add(`centerOffset`,`vec3`,[0,0,0]),f.attributes.add(`groundDistance`,`float`),l(m,p),u(m,p),m.uniforms.add(i,new t(`polygonOffset`,e=>e.shaderPolygonOffset),new e(`aboveGround`,e=>e.camera.aboveGround?1:-1)),p.hasVerticalOffset&&r(m),m.code.add(n`struct ProjectHUDAux {
2
+ import{FloatBindUniform as e}from"../../shaderModules/FloatBindUniform.js";import{FloatPassUniform as t}from"../../shaderModules/FloatPassUniform.js";import{glsl as n}from"../../shaderModules/glsl.js";import{addVerticalOffset as r}from"../attributes/VerticalOffset.glsl.js";import{viewport as i,viewNormal as a,pixelRatio as o}from"../util/cameraUniforms.js";import{ScreenSizePerspective as s,addScreenSizePerspectiveAlignment as c}from"../util/ScreenSizePerspective.glsl.js";import{addProjView as l,addCameraPosition as u}from"../util/View.glsl.js";const d=.5;function f(f,p){let m=f.vertex;f.include(s),f.attributes.add(`position`,`vec3`),f.vertex.inputs.add(`position`,()=>`position`),f.attributes.add(`normal`,`vec3`),p.hasVertexCenterOffset?f.attributes.add(`centerOffset`,`vec3`):m.constants.add(`centerOffset`,`vec3`,[0,0,0]),f.attributes.add(`groundDistance`,`float`),l(m,p),u(m,p),m.uniforms.add(i,new t(`polygonOffset`,e=>e.shaderPolygonOffset),new e(`aboveGround`,e=>e.camera.aboveGround?1:-1)),p.hasVerticalOffset&&r(m),m.code.add(n`struct ProjectHUDAux {
3
3
  vec3 posModel;
4
4
  vec3 posView;
5
5
  vec3 vnormal;
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{Texture2DBindUniform as e}from"../shaderModules/Texture2DBindUniform.js";const t=new e(`lastFrameColorTexture`,e=>e.reprojection.lastFrameColor?.getTexture());export{t as lastFrameColorTexture};
2
+ import{Texture2DBindUniform as e}from"../shaderModules/Texture2DBindUniform.js";const t=new e(`lastFrameColorTexture`,e=>e.reprojection.lastFrameColor?.getTexture()),n=new e(`lastFrameEmissionTexture`,e=>e.reprojection.lastFrameEmission?.getTexture());export{t as lastFrameColorTexture,n as lastFrameEmissionTexture};