@arcgis/core 6.0.0-next.23 → 6.0.0-next.25

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 (237) hide show
  1. package/Graphic.d.ts +47 -14
  2. package/PopupTemplate.js +1 -1
  3. package/WebScene.d.ts +3 -0
  4. package/arcade/functions/string.js +1 -1
  5. package/assets/esri/core/workers/RemoteClient.js +1 -1
  6. package/assets/esri/core/workers/chunks/{db9921fbda556f142c4a.js → 04d55ed51e8b2683c4b4.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{435b90168f79c5587a07.js → 04ecf15524ff3838c01c.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{e2f42aec02bff33b25dd.js → 09300e74e5b014ce6269.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{fcb86d24fc7e0666b564.js → 096b2bf1c0d69d27f20c.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{612345f17f5eeb99ea8f.js → 0d9c4c6c571ce26d356b.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{0f725cf79ce00e790a7d.js → 1168bc5c9f0a7e1f63a2.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{12a7997a40c77f5c9160.js → 151e5799ede763a03ee2.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{a64446a3328a7323e307.js → 173f89c55a5c79ff065b.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{8715661a838361d4211a.js → 1b24a40c0fa197014873.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{ca0d4ce453d8eb35467d.js → 277263466837e1673f56.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{b1d989b72203113a06fe.js → 2a36fe3f3f257a779a1b.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{ffcb99693182a621a93e.js → 2cf8172be83b10b11bdc.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{fcaf9450642fcef83286.js → 3048e74e6246324ce6fc.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{95b82cbbe355266c65d7.js → 30af63b3b750142faadb.js} +1 -1
  20. package/assets/esri/core/workers/chunks/30dcf2cfb31cb70de7df.js +1 -0
  21. package/assets/esri/core/workers/chunks/{9f0a973a0dd28953ce25.js → 371e2ddb88cc6b9a41e8.js} +1 -1
  22. package/assets/esri/core/workers/chunks/3fd5c3cd8457ddc68798.js +1 -0
  23. package/assets/esri/core/workers/chunks/{62fec1816907f070f079.js → 3fe04f13215474accb09.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{f47fe4433b05fca5c3ad.js → 42f6194633c2d879c8da.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{cddc3e285f763ccf33c2.js → 4869e097261ded90b8bb.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{d8a7eba588d374b2f961.js → 4bb9a5f4ca944d3fc206.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{8052da8be251c3ff2176.js → 4d93bed14945e3d34d5c.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{65cb5e39c467a35621ca.js → 56e903ccef66cbe18f92.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{44d5508042cacdfcac47.js → 58da3f8cf0f7f6a7e4fa.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{bc915fb182d463d804e6.js → 5c04835b0b52461183cd.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{7e8611cb709f105946f5.js → 6061232c96e11eb7b25d.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{1e514e1c9aabefa04201.js → 64382363d6dc04ff1eac.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{c82daefb193aae895bc0.js → 67e06d606c7fd2064adf.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{434a8ba841a59e0deab9.js → 67e533748435253aaba6.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{feb41abc03d677df6f73.js → 6b9961261241fdce0e94.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{949bee7b304e625a7891.js → 6db0f8fe1402643fbe1a.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{96c4ea9cfa3930f1c3fb.js → 6f1d6453184e0a1530ad.js} +1 -1
  38. package/assets/esri/core/workers/chunks/6f897b4e7ddd1dd1672b.js +1 -0
  39. package/assets/esri/core/workers/chunks/{0049b66ccbfb168caa76.js → 7124ad8dc5ad40dc66f3.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{6e107ce73633de8ac257.js → 72f4dad65e16a7d7c58f.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{0df9a906f7823c23d426.js → 7566321c6a2913f2852b.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{c4ddac23bd649d24f3f2.js → 75d551a449bba61ce238.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{af349c7bc8ef41a0e1bd.js → 7748c2886d0122b40eeb.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{b4c3ec081874b49ff89b.js → 78fbe330f16bdbdb886e.js} +1 -1
  45. package/assets/esri/core/workers/chunks/79483c05867ba1386f5a.js +1 -0
  46. package/assets/esri/core/workers/chunks/7b482afb9fd1229f5707.js +1 -0
  47. package/assets/esri/core/workers/chunks/7c631e2947243e2c9bde.js +1 -0
  48. package/assets/esri/core/workers/chunks/7db9e615e60d824eac1b.js +1 -0
  49. package/assets/esri/core/workers/chunks/{8a7b02037151767542f1.js → 7dbf4c7480bf9c72820d.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{64b360625c68cb863a08.js → 84940d8e14caf5a27e04.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{1b1d3f6916d2cb751435.js → 87177e0f82e8a6ae3189.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{5cb26bbaa08114aec5ce.js → 89cc1a5539b82fb46216.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{9d40786c5ceface786ba.js → 8a485130781b49dbf608.js} +1 -1
  54. package/assets/esri/core/workers/chunks/8b5dcc4282772bf6b675.js +1 -0
  55. package/assets/esri/core/workers/chunks/{8c12269d26f5a4c753cb.js → 8ebaf5754e86a45b0497.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{542e5640ea1b80ef801a.js → 9189dfe19a2a2ccd5173.js} +1 -1
  57. package/assets/esri/core/workers/chunks/{67a35155b8b4d36f171e.js → 926e0a3827eaf16ca8b4.js} +1 -1
  58. package/assets/esri/core/workers/chunks/{dc1761cba0454fda3cf9.js → 9630234267098115de4d.js} +1 -1
  59. package/assets/esri/core/workers/chunks/{10d80e793019dfb45ca2.js → 987424121cf30b0f3c50.js} +1 -1
  60. package/assets/esri/core/workers/chunks/9afc87474cef1fc4fe4a.js +1 -0
  61. package/assets/esri/core/workers/chunks/{facd1ff23203fed67686.js → 9b048f80c2d28d527373.js} +1 -1
  62. package/assets/esri/core/workers/chunks/9dd48e75b4e8d9811d81.js +1 -0
  63. package/assets/esri/core/workers/chunks/{ee08ae5b73439a1ff666.js → a163c6005aba3378edaa.js} +1 -1
  64. package/assets/esri/core/workers/chunks/{517106048980a3cbe072.js → a4b822ee45810c4c292a.js} +1 -1
  65. package/assets/esri/core/workers/chunks/{092e311cb7aea92a6a26.js → acb265a22be5e12f38e5.js} +1 -1
  66. package/assets/esri/core/workers/chunks/{1a411ddae7a47015370c.js → acf4737ba509cbd73cce.js} +1 -1
  67. package/assets/esri/core/workers/chunks/{d247dd53788d512b9c9f.js → af3c6794334626b94f00.js} +1 -1
  68. package/assets/esri/core/workers/chunks/{532e9cda8ac3601d8892.js → b12acf1f694f82e00df9.js} +1 -1
  69. package/assets/esri/core/workers/chunks/{636cd05abfbdff19029e.js → ba3d5abff65aefcb8dee.js} +1 -1
  70. package/assets/esri/core/workers/chunks/{504184828048310a052c.js → bdc221d94300c225665a.js} +1 -1
  71. package/assets/esri/core/workers/chunks/c0eb27263f608dc3684b.js +1 -0
  72. package/assets/esri/core/workers/chunks/c2318c014e97ba519be8.js +1 -0
  73. package/assets/esri/core/workers/chunks/{7f8e327acad48c9e75ea.js → c62237c344e341619341.js} +1 -1
  74. package/assets/esri/core/workers/chunks/{a2ad3e620c98e2b2eb06.js → cd355baab983033c3ef0.js} +1 -1
  75. package/assets/esri/core/workers/chunks/{7be6d621a0d1e33dfff4.js → d070fcb73ce274ab80e4.js} +1 -1
  76. package/assets/esri/core/workers/chunks/{6d41444b46677aa762a7.js → db41490bd39d863305bf.js} +1 -1
  77. package/assets/esri/core/workers/chunks/{fc5a36e54929e03efa86.js → dba5f44c4e4a3f075df2.js} +1 -1
  78. package/assets/esri/core/workers/chunks/{3e30b96a8c75bd5b9ae2.js → ddc95cdac6c06fc4794c.js} +1 -1
  79. package/assets/esri/core/workers/chunks/{a5c8f9f5be4ef5063b42.js → df26ec0b508cf4716e0a.js} +1 -1
  80. package/assets/esri/core/workers/chunks/{f426da2210888cc264b4.js → e83f9abee611c5b80009.js} +1 -1
  81. package/assets/esri/core/workers/chunks/{8487727f1197cf7dbf50.js → ef12fa3574d4cbf8b084.js} +1 -1
  82. package/assets/esri/core/workers/chunks/f10c883eb26330e3421c.js +1 -0
  83. package/assets/esri/core/workers/chunks/f46e92c67986c8c09bdd.js +1 -0
  84. package/assets/esri/core/workers/chunks/{709e019885822b1f6f3e.js → f905f1a1aa4c123cbe83.js} +1 -1
  85. package/assets/esri/core/workers/chunks/{5b91e2dffdc84c006539.js → fb37f0848196c28b7fd7.js} +1 -1
  86. package/assets/esri/libs/librust-parquet/pkg/parquet_bg.wasm +0 -0
  87. package/assets/esri/libs/librust-text/pkg/text_bg.wasm +0 -0
  88. package/chunks/MultiPathImpl.js +1 -1
  89. package/chunks/OperatorProximityGeodesic.js +1 -1
  90. package/chunks/basis_encoder.js +1 -1
  91. package/chunks/basis_transcoder.js +1 -1
  92. package/chunks/draco_mesh_decoder.js +1 -1
  93. package/chunks/dxt_encoder.js +1 -1
  94. package/chunks/i3s.js +1 -1
  95. package/chunks/lclayout.js +1 -1
  96. package/chunks/lerc-wasm.js +1 -1
  97. package/chunks/libtess-f32.js +1 -1
  98. package/chunks/libtess-f64.js +1 -1
  99. package/chunks/lyr3DMain.js +1 -1
  100. package/chunks/lyr3DWorker.js +1 -1
  101. package/chunks/parquet.js +1 -1
  102. package/chunks/qb3-wasm.js +1 -1
  103. package/chunks/rbush.js +1 -1
  104. package/chunks/text.js +1 -1
  105. package/chunks/vxlLayer.js +1 -1
  106. package/config.js +1 -1
  107. package/core/workers/WorkerFallback.js +4 -2
  108. package/core/workers/workerFactory.js +1 -1
  109. package/core/workers/workers.js +4 -2
  110. package/geometry/support/labelPoint.js +1 -1
  111. package/graphic/AnnotationFeatureGraphicOrigin.d.ts +49 -9
  112. package/graphic/BuildingGraphicOrigin.d.ts +49 -0
  113. package/graphic/CSVGraphicOrigin.d.ts +42 -9
  114. package/graphic/CatalogGraphicOrigin.d.ts +42 -9
  115. package/graphic/DimensionFeatureGraphicOrigin.d.ts +42 -9
  116. package/graphic/FeatureGraphicOrigin.d.ts +42 -9
  117. package/graphic/GeoJSONGraphicOrigin.d.ts +42 -9
  118. package/graphic/GeoRSSGraphicOrigin.d.ts +42 -9
  119. package/graphic/GraphicOrigin.d.ts +52 -12
  120. package/graphic/ImageryGraphicOrigin.d.ts +42 -9
  121. package/graphic/ImageryTileGraphicOrigin.d.ts +42 -9
  122. package/graphic/KMLGraphicOrigin.d.ts +47 -10
  123. package/graphic/KnowledgeGraphGraphicOrigin.d.ts +49 -1
  124. package/graphic/LinkChartGraphicOrigin.d.ts +49 -1
  125. package/graphic/MapImageGraphicOrigin.d.ts +49 -1
  126. package/graphic/MapNotesGraphicOrigin.d.ts +48 -1
  127. package/graphic/OGCFeatureGraphicOrigin.d.ts +42 -9
  128. package/graphic/OrientedImageryGraphicOrigin.d.ts +42 -9
  129. package/graphic/ParquetGraphicOrigin.d.ts +42 -9
  130. package/graphic/PointCloudGraphicOrigin.d.ts +43 -0
  131. package/graphic/SceneGraphicOrigin.d.ts +43 -0
  132. package/graphic/SketchGraphicOrigin.d.ts +43 -0
  133. package/graphic/StreamGraphicOrigin.d.ts +43 -0
  134. package/graphic/SubtypeGroupGraphicOrigin.d.ts +49 -1
  135. package/graphic/TileGraphicOrigin.d.ts +49 -1
  136. package/graphic/VectorTileGraphicOrigin.d.ts +43 -14
  137. package/graphic/VoxelGraphicOrigin.d.ts +43 -0
  138. package/graphic/WCSGraphicOrigin.d.ts +43 -0
  139. package/graphic/WFSGraphicOrigin.d.ts +42 -9
  140. package/graphic/getGraphicOriginTitle.d.ts +21 -3
  141. package/kernel.js +1 -1
  142. package/layers/GaussianSplatLayer.d.ts +2 -1
  143. package/layers/ParquetLayer.d.ts +24 -1
  144. package/layers/ParquetLayer.js +1 -1
  145. package/layers/mixins/ReloadableLayer.js +1 -1
  146. package/layers/orientedImagery/transformations/utils.js +1 -1
  147. package/layers/save/featureLayerUtils.js +1 -1
  148. package/layers/save/imageryUtils.js +1 -1
  149. package/layers/save/mapImageLayerUtils.js +1 -1
  150. package/layers/save/mediaLayerUtils.js +1 -1
  151. package/layers/save/parquetLayerUtils.js +2 -0
  152. package/layers/save/streamLayerUtils.js +1 -1
  153. package/layers/support/LabelClass.d.ts +8 -2
  154. package/layers/support/layersMapping.js +1 -1
  155. package/layers/support/rasterJobHelper.js +1 -1
  156. package/layers/video/VideoController.js +5 -5
  157. package/package.json +2 -2
  158. package/popup/content.js +1 -1
  159. package/portal/schemas/definitions.js +1 -1
  160. package/portal/schemas/webScene.js +1 -1
  161. package/rest/query/operations/pbfDehydratedFeatureSet.js +1 -1
  162. package/rest/query/operations/pbfFlatFeatureSet.js +1 -1
  163. package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
  164. package/undoredo/support/ApplySet.js +1 -1
  165. package/views/2d/engine/flow/ProcessingTimeEstimate.js +1 -1
  166. package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
  167. package/views/2d/engine/vectorTiles/buckets/SymbolBucket.js +1 -1
  168. package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
  169. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
  170. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  171. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  172. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  173. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  174. package/views/3d/layers/graphics/ElevationAligners.js +1 -1
  175. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  176. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  177. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  178. package/views/3d/layers/graphics/LabelParameters.js +1 -1
  179. package/views/3d/layers/graphics/Labeler.js +1 -1
  180. package/views/3d/layers/graphics/elevationAlignmentUtils.js +1 -1
  181. package/views/3d/layers/graphics/pointUtils.js +1 -1
  182. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  183. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  184. package/views/3d/layers/support/Tiles3DBVH.js +1 -1
  185. package/views/3d/layers/support/featureTileQuery3D.js +1 -1
  186. package/views/3d/state/controllers/ZoomControllerLocal.js +1 -1
  187. package/views/3d/state/controllers/ZoomStepControllerLocal.js +1 -1
  188. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  189. package/views/3d/state/utils/groundNavigationUtils.js +1 -1
  190. package/views/3d/state/utils/navigationUtils.js +1 -1
  191. package/views/3d/terrain/TerrainRenderer.js +1 -1
  192. package/views/3d/terrain/TerrainSurface.js +1 -1
  193. package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
  194. package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowCastRenderer.js +1 -1
  195. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  196. package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
  197. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  198. package/views/3d/webgl-engine/lib/screenPolygonTriangleIntersections.js +1 -1
  199. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  200. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  201. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  202. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  203. package/views/3d/webgl-engine/materials/TriangleMaterial.js +1 -1
  204. package/views/3d/webgl-engine/materials/internal/worldSizedRibbonLineIntersectionUtils.js +1 -1
  205. package/views/DOMContainer.js +1 -1
  206. package/views/draw/SegmentDrawAction.js +1 -1
  207. package/views/interactive/snapping/SnappingManagerPool.js +1 -1
  208. package/views/interactive/tooltip/content/TooltipContent.js +1 -1
  209. package/views/interactive/tooltip/fields/TooltipField.js +1 -1
  210. package/views/support/LayerViewManager.js +1 -1
  211. package/views/support/ScheduledQueueProcessor.js +1 -1
  212. package/views/support/screenshotUtils.js +1 -1
  213. package/views/ui/UI.js +1 -1
  214. package/webdoc/support/webdocSaveUtils.js +1 -1
  215. package/webscene/Slide.d.ts +1 -2
  216. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  217. package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
  218. package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
  219. package/widgets/FeatureTable/RelationshipColumn.js +1 -1
  220. package/widgets/OrientedImageryViewer/ImageMeasurementWorker.js +1 -1
  221. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  222. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  223. package/widgets/OrientedImageryViewer/services/ImageMeasurementService.js +1 -1
  224. package/widgets/Sketch/SketchViewModel.js +1 -1
  225. package/assets/esri/core/workers/chunks/14d5d219e7fe017f23f0.js +0 -1
  226. package/assets/esri/core/workers/chunks/42753cf4965a94bc91ca.js +0 -1
  227. package/assets/esri/core/workers/chunks/42e985a576d7aaeed0cf.js +0 -1
  228. package/assets/esri/core/workers/chunks/5046214dd32029cb733d.js +0 -1
  229. package/assets/esri/core/workers/chunks/58865772bed48141a56a.js +0 -1
  230. package/assets/esri/core/workers/chunks/72e6d594b7262430ae55.js +0 -1
  231. package/assets/esri/core/workers/chunks/7d11710e1586a3d75887.js +0 -1
  232. package/assets/esri/core/workers/chunks/8f74d92ac69714b9fd4e.js +0 -1
  233. package/assets/esri/core/workers/chunks/947674b2ca8be65b9bcc.js +0 -1
  234. package/assets/esri/core/workers/chunks/9e7c4eda135c4911b268.js +0 -1
  235. package/assets/esri/core/workers/chunks/a09d2e1e2540921e4717.js +0 -1
  236. package/assets/esri/core/workers/chunks/dfa5f1311806473e473f.js +0 -1
  237. package/assets/esri/core/workers/chunks/fc76aff0f7d95e517d8f.js +0 -1
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{copy as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as n,normalize as r}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as a}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as o}from"../../../../geometry/projection/projectBuffer.js";import{isDehydratedPoint as s}from"../../../../layers/graphics/dehydratedFeatureUtils.js";import{isSamplePosition as c,getElevationAtPoint as l}from"../../support/ElevationProvider.js";import{updateObjectVertexField as u,updateVertexFieldVec3f as d,updateVertexFieldFloat as f}from"../../webgl-engine/lib/bufferGeometryUtils.js";function p(e,t,n,r,i,a,s,c,l,u,d){let f=j[d.mode],p=0;if(!o(e,t,n,r,l.spatialReference,i,c))return;let m,h;if(f?.requiresAlignment(d)?(p=f.applyElevationAlignmentBuffer(r,i,a,s,c,l,u,d),m=a,h=s):(m=r,h=i),o(m,l.spatialReference,h,a,u.spatialReference,s,c))return p}function m(e,t,n,r,i){let a=(s(e)?e.z:c(e)?e.array[e.offset+2]:e[2])||0;switch(n.mode){case`on-the-ground`:{let n=l(t,e,`ground`)??0;i.verticalDistanceToGround=0,i.sampledElevation=n,i.z=n;return}case`relative-to-ground`:{let o=l(t,e,`ground`)??0,s=n.geometryZWithOffset(a,r);i.verticalDistanceToGround=s,i.sampledElevation=o,i.z=s+o;return}case`relative-to-scene`:{let o=l(t,e,`scene`)??0,s=n.geometryZWithOffset(a,r);i.verticalDistanceToGround=s,i.sampledElevation=o,i.z=s+o;return}case`absolute-height`:{let o=n.geometryZWithOffset(a,r),s=l(t,e,`ground`)??0;i.verticalDistanceToGround=o-s,i.sampledElevation=s,i.z=o;return}default:i.z=0;return}}function h(e,t,n,r){return m(e,t,n,r,L),L.z}function g(e,t,n){return t===`on-the-ground`&&n===`on-the-ground`?e.staysOnTheGround:t!==n&&(t===`on-the-ground`||n===`on-the-ground`)?e.onTheGroundChanged:t==null||n==null?e.definedChanged:1}function _(e){return e===`relative-to-ground`||e===`relative-to-scene`}function v(e){return e!==`absolute-height`}function y(t,n,r,i,o){m(n,r,o,i,L),w(t,L.verticalDistanceToGround);let s=L.sampledElevation,c=e(M,t.transformation);return R[0]=n.x,R[1]=n.y,R[2]=L.z,a(n.spatialReference,R,c,i.spatialReference)?t.transformation=c:console.warn(`Could not locate symbol object properly, it might be misplaced`),s}function b(e,t,r,i,a){m(t,r,a,i,L),C(e,L.verticalDistanceToGround);let o=L.sampledElevation;return n(P,t.x,t.y,L.z),x(e,P,t.spatialReference,i),o}function x(e,t,n,r){a(n,t,N,r.spatialReference)?S(e,N):console.warn(`Could not locate symbol object properly, it might be misplaced`)}function S(e,t){n(I,t[8],t[9],t[10]),r(I,I);for(let r of e.geometries){let i=r.localOrigin.vec3;n(F,t[12]-i[0],t[13]-i[1],t[14]-i[2]),u(e,d,r,`position`,0,F),u(e,d,r,`normal`,0,I)}}function C(e,t){for(let n of e.geometries)u(e,f,n,`groundDistance`,0,t)}function w(e,t){for(let n=0;n<e.geometries.length;++n){let r=e.geometries[n].getMutableAttribute(`groundDistance`);r&&r.data[0]!==t&&(r.data[0]=t,e.geometryVertexAttributeUpdated(e.geometries[n],`groundDistance`))}}function T(e,t,n,r,i,a){let o=0,s=a.spatialReference;t*=3,r*=3;for(let c=0;c<i;++c){let i=e[t],c=e[t+1],l=e[t+2],u=a.getElevation(i,c,l,s,`ground`)??0;o+=u,n[r]=i,n[r+1]=c,n[r+2]=u,t+=3,r+=3}return o/i}function E(e,t,n,r,i,a,o,s){let c=0,l=s.calculateOffsetRenderUnits(o),u=s.featureExpressionInfoContext,d=a.spatialReference;t*=3,r*=3;for(let o=0;o<i;++o){let i=e[t],o=e[t+1],s=e[t+2],f=a.getElevation(i,o,s,d,`ground`)??0;c+=f,n[r]=i,n[r+1]=o,u==null?n[r+2]=s+f+l:n[r+2]=f+l,t+=3,r+=3}return c/i}function D(e,t,n,r,i,a,o,s){let c=0,l=s.calculateOffsetRenderUnits(o),u=s.featureExpressionInfoContext,d=a.spatialReference;t*=3,r*=3;for(let o=0;o<i;++o){let i=e[t],o=e[t+1],s=e[t+2],f=a.getElevation(i,o,s,d,`scene`)??0;c+=f,n[r]=i,n[r+1]=o,u==null?n[r+2]=s+f+l:n[r+2]=f+l,t+=3,r+=3}return c/i}function O(e){let t=e.meterUnitOffset,n=e.featureExpressionInfoContext;return t!==0||n!=null}function k(e,t,n,r,i,a,o,s){let c=s.calculateOffsetRenderUnits(o),l=s.featureExpressionInfoContext;t*=3,r*=3;for(let a=0;a<i;++a){let i=e[t],a=e[t+1],o=e[t+2];n[r]=i,n[r+1]=a,l==null?n[r+2]=o+c:n[r+2]=c,t+=3,r+=3}return 0}class A{constructor(){this.verticalDistanceToGround=0,this.sampledElevation=0,this.z=0}}const j={"absolute-height":{applyElevationAlignmentBuffer:k,requiresAlignment:O},"on-the-ground":{applyElevationAlignmentBuffer:T,requiresAlignment:()=>!0},"relative-to-ground":{applyElevationAlignmentBuffer:E,requiresAlignment:()=>!0},"relative-to-scene":{applyElevationAlignmentBuffer:D,requiresAlignment:()=>!0}},M=t(),N=t(),P=i(),F=i(),I=i(),L=new A,R=i();export{A as SampleElevationInfo,b as applyBufferElevationAlignmentForHUD,x as applyBufferPointPlacement,S as applyBufferPointTransformation,y as applyElevationAlignmentForHUD,p as applyPerVertexElevationAlignment,g as elevationModeChangeUpdateType,h as evaluateElevationAlignmentAtPoint,m as evaluateElevationInfoAtPoint,_ as needsElevationUpdates2D,v as needsElevationUpdates3D,C as updateBufferPointGroundDistance,w as updateVertexPointGroundDistance};
2
+ import{fromMat4 as e}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{copy 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,exactEquals as a,copy as o,transformMat3 as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as c,create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as u}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as d}from"../../../../geometry/projection/projectBuffer.js";import{isDehydratedPoint as f}from"../../../../layers/graphics/dehydratedFeatureUtils.js";import{isSamplePosition as p,getElevationAtPoint as m}from"../../support/ElevationProvider.js";import{updateObjectVertexField as h,updateVertexFieldVec3f as g,updateVertexFieldFloat as _}from"../../webgl-engine/lib/bufferGeometryUtils.js";function v(e,t,n,r,i,a,o,s,c,l,u){let f=I[u.mode],p=0;if(!d(e,t,n,r,c.spatialReference,i,s))return;let m,h;if(f?.requiresAlignment(u)?(p=f.applyElevationAlignmentBuffer(r,i,a,o,s,c,l,u),m=a,h=o):(m=r,h=i),d(m,c.spatialReference,h,a,l.spatialReference,o,s))return p}function y(e,t,n,r,i){let a=(f(e)?e.z:p(e)?e.array[e.offset+2]:e[2])||0;switch(n.mode){case`on-the-ground`:{let n=m(t,e,`ground`)??0;i.verticalDistanceToGround=0,i.sampledElevation=n,i.z=n;return}case`relative-to-ground`:{let o=m(t,e,`ground`)??0,s=n.geometryZWithOffset(a,r);i.verticalDistanceToGround=s,i.sampledElevation=o,i.z=s+o;return}case`relative-to-scene`:{let o=m(t,e,`scene`)??0,s=n.geometryZWithOffset(a,r);i.verticalDistanceToGround=s,i.sampledElevation=o,i.z=s+o;return}case`absolute-height`:{let o=n.geometryZWithOffset(a,r),s=m(t,e,`ground`)??0;i.verticalDistanceToGround=o-s,i.sampledElevation=s,i.z=o;return}default:i.z=0;return}}function b(e,t,n,r){return y(e,t,n,r,H),H.z}function x(e,t,n){return t===`on-the-ground`&&n===`on-the-ground`?e.staysOnTheGround:t!==n&&(t===`on-the-ground`||n===`on-the-ground`)?e.onTheGroundChanged:t==null||n==null?e.definedChanged:1}function S(e){return e===`relative-to-ground`||e===`relative-to-scene`}function C(e){return e!==`absolute-height`}function w(e,t,r,i,a){y(t,r,a,i,H),k(e,H.verticalDistanceToGround);let o=H.sampledElevation,s=n(L,e.transformation);return U[0]=t.x,U[1]=t.y,U[2]=H.z,u(t.spatialReference,U,s,i.spatialReference)?e.transformation=s:console.warn(`Could not locate symbol object properly, it might be misplaced`),o}function T(t,n,r,l,u,d,f,p){return y(t,n,l,r,p),i(z,t.x,t.y,p.z),E(z,t.spatialReference,r,d)?(a(u,c)?o(f,c):(e(R,d),s(f,u,R)),d[12]+=f[0],d[13]+=f[1],d[14]+=f[2],!0):!1}function E(e,t,n,r){return u(t,e,r,n.spatialReference)?!0:(console.warn(`Could not locate symbol object properly, it might be misplaced`),!1)}function D(e,t){i(V,t[8],t[9],t[10]);for(let n of e.geometries){let r=n.localOrigin.vec3;i(B,t[12]-r[0],t[13]-r[1],t[14]-r[2]),h(e,g,n,`position`,0,B),h(e,g,n,`normal`,0,V)}}function O(e,t){for(let n of e.geometries)h(e,_,n,`groundDistance`,0,t)}function k(e,t){for(let n=0;n<e.geometries.length;++n){let r=e.geometries[n].getMutableAttribute(`groundDistance`);r&&r.data[0]!==t&&(r.data[0]=t,e.geometryVertexAttributeUpdated(e.geometries[n],`groundDistance`))}}function A(e,t,n,r,i,a){let o=0,s=a.spatialReference;t*=3,r*=3;for(let c=0;c<i;++c){let i=e[t],c=e[t+1],l=e[t+2],u=a.getElevation(i,c,l,s,`ground`)??0;o+=u,n[r]=i,n[r+1]=c,n[r+2]=u,t+=3,r+=3}return o/i}function j(e,t,n,r,i,a,o,s){let c=0,l=s.calculateOffsetRenderUnits(o),u=s.featureExpressionInfoContext,d=a.spatialReference;t*=3,r*=3;for(let o=0;o<i;++o){let i=e[t],o=e[t+1],s=e[t+2],f=a.getElevation(i,o,s,d,`ground`)??0;c+=f,n[r]=i,n[r+1]=o,u==null?n[r+2]=s+f+l:n[r+2]=f+l,t+=3,r+=3}return c/i}function M(e,t,n,r,i,a,o,s){let c=0,l=s.calculateOffsetRenderUnits(o),u=s.featureExpressionInfoContext,d=a.spatialReference;t*=3,r*=3;for(let o=0;o<i;++o){let i=e[t],o=e[t+1],s=e[t+2],f=a.getElevation(i,o,s,d,`scene`)??0;c+=f,n[r]=i,n[r+1]=o,u==null?n[r+2]=s+f+l:n[r+2]=f+l,t+=3,r+=3}return c/i}function N(e){let t=e.meterUnitOffset,n=e.featureExpressionInfoContext;return t!==0||n!=null}function P(e,t,n,r,i,a,o,s){let c=s.calculateOffsetRenderUnits(o),l=s.featureExpressionInfoContext;t*=3,r*=3;for(let a=0;a<i;++a){let i=e[t],a=e[t+1],o=e[t+2];n[r]=i,n[r+1]=a,l==null?n[r+2]=o+c:n[r+2]=c,t+=3,r+=3}return 0}class F{constructor(){this.verticalDistanceToGround=0,this.sampledElevation=0,this.z=0}}const I={"absolute-height":{applyElevationAlignmentBuffer:P,requiresAlignment:N},"on-the-ground":{applyElevationAlignmentBuffer:A,requiresAlignment:()=>!0},"relative-to-ground":{applyElevationAlignmentBuffer:j,requiresAlignment:()=>!0},"relative-to-scene":{applyElevationAlignmentBuffer:M,requiresAlignment:()=>!0}},L=r(),R=t(),z=l(),B=l(),V=l(),H=new F,U=l();export{F as SampleElevationInfo,D as applyBufferPointTransformation,w as applyElevationAlignmentForHUD,v as applyPerVertexElevationAlignment,E as computePointTransformation,T as computePointTransformationForHUD,x as elevationModeChangeUpdateType,b as evaluateElevationAlignmentAtPoint,y as evaluateElevationInfoAtPoint,S as needsElevationUpdates2D,C as needsElevationUpdates3D,O as updateBufferPointGroundDistance,k as updateVertexPointGroundDistance};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{fromValues as e,create as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectPointToVector as n}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as r}from"../../../../geometry/support/aaBoundingBox.js";import{getPointOnPath as i,getPathLength as a}from"../../../../geometry/support/coordsUtils.js";import{makeDehydratedPoint as o}from"../../../../layers/graphics/dehydratedPoint.js";import{applyElevationAlignmentForHUD as s,applyBufferElevationAlignmentForHUD as c}from"./elevationAlignmentUtils.js";import{computeCentroid as l}from"./graphicUtils.js";import{BufferObject3D as u}from"../../webgl-engine/lib/BufferObject3D.js";import{Object3D as d}from"../../webgl-engine/lib/Object3D.js";function f(e,t,n,r,i){if(g(e,t))return null;n.localOrigin=y(e,t);let a=new d({geometries:[n],castShadow:!1,layerViewUid:e.layerViewUid,graphicUid:i,usesVerticalDistanceToGround:!0});return{object:a,sampledElevation:s(a,t,e.elevationProvider,e.renderCoordsHelper,r)}}function p(e,t,n,r){return g(t,n)?null:s(e,n,t.elevationProvider,t.renderCoordsHelper,r)}function m(e,t,n,r,i){if(g(e,t))return null;let a=new u({geometries:[n],castShadow:!1,layerViewUid:e.layerViewUid,graphicUid:i});return{object:a,sampledElevation:c(a,t,e.elevationProvider,e.renderCoordsHelper,r)}}function h(e,t,n,r){if(g(t,n))return null;let i=y(t,n);return e.geometries.some(e=>e.localOrigin!==i)?null:c(e,n,t.elevationProvider,t.renderCoordsHelper,r)}function g(e,t){let i=e.clippingExtent;return i?(n(t,b,e.elevationProvider.spatialReference),!r(i,b)):!1}function _(t,r,i){let a=t.elevationContext,o=i.spatialReference;n(r,b,o),a.centerInElevationSR=e(b[0],b[1],r.hasZ?b[2]:0)}function v(e){switch(e.type){case`point`:return e;case`polygon`:case`extent`:return l(e);case`polyline`:{let t=e.paths[0];if(!t||t.length===0)return null;let n=i(t,a(t)/2);return o(n[0],n[1],n[2],e.spatialReference)}case`mesh`:return e.extent.center}return null}function y(e,t){return n(t,b,e.renderCoordsHelper.spatialReference),e.localOriginFactory.getOrigin(b)}const b=t();export{m as createBufferStageObject,f as createStageObject,_ as extendPointGraphicElevationContext,y as getLocalOriginForPoint,v as placePointOnGeometry,h as updateBufferStageObjectGeometry,p as updateStageObjectGeometry};
2
+ import{getTranslation as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as n}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as r,create as i,ZEROS as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectPointToVector as o}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as s}from"../../../../geometry/support/aaBoundingBox.js";import{getPointOnPath as c,getPathLength as l}from"../../../../geometry/support/coordsUtils.js";import{makeDehydratedPoint as u}from"../../../../layers/graphics/dehydratedPoint.js";import{computePointTransformationForHUD as d,updateBufferPointGroundDistance as f,SampleElevationInfo as p,applyBufferPointTransformation as m,applyElevationAlignmentForHUD as h}from"./elevationAlignmentUtils.js";import{computeCentroid as g}from"./graphicUtils.js";import{BufferObject3D as _}from"../../webgl-engine/lib/BufferObject3D.js";import{createPointBufferGeometry as v}from"../../webgl-engine/lib/GeometryUtil.js";import{Object3D as y}from"../../webgl-engine/lib/Object3D.js";function b(e,t,n,r,i){if(T(e,t))return null;n.localOrigin=O(e,t);let a=new y({geometries:[n],castShadow:!1,layerViewUid:e.layerViewUid,graphicUid:i,usesVerticalDistanceToGround:!0});return{object:a,sampledElevation:h(a,t,e.elevationProvider,e.renderCoordsHelper,r)}}function x(e,t,n,r,i,o){return S(e,t,n,r,i,o,a,k)}function S(t,r,i,a,o,s,c,l){if(T(t,r)||!d(r,t.elevationProvider,t.renderCoordsHelper,o,c,j,l,M))return null;e(k,j);let u=t.localOriginFactory.getOrigin(k);n(A,j[8],j[9],j[10]);let f=v(i,u,{...a,position:k,normal:A,groundDistance:M.verticalDistanceToGround});return{object:new _({geometries:[f],layerViewUid:t.layerViewUid,graphicUid:s}),sampledElevation:M.sampledElevation}}function C(e,t,n,r){return w(e,t,n,r,a,k)}function w(t,n,r,i,a,o){return T(n,r)||!d(r,n.elevationProvider,n.renderCoordsHelper,i,a,j,o,M)||(e(k,j),t.geometries.some(e=>n.localOriginFactory.needsOriginUpdate(e.localOrigin,k,0)))?null:(f(t,M.verticalDistanceToGround),m(t,j),M.sampledElevation)}function T(e,t){let n=e.clippingExtent;return n?(o(t,k,e.elevationProvider.spatialReference),!s(n,k)):!1}function E(e,t,n){let i=e.elevationContext,a=n.spatialReference;o(t,k,a),i.centerInElevationSR=r(k[0],k[1],t.hasZ?k[2]:0)}function D(e){switch(e.type){case`point`:return e;case`polygon`:case`extent`:return g(e);case`polyline`:{let t=e.paths[0];if(!t||t.length===0)return null;let n=c(t,l(t)/2);return u(n[0],n[1],n[2],e.spatialReference)}case`mesh`:return e.extent.center}return null}function O(e,t){return o(t,k,e.renderCoordsHelper.spatialReference),e.localOriginFactory.getOrigin(k)}const k=i(),A=i(),j=t(),M=new p;export{x as createBufferStageObject,b as createStageObject,S as createTranslatedBufferStageObject,E as extendPointGraphicElevationContext,O as getLocalOriginForPoint,D as placePointOnGeometry,C as updateBufferStageObjectGeometry,w as updateTranslatedBufferStageObjectGeometry};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import has from"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{isAbortError as t}from"../../../../core/promiseUtils.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBoundingSphere as r}from"../../../../geometry/projection/projectBoundingSphere.js";import{Sphere as i}from"../../../../geometry/support/sphere.js";import{NodeBoundingData as a,Node as o,NodeTraversalState as s}from"./I3SNode.js";import{addWraparound as c}from"./I3SUtil.js";import{ValidatedNode as l}from"./ValidatedNode.js";import{ElevationRange as u}from"../../support/ElevationRange.js";import{Obb as d}from"../../support/orientedBoundingBox.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(t,n,r,i,o,s,c,l,u,d,f,m,h,_,y){if(this.viewingMode=t,this._layer=n,this._requester=i,this._clientNodeLoader=o,this._viewportQueries=s,this._logger=c,this.holeFilling=l,this._isLoaded=u,this._isReloading=d,this._shouldLoadNode=f,this._enable=m,this._needsUpdate=h,this._computeVisibilityObb=_,this._computeNodeFiltering=y,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 e({deallocator:null}),this.ignoreServiceObb=!1,this._pageQueue=[],this._newPages=[],this._needsNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._isEditable=n.associatedLayer?.infoFor3D!=null,n.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${n.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,r.type===`page`){let e=r.rootPage;switch(this.urlPrefix=r.urlPrefix,this._pageSize=r.pageSize,r.lodMetric){case`maxScreenThreshold`:this._lodMetric=1;break;case`maxScreenThresholdSQ`:this._lodMetric=1,this._lodConversion=k}if(this._isEditable){this._rootIndex=-1;let t=C(r.rootIndex,r.pageSize),n=e.nodes[t],i={nodes:[{index:this._rootIndex,children:[r.rootIndex],mesh:void 0,obb:n.obb,lodThreshold:n.lodThreshold}]};this._addPage(S(this._rootIndex,this._pageSize),i),this.getNode(-1).serviceObbInIndexSR=void 0}else this._rootIndex=r.rootIndex;this._addPage(S(r.rootIndex,this._pageSize),e),this._updateParentsAndLevel()}else if(r.type===`node`){this.urlPrefix=r.urlPrefix;let e=new p;if(this._nodePages.set(0,e),this._isEditable){this._clientNodePage=new p;let e={id:`-1`,version:null,mbs:r.rootNode.mbs,obb:r.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:`root`,href:`../root`,mbs:r.rootNode.mbs,obb:r.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new a(e.id),-1);let t=this._validateNode(e.id,e);t&&this._addNode(t,this._rootIndex)}else this._rootIndex=this._makeRefNode(new a(r.rootNode.id),-1);let t=this._validateNode(r.rootNode.id,r.rootNode);t&&this._addNode(t,0)}}addClientNodeToIndex(e,t){let n=new a(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 n=this.urlPrefix+e;this._requester.request(n,`json`).then(t=>{this._nodePages.has(e)?this._logger.error(`Queued page [${e}] already loaded`):this._pageQueue.push({pageIndex:e,page:t})}).catch(n=>{this._loadingPages.delete(e),!t(n)&&(this._failedPages.add(e),this._logger.error(`#loadPage()`,this._layer,`Error when loading page ${e}`,n))})}_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,c=t.children?t.children.length:0;r.push(this._rootIndex);for(let e=0;e<c;e++)n.push(t.children[e]);let l=`${t.index}`,u=d.fromJSON(t.obb),p=new i(u.getCenter(N),u.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 o(l,w(a,e,this._pageSize),p,c,0,v,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),h?.featureCount??null,u);return y.visibilityObbInRenderSR=this._computeVisibilityObb(y),y.vertexCount=h?h.vertexCount:0,new f(s,c,_(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 c=new o(e.id,t,e.mbs,s.childCount,r,e.resources,e.version,i,a,e.numFeatures,e.obb?d.fromJSON(e.obb):null);s.node=c,c.visibilityObbInRenderSR=this._computeVisibilityObb(c);let l=s.nodeBoundingData;return l!=null&&(l.serviceMbsInIndexSR??=e.mbs,c.shareServiceBVsInRenderSRWith(l),l.visibilityObbInRenderSR=c.visibilityObbInRenderSR),c}_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 u,a=!1;for(let t=0;t<n.childCount;t++){let n=this.getChildIndex(e,t),r=this._updateElevationRange(n,i);a||=!r}if(n.childCount===0||a){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:o,maxElevation:s}=r;return o===i.minElevation&&s===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),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))}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):!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 s(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 n=this._getNodeDescriptor(e);if(n.node){this._logger.error(`Node[${e}] already in descriptor`);return}let r=n.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(n=>{o(),t(n)||(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,o=this._layer.attributeStorageInfo;r!=null&&(!Array.isArray(r)||r.some((e,t)=>e.href!==`./attributes/${o?.[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 s=t.hasOwnProperty(`obb`)&&!this.ignoreServiceObb?t.obb:void 0,c=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 a(`${t.id}`,new i(t.mbs));return r.serviceObbInIndexSR=!this.ignoreServiceObb&&t.hasOwnProperty(`obb`)&&t.obb?d.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 l(e,new i(t.mbs),s,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,c)}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(t){this.missing=t,this.update=new e({deallocator:null}),this.add=new e({deallocator:null}),this.remove=new e({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 c(e,-2)}function v(e){return c(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=n(),P=has(`esri-mobile`)?100:300;export{m as I3SIndex,E as selectErrorMetric};
2
+ import has from"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{isAbortError as t}from"../../../../core/promiseUtils.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBoundingSphere as r}from"../../../../geometry/projection/projectBoundingSphere.js";import{Sphere as i}from"../../../../geometry/support/sphere.js";import{NodeBoundingData as a,Node as o,NodeTraversalState as s}from"./I3SNode.js";import{addWraparound as c}from"./I3SUtil.js";import{ValidatedNode as l}from"./ValidatedNode.js";import{ElevationRange as u}from"../../support/ElevationRange.js";import{Obb as d}from"../../support/orientedBoundingBox.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(t,n,r,i,o,s,c,l,u,d,f,m,h,_,y){if(this.viewingMode=t,this._layer=n,this._requester=i,this._clientNodeLoader=o,this._viewportQueries=s,this._logger=c,this.holeFilling=l,this._isLoaded=u,this._isReloading=d,this._shouldLoadNode=f,this._enable=m,this._needsUpdate=h,this._computeVisibilityObb=_,this._computeNodeFiltering=y,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 e({deallocator:null}),this.ignoreServiceObb=!1,this._pageQueue=[],this._newPages=[],this._needsNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._isEditable=n.associatedLayer?.infoFor3D!=null,n.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${n.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,r.type===`page`){let e=r.rootPage;switch(this.urlPrefix=r.urlPrefix,this._pageSize=r.pageSize,r.lodMetric){case`maxScreenThreshold`:this._lodMetric=1;break;case`maxScreenThresholdSQ`:this._lodMetric=1,this._lodConversion=k}if(this._isEditable){this._rootIndex=-1;let t=C(r.rootIndex,r.pageSize),n=e.nodes[t],i={nodes:[{index:this._rootIndex,children:[r.rootIndex],mesh:void 0,obb:n.obb,lodThreshold:n.lodThreshold}]};this._addPage(S(this._rootIndex,this._pageSize),i),this.getNode(-1).serviceObbInIndexSR=void 0}else this._rootIndex=r.rootIndex;this._addPage(S(r.rootIndex,this._pageSize),e),this._updateParentsAndLevel()}else if(r.type===`node`){this.urlPrefix=r.urlPrefix;let e=new p;if(this._nodePages.set(0,e),this._isEditable){this._clientNodePage=new p;let e={id:`-1`,version:null,mbs:r.rootNode.mbs,obb:r.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:`root`,href:`../root`,mbs:r.rootNode.mbs,obb:r.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new a(e.id),-1);let t=this._validateNode(e.id,e);t&&this._addNode(t,this._rootIndex)}else this._rootIndex=this._makeRefNode(new a(r.rootNode.id),-1);let t=this._validateNode(r.rootNode.id,r.rootNode);t&&this._addNode(t,0)}}addClientNodeToIndex(e,t){let n=new a(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 n=this.urlPrefix+e;this._requester.request(n,`json`).then(t=>{this._nodePages.has(e)?this._logger.error(`Queued page [${e}] already loaded`):this._pageQueue.push({pageIndex:e,page:t})}).catch(n=>{this._loadingPages.delete(e),t(n)||(this._failedPages.add(e),this._logger.error(`#loadPage()`,this._layer,`Error when loading page ${e}`,n))})}_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,c=t.children?t.children.length:0;r.push(this._rootIndex);for(let e=0;e<c;e++)n.push(t.children[e]);let l=`${t.index}`,u=d.fromJSON(t.obb),p=new i(u.getCenter(N),u.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 o(l,w(a,e,this._pageSize),p,c,0,v,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),h?.featureCount??null,u);return y.visibilityObbInRenderSR=this._computeVisibilityObb(y),y.vertexCount=h?h.vertexCount:0,new f(s,c,_(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 c=new o(e.id,t,e.mbs,s.childCount,r,e.resources,e.version,i,a,e.numFeatures,e.obb?d.fromJSON(e.obb):null);s.node=c,c.visibilityObbInRenderSR=this._computeVisibilityObb(c);let l=s.nodeBoundingData;return l!=null&&(l.serviceMbsInIndexSR??=e.mbs,c.shareServiceBVsInRenderSRWith(l),l.visibilityObbInRenderSR=c.visibilityObbInRenderSR),c}_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 u,a=!1;for(let t=0;t<n.childCount;t++){let n=this.getChildIndex(e,t),r=this._updateElevationRange(n,i);a||=!r}if(n.childCount===0||a){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:o,maxElevation:s}=r;return o===i.minElevation&&s===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),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))}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):!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 s(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 n=this._getNodeDescriptor(e);if(n.node){this._logger.error(`Node[${e}] already in descriptor`);return}let r=n.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(n=>{o(),t(n)||(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,o=this._layer.attributeStorageInfo;r!=null&&(!Array.isArray(r)||r.some((e,t)=>e.href!==`./attributes/${o?.[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 s=t.hasOwnProperty(`obb`)&&!this.ignoreServiceObb?t.obb:void 0,c=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 a(`${t.id}`,new i(t.mbs));return r.serviceObbInIndexSR=!this.ignoreServiceObb&&t.hasOwnProperty(`obb`)&&t.obb?d.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 l(e,new i(t.mbs),s,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,c)}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(t){this.missing=t,this.update=new e({deallocator:null}),this.add=new e({deallocator:null}),this.remove=new e({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 c(e,-2)}function v(e){return c(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=n(),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{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{splitIntoChunks as n}from"../../../../core/arrayUtils.js";import{createTask as r,resultOrAbort as i}from"../../../../core/asyncUtils.js";import a from"../../../../core/Collection.js";import{makeHandle as o}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import s from"../../../../core/Logger.js";import{abortMaybe as c,destroyMaybe as l}from"../../../../core/maybe.js";import{estimateNumberMemory as u,estimateStringMemory as d}from"../../../../core/memoryEstimations.js";import{whenOrAbort as f,throwIfAborted as p}from"../../../../core/promiseUtils.js";import m from"../../../../core/ReactiveSet.js";import{watch as h,sync as g}from"../../../../core/reactiveUtils.js";import{property as _,subclass as v}from"../../../../core/accessorSupport/decorators.js";import{equals as y}from"../../../../geometry/support/spatialReferenceUtils.js";import{formatNumber as b}from"../../../../intl/number.js";import{getMaximumQuerySize as x,queryAllJSON as S}from"../../../../layers/support/featureQueryAll.js";let C=class extends t{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=D,this._definitionExpressionDirty=!0,this._interactiveEditingSessions=new a,this.geometryOverrides=new a,this._clientGeometryCache=new Map,this._attributeChangedObjectIds=new m,this._geometryChangedObjectIds=new m,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController,this._applyGeometryOverridesTask=null,this._featureIdLocks=new Map}initialize(){this._memCache=new T(this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`)),this.addHandles(h(()=>this.layer.definitionExpression,async()=>{this._definitionExpressionDirty=!0,!this._pendingFetchChangedObjectIds&&(this._applyGeometryOverridesTask=c(this._applyGeometryOverridesTask),this._applyGeometryOverridesTask=r(e=>this._queryAndAddGeometryOverrides(e)),await this._applyGeometryOverridesTask.promise.catch(()=>{}))},g)),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.finally(()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null}).catch(()=>{})}destroy(){this._set(`layer`,null),this._memCache=l(this._memCache),this._pendingFetchAbortController=c(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null,this._featureIdLocks.clear()}get is3DOFL(){return this._associatedLayer?.infoFor3D!=null}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort((e,t)=>e-t):[]}get _associatedLayer(){return this.layer==null?null:this.layer.associatedLayer}get hasGeometryChanges(){return this._geometryChangedObjectIds.size>0}get updating(){return this.is3DOFL?!!(this._pendingFetchChangedObjectIds||this._applyGeometryOverridesTask&&!this._applyGeometryOverridesTask.finished):!1}get isEmpty(){return this._pendingFetchChangedObjectIds==null&&this._attributeChangedObjectIds.size===0&&this._geometryChangedObjectIds.size===0}featureHasGeometryChanges(e){return this._geometryChangedObjectIds.has(e)}featureHasAttributeChanges(e){return this._attributeChangedObjectIds.has(e)}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e);let t=this._interactiveEditingSessions,n=new w(e,()=>{t.remove(n)});return t.unshift(n),n}async applyAttributeOverrides(e,t,n,r=[]){if(this._pendingFetchChangedObjectIds&&await f(this._pendingFetchChangedObjectIds,n),t==null)return;let{attributeData:i,loadedAttributes:a}=t;if(a==null||i==null||this._attributeChangedObjectIds.size===0)return;let o=new Set;for(let e of a)o.add(e.index);for(let t of r)o.has(t.index)||(a.push(t),i[t.name]=Array(e.length));let s=await this._lockFeatureIds(e);try{let t={attributeData:i,loadedAttributes:a},{objectIds:r,fieldNames:o}=this._getOverridesFromCache(e,t,this._attributeChangedObjectIds);if(r.length===0||o.length===0)return;let s=await this._queryAttributeOverridesFromAssociatedLayer(r,o,n);if(s==null)return;this._processOverridesFromAssociatedLayer(e,s,o,t)}finally{s.remove()}}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);let n=this._clientGeometryCache.get(e);if(n!=null&&(this.geometryOverrides.remove(n),this._clientGeometryCache.delete(e)),t!=null){let n={oid:e,mesh:t};this.geometryOverrides.add(n),this._clientGeometryCache.set(e,n)}}updateAttributeValue(e,t,n){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,n)}featureAdded(e){this.is3DOFL&&this._geometryChangedObjectIds.add(e),this._attributeChangedObjectIds.add(e)}_cacheAttributeValue(e,t,n){this._memCache.put(e,t,n)}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:n},r){let i=[];for(let e of t)i[e.index]=n[e.name];let a=new Set,o=new Set;for(let n=0;n<e.length;n++){let s=e[n];if(r.has(s))for(let e of t){let t=this._attributeFromCache(s,e.index);t===void 0?(a.add(s),o.add(e.name)):i[e.index][n]=t}}return{objectIds:Array.from(a),fieldNames:Array.from(o)}}_attributeFromCache(e,t){let n=this._fromInteractiveEditingSession(e,t);return n===void 0?this._memCache.get(e,t):n}_fromInteractiveEditingSession(e,t){if(this._interactiveEditingSessions!=null)for(let n of this._interactiveEditingSessions){if(n.objectId!==e)continue;let r=n.getAttribute(t);if(r!==void 0)return r}}async _queryAttributeOverridesFromAssociatedLayer(e,t,n){if(e.length===0)return null;this._logWarningIfMaximumObjectsExceeded();let{associatedLayer:r}=this.layer;if(r==null)return null;let i=r.createQuery(),{objectIdField:a}=r,o=[a,...t];i.where=this.layer.definitionExpression||`1=1`,i.returnGeometry=!1,i.outFields=o,r.capabilities.query.supportsCacheHint&&(i.cacheHint=!0);let s=await this._executeBatchQuery(r,e,i,n),c=[];for(let e of s)if(e.ok)for(let t of e.value.features)c.push(t);return c}async _queryGeometryOverridesFromAssociatedLayer(e,t){if(e.length===0||!this.is3DOFL)return null;let n=this.layer.associatedLayer,r=n.infoFor3D,{spatialReference:i}=n;if(this.view){let{state:{viewingMode:e},spatialReference:t}=this.view,n=e===1,r=i.isGeographic;if(n&&!r)return s.getLogger(this).warn(`unsupported-pcs-edits-in-global-view`,this.layer.title,O(i,t,this.view.viewingMode,0)),null;if(!n&&r)return s.getLogger(this).warn(`unsupported-gcs-edits-in-local-view`,this.layer.title,O(i,t,this.view.viewingMode,0)),null;if(!(y(i,t)||n&&t.isWebMercator&&i.isWGS84))return s.getLogger(this).warn(`unsupported-mismatched-spatial-reference-edits`,this.layer.title,O(i,t,this.view.viewingMode,1)),null}this._logWarningIfMaximumObjectsExceeded();let{objectIdField:a,globalIdField:o}=n,c=[a,...o==null?[]:[o]],l=n.createQuery();l.where=this.layer.definitionExpression||`1=1`,l.returnGeometry=!0,l.outFields=c,l.returnZ=n.hasZ,l.returnM=n.hasM,n.capabilities.query.supportsCacheHint&&(l.cacheHint=!0);let{assetMapFromAssetMapsJSON:u,extractMesh:d}=await import(`../../../../rest/support/meshFeatureSet.js`),f=await this._executeBatchQuery(n,e,l,t),p=[];for(let e of f){if(!e.ok)continue;let{assetMaps:t,features:n,globalIdFieldName:a}=e.value;if(t==null)continue;let o=u(r,t);for(let e of n){let t=d(e,a,i,r,o),n=e;t==null?n.geometry=null:(n.geometry=t,p.push(n))}}return p}_logWarningIfMaximumObjectsExceeded(){if(!this._warnMaximumChangedObjectsExceeded)return;this._warnMaximumChangedObjectsExceeded=!1;let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${b(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`,t=this.layer.portalItem;t?.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,s.getLogger(this).warn(`#queryOverrides()`,this.layer.title,`${e}.`)}async _executeBatchQuery(e,t,r,a){if(t.length===0)return[];let o=x(e);t=[...t].sort((e,t)=>e-t);let s=n(t,o).map(t=>{let n=r.clone();return n.objectIds=t,i(S(e,n,{signal:a}))});return Promise.all(s)}_processOverridesFromAssociatedLayer(e,t,n,{loadedAttributes:r,attributeData:i}){let a=this._associatedLayer;if(a==null)return;let o=a.objectIdField,s=n.map(t=>(t in i||(i[t]=Array(e.length)),i[t])),c=new Map(r.map(e=>[e.name,e.index])),l=n.map(e=>c.get(e)),u=new Map(Array.from(e,(e,t)=>[e,t]));for(let e of t){let t=e.attributes[o];for(let r=0;r<n.length;r++){let i=l[r],a=u.get(t),o=e.attributes[n[r]];s[r][a]=o,this._cacheAttributeValue(t,i,o)}}}async _fetchChangedObjectIds(e){let t=this.layer;await t.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();let{associatedLayer:n}=t;if(n==null||(await n.load({signal:e}),!n.capabilities?.operations?.supportsChangeTracking))return;let r=this._getFetchChangedObjectIdsServerGen();if(r==null)return;let i=await this.extractChanges.fetch(n,{serverGen:r,returnGeometryChanges:this.is3DOFL,signal:e});if(p(e),i!=null)for(this._setChangedObjectIds(i);this._definitionExpressionDirty;)await this._queryAndAddGeometryOverrides(e)}_setChangedObjectIds(e){let{attributeChangedObjectIds:t,geometryChangedObjectIds:n}=e,r=Math.min(this._maximumNumberOfEditOVerrides,t.length);r<t.length&&(this._warnMaximumChangedObjectsExceeded=!0);let i=t.sort((e,t)=>e-t);for(let e=0;e<r;++e){let t=i[e];this._attributeChangedObjectIds.add(t)}for(let e of n)this._geometryChangedObjectIds.add(e)}async _queryAndAddGeometryOverrides(e){this._definitionExpressionDirty=!1;let{associatedLayer:t}=this.layer;if(t!=null&&t.capabilities?.operations?.supportsChangeTracking&&this.is3DOFL&&this._geometryChangedObjectIds.size>0){let n=await this._queryGeometryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),e);if(n!=null)for(let e of n)e.geometry!=null&&this.updateGeometry(e.attributes[t.objectIdField],e.geometry)}}_getFetchChangedObjectIdsServerGen(){let e=this.layer;if(e.serviceUpdateTimeStamp?.lastUpdate!=null)return e.serviceUpdateTimeStamp.lastUpdate;let t=e.associatedLayer;return t?.serverGens?.minServerGen==null?null:t.serverGens.minServerGen}async _lockFeatureIds(e){let t=this._featureIdLocks,n=!0;for(;n;){let r=[];for(let n of e){let e=t.get(n);e&&r.push(e)}r.length===0?n=!1:await Promise.all(r)}let r=Promise.withResolvers(),i=r.promise;for(let n of e)t.set(n,i);return o(()=>{for(let n of e)t.delete(n);r.resolve()})}get test(){}};e([_({constructOnly:!0})],C.prototype,`view`,void 0),e([_({constructOnly:!0})],C.prototype,`layer`,void 0),e([_({constructOnly:!0})],C.prototype,`extractChanges`,void 0),e([_({readOnly:!0})],C.prototype,`is3DOFL`,null),e([_()],C.prototype,`_interactiveEditingSessions`,void 0),e([_({readOnly:!0})],C.prototype,`sortedGeometryChangedObjectIds`,null),e([_({readOnly:!0})],C.prototype,`geometryOverrides`,void 0),e([_()],C.prototype,`_clientGeometryCache`,void 0),e([_()],C.prototype,`_associatedLayer`,null),e([_({constructOnly:!0})],C.prototype,`memoryController`,void 0),e([_()],C.prototype,`_attributeChangedObjectIds`,void 0),e([_()],C.prototype,`_geometryChangedObjectIds`,void 0),e([_()],C.prototype,`hasGeometryChanges`,null),e([_()],C.prototype,`_pendingFetchChangedObjectIds`,void 0),e([_()],C.prototype,`_pendingFetchAbortController`,void 0),e([_()],C.prototype,`_applyGeometryOverridesTask`,void 0),e([_()],C.prototype,`updating`,null),e([_()],C.prototype,`isEmpty`,null),C=e([v(`esri.views.3d.layers.i3s.I3SOverrides`)],C);class w{constructor(e,t){this.objectId=e,this._remove=t,this._updates=new Map,this._isActive=!0}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}remove(){this.isActive&&(this._isActive=!1,this._remove())}get isActive(){return this._isActive}}class T{constructor(e){this._cache=e}destroy(){this._cache.destroy()}put(e,t,n){this._cache.put(this._getKey(e,t),new E(n))}get(e,t){return this._cache.get(this._getKey(e,t))?.value}_getKey(e,t){return`${e}-${t}`}}class E{constructor(e){this.value=e,this.usedMemory=typeof e==`string`?d(e):u}}const D=5e4;function O(e,t,n,r){return`Displaying the edits of a SceneLayer with a${r===0?e.isGeographic?` geographic `:` projected `:` `}spatial reference (wkid:${e.wkid}) in ${n} viewing mode${r===1?` with spatial reference (wkid:${t.wkid}) `:` `}is not supported. No geometry edits will be displayed for this layer.\nPlease consider re-caching the scene service or changing the ${r===0?`viewing mode`:`view spatial reference`} to display edits.`}export{C as I3SOverrides};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{splitIntoChunks as n}from"../../../../core/arrayUtils.js";import{createTask as r,resultOrAbort as i}from"../../../../core/asyncUtils.js";import a from"../../../../core/Collection.js";import{makeHandle as o}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import s from"../../../../core/Logger.js";import{abortMaybe as c,destroyMaybe as l}from"../../../../core/maybe.js";import{estimateNumberMemory as u,estimateStringMemory as d}from"../../../../core/memoryEstimations.js";import{whenOrAbort as f,throwIfAborted as p}from"../../../../core/promiseUtils.js";import m from"../../../../core/ReactiveSet.js";import{watch as h,sync as g}from"../../../../core/reactiveUtils.js";import{property as _,subclass as v}from"../../../../core/accessorSupport/decorators.js";import{equals as y}from"../../../../geometry/support/spatialReferenceUtils.js";import{formatNumber as b}from"../../../../intl/number.js";import{getMaximumQuerySize as x,queryAllJSON as S}from"../../../../layers/support/featureQueryAll.js";let C=class extends t{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=D,this._definitionExpressionDirty=!0,this._interactiveEditingSessions=new a,this.geometryOverrides=new a,this._clientGeometryCache=new Map,this._attributeChangedObjectIds=new m,this._geometryChangedObjectIds=new m,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController,this._applyGeometryOverridesTask=null,this._featureIdLocks=new Map}initialize(){this._memCache=new T(this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`)),this.addHandles(h(()=>this.layer.definitionExpression,async()=>{this._definitionExpressionDirty=!0,this._pendingFetchChangedObjectIds||(this._applyGeometryOverridesTask=c(this._applyGeometryOverridesTask),this._applyGeometryOverridesTask=r(e=>this._queryAndAddGeometryOverrides(e)),await this._applyGeometryOverridesTask.promise.catch(()=>{}))},g)),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.finally(()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null}).catch(()=>{})}destroy(){this._set(`layer`,null),this._memCache=l(this._memCache),this._pendingFetchAbortController=c(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null,this._featureIdLocks.clear()}get is3DOFL(){return this._associatedLayer?.infoFor3D!=null}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort((e,t)=>e-t):[]}get _associatedLayer(){return this.layer==null?null:this.layer.associatedLayer}get hasGeometryChanges(){return this._geometryChangedObjectIds.size>0}get updating(){return this.is3DOFL?!!(this._pendingFetchChangedObjectIds||this._applyGeometryOverridesTask&&!this._applyGeometryOverridesTask.finished):!1}get isEmpty(){return this._pendingFetchChangedObjectIds==null&&this._attributeChangedObjectIds.size===0&&this._geometryChangedObjectIds.size===0}featureHasGeometryChanges(e){return this._geometryChangedObjectIds.has(e)}featureHasAttributeChanges(e){return this._attributeChangedObjectIds.has(e)}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e);let t=this._interactiveEditingSessions,n=new w(e,()=>{t.remove(n)});return t.unshift(n),n}async applyAttributeOverrides(e,t,n,r=[]){if(this._pendingFetchChangedObjectIds&&await f(this._pendingFetchChangedObjectIds,n),t==null)return;let{attributeData:i,loadedAttributes:a}=t;if(a==null||i==null||this._attributeChangedObjectIds.size===0)return;let o=new Set;for(let e of a)o.add(e.index);for(let t of r)o.has(t.index)||(a.push(t),i[t.name]=Array(e.length));let s=await this._lockFeatureIds(e);try{let t={attributeData:i,loadedAttributes:a},{objectIds:r,fieldNames:o}=this._getOverridesFromCache(e,t,this._attributeChangedObjectIds);if(r.length===0||o.length===0)return;let s=await this._queryAttributeOverridesFromAssociatedLayer(r,o,n);if(s==null)return;this._processOverridesFromAssociatedLayer(e,s,o,t)}finally{s.remove()}}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);let n=this._clientGeometryCache.get(e);if(n!=null&&(this.geometryOverrides.remove(n),this._clientGeometryCache.delete(e)),t!=null){let n={oid:e,mesh:t};this.geometryOverrides.add(n),this._clientGeometryCache.set(e,n)}}updateAttributeValue(e,t,n){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,n)}featureAdded(e){this.is3DOFL&&this._geometryChangedObjectIds.add(e),this._attributeChangedObjectIds.add(e)}_cacheAttributeValue(e,t,n){this._memCache.put(e,t,n)}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:n},r){let i=[];for(let e of t)i[e.index]=n[e.name];let a=new Set,o=new Set;for(let n=0;n<e.length;n++){let s=e[n];if(r.has(s))for(let e of t){let t=this._attributeFromCache(s,e.index);t===void 0?(a.add(s),o.add(e.name)):i[e.index][n]=t}}return{objectIds:Array.from(a),fieldNames:Array.from(o)}}_attributeFromCache(e,t){let n=this._fromInteractiveEditingSession(e,t);return n===void 0?this._memCache.get(e,t):n}_fromInteractiveEditingSession(e,t){if(this._interactiveEditingSessions!=null)for(let n of this._interactiveEditingSessions){if(n.objectId!==e)continue;let r=n.getAttribute(t);if(r!==void 0)return r}}async _queryAttributeOverridesFromAssociatedLayer(e,t,n){if(e.length===0)return null;this._logWarningIfMaximumObjectsExceeded();let{associatedLayer:r}=this.layer;if(r==null)return null;let i=r.createQuery(),{objectIdField:a}=r,o=[a,...t];i.where=this.layer.definitionExpression||`1=1`,i.returnGeometry=!1,i.outFields=o,r.capabilities.query.supportsCacheHint&&(i.cacheHint=!0);let s=await this._executeBatchQuery(r,e,i,n),c=[];for(let e of s)if(e.ok)for(let t of e.value.features)c.push(t);return c}async _queryGeometryOverridesFromAssociatedLayer(e,t){if(e.length===0||!this.is3DOFL)return null;let n=this.layer.associatedLayer,r=n.infoFor3D,{spatialReference:i}=n;if(this.view){let{state:{viewingMode:e},spatialReference:t}=this.view,n=e===1,r=i.isGeographic;if(n&&!r)return s.getLogger(this).warn(`unsupported-pcs-edits-in-global-view`,this.layer.title,O(i,t,this.view.viewingMode,0)),null;if(!n&&r)return s.getLogger(this).warn(`unsupported-gcs-edits-in-local-view`,this.layer.title,O(i,t,this.view.viewingMode,0)),null;if(!(y(i,t)||n&&t.isWebMercator&&i.isWGS84))return s.getLogger(this).warn(`unsupported-mismatched-spatial-reference-edits`,this.layer.title,O(i,t,this.view.viewingMode,1)),null}this._logWarningIfMaximumObjectsExceeded();let{objectIdField:a,globalIdField:o}=n,c=[a,...o==null?[]:[o]],l=n.createQuery();l.where=this.layer.definitionExpression||`1=1`,l.returnGeometry=!0,l.outFields=c,l.returnZ=n.hasZ,l.returnM=n.hasM,n.capabilities.query.supportsCacheHint&&(l.cacheHint=!0);let{assetMapFromAssetMapsJSON:u,extractMesh:d}=await import(`../../../../rest/support/meshFeatureSet.js`),f=await this._executeBatchQuery(n,e,l,t),p=[];for(let e of f){if(!e.ok)continue;let{assetMaps:t,features:n,globalIdFieldName:a}=e.value;if(t==null)continue;let o=u(r,t);for(let e of n){let t=d(e,a,i,r,o),n=e;t==null?n.geometry=null:(n.geometry=t,p.push(n))}}return p}_logWarningIfMaximumObjectsExceeded(){if(!this._warnMaximumChangedObjectsExceeded)return;this._warnMaximumChangedObjectsExceeded=!1;let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${b(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`,t=this.layer.portalItem;t?.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,s.getLogger(this).warn(`#queryOverrides()`,this.layer.title,`${e}.`)}async _executeBatchQuery(e,t,r,a){if(t.length===0)return[];let o=x(e);t=[...t].sort((e,t)=>e-t);let s=n(t,o).map(t=>{let n=r.clone();return n.objectIds=t,i(S(e,n,{signal:a}))});return Promise.all(s)}_processOverridesFromAssociatedLayer(e,t,n,{loadedAttributes:r,attributeData:i}){let a=this._associatedLayer;if(a==null)return;let o=a.objectIdField,s=n.map(t=>(t in i||(i[t]=Array(e.length)),i[t])),c=new Map(r.map(e=>[e.name,e.index])),l=n.map(e=>c.get(e)),u=new Map(Array.from(e,(e,t)=>[e,t]));for(let e of t){let t=e.attributes[o];for(let r=0;r<n.length;r++){let i=l[r],a=u.get(t),o=e.attributes[n[r]];s[r][a]=o,this._cacheAttributeValue(t,i,o)}}}async _fetchChangedObjectIds(e){let t=this.layer;await t.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();let{associatedLayer:n}=t;if(n==null||(await n.load({signal:e}),!n.capabilities?.operations?.supportsChangeTracking))return;let r=this._getFetchChangedObjectIdsServerGen();if(r==null)return;let i=await this.extractChanges.fetch(n,{serverGen:r,returnGeometryChanges:this.is3DOFL,signal:e});if(p(e),i!=null)for(this._setChangedObjectIds(i);this._definitionExpressionDirty;)await this._queryAndAddGeometryOverrides(e)}_setChangedObjectIds(e){let{attributeChangedObjectIds:t,geometryChangedObjectIds:n}=e,r=Math.min(this._maximumNumberOfEditOVerrides,t.length);r<t.length&&(this._warnMaximumChangedObjectsExceeded=!0);let i=t.sort((e,t)=>e-t);for(let e=0;e<r;++e){let t=i[e];this._attributeChangedObjectIds.add(t)}for(let e of n)this._geometryChangedObjectIds.add(e)}async _queryAndAddGeometryOverrides(e){this._definitionExpressionDirty=!1;let{associatedLayer:t}=this.layer;if(t!=null&&t.capabilities?.operations?.supportsChangeTracking&&this.is3DOFL&&this._geometryChangedObjectIds.size>0){let n=await this._queryGeometryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),e);if(n!=null)for(let e of n)e.geometry!=null&&this.updateGeometry(e.attributes[t.objectIdField],e.geometry)}}_getFetchChangedObjectIdsServerGen(){let e=this.layer;if(e.serviceUpdateTimeStamp?.lastUpdate!=null)return e.serviceUpdateTimeStamp.lastUpdate;let t=e.associatedLayer;return t?.serverGens?.minServerGen==null?null:t.serverGens.minServerGen}async _lockFeatureIds(e){let t=this._featureIdLocks,n=!0;for(;n;){let r=[];for(let n of e){let e=t.get(n);e&&r.push(e)}r.length===0?n=!1:await Promise.all(r)}let r=Promise.withResolvers(),i=r.promise;for(let n of e)t.set(n,i);return o(()=>{for(let n of e)t.delete(n);r.resolve()})}get test(){}};e([_({constructOnly:!0})],C.prototype,`view`,void 0),e([_({constructOnly:!0})],C.prototype,`layer`,void 0),e([_({constructOnly:!0})],C.prototype,`extractChanges`,void 0),e([_({readOnly:!0})],C.prototype,`is3DOFL`,null),e([_()],C.prototype,`_interactiveEditingSessions`,void 0),e([_({readOnly:!0})],C.prototype,`sortedGeometryChangedObjectIds`,null),e([_({readOnly:!0})],C.prototype,`geometryOverrides`,void 0),e([_()],C.prototype,`_clientGeometryCache`,void 0),e([_()],C.prototype,`_associatedLayer`,null),e([_({constructOnly:!0})],C.prototype,`memoryController`,void 0),e([_()],C.prototype,`_attributeChangedObjectIds`,void 0),e([_()],C.prototype,`_geometryChangedObjectIds`,void 0),e([_()],C.prototype,`hasGeometryChanges`,null),e([_()],C.prototype,`_pendingFetchChangedObjectIds`,void 0),e([_()],C.prototype,`_pendingFetchAbortController`,void 0),e([_()],C.prototype,`_applyGeometryOverridesTask`,void 0),e([_()],C.prototype,`updating`,null),e([_()],C.prototype,`isEmpty`,null),C=e([v(`esri.views.3d.layers.i3s.I3SOverrides`)],C);class w{constructor(e,t){this.objectId=e,this._remove=t,this._updates=new Map,this._isActive=!0}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}remove(){this.isActive&&(this._isActive=!1,this._remove())}get isActive(){return this._isActive}}class T{constructor(e){this._cache=e}destroy(){this._cache.destroy()}put(e,t,n){this._cache.put(this._getKey(e,t),new E(n))}get(e,t){return this._cache.get(this._getKey(e,t))?.value}_getKey(e,t){return`${e}-${t}`}}class E{constructor(e){this.value=e,this.usedMemory=typeof e==`string`?d(e):u}}const D=5e4;function O(e,t,n,r){return`Displaying the edits of a SceneLayer with a${r===0?e.isGeographic?` geographic `:` projected `:` `}spatial reference (wkid:${e.wkid}) in ${n} viewing mode${r===1?` with spatial reference (wkid:${t.wkid}) `:` `}is not supported. No geometry edits will be displayed for this layer.\nPlease consider re-caching the scene service or changing the ${r===0?`viewing mode`:`view spatial reference`} to display edits.`}export{C as I3SOverrides};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import e from"../../../../core/Logger.js";import{getOrCreateMapValue as t}from"../../../../core/MapUtils.js";import{sub as n,normalize as r,len as i,dot as a}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as o,create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.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}destroy(){this._rootNode?.clear(),this._tileMap.clear()}_nextIntersectionGeneration(){return this._intersectionGeneration++,this._intersectionGeneration}addTile(e){let{obb:n}=e,r=[this._ensureRootNode()],i=[],a=t(this._tileMap,e,()=>new Set),o=t=>{if(a.has(t))return;let n=t.addOwnTile(e);T(i,t.parent,n),a.add(t)};for(;r.length>0;){let t=r.pop(),i=this._getSizeStopLength(t);if(t.treeDepth>=U||A(e.obb)>=.5*i){o(t);continue}let{hPlane:a,vPlane:s}=t,c=n.signedDistancePlane(a.normal,a.distance),l=n.signedDistancePlane(s.normal,s.distance);c===0&&l===0?o(t):w(t,c,l,(e,t)=>{r.push(this._ensureChild(e,t))})}this._propagateSummaryUpdates(i)}removeTile(t){if(!this._rootNode){e.getLogger(`Tiles3DBVH`).error(`Tiles3DBVH: Attempted to remove a tile that is not loaded (no root node)`);return}let n=this._tileMap.get(t);if(!n||n.size===0){e.getLogger(`Tiles3DBVH`).error(`Tiles3DBVH internal error: Attempted to remove a tile that is not loaded (not in tile map)`);return}let r=[];this._tileMap.delete(t);for(let e of n){e.removeOwnTile(t);let n=e.updateOwnSummaries();T(r,e.parent,n)}this._propagateSummaryUpdates(r)}_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(e,t,i){let a=this._rootNode;if(!a)return;n(B,t,e);let o=r(B,B);if(!a.subtreeIntersectsRay(e,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 t=c.pop();u.tMax=l.pop(),u.tMin=l.pop(),t.forEachOwnTileIntersectingRay(e,o,u,s,i);let{hPlane:n,vPlane:r}=t;for(let i=0;i<4;i++){let a=t.children[i];if(a==null)continue;let s=i,d=s===0||s===2,f=s===0||s===1,p=N(e,o,N(e,o,u,r,!d),n,!f);p&&a.subtreeIntersectsRay(e,o,p)&&(c.push(a),l.push(p.tMin,p.tMax))}}}_forEachTileIntersectingVerticalRay(e,t,a){let o=this._rootNode;if(!o)return;n(B,t,e);let s=r(B,B),c={tMin:0,tMax:this.viewingMode===`global`?i(e):1/0};if(!o.subtreeIntersectsRay(e,s,c))return;let l=this._nextIntersectionGeneration(),u=[o];for(;u.length>0;){let t=u.pop();t.forEachOwnTileIntersectingRay(e,s,c,l,a),!t.isLeaf&&w(t,k(t.hPlane,e),k(t.vPlane,e),(t,n)=>{let r=t.children[n];r&&r.subtreeIntersectsRay(e,s,c)&&u.push(r)},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(o(0,1,0),0),new D(o(1,0,0),0),n*2,c(-n,-n,-1/0,n,n,1/0));this._rootNode=r}return this._rootNode}_ensureChild(t,n){if(t.treeDepth>=U){let t=`Internal error: attempted to create a child node for a node that is already at max depth`;throw e.getLogger(`Tiles3DBVH`).error(t),Error(t)}let r=t.children[n];if(r===null){let{extent:e,hPlane:i,vPlane:a,treeDepth:o,sideLength:s}=t,l=.5*(e[0]+e[2]),u=.5*(e[1]+e[3]),d=n===0||n===1,f=n===2||n===0,p=g(f?e[0]:l,d?e[1]:u,f?l:e[2],d?u:e[3]),m=new D(i.normal,-.5*(p[1]+p[3])),h=new D(a.normal,-.5*(p[0]+p[2]));r=new C(t,o+1,p,m,h,s*.5,c(p[0],p[1],-1/0,p[2],p[3],1/0)),t.children[n]=r}return r}}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(o(0,0,1),0),new D(o(0,1,0),0),Math.PI*_.radius);this._rootNode=e}return this._rootNode}_ensureChild(t,n){if(t.treeDepth>=U){let t=`Attempted to create a child node for a node that is already at max depth`;throw e.getLogger(`Tiles3DBVH`).error(t),Error(t)}let r=t.children[n];if(r===null){let{extent:e,treeDepth:i}=t,a=.5*(e[0]+e[2]),s=.5*(e[1]+e[3]),c=n===0||n===1,l=n===2||n===0,u=g(l?e[0]:a,c?e[1]:s,l?a:e[2],c?s:e[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=o(-_*p,-_*m,h),y=new D(v,0),b=new D(o(-m,p,0),0),x=j(u);r=new C(t,i+1,u,y,b,x),t.children[n]=r}return r}}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(t){let n=this._ownTiles,r=n.indexOf(t);if(r===-1){e.getLogger(`Tiles3DBVH`).error(`BVNode: Attempted to remove a tile that is not in the node`);return}let i=n.length-1;r<i&&(n[r]=n[i]),n.length=i}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 r=a(n.normal,e)+n.distance;return r<0?Math.min(r+t,0):Math.max(r-t,0)}function k(e,t){return a(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,r,i){if(!n)return null;let o=1e-12,s=a(r.normal,t),c=k(r,e)+n.tMin*s;if(Math.abs(s)<o)return(i?c>=-1e-12:c<=o)?n:null;let l=n.tMin-c/s,u=i===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,i=[o(1,0,0),o(0,1,0),o(0,0,1)],a=r.getCenter(V),s=!1;for(let t=0;t<3;t++){let o=r.projectedRadius(i[t]),c=Math.max(n?.[t]??-1/0,a[t]-o),l=Math.min(n?.[t+3]??1/0,a[t]+o);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=s(),V=s(),H=[],U=30;export{y as createTileBVH};
2
+ import e from"../../../../core/Logger.js";import{getOrCreateMapValue as t}from"../../../../core/MapUtils.js";import{sub as n,normalize as r,len as i,dot as a}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as o,create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.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}destroy(){this._rootNode?.clear(),this._tileMap.clear()}_nextIntersectionGeneration(){return this._intersectionGeneration++,this._intersectionGeneration}addTile(e){let{obb:n}=e,r=[this._ensureRootNode()],i=[],a=t(this._tileMap,e,()=>new Set),o=t=>{if(a.has(t))return;let n=t.addOwnTile(e);T(i,t.parent,n),a.add(t)};for(;r.length>0;){let t=r.pop(),i=this._getSizeStopLength(t);if(t.treeDepth>=U||A(e.obb)>=.5*i){o(t);continue}let{hPlane:a,vPlane:s}=t,c=n.signedDistancePlane(a.normal,a.distance),l=n.signedDistancePlane(s.normal,s.distance);c===0&&l===0?o(t):w(t,c,l,(e,t)=>{r.push(this._ensureChild(e,t))})}this._propagateSummaryUpdates(i)}removeTile(t){if(!this._rootNode){e.getLogger(`Tiles3DBVH`).error(`Tiles3DBVH: Attempted to remove a tile that is not loaded (no root node)`);return}let n=this._tileMap.get(t);if(!n||n.size===0){e.getLogger(`Tiles3DBVH`).error(`Tiles3DBVH internal error: Attempted to remove a tile that is not loaded (not in tile map)`);return}let r=[];this._tileMap.delete(t);for(let e of n){e.removeOwnTile(t);let n=e.updateOwnSummaries();T(r,e.parent,n)}this._propagateSummaryUpdates(r)}_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(e,t,i){let a=this._rootNode;if(!a)return;n(B,t,e);let o=r(B,B);if(!a.subtreeIntersectsRay(e,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 t=c.pop();u.tMax=l.pop(),u.tMin=l.pop(),t.forEachOwnTileIntersectingRay(e,o,u,s,i);let{hPlane:n,vPlane:r}=t;for(let i=0;i<4;i++){let a=t.children[i];if(a==null)continue;let s=i,d=s===0||s===2,f=s===0||s===1,p=N(e,o,N(e,o,u,r,!d),n,!f);p&&a.subtreeIntersectsRay(e,o,p)&&(c.push(a),l.push(p.tMin,p.tMax))}}}_forEachTileIntersectingVerticalRay(e,t,a){let o=this._rootNode;if(!o)return;n(B,t,e);let s=r(B,B),c={tMin:0,tMax:this.viewingMode===`global`?i(e):1/0};if(!o.subtreeIntersectsRay(e,s,c))return;let l=this._nextIntersectionGeneration(),u=[o];for(;u.length>0;){let t=u.pop();t.forEachOwnTileIntersectingRay(e,s,c,l,a),t.isLeaf||w(t,k(t.hPlane,e),k(t.vPlane,e),(t,n)=>{let r=t.children[n];r&&r.subtreeIntersectsRay(e,s,c)&&u.push(r)},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(o(0,1,0),0),new D(o(1,0,0),0),n*2,c(-n,-n,-1/0,n,n,1/0));this._rootNode=r}return this._rootNode}_ensureChild(t,n){if(t.treeDepth>=U){let t=`Internal error: attempted to create a child node for a node that is already at max depth`;throw e.getLogger(`Tiles3DBVH`).error(t),Error(t)}let r=t.children[n];if(r===null){let{extent:e,hPlane:i,vPlane:a,treeDepth:o,sideLength:s}=t,l=.5*(e[0]+e[2]),u=.5*(e[1]+e[3]),d=n===0||n===1,f=n===2||n===0,p=g(f?e[0]:l,d?e[1]:u,f?l:e[2],d?u:e[3]),m=new D(i.normal,-.5*(p[1]+p[3])),h=new D(a.normal,-.5*(p[0]+p[2]));r=new C(t,o+1,p,m,h,s*.5,c(p[0],p[1],-1/0,p[2],p[3],1/0)),t.children[n]=r}return r}}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(o(0,0,1),0),new D(o(0,1,0),0),Math.PI*_.radius);this._rootNode=e}return this._rootNode}_ensureChild(t,n){if(t.treeDepth>=U){let t=`Attempted to create a child node for a node that is already at max depth`;throw e.getLogger(`Tiles3DBVH`).error(t),Error(t)}let r=t.children[n];if(r===null){let{extent:e,treeDepth:i}=t,a=.5*(e[0]+e[2]),s=.5*(e[1]+e[3]),c=n===0||n===1,l=n===2||n===0,u=g(l?e[0]:a,c?e[1]:s,l?a:e[2],c?s:e[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=o(-_*p,-_*m,h),y=new D(v,0),b=new D(o(-m,p,0),0),x=j(u);r=new C(t,i+1,u,y,b,x),t.children[n]=r}return r}}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(t){let n=this._ownTiles,r=n.indexOf(t);if(r===-1){e.getLogger(`Tiles3DBVH`).error(`BVNode: Attempted to remove a tile that is not in the node`);return}let i=n.length-1;r<i&&(n[r]=n[i]),n.length=i}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 r=a(n.normal,e)+n.distance;return r<0?Math.min(r+t,0):Math.max(r-t,0)}function k(e,t){return a(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,r,i){if(!n)return null;let o=1e-12,s=a(r.normal,t),c=k(r,e)+n.tMin*s;if(Math.abs(s)<o)return(i?c>=-1e-12:c<=o)?n:null;let l=n.tMin-c/s,u=i===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,i=[o(1,0,0),o(0,1,0),o(0,0,1)],a=r.getCenter(V),s=!1;for(let t=0;t<3;t++){let o=r.projectedRadius(i[t]),c=Math.max(n?.[t]??-1/0,a[t]-o),l=Math.min(n?.[t+3]??1/0,a[t]+o);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=s(),V=s(),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{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import n from"../../../../core/Error.js";import{destroyMaybe as r}from"../../../../core/maybe.js";import{throwIfAborted as i,createAbortError as a}from"../../../../core/promiseUtils.js";import{difference as o}from"../../../../core/SetUtils.js";import{parseWhereClause as s}from"../../../../core/sql.js";import{property as c,subclass as l}from"../../../../core/accessorSupport/decorators.js";import{fromFeatureSetJSON as u}from"../../../../layers/graphics/dehydratedFeatures.js";import{canConvertSqlRelativeTime as d,sqlRelativeTimeToAbsolute as f}from"../../../../layers/support/relativeTimeQueryUtils.js";import{queueAutoPriority as p}from"../../../../request/queue.js";import{runQuery as m,executeQuery as h,executeQueryForCount as g}from"../../../../rest/query/operations/query.js";import{PBFDecoder as _}from"../../support/PBFDecoder.js";let v=class extends t{constructor(e){super(e)}get implicitFields(){if(!this.layer.outFields?.includes(`*`))return new Set;let e=new Set(this.layerView.requiredFields),t=new Set(this.layerView.availableFields);return o(t,e)}async queryFeaturesDehydrated(e,t){let{layer:n}=this,r=n.capabilities,o=r?.query?.supportsFormatPBF,c=n.parsedUrl,l=d(e.where)?await f(n.fieldsIndex,e.where,r.query.relativeTimeBinWindow):e.where,p=e.where;l!==e.where&&(e=e.clone(),e.where=l);let g;if(o){this._decoder??=new _(this.controller);let r={sourceSpatialReference:n.spatialReference?.toJSON()??null,applyTransform:!0,maxStringAttributeFields:this.implicitFields,maxStringAttributeLength:S};g=await m(c,e,`pbf`,this._createRequestOptions(t)).then(e=>(i(t),this._decoder==null?Promise.reject(a()):this._decoder.invoke({buffer:e,options:r},t.completeFeatureFromTransfer,t.signal)))}else g=await h(c,e,n.spatialReference,this._createRequestOptions(t)).then(e=>u(e,{maxStringAttributeFields:this.implicitFields,maxStringAttributeLength:S}));if(p&&e.where!==p){let e=await this.controller.schedule(()=>s(p,this.layer.fieldsIndex),t.signal);g.features=await this.controller.schedule(()=>g.features.filter(t=>e.testFeatureCompiled(t)),t.signal)}return g}queryFeatureCount(e,t){return g(this.layer.parsedUrl,e,this._createRequestOptions(t))}destroy(){this._decoder=r(this._decoder)}_createRequestOptions(e){return{...p,...e,query:{...this.layer.customParameters,token:this.layer.apiKey,...e?.query}}}};e([c({constructOnly:!0})],v.prototype,`layer`,void 0),e([c({constructOnly:!0})],v.prototype,`layerView`,void 0),e([c({constructOnly:!0})],v.prototype,`controller`,void 0),e([c({readOnly:!0})],v.prototype,`implicitFields`,null),v=e([l(`esri.views.3d.layers.support.featureTileQuery3D.FeatureTileServiceQuery3D`)],v);let y=class extends t{constructor(e){super(e)}queryFeaturesDehydrated(e,t){return this.layer.queryFeatures(e,t)}};e([c({constructOnly:!0})],y.prototype,`layer`,void 0),y=e([l(`esri.views.3d.layers.support.featureTileQuery3D.FeatureTileOGCServiceQuery3D`)],y);let b=class extends t{constructor(e){super(e)}queryFeaturesDehydrated(e,t){return this.layer.source.queryFeaturesJSON(e,t).then(u,n=>{if(n&&n.name===`query-features-json:unsupported`)return this.layer.queryFeatures(e,t);throw n})}queryFeatureCount(e,t){return this.layer.queryFeatureCount(e,t)}};e([c({constructOnly:!0})],b.prototype,`layer`,void 0),b=e([l(`esri.views.3d.layers.support.featureTileQuery3D.FeatureTileClientQuery3D`)],b);function x(e,t){let{layer:r}=e;switch(r.type){case`feature`:switch(r.source.type){case`feature-layer`:return new v({layer:r,layerView:e,controller:t});case`memory`:return new b({layer:r});case`csv`:case`geojson`:case`oriented-imagery`:case`wfs`:case`ogc-feature`:case`parquet`:break;default:r.source.type}break;case`catalog-footprint`:return new v({layer:r,layerView:e,controller:t});case`csv`:case`geojson`:case`oriented-imagery`:case`wfs`:return new b({layer:r});case`ogc-feature`:return new y({layer:r})}throw new n(`feature-layer:unsupported`,`Unsupported Feature layer type ${e.layer.type}:${e.layer.source.type}`)}const S=1024;export{x as createFeatureTileQuery3D};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import n from"../../../../core/Error.js";import{destroyMaybe as r}from"../../../../core/maybe.js";import{throwIfAborted as i,createAbortError as a}from"../../../../core/promiseUtils.js";import{difference as o}from"../../../../core/SetUtils.js";import{parseWhereClause as s}from"../../../../core/sql.js";import{property as c,subclass as l}from"../../../../core/accessorSupport/decorators.js";import{fromFeatureSetJSON as u}from"../../../../layers/graphics/dehydratedFeatures.js";import{canConvertSqlRelativeTime as d,sqlRelativeTimeToAbsolute as f}from"../../../../layers/support/relativeTimeQueryUtils.js";import p from"../../../../layers/support/TimeInformation.js";import{queueAutoPriority as m}from"../../../../request/queue.js";import{runQuery as h,executeQuery as g,executeQueryForCount as _}from"../../../../rest/query/operations/query.js";import{PBFDecoder as v}from"../../support/PBFDecoder.js";let y=class extends t{constructor(e){super(e)}get implicitFields(){if(!this.layer.outFields?.includes(`*`))return new Set;let e=new Set(this.layerView.requiredFields),t=new Set(this.layerView.availableFields);return o(t,e)}async queryFeaturesDehydrated(e,t){let{layer:n}=this,r=n.capabilities,o=r?.query?.supportsFormatPBF,c=n.parsedUrl,l=d(e.where)?await f(n.fieldsIndex,e.where,r.query.relativeTimeBinWindow):e.where,p=e.where;l!==e.where&&(e=e.clone(),e.where=l);let m;if(o){this._decoder??=new v(this.controller);let r={sourceSpatialReference:n.spatialReference?.toJSON()??null,applyTransform:!0,maxStringAttributeFields:this.implicitFields,maxStringAttributeLength:C};m=await h(c,e,`pbf`,this._createRequestOptions(t),void 0,this._createLayerMetadata()).then(e=>(i(t),this._decoder==null?Promise.reject(a()):this._decoder.invoke({buffer:e,options:r},t.completeFeatureFromTransfer,t.signal)))}else m=await g(c,e,n.spatialReference,this._createRequestOptions(t),this._createLayerMetadata()).then(e=>u(e,{maxStringAttributeFields:this.implicitFields,maxStringAttributeLength:C}));if(p&&e.where!==p){let e=await this.controller.schedule(()=>s(p,this.layer.fieldsIndex),t.signal);m.features=await this.controller.schedule(()=>m.features.filter(t=>e.testFeatureCompiled(t)),t.signal)}return m}queryFeatureCount(e,t){return _(this.layer.parsedUrl,e,this._createRequestOptions(t),this._createLayerMetadata())}destroy(){this._decoder=r(this._decoder)}_createLayerMetadata(){let{layer:e}=this,{fieldsIndex:t}=e,n=`uniqueIdFields`in e?e.uniqueIdFields:void 0;return{timeInformation:new p({fieldsIndex:t,layer:e}),uniqueIdFields:n}}_createRequestOptions(e){return{...m,...e,query:{...this.layer.customParameters,token:this.layer.apiKey,...e?.query}}}};e([c({constructOnly:!0})],y.prototype,`layer`,void 0),e([c({constructOnly:!0})],y.prototype,`layerView`,void 0),e([c({constructOnly:!0})],y.prototype,`controller`,void 0),e([c({readOnly:!0})],y.prototype,`implicitFields`,null),y=e([l(`esri.views.3d.layers.support.featureTileQuery3D.FeatureTileServiceQuery3D`)],y);let b=class extends t{constructor(e){super(e)}queryFeaturesDehydrated(e,t){return this.layer.queryFeatures(e,t)}};e([c({constructOnly:!0})],b.prototype,`layer`,void 0),b=e([l(`esri.views.3d.layers.support.featureTileQuery3D.FeatureTileOGCServiceQuery3D`)],b);let x=class extends t{constructor(e){super(e)}queryFeaturesDehydrated(e,t){return this.layer.source.queryFeaturesJSON(e,t).then(u,n=>{if(n&&n.name===`query-features-json:unsupported`)return this.layer.queryFeatures(e,t);throw n})}queryFeatureCount(e,t){return this.layer.queryFeatureCount(e,t)}};e([c({constructOnly:!0})],x.prototype,`layer`,void 0),x=e([l(`esri.views.3d.layers.support.featureTileQuery3D.FeatureTileClientQuery3D`)],x);function S(e,t){let{layer:r}=e;switch(r.type){case`feature`:switch(r.source.type){case`feature-layer`:return new y({layer:r,layerView:e,controller:t});case`memory`:return new x({layer:r});case`csv`:case`geojson`:case`oriented-imagery`:case`wfs`:case`ogc-feature`:case`parquet`:break;default:r.source.type}break;case`catalog-footprint`:return new y({layer:r,layerView:e,controller:t});case`csv`:case`geojson`:case`oriented-imagery`:case`wfs`:return new x({layer:r});case`ogc-feature`:return new b({layer:r})}throw new n(`feature-layer:unsupported`,`Unsupported Feature layer type ${e.layer.type}:${e.layer.source.type}`)}const C=1024;export{S as createFeatureTileQuery3D};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{clamp as t}from"../../../../core/mathUtils.js";import{createScreenPointArray as n}from"../../../../core/screenUtils.js";import{subclass as r}from"../../../../core/accessorSupport/decorators.js";import{copy as i,distance as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{subtract as s,length as c,normalize as l,scale as u,add as d,negate as f,copy as p,lerp as m}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as h,fromValues as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as _,fromPositionAndNormal as v}from"../../../../geometry/support/plane.js";import{pixelDistanceToInteractionFactor as y,applyAll as b}from"../../camera/constraintUtils.js";import{ConstraintOptions as x}from"../../camera/constraintUtils/ConstraintOptions.js";import{getVoxelWasm as S}from"../../layers/VoxelWasm.js";import{InteractiveController as C}from"./InteractiveController.js";import{normalizeCoordinate as w,excludeTerrain as T,zoomPivotDistanceClamp as E,getTiltScaleFactor as D,maxZoomPivotDistanceModifier as O,searchAreaSize as k,intersectPlaneFromScreenPoint as A,distanceComparisonTolerance as j}from"../utils/navigationUtils.js";let M=class extends C{constructor(){super(...arguments),this._tmpP=h(),this._tmpDir=h(),this._tmpN=h(),this._tmpP0=o(),this._tmpPoi=h(),this._tmpRayDir=h(),this.dragBeginPoint=n(),this._normalizedAnchorPoint=o(),this._constraintOptions=new x(15,1,0,this.startCamera,h()),this._plane=_()}get _intersectionHelper(){return this.view.sceneIntersectionHelper}begin(e){if(!this.running)return;i(this.dragBeginPoint,e),w(this.startCamera,e,this._normalizedAnchorPoint);let n=this._intersectionHelper.intersectScreenFreePointFallback(e,this._tmpP,this.view.groundView.invisible?T:{});s(this._tmpDir,this._tmpP,this.startCamera.eye);let r=c(this._tmpDir);l(this._tmpDir,this._tmpDir);let a=Math.abs(this.view.camera.position.z),o=t(D(P,this._tmpDir,O)*a,E[0],E[1]),p=this.view.stage.renderView.getMinimalDepthForArea(S(this.view),e[0],e[1],this.view.state.camera,k)??o;n&&(p=Math.min(p,r)),u(this._tmpDir,this._tmpDir,p),d(this._tmpP,this.startCamera.eye,this._tmpDir),s(this._tmpN,this.startCamera.eye,this.startCamera.center),l(this._tmpN,this._tmpN),this._tmpN[1]<0&&f(this._tmpN,this._tmpN),v(this._tmpP,this._tmpN,this._plane)}update(e){if(!this.running)return;A(this._plane,this.currentCamera,this.dragBeginPoint,this._tmpPoi)||p(this._tmpPoi,this.currentCamera.center),w(this.currentCamera,e,this._tmpP0);let t=(this._tmpP0[1]-this._normalizedAnchorPoint[1])*4;i(this._normalizedAnchorPoint,this._tmpP0),s(this._tmpRayDir,this._tmpPoi,this.currentCamera.eye);let n=c(this._tmpRayDir),r=n*(1-t);this._constraintOptions.interactionDirection&&(p(this._constraintOptions.interactionDirection,this._tmpRayDir),u(this._constraintOptions.interactionDirection,this._constraintOptions.interactionDirection,Math.sign(t)/n));let o=this.view.state.constraints.minimumPoiDistance;t>=0&&r<o&&(r=o,t=-(r-n)/n),!(Math.abs(n-r)<j)&&(u(this._tmpRayDir,this._tmpRayDir,t),this.currentCamera.eye=d(N,this.currentCamera.eye,this._tmpRayDir),m(N,this.currentCamera.center,this._tmpPoi,t),this._tmpPoi[2]>this.startCamera.center[2]?N[2]=Math.max(this.startCamera.center[2],N[2]):N[2]=Math.min(this.startCamera.center[2],N[2]),this.currentCamera.center=N,this._constraintOptions.interactionFactor=y(a(this.dragBeginPoint,e)),b(this.view,this.currentCamera,this._constraintOptions),this.commitCamera())}finish(){this.running&&this.finishController()}};M=e([r(`esri.views.3d.state.controllers.ZoomControllerLocal`)],M);const N=h(),P=g(0,0,1);export{M as ZoomControllerLocal};
2
+ import{__decorate as e}from"tslib";import{clamp as t}from"../../../../core/mathUtils.js";import{createScreenPointArray as n}from"../../../../core/screenUtils.js";import{subclass as r}from"../../../../core/accessorSupport/decorators.js";import{copy as i,distance as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{subtract as s,length as c,normalize as l,scale as u,add as d,negate as f,copy as p,lerp as m}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as h,fromValues as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as _,fromPositionAndNormal as v}from"../../../../geometry/support/plane.js";import{pixelDistanceToInteractionFactor as y,applyAll as b}from"../../camera/constraintUtils.js";import{ConstraintOptions as x}from"../../camera/constraintUtils/ConstraintOptions.js";import{getVoxelWasm as S}from"../../layers/VoxelWasm.js";import{InteractiveController as C}from"./InteractiveController.js";import{normalizeCoordinate as w,excludeTerrain as T,zoomPivotDistanceClamp as E,getTiltScaleFactor as D,maxZoomPivotDistanceModifier as O,searchAreaSize as k,intersectPlaneFromScreenPoint as A,distanceComparisonTolerance as j}from"../utils/navigationUtils.js";let M=class extends C{constructor(){super(...arguments),this._tmpP=h(),this._tmpDir=h(),this._tmpN=h(),this._tmpP0=o(),this._tmpPoi=h(),this._tmpRayDir=h(),this.dragBeginPoint=n(),this._normalizedAnchorPoint=o(),this._constraintOptions=new x(15,1,0,this.startCamera,h()),this._plane=_()}get _intersectionHelper(){return this.view.sceneIntersectionHelper}begin(e){if(!this.running)return;i(this.dragBeginPoint,e),w(this.startCamera,e,this._normalizedAnchorPoint);let n=this._intersectionHelper.intersectScreenFreePointFallback(e,this._tmpP,this.view.groundView.invisible?T:{});s(this._tmpDir,this._tmpP,this.startCamera.eye);let r=c(this._tmpDir);l(this._tmpDir,this._tmpDir);let a=Math.abs(this.view.camera.position.z),o=t(D(P,this._tmpDir,O)*a,E[0],E[1]),p=this.view.stage.renderView.getMinimalDepthForArea(S(this.view),e[0],e[1],this.view.state.camera,k)??o;n&&(p=Math.min(p,r)),u(this._tmpDir,this._tmpDir,p),d(this._tmpP,this.startCamera.eye,this._tmpDir),s(this._tmpN,this.startCamera.eye,this.startCamera.center),l(this._tmpN,this._tmpN),this._tmpN[1]<0&&f(this._tmpN,this._tmpN),v(this._tmpP,this._tmpN,this._plane)}update(e){if(!this.running)return;A(this._plane,this.currentCamera,this.dragBeginPoint,this._tmpPoi)||p(this._tmpPoi,this.currentCamera.center),w(this.currentCamera,e,this._tmpP0);let t=(this._tmpP0[1]-this._normalizedAnchorPoint[1])*4;i(this._normalizedAnchorPoint,this._tmpP0),s(this._tmpRayDir,this._tmpPoi,this.currentCamera.eye);let n=c(this._tmpRayDir),r=n*(1-t);this._constraintOptions.interactionDirection&&(p(this._constraintOptions.interactionDirection,this._tmpRayDir),u(this._constraintOptions.interactionDirection,this._constraintOptions.interactionDirection,Math.sign(t)/n));let o=this.view.state.constraints.minimumPoiDistance;t>=0&&r<o&&(r=o,t=-(r-n)/n),Math.abs(n-r)<j||(u(this._tmpRayDir,this._tmpRayDir,t),this.currentCamera.eye=d(N,this.currentCamera.eye,this._tmpRayDir),m(N,this.currentCamera.center,this._tmpPoi,t),this._tmpPoi[2]>this.startCamera.center[2]?N[2]=Math.max(this.startCamera.center[2],N[2]):N[2]=Math.min(this.startCamera.center[2],N[2]),this.currentCamera.center=N,this._constraintOptions.interactionFactor=y(a(this.dragBeginPoint,e)),b(this.view,this.currentCamera,this._constraintOptions),this.commitCamera())}finish(){this.running&&this.finishController()}};M=e([r(`esri.views.3d.state.controllers.ZoomControllerLocal`)],M);const N=h(),P=g(0,0,1);export{M as ZoomControllerLocal};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{clamp as t}from"../../../../core/mathUtils.js";import{Milliseconds as n}from"../../../../core/time.js";import{subclass as r}from"../../../../core/accessorSupport/decorators.js";import{copy as i,subtract as a,normalize as o,length as s,add as c,scale as l,squaredDistance as u,lerp as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as f,fromValues as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{applyAll as m}from"../../camera/constraintUtils.js";import{ConstraintOptions as h}from"../../camera/constraintUtils/ConstraintOptions.js";import{getVoxelWasm as g}from"../../layers/VoxelWasm.js";import{PointToPointAnimationController as _}from"./PointToPointAnimationController.js";import{excludeTerrain as v,zoomStepDistanceClamp as y,getTiltScaleFactor as b,maxZoomStepDistanceModifier as x,distanceComparisonTolerance as S}from"../utils/navigationUtils.js";import C from"../../webgl/RenderCamera.js";import{Intersector as w}from"../../webgl-engine/lib/Intersector.js";import{outExpo as T}from"../../../animation/easing.js";let E=class extends _{constructor(){super(...arguments),this._zoomLocation=f(),this._tmpCamera=new C,this._tmpRayDir=f(),this._tmpCenter=f(),this._beginCamera=new C,this._constraintOptions=new h(15,1,null,this._beginCamera)}initialize(){this._intersector=new w(this.view.state.viewingMode)}step(e,n){if(!this.running)return;let r=this.view.state;this.animation.finished?this._beginCamera.copyFrom(r.camera):this.animation.cameraAt(1,this._beginCamera),this._tmpCamera.copyFrom(r.camera);let u=!1;e>0?(u=this._intersectionHelper.intersectScreenFreePointFallback(n,this._zoomLocation,this.view.groundView.invisible?v:{}),this._intersectsValidTarget(this._tmpCamera,this._tmpCenter)&&(this._tmpCamera.center=this._tmpCenter)):this._intersectsValidTarget(this._tmpCamera,this._zoomLocation)?this._tmpCamera.center=this._zoomLocation:i(this._zoomLocation,this._tmpCamera.center);let d=.6**e,p=this.view.stage.renderView.getMinimalDepthForArea(g(this.view),n[0],n[1],this.view.state.camera,60);a(k,this._tmpCamera.eye,this._zoomLocation),o(k,k);let m=Math.abs(this.view.camera.position.z),h=t(b(O,k,x)*m,y[0],y[1]);p??=h;let _=f();a(_,this._zoomLocation,this._tmpCamera.eye),(p<s(_)||!u)&&(o(_,_),c(this._zoomLocation,this._tmpCamera.eye,l(_,_,p))),this._updateCamera(this._tmpCamera,d,this._zoomLocation),this.begin(this._tmpCamera)}_intersectsValidTarget(e,t){return this._intersectionHelper.intersectRay(e.ray,this._intersector,t)?u(e.eye,t)>=16:!1}animationSettings(){return{duration:n(600),easing:T}}_updateCamera(e,t,n){a(this._tmpRayDir,n,e.eye);let r=s(this._tmpRayDir),i=r*t,o=t<=1,c=Math.max(4,e.nearFar[0]*1.01);i!==0&&(o&&i<c&&(i=c,t=i/r),!(Math.abs(r-i)<S)&&(l(this._tmpRayDir,this._tmpRayDir,t),e.eye=a(D,n,this._tmpRayDir),e.center=d(D,e.center,n,1-t),m(this.view,e,this._constraintOptions)))}};E=e([r(`esri.views.3d.state.controllers.ZoomStepControllerLocal`)],E);const D=f(),O=p(0,0,1),k=f();export{E as ZoomStepControllerLocal};
2
+ import{__decorate as e}from"tslib";import{clamp as t}from"../../../../core/mathUtils.js";import{Milliseconds as n}from"../../../../core/time.js";import{subclass as r}from"../../../../core/accessorSupport/decorators.js";import{copy as i,subtract as a,normalize as o,length as s,add as c,scale as l,squaredDistance as u,lerp as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as f,fromValues as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{applyAll as m}from"../../camera/constraintUtils.js";import{ConstraintOptions as h}from"../../camera/constraintUtils/ConstraintOptions.js";import{getVoxelWasm as g}from"../../layers/VoxelWasm.js";import{PointToPointAnimationController as _}from"./PointToPointAnimationController.js";import{excludeTerrain as v,zoomStepDistanceClamp as y,getTiltScaleFactor as b,maxZoomStepDistanceModifier as x,distanceComparisonTolerance as S}from"../utils/navigationUtils.js";import C from"../../webgl/RenderCamera.js";import{Intersector as w}from"../../webgl-engine/lib/Intersector.js";import{outExpo as T}from"../../../animation/easing.js";let E=class extends _{constructor(){super(...arguments),this._zoomLocation=f(),this._tmpCamera=new C,this._tmpRayDir=f(),this._tmpCenter=f(),this._beginCamera=new C,this._constraintOptions=new h(15,1,null,this._beginCamera)}initialize(){this._intersector=new w(this.view.state.viewingMode)}step(e,n){if(!this.running)return;let r=this.view.state;this.animation.finished?this._beginCamera.copyFrom(r.camera):this.animation.cameraAt(1,this._beginCamera),this._tmpCamera.copyFrom(r.camera);let u=!1;e>0?(u=this._intersectionHelper.intersectScreenFreePointFallback(n,this._zoomLocation,this.view.groundView.invisible?v:{}),this._intersectsValidTarget(this._tmpCamera,this._tmpCenter)&&(this._tmpCamera.center=this._tmpCenter)):this._intersectsValidTarget(this._tmpCamera,this._zoomLocation)?this._tmpCamera.center=this._zoomLocation:i(this._zoomLocation,this._tmpCamera.center);let d=.6**e,p=this.view.stage.renderView.getMinimalDepthForArea(g(this.view),n[0],n[1],this.view.state.camera,60);a(k,this._tmpCamera.eye,this._zoomLocation),o(k,k);let m=Math.abs(this.view.camera.position.z),h=t(b(O,k,x)*m,y[0],y[1]);p??=h;let _=f();a(_,this._zoomLocation,this._tmpCamera.eye),(p<s(_)||!u)&&(o(_,_),c(this._zoomLocation,this._tmpCamera.eye,l(_,_,p))),this._updateCamera(this._tmpCamera,d,this._zoomLocation),this.begin(this._tmpCamera)}_intersectsValidTarget(e,t){return this._intersectionHelper.intersectRay(e.ray,this._intersector,t)?u(e.eye,t)>=16:!1}animationSettings(){return{duration:n(600),easing:T}}_updateCamera(e,t,n){a(this._tmpRayDir,n,e.eye);let r=s(this._tmpRayDir),i=r*t,o=t<=1,c=Math.max(4,e.nearFar[0]*1.01);i!==0&&(o&&i<c&&(i=c,t=i/r),Math.abs(r-i)<S||(l(this._tmpRayDir,this._tmpRayDir,t),e.eye=a(D,n,this._tmpRayDir),e.center=d(D,e.center,n,1-t),m(this.view,e,this._constraintOptions)))}};E=e([r(`esri.views.3d.state.controllers.ZoomStepControllerLocal`)],E);const D=f(),O=p(0,0,1),k=f();export{E as ZoomStepControllerLocal};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{lerp as e}from"../../../../core/mathUtils.js";import t from"../../../../core/PooledArray.js";import{castRenderScreenPointArray3 as n,createRenderScreenPointArray3 as r,createScreenPointArray as i}from"../../../../core/screenUtils.js";import{getMetersPerVerticalUnitForSR as a}from"../../../../core/units.js";import{set as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as s}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{add as c,normalize as l,dot as u,distance as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as f,clone as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as m,copy as h,negativeInfinity as g,expandWithNestedArray as _}from"../../../../geometry/support/aaBoundingRect.js";import{createSpatialReferenceCyclical as v}from"../../../../geometry/support/normalizeUtils.js";import{create as y}from"../../../../geometry/support/ray.js";import{sv3d as b}from"../../../../geometry/support/vectorStacks.js";import{getElevationOffsetInMeters as x}from"../../../../support/elevationInfoUtils.js";import{g as S}from"../../../../chunks/cameraUtilsSpherical.js";import{computeMapPointFromVec3d as C}from"../../support/hitTest.js";import{fromRenderAtEye as w,fromScreen as T}from"../../support/geometryUtils/ray.js";import{defaultTolerance as E,Intersector as D,defaultScreenPolygonPrimitiveProcessor as O}from"../../webgl-engine/lib/Intersector.js";import{RayIntersectionQuery as k,DrapedScreenPolygonIntersectionQuery as A}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as j}from"../../webgl-engine/lib/IntersectorResult.js";import{SliceScreenPolygonPrimitiveProcessor as M,createSliceExtrusionHalfspacePlanes as N,clipPolygonAgainstSlicedAwayHalfspaces as P,sliceFilterPredicate as F}from"../../webgl-engine/lib/intersectorUtils.js";import{prepareScreenPolygonIntersectionQuery as I}from"../../webgl-engine/lib/screenPolygonIntersectionUtils.js";import{TaskPriority as L}from"../../../support/Scheduler.js";class R{constructor(e,n,r){this.viewingMode=e,this._forEachLayer=n,this._view=r,this._externalIntersectionHandlers=new t,this._tolerance=E,this._tmpRay=y(),this._tmpRegion=m(),this._validateHUDIntersector=new D(this.viewingMode),this._validateHUDIntersector.options.hud=!1,this._screenPolygonIntersectionTask=this._view.resourceController.scheduler.registerTask(L.SCREEN_POLYGON_INTERSECTION)}destroy(){this._screenPolygonIntersectionTask.remove(),this._externalIntersectionHandlers.prune()}get screenPolygonIntersectionTask(){return this._screenPolygonIntersectionTask}intersectScreen(e,t,n){return this.intersectRay(this._getPickRay(e,this._tmpRay),H(this.viewingMode),t,n)}intersectScreenFreePointFallback(e,t,n){return this.intersectRayFreePointFallback(this._getPickRay(e,this._tmpRay),t,n)}intersectRayFreePointFallback(e,t,n){return this.intersectRay(e,H(this.viewingMode),t,n)||this._intersectRayFreePointLocal(e,t)}intersectRay(e,t,n,r){return t.options.selectionMode=!1,t.options.store=0,this.computeIntersection(e,t,!1,r),t.results.min?t.results.min.getIntersectionPoint(n):!1}getCenterRayWithSubpixelOffset(e,t,n=.5,r=.5){return e.getRenderCenter(Z,n,r),Z[0]+=.0466,Z[1]-=.0123,w(e,Z,t)}intersectIntersectorScreen(e,t,n){this.computeIntersection(this._getPickRay(e,this._tmpRay),t,!1,n)}async intersectIntersectorScreenPolygon(e,t,n){t.polygonResults.init();let r=this._view.state.camera,i=await I(r,e);i!=null&&await this._screenPolygonIntersectionTask.scheduleGenerator(e=>this._intersectIntersectorScreenPolygon(r,t,i,n,e))}*_intersectIntersectorScreenPolygon(e,t,n,r,i){let a=new U(r,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!r||!(`include`in r||`exclude`in r),t.camera=e,t.point=null,t.screenPolygonPrimitiveProcessor=O,yield*t.intersectScreenPolygon(a.layers,n);let o=this._view.slice.plane,s=o?new M(o):null;t.screenPolygonPrimitiveProcessor=s??O,yield*t.intersectScreenPolygon(a.sliceableLayers,n),t.screenPolygonPrimitiveProcessor=O,yield*this._intersectPolygonHandlersGenerator(t,a,n,null,s,void 0,!0,i),yield*this._intersectDrapedScreenPolygon(t,a,n,r),yield*t.intersectHUDScreenPolygon(a.layers,n),t.screenPolygonPrimitiveProcessor=s??O,yield*t.intersectHUDScreenPolygon(a.sliceableLayers,n),t.polygonResults.sortResults()}intersectToolIntersectorScreen(e,t,n){let r=this._getPickRay(e,this._tmpRay);this.intersectToolIntersectorRay(r,t,n)}intersectToolIntersectorRay(e,t,n){t.options.selectionMode=!0,this.computeIntersection(e,t,!1,n);let r=t.results.min;this._view.groundView.opaque||j(r)&&r.intersector!==7||(t.options.selectionMode=!1,this.computeIntersection(e,t,!1,n))}setTolerance(e=E){this._tolerance=e}addIntersectionHandler(e){this._externalIntersectionHandlers.push(e),this._externalIntersectionHandlers.sort((e,t)=>e.type===7?1:t.type===7?-1:0)}removeIntersectionHandler(e){this._externalIntersectionHandlers.removeUnordered(e)!=null&&this._externalIntersectionHandlers.sort((e,t)=>e.type===7?1:t.type===7?-1:0)}_getPickRay(e,t){let n=this._view.state.camera;return T(n,e,t)}_intersectRayFreePointLocal(e,t){return this.viewingMode!==2||e==null||c(t,e.origin,l(b.get(),e.direction)),!1}intersectElevationFromScreen(e,t,n=0,r=null){return this._intersectElevation(this._getPickRay(e,this._tmpRay),t,n,r)}_intersectElevation(e,t,r=0,i=null){if(e==null)return null;let o=this._view,{renderCoordsHelper:s}=o,c=a(o.spatialReference),d=t==null?`absolute-height`:t.mode,f=x(t)/c,p=(d===`on-the-ground`?0:f+r)*c/s.unitInMeters,{camera:m}=o.state;if(d===`absolute-height`){let t=s?.getAltitude(m.eye),n=u(l(K,e.direction),s.worldUpAtPosition(m.eye,q));if(t<p&&n<0||t>=p&&n>0)return null;if(s.intersectInfiniteManifold(e,p,K)){let e=C(o,K);return e.z??=0,e.z-=f,e}return null}let h=m.projectToRenderScreen(e.origin,n(b.get())),g=new U(null,this._forEachLayer),_=o.slice.plane,v=_?F(_):null,y=new D(this.viewingMode);y.options.store=0,y.options.verticalOffset=p,y.options.normalRequired=!1;let S=this._createRayIntersectionQuery(e,h,!1);y.metersPerRenderUnit=this._view.renderCoordsHelper.unitInMeters,y.reset(S.beginPoint,S.endPoint,m),y.point=h;let w=null;if(i&&`type`in i&&i.type===`graphics`){let e=o.allLayerViews.find(e=>e.layer===i)?.uid;w=e?t=>t.layerViewUid===e:null}else i&&(w=e=>e.graphicUid!==i.uid);switch(d){case`relative-to-scene`:y.intersect(g.layers,S.screenPoint,this._tolerance,null,e=>(!w||w(e))&&!!e.lastValidElevationBB),this._intersectRayHandlers(y,g,S,v,!1,e=>e.type===2||e.type===7||e.type===8,!1);break;case`on-the-ground`:case`relative-to-ground`:this._intersectRayHandlers(y,g,S,v,!1,e=>e.isGround,!1)}if(y.results.min.getIntersectionPoint(K)){let e=C(o,K);return e.z=r,e}return null}computeIntersection(e,t,r,i){if(e==null)return;let a=this._view.state.camera,o=a.projectToRenderScreen(e.origin,n(b.get())),s=new U(i,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!i||!(`include`in i||`exclude`in i);let c=this._createRayIntersectionQuery(e,o,r);t.metersPerRenderUnit=this._view.renderCoordsHelper.unitInMeters,t.reset(c.beginPoint,c.endPoint,a),t.intersect(s.layers,c.screenPoint,this._tolerance,null,s.objectFilter);let l=this._view.slice.plane,u=l?F(l):null;t.intersect(s.sliceableLayers,c.screenPoint,this._tolerance,u,s.objectFilter);let d=i&&(i.requiresGroundFeedback||i.enableDraped);this._intersectRayHandlers(t,s,c,u,!!d,e=>s.allowedIntersectorTypes==null||s.allowedIntersectorTypes.has(e.type));let f=b.get(),p=this._view,m=p.groundView.spatialReference;if(i&&i.enableDraped&&m!=null&&t.results.ground.getIntersectionPoint(f)){let e=p.overlayManager.renderer,n=p.renderCoordsHelper.spatialReference,r=b.get();p.renderCoordsHelper.fromRenderCoords(f,r,m),r[2]=p.elevationProvider?.getElevation(f[0],f[1],f[2],n,`ground`)??0,e.intersectRay(t,r,t.results.ground,e=>s.filterRenderGeometry(e))}t.sortResults(),this._processHUDResults(t)}_processHUDResults(e){let t=e.results.hud;h(this._tmpRegion,g);let n=[],r=this._tmpRegion,i=e=>{n.push(new z(e))};e.sortResults(t.all),t.min.distance!=null&&i(t.min);for(let e of t.all)t.min.target.object!==e.target.object&&t.max.target.object!==e.target.object&&i(e);if(t.max.distance!=null&&t.max.target.object!==t.min.target.object&&i(t.max),!n.length)return;r[0]===r[2]&&(r[2]+=1),r[1]===r[3]&&(r[3]+=1);let a=!0,o=e.results.max.distance==null,s=0;for(let t of n)a&&=(e.results.min.copy(t.result),!1),o&&e.results.max.copy(t.result),e.options.store===2&&e.results.all.splice(s++,0,t.result)}_createRayIntersectionQuery(e,t,n){return new k(e.origin,c(f(),e.origin,e.direction),t,n)}_intersectRayHandlers(e,t,n,r,i,a=()=>!0,o=!0){let{options:s}=e,c=s.isFiltered,l=s.filteredLayerViewUids;for(let{handler:c,filterPredicate:l,isFiltered:u,filteredLayerViewUids:d}of this._getFilteredIntersectionHandlers(t,r,null,a,o))(!u||c.isGround&&i)&&(s.isFiltered=u,s.filteredLayerViewUids=d,c.intersectRay(e,l,e.rayBegin,e.rayEnd,n.screenPoint,n.isVerticalRay));s.isFiltered=c,s.filteredLayerViewUids=l}*_intersectPolygonHandlersGenerator(e,t,n,r,i,a=()=>!0,o=!0,s){let{options:c}=e,l=c.isFiltered,u=c.filteredLayerViewUids,d=e.screenPolygonPrimitiveProcessor;for(let{handler:l,screenPolygonPrimitiveProcessor:u,isFiltered:d,filteredLayerViewUids:f}of this._getFilteredIntersectionHandlers(t,r,i,a,o))d||l.intersectScreenPolygon==null||(c.isFiltered=d,c.filteredLayerViewUids=f,e.screenPolygonPrimitiveProcessor=u??O,yield*l.intersectScreenPolygon(e,n,s));c.isFiltered=l,c.filteredLayerViewUids=u,e.screenPolygonPrimitiveProcessor=d}*_intersectDrapedScreenPolygon(e,t,n,r){let{basemapTerrain:i,overlayManager:a}=this._view,o=this._view.groundView.spatialReference!=null&&!a.renderer.isEmpty;if(!e.options.selectionMode||!r?.enableDraped||!o)return;let s=yield*this._createDrapedPolygonIntersectionQueries(n,i.slicePlaneEnabled?this._view.slice.plane:null);s!=null&&(yield*this._view.overlayManager.renderer.intersectScreenPolygon(e,s,e=>t.filterRenderGeometry(e)))}*_createDrapedPolygonIntersectionQueries(t,n){let{state:{camera:{eye:r}},pointsOfInterest:i}=this._view,a=this._view.groundView.spatialReference,c=[],l=n?[]:null,u=S(this._view,i.focus.renderLocation),f=v(a),m=1/0,h=null,g=K,_=q,y=e=>{if(!this._intersectDrapedScreenPolygonPoint(g,_,e))return!1;let t=h!=null&&f?h+f.shortestSignedDiff(h,g[0]):g[0];return h=t,c.push(s(t,g[1])),l&&l.push(p(_)),m=Math.min(m,d(r,_)),!0},{points:b}=t,{length:x}=b;for(let t=0;t<x;t++){let n=b[t],r=b[(t+1)%x];for(let t=0;t<u;t++){let i=t/u;if(!y(t===0?n:o(Y,e(n[0],r[0],i),e(n[1],r[1],i))))return null;yield}}if(!Number.isFinite(m))return null;if(n==null||!l)return[G(c,m)];let C=this._clipDrapedScreenPolygonIntersectionQueries(l,n,f,r);return C.length>0?C:null}_clipDrapedScreenPolygonIntersectionQueries(e,t,n,r){let i=[],a=N(t);for(let t of P(a,e)){let e=this._createDrapedQueryFromRenderPolygon(t,n,r);e!=null&&i.push(e)}return i.sort((e,t)=>e.distance-t.distance),i}_createDrapedQueryFromRenderPolygon(e,t,n){let{renderCoordsHelper:r}=this._view,i=this._view.groundView.spatialReference,a=[],o=1/0,c=null;for(let l of e){if(!r.fromRenderCoords(l,X,i))return null;let e=c!=null&&t?c+t.shortestSignedDiff(c,X[0]):X[0];c=e,a.push(s(e,X[1])),o=Math.min(o,d(n,l))}return a.length>=3&&Number.isFinite(o)?G(a,o):null}_intersectDrapedScreenPolygonPoint(e,t,n){let r=this._getPickRay(n,this._tmpRay);if(r==null)return!1;let{renderCoordsHelper:i}=this._view;this._intersectGroundPoint(t,r,n)||i.intersectManifoldClosestSilhouette(r,0,t);let a=this._view.groundView.spatialReference;return!!i.fromRenderCoords(t,e,a)}_intersectGroundPoint(e,t,n){let r=this._view.state.camera,i=new U(null,this._forEachLayer),a=new D(this.viewingMode);J[0]=n[0],J[1]=n[1],J[2]=0;let o=this._createRayIntersectionQuery(t,J,!1);return a.options.selectionMode=!0,a.options.store=0,a.options.normalRequired=!1,a.options.selectOpaqueTerrainOnly=!1,a.reset(o.beginPoint,o.endPoint,r),this._intersectRayHandlers(a,i,o,null,!0,e=>e.isGround,!1),a.results.ground.getIntersectionPoint(e)}*_getFilteredIntersectionHandlers(e,t,n,r=()=>!0,i=!0){for(let a of this._externalIntersectionHandlers){if(!r(a))continue;let o=!1,s=[];if(i){let t=a.layerViewUid,n=a.sublayerId,r=Array.isArray(t),i=r?t:[t],c=!1;for(let t of i)e.filterLayerViewUid(t,n)?c=!0:r&&s.push(t);o=!c}yield new B(a,a.slicePlaneEnabled?t:null,a.slicePlaneEnabled?n:null,o,s)}}}class z{constructor(e){this.result=e,this.screenPoint=r()}}class B{constructor(e,t,n,r,i){this.handler=e,this.filterPredicate=t,this.screenPolygonPrimitiveProcessor=n,this.isFiltered=r,this.filteredLayerViewUids=i}}let V;function H(e){return V&&V.viewingMode===e||(V=new D(e)),V}class U{constructor(e,t){this.layers=[],this.sliceableLayers=[],this.include=e?.include,this.exclude=e?.exclude,this.objectFilter=e?.objectFilter,this.allowedIntersectorTypes=e?.allowedIntersectorTypes,t(e=>{e.pickable&&this.filterLayerViewUid(e.apiLayerViewUid)&&(e.sliceable?this.sliceableLayers:this.layers).push(e)})}filterLayerViewUid(e,t){let{include:n,exclude:r}=this;if(e==null)return n==null&&r==null;let i=n instanceof Map?n.get(e)??!1:n?.has(e),a=r instanceof Map?r.get(e)??!1:r?.has(e);return(i==null||(typeof i==`boolean`?i:t!=null&&i.has(t)))&&(a==null||!(typeof a==`boolean`?a:t!=null&&a.has(t)))}filterRenderGeometry(e){return this.filterLayerViewUid(e.layerViewUid)}}function W(e){return typeof e==`object`&&!!e&&`intersectRay`in e}function G(e,t){return new A(e,_(m(g),e),t)}const K=f(),q=f(),J=r(),Y=i(),X=f(),Z=r();export{R as SceneIntersectionHelper,W as isIntersectionHandler};
2
+ import{lerp as e}from"../../../../core/mathUtils.js";import t from"../../../../core/PooledArray.js";import{castRenderScreenPointArray3 as n,createRenderScreenPointArray3 as r,createScreenPointArray as i}from"../../../../core/screenUtils.js";import{getMetersPerVerticalUnitForSR as a}from"../../../../core/units.js";import{set as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as s}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{add as c,normalize as l,dot as u,distance as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as f,clone as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as m,copy as h,negativeInfinity as g,expandWithNestedArray as _}from"../../../../geometry/support/aaBoundingRect.js";import{createSpatialReferenceCyclical as v}from"../../../../geometry/support/normalizeUtils.js";import{create as y}from"../../../../geometry/support/ray.js";import{sv3d as b}from"../../../../geometry/support/vectorStacks.js";import{getElevationOffsetInMeters as x}from"../../../../support/elevationInfoUtils.js";import{g as S}from"../../../../chunks/cameraUtilsSpherical.js";import{computeMapPointFromVec3d as C}from"../../support/hitTest.js";import{fromRenderAtEye as w,fromScreen as T}from"../../support/geometryUtils/ray.js";import{defaultTolerance as E,Intersector as D,defaultScreenPolygonPrimitiveProcessor as O}from"../../webgl-engine/lib/Intersector.js";import{RayIntersectionQuery as k,DrapedScreenPolygonIntersectionQuery as A}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as j}from"../../webgl-engine/lib/IntersectorResult.js";import{SliceScreenPolygonPrimitiveProcessor as M,createSliceExtrusionHalfspacePlanes as N,clipPolygonAgainstSlicedAwayHalfspaces as P,sliceFilterPredicate as F}from"../../webgl-engine/lib/intersectorUtils.js";import{prepareScreenPolygonIntersectionQuery as I}from"../../webgl-engine/lib/screenPolygonIntersectionUtils.js";import{TaskPriority as L}from"../../../support/Scheduler.js";class R{constructor(e,n,r){this.viewingMode=e,this._forEachLayer=n,this._view=r,this._externalIntersectionHandlers=new t,this._tolerance=E,this._tmpRay=y(),this._tmpRegion=m(),this._validateHUDIntersector=new D(this.viewingMode),this._validateHUDIntersector.options.hud=!1,this._screenPolygonIntersectionTask=this._view.resourceController.scheduler.registerTask(L.SCREEN_POLYGON_INTERSECTION)}destroy(){this._screenPolygonIntersectionTask.remove(),this._externalIntersectionHandlers.prune()}get screenPolygonIntersectionTask(){return this._screenPolygonIntersectionTask}intersectScreen(e,t,n){return this.intersectRay(this._getPickRay(e,this._tmpRay),H(this.viewingMode),t,n)}intersectScreenFreePointFallback(e,t,n){return this.intersectRayFreePointFallback(this._getPickRay(e,this._tmpRay),t,n)}intersectRayFreePointFallback(e,t,n){return this.intersectRay(e,H(this.viewingMode),t,n)||this._intersectRayFreePointLocal(e,t)}intersectRay(e,t,n,r){return t.options.selectionMode=!1,t.options.store=0,this.computeIntersection(e,t,!1,r),t.results.min?t.results.min.getIntersectionPoint(n):!1}getCenterRayWithSubpixelOffset(e,t,n=.5,r=.5){return e.getRenderCenter(Z,n,r),Z[0]+=.0466,Z[1]-=.0123,w(e,Z,t)}intersectIntersectorScreen(e,t,n){this.computeIntersection(this._getPickRay(e,this._tmpRay),t,!1,n)}async intersectIntersectorScreenPolygon(e,t,n){t.polygonResults.init();let r=this._view.state.camera,i=await I(r,e);i!=null&&await this._screenPolygonIntersectionTask.scheduleGenerator(e=>this._intersectIntersectorScreenPolygon(r,t,i,n,e))}*_intersectIntersectorScreenPolygon(e,t,n,r,i){let a=new U(r,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!r||!(`include`in r||`exclude`in r),t.camera=e,t.metersPerRenderUnit=this._view.renderCoordsHelper.unitInMeters,t.point=null,t.screenPolygonPrimitiveProcessor=O,yield*t.intersectScreenPolygon(a.layers,n);let o=this._view.slice.plane,s=o?new M(o):null;t.screenPolygonPrimitiveProcessor=s??O,yield*t.intersectScreenPolygon(a.sliceableLayers,n),t.screenPolygonPrimitiveProcessor=O,yield*this._intersectPolygonHandlersGenerator(t,a,n,null,s,void 0,!0,i),yield*this._intersectDrapedScreenPolygon(t,a,n,r),yield*t.intersectHUDScreenPolygon(a.layers,n),t.screenPolygonPrimitiveProcessor=s??O,yield*t.intersectHUDScreenPolygon(a.sliceableLayers,n),t.polygonResults.sortResults()}intersectToolIntersectorScreen(e,t,n){let r=this._getPickRay(e,this._tmpRay);this.intersectToolIntersectorRay(r,t,n)}intersectToolIntersectorRay(e,t,n){t.options.selectionMode=!0,this.computeIntersection(e,t,!1,n);let r=t.results.min;this._view.groundView.opaque||j(r)&&r.intersector!==7||(t.options.selectionMode=!1,this.computeIntersection(e,t,!1,n))}setTolerance(e=E){this._tolerance=e}addIntersectionHandler(e){this._externalIntersectionHandlers.push(e),this._externalIntersectionHandlers.sort((e,t)=>e.type===7?1:t.type===7?-1:0)}removeIntersectionHandler(e){this._externalIntersectionHandlers.removeUnordered(e)!=null&&this._externalIntersectionHandlers.sort((e,t)=>e.type===7?1:t.type===7?-1:0)}_getPickRay(e,t){let n=this._view.state.camera;return T(n,e,t)}_intersectRayFreePointLocal(e,t){return this.viewingMode!==2||e==null||c(t,e.origin,l(b.get(),e.direction)),!1}intersectElevationFromScreen(e,t,n=0,r=null){return this._intersectElevation(this._getPickRay(e,this._tmpRay),t,n,r)}_intersectElevation(e,t,r=0,i=null){if(e==null)return null;let o=this._view,{renderCoordsHelper:s}=o,c=a(o.spatialReference),d=t==null?`absolute-height`:t.mode,f=x(t)/c,p=(d===`on-the-ground`?0:f+r)*c/s.unitInMeters,{camera:m}=o.state;if(d===`absolute-height`){let t=s?.getAltitude(m.eye),n=u(l(K,e.direction),s.worldUpAtPosition(m.eye,q));if(t<p&&n<0||t>=p&&n>0)return null;if(s.intersectInfiniteManifold(e,p,K)){let e=C(o,K);return e.z??=0,e.z-=f,e}return null}let h=m.projectToRenderScreen(e.origin,n(b.get())),g=new U(null,this._forEachLayer),_=o.slice.plane,v=_?F(_):null,y=new D(this.viewingMode);y.options.store=0,y.options.verticalOffset=p,y.options.normalRequired=!1;let S=this._createRayIntersectionQuery(e,h,!1);y.metersPerRenderUnit=this._view.renderCoordsHelper.unitInMeters,y.reset(S.beginPoint,S.endPoint,m),y.point=h;let w=null;if(i&&`type`in i&&i.type===`graphics`){let e=o.allLayerViews.find(e=>e.layer===i)?.uid;w=e?t=>t.layerViewUid===e:null}else i&&(w=e=>e.graphicUid!==i.uid);switch(d){case`relative-to-scene`:y.intersect(g.layers,S.screenPoint,this._tolerance,null,e=>(!w||w(e))&&!!e.lastValidElevationBB),this._intersectRayHandlers(y,g,S,v,!1,e=>e.type===2||e.type===7||e.type===8,!1);break;case`on-the-ground`:case`relative-to-ground`:this._intersectRayHandlers(y,g,S,v,!1,e=>e.isGround,!1)}if(y.results.min.getIntersectionPoint(K)){let e=C(o,K);return e.z=r,e}return null}computeIntersection(e,t,r,i){if(e==null)return;let a=this._view.state.camera,o=a.projectToRenderScreen(e.origin,n(b.get())),s=new U(i,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!i||!(`include`in i||`exclude`in i);let c=this._createRayIntersectionQuery(e,o,r);t.metersPerRenderUnit=this._view.renderCoordsHelper.unitInMeters,t.reset(c.beginPoint,c.endPoint,a),t.intersect(s.layers,c.screenPoint,this._tolerance,null,s.objectFilter);let l=this._view.slice.plane,u=l?F(l):null;t.intersect(s.sliceableLayers,c.screenPoint,this._tolerance,u,s.objectFilter);let d=i&&(i.requiresGroundFeedback||i.enableDraped);this._intersectRayHandlers(t,s,c,u,!!d,e=>s.allowedIntersectorTypes==null||s.allowedIntersectorTypes.has(e.type));let f=b.get(),p=this._view,m=p.groundView.spatialReference;if(i&&i.enableDraped&&m!=null&&t.results.ground.getIntersectionPoint(f)){let e=p.overlayManager.renderer,n=p.renderCoordsHelper.spatialReference,r=b.get();p.renderCoordsHelper.fromRenderCoords(f,r,m),r[2]=p.elevationProvider?.getElevation(f[0],f[1],f[2],n,`ground`)??0,e.intersectRay(t,r,t.results.ground,e=>s.filterRenderGeometry(e))}t.sortResults(),this._processHUDResults(t)}_processHUDResults(e){let t=e.results.hud;h(this._tmpRegion,g);let n=[],r=this._tmpRegion,i=e=>{n.push(new z(e))};e.sortResults(t.all),t.min.distance!=null&&i(t.min);for(let e of t.all)t.min.target.object!==e.target.object&&t.max.target.object!==e.target.object&&i(e);if(t.max.distance!=null&&t.max.target.object!==t.min.target.object&&i(t.max),!n.length)return;r[0]===r[2]&&(r[2]+=1),r[1]===r[3]&&(r[3]+=1);let a=!0,o=e.results.max.distance==null,s=0;for(let t of n)a&&=(e.results.min.copy(t.result),!1),o&&e.results.max.copy(t.result),e.options.store===2&&e.results.all.splice(s++,0,t.result)}_createRayIntersectionQuery(e,t,n){return new k(e.origin,c(f(),e.origin,e.direction),t,n)}_intersectRayHandlers(e,t,n,r,i,a=()=>!0,o=!0){let{options:s}=e,c=s.isFiltered,l=s.filteredLayerViewUids;for(let{handler:c,filterPredicate:l,isFiltered:u,filteredLayerViewUids:d}of this._getFilteredIntersectionHandlers(t,r,null,a,o))(!u||c.isGround&&i)&&(s.isFiltered=u,s.filteredLayerViewUids=d,c.intersectRay(e,l,e.rayBegin,e.rayEnd,n.screenPoint,n.isVerticalRay));s.isFiltered=c,s.filteredLayerViewUids=l}*_intersectPolygonHandlersGenerator(e,t,n,r,i,a=()=>!0,o=!0,s){let{options:c}=e,l=c.isFiltered,u=c.filteredLayerViewUids,d=e.screenPolygonPrimitiveProcessor;for(let{handler:l,screenPolygonPrimitiveProcessor:u,isFiltered:d,filteredLayerViewUids:f}of this._getFilteredIntersectionHandlers(t,r,i,a,o))d||l.intersectScreenPolygon==null||(c.isFiltered=d,c.filteredLayerViewUids=f,e.screenPolygonPrimitiveProcessor=u??O,yield*l.intersectScreenPolygon(e,n,s));c.isFiltered=l,c.filteredLayerViewUids=u,e.screenPolygonPrimitiveProcessor=d}*_intersectDrapedScreenPolygon(e,t,n,r){let{basemapTerrain:i,overlayManager:a}=this._view,o=this._view.groundView.spatialReference!=null&&!a.renderer.isEmpty;if(!e.options.selectionMode||!r?.enableDraped||!o)return;let s=yield*this._createDrapedPolygonIntersectionQueries(n,i.slicePlaneEnabled?this._view.slice.plane:null);s!=null&&(yield*this._view.overlayManager.renderer.intersectScreenPolygon(e,s,e=>t.filterRenderGeometry(e)))}*_createDrapedPolygonIntersectionQueries(t,n){let{state:{camera:{eye:r}},pointsOfInterest:i}=this._view,a=this._view.groundView.spatialReference,c=[],l=n?[]:null,u=S(this._view,i.focus.renderLocation),f=v(a),m=1/0,h=null,g=K,_=q,y=e=>{if(!this._intersectDrapedScreenPolygonPoint(g,_,e))return!1;let t=h!=null&&f?h+f.shortestSignedDiff(h,g[0]):g[0];return h=t,c.push(s(t,g[1])),l&&l.push(p(_)),m=Math.min(m,d(r,_)),!0},{points:b}=t,{length:x}=b;for(let t=0;t<x;t++){let n=b[t],r=b[(t+1)%x];for(let t=0;t<u;t++){let i=t/u;if(!y(t===0?n:o(Y,e(n[0],r[0],i),e(n[1],r[1],i))))return null;yield}}if(!Number.isFinite(m))return null;if(n==null||!l)return[G(c,m)];let C=this._clipDrapedScreenPolygonIntersectionQueries(l,n,f,r);return C.length>0?C:null}_clipDrapedScreenPolygonIntersectionQueries(e,t,n,r){let i=[],a=N(t);for(let t of P(a,e)){let e=this._createDrapedQueryFromRenderPolygon(t,n,r);e!=null&&i.push(e)}return i.sort((e,t)=>e.distance-t.distance),i}_createDrapedQueryFromRenderPolygon(e,t,n){let{renderCoordsHelper:r}=this._view,i=this._view.groundView.spatialReference,a=[],o=1/0,c=null;for(let l of e){if(!r.fromRenderCoords(l,X,i))return null;let e=c!=null&&t?c+t.shortestSignedDiff(c,X[0]):X[0];c=e,a.push(s(e,X[1])),o=Math.min(o,d(n,l))}return a.length>=3&&Number.isFinite(o)?G(a,o):null}_intersectDrapedScreenPolygonPoint(e,t,n){let r=this._getPickRay(n,this._tmpRay);if(r==null)return!1;let{renderCoordsHelper:i}=this._view;this._intersectGroundPoint(t,r,n)||i.intersectManifoldClosestSilhouette(r,0,t);let a=this._view.groundView.spatialReference;return!!i.fromRenderCoords(t,e,a)}_intersectGroundPoint(e,t,n){let r=this._view.state.camera,i=new U(null,this._forEachLayer),a=new D(this.viewingMode);J[0]=n[0],J[1]=n[1],J[2]=0;let o=this._createRayIntersectionQuery(t,J,!1);return a.options.selectionMode=!0,a.options.store=0,a.options.normalRequired=!1,a.options.selectOpaqueTerrainOnly=!1,a.reset(o.beginPoint,o.endPoint,r),this._intersectRayHandlers(a,i,o,null,!0,e=>e.isGround,!1),a.results.ground.getIntersectionPoint(e)}*_getFilteredIntersectionHandlers(e,t,n,r=()=>!0,i=!0){for(let a of this._externalIntersectionHandlers){if(!r(a))continue;let o=!1,s=[];if(i){let t=a.layerViewUid,n=a.sublayerId,r=Array.isArray(t),i=r?t:[t],c=!1;for(let t of i)e.filterLayerViewUid(t,n)?c=!0:r&&s.push(t);o=!c}yield new B(a,a.slicePlaneEnabled?t:null,a.slicePlaneEnabled?n:null,o,s)}}}class z{constructor(e){this.result=e,this.screenPoint=r()}}class B{constructor(e,t,n,r,i){this.handler=e,this.filterPredicate=t,this.screenPolygonPrimitiveProcessor=n,this.isFiltered=r,this.filteredLayerViewUids=i}}let V;function H(e){return V&&V.viewingMode===e||(V=new D(e)),V}class U{constructor(e,t){this.layers=[],this.sliceableLayers=[],this.include=e?.include,this.exclude=e?.exclude,this.objectFilter=e?.objectFilter,this.allowedIntersectorTypes=e?.allowedIntersectorTypes,t(e=>{e.pickable&&this.filterLayerViewUid(e.apiLayerViewUid)&&(e.sliceable?this.sliceableLayers:this.layers).push(e)})}filterLayerViewUid(e,t){let{include:n,exclude:r}=this;if(e==null)return n==null&&r==null;let i=n instanceof Map?n.get(e)??!1:n?.has(e),a=r instanceof Map?r.get(e)??!1:r?.has(e);return(i==null||(typeof i==`boolean`?i:t!=null&&i.has(t)))&&(a==null||!(typeof a==`boolean`?a:t!=null&&a.has(t)))}filterRenderGeometry(e){return this.filterLayerViewUid(e.layerViewUid)}}function W(e){return typeof e==`object`&&!!e&&`intersectRay`in e}function G(e,t){return new A(e,_(m(g),e),t)}const K=f(),q=f(),J=r(),Y=i(),X=f(),Z=r();export{R as SceneIntersectionHelper,W as isIntersectionHandler};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import e from"../../../../core/Logger.js";import{createScreenPointArray as t}from"../../../../core/screenUtils.js";import{distance as n,normalize as r,cross as i,add as a,crossAndNormalize as o,subtract as s,dot as c,scaleAndAdd as l,scale as u,copy as d,length 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{getReferenceEllipsoid as m}from"../../../../geometry/ellipsoidUtils.js";import{fromValues as h}from"../../../../geometry/support/lineSegment.js";import{create as g,fromPositionAndNormal as _,distance as v,projectPoint as y,projectVector as b,intersectLineSegment as x}from"../../../../geometry/support/plane.js";import{create as S}from"../../../../geometry/support/ray.js";import{Sphere as C}from"../../../../geometry/support/sphere.js";import{fromRenderCamera as w}from"../../webgl.js";import{getVoxelWasm as T}from"../../layers/VoxelWasm.js";import{pickPointAndInitSphere as E,sphereOrPlanePointFromScreenPoint as D,intersectPlaneFromScreenPoint as O,searchAreaSize as k}from"./navigationUtils.js";import{OffsetCorrectionController as ee}from"./OffsetCorrectionController.js";import{fromScreenAtEye as te}from"../../support/geometryUtils/ray.js";import ne from"../../webgl/RenderCamera.js";import{Intersector as A}from"../../webgl-engine/lib/Intersector.js";const j=1.5,M={xSpeedMultiplier:j,ySpeedMultiplier:j,maxElevation:1e4,relativeHorizonPadding:.1,minimumHorizonPadding:12},N=p(),P=p(),re=t(),F=p(),I=g(),L=p(),R=p(),z=p(),B=p(),V=p(),ie=p(),H=p(),U=p(),W=p(),G=p(),K=t(),q=S(),J=new C,Y=p(),ae=g(),X=p(),oe=p();function se(e,t){return b(t,e.viewForward,N),a(P,e.eye,N),e.projectToScreen(P,re),re[1]}function ce(e,t,d){let f=e.eye;if(n(t.center,f)<t.radius)return r(V,f),i(ie,V,e.viewRight),a(P,f,ie),e.projectToScreen(P,K),K[1];let p=e.up;te(e,d,q);let m=t.radius;if(o(F,p,q.direction),_(f,F,I),v(I,t.center)>m)return null;y(I,t.center,L);let h=n(t.center,L),g=Math.sqrt(m**2-h**2);s(R,f,L),r(z,R),o(B,F,z);let b=c(R,z),x=c(R,B),S=Math.sqrt(b**2+x**2),C=Math.sqrt(S**2-g**2),w=g**2/S**2,T=g/S**2*C,E=w*b,D=T*-x,O=w*x,k=T*b,ee=E+D,ne=E-D,A=O+k,j=O-k;return a(H,L,l(H,u(H,z,ee),B,A)),a(U,L,l(U,u(U,z,ne),B,j)),s(W,H,f),r(W,W),s(G,U,f),r(G,G),c(e.viewForward,W)>=c(e.viewForward,G)?e.projectToScreen(H,K):e.projectToScreen(U,K),K[1]}function le(e,t,n=!0){return n?e<t:e<=t}function Z(e,t,n=!0){return n?e>t:e>=t}function ue(e,t,n){return t?e>n:e<n}function Q(e,t){let n=e.fullHeight/e.pixelRatio,r=Math.max(t,n-t);return Math.max(M.minimumHorizonPadding,M.relativeHorizonPadding*r)}function de(e,t){return[fe(e,t),pe(e,t)]}function fe(e,t){let n=e.fullHeight/e.pixelRatio;return Math.min(n,t+Q(e,t))}function pe(e,t){return Math.max(0,t-Q(e,t))}function me(e,t,n){let r={translation:e,location:t};return n&&(r.normal=n),r}function he(e){let{view:t}=e;return t.viewingMode===`global`?ge(e):_e(e)}function ge(e){let{view:t,originalScreenPoint:i,horizonY:a,horizonPadding:o,outTranslation:s,outGrabLocation:c,outGrabNormal:l,intersectionOptions:u,depthSearchSize:f}=e,p=t.state.camera,h=me(s,c,l);J.radius=m(t.spatialReference).radius;let g=E(t,p,i,J.radius,1,u);if(g.scenePickPoint==null)return!1;let _=g.hasGeometryIntersection;d(Y,g.scenePickPoint),d(h.location,Y);let v=g.sphere;h.normal&&g.normal&&d(h.normal,g.normal);let y=ye(i,a,o,_),b=_?n(Y,p.eye):1/0;return y.wasAdjusted&&be({view:t,screenAdjustment:y,intersector:$(t),fallbackCheck:(e,t,n)=>{let i=D(v,p,e,t);return i&&n&&r(n,t),i},output:h,intersectionOptions:u}),Se({view:t,screenPoint:y.adjustedScreenPoint,camera:p,initialDistance:b,depthSearchSize:f??k,output:h}),!0}function _e(e){let{view:t,originalScreenPoint:i,horizonY:a,horizonPadding:o,outTranslation:s,outGrabLocation:c,outGrabNormal:u,intersectionOptions:f,depthSearchSize:p}=e,m=t.sceneIntersectionHelper,h=t.state.camera,g=$(t),v=me(s,c,u);m.intersectIntersectorScreen(i,g,f);let y=g.results.min.getIntersectionPoint(Y),b=y?n(Y,h.eye):1/0;y&&(d(v.location,Y),v.normal&&d(v.normal,g.results.min.normal)),t.renderCoordsHelper.worldUpAtPosition(h.eye,V),l(X,h.eye,V,-h.relativeElevation),_(X,V,ae);let x=ye(i,a,o,y);return x.wasAdjusted&&be({view:t,screenAdjustment:x,intersector:g,fallbackCheck:(e,t,n)=>{let i=O(ae,h,e,t);return i&&n&&r(n,V),i},output:v,intersectionOptions:f}),Se({view:t,screenPoint:x.adjustedScreenPoint,camera:h,initialDistance:b,depthSearchSize:p??k,output:v}),!0}function ve(e,t,n,r){return!r&&le(e,t)||r&&ue(e,!1,n[0])?n[0]:!r&&Z(e,t,!1)?n[1]:null}function ye(e,n,r,i){let a=ve(e[1],n,r,i);return{originalScreenPoint:e,adjustedScreenPoint:t(e[0],a??e[1]),horizonY:n,horizonPadding:r,wasAdjusted:a!==null}}function $(e){let t=new A(e.state.viewingMode);return t.options.selectionMode=!0,t.options.store=0,t.options.hud=!1,t.options.normalRequired=!0,t}function be(e){let{view:t,screenAdjustment:n,fallbackCheck:r,intersector:i,output:a,intersectionOptions:o}=e,s=t.sceneIntersectionHelper;s.intersectIntersectorScreen(n.adjustedScreenPoint,i,{...o,requiresGroundFeedback:!0});let c=i.results.min.getIntersectionPoint(a.location);if(c){a.normal&&d(a.normal,i.results.min.normal);return}let l=xe(n);s.intersectIntersectorScreen(l,i,{...o,requiresGroundFeedback:!0}),c=i.results.min.getIntersectionPoint(a.location),c?a.normal&&d(a.normal,i.results.min.normal):(c=r(n.adjustedScreenPoint,a.location,a.normal),!c&&r(l,a.location,a.normal))}function xe(e){let{originalScreenPoint:n,adjustedScreenPoint:r,horizonY:i,horizonPadding:a}=e,o=Z(r[1],i)?Math.min(a[1],n[1]):Math.max(a[0],n[1]);return t(r[0],o)}function Se(e){Ce(e),we(e)}function Ce(e){let{view:t,camera:n,output:r}=e,{offset:i}=t.navigation.mode;if(!i)return;let{translation:a,location:o}=r;t.renderCoordsHelper.worldUpAtPosition(n.eye,V),l(X,n.eye,V,-i),_(X,V,I),x(I,h(n.eye,s(N,o,n.eye)),X)&&(d(o,X),s(a,o,n.eye))}function we(e){let{view:t,screenPoint:n,camera:i,initialDistance:o,depthSearchSize:c,output:l}=e,d=c>0?t.stage.renderView.getMinimalDepthForArea(T(t),n[0],n[1],i,c):null;s(l.translation,l.location,i.eye);let p=Math.min(f(l.translation),o);d&&d<=p&&(p=d),r(l.translation,l.translation),u(l.translation,l.translation,p),a(l.location,l.translation,i.eye)}async function Te(t,r){let i=t.navigation.mode;if(i.type!==`ground`){e.getLogger(`esri`).warn(`Can only advance while in ground navigation mode!`);return}let{camera:c}=t.state;t.renderCoordsHelper.worldUpAtPosition(c.eye,V);let l=t.sceneIntersectionHelper,p=$(t),m=o(N,V,c.viewRight);d(q.origin,c.eye),u(q.direction,m,r);let h=l.intersectRay(q,p,Y,{include:i.include,exclude:i.exclude}),g=new ne().copyFrom(c),_=s(oe,c.center,c.eye);return!h||n(Y,c.eye)>r?g.eye=a(N,q.origin,q.direction):(s(N,Y,c.eye),f(N)>2&&(Ee(N,N,.25,2),g.eye=a(N,c.eye,N))),g.center=a(N,g.eye,_),new ee(t).immediatelyCorrectGroundElevation({camera:g,correctionLimit:100}),t.goTo(w(t,g),{duration:500,liftOffDisabled:!0})}function Ee(e,t,n,r){let i=f(e),a=Math.min(n,Math.max(i-r,0)/i);u(t,e,a)}export{Q as computeHorizonPadding,de as computeHorizonPaddingLimits,he as findGroundNavigationGrabLocation,se as findPlaneHorizonY,ce as findSphereHorizonY,Te as groundNavigationAdvance,M as groundNavigationConstants,le as isAboveHorizon,Z as isBelowHorizon,Ee as shortenTranslation,ue as shouldClampScreenY};
2
+ import e from"../../../../core/Logger.js";import{createScreenPointArray as t}from"../../../../core/screenUtils.js";import{distance as n,normalize as r,cross as i,add as a,crossAndNormalize as o,subtract as s,dot as c,scaleAndAdd as l,scale as u,copy as d,length 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{getReferenceEllipsoid as m}from"../../../../geometry/ellipsoidUtils.js";import{fromValues as h}from"../../../../geometry/support/lineSegment.js";import{create as g,fromPositionAndNormal as _,distance as v,projectPoint as y,projectVector as b,intersectLineSegment as x}from"../../../../geometry/support/plane.js";import{create as S}from"../../../../geometry/support/ray.js";import{Sphere as C}from"../../../../geometry/support/sphere.js";import{fromRenderCamera as w}from"../../webgl.js";import{getVoxelWasm as T}from"../../layers/VoxelWasm.js";import{pickPointAndInitSphere as E,sphereOrPlanePointFromScreenPoint as D,intersectPlaneFromScreenPoint as O,searchAreaSize as k}from"./navigationUtils.js";import{OffsetCorrectionController as ee}from"./OffsetCorrectionController.js";import{fromScreenAtEye as te}from"../../support/geometryUtils/ray.js";import ne from"../../webgl/RenderCamera.js";import{Intersector as A}from"../../webgl-engine/lib/Intersector.js";const j=1.5,M={xSpeedMultiplier:j,ySpeedMultiplier:j,maxElevation:1e4,relativeHorizonPadding:.1,minimumHorizonPadding:12},N=p(),P=p(),re=t(),F=p(),I=g(),L=p(),R=p(),z=p(),B=p(),V=p(),ie=p(),H=p(),U=p(),W=p(),G=p(),K=t(),q=S(),J=new C,Y=p(),ae=g(),X=p(),oe=p();function se(e,t){return b(t,e.viewForward,N),a(P,e.eye,N),e.projectToScreen(P,re),re[1]}function ce(e,t,d){let f=e.eye;if(n(t.center,f)<t.radius)return r(V,f),i(ie,V,e.viewRight),a(P,f,ie),e.projectToScreen(P,K),K[1];let p=e.up;te(e,d,q);let m=t.radius;if(o(F,p,q.direction),_(f,F,I),v(I,t.center)>m)return null;y(I,t.center,L);let h=n(t.center,L),g=Math.sqrt(m**2-h**2);s(R,f,L),r(z,R),o(B,F,z);let b=c(R,z),x=c(R,B),S=Math.sqrt(b**2+x**2),C=Math.sqrt(S**2-g**2),w=g**2/S**2,T=g/S**2*C,E=w*b,D=T*-x,O=w*x,k=T*b,ee=E+D,ne=E-D,A=O+k,j=O-k;return a(H,L,l(H,u(H,z,ee),B,A)),a(U,L,l(U,u(U,z,ne),B,j)),s(W,H,f),r(W,W),s(G,U,f),r(G,G),c(e.viewForward,W)>=c(e.viewForward,G)?e.projectToScreen(H,K):e.projectToScreen(U,K),K[1]}function le(e,t,n=!0){return n?e<t:e<=t}function Z(e,t,n=!0){return n?e>t:e>=t}function ue(e,t,n){return t?e>n:e<n}function Q(e,t){let n=e.fullHeight/e.pixelRatio,r=Math.max(t,n-t);return Math.max(M.minimumHorizonPadding,M.relativeHorizonPadding*r)}function de(e,t){return[fe(e,t),pe(e,t)]}function fe(e,t){let n=e.fullHeight/e.pixelRatio;return Math.min(n,t+Q(e,t))}function pe(e,t){return Math.max(0,t-Q(e,t))}function me(e,t,n){let r={translation:e,location:t};return n&&(r.normal=n),r}function he(e){let{view:t}=e;return t.viewingMode===`global`?ge(e):_e(e)}function ge(e){let{view:t,originalScreenPoint:i,horizonY:a,horizonPadding:o,outTranslation:s,outGrabLocation:c,outGrabNormal:l,intersectionOptions:u,depthSearchSize:f}=e,p=t.state.camera,h=me(s,c,l);J.radius=m(t.spatialReference).radius;let g=E(t,p,i,J.radius,1,u);if(g.scenePickPoint==null)return!1;let _=g.hasGeometryIntersection;d(Y,g.scenePickPoint),d(h.location,Y);let v=g.sphere;h.normal&&g.normal&&d(h.normal,g.normal);let y=ye(i,a,o,_),b=_?n(Y,p.eye):1/0;return y.wasAdjusted&&be({view:t,screenAdjustment:y,intersector:$(t),fallbackCheck:(e,t,n)=>{let i=D(v,p,e,t);return i&&n&&r(n,t),i},output:h,intersectionOptions:u}),Se({view:t,screenPoint:y.adjustedScreenPoint,camera:p,initialDistance:b,depthSearchSize:f??k,output:h}),!0}function _e(e){let{view:t,originalScreenPoint:i,horizonY:a,horizonPadding:o,outTranslation:s,outGrabLocation:c,outGrabNormal:u,intersectionOptions:f,depthSearchSize:p}=e,m=t.sceneIntersectionHelper,h=t.state.camera,g=$(t),v=me(s,c,u);m.intersectIntersectorScreen(i,g,f);let y=g.results.min.getIntersectionPoint(Y),b=y?n(Y,h.eye):1/0;y&&(d(v.location,Y),v.normal&&d(v.normal,g.results.min.normal)),t.renderCoordsHelper.worldUpAtPosition(h.eye,V),l(X,h.eye,V,-h.relativeElevation),_(X,V,ae);let x=ye(i,a,o,y);return x.wasAdjusted&&be({view:t,screenAdjustment:x,intersector:g,fallbackCheck:(e,t,n)=>{let i=O(ae,h,e,t);return i&&n&&r(n,V),i},output:v,intersectionOptions:f}),Se({view:t,screenPoint:x.adjustedScreenPoint,camera:h,initialDistance:b,depthSearchSize:p??k,output:v}),!0}function ve(e,t,n,r){return!r&&le(e,t)||r&&ue(e,!1,n[0])?n[0]:!r&&Z(e,t,!1)?n[1]:null}function ye(e,n,r,i){let a=ve(e[1],n,r,i);return{originalScreenPoint:e,adjustedScreenPoint:t(e[0],a??e[1]),horizonY:n,horizonPadding:r,wasAdjusted:a!==null}}function $(e){let t=new A(e.state.viewingMode);return t.options.selectionMode=!0,t.options.store=0,t.options.hud=!1,t.options.normalRequired=!0,t}function be(e){let{view:t,screenAdjustment:n,fallbackCheck:r,intersector:i,output:a,intersectionOptions:o}=e,s=t.sceneIntersectionHelper;s.intersectIntersectorScreen(n.adjustedScreenPoint,i,{...o,requiresGroundFeedback:!0});let c=i.results.min.getIntersectionPoint(a.location);if(c){a.normal&&d(a.normal,i.results.min.normal);return}let l=xe(n);s.intersectIntersectorScreen(l,i,{...o,requiresGroundFeedback:!0}),c=i.results.min.getIntersectionPoint(a.location),c?a.normal&&d(a.normal,i.results.min.normal):(c=r(n.adjustedScreenPoint,a.location,a.normal),c||r(l,a.location,a.normal))}function xe(e){let{originalScreenPoint:n,adjustedScreenPoint:r,horizonY:i,horizonPadding:a}=e,o=Z(r[1],i)?Math.min(a[1],n[1]):Math.max(a[0],n[1]);return t(r[0],o)}function Se(e){Ce(e),we(e)}function Ce(e){let{view:t,camera:n,output:r}=e,{offset:i}=t.navigation.mode;if(!i)return;let{translation:a,location:o}=r;t.renderCoordsHelper.worldUpAtPosition(n.eye,V),l(X,n.eye,V,-i),_(X,V,I),x(I,h(n.eye,s(N,o,n.eye)),X)&&(d(o,X),s(a,o,n.eye))}function we(e){let{view:t,screenPoint:n,camera:i,initialDistance:o,depthSearchSize:c,output:l}=e,d=c>0?t.stage.renderView.getMinimalDepthForArea(T(t),n[0],n[1],i,c):null;s(l.translation,l.location,i.eye);let p=Math.min(f(l.translation),o);d&&d<=p&&(p=d),r(l.translation,l.translation),u(l.translation,l.translation,p),a(l.location,l.translation,i.eye)}async function Te(t,r){let i=t.navigation.mode;if(i.type!==`ground`){e.getLogger(`esri`).warn(`Can only advance while in ground navigation mode!`);return}let{camera:c}=t.state;t.renderCoordsHelper.worldUpAtPosition(c.eye,V);let l=t.sceneIntersectionHelper,p=$(t),m=o(N,V,c.viewRight);d(q.origin,c.eye),u(q.direction,m,r);let h=l.intersectRay(q,p,Y,{include:i.include,exclude:i.exclude}),g=new ne().copyFrom(c),_=s(oe,c.center,c.eye);return!h||n(Y,c.eye)>r?g.eye=a(N,q.origin,q.direction):(s(N,Y,c.eye),f(N)>2&&(Ee(N,N,.25,2),g.eye=a(N,c.eye,N))),g.center=a(N,g.eye,_),new ee(t).immediatelyCorrectGroundElevation({camera:g,correctionLimit:100}),t.goTo(w(t,g),{duration:500,liftOffDisabled:!0})}function Ee(e,t,n,r){let i=f(e),a=Math.min(n,Math.max(i-r,0)/i);u(t,e,a)}export{Q as computeHorizonPadding,de as computeHorizonPaddingLimits,he as findGroundNavigationGrabLocation,se as findPlaneHorizonY,ce as findSphereHorizonY,Te as groundNavigationAdvance,M as groundNavigationConstants,le as isAboveHorizon,Z as isBelowHorizon,Ee as shortenTranslation,ue as shouldClampScreenY};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{cyclicalPI as e}from"../../../../core/Cyclical.js";import{deg2rad as t,clamp as n,acosClamped as r,asinClamped as i}from"../../../../core/mathUtils.js";import{createScreenPointArray as a}from"../../../../core/screenUtils.js";import{fromRotation as o,exactEquals as s,multiply as c,rotate as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as u,create as d}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as f}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{exactEquals as ee,length as m,dot as h,subtract as g,normalize as _,squaredDistance as v,copy as y,transformMat4 as b,add as x,distance as te,cross as S,scale as C,lerp as ne,set as re}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{clone as ie,create as w}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as ae,axis as oe,fromPoints as se,wrapAxisAngle as ce}from"../../../../geometry/support/axisAngle.js";import{coordinateSystemFromOneAxisAndNormalVector as le,vectorCoordinates as ue}from"../../../../geometry/support/coordinateSystem.js";import{create as de,fromNormalAndOffset as fe,intersectRay as T}from"../../../../geometry/support/plane.js";import{Sphere as pe}from"../../../../geometry/support/sphere.js";import{sm4d as me,sv3d as E}from"../../../../geometry/support/vectorStacks.js";import{fromScreenAtEye as D,fromScreen as he}from"../../support/geometryUtils/ray.js";import{intersectScreen as ge}from"../../support/geometryUtils/sphere.js";import _e from"../../webgl/RenderCamera.js";import{Intersector as ve}from"../../webgl-engine/lib/Intersector.js";import{terrainId as ye}from"../../webgl-engine/lib/verticalOffsetUtils.js";const be=30,xe=[1,3e8],Se=8,Ce=[200,1508e5],we=5,Te=50,Ee=5,De=10,Oe=90,O=1e-6,ke={exclude:new Set([ye])};function Ae(e,t,n){return n[0]=t[0]/(e.fullWidth/e.pixelRatio),n[1]=t[1]/(e.fullHeight/e.pixelRatio),n}function je(e){for(;e>Math.PI;)e-=2*Math.PI;for(;e<-Math.PI;)e+=2*Math.PI;return e}function k(e,t,n){let r=o(me.get(),n[3],oe(n));r==null||s(r,u)||(g(Y,e.eye,t),b(Y,Y,r),e.eye=x(Y,Y,t),g(Y,e.center,t),b(Y,Y,r),e.center=x(Y,Y,t),e.up=b(Y,e.up,r))}function Me(e,t,n,r){return T(e,he(t,n,dt),r)}function Ne(e,t,n,r){return T(e,D(t,n,dt),r)}function Pe(e,t,n,r){let i=E.get(),a=1-n;g(i,t,e.eye);let o=m(i),s=o*(1-a);a>=0&&s<r&&(s=r,a=-(s-o)/o),!(Math.abs(o-s)<O)&&(C(i,i,a),e.eye=x(Y,e.eye,i),e.center=ne(Y,e.center,t,a))}function Fe(e,t,n){t.getScreenCenter(Ie),ge(e,t,Ie,Y)&&(t.center=Y);let r=t.distance,i=r*n;if(Math.abs(r-i)<O)return;let a=C(E.get(),t.viewForward,i);t.eye=g(Y,t.center,a)}const Ie=a();function Le(e,t){re(t,0,0,0);for(let n of e)x(t,t,n);C(t,t,1/e.length)}function Re(e,t,n,r){return Math.sin(e/m(t))*(n+r.radius)}function ze(e,t,n,r){return Re(Math.PI/2,t,n,r)+(e-Math.PI/2)}const A={Elevation:3e4,Angle:t(16)},j=t(80);function Be(e,t,n,r,i,a){let o=e.sceneIntersectionHelper,s=new ve(e.state.viewingMode);s.options.selectionMode=!1,s.options.store=0,s.options.hud=!1,s.options.normalRequired=!0;let c=null,l=w(),u=new pe,d=!0,f=!0,{eye:p}=t;o.intersectIntersectorScreen(n,s,a);let h=s.results.min;return h.getIntersectionPoint(l)&&!ee(p,l)&&it(p,l,r)?(c=ie(h.normal),u.radius=m(l)):(f=!1,u.radius=!t.aboveGround||i===0?m(t.eye)-t.relativeElevation:Math.max(m(t.center),.9*r),i===1?Ue(u,t,n,l):d=ge(u,t,n,l)),{sphere:u,scenePickPoint:d?l:null,hasGeometryIntersection:f,intersectorType:h.intersector,normal:c}}function Ve(e,t,n,r){let i=e.relativeElevation;if(i>A.Elevation&&r===`global`)return 1;D(e,t,$);let a=Math.sign(i),o=n.worldUpAtPosition(e.eye,Y);return-a*h(o,$.direction)<Math.sin(A.Angle)*m($.direction)?0:1}function He(e,t,n){g(M,n,t),e.eye=g(Y,e.eye,M),e.center=g(Y,e.center,M)}const M=w();function Ue(e,t,n,r){let i=D(t,n,dt);return i!=null&&(e.closestPointOnSilhouette(i,N),e.intersectRay(i,r)?v(N,i.origin)<v(r,i.origin)?(y(r,N),!1):!0:(g(P,t.eye,t.center),_(P,P),fe(P,-h(_(P,P),N),We),T(We,i,r),!1))}const N=w(),P=w(),We=de();function Ge(a,o,s,c,l,u){let d=0;if(S(Q,a,o),g(X,a,o),m(a)<=l||!c.aboveGround){S(s,X,c.eye);let f=h(a,o)/(m(a)*m(o));if(f<.9999)d=r(f);else{let e=m(S(w(),a,o))/(m(a)*m(o));d=i(e)}let p=Math.cos(n(e.normalize(t(u)),0,j));d=-d-Math.max(0,m(o)-l)/(p*l)}else g(Ke,c.eye,c.center),S(s,X,Ke),d=-m(X)/l;return _(s,s),C(s,s,m(Q)),d}const Ke=w();function F(i,a,o,s){let c,l,u=Math.cos(n(e.normalize(t(s)),0,j));return c=a>o?-(a-o)/(u*o):a<-o?Math.PI-(a+o)/(u*o):r(a/o),l=i>o?-(i-o)/(u*o):i<-o?Math.PI-(i+o)/(u*o):r(i/o),(l-c)*o}function qe(e,t,n,r,i,a,o,s,c,l){let u=F(e[2],t[2],a.radius,s),d=c?F(e[0],t[0],a.radius,180):t[0]-e[0],p=Math.sin(o)*d-Math.cos(o)*u,ee=Math.cos(o)*d+Math.sin(o)*u;_(Y,i);let m=c?p/Math.sqrt(Math.abs(a.radius**2-h(n,Y)**2)):p/a.radius,g=ee/Math.sqrt(Math.abs(a.radius**2-h(n,r)**2));f(l,m,g)}function Je(e,t,n,r,i,a,o,s,c,l){S(Q,e,t),le(a.up,a.eye,V,H,U),le([0,0,1],a.eye,z,B,at),y(n,B),y(r,z),_(n,n),C(n,n,m(Q)),ue(e,_(H,H),_(U,U),_(V,V),ot),ue(t,H,U,V,st),qe(ot,st,e,z,B,o,s,c,l,i)}function Ye(e,t,n,r,i,a,s){o(G,i,r),o(K,s,a),c(q,G,K),g(t,e,n),b(t,t,q),x(t,t,n)}function Xe(e,t,n,r,i,a){o(G,r,n),o(K,a,i),c(q,G,K),g(Y,e.eye,t),b(Y,Y,q),e.eye=x(Y,Y,t),g(Y,e.center,t),b(Y,Y,q),e.center=x(Y,Y,t),g(Y,e.up,t),b(Y,Y,q),e.up=x(Y,Y,t)}const I={Pole:.95,Angle:t(18),Tilt:45,TiltHysteresisMargin:1e-7};let L=!1;function R(e,t,n,r,i,a){let o=Math.abs(r)>Math.PI-I.Angle||Math.abs(r)<I.Angle,s=(Math.abs(e[2])<n*I.Pole||Math.abs(t)>n)&&a;return o&&s?!L&&i<I.Tilt-I.TiltHysteresisMargin?L=!0:L&&i>I.Tilt+I.TiltHysteresisMargin&&(L=!1):L=!1,L}function Ze(e,t,n,r,i,a){if(a)se(n,r,ct),k(t,e.center,ct);else{let a=Ge(n,r,lt,t,e.radius,i);k(t,e.center,ce(lt,a))}}function Qe(e,t,n,r,i,a,o){let s=o?20:1;y(J,r),Z.copyFrom(t);let c,l;for(let r=0;r<s&&v(n,J)>1e-12&&(c=v(n,J),Je(n,J,B,z,W,Z,e,i,a,o),Xe(Z,e.center,z,W[1],B,W[0]),Ye(J,J,e.center,z,W[1],B,W[0]),l=v(n,J),l<c||r===0);r++)t.copyFrom(Z)}function $e(n,r,i,a,o,s,c){R(i,h(r.up,i),n.radius,-e.normalize(t(o)),s,r.aboveGround)?Qe(n,r,i,a,-e.normalize(t(o)),s,c):Ze(n,r,i,a,s,c)}function et(e,t,n,r,i,a){let{eye:o}=e;le([0,0,1],o,z,B,at);let s=t.translation[0]*n.pan,c=i.mode===`zoom`?0:t.translation[1]*n.pan,u=Math.max(Math.sqrt(Math.abs(1-h(e.center,z)**2/m(e.center)**2)),.5),d=(Math.sin(a)*c+Math.cos(a)*s)/u,f=-Math.cos(a)*c+Math.sin(a)*s;switch(l(r.pan.matrix,r.pan.matrix,d,z),r.pan.enabled=!0,i.mode){case`pan`:l(r.pan.matrix,r.pan.matrix,f,B),r.pan.enabled=!0;break;case`zoom`:r.zoom=-t.translation[1]*n.zoom}}function tt(e,t,n,r,i){let{eye:a,viewRight:o}=e,s=S(E.get(),o,a),c=t.translation[0]*n.pan;switch(c!==0&&(l(r.pan.matrix,r.pan.matrix,-c,s),r.pan.enabled=!0),i.mode){case`pan`:{let e=t.translation[1]*n.pan;e!==0&&(l(r.pan.matrix,r.pan.matrix,e,o),r.pan.enabled=!0);break}case`zoom`:r.zoom=-t.translation[1]*n.zoom}}function nt(n,r,i,a,o,s,c,l,u){R(n.center,h(n.up,n.center),m(n.center),-e.normalize(t(s)),c,r.aboveGround)?et(r,i,a,l,u,-e.normalize(t(o))):tt(r,i,a,l,u)}function rt(e,t,n=1/0){let r=Math.abs(h(e,t));return Math.min(n,1/r)}function it(e,t,n){let r=te(e,t),i=m(e);return r<Math.max(i,n)}const z=w(),B=w(),at=w(),V=w(),H=w(),U=w(),ot=w(),st=w(),W=p(),ct=ae(),G=d(),K=d(),q=d(),J=w(),Y=w(),X=w();let Z=new _e;const Q=w(),lt=w();function ut(){Z=new _e}const dt={origin:w(),direction:w()},$={origin:w(),direction:w()};export{j as TiltThresholdPanningSpeed,A as VerticalPanTresholds,He as applyPanPlanar,Ze as applyPanSphericalDirectRotation,Qe as applyPanSphericalPreserveHeading,k as applyRotation,Xe as applyRotationWithTwoAxes,Fe as applyZoomOnSphere,Pe as applyZoomToPoint,Le as centroid,ut as cleanupNavigationUtils,O as distanceComparisonTolerance,ke as excludeTerrain,rt as getTiltScaleFactor,Ve as inferNavigationMode,Me as intersectPlaneFromScreenPoint,Ne as intersectPlaneFromScreenPointAtEye,it as isHitOnSamePlanetSide,F as lengthFromPoints,we as maxPanDistanceModifier,Ee as maxRotatePivotDistanceModifier,be as maxZoomPivotDistanceModifier,Se as maxZoomStepDistanceModifier,Te as minPinchAndPanCameraHeight,De as minRotatePivotDistance,Ae as normalizeCoordinate,je as normalizeRotationDelta,ze as offSurfaceTiltToEyeTiltGlobal,Re as onSurfaceTiltToEyeTiltGlobal,nt as panMotionToRotationMatrix,$e as panToPosition,Be as pickPointAndInitSphere,I as preservingHeadingThresholds,Ye as rotatePointAroundTwoAxes,Ge as rotationAngleAndAxisDirectRotation,Je as rotationAnglesAndAxesHeadingPreserving,qe as rotationAnglesHeadingPreserving,Oe as searchAreaSize,R as shouldPreserveHeading,Ue as sphereOrPlanePointFromScreenPoint,xe as zoomPivotDistanceClamp,Ce as zoomStepDistanceClamp};
2
+ import{cyclicalPI as e}from"../../../../core/Cyclical.js";import{deg2rad as t,clamp as n,acosClamped as r,asinClamped as i}from"../../../../core/mathUtils.js";import{createScreenPointArray as a}from"../../../../core/screenUtils.js";import{fromRotation as o,exactEquals as s,multiply as c,rotate as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as u,create as d}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as f}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{exactEquals as ee,length as m,dot as h,subtract as g,normalize as _,squaredDistance as v,copy as y,transformMat4 as b,add as x,distance as te,cross as S,scale as C,lerp as ne,set as re}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{clone as ie,create as w}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as ae,axis as oe,fromPoints as se,wrapAxisAngle as ce}from"../../../../geometry/support/axisAngle.js";import{coordinateSystemFromOneAxisAndNormalVector as le,vectorCoordinates as ue}from"../../../../geometry/support/coordinateSystem.js";import{create as de,fromNormalAndOffset as fe,intersectRay as T}from"../../../../geometry/support/plane.js";import{Sphere as pe}from"../../../../geometry/support/sphere.js";import{sm4d as me,sv3d as E}from"../../../../geometry/support/vectorStacks.js";import{fromScreenAtEye as D,fromScreen as he}from"../../support/geometryUtils/ray.js";import{intersectScreen as ge}from"../../support/geometryUtils/sphere.js";import _e from"../../webgl/RenderCamera.js";import{Intersector as ve}from"../../webgl-engine/lib/Intersector.js";import{terrainId as ye}from"../../webgl-engine/lib/verticalOffsetUtils.js";const be=30,xe=[1,3e8],Se=8,Ce=[200,1508e5],we=5,Te=50,Ee=5,De=10,Oe=90,O=1e-6,ke={exclude:new Set([ye])};function Ae(e,t,n){return n[0]=t[0]/(e.fullWidth/e.pixelRatio),n[1]=t[1]/(e.fullHeight/e.pixelRatio),n}function je(e){for(;e>Math.PI;)e-=2*Math.PI;for(;e<-Math.PI;)e+=2*Math.PI;return e}function k(e,t,n){let r=o(me.get(),n[3],oe(n));r==null||s(r,u)||(g(Y,e.eye,t),b(Y,Y,r),e.eye=x(Y,Y,t),g(Y,e.center,t),b(Y,Y,r),e.center=x(Y,Y,t),e.up=b(Y,e.up,r))}function Me(e,t,n,r){return T(e,he(t,n,dt),r)}function Ne(e,t,n,r){return T(e,D(t,n,dt),r)}function Pe(e,t,n,r){let i=E.get(),a=1-n;g(i,t,e.eye);let o=m(i),s=o*(1-a);a>=0&&s<r&&(s=r,a=-(s-o)/o),Math.abs(o-s)<O||(C(i,i,a),e.eye=x(Y,e.eye,i),e.center=ne(Y,e.center,t,a))}function Fe(e,t,n){t.getScreenCenter(Ie),ge(e,t,Ie,Y)&&(t.center=Y);let r=t.distance,i=r*n;if(Math.abs(r-i)<O)return;let a=C(E.get(),t.viewForward,i);t.eye=g(Y,t.center,a)}const Ie=a();function Le(e,t){re(t,0,0,0);for(let n of e)x(t,t,n);C(t,t,1/e.length)}function Re(e,t,n,r){return Math.sin(e/m(t))*(n+r.radius)}function ze(e,t,n,r){return Re(Math.PI/2,t,n,r)+(e-Math.PI/2)}const A={Elevation:3e4,Angle:t(16)},j=t(80);function Be(e,t,n,r,i,a){let o=e.sceneIntersectionHelper,s=new ve(e.state.viewingMode);s.options.selectionMode=!1,s.options.store=0,s.options.hud=!1,s.options.normalRequired=!0;let c=null,l=w(),u=new pe,d=!0,f=!0,{eye:p}=t;o.intersectIntersectorScreen(n,s,a);let h=s.results.min;return h.getIntersectionPoint(l)&&!ee(p,l)&&it(p,l,r)?(c=ie(h.normal),u.radius=m(l)):(f=!1,u.radius=!t.aboveGround||i===0?m(t.eye)-t.relativeElevation:Math.max(m(t.center),.9*r),i===1?Ue(u,t,n,l):d=ge(u,t,n,l)),{sphere:u,scenePickPoint:d?l:null,hasGeometryIntersection:f,intersectorType:h.intersector,normal:c}}function Ve(e,t,n,r){let i=e.relativeElevation;if(i>A.Elevation&&r===`global`)return 1;D(e,t,$);let a=Math.sign(i),o=n.worldUpAtPosition(e.eye,Y);return-a*h(o,$.direction)<Math.sin(A.Angle)*m($.direction)?0:1}function He(e,t,n){g(M,n,t),e.eye=g(Y,e.eye,M),e.center=g(Y,e.center,M)}const M=w();function Ue(e,t,n,r){let i=D(t,n,dt);return i!=null&&(e.closestPointOnSilhouette(i,N),e.intersectRay(i,r)?v(N,i.origin)<v(r,i.origin)?(y(r,N),!1):!0:(g(P,t.eye,t.center),_(P,P),fe(P,-h(_(P,P),N),We),T(We,i,r),!1))}const N=w(),P=w(),We=de();function Ge(a,o,s,c,l,u){let d=0;if(S(Q,a,o),g(X,a,o),m(a)<=l||!c.aboveGround){S(s,X,c.eye);let f=h(a,o)/(m(a)*m(o));if(f<.9999)d=r(f);else{let e=m(S(w(),a,o))/(m(a)*m(o));d=i(e)}let p=Math.cos(n(e.normalize(t(u)),0,j));d=-d-Math.max(0,m(o)-l)/(p*l)}else g(Ke,c.eye,c.center),S(s,X,Ke),d=-m(X)/l;return _(s,s),C(s,s,m(Q)),d}const Ke=w();function F(i,a,o,s){let c,l,u=Math.cos(n(e.normalize(t(s)),0,j));return c=a>o?-(a-o)/(u*o):a<-o?Math.PI-(a+o)/(u*o):r(a/o),l=i>o?-(i-o)/(u*o):i<-o?Math.PI-(i+o)/(u*o):r(i/o),(l-c)*o}function qe(e,t,n,r,i,a,o,s,c,l){let u=F(e[2],t[2],a.radius,s),d=c?F(e[0],t[0],a.radius,180):t[0]-e[0],p=Math.sin(o)*d-Math.cos(o)*u,ee=Math.cos(o)*d+Math.sin(o)*u;_(Y,i);let m=c?p/Math.sqrt(Math.abs(a.radius**2-h(n,Y)**2)):p/a.radius,g=ee/Math.sqrt(Math.abs(a.radius**2-h(n,r)**2));f(l,m,g)}function Je(e,t,n,r,i,a,o,s,c,l){S(Q,e,t),le(a.up,a.eye,V,H,U),le([0,0,1],a.eye,z,B,at),y(n,B),y(r,z),_(n,n),C(n,n,m(Q)),ue(e,_(H,H),_(U,U),_(V,V),ot),ue(t,H,U,V,st),qe(ot,st,e,z,B,o,s,c,l,i)}function Ye(e,t,n,r,i,a,s){o(G,i,r),o(K,s,a),c(q,G,K),g(t,e,n),b(t,t,q),x(t,t,n)}function Xe(e,t,n,r,i,a){o(G,r,n),o(K,a,i),c(q,G,K),g(Y,e.eye,t),b(Y,Y,q),e.eye=x(Y,Y,t),g(Y,e.center,t),b(Y,Y,q),e.center=x(Y,Y,t),g(Y,e.up,t),b(Y,Y,q),e.up=x(Y,Y,t)}const I={Pole:.95,Angle:t(18),Tilt:45,TiltHysteresisMargin:1e-7};let L=!1;function R(e,t,n,r,i,a){let o=Math.abs(r)>Math.PI-I.Angle||Math.abs(r)<I.Angle,s=(Math.abs(e[2])<n*I.Pole||Math.abs(t)>n)&&a;return o&&s?!L&&i<I.Tilt-I.TiltHysteresisMargin?L=!0:L&&i>I.Tilt+I.TiltHysteresisMargin&&(L=!1):L=!1,L}function Ze(e,t,n,r,i,a){if(a)se(n,r,ct),k(t,e.center,ct);else{let a=Ge(n,r,lt,t,e.radius,i);k(t,e.center,ce(lt,a))}}function Qe(e,t,n,r,i,a,o){let s=o?20:1;y(J,r),Z.copyFrom(t);let c,l;for(let r=0;r<s&&v(n,J)>1e-12&&(c=v(n,J),Je(n,J,B,z,W,Z,e,i,a,o),Xe(Z,e.center,z,W[1],B,W[0]),Ye(J,J,e.center,z,W[1],B,W[0]),l=v(n,J),l<c||r===0);r++)t.copyFrom(Z)}function $e(n,r,i,a,o,s,c){R(i,h(r.up,i),n.radius,-e.normalize(t(o)),s,r.aboveGround)?Qe(n,r,i,a,-e.normalize(t(o)),s,c):Ze(n,r,i,a,s,c)}function et(e,t,n,r,i,a){let{eye:o}=e;le([0,0,1],o,z,B,at);let s=t.translation[0]*n.pan,c=i.mode===`zoom`?0:t.translation[1]*n.pan,u=Math.max(Math.sqrt(Math.abs(1-h(e.center,z)**2/m(e.center)**2)),.5),d=(Math.sin(a)*c+Math.cos(a)*s)/u,f=-Math.cos(a)*c+Math.sin(a)*s;switch(l(r.pan.matrix,r.pan.matrix,d,z),r.pan.enabled=!0,i.mode){case`pan`:l(r.pan.matrix,r.pan.matrix,f,B),r.pan.enabled=!0;break;case`zoom`:r.zoom=-t.translation[1]*n.zoom}}function tt(e,t,n,r,i){let{eye:a,viewRight:o}=e,s=S(E.get(),o,a),c=t.translation[0]*n.pan;switch(c!==0&&(l(r.pan.matrix,r.pan.matrix,-c,s),r.pan.enabled=!0),i.mode){case`pan`:{let e=t.translation[1]*n.pan;e!==0&&(l(r.pan.matrix,r.pan.matrix,e,o),r.pan.enabled=!0);break}case`zoom`:r.zoom=-t.translation[1]*n.zoom}}function nt(n,r,i,a,o,s,c,l,u){R(n.center,h(n.up,n.center),m(n.center),-e.normalize(t(s)),c,r.aboveGround)?et(r,i,a,l,u,-e.normalize(t(o))):tt(r,i,a,l,u)}function rt(e,t,n=1/0){let r=Math.abs(h(e,t));return Math.min(n,1/r)}function it(e,t,n){let r=te(e,t),i=m(e);return r<Math.max(i,n)}const z=w(),B=w(),at=w(),V=w(),H=w(),U=w(),ot=w(),st=w(),W=p(),ct=ae(),G=d(),K=d(),q=d(),J=w(),Y=w(),X=w();let Z=new _e;const Q=w(),lt=w();function ut(){Z=new _e}const dt={origin:w(),direction:w()},$={origin:w(),direction:w()};export{j as TiltThresholdPanningSpeed,A as VerticalPanTresholds,He as applyPanPlanar,Ze as applyPanSphericalDirectRotation,Qe as applyPanSphericalPreserveHeading,k as applyRotation,Xe as applyRotationWithTwoAxes,Fe as applyZoomOnSphere,Pe as applyZoomToPoint,Le as centroid,ut as cleanupNavigationUtils,O as distanceComparisonTolerance,ke as excludeTerrain,rt as getTiltScaleFactor,Ve as inferNavigationMode,Me as intersectPlaneFromScreenPoint,Ne as intersectPlaneFromScreenPointAtEye,it as isHitOnSamePlanetSide,F as lengthFromPoints,we as maxPanDistanceModifier,Ee as maxRotatePivotDistanceModifier,be as maxZoomPivotDistanceModifier,Se as maxZoomStepDistanceModifier,Te as minPinchAndPanCameraHeight,De as minRotatePivotDistance,Ae as normalizeCoordinate,je as normalizeRotationDelta,ze as offSurfaceTiltToEyeTiltGlobal,Re as onSurfaceTiltToEyeTiltGlobal,nt as panMotionToRotationMatrix,$e as panToPosition,Be as pickPointAndInitSphere,I as preservingHeadingThresholds,Ye as rotatePointAroundTwoAxes,Ge as rotationAngleAndAxisDirectRotation,Je as rotationAnglesAndAxesHeadingPreserving,qe as rotationAnglesHeadingPreserving,Oe as searchAreaSize,R as shouldPreserveHeading,Ue as sphereOrPlanePointFromScreenPoint,xe as zoomPivotDistanceClamp,Ce as zoomStepDistanceClamp};