@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{toRadian as e}from"../../../../core/libs/gl-matrix-2/math/common.js";import{fromValues as t,create as n}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{scale as i}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{getMetersPerUnitForSR as a}from"../../../../core/units.js";import{fromBuffer as o,intersectsClippingArea as s,empty as c,expandWithAABB as l,create as u,center as d}from"../../../../geometry/support/aaBoundingBox.js";import{empty as f,expandXYInPlace as p,create as m}from"../../../../geometry/support/aaBoundingRect.js";import{BufferViewVec3f as h,BufferViewVec2f as g,BufferViewVec4u8 as _}from"../../../../geometry/support/buffer/BufferView.js";import{loadTessellationUtils as v,preloadedPolygonToRenderInfoElevationAligned as y,preloadedPolygonToRenderInfoDraped as b}from"../../support/renderInfoUtils/polygon.js";import{BufferGeometry as x}from"../../webgl-engine/lib/BufferGeometry.js";import{BufferObject3D as S}from"../../webgl-engine/lib/BufferObject3D.js";import{Buffers as C}from"../../webgl-engine/lib/Buffers.js";import{wavePresets as w}from"../../webgl-engine/materials/internal/waterMaterialUtils.js";import{Parameters as T,WaterMaterial as E,getWaterLayout as D}from"../../webgl-engine/materials/WaterMaterial.js";import{perBufferVertexElevationAligner as O}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as k,needsElevationUpdates2D as A}from"./elevationAlignmentUtils.js";import{Graphics3DBufferGraphicLayer as j}from"./Graphics3DBufferGraphicLayer.js";import{Graphics3DDrapedBufferGraphicLayer as M}from"./Graphics3DDrapedBufferGraphicLayer.js";import{Graphics3DSymbolLayer as N}from"./Graphics3DSymbolLayer.js";import{geometryAsPolygon as P,PolygonCreationDataBase as F}from"./polygonUtils.js";const I=[`polyline`,`polygon`,`extent`];class L extends N{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r)}async doLoad(){await v()}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry,I,this.symbolLayer.type))return null;let n=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus(n.mode===`on-the-ground`),this.ensureMaterial(),this.draped?this._createAsOverlay(t):this._createAs3DShape(t,n,t.uid)}ensureMaterial(){if(this._materials[0])return;let e=new T,n=this.symbolLayer.color.toUnitRGBA();n[3]*=this._getLayerOpacity(),e.color=n,e.transparent=n[3]<1||this.needsDrivenTransparentPass,e.waveDirection=this.symbolLayer.waveDirection==null?t(0,0):R(this.symbolLayer.waveDirection);let r=this.symbolLayer.waveStrength+`-`+this.symbolLayer.waterbodySize,i=w[r];e.waveStrength=i.waveStrength,e.waveTextureRepeat=i.textureRepeat,e.waveVelocity=i.waveVelocity,e.flowStrength=i.perturbationStrength,e.hasSlicePlane=this._context.slicePlaneEnabled,e.draped=this.draped,e.useIndexing=!0,this._materials[0]=new E(e,this._context)}layerOpacityChanged(){if(this._materials[0]==null)return;let e=this._materials[0].parameters.color,t=this.symbolLayer.color.a*this._getLayerOpacity(),n=t<1||this.needsDrivenTransparentPass;this._materials[0].setParameters({color:[e[0],e[1],e[2],t],transparent:n})}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=k(L.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=A(r);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicallyBasedRenderingChanged(){return!0}get needsDrivenTransparentPass(){return!1}_createAs3DShape(e,t,n){let r=P(e.geometry);if(r==null)return null;let i=y(r,this._context.elevationProvider,this._context.renderCoordsHelper,t,{owner:this._context.layer});if(i==null)return null;let a=new W(i,this._context.layerViewUid,e.uid);if(a.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(a),this._create3DShapeGeometries(a),this._logGeometryCreationWarnings(a.renderInfo,r.rings,`rings`,`WaterSymbol3DLayer`),a.outGeometries.length===0)return null;let o=new S({geometries:a.outGeometries,castShadow:!1,layerViewUid:this._context.layerViewUid,graphicUid:n}),s=new j(this,o,null,O,t);return s.alignedSampledElevation=a.renderInfo.sampledElevation,s.needsElevationUpdates=A(t.mode),s}_create3DShapeGeometries(e){let{mapPositions:t}=e.renderInfo;if(e.renderInfo.polygonIndexCount===0||this._context.clippingExtent!=null&&(o(t,V),!s(V,this._context.clippingExtent)))return;let n=z(e.renderInfo,this._materials[0],this._context.localOriginFactory,this._context.elevationProvider.spatialReference,e.olidColor,e.layerViewUid,e.graphicUid);e.outGeometries.push(n)}_createAsOverlay(e){let t=P(e.geometry);if(t==null)return null;this._materials[0].renderPriority=this._renderPriority;let n=b(t,{drapedSpatialReference:this._context.overlaySR,owner:this._context.layer});if(n==null)return null;let r=new G(n,this._context.layerViewUid,e.uid);return r.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(r),r.outBoundingBox=c(),this._createAsOverlayWater(r),this._logGeometryCreationWarnings(r.renderInfo,t.rings,`rings`,`WaterSymbol3DLayer`),r.outGeometries.length===0?null:new M(this,r.outGeometries,r.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayWater(e){let{positions:t}=e.renderInfo;if(o(t,V),!s(V,this._context.clippingExtent)||(l(e.outBoundingBox,V),e.renderInfo.polygonIndexCount===0))return;let n=z(e.renderInfo,this._materials[0],this._context.drapeSourceRenderer.rendererContext.localOriginFactory,this._context.overlaySR,e.olidColor,e.layerViewUid,e.graphicUid);e.outGeometries.push(n)}test(){return{...super.test(),create3DShape:e=>this._createAs3DShape(e.graphic,e.elevationContext,e.graphicUid),ensureMaterial:()=>this.ensureMaterial()}}}function R(t){let r=n(),i=e(t);return r[0]=Math.sin(i),r[1]=Math.cos(i),r}function z(e,t,n,r,s,c,l){let{positions:u,polygonIndices:m,vertexCount:v}=e,y=`mapPositions`in e?e.mapPositions:null,b=y??u;o(u,V),d(V,U);let S=n.getOrigin(U),w=D().createBuffer(v),T=w.getField(`position`,h),E=w.getField(`uv0`,g),O=w.getField(`olidColor`,_),k=a(r);f(H);for(let e=0;e<v;e++)p(H,b[e*3],b[e*3+1]);i(H,H,k);let[A,j]=H,M=A-A%B,N=j-j%B,P=S.vec3;for(let e=0;e<v;e++){let t=e*3;T.setValues(e,u[t]-P[0],u[t+1]-P[1],u[t+2]-P[2]),E.setValues(e,(b[t]*k-M)/B,(b[t+1]*k-N)/B),O!=null&&s!=null&&O.setVec(e,s)}let F=new x(t,new C(w,void 0,m),S,y);return F.layerViewUid=c,F.graphicUid=l,F}const B=100,V=u(),H=m(),U=r();class W extends F{}class G extends F{}export{L as Graphics3DWaterSymbolLayer,z as createWaterGeometry,R as headingVectorFromAngle};
2
+ import{toRadian as e}from"../../../../core/libs/gl-matrix-2/math/common.js";import{fromValues as t,create as n}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{scale as i}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{getMetersPerUnitForSR as a}from"../../../../core/units.js";import{fromBuffer as o,intersectsClippingArea as s,empty as c,expandWithAABB as l,create as u,center as d}from"../../../../geometry/support/aaBoundingBox.js";import{empty as f,expandXYInPlace as p,create as m}from"../../../../geometry/support/aaBoundingRect.js";import{BufferViewVec3f as h,BufferViewVec2f as g,BufferViewVec4u8 as _}from"../../../../geometry/support/buffer/BufferView.js";import{loadTessellationUtils as v,preloadedPolygonToRenderInfoElevationAligned as y,preloadedPolygonToRenderInfoDraped as b}from"../../support/renderInfoUtils/polygon.js";import{BufferGeometry as x}from"../../webgl-engine/lib/BufferGeometry.js";import{BufferObject3D as S}from"../../webgl-engine/lib/BufferObject3D.js";import{Buffers as C}from"../../webgl-engine/lib/Buffers.js";import{wavePresets as w}from"../../webgl-engine/materials/internal/waterMaterialUtils.js";import{Parameters as T,WaterMaterial as E,getWaterLayout as D}from"../../webgl-engine/materials/WaterMaterial.js";import{perBufferVertexElevationAligner as O}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as k,needsElevationUpdates2D as A}from"./elevationAlignmentUtils.js";import{Graphics3DBufferGraphicLayer as j}from"./Graphics3DBufferGraphicLayer.js";import{Graphics3DDrapedBufferGraphicLayer as M}from"./Graphics3DDrapedBufferGraphicLayer.js";import{Graphics3DSymbolLayer as N}from"./Graphics3DSymbolLayer.js";import{geometryAsPolygon as P,PolygonCreationDataBase as F}from"./polygonUtils.js";const I=[`polyline`,`polygon`,`extent`];class L extends N{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r)}async doLoad(){await v()}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry,I,this.symbolLayer.type))return null;let n=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus(n.mode===`on-the-ground`),this.ensureMaterial(),this.draped?this._createAsOverlay(t):this._createAs3DShape(t,n,t.uid)}ensureMaterial(){if(this._materials[0])return;let e=new T,n=this.symbolLayer.color.toUnitRGBA();n[3]*=this._getLayerOpacity(),e.color=n,e.transparent=n[3]<1||this.needsDrivenTransparentPass,e.waveDirection=this.symbolLayer.waveDirection==null?t(0,0):R(this.symbolLayer.waveDirection);let r=this.symbolLayer.waveStrength+`-`+this.symbolLayer.waterbodySize,i=w[r];e.waveStrength=i.waveStrength,e.waveTextureRepeat=i.textureRepeat,e.waveVelocity=i.waveVelocity,e.flowStrength=i.perturbationStrength,e.hasSlicePlane=this._context.slicePlaneEnabled,e.draped=this.draped,e.castShadows=this.symbolLayer.castShadows,e.useIndexing=!0,this._materials[0]=new E(e,this._context)}layerOpacityChanged(){if(this._materials[0]==null)return;let e=this._materials[0].parameters.color,t=this.symbolLayer.color.a*this._getLayerOpacity(),n=t<1||this.needsDrivenTransparentPass;this._materials[0].setParameters({color:[e[0],e[1],e[2],t],transparent:n})}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=k(L.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=A(r);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicallyBasedRenderingChanged(){return!0}get needsDrivenTransparentPass(){return!1}_createAs3DShape(e,t,n){let r=P(e.geometry);if(r==null)return null;let i=y(r,this._context.elevationProvider,this._context.renderCoordsHelper,t,{owner:this._context.layer});if(i==null)return null;let a=new W(i,this._context.layerViewUid,e.uid);if(a.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(a),this._create3DShapeGeometries(a),this._logGeometryCreationWarnings(a.renderInfo,r.rings,`rings`,`WaterSymbol3DLayer`),a.outGeometries.length===0)return null;let o=new S({geometries:a.outGeometries,castShadows:this.symbolLayer.castShadows,layerViewUid:this._context.layerViewUid,graphicUid:n}),s=new j(this,o,null,O,t);return s.alignedSampledElevation=a.renderInfo.sampledElevation,s.needsElevationUpdates=A(t.mode),s}_create3DShapeGeometries(e){let{mapPositions:t}=e.renderInfo;if(e.renderInfo.polygonIndexCount===0||this._context.clippingExtent!=null&&(o(t,V),!s(V,this._context.clippingExtent)))return;let n=z(e.renderInfo,this._materials[0],this._context.localOriginFactory,this._context.elevationProvider.spatialReference,e.olidColor,e.layerViewUid,e.graphicUid);e.outGeometries.push(n)}_createAsOverlay(e){let t=P(e.geometry);if(t==null)return null;this._materials[0].renderPriority=this._renderPriority;let n=b(t,{drapedSpatialReference:this._context.overlaySR,owner:this._context.layer});if(n==null)return null;let r=new G(n,this._context.layerViewUid,e.uid);return r.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(r),r.outBoundingBox=c(),this._createAsOverlayWater(r),this._logGeometryCreationWarnings(r.renderInfo,t.rings,`rings`,`WaterSymbol3DLayer`),r.outGeometries.length===0?null:new M(this,r.outGeometries,r.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayWater(e){let{positions:t}=e.renderInfo;if(o(t,V),!s(V,this._context.clippingExtent)||(l(e.outBoundingBox,V),e.renderInfo.polygonIndexCount===0))return;let n=z(e.renderInfo,this._materials[0],this._context.drapeSourceRenderer.rendererContext.localOriginFactory,this._context.overlaySR,e.olidColor,e.layerViewUid,e.graphicUid);e.outGeometries.push(n)}test(){return{...super.test(),create3DShape:e=>this._createAs3DShape(e.graphic,e.elevationContext,e.graphicUid),ensureMaterial:()=>this.ensureMaterial()}}}function R(t){let r=n(),i=e(t);return r[0]=Math.sin(i),r[1]=Math.cos(i),r}function z(e,t,n,r,s,c,l){let{positions:u,polygonIndices:m,vertexCount:v}=e,y=`mapPositions`in e?e.mapPositions:null,b=y??u;o(u,V),d(V,U);let S=n.getOrigin(U),w=D().createBuffer(v),T=w.getField(`position`,h),E=w.getField(`uv0`,g),O=w.getField(`olidColor`,_),k=a(r);f(H);for(let e=0;e<v;e++)p(H,b[e*3],b[e*3+1]);i(H,H,k);let[A,j]=H,M=A-A%B,N=j-j%B,P=S.vec3;for(let e=0;e<v;e++){let t=e*3;T.setValues(e,u[t]-P[0],u[t+1]-P[1],u[t+2]-P[2]),E.setValues(e,(b[t]*k-M)/B,(b[t+1]*k-N)/B),O!=null&&s!=null&&O.setVec(e,s)}let F=new x(t,new C(w,void 0,m),S,y);return F.layerViewUid=c,F.graphicUid=l,F}const B=100,V=u(),H=m(),U=r();class W extends F{}class G extends F{}export{L as Graphics3DWaterSymbolLayer,z as createWaterGeometry,R as headingVectorFromAngle};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import has from"../../../../core/has.js";import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import t from"../../../../core/PooledArray.js";import{isAbortError as n}from"../../../../core/promiseUtils.js";import{projectBoundingSphere as r}from"../../../../geometry/projection/projectBoundingSphere.js";import{Sphere as i}from"../../../../geometry/support/sphere.js";import{ElevationRange as a}from"../../support/ElevationRange.js";import{Obb as o}from"../../support/orientedBoundingBox.js";import{NodeBoundingData as s,Node as c,NodeTraversalState as l}from"./I3SNode.js";import{addWraparound as u}from"./I3SUtil.js";import{ValidatedNode as d}from"./ValidatedNode.js";class f{constructor(e,t,n,r,i){this.childOffset=e,this.childCount=t,this.visibilityCache=n,this._boundingData=r,this.node=i,this.parentIndex=-1,this.useAsHole=0,this.filterImpact=2,this.traversalState=null}get nodeBoundingData(){return this._boundingData}destroy(){this._boundingData=null,this.node=null,this.traversalState=null}invalidateBounds(){this.node?.invalidateServiceBVsInRenderSR(),this.nodeBoundingData?.invalidateServiceBVsInRenderSR()}}class p{constructor(e=[],t=[]){this._nodeDescriptors=e,this._children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}destroy(){for(let e of this._nodeDescriptors)e.destroy();this._nodeDescriptors.length=0,this._children.length=0}get nodes(){return this._nodeDescriptors}addNode(e){return this._nodeDescriptors.push(e),this._nodeDescriptors.length-1}setNodes(e,t){this._nodeDescriptors=e,this._children=t}get children(){return this._children}}class m{get _useNodePages(){return this._pageSize>0}constructor(e,n,r,i,a,o,c,l,u,d,f,m,h,_,y,b){if(this._layer=e,this._groundNavigationCheckDistance=r,this._requester=a,this._clientNodeLoader=o,this._viewportQueries=c,this._logger=l,this.holeFilling=u,this._isLoaded=d,this._isReloading=f,this._shouldLoadNode=m,this._enable=h,this._needsUpdate=_,this._computeVisibilityObb=y,this._computeNodeFiltering=b,this._dirty=!0,this._nodePages=new Map,this._clientNodePage=null,this._pageSize=0,this._rootIndex=0,this._lodMetric=0,this._lodConversion=e=>e,this._isEditable=!1,this.urlPrefix=``,this._loadingNodes=new Set,this._loadingPages=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=-1/0,this._maxProcessingPrio=1/0,this._version=v(0),this._visibilityCacheVersion=v(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._progressiveLoadPenaltyWeight=10,this._missingPagesAndNodes=new Set,this._prioritizedMissingNodeAndPageIds=[],this._prefetchNodes=new Set,this._prioritizedPrefetchNodes=[],this._updates=new g(this._missingPagesAndNodes),this._imModificationUncategorized=new t({deallocator:null}),this.ignoreServiceObb=!1,this.isGroundNavigationMode=!1,this._pageQueue=[],this._newPages=[],this._needsNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._isEditable=e.associatedLayer?.infoFor3D!=null,this.isGroundNavigationMode=n,e.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${e.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,i.type===`page`){let e=i.rootPage;switch(this.urlPrefix=i.urlPrefix,this._pageSize=i.pageSize,i.lodMetric){case`maxScreenThreshold`:this._lodMetric=1;break;case`maxScreenThresholdSQ`:this._lodMetric=1,this._lodConversion=k}if(this._isEditable){this._rootIndex=-1;let t=C(i.rootIndex,i.pageSize),n=e.nodes[t],r={nodes:[{index:this._rootIndex,children:[i.rootIndex],mesh:void 0,obb:n.obb,lodThreshold:n.lodThreshold}]};this._addPage(S(this._rootIndex,this._pageSize),r),this.getNode(-1).serviceObbInIndexSR=void 0}else this._rootIndex=i.rootIndex;this._addPage(S(i.rootIndex,this._pageSize),e),this._updateParentsAndLevel()}else if(i.type===`node`){this.urlPrefix=i.urlPrefix;let e=new p;if(this._nodePages.set(0,e),this._isEditable){this._clientNodePage=new p;let e={id:`-1`,version:null,mbs:i.rootNode.mbs,obb:i.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:`root`,href:`../root`,mbs:i.rootNode.mbs,obb:i.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new s(e.id),-1);let t=this._validateNode(e.id,e);t&&this._addNode(t,this._rootIndex)}else this._rootIndex=this._makeRefNode(new s(i.rootNode.id),-1);let t=this._validateNode(i.rootNode.id,i.rootNode);t&&this._addNode(t,0)}}addClientNodeToIndex(e,t){let n=new s(e,t),r=this._makeClientRefNode(n,-1);return this._linkChildToParentNode(-1,r),this.requestUpdate(),r}removeClientNodeFromIndex(e,t,n){this._destroyClientRefNode(e,t,n),this.requestUpdate()}_canRequest(e){return!this._requester.isFull(e)}_loadPage(e){if(this._nodePages.has(e)){this._logger.error(`Requested load page [${e}] already loaded`);return}if(this._loadingPages.has(e)){this._logger.error(`Requested load page [${e}] already loading`);return}this._loadingPages.add(e);let t=this.urlPrefix+e;this._requester.request(t,`json`).then(t=>{this._nodePages.has(e)?this._logger.error(`Queued page [${e}] already loaded`):this._pageQueue.push({pageIndex:e,page:t})}).catch(t=>{this._loadingPages.delete(e),n(t)||(this._failedPages.add(e),this._logger.error(`#loadPage()`,this._layer,`Error when loading page ${e}`,t))})}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){let{pageIndex:t,page:n}=this._pageQueue.shift();this._addPage(t,n),this._loadingPages.delete(t),e.madeProgress(),this._needsNodeElevationRange&&this._newPages.push(t)}this._updateParentsAndLevel()}_invalidateElevationRangeForNewPages(e){if(this._needsNodeElevationRange)for(;this._newPages.length>0&&!e.done;)this._nodePages.get(this._newPages.shift())?.nodes.forEach(e=>{let t=e.parentIndex;for(;t!=null&&t!==this._rootIndex;){let e=this.getNode(t);e?.elevationRangeValid&&(e.invalidateElevationRange(),this.invalidateBoundingVolumeCache(t)),t=this._getParentIndex(t)}})}_addPage(e,t){if(this._nodePages.has(e)){this._logger.error(`Page[${e}] reloaded`);return}let n=[],r=[],a=t.nodes.map((t,a)=>{let s=n.length,l=t.children?t.children.length:0;r.push(this._rootIndex);for(let e=0;e<l;e++)n.push(t.children[e]);let u=`${t.index}`,d=o.fromJSON(t.obb),p=new i(d.getCenter(N),d.radius),m=t.mesh?.attribute,h=t.mesh?.geometry,g=t.mesh?.material,v={hasSharedResource:!1,isEmpty:h==null,attributes:m?.resource==null?void 0:`${m.resource}`,geometry:h?.resource==null?void 0:`${h.resource}`,texture:g?.resource==null?void 0:`${g.resource}`,geometryDefinition:h?h.definition:-1,materialDefinition:g?g.definition:-1},y=new c(u,w(a,e,this._pageSize),p,l,0,v,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),h?.featureCount??null,d);return y.visibilityObbInRenderSR=this._computeVisibilityObb(y),y.vertexCount=h?h.vertexCount:0,new f(s,l,_(this._visibilityCacheVersion),null,y)}),s=new p(a,n);e===-1?this._clientNodePage=s:this._nodePages.set(e,s)}_updateParentsAndLevel(){let e=[],t=(t,n,r)=>{let i=this._getPage(t);if(i!=null){let a=C(t,this._pageSize),o=i.nodes[a];o.parentIndex=n??-1;let s=o.node;s!=null&&(s.level=r,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){let n=e.pop(),r=this.getNode(n);if(r!=null)for(let e=0;e<r.childCount;e++)t(this.getChildIndex(r.index,e),n,r.level+1),this._maxLevel=Math.max(this._maxLevel,r.level+1)}}_getPage(e){let t=S(e,this._pageSize);return this._getPageFromPageIndex(t)}_getPageFromPageIndex(e){return e<0?this._clientNodePage:this._nodePages.get(e)}_getNodeDescriptor(e){let t=this._getPage(e);return t==null?null:(t.lastTraversed=this._frameNumber,t.nodes[C(e,this._pageSize)])}_addNode(e,t){e.children&&this.populateChildren(t,e.children);let n=this.getParent(t),r=n==null?0:n.level+1;this._maxLevel=Math.max(this._maxLevel,e.children?r+1:r);let{lodMetric:i,maxError:a}=E(e.lodSelection),s=this._getNodeDescriptor(t);if(s.node!=null)return this._logger.error(`Loaded node[${t}] already in descriptor`),s.node;let l=new c(e.id,t,e.mbs,s.childCount,r,e.resources,e.version,i,a,e.numFeatures,e.obb?o.fromJSON(e.obb):null);s.node=l,l.visibilityObbInRenderSR=this._computeVisibilityObb(l);let u=s.nodeBoundingData;return u!=null&&(u.serviceMbsInIndexSR??=e.mbs,l.shareServiceBVsInRenderSRWith(u),u.visibilityObbInRenderSR=l.visibilityObbInRenderSR),l}_makeRefNode(e,t){let n=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(n==null)return-1;let r=n.nodes.length,i=new f(0,0,_(this._visibilityCacheVersion),e,null);return n.addNode(i),i.parentIndex=t,e.invalidateServiceBVsInRenderSR(),r}_makeClientRefNode(e,t){let n=this._clientNodePage;if(n==null)return-1;if(t>=0)throw Error(`I3SIndex::client side nodes can not be made children of service side nodes.`);let r=-(n.nodes.length+1),i=new f(0,0,_(this._visibilityCacheVersion),e,null);return n.addNode(i),i.parentIndex=t,e.invalidateServiceBVsInRenderSR(),r}_linkChildToParentNode(e,t){let n=this._clientNodePage;if(n==null||e>=0)return;let r=C(e,this._pageSize),i=C(t,this._pageSize),a=n.nodes[r],o=a.childOffset;n.children.splice(a.childOffset+a.childCount,0,t),a.childCount+=1,a.node!=null&&(a.node.childCount+=1);for(let e of n.nodes)e.childOffset>o&&(e.childOffset+=1);let s=n.nodes[i];s.parentIndex=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,n){let r=this._clientNodePage;if(r==null)return;let i=this._getParentIndex(e);if(i==null)return;let a=new Set,o=new Map,s=e=>{let n=C(e,this._pageSize),i=r.nodes[n];if(i.childCount>0)for(let e=i.childOffset;e<i.childOffset+i.childCount;++e)s(r.children[e]);let o=i.node?.id??i.nodeBoundingData?.id;if(o==null)throw Error(`Node has no id`);t(o,e),a.add(i)};s(e);let c=r.nodes,l=r.children,u=r.nodes.map(()=>-1),d=[],f=[];for(let e=0;e<c.length;++e){let t=c[e];if(a.has(t))continue;let r=d.length,i=w(e,-1,this._pageSize),s=w(r,-1,this._pageSize);if(t.node&&(t.node.index=s),u[e]=s,d.push(t),i!==s){let e=t.node?.id??t.nodeBoundingData?.id;if(e==null)throw Error(`Node has no id`);n(e,i,s),o.set(i,s)}}for(let e=0;e<d.length;++e){let t=w(e,-1,this._pageSize),n=d[e],r=f.length;for(let e=n.childOffset;e<n.childOffset+n.childCount;++e){let n=l[e];if(n>=0)f.push(n);else{let e=C(n,this._pageSize),r=c[e];if(a.has(r))continue;let i=u[e];f.push(i),r.parentIndex=t}}n.childOffset=r,n.childCount=f.length-r,n.node&&(n.node.childCount=n.childCount)}r.setNodes(d,f),this._updateParentBoundingInformation(u[C(i,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null,n=this._clientNodeLoader.indexSR,a=this._clientNodeLoader.renderSR,o=this._getNodeDescriptor(t);if(o==null)return;for(let i=0;i<o.childCount;i++){let o=this.getChildIndex(t,i),s=this._getNodeDescriptor(o),c=s==null?null:s.nodeBoundingData||s.node;if(c?.serviceMbsInIndexSR!=null&&c.serviceMbsInIndexSR.radius>0){if(e==null)e=A.copyFrom(c.serviceMbsInIndexSR);else{let t=j;r(c.serviceMbsInIndexSR,n,t,a);let i=M;r(e,n,i,a),r(t.union(i),a,e,n)}}}let s=t=>{t!=null&&(t.serviceObbInIndexSR=null,e==null?t.serviceMbsInIndexSR?.invalidate():(t.serviceMbsInIndexSR??=new i,t.serviceMbsInIndexSR.copyFrom(e)),t.invalidateServiceBVsInRenderSR(),t.geometryObbInRenderSR=null)};s(o.nodeBoundingData),s(o.node),this.invalidateNodeVisibilityCacheInternal(o),t=this._getParentIndex(t)}while(t!=null)}populateChildren(e,t){let n=this._getNodeDescriptor(e),r=this._getPage(e);n.childOffset=r.children.length,n.childCount=t.length;for(let n=0;n<t.length;n++){let i=this._makeRefNode(t[n],e);r.children.push(i)}}getNode(e){let t=this._getNodeDescriptor(e);return t==null?null:t.node}getIndexById(e){let t;return this._forAllNodes((n,r)=>{(n.node!=null&&n.node.id===e||n.nodeBoundingData!=null&&n.nodeBoundingData.id===e)&&(t=r)}),t}getNodeById(e){let t=this.getIndexById(e);return t!=null&&t>=0?this.getNode(t):null}getChildIndex(e,t){let n=this._getPage(e);if(n==null)return-1;let r=n.nodes[C(e,this._pageSize)];return n.children[r.childOffset+t]}_getParentIndex(e){let t=this._getPage(e);return t!=null&&e!==this._rootIndex?t.nodes[C(e,this._pageSize)]?.parentIndex:null}getParent(e){let t=this._getParentIndex(e);return t==null?null:this.getNode(t)}isLeaf(e){let t=this._getNodeDescriptor(e);return t!=null&&t.childCount===0}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes(e=>{e.node!=null&&(e.node.geometryObbInRenderSR=null)})}invalidateVisibilityCache(){this._visibilityCacheVersion=v(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){let t=this._getNodeDescriptor(e);t!=null&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=_(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){let t=this._getNodeDescriptor(e);t!=null&&(t?.invalidateBounds(),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){let t=this._getNodeDescriptor(e);t!=null&&(this._needsNodeElevationRange?(t.node==null?t.nodeBoundingData:t.node)?.invalidateElevationRange():this.invalidateBoundingVolumeCache(e))}invalidateGeometryVisibility(e){let t=this._getNodeDescriptor(e)?.node;t&&(t.geometryObbInRenderSR=null,t.invalidateServiceBVsInRenderSR())}invalidateVisibilityObbs(){this.rootNode!=null&&this.traverse(this.rootNode,e=>(e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.geometryObbInRenderSR=null,!0))}_isElevationRangeValid(e){if(!this._needsNodeElevationRange)return!0;let t=e?.node??e?.nodeBoundingData;return!t||t.elevationRangeValid}_updateElevationRange(e,t){let n=this._getNodeDescriptor(e);if(!n)return!1;let r=n?.node??n?.nodeBoundingData;if(!r)return!1;if(r.elevationRangeValid)return t?.expandElevationRange(r),!0;let i=new a,o=!1;for(let t=0;t<n.childCount;t++){let n=this.getChildIndex(e,t),r=this._updateElevationRange(n,i);o||=!r}if(n.childCount===0||o){let e=!n.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(r,e,i)}(i.minElevation===1/0||i.maxElevation===-1/0)&&i.expandElevationRangeValues(0,0);let{minElevation:s,maxElevation:c}=r;return s===i.minElevation&&c===i.maxElevation?(t?.expandElevationRange(r),!0):(n.node?.setElevationRange(i),n.nodeBoundingData?.setElevationRange(i),this.invalidateBoundingVolumeCache(e),t?.expandElevationRange(r),!0)}isNodeVisible(e){let t=this._getNodeDescriptor(e);if(t==null)return!0;let n=t.nodeBoundingData;if(n!=null&&!n.serviceMbsInIndexSR)return!0;if(this._isElevationRangeValid(t)&&b(t.visibilityCache,this._visibilityCacheVersion))return x(t.visibilityCache);let r=t.node,i=this._viewportQueries;if(r){let e=i.ensureElevationAgnosticBoundingVolume(r),n=i.isElevationAgnosticBoundingVolumeVisible(e,this.isGroundNavigationMode?this._groundNavigationCheckDistance:0),a=n;if(this._needsNodeElevationRange&&n){let t=i.getNodeObbInRenderSRIndependentOfElevationOffset(r);t!=null&&(a=i.isObbVisibleIndependentOfElevation(e,t))}if(!a)return t.visibilityCache=y(!1,this._visibilityCacheVersion),!1}if(this._layerHasFilter&&this._computeNodeFiltering&&(r!=null||n!=null)&&t.filterImpact===2){let e=r==null?n==null?null:n.serviceMbsInIndexSR:r.serviceMbsInIndexSR;t.filterImpact=e==null?0:this._computeNodeFiltering(e)}let a=r!=null&&t.filterImpact===1,o=(r==null||r.imModificationImpact!==2)&&!a;if(o){let t=r&&(!n||r.visibilityObbInRenderSR)?r:n??null;t!=null&&(this._needsNodeElevationRange&&this._updateElevationRange(e),o=i.isNodeVisible(t,this.isGroundNavigationMode))}return t.visibilityCache=y(o,this._visibilityCacheVersion),o}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;let t=this._getNodeDescriptor(e);return t?.node?.geometryObbInRenderSR!=null&&(!this.layerHasModifications||t.node.imModificationImpact!==4)?this._viewportQueries.isGeometryVisible(t.node,this.isGroundNavigationMode):!0}_traverseCoverage(e,t,n,r,i){let a=this._getPage(e);if(a==null||t.childCount===0)return;let o=t.childOffset+t.childCount,s=[];for(let e=t.childOffset;e<o;++e){let t=a.children[e],n=this._getNodeDescriptor(t);n?.node!=null&&this.isGeometryVisible(t)&&s.push(n)}r/=s.length;for(let e of s){let t=e.node.index;this._isLoaded(t)||this._isReloading(t)?(i.delta=Math.max(i.delta,n),i.coverage+=r):this._traverseCoverage(t,e,n+1,r,i)}}useNodeAsHole(e){if(this.holeFilling===`off`)return!1;let t=this._getNodeDescriptor(e);if(t==null)return!1;if(this.holeFilling===`always`)return!0;if(b(t.useAsHole,this._version))return x(t.useAsHole);let n={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,n);let r=n.delta*n.coverage<=.5;return t.useAsHole=y(r,this._version),r}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.destroy(),this._nodePages.clear(),this._clientNodePage=null,this._layer=null,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._imModificationUncategorized.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=v(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes(({node:e})=>{e!=null&&(e.imModificationImpact=4,e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))}),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes(e=>{if(e!=null){e.filterImpact=2;let t=e.node;t!=null&&this.invalidateNodeVisibilityCache(t.index)}}),this.invalidateVisibilityCache()}update(e,t,n){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._invalidateElevationRangeForNewPages(t),this.resetUpdateState(e);let r=!0,i=new D,a=new O,o=this._imModificationUncategorized;o.clear();let s=new Set,c=0;this.traverseVisible((s,l,u)=>{let d=e=>{this._shouldLoadNode(e)&&e.childCount&&(r=!1)};if(!l){let e=S(s,this._pageSize),t=this._getNodeLoadPriority(s);t===1/0&&(t=this._getNodeLoadPriority(u)),h.set(e,Math.max(t,h.get(e)||0)),!this._loadingPages.has(e)&&!this._failedPages.has(e)&&(this._missingPagesAndNodes.add(e),++c),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,t);return}let{node:f,childCount:p}=l;if(this._updateNodeFeatureEstimate(f,a),!f){let e=this._getNodeLoadPriority(s);!this._loadingNodes.has(s)&&!this._failedNodes.has(s)&&(this._missingPagesAndNodes.add(s),h.set(s,e)),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e);return}let m=this._getPage(s);if(!this._useNodePages&&this._missingPagesAndNodes.size===0)for(let e=0;e<p;e++){let t=m.children[l.childOffset+e],n=this._getNodeDescriptor(t);n!=null&&!n.node&&!this._loadingNodes.has(t)&&!this._failedNodes.has(t)&&t>=0&&(h.set(t,this._getNodeLoadPriority(t)),this._prefetchNodes.add(t))}if(f.failed||f.resources.isEmpty){d(f);return}if(this._isLoaded(s)){if(i.known+=f.memory,++i.knownNodes,d(f),this._shouldLoadNode(f)||(i.unremoved+=f.memory),this._needsUpdate(f)){let e=this._getNodeLoadPriority(s);h.set(s,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(s)}return}if(f.memory&&(i.known+=f.memory,++i.knownNodes),!this._shouldLoadNode(f)){this._isReloading(s)&&this._updates.remove.push(s);return}if(d(f),f.memory?(i.missing+=f.memory,i.known+=f.memory,++i.knownNodes):++i.missingNodes,e.includes(f.index)){this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._getNodeLoadPriority(s)),this._updates.cancel=this._updates.cancel.filter(e=>e!==f.index);return}if(!t.done&&this._enable(f)){t.madeProgress();return}let g=this._getNodeLoadPriority(s);h.set(s,g),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,g),this._updates.add.push(s),this.layerHasModifications&&n&&f!=null&&f.imModificationImpact===4&&o.push(s)},s),this._frameNumber++,this._prioritizeMissingNodesAndPages(),this._removeUnusedNodePages(s,c),this._handleModifications(n,o),this._updateUnloadedMemoryEstimate(i),this._featureEstimate.estimate=this._computeFeatureEstimate(a),this._featureEstimate.leavesReached=r,this._updates.add.filterInPlace(e=>h.get(e)>=this._maxUnloadedPrio).sort((e,t)=>h.get(e)-h.get(t)),this._updates.update.sort((e,t)=>h.get(e)-h.get(t)),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.size,this._dirty=this._indexMissing>0,h.clear()}_updateUnloadedMemoryEstimate(e){this._unloadedMemoryEstimate=e.missing-e.unremoved,e.knownNodes>3&&e.missingNodes>0&&(this._unloadedMemoryEstimate+=e.known/e.knownNodes*e.missingNodes),this._unloadedMemoryEstimate=Math.max(0,this._unloadedMemoryEstimate)*.8}resetUpdateState(e){this._maxUnloadedPrio=-1/0,this._maxProcessingPrio=-1/0,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),h.clear()}_prioritizeMissingNodesAndPages(){let e=this._prioritizedMissingNodeAndPageIds;e.length=0,this._missingPagesAndNodes.forEach(t=>e.push(t)),e.sort((e,t)=>h.get(e)-h.get(t)),e.length>0&&(this._maxUnloadedPrio=h.get(e[e.length-1]),this._prefetchNodes.clear())}_handleModifications(e,t){this.layerHasModifications&&this._updates.add.length!==0&&(t.length>0&&e?.(t),this._updates.add.filterInPlace(e=>{let t=this._getNodeDescriptor(e),n=t?.node==null||t.node.imModificationImpact!==2;return n||this.invalidateNodeVisibilityCache(e),n}))}checkFeatureTarget(e,t){let n=this._viewportQueries.updateScreenSpaceErrorBias(t),r=t,i=t,a=n,o=10;for(;o--;){let n=new O;if(this._updateFeatureEstimate(r,n),this._computeFeatureEstimate(n)<=e){if(r>=t||n.missingNodes>0||o===0)break;a=r,r=(r+i)*.5}else i=r,r=(r+a)*.5}return this._version=v(this._version),this._viewportQueries.updateScreenSpaceErrorBias(n),Math.min(t,r)}_removeUnusedNodePages(e,t){if(!this._useNodePages)return;let n=e.size,r=this._nodePages,i=r.size+this._loadingPages.size+t;if(i>P&&i>n){let t=[];for(let[n,i]of r)i.numNodesWithLoadedChildren===0&&!e.has(n)&&t.push([i.lastTraversed,n]);t.sort((e,t)=>e[0]-t[0]).some(e=>{let t=e[1];return this._deleteNodePage(t),r.size<=P})}}_updateFeatureEstimate(e,t){this._version=v(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible((e,n)=>this._updateNodeFeatureEstimate(n?.node,t))}_updateNodeFeatureEstimate(e,t){e!=null&&!e.failed&&this._shouldLoadNode(e)&&(e.numFeatures==null?++t.missingNodes:(t.numFeatures+=e.numFeatures,++t.knownNodes))}_computeFeatureEstimate(e){let t=e.numFeatures;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.numFeatures/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._prioritizedMissingNodeAndPageIds,this._missingPagesAndNodes)}prefetch(){let e=this._prioritizedPrefetchNodes;return this._prefetchNodes.forEach(t=>e.push(t)),e.sort((e,t)=>h.get(e)-h.get(t)),this._load(e,this._prefetchNodes)}_load(e,t){if(e.length===0||!this._canRequest(this.urlPrefix))return!1;for(;e.length>0&&this._canRequest(this.urlPrefix);){let n=e[e.length-1];e.length--,t.delete(n),this._useNodePages&&n>=0?this._loadPage(n):this._loadNode(n)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetchNodes.size>0}get indexLoading(){return this._loadingPages.size+this._loadingNodes.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(e==null)return null;let t=e.index,n=this._getNodeDescriptor(t);if(!n)return null;let r=n?.traversalState;if(r&&b(r.version,this._version))return r;let i=this._viewportQueries.getLodLevel(e),a=this._viewportQueries.hasLOD(e),o=!0;if(a){let e=this._getParentIndex(t);if(e!=null){let t=this._getNodeDescriptor(e)?.traversalState;o=!!t&&i>t.lodLevel}else o=i>0}else o=e.childCount===0;return r?(r.lodLevel=i,r.isChosen=o,r.version=y(!0,this._version),r):(r=new l(a,o,i,y(!0,this._version)),n.traversalState=r,r)}_loadNode(e){if(this._loadingNodes.has(e)){this._logger.error(`Node[${e}] already loading`);return}this._loadingNodes.add(e);let t=this._getNodeDescriptor(e);if(t.node){this._logger.error(`Node[${e}] already in descriptor`);return}let r=t.nodeBoundingData;if(r==null){this._failedNodes.add(e);return}let i=r.id,a=this.urlPrefix+i,o=()=>{this._loadingNodes.delete(e),this._missingPagesAndNodes.size===0&&this._loadingNodes.size===0&&this.requestUpdate()};(e>=0?this._requester.request(a,`json`):this._clientNodeLoader.loadNodeJSON(i)).then(t=>{o();let n=this._validateNode(i,t);if(n==null)return;n.obb&&this.invalidateNodeVisibilityCache(e);let r=this._addNode(n,e);this.nodeTraversalState(r)}).catch(t=>{o(),n(t)||(this._logger.error(`#loadNode()`,this._layer,`Error loading node: `+a),this._failedNodes.add(e))})}_validateNode(e,t){if(typeof t!=`object`||!t||t.id!==e)return this._logger.error(`#validateNode()`,this._layer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error(`#validateNode()`,this._layer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&t.sharedResource.href!==`./shared`&&t.sharedResource.href!==`./shared/`&&this._logger.warn(`#validateNode()`,this._layer,`Invalid shared resource href on node "${e}"`);let n=t.geometryData;n!=null&&!(Array.isArray(n)&&n.length===0)&&!(Array.isArray(n)&&n.length===1&&n[0].href===`./geometries/0`)&&this._logger.warn(`#validateNode()`,this._layer,`Invalid geometry data on node "${e}"`);let r=t.attributeData,a=this._layer.attributeStorageInfo;r!=null&&(!Array.isArray(r)||r.some((e,t)=>e.href!==`./attributes/${a?.[t]?.key??`f_${t}`}/0`))&&this._logger.warn(`#validateNode()`,this._layer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn(`#validateNode()`,this._layer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);let c=t.hasOwnProperty(`obb`)&&!this.ignoreServiceObb?t.obb:void 0,l=t.featureData?.length===1&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,u=Array.isArray(t.children)?t.children.map(t=>{if(t==null)return null;let n=t=>this._logger.error(`#validateNode()`,this._layer,`Invalid node reference on node ${e}: ${t}`);if(typeof t.id==`number`)n(`id ${t.id} is a number instead of a string.`);else if(typeof t.id!=`string`||!Array.isArray(t.mbs))return n(`Missing or invalid id.`),null;if(!Array.isArray(t.mbs))return n(`Invalid bounding volume on reference ${t.id}.`),null;let r=new s(`${t.id}`,new i(t.mbs));return r.serviceObbInIndexSR=!this.ignoreServiceObb&&t.hasOwnProperty(`obb`)&&t.obb?o.fromJSON(t.obb):null,r.visibilityObbInRenderSR=this._computeVisibilityObb(r),r}).filter(e=>e!=null):null,f=t.featureData?.length??!1,p=t.isEmpty===!0;return new d(e,new i(t.mbs),c,typeof t.version==`string`?t.version:null,{isEmpty:!f&&p,hasSharedResource:t.sharedResource!=null,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:t.geometryData==null?void 0:e},u,Array.isArray(t.lodSelection)?t.lodSelection:null,l)}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes(e=>{e.node!=null&&(e.node.failed=!1)})}_getNodeLoadPriority(e){let t=this._getNodeDescriptor(e),n=this._getParentIndex(e);if(t==null||n==null&&t.node==null)return n==null?1/0:this._getNodeLoadPriority(n);let r=0;t.node&&n!=null&&(r=this._getNodeDescriptor(n).traversalState?.lodLevel??0);let i=this._getHoleBonus(e);return-(this._viewportQueries.distToCameraPOIRay(t.nodeBoundingData??t.node)*(1+r)+r*this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI())+i}_getHoleBonus(e){return this._hasLoadedAncestor(e)?0:this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI()}_hasLoadedAncestor(e){let t=this._getParentIndex(e);for(;t!=null;){if(this._isLoaded(t))return!0;t=this._getParentIndex(t)}return!1}traverseVisible(e,t){let n=this._getNodeDescriptor(this._rootIndex);n==null?e(this._rootIndex,null,null):this._traverseVisible(this._rootIndex,null,n,e,t)}_traverseVisible(e,t,n,r,i){let a=S(e,this._pageSize);if(i&&i.add(a),n.node&&n.childCount===0){this.isGeometryVisible(e)&&r(e,n,t);return}if(!this.isNodeVisible(e)||(r(e,n,t),n.node==null))return;let o=this.nodeTraversalState(n.node);if(o?.nodeHasLOD&&o.lodLevel===this._maxLodLevel)return;let s=this._getPageFromPageIndex(a);for(let t=0;t<n.childCount;t++){let a=s.children[n.childOffset+t],o=this._getNodeDescriptor(a);if(o)this._traverseVisible(a,e,o,r,i);else{if(i){let e=S(a,this._pageSize);i.add(e)}r(a,null,e)}}}traverse(e,t){for(let n of this.traverseValues(e,t));}*traverseValues(e,t){t(e)&&(yield e,yield*this._traverseDescendantValues(e,t))}*_traverseDescendantValues(e,t){let n=e.index,r=this._pageSize,i=S(n,r),a=this._getPageFromPageIndex(i);if(a==null)return;let o=this._frameNumber,s=this._nodePages,c=C(n,r),l=a.nodes[c],u=l.childCount;if(a.lastTraversed=o,u===0)return;let d=[],f=[],p=0;{let{childOffset:e,childCount:t}=l,{children:n}=a;f.length=2**Math.ceil(Math.log2(p+t));for(let r=e;r<e+t;++r){let e=n[r];e>=0?(f[p]=e,++p):d.push(e)}}if(d.length>0){let e=this._clientNodePage;if(e){let n=e.children,r=0;for(;r<d.length;){let i=d[r];++r;let a=-i-1,o=e.nodes[a],s=o.node;if(!s||!t(s))continue;yield s;let{childCount:c}=o;if(c===0)continue;let{childOffset:l}=o,u=l+c;for(let e=l;e<u;++e)d.push(n[e])}}}if(p>0){let e=0;if(r>0){let n=i*r,c=a,l=c.nodes;for(;e<p;){let i=f[e];++e;let a;if(n<=i&&i<n+r)a=c;else{let e=i/r|0,t=s.get(e);if(t===void 0)continue;a=t,a.lastTraversed=o,c=a,l=c.nodes,n=r*e}let u=i-n,d=l[u],m=d?.node;if(m==null||t(m)===!1||(yield m,d.node==null))continue;let{childCount:h}=d;if(h===0)continue;let g=p+h;for(f.length<g&&(f.length=2**Math.ceil(Math.log2(p+h)));f.length<p+h;)f.length+=f.length;let _=a.children,{childOffset:v}=d,y=v+h;for(let e=v;e<y;++e)f[p]=_[e],++p}}else{let n=s.get(0);if(n)for(;e<p;){let r=f[e++],i=n.nodes[r],a=i.node;if(!a||!t(a))continue;yield a;let{childCount:o}=i;if(o===0)continue;f.length=Math.max(f.length,2**Math.ceil(Math.log2(p+o)));let s=n.children,{childOffset:c}=i,l=c+o;for(let e=c;e<l;++e)f[p]=s[e],++p}}}}traverseDescendants(e,t){for(let n of this._traverseDescendantValues(e,t));}updateChildrenLoaded(e,t){let n=this.getNode(e);for(;n!=null;){let e=n.childrenLoaded,r=e+t;n.childrenLoaded=r;let i=e===0?1:r===0?-1:0,a=n.index;if(i!==0){let e=this._getPage(a);e.numNodesWithLoadedChildren+=i}n=this.getParent(a)}}checkChildrenLoadedInvariant(){return!0}updateElevationInfo(e,t){this._needsNodeElevationRange=t&&!!e&&(e.mode===`relative-to-ground`||e.mode===`relative-to-scene`||e.mode===`on-the-ground`),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes(e=>{e?.invalidateBounds(),e.node?.invalidateElevationRange(),e.nodeBoundingData?.invalidateElevationRange()})}_forAllNodes(e){if(this._clientNodePage!=null){let t=this._clientNodePage;for(let n=0;n<t.nodes.length;n++)e(t.nodes[n],-(n+1))}for(let[t,n]of this._nodePages){let r=t*this._pageSize;for(let t=0;t<n.nodes.length;t++)e(n.nodes[t],r+t)}}clearCaches(){if(this._useNodePages){let e=this._nodePages,t=new Set;this.traverseVisible(e=>t.add(S(e,this._pageSize)));for(let[n,r]of e)if(r.numNodesWithLoadedChildren===0&&!t.has(n))this._deleteNodePage(n);else for(let e of r.nodes)e.traversalState=null}}_deleteNodePage(e){if(!this._nodePages.has(e)){this._logger.error(`Destroying non-existent page ${e}`);return}let t=this._nodePages.get(e);this._nodePages.delete(e),t?.destroy()}get test(){}}const h=new Map;class g{constructor(e){this.missing=e,this.update=new t({deallocator:null}),this.add=new t({deallocator:null}),this.remove=new t({deallocator:null}),this.cancel=[]}destroy(){this.update.prune(),this.add.prune(),this.remove.prune(),this.cancel.length=0}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function _(e){return u(e,-2)}function v(e){return u(e,2)}function y(e,t){return t+ +!!e}function b(e,t){return(e&-2)===t}function x(e){return(e&1)==1}function S(e,t){return e<0?-1:t>0?e/t|0:0}function C(e,t){return e<0?-e-1:t===0?e:e%t}function w(e,t,n){return t===-1?-(e+1):n===0?e:t*n+e}const T=[[`maxScreenThreshold`,1],[`screenSpaceRelative`,2],[`removedFeatureDiameter`,3],[`distanceRangeFromDefaultCamera`,4]];function E(e){if(e){for(let t=0;t<e.length;t++)for(let n of T)if(n[0]===e[t].metricType)return{lodMetric:n[1],maxError:e[t].maxError}}return{lodMetric:0,maxError:0}}class D{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}class O{constructor(){this.numFeatures=0,this.knownNodes=0,this.missingNodes=0}}function k(e){return Math.sqrt(4/Math.PI*e)}const A=new i,j=new i,M=new i,N=e(),P=has(`esri-mobile`)?100:300;export{m as I3SIndex,E as selectErrorMetric};
2
+ import has from"../../../../core/has.js";import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import t from"../../../../core/PooledArray.js";import{isAbortError as n}from"../../../../core/promiseUtils.js";import{projectBoundingSphere as r}from"../../../../geometry/projection/projectBoundingSphere.js";import{Sphere as i}from"../../../../geometry/support/sphere.js";import{ElevationRange as a}from"../../support/ElevationRange.js";import{Obb as o}from"../../support/orientedBoundingBox.js";import{NodeBoundingData as s,Node as c,NodeTraversalState as l}from"./I3SNode.js";import{addWraparound as u}from"./I3SUtil.js";import{ValidatedNode as d}from"./ValidatedNode.js";class f{constructor(e,t,n,r,i){this.childOffset=e,this.childCount=t,this.visibilityCache=n,this._boundingData=r,this.node=i,this.parentIndex=-1,this.useAsHole=0,this.filterImpact=2,this.traversalState=null}get nodeBoundingData(){return this._boundingData}destroy(){this._boundingData=null,this.node=null,this.traversalState=null}invalidateBounds(){this.node?.invalidateServiceBVsInRenderSR(),this.nodeBoundingData?.invalidateServiceBVsInRenderSR()}}class p{constructor(e=[],t=[]){this._nodeDescriptors=e,this._children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}destroy(){for(let e of this._nodeDescriptors)e.destroy();this._nodeDescriptors.length=0,this._children.length=0}get nodes(){return this._nodeDescriptors}addNode(e){return this._nodeDescriptors.push(e),this._nodeDescriptors.length-1}setNodes(e,t){this._nodeDescriptors=e,this._children=t}get children(){return this._children}}class m{get _useNodePages(){return this._pageSize>0}constructor(e,n,r,i,a,o,c,l,u,d,f,m,h,_,y,b){if(this._layer=e,this._groundNavigationCheckDistance=r,this._requester=a,this._clientNodeLoader=o,this._viewportQueries=c,this._logger=l,this.holeFilling=u,this._isLoaded=d,this._isReloading=f,this._shouldLoadNode=m,this._enable=h,this._needsUpdate=_,this._computeVisibilityObb=y,this._computeNodeFiltering=b,this._dirty=!0,this._nodePages=new Map,this._clientNodePage=null,this._pageSize=0,this._rootIndex=0,this._lodMetric=0,this._lodConversion=e=>e,this._isEditable=!1,this.urlPrefix=``,this._loadingNodes=new Set,this._loadingPages=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=-1/0,this._maxProcessingPrio=1/0,this._version=v(0),this._visibilityCacheVersion=v(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._progressiveLoadPenaltyWeight=10,this._missingPagesAndNodes=new Set,this._prioritizedMissingNodeAndPageIds=[],this._prefetchNodes=new Set,this._prioritizedPrefetchNodes=[],this._updates=new g(this._missingPagesAndNodes),this._imModificationUncategorized=new t({deallocator:null}),this.ignoreServiceObb=!1,this.isGroundNavigationMode=!1,this._pageQueue=[],this._newPages=[],this._needsNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._isEditable=e.associatedLayer?.infoFor3D!=null,this.isGroundNavigationMode=n,e.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${e.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,i.type===`page`){let e=i.rootPage;switch(this.urlPrefix=i.urlPrefix,this._pageSize=i.pageSize,i.lodMetric){case`maxScreenThreshold`:this._lodMetric=1;break;case`maxScreenThresholdSQ`:this._lodMetric=1,this._lodConversion=k}if(this._isEditable){this._rootIndex=-1;let t=C(i.rootIndex,i.pageSize),n=e.nodes[t],r={nodes:[{index:this._rootIndex,children:[i.rootIndex],mesh:void 0,obb:n.obb,lodThreshold:n.lodThreshold}]};this._addPage(S(this._rootIndex,this._pageSize),r),this.getNode(-1).serviceObbInIndexSR=void 0}else this._rootIndex=i.rootIndex;this._addPage(S(i.rootIndex,this._pageSize),e),this._updateParentsAndLevel()}else if(i.type===`node`){this.urlPrefix=i.urlPrefix;let e=new p;if(this._nodePages.set(0,e),this._isEditable){this._clientNodePage=new p;let e={id:`-1`,version:null,mbs:i.rootNode.mbs,obb:i.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:`root`,href:`../root`,mbs:i.rootNode.mbs,obb:i.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new s(e.id),-1);let t=this._validateNode(e.id,e);t&&this._addNode(t,this._rootIndex)}else this._rootIndex=this._makeRefNode(new s(i.rootNode.id),-1);let t=this._validateNode(i.rootNode.id,i.rootNode);t&&this._addNode(t,0)}}addClientNodeToIndex(e,t){let n=new s(e,t),r=this._makeClientRefNode(n,-1);return this._linkChildToParentNode(-1,r),this.requestUpdate(),r}removeClientNodeFromIndex(e,t,n){this._destroyClientRefNode(e,t,n),this.requestUpdate()}_canRequest(e){return!this._requester.isFull(e)}_loadPage(e){if(this._nodePages.has(e)){this._logger.error(`Requested load page [${e}] already loaded`);return}if(this._loadingPages.has(e)){this._logger.error(`Requested load page [${e}] already loading`);return}this._loadingPages.add(e);let t=this.urlPrefix+e;this._requester.request(t,`json`).then(t=>{this._nodePages.has(e)?this._logger.error(`Queued page [${e}] already loaded`):this._pageQueue.push({pageIndex:e,page:t})}).catch(t=>{this._loadingPages.delete(e),n(t)||(this._failedPages.add(e),this._logger.error(`#loadPage()`,this._layer,`Error when loading page ${e}`,t))})}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){let{pageIndex:t,page:n}=this._pageQueue.shift();this._addPage(t,n),this._loadingPages.delete(t),e.madeProgress(),this._needsNodeElevationRange&&this._newPages.push(t)}this._updateParentsAndLevel()}_invalidateElevationRangeForNewPages(e){if(this._needsNodeElevationRange)for(;this._newPages.length>0&&!e.done;)this._nodePages.get(this._newPages.shift())?.nodes.forEach(e=>{let t=e.parentIndex;for(;t!=null&&t!==this._rootIndex;){let e=this.getNode(t);e?.elevationRangeValid&&(e.invalidateElevationRange(),this.invalidateBoundingVolumeCache(t)),t=this._getParentIndex(t)}})}_addPage(e,t){if(this._nodePages.has(e)){this._logger.error(`Page[${e}] reloaded`);return}let n=[],r=[],a=t.nodes.map((t,a)=>{let s=n.length,l=t.children?t.children.length:0;r.push(this._rootIndex);for(let e=0;e<l;e++)n.push(t.children[e]);let u=`${t.index}`,d=o.fromJSON(t.obb),p=new i(d.getCenter(N),d.radius),m=t.mesh?.attribute,h=t.mesh?.geometry,g=t.mesh?.material,v={hasSharedResource:!1,isEmpty:h==null,attributes:m?.resource==null?void 0:`${m.resource}`,geometry:h?.resource==null?void 0:`${h.resource}`,texture:g?.resource==null?void 0:`${g.resource}`,geometryDefinition:h?h.definition:-1,materialDefinition:g?g.definition:-1},y=new c(u,w(a,e,this._pageSize),p,l,0,v,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),h?.featureCount??null,d);return y.visibilityObbInRenderSR=this._computeVisibilityObb(y),y.vertexCount=h?h.vertexCount:0,new f(s,l,_(this._visibilityCacheVersion),null,y)}),s=new p(a,n);e===-1?this._clientNodePage=s:this._nodePages.set(e,s)}_updateParentsAndLevel(){let e=[],t=(t,n,r)=>{let i=this._getPage(t);if(i!=null){let a=C(t,this._pageSize),o=i.nodes[a];o.parentIndex=n??-1;let s=o.node;s!=null&&(s.level=r,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){let n=e.pop(),r=this.getNode(n);if(r!=null)for(let e=0;e<r.childCount;e++)t(this.getChildIndex(r.index,e),n,r.level+1),this._maxLevel=Math.max(this._maxLevel,r.level+1)}}_getPage(e){let t=S(e,this._pageSize);return this._getPageFromPageIndex(t)}_getPageFromPageIndex(e){return e<0?this._clientNodePage:this._nodePages.get(e)}_getNodeDescriptor(e){let t=this._getPage(e);return t==null?null:(t.lastTraversed=this._frameNumber,t.nodes[C(e,this._pageSize)])}_addNode(e,t){e.children&&this.populateChildren(t,e.children);let n=this.getParent(t),r=n==null?0:n.level+1;this._maxLevel=Math.max(this._maxLevel,e.children?r+1:r);let{lodMetric:i,maxError:a}=E(e.lodSelection),s=this._getNodeDescriptor(t);if(s.node!=null)return this._logger.error(`Loaded node[${t}] already in descriptor`),s.node;let l=new c(e.id,t,e.mbs,s.childCount,r,e.resources,e.version,i,a,e.numFeatures,e.obb?o.fromJSON(e.obb):null);s.node=l,l.visibilityObbInRenderSR=this._computeVisibilityObb(l);let u=s.nodeBoundingData;return u!=null&&(u.serviceMbsInIndexSR??=e.mbs,l.shareServiceBVsInRenderSRWith(u),u.visibilityObbInRenderSR=l.visibilityObbInRenderSR),l}_makeRefNode(e,t){let n=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(n==null)return-1;let r=n.nodes.length,i=new f(0,0,_(this._visibilityCacheVersion),e,null);return n.addNode(i),i.parentIndex=t,e.invalidateServiceBVsInRenderSR(),r}_makeClientRefNode(e,t){let n=this._clientNodePage;if(n==null)return-1;if(t>=0)throw Error(`I3SIndex::client side nodes can not be made children of service side nodes.`);let r=-(n.nodes.length+1),i=new f(0,0,_(this._visibilityCacheVersion),e,null);return n.addNode(i),i.parentIndex=t,e.invalidateServiceBVsInRenderSR(),r}_linkChildToParentNode(e,t){let n=this._clientNodePage;if(n==null||e>=0)return;let r=C(e,this._pageSize),i=C(t,this._pageSize),a=n.nodes[r],o=a.childOffset;n.children.splice(a.childOffset+a.childCount,0,t),a.childCount+=1,a.node!=null&&(a.node.childCount+=1);for(let e of n.nodes)e.childOffset>o&&(e.childOffset+=1);let s=n.nodes[i];s.parentIndex=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,n){let r=this._clientNodePage;if(r==null)return;let i=this._getParentIndex(e);if(i==null)return;let a=new Set,o=new Map,s=e=>{let n=C(e,this._pageSize),i=r.nodes[n];if(i.childCount>0)for(let e=i.childOffset;e<i.childOffset+i.childCount;++e)s(r.children[e]);let o=i.node?.id??i.nodeBoundingData?.id;if(o==null)throw Error(`Node has no id`);t(o,e),a.add(i)};s(e);let c=r.nodes,l=r.children,u=r.nodes.map(()=>-1),d=[],f=[];for(let e=0;e<c.length;++e){let t=c[e];if(a.has(t))continue;let r=d.length,i=w(e,-1,this._pageSize),s=w(r,-1,this._pageSize);if(t.node&&(t.node.index=s),u[e]=s,d.push(t),i!==s){let e=t.node?.id??t.nodeBoundingData?.id;if(e==null)throw Error(`Node has no id`);n(e,i,s),o.set(i,s)}}for(let e=0;e<d.length;++e){let t=w(e,-1,this._pageSize),n=d[e],r=f.length;for(let e=n.childOffset;e<n.childOffset+n.childCount;++e){let n=l[e];if(n>=0)f.push(n);else{let e=C(n,this._pageSize),r=c[e];if(a.has(r))continue;let i=u[e];f.push(i),r.parentIndex=t}}n.childOffset=r,n.childCount=f.length-r,n.node&&(n.node.childCount=n.childCount)}r.setNodes(d,f),this._updateParentBoundingInformation(u[C(i,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null,n=this._clientNodeLoader.indexSR,a=this._clientNodeLoader.renderSR,o=this._getNodeDescriptor(t);if(o==null)return;for(let i=0;i<o.childCount;i++){let o=this.getChildIndex(t,i),s=this._getNodeDescriptor(o),c=s==null?null:s.nodeBoundingData||s.node;if(c?.serviceMbsInIndexSR!=null&&c.serviceMbsInIndexSR.radius>0){if(e==null)e=A.copyFrom(c.serviceMbsInIndexSR);else{let t=j;r(c.serviceMbsInIndexSR,n,t,a);let i=M;r(e,n,i,a),r(t.union(i),a,e,n)}}}let s=t=>{t!=null&&(t.serviceObbInIndexSR=null,e==null?t.serviceMbsInIndexSR?.invalidate():(t.serviceMbsInIndexSR??=new i,t.serviceMbsInIndexSR.copyFrom(e)),t.invalidateServiceBVsInRenderSR(),t.geometryObbInRenderSR=null)};s(o.nodeBoundingData),s(o.node),this.invalidateNodeVisibilityCacheInternal(o),t=this._getParentIndex(t)}while(t!=null)}populateChildren(e,t){let n=this._getNodeDescriptor(e),r=this._getPage(e);n.childOffset=r.children.length,n.childCount=t.length;for(let n=0;n<t.length;n++){let i=this._makeRefNode(t[n],e);r.children.push(i)}}getNode(e){let t=this._getNodeDescriptor(e);return t==null?null:t.node}getIndexById(e){let t;return this._forAllNodes((n,r)=>{(n.node!=null&&n.node.id===e||n.nodeBoundingData!=null&&n.nodeBoundingData.id===e)&&(t=r)}),t}getNodeById(e){let t=this.getIndexById(e);return t!=null&&t>=0?this.getNode(t):null}getChildIndex(e,t){let n=this._getPage(e);if(n==null)return-1;let r=n.nodes[C(e,this._pageSize)];return n.children[r.childOffset+t]}_getParentIndex(e){let t=this._getPage(e);return t!=null&&e!==this._rootIndex?t.nodes[C(e,this._pageSize)]?.parentIndex:null}getParent(e){let t=this._getParentIndex(e);return t==null?null:this.getNode(t)}isLeaf(e){let t=this._getNodeDescriptor(e);return t!=null&&t.childCount===0}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes(e=>{e.node!=null&&(e.node.geometryObbInRenderSR=null)})}invalidateVisibilityCache(){this._visibilityCacheVersion=v(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){let t=this._getNodeDescriptor(e);t!=null&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=_(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){let t=this._getNodeDescriptor(e);t!=null&&(t?.invalidateBounds(),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){let t=this._getNodeDescriptor(e);t!=null&&(this._needsNodeElevationRange?(t.node==null?t.nodeBoundingData:t.node)?.invalidateElevationRange():this.invalidateBoundingVolumeCache(e))}invalidateGeometryVisibility(e){let t=this._getNodeDescriptor(e)?.node;t&&(t.geometryObbInRenderSR=null,t.invalidateServiceBVsInRenderSR())}invalidateVisibilityObbs(){this.rootNode!=null&&this.traverse(this.rootNode,e=>(e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.geometryObbInRenderSR=null,!0))}_isElevationRangeValid(e){if(!this._needsNodeElevationRange)return!0;let t=e?.node??e?.nodeBoundingData;return!t||t.elevationRangeValid}_updateElevationRange(e,t){let n=this._getNodeDescriptor(e);if(!n)return!1;let r=n?.node??n?.nodeBoundingData;if(!r)return!1;if(r.elevationRangeValid)return t?.expandElevationRange(r),!0;let i=new a,o=!1;for(let t=0;t<n.childCount;t++){let n=this.getChildIndex(e,t),r=this._updateElevationRange(n,i);o||=!r}if(n.childCount===0||o){let e=!n.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(r,e,i)}(i.minElevation===1/0||i.maxElevation===-1/0)&&i.expandElevationRangeValues(0,0);let{minElevation:s,maxElevation:c}=r;return s===i.minElevation&&c===i.maxElevation?(t?.expandElevationRange(r),!0):(n.node?.setElevationRange(i),n.nodeBoundingData?.setElevationRange(i),this.invalidateBoundingVolumeCache(e),t?.expandElevationRange(r),!0)}isNodeVisible(e){let t=this._getNodeDescriptor(e);if(t==null)return!0;let n=t.nodeBoundingData;if(n!=null&&!n.serviceMbsInIndexSR)return!0;if(this._isElevationRangeValid(t)&&b(t.visibilityCache,this._visibilityCacheVersion))return x(t.visibilityCache);let r=t.node,i=this._viewportQueries;if(r){let e=i.ensureElevationAgnosticBoundingVolume(r),n=i.isElevationAgnosticBoundingVolumeVisible(e,this.isGroundNavigationMode?this._groundNavigationCheckDistance:0),a=n;if(this._needsNodeElevationRange&&n){let t=i.getNodeObbInRenderSRIndependentOfElevationOffset(r);t!=null&&(a=i.isObbVisibleIndependentOfElevation(e,t))}if(!a)return t.visibilityCache=y(!1,this._visibilityCacheVersion),!1}if(this._layerHasFilter&&this._computeNodeFiltering&&(r!=null||n!=null)&&t.filterImpact===2){let e=r==null?n==null?null:n.serviceMbsInIndexSR:r.serviceMbsInIndexSR;t.filterImpact=e==null?0:this._computeNodeFiltering(e)}let a=r!=null&&t.filterImpact===1,o=(r==null||r.imModificationImpact!==2)&&!a;if(o){let t=r&&(!n||r.visibilityObbInRenderSR)?r:n??null;t!=null&&(this._needsNodeElevationRange&&this._updateElevationRange(e),o=i.isNodeVisible(t,this.isGroundNavigationMode))}return t.visibilityCache=y(o,this._visibilityCacheVersion),o}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;let t=this._getNodeDescriptor(e);return t?.node?.geometryObbInRenderSR!=null&&(!this.layerHasModifications||t.node.imModificationImpact!==4)?this._viewportQueries.isGeometryVisible(t.node,this.isGroundNavigationMode):!0}_traverseCoverage(e,t,n,r,i){let a=this._getPage(e);if(a==null||t.childCount===0)return;let o=t.childOffset+t.childCount,s=[];for(let e=t.childOffset;e<o;++e){let t=a.children[e],n=this._getNodeDescriptor(t);n?.node!=null&&this.isGeometryVisible(t)&&s.push(n)}r/=s.length;for(let e of s){let t=e.node.index;this._isLoaded(t)||this._isReloading(t)?(i.delta=Math.max(i.delta,n),i.coverage+=r):this._traverseCoverage(t,e,n+1,r,i)}}useNodeAsHole(e){if(this.holeFilling===`off`)return!1;let t=this._getNodeDescriptor(e);if(t==null)return!1;if(this.holeFilling===`always`)return!0;if(b(t.useAsHole,this._version))return x(t.useAsHole);let n={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,n);let r=n.delta*n.coverage<=.5;return t.useAsHole=y(r,this._version),r}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.destroy(),this._nodePages.clear(),this._clientNodePage=null,this._layer=null,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._imModificationUncategorized.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=v(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes(({node:e})=>{e!=null&&(e.imModificationImpact=4,e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))}),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes(e=>{if(e!=null){e.filterImpact=2;let t=e.node;t!=null&&this.invalidateNodeVisibilityCache(t.index)}}),this.invalidateVisibilityCache()}update(e,t,n){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._invalidateElevationRangeForNewPages(t),this.resetUpdateState(e);let r=new Set(e),i=new Set,a=!0,o=new D,s=new O,c=this._imModificationUncategorized;c.clear();let l=new Set,u=0;this.traverseVisible((e,l,d)=>{let f=e=>{this._shouldLoadNode(e)&&e.childCount&&(a=!1)};if(!l){let t=S(e,this._pageSize),n=this._getNodeLoadPriority(e);n===1/0&&(n=this._getNodeLoadPriority(d)),h.set(t,Math.max(n,h.get(t)||0)),!this._loadingPages.has(t)&&!this._failedPages.has(t)&&(this._missingPagesAndNodes.add(t),++u),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,n);return}let{node:p,childCount:m}=l;if(this._updateNodeFeatureEstimate(p,s),!p){let t=this._getNodeLoadPriority(e);!this._loadingNodes.has(e)&&!this._failedNodes.has(e)&&(this._missingPagesAndNodes.add(e),h.set(e,t)),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,t);return}let g=this._getPage(e);if(!this._useNodePages&&this._missingPagesAndNodes.size===0)for(let e=0;e<m;e++){let t=g.children[l.childOffset+e],n=this._getNodeDescriptor(t);n!=null&&!n.node&&!this._loadingNodes.has(t)&&!this._failedNodes.has(t)&&t>=0&&(h.set(t,this._getNodeLoadPriority(t)),this._prefetchNodes.add(t))}if(p.failed||p.resources.isEmpty){f(p);return}if(this._isLoaded(e)){if(o.known+=p.memory,++o.knownNodes,f(p),this._shouldLoadNode(p)||(o.unremoved+=p.memory),this._needsUpdate(p)){let t=this._getNodeLoadPriority(e);h.set(e,t),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,t),this._updates.update.push(e)}return}if(p.memory&&(o.known+=p.memory,++o.knownNodes),!this._shouldLoadNode(p)){this._isReloading(e)&&this._updates.remove.push(e);return}if(f(p),p.memory?(o.missing+=p.memory,o.known+=p.memory,++o.knownNodes):++o.missingNodes,r.has(p.index)){this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._getNodeLoadPriority(e)),i.add(p.index);return}if(!t.done&&this._enable(p)){t.madeProgress();return}let _=this._getNodeLoadPriority(e);h.set(e,_),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,_),this._updates.add.push(e),this.layerHasModifications&&n&&p!=null&&p.imModificationImpact===4&&c.push(e)},l),i.size>0&&(this._updates.cancel=this._updates.cancel.filter(e=>!i.has(e))),this._frameNumber++,this._prioritizeMissingNodesAndPages(),this._removeUnusedNodePages(l,u),this._handleModifications(n,c),this._updateUnloadedMemoryEstimate(o),this._featureEstimate.estimate=this._computeFeatureEstimate(s),this._featureEstimate.leavesReached=a,this._updates.add.filterInPlace(e=>h.get(e)>=this._maxUnloadedPrio).sort((e,t)=>h.get(e)-h.get(t)),this._updates.update.sort((e,t)=>h.get(e)-h.get(t)),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.size,this._dirty=this._indexMissing>0,h.clear()}_updateUnloadedMemoryEstimate(e){this._unloadedMemoryEstimate=e.missing-e.unremoved,e.knownNodes>3&&e.missingNodes>0&&(this._unloadedMemoryEstimate+=e.known/e.knownNodes*e.missingNodes),this._unloadedMemoryEstimate=Math.max(0,this._unloadedMemoryEstimate)*.8}resetUpdateState(e){this._maxUnloadedPrio=-1/0,this._maxProcessingPrio=-1/0,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),h.clear()}_prioritizeMissingNodesAndPages(){let e=this._prioritizedMissingNodeAndPageIds;e.length=0,this._missingPagesAndNodes.forEach(t=>e.push(t)),e.sort((e,t)=>h.get(e)-h.get(t)),e.length>0&&(this._maxUnloadedPrio=h.get(e[e.length-1]),this._prefetchNodes.clear())}_handleModifications(e,t){this.layerHasModifications&&this._updates.add.length!==0&&(t.length>0&&e?.(t),this._updates.add.filterInPlace(e=>{let t=this._getNodeDescriptor(e),n=t?.node==null||t.node.imModificationImpact!==2;return n||this.invalidateNodeVisibilityCache(e),n}))}checkFeatureTarget(e,t){let n=this._viewportQueries.updateScreenSpaceErrorBias(t),r=t,i=t,a=n,o=10;for(;o--;){let n=new O;if(this._updateFeatureEstimate(r,n),this._computeFeatureEstimate(n)<=e){if(r>=t||n.missingNodes>0||o===0)break;a=r,r=(r+i)*.5}else i=r,r=(r+a)*.5}return this._version=v(this._version),this._viewportQueries.updateScreenSpaceErrorBias(n),Math.min(t,r)}_removeUnusedNodePages(e,t){if(!this._useNodePages)return;let n=e.size,r=this._nodePages,i=r.size+this._loadingPages.size+t;if(i>P&&i>n){let t=[];for(let[n,i]of r)i.numNodesWithLoadedChildren===0&&!e.has(n)&&t.push([i.lastTraversed,n]);t.sort((e,t)=>e[0]-t[0]).some(e=>{let t=e[1];return this._deleteNodePage(t),r.size<=P})}}_updateFeatureEstimate(e,t){this._version=v(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible((e,n)=>this._updateNodeFeatureEstimate(n?.node,t))}_updateNodeFeatureEstimate(e,t){e!=null&&!e.failed&&this._shouldLoadNode(e)&&(e.numFeatures==null?++t.missingNodes:(t.numFeatures+=e.numFeatures,++t.knownNodes))}_computeFeatureEstimate(e){let t=e.numFeatures;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.numFeatures/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._prioritizedMissingNodeAndPageIds,this._missingPagesAndNodes)}prefetch(){let e=this._prioritizedPrefetchNodes;return this._prefetchNodes.forEach(t=>e.push(t)),e.sort((e,t)=>h.get(e)-h.get(t)),this._load(e,this._prefetchNodes)}_load(e,t){if(e.length===0||!this._canRequest(this.urlPrefix))return!1;for(;e.length>0&&this._canRequest(this.urlPrefix);){let n=e[e.length-1];e.length--,t.delete(n),this._useNodePages&&n>=0?this._loadPage(n):this._loadNode(n)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetchNodes.size>0}get indexLoading(){return this._loadingPages.size+this._loadingNodes.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(e==null)return null;let t=e.index,n=this._getNodeDescriptor(t);if(!n)return null;let r=n?.traversalState;if(r&&b(r.version,this._version))return r;let i=this._viewportQueries.getLodLevel(e),a=this._viewportQueries.hasLOD(e),o=!0;if(a){let e=this._getParentIndex(t);if(e!=null){let t=this._getNodeDescriptor(e)?.traversalState;o=!!t&&i>t.lodLevel}else o=i>0}else o=e.childCount===0;return r?(r.lodLevel=i,r.isChosen=o,r.version=y(!0,this._version),r):(r=new l(a,o,i,y(!0,this._version)),n.traversalState=r,r)}_loadNode(e){if(this._loadingNodes.has(e)){this._logger.error(`Node[${e}] already loading`);return}this._loadingNodes.add(e);let t=this._getNodeDescriptor(e);if(t.node){this._logger.error(`Node[${e}] already in descriptor`);return}let r=t.nodeBoundingData;if(r==null){this._failedNodes.add(e);return}let i=r.id,a=this.urlPrefix+i,o=()=>{this._loadingNodes.delete(e),this._missingPagesAndNodes.size===0&&this._loadingNodes.size===0&&this.requestUpdate()};(e>=0?this._requester.request(a,`json`):this._clientNodeLoader.loadNodeJSON(i)).then(t=>{o();let n=this._validateNode(i,t);if(n==null)return;n.obb&&this.invalidateNodeVisibilityCache(e);let r=this._addNode(n,e);this.nodeTraversalState(r)}).catch(t=>{o(),n(t)||(this._logger.error(`#loadNode()`,this._layer,`Error loading node: `+a),this._failedNodes.add(e))})}_validateNode(e,t){if(typeof t!=`object`||!t||t.id!==e)return this._logger.error(`#validateNode()`,this._layer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error(`#validateNode()`,this._layer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&t.sharedResource.href!==`./shared`&&t.sharedResource.href!==`./shared/`&&this._logger.warn(`#validateNode()`,this._layer,`Invalid shared resource href on node "${e}"`);let n=t.geometryData;n!=null&&!(Array.isArray(n)&&n.length===0)&&!(Array.isArray(n)&&n.length===1&&n[0].href===`./geometries/0`)&&this._logger.warn(`#validateNode()`,this._layer,`Invalid geometry data on node "${e}"`);let r=t.attributeData,a=this._layer.attributeStorageInfo;r!=null&&(!Array.isArray(r)||r.some((e,t)=>e.href!==`./attributes/${a?.[t]?.key??`f_${t}`}/0`))&&this._logger.warn(`#validateNode()`,this._layer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn(`#validateNode()`,this._layer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);let c=t.hasOwnProperty(`obb`)&&!this.ignoreServiceObb?t.obb:void 0,l=t.featureData?.length===1&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,u=Array.isArray(t.children)?t.children.map(t=>{if(t==null)return null;let n=t=>this._logger.error(`#validateNode()`,this._layer,`Invalid node reference on node ${e}: ${t}`);if(typeof t.id==`number`)n(`id ${t.id} is a number instead of a string.`);else if(typeof t.id!=`string`||!Array.isArray(t.mbs))return n(`Missing or invalid id.`),null;if(!Array.isArray(t.mbs))return n(`Invalid bounding volume on reference ${t.id}.`),null;let r=new s(`${t.id}`,new i(t.mbs));return r.serviceObbInIndexSR=!this.ignoreServiceObb&&t.hasOwnProperty(`obb`)&&t.obb?o.fromJSON(t.obb):null,r.visibilityObbInRenderSR=this._computeVisibilityObb(r),r}).filter(e=>e!=null):null,f=t.featureData?.length??!1,p=t.isEmpty===!0;return new d(e,new i(t.mbs),c,typeof t.version==`string`?t.version:null,{isEmpty:!f&&p,hasSharedResource:t.sharedResource!=null,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:t.geometryData==null?void 0:e},u,Array.isArray(t.lodSelection)?t.lodSelection:null,l)}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes(e=>{e.node!=null&&(e.node.failed=!1)})}_getNodeLoadPriority(e){let t=this._getNodeDescriptor(e),n=this._getParentIndex(e);if(t==null||n==null&&t.node==null)return n==null?1/0:this._getNodeLoadPriority(n);let r=0;t.node&&n!=null&&(r=this._getNodeDescriptor(n).traversalState?.lodLevel??0);let i=this._getHoleBonus(e);return-(this._viewportQueries.distToCameraPOIRay(t.nodeBoundingData??t.node)*(1+r)+r*this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI())+i}_getHoleBonus(e){return this._hasLoadedAncestor(e)?0:this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI()}_hasLoadedAncestor(e){let t=this._getParentIndex(e);for(;t!=null;){if(this._isLoaded(t))return!0;t=this._getParentIndex(t)}return!1}traverseVisible(e,t){let n=this._getNodeDescriptor(this._rootIndex);n==null?e(this._rootIndex,null,null):this._traverseVisible(this._rootIndex,null,n,e,t)}_traverseVisible(e,t,n,r,i){let a=S(e,this._pageSize);if(i&&i.add(a),n.node&&n.childCount===0){this.isGeometryVisible(e)&&r(e,n,t);return}if(!this.isNodeVisible(e)||(r(e,n,t),n.node==null))return;let o=this.nodeTraversalState(n.node);if(o?.nodeHasLOD&&o.lodLevel===this._maxLodLevel)return;let s=this._getPageFromPageIndex(a);for(let t=0;t<n.childCount;t++){let a=s.children[n.childOffset+t],o=this._getNodeDescriptor(a);if(o)this._traverseVisible(a,e,o,r,i);else{if(i){let e=S(a,this._pageSize);i.add(e)}r(a,null,e)}}}traverse(e,t){for(let n of this.traverseValues(e,t));}*traverseValues(e,t){t(e)&&(yield e,yield*this._traverseDescendantValues(e,t))}*_traverseDescendantValues(e,t){let n=e.index,r=this._pageSize,i=S(n,r),a=this._getPageFromPageIndex(i);if(a==null)return;let o=this._frameNumber,s=this._nodePages,c=C(n,r),l=a.nodes[c],u=l.childCount;if(a.lastTraversed=o,u===0)return;let d=[],f=[],p=0;{let{childOffset:e,childCount:t}=l,{children:n}=a;f.length=2**Math.ceil(Math.log2(p+t));for(let r=e;r<e+t;++r){let e=n[r];e>=0?(f[p]=e,++p):d.push(e)}}if(d.length>0){let e=this._clientNodePage;if(e){let n=e.children,r=0;for(;r<d.length;){let i=d[r];++r;let a=-i-1,o=e.nodes[a],s=o.node;if(!s||!t(s))continue;yield s;let{childCount:c}=o;if(c===0)continue;let{childOffset:l}=o,u=l+c;for(let e=l;e<u;++e)d.push(n[e])}}}if(p>0){let e=0;if(r>0){let n=i*r,c=a,l=c.nodes;for(;e<p;){let i=f[e];++e;let a;if(n<=i&&i<n+r)a=c;else{let e=i/r|0,t=s.get(e);if(t===void 0)continue;a=t,a.lastTraversed=o,c=a,l=c.nodes,n=r*e}let u=i-n,d=l[u],m=d?.node;if(m==null||t(m)===!1||(yield m,d.node==null))continue;let{childCount:h}=d;if(h===0)continue;let g=p+h;for(f.length<g&&(f.length=2**Math.ceil(Math.log2(p+h)));f.length<p+h;)f.length+=f.length;let _=a.children,{childOffset:v}=d,y=v+h;for(let e=v;e<y;++e)f[p]=_[e],++p}}else{let n=s.get(0);if(n)for(;e<p;){let r=f[e++],i=n.nodes[r],a=i.node;if(!a||!t(a))continue;yield a;let{childCount:o}=i;if(o===0)continue;f.length=Math.max(f.length,2**Math.ceil(Math.log2(p+o)));let s=n.children,{childOffset:c}=i,l=c+o;for(let e=c;e<l;++e)f[p]=s[e],++p}}}}traverseDescendants(e,t){for(let n of this._traverseDescendantValues(e,t));}updateChildrenLoaded(e,t){let n=this.getNode(e);for(;n!=null;){let e=n.childrenLoaded,r=e+t;n.childrenLoaded=r;let i=e===0?1:r===0?-1:0,a=n.index;if(i!==0){let e=this._getPage(a);e.numNodesWithLoadedChildren+=i}n=this.getParent(a)}}checkChildrenLoadedInvariant(){return!0}updateElevationInfo(e,t){this._needsNodeElevationRange=t&&!!e&&(e.mode===`relative-to-ground`||e.mode===`relative-to-scene`||e.mode===`on-the-ground`),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes(e=>{e?.invalidateBounds(),e.node?.invalidateElevationRange(),e.nodeBoundingData?.invalidateElevationRange()})}_forAllNodes(e){if(this._clientNodePage!=null){let t=this._clientNodePage;for(let n=0;n<t.nodes.length;n++)e(t.nodes[n],-(n+1))}for(let[t,n]of this._nodePages){let r=t*this._pageSize;for(let t=0;t<n.nodes.length;t++)e(n.nodes[t],r+t)}}clearCaches(){if(this._useNodePages){let e=this._nodePages,t=new Set;this.traverseVisible(e=>t.add(S(e,this._pageSize)));for(let[n,r]of e)if(r.numNodesWithLoadedChildren===0&&!t.has(n))this._deleteNodePage(n);else for(let e of r.nodes)e.traversalState=null}}_deleteNodePage(e){if(!this._nodePages.has(e)){this._logger.error(`Destroying non-existent page ${e}`);return}let t=this._nodePages.get(e);this._nodePages.delete(e),t?.destroy()}get test(){}}const h=new Map;class g{constructor(e){this.missing=e,this.update=new t({deallocator:null}),this.add=new t({deallocator:null}),this.remove=new t({deallocator:null}),this.cancel=[]}destroy(){this.update.prune(),this.add.prune(),this.remove.prune(),this.cancel.length=0}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function _(e){return u(e,-2)}function v(e){return u(e,2)}function y(e,t){return t+ +!!e}function b(e,t){return(e&-2)===t}function x(e){return(e&1)==1}function S(e,t){return e<0?-1:t>0?e/t|0:0}function C(e,t){return e<0?-e-1:t===0?e:e%t}function w(e,t,n){return t===-1?-(e+1):n===0?e:t*n+e}const T=[[`maxScreenThreshold`,1],[`screenSpaceRelative`,2],[`removedFeatureDiameter`,3],[`distanceRangeFromDefaultCamera`,4]];function E(e){if(e){for(let t=0;t<e.length;t++)for(let n of T)if(n[0]===e[t].metricType)return{lodMetric:n[1],maxError:e[t].maxError}}return{lodMetric:0,maxError:0}}class D{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}class O{constructor(){this.numFeatures=0,this.knownNodes=0,this.missingNodes=0}}function k(e){return Math.sqrt(4/Math.PI*e)}const A=new i,j=new i,M=new i,N=e(),P=has(`esri-mobile`)?100:300;export{m as I3SIndex,E as selectErrorMetric};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{intersectsSphere as e}from"../../../../geometry/support/frustumPlanes.js";import{IntersectorResultRay as t}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as n}from"../../webgl-engine/lib/RayIntersections.js";import{getVerticalOffsetI3S as r}from"../../webgl-engine/lib/verticalOffsetUtils.js";import{I3sTarget as i}from"./Intersector.js";class a{constructor(e,t){this.node=e,this.objectHandle=t}}class o{get isGround(){return this.integratedMeshSemantics.shouldIntersectAsGround}constructor(e){this.type=2,this._needVerticalOffset=!1,this.layerViewUid=e.layerViewUid,this.sublayerId=e.sublayerId,this._collection=e.collection,this._traverseNodeHierarchy=e.traverseNodeHierarchy,this.slicePlaneEnabled=e.slicePlaneEnabled,this.integratedMeshSemantics=e.integratedMeshSemantics}updateElevationAlignState(e,t){this._needVerticalOffset=e&&t}intersectRay(e,a,o,c,l,u){let d=e.options.store===2,f=e.ray.direction,p=e=>e,m=e=>e,h=r(e.verticalOffset??(this._needVerticalOffset?0:null));e.verticalOffset!=null&&h!=null&&(p=e=>h.applyToMbs(e),m=e=>h.applyToObb(e));let{results:g,tolerance:_}=e,v=new n(_,u,e.options.normalRequired),y=e=>{if(e.childrenLoaded===0)return!1;let t=e.serviceObbInRenderSR?.isValid?e.serviceObbInRenderSR:null;return!(t&&!m(t).intersectRay(o,f,_))};for(let{node:n,objectHandle:r}of this._traverseNodeHierarchy(y)){let l=n.serviceObbInRenderSR?.isValid?n.serviceObbInRenderSR:null,{serviceMbsInRenderSRElevationAdjusted:u}=n;r&&(l||!u.isValid||s(p(u),o,f,_))&&(n.geometryObbInRenderSR==null||m(n.geometryObbInRenderSR).intersectRay(o,f,_))&&this._collection.intersectRay(r,o,c,h,v,(r,s,l,u,f)=>{if(s<0||a!=null&&!a(o,c,s))return;let p=e=>{let t=new i(this.layerViewUid,this.sublayerId,n.index,f,u);e.set(this.type,t,r,s,l)};if(this.isGround&&(g.ground.renderDistance==null||s<g.ground.renderDistance)&&p(g.ground),!e.options.isFiltered&&((g.min.renderDistance==null||s<g.min.renderDistance)&&p(g.min),(g.max.renderDistance==null||r>g.max.renderDistance)&&p(g.max),d)){let n=new t(e.ray);p(n),e.results.all.push(n)}})}}*intersectScreenPolygon(t,n){if(t.camera==null)return;let a=r(this._needVerticalOffset?0:null),o=t=>{if(t.childrenLoaded===0)return!1;let r=t.serviceObbInRenderSR?.isValid?t.serviceObbInRenderSR:null;if(r!=null){if(!r.intersectsFrustumConservativeApproximation(n.broadPhaseFrustum))return!1}else{let r=t.serviceMbsInRenderSRElevationAdjusted;if(r.isValid&&!e(n.broadPhaseFrustum,r))return!1}return!0};for(let{node:e,objectHandle:r}of this._traverseNodeHierarchy(o))r!=null&&r.visible&&(e.geometryObbInRenderSR==null||e.geometryObbInRenderSR.intersectsFrustumConservativeApproximation(n.broadPhaseFrustum))&&(yield*this._collection.intersectScreenPolygon(r,t,n,a,(n,r,a,o)=>{t.polygonResults.add(this.type,new i(this.layerViewUid,this.sublayerId,e.index,n,o),r)}))}}function s(e,t,n,r=0){let i=e.radius+r,a=t[0]-e.center[0],o=t[1]-e.center[1],s=t[2]-e.center[2],[c,l,u]=n,d=c*c+l*l+u*u,f=c*a+l*o+u*s,p=a*a+o*o+s*s-i*i;return f*f-d*p>=0}export{o as I3SIntersectionHandler,a as TraversedIntersectionNode};
2
+ import{intersectsSphere as e}from"../../../../geometry/support/frustumPlanes.js";import{IntersectorResultRay as t}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as n}from"../../webgl-engine/lib/RayIntersections.js";import{getVerticalOffsetI3S as r}from"../../webgl-engine/lib/verticalOffsetUtils.js";import{I3sTarget as i}from"./Intersector.js";class a{constructor(e,t){this.node=e,this.objectHandle=t}}class o{get isGround(){return this.integratedMeshSemantics.shouldIntersectAsGround}constructor(e){this.type=2,this._needVerticalOffset=!1,this.layerViewUid=e.layerViewUid,this.sublayerId=e.sublayerId,this._collection=e.collection,this._traverseNodeHierarchy=e.traverseNodeHierarchy,this.slicePlaneEnabled=e.slicePlaneEnabled,this.integratedMeshSemantics=e.integratedMeshSemantics}updateElevationAlignState(e,t){this._needVerticalOffset=e&&t}intersectRay(e,a,o,c,l,u,d){let f=e.options.store===2,p=e.ray.direction,m=e=>e,h=e=>e,g=r(e.verticalOffset??(this._needVerticalOffset?0:null));e.verticalOffset!=null&&g!=null&&(m=e=>g.applyToMbs(e),h=e=>g.applyToObb(e));let{results:_,tolerance:v}=e,y=new n(v,u,e.options.normalRequired,d),b=e=>{if(e.childrenLoaded===0)return!1;let t=e.serviceObbInRenderSR?.isValid?e.serviceObbInRenderSR:null;return!(t&&!h(t).intersectRay(o,p,v))};for(let{node:n,objectHandle:r}of this._traverseNodeHierarchy(b)){let l=n.serviceObbInRenderSR?.isValid?n.serviceObbInRenderSR:null,{serviceMbsInRenderSRElevationAdjusted:u}=n;if(r&&(l||!u.isValid||s(m(u),o,p,v))&&(n.geometryObbInRenderSR==null||h(n.geometryObbInRenderSR).intersectRay(o,p,v))&&!this._collection.intersectRay(r,o,c,g,y,(r,s,l,u,d)=>{if(s<0||a!=null&&!a(o,c,s))return;let p=e=>{let t=new i(this.layerViewUid,this.sublayerId,n.index,d,u);e.set(this.type,t,r,s,l)};if(this.isGround&&(_.ground.renderDistance==null||s<_.ground.renderDistance)&&p(_.ground),!e.options.isFiltered&&((_.min.renderDistance==null||s<_.min.renderDistance)&&p(_.min),(_.max.renderDistance==null||r>_.max.renderDistance)&&p(_.max),f)){let n=new t(e.ray);p(n),e.results.all.push(n)}}))return!1}return!0}*intersectScreenPolygon(t,n){if(t.camera==null)return;let a=r(this._needVerticalOffset?0:null),o=t=>{if(t.childrenLoaded===0)return!1;let r=t.serviceObbInRenderSR?.isValid?t.serviceObbInRenderSR:null;if(r!=null){if(!r.intersectsFrustumConservativeApproximation(n.broadPhaseFrustum))return!1}else{let r=t.serviceMbsInRenderSRElevationAdjusted;if(r.isValid&&!e(n.broadPhaseFrustum,r))return!1}return!0};for(let{node:e,objectHandle:r}of this._traverseNodeHierarchy(o))r!=null&&r.visible&&(e.geometryObbInRenderSR==null||e.geometryObbInRenderSR.intersectsFrustumConservativeApproximation(n.broadPhaseFrustum))&&(yield*this._collection.intersectScreenPolygon(r,t,n,a,(n,r,a,o)=>{t.polygonResults.add(this.type,new i(this.layerViewUid,this.sublayerId,e.index,n,o),r)}))}}function s(e,t,n,r=0){let i=e.radius+r,a=t[0]-e.center[0],o=t[1]-e.center[1],s=t[2]-e.center[2],[c,l,u]=n,d=c*c+l*l+u*u,f=c*a+l*o+u*s,p=a*a+o*o+s*s-i*i;return f*f-d*p>=0}export{o as I3SIntersectionHandler,a as TraversedIntersectionNode};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{binaryIndexOf as e}from"../../../../core/arrayUtils.js";import t from"../../../../core/Error.js";import has from"../../../../core/has.js";import{invert as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{transformMat4 as i,copy as a}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectVectorToVector as s}from"../../../../geometry/projection/projectVectorToVector.js";import{canProjectWithoutEngine as c}from"../../../../geometry/projectionUtils.js";import l from"../../../../geometry/SpatialReference.js";import{create as u,empty as d,expandPointInPlace as f,intersects as p}from"../../../../geometry/support/aaBoundingRect.js";import{fetchFeaturePopupFeatures as m}from"../../../../layers/support/featurePopupQueryUtils.js";import h from"../../../../request.js";import g from"../../../../rest/support/Query.js";import{spatialReferenceIncompatibleError as _}from"../../../support/layerViewUtils.js";import{Obb as v,compute as ee}from"../../support/orientedBoundingBox.js";import{emissiveStrengthDefault as y}from"../../webgl-engine/core/shaderLibrary/output/getEmissions.glsl.js";import{createSolidEdgeMaterial as b,createMaterialFromEdges as te}from"../support/edgeUtils.js";import{parseColorMixMode as x}from"../support/symbolColorUtils.js";import{readBinaryAttribute as S,getCachedAttributeValue as C}from"./I3SBinaryReader.js";import{computeGlobalTransformation as w}from"./I3SProjectionUtil.js";function T(e){return e?parseInt(e.slice(e.lastIndexOf(`/`)+1),10):void 0}function E(e){if(has(`disable-feature:i3s-draco`)||!e)return!1;for(let t of e)for(let e of t.geometryBuffers)if(e.compressedAttributes?.encoding===`draco`)return!0;return!1}function ne(e,t,n,r,i){n.traverse(t,t=>i.intersectsElevationUpdate(e,t)?(r(t),!0):!1)}function re(e,t,n){let r=0,i=0;for(let a=0;a<t.length&&r<e.length;a++)e[r]===t[a]&&(n(a)&&(e[i]=e[r],i++),r++);e.length=i}function ie(t,n,r){let i=0,a=0;for(;i<r.length;)e(t,r[i])>=0===n&&(r[a]=r[i],a++),i++;r.length=a}function ae(e,t){if(t.rotationScale[1]===0&&t.rotationScale[2]===0&&t.rotationScale[3]===0&&t.rotationScale[5]===0&&t.rotationScale[6]===0&&t.rotationScale[7]===0)return D[0]=(e[0]-t.position[0])/t.rotationScale[0],D[1]=(e[1]-t.position[1])/t.rotationScale[4],D[2]=(e[2]-t.position[0])/t.rotationScale[0],D[3]=(e[3]-t.position[1])/t.rotationScale[4],D}const D=u();function oe(e,t){let n=t.center[0],r=t.center[1],i=t.radius,a=e[0]-n,o=n-e[2],s=e[1]-r,c=r-e[3],l=Math.max(a,o,0),u=Math.max(s,c,0),d=l*l+u*u;return d>i*i?0:d>0?1:-Math.max(a,o,s,c)>i?3:2}function O(e,t,n){let r=[],i=n?.missingFields,a=n?.originalFields,o=!1;for(let n of e){let e=t?.get(n);e?(a?.push(n),r.push(e.name),n!==e.name&&(o=!0)):i?.push(n)}return n&&`hasMismatchedCasing`in n&&(n.hasMismatchedCasing=o),r}async function se(e,n,r,i,a,o){if(n.length===0)return[];let s=e.attributeStorageInfo;if(e.associatedLayer!=null)try{return await j(e.associatedLayer,n,i,o)}catch(t){if(e.associatedLayer.loaded)throw t}if(s){let t=k(e,n,r,a),c=e.parsedUrl.path;return await Promise.allSettled(t.map(t=>M(c,s,t.node,t.indices,i,e.apiKey,e.customParameters,o).then(e=>{for(let n=0;n<t.graphics.length;n++){let r=t.graphics[n],i=e[n];if(r.attributes)for(let e in r.attributes)e in i||(i[e]=r.attributes[e]);r.attributes=i}}))),n}throw new t(`scenelayer:no-attribute-source`,`This scene layer does not have a source for attributes available`)}function k({globalIdField:e},t,n,r){let i=new Map,a=[],o=r();for(let r of t){let t=r.attributes?.[n],s=t==null?r.getGlobalId():void 0;for(let n=0;n<o.length;n++){let c=o[n],l=A(c,t,e,s);if(l<0)continue;let u=i.get(c.node);u||(u={node:c.node,indices:[],graphics:[]},a.push(u),i.set(c.node,u)),u.indices.push(l),u.graphics.push(r);for(let e=n;e>0;e--)o[e]=o[e-1];o[0]=c;break}}return a}function A(e,t,n,r){if(t!=null&&typeof t==`number`)return e.featureIds.indexOf(t);if(r==null||n==null)return-1;let i=e.attributeInfo?.attributeData?.[n];return i?i.indexOf(r):-1}async function j(e,t,n,r){let i=[],a={hasMismatchedCasing:!1,originalFields:i},o=O(n,e.fieldsIndex,a),s=new g({outFields:[...o]});if(await m(e,t,s,{updateSourceAttributes:!0,...r}),!a.hasMismatchedCasing)return t;for(let e=0;e<t.length;e++){let n=t[e];if(n.attributes)for(let e=0;e<i.length;e++){let t=i[e],r=o[e];r in n.attributes&&(n.attributes[t]=n.attributes[r],delete n.attributes[r])}}return t}function M(e,t,n,r,i,a,o,s){return N(e,t,n.resources.attributes,r,i,a,o,s)}async function N(e,t,n,r,i,a,o,s){let c=[];for(let r of t)if(r&&i.includes(r.name)){let t=`${e}/nodes/${n}/attributes/${r.key}/0`;c.push({url:t,storageInfo:r})}let l=await Promise.allSettled(c.map(e=>h(e.url,{responseType:`array-buffer`,query:{...o,token:a},signal:s?.signal}).then(t=>S(e.storageInfo,t.data)))),u=[];for(let e of r){let t={};for(let n=0;n<l.length;n++){let r=l[n];if(r.status===`fulfilled`){let i=r.value;t[c[n].storageInfo.name]=C(i,e)}}u.push(t)}return u}function P(e){let n=e.store,r=n.indexCRS||n.geographicCRS,i=r===void 0?n.indexWKT:void 0;if(i){if(e.spatialReference){if(i!==e.spatialReference.wkt)throw new t(`layerview:store-spatial-reference-wkt-index-incompatible`,`The indexWKT of the scene layer store does not match the WKT of the layer spatial reference`,{})}else throw new t(`layerview:no-store-spatial-reference-wkt-index-and-no-layer-spatial-reference`,`Found indexWKT in the scene layer store but no layer spatial reference`,{})}let a=r?new l(T(r)):e.spatialReference;return a.equals(e.spatialReference)?e.spatialReference:a}function F(e){let n=e.store,r=n.vertexCRS||n.projectedCRS,i=r===void 0?n.vertexWKT:void 0;if(i){if(e.spatialReference){if(i!==e.spatialReference.wkt)throw new t(`layerview:store-spatial-reference-wkt-vertex-incompatible`,`The vertexWKT of the scene layer store does not match the WKT of the layer spatial reference`,{})}else throw new t(`layerview:no-store-spatial-reference-wkt-vertex-and-no-layer-spatial-reference`,`Found vertexWKT in the scene layer store but no layer spatial reference`,{})}let a=r?new l(T(r)):e.spatialReference;return a.equals(e.spatialReference)?e.spatialReference:a}function I(e,t,n){if(!c(e,t)||n===`local`&&!R(e,t))throw _(`scene layer`,e?.wkid,t?.wkid)}function L(e,n,r){if(e.serviceUpdateTimeStamp?.lastUpdate!==n.serviceUpdateTimeStamp?.lastUpdate||!r.isEmpty||e.associatedLayer?.url!==n.associatedLayer?.url)throw new t(`layerview:recycle-failed`,`Could not recycle layerview`)}function R(e,t){return e.equals(t)||e.isWGS84&&t.isWebMercator||e.isWebMercator&&t.isWGS84}function z(e,t,n){let r=P(e),i=F(e);I(r,t,n),I(i,t,n)}function B(e){return!(e.geometryType!=null&&e.geometryType!==`triangles`||e.topology!=null&&e.topology!==`PerAttributeArray`||e.vertexAttributes?.position==null)}function V(e){if(e.store?.defaultGeometrySchema==null||!B(e.store.defaultGeometrySchema))throw new t(`scenelayer:unsupported-geometry-schema`,`The geometry schema of this scene layer is not supported.`,{url:e.parsedUrl.path})}function H(e,t){z(e,t.spatialReference,t.viewingMode)}function U(e){return!(e.geometryType==null||e.geometryType!==`points`||e.topology!=null&&e.topology!==`PerAttributeArray`||e.encoding!=null&&e.encoding!==``&&e.encoding!==`lepcc-xyz`||e.vertexAttributes?.position==null)}function W(e){if(e.store?.defaultGeometrySchema==null||!U(e.store.defaultGeometrySchema))throw new t(`pointcloud:unsupported-geometry-schema`,`The geometry schema of this point cloud scene layer is not supported.`,{})}function G(e,t){I(e.spatialReference,t.spatialReference,t.viewingMode)}function ce(e){return e.type===`simple`||e.type===`class-breaks`||e.type===`unique-value`}function le(e){return e.type===`mesh-3d`}function ue(e){if(e==null||!ce(e)||(e.type===`unique-value`||e.type===`class-breaks`)&&e.defaultSymbol==null)return!0;let t=e.symbols;if(t.length===0)return!0;for(let e of t){if(!le(e)||e.symbolLayers.length===0)return!0;for(let t of e.symbolLayers.items)if(t.type!==`fill`||t.material?.color==null||t.material.colorMixMode!==`replace`)return!0}return!1}const de=b({color:[0,0,0,0],opacity:0});class K{constructor(){this.edgeMaterial=null,this.material=null,this.castShadows=!0}}function fe(e){let t=new K,n=!1,r=!1;for(let i of e.symbolLayers.items)if(i.type===`fill`&&i.enabled){let e=i.material,a=i.edges;if(e!=null&&!n){let r=e.color,a=x(e.colorMixMode),o={strength:e.emissive?.strength??y,source:+(e.emissive?.source===`color`)};t.material=r==null?{color:[1,1,1],alpha:1,colorMixMode:1,emissive:o}:{color:[r.r/255,r.g/255,r.b/255],alpha:r.a,colorMixMode:a,emissive:o},t.castShadows=i.castShadows,n=!0}a!=null&&!r&&(t.edgeMaterial=te(a,{}),r=!0)}return t.material||={color:[1,1,1],alpha:1,colorMixMode:1,emissive:{strength:y,source:0}},t}function q(e,t){return(e|0)+(t|0)|0}function pe(e,t,r,o,c,l,u){if(!l||l.length===0||t==null||!e.serviceMbsInIndexSR)return null;let m=w(e.serviceMbsInIndexSR,c,`none`,r,t);n($,m);let h=null,g=()=>{if(!h){if(h=me,d(Y),e.serviceObbInIndexSR!=null){e.serviceObbInIndexSR.transform(X,r,t,c,u),X.getCorners(h);for(let e of h)i(e,e,$),f(Y,e)}else{let n=e.serviceMbsInIndexSR;if(!n)return;let o=n.radius;s(n.center,r,Z,t),i(Z,Z,$),Z[2]+=c;for(let e=0;e<8;++e){let t=e&1?o:-o,n=e&2?o:-o,r=e&4?o:-o,i=h[e];a(i,[Z[0]+t,Z[1]+n,Z[2]+r]),f(Y,i)}}}},_=1/0,v=-1/0,y=e=>{if(e.type!==`replace`)return;let n=e.geometry;if(!n?.hasZ)return;d(J);let r=n.spatialReference||o,a=n.rings.reduce((e,n)=>n.reduce((e,n)=>(s(n,r,Z,t),i(Z,Z,$),f(J,Z),Math.min(Z[2],e)),e),1/0);g(),p(Y,J)&&(_=Math.min(_,a),v=Math.max(v,a))};if(l.forEach(e=>y(e)),_===1/0)return null;let b=(e,t,n)=>{i(Z,n,m),e[t]=Z[0],e[t+1]=Z[1],e[t+2]=Z[2],t+=24,n[2]=_,i(Z,n,m),e[t]=Z[0],e[t+1]=Z[1],e[t+2]=Z[2],t+=24,n[2]=v,i(Z,n,m),e[t]=Z[0],e[t+1]=Z[1],e[t+2]=Z[2]};for(let e=0;e<8;++e)b(Q.data,e*3,h[e]);return ee(Q)}const me=[o(),o(),o(),o(),o(),o(),o(),o()],J=u(),Y=u(),X=new v,Z=o(),Q={data:Array(72),size:3,exclusive:!0,stride:3},$=r();export{K as SymbolInfo,q as addWraparound,G as checkPointCloudLayerCompatibleWithView,W as checkPointCloudLayerValid,L as checkRecyclable,H as checkSceneLayerCompatibleWithView,V as checkSceneLayerValid,I as checkSpatialReference,z as checkSpatialReferences,pe as computeVisibilityObb,E as containsDraco,T as extractWkid,re as filterInPlace,O as findFieldsCaseInsensitive,ne as findIntersectingNodes,ae as getClipRect,P as getIndexCrs,fe as getSymbolInfo,F as getVertexCrs,oe as intersectBoundingRectWithMbs,R as isSupportedLocalModeProjection,ie as objectIdFilter,N as queryAttributesFromCachedAttributesId,ue as rendererNeedsTextures,de as transparentEdgeMaterial,se as whenGraphicAttributes};
2
+ import{binaryIndexOf as e}from"../../../../core/arrayUtils.js";import t from"../../../../core/Error.js";import has from"../../../../core/has.js";import{invert as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as i,transformMat4 as a,copy 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{projectVectorToVector as c}from"../../../../geometry/projection/projectVectorToVector.js";import{canProjectWithoutEngine as l}from"../../../../geometry/projectionUtils.js";import u from"../../../../geometry/SpatialReference.js";import{fromBuffer as d}from"../../../../geometry/support/aaBoundingBox.js";import{create as f,intersects as p,empty as m,expandPointInPlace as h}from"../../../../geometry/support/aaBoundingRect.js";import{fetchFeaturePopupFeatures as g}from"../../../../layers/support/featurePopupQueryUtils.js";import _ from"../../../../request.js";import v from"../../../../rest/support/Query.js";import{spatialReferenceIncompatibleError as y}from"../../../support/layerViewUtils.js";import{Obb as b,compute as ee}from"../../support/orientedBoundingBox.js";import{emissiveStrengthDefault as x}from"../../webgl-engine/core/shaderLibrary/output/getEmissions.glsl.js";import{createSolidEdgeMaterial as te,createMaterialFromEdges as S}from"../support/edgeUtils.js";import{parseColorMixMode as C}from"../support/symbolColorUtils.js";import{readBinaryAttribute as w,getCachedAttributeValue as ne}from"./I3SBinaryReader.js";import{computeGlobalTransformation as re}from"./I3SProjectionUtil.js";function T(e){return e?parseInt(e.slice(e.lastIndexOf(`/`)+1),10):void 0}function E(e){if(has(`disable-feature:i3s-draco`)||!e)return!1;for(let t of e)for(let e of t.geometryBuffers)if(e.compressedAttributes?.encoding===`draco`)return!0;return!1}function D(e,t,n,r,i){n.traverse(t,t=>i.intersectsElevationUpdate(e,t)?(r(t),!0):!1)}function O(e,t,n){let r=0,i=0;for(let a=0;a<t.length&&r<e.length;a++)e[r]===t[a]&&(n(a)&&(e[i]=e[r],i++),r++);e.length=i}function k(t,n,r){let i=0,a=0;for(;i<r.length;)e(t,r[i])>=0===n&&(r[a]=r[i],a++),i++;r.length=a}function ie(e,t){if(t.rotationScale[1]===0&&t.rotationScale[2]===0&&t.rotationScale[3]===0&&t.rotationScale[5]===0&&t.rotationScale[6]===0&&t.rotationScale[7]===0)return A[0]=(e[0]-t.position[0])/t.rotationScale[0],A[1]=(e[1]-t.position[1])/t.rotationScale[4],A[2]=(e[2]-t.position[0])/t.rotationScale[0],A[3]=(e[3]-t.position[1])/t.rotationScale[4],A}const A=f();function ae(e,t){let n=t.center[0],r=t.center[1],i=t.radius,a=e[0]-n,o=n-e[2],s=e[1]-r,c=r-e[3],l=Math.max(a,o,0),u=Math.max(s,c,0),d=l*l+u*u;return d>i*i?0:d>0?1:-Math.max(a,o,s,c)>i?3:2}function j(e,t,n){let r=[],i=n?.missingFields,a=n?.originalFields,o=!1;for(let n of e){let e=t?.get(n);e?(a?.push(n),r.push(e.name),n!==e.name&&(o=!0)):i?.push(n)}return n&&`hasMismatchedCasing`in n&&(n.hasMismatchedCasing=o),r}async function oe(e,n,r,i,a,o){if(n.length===0)return[];let s=e.attributeStorageInfo;if(e.associatedLayer!=null)try{return await N(e.associatedLayer,n,i,o)}catch(t){if(e.associatedLayer.loaded)throw t}if(s){let t=se(e,n,r,a),c=e.parsedUrl.path;return await Promise.allSettled(t.map(t=>P(c,s,t.node,t.indices,i,e.apiKey,e.customParameters,o).then(e=>{for(let n=0;n<t.graphics.length;n++){let r=t.graphics[n],i=e[n];if(r.attributes)for(let e in r.attributes)e in i||(i[e]=r.attributes[e]);r.attributes=i}}))),n}throw new t(`scenelayer:no-attribute-source`,`This scene layer does not have a source for attributes available`)}function se({globalIdField:e},t,n,r){let i=new Map,a=[],o=r();for(let r of t){let t=r.attributes?.[n],s=t==null?r.getGlobalId():void 0;for(let n=0;n<o.length;n++){let c=o[n],l=M(c,t,e,s);if(l<0)continue;let u=i.get(c.node);u||(u={node:c.node,indices:[],graphics:[]},a.push(u),i.set(c.node,u)),u.indices.push(l),u.graphics.push(r);for(let e=n;e>0;e--)o[e]=o[e-1];o[0]=c;break}}return a}function M(e,t,n,r){if(t!=null&&typeof t==`number`)return e.featureIds.indexOf(t);if(r==null||n==null)return-1;let i=e.attributeInfo?.attributeData?.[n];return i?i.indexOf(r):-1}async function N(e,t,n,r){let i=[],a={hasMismatchedCasing:!1,originalFields:i},o=j(n,e.fieldsIndex,a),s=new v({outFields:[...o]});if(await g(e,t,s,{updateSourceAttributes:!0,...r}),!a.hasMismatchedCasing)return t;for(let e=0;e<t.length;e++){let n=t[e];if(n.attributes)for(let e=0;e<i.length;e++){let t=i[e],r=o[e];r in n.attributes&&(n.attributes[t]=n.attributes[r],delete n.attributes[r])}}return t}function P(e,t,n,r,i,a,o,s){return F(e,t,n.resources.attributes,r,i,a,o,s)}async function F(e,t,n,r,i,a,o,s){let c=[];for(let r of t)if(r&&i.includes(r.name)){let t=`${e}/nodes/${n}/attributes/${r.key}/0`;c.push({url:t,storageInfo:r})}let l=await Promise.allSettled(c.map(e=>_(e.url,{responseType:`array-buffer`,query:{...o,token:a},signal:s?.signal}).then(t=>w(e.storageInfo,t.data)))),u=[];for(let e of r){let t={};for(let n=0;n<l.length;n++){let r=l[n];if(r.status===`fulfilled`){let i=r.value;t[c[n].storageInfo.name]=ne(i,e)}}u.push(t)}return u}function I(e){let n=e.store,r=n.indexCRS||n.geographicCRS,i=r===void 0?n.indexWKT:void 0;if(i){if(e.spatialReference){if(i!==e.spatialReference.wkt)throw new t(`layerview:store-spatial-reference-wkt-index-incompatible`,`The indexWKT of the scene layer store does not match the WKT of the layer spatial reference`,{})}else throw new t(`layerview:no-store-spatial-reference-wkt-index-and-no-layer-spatial-reference`,`Found indexWKT in the scene layer store but no layer spatial reference`,{})}let a=r?new u(T(r)):e.spatialReference;return a.equals(e.spatialReference)?e.spatialReference:a}function L(e){let n=e.store,r=n.vertexCRS||n.projectedCRS,i=r===void 0?n.vertexWKT:void 0;if(i){if(e.spatialReference){if(i!==e.spatialReference.wkt)throw new t(`layerview:store-spatial-reference-wkt-vertex-incompatible`,`The vertexWKT of the scene layer store does not match the WKT of the layer spatial reference`,{})}else throw new t(`layerview:no-store-spatial-reference-wkt-vertex-and-no-layer-spatial-reference`,`Found vertexWKT in the scene layer store but no layer spatial reference`,{})}let a=r?new u(T(r)):e.spatialReference;return a.equals(e.spatialReference)?e.spatialReference:a}function R(e,t,n){if(!l(e,t)||!n&&!B(e,t))throw y(`scene layer`,e?.wkid,t?.wkid)}function z(e,n,r){if(e.serviceUpdateTimeStamp?.lastUpdate!==n.serviceUpdateTimeStamp?.lastUpdate||!r.isEmpty||e.associatedLayer?.url!==n.associatedLayer?.url)throw new t(`layerview:recycle-failed`,`Could not recycle layerview`)}function B(e,t){return e.equals(t)||e.isWGS84&&t.isWebMercator||e.isWebMercator&&t.isWGS84}function V(e,t,n){let r=I(e),i=L(e);R(r,t,n),R(i,t,n)}function H(e){return!(e.geometryType!=null&&e.geometryType!==`triangles`||e.topology!=null&&e.topology!==`PerAttributeArray`||e.vertexAttributes?.position==null)}function U(e){if(e.store?.defaultGeometrySchema==null||!H(e.store.defaultGeometrySchema))throw new t(`scenelayer:unsupported-geometry-schema`,`The geometry schema of this scene layer is not supported.`,{url:e.parsedUrl.path})}function W(e,t){V(e,t.spatialReference,t.state.isGlobal)}function G(e){return!(e.geometryType==null||e.geometryType!==`points`||e.topology!=null&&e.topology!==`PerAttributeArray`||e.encoding!=null&&e.encoding!==``&&e.encoding!==`lepcc-xyz`||e.vertexAttributes?.position==null)}function K(e){if(e.store?.defaultGeometrySchema==null||!G(e.store.defaultGeometrySchema))throw new t(`pointcloud:unsupported-geometry-schema`,`The geometry schema of this point cloud scene layer is not supported.`,{})}function ce(e,t){R(e.spatialReference,t.spatialReference,t.state.isGlobal)}function le(e){return e.type===`simple`||e.type===`class-breaks`||e.type===`unique-value`}function ue(e){return e.type===`mesh-3d`}function de(e){if(e==null||!le(e)||(e.type===`unique-value`||e.type===`class-breaks`)&&e.defaultSymbol==null)return!0;let t=e.symbols;if(t.length===0)return!0;for(let e of t){if(!ue(e)||e.symbolLayers.length===0)return!0;for(let t of e.symbolLayers.items)if(t.type!==`fill`||t.material?.color==null||t.material.colorMixMode!==`replace`)return!0}return!1}const fe=te({color:[0,0,0,0],opacity:0});class q{constructor(){this.edgeMaterial=null,this.material=null,this.castShadows=!0}}function pe(e){let t=new q,n=!1,r=!1;for(let i of e.symbolLayers.items)if(i.type===`fill`&&i.enabled){let e=i.material,a=i.edges;if(e!=null&&!n){let r=e.color,a=C(e.colorMixMode),o={strength:e.emissive?.strength??x,source:+(e.emissive?.source===`color`)};t.material=r==null?{color:[1,1,1],alpha:1,colorMixMode:1,emissive:o}:{color:[r.r/255,r.g/255,r.b/255],alpha:r.a,colorMixMode:a,emissive:o},t.castShadows=i.castShadows,n=!0}a!=null&&!r&&(t.edgeMaterial=S(a,{}),r=!0)}return t.material||={color:[1,1,1],alpha:1,colorMixMode:1,emissive:{strength:x,source:0}},t}function me(e,t){return(e|0)+(t|0)|0}function he(e,t,n){let r=[];if(n==null)return r;for(let i of e){let e=i.geometry;if(i.type!==`replace`||!e?.hasZ)continue;let a=e.rings,o=new Float64Array(a.reduce((e,t)=>e+t.length,0)*3),s=e.spatialReference||t,l=0;for(let e of a)for(let t of e)c(t,s,Z,n),o.set(Z,l),l+=3;o.length>0&&r.push({vertices:o,bounds:d(o)})}return r}function ge(e,t,r,s,l,u){if(!l||l.length===0||t==null||!e.serviceMbsInIndexSR)return null;let d=re(e.serviceMbsInIndexSR,s,`none`,r,t);n($,d);let f=null,g=()=>{if(!f){if(f=_e,m(Y),e.serviceObbInIndexSR!=null){e.serviceObbInIndexSR.transform(X,r,t,s,u),X.getCorners(f);for(let e of f)a(e,e,$),h(Y,e)}else{let n=e.serviceMbsInIndexSR;if(!n)return;let i=n.radius;c(n.center,r,Z,t),a(Z,Z,$),Z[2]+=s;for(let e=0;e<8;++e){let t=e&1?i:-i,n=e&2?i:-i,r=e&4?i:-i,a=f[e];o(a,[Z[0]+t,Z[1]+n,Z[2]+r]),h(Y,a)}}}},_=1/0,v=-1/0,y=({vertices:e,bounds:t})=>{for(let e=0;e<2;++e){let n=$[e],r=$[e+4],i=$[e+8],a=$[e+12];J[e]=n*t[n<0?3:0]+r*t[r<0?4:1]+i*t[i<0?5:2]+a,J[e+2]=n*t[n<0?0:3]+r*t[r<0?1:4]+i*t[i<0?2:5]+a}if(g(),!p(Y,J))return;m(J);let n=1/0;for(let t=0;t<e.length;t+=3)i(Z,e[t],e[t+1],e[t+2]),a(Z,Z,$),h(J,Z),n=Math.min(n,Z[2]);p(Y,J)&&(_=Math.min(_,n),v=Math.max(v,n))};if(l.forEach(e=>y(e)),_===1/0)return null;let b=(e,t,n)=>{a(Z,n,d),e[t]=Z[0],e[t+1]=Z[1],e[t+2]=Z[2],t+=24,n[2]=_,a(Z,n,d),e[t]=Z[0],e[t+1]=Z[1],e[t+2]=Z[2],t+=24,n[2]=v,a(Z,n,d),e[t]=Z[0],e[t+1]=Z[1],e[t+2]=Z[2]};for(let e=0;e<8;++e)b(Q.data,e*3,f[e]);return ee(Q)}const _e=[s(),s(),s(),s(),s(),s(),s(),s()],J=f(),Y=f(),X=new b,Z=s(),Q={data:Array(72),size:3,exclusive:!0,stride:3},$=r();export{q as SymbolInfo,me as addWraparound,ce as checkPointCloudLayerCompatibleWithView,K as checkPointCloudLayerValid,z as checkRecyclable,W as checkSceneLayerCompatibleWithView,U as checkSceneLayerValid,R as checkSpatialReference,V as checkSpatialReferences,ge as computeVisibilityObb,E as containsDraco,T as extractWkid,O as filterInPlace,j as findFieldsCaseInsensitive,D as findIntersectingNodes,ie as getClipRect,I as getIndexCrs,pe as getSymbolInfo,L as getVertexCrs,ae as intersectBoundingRectWithMbs,B as isSupportedLocalModeProjection,k as objectIdFilter,he as projectVisibilityModifications,F as queryAttributesFromCachedAttributesId,de as rendererNeedsTextures,fe as transparentEdgeMaterial,oe as whenGraphicAttributes};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{sub as e,normalize as t,len as n,dot as r}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as i,create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import o from"../../../../core/Logger.js";import{getOrCreateMapValue as s}from"../../../../core/MapUtils.js";import{fromValues as c,isEmpty as l,containedBySphere as u,setEmpty as d,intersectsSphere as f,intersectsRay as p,copy as m,exactEquals as h}from"../../../../geometry/support/aaBoundingBox.js";import{fromValues as g}from"../../../../geometry/support/aaBoundingRect.js";import{earth as _}from"../../../../geometry/support/Ellipsoid.js";import{ElevationRange as v}from"../../support/ElevationRange.js";function y(e,t){return e===`local`?new x(t):new S(t)}class b{constructor(e,t){this.viewingMode=e,this.layerExtent=t,this._rootNode=null,this._intersectionGeneration=0,this._tileMap=new Map}get elevationRange(){return this._rootNode?.subtreeElevationRange}destroy(){this._rootNode?.clear(),this._tileMap.clear()}_nextIntersectionGeneration(){return this._intersectionGeneration++,this._intersectionGeneration}addTile(e){let{obb:t}=e,n=[this._ensureRootNode()],r=[],i=s(this._tileMap,e,()=>new Set),a=t=>{if(i.has(t))return;let n=t.addOwnTile(e);T(r,t.parent,n),i.add(t)};for(;n.length>0;){let r=n.pop(),i=this._getSizeStopLength(r);if(r.treeDepth>=U||A(e.obb)>=.5*i){a(r);continue}let{hPlane:o,vPlane:s}=r,c=t.signedDistancePlane(o.normal,o.distance),l=t.signedDistancePlane(s.normal,s.distance);c===0&&l===0?a(r):w(r,c,l,(e,t)=>{n.push(this._ensureChild(e,t))})}this._propagateSummaryUpdates(r)}removeTile(e){if(!this._rootNode){o.getLogger(`Tiles3DBVH`).error(`Tiles3DBVH: Attempted to remove a tile that is not loaded (no root node)`);return}let t=this._tileMap.get(e);if(!t||t.size===0){o.getLogger(`Tiles3DBVH`).error(`Tiles3DBVH internal error: Attempted to remove a tile that is not loaded (not in tile map)`);return}let n=[];this._tileMap.delete(e);for(let r of t){r.removeOwnTile(e);let t=r.updateOwnSummaries();T(n,r.parent,t)}this._propagateSummaryUpdates(n)}_propagateSummaryUpdates(e){if(e.length===0)return;e.sort((e,t)=>e.node.treeDepth-t.node.treeDepth);let t=new Map,n=-1,r=()=>e.length>0?e[e.length-1].node.treeDepth:-1;for(;e.length>0||t.size>0;){let i=t.size>0?n:r(),a=t;for(t=new Map;e.length>0&&r()===i;){let{node:t,childrenUpdateKind:n}=e.pop();E(a,t,n)}for(let[e,n]of a){let r=0;for(let t=0;t<4;t++){let n=e.children[t];n&&n.isLeaf&&!n.hasTiles&&(n.clear(),e.children[t]=null,r=3)}r|=e.updateSubtreeSummaries(n|r),E(t,e.parent,r)}t.size>0&&(n=i-1)}}forEachTileIntersectingRay(e,t,n,r){r?this._forEachTileIntersectingVerticalRay(e,t,n):this._forEachTileIntersectingRayGeneral(e,t,n)}_forEachTileIntersectingRayGeneral(n,r,i){let a=this._rootNode;if(!a)return;e(B,r,n);let o=t(B,B);if(!a.subtreeIntersectsRay(n,o,{tMin:0,tMax:1/0}))return;let s=this._nextIntersectionGeneration(),c=[a],l=H;l.length=0,l.push(0,1/0);let u={tMin:0,tMax:1/0};for(;c.length>0;){let e=c.pop();u.tMax=l.pop(),u.tMin=l.pop(),e.forEachOwnTileIntersectingRay(n,o,u,s,i);let{hPlane:t,vPlane:r}=e;for(let i=0;i<4;i++){let a=e.children[i];if(a==null)continue;let s=i,d=s===0||s===2,f=s===0||s===1,p=N(n,o,N(n,o,u,r,!d),t,!f);p&&a.subtreeIntersectsRay(n,o,p)&&(c.push(a),l.push(p.tMin,p.tMax))}}}_forEachTileIntersectingVerticalRay(r,i,a){let o=this._rootNode;if(!o)return;e(B,i,r);let s=t(B,B),c={tMin:0,tMax:this.viewingMode===`global`?n(r):1/0};if(!o.subtreeIntersectsRay(r,s,c))return;let l=this._nextIntersectionGeneration(),u=[o];for(;u.length>0;){let e=u.pop();e.forEachOwnTileIntersectingRay(r,s,c,l,a),e.isLeaf||w(e,k(e.hPlane,r),k(e.vPlane,r),(e,t)=>{let n=e.children[t];n&&n.subtreeIntersectsRay(r,s,c)&&u.push(n)},1)}}getElevationRangeIntersectingSphere(e){let t=this._rootNode;if(!t||!t.subtreeIntersectsSphere(e))return null;let n=this._nextIntersectionGeneration(),r=new v,i=[t];for(;i.length>0;){let t=i.pop();if(!r.contains(t.subtreeElevationRange)){if(t.subtreeContainedBySphere(e))r.expandElevationRange(t.subtreeElevationRange);else{if(t.ownIntersectsSphere(e))for(let i of t.ownTiles){if(i.bvhIntersectionGeneration===n||(i.bvhIntersectionGeneration=n,!(i.boundingVolumeIntersectsSphere?.(e)??i.obb.intersectSphere(e))))continue;let t=i.elevationRange;r.contains(t)||r.expandElevationRange(t)}t.isLeaf||w(t,O(e.center,e.radius,t.hPlane),O(e.center,e.radius,t.vPlane),(t,n)=>{let a=t.children[n];if(a&&a.subtreeIntersectsSphere(e)){if(r.contains(a.subtreeElevationRange))return;i.push(a)}})}}}return r.isEmpty?null:r}}class x extends b{constructor(e){super(`local`,e)}_getSizeStopLength(e){return e.sideLength}_ensureRootNode(){if(!this._rootNode){let e=this.layerExtent,t=Math.max(Math.abs(e[0]),Math.abs(e[1]),Math.abs(e[2]),Math.abs(e[3])),n=2**Math.max(1,Math.ceil(Math.log2(t))),r=new C(null,0,g(-n,-n,n,n),new D(i(0,1,0),0),new D(i(1,0,0),0),n*2,c(-n,-n,-1/0,n,n,1/0));this._rootNode=r}return this._rootNode}_ensureChild(e,t){if(e.treeDepth>=U){let e=`Internal error: attempted to create a child node for a node that is already at max depth`;throw o.getLogger(`Tiles3DBVH`).error(e),Error(e)}let n=e.children[t];if(n===null){let{extent:r,hPlane:i,vPlane:a,treeDepth:o,sideLength:s}=e,l=.5*(r[0]+r[2]),u=.5*(r[1]+r[3]),d=t===0||t===1,f=t===2||t===0,p=g(f?r[0]:l,d?r[1]:u,f?l:r[2],d?u:r[3]),m=new D(i.normal,-.5*(p[1]+p[3])),h=new D(a.normal,-.5*(p[0]+p[2]));n=new C(e,o+1,p,m,h,s*.5,c(p[0],p[1],-1/0,p[2],p[3],1/0)),e.children[t]=n}return n}}class S extends b{constructor(e){super(`global`,e)}_getSizeStopLength(e){return M(e.extent)}_ensureRootNode(){if(!this._rootNode){let e=new C(null,0,g(-Math.PI,-Math.PI/2,Math.PI,Math.PI/2),new D(i(0,0,1),0),new D(i(0,1,0),0),Math.PI*_.radius);this._rootNode=e}return this._rootNode}_ensureChild(e,t){if(e.treeDepth>=U){let e=`Attempted to create a child node for a node that is already at max depth`;throw o.getLogger(`Tiles3DBVH`).error(e),Error(e)}let n=e.children[t];if(n===null){let{extent:r,treeDepth:a}=e,o=.5*(r[0]+r[2]),s=.5*(r[1]+r[3]),c=t===0||t===1,l=t===2||t===0,u=g(l?r[0]:o,c?r[1]:s,l?o:r[2],c?s:r[3]),d=.5*(u[0]+u[2]),f=.5*(u[1]+u[3]),p=Math.cos(d),m=Math.sin(d),h=Math.cos(f),_=Math.sin(f),v=i(-_*p,-_*m,h),y=new D(v,0),b=new D(i(-m,p,0),0),x=j(u);n=new C(e,a+1,u,y,b,x),e.children[t]=n}return n}}class C{constructor(e,t,n,r,i,a,o){this.parent=e,this._treeDepth=t,this.extent=n,this.hPlane=r,this.vPlane=i,this.sideLength=a,this.bounds=o,this._ownAABB=c(1/0,1/0,1/0,-1/0,-1/0,-1/0),this._subtreeAABB=c(1/0,1/0,1/0,-1/0,-1/0,-1/0),this._ownElevationRange=new v,this._subtreeElevationRange=new v,this._ownTiles=[],this.children=[null,null,null,null]}get subtreeAABB(){return this._subtreeAABB}get subtreeElevationRange(){return this._subtreeElevationRange}subtreeContainedBySphere(e){let t=this._subtreeAABB;return l(t)?!0:u(t,e)}clear(){for(let e=0;e<4;e++)this.children[e]?.clear(),this.children[e]=null;this._ownTiles.length=0,d(this._ownAABB),d(this._subtreeAABB),this._ownElevationRange.initializeEmpty(),this._subtreeElevationRange.initializeEmpty()}get isLeaf(){return this.children.every(e=>e==null)}get treeDepth(){return this._treeDepth}subtreeIntersectsSphere(e){return f(this.subtreeAABB,e)}ownIntersectsSphere(e){return this.hasTiles&&f(this._ownAABB,e)}subtreeIntersectsRay(e,t,n){return p(this._subtreeAABB,e,t,n)}ownIntersectsRay(e,t,n){return this.hasTiles?p(this._ownAABB,e,t,n):null}forEachOwnTileIntersectingRay(e,t,n,r,i){if(this.ownIntersectsRay(e,t,n))for(let n of this.ownTiles)n.bvhIntersectionGeneration!==r&&(n.bvhIntersectionGeneration=r,(n.boundingVolumeIntersectsRay?.(e,t)??n.obb.intersectRay(e,t))&&i(n))}addOwnTile(e){this._ownTiles.push(e);let t=P(this._ownAABB,e,this.bounds)&&F(this._subtreeAABB,this._ownAABB,this.bounds),n=this._ownElevationRange.expandElevationRange(e.elevationRange)&&this._subtreeElevationRange.expandElevationRange(e.elevationRange);return!!t|(n?2:0)}removeOwnTile(e){let t=this._ownTiles,n=t.indexOf(e);if(n===-1){o.getLogger(`Tiles3DBVH`).error(`BVNode: Attempted to remove a tile that is not in the node`);return}let r=t.length-1;n<r&&(t[n]=t[r]),t.length=r}updateOwnSummaries(){let e=I(this._ownAABB,this.ownTiles,this.bounds),t=L(this._ownElevationRange,this.ownTiles),n=!!e|(t?2:0);return this.updateSubtreeSummaries(n)}updateSubtreeSummaries(e){if(this.isLeaf&&!this.hasTiles)return d(this._subtreeAABB),this._subtreeElevationRange.initializeEmpty(),3;let t=0;if(e&1){m(R,this._subtreeAABB),d(this._subtreeAABB),F(this._subtreeAABB,this._ownAABB,this.bounds);for(let e of this.children)e&&F(this._subtreeAABB,e.subtreeAABB,this.bounds);h(this._subtreeAABB,R)||(t|=1)}if(e&2){z.setElevationRange(this._subtreeElevationRange),this._subtreeElevationRange.initializeEmpty(),this._subtreeElevationRange.expandElevationRange(this._ownElevationRange);for(let e of this.children)e&&this._subtreeElevationRange.expandElevationRange(e.subtreeElevationRange);this._subtreeElevationRange.equals(z)||(t|=2)}return t}get ownTiles(){return this._ownTiles}get hasTiles(){return this._ownTiles.length>0}}function w(e,t,n,r,i=1e-12){t<=i&&(n<=i&&r(e,0),n>=-i&&r(e,1)),t>=-i&&(n<=i&&r(e,2),n>=-i&&r(e,3))}function T(e,t,n){t!=null&&n!==0&&e.push({node:t,childrenUpdateKind:n})}function E(e,t,n){if(t==null||n===0)return;let r=e.get(t)??0;e.set(t,r|n)}class D{constructor(e=[0,0,0],t=0){this.normal=e,this.distance=t}}function O(e,t,n){let i=r(n.normal,e)+n.distance;return i<0?Math.min(i+t,0):Math.max(i-t,0)}function k(e,t){return r(e.normal,t)+e.distance}function A(e){return 2*Math.max(e.halfSizeX,e.halfSizeY,e.halfSizeZ)}function j(e){let t=Math.abs(e[2]-e[0]),n=Math.abs(e[3]-e[1]),r=.5*(e[1]+e[3]),i=_.radius*Math.abs(Math.cos(r))*t,a=_.radius*n;return Math.max(i,a)}function M(e){let t=Math.abs(e[2]-e[0]),n=Math.abs(e[3]-e[1]),r=.5*(e[1]+e[3]),i=_.radius*Math.abs(Math.cos(r))*t,a=_.radius*n;return Math.min(i,a)}function N(e,t,n,i,a){if(!n)return null;let o=1e-12,s=r(i.normal,t),c=k(i,e)+n.tMin*s;if(Math.abs(s)<o)return(a?c>=-1e-12:c<=o)?n:null;let l=n.tMin-c/s,u=a===s>0?{tMin:Math.max(n.tMin,l),tMax:n.tMax}:{tMin:n.tMin,tMax:Math.min(n.tMax,l)};return u.tMin<=u.tMax?u:null}function P(e,t,n){let{obb:r}=t,a=[i(1,0,0),i(0,1,0),i(0,0,1)],o=r.getCenter(V),s=!1;for(let t=0;t<3;t++){let i=r.projectedRadius(a[t]),c=Math.max(n?.[t]??-1/0,o[t]-i),l=Math.min(n?.[t+3]??1/0,o[t]+i);c<e[t]&&(e[t]=c,s=!0),l>e[t+3]&&(e[t+3]=l,s=!0)}return s}function F(e,t,n){if(l(t))return!1;let r=!1;for(let i=0;i<3;i++){let a=Math.max(n?.[i]??-1/0,t[i]),o=Math.min(n?.[i+3]??1/0,t[i+3]);a<e[i]&&(e[i]=a,r=!0),o>e[i+3]&&(e[i+3]=o,r=!0)}return r}function I(e,t,n){m(R,e),d(e);for(let r of t)P(e,r,n);return!h(e,R)}function L(e,t){z.setElevationRange(e),e.initializeEmpty();for(let n of t)e.expandElevationRange(n.elevationRange);return!e.equals(z)}const R=c(0,0,0,0,0,0),z=new v,B=a(),V=a(),H=[],U=30;export{y as createTileBVH};
2
+ import{sub as e,normalize as t,len as n,dot as r}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as i,create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import o from"../../../../core/Logger.js";import{getOrCreateMapValue as s}from"../../../../core/MapUtils.js";import{fromValues as c,isEmpty as l,containedBySphere as u,setEmpty as d,intersectsSphere as f,intersectsRay as p,copy as m,exactEquals as h}from"../../../../geometry/support/aaBoundingBox.js";import{fromValues as g}from"../../../../geometry/support/aaBoundingRect.js";import{earth as _}from"../../../../geometry/support/Ellipsoid.js";import{ElevationRange as v}from"../../support/ElevationRange.js";function y(e,t){return e?new S(t):new x(t)}class b{constructor(e,t){this.isGlobal=e,this.layerExtent=t,this._rootNode=null,this._intersectionGeneration=0,this._tileMap=new Map}get elevationRange(){return this._rootNode?.subtreeElevationRange}destroy(){this._rootNode?.clear(),this._tileMap.clear()}_nextIntersectionGeneration(){return this._intersectionGeneration++,this._intersectionGeneration}addTile(e){let{obb:t}=e,n=[this._ensureRootNode()],r=[],i=s(this._tileMap,e,()=>new Set),a=t=>{if(i.has(t))return;let n=t.addOwnTile(e);T(r,t.parent,n),i.add(t)};for(;n.length>0;){let r=n.pop(),i=this._getSizeStopLength(r);if(r.treeDepth>=U||A(e.obb)>=.5*i){a(r);continue}let{hPlane:o,vPlane:s}=r,c=t.signedDistancePlane(o.normal,o.distance),l=t.signedDistancePlane(s.normal,s.distance);c===0&&l===0?a(r):w(r,c,l,(e,t)=>{n.push(this._ensureChild(e,t))})}this._propagateSummaryUpdates(r)}removeTile(e){if(!this._rootNode){o.getLogger(`Tiles3DBVH`).error(`Tiles3DBVH: Attempted to remove a tile that is not loaded (no root node)`);return}let t=this._tileMap.get(e);if(!t||t.size===0){o.getLogger(`Tiles3DBVH`).error(`Tiles3DBVH internal error: Attempted to remove a tile that is not loaded (not in tile map)`);return}let n=[];this._tileMap.delete(e);for(let r of t){r.removeOwnTile(e);let t=r.updateOwnSummaries();T(n,r.parent,t)}this._propagateSummaryUpdates(n)}_propagateSummaryUpdates(e){if(e.length===0)return;e.sort((e,t)=>e.node.treeDepth-t.node.treeDepth);let t=new Map,n=-1,r=()=>e.length>0?e[e.length-1].node.treeDepth:-1;for(;e.length>0||t.size>0;){let i=t.size>0?n:r(),a=t;for(t=new Map;e.length>0&&r()===i;){let{node:t,childrenUpdateKind:n}=e.pop();E(a,t,n)}for(let[e,n]of a){let r=0;for(let t=0;t<4;t++){let n=e.children[t];n&&n.isLeaf&&!n.hasTiles&&(n.clear(),e.children[t]=null,r=3)}r|=e.updateSubtreeSummaries(n|r),E(t,e.parent,r)}t.size>0&&(n=i-1)}}forEachTileIntersectingRay(e,t,n,r){return r?this._forEachTileIntersectingVerticalRay(e,t,n):this._forEachTileIntersectingRayGeneral(e,t,n)}_forEachTileIntersectingRayGeneral(n,r,i){let a=this._rootNode;if(!a)return!0;e(B,r,n);let o=t(B,B);if(!a.subtreeIntersectsRay(n,o,{tMin:0,tMax:1/0}))return!0;let s=this._nextIntersectionGeneration(),c=[a],l=H;l.length=0,l.push(0,1/0);let u={tMin:0,tMax:1/0};for(;c.length>0;){let e=c.pop();if(u.tMax=l.pop(),u.tMin=l.pop(),!e.forEachOwnTileIntersectingRay(n,o,u,s,i))return!1;let{hPlane:t,vPlane:r}=e;for(let i=0;i<4;i++){let a=e.children[i];if(a==null)continue;let s=i,d=s===0||s===2,f=s===0||s===1,p=N(n,o,N(n,o,u,r,!d),t,!f);p&&a.subtreeIntersectsRay(n,o,p)&&(c.push(a),l.push(p.tMin,p.tMax))}}return!0}_forEachTileIntersectingVerticalRay(r,i,a){let o=this._rootNode;if(!o)return!0;e(B,i,r);let s=t(B,B),c={tMin:0,tMax:this.isGlobal?n(r):1/0};if(!o.subtreeIntersectsRay(r,s,c))return!0;let l=this._nextIntersectionGeneration(),u=[o];for(;u.length>0;){let e=u.pop();if(!e.forEachOwnTileIntersectingRay(r,s,c,l,a))return!1;e.isLeaf||w(e,k(e.hPlane,r),k(e.vPlane,r),(e,t)=>{let n=e.children[t];n&&n.subtreeIntersectsRay(r,s,c)&&u.push(n)},1)}return!0}getElevationRangeIntersectingSphere(e){let t=this._rootNode;if(!t||!t.subtreeIntersectsSphere(e))return null;let n=this._nextIntersectionGeneration(),r=new v,i=[t];for(;i.length>0;){let t=i.pop();if(!r.contains(t.subtreeElevationRange)){if(t.subtreeContainedBySphere(e))r.expandElevationRange(t.subtreeElevationRange);else{if(t.ownIntersectsSphere(e))for(let i of t.ownTiles){if(i.bvhIntersectionGeneration===n||(i.bvhIntersectionGeneration=n,!(i.boundingVolumeIntersectsSphere?.(e)??i.obb.intersectSphere(e))))continue;let t=i.elevationRange;r.contains(t)||r.expandElevationRange(t)}t.isLeaf||w(t,O(e.center,e.radius,t.hPlane),O(e.center,e.radius,t.vPlane),(t,n)=>{let a=t.children[n];if(a&&a.subtreeIntersectsSphere(e)){if(r.contains(a.subtreeElevationRange))return;i.push(a)}})}}}return r.isEmpty?null:r}}class x extends b{constructor(e){super(!1,e)}_getSizeStopLength(e){return e.sideLength}_ensureRootNode(){if(!this._rootNode){let e=this.layerExtent,t=Math.max(Math.abs(e[0]),Math.abs(e[1]),Math.abs(e[2]),Math.abs(e[3])),n=2**Math.max(1,Math.ceil(Math.log2(t))),r=new C(null,0,g(-n,-n,n,n),new D(i(0,1,0),0),new D(i(1,0,0),0),n*2,c(-n,-n,-1/0,n,n,1/0));this._rootNode=r}return this._rootNode}_ensureChild(e,t){if(e.treeDepth>=U){let e=`Internal error: attempted to create a child node for a node that is already at max depth`;throw o.getLogger(`Tiles3DBVH`).error(e),Error(e)}let n=e.children[t];if(n===null){let{extent:r,hPlane:i,vPlane:a,treeDepth:o,sideLength:s}=e,l=.5*(r[0]+r[2]),u=.5*(r[1]+r[3]),d=t===0||t===1,f=t===2||t===0,p=g(f?r[0]:l,d?r[1]:u,f?l:r[2],d?u:r[3]),m=new D(i.normal,-.5*(p[1]+p[3])),h=new D(a.normal,-.5*(p[0]+p[2]));n=new C(e,o+1,p,m,h,s*.5,c(p[0],p[1],-1/0,p[2],p[3],1/0)),e.children[t]=n}return n}}class S extends b{constructor(e){super(!0,e)}_getSizeStopLength(e){return M(e.extent)}_ensureRootNode(){if(!this._rootNode){let e=new C(null,0,g(-Math.PI,-Math.PI/2,Math.PI,Math.PI/2),new D(i(0,0,1),0),new D(i(0,1,0),0),Math.PI*_.radius);this._rootNode=e}return this._rootNode}_ensureChild(e,t){if(e.treeDepth>=U){let e=`Attempted to create a child node for a node that is already at max depth`;throw o.getLogger(`Tiles3DBVH`).error(e),Error(e)}let n=e.children[t];if(n===null){let{extent:r,treeDepth:a}=e,o=.5*(r[0]+r[2]),s=.5*(r[1]+r[3]),c=t===0||t===1,l=t===2||t===0,u=g(l?r[0]:o,c?r[1]:s,l?o:r[2],c?s:r[3]),d=.5*(u[0]+u[2]),f=.5*(u[1]+u[3]),p=Math.cos(d),m=Math.sin(d),h=Math.cos(f),_=Math.sin(f),v=i(-_*p,-_*m,h),y=new D(v,0),b=new D(i(-m,p,0),0),x=j(u);n=new C(e,a+1,u,y,b,x),e.children[t]=n}return n}}class C{constructor(e,t,n,r,i,a,o){this.parent=e,this._treeDepth=t,this.extent=n,this.hPlane=r,this.vPlane=i,this.sideLength=a,this.bounds=o,this._ownAABB=c(1/0,1/0,1/0,-1/0,-1/0,-1/0),this._subtreeAABB=c(1/0,1/0,1/0,-1/0,-1/0,-1/0),this._ownElevationRange=new v,this._subtreeElevationRange=new v,this._ownTiles=[],this.children=[null,null,null,null]}get subtreeAABB(){return this._subtreeAABB}get subtreeElevationRange(){return this._subtreeElevationRange}subtreeContainedBySphere(e){let t=this._subtreeAABB;return l(t)?!0:u(t,e)}clear(){for(let e=0;e<4;e++)this.children[e]?.clear(),this.children[e]=null;this._ownTiles.length=0,d(this._ownAABB),d(this._subtreeAABB),this._ownElevationRange.initializeEmpty(),this._subtreeElevationRange.initializeEmpty()}get isLeaf(){return this.children.every(e=>e==null)}get treeDepth(){return this._treeDepth}subtreeIntersectsSphere(e){return f(this.subtreeAABB,e)}ownIntersectsSphere(e){return this.hasTiles&&f(this._ownAABB,e)}subtreeIntersectsRay(e,t,n){return p(this._subtreeAABB,e,t,n)}ownIntersectsRay(e,t,n){return this.hasTiles?p(this._ownAABB,e,t,n):null}forEachOwnTileIntersectingRay(e,t,n,r,i){if(!this.ownIntersectsRay(e,t,n))return!0;for(let n of this.ownTiles)if(n.bvhIntersectionGeneration!==r&&(n.bvhIntersectionGeneration=r,(n.boundingVolumeIntersectsRay?.(e,t)??n.obb.intersectRay(e,t))&&i(n)===!1))return!1;return!0}addOwnTile(e){this._ownTiles.push(e);let t=P(this._ownAABB,e,this.bounds)&&F(this._subtreeAABB,this._ownAABB,this.bounds),n=this._ownElevationRange.expandElevationRange(e.elevationRange)&&this._subtreeElevationRange.expandElevationRange(e.elevationRange);return!!t|(n?2:0)}removeOwnTile(e){let t=this._ownTiles,n=t.indexOf(e);if(n===-1){o.getLogger(`Tiles3DBVH`).error(`BVNode: Attempted to remove a tile that is not in the node`);return}let r=t.length-1;n<r&&(t[n]=t[r]),t.length=r}updateOwnSummaries(){let e=I(this._ownAABB,this.ownTiles,this.bounds),t=L(this._ownElevationRange,this.ownTiles),n=!!e|(t?2:0);return this.updateSubtreeSummaries(n)}updateSubtreeSummaries(e){if(this.isLeaf&&!this.hasTiles)return d(this._subtreeAABB),this._subtreeElevationRange.initializeEmpty(),3;let t=0;if(e&1){m(R,this._subtreeAABB),d(this._subtreeAABB),F(this._subtreeAABB,this._ownAABB,this.bounds);for(let e of this.children)e&&F(this._subtreeAABB,e.subtreeAABB,this.bounds);h(this._subtreeAABB,R)||(t|=1)}if(e&2){z.setElevationRange(this._subtreeElevationRange),this._subtreeElevationRange.initializeEmpty(),this._subtreeElevationRange.expandElevationRange(this._ownElevationRange);for(let e of this.children)e&&this._subtreeElevationRange.expandElevationRange(e.subtreeElevationRange);this._subtreeElevationRange.equals(z)||(t|=2)}return t}get ownTiles(){return this._ownTiles}get hasTiles(){return this._ownTiles.length>0}}function w(e,t,n,r,i=1e-12){t<=i&&(n<=i&&r(e,0),n>=-i&&r(e,1)),t>=-i&&(n<=i&&r(e,2),n>=-i&&r(e,3))}function T(e,t,n){t!=null&&n!==0&&e.push({node:t,childrenUpdateKind:n})}function E(e,t,n){if(t==null||n===0)return;let r=e.get(t)??0;e.set(t,r|n)}class D{constructor(e=[0,0,0],t=0){this.normal=e,this.distance=t}}function O(e,t,n){let i=r(n.normal,e)+n.distance;return i<0?Math.min(i+t,0):Math.max(i-t,0)}function k(e,t){return r(e.normal,t)+e.distance}function A(e){return 2*Math.max(e.halfSizeX,e.halfSizeY,e.halfSizeZ)}function j(e){let t=Math.abs(e[2]-e[0]),n=Math.abs(e[3]-e[1]),r=.5*(e[1]+e[3]),i=_.radius*Math.abs(Math.cos(r))*t,a=_.radius*n;return Math.max(i,a)}function M(e){let t=Math.abs(e[2]-e[0]),n=Math.abs(e[3]-e[1]),r=.5*(e[1]+e[3]),i=_.radius*Math.abs(Math.cos(r))*t,a=_.radius*n;return Math.min(i,a)}function N(e,t,n,i,a){if(!n)return null;let o=1e-12,s=r(i.normal,t),c=k(i,e)+n.tMin*s;if(Math.abs(s)<o)return(a?c>=-1e-12:c<=o)?n:null;let l=n.tMin-c/s,u=a===s>0?{tMin:Math.max(n.tMin,l),tMax:n.tMax}:{tMin:n.tMin,tMax:Math.min(n.tMax,l)};return u.tMin<=u.tMax?u:null}function P(e,t,n){let{obb:r}=t,a=[i(1,0,0),i(0,1,0),i(0,0,1)],o=r.getCenter(V),s=!1;for(let t=0;t<3;t++){let i=r.projectedRadius(a[t]),c=Math.max(n?.[t]??-1/0,o[t]-i),l=Math.min(n?.[t+3]??1/0,o[t]+i);c<e[t]&&(e[t]=c,s=!0),l>e[t+3]&&(e[t+3]=l,s=!0)}return s}function F(e,t,n){if(l(t))return!1;let r=!1;for(let i=0;i<3;i++){let a=Math.max(n?.[i]??-1/0,t[i]),o=Math.min(n?.[i+3]??1/0,t[i+3]);a<e[i]&&(e[i]=a,r=!0),o>e[i+3]&&(e[i+3]=o,r=!0)}return r}function I(e,t,n){m(R,e),d(e);for(let r of t)P(e,r,n);return!h(e,R)}function L(e,t){z.setElevationRange(e),e.initializeEmpty();for(let n of t)e.expandElevationRange(n.elevationRange);return!e.equals(z)}const R=c(0,0,0,0,0,0),z=new v,B=a(),V=a(),H=[],U=30;export{y as createTileBVH};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ElevationRange as t}from"../../support/ElevationRange.js";import{IntersectorResultRay as n}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as r,computeInvDir as i,intersectAabbInvDir as a}from"../../webgl-engine/lib/RayIntersections.js";import{Tiles3DTarget as o}from"../i3s/Intersector.js";import{createTileBVHForLayer as s}from"./createTileBVHForLayer.js";class c{constructor(e,t){this.layerView=e,this.integratedMeshSemantics=t,this.type=8,this.slicePlaneEnabled=!1,this.layerViewUid=e.uid,this._bvh=s(e)}destroy(){this._bvh.destroy()}addTile(e){this._bvh.addTile(e)}removeTile(e){this._bvh.removeTile(e)}get isGround(){return this.integratedMeshSemantics.shouldIntersectAsGround}intersectRay(e,t,s,c,u,d){if(e.options.filteredLayerViewUids.includes(this.layerView.uid))return;let{results:f,tolerance:p}=e,m=e.options.store===2,{componentObjectCollection:h}=this.layerView.view.stage.renderView,g=new r(p,d,e.options.normalRequired),_=i(s,c,l),v=(r,i,a)=>{if(i<0||t!=null&&!t(s,c,r))return;let l=e=>{let t=new o(this.layerView.uid);e.set(this.type,t,r,i,a)};if(this.isGround&&(f.ground.renderDistance==null||i<f.ground.renderDistance)&&l(f.ground),!e.options.isFiltered&&((f.min.renderDistance==null||i<f.min.renderDistance)&&l(f.min),(f.max.renderDistance==null||i>f.max.renderDistance)&&l(f.max),m)){let t=new n(e.ray);l(t),e.results.all.push(t)}};this._bvh.forEachTileIntersectingRay(s,c,e=>{let{componentObjects:t}=e;for(let e of t)a(e.aabbInWorldCoordinates,s,_,0)&&h.intersectRay(e,s,c,null,g,v)},d)}get elevationRange(){let e=this._bvh.elevationRange;return e!=null&&!e.isEmpty?new t(e.minElevation,e.maxElevation):null}getElevationRange(e){return this._bvh.getElevationRangeIntersectingSphere(e)??new t(0,0)}}const l=e();export{c as Tiles3DMeshIntersectionHandler};
2
+ import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ElevationRange as t}from"../../support/ElevationRange.js";import{IntersectorResultRay as n}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as r,computeInvDir as i,intersectAabbInvDir as a}from"../../webgl-engine/lib/RayIntersections.js";import{Tiles3DTarget as o}from"../i3s/Intersector.js";import{createTileBVHForLayer as s}from"./createTileBVHForLayer.js";class c{constructor(e,t){this.layerView=e,this.integratedMeshSemantics=t,this.type=8,this.slicePlaneEnabled=!1,this.layerViewUid=e.uid,this._bvh=s(e)}destroy(){this._bvh.destroy()}addTile(e){this._bvh.addTile(e)}removeTile(e){this._bvh.removeTile(e)}get isGround(){return this.integratedMeshSemantics.shouldIntersectAsGround}intersectRay(e,t,s,c,u,d,f){if(e.options.filteredLayerViewUids.includes(this.layerView.uid))return!0;let{results:p,tolerance:m}=e,h=e.options.store===2,{componentObjectCollection:g}=this.layerView.view.stage.renderView,_=new r(m,d,e.options.normalRequired,f),v=i(s,c,l),y=(r,i,a)=>{if(i<0||t!=null&&!t(s,c,r))return;let l=e=>{let t=new o(this.layerView.uid);e.set(this.type,t,r,i,a)};if(this.isGround&&(p.ground.renderDistance==null||i<p.ground.renderDistance)&&l(p.ground),!e.options.isFiltered&&((p.min.renderDistance==null||i<p.min.renderDistance)&&l(p.min),(p.max.renderDistance==null||i>p.max.renderDistance)&&l(p.max),h)){let t=new n(e.ray);l(t),e.results.all.push(t)}};return this._bvh.forEachTileIntersectingRay(s,c,e=>{let{componentObjects:t}=e;for(let e of t)if(a(e.aabbInWorldCoordinates,s,v,0)&&!g.intersectRay(e,s,c,null,_,y))return!1;return!0},d)}get elevationRange(){let e=this._bvh.elevationRange;return e!=null&&!e.isEmpty?new t(e.minElevation,e.maxElevation):null}getElevationRange(e){return this._bvh.getElevationRangeIntersectingSphere(e)??new t(0,0)}}const l=e();export{c as Tiles3DMeshIntersectionHandler};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{project as e}from"../../../../geometry/projectionUtils.js";import{fromExtent as t}from"../../../../geometry/support/aaBoundingRect.js";import{createTileBVH as n}from"./Tiles3DBVH.js";function r(r){let{view:i}=r,a=r.useEsriCrs?r.fullExtentInLocalViewSpatialReference:r.layer.fullExtent?e(r.layer.fullExtent,i.renderSpatialReference):void 0;return n(i.viewingMode,t(a??i.extent))}export{r as createTileBVHForLayer};
2
+ import{project as e}from"../../../../geometry/projectionUtils.js";import{fromExtent as t}from"../../../../geometry/support/aaBoundingRect.js";import{createTileBVH as n}from"./Tiles3DBVH.js";function r(r){let{view:i}=r,a=r.useEsriCrs?r.fullExtentInLocalViewSpatialReference:r.layer.fullExtent?e(r.layer.fullExtent,i.renderSpatialReference):void 0;return n(i.state.isGlobal,t(a??i.extent))}export{r as createTileBVHForLayer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{subclass as t}from"../../../../core/accessorSupport/decorators.js";import{cyclicalPI as n}from"../../../../core/Cyclical.js";import{copy as r,distance as i}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{copy as a,negate as o,length as s,subtract as c,normalize as l,add as u,scale as d,dot as f}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{deg2rad as m}from"../../../../core/mathUtils.js";import{createScreenPointArray as h,screenPointObjectToArray as g}from"../../../../core/screenUtils.js";import{getReferenceEllipsoid as _}from"../../../../geometry/ellipsoidUtils.js";import{wrapAxisAngle as v}from"../../../../geometry/support/axisAngle.js";import{create as y,fromPositionAndNormal as b,getNormal as ee}from"../../../../geometry/support/plane.js";import{Sphere as x}from"../../../../geometry/support/sphere.js";import{PanPlanarMomentumEstimator as S}from"../../../navigation/PanPlanarMomentumEstimator.js";import{PanSphericalMomentumEstimator as C}from"../../../navigation/PanSphericalMomentumEstimator.js";import{RotationMomentumEstimator as w}from"../../../navigation/RotationMomentumEstimator.js";import{ZoomMomentumEstimator as T}from"../../../navigation/ZoomMomentumEstimator.js";import{pixelDistanceToInteractionFactor as E,applyAll as D}from"../../camera/constraintUtils.js";import{ConstraintOptions as O}from"../../camera/constraintUtils/ConstraintOptions.js";import{ExponentialFalloff as k}from"../../input/util.js";import A from"../../webgl/RenderCamera.js";import{pickPointAndInitSphere as j,excludeTerrain as M,inferNavigationMode as N,sphereOrPlanePointFromScreenPoint as P,maxPanDistanceModifier as F,minPinchAndPanCameraHeight as I,searchAreaSize as L,intersectPlaneFromScreenPointAtEye as R,applyZoomOnSphere as z,shouldPreserveHeading as B,applyPanSphericalPreserveHeading as V,applyPanSphericalDirectRotation as H,normalizeRotationDelta as U,applyRotation as W,applyPanPlanar as G,applyZoomToPoint as K}from"../utils/navigationUtils.js";import{InteractiveController as q}from"./InteractiveController.js";import{PanPlanarMomentumController as J}from"./momentum/PanPlanarMomentumController.js";import{PanSphericalMomentumController as Y}from"./momentum/PanSphericalMomentumController.js";import{RotationMomentumController as X}from"./momentum/RotationMomentumController.js";import{ZoomPlanarMomentumController as Z}from"./momentum/ZoomPlanarMomentumController.js";import{ZoomSphericalMomentumController as Q}from"./momentum/ZoomSphericalMomentumController.js";let $=class extends q{constructor(e){super(e),this._smoothRotation=new k(.05),this._rotationAxis=p(),this._beginAngle=0,this._beginHeading=0,this._panningPlane=y(),this._beginRadius=0,this._smoothScaling=new k(.05),this._zoomCenterScreen=h(),this._zoomMomentumEstimator=new T,this._rotationMomentumEstimator=new w,this._panSphericalMomentumEstimator=new C,this._panPlanarMomentumEstimator=new S,this._adjustedSphere=new x,this._tmp3d=p(),this._tmpScreenPointArray=h(),this._beginScreenPoint=h(),this._beginScenePoint=p(),this._screenPickPoint=h(),this._scenePickPoint=p(),this._navigationMode=1,this._sphere=new x,this._pointerCount=0,this._tmpInteractionDirection=p(),this._beginCamera=new A,this._constraintOptions=new O(15,0,0,this._beginCamera)}begin(e){if(!this.running)return;this._zoomMomentumEstimator.enabled=this._rotationMomentumEstimator.enabled=this._panPlanarMomentumEstimator.enabled=this._panSphericalMomentumEstimator.enabled=this.view.navigation.momentumEnabled,this._beginHeading=-n.normalize(m(this.view.camera.heading)),this._beginRadius=e.radius,this._beginAngle=e.angle,this._pointerCount=e.pointers.size,this._smoothRotation.reset(),g(e.center,this._screenPickPoint),r(this._beginScreenPoint,this._screenPickPoint);let t=j(this.view,this.startCamera,this._screenPickPoint,_(this.view.spatialReference).radius,1,this.view.groundView.invisible?M:{});t.scenePickPoint!=null&&(this._scenePickPoint=t.scenePickPoint,this._sphere=t.sphere,a(this._beginScenePoint,this._scenePickPoint),this._navigationMode=N(this.startCamera,this._screenPickPoint,this.view.renderCoordsHelper,this.view.viewingMode),this._navigationMode===0&&this._preparePlanarPanMode(e,t.hasGeometryIntersection),this._beginCamera.copyFrom(this.startCamera))}update(e){if(!this.running)return;this.currentCamera.copyFrom(this.startCamera);let t=e.pointers.size>1;this._navigationMode===1?(t&&this._zoomSpherical(e),this._panningSpherical(e),t&&this._rotateSpherical(e)):(t&&this._zoomPlanar(e),this._panningPlanar(e),t&&this._rotatePlanar(e)),this.commitCamera()}end(e){e.pointers.size===this._pointerCount&&this.update(e),this.finishController();let t=this.view.animationsEnabled&&this._zoomMomentumEstimator.evaluateMomentum();if(t)return this._navigationMode===1?new Q({view:this.view,momentum:t,screenCenter:this._zoomCenterScreen,sceneCenter:this._beginScenePoint,radius:this._sphere.radius}):new Z({view:this.view,momentum:t,zoomCenter:this._beginScenePoint});let n=this.view.animationsEnabled&&this._rotationMomentumEstimator.evaluateMomentum();if(n)return new X({view:this.view,momentum:n,center:this._sphere.center,axis:this._rotationAxis});if(this._navigationMode===1){let e=this.view.animationsEnabled&&this._panSphericalMomentumEstimator.evaluateMomentum();if(e)return new Y({view:this.view,momentum:e})}else{let e=this.view.animationsEnabled&&this._panPlanarMomentumEstimator.evaluateMomentum();if(e)return new J({view:this.view,momentum:e})}return null}_preparePlanarPanMode(e,t){let n=o(this._tmp3d,this.startCamera.viewForward);b(this._scenePickPoint,n,this._panningPlane);let r=h(this._screenPickPoint[0],0),i=p(),m=s(this.startCamera.eye);this._adjustedSphere.radius=m<this._sphere.radius?m-100:this._sphere.radius,P(this._adjustedSphere,this.startCamera,r,i);let _=p(),v=p(),y=p();c(_,this._scenePickPoint,this.currentCamera.eye);let x=s(_);l(_,_);let S=F*Math.max(Math.abs(this.view.camera.position.z),I),C=this.view.stage.renderView.getMinimalDepthForArea(null,this._screenPickPoint[0],this._screenPickPoint[1],this.view.state.camera,L)??S;t&&(C=Math.min(C,x)),a(y,u(v,this.currentCamera.eye,d(v,_,C))),this._panningPlane[3]=-f(ee(this._panningPlane),y),this.startCamera.center=u(v,this.startCamera.eye,d(v,this.startCamera.viewForward,C));let w=g(e.center,this._tmpScreenPointArray);R(this._panningPlane,this.startCamera,w,this._beginScenePoint)}_zoomSpherical(e){let t=this._beginRadius/e.radius,n=Math.min(Math.max(e.radius,40),120)*.001875;this._smoothScaling.gain=n,this._smoothScaling.update(t),z(this._sphere,this.currentCamera,this._smoothScaling.value),g(e.center,this._zoomCenterScreen),this._zoomMomentumEstimator.add(this._smoothScaling.value,e.timestamp*.001),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=E(e.radius-this._beginRadius),D(this.view,this.currentCamera,this._constraintOptions)}_panningSpherical(e){let t=g(e.center,this._tmpScreenPointArray);P(this._sphere,this.currentCamera,t,this._tmp3d),B(this._beginScenePoint,f(this.currentCamera.up,this._beginScenePoint),this._sphere.radius,this._beginHeading,this.view.camera.tilt,this.startCamera.aboveGround)?(V(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this._beginHeading,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumPreserveHeading(t,this._tmp3d,e.timestamp*.001,this.startCamera,this._sphere,this._beginHeading,this.view.camera.tilt)):(H(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumDirectRotation(t,this._tmp3d,e.timestamp*.001,this.startCamera,this._sphere.radius,this.view.camera.tilt)),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=E(i(this._screenPickPoint,t)),D(this.view,this.currentCamera,this._constraintOptions)}_rotateSpherical(e){l(this._rotationAxis,this._scenePickPoint),this.currentCamera.aboveGround||o(this._rotationAxis,this._rotationAxis);let t=this._smoothRotation.value,n=t+U(e.angle-t),r=Math.min(Math.max(e.radius,40),120)*.00125;this._smoothRotation.gain=r,this._smoothRotation.update(n);let i=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(i,e.timestamp*.001),W(this.currentCamera,this._sphere.center,v(this._rotationAxis,i)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=E(e.radius*n),D(this.view,this.currentCamera,this._constraintOptions)}_panningPlanar(e){let t=g(e.center,this._tmpScreenPointArray);R(this._panningPlane,this.currentCamera,t,this._tmp3d)&&(G(this.currentCamera,this._beginScenePoint,this._tmp3d),this._panPlanarMomentumEstimator.add(t,this._tmp3d,e.timestamp*.001),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=E(i(this._beginScreenPoint,t)),this._constraintOptions.interactionDirection=this.view.renderCoordsHelper.worldUpAtPosition(this.currentCamera.eye,this._tmpInteractionDirection),D(this.view,this.currentCamera,this._constraintOptions),this._constraintOptions.interactionDirection=null)}_zoomPlanar(e){let t=this._beginRadius/e.radius,n=Math.min(Math.max(e.radius,40),120)*.001875;this._smoothScaling.gain=n,this._smoothScaling.update(t),this._zoomMomentumEstimator.add(this._smoothScaling.value,e.timestamp*.001),K(this.currentCamera,this._beginScenePoint,this._smoothScaling.value,this.view.state.constraints.minimumPoiDistance),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=E(e.radius-this._beginRadius),D(this.view,this.currentCamera,this._constraintOptions)}_rotatePlanar(e){a(this._rotationAxis,this._beginScenePoint),this.currentCamera.aboveGround||o(this._rotationAxis,this._rotationAxis);let t=this._smoothRotation.value,n=e.angle-t;n=U(n);let r=t+n,i=Math.min(Math.max(e.radius,40),120)*.00125;this._smoothRotation.gain=i,this._smoothRotation.update(r);let s=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(s,e.timestamp*.001),W(this.currentCamera,this._sphere.center,v(this._rotationAxis,s)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=E(e.radius*s),D(this.view,this.currentCamera,this._constraintOptions)}};$=e([t(`esri.views.3d.state.controllers.PinchAndPanControllerGlobal`)],$);export{$ as PinchAndPanControllerGlobal};
2
+ import{__decorate as e}from"tslib";import{subclass as t}from"../../../../core/accessorSupport/decorators.js";import{cyclicalPI as n}from"../../../../core/Cyclical.js";import{copy as r,distance as i}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{copy as a,negate as o,length as s,subtract as c,normalize as l,add as u,scale as d,dot as f}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{deg2rad as m}from"../../../../core/mathUtils.js";import{createScreenPointArray as h,screenPointObjectToArray as g}from"../../../../core/screenUtils.js";import{getReferenceEllipsoid as _}from"../../../../geometry/ellipsoidUtils.js";import{wrapAxisAngle as v}from"../../../../geometry/support/axisAngle.js";import{create as y,fromPositionAndNormal as b,getNormal as ee}from"../../../../geometry/support/plane.js";import{Sphere as x}from"../../../../geometry/support/sphere.js";import{PanPlanarMomentumEstimator as S}from"../../../navigation/PanPlanarMomentumEstimator.js";import{PanSphericalMomentumEstimator as C}from"../../../navigation/PanSphericalMomentumEstimator.js";import{RotationMomentumEstimator as w}from"../../../navigation/RotationMomentumEstimator.js";import{ZoomMomentumEstimator as T}from"../../../navigation/ZoomMomentumEstimator.js";import{pixelDistanceToInteractionFactor as E,applyAll as D}from"../../camera/constraintUtils.js";import{ConstraintOptions as O}from"../../camera/constraintUtils/ConstraintOptions.js";import{ExponentialFalloff as k}from"../../input/util.js";import A from"../../webgl/RenderCamera.js";import{pickPointAndInitSphere as j,excludeTerrain as M,inferNavigationMode as N,sphereOrPlanePointFromScreenPoint as P,maxPanDistanceModifier as F,minPinchAndPanCameraHeight as I,searchAreaSize as L,intersectPlaneFromScreenPointAtEye as R,applyZoomOnSphere as z,shouldPreserveHeading as B,applyPanSphericalPreserveHeading as V,applyPanSphericalDirectRotation as H,normalizeRotationDelta as U,applyRotation as W,applyPanPlanar as G,applyZoomToPoint as K}from"../utils/navigationUtils.js";import{InteractiveController as q}from"./InteractiveController.js";import{PanPlanarMomentumController as J}from"./momentum/PanPlanarMomentumController.js";import{PanSphericalMomentumController as Y}from"./momentum/PanSphericalMomentumController.js";import{RotationMomentumController as X}from"./momentum/RotationMomentumController.js";import{ZoomPlanarMomentumController as Z}from"./momentum/ZoomPlanarMomentumController.js";import{ZoomSphericalMomentumController as Q}from"./momentum/ZoomSphericalMomentumController.js";let $=class extends q{constructor(e){super(e),this._smoothRotation=new k(.05),this._rotationAxis=p(),this._beginAngle=0,this._beginHeading=0,this._panningPlane=y(),this._beginRadius=0,this._smoothScaling=new k(.05),this._zoomCenterScreen=h(),this._zoomMomentumEstimator=new T,this._rotationMomentumEstimator=new w,this._panSphericalMomentumEstimator=new C,this._panPlanarMomentumEstimator=new S,this._adjustedSphere=new x,this._tmp3d=p(),this._tmpScreenPointArray=h(),this._beginScreenPoint=h(),this._beginScenePoint=p(),this._screenPickPoint=h(),this._scenePickPoint=p(),this._navigationMode=1,this._sphere=new x,this._pointerCount=0,this._tmpInteractionDirection=p(),this._beginCamera=new A,this._constraintOptions=new O(15,0,0,this._beginCamera)}begin(e){if(!this.running)return;this._zoomMomentumEstimator.enabled=this._rotationMomentumEstimator.enabled=this._panPlanarMomentumEstimator.enabled=this._panSphericalMomentumEstimator.enabled=this.view.navigation.momentumEnabled,this._beginHeading=-n.normalize(m(this.view.camera.heading)),this._beginRadius=e.radius,this._beginAngle=e.angle,this._pointerCount=e.pointers.size,this._smoothRotation.reset(),g(e.center,this._screenPickPoint),r(this._beginScreenPoint,this._screenPickPoint);let t=j(this.view,this.startCamera,this._screenPickPoint,_(this.view.spatialReference).radius,1,this.view.groundView.invisible?M:{});t.scenePickPoint!=null&&(this._scenePickPoint=t.scenePickPoint,this._sphere=t.sphere,a(this._beginScenePoint,this._scenePickPoint),this._navigationMode=N(this.startCamera,this._screenPickPoint,this.view.renderCoordsHelper,this.view.state.isGlobal),this._navigationMode===0&&this._preparePlanarPanMode(e,t.hasGeometryIntersection),this._beginCamera.copyFrom(this.startCamera))}update(e){if(!this.running)return;this.currentCamera.copyFrom(this.startCamera);let t=e.pointers.size>1;this._navigationMode===1?(t&&this._zoomSpherical(e),this._panningSpherical(e),t&&this._rotateSpherical(e)):(t&&this._zoomPlanar(e),this._panningPlanar(e),t&&this._rotatePlanar(e)),this.commitCamera()}end(e){e.pointers.size===this._pointerCount&&this.update(e),this.finishController();let t=this.view.animationsEnabled&&this._zoomMomentumEstimator.evaluateMomentum();if(t)return this._navigationMode===1?new Q({view:this.view,momentum:t,screenCenter:this._zoomCenterScreen,sceneCenter:this._beginScenePoint,radius:this._sphere.radius}):new Z({view:this.view,momentum:t,zoomCenter:this._beginScenePoint});let n=this.view.animationsEnabled&&this._rotationMomentumEstimator.evaluateMomentum();if(n)return new X({view:this.view,momentum:n,center:this._sphere.center,axis:this._rotationAxis});if(this._navigationMode===1){let e=this.view.animationsEnabled&&this._panSphericalMomentumEstimator.evaluateMomentum();if(e)return new Y({view:this.view,momentum:e})}else{let e=this.view.animationsEnabled&&this._panPlanarMomentumEstimator.evaluateMomentum();if(e)return new J({view:this.view,momentum:e})}return null}_preparePlanarPanMode(e,t){let n=o(this._tmp3d,this.startCamera.viewForward);b(this._scenePickPoint,n,this._panningPlane);let r=h(this._screenPickPoint[0],0),i=p(),m=s(this.startCamera.eye);this._adjustedSphere.radius=m<this._sphere.radius?m-100:this._sphere.radius,P(this._adjustedSphere,this.startCamera,r,i);let _=p(),v=p(),y=p();c(_,this._scenePickPoint,this.currentCamera.eye);let x=s(_);l(_,_);let S=F*Math.max(Math.abs(this.view.camera.position.z),I),C=this.view.stage.renderView.getMinimalDepthForArea(null,this._screenPickPoint[0],this._screenPickPoint[1],this.view.state.camera,L)??S;t&&(C=Math.min(C,x)),a(y,u(v,this.currentCamera.eye,d(v,_,C))),this._panningPlane[3]=-f(ee(this._panningPlane),y),this.startCamera.center=u(v,this.startCamera.eye,d(v,this.startCamera.viewForward,C));let w=g(e.center,this._tmpScreenPointArray);R(this._panningPlane,this.startCamera,w,this._beginScenePoint)}_zoomSpherical(e){let t=this._beginRadius/e.radius,n=Math.min(Math.max(e.radius,40),120)*.001875;this._smoothScaling.gain=n,this._smoothScaling.update(t),z(this._sphere,this.currentCamera,this._smoothScaling.value),g(e.center,this._zoomCenterScreen),this._zoomMomentumEstimator.add(this._smoothScaling.value,e.timestamp*.001),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=E(e.radius-this._beginRadius),D(this.view,this.currentCamera,this._constraintOptions)}_panningSpherical(e){let t=g(e.center,this._tmpScreenPointArray);P(this._sphere,this.currentCamera,t,this._tmp3d),B(this._beginScenePoint,f(this.currentCamera.up,this._beginScenePoint),this._sphere.radius,this._beginHeading,this.view.camera.tilt,this.startCamera.aboveGround)?(V(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this._beginHeading,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumPreserveHeading(t,this._tmp3d,e.timestamp*.001,this.startCamera,this._sphere,this._beginHeading,this.view.camera.tilt)):(H(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumDirectRotation(t,this._tmp3d,e.timestamp*.001,this.startCamera,this._sphere.radius,this.view.camera.tilt)),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=E(i(this._screenPickPoint,t)),D(this.view,this.currentCamera,this._constraintOptions)}_rotateSpherical(e){l(this._rotationAxis,this._scenePickPoint),this.currentCamera.aboveGround||o(this._rotationAxis,this._rotationAxis);let t=this._smoothRotation.value,n=t+U(e.angle-t),r=Math.min(Math.max(e.radius,40),120)*.00125;this._smoothRotation.gain=r,this._smoothRotation.update(n);let i=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(i,e.timestamp*.001),W(this.currentCamera,this._sphere.center,v(this._rotationAxis,i)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=E(e.radius*n),D(this.view,this.currentCamera,this._constraintOptions)}_panningPlanar(e){let t=g(e.center,this._tmpScreenPointArray);R(this._panningPlane,this.currentCamera,t,this._tmp3d)&&(G(this.currentCamera,this._beginScenePoint,this._tmp3d),this._panPlanarMomentumEstimator.add(t,this._tmp3d,e.timestamp*.001),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=E(i(this._beginScreenPoint,t)),this._constraintOptions.interactionDirection=this.view.renderCoordsHelper.worldUpAtPosition(this.currentCamera.eye,this._tmpInteractionDirection),D(this.view,this.currentCamera,this._constraintOptions),this._constraintOptions.interactionDirection=null)}_zoomPlanar(e){let t=this._beginRadius/e.radius,n=Math.min(Math.max(e.radius,40),120)*.001875;this._smoothScaling.gain=n,this._smoothScaling.update(t),this._zoomMomentumEstimator.add(this._smoothScaling.value,e.timestamp*.001),K(this.currentCamera,this._beginScenePoint,this._smoothScaling.value,this.view.state.constraints.minimumPoiDistance),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=E(e.radius-this._beginRadius),D(this.view,this.currentCamera,this._constraintOptions)}_rotatePlanar(e){a(this._rotationAxis,this._beginScenePoint),this.currentCamera.aboveGround||o(this._rotationAxis,this._rotationAxis);let t=this._smoothRotation.value,n=e.angle-t;n=U(n);let r=t+n,i=Math.min(Math.max(e.radius,40),120)*.00125;this._smoothRotation.gain=i,this._smoothRotation.update(r);let s=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(s,e.timestamp*.001),W(this.currentCamera,this._sphere.center,v(this._rotationAxis,s)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=E(e.radius*s),D(this.view,this.currentCamera,this._constraintOptions)}};$=e([t(`esri.views.3d.state.controllers.PinchAndPanControllerGlobal`)],$);export{$ as PinchAndPanControllerGlobal};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{subclass as t}from"../../../../core/accessorSupport/decorators.js";import{distance as n}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{negate as r,copy as i,dot as a,subtract as o,length as s,normalize as c,scale as l,add as u}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d,fromValues as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{createScreenPointArray as p,screenPointObjectToArray as m}from"../../../../core/screenUtils.js";import{wrapAxisAngle as h}from"../../../../geometry/support/axisAngle.js";import{create as g,fromNormalAndOffset as _,setOffsetFromPoint as v,negate as y,getNormal as b}from"../../../../geometry/support/plane.js";import{PanPlanarMomentumEstimator as x}from"../../../navigation/PanPlanarMomentumEstimator.js";import{RotationMomentumEstimator as S}from"../../../navigation/RotationMomentumEstimator.js";import{ZoomMomentumEstimator as C}from"../../../navigation/ZoomMomentumEstimator.js";import{pixelDistanceToInteractionFactor as w,applyAll as T}from"../../camera/constraintUtils.js";import{ConstraintOptions as E}from"../../camera/constraintUtils/ConstraintOptions.js";import{ExponentialFalloff as D}from"../../input/util.js";import{getVoxelWasm as O}from"../../layers/VoxelWasm.js";import k from"../../webgl/RenderCamera.js";import{inferNavigationMode as A,excludeTerrain as j,getTiltScaleFactor as M,maxPanDistanceModifier as N,minPinchAndPanCameraHeight as P,searchAreaSize as F,centroid as I,applyZoomToPoint as L,applyPanPlanar as R,normalizeRotationDelta as z,applyRotation as B,intersectPlaneFromScreenPointAtEye as V}from"../utils/navigationUtils.js";import{InteractiveController as H}from"./InteractiveController.js";import{PanPlanarMomentumController as U}from"./momentum/PanPlanarMomentumController.js";import{RotationMomentumController as W}from"./momentum/RotationMomentumController.js";import{ZoomPlanarMomentumController as G}from"./momentum/ZoomPlanarMomentumController.js";const K=f(0,0,1);let q=class extends H{constructor(e){super(e),this._rotationValueSmooth=new D(.05),this._scalingValueSmooth=new D(.05),this._planeHorizontal=g(),this._planeVertical=g(),this._rotationMomentumEstimator=new S,this._panMomentumEstimator=new x(300,12,.9),this._zoomMomentumEstimator=new C,this._beginRadius=0,this._beginCenter=d(),this._beginAngle=0,this._tmpPoints=[],this._navigationMode=1,this._beginCenterScreen=p(),this._tmpCentroid3d=d(),this._tmpCentroid2d=p(),this._tmp2d=p(),this._pointerCount=0,this._beginCamera=new k,this._constraintOptions=new E(15,0,0,this._beginCamera)}begin(e){if(!this.running)return;let t=this.view.navigation.momentumEnabled;this._zoomMomentumEstimator.enabled=t,this._rotationMomentumEstimator.enabled=t,this._panMomentumEstimator.enabled=t,this._beginRadius=e.radius,this._pointerCount=e.pointers.size,this._beginAngle=e.angle,this._rotationValueSmooth.reset(),this._scalingValueSmooth.reset(),m(e.center,this._beginCenterScreen),_(K,0,this._planeHorizontal);let n=d();r(n,this.startCamera.viewForward);let f=d();i(f,K);let p=a(n,f);this._navigationMode=A(this.startCamera,this._beginCenterScreen,this.view.renderCoordsHelper,this.view.viewingMode);let h=d(),g=this._intersectionHelper.intersectScreenFreePointFallback(this._beginCenterScreen,h,this.view.groundView.invisible?j:{}),x=M(f,this.startCamera.viewForward,N)*Math.max(Math.abs(this.view.camera.position.z),P);v(this._planeHorizontal,this._planeHorizontal,h),this.startCamera.aboveGround||y(this._planeHorizontal,this._planeHorizontal);let S=d(),C=d(),w=d();o(S,h,this.currentCamera.eye);let T=s(S);if(c(S,S),this._navigationMode===0){l(f,f,p),o(b(this._planeVertical),n,f),c(b(this._planeVertical),b(this._planeVertical)),v(this._planeVertical,this._planeVertical,h);let t=this.view.stage.renderView.getMinimalDepthForArea(O(this.view),this._beginCenterScreen[0],this._beginCenterScreen[1],this.view.state.camera,F)??x;g&&(t=Math.min(t,T)),i(w,u(C,this.currentCamera.eye,l(C,S,t))),this._planeVertical[3]=-a(b(this._planeVertical),w),this._computePlanePoints(e.pointers,this._planeVertical,this.startCamera,this._tmpPoints),I(this._tmpPoints,this._beginCenter)}else{let t=g?T:x;i(w,u(C,this.currentCamera.eye,l(C,S,t))),this._planeHorizontal[3]=-a(b(this._planeHorizontal),w),this._computePlanePoints(e.pointers,this._planeHorizontal,this.startCamera,this._tmpPoints),I(this._tmpPoints,this._beginCenter)}this._beginCamera.copyFrom(this.startCamera)}update(e){if(!this.running)return;this.currentCamera.copyFrom(this.startCamera);let t=e.pointers.size>1,r=this._navigationMode===1?this._planeHorizontal:this._planeVertical,i=this._beginCenter;if(t){let t=this._beginRadius/e.radius,n=Math.min(Math.max(e.radius,40),120)*.001875;this._scalingValueSmooth.gain=n,this._scalingValueSmooth.update(t),L(this.currentCamera,i,this._scalingValueSmooth.value,this.view.state.constraints.minimumPoiDistance),this._zoomMomentumEstimator.add(this._scalingValueSmooth.value,e.timestamp*.001),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=w(Math.abs(e.radius-this._beginRadius)),T(this.view,this.currentCamera,this._constraintOptions)}if(this._computePlanePoints(e.pointers,r,this.currentCamera,this._tmpPoints),I(this._tmpPoints,this._tmpCentroid3d),m(e.center,this._tmpCentroid2d),R(this.currentCamera,i,this._tmpCentroid3d),this._panMomentumEstimator.add(this._tmpCentroid2d,this._tmpCentroid3d,e.timestamp*.001),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=w(n(this._beginCenterScreen,this._tmpCentroid2d)),T(this.view,this.currentCamera,this._constraintOptions),t){let t=i,n=this._rotationValueSmooth.value,r=n+z(e.angle-n),a=Math.min(Math.max(e.radius,40),120)*.00125;this._rotationValueSmooth.gain=a,this._rotationValueSmooth.update(r);let o=this._rotationValueSmooth.value-this._beginAngle;this._rotationMomentumEstimator.add(o,e.timestamp*.001);let s=b(this._planeHorizontal);B(this.currentCamera,t,h(s,o)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=w(Math.abs(e.radius*o)),T(this.view,this.currentCamera,this._constraintOptions)}this.commitCamera()}end(e){e.pointers.size===this._pointerCount&&this.update(e),this.finishController();let t=this.view.animationsEnabled&&this._zoomMomentumEstimator.evaluateMomentum();if(t)return new G({view:this.view,momentum:t,zoomCenter:this._beginCenter});let n=this.view.animationsEnabled&&this._rotationMomentumEstimator.evaluateMomentum();if(n)return new W({view:this.view,momentum:n,center:this._beginCenter,axis:b(this._planeHorizontal)});let r=this.view.animationsEnabled&&this._panMomentumEstimator.evaluateMomentum();return r?new U({view:this.view,momentum:r}):null}_computePlanePoints(e,t,n,r){r.length=e.size;let i=this._tmp2d,a=0;return e.forEach(e=>{i[0]=e.x,i[1]=e.y,r[a]===void 0&&(r[a]=d()),V(t,n,i,r[a]),a+=1}),r}get _intersectionHelper(){return this.view.sceneIntersectionHelper}};q=e([t(`esri.views.3d.state.controllers.PinchAndPanControllerLocal`)],q);export{q as PinchAndPanControllerLocal};
2
+ import{__decorate as e}from"tslib";import{subclass as t}from"../../../../core/accessorSupport/decorators.js";import{distance as n}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{negate as r,copy as i,dot as a,subtract as o,length as s,normalize as c,scale as l,add as u}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d,fromValues as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{createScreenPointArray as p,screenPointObjectToArray as m}from"../../../../core/screenUtils.js";import{wrapAxisAngle as h}from"../../../../geometry/support/axisAngle.js";import{create as g,fromNormalAndOffset as _,setOffsetFromPoint as v,negate as y,getNormal as b}from"../../../../geometry/support/plane.js";import{PanPlanarMomentumEstimator as x}from"../../../navigation/PanPlanarMomentumEstimator.js";import{RotationMomentumEstimator as S}from"../../../navigation/RotationMomentumEstimator.js";import{ZoomMomentumEstimator as C}from"../../../navigation/ZoomMomentumEstimator.js";import{pixelDistanceToInteractionFactor as w,applyAll as T}from"../../camera/constraintUtils.js";import{ConstraintOptions as E}from"../../camera/constraintUtils/ConstraintOptions.js";import{ExponentialFalloff as D}from"../../input/util.js";import{getVoxelWasm as O}from"../../layers/VoxelWasm.js";import k from"../../webgl/RenderCamera.js";import{inferNavigationMode as A,excludeTerrain as j,getTiltScaleFactor as M,maxPanDistanceModifier as N,minPinchAndPanCameraHeight as P,searchAreaSize as F,centroid as I,applyZoomToPoint as L,applyPanPlanar as R,normalizeRotationDelta as z,applyRotation as B,intersectPlaneFromScreenPointAtEye as V}from"../utils/navigationUtils.js";import{InteractiveController as H}from"./InteractiveController.js";import{PanPlanarMomentumController as U}from"./momentum/PanPlanarMomentumController.js";import{RotationMomentumController as W}from"./momentum/RotationMomentumController.js";import{ZoomPlanarMomentumController as G}from"./momentum/ZoomPlanarMomentumController.js";const K=f(0,0,1);let q=class extends H{constructor(e){super(e),this._rotationValueSmooth=new D(.05),this._scalingValueSmooth=new D(.05),this._planeHorizontal=g(),this._planeVertical=g(),this._rotationMomentumEstimator=new S,this._panMomentumEstimator=new x(300,12,.9),this._zoomMomentumEstimator=new C,this._beginRadius=0,this._beginCenter=d(),this._beginAngle=0,this._tmpPoints=[],this._navigationMode=1,this._beginCenterScreen=p(),this._tmpCentroid3d=d(),this._tmpCentroid2d=p(),this._tmp2d=p(),this._pointerCount=0,this._beginCamera=new k,this._constraintOptions=new E(15,0,0,this._beginCamera)}begin(e){if(!this.running)return;let t=this.view.navigation.momentumEnabled;this._zoomMomentumEstimator.enabled=t,this._rotationMomentumEstimator.enabled=t,this._panMomentumEstimator.enabled=t,this._beginRadius=e.radius,this._pointerCount=e.pointers.size,this._beginAngle=e.angle,this._rotationValueSmooth.reset(),this._scalingValueSmooth.reset(),m(e.center,this._beginCenterScreen),_(K,0,this._planeHorizontal);let n=d();r(n,this.startCamera.viewForward);let f=d();i(f,K);let p=a(n,f);this._navigationMode=A(this.startCamera,this._beginCenterScreen,this.view.renderCoordsHelper,this.view.state.isGlobal);let h=d(),g=this._intersectionHelper.intersectScreenFreePointFallback(this._beginCenterScreen,h,this.view.groundView.invisible?j:{}),x=M(f,this.startCamera.viewForward,N)*Math.max(Math.abs(this.view.camera.position.z),P);v(this._planeHorizontal,this._planeHorizontal,h),this.startCamera.aboveGround||y(this._planeHorizontal,this._planeHorizontal);let S=d(),C=d(),w=d();o(S,h,this.currentCamera.eye);let T=s(S);if(c(S,S),this._navigationMode===0){l(f,f,p),o(b(this._planeVertical),n,f),c(b(this._planeVertical),b(this._planeVertical)),v(this._planeVertical,this._planeVertical,h);let t=this.view.stage.renderView.getMinimalDepthForArea(O(this.view),this._beginCenterScreen[0],this._beginCenterScreen[1],this.view.state.camera,F)??x;g&&(t=Math.min(t,T)),i(w,u(C,this.currentCamera.eye,l(C,S,t))),this._planeVertical[3]=-a(b(this._planeVertical),w),this._computePlanePoints(e.pointers,this._planeVertical,this.startCamera,this._tmpPoints),I(this._tmpPoints,this._beginCenter)}else{let t=g?T:x;i(w,u(C,this.currentCamera.eye,l(C,S,t))),this._planeHorizontal[3]=-a(b(this._planeHorizontal),w),this._computePlanePoints(e.pointers,this._planeHorizontal,this.startCamera,this._tmpPoints),I(this._tmpPoints,this._beginCenter)}this._beginCamera.copyFrom(this.startCamera)}update(e){if(!this.running)return;this.currentCamera.copyFrom(this.startCamera);let t=e.pointers.size>1,r=this._navigationMode===1?this._planeHorizontal:this._planeVertical,i=this._beginCenter;if(t){let t=this._beginRadius/e.radius,n=Math.min(Math.max(e.radius,40),120)*.001875;this._scalingValueSmooth.gain=n,this._scalingValueSmooth.update(t),L(this.currentCamera,i,this._scalingValueSmooth.value,this.view.state.constraints.minimumPoiDistance),this._zoomMomentumEstimator.add(this._scalingValueSmooth.value,e.timestamp*.001),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=w(Math.abs(e.radius-this._beginRadius)),T(this.view,this.currentCamera,this._constraintOptions)}if(this._computePlanePoints(e.pointers,r,this.currentCamera,this._tmpPoints),I(this._tmpPoints,this._tmpCentroid3d),m(e.center,this._tmpCentroid2d),R(this.currentCamera,i,this._tmpCentroid3d),this._panMomentumEstimator.add(this._tmpCentroid2d,this._tmpCentroid3d,e.timestamp*.001),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=w(n(this._beginCenterScreen,this._tmpCentroid2d)),T(this.view,this.currentCamera,this._constraintOptions),t){let t=i,n=this._rotationValueSmooth.value,r=n+z(e.angle-n),a=Math.min(Math.max(e.radius,40),120)*.00125;this._rotationValueSmooth.gain=a,this._rotationValueSmooth.update(r);let o=this._rotationValueSmooth.value-this._beginAngle;this._rotationMomentumEstimator.add(o,e.timestamp*.001);let s=b(this._planeHorizontal);B(this.currentCamera,t,h(s,o)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=w(Math.abs(e.radius*o)),T(this.view,this.currentCamera,this._constraintOptions)}this.commitCamera()}end(e){e.pointers.size===this._pointerCount&&this.update(e),this.finishController();let t=this.view.animationsEnabled&&this._zoomMomentumEstimator.evaluateMomentum();if(t)return new G({view:this.view,momentum:t,zoomCenter:this._beginCenter});let n=this.view.animationsEnabled&&this._rotationMomentumEstimator.evaluateMomentum();if(n)return new W({view:this.view,momentum:n,center:this._beginCenter,axis:b(this._planeHorizontal)});let r=this.view.animationsEnabled&&this._panMomentumEstimator.evaluateMomentum();return r?new U({view:this.view,momentum:r}):null}_computePlanePoints(e,t,n,r){r.length=e.size;let i=this._tmp2d,a=0;return e.forEach(e=>{i[0]=e.x,i[1]=e.y,r[a]===void 0&&(r[a]=d()),V(t,n,i,r[a]),a+=1}),r}get _intersectionHelper(){return this.view.sceneIntersectionHelper}};q=e([t(`esri.views.3d.state.controllers.PinchAndPanControllerLocal`)],q);export{q as PinchAndPanControllerLocal};
@@ -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{fromRotation as r,rotate as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{copy as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{exactEquals as c,copy as l,subtract as u,length as d,normalize as f,add as p,scale as m,dot as h,cross as g,transformMat4 as _}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{acosClamped as y,clamp as b}from"../../../../core/mathUtils.js";import{createScreenPointArray as x}from"../../../../core/screenUtils.js";import{applyAll as S}from"../../camera/constraintUtils.js";import{ConstraintOptions as C}from"../../camera/constraintUtils/ConstraintOptions.js";import{getVoxelWasm as w}from"../../layers/VoxelWasm.js";import{TiltRange as T}from"../Constraints.js";import{excludeTerrain as E,normalizeCoordinate as D,getTiltScaleFactor as O,maxRotatePivotDistanceModifier as k,minRotatePivotDistance as A,inferNavigationMode as j,searchAreaSize as M}from"../utils/navigationUtils.js";import{InteractiveController as N}from"./InteractiveController.js";let P=class extends N{get _intersectionHelper(){return this.view.sceneIntersectionHelper}constructor(e){super(e),this.pivot=0,this._rotateScale=3,this._lastPoint=s(),this._tmpWorldUp=v(),this._tmpViewDir=v(),this._tmpRotCurPoint=s(),this._tmpTransf=a(),this._tmpAxis=v(),this._tmpPivotPoint=v(),this._pivotPos=v(),this._constraintOptions=new C(15,2,0,this.startCamera)}begin(e){if(this.running){switch(this.pivot){case 1:l(this._pivotPos,this.startCamera.eye),this._constraintOptions.interactionType=3,this._constraintOptions.tiltMode=1,this._constraintOptions.selection=0;break;case 0:{let t=this._intersectionHelper.intersectRayFreePointFallback(this.startCamera.ray,this._pivotPos,this.view.groundView.invisible?E:{})&&!c(this.startCamera.eye,this._pivotPos);t||l(this._pivotPos,this.startCamera.center),this._constrainPivotPoint(e,t),this.startCamera.center=this._pivotPos,this._constraintOptions.interactionType=2,this._constraintOptions.tiltMode=0,this._constraintOptions.selection=11;break}}D(this.startCamera,e,this._lastPoint)}}_constrainPivotPoint(e,t){let n=this.startCamera,r=v();u(r,this._pivotPos,n.eye);let i=d(r),a=Math.abs(this.view.camera.position.z);this.view.renderCoordsHelper.worldUpAtPosition(n.eye,I);let o=Math.max(O(I,n.viewForward,k)*a,A);t&&(o=Math.min(i,o));let s=x(n.width/n.pixelRatio*.5,n.height/n.pixelRatio*.5),c=j(this.startCamera,s,this.view.renderCoordsHelper,this.view.viewingMode),h=this.view.stage.renderView.getMinimalDepthForArea(w(this.view),n.fullWidth/n.pixelRatio*.5,n.fullHeight/n.pixelRatio*.5,n,M*2.5,M),g=this.view.stage.renderView.getMinimalDepthForArea(w(this.view),e[0],e[1],n,M);(h!=null||g!=null)&&(h=h??g??0,g=g==null||c===1?h:g,o=h>g?g:h,o=t?Math.min(o,i):o),f(r,r),l(this._pivotPos,p(this._tmpPivotPoint,n.eye,m(this._tmpPivotPoint,r,o)))}update(e){if(this.running){switch(this.pivot){case 1:this.currentCamera.center=this._applyRotation(this.currentCamera,e,this.currentCamera.center,this._pivotPos);break;case 0:this.currentCamera.center=this._pivotPos,this.currentCamera.eye=this._applyRotation(this.currentCamera,e,this.currentCamera.eye,this._pivotPos)}S(this.view,this.currentCamera,this._constraintOptions),this.commitCamera()}}end(){this.running&&this.finishController()}_applyRotation(e,t,n,a){this.view.renderCoordsHelper.worldUpAtPosition(a,this._tmpWorldUp),D(e,t,this._tmpRotCurPoint);let s=(this._lastPoint[1]-this._tmpRotCurPoint[1])*this._rotateScale,c=(this._tmpRotCurPoint[0]-this._lastPoint[0])*this._rotateScale;u(this._tmpViewDir,n,a);let l=d(this._tmpViewDir),f=y(h(this._tmpViewDir,this._tmpWorldUp)/l);if(this.pivot===1){s*=-.5;let e=.5*Math.PI-f,t=.5*Math.PI*.99;s=e-Math.max(-t,Math.min(t,e+s))}return s=b(s+f,T.min,T.max)-f,g(this._tmpAxis,e.up,this._tmpViewDir),this.pivot===0&&(c=-c),r(this._tmpTransf,c,this._tmpWorldUp),i(this._tmpTransf,this._tmpTransf,s,this._tmpAxis),_(this._tmpViewDir,this._tmpViewDir,this._tmpTransf),e.up=_(F,e.up,this._tmpTransf),p(F,a,this._tmpViewDir),o(this._lastPoint,this._tmpRotCurPoint),F}};e([t()],P.prototype,`pivot`,void 0),P=e([n(`esri.views.3d.state.controllers.RotateController`)],P);const F=v(),I=v();export{P as RotateController};
2
+ import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{fromRotation as r,rotate as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{copy as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{exactEquals as c,copy as l,subtract as u,length as d,normalize as f,add as p,scale as m,dot as h,cross as g,transformMat4 as _}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{acosClamped as y,clamp as b}from"../../../../core/mathUtils.js";import{createScreenPointArray as x}from"../../../../core/screenUtils.js";import{applyAll as S}from"../../camera/constraintUtils.js";import{ConstraintOptions as C}from"../../camera/constraintUtils/ConstraintOptions.js";import{getVoxelWasm as w}from"../../layers/VoxelWasm.js";import{TiltRange as T}from"../Constraints.js";import{excludeTerrain as E,normalizeCoordinate as D,getTiltScaleFactor as O,maxRotatePivotDistanceModifier as k,minRotatePivotDistance as A,inferNavigationMode as j,searchAreaSize as M}from"../utils/navigationUtils.js";import{InteractiveController as N}from"./InteractiveController.js";let P=class extends N{get _intersectionHelper(){return this.view.sceneIntersectionHelper}constructor(e){super(e),this.pivot=0,this._rotateScale=3,this._lastPoint=s(),this._tmpWorldUp=v(),this._tmpViewDir=v(),this._tmpRotCurPoint=s(),this._tmpTransf=a(),this._tmpAxis=v(),this._tmpPivotPoint=v(),this._pivotPos=v(),this._constraintOptions=new C(15,2,0,this.startCamera)}begin(e){if(this.running){switch(this.pivot){case 1:l(this._pivotPos,this.startCamera.eye),this._constraintOptions.interactionType=3,this._constraintOptions.tiltMode=1,this._constraintOptions.selection=0;break;case 0:{let t=this._intersectionHelper.intersectRayFreePointFallback(this.startCamera.ray,this._pivotPos,this.view.groundView.invisible?E:{})&&!c(this.startCamera.eye,this._pivotPos);t||l(this._pivotPos,this.startCamera.center),this._constrainPivotPoint(e,t),this.startCamera.center=this._pivotPos,this._constraintOptions.interactionType=2,this._constraintOptions.tiltMode=0,this._constraintOptions.selection=11;break}}D(this.startCamera,e,this._lastPoint)}}_constrainPivotPoint(e,t){let n=this.startCamera,r=v();u(r,this._pivotPos,n.eye);let i=d(r),a=Math.abs(this.view.camera.position.z);this.view.renderCoordsHelper.worldUpAtPosition(n.eye,I);let o=Math.max(O(I,n.viewForward,k)*a,A);t&&(o=Math.min(i,o));let s=x(n.width/n.pixelRatio*.5,n.height/n.pixelRatio*.5),c=j(this.startCamera,s,this.view.renderCoordsHelper,this.view.state.isGlobal),h=this.view.stage.renderView.getMinimalDepthForArea(w(this.view),n.fullWidth/n.pixelRatio*.5,n.fullHeight/n.pixelRatio*.5,n,M*2.5,M),g=this.view.stage.renderView.getMinimalDepthForArea(w(this.view),e[0],e[1],n,M);(h!=null||g!=null)&&(h=h??g??0,g=g==null||c===1?h:g,o=h>g?g:h,o=t?Math.min(o,i):o),f(r,r),l(this._pivotPos,p(this._tmpPivotPoint,n.eye,m(this._tmpPivotPoint,r,o)))}update(e){if(this.running){switch(this.pivot){case 1:this.currentCamera.center=this._applyRotation(this.currentCamera,e,this.currentCamera.center,this._pivotPos);break;case 0:this.currentCamera.center=this._pivotPos,this.currentCamera.eye=this._applyRotation(this.currentCamera,e,this.currentCamera.eye,this._pivotPos)}S(this.view,this.currentCamera,this._constraintOptions),this.commitCamera()}}end(){this.running&&this.finishController()}_applyRotation(e,t,n,a){this.view.renderCoordsHelper.worldUpAtPosition(a,this._tmpWorldUp),D(e,t,this._tmpRotCurPoint);let s=(this._lastPoint[1]-this._tmpRotCurPoint[1])*this._rotateScale,c=(this._tmpRotCurPoint[0]-this._lastPoint[0])*this._rotateScale;u(this._tmpViewDir,n,a);let l=d(this._tmpViewDir),f=y(h(this._tmpViewDir,this._tmpWorldUp)/l);if(this.pivot===1){s*=-.5;let e=.5*Math.PI-f,t=.5*Math.PI*.99;s=e-Math.max(-t,Math.min(t,e+s))}return s=b(s+f,T.min,T.max)-f,g(this._tmpAxis,e.up,this._tmpViewDir),this.pivot===0&&(c=-c),r(this._tmpTransf,c,this._tmpWorldUp),i(this._tmpTransf,this._tmpTransf,s,this._tmpAxis),_(this._tmpViewDir,this._tmpViewDir,this._tmpTransf),e.up=_(F,e.up,this._tmpTransf),p(F,a,this._tmpViewDir),o(this._lastPoint,this._tmpRotCurPoint),F}};e([t()],P.prototype,`pivot`,void 0),P=e([n(`esri.views.3d.state.controllers.RotateController`)],P);const F=v(),I=v();export{P as RotateController};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{subclass as t}from"../../../../core/accessorSupport/decorators.js";import{copy as n,distance as r}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{normalize as a,subtract as o,length as s,scale as c,add as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{clamp as d}from"../../../../core/mathUtils.js";import{createScreenPointArray as f}from"../../../../core/screenUtils.js";import{getReferenceEllipsoid as p}from"../../../../geometry/ellipsoidUtils.js";import{create as m,fromPoints as h}from"../../../../geometry/support/axisAngle.js";import{Sphere as g}from"../../../../geometry/support/sphere.js";import{pixelDistanceToInteractionFactor as _,applyAll as v}from"../../camera/constraintUtils.js";import{ConstraintOptions as y}from"../../camera/constraintUtils/ConstraintOptions.js";import{applySurfaceCollisionConstraint as b}from"../../camera/constraintUtils/surfaceCollision.js";import{fromScreenAtEye as x}from"../../support/geometryUtils/ray.js";import{normalizeCoordinate as S,pickPointAndInitSphere as C,excludeTerrain as w,inferNavigationMode as T,zoomPivotDistanceClamp as E,getTiltScaleFactor as D,searchAreaSize as O,distanceComparisonTolerance as k,sphereOrPlanePointFromScreenPoint as A,applyRotation as j,maxZoomPivotDistanceModifier as M}from"../utils/navigationUtils.js";import{InteractiveController as N}from"./InteractiveController.js";let P=class extends N{constructor(){super(...arguments),this._pickPoint=u(),this._tmpP0=i(),this._panAxisAngle=m(),this._tmpRayDir=u(),this._tmpRayDirPick=u(),this._targetOnSphere=u(),this._navigationMode=1,this._tmpRay={origin:u(),direction:u()},this.dragBeginPoint=f(),this._normalizedAnchorPoint=i(),this._constraintOptions=new y(7,1,0,this.startCamera),this._sphere=new g,this._hasPickPoint=!1}begin(e){if(!this.running)return;n(this.dragBeginPoint,e),S(this.startCamera,e,this._normalizedAnchorPoint);let t=p(this.view.spatialReference),r=C(this.view,this.startCamera,e,t.radius,0,this.view.groundView.invisible?w:{});if(this._navigationMode=T(this.startCamera,e,this.view.renderCoordsHelper,this.view.viewingMode),this._navigationMode===1)this._hasPickPoint=!!r.scenePickPoint,this._pickPoint=r.scenePickPoint??this._pickPoint,this._sphere=r.sphere;else{x(this.startCamera,e,this._tmpRay),a(this._tmpRay.direction,this._tmpRay.direction);let t;r.scenePickPoint!=null&&(o(this._tmpRayDirPick,this.startCamera.eye,r.scenePickPoint),t=s(this._tmpRayDirPick));let n=Math.abs(this.view.camera.position.z);this.view.renderCoordsHelper.worldUpAtPosition(this.startCamera.eye,I);let i=d(D(I,this._tmpRay.direction,M)*n,E[0],E[1]),u=this.view.stage.renderView.getMinimalDepthForArea(null,e[0],e[1],this.view.state.camera,O)??i;t!=null&&(u=Math.min(u,t)),this._hasPickPoint=!0,c(this._tmpRay.direction,this._tmpRay.direction,u),l(this._pickPoint,this._tmpRay.origin,this._tmpRay.direction)}}update(e){if(this.running){if(this.currentCamera.eye=this.startCamera.eye,this.currentCamera.center=this.startCamera.center,this.currentCamera.up=this.startCamera.up,this._navigationMode===1){o(this._tmpRayDir,this.currentCamera.center,this.currentCamera.eye);let t=s(this._tmpRayDir);S(this.currentCamera,e,this._tmpP0);let n=(this._normalizedAnchorPoint[1]-this._tmpP0[1])*12,i=t*2**n,a=this.view.state.constraints.minimumPoiDistance;if(n<0&&i<a&&(i=a),Math.abs(t-i)<k)return;if(this._hasPickPoint&&i<t){let e=1-(1-i/t)*(1-this._sphere.radius/s(this.currentCamera.center));this.currentCamera.center=c(F,this.currentCamera.center,e)}c(this._tmpRayDir,this._tmpRayDir,-i/t),this.currentCamera.eye=l(F,this.currentCamera.center,this._tmpRayDir),this._constraintOptions.interactionFactor=_(r(this.dragBeginPoint,e)),v(this.view,this.currentCamera,this._constraintOptions),this._hasPickPoint&&(A(this._sphere,this.currentCamera,this.dragBeginPoint,this._targetOnSphere),h(this._pickPoint,this._targetOnSphere,this._panAxisAngle),j(this.currentCamera,this._sphere.center,this._panAxisAngle))}else{let t=s(this._tmpRay.direction);S(this.currentCamera,e,this._tmpP0);let n=(this._normalizedAnchorPoint[1]-this._tmpP0[1])*12,r=t*2**n,i=this.view.state.constraints.minimumPoiDistance;if(n<0&&r<i&&(r=i),Math.abs(t-r)<k)return;c(this._tmpRayDir,this._tmpRay.direction,1-r/t),this.currentCamera.eye=l(F,this.currentCamera.eye,this._tmpRayDir),this.currentCamera.center=l(F,this.currentCamera.center,this._tmpRayDir),a(this._tmpRayDir,this._tmpRayDir),this._constraintOptions.interactionDirection=this._tmpRayDir,v(this.view,this.currentCamera,this._constraintOptions),this._constraintOptions.interactionDirection=null}b(this.view,null,this.currentCamera),this.commitCamera()}}finish(){this.running&&this.finishController()}};P=e([t(`esri.views.3d.state.controllers.ZoomControllerGlobal`)],P);const F=u(),I=u();export{P as ZoomControllerGlobal};
2
+ import{__decorate as e}from"tslib";import{subclass as t}from"../../../../core/accessorSupport/decorators.js";import{copy as n,distance as r}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{normalize as a,subtract as o,length as s,scale as c,add as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{clamp as d}from"../../../../core/mathUtils.js";import{createScreenPointArray as f}from"../../../../core/screenUtils.js";import{getReferenceEllipsoid as p}from"../../../../geometry/ellipsoidUtils.js";import{create as m,fromPoints as h}from"../../../../geometry/support/axisAngle.js";import{Sphere as g}from"../../../../geometry/support/sphere.js";import{pixelDistanceToInteractionFactor as _,applyAll as v}from"../../camera/constraintUtils.js";import{ConstraintOptions as y}from"../../camera/constraintUtils/ConstraintOptions.js";import{applySurfaceCollisionConstraint as b}from"../../camera/constraintUtils/surfaceCollision.js";import{fromScreenAtEye as x}from"../../support/geometryUtils/ray.js";import{normalizeCoordinate as S,pickPointAndInitSphere as C,excludeTerrain as w,inferNavigationMode as T,zoomPivotDistanceClamp as E,getTiltScaleFactor as D,searchAreaSize as O,distanceComparisonTolerance as k,sphereOrPlanePointFromScreenPoint as A,applyRotation as j,maxZoomPivotDistanceModifier as M}from"../utils/navigationUtils.js";import{InteractiveController as N}from"./InteractiveController.js";let P=class extends N{constructor(){super(...arguments),this._pickPoint=u(),this._tmpP0=i(),this._panAxisAngle=m(),this._tmpRayDir=u(),this._tmpRayDirPick=u(),this._targetOnSphere=u(),this._navigationMode=1,this._tmpRay={origin:u(),direction:u()},this.dragBeginPoint=f(),this._normalizedAnchorPoint=i(),this._constraintOptions=new y(7,1,0,this.startCamera),this._sphere=new g,this._hasPickPoint=!1}begin(e){if(!this.running)return;n(this.dragBeginPoint,e),S(this.startCamera,e,this._normalizedAnchorPoint);let t=p(this.view.spatialReference),r=C(this.view,this.startCamera,e,t.radius,0,this.view.groundView.invisible?w:{});if(this._navigationMode=T(this.startCamera,e,this.view.renderCoordsHelper,this.view.state.isGlobal),this._navigationMode===1)this._hasPickPoint=!!r.scenePickPoint,this._pickPoint=r.scenePickPoint??this._pickPoint,this._sphere=r.sphere;else{x(this.startCamera,e,this._tmpRay),a(this._tmpRay.direction,this._tmpRay.direction);let t;r.scenePickPoint!=null&&(o(this._tmpRayDirPick,this.startCamera.eye,r.scenePickPoint),t=s(this._tmpRayDirPick));let n=Math.abs(this.view.camera.position.z);this.view.renderCoordsHelper.worldUpAtPosition(this.startCamera.eye,I);let i=d(D(I,this._tmpRay.direction,M)*n,E[0],E[1]),u=this.view.stage.renderView.getMinimalDepthForArea(null,e[0],e[1],this.view.state.camera,O)??i;t!=null&&(u=Math.min(u,t)),this._hasPickPoint=!0,c(this._tmpRay.direction,this._tmpRay.direction,u),l(this._pickPoint,this._tmpRay.origin,this._tmpRay.direction)}}update(e){if(this.running){if(this.currentCamera.eye=this.startCamera.eye,this.currentCamera.center=this.startCamera.center,this.currentCamera.up=this.startCamera.up,this._navigationMode===1){o(this._tmpRayDir,this.currentCamera.center,this.currentCamera.eye);let t=s(this._tmpRayDir);S(this.currentCamera,e,this._tmpP0);let n=(this._normalizedAnchorPoint[1]-this._tmpP0[1])*12,i=t*2**n,a=this.view.state.constraints.minimumPoiDistance;if(n<0&&i<a&&(i=a),Math.abs(t-i)<k)return;if(this._hasPickPoint&&i<t){let e=1-(1-i/t)*(1-this._sphere.radius/s(this.currentCamera.center));this.currentCamera.center=c(F,this.currentCamera.center,e)}c(this._tmpRayDir,this._tmpRayDir,-i/t),this.currentCamera.eye=l(F,this.currentCamera.center,this._tmpRayDir),this._constraintOptions.interactionFactor=_(r(this.dragBeginPoint,e)),v(this.view,this.currentCamera,this._constraintOptions),this._hasPickPoint&&(A(this._sphere,this.currentCamera,this.dragBeginPoint,this._targetOnSphere),h(this._pickPoint,this._targetOnSphere,this._panAxisAngle),j(this.currentCamera,this._sphere.center,this._panAxisAngle))}else{let t=s(this._tmpRay.direction);S(this.currentCamera,e,this._tmpP0);let n=(this._normalizedAnchorPoint[1]-this._tmpP0[1])*12,r=t*2**n,i=this.view.state.constraints.minimumPoiDistance;if(n<0&&r<i&&(r=i),Math.abs(t-r)<k)return;c(this._tmpRayDir,this._tmpRay.direction,1-r/t),this.currentCamera.eye=l(F,this.currentCamera.eye,this._tmpRayDir),this.currentCamera.center=l(F,this.currentCamera.center,this._tmpRayDir),a(this._tmpRayDir,this._tmpRayDir),this._constraintOptions.interactionDirection=this._tmpRayDir,v(this.view,this.currentCamera,this._constraintOptions),this._constraintOptions.interactionDirection=null}b(this.view,null,this.currentCamera),this.commitCamera()}}finish(){this.running&&this.finishController()}};P=e([t(`esri.views.3d.state.controllers.ZoomControllerGlobal`)],P);const F=u(),I=u();export{P as ZoomControllerGlobal};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{subclass as t}from"../../../../core/accessorSupport/decorators.js";import{copy as n,squaredDistance as r,normalize as i,scale as a,length as o,subtract as s,add as c}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{clamp as u}from"../../../../core/mathUtils.js";import{Milliseconds as d}from"../../../../core/time.js";import{getReferenceEllipsoid as f}from"../../../../geometry/ellipsoidUtils.js";import{create as p}from"../../../../geometry/support/ray.js";import{Sphere as m}from"../../../../geometry/support/sphere.js";import{outExpo as h}from"../../../animation/easing.js";import{applyAll as g}from"../../camera/constraintUtils.js";import{ConstraintOptions as _}from"../../camera/constraintUtils/ConstraintOptions.js";import{applySurfaceCollisionConstraint as v}from"../../camera/constraintUtils/surfaceCollision.js";import{fromScreenAtEye as y}from"../../support/geometryUtils/ray.js";import{intersectScreen as b}from"../../support/geometryUtils/sphere.js";import{Intersector as x}from"../../webgl-engine/lib/Intersector.js";import S from"../../webgl/RenderCamera.js";import{excludeTerrain as C,isHitOnSamePlanetSide as w,inferNavigationMode as T,zoomStepDistanceClamp as E,getTiltScaleFactor as D,maxZoomStepDistanceModifier as O,distanceComparisonTolerance as k,panToPosition as A}from"../utils/navigationUtils.js";import{PointToPointAnimationController as j}from"./PointToPointAnimationController.js";const M=.6;let N=class extends j{constructor(){super(...arguments),this._zoomLocation=l(),this._tmpCamera=new S,this._tmpViewDir=l(),this._tmpRayDir=p(),this._targetOnSphere=l(),this._tmpCenter=l(),this._beginCamera=new S,this._constraintOptions=new _(7,1,null,this._beginCamera),this._sphere=new m}initialize(){this._intersector=new x(this.view.state.isGlobal)}step(e,t){if(!this.running)return;let r=this.view.state;this.animation.finished?this._beginCamera.copyFrom(r.camera):this.animation.cameraAt(1,this._beginCamera);let i=!1,a=!1;this._intersectionHelper.intersectScreen(t,this._zoomLocation,this.view.map.ground.opacity===0?C:{})&&w(r.camera.eye,this._zoomLocation,f(this.view.spatialReference).radius)&&(i=e>0,a=!0),this._tmpCamera.copyFrom(r.camera),i?this._intersectsValidTarget(this._tmpCamera,this._tmpCenter)&&(this._tmpCamera.center=this._tmpCenter):this._intersectsValidTarget(this._tmpCamera,this._zoomLocation)?this._tmpCamera.center=this._zoomLocation:n(this._zoomLocation,this._tmpCamera.center),this._updateCamera(this._tmpCamera,e,t,a),this.begin(this._tmpCamera)}_intersectsValidTarget(e,t){return this._intersectionHelper.intersectRay(e.ray,this._intersector,t)?r(e.eye,t)>=16:!1}animationSettings(){return{duration:d(600),easing:h}}_updateCamera(e,t,n,l){let d=T(e,n,this.view.renderCoordsHelper,this.view.viewingMode),f=Math.abs(this.view.camera.position.z),p=this._zoomLocation;i(F,e.eye),a(F,F,-1),y(e,n,this._tmpRayDir),i(this._tmpRayDir.direction,this._tmpRayDir.direction);let m=u(D(F,this._tmpRayDir.direction,O)*f,E[0],E[1]);if(d===1){let i=M**t;this._sphere.radius=o(p),s(this._tmpViewDir,e.center,e.eye);let l=Math.min(o(this._tmpViewDir),m),u=l*i;if(i<=1&&u<4&&(u=4,i=u/l),Math.abs(l-u)<k)return;let d=o(e.center);if(this._sphere.radius!==d){let t=this._sphere.radius+i*(d-this._sphere.radius);e.center=a(P,e.center,t/d)}a(this._tmpViewDir,this._tmpViewDir,-i),e.eye=c(P,e.center,this._tmpViewDir),g(this.view,e,this._constraintOptions),r(p,e.center)>1e-12&&b(this._sphere,e,n,this._targetOnSphere)&&A(this._sphere,e,p,this._targetOnSphere,this.view.camera.heading,this.view.camera.tilt,!0)}else{let r=M**Math.abs(t),u=t>0?1:-1;s(this._tmpViewDir,p,e.eye);let d=o(this._tmpViewDir),f=this.view.stage.renderView.getMinimalDepthForArea(null,n[0],n[1],this.view.state.camera,60)??m;l&&t>0&&(f=Math.min(f,d)),a(this._tmpRayDir.direction,this._tmpRayDir.direction,f),c(p,this._tmpRayDir.origin,this._tmpRayDir.direction);let h=f*r,_=Math.max(4,e.nearFar[0]*1.01);if(t>0&&h<_&&(h=_,r=h/f),Math.abs(f-h)<k)return;a(this._tmpRayDir.direction,this._tmpRayDir.direction,u*(1-r)),e.eye=c(P,e.eye,this._tmpRayDir.direction),e.center=c(P,e.center,this._tmpRayDir.direction),i(this._tmpRayDir.direction,this._tmpRayDir.direction),this._constraintOptions.interactionDirection=this._tmpRayDir.direction,g(this.view,e,this._constraintOptions),this._constraintOptions.interactionDirection=null}v(this.view,null,e)}};N=e([t(`esri.views.3d.state.controllers.ZoomStepControllerGlobal`)],N);const P=l(),F=l();export{N as ZoomStepControllerGlobal};
2
+ import{__decorate as e}from"tslib";import{subclass as t}from"../../../../core/accessorSupport/decorators.js";import{copy as n,squaredDistance as r,normalize as i,scale as a,length as o,subtract as s,add as c}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{clamp as u}from"../../../../core/mathUtils.js";import{Milliseconds as d}from"../../../../core/time.js";import{getReferenceEllipsoid as f}from"../../../../geometry/ellipsoidUtils.js";import{create as p}from"../../../../geometry/support/ray.js";import{Sphere as m}from"../../../../geometry/support/sphere.js";import{outExpo as h}from"../../../animation/easing.js";import{applyAll as g}from"../../camera/constraintUtils.js";import{ConstraintOptions as _}from"../../camera/constraintUtils/ConstraintOptions.js";import{applySurfaceCollisionConstraint as v}from"../../camera/constraintUtils/surfaceCollision.js";import{fromScreenAtEye as y}from"../../support/geometryUtils/ray.js";import{intersectScreen as b}from"../../support/geometryUtils/sphere.js";import{Intersector as x}from"../../webgl-engine/lib/Intersector.js";import S from"../../webgl/RenderCamera.js";import{excludeTerrain as C,isHitOnSamePlanetSide as w,inferNavigationMode as T,zoomStepDistanceClamp as E,getTiltScaleFactor as D,maxZoomStepDistanceModifier as O,distanceComparisonTolerance as k,panToPosition as A}from"../utils/navigationUtils.js";import{PointToPointAnimationController as j}from"./PointToPointAnimationController.js";const M=.6;let N=class extends j{constructor(){super(...arguments),this._zoomLocation=l(),this._tmpCamera=new S,this._tmpViewDir=l(),this._tmpRayDir=p(),this._targetOnSphere=l(),this._tmpCenter=l(),this._beginCamera=new S,this._constraintOptions=new _(7,1,null,this._beginCamera),this._sphere=new m}initialize(){this._intersector=new x(this.view.state.isGlobal)}step(e,t){if(!this.running)return;let r=this.view.state;this.animation.finished?this._beginCamera.copyFrom(r.camera):this.animation.cameraAt(1,this._beginCamera);let i=!1,a=!1;this._intersectionHelper.intersectScreen(t,this._zoomLocation,this.view.map.ground.opacity===0?C:{})&&w(r.camera.eye,this._zoomLocation,f(this.view.spatialReference).radius)&&(i=e>0,a=!0),this._tmpCamera.copyFrom(r.camera),i?this._intersectsValidTarget(this._tmpCamera,this._tmpCenter)&&(this._tmpCamera.center=this._tmpCenter):this._intersectsValidTarget(this._tmpCamera,this._zoomLocation)?this._tmpCamera.center=this._zoomLocation:n(this._zoomLocation,this._tmpCamera.center),this._updateCamera(this._tmpCamera,e,t,a),this.begin(this._tmpCamera)}_intersectsValidTarget(e,t){return this._intersectionHelper.intersectRay(e.ray,this._intersector,t)?r(e.eye,t)>=16:!1}animationSettings(){return{duration:d(600),easing:h}}_updateCamera(e,t,n,l){let d=T(e,n,this.view.renderCoordsHelper,this.view.state.isGlobal),f=Math.abs(this.view.camera.position.z),p=this._zoomLocation;i(F,e.eye),a(F,F,-1),y(e,n,this._tmpRayDir),i(this._tmpRayDir.direction,this._tmpRayDir.direction);let m=u(D(F,this._tmpRayDir.direction,O)*f,E[0],E[1]);if(d===1){let i=M**t;this._sphere.radius=o(p),s(this._tmpViewDir,e.center,e.eye);let l=Math.min(o(this._tmpViewDir),m),u=l*i;if(i<=1&&u<4&&(u=4,i=u/l),Math.abs(l-u)<k)return;let d=o(e.center);if(this._sphere.radius!==d){let t=this._sphere.radius+i*(d-this._sphere.radius);e.center=a(P,e.center,t/d)}a(this._tmpViewDir,this._tmpViewDir,-i),e.eye=c(P,e.center,this._tmpViewDir),g(this.view,e,this._constraintOptions),r(p,e.center)>1e-12&&b(this._sphere,e,n,this._targetOnSphere)&&A(this._sphere,e,p,this._targetOnSphere,this.view.camera.heading,this.view.camera.tilt,!0)}else{let r=M**Math.abs(t),u=t>0?1:-1;s(this._tmpViewDir,p,e.eye);let d=o(this._tmpViewDir),f=this.view.stage.renderView.getMinimalDepthForArea(null,n[0],n[1],this.view.state.camera,60)??m;l&&t>0&&(f=Math.min(f,d)),a(this._tmpRayDir.direction,this._tmpRayDir.direction,f),c(p,this._tmpRayDir.origin,this._tmpRayDir.direction);let h=f*r,_=Math.max(4,e.nearFar[0]*1.01);if(t>0&&h<_&&(h=_,r=h/f),Math.abs(f-h)<k)return;a(this._tmpRayDir.direction,this._tmpRayDir.direction,u*(1-r)),e.eye=c(P,e.eye,this._tmpRayDir.direction),e.center=c(P,e.center,this._tmpRayDir.direction),i(this._tmpRayDir.direction,this._tmpRayDir.direction),this._constraintOptions.interactionDirection=this._tmpRayDir.direction,g(this.view,e,this._constraintOptions),this._constraintOptions.interactionDirection=null}v(this.view,null,e)}};N=e([t(`esri.views.3d.state.controllers.ZoomStepControllerGlobal`)],N);const P=l(),F=l();export{N as ZoomStepControllerGlobal};