@arcgis/core 6.0.0-next.22 → 6.0.0-next.24

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 (433) hide show
  1. package/Graphic.d.ts +47 -14
  2. package/PopupTemplate.js +1 -1
  3. package/WebScene.d.ts +3 -0
  4. package/analysis/LineOfSightAnalysis.d.ts +1 -1
  5. package/analysis/LineOfSightAnalysisObserver.d.ts +5 -4
  6. package/analysis/LineOfSightAnalysisTarget.d.ts +4 -4
  7. package/analysis/Viewshed.d.ts +4 -4
  8. package/arcade/functions/string.js +1 -1
  9. package/arcgisGlobal.d.ts +0 -5
  10. package/assets/esri/core/workers/RemoteClient.js +1 -1
  11. package/assets/esri/core/workers/chunks/{3c277a0f099d67090d07.js → 02335385b1476fe322eb.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{db9921fbda556f142c4a.js → 04d55ed51e8b2683c4b4.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{435b90168f79c5587a07.js → 04ecf15524ff3838c01c.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{e2f42aec02bff33b25dd.js → 09300e74e5b014ce6269.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{fcb86d24fc7e0666b564.js → 096b2bf1c0d69d27f20c.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{612345f17f5eeb99ea8f.js → 0d9c4c6c571ce26d356b.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{0f725cf79ce00e790a7d.js → 1168bc5c9f0a7e1f63a2.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{4911ce62421a6c3320b0.js → 13c64087be3b2985a21b.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{8e19629899a5becf8e19.js → 150e7a7bd5df25693da7.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{12a7997a40c77f5c9160.js → 151e5799ede763a03ee2.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{a64446a3328a7323e307.js → 173f89c55a5c79ff065b.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{8715661a838361d4211a.js → 1b24a40c0fa197014873.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{ca0d4ce453d8eb35467d.js → 277263466837e1673f56.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{b1d989b72203113a06fe.js → 2a36fe3f3f257a779a1b.js} +1 -1
  25. package/assets/esri/core/workers/chunks/2c0cb214fedb29487eef.js +1 -0
  26. package/assets/esri/core/workers/chunks/{ffcb99693182a621a93e.js → 2cf8172be83b10b11bdc.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{fcaf9450642fcef83286.js → 3048e74e6246324ce6fc.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{95b82cbbe355266c65d7.js → 30af63b3b750142faadb.js} +1 -1
  29. package/assets/esri/core/workers/chunks/30dcf2cfb31cb70de7df.js +1 -0
  30. package/assets/esri/core/workers/chunks/{9f0a973a0dd28953ce25.js → 371e2ddb88cc6b9a41e8.js} +1 -1
  31. package/assets/esri/core/workers/chunks/3fd5c3cd8457ddc68798.js +1 -0
  32. package/assets/esri/core/workers/chunks/{62fec1816907f070f079.js → 3fe04f13215474accb09.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{f47fe4433b05fca5c3ad.js → 42f6194633c2d879c8da.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{cddc3e285f763ccf33c2.js → 4869e097261ded90b8bb.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{d8a7eba588d374b2f961.js → 4bb9a5f4ca944d3fc206.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{2e096537a3a5555a4a93.js → 4cb751dc8d00bdaeb04c.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{8052da8be251c3ff2176.js → 4d93bed14945e3d34d5c.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{65cb5e39c467a35621ca.js → 56e903ccef66cbe18f92.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{44d5508042cacdfcac47.js → 58da3f8cf0f7f6a7e4fa.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{bc915fb182d463d804e6.js → 5c04835b0b52461183cd.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{7e8611cb709f105946f5.js → 6061232c96e11eb7b25d.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{1e514e1c9aabefa04201.js → 64382363d6dc04ff1eac.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{c82daefb193aae895bc0.js → 67e06d606c7fd2064adf.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{434a8ba841a59e0deab9.js → 67e533748435253aaba6.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{feb41abc03d677df6f73.js → 6b9961261241fdce0e94.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{949bee7b304e625a7891.js → 6db0f8fe1402643fbe1a.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{baed828b7846c0863289.js → 6f1d6453184e0a1530ad.js} +22 -18
  48. package/assets/esri/core/workers/chunks/6f897b4e7ddd1dd1672b.js +1 -0
  49. package/assets/esri/core/workers/chunks/{0049b66ccbfb168caa76.js → 7124ad8dc5ad40dc66f3.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{6e107ce73633de8ac257.js → 72f4dad65e16a7d7c58f.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{0df9a906f7823c23d426.js → 7566321c6a2913f2852b.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{c4ddac23bd649d24f3f2.js → 75d551a449bba61ce238.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{af349c7bc8ef41a0e1bd.js → 7748c2886d0122b40eeb.js} +1 -1
  54. package/assets/esri/core/workers/chunks/{b4c3ec081874b49ff89b.js → 78fbe330f16bdbdb886e.js} +1 -1
  55. package/assets/esri/core/workers/chunks/79483c05867ba1386f5a.js +1 -0
  56. package/assets/esri/core/workers/chunks/7b482afb9fd1229f5707.js +1 -0
  57. package/assets/esri/core/workers/chunks/7c631e2947243e2c9bde.js +1 -0
  58. package/assets/esri/core/workers/chunks/{814751e705c05099f864.js → 7c75a8ee266c36baa902.js} +1 -1
  59. package/assets/esri/core/workers/chunks/7db9e615e60d824eac1b.js +1 -0
  60. package/assets/esri/core/workers/chunks/{8a7b02037151767542f1.js → 7dbf4c7480bf9c72820d.js} +1 -1
  61. package/assets/esri/core/workers/chunks/{1b1d3f6916d2cb751435.js → 87177e0f82e8a6ae3189.js} +1 -1
  62. package/assets/esri/core/workers/chunks/{5cb26bbaa08114aec5ce.js → 89cc1a5539b82fb46216.js} +1 -1
  63. package/assets/esri/core/workers/chunks/8b5dcc4282772bf6b675.js +1 -0
  64. package/assets/esri/core/workers/chunks/{8c12269d26f5a4c753cb.js → 8ebaf5754e86a45b0497.js} +1 -1
  65. package/assets/esri/core/workers/chunks/{542e5640ea1b80ef801a.js → 9189dfe19a2a2ccd5173.js} +1 -1
  66. package/assets/esri/core/workers/chunks/{67a35155b8b4d36f171e.js → 926e0a3827eaf16ca8b4.js} +1 -1
  67. package/assets/esri/core/workers/chunks/{dc1761cba0454fda3cf9.js → 9630234267098115de4d.js} +1 -1
  68. package/assets/esri/core/workers/chunks/{10d80e793019dfb45ca2.js → 987424121cf30b0f3c50.js} +1 -1
  69. package/assets/esri/core/workers/chunks/9afc87474cef1fc4fe4a.js +1 -0
  70. package/assets/esri/core/workers/chunks/{facd1ff23203fed67686.js → 9b048f80c2d28d527373.js} +1 -1
  71. package/assets/esri/core/workers/chunks/9dd48e75b4e8d9811d81.js +1 -0
  72. package/assets/esri/core/workers/chunks/{ee08ae5b73439a1ff666.js → a163c6005aba3378edaa.js} +1 -1
  73. package/assets/esri/core/workers/chunks/a4b822ee45810c4c292a.js +1 -0
  74. package/assets/esri/core/workers/chunks/{092e311cb7aea92a6a26.js → acb265a22be5e12f38e5.js} +1 -1
  75. package/assets/esri/core/workers/chunks/{1a411ddae7a47015370c.js → acf4737ba509cbd73cce.js} +1 -1
  76. package/assets/esri/core/workers/chunks/ad96132bc89671e595f3.js +1 -0
  77. package/assets/esri/core/workers/chunks/{d247dd53788d512b9c9f.js → af3c6794334626b94f00.js} +1 -1
  78. package/assets/esri/core/workers/chunks/{532e9cda8ac3601d8892.js → b12acf1f694f82e00df9.js} +1 -1
  79. package/assets/esri/core/workers/chunks/{d08ff41e2a9bcd58b64a.js → ba3d5abff65aefcb8dee.js} +1 -1
  80. package/assets/esri/core/workers/chunks/{504184828048310a052c.js → bdc221d94300c225665a.js} +1 -1
  81. package/assets/esri/core/workers/chunks/c0eb27263f608dc3684b.js +1 -0
  82. package/assets/esri/core/workers/chunks/c2318c014e97ba519be8.js +1 -0
  83. package/assets/esri/core/workers/chunks/{7f8e327acad48c9e75ea.js → c62237c344e341619341.js} +1 -1
  84. package/assets/esri/core/workers/chunks/{a2ad3e620c98e2b2eb06.js → cd355baab983033c3ef0.js} +1 -1
  85. package/assets/esri/core/workers/chunks/{7be6d621a0d1e33dfff4.js → d070fcb73ce274ab80e4.js} +1 -1
  86. package/assets/esri/core/workers/chunks/{6d41444b46677aa762a7.js → db41490bd39d863305bf.js} +1 -1
  87. package/assets/esri/core/workers/chunks/{fc5a36e54929e03efa86.js → dba5f44c4e4a3f075df2.js} +1 -1
  88. package/assets/esri/core/workers/chunks/{3e30b96a8c75bd5b9ae2.js → ddc95cdac6c06fc4794c.js} +1 -1
  89. package/assets/esri/core/workers/chunks/{a5c8f9f5be4ef5063b42.js → df26ec0b508cf4716e0a.js} +1 -1
  90. package/assets/esri/core/workers/chunks/{f426da2210888cc264b4.js → e83f9abee611c5b80009.js} +1 -1
  91. package/assets/esri/core/workers/chunks/{8487727f1197cf7dbf50.js → ef12fa3574d4cbf8b084.js} +1 -1
  92. package/assets/esri/core/workers/chunks/f10c883eb26330e3421c.js +1 -0
  93. package/assets/esri/core/workers/chunks/f46e92c67986c8c09bdd.js +1 -0
  94. package/assets/esri/core/workers/chunks/{709e019885822b1f6f3e.js → f905f1a1aa4c123cbe83.js} +1 -1
  95. package/assets/esri/core/workers/chunks/{5b91e2dffdc84c006539.js → fb37f0848196c28b7fd7.js} +1 -1
  96. package/assets/esri/libs/librust-parquet/pkg/parquet_bg.wasm +0 -0
  97. package/assets/esri/libs/librust-text/pkg/text_bg.wasm +0 -0
  98. package/assets/esri/themes/base/_core.scss +0 -2
  99. package/assets/esri/themes/dark/main.css +1 -1
  100. package/assets/esri/themes/light/main.css +1 -1
  101. package/assets/esri/themes/light/view.css +1 -1
  102. package/chunks/Component.glsl.js +9 -12
  103. package/chunks/DefaultMaterial.glsl.js +4 -5
  104. package/chunks/MultiPathImpl.js +1 -1
  105. package/chunks/OperatorProximityGeodesic.js +1 -1
  106. package/chunks/Path.glsl.js +2 -4
  107. package/chunks/RealisticTree.glsl.js +3 -3
  108. package/chunks/SSAO.glsl.js +1 -2
  109. package/chunks/basis_encoder.js +1 -1
  110. package/chunks/basis_transcoder.js +1 -1
  111. package/chunks/draco_mesh_decoder.js +1 -1
  112. package/chunks/dxt_encoder.js +1 -1
  113. package/chunks/i3s.js +1 -1
  114. package/chunks/lclayout.js +1 -1
  115. package/chunks/lerc-wasm.js +1 -1
  116. package/chunks/libtess-f32.js +1 -1
  117. package/chunks/libtess-f64.js +1 -1
  118. package/chunks/lyr3DMain.js +1 -1
  119. package/chunks/lyr3DWorker.js +1 -1
  120. package/chunks/parquet.js +1 -1
  121. package/chunks/qb3-wasm.js +1 -1
  122. package/chunks/rbush.js +1 -1
  123. package/chunks/text.js +1 -1
  124. package/chunks/vxlLayer.js +1 -1
  125. package/config.js +1 -1
  126. package/core/workers/WorkerFallback.js +4 -2
  127. package/core/workers/workerFactory.js +1 -1
  128. package/core/workers/workers.js +4 -2
  129. package/geometry/support/clipRay.js +1 -1
  130. package/geometry/support/labelPoint.js +1 -1
  131. package/geometry/support/plane.js +1 -1
  132. package/graphic/AnnotationFeatureGraphicOrigin.d.ts +49 -9
  133. package/graphic/BuildingGraphicOrigin.d.ts +49 -0
  134. package/graphic/CSVGraphicOrigin.d.ts +42 -9
  135. package/graphic/CatalogGraphicOrigin.d.ts +42 -9
  136. package/graphic/DimensionFeatureGraphicOrigin.d.ts +42 -9
  137. package/graphic/FeatureGraphicOrigin.d.ts +42 -9
  138. package/graphic/GeoJSONGraphicOrigin.d.ts +42 -9
  139. package/graphic/GeoRSSGraphicOrigin.d.ts +42 -9
  140. package/graphic/GraphicOrigin.d.ts +52 -12
  141. package/graphic/ImageryGraphicOrigin.d.ts +42 -9
  142. package/graphic/ImageryTileGraphicOrigin.d.ts +42 -9
  143. package/graphic/KMLGraphicOrigin.d.ts +47 -10
  144. package/graphic/KnowledgeGraphGraphicOrigin.d.ts +49 -1
  145. package/graphic/LinkChartGraphicOrigin.d.ts +49 -1
  146. package/graphic/MapImageGraphicOrigin.d.ts +49 -1
  147. package/graphic/MapNotesGraphicOrigin.d.ts +48 -1
  148. package/graphic/OGCFeatureGraphicOrigin.d.ts +42 -9
  149. package/graphic/OrientedImageryGraphicOrigin.d.ts +42 -9
  150. package/graphic/ParquetGraphicOrigin.d.ts +42 -9
  151. package/graphic/PointCloudGraphicOrigin.d.ts +43 -0
  152. package/graphic/SceneGraphicOrigin.d.ts +43 -0
  153. package/graphic/SketchGraphicOrigin.d.ts +43 -0
  154. package/graphic/StreamGraphicOrigin.d.ts +43 -0
  155. package/graphic/SubtypeGroupGraphicOrigin.d.ts +49 -1
  156. package/graphic/TileGraphicOrigin.d.ts +49 -1
  157. package/graphic/VectorTileGraphicOrigin.d.ts +43 -14
  158. package/graphic/VoxelGraphicOrigin.d.ts +43 -0
  159. package/graphic/WCSGraphicOrigin.d.ts +43 -0
  160. package/graphic/WFSGraphicOrigin.d.ts +42 -9
  161. package/graphic/getGraphicOriginTitle.d.ts +21 -3
  162. package/interfaces.d.ts +0 -55
  163. package/kernel.js +1 -1
  164. package/layers/ElevationLayer.d.ts +6 -2
  165. package/layers/GaussianSplatLayer.d.ts +2 -1
  166. package/layers/GeoJSONLayer.d.ts +2 -107
  167. package/layers/IntegratedMeshLayer.js +1 -1
  168. package/layers/ParquetLayer.d.ts +24 -1
  169. package/layers/ParquetLayer.js +1 -1
  170. package/layers/SceneLayer.d.ts +40 -16
  171. package/layers/ViewshedLayer.d.ts +10 -4
  172. package/layers/WMSLayer.d.ts +2 -69
  173. package/layers/mixins/ReloadableLayer.js +1 -1
  174. package/layers/mixins/TemporalLayer.d.ts +70 -48
  175. package/layers/mixins/TiledImagery.d.ts +0 -11
  176. package/layers/orientedImagery/transformations/utils.js +1 -1
  177. package/layers/save/featureLayerUtils.js +1 -1
  178. package/layers/save/imageryUtils.js +1 -1
  179. package/layers/save/mapImageLayerUtils.js +1 -1
  180. package/layers/save/mediaLayerUtils.js +1 -1
  181. package/layers/save/parquetLayerUtils.js +2 -0
  182. package/layers/save/streamLayerUtils.js +1 -1
  183. package/layers/support/LabelClass.d.ts +8 -2
  184. package/layers/support/layersMapping.js +1 -1
  185. package/layers/support/rasterJobHelper.js +1 -1
  186. package/layers/video/VideoController.js +5 -5
  187. package/package.json +2 -2
  188. package/popup/content.d.ts +38 -1
  189. package/popup/content.js +1 -1
  190. package/portal/schemas/definitions.js +1 -1
  191. package/portal/schemas/webScene.js +1 -1
  192. package/rest/query/operations/pbfDehydratedFeatureSet.js +1 -1
  193. package/rest/query/operations/pbfFlatFeatureSet.js +1 -1
  194. package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
  195. package/smartMapping/popup/support/clusterUtils.js +1 -1
  196. package/smartMapping/popup/support/utils.js +2 -2
  197. package/smartMapping/renderers/size.js +1 -1
  198. package/smartMapping/renderers/support/regenerateUtils.js +1 -1
  199. package/support/timeUtils.d.ts +11 -0
  200. package/undoredo/support/ApplySet.js +1 -1
  201. package/views/2d/engine/flow/ProcessingTimeEstimate.js +1 -1
  202. package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
  203. package/views/2d/engine/vectorTiles/buckets/SymbolBucket.js +1 -1
  204. package/views/2d/engine/webgl/GlyphWorker.js +1 -1
  205. package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
  206. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
  207. package/views/2d/layers/features/Processor.js +1 -1
  208. package/views/2d/layers/features/aggregation/GeohashSpatialIndex.js +1 -1
  209. package/views/2d/layers/features/aggregation/GridSpatialIndex.js +1 -1
  210. package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
  211. package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
  212. package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
  213. package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
  214. package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
  215. package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
  216. package/views/2d/layers/features/layerAdapters/ParquetLayerAdapter.js +1 -1
  217. package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +1 -1
  218. package/views/2d/layers/features/processor/AggregateStrategy.js +1 -1
  219. package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
  220. package/views/2d/layers/features/processor/bins/BinAdapter.js +1 -1
  221. package/views/2d/layers/features/processor/bins/BinLevelState.js +1 -1
  222. package/views/2d/layers/features/processor/clusters/ClusterAdapter.js +1 -1
  223. package/views/2d/layers/features/processor/clusters/ClusterLevelState.js +1 -1
  224. package/views/2d/layers/features/processor/tracks/TrackAdapter.js +1 -1
  225. package/views/2d/layers/features/processor/tracks/TrackLevelState.js +1 -1
  226. package/views/2d/layers/features/schema/processor/SimpleProcessorSchema.js +1 -1
  227. package/views/2d/layers/features/sources/strategies/chunks/ASourceChunk.js +1 -1
  228. package/views/2d/layers/features/sources/strategies/chunks/ByReferenceTileSourceChunk.js +1 -1
  229. package/views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js +1 -1
  230. package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +1 -1
  231. package/views/2d/layers/features/sources/strategies/chunks/ParquetSnapshotSourceChunk.js +1 -1
  232. package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
  233. package/views/2d/layers/features/sources/strategies/chunks/StreamSourceChunk.js +1 -1
  234. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  235. package/views/2d/layers/features/support/FeatureFilterEvaluator.js +1 -1
  236. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  237. package/views/2d/layers/features/support/GraphicsReader.js +1 -1
  238. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  239. package/views/3d/environment/SunLighting.d.ts +0 -1
  240. package/views/3d/environment/SunLighting.js +1 -1
  241. package/views/3d/environment/VirtualLighting.d.ts +0 -1
  242. package/views/3d/environment/VirtualLighting.js +1 -1
  243. package/views/3d/input/handlers/ground/GroundDoubleClickMove.js +1 -1
  244. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  245. package/views/3d/interactive/placementTools/GroundNavigationPlacementTool3D.js +1 -1
  246. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  247. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  248. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  249. package/views/3d/layers/graphics/ElevationAligners.js +1 -1
  250. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  251. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  252. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  253. package/views/3d/layers/graphics/LabelParameters.js +1 -1
  254. package/views/3d/layers/graphics/Labeler.js +1 -1
  255. package/views/3d/layers/graphics/elevationAlignmentUtils.js +1 -1
  256. package/views/3d/layers/graphics/pointUtils.js +1 -1
  257. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  258. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  259. package/views/3d/layers/support/Tiles3DBVH.js +1 -1
  260. package/views/3d/layers/support/featureTileQuery3D.js +1 -1
  261. package/views/3d/state/controllers/ZoomControllerLocal.js +1 -1
  262. package/views/3d/state/controllers/ZoomStepControllerLocal.js +1 -1
  263. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  264. package/views/3d/state/utils/groundNavigationUtils.js +1 -1
  265. package/views/3d/state/utils/navigationUtils.js +1 -1
  266. package/views/3d/terrain/TerrainRenderer.js +1 -1
  267. package/views/3d/terrain/TerrainSurface.js +1 -1
  268. package/views/3d/webgl-engine/collections/Component/Material/Component.glsl.js +1 -1
  269. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUD.glsl.js +1 -2
  270. package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceRayMarching.glsl.js +1 -2
  271. package/views/3d/webgl-engine/effects/glow/applyEmissiveGlow.glsl.js +9 -4
  272. package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
  273. package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowCastRenderer.js +1 -1
  274. package/views/3d/webgl-engine/effects/snowcover/applySnow.glsl.js +18 -0
  275. package/views/3d/webgl-engine/lib/Intersector.js +1 -1
  276. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  277. package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
  278. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  279. package/views/3d/webgl-engine/lib/screenPolygonTriangleIntersections.js +1 -1
  280. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  281. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  282. package/views/3d/webgl-engine/materials/Path.glsl.js +1 -1
  283. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  284. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  285. package/views/3d/webgl-engine/materials/TriangleMaterial.js +1 -1
  286. package/views/3d/webgl-engine/materials/internal/worldSizedRibbonLineIntersectionUtils.js +2 -0
  287. package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
  288. package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
  289. package/views/DOMContainer.js +1 -1
  290. package/views/draw/SegmentDrawAction.js +1 -1
  291. package/views/interactive/snapping/SnappingManagerPool.js +1 -1
  292. package/views/interactive/tooltip/content/TooltipContent.js +1 -1
  293. package/views/interactive/tooltip/fields/TooltipField.js +1 -1
  294. package/views/layers/LineOfSightLayerView.d.ts +2 -2
  295. package/views/layers/ViewshedLayerView.d.ts +2 -1
  296. package/views/support/LayerViewManager.js +1 -1
  297. package/views/support/ScheduledQueueProcessor.js +1 -1
  298. package/views/support/screenshotUtils.js +1 -1
  299. package/views/ui/UI.js +1 -1
  300. package/webdoc/support/webdocSaveUtils.js +1 -1
  301. package/webscene/Slide.d.ts +1 -2
  302. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  303. package/widgets/Feature/FeatureExpression/FeatureExpressionViewModel.js +1 -1
  304. package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
  305. package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
  306. package/widgets/FeatureTable/RelationshipColumn.js +1 -1
  307. package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
  308. package/widgets/Locate.d.ts +1 -1
  309. package/widgets/OrientedImageryViewer/ImageMeasurementWorker.js +1 -1
  310. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  311. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  312. package/widgets/OrientedImageryViewer/services/ImageMeasurementService.js +1 -1
  313. package/widgets/Search/SearchViewModel.js +1 -1
  314. package/widgets/Search/support/layerSearchUtils.js +1 -1
  315. package/widgets/Sketch/SketchViewModel.js +1 -1
  316. package/widgets/Sketch/support/PluginManager.js +1 -1
  317. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceFeature.js +1 -1
  318. package/widgets/support/GeolocationPositioning.d.ts +1 -2
  319. package/assets/esri/core/workers/chunks/14d5d219e7fe017f23f0.js +0 -1
  320. package/assets/esri/core/workers/chunks/42045cf46497828cd3c0.js +0 -1
  321. package/assets/esri/core/workers/chunks/42753cf4965a94bc91ca.js +0 -1
  322. package/assets/esri/core/workers/chunks/42e985a576d7aaeed0cf.js +0 -1
  323. package/assets/esri/core/workers/chunks/5046214dd32029cb733d.js +0 -1
  324. package/assets/esri/core/workers/chunks/576248e9ae2654569420.js +0 -1
  325. package/assets/esri/core/workers/chunks/58865772bed48141a56a.js +0 -1
  326. package/assets/esri/core/workers/chunks/6059853ef3b6cddbe869.js +0 -1
  327. package/assets/esri/core/workers/chunks/72e6d594b7262430ae55.js +0 -1
  328. package/assets/esri/core/workers/chunks/7d11710e1586a3d75887.js +0 -1
  329. package/assets/esri/core/workers/chunks/8f74d92ac69714b9fd4e.js +0 -1
  330. package/assets/esri/core/workers/chunks/a09d2e1e2540921e4717.js +0 -1
  331. package/assets/esri/core/workers/chunks/a35c69a4751d28c39907.js +0 -1
  332. package/assets/esri/core/workers/chunks/a679207c3458cc0b1fec.js +0 -1
  333. package/assets/esri/core/workers/chunks/dfa5f1311806473e473f.js +0 -1
  334. package/assets/esri/core/workers/chunks/fc76aff0f7d95e517d8f.js +0 -1
  335. package/assets/esri/themes/base/widgets/_DirectionalPad.scss +0 -85
  336. package/assets/esri/widgets/DirectionalPad/t9n/messages.ar.json +0 -1
  337. package/assets/esri/widgets/DirectionalPad/t9n/messages.bg.json +0 -1
  338. package/assets/esri/widgets/DirectionalPad/t9n/messages.bs.json +0 -1
  339. package/assets/esri/widgets/DirectionalPad/t9n/messages.ca.json +0 -1
  340. package/assets/esri/widgets/DirectionalPad/t9n/messages.cs.json +0 -1
  341. package/assets/esri/widgets/DirectionalPad/t9n/messages.da.json +0 -1
  342. package/assets/esri/widgets/DirectionalPad/t9n/messages.de.json +0 -1
  343. package/assets/esri/widgets/DirectionalPad/t9n/messages.el.json +0 -1
  344. package/assets/esri/widgets/DirectionalPad/t9n/messages.en.json +0 -1
  345. package/assets/esri/widgets/DirectionalPad/t9n/messages.es.json +0 -1
  346. package/assets/esri/widgets/DirectionalPad/t9n/messages.et.json +0 -1
  347. package/assets/esri/widgets/DirectionalPad/t9n/messages.fi.json +0 -1
  348. package/assets/esri/widgets/DirectionalPad/t9n/messages.fr.json +0 -1
  349. package/assets/esri/widgets/DirectionalPad/t9n/messages.he.json +0 -1
  350. package/assets/esri/widgets/DirectionalPad/t9n/messages.hr.json +0 -1
  351. package/assets/esri/widgets/DirectionalPad/t9n/messages.hu.json +0 -1
  352. package/assets/esri/widgets/DirectionalPad/t9n/messages.id.json +0 -1
  353. package/assets/esri/widgets/DirectionalPad/t9n/messages.it.json +0 -1
  354. package/assets/esri/widgets/DirectionalPad/t9n/messages.ja.json +0 -1
  355. package/assets/esri/widgets/DirectionalPad/t9n/messages.ko.json +0 -1
  356. package/assets/esri/widgets/DirectionalPad/t9n/messages.lt.json +0 -1
  357. package/assets/esri/widgets/DirectionalPad/t9n/messages.lv.json +0 -1
  358. package/assets/esri/widgets/DirectionalPad/t9n/messages.nl.json +0 -1
  359. package/assets/esri/widgets/DirectionalPad/t9n/messages.no.json +0 -1
  360. package/assets/esri/widgets/DirectionalPad/t9n/messages.pl.json +0 -1
  361. package/assets/esri/widgets/DirectionalPad/t9n/messages.pt-BR.json +0 -1
  362. package/assets/esri/widgets/DirectionalPad/t9n/messages.pt-PT.json +0 -1
  363. package/assets/esri/widgets/DirectionalPad/t9n/messages.ro.json +0 -1
  364. package/assets/esri/widgets/DirectionalPad/t9n/messages.ru.json +0 -1
  365. package/assets/esri/widgets/DirectionalPad/t9n/messages.sk.json +0 -1
  366. package/assets/esri/widgets/DirectionalPad/t9n/messages.sl.json +0 -1
  367. package/assets/esri/widgets/DirectionalPad/t9n/messages.sr.json +0 -1
  368. package/assets/esri/widgets/DirectionalPad/t9n/messages.sv.json +0 -1
  369. package/assets/esri/widgets/DirectionalPad/t9n/messages.th.json +0 -1
  370. package/assets/esri/widgets/DirectionalPad/t9n/messages.tr.json +0 -1
  371. package/assets/esri/widgets/DirectionalPad/t9n/messages.uk.json +0 -1
  372. package/assets/esri/widgets/DirectionalPad/t9n/messages.vi.json +0 -1
  373. package/assets/esri/widgets/DirectionalPad/t9n/messages.zh-CN.json +0 -1
  374. package/assets/esri/widgets/DirectionalPad/t9n/messages.zh-HK.json +0 -1
  375. package/assets/esri/widgets/DirectionalPad/t9n/messages.zh-TW.json +0 -1
  376. package/assets/esri/widgets/Track/t9n/messages.ar.json +0 -1
  377. package/assets/esri/widgets/Track/t9n/messages.bg.json +0 -1
  378. package/assets/esri/widgets/Track/t9n/messages.bs.json +0 -1
  379. package/assets/esri/widgets/Track/t9n/messages.ca.json +0 -1
  380. package/assets/esri/widgets/Track/t9n/messages.cs.json +0 -1
  381. package/assets/esri/widgets/Track/t9n/messages.da.json +0 -1
  382. package/assets/esri/widgets/Track/t9n/messages.de.json +0 -1
  383. package/assets/esri/widgets/Track/t9n/messages.el.json +0 -1
  384. package/assets/esri/widgets/Track/t9n/messages.en.json +0 -1
  385. package/assets/esri/widgets/Track/t9n/messages.es.json +0 -1
  386. package/assets/esri/widgets/Track/t9n/messages.et.json +0 -1
  387. package/assets/esri/widgets/Track/t9n/messages.fi.json +0 -1
  388. package/assets/esri/widgets/Track/t9n/messages.fr.json +0 -1
  389. package/assets/esri/widgets/Track/t9n/messages.he.json +0 -1
  390. package/assets/esri/widgets/Track/t9n/messages.hr.json +0 -1
  391. package/assets/esri/widgets/Track/t9n/messages.hu.json +0 -1
  392. package/assets/esri/widgets/Track/t9n/messages.id.json +0 -1
  393. package/assets/esri/widgets/Track/t9n/messages.it.json +0 -1
  394. package/assets/esri/widgets/Track/t9n/messages.ja.json +0 -1
  395. package/assets/esri/widgets/Track/t9n/messages.ko.json +0 -1
  396. package/assets/esri/widgets/Track/t9n/messages.lt.json +0 -1
  397. package/assets/esri/widgets/Track/t9n/messages.lv.json +0 -1
  398. package/assets/esri/widgets/Track/t9n/messages.nl.json +0 -1
  399. package/assets/esri/widgets/Track/t9n/messages.no.json +0 -1
  400. package/assets/esri/widgets/Track/t9n/messages.pl.json +0 -1
  401. package/assets/esri/widgets/Track/t9n/messages.pt-BR.json +0 -1
  402. package/assets/esri/widgets/Track/t9n/messages.pt-PT.json +0 -1
  403. package/assets/esri/widgets/Track/t9n/messages.ro.json +0 -1
  404. package/assets/esri/widgets/Track/t9n/messages.ru.json +0 -1
  405. package/assets/esri/widgets/Track/t9n/messages.sk.json +0 -1
  406. package/assets/esri/widgets/Track/t9n/messages.sl.json +0 -1
  407. package/assets/esri/widgets/Track/t9n/messages.sr.json +0 -1
  408. package/assets/esri/widgets/Track/t9n/messages.sv.json +0 -1
  409. package/assets/esri/widgets/Track/t9n/messages.th.json +0 -1
  410. package/assets/esri/widgets/Track/t9n/messages.tr.json +0 -1
  411. package/assets/esri/widgets/Track/t9n/messages.uk.json +0 -1
  412. package/assets/esri/widgets/Track/t9n/messages.vi.json +0 -1
  413. package/assets/esri/widgets/Track/t9n/messages.zh-CN.json +0 -1
  414. package/assets/esri/widgets/Track/t9n/messages.zh-HK.json +0 -1
  415. package/assets/esri/widgets/Track/t9n/messages.zh-TW.json +0 -1
  416. package/views/2d/layers/features/FeatureSpatialIndex.js +0 -2
  417. package/views/2d/layers/features/support/FeatureSetReaderIndirect.js +0 -2
  418. package/views/3d/webgl-engine/effects/snowcover/SnowCover.glsl.js +0 -12
  419. package/widgets/DirectionalPad/DirectionalPadViewModel.d.ts +0 -85
  420. package/widgets/DirectionalPad/DirectionalPadViewModel.js +0 -2
  421. package/widgets/DirectionalPad/VisibleElements.d.ts +0 -40
  422. package/widgets/DirectionalPad/VisibleElements.js +0 -2
  423. package/widgets/DirectionalPad/constants.js +0 -2
  424. package/widgets/DirectionalPad/css.js +0 -2
  425. package/widgets/DirectionalPad/types.d.ts +0 -27
  426. package/widgets/DirectionalPad/utils.js +0 -2
  427. package/widgets/DirectionalPad.d.ts +0 -156
  428. package/widgets/DirectionalPad.js +0 -2
  429. package/widgets/Track/TrackViewModel.d.ts +0 -131
  430. package/widgets/Track/TrackViewModel.js +0 -2
  431. package/widgets/Track/types.d.ts +0 -6
  432. package/widgets/Track.d.ts +0 -278
  433. package/widgets/Track.js +0 -2
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{forEach as n,result as r}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import i from"../../../../core/Logger.js";import{disposeMaybe as a,abortMaybe as o}from"../../../../core/maybe.js";import{throwIfAborted as s,isAbortError as c}from"../../../../core/promiseUtils.js";import l from"../../../../core/Queue.js";import{watch as u}from"../../../../core/reactiveUtils.js";import{property as d,subclass as f}from"../../../../core/accessorSupport/decorators.js";import{fromValues as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{isInEffectiveScaleRange as m}from"../../../../geometry/support/scaleUtils.js";import{hydrateGraphic as h}from"../../../../layers/graphics/hydratedFeatures.js";import{createLabelFunction as g}from"../../../../layers/support/labelFormatUtils.js";import{hasCalloutSupport as _}from"../../../../symbols/callouts/calloutUtils.js";import{make as v}from"./Graphics3DCalloutSymbolLayerFactory.js";import{LineCalloutCreationContext as y,LineCalloutSymbolLayerRenderingInfo as b}from"./Graphics3DLineCalloutSymbolLayer.js";import{getGraphics3DSymbol as x}from"./graphicSymbolUtils.js";import{LabelInfo as S}from"./LabelInfo.js";import{LabelParameters as C}from"./LabelParameters.js";import{horizontalPlacementFromAnchor as w,verticalPlacementFromAnchor as T,textRenderAlignmentFromHorizontalPlacement as E}from"./placementUtils.js";import{placePointOnGeometry as D}from"./pointUtils.js";import{TextRenderer as O}from"../../webgl-engine/lib/TextRenderer.js";import{TextRenderParameters as k}from"../../webgl-engine/lib/TextRenderParameters.js";import{TextTextureAtlas as A}from"../../webgl-engine/lib/TextTextureAtlas.js";import{WebGLLayer as j}from"../../webgl-engine/lib/WebGLLayer.js";import{hasLayerBasedScaleVisibility as M}from"../../../support/layerViewUtils.js";import{TaskPriority as N}from"../../../support/Scheduler.js";import{Yield as P}from"../../../support/Yield.js";class F{constructor(e,t){this.labelingContext=e,this.graphics3DGraphic=t,this.hasGraphics3DResources=!1,this.visible=!1,this.textureAtlasHandles=[],this.textInitialized=!1,this.textRenderers=[],this.textLabelPlacements=[]}}class I{constructor(e,t,n,r,i){this.labelClass=e,this.graphics3DSymbol=t,this.graphics3DCalloutSymbolLayer=n,this.textRenderParameters=r,this.labelFunction=i,this.calloutSymbolLayerIndex=0,this.graphics=new Map,this.scaleVisibility=null}}class L{constructor(e,t,n,r,i,a,o,s){this.layer=t,this.graphics3DCore=n,this.scaleVisibility=r,this.emptySymbolLabelSupported=i,this.elevationInfoOverride=a,this.disablePlacement=o,this.active=s,this.labelClassAbortController=new AbortController,this._labelClassContexts=[],this.graphics=new Map,this.labelsToInitialize=new Map,this.stageLayer=new j(e,{pickable:!0},n.owner.layerViewUid)}destroy(){this.stageLayer.destroy()}get labelClassContexts(){return this._labelClassContexts}setLabelClassContext(e,t){this._labelClassContexts[e]=t}resetLabelClassContext(){this._labelClassContexts.length=0}}let R=class extends t{constructor(e){super(e),this._hudMaterials=new Map,this._calloutMaterials=new Map,this._dirty=!1,this._focusAreasLabelsQueue=new l,this._labels=new Map,this._labelingContexts=[]}setup(){this.dispose(),this.addHandles([u(()=>this.view.state?.camera,()=>this.setDirty()),u(()=>this.view.state?.rasterPixelRatio,()=>this._resetAllLabels()),u(()=>this.view.timeZone,()=>this._resetArcadeLabels()),u(()=>this.view.focusAreasView?.polygons,()=>this._updateFocus()),this.view.resourceController.scheduler.registerTask(N.LABELER,this)]),M()&&this.addHandles(u(()=>this.view.scale,()=>this._updateScaleVisibility())),this._textTextureAtlas=new A({view:this.view})}dispose(){this.removeAllHandles(),this._textTextureAtlas=a(this._textTextureAtlas),this._hudMaterials.clear(),this._calloutMaterials.clear(),this._labelingContexts.length=0,this._labels.clear()}destroy(){this.dispose(),G.graphic=null,G.renderingInfo=null,G.layer=null}_updateFocus(){this._focusAreasLabelsQueue.clear(),this._labelingContexts.forEach(e=>{e.graphics.forEach(t=>{this._focusAreasLabelsQueue.push({graphic3DGraphic:t,labelingContext:e})})})}_activateLabelingContext(e){e.graphics.forEach((t,n)=>{let r=new F(e,t);this._labels.set(n,r),e.labelsToInitialize.set(n,r),t.setVisibilityFlag(16,1,!0)}),e.active=!0}_deactivateLabelingContext(e){e.graphics.forEach((e,t)=>{e.setVisibilityFlag(16,1,!1),this.setLabelGraphicVisibility(e,!1),e.clearLabelGraphics(),this._labels.delete(t)}),e.active=!1}_addLabelTextureToAtlas(e){if(this._textTextureAtlas)for(let t of e.graphics3DGraphic.labelLayers){if(!t.labelClass)continue;let n=e.textRenderers[t.labelClassContextIndex];n&&(e.textureAtlasHandles.push(this._textTextureAtlas.addText(n,e=>B(t.stageObject,e))),z(t.stageObject,n))}}_removeLabelTextureFromAtlas(e){e.textureAtlasHandles.forEach(e=>e.remove()),e.textureAtlasHandles.length=0}get readyToRun(){return this.view.ready&&(this._dirty||this.deconflictor.readyToRun||this._focusAreasLabelsQueue.length>0)}runTask(e){return this._updateLabels(e),this._applyFocusAreasUpdates(e),!this._dirty&&this.deconflictor.readyToRun&&this.deconflictor.runTask(e),P}_updateLabels(e){if(this._dirty){this._dirty=!1;for(let t of this._labelingContexts)if(t.active){if(V(t))this._dirty=!0;else if(H(t.labelClassContexts)){if(t.labelClassContexts===null){this._deactivateLabelingContext(t);continue}this._createLabelClassContext(t),this._dirty=!0}else for(let[n,r]of t.labelsToInitialize)if(this._ensureGraphics3DResources(r)&&(this._labels.set(n,r),this.deconflictor.setDirty(),e.madeProgress()),(r.visible&&r.textInitialized||!r.visible&&r.hasGraphics3DResources)&&(t.labelsToInitialize.delete(n),e.madeProgress()),e.done){this._dirty=!0;break}}this._dirty||this.notifyChange(`updating`)}}_applyFocusAreasUpdates(e){for(;this._focusAreasLabelsQueue.length>0&&!e.done;){e.madeProgress();let{graphic3DGraphic:t,labelingContext:n}=this._focusAreasLabelsQueue.pop();if(t.labelLayers.length===0||!n.active)continue;let r=D(t.graphic.geometry);if(r==null)continue;let i=this.view.focusAreasView?.containsGeometry(r)??!0;t.labelLayers.forEach(e=>{e.stageObject.geometries.some(e=>e.material.parameters.focusAreaStyle==null!==i)&&(this._removeGraphic(n,t),this._addGraphic(n,t),this.setDirty())})}this._focusAreasLabelsQueue.length===0&&(this.notifyChange(`readyToRun`),this.notifyChange(`updating`))}async _createLabelClassContextAsync(e){let t=e.labelClassAbortController?.signal;e.layer.when&&await e.layer.when(),s(t),e.scaleVisibility?.updateScaleRangeActive();let a=e.graphics3DCore,o=a.layer.labelingInfo?.filter(e=>!!e.symbol);o&&o.length!==0&&(await n(o,async(n,o)=>{let c=n.symbol,l=x(a.getOrCreateGraphics3DSymbol(c));if(l==null){i.getLogger(this).error(`Failed to create Graphics3DSymbol for label`);return}await l.load(),s(t);let u=null;_(c)&&c.hasVisibleCallout()&&(u=v(c,a.symbolCreationContext),await u.load(),s(t));let d=await r(g(n,e.layer.fieldsIndex,this.view.spatialReference));if(s(t),d.ok===!0){let r=await this._createTextRenderParameters(l.symbol);s(t);let i=new I(n,l,u,r,d.value);this._updateLabelClassContextVisibility(i),e.setLabelClassContext(o,i)}else i.getLogger(this).error(`Label expression failed to evaluate: ${d.error}`)}),s(t))}async _createLabelClassContext(e){return e.labelClassPromise??(e.labelClassPromise=this._createLabelClassContextAsync(e).catch(t=>{if(c(t))throw t;e.resetLabelClassContext()}).then(()=>{e.labelClassAbortController=null,this.notifyChange(`updating`)}).catch(()=>{}),this.notifyChange(`updating`)),e.labelClassPromise}async _createTextRenderParameters(e){let t=e.symbolLayers.at(0);return t?.type===`text`?k.fromSymbol(t,this.view.state.rasterPixelRatio):null}_destroyLabelClassContext(e){for(let t of e.labelClassContexts)t&&--t.graphics3DSymbol.referenced;let t=e.labelClassAbortController;e.labelClassAbortController=new AbortController,o(t),e.resetLabelClassContext(),e.labelClassPromise=null,this.notifyChange(`updating`)}_createTextSymbolGraphic(e,t,n,r,i,a){if(!this._textTextureAtlas)return null;let o=new C(n,w(n.anchor),T(n.anchor),e.text,p(e.displayWidth,e.displayHeight));return G.graphic=t,G.layer=r,G.renderingInfo=null,i.createLabel(G,o,this._hudMaterials,this._textTextureAtlas,()=>a.placement?.elevationOffset??null)}_createLineCalloutGraphic(e,t,n,r,i){G.graphic=e,G.layer=i;let a=r.screenOffset[0];return G.renderingInfo=new b(null,t,r.translation,r.centerOffset,r.groundDistance,a,r.centerOffsetUnits,r.elevationOffset),n.createGraphics3DGraphic(G,this._calloutMaterials)}_ensureGraphics3DResources(e){if(e.hasGraphics3DResources)return!1;let t=e.graphics3DGraphic;if(t.destroyed)return!1;this._ensureTextTextureResources(e);let n=e.labelingContext,r=n.labelClassContexts;if(H(r)||!n.emptySymbolLabelSupported&&t.layers.length===0)return!1;let i=!1,a=t.graphic,o=n.layer,s=W(n.layer);for(let c=0;c<r.length;c++){let l=e.textRenderers[c],u=e.textLabelPlacements[c],d=r[c];if(l==null||u==null||d==null)continue;let f=d.graphics3DSymbol,p=U(f),m=f.symbolLayers[0];if(!m)continue;m.setElevationInfoOverride(n.elevationInfoOverride);let h=new S(t,p,d.labelClass),g=this._createTextSymbolGraphic(l,a,u,o,m,h);if(g==null)return!1;g.labelClass=d.labelClass,g.labelClassContextIndex=c,t.addLabelGraphic(g,n.stageLayer),this.deconflictor.setPriority(t,d.textRenderParameters?.definition.size??0),t.setVisibilityFlag(16,1,s),t.setVisibilityFlag(16,2,d.scaleVisibility??!0),t.setVisibilityFlag(16,8,!1),M()&&d.graphics.set(a.uid,t),i=!0;let _=d.graphics3DCalloutSymbolLayer;if(_&&u.hasLabelVerticalOffset){_.setElevationInfoOverride(n.elevationInfoOverride);let e=this._createLineCalloutGraphic(a,p,_,u,o);e!=null&&(d.calloutSymbolLayerIndex=t.labelLayers.length,t.addLabelGraphic(e,n.stageLayer))}break}return i&&n.scaleVisibility?.updateGraphicLabelScaleVisibility(t),e.hasGraphics3DResources=!0,!0}_destroyGraphics3DResources(e){let t=e.labelingContext.labelClassContexts;for(let n of e.graphics3DGraphic.labelLayers)n.labelClass!=null&&t[n.labelClassContextIndex].graphics3DSymbol.symbolLayers[0]?.onRemoveGraphic(n);e.graphics3DGraphic.clearLabelGraphics(),e.hasGraphics3DResources=!1}_ensureTextTextureResources(e){if(e.textInitialized)return;let t=e.labelingContext,n=t.labelClassContexts;if(H(n))return;let r=e.graphics3DGraphic.graphic;for(let i=0;i<n.length;i++){let a=n[i];if(e.textRenderers[i]=null,e.textLabelPlacements[i]=null,a?.textRenderParameters==null)continue;let o=a.labelFunction,s;if(o.type===`arcade`)try{let e=o.needsHydrationToEvaluate()?h(r,t.layer,null):r;s=o.evaluate(e,this.view.timeZone)}catch{s=null}else s=o.evaluate(r);if(s==null||s===``||/^\s+$/.test(s))continue;let c=a.graphics3DSymbol;if(!c.symbolLayers[0])continue;let l=e.graphics3DGraphic,u=c.symbol?.type===`label-3d`?c.symbol:null,d=a.labelClass,f=t.disablePlacement,p=new S(l,u,d,f).placement;if(p==null)continue;let m=w(p.anchor),g=E(m);e.textRenderers[i]=new O(s,g,a.textRenderParameters,A.maxSize),e.textLabelPlacements[i]=p}e.textInitialized=!0}_destroyTextTextureResources(e){e.textInitialized=!1,e.textRenderers.length=0,e.textLabelPlacements.length=0}_addGraphic(e,t){let n=t.graphic.uid;if(e.graphics.set(n,t),e.active){let r=new F(e,t);this._labels.set(n,r),e.labelsToInitialize.set(n,r)}this.setDirty(),this.deconflictor.setDirty()}_updateGraphicGeometry(e,t){let n=t.graphic.uid,r=this._labels.get(n);if(!r)return!0;for(let n of r.graphics3DGraphic.labelLayers)if(n.labelClass!=null&&!e.labelClassContexts[n.labelClassContextIndex].graphics3DSymbol.symbolLayers[0].updateGeometry(t.graphic,n))return!1;return this.setDirty(),this.deconflictor.setDirty(),!0}_removeGraphic(e,t){let n=t.graphic.uid,r=this._labels.get(n);e.graphics.delete(n),e.labelClassContexts.forEach(e=>e?.graphics.delete(n)),r&&(this._destroyGraphic(r,n),e.labelsToInitialize.delete(n),this.setDirty(),this.deconflictor.setDirty())}_destroyGraphic(e,t){this._labels.delete(t),e.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(e),this._destroyTextTextureResources(e),e.hasGraphics3DResources&&this._destroyGraphics3DResources(e)}async _labelingInfoChange(e,t){if(t)for(let n of t){let t=e.graphics.get(n);t&&(this._removeGraphic(e,t),this._addGraphic(e,t))}else return this._visibilityInfoChange(e),this._resetLabels(e),this._createLabelClassContext(e)}_globalPropertyChanged(e,t){for(let n of t.labelClassContexts){if(!n)continue;let r=new Map;t.graphics.forEach(e=>r.set(e.graphic.uid,e)),n.graphics3DSymbol.symbolLayers[0].globalPropertyChanged(e,r,e=>e.labelLayers[0]),n.graphics3DCalloutSymbolLayer&&n.graphics3DCalloutSymbolLayer.globalPropertyChanged(e,r,e=>e.labelLayers[n.calloutSymbolLayerIndex])}}_visibilityInfoChange(e){let t=W(e.layer);t&&!e.active&&this._activateLabelingContext(e),!t&&e.active&&this._deactivateLabelingContext(e),this.setDirty()}_resetAllLabels(){for(let e of this._labelingContexts)this._resetLabels(e)}_resetArcadeLabels(){for(let e of this._labelingContexts)e.labelClassContexts.some(e=>e?.labelFunction.type===`arcade`)&&this._resetLabels(e)}_resetLabels(e){e.graphics.forEach((t,n)=>{let r=this._labels.get(n);r&&(this._destroyGraphic(r,n),r.visible=!1,e.labelsToInitialize.set(n,r))}),this._destroyLabelClassContext(e),this.setDirty(),this.deconflictor.setDirty()}_findLabelingContext(e){for(let t of this._labelingContexts)if(t.graphics3DCore===e)return t;return null}addGraphicsOwner(e,t,n){let r=n?.emptySymbolLabelSupported||!1,i=n?.elevationInfoOverride||null,a=n?.disablePlacement||null;if(this._findLabelingContext(e))return;let o=e.layer,s=new L(this.view.stage,o,e,t,r,i,a,W(o));return this._labelingContexts.push(s),this.setDirty(),{addGraphic:e=>this._addGraphic(s,e),removeGraphic:e=>this._removeGraphic(s,e),updateGraphicGeometry:e=>this._updateGraphicGeometry(s,e),layerLabelsEnabled:()=>W(s.layer),labelingInfoChange:e=>this._labelingInfoChange(s,e),elevationInfoChange:()=>this._globalPropertyChanged(`elevationInfo`,s),screenSizePerspectiveEnabledChanged:()=>this._globalPropertyChanged(`screenSizePerspectiveEnabled`,s),slicePlaneEnabledChange:()=>this._globalPropertyChanged(`slicePlaneEnabled`,s),visibilityInfoChange:()=>this._visibilityInfoChange(s),reset:()=>this._resetLabels(s),remove:()=>this._removeGraphicsOwner(e),setDirty:()=>this.setDirty()}}_removeGraphicsOwner(e){let t=this._findLabelingContext(e);if(!t)return;let n=this._labelingContexts.indexOf(t);this._labelingContexts.splice(n,1),t.graphics.forEach(e=>this._removeGraphic(t,e)),t.destroy(),this.setDirty()}_updateScaleVisibility(){for(let e of this._labelingContexts)if(e.active&&!V(e))for(let t of e.labelClassContexts)this._updateLabelClassContextVisibility(t)}_updateLabelClassContextVisibility(e){if(!e||!M())return;let{labelClass:t,graphics:n}=e,r={minScale:t.minScale,maxScale:t.maxScale},i=m(r,this.view.scale),a=e.scaleVisibility==null||e.scaleVisibility!==i;e.scaleVisibility=i,a&&n.size&&(n.forEach(e=>e.setVisibilityFlag(16,2,i)),this.deconflictor.setDirty(),this.setDirty())}setLabelGraphicVisibility(e,t){let n=e.graphic.uid,r=this._labels.get(n);r&&r.visible!==t&&(t&&!r.textureAtlasHandles.length?(this._addLabelTextureToAtlas(r),r.textInitialized||r.labelingContext.labelsToInitialize.set(n,r)):!t&&r.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(r),r.visible=t,this.setDirty())}setDirty(){!this._dirty&&this._labelingContexts.length>0&&(this._dirty=!0,this.notifyChange(`updating`))}get updating(){return this._dirty||this._textTextureAtlas?.updating||this.deconflictor.updating||this._labelingContexts.some(e=>V(e))||this._focusAreasLabelsQueue.length>0}get updatingProgress(){if(!this.updating||!this._textTextureAtlas)return 1;let e=this._labelingContexts.length>0?this._labelingContexts.reduce((e,t)=>e+ +!V(t),0)/this._labelingContexts.length:1;return(this._dirty?0:.3)+(this._textTextureAtlas.updating?0:.1)+e*.1+this.deconflictor.updatingProgress*.5}get usedMemory(){return this._textTextureAtlas?.usedMemory??0}get test(){}};e([d({constructOnly:!0})],R.prototype,`view`,void 0),e([d({constructOnly:!0})],R.prototype,`deconflictor`,void 0),e([d()],R.prototype,`_textTextureAtlas`,void 0),e([d({type:Boolean,readOnly:!0})],R.prototype,`updating`,null),R=e([f(`esri.views.3d.layers.graphics.Labeler`)],R);function z(e,t){e.geometries[0].setAttributeData(`size`,[t.displayWidth,t.displayHeight]),e.geometryVertexAttributeUpdated(e.geometries[0],`size`)}function B(e,t){e.geometries[0].setAttributeData(`uvi`,t),e.geometryVertexAttributeUpdated(e.geometries[0],`uvi`,!0)}function V(e){return!!e.labelClassPromise&&!!e.labelClassAbortController}function H(e){return(e?.length??0)===0}function U(e){return e.symbol?.type===`label-3d`?e.symbol:null}function W(e){return!!e.labelsVisible&&!!e.labelingInfo?.some(e=>!!e.symbol)}const G=new y(null,null,null);export{R as Labeler,W as areLabelsVisible};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{forEach as n,result as r}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import i from"../../../../core/Logger.js";import{disposeMaybe as a,abortMaybe as o}from"../../../../core/maybe.js";import{throwIfAborted as s,isAbortError as c}from"../../../../core/promiseUtils.js";import l from"../../../../core/Queue.js";import{watch as u}from"../../../../core/reactiveUtils.js";import{property as d,subclass as f}from"../../../../core/accessorSupport/decorators.js";import{fromValues as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{isInEffectiveScaleRange as m}from"../../../../geometry/support/scaleUtils.js";import{BufferViewVec4i16 as h,BufferViewVec2f as g}from"../../../../geometry/support/buffer/BufferView.js";import{hydrateGraphic as _}from"../../../../layers/graphics/hydratedFeatures.js";import{createLabelFunction as v}from"../../../../layers/support/labelFormatUtils.js";import{hasCalloutSupport as y}from"../../../../symbols/callouts/calloutUtils.js";import{make as b}from"./Graphics3DCalloutSymbolLayerFactory.js";import{LineCalloutCreationContext as x,LineCalloutSymbolLayerRenderingInfo as S}from"./Graphics3DLineCalloutSymbolLayer.js";import{getGraphics3DSymbol as C}from"./graphicSymbolUtils.js";import{LabelInfo as w}from"./LabelInfo.js";import{LabelParameters as T}from"./LabelParameters.js";import{horizontalPlacementFromAnchor as E,verticalPlacementFromAnchor as D,textRenderAlignmentFromHorizontalPlacement as O}from"./placementUtils.js";import{placePointOnGeometry as k}from"./pointUtils.js";import{TextRenderer as A}from"../../webgl-engine/lib/TextRenderer.js";import{TextRenderParameters as j}from"../../webgl-engine/lib/TextRenderParameters.js";import{TextTextureAtlas as M}from"../../webgl-engine/lib/TextTextureAtlas.js";import{WebGLLayer as N}from"../../webgl-engine/lib/WebGLLayer.js";import{hasLayerBasedScaleVisibility as P}from"../../../support/layerViewUtils.js";import{TaskPriority as F}from"../../../support/Scheduler.js";import{Yield as I}from"../../../support/Yield.js";class L{constructor(e,t){this.labelingContext=e,this.graphics3DGraphic=t,this.hasGraphics3DResources=!1,this.visible=!1,this.textureAtlasHandles=[],this.textInitialized=!1,this.textRenderers=[],this.textLabelPlacements=[]}}class R{constructor(e,t,n,r,i){this.labelClass=e,this.graphics3DSymbol=t,this.graphics3DCalloutSymbolLayer=n,this.textRenderParameters=r,this.labelFunction=i,this.calloutSymbolLayerIndex=0,this.graphics=new Map,this.scaleVisibility=null}}class z{constructor(e,t,n,r,i,a,o,s){this.layer=t,this.graphics3DCore=n,this.scaleVisibility=r,this.emptySymbolLabelSupported=i,this.elevationInfoOverride=a,this.disablePlacement=o,this.active=s,this.labelClassAbortController=new AbortController,this._labelClassContexts=[],this.graphics=new Map,this.labelsToInitialize=new Map,this.stageLayer=new N(e,{pickable:!0},n.owner.layerViewUid)}destroy(){this.stageLayer.destroy()}get labelClassContexts(){return this._labelClassContexts}setLabelClassContext(e,t){this._labelClassContexts[e]=t}resetLabelClassContext(){this._labelClassContexts.length=0}}let B=class extends t{constructor(e){super(e),this._hudMaterials=new Map,this._calloutMaterials=new Map,this._dirty=!1,this._focusAreasLabelsQueue=new l,this._labels=new Map,this._labelingContexts=[]}setup(){this.dispose(),this.addHandles([u(()=>this.view.state?.camera,()=>this.setDirty()),u(()=>this.view.state?.rasterPixelRatio,()=>this._resetAllLabels()),u(()=>this.view.timeZone,()=>this._resetArcadeLabels()),u(()=>this.view.focusAreasView?.polygons,()=>this._updateFocus()),this.view.resourceController.scheduler.registerTask(F.LABELER,this)]),P()&&this.addHandles(u(()=>this.view.scale,()=>this._updateScaleVisibility())),this._textTextureAtlas=new M({view:this.view})}dispose(){this.removeAllHandles(),this._textTextureAtlas=a(this._textTextureAtlas),this._hudMaterials.clear(),this._calloutMaterials.clear(),this._labelingContexts.length=0,this._labels.clear()}destroy(){this.dispose(),q.graphic=null,q.renderingInfo=null,q.layer=null}_updateFocus(){this._focusAreasLabelsQueue.clear(),this._labelingContexts.forEach(e=>{e.graphics.forEach(t=>{this._focusAreasLabelsQueue.push({graphic3DGraphic:t,labelingContext:e})})})}_activateLabelingContext(e){e.graphics.forEach((t,n)=>{let r=new L(e,t);this._labels.set(n,r),e.labelsToInitialize.set(n,r),t.setVisibilityFlag(16,1,!0)}),e.active=!0}_deactivateLabelingContext(e){e.graphics.forEach((e,t)=>{e.setVisibilityFlag(16,1,!1),this.setLabelGraphicVisibility(e,!1),e.clearLabelGraphics(),this._labels.delete(t)}),e.active=!1}_addLabelTextureToAtlas(e){if(this._textTextureAtlas)for(let t of e.graphics3DGraphic.labelLayers){if(!t.labelClass||t.type!==`buffer`)continue;let n=e.textRenderers[t.labelClassContextIndex];n&&(e.textureAtlasHandles.push(this._textTextureAtlas.addText(n,e=>H(t.stageObject,e))),V(t.stageObject,n))}}_removeLabelTextureFromAtlas(e){e.textureAtlasHandles.forEach(e=>e.remove()),e.textureAtlasHandles.length=0}get readyToRun(){return this.view.ready&&(this._dirty||this.deconflictor.readyToRun||this._focusAreasLabelsQueue.length>0)}runTask(e){return this._updateLabels(e),this._applyFocusAreasUpdates(e),!this._dirty&&this.deconflictor.readyToRun&&this.deconflictor.runTask(e),I}_updateLabels(e){if(this._dirty){this._dirty=!1;for(let t of this._labelingContexts)if(t.active){if(U(t))this._dirty=!0;else if(W(t.labelClassContexts)){if(t.labelClassContexts===null){this._deactivateLabelingContext(t);continue}this._createLabelClassContext(t),this._dirty=!0}else for(let[n,r]of t.labelsToInitialize)if(this._ensureGraphics3DResources(r)&&(this._labels.set(n,r),this.deconflictor.setDirty(),e.madeProgress()),(r.visible&&r.textInitialized||!r.visible&&r.hasGraphics3DResources)&&(t.labelsToInitialize.delete(n),e.madeProgress()),e.done){this._dirty=!0;break}}this._dirty||this.notifyChange(`updating`)}}_applyFocusAreasUpdates(e){for(;this._focusAreasLabelsQueue.length>0&&!e.done;){e.madeProgress();let{graphic3DGraphic:t,labelingContext:n}=this._focusAreasLabelsQueue.pop();if(t.labelLayers.length===0||!n.active)continue;let r=k(t.graphic.geometry);if(r==null)continue;let i=this.view.focusAreasView?.containsGeometry(r)??!0;t.labelLayers.forEach(e=>{e.stageObject.geometries.some(e=>e.material.parameters.focusAreaStyle==null!==i)&&(this._removeGraphic(n,t),this._addGraphic(n,t),this.setDirty())})}this._focusAreasLabelsQueue.length===0&&(this.notifyChange(`readyToRun`),this.notifyChange(`updating`))}async _createLabelClassContextAsync(e){let t=e.labelClassAbortController?.signal;e.layer.when&&await e.layer.when(),s(t),e.scaleVisibility?.updateScaleRangeActive();let a=e.graphics3DCore,o=a.layer.labelingInfo?.filter(e=>!!e.symbol);o&&o.length!==0&&(await n(o,async(n,o)=>{let c=n.symbol,l=C(a.getOrCreateGraphics3DSymbol(c));if(l==null){i.getLogger(this).error(`Failed to create Graphics3DSymbol for label`);return}await l.load(),s(t);let u=null;y(c)&&c.hasVisibleCallout()&&(u=b(c,a.symbolCreationContext),await u.load(),s(t));let d=await r(v(n,e.layer.fieldsIndex,this.view.spatialReference));if(s(t),d.ok===!0){let r=await this._createTextRenderParameters(l.symbol);s(t);let i=new R(n,l,u,r,d.value);this._updateLabelClassContextVisibility(i),e.setLabelClassContext(o,i)}else i.getLogger(this).error(`Label expression failed to evaluate: ${d.error}`)}),s(t))}async _createLabelClassContext(e){return e.labelClassPromise??(e.labelClassPromise=this._createLabelClassContextAsync(e).catch(t=>{if(c(t))throw t;e.resetLabelClassContext()}).then(()=>{e.labelClassAbortController=null,this.notifyChange(`updating`)}).catch(()=>{}),this.notifyChange(`updating`)),e.labelClassPromise}async _createTextRenderParameters(e){let t=e.symbolLayers.at(0);return t?.type===`text`?j.fromSymbol(t,this.view.state.rasterPixelRatio):null}_destroyLabelClassContext(e){for(let t of e.labelClassContexts)t&&--t.graphics3DSymbol.referenced;let t=e.labelClassAbortController;e.labelClassAbortController=new AbortController,o(t),e.resetLabelClassContext(),e.labelClassPromise=null,this.notifyChange(`updating`)}_createTextSymbolGraphic(e,t,n,r,i,a){if(!this._textTextureAtlas)return null;let o=new T(n,E(n.anchor),D(n.anchor),e.text,p(e.displayWidth,e.displayHeight));return q.graphic=t,q.layer=r,q.renderingInfo=null,i.createLabel(q,o,this._hudMaterials,this._textTextureAtlas,()=>a.placement?.elevationOffset??null)}_createLineCalloutGraphic(e,t,n,r,i){q.graphic=e,q.layer=i;let a=r.screenOffset[0];return q.renderingInfo=new S(null,t,r.translation,r.centerOffset,r.groundDistance,a,r.centerOffsetUnits,r.elevationOffset),n.createGraphics3DGraphic(q,this._calloutMaterials)}_ensureGraphics3DResources(e){if(e.hasGraphics3DResources)return!1;let t=e.graphics3DGraphic;if(t.destroyed)return!1;this._ensureTextTextureResources(e);let n=e.labelingContext,r=n.labelClassContexts;if(W(r)||!n.emptySymbolLabelSupported&&t.layers.length===0)return!1;let i=!1,a=t.graphic,o=n.layer,s=K(n.layer);for(let c=0;c<r.length;c++){let l=e.textRenderers[c],u=e.textLabelPlacements[c],d=r[c];if(l==null||u==null||d==null)continue;let f=d.graphics3DSymbol,p=G(f),m=f.symbolLayers[0];if(!m)continue;m.setElevationInfoOverride(n.elevationInfoOverride);let h=new w(t,p,d.labelClass),g=this._createTextSymbolGraphic(l,a,u,o,m,h);if(g==null)return!1;g.labelClass=d.labelClass,g.labelClassContextIndex=c,t.addLabelGraphic(g,n.stageLayer),this.deconflictor.setPriority(t,d.textRenderParameters?.definition.size??0),t.setVisibilityFlag(16,1,s),t.setVisibilityFlag(16,2,d.scaleVisibility??!0),t.setVisibilityFlag(16,8,!1),P()&&d.graphics.set(a.uid,t),i=!0;let _=d.graphics3DCalloutSymbolLayer;if(_&&u.hasLabelVerticalOffset){_.setElevationInfoOverride(n.elevationInfoOverride);let e=this._createLineCalloutGraphic(a,p,_,u,o);e!=null&&(d.calloutSymbolLayerIndex=t.labelLayers.length,t.addLabelGraphic(e,n.stageLayer))}break}return i&&n.scaleVisibility?.updateGraphicLabelScaleVisibility(t),e.hasGraphics3DResources=!0,!0}_destroyGraphics3DResources(e){let t=e.labelingContext.labelClassContexts;for(let n of e.graphics3DGraphic.labelLayers)n.labelClass!=null&&t[n.labelClassContextIndex].graphics3DSymbol.symbolLayers[0]?.onRemoveGraphic(n);e.graphics3DGraphic.clearLabelGraphics(),e.hasGraphics3DResources=!1}_ensureTextTextureResources(e){if(e.textInitialized)return;let t=e.labelingContext,n=t.labelClassContexts;if(W(n))return;let r=e.graphics3DGraphic.graphic;for(let i=0;i<n.length;i++){let a=n[i];if(e.textRenderers[i]=null,e.textLabelPlacements[i]=null,a?.textRenderParameters==null)continue;let o=a.labelFunction,s;if(o.type===`arcade`)try{let e=o.needsHydrationToEvaluate()?_(r,t.layer,null):r;s=o.evaluate(e,this.view.timeZone)}catch{s=null}else s=o.evaluate(r);if(s==null||s===``||/^\s+$/.test(s))continue;let c=a.graphics3DSymbol;if(!c.symbolLayers[0])continue;let l=e.graphics3DGraphic,u=c.symbol?.type===`label-3d`?c.symbol:null,d=a.labelClass,f=t.disablePlacement,p=new w(l,u,d,f).placement;if(p==null)continue;let m=E(p.anchor),h=O(m);e.textRenderers[i]=new A(s,h,a.textRenderParameters,M.maxSize),e.textLabelPlacements[i]=p}e.textInitialized=!0}_destroyTextTextureResources(e){e.textInitialized=!1,e.textRenderers.length=0,e.textLabelPlacements.length=0}_addGraphic(e,t){let n=t.graphic.uid;if(e.graphics.set(n,t),e.active){let r=new L(e,t);this._labels.set(n,r),e.labelsToInitialize.set(n,r)}this.setDirty(),this.deconflictor.setDirty()}_updateGraphicGeometry(e,t){let n=t.graphic.uid,r=this._labels.get(n);if(!r)return!0;for(let n of r.graphics3DGraphic.labelLayers){if(n.labelClass==null)continue;let i=e.labelClassContexts[n.labelClassContextIndex].graphics3DSymbol.symbolLayers[0],a=r.textLabelPlacements[n.labelClassContextIndex];if(n.type!==`buffer`||!i.updateGeometry(t.graphic,n,a))return!1}return this.setDirty(),this.deconflictor.setDirty(),!0}_removeGraphic(e,t){let n=t.graphic.uid,r=this._labels.get(n);e.graphics.delete(n),e.labelClassContexts.forEach(e=>e?.graphics.delete(n)),r&&(this._destroyGraphic(r,n),e.labelsToInitialize.delete(n),this.setDirty(),this.deconflictor.setDirty())}_destroyGraphic(e,t){this._labels.delete(t),e.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(e),this._destroyTextTextureResources(e),e.hasGraphics3DResources&&this._destroyGraphics3DResources(e)}async _labelingInfoChange(e,t){if(t)for(let n of t){let t=e.graphics.get(n);t&&(this._removeGraphic(e,t),this._addGraphic(e,t))}else return this._visibilityInfoChange(e),this._resetLabels(e),this._createLabelClassContext(e)}_globalPropertyChanged(e,t){for(let n of t.labelClassContexts){if(!n)continue;let r=new Map;t.graphics.forEach(e=>r.set(e.graphic.uid,e)),n.graphics3DSymbol.symbolLayers[0].globalPropertyChanged(e,r,e=>e.labelLayers[0]),n.graphics3DCalloutSymbolLayer&&n.graphics3DCalloutSymbolLayer.globalPropertyChanged(e,r,e=>e.labelLayers[n.calloutSymbolLayerIndex])}}_visibilityInfoChange(e){let t=K(e.layer);t&&!e.active&&this._activateLabelingContext(e),!t&&e.active&&this._deactivateLabelingContext(e),this.setDirty()}_resetAllLabels(){for(let e of this._labelingContexts)this._resetLabels(e)}_resetArcadeLabels(){for(let e of this._labelingContexts)e.labelClassContexts.some(e=>e?.labelFunction.type===`arcade`)&&this._resetLabels(e)}_resetLabels(e){e.graphics.forEach((t,n)=>{let r=this._labels.get(n);r&&(this._destroyGraphic(r,n),r.visible=!1,e.labelsToInitialize.set(n,r))}),this._destroyLabelClassContext(e),this.setDirty(),this.deconflictor.setDirty()}_findLabelingContext(e){for(let t of this._labelingContexts)if(t.graphics3DCore===e)return t;return null}addGraphicsOwner(e,t,n){let r=n?.emptySymbolLabelSupported||!1,i=n?.elevationInfoOverride||null,a=n?.disablePlacement||null;if(this._findLabelingContext(e))return;let o=e.layer,s=new z(this.view.stage,o,e,t,r,i,a,K(o));return this._labelingContexts.push(s),this.setDirty(),{addGraphic:e=>this._addGraphic(s,e),removeGraphic:e=>this._removeGraphic(s,e),updateGraphicGeometry:e=>this._updateGraphicGeometry(s,e),layerLabelsEnabled:()=>K(s.layer),labelingInfoChange:e=>this._labelingInfoChange(s,e),elevationInfoChange:()=>this._globalPropertyChanged(`elevationInfo`,s),screenSizePerspectiveEnabledChanged:()=>this._globalPropertyChanged(`screenSizePerspectiveEnabled`,s),slicePlaneEnabledChange:()=>this._globalPropertyChanged(`slicePlaneEnabled`,s),visibilityInfoChange:()=>this._visibilityInfoChange(s),reset:()=>this._resetLabels(s),remove:()=>this._removeGraphicsOwner(e),setDirty:()=>this.setDirty()}}_removeGraphicsOwner(e){let t=this._findLabelingContext(e);if(!t)return;let n=this._labelingContexts.indexOf(t);this._labelingContexts.splice(n,1),t.graphics.forEach(e=>this._removeGraphic(t,e)),t.destroy(),this.setDirty()}_updateScaleVisibility(){for(let e of this._labelingContexts)if(e.active&&!U(e))for(let t of e.labelClassContexts)this._updateLabelClassContextVisibility(t)}_updateLabelClassContextVisibility(e){if(!e||!P())return;let{labelClass:t,graphics:n}=e,r={minScale:t.minScale,maxScale:t.maxScale},i=m(r,this.view.scale),a=e.scaleVisibility==null||e.scaleVisibility!==i;e.scaleVisibility=i,a&&n.size&&(n.forEach(e=>e.setVisibilityFlag(16,2,i)),this.deconflictor.setDirty(),this.setDirty())}setLabelGraphicVisibility(e,t){let n=e.graphic.uid,r=this._labels.get(n);r&&r.visible!==t&&(t&&!r.textureAtlasHandles.length?(this._addLabelTextureToAtlas(r),r.textInitialized||r.labelingContext.labelsToInitialize.set(n,r)):!t&&r.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(r),r.visible=t,this.setDirty())}setDirty(){!this._dirty&&this._labelingContexts.length>0&&(this._dirty=!0,this.notifyChange(`updating`))}get updating(){return this._dirty||this._textTextureAtlas?.updating||this.deconflictor.updating||this._labelingContexts.some(e=>U(e))||this._focusAreasLabelsQueue.length>0}get updatingProgress(){if(!this.updating||!this._textTextureAtlas)return 1;let e=this._labelingContexts.length>0?this._labelingContexts.reduce((e,t)=>e+ +!U(t),0)/this._labelingContexts.length:1;return(this._dirty?0:.3)+(this._textTextureAtlas.updating?0:.1)+e*.1+this.deconflictor.updatingProgress*.5}get usedMemory(){return this._textTextureAtlas?.usedMemory??0}get test(){}};e([d({constructOnly:!0})],B.prototype,`view`,void 0),e([d({constructOnly:!0})],B.prototype,`deconflictor`,void 0),e([d()],B.prototype,`_textTextureAtlas`,void 0),e([d({type:Boolean,readOnly:!0})],B.prototype,`updating`,null),B=e([f(`esri.views.3d.layers.graphics.Labeler`)],B);function V(e,t){let{displayWidth:n,displayHeight:r}=t,i=e.geometries[0];i.getMutableVertexField(`size`,g).setValues(0,n,r),e.geometryVertexAttributeUpdated(i,`size`)}function H(e,t){let n=e.geometries[0];n.getMutableVertexField(`uvi`,h).setVec(0,t),e.geometryVertexAttributeUpdated(n,`uvi`,!0)}function U(e){return!!e.labelClassPromise&&!!e.labelClassAbortController}function W(e){return(e?.length??0)===0}function G(e){return e.symbol?.type===`label-3d`?e.symbol:null}function K(e){return!!e.labelsVisible&&!!e.labelingInfo?.some(e=>!!e.symbol)}const q=new x(null,null,null);export{B as Labeler,K as areLabelsVisible};
@@ -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.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.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};