@arcgis/core 5.0.0-next.57 → 5.0.0-next.59

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 (351) hide show
  1. package/Graphic.d.ts +2 -2
  2. package/Viewpoint.d.ts +1 -1
  3. package/applications/Components/arcadeFeatureUtils.d.ts +20 -1
  4. package/applications/Components/arcadeFeatureUtils.js +1 -1
  5. package/applications/Urban/meshUtils.d.ts +2 -2
  6. package/arcade.d.ts +1 -1
  7. package/arcade.js +1 -1
  8. package/assets/esri/core/workers/RemoteClient.js +1 -1
  9. package/assets/esri/core/workers/chunks/0bd73a66baea2f52e8a6.js +1 -0
  10. package/assets/esri/core/workers/chunks/18ce7b1559a45d017c45.js +1 -0
  11. package/assets/esri/core/workers/chunks/262c5794650853457acc.js +1 -0
  12. package/assets/esri/core/workers/chunks/3405a23973f9e701a4d6.js +1 -0
  13. package/assets/esri/core/workers/chunks/352c674730c7b7258ae3.js +1 -0
  14. package/assets/esri/core/workers/chunks/55a9ea536c64976c3409.js +1 -0
  15. package/assets/esri/core/workers/chunks/62752cd6821959cf6751.js +1 -0
  16. package/assets/esri/core/workers/chunks/72e3a48aa365542b0689.js +1 -0
  17. package/assets/esri/core/workers/chunks/{5f9e64f00329cb646f0c.js → 741d170187e58e81584d.js} +1 -1
  18. package/assets/esri/core/workers/chunks/a6b1e3ec30f6d641aea9.js +1 -0
  19. package/assets/esri/core/workers/chunks/{da2c41ac0f82f32013c1.js → a7aa87e2c4197ba595ef.js} +10 -10
  20. package/assets/esri/core/workers/chunks/{d76513a6260d9ec4ea25.js → bf82bb1cdd8b31e7f2aa.js} +1 -1
  21. package/assets/esri/layers/raster/formats/lerc-wasm.wasm +0 -0
  22. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  23. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  24. package/assets/esri/themes/base/widgets/_Attribution.scss +2 -2
  25. package/assets/esri/themes/base/widgets/_FeatureTable.scss +24 -0
  26. package/assets/esri/themes/dark/main.css +1 -1
  27. package/assets/esri/themes/light/main.css +1 -1
  28. package/assets/esri/themes/light/view.css +1 -1
  29. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable.json +1 -1
  30. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ar.json +1 -1
  31. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_bg.json +1 -1
  32. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_bs.json +1 -1
  33. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ca.json +1 -1
  34. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_cs.json +1 -1
  35. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_da.json +1 -1
  36. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_de.json +1 -1
  37. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_el.json +1 -1
  38. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_en.json +1 -1
  39. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_es.json +1 -1
  40. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_et.json +1 -1
  41. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_fi.json +1 -1
  42. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_fr.json +1 -1
  43. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_he.json +1 -1
  44. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_hr.json +1 -1
  45. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_hu.json +1 -1
  46. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_id.json +1 -1
  47. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_it.json +1 -1
  48. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ja.json +1 -1
  49. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ko.json +1 -1
  50. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_lt.json +1 -1
  51. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_lv.json +1 -1
  52. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_nl.json +1 -1
  53. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_no.json +1 -1
  54. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pl.json +1 -1
  55. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pt-BR.json +1 -1
  56. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pt-PT.json +1 -1
  57. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ro.json +1 -1
  58. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ru.json +1 -1
  59. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sk.json +1 -1
  60. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sl.json +1 -1
  61. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sr.json +1 -1
  62. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sv.json +1 -1
  63. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_th.json +1 -1
  64. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_tr.json +1 -1
  65. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_uk.json +1 -1
  66. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_vi.json +1 -1
  67. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-CN.json +1 -1
  68. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-HK.json +1 -1
  69. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-TW.json +1 -1
  70. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_fr.json +1 -1
  71. package/chunks/lerc-wasm.js +1 -1
  72. package/config.js +1 -1
  73. package/core/workers/workerFactory.js +1 -1
  74. package/editing/sharedTemplates/executor/builders/offsetLine.js +1 -1
  75. package/editing/sharedTemplates/executor/builders/offsetPrimaryLine.js +1 -1
  76. package/editing/sharedTemplates/executor/builders/polygonBoundary.js +1 -1
  77. package/editing/sharedTemplates/executor/builders/polygonBoundaryTwoPoint.js +1 -1
  78. package/editing/sharedTemplates/executor/builders/polygonVertices.js +1 -1
  79. package/editing/sharedTemplates/executor/builders/support/builderUtils.js +1 -1
  80. package/editing/sharedTemplates/executor/builders/support/shapeUtils.js +1 -1
  81. package/editing/sharedTemplates/executor/support/createFeatureServiceEdit.js +1 -1
  82. package/editing/sharedTemplates/executor/support/createPresetServiceEdit.js +1 -1
  83. package/geometry/Extent.d.ts +1 -1
  84. package/geometry/Mesh.d.ts +2 -2
  85. package/geometry/SpatialReference.js +1 -1
  86. package/geometry/geometryEngine.d.ts +3 -3
  87. package/geometry/{geometryEngineInterfaces.d.ts → geometryEngineTypes.d.ts} +1 -1
  88. package/geometry/operators/affineTransformOperator.d.ts +3 -3
  89. package/geometry/operators/alphaShapeOperator.d.ts +1 -1
  90. package/geometry/operators/areaOperator.d.ts +1 -1
  91. package/geometry/operators/boundaryOperator.d.ts +3 -3
  92. package/geometry/operators/bufferOperator.d.ts +1 -1
  93. package/geometry/operators/centroidOperator.d.ts +1 -1
  94. package/geometry/operators/clipOperator.d.ts +3 -3
  95. package/geometry/operators/containsOperator.d.ts +1 -1
  96. package/geometry/operators/convexHullOperator.d.ts +3 -3
  97. package/geometry/operators/crossesOperator.d.ts +1 -1
  98. package/geometry/operators/cutOperator.d.ts +2 -2
  99. package/geometry/operators/densifyOperator.d.ts +3 -3
  100. package/geometry/operators/differenceOperator.d.ts +3 -3
  101. package/geometry/operators/disjointOperator.d.ts +1 -1
  102. package/geometry/operators/distanceOperator.d.ts +1 -1
  103. package/geometry/operators/equalsOperator.d.ts +1 -1
  104. package/geometry/operators/generalizeOperator.d.ts +3 -3
  105. package/geometry/operators/geodesicBufferOperator.d.ts +1 -2
  106. package/geometry/operators/geodesicProximityOperator.d.ts +2 -5
  107. package/geometry/operators/geodeticAreaOperator.d.ts +1 -2
  108. package/geometry/operators/geodeticDensifyOperator.d.ts +3 -4
  109. package/geometry/operators/geodeticDistanceOperator.d.ts +1 -2
  110. package/geometry/operators/geodeticLengthOperator.d.ts +1 -2
  111. package/geometry/operators/geodeticUtilsOperator.d.ts +1 -1
  112. package/geometry/operators/graphicBufferOperator.d.ts +1 -1
  113. package/geometry/operators/integrateOperator.d.ts +2 -2
  114. package/geometry/operators/intersectionOperator.d.ts +3 -3
  115. package/geometry/operators/intersectsOperator.d.ts +1 -1
  116. package/geometry/operators/isNearOperator.d.ts +1 -1
  117. package/geometry/operators/labelPointOperator.d.ts +1 -1
  118. package/geometry/operators/lengthOperator.d.ts +1 -1
  119. package/geometry/operators/linesToPolygonsOperator.d.ts +1 -1
  120. package/geometry/operators/locateBetweenOperator.d.ts +2 -2
  121. package/geometry/operators/minimumBoundingCircleOperator.d.ts +1 -1
  122. package/geometry/operators/multiPartToSinglePartOperator.d.ts +2 -2
  123. package/geometry/operators/offsetOperator.d.ts +3 -3
  124. package/geometry/operators/overlapsOperator.d.ts +1 -1
  125. package/geometry/operators/projectOperator.d.ts +4 -6
  126. package/geometry/operators/proximityOperator.d.ts +2 -2
  127. package/geometry/operators/relateOperator.d.ts +1 -1
  128. package/geometry/operators/shapePreservingProjectOperator.d.ts +3 -3
  129. package/geometry/operators/simplifyOGCOperator.d.ts +3 -3
  130. package/geometry/operators/simplifyOperator.d.ts +3 -3
  131. package/geometry/operators/symmetricDifferenceOperator.d.ts +3 -3
  132. package/geometry/operators/touchesOperator.d.ts +1 -1
  133. package/geometry/operators/{support/proximityResult.d.ts → types.d.ts} +18 -3
  134. package/geometry/operators/unionOperator.d.ts +3 -3
  135. package/geometry/operators/withinOperator.d.ts +1 -1
  136. package/geometry/projection/projectBoundingSphere.js +1 -1
  137. package/geometry/support/curves/curveUtils.js +1 -1
  138. package/geometry/support/geodesicUtils.d.ts +15 -2
  139. package/geometry/support/jsonUtils.d.ts +1 -1
  140. package/geometry/support/meshUtils/types.d.ts +34 -0
  141. package/geometry/support/meshUtils.d.ts +4 -7
  142. package/geometry/support/sphere.js +1 -1
  143. package/geometry/support/webMercatorUtils.d.ts +1 -1
  144. package/geometry/types.d.ts +23 -1
  145. package/geometry.d.ts +1 -1
  146. package/interfaces.d.ts +69 -72
  147. package/kernel.js +1 -1
  148. package/layers/CSVLayer.d.ts +0 -2
  149. package/layers/CatalogLayer.d.ts +1 -1
  150. package/layers/FeatureLayer.d.ts +1 -1
  151. package/layers/GeoJSONLayer.d.ts +1 -1
  152. package/layers/KnowledgeGraphLayer.js +1 -1
  153. package/layers/LinkChartLayer.js +1 -1
  154. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  155. package/layers/OGCFeatureLayer.d.ts +1 -1
  156. package/layers/OrientedImageryLayer.d.ts +1 -3
  157. package/layers/ParquetLayer.d.ts +1 -1
  158. package/layers/WFSLayer.d.ts +1 -1
  159. package/layers/catalog/CatalogFootprintLayer.d.ts +1 -1
  160. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  161. package/layers/knowledgeGraph/KnowledgeGraphSublayer.d.ts +3 -3
  162. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  163. package/layers/knowledgeGraph/layerUtils.js +1 -1
  164. package/layers/mixins/APIKeyMixin.d.ts +2 -2
  165. package/layers/mixins/ArcGISImageService.d.ts +4 -3
  166. package/layers/mixins/BlendLayer.d.ts +16 -15
  167. package/layers/mixins/DisplayFilteredLayer.d.ts +6 -3
  168. package/layers/mixins/FeatureEffectLayer.d.ts +23 -21
  169. package/layers/mixins/FeatureLayerBase.d.ts +23 -20
  170. package/layers/mixins/ImageryTileMixin.d.ts +5 -5
  171. package/layers/mixins/PortalLayer.d.ts +7 -7
  172. package/layers/mixins/RasterPresetRendererMixin.d.ts +6 -3
  173. package/layers/mixins/SceneService.d.ts +2 -2
  174. package/layers/mixins/TemporalLayer.d.ts +8 -7
  175. package/layers/mixins/TemporalSceneLayer.d.ts +2 -2
  176. package/layers/mixins/TrackableLayer.d.ts +4 -4
  177. package/layers/ogc/wfsUtils.d.ts +1 -1
  178. package/layers/raster/formats/Lerc.js +1 -1
  179. package/layers/raster/functions/creators/createSurfaceFunctions.d.ts +2 -2
  180. package/layers/support/DisplayFilterInfo.d.ts +7 -7
  181. package/layers/support/FeatureReductionCluster.d.ts +5 -5
  182. package/layers/support/FieldsIndex.d.ts +1 -2
  183. package/layers/support/RasterBandInfo.d.ts +1 -1
  184. package/layers/support/RasterInfo.d.ts +2 -2
  185. package/layers/support/RasterSensorInfo.d.ts +1 -1
  186. package/layers/support/Sublayer.d.ts +3 -3
  187. package/layers/support/SubtypeSublayer.d.ts +1 -1
  188. package/layers/support/TrackInfo.d.ts +2 -2
  189. package/layers/support/arcgisLayerUrl.js +1 -1
  190. package/layers/support/fieldUtils.d.ts +0 -1
  191. package/layers/support/source/QueryTableDataSource.d.ts +2 -2
  192. package/layers/support/types.d.ts +2 -2
  193. package/layers/types.d.ts +1 -1
  194. package/package.json +2 -2
  195. package/popup/FieldInfo.d.ts +8 -8
  196. package/popup/content/AttachmentsContent.d.ts +2 -2
  197. package/popup/content/CustomContent.d.ts +1 -1
  198. package/portal/interfaces.d.ts +2 -2
  199. package/portal/support/resourceUtils.d.ts +6 -7
  200. package/rest/featureService/types.d.ts +1 -1
  201. package/rest/geometryService.d.ts +2 -2
  202. package/rest/imageService.d.ts +1 -1
  203. package/rest/knowledgeGraph/GraphAnyValue.d.ts +1 -1
  204. package/rest/query/support/AttachmentInfo.d.ts +1 -1
  205. package/rest/query.d.ts +1 -1
  206. package/rest/support/BufferParameters.d.ts +1 -1
  207. package/rest/support/DataLayer.d.ts +1 -1
  208. package/rest/support/DensifyParameters.d.ts +1 -1
  209. package/rest/support/DistanceParameters.d.ts +1 -1
  210. package/rest/support/FeatureSet.d.ts +2 -2
  211. package/rest/support/FindImagesParameters.d.ts +1 -1
  212. package/rest/support/GeneralizeParameters.d.ts +1 -1
  213. package/rest/support/IdentifyParameters.d.ts +1 -1
  214. package/rest/support/ImageGPSInfoParameters.d.ts +1 -1
  215. package/rest/support/ImageMeasureResultAreaValue.d.ts +1 -1
  216. package/rest/support/ImageToMapMultirayParameters.d.ts +1 -1
  217. package/rest/support/OffsetParameters.d.ts +1 -1
  218. package/rest/support/ProjectParameters.d.ts +1 -1
  219. package/rest/support/Query.d.ts +1 -1
  220. package/rest/support/QueryMixin.d.ts +1 -1
  221. package/rest/support/RelationParameters.d.ts +1 -1
  222. package/rest/support/RelationshipQuery.d.ts +1 -1
  223. package/rest/support/TopFeaturesQuery.d.ts +1 -1
  224. package/smartMapping/labels/bins.d.ts +3 -6
  225. package/smartMapping/labels/clusters.d.ts +2 -2
  226. package/smartMapping/popup/clusters.d.ts +4 -4
  227. package/smartMapping/popup/templates.d.ts +4 -4
  228. package/smartMapping/renderers/color.d.ts +6 -6
  229. package/smartMapping/renderers/size.d.ts +6 -6
  230. package/smartMapping/statistics/support/ageUtils.d.ts +5 -5
  231. package/smartMapping/statistics/types.d.ts +5 -5
  232. package/smartMapping/types.d.ts +9 -1
  233. package/support/revision.js +1 -1
  234. package/unionTypes.d.ts +1 -1
  235. package/views/2d/MapViewConstraints.d.ts +5 -4
  236. package/views/2d/engine/webgl/Painter.js +1 -1
  237. package/views/2d/engine/webgl/shaderGraph/GLSLShaderModule.js +1 -1
  238. package/views/2d/engine/webgl/shaderGraph/GraphShaderModule.js +1 -1
  239. package/views/2d/engine/webgl/shaderGraph/graph/GlslGraphWriter.js +1 -1
  240. package/views/2d/engine/webgl/shaderGraph/graph/ShaderGraphContext.js +1 -1
  241. package/views/2d/engine/webgl/shaderGraph/typed/TypedShaderProgram.js +1 -1
  242. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  243. package/views/2d/layers/features/PipelineConnectionHandlers.js +1 -1
  244. package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
  245. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  246. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  247. package/views/3d/layers/I3SMeshView3D.js +1 -1
  248. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  249. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  250. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  251. package/views/3d/layers/i3s/I3SNode.js +1 -1
  252. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  253. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  254. package/views/3d/layers/support/Tiles3DIntersectionHandler.js +1 -1
  255. package/views/3d/support/ElevationRange.js +1 -1
  256. package/views/3d/terrain/TerrainSurface.js +1 -1
  257. package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechniqueConfiguration.js +1 -1
  258. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  259. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  260. package/views/BreakpointsOwner.d.ts +1 -1
  261. package/views/LinkChartView.d.ts +1 -2
  262. package/views/MapView.d.ts +1 -2
  263. package/views/SceneView.d.ts +1 -2
  264. package/views/View.d.ts +1 -1
  265. package/views/Viewport2DMixin.d.ts +1 -1
  266. package/views/draw/MultipointDrawAction.d.ts +1 -1
  267. package/views/draw/MultipointDrawAction.js +1 -1
  268. package/views/draw/PointDrawAction.d.ts +1 -1
  269. package/views/draw/PointDrawAction.js +1 -1
  270. package/views/draw/PolygonDrawAction.d.ts +1 -1
  271. package/views/draw/PolygonDrawAction.js +1 -1
  272. package/views/draw/PolylineDrawAction.d.ts +1 -1
  273. package/views/draw/PolylineDrawAction.js +1 -1
  274. package/views/draw/SegmentDrawAction.d.ts +1 -1
  275. package/views/draw/SegmentDrawAction.js +1 -1
  276. package/views/input/{IViewEvents.js → mouseButtons.js} +1 -1
  277. package/views/input/types.d.ts +602 -1
  278. package/views/layers/BuildingSceneLayerView.d.ts +1 -1
  279. package/views/layers/FeatureLayerViewMixin.d.ts +1 -1
  280. package/views/layers/ImageryLayerViewMixin.d.ts +1 -1
  281. package/views/layers/MediaLayerViewMixin.d.ts +1 -1
  282. package/views/layers/PointCloudLayerView.d.ts +1 -1
  283. package/views/layers/SceneLayerView.d.ts +2 -2
  284. package/views/types.d.ts +148 -2
  285. package/webdoc/geotriggersInfo/FeatureFilter.d.ts +1 -1
  286. package/webscene/support/FeatureReferenceObjectId.d.ts +1 -1
  287. package/widgets/BasemapLayerList/BasemapLayerListViewModel.d.ts +1 -2
  288. package/widgets/BasemapLayerList.d.ts +3 -4
  289. package/widgets/CatalogLayerList/CatalogLayerListViewModel.d.ts +1 -1
  290. package/widgets/CatalogLayerList.d.ts +2 -4
  291. package/widgets/Directions/DirectionsViewModel.d.ts +1 -1
  292. package/widgets/Editor/types.d.ts +1 -1
  293. package/widgets/Feature/support/arcadeFeatureUtils.js +1 -1
  294. package/widgets/FeatureTable/FeatureTableViewModel.d.ts +46 -5
  295. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  296. package/widgets/FeatureTable/FieldColumn.js +1 -1
  297. package/widgets/FeatureTable/Grid/EditorColumn.js +1 -1
  298. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  299. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  300. package/widgets/FeatureTable/VisibleElements.d.ts +30 -9
  301. package/widgets/FeatureTable/VisibleElements.js +1 -1
  302. package/widgets/FeatureTable/support/AttachmentsViewOptions.d.ts +1 -1
  303. package/widgets/FeatureTable/support/FeatureStore.d.ts +1 -0
  304. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  305. package/widgets/FeatureTable/support/interfaces.d.ts +2 -2
  306. package/widgets/FeatureTable.d.ts +46 -5
  307. package/widgets/FeatureTable.js +1 -1
  308. package/widgets/LayerList/LayerListViewModel.d.ts +9 -10
  309. package/widgets/LayerList/ListItem.d.ts +9 -11
  310. package/widgets/LayerList/ListItemPanel.d.ts +1 -1
  311. package/widgets/LayerList.d.ts +7 -4
  312. package/widgets/Legend/LegendViewModel.d.ts +5 -5
  313. package/widgets/Legend/support/ActiveLayerInfo.d.ts +5 -5
  314. package/widgets/Legend.d.ts +4 -4
  315. package/widgets/Popup/types.d.ts +3 -3
  316. package/widgets/Popup.d.ts +3 -3
  317. package/widgets/TableList/TableListViewModel.d.ts +2 -4
  318. package/widgets/TableList.d.ts +1 -1
  319. package/widgets/UtilityNetworkTrace/types.d.ts +1 -1
  320. package/assets/esri/core/workers/chunks/052ded41dc06c93ec0a7.js +0 -1
  321. package/assets/esri/core/workers/chunks/30184e39129d9c66ea54.js +0 -1
  322. package/assets/esri/core/workers/chunks/5340887a4a48bde3407a.js +0 -1
  323. package/assets/esri/core/workers/chunks/537de53ef1e9101468f5.js +0 -1
  324. package/assets/esri/core/workers/chunks/94f02082a006003ef5a9.js +0 -1
  325. package/assets/esri/core/workers/chunks/a1f264abbd6354c333bf.js +0 -1
  326. package/assets/esri/core/workers/chunks/d3db7244fac7398cc700.js +0 -1
  327. package/assets/esri/core/workers/chunks/d94a2ad5a91de7086fbe.js +0 -1
  328. package/assets/esri/core/workers/chunks/ed38c1043e6a83f49f93.js +0 -1
  329. package/geometry/geodesicUtils.d.ts +0 -19
  330. package/geometry/operators/support/geodeticCurveType.d.ts +0 -2
  331. package/geometry/operators/support/projectionTransformation.d.ts +0 -16
  332. package/geometry/support/MeshVertexSpace.d.ts +0 -4
  333. package/geometry/support/meshUtils/elevation.d.ts +0 -16
  334. package/geometry/support/meshUtils/elevationSampler.d.ts +0 -9
  335. package/geometry/support/meshUtils/georeference.d.ts +0 -10
  336. package/geometry/support/typeUtils.d.ts +0 -16
  337. package/smartMapping/popup/support/utils.d.ts +0 -13
  338. package/smartMapping/support/binningUtils.d.ts +0 -11
  339. package/smartMapping/support/clusterUtils.d.ts +0 -11
  340. package/smartMapping/support/utils.d.ts +0 -4
  341. package/views/2d/constraints/GeometryConstraint.d.ts +0 -4
  342. package/views/HitTestItem3D.d.ts +0 -20
  343. package/views/HitTestOptions.d.ts +0 -25
  344. package/views/IBreakpointsOwner.d.ts +0 -55
  345. package/views/IObjectId.d.ts +0 -2
  346. package/views/ISceneView.d.ts +0 -5
  347. package/views/IView.d.ts +0 -43
  348. package/views/input/IViewEvents.d.ts +0 -602
  349. /package/views/draw/input/{CursorUpdateEvents.d.ts → CursorUpdateEvent.d.ts} +0 -0
  350. /package/views/draw/input/{CursorUpdateEvents.js → CursorUpdateEvent.js} +0 -0
  351. /package/views/layers/{HighlightableLayerView.d.ts → types.d.ts} +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{initial as o,watch as n,when as a}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as d,subclass as c}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as m}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as u,IDENTITY as p}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as b}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{i as g,b as y,t as _}from"../../../chunks/vec32.js";import{freeze as v,create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as j}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as x,getReferenceEllipsoid as O}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as M}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as C}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as T}from"../../../geometry/projection/projectVectorToVector.js";import{create as E}from"../../../geometry/support/aaBoundingRect.js";import{getContinuousIndexArray as R}from"../../../geometry/support/Indices.js";import{BufferViewVec2f as U,BufferViewVec4f as H,BufferViewVec4u8 as S,BufferViewVec4u16 as P,BufferViewVec3f as A,BufferViewVec3u8 as V,BufferViewVec3u16 as L,BufferViewInt16 as k,BufferViewUint32 as I,BufferViewUint16 as F}from"../../../geometry/support/buffer/BufferView.js";import D from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as B}from"../../../support/elevationInfoUtils.js";import{LayerView3D as G}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as z}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as N,removeLayerViewFromWasm as W,getLyr3DWasm as $}from"./Lyr3DWasm.js";import{toWasmModification as q}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as J}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as Z,alphaModeConversion as K,faceCullingConversion as Q,wrapModeConversion as X,lyr3DTypeToByteSize as Y}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as ee}from"./support/Tiles3DIntersectionHandler.js";import{Frustum as te}from"../state/Frustum.js";import{ElevationRange as ie}from"../support/ElevationRange.js";import{toBoundingRect as se}from"../support/extentUtils.js";import{compute as re,Obb as oe}from"../support/orientedBoundingBox.js";import{glLayout as ne}from"../support/buffer/glUtil.js";import{ObjectParameters as ae}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as le,createVertexBufferLayout as de,SourceParameters as ce,SourceGeometry as he}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as me}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as ue}from"../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as pe}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as fe}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as be}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as ge}from"../webgl-engine/lib/Normals.js";import{writeAttribute as ye,writeBufferVec2 as _e}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import ve from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as we,isInEffectiveScaleRange as je,validateScaleRange as xe}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as Oe}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as Me}from"../../../webscene/support/AlphaCutoff.js";class Ce{constructor(e,t,i,s,r,o,n,a,l,d){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.nodeDepth=l,this.elevationRange=d,this.isLoaded=!1,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage;const c=w();n?.getCenter(c),this._obbCenter=c,this._obbRadius=n?.radius??0,this._obbRadiusSquared=this._obbRadius**2;const h=n?.halfSize;this._obbShortestHalfsize=h?Math.min(h[0],h[1],h[2]):0}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const i=this._obbCenter,s=i[0]-e[0],r=i[1]-e[1],o=i[2]-e[2],n=s*t[0]+r*t[1]+o*t[2];return s*s+r*r+o*o-n*n<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const{obb:t}=this;if(!t)return!0;const i=e.center,s=this._obbCenter,r=s[0]-i[0],o=s[1]-i[1],n=s[2]-i[2],a=r*r+o*o+n*n,l=this._obbRadius,d=e.radius;if(a>(l+d)**2)return!1;if(a<=(this._obbShortestHalfsize+d)**2)return!0;return Math.sqrt(a)+l<=d||t.intersectSphere(e)}}function Te(e){return Math.round(e/1048.576)/1e3}let Ee=class extends(G(ve)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new Oe,this._replacesTerrain=!1,this._isUsedAsGroundLayer=!1,this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._frustum=new te(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{r(t),this.layer=e}):null}canRecycleWith(e){return e.url===this.layer.url&&"integrated-mesh-3dtiles"===e.type&&e.replacesTerrain===this._replacesTerrain&&e.isUsedAsGroundLayer===this._isUsedAsGroundLayer}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._replacesTerrain=this.layer.replacesTerrain,this._isUsedAsGroundLayer=this.layer.isUsedAsGroundLayer,this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw we("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=N(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new ee(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),o),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),o),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),o),this._elevationProvider=new J({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),e.elevationProvider.register(1,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),a(()=>this.fullOpacity,()=>this._opacityChange())]),this._suspendedHandle=n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)});this.addResolvingPromise(t)}get fullOpacity(){return this.layer.replacesTerrain&&has("enable-feature:oit-ground")?this.view.map.ground.opacity:1}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateMaterial(t,t=>t.objectOpacity=e))}_cameraChanged(){const e=this._frustum;e.update(this.view.state.contentCamera);const t=this._visibleObjects;let i=!1;this._loadedObjects.forEach(s=>{const r=s.obb?.intersectsFrustum(e)??!1;r!==s.isVisible&&(s.isVisible=r,r?t.add(s):t.delete(s),s.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,r)),i=!0)}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),W(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=s(this._visibleGeometryChangedSchedulerHandle)}_modificationsChanged(){const e=this.layer.spatialReference,t=q(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=E();this._layerClippingArea=se(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.layer.replacesTerrain),this.forEachComponentObject(t=>this._collection.updateMaterial(t,t=>t.commonMaterialParameters.hasSlicePlane=e))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,B(e))}get _wasm(){return $(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||je(this.layer.effectiveScaleRange,this.view.scale)}canResume(){const e=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.layer.isUsedAsGroundLayer||xe(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,r++):(i+=n.textureMemoryUsage,s+=n.vboMemoryUsage,o++)}),new z(this.usedMemory,r,o,Te(t),Te(e),Te(s),Te(i))}_canProjectWithoutEngine(){if(2===this.view.state.viewingMode){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return B(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new ie(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new ie;return 0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this.forEachVisibleTile(t=>e.expandElevationRange(t.elevationRange))),e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const i of e)for(const e of i.componentObjects)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw new Error(e)}let t=0;const{meshData:i}=e;if(null==i.data)throw new Error("meshData.data undefined");if(i.desc=JSON.parse(i.desc),null==i.desc)throw new Error("meshData.desc undefined");const s=v(...i.desc.origin),r=this.view.basemapTerrain.spatialReference;let o,n;if("global"===this.view.viewingMode){const e=f();M(x,s,e,r),o=h(u(),e),n=m(u(),o)}else o=p,n=p;const a=w(),l=Se(i.desc.obb);let d=0,c=0;const b={textureMemoryUsage:0},E=new Array,R=new Map,H=i.desc.prims.length,S=new Array,P=new ie;try{const e="global"===this.view.viewingMode,t=e?O(this.view.spatialReference).radius:0;for(let h=0;h<H;h++){const m=i.desc.prims[h];this._dbg(2,JSON.stringify(m));if(null==Z[m.ptype]||null==i.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+m.ptype+"). Skipping primitive.");continue}const u=i.desc?.materials&&null!=m.materialId?i.desc.materials[m.materialId]:null,f=null!=u?u.lightingModel:"Unlit",{positionView:v,positionAttr:x,normalsView:O,normalsAttr:M,colorAttr:H,texCoord0Attr:S,indicesView:A}=this.getBufferViews(m,i.data.buffer,o);if(null==x||null==v||null==A)continue;const V=x.data.length/x.size,L=(e,t)=>!e||e.data.length/e.size===V||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!L(S,"numTexcoord")||!L(H,"numColors")||!L(M,"normals"))continue;const k=new le(null!=H,S?1:0,null!=O,this._shadeNormals||this.layer.replacesTerrain,this._applySSAO),I=de(k);for(let i=0;i<v.count;i++){v.getVec(i,a),g(a,a,s);const r=e?y(a)-t:a[2];P.expandElevationRangeValues(r,r)}const F=l?.clone()??He(x,s);if(o!==p)for(let e=0;e<v.count;e++)v.getVec(e,a),_(a,a,o),v.setVec(e,a);const D=I.createBuffer(x.data.length);if(ye("position",x,null,null,D,0),null!=S){const e=D.getField("uv0",U);_e(S,e,0)}null!=H&&ye("color",H,null,null,D,0),null!=M&&ye("normalCompressed",M,null,null,D,0);const B=new Uint32Array([0,A.typedBuffer.length]),G=new ce(ne(I),k.shadeNormals,k.applySSAO,k.textureCoordinateType),z=new he({data:D.buffer,count:D.byteLength/I.stride},{positions:v.typedBuffer,indices:A.typedBuffer},A.typedBuffer,B,G);d+=v.count+A.count;const N=this.view.renderSpatialReference,W=w(),$=[1,1,1];C(s,N,$,r)||this._dbg(3,"Unsupported coordinate system for IM overlay"),T(s,N,W,r);let q=()=>{},J=Promise.resolve(Ae);if(u){const e=e=>this._getTexture(e,i,R,b),t=e(u.baseColorTex),s="Pbr"===f,r=s?e(u.metalTex):null,o=s?e(u.emissiveTex):null,n=s?e(u.occlusionTex):null,a=s?e(u.normalTex):null,l=[t,r,o,n,a].map(e=>e?.loadPromise??null);J=Promise.all(l),q=e=>{e.baseColor=u.baseColorFactor,e.usePBR="Pbr"===f,e.hasParametersFromSource=!1,e.baseColorTexture=t,e.usePBR&&(e.mrrFactors=[u.metallicFactor,u.roughnessFactor,0],e.emissiveBaseColor=u.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=r,e.emissionTexture=o,e.occlusionTexture=n,e.normalTexture=a),e.alphaDiscardMode=K[u.alphaMode],e.objectOpacity=this.fullOpacity,b.textureMemoryUsage+=e.baseColorTexture?.texture?.usedMemory??0,e.usePBR&&(b.textureMemoryUsage+=(e.metallicRoughnessTexture?.texture?.usedMemory??0)+(e.emissionTexture?.texture?.usedMemory??0)+(e.occlusionTexture?.texture?.usedMemory??0)+(e.normalTexture?.texture?.usedMemory??0)),e.commonMaterialParameters.doubleSided=u.isDoubleSided,e.commonMaterialParameters.cullFace=Q[u.faceCulling??"NotSet"],e.commonMaterialParameters.isGround=this.layer.replacesTerrain,e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=0,e.textureAlphaCutoff=u.alphaCutoff??Me,e.alphaDiscardMode=K[u.alphaMode],e.isIntegratedMesh=!0,e.sphereDepthInterpolate=this.layer.hasGoogleUrl,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=pe(this.view.spatialReference)}}const X=J.then(()=>()=>{if(this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}const e=this._collection.createObject(new ae(j(W[0],W[1],$[0],$[1]),new me(s,n),F,z,!1));return this._collection.updateMaterial(e,q),c+=this._collection.getObjectGPUMemoryUsage(e),e});E.push(X)}if(S.push(...await Promise.all(E)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(I){throw R.forEach(e=>this._stage.removeTexture(e)),I}const A=S.map(e=>e()),V=new Array;R.forEach(e=>V.push(e));const{fullExtent:L}=this.layer;L?.hasZ&&L.zmax&&L.zmin&&(P.minElevation=Math.max(P.minElevation,L.zmin),P.maxElevation=Math.min(P.maxElevation,L.zmax));const k=new Ce(e.handle,A,V,d,c,b.textureMemoryUsage,l,e.stableNodeId,e.nodeDepth,P);return this._lyrHandleToObjects.set(e.handle,k),this._memCache.put(Pe(k.handle),k),t=k.usedMemory,this._cacheMemory+=t,{memUsageBytes:k.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){const t=Pe(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){if(this.destroyed||this.destroying)return;const s=this._frustum,r=new Array;let o=!1;for(let n=0;n<i;++n){if(!t[n])continue;const i=e[n],a=this._lyrHandleToObjects.get(i);if(a){if(a.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${a.stableNodeId}`);continue}o=!0,a.isLoaded=!0,this._loadedObjects.add(a),this._usedMemory+=a.usedMemory,this._cacheMemory-=a.usedMemory;const e=a.obb?.intersectsFrustum(s)??!0;if(a.isVisible=e,e){this._visibleObjects.add(a);const{minElevation:e,maxElevation:t}=a.elevationRange;(e<this.visibleElevationRange.minElevation||t>this.visibleElevationRange.maxElevation)&&this._setVisibleElevationRangeDirty()}e&&a.obb&&r.push(a.obb),a.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(Pe(i))}else this._dbg(3,`Tried to mark Non existent object ${i} as loaded`)}for(let n=0;n<i;++n){const i=e[n];if(t[n])continue;const s=this._lyrHandleToObjects.get(i);if(s){if(!s.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${s.stableNodeId}`);continue}const e=this._visibleObjects.delete(s);if(s.isVisible=!1,s.isLoaded=!1,this._loadedObjects.delete(s),e){this._visibleGeometryChanged();const{minElevation:e,maxElevation:t}=s.elevationRange;e!==this.visibleElevationRange.minElevation&&t!==this.visibleElevationRange.maxElevation||this._setVisibleElevationRangeDirty()}this._usedMemory-=s.usedMemory,this._cacheMemory+=s.usedMemory,e&&s.obb&&r.push(s.obb),s.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(Pe(i),s)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),this._elevationProvider.notifyObjectsChanged(r),this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_getTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=i.get(r)??this._createTexture(e,t,i,s);return o?new ue(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!r.mipCount||a>1,d=X[e.wrapMode??"None"];let c=r.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,r.data.byteOffset,r.data.byteCount);let m=null,u=null,p=null;switch(r.format){case"Raw":"R8"===r.pixelFormat?(m=h,c=6403,u=""):"Rgb8"===r.pixelFormat?(m=h,c=6407,u=""):"Rgba8"===r.pixelFormat&&(m=h,c=6408,u="");break;case"Dxt1":m=h,c=6407,u="image/vnd-ms.dds";break;case"Dxt5":m=h,c=6408,u="image/vnd-ms.dds";break;case"Basis":m=h,c=6407,u="image/ktx2";break;case"Png":u="image/png",p=document.createElement("img");break;case"Jpeg":u="image/jpeg",p=document.createElement("img");break;case"Etc2":u="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&u){const e=new Blob([h],{type:u});p.src=URL.createObjectURL(e),m=p}if(m&&null!=u){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0,t=new be(m,{mipmap:l,maxAnisotropy:a,encoding:u,wrap:d,pixelFormat:c,compressionOptions:e,noUnpackFlip:!0,width:r.mip0Width,height:r.mip0Height});return this._stage.addTexture(t),i.set(r,t),t}return null}getBufferViews(e,t,i){let s,r,o,n,a,l,d,c=null;for(let m=0;m<e.atrbs.length;m++){const d=e.atrbs[m],{view:u}=d,p=void 0,f=u.byteOffset+u.byteCount,b=u.byteCount/Y[u.type],g=R(b);try{switch(d.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(s=new A(t,u.byteOffset,p,f),r=new fe(s.typedBuffer,g,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new A(t,u.byteOffset,p,f),s=ge(e.typedBuffer,i);a=new k(s.buffer),l=new fe(a.typedBuffer,g,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===n&&(n=new fe(new U(t,u.byteOffset,p,f).typedBuffer,g,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(c=new H(t,u.byteOffset,p,f)),"U8"===u.type&&(c=new S(t,u.byteOffset,p,f)),"U16"===u.type&&(c=new P(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(c=new A(t,u.byteOffset,p,f)),"U8"===u.type&&(c=new V(t,u.byteOffset,p,f)),"U16"===u.type&&(c=new L(t,u.byteOffset,p,f))),null==c?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new fe(c.typedBuffer,g,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+d.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":d=new F(t,i.byteOffset,s,r);break;case"U32":d=new I(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==d&&null!=s){const e=s.count;d=d=e<65535?new F(new Uint16Array(e).buffer):new I(new Uint32Array(e).buffer);for(let t=0;t<e;t++)d.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:n,indicesView:d,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.layer.isUsedAsGroundLayer&&"replace"!==e.type)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info("Ground layers only support replace modifications. Other modification types have been ignored.")},o),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([d()],Ee.prototype,"fullOpacity",null),e([d({readOnly:!0})],Ee.prototype,"ready",null),e([d({type:[D]})],Ee.prototype,"_modifications",void 0),e([d()],Ee.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([d()],Ee.prototype,"layer",void 0),e([d({readOnly:!0})],Ee.prototype,"visibleAtCurrentScale",null),e([d({readOnly:!0})],Ee.prototype,"_collection",null),e([d()],Ee.prototype,"elevationOffset",null),e([d({readOnly:!0})],Ee.prototype,"visibleElevationRange",null),Ee=e([c("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Ee);const Re=Ee,Ue=w();function He(e,t){const i=re(e);return g(Ue,i.center,t),i.center=Ue,i}function Se(e){return e?new oe(e.center,e.halfSize,b(...e.quaternion)):null}function Pe(e){return`${e}`}const Ae=new Array;export{Re as default};
5
+ import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{initial as o,watch as n,when as a}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as d,subclass as c}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as m}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as u,IDENTITY as p}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as b}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{i as g,b as y,t as _}from"../../../chunks/vec32.js";import{freeze as v,create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as j}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as x,getReferenceEllipsoid as M}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as O}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as C}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as T}from"../../../geometry/projection/projectVectorToVector.js";import{create as E}from"../../../geometry/support/aaBoundingRect.js";import{getContinuousIndexArray as R}from"../../../geometry/support/Indices.js";import{BufferViewVec2f as U,BufferViewVec4f as V,BufferViewVec4u8 as H,BufferViewVec4u16 as S,BufferViewVec3f as P,BufferViewVec3u8 as A,BufferViewVec3u16 as L,BufferViewInt16 as k,BufferViewUint32 as I,BufferViewUint16 as F}from"../../../geometry/support/buffer/BufferView.js";import D from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as B}from"../../../support/elevationInfoUtils.js";import{LayerView3D as G}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as z}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as N,removeLayerViewFromWasm as W,getLyr3DWasm as $}from"./Lyr3DWasm.js";import{toWasmModification as q}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as J}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as Z,alphaModeConversion as K,faceCullingConversion as Q,wrapModeConversion as X,lyr3DTypeToByteSize as Y}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as ee}from"./support/Tiles3DIntersectionHandler.js";import{Frustum as te}from"../state/Frustum.js";import{ElevationRange as ie}from"../support/ElevationRange.js";import{toBoundingRect as se}from"../support/extentUtils.js";import{compute as re,Obb as oe}from"../support/orientedBoundingBox.js";import{glLayout as ne}from"../support/buffer/glUtil.js";import{ObjectParameters as ae}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as le,createVertexBufferLayout as de,SourceParameters as ce,SourceGeometry as he}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as me}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as ue}from"../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as pe}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as fe}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as be}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as ge}from"../webgl-engine/lib/Normals.js";import{writeAttribute as ye,writeBufferVec2 as _e}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import ve from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as we,isInEffectiveScaleRange as je,validateScaleRange as xe}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as Me}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as Oe}from"../../../webscene/support/AlphaCutoff.js";class Ce{constructor(e,t,i,s,r,o,n,a,l,d){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.nodeDepth=l,this.elevationRange=d,this.isLoaded=!1,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage;const c=w();n?.getCenter(c),this._obbCenter=c,this._obbRadius=n?.radius??0,this._obbRadiusSquared=this._obbRadius**2;const h=n?.halfSize;this._obbShortestHalfsize=h?Math.min(h[0],h[1],h[2]):0}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const i=this._obbCenter,s=i[0]-e[0],r=i[1]-e[1],o=i[2]-e[2],n=s*t[0]+r*t[1]+o*t[2];return s*s+r*r+o*o-n*n<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const{obb:t}=this;if(!t)return!0;const i=e.center,s=this._obbCenter,r=s[0]-i[0],o=s[1]-i[1],n=s[2]-i[2],a=r*r+o*o+n*n,l=this._obbRadius,d=e.radius;if(a>(l+d)**2)return!1;if(a<=(this._obbShortestHalfsize+d)**2)return!0;return Math.sqrt(a)+l<=d||t.intersectSphere(e)}}function Te(e){return Math.round(e/1048.576)/1e3}let Ee=class extends(G(ve)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new Me,this._replacesTerrain=!1,this._isUsedAsGroundLayer=!1,this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._frustum=new te(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{r(t),this.layer=e}):null}canRecycleWith(e){return e.url===this.layer.url&&"integrated-mesh-3dtiles"===e.type&&e.replacesTerrain===this._replacesTerrain&&e.isUsedAsGroundLayer===this._isUsedAsGroundLayer}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._replacesTerrain=this.layer.replacesTerrain,this._isUsedAsGroundLayer=this.layer.isUsedAsGroundLayer,this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw we("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=N(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new ee(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),o),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),o),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),o),this._elevationProvider=new J({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),e.elevationProvider.register(1,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),a(()=>this.fullOpacity,()=>this._opacityChange())]),this._suspendedHandle=n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)});this.addResolvingPromise(t)}get fullOpacity(){return this.layer.replacesTerrain&&has("enable-feature:oit-ground")?this.view.map.ground.opacity:1}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateMaterial(t,t=>t.objectOpacity=e))}_cameraChanged(){const e=this._frustum;e.update(this.view.state.contentCamera);const t=this._visibleObjects;let i=!1;this._loadedObjects.forEach(s=>{const r=s.obb?.intersectsFrustum(e)??!1;r!==s.isVisible&&(s.isVisible=r,r?t.add(s):t.delete(s),s.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,r)),i||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(r,s.elevationRange))}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),W(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=s(this._visibleGeometryChangedSchedulerHandle)}_modificationsChanged(){const e=this.layer.spatialReference,t=q(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=E();this._layerClippingArea=se(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.layer.replacesTerrain),this.forEachComponentObject(t=>this._collection.updateMaterial(t,t=>t.commonMaterialParameters.hasSlicePlane=e))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,B(e))}get _wasm(){return $(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||je(this.layer.effectiveScaleRange,this.view.scale)}canResume(){const e=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.layer.isUsedAsGroundLayer||xe(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,r++):(i+=n.textureMemoryUsage,s+=n.vboMemoryUsage,o++)}),new z(this.usedMemory,r,o,Te(t),Te(e),Te(s),Te(i))}_canProjectWithoutEngine(){if(2===this.view.state.viewingMode){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return B(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new ie(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new ie;0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this.forEachVisibleTile(t=>e.expandElevationRange(t.elevationRange)));const t=this._get("visibleElevationRange");return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const i of e)for(const e of i.componentObjects)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw new Error(e)}let t=0;const{meshData:i}=e;if(null==i.data)throw new Error("meshData.data undefined");if(i.desc=JSON.parse(i.desc),null==i.desc)throw new Error("meshData.desc undefined");const s=v(...i.desc.origin),r=this.view.basemapTerrain.spatialReference;let o,n;if("global"===this.view.viewingMode){const e=f();O(x,s,e,r),o=h(u(),e),n=m(u(),o)}else o=p,n=p;const a=w(),l=He(i.desc.obb);let d=0,c=0;const b={textureMemoryUsage:0},E=new Array,R=new Map,V=i.desc.prims.length,H=new Array,S=new ie;try{const e="global"===this.view.viewingMode,t=e?M(this.view.spatialReference).radius:0;for(let h=0;h<V;h++){const m=i.desc.prims[h];this._dbg(2,JSON.stringify(m));if(null==Z[m.ptype]||null==i.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+m.ptype+"). Skipping primitive.");continue}const u=i.desc?.materials&&null!=m.materialId?i.desc.materials[m.materialId]:null,f=null!=u?u.lightingModel:"Unlit",{positionView:v,positionAttr:x,normalsView:M,normalsAttr:O,colorAttr:V,texCoord0Attr:H,indicesView:P}=this.getBufferViews(m,i.data.buffer,o);if(null==x||null==v||null==P)continue;const A=x.data.length/x.size,L=(e,t)=>!e||e.data.length/e.size===A||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!L(H,"numTexcoord")||!L(V,"numColors")||!L(O,"normals"))continue;const k=new le(null!=V,H?1:0,null!=M,this._shadeNormals||this.layer.replacesTerrain,this._applySSAO),I=de(k);for(let i=0;i<v.count;i++){v.getVec(i,a),g(a,a,s);const r=e?y(a)-t:a[2];S.expandElevationRangeValues(r,r)}const F=l?.clone()??Ve(x,s);if(o!==p)for(let e=0;e<v.count;e++)v.getVec(e,a),_(a,a,o),v.setVec(e,a);const D=I.createBuffer(x.data.length);if(ye("position",x,null,null,D,0),null!=H){const e=D.getField("uv0",U);_e(H,e,0)}null!=V&&ye("color",V,null,null,D,0),null!=O&&ye("normalCompressed",O,null,null,D,0);const B=new Uint32Array([0,P.typedBuffer.length]),G=new ce(ne(I),k.shadeNormals,k.applySSAO,k.textureCoordinateType),z=new he({data:D.buffer,count:D.byteLength/I.stride},{positions:v.typedBuffer,indices:P.typedBuffer},P.typedBuffer,B,G);d+=v.count+P.count;const N=this.view.renderSpatialReference,W=w(),$=[1,1,1];C(s,N,$,r)||this._dbg(3,"Unsupported coordinate system for IM overlay"),T(s,N,W,r);let q=()=>{},J=Promise.resolve(Pe);if(u){const e=e=>this._getTexture(e,i,R,b),t=e(u.baseColorTex),s="Pbr"===f,r=s?e(u.metalTex):null,o=s?e(u.emissiveTex):null,n=s?e(u.occlusionTex):null,a=s?e(u.normalTex):null,l=[t,r,o,n,a].map(e=>e?.loadPromise??null);J=Promise.all(l),q=e=>{e.baseColor=u.baseColorFactor,e.usePBR="Pbr"===f,e.hasParametersFromSource=!1,e.baseColorTexture=t,e.usePBR&&(e.mrrFactors=[u.metallicFactor,u.roughnessFactor,0],e.emissiveBaseColor=u.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=r,e.emissionTexture=o,e.occlusionTexture=n,e.normalTexture=a),e.alphaDiscardMode=K[u.alphaMode],e.objectOpacity=this.fullOpacity,b.textureMemoryUsage+=e.baseColorTexture?.texture?.usedMemory??0,e.usePBR&&(b.textureMemoryUsage+=(e.metallicRoughnessTexture?.texture?.usedMemory??0)+(e.emissionTexture?.texture?.usedMemory??0)+(e.occlusionTexture?.texture?.usedMemory??0)+(e.normalTexture?.texture?.usedMemory??0)),e.commonMaterialParameters.doubleSided=u.isDoubleSided,e.commonMaterialParameters.cullFace=Q[u.faceCulling??"NotSet"],e.commonMaterialParameters.isGround=this.layer.replacesTerrain,e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=0,e.textureAlphaCutoff=u.alphaCutoff??Oe,e.alphaDiscardMode=K[u.alphaMode],e.isIntegratedMesh=!0,e.sphereDepthInterpolate=this.layer.hasGoogleUrl,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=pe(this.view.spatialReference)}}const X=J.then(()=>()=>{if(this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}const e=this._collection.createObject(new ae(j(W[0],W[1],$[0],$[1]),new me(s,n),F,z,!1));return this._collection.updateMaterial(e,q),c+=this._collection.getObjectGPUMemoryUsage(e),e});E.push(X)}if(H.push(...await Promise.all(E)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(I){throw R.forEach(e=>this._stage.removeTexture(e)),I}const P=H.map(e=>e()),A=new Array;R.forEach(e=>A.push(e));const{fullExtent:L}=this.layer;L?.hasZ&&L.zmax&&L.zmin&&(S.minElevation=Math.max(S.minElevation,L.zmin),S.maxElevation=Math.min(S.maxElevation,L.zmax));const k=new Ce(e.handle,P,A,d,c,b.textureMemoryUsage,l,e.stableNodeId,e.nodeDepth,S);return this._lyrHandleToObjects.set(e.handle,k),this._memCache.put(Se(k.handle),k),t=k.usedMemory,this._cacheMemory+=t,{memUsageBytes:k.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){const t=Se(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){if(this.destroyed||this.destroying)return;const s=this._frustum,r=new Array;let o=!1,n=!1;for(let a=0;a<i;++a){if(!t[a])continue;const i=e[a],l=this._lyrHandleToObjects.get(i);if(l){if(l.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${l.stableNodeId}`);continue}o=!0,l.isLoaded=!0,this._loadedObjects.add(l),this._usedMemory+=l.usedMemory,this._cacheMemory-=l.usedMemory;const e=l.obb?.intersectsFrustum(s)??!0;l.isVisible=e,e&&(this._visibleObjects.add(l),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,l.elevationRange)),e&&l.obb&&r.push(l.obb),l.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(Se(i))}else this._dbg(3,`Tried to mark Non existent object ${i} as loaded`)}for(let a=0;a<i;++a){const i=e[a];if(t[a])continue;const s=this._lyrHandleToObjects.get(i);if(s){if(!s.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${s.stableNodeId}`);continue}const e=this._visibleObjects.delete(s);s.isVisible=!1,s.isLoaded=!1,this._loadedObjects.delete(s),e&&(this._visibleGeometryChanged(),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,s.elevationRange)),this._usedMemory-=s.usedMemory,this._cacheMemory+=s.usedMemory,e&&s.obb&&r.push(s.obb),s.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(Se(i),s)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),this._elevationProvider.notifyObjectsChanged(r),n&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){const{visibleElevationRange:i}=this,{minElevation:s,maxElevation:r}=t;return e?s<i.minElevation||r>i.maxElevation:s===i.minElevation||r===i.maxElevation}_getTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=i.get(r)??this._createTexture(e,t,i,s);return o?new ue(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!r.mipCount||a>1,d=X[e.wrapMode??"None"];let c=r.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,r.data.byteOffset,r.data.byteCount);let m=null,u=null,p=null;switch(r.format){case"Raw":"R8"===r.pixelFormat?(m=h,c=6403,u=""):"Rgb8"===r.pixelFormat?(m=h,c=6407,u=""):"Rgba8"===r.pixelFormat&&(m=h,c=6408,u="");break;case"Dxt1":m=h,c=6407,u="image/vnd-ms.dds";break;case"Dxt5":m=h,c=6408,u="image/vnd-ms.dds";break;case"Basis":m=h,c=6407,u="image/ktx2";break;case"Png":u="image/png",p=document.createElement("img");break;case"Jpeg":u="image/jpeg",p=document.createElement("img");break;case"Etc2":u="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&u){const e=new Blob([h],{type:u});p.src=URL.createObjectURL(e),m=p}if(m&&null!=u){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0,t=new be(m,{mipmap:l,maxAnisotropy:a,encoding:u,wrap:d,pixelFormat:c,compressionOptions:e,noUnpackFlip:!0,width:r.mip0Width,height:r.mip0Height});return this._stage.addTexture(t),i.set(r,t),t}return null}getBufferViews(e,t,i){let s,r,o,n,a,l,d,c=null;for(let m=0;m<e.atrbs.length;m++){const d=e.atrbs[m],{view:u}=d,p=void 0,f=u.byteOffset+u.byteCount,b=u.byteCount/Y[u.type],g=R(b);try{switch(d.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(s=new P(t,u.byteOffset,p,f),r=new fe(s.typedBuffer,g,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new P(t,u.byteOffset,p,f),s=ge(e.typedBuffer,i);a=new k(s.buffer),l=new fe(a.typedBuffer,g,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===n&&(n=new fe(new U(t,u.byteOffset,p,f).typedBuffer,g,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(c=new V(t,u.byteOffset,p,f)),"U8"===u.type&&(c=new H(t,u.byteOffset,p,f)),"U16"===u.type&&(c=new S(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(c=new P(t,u.byteOffset,p,f)),"U8"===u.type&&(c=new A(t,u.byteOffset,p,f)),"U16"===u.type&&(c=new L(t,u.byteOffset,p,f))),null==c?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new fe(c.typedBuffer,g,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+d.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":d=new F(t,i.byteOffset,s,r);break;case"U32":d=new I(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==d&&null!=s){const e=s.count;d=d=e<65535?new F(new Uint16Array(e).buffer):new I(new Uint32Array(e).buffer);for(let t=0;t<e;t++)d.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:n,indicesView:d,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.layer.isUsedAsGroundLayer&&"replace"!==e.type)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info("Ground layers only support replace modifications. Other modification types have been ignored.")},o),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([d()],Ee.prototype,"fullOpacity",null),e([d({readOnly:!0})],Ee.prototype,"ready",null),e([d({type:[D]})],Ee.prototype,"_modifications",void 0),e([d()],Ee.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([d()],Ee.prototype,"layer",void 0),e([d({readOnly:!0})],Ee.prototype,"visibleAtCurrentScale",null),e([d({readOnly:!0})],Ee.prototype,"_collection",null),e([d()],Ee.prototype,"elevationOffset",null),e([d({readOnly:!0})],Ee.prototype,"visibleElevationRange",null),Ee=e([c("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Ee);const Re=Ee,Ue=w();function Ve(e,t){const i=re(e);return g(Ue,i.center,t),i.center=Ue,i}function He(e){return e?new oe(e.center,e.halfSize,b(...e.quaternion)):null}function Se(e){return`${e}`}const Pe=new Array;export{Re as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{isAbortError as t}from"../../../../core/promiseUtils.js";import{projectBoundingSphere as i}from"../../../../geometry/projection/projectBoundingSphere.js";import{Sphere as s}from"../../../../geometry/support/sphere.js";import{NodeBoundingData as n,Node as o,NodeTraversalState as r}from"./I3SNode.js";import{invalidateMbs as d,addWraparound as a}from"./I3SUtil.js";import{ValidatedNode as l}from"./ValidatedNode.js";import{ElevationRange as h}from"../../support/ElevationRange.js";import{Obb as u}from"../../support/orientedBoundingBox.js";class c{constructor(e,t,i,s,n){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this._boundingData=s,this.node=n,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 g{constructor(e=new Array,t=new Array){this._nodeDescriptors=e,this._children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}destroy(){for(const 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 _{get _useNodePages(){return this._pageSize>0}constructor(t,i,s,o,r,d,a,l,h,u,c,_,f,v,N){if(this.viewingMode=t,this._layer=i,this._requester=o,this._clientNodeLoader=r,this._viewportQueries=d,this._logger=a,this.holeFilling=l,this._isLoaded=h,this._isReloading=u,this._shouldLoadNode=c,this._enable=_,this._needsUpdate=f,this._computeVisibilityObb=v,this._computeNodeFiltering=N,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=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._version=p(0),this._visibilityCacheVersion=p(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._progressiveLoadPenaltyWeight=10,this._missingPagesAndNodes=new Set,this._prioritizedMissingNodeAndPageIds=new Array,this._prefetchNodes=new Set,this._prioritizedPrefetchNodes=new Array,this._updates=new m(this._missingPagesAndNodes),this._imModificationUncategorized=new e({deallocator:null}),this.ignoreServiceObb=!1,this._pageQueue=new Array,this._newPages=new Array,this.needNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._traverseDescendantsQueue=[0],this._traverseDescendantsNestingLevel=0,this._isEditable=null!=i.associatedLayer?.infoFor3D,i.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${i.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,"page"===s.type){const e=s.rootPage;switch(this.urlPrefix=s.urlPrefix,this._pageSize=s.pageSize,s.lodMetric){case"maxScreenThreshold":this._lodMetric=1;break;case"maxScreenThresholdSQ":this._lodMetric=1,this._lodConversion=E}if(this._isEditable){this._rootIndex=-1;const t=I(s.rootIndex,s.pageSize),i=e.nodes[t],n={nodes:[{index:this._rootIndex,children:[s.rootIndex],mesh:void 0,obb:i.obb,lodThreshold:i.lodThreshold}]};this._addPage(P(this._rootIndex,this._pageSize),n),this.getNode(-1).serviceObbInIndexSR=void 0}else this._rootIndex=s.rootIndex;this._addPage(P(s.rootIndex,this._pageSize),e),this._updateParentsAndLevel()}else if("node"===s.type){this.urlPrefix=s.urlPrefix;const e=new g;if(this._nodePages.set(0,e),this._isEditable){this._clientNodePage=new g;const e={id:"-1",version:null,mbs:s.rootNode.mbs,obb:s.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:"root",href:"../root",mbs:s.rootNode.mbs,obb:s.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new n(e.id),-1);const t=this._validateNode(e.id,e);t&&this._addNode(t,this._rootIndex)}else this._rootIndex=this._makeRefNode(new n(s.rootNode.id),-1);const t=this._validateNode(s.rootNode.id,s.rootNode);t&&this._addNode(t,0)}}addClientNodeToIndex(e,t){const i=-1,s=new n(e,t),o=this._makeClientRefNode(s,i);return this._linkChildToParentNode(i,o),this.requestUpdate(),o}removeClientNodeFromIndex(e,t,i){this._destroyClientRefNode(e,t,i),this.requestUpdate()}_canRequest(e){return!this._requester.isFull(e)}_loadPage(e){if(this._nodePages.has(e))return void this._logger.error(`Requested load page [${e}] already loaded`);if(this._loadingPages.has(e))return void this._logger.error(`Requested load page [${e}] already loading`);this._loadingPages.add(e);const i=this.urlPrefix+e;this._requester.request(i,"json").then(t=>{this._nodePages.has(e)?this._logger.error(`Queued page [${e}] already loaded`):this._pageQueue.push({pageIndex:e,page:t})}).catch(i=>{this._loadingPages.delete(e),t(i)||(this._failedPages.add(e),this._logger.error("#loadPage()",this._layer,`Error when loading page ${e}`,i))})}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){const{pageIndex:t,page:i}=this._pageQueue.shift();this._addPage(t,i),this._loadingPages.delete(t),e.madeProgress(),this.needNodeElevationRange&&this._newPages.push(t)}this._updateParentsAndLevel()}_invalidateElevationRangeForNewPages(e){if(this.needNodeElevationRange)for(;this._newPages.length>0&&!e.done;){const e=this._nodePages.get(this._newPages.shift());e?.nodes.forEach(e=>{let t=e.parentIndex;for(;null!=t&&t!==this._rootIndex;){const e=this.getNode(t);e?.elevationRangeValid&&(e.invalidateElevationRange(),this.invalidateBoundingVolumeCache(t)),t=this._getParentIndex(t)}})}}_addPage(e,t){if(this._nodePages.has(e))return void this._logger.error(`Page[${e}] reloaded`);const i=[],n=[],r=t.nodes.map((t,r)=>{const d=i.length,a=t.children?t.children.length:0;n.push(this._rootIndex);for(let e=0;e<a;e++)i.push(t.children[e]);const l=`${t.index}`,h=u.fromJSON(t.obb),g=new s(h.center,h.radius),_=t.mesh?.attribute,f=t.mesh?.geometry,m=t.mesh?.material,p={hasSharedResource:!1,isEmpty:null==f,attributes:null!=_?.resource?`${_.resource}`:void 0,geometry:null!=f?.resource?`${f.resource}`:void 0,texture:null!=m?.resource?`${m.resource}`:void 0,geometryDefinition:f?f.definition:-1,materialDefinition:m?m.definition:-1},N=new o(l,x(r,e,this._pageSize),g,a,0,p,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),f?.featureCount??null);return N.serviceObbInIndexSR=h,N.visibilityObbInRenderSR=this._computeVisibilityObb(N),N.vertexCount=f?f.vertexCount:0,new c(d,a,v(this._visibilityCacheVersion),null,N)}),d=new g(r,i);-1===e?this._clientNodePage=d:this._nodePages.set(e,d)}_updateParentsAndLevel(){const e=new Array,t=(t,i,s)=>{const n=this._getPage(t);if(null!=n){const o=I(t,this._pageSize),r=n.nodes[o];r.parentIndex=null!=i?i:-1;const d=r.node;null!=d&&(d.level=s,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){const i=e.pop(),s=this.getNode(i);if(null!=s)for(let e=0;e<s.childCount;e++){t(this.getChildIndex(s.index,e),i,s.level+1),this._maxLevel=Math.max(this._maxLevel,s.level+1)}}}_getPage(e){const t=P(e,this._pageSize);return this._getPageFromPageIndex(t)}_getPageFromPageIndex(e){return e<0?this._clientNodePage:this._nodePages.get(e)}_getNodeDescriptor(e){const t=this._getPage(e);return null==t?null:(t.lastTraversed=this._frameNumber,t.nodes[I(e,this._pageSize)])}_addNode(e,t){e.children&&this.populateChildren(t,e.children);const i=this.getParent(t),s=null!=i?i.level+1:0;this._maxLevel=Math.max(this._maxLevel,e.children?s+1:s);const{lodMetric:n,maxError:r}=R(e.lodSelection),d=this._getNodeDescriptor(t);if(null!=d.node)return this._logger.error(`Loaded node[${t}] already in descriptor`),d.node;const a=new o(e.id,t,e.mbs,d.childCount,s,e.resources,e.version,n,r,e.numFeatures);d.node=a,e.obb&&(a.serviceObbInIndexSR=u.fromJSON(e.obb)),a.visibilityObbInRenderSR=this._computeVisibilityObb(a);const l=d.nodeBoundingData;return null!=l&&(null==l.serviceMbsInIndexSR&&(l.serviceMbsInIndexSR=e.mbs),a.shareServiceBVsInRenderSRWith(l),l.visibilityObbInRenderSR=a.visibilityObbInRenderSR),a}_makeRefNode(e,t){const i=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(null==i)return-1;const s=i.nodes.length,n=new c(0,0,v(this._visibilityCacheVersion),e,null);return i.addNode(n),n.parentIndex=t,e.invalidateServiceBVsInRenderSR(),s}_makeClientRefNode(e,t){const i=this._clientNodePage;if(null==i)return-1;if(t>=0)throw new Error("I3SIndex::client side nodes can not be made children of service side nodes.");const s=-(i.nodes.length+1),n=new c(0,0,v(this._visibilityCacheVersion),e,null);return i.addNode(n),n.parentIndex=t,e.invalidateServiceBVsInRenderSR(),s}_linkChildToParentNode(e,t){const i=this._clientNodePage;if(null==i||e>=0)return;const s=I(e,this._pageSize),n=I(t,this._pageSize),o=i.nodes[s],r=o.childOffset;i.children.splice(o.childOffset+o.childCount,0,t);const d=1;o.childCount+=d,null!=o.node&&(o.node.childCount+=d);for(const a of i.nodes)a.childOffset>r&&(a.childOffset+=d);i.nodes[n].parentIndex=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,i){const s=this._clientNodePage;if(null==s)return;const n=this._getParentIndex(e);if(null==n)return;const o=new Set,r=new Map,d=e=>{const i=I(e,this._pageSize),n=s.nodes[i];if(n.childCount>0)for(let t=n.childOffset;t<n.childOffset+n.childCount;++t)d(s.children[t]);const r=n.node?.id??n.nodeBoundingData?.id;if(null==r)throw new Error("Node has no id");t(r,e),o.add(n)};d(e);const a=s.nodes,l=s.children,h=s.nodes.map(()=>-1),u=[],c=[];for(let g=0;g<a.length;++g){const e=a[g];if(o.has(e))continue;const t=u.length,s=x(g,-1,this._pageSize),n=x(t,-1,this._pageSize);if(e.node&&(e.node.index=n),h[g]=n,u.push(e),s!==n){const t=e.node?.id??e.nodeBoundingData?.id;if(null==t)throw new Error("Node has no id");i(t,s,n),r.set(s,n)}}for(let g=0;g<u.length;++g){const e=x(g,-1,this._pageSize),t=u[g],i=c.length;for(let s=t.childOffset;s<t.childOffset+t.childCount;++s){const t=l[s];if(t>=0)c.push(t);else{const i=I(t,this._pageSize),s=a[i];if(o.has(s))continue;const n=h[i];c.push(n),s.parentIndex=e}}t.childOffset=i,t.childCount=c.length-i,t.node&&(t.node.childCount=t.childCount)}s.setNodes(u,c),this._updateParentBoundingInformation(h[I(n,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null;const n=this._clientNodeLoader.indexSR,o=this._clientNodeLoader.renderSR,r=this._getNodeDescriptor(t);if(null==r)return;for(let s=0;s<r.childCount;s++){const r=this.getChildIndex(t,s),d=this._getNodeDescriptor(r),a=null!=d?d.nodeBoundingData||d.node:null;if(null!=a?.serviceMbsInIndexSR&&a.serviceMbsInIndexSR.radius>0)if(null==e)e=D.copy(a.serviceMbsInIndexSR);else{const t=M;i(a.serviceMbsInIndexSR,n,t,o);const s=V;i(e,n,s,o),i(t.union(s),o,e,n)}}const a=t=>{null!=t&&(t.serviceObbInIndexSR=null,null!=e?(t.serviceMbsInIndexSR??=new s,t.serviceMbsInIndexSR.copy(e)):d(t.serviceMbsInIndexSR),t.invalidateServiceBVsInRenderSR(),t.geometryObbInRenderSR=null)};a(r.nodeBoundingData),a(r.node),this.invalidateNodeVisibilityCacheInternal(r),t=this._getParentIndex(t)}while(null!=t)}populateChildren(e,t){const i=this._getNodeDescriptor(e),s=this._getPage(e);i.childOffset=s.children.length,i.childCount=t.length;for(let n=0;n<t.length;n++){const i=this._makeRefNode(t[n],e);s.children.push(i)}}getNode(e){const t=this._getNodeDescriptor(e);return null!=t?t.node:null}getIndexById(e){let t;return this._forAllNodes((i,s)=>{(null!=i.node&&i.node.id===e||null!=i.nodeBoundingData&&i.nodeBoundingData.id===e)&&(t=s)}),t}getNodeById(e){const t=this.getIndexById(e);return null!=t&&t>=0?this.getNode(t):null}getChildIndex(e,t){const i=this._getPage(e);if(null==i)return-1;const s=i.nodes[I(e,this._pageSize)];return i.children[s.childOffset+t]}_getParentIndex(e){const t=this._getPage(e);return null!=t&&e!==this._rootIndex?t.nodes[I(e,this._pageSize)]?.parentIndex:null}getParent(e){const t=this._getParentIndex(e);return null!=t?this.getNode(t):null}isLeaf(e){const t=this._getNodeDescriptor(e);return null!=t&&0===t.childCount}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes(e=>{null!=e.node&&(e.node.geometryObbInRenderSR=null)})}invalidateVisibilityCache(){this._visibilityCacheVersion=p(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){const t=this._getNodeDescriptor(e);null!=t&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=v(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){const t=this._getNodeDescriptor(e);null!=t&&(t?.invalidateBounds(),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){const t=this._getNodeDescriptor(e);if(null==t)return;if(!this.needNodeElevationRange)return void this.invalidateBoundingVolumeCache(e);const i=null!=t.node?t.node:t.nodeBoundingData;null!=i&&i.invalidateElevationRange()}invalidateGeometryVisibility(e){const t=this._getNodeDescriptor(e),i=t?.node;i&&(i.geometryObbInRenderSR=null,i.invalidateServiceBVsInRenderSR())}invalidateVisibilityObbs(){null!=this.rootNode&&this.traverse(this.rootNode,e=>(e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.geometryObbInRenderSR=null,!0))}_isElevationRangeUpToDate(e){if(!this.needNodeElevationRange)return!0;const t=e?.node??e?.nodeBoundingData;return!t||t.elevationRangeValid}_updateElevationRange(e,t){const i=this._getNodeDescriptor(e);if(!i)return!1;const s=i?.node??i?.nodeBoundingData;if(!s)return!1;if(s.elevationRangeValid)return t?.expandElevationRange(s),!0;const n=new h;let o=!1;for(let a=0;a<i.childCount;a++){const t=this.getChildIndex(e,a),i=this._updateElevationRange(t,n);o=o||!i}if(0===i.childCount||o){const e=!i.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(s,e,n)}n.minElevation!==1/0&&n.maxElevation!==-1/0||n.expandElevationRangeValues(0,0);const{minElevation:r,maxElevation:d}=s;return r===n.minElevation&&d===n.maxElevation?(t?.expandElevationRange(s),!0):(i.node?.setElevationRange(n),i.nodeBoundingData?.setElevationRange(n),this.invalidateBoundingVolumeCache(e),t?.expandElevationRange(s),!0)}isNodeVisible(e){const t=this._getNodeDescriptor(e);if(null==t)return!0;const i=t.nodeBoundingData;if(null!=i&&!i.serviceMbsInIndexSR)return!0;if(this._isElevationRangeUpToDate(t)&&b(t.visibilityCache,this._visibilityCacheVersion))return y(t.visibilityCache);const s=t.node,n=this._viewportQueries;if(s){const e=n.ensureElevationAgnosticBoundingVolume(s),i=n.isElevationAgnosticBoundingVolumeVisible(e);let o=i;if(this.needNodeElevationRange&&i){const t=n.getNodeObbInRenderSRIndependentOfElevationOffset(s);null!=t&&(o=n.isObbVisibleIndependentOfElevation(e,t))}if(!o)return t.visibilityCache=N(!1,this._visibilityCacheVersion),!1}if(this._layerHasFilter&&this._computeNodeFiltering&&(null!=s||null!=i)&&2===t.filterImpact){const e=null!=s?s.serviceMbsInIndexSR:null!=i?i.serviceMbsInIndexSR:null;t.filterImpact=null!=e?this._computeNodeFiltering(e):0}const o=null!=s&&1===t.filterImpact;let r=!(null!=s&&2===s.imModificationImpact)&&!o;if(r){const t=!s||i&&!s.visibilityObbInRenderSR?i??null:s;if(null!=t){this.needNodeElevationRange&&this._updateElevationRange(e);r=n.isNodeVisible(t)}}return t.visibilityCache=N(r,this._visibilityCacheVersion),r}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;const t=this._getNodeDescriptor(e);return!!(null==t?.node?.geometryObbInRenderSR||this.layerHasModifications&&4===t.node.imModificationImpact)||this._viewportQueries.isGeometryVisible(t.node)}_traverseCoverage(e,t,i,s,n){const o=this._getPage(e);if(null==o||0===t.childCount)return;const r=t.childOffset+t.childCount,d=new Array;for(let a=t.childOffset;a<r;++a){const e=o.children[a],t=this._getNodeDescriptor(e);null!=t?.node&&this.isGeometryVisible(e)&&d.push(t)}s/=d.length;for(const a of d){const e=a.node.index;this._isLoaded(e)||this._isReloading(e)?(n.delta=Math.max(n.delta,i),n.coverage+=s):this._traverseCoverage(e,a,i+1,s,n)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const t=this._getNodeDescriptor(e);if(null==t)return!1;if("always"===this.holeFilling)return!0;if(b(t.useAsHole,this._version))return y(t.useAsHole);const i={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,i);const s=i.delta*i.coverage<=.5;return t.useAsHole=N(s,this._version),s}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=p(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes(({node:e})=>{null!=e&&(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(null!=e){e.filterImpact=2;const t=e.node;null!=t&&this.invalidateNodeVisibilityCache(t.index)}}),this.invalidateVisibilityCache()}update(e,t,i){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._invalidateElevationRangeForNewPages(t),this.resetUpdateState(e);let s=!0;const n=new w,o=new C,r=this._imModificationUncategorized;r.clear();const d=new Set;let a=0;const l=(d,l,h)=>{const u=e=>{this._shouldLoadNode(e)&&e.childCount&&(s=!1)};if(!l){const e=P(d,this._pageSize);let t=this._getNodeLoadPriority(d);return t===1/0&&(t=this._getNodeLoadPriority(h)),f.set(e,Math.max(t,f.get(e)||0)),this._loadingPages.has(e)||this._failedPages.has(e)||(this._missingPagesAndNodes.add(e),++a),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,t))}const{node:c,childCount:g}=l;if(this._updateNodeFeatureEstimate(c,o),!c){const e=this._getNodeLoadPriority(d);return this._loadingNodes.has(d)||this._failedNodes.has(d)||(this._missingPagesAndNodes.add(d),f.set(d,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const _=this._getPage(d);if(!this._useNodePages&&0===this._missingPagesAndNodes.size)for(let e=0;e<g;e++){const t=_.children[l.childOffset+e],i=this._getNodeDescriptor(t);null!=i&&!i.node&&!this._loadingNodes.has(t)&&!this._failedNodes.has(t)&&t>=0&&(f.set(t,this._getNodeLoadPriority(t)),this._prefetchNodes.add(t))}if(c.failed||c.resources.isEmpty)return void u(c);if(this._isLoaded(d)){if(n.known+=c.memory,++n.knownNodes,u(c),this._shouldLoadNode(c)||(n.unremoved+=c.memory),this._needsUpdate(c)){const e=this._getNodeLoadPriority(d);f.set(d,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(d)}return}if(c.memory&&(n.known+=c.memory,++n.knownNodes),!this._shouldLoadNode(c))return void(this._isReloading(d)&&this._updates.remove.push(d));if(u(c),c.memory?(n.missing+=c.memory,n.known+=c.memory,++n.knownNodes):++n.missingNodes,e.includes(c.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._getNodeLoadPriority(d)),void(this._updates.cancel=this._updates.cancel.filter(e=>e!==c.index));if(!t.done&&this._enable(c))return void t.madeProgress();const m=this._getNodeLoadPriority(d);f.set(d,m),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,m),this._updates.add.push(d),this.layerHasModifications&&i&&null!=c&&4===c.imModificationImpact&&r.push(d)};this.traverseVisible(l,d),this._frameNumber++,this._prioritizeMissingNodesAndPages(),this._removeUnusedNodePages(d,a),this._handleModifications(i,r),this._updateUnloadedMemoryEstimate(n),this._featureEstimate.estimate=this._computeFeatureEstimate(o),this._featureEstimate.leavesReached=s,this._updates.add.filterInPlace(e=>f.get(e)>=this._maxUnloadedPrio).sort((e,t)=>f.get(e)-f.get(t)),this._updates.update.sort((e,t)=>f.get(e)-f.get(t)),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.size,this._dirty=this._indexMissing>0,f.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=.8*Math.max(0,this._unloadedMemoryEstimate)}resetUpdateState(e){this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),f.clear()}_prioritizeMissingNodesAndPages(){const e=this._prioritizedMissingNodeAndPageIds;e.length=0,this._missingPagesAndNodes.forEach(t=>e.push(t)),e.sort((e,t)=>f.get(e)-f.get(t)),e.length>0&&(this._maxUnloadedPrio=f.get(e[e.length-1]),this._prefetchNodes.clear())}_handleModifications(e,t){this.layerHasModifications&&0!==this._updates.add.length&&(t.length>0&&e?.(t),this._updates.add.filterInPlace(e=>{const t=this._getNodeDescriptor(e),i=null==t?.node||2!==t.node.imModificationImpact;return i||this.invalidateNodeVisibilityCache(e),i}))}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let s=t,n=t,o=i,r=10;for(;r--;){const i=new C;this._updateFeatureEstimate(s,i);if(this._computeFeatureEstimate(i)<=e){if(s>=t||i.missingNodes>0||0===r)break;o=s,s=.5*(s+n)}else n=s,s=.5*(s+o)}return this._version=p(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,s)}_removeUnusedNodePages(e,t){if(!this._useNodePages)return;const i=e.size,s=this._nodePages,n=s.size+this._loadingPages.size+t;if(n>A&&n>i){const t=new Array;for(const[i,n]of s)0!==n.numNodesWithLoadedChildren||e.has(i)||t.push([n.lastTraversed,i]);t.sort((e,t)=>e[0]-t[0]).some(e=>{const t=e[1];return this._deleteNodePage(t),s.size<=A})}}_updateFeatureEstimate(e,t){this._version=p(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible((e,i)=>this._updateNodeFeatureEstimate(i?.node,t))}_updateNodeFeatureEstimate(e,t){null!=e&&!e.failed&&this._shouldLoadNode(e)&&(null!=e.numFeatures?(t.numFeatures+=e.numFeatures,++t.knownNodes):++t.missingNodes)}_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(){const e=this._prioritizedPrefetchNodes;return this._prefetchNodes.forEach(t=>e.push(t)),e.sort((e,t)=>f.get(e)-f.get(t)),this._load(e,this._prefetchNodes)}_load(e,t){if(0===e.length||!this._canRequest(this.urlPrefix))return!1;for(;e.length>0&&this._canRequest(this.urlPrefix);){const i=e[e.length-1];e.length--,t.delete(i),this._useNodePages&&i>=0?this._loadPage(i):this._loadNode(i)}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(null==e)return null;const t=e.index,i=this._getNodeDescriptor(t);if(!i)return null;let s=i?.traversalState;if(s&&b(s.version,this._version))return s;const n=this._viewportQueries.getLodLevel(e),o=this._viewportQueries.hasLOD(e);let d=!0;if(o){const e=this._getParentIndex(t);if(null!=e){const t=this._getNodeDescriptor(e),i=t?.traversalState;d=!!i&&n>i.lodLevel}else d=n>0}else d=0===e.childCount;return s?(s.lodLevel=n,s.isChosen=d,s.version=N(!0,this._version),s):(s=new r(o,d,n,N(!0,this._version)),i.traversalState=s,s)}_loadNode(e){if(this._loadingNodes.has(e))return void this._logger.error(`Node[${e}] already loading`);this._loadingNodes.add(e);const i=this._getNodeDescriptor(e);if(i.node)return void this._logger.error(`Node[${e}] already in descriptor`);const s=i.nodeBoundingData;if(null==s)return void this._failedNodes.add(e);const n=s.id,o=this.urlPrefix+n,r=()=>{this._loadingNodes.delete(e),0===this._missingPagesAndNodes.size&&0===this._loadingNodes.size&&this.requestUpdate()};(e>=0?this._requester.request(o,"json"):this._clientNodeLoader.loadNodeJSON(n)).catch(i=>{r(),t(i)||(this._logger.error("#loadNode()",this._layer,"Error loading node: "+o),this._failedNodes.add(e))}).then(t=>{r();const i=this._validateNode(n,t);if(null==i)return;i.obb&&this.invalidateNodeVisibilityCache(e);const s=this._addNode(i,e);this.nodeTraversalState(s)})}_validateNode(e,t){if(null==t||"object"!=typeof 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&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this._logger.warn("#validateNode()",this._layer,`Invalid shared resource href on node "${e}"`);const i=t.geometryData;null==i||Array.isArray(i)&&0===i.length||Array.isArray(i)&&1===i.length&&"./geometries/0"===i[0].href||this._logger.warn("#validateNode()",this._layer,`Invalid geometry data on node "${e}"`);const o=t.attributeData,r=this._layer.attributeStorageInfo;null==o||Array.isArray(o)&&!o.some((e,t)=>e.href!==`./attributes/${r?.[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.`);const d=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:void 0,a=1===t.featureData?.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,h=t=>{if(null==t)return null;const i=t=>this._logger.error("#validateNode()",this._layer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;const o=new n(`${t.id}`,new s(t.mbs));return o.serviceObbInIndexSR=!this.ignoreServiceObb&&t.hasOwnProperty("obb")&&t.obb?u.fromJSON(t.obb):null,o.visibilityObbInRenderSR=this._computeVisibilityObb(o),o},c=Array.isArray(t.children)?t.children.map(h).filter(e=>null!=e):null,g=t.featureData?.length??!1,_=!0===t.isEmpty;return new l(e,new s(t.mbs),d,"string"==typeof t.version?t.version:null,{isEmpty:!g&&_,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:null!=t.geometryData?e:void 0},c,Array.isArray(t.lodSelection)?t.lodSelection:null,a)}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes(e=>{null!=e.node&&(e.node.failed=!1)})}_getNodeLoadPriority(e){const t=this._getNodeDescriptor(e),i=this._getParentIndex(e);if(null==t||null==i&&null==t.node)return null==i?1/0:this._getNodeLoadPriority(i);let s=0;if(t.node&&null!=i){const e=this._getNodeDescriptor(i);s=e.traversalState?.lodLevel??0}const n=this._getHoleBonus(e);return-(this._viewportQueries.distToCameraPOIRay(t.nodeBoundingData??t.node)*(1+s)+s*this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI())+n}_getHoleBonus(e){return this._hasLoadedAncestor(e)?0:this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI()}_hasLoadedAncestor(e){let t=this._getParentIndex(e);for(;null!=t;){if(this._isLoaded(t))return!0;t=this._getParentIndex(t)}return!1}traverseVisible(e,t){const i=this._getNodeDescriptor(this._rootIndex);null!=i?this._traverseVisible(this._rootIndex,null,i,e,t):e(this._rootIndex,null,null)}_traverseVisible(e,t,i,s,n){const o=P(e,this._pageSize);if(n&&n.add(o),i.node&&0===i.childCount)return void(this.isGeometryVisible(e)&&s(e,i,t));if(!this.isNodeVisible(e))return;if(s(e,i,t),null==i.node)return;const r=this.nodeTraversalState(i.node);if(r?.nodeHasLOD&&r.lodLevel===this._maxLodLevel)return;const d=this._getPageFromPageIndex(o);for(let a=0;a<i.childCount;a++){const t=d.children[i.childOffset+a],o=this._getNodeDescriptor(t);if(o)this._traverseVisible(t,e,o,s,n);else{if(n){const e=P(t,this._pageSize);n.add(e)}s(t,null,e)}}}traverse(e,t){t(e)&&this.traverseDescendants(e,t)}traverseDescendants(e,t){++this._traverseDescendantsNestingLevel;const i=e.index,s=this._pageSize,n=P(i,s),o=this._getPageFromPageIndex(n);if(null==o)return;const r=this._frameNumber,d=this._nodePages,a=I(i,s),l=o.nodes[a],h=l.childCount;if(o.lastTraversed=r,0===h)return;const u=new Array,c=1===this._traverseDescendantsNestingLevel?this._traverseDescendantsQueue:[0];let g=0;{const{childOffset:e,childCount:t}=l,{children:i}=o;c.length=2**Math.ceil(Math.log2(g+t));for(let s=e;s<e+t;++s){const e=i[s];e>=0?(c[g]=e,++g):u.push(e)}}if(u.length>0){const e=this._clientNodePage;if(e){const i=e.children;let s=0;for(;s<u.length;){const n=u[s];++s;const o=-n-1,r=e.nodes[o],d=r.node;if(!d||!t(d))continue;const{childCount:a}=r;if(0===a)continue;const{childOffset:l}=r,h=l+a;for(let e=l;e<h;++e)u.push(i[e])}}}if(g>0){let e=0;if(s>0){let i=n*s,a=o,l=a.nodes;for(;e<g;){const n=c[e];let o;if(++e,i<=n&&n<i+s)o=a;else{const e=n/s|0,t=d.get(e);if(void 0===t)continue;o=t,o.lastTraversed=r,a=o,l=a.nodes,i=s*e}const h=l[n-i],u=h.node;if(null==u||!1===t(u))continue;const{childCount:_}=h;if(0===_)continue;const f=g+_;for(c.length<f&&(c.length=2**Math.ceil(Math.log2(g+_)));c.length<g+_;)c.length+=c.length;const m=o.children,{childOffset:v}=h,p=v+_;for(let e=v;e<p;++e)c[g]=m[e],++g}}else{const i=d.get(0);if(i)for(;e<g;){const s=c[e++],n=i.nodes[s],o=n.node;if(!o||!t(o))continue;const{childCount:r}=n;if(0===r)continue;c.length=Math.max(c.length,2**Math.ceil(Math.log2(g+r)));const d=i.children,{childOffset:a}=n,l=a+r;for(let e=a;e<l;++e)c[g]=d[e],++g}}}--this._traverseDescendantsNestingLevel}updateChildrenLoaded(e,t){let i=this.getNode(e);for(;null!=i;){const e=i.childrenLoaded,s=e+t;i.childrenLoaded=s;const n=0===e?1:0===s?-1:0,o=i.index;if(0!==n){this._getPage(o).numNodesWithLoadedChildren+=n}i=this.getParent(o)}}checkChildrenLoadedInvariant(){return!0}updateElevationInfo(e,t){this.needNodeElevationRange=t&&!!e&&("relative-to-ground"===e.mode||"relative-to-scene"===e.mode||"on-the-ground"===e.mode),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes(e=>{e?.invalidateBounds(),e.node?.invalidateElevationRange(),e.nodeBoundingData?.invalidateElevationRange()})}_forAllNodes(e){if(null!=this._clientNodePage){const t=this._clientNodePage;for(let i=0;i<t.nodes.length;i++)e(t.nodes[i],-(i+1))}for(const[t,i]of this._nodePages){const s=t*this._pageSize;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],s+t)}}clearCaches(){if(this._useNodePages){const e=this._nodePages,t=new Set;this.traverseVisible(e=>t.add(P(e,this._pageSize)));for(const[i,s]of e)if(0!==s.numNodesWithLoadedChildren||t.has(i))for(const e of s.nodes)e.traversalState=null;else this._deleteNodePage(i)}}_deleteNodePage(e){if(!this._nodePages.has(e))return void this._logger.error(`Destroying non-existent page ${e}`);const t=this._nodePages.get(e);this._nodePages.delete(e),t?.destroy()}get test(){}}const f=new Map;class m{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 v(e){return a(e,-2)}function p(e){return a(e,2)}function N(e,t){return t+(e?1:0)}function b(e,t){return(-2&e)===t}function y(e){return!(1&~e)}function P(e,t){return e<0?-1:t>0?e/t|0:0}function I(e,t){return e<0?-e-1:0===t?e:e%t}function x(e,t,i){return-1===t?-(e+1):0===i?e:t*i+e}const S=[["maxScreenThreshold",1],["screenSpaceRelative",2],["removedFeatureDiameter",3],["distanceRangeFromDefaultCamera",4]];function R(e){if(e)for(let t=0;t<e.length;t++)for(const i of S)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:0,maxError:0}}class w{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}class C{constructor(){this.numFeatures=0,this.knownNodes=0,this.missingNodes=0}}function E(e){return Math.sqrt(e*(4/Math.PI))}const D=new s,M=new s,V=new s,A=has("esri-mobile")?100:300;export{_ as I3SIndex,R as selectErrorMetric};
5
+ import has from"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{isAbortError as t}from"../../../../core/promiseUtils.js";import{projectBoundingSphere as i}from"../../../../geometry/projection/projectBoundingSphere.js";import{Sphere as s}from"../../../../geometry/support/sphere.js";import{NodeBoundingData as n,Node as o,NodeTraversalState as r}from"./I3SNode.js";import{addWraparound as d}from"./I3SUtil.js";import{ValidatedNode as a}from"./ValidatedNode.js";import{ElevationRange as l}from"../../support/ElevationRange.js";import{Obb as h}from"../../support/orientedBoundingBox.js";class u{constructor(e,t,i,s,n){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this._boundingData=s,this.node=n,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 c{constructor(e=new Array,t=new Array){this._nodeDescriptors=e,this._children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}destroy(){for(const 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 g{get _useNodePages(){return this._pageSize>0}constructor(t,i,s,o,r,d,a,l,h,u,g,_,m,p,N){if(this.viewingMode=t,this._layer=i,this._requester=o,this._clientNodeLoader=r,this._viewportQueries=d,this._logger=a,this.holeFilling=l,this._isLoaded=h,this._isReloading=u,this._shouldLoadNode=g,this._enable=_,this._needsUpdate=m,this._computeVisibilityObb=p,this._computeNodeFiltering=N,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=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,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=new Array,this._prefetchNodes=new Set,this._prioritizedPrefetchNodes=new Array,this._updates=new f(this._missingPagesAndNodes),this._imModificationUncategorized=new e({deallocator:null}),this.ignoreServiceObb=!1,this._pageQueue=new Array,this._newPages=new Array,this.needNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._traverseDescendantsQueue=[0],this._traverseDescendantsNestingLevel=0,this._isEditable=null!=i.associatedLayer?.infoFor3D,i.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${i.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,"page"===s.type){const e=s.rootPage;switch(this.urlPrefix=s.urlPrefix,this._pageSize=s.pageSize,s.lodMetric){case"maxScreenThreshold":this._lodMetric=1;break;case"maxScreenThresholdSQ":this._lodMetric=1,this._lodConversion=C}if(this._isEditable){this._rootIndex=-1;const t=P(s.rootIndex,s.pageSize),i=e.nodes[t],n={nodes:[{index:this._rootIndex,children:[s.rootIndex],mesh:void 0,obb:i.obb,lodThreshold:i.lodThreshold}]};this._addPage(y(this._rootIndex,this._pageSize),n),this.getNode(-1).serviceObbInIndexSR=void 0}else this._rootIndex=s.rootIndex;this._addPage(y(s.rootIndex,this._pageSize),e),this._updateParentsAndLevel()}else if("node"===s.type){this.urlPrefix=s.urlPrefix;const e=new c;if(this._nodePages.set(0,e),this._isEditable){this._clientNodePage=new c;const e={id:"-1",version:null,mbs:s.rootNode.mbs,obb:s.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:"root",href:"../root",mbs:s.rootNode.mbs,obb:s.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new n(e.id),-1);const t=this._validateNode(e.id,e);t&&this._addNode(t,this._rootIndex)}else this._rootIndex=this._makeRefNode(new n(s.rootNode.id),-1);const t=this._validateNode(s.rootNode.id,s.rootNode);t&&this._addNode(t,0)}}addClientNodeToIndex(e,t){const i=-1,s=new n(e,t),o=this._makeClientRefNode(s,i);return this._linkChildToParentNode(i,o),this.requestUpdate(),o}removeClientNodeFromIndex(e,t,i){this._destroyClientRefNode(e,t,i),this.requestUpdate()}_canRequest(e){return!this._requester.isFull(e)}_loadPage(e){if(this._nodePages.has(e))return void this._logger.error(`Requested load page [${e}] already loaded`);if(this._loadingPages.has(e))return void this._logger.error(`Requested load page [${e}] already loading`);this._loadingPages.add(e);const i=this.urlPrefix+e;this._requester.request(i,"json").then(t=>{this._nodePages.has(e)?this._logger.error(`Queued page [${e}] already loaded`):this._pageQueue.push({pageIndex:e,page:t})}).catch(i=>{this._loadingPages.delete(e),t(i)||(this._failedPages.add(e),this._logger.error("#loadPage()",this._layer,`Error when loading page ${e}`,i))})}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){const{pageIndex:t,page:i}=this._pageQueue.shift();this._addPage(t,i),this._loadingPages.delete(t),e.madeProgress(),this.needNodeElevationRange&&this._newPages.push(t)}this._updateParentsAndLevel()}_invalidateElevationRangeForNewPages(e){if(this.needNodeElevationRange)for(;this._newPages.length>0&&!e.done;){const e=this._nodePages.get(this._newPages.shift());e?.nodes.forEach(e=>{let t=e.parentIndex;for(;null!=t&&t!==this._rootIndex;){const e=this.getNode(t);e?.elevationRangeValid&&(e.invalidateElevationRange(),this.invalidateBoundingVolumeCache(t)),t=this._getParentIndex(t)}})}}_addPage(e,t){if(this._nodePages.has(e))return void this._logger.error(`Page[${e}] reloaded`);const i=[],n=[],r=t.nodes.map((t,r)=>{const d=i.length,a=t.children?t.children.length:0;n.push(this._rootIndex);for(let e=0;e<a;e++)i.push(t.children[e]);const l=`${t.index}`,c=h.fromJSON(t.obb),g=new s(c.center,c.radius),_=t.mesh?.attribute,f=t.mesh?.geometry,v=t.mesh?.material,p={hasSharedResource:!1,isEmpty:null==f,attributes:null!=_?.resource?`${_.resource}`:void 0,geometry:null!=f?.resource?`${f.resource}`:void 0,texture:null!=v?.resource?`${v.resource}`:void 0,geometryDefinition:f?f.definition:-1,materialDefinition:v?v.definition:-1},N=new o(l,I(r,e,this._pageSize),g,a,0,p,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),f?.featureCount??null);return N.serviceObbInIndexSR=c,N.visibilityObbInRenderSR=this._computeVisibilityObb(N),N.vertexCount=f?f.vertexCount:0,new u(d,a,m(this._visibilityCacheVersion),null,N)}),d=new c(r,i);-1===e?this._clientNodePage=d:this._nodePages.set(e,d)}_updateParentsAndLevel(){const e=new Array,t=(t,i,s)=>{const n=this._getPage(t);if(null!=n){const o=P(t,this._pageSize),r=n.nodes[o];r.parentIndex=null!=i?i:-1;const d=r.node;null!=d&&(d.level=s,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){const i=e.pop(),s=this.getNode(i);if(null!=s)for(let e=0;e<s.childCount;e++){t(this.getChildIndex(s.index,e),i,s.level+1),this._maxLevel=Math.max(this._maxLevel,s.level+1)}}}_getPage(e){const t=y(e,this._pageSize);return this._getPageFromPageIndex(t)}_getPageFromPageIndex(e){return e<0?this._clientNodePage:this._nodePages.get(e)}_getNodeDescriptor(e){const t=this._getPage(e);return null==t?null:(t.lastTraversed=this._frameNumber,t.nodes[P(e,this._pageSize)])}_addNode(e,t){e.children&&this.populateChildren(t,e.children);const i=this.getParent(t),s=null!=i?i.level+1:0;this._maxLevel=Math.max(this._maxLevel,e.children?s+1:s);const{lodMetric:n,maxError:r}=S(e.lodSelection),d=this._getNodeDescriptor(t);if(null!=d.node)return this._logger.error(`Loaded node[${t}] already in descriptor`),d.node;const a=new o(e.id,t,e.mbs,d.childCount,s,e.resources,e.version,n,r,e.numFeatures);d.node=a,e.obb&&(a.serviceObbInIndexSR=h.fromJSON(e.obb)),a.visibilityObbInRenderSR=this._computeVisibilityObb(a);const l=d.nodeBoundingData;return null!=l&&(null==l.serviceMbsInIndexSR&&(l.serviceMbsInIndexSR=e.mbs),a.shareServiceBVsInRenderSRWith(l),l.visibilityObbInRenderSR=a.visibilityObbInRenderSR),a}_makeRefNode(e,t){const i=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(null==i)return-1;const s=i.nodes.length,n=new u(0,0,m(this._visibilityCacheVersion),e,null);return i.addNode(n),n.parentIndex=t,e.invalidateServiceBVsInRenderSR(),s}_makeClientRefNode(e,t){const i=this._clientNodePage;if(null==i)return-1;if(t>=0)throw new Error("I3SIndex::client side nodes can not be made children of service side nodes.");const s=-(i.nodes.length+1),n=new u(0,0,m(this._visibilityCacheVersion),e,null);return i.addNode(n),n.parentIndex=t,e.invalidateServiceBVsInRenderSR(),s}_linkChildToParentNode(e,t){const i=this._clientNodePage;if(null==i||e>=0)return;const s=P(e,this._pageSize),n=P(t,this._pageSize),o=i.nodes[s],r=o.childOffset;i.children.splice(o.childOffset+o.childCount,0,t);const d=1;o.childCount+=d,null!=o.node&&(o.node.childCount+=d);for(const a of i.nodes)a.childOffset>r&&(a.childOffset+=d);i.nodes[n].parentIndex=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,i){const s=this._clientNodePage;if(null==s)return;const n=this._getParentIndex(e);if(null==n)return;const o=new Set,r=new Map,d=e=>{const i=P(e,this._pageSize),n=s.nodes[i];if(n.childCount>0)for(let t=n.childOffset;t<n.childOffset+n.childCount;++t)d(s.children[t]);const r=n.node?.id??n.nodeBoundingData?.id;if(null==r)throw new Error("Node has no id");t(r,e),o.add(n)};d(e);const a=s.nodes,l=s.children,h=s.nodes.map(()=>-1),u=[],c=[];for(let g=0;g<a.length;++g){const e=a[g];if(o.has(e))continue;const t=u.length,s=I(g,-1,this._pageSize),n=I(t,-1,this._pageSize);if(e.node&&(e.node.index=n),h[g]=n,u.push(e),s!==n){const t=e.node?.id??e.nodeBoundingData?.id;if(null==t)throw new Error("Node has no id");i(t,s,n),r.set(s,n)}}for(let g=0;g<u.length;++g){const e=I(g,-1,this._pageSize),t=u[g],i=c.length;for(let s=t.childOffset;s<t.childOffset+t.childCount;++s){const t=l[s];if(t>=0)c.push(t);else{const i=P(t,this._pageSize),s=a[i];if(o.has(s))continue;const n=h[i];c.push(n),s.parentIndex=e}}t.childOffset=i,t.childCount=c.length-i,t.node&&(t.node.childCount=t.childCount)}s.setNodes(u,c),this._updateParentBoundingInformation(h[P(n,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null;const n=this._clientNodeLoader.indexSR,o=this._clientNodeLoader.renderSR,r=this._getNodeDescriptor(t);if(null==r)return;for(let s=0;s<r.childCount;s++){const r=this.getChildIndex(t,s),d=this._getNodeDescriptor(r),a=null!=d?d.nodeBoundingData||d.node:null;if(null!=a?.serviceMbsInIndexSR&&a.serviceMbsInIndexSR.radius>0)if(null==e)e=E.copyFrom(a.serviceMbsInIndexSR);else{const t=D;i(a.serviceMbsInIndexSR,n,t,o);const s=M;i(e,n,s,o),i(t.union(s),o,e,n)}}const d=t=>{null!=t&&(t.serviceObbInIndexSR=null,null!=e?(t.serviceMbsInIndexSR??=new s,t.serviceMbsInIndexSR.copyFrom(e)):t.serviceMbsInIndexSR?.invalidate(),t.invalidateServiceBVsInRenderSR(),t.geometryObbInRenderSR=null)};d(r.nodeBoundingData),d(r.node),this.invalidateNodeVisibilityCacheInternal(r),t=this._getParentIndex(t)}while(null!=t)}populateChildren(e,t){const i=this._getNodeDescriptor(e),s=this._getPage(e);i.childOffset=s.children.length,i.childCount=t.length;for(let n=0;n<t.length;n++){const i=this._makeRefNode(t[n],e);s.children.push(i)}}getNode(e){const t=this._getNodeDescriptor(e);return null!=t?t.node:null}getIndexById(e){let t;return this._forAllNodes((i,s)=>{(null!=i.node&&i.node.id===e||null!=i.nodeBoundingData&&i.nodeBoundingData.id===e)&&(t=s)}),t}getNodeById(e){const t=this.getIndexById(e);return null!=t&&t>=0?this.getNode(t):null}getChildIndex(e,t){const i=this._getPage(e);if(null==i)return-1;const s=i.nodes[P(e,this._pageSize)];return i.children[s.childOffset+t]}_getParentIndex(e){const t=this._getPage(e);return null!=t&&e!==this._rootIndex?t.nodes[P(e,this._pageSize)]?.parentIndex:null}getParent(e){const t=this._getParentIndex(e);return null!=t?this.getNode(t):null}isLeaf(e){const t=this._getNodeDescriptor(e);return null!=t&&0===t.childCount}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes(e=>{null!=e.node&&(e.node.geometryObbInRenderSR=null)})}invalidateVisibilityCache(){this._visibilityCacheVersion=v(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){const t=this._getNodeDescriptor(e);null!=t&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=m(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){const t=this._getNodeDescriptor(e);null!=t&&(t?.invalidateBounds(),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){const t=this._getNodeDescriptor(e);if(null==t)return;if(!this.needNodeElevationRange)return void this.invalidateBoundingVolumeCache(e);const i=null!=t.node?t.node:t.nodeBoundingData;null!=i&&i.invalidateElevationRange()}invalidateGeometryVisibility(e){const t=this._getNodeDescriptor(e),i=t?.node;i&&(i.geometryObbInRenderSR=null,i.invalidateServiceBVsInRenderSR())}invalidateVisibilityObbs(){null!=this.rootNode&&this.traverse(this.rootNode,e=>(e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.geometryObbInRenderSR=null,!0))}_isElevationRangeUpToDate(e){if(!this.needNodeElevationRange)return!0;const t=e?.node??e?.nodeBoundingData;return!t||t.elevationRangeValid}_updateElevationRange(e,t){const i=this._getNodeDescriptor(e);if(!i)return!1;const s=i?.node??i?.nodeBoundingData;if(!s)return!1;if(s.elevationRangeValid)return t?.expandElevationRange(s),!0;const n=new l;let o=!1;for(let a=0;a<i.childCount;a++){const t=this.getChildIndex(e,a),i=this._updateElevationRange(t,n);o=o||!i}if(0===i.childCount||o){const e=!i.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(s,e,n)}n.minElevation!==1/0&&n.maxElevation!==-1/0||n.expandElevationRangeValues(0,0);const{minElevation:r,maxElevation:d}=s;return r===n.minElevation&&d===n.maxElevation?(t?.expandElevationRange(s),!0):(i.node?.setElevationRange(n),i.nodeBoundingData?.setElevationRange(n),this.invalidateBoundingVolumeCache(e),t?.expandElevationRange(s),!0)}isNodeVisible(e){const t=this._getNodeDescriptor(e);if(null==t)return!0;const i=t.nodeBoundingData;if(null!=i&&!i.serviceMbsInIndexSR)return!0;if(this._isElevationRangeUpToDate(t)&&N(t.visibilityCache,this._visibilityCacheVersion))return b(t.visibilityCache);const s=t.node,n=this._viewportQueries;if(s){const e=n.ensureElevationAgnosticBoundingVolume(s),i=n.isElevationAgnosticBoundingVolumeVisible(e);let o=i;if(this.needNodeElevationRange&&i){const t=n.getNodeObbInRenderSRIndependentOfElevationOffset(s);null!=t&&(o=n.isObbVisibleIndependentOfElevation(e,t))}if(!o)return t.visibilityCache=p(!1,this._visibilityCacheVersion),!1}if(this._layerHasFilter&&this._computeNodeFiltering&&(null!=s||null!=i)&&2===t.filterImpact){const e=null!=s?s.serviceMbsInIndexSR:null!=i?i.serviceMbsInIndexSR:null;t.filterImpact=null!=e?this._computeNodeFiltering(e):0}const o=null!=s&&1===t.filterImpact;let r=!(null!=s&&2===s.imModificationImpact)&&!o;if(r){const t=!s||i&&!s.visibilityObbInRenderSR?i??null:s;if(null!=t){this.needNodeElevationRange&&this._updateElevationRange(e);r=n.isNodeVisible(t)}}return t.visibilityCache=p(r,this._visibilityCacheVersion),r}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;const t=this._getNodeDescriptor(e);return!!(null==t?.node?.geometryObbInRenderSR||this.layerHasModifications&&4===t.node.imModificationImpact)||this._viewportQueries.isGeometryVisible(t.node)}_traverseCoverage(e,t,i,s,n){const o=this._getPage(e);if(null==o||0===t.childCount)return;const r=t.childOffset+t.childCount,d=new Array;for(let a=t.childOffset;a<r;++a){const e=o.children[a],t=this._getNodeDescriptor(e);null!=t?.node&&this.isGeometryVisible(e)&&d.push(t)}s/=d.length;for(const a of d){const e=a.node.index;this._isLoaded(e)||this._isReloading(e)?(n.delta=Math.max(n.delta,i),n.coverage+=s):this._traverseCoverage(e,a,i+1,s,n)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const t=this._getNodeDescriptor(e);if(null==t)return!1;if("always"===this.holeFilling)return!0;if(N(t.useAsHole,this._version))return b(t.useAsHole);const i={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,i);const s=i.delta*i.coverage<=.5;return t.useAsHole=p(s,this._version),s}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})=>{null!=e&&(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(null!=e){e.filterImpact=2;const t=e.node;null!=t&&this.invalidateNodeVisibilityCache(t.index)}}),this.invalidateVisibilityCache()}update(e,t,i){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._invalidateElevationRangeForNewPages(t),this.resetUpdateState(e);let s=!0;const n=new R,o=new w,r=this._imModificationUncategorized;r.clear();const d=new Set;let a=0;const l=(d,l,h)=>{const u=e=>{this._shouldLoadNode(e)&&e.childCount&&(s=!1)};if(!l){const e=y(d,this._pageSize);let t=this._getNodeLoadPriority(d);return t===1/0&&(t=this._getNodeLoadPriority(h)),_.set(e,Math.max(t,_.get(e)||0)),this._loadingPages.has(e)||this._failedPages.has(e)||(this._missingPagesAndNodes.add(e),++a),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,t))}const{node:c,childCount:g}=l;if(this._updateNodeFeatureEstimate(c,o),!c){const e=this._getNodeLoadPriority(d);return this._loadingNodes.has(d)||this._failedNodes.has(d)||(this._missingPagesAndNodes.add(d),_.set(d,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const f=this._getPage(d);if(!this._useNodePages&&0===this._missingPagesAndNodes.size)for(let e=0;e<g;e++){const t=f.children[l.childOffset+e],i=this._getNodeDescriptor(t);null!=i&&!i.node&&!this._loadingNodes.has(t)&&!this._failedNodes.has(t)&&t>=0&&(_.set(t,this._getNodeLoadPriority(t)),this._prefetchNodes.add(t))}if(c.failed||c.resources.isEmpty)return void u(c);if(this._isLoaded(d)){if(n.known+=c.memory,++n.knownNodes,u(c),this._shouldLoadNode(c)||(n.unremoved+=c.memory),this._needsUpdate(c)){const e=this._getNodeLoadPriority(d);_.set(d,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(d)}return}if(c.memory&&(n.known+=c.memory,++n.knownNodes),!this._shouldLoadNode(c))return void(this._isReloading(d)&&this._updates.remove.push(d));if(u(c),c.memory?(n.missing+=c.memory,n.known+=c.memory,++n.knownNodes):++n.missingNodes,e.includes(c.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._getNodeLoadPriority(d)),void(this._updates.cancel=this._updates.cancel.filter(e=>e!==c.index));if(!t.done&&this._enable(c))return void t.madeProgress();const m=this._getNodeLoadPriority(d);_.set(d,m),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,m),this._updates.add.push(d),this.layerHasModifications&&i&&null!=c&&4===c.imModificationImpact&&r.push(d)};this.traverseVisible(l,d),this._frameNumber++,this._prioritizeMissingNodesAndPages(),this._removeUnusedNodePages(d,a),this._handleModifications(i,r),this._updateUnloadedMemoryEstimate(n),this._featureEstimate.estimate=this._computeFeatureEstimate(o),this._featureEstimate.leavesReached=s,this._updates.add.filterInPlace(e=>_.get(e)>=this._maxUnloadedPrio).sort((e,t)=>_.get(e)-_.get(t)),this._updates.update.sort((e,t)=>_.get(e)-_.get(t)),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.size,this._dirty=this._indexMissing>0,_.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=.8*Math.max(0,this._unloadedMemoryEstimate)}resetUpdateState(e){this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),_.clear()}_prioritizeMissingNodesAndPages(){const e=this._prioritizedMissingNodeAndPageIds;e.length=0,this._missingPagesAndNodes.forEach(t=>e.push(t)),e.sort((e,t)=>_.get(e)-_.get(t)),e.length>0&&(this._maxUnloadedPrio=_.get(e[e.length-1]),this._prefetchNodes.clear())}_handleModifications(e,t){this.layerHasModifications&&0!==this._updates.add.length&&(t.length>0&&e?.(t),this._updates.add.filterInPlace(e=>{const t=this._getNodeDescriptor(e),i=null==t?.node||2!==t.node.imModificationImpact;return i||this.invalidateNodeVisibilityCache(e),i}))}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let s=t,n=t,o=i,r=10;for(;r--;){const i=new w;this._updateFeatureEstimate(s,i);if(this._computeFeatureEstimate(i)<=e){if(s>=t||i.missingNodes>0||0===r)break;o=s,s=.5*(s+n)}else n=s,s=.5*(s+o)}return this._version=v(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,s)}_removeUnusedNodePages(e,t){if(!this._useNodePages)return;const i=e.size,s=this._nodePages,n=s.size+this._loadingPages.size+t;if(n>V&&n>i){const t=new Array;for(const[i,n]of s)0!==n.numNodesWithLoadedChildren||e.has(i)||t.push([n.lastTraversed,i]);t.sort((e,t)=>e[0]-t[0]).some(e=>{const t=e[1];return this._deleteNodePage(t),s.size<=V})}}_updateFeatureEstimate(e,t){this._version=v(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible((e,i)=>this._updateNodeFeatureEstimate(i?.node,t))}_updateNodeFeatureEstimate(e,t){null!=e&&!e.failed&&this._shouldLoadNode(e)&&(null!=e.numFeatures?(t.numFeatures+=e.numFeatures,++t.knownNodes):++t.missingNodes)}_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(){const e=this._prioritizedPrefetchNodes;return this._prefetchNodes.forEach(t=>e.push(t)),e.sort((e,t)=>_.get(e)-_.get(t)),this._load(e,this._prefetchNodes)}_load(e,t){if(0===e.length||!this._canRequest(this.urlPrefix))return!1;for(;e.length>0&&this._canRequest(this.urlPrefix);){const i=e[e.length-1];e.length--,t.delete(i),this._useNodePages&&i>=0?this._loadPage(i):this._loadNode(i)}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(null==e)return null;const t=e.index,i=this._getNodeDescriptor(t);if(!i)return null;let s=i?.traversalState;if(s&&N(s.version,this._version))return s;const n=this._viewportQueries.getLodLevel(e),o=this._viewportQueries.hasLOD(e);let d=!0;if(o){const e=this._getParentIndex(t);if(null!=e){const t=this._getNodeDescriptor(e),i=t?.traversalState;d=!!i&&n>i.lodLevel}else d=n>0}else d=0===e.childCount;return s?(s.lodLevel=n,s.isChosen=d,s.version=p(!0,this._version),s):(s=new r(o,d,n,p(!0,this._version)),i.traversalState=s,s)}_loadNode(e){if(this._loadingNodes.has(e))return void this._logger.error(`Node[${e}] already loading`);this._loadingNodes.add(e);const i=this._getNodeDescriptor(e);if(i.node)return void this._logger.error(`Node[${e}] already in descriptor`);const s=i.nodeBoundingData;if(null==s)return void this._failedNodes.add(e);const n=s.id,o=this.urlPrefix+n,r=()=>{this._loadingNodes.delete(e),0===this._missingPagesAndNodes.size&&0===this._loadingNodes.size&&this.requestUpdate()};(e>=0?this._requester.request(o,"json"):this._clientNodeLoader.loadNodeJSON(n)).catch(i=>{r(),t(i)||(this._logger.error("#loadNode()",this._layer,"Error loading node: "+o),this._failedNodes.add(e))}).then(t=>{r();const i=this._validateNode(n,t);if(null==i)return;i.obb&&this.invalidateNodeVisibilityCache(e);const s=this._addNode(i,e);this.nodeTraversalState(s)})}_validateNode(e,t){if(null==t||"object"!=typeof 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&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this._logger.warn("#validateNode()",this._layer,`Invalid shared resource href on node "${e}"`);const i=t.geometryData;null==i||Array.isArray(i)&&0===i.length||Array.isArray(i)&&1===i.length&&"./geometries/0"===i[0].href||this._logger.warn("#validateNode()",this._layer,`Invalid geometry data on node "${e}"`);const o=t.attributeData,r=this._layer.attributeStorageInfo;null==o||Array.isArray(o)&&!o.some((e,t)=>e.href!==`./attributes/${r?.[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.`);const d=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:void 0,l=1===t.featureData?.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,u=t=>{if(null==t)return null;const i=t=>this._logger.error("#validateNode()",this._layer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;const o=new n(`${t.id}`,new s(t.mbs));return o.serviceObbInIndexSR=!this.ignoreServiceObb&&t.hasOwnProperty("obb")&&t.obb?h.fromJSON(t.obb):null,o.visibilityObbInRenderSR=this._computeVisibilityObb(o),o},c=Array.isArray(t.children)?t.children.map(u).filter(e=>null!=e):null,g=t.featureData?.length??!1,_=!0===t.isEmpty;return new a(e,new s(t.mbs),d,"string"==typeof t.version?t.version:null,{isEmpty:!g&&_,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:null!=t.geometryData?e:void 0},c,Array.isArray(t.lodSelection)?t.lodSelection:null,l)}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes(e=>{null!=e.node&&(e.node.failed=!1)})}_getNodeLoadPriority(e){const t=this._getNodeDescriptor(e),i=this._getParentIndex(e);if(null==t||null==i&&null==t.node)return null==i?1/0:this._getNodeLoadPriority(i);let s=0;if(t.node&&null!=i){const e=this._getNodeDescriptor(i);s=e.traversalState?.lodLevel??0}const n=this._getHoleBonus(e);return-(this._viewportQueries.distToCameraPOIRay(t.nodeBoundingData??t.node)*(1+s)+s*this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI())+n}_getHoleBonus(e){return this._hasLoadedAncestor(e)?0:this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI()}_hasLoadedAncestor(e){let t=this._getParentIndex(e);for(;null!=t;){if(this._isLoaded(t))return!0;t=this._getParentIndex(t)}return!1}traverseVisible(e,t){const i=this._getNodeDescriptor(this._rootIndex);null!=i?this._traverseVisible(this._rootIndex,null,i,e,t):e(this._rootIndex,null,null)}_traverseVisible(e,t,i,s,n){const o=y(e,this._pageSize);if(n&&n.add(o),i.node&&0===i.childCount)return void(this.isGeometryVisible(e)&&s(e,i,t));if(!this.isNodeVisible(e))return;if(s(e,i,t),null==i.node)return;const r=this.nodeTraversalState(i.node);if(r?.nodeHasLOD&&r.lodLevel===this._maxLodLevel)return;const d=this._getPageFromPageIndex(o);for(let a=0;a<i.childCount;a++){const t=d.children[i.childOffset+a],o=this._getNodeDescriptor(t);if(o)this._traverseVisible(t,e,o,s,n);else{if(n){const e=y(t,this._pageSize);n.add(e)}s(t,null,e)}}}traverse(e,t){t(e)&&this.traverseDescendants(e,t)}traverseDescendants(e,t){++this._traverseDescendantsNestingLevel;const i=e.index,s=this._pageSize,n=y(i,s),o=this._getPageFromPageIndex(n);if(null==o)return;const r=this._frameNumber,d=this._nodePages,a=P(i,s),l=o.nodes[a],h=l.childCount;if(o.lastTraversed=r,0===h)return;const u=new Array,c=1===this._traverseDescendantsNestingLevel?this._traverseDescendantsQueue:[0];let g=0;{const{childOffset:e,childCount:t}=l,{children:i}=o;c.length=2**Math.ceil(Math.log2(g+t));for(let s=e;s<e+t;++s){const e=i[s];e>=0?(c[g]=e,++g):u.push(e)}}if(u.length>0){const e=this._clientNodePage;if(e){const i=e.children;let s=0;for(;s<u.length;){const n=u[s];++s;const o=-n-1,r=e.nodes[o],d=r.node;if(!d||!t(d))continue;const{childCount:a}=r;if(0===a)continue;const{childOffset:l}=r,h=l+a;for(let e=l;e<h;++e)u.push(i[e])}}}if(g>0){let e=0;if(s>0){let i=n*s,a=o,l=a.nodes;for(;e<g;){const n=c[e];let o;if(++e,i<=n&&n<i+s)o=a;else{const e=n/s|0,t=d.get(e);if(void 0===t)continue;o=t,o.lastTraversed=r,a=o,l=a.nodes,i=s*e}const h=l[n-i],u=h.node;if(null==u||!1===t(u))continue;const{childCount:_}=h;if(0===_)continue;const f=g+_;for(c.length<f&&(c.length=2**Math.ceil(Math.log2(g+_)));c.length<g+_;)c.length+=c.length;const m=o.children,{childOffset:v}=h,p=v+_;for(let e=v;e<p;++e)c[g]=m[e],++g}}else{const i=d.get(0);if(i)for(;e<g;){const s=c[e++],n=i.nodes[s],o=n.node;if(!o||!t(o))continue;const{childCount:r}=n;if(0===r)continue;c.length=Math.max(c.length,2**Math.ceil(Math.log2(g+r)));const d=i.children,{childOffset:a}=n,l=a+r;for(let e=a;e<l;++e)c[g]=d[e],++g}}}--this._traverseDescendantsNestingLevel}updateChildrenLoaded(e,t){let i=this.getNode(e);for(;null!=i;){const e=i.childrenLoaded,s=e+t;i.childrenLoaded=s;const n=0===e?1:0===s?-1:0,o=i.index;if(0!==n){this._getPage(o).numNodesWithLoadedChildren+=n}i=this.getParent(o)}}checkChildrenLoadedInvariant(){return!0}updateElevationInfo(e,t){this.needNodeElevationRange=t&&!!e&&("relative-to-ground"===e.mode||"relative-to-scene"===e.mode||"on-the-ground"===e.mode),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes(e=>{e?.invalidateBounds(),e.node?.invalidateElevationRange(),e.nodeBoundingData?.invalidateElevationRange()})}_forAllNodes(e){if(null!=this._clientNodePage){const t=this._clientNodePage;for(let i=0;i<t.nodes.length;i++)e(t.nodes[i],-(i+1))}for(const[t,i]of this._nodePages){const s=t*this._pageSize;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],s+t)}}clearCaches(){if(this._useNodePages){const e=this._nodePages,t=new Set;this.traverseVisible(e=>t.add(y(e,this._pageSize)));for(const[i,s]of e)if(0!==s.numNodesWithLoadedChildren||t.has(i))for(const e of s.nodes)e.traversalState=null;else this._deleteNodePage(i)}}_deleteNodePage(e){if(!this._nodePages.has(e))return void this._logger.error(`Destroying non-existent page ${e}`);const t=this._nodePages.get(e);this._nodePages.delete(e),t?.destroy()}get test(){}}const _=new Map;class f{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 m(e){return d(e,-2)}function v(e){return d(e,2)}function p(e,t){return t+(e?1:0)}function N(e,t){return(-2&e)===t}function b(e){return!(1&~e)}function y(e,t){return e<0?-1:t>0?e/t|0:0}function P(e,t){return e<0?-e-1:0===t?e:e%t}function I(e,t,i){return-1===t?-(e+1):0===i?e:t*i+e}const x=[["maxScreenThreshold",1],["screenSpaceRelative",2],["removedFeatureDiameter",3],["distanceRangeFromDefaultCamera",4]];function S(e){if(e)for(let t=0;t<e.length;t++)for(const i of x)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:0,maxError:0}}class R{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}class w{constructor(){this.numFeatures=0,this.knownNodes=0,this.missingNodes=0}}function C(e){return Math.sqrt(e*(4/Math.PI))}const E=new s,D=new s,M=new s,V=has("esri-mobile")?100:300;export{g as I3SIndex,S as selectErrorMetric};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{isValidMbs as e}from"./I3SUtil.js";import{I3sTarget as t}from"./Intersector.js";import{IntersectorResult as n}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as i}from"../../webgl-engine/lib/RayIntersections.js";import{getVerticalOffsetI3S as r}from"../../webgl-engine/lib/verticalOffsetUtils.js";class s{constructor(e){this.type=2,this._needVerticalOffset=!1,this.layerViewUid=e.layerViewUid,this.sublayerId=e.sublayerId,this._collection=e.collection,this._traverseNodeHierarchy=e.traverseNodeHierarchy,this.slicePlaneEnabled=e.slicePlaneEnabled,this.isGround=e.isGround}updateElevationAlignState(e,t){this._needVerticalOffset=e&&1===t}intersect(s,o,c,a,d,u){const b=2===s.options.store,f=s.ray.direction;let h=e=>e,y=e=>e;const m=r(s.verticalOffset??(this._needVerticalOffset?0:null));null!=s.verticalOffset&&null!=m&&(h=e=>m.applyToMbs(e),y=e=>m.applyToObb(e));const{results:p,tolerance:R}=s,I=new i(R,u,s.options.normalRequired),g=(i,r)=>{if(0===i.childrenLoaded)return!1;const d=i.serviceObbInRenderSR?.isValid?i.serviceObbInRenderSR:null;return!(d&&!y(d).intersectRay(c,f,R))&&(!r||!d&&e(i.serviceMbsInRenderSR)&&!l(h(i.serviceMbsInRenderSR),c,f,R)||null!=i.geometryObbInRenderSR&&!y(i.geometryObbInRenderSR).intersectRay(c,f,R)||this._collection.intersect(r,c,a,m,I,(e,r,l,d)=>{if(r<0||null!=o&&!o(c,a,r))return;const u=n=>{const s=new t(this.layerViewUid,this.sublayerId,i.index,e,d);n.set(this.type,s,r,l)};if(this.isGround&&(null==p.ground.distance||r<p.ground.distance)&&u(p.ground),!s.options.isFiltered&&((null==p.min.distance||r<p.min.distance)&&u(p.min),(null==p.max.distance||r>p.max.distance)&&u(p.max),b)){const e=new n(s.ray);u(e),s.results.all.push(e)}}),!0)};this._traverseNodeHierarchy(g)}}function l(e,t,n,i=0){const r=e.radius+i,s=t[0]-e.center[0],l=t[1]-e.center[1],o=t[2]-e.center[2],[c,a,d]=n,u=c*s+a*l+d*o;return u*u-(c*c+a*a+d*d)*(s*s+l*l+o*o-r*r)>=0}export{s as I3SIntersectionHandler};
5
+ import{I3sTarget as e}from"./Intersector.js";import{IntersectorResult as t}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as n}from"../../webgl-engine/lib/RayIntersections.js";import{getVerticalOffsetI3S as i}from"../../webgl-engine/lib/verticalOffsetUtils.js";class r{constructor(e){this.type=2,this._needVerticalOffset=!1,this.layerViewUid=e.layerViewUid,this.sublayerId=e.sublayerId,this._collection=e.collection,this._traverseNodeHierarchy=e.traverseNodeHierarchy,this.slicePlaneEnabled=e.slicePlaneEnabled,this.isGround=e.isGround}updateElevationAlignState(e,t){this._needVerticalOffset=e&&1===t}intersect(r,l,o,c,a,d){const u=2===r.options.store,b=r.ray.direction;let h=e=>e,f=e=>e;const y=i(r.verticalOffset??(this._needVerticalOffset?0:null));null!=r.verticalOffset&&null!=y&&(h=e=>y.applyToMbs(e),f=e=>y.applyToObb(e));const{results:m,tolerance:R}=r,p=new n(R,d,r.options.normalRequired),g=(n,i)=>{if(0===n.childrenLoaded)return!1;const a=n.serviceObbInRenderSR?.isValid?n.serviceObbInRenderSR:null;return!(a&&!f(a).intersectRay(o,b,R))&&(!i||!a&&n.serviceMbsInRenderSR.isValid&&!s(h(n.serviceMbsInRenderSR),o,b,R)||null!=n.geometryObbInRenderSR&&!f(n.geometryObbInRenderSR).intersectRay(o,b,R)||this._collection.intersect(i,o,c,y,p,(i,s,a,d)=>{if(s<0||null!=l&&!l(o,c,s))return;const b=t=>{const r=new e(this.layerViewUid,this.sublayerId,n.index,i,d);t.set(this.type,r,s,a)};if(this.isGround&&(null==m.ground.distance||s<m.ground.distance)&&b(m.ground),!r.options.isFiltered&&((null==m.min.distance||s<m.min.distance)&&b(m.min),(null==m.max.distance||s>m.max.distance)&&b(m.max),u)){const e=new t(r.ray);b(e),r.results.all.push(e)}}),!0)};this._traverseNodeHierarchy(g)}}function s(e,t,n,i=0){const r=e.radius+i,s=t[0]-e.center[0],l=t[1]-e.center[1],o=t[2]-e.center[2],[c,a,d]=n,u=c*s+a*l+d*o;return u*u-(c*c+a*a+d*d)*(s*s+l*l+o*o-r*r)>=0}export{r as I3SIntersectionHandler};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{Sphere as e}from"../../../../geometry/support/sphere.js";import{invalidateMbs as t}from"./I3SUtil.js";import{ElevationRange as s}from"../../support/ElevationRange.js";class i extends s{constructor(t,s){super(NaN,NaN),this.id=t,this.serviceMbsInIndexSR=s,this.serviceMbsInRenderSR=new e(0,0,0,-1)}invalidateServiceBVsInRenderSR(){t(this.serviceMbsInRenderSR),this.serviceObbInRenderSR?.invalidate()}shareServiceBVsInRenderSRWith(e){this.serviceObbInRenderSR=e.serviceObbInRenderSR,this.serviceMbsInRenderSR=e.serviceMbsInRenderSR}}class r extends i{constructor(e,t,s,i,r,n,d,h,o,c){super(e,s),this.index=t,this.childCount=i,this.level=r,this.resources=n,this.version=d,this.lodMetric=h,this.maxError=o,this.numFeatures=c,this.failed=!1,this.cacheState=0,this.vertexCount=0,this.memory=0,this.childrenLoaded=0,this.hasModifications=!1,this.imModificationImpact=4,this.elevationAgnosticBoundingVolume=new a}invalidateServiceBVsInRenderSR(){super.invalidateServiceBVsInRenderSR(),this.elevationAgnosticBoundingVolume.invalidate()}}class n{constructor(e,t,s,i){this.nodeHasLOD=e,this.isChosen=t,this.lodLevel=s,this.version=i}}class a{constructor(){this._data=[0,0,0,-1]}invalidate(){this._data[3]=-1}get valid(){return-1!==this._data[3]}get radius(){return this._data[3]}getAxis(e){return e[0]=this._data[0],e[1]=this._data[1],e[2]=this._data[2],e}set(e,t){this._data[0]=e[0],this._data[1]=e[1],this._data[2]=e[2],this._data[3]=t}}export{a as ElevationAgnosticBoundingVolume,r as Node,i as NodeBoundingData,n as NodeTraversalState};
5
+ import{Sphere as e}from"../../../../geometry/support/sphere.js";import{ElevationRange as s}from"../../support/ElevationRange.js";class t extends s{constructor(s,t){super(NaN,NaN),this.id=s,this.serviceMbsInIndexSR=t,this._serviceMbsInRenderSR=new e(0,0,0,-1)}get serviceMbsInRenderSR(){return this._serviceMbsInRenderSR}updateServiceMbsInRenderSR(e){return this._serviceMbsInRenderSR.copyFrom(e),this._serviceMbsInRenderSR}invalidateServiceBVsInRenderSR(){this._serviceMbsInRenderSR.invalidate(),this.serviceObbInRenderSR?.invalidate()}shareServiceBVsInRenderSRWith(e){this.serviceObbInRenderSR=e.serviceObbInRenderSR,this._serviceMbsInRenderSR=e._serviceMbsInRenderSR}}class i extends t{constructor(e,s,t,i,r,a,d,h,o,c){super(e,t),this.index=s,this.childCount=i,this.level=r,this.resources=a,this.version=d,this.lodMetric=h,this.maxError=o,this.numFeatures=c,this.failed=!1,this.cacheState=0,this.vertexCount=0,this.memory=0,this.childrenLoaded=0,this.hasModifications=!1,this.imModificationImpact=4,this.elevationAgnosticBoundingVolume=new n}invalidateServiceBVsInRenderSR(){super.invalidateServiceBVsInRenderSR(),this.elevationAgnosticBoundingVolume.invalidate()}}class r{constructor(e,s,t,i){this.nodeHasLOD=e,this.isChosen=s,this.lodLevel=t,this.version=i}}class n{constructor(){this._data=[0,0,0,-1]}invalidate(){this._data[3]=-1}get valid(){return-1!==this._data[3]}get radius(){return this._data[3]}getAxis(e){return e[0]=this._data[0],e[1]=this._data[1],e[2]=this._data[2],e}set(e,s){this._data[0]=e[0],this._data[1]=e[1],this._data[2]=e[2],this._data[3]=s}}export{n as ElevationAgnosticBoundingVolume,i as Node,t as NodeBoundingData,r as NodeTraversalState};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../request.js";import{binaryIndexOf as t}from"../../../../core/arrayUtils.js";import r from"../../../../core/Error.js";import has from"../../../../core/has.js";import{invert as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{p as i,d as s}from"../../../../chunks/vec32.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{canProjectWithoutEngine as l}from"../../../../geometry/projectionUtils.js";import c from"../../../../geometry/SpatialReference.js";import{projectVectorToVector as u}from"../../../../geometry/projection/projectVectorToVector.js";import{create as f,empty as p,expandPointInPlace as m,intersects as d}from"../../../../geometry/support/aaBoundingRect.js";import{fetchFeaturePopupFeatures as h}from"../../../../layers/support/featurePopupQueryUtils.js";import y from"../../../../rest/support/Query.js";import{readBinaryAttribute as g,getCachedAttributeValue as b}from"./I3SBinaryReader.js";import{computeGlobalTransformation as w}from"./I3SProjectionUtil.js";import{createSolidEdgeMaterial as v,createMaterialFromEdges as x}from"../support/edgeUtils.js";import{parseColorMixMode as S}from"../support/symbolColorUtils.js";import{Obb as M,compute as R}from"../../support/orientedBoundingBox.js";import{emissiveStrengthDefault as j}from"../../webgl-engine/core/shaderLibrary/output/Emissions.glsl.js";import{spatialReferenceIncompatibleError as I}from"../../../support/layerViewUtils.js";function T(e){return e?parseInt(e.slice(e.lastIndexOf("/")+1),10):void 0}function k(e){if(has("disable-feature:i3s-draco")||!e)return!1;for(const t of e)for(const e of t.geometryBuffers)if("draco"===e.compressedAttributes?.encoding)return!0;return!1}function U(e,t,r,o){r.traverse(t,t=>{const r=t.serviceMbsInIndexSR;return 0!==(null!=r&&L(e,r))&&(o(t),!0)})}function W(e,t,r){let o=0,n=0;for(let i=0;i<t.length&&o<e.length;i++)e[o]===t[i]&&(r(i)&&(e[n]=e[o],n++),o++);e.length=n}function C(e,r,o){let n=0,i=0;for(;n<o.length;){t(e,o[n])>=0===r&&(o[i]=o[n],i++),n++}o.length=i}function A(e,t){if(0===t.rotationScale[1]&&0===t.rotationScale[2]&&0===t.rotationScale[3]&&0===t.rotationScale[5]&&0===t.rotationScale[6]&&0===t.rotationScale[7])return K[0]=(e[0]-t.position[0])/t.rotationScale[0],K[1]=(e[1]-t.position[1])/t.rotationScale[4],K[2]=(e[2]-t.position[0])/t.rotationScale[0],K[3]=(e[3]-t.position[1])/t.rotationScale[4],K}const K=f();function L(e,t){const r=t.center[0],o=t.center[1],n=t.radius,i=e[0]-r,s=r-e[2],a=e[1]-o,l=o-e[3],c=Math.max(i,s,0),u=Math.max(a,l,0),f=c*c+u*u;if(f>n*n)return 0;if(f>0)return 1;return-Math.max(i,s,a,l)>n?3:2}function q(e,t,r){const o=[],n=r?.missingFields,i=r?.originalFields;let s=!1;for(const a of e){const e=t.get(a);e?(i?.push(a),o.push(e.name),a!==e.name&&(s=!0)):n?.push(a)}return r&&"hasMismatchedCasing"in r&&(r.hasMismatchedCasing=s),o}async function F(e,t,o,n,i,s){if(0===t.length)return[];const a=e.attributeStorageInfo;if(null!=e.associatedLayer)try{return await B(e.associatedLayer,t,n,s)}catch(l){if(e.associatedLayer.loaded)throw l}if(a){const r=G(e,t,o,i),l=e.parsedUrl.path;return await Promise.allSettled(r.map(t=>O(l,a,t.node,t.indices,n,e.apiKey,e.customParameters,s).then(e=>{for(let r=0;r<t.graphics.length;r++){const o=t.graphics[r],n=e[r];if(o.attributes)for(const e in o.attributes)e in n||(n[e]=o.attributes[e]);o.attributes=n}}))),t}throw new r("scenelayer:no-attribute-source","This scene layer does not have a source for attributes available")}function G({globalIdField:e},t,r,o){const n=new Map,i=[],s=o();for(const a of t){const t=a.attributes?.[r],o=null==t?a.getGlobalId():void 0;for(let r=0;r<s.length;r++){const l=s[r],c=P(l,t,e,o);if(c<0)continue;let u=n.get(l.node);u||(u={node:l.node,indices:[],graphics:[]},i.push(u),n.set(l.node,u)),u.indices.push(c),u.graphics.push(a);for(let e=r;e>0;e--)s[e]=s[e-1];s[0]=l;break}}return i}function P(e,t,r,o){if(null!=t&&"number"==typeof t)return e.featureIds.indexOf(t);if(null==o||null==r)return-1;const n=e.attributeInfo?.attributeData?.[r];return n?n.indexOf(o):-1}async function B(e,t,r,o){const n=[],i={hasMismatchedCasing:!1,originalFields:n},s=q(r,e.fieldsIndex,i),a=new y({outFields:[...s]});if(await h(e,t,a,{updateSourceAttributes:!0,...o}),!i.hasMismatchedCasing)return t;for(let l=0;l<t.length;l++){const e=t[l];if(e.attributes)for(let t=0;t<n.length;t++){const r=n[t],o=s[t];o in e.attributes&&(e.attributes[r]=e.attributes[o],delete e.attributes[o])}}return t}function O(e,t,r,o,n,i,s,a){return E(e,t,r.resources.attributes,o,n,i,s,a)}async function E(t,r,o,n,i,s,a,l){const c=[];for(const e of r)if(e&&i.includes(e.name)){const r=`${t}/nodes/${o}/attributes/${e.key}/0`;c.push({url:r,storageInfo:e})}const u=await Promise.allSettled(c.map(t=>e(t.url,{responseType:"array-buffer",query:{...a,token:s},signal:l?.signal}).then(e=>g(t.storageInfo,e.data)))),f=[];for(const e of n){const t={};for(let r=0;r<u.length;r++){const o=u[r];if("fulfilled"===o.status){const n=o.value;t[c[r].storageInfo.name]=b(n,e)}}f.push(t)}return f}function V(e){const t=e.store,o=t.indexCRS||t.geographicCRS,n=void 0===o?t.indexWKT:void 0;if(n){if(!e.spatialReference)throw new r("layerview:no-store-spatial-reference-wkt-index-and-no-layer-spatial-reference","Found indexWKT in the scene layer store but no layer spatial reference",{});if(n!==e.spatialReference.wkt)throw new r("layerview:store-spatial-reference-wkt-index-incompatible","The indexWKT of the scene layer store does not match the WKT of the layer spatial reference",{})}const i=o?new c(T(o)):e.spatialReference;return i.equals(e.spatialReference)?e.spatialReference:i}function $(e){const t=e.store,o=t.vertexCRS||t.projectedCRS,n=void 0===o?t.vertexWKT:void 0;if(n){if(!e.spatialReference)throw new r("layerview:no-store-spatial-reference-wkt-vertex-and-no-layer-spatial-reference","Found vertexWKT in the scene layer store but no layer spatial reference",{});if(n!==e.spatialReference.wkt)throw new r("layerview:store-spatial-reference-wkt-vertex-incompatible","The vertexWKT of the scene layer store does not match the WKT of the layer spatial reference",{})}const i=o?new c(T(o)):e.spatialReference;return i.equals(e.spatialReference)?e.spatialReference:i}function z(e,t,r){if(!l(e,t))throw I("scene layer",e?.wkid,t?.wkid);if("local"===r&&!D(e,t))throw I("scene layer",e?.wkid,t?.wkid)}function Q(e,t,o){if(e.serviceUpdateTimeStamp?.lastUpdate!==t.serviceUpdateTimeStamp?.lastUpdate||!o.isEmpty||e.associatedLayer?.url!==t.associatedLayer?.url)throw new r("layerview:recycle-failed","Could not recycle layerview")}function D(e,t){return e.equals(t)||e.isWGS84&&t.isWebMercator||e.isWebMercator&&t.isWGS84}function Z(e,t,r){const o=V(e),n=$(e);z(o,t,r),z(n,t,r)}function H(e){return(null==e.geometryType||"triangles"===e.geometryType)&&((null==e.topology||"PerAttributeArray"===e.topology)&&null!=e.vertexAttributes?.position)}function J(e){if(null==e.store?.defaultGeometrySchema||!H(e.store.defaultGeometrySchema))throw new r("scenelayer:unsupported-geometry-schema","The geometry schema of this scene layer is not supported.",{url:e.parsedUrl.path})}function N(e,t){Z(e,t.spatialReference,t.viewingMode)}function X(e){return null!=e.geometryType&&"points"===e.geometryType&&((null==e.topology||"PerAttributeArray"===e.topology)&&((null==e.encoding||""===e.encoding||"lepcc-xyz"===e.encoding)&&null!=e.vertexAttributes?.position))}function Y(e){if(null==e.store?.defaultGeometrySchema||!X(e.store.defaultGeometrySchema))throw new r("pointcloud:unsupported-geometry-schema","The geometry schema of this point cloud scene layer is not supported.",{})}function _(e,t){z(e.spatialReference,t.spatialReference,t.viewingMode)}function ee(e){return"simple"===e.type||"class-breaks"===e.type||"unique-value"===e.type}function te(e){return"mesh-3d"===e.type}function re(e){if(null==e||!ee(e))return!0;if(("unique-value"===e.type||"class-breaks"===e.type)&&null==e.defaultSymbol)return!0;const t=e.symbols;if(0===t.length)return!0;for(const r of t){if(!te(r)||0===r.symbolLayers.length)return!0;for(const e of r.symbolLayers.items)if("fill"!==e.type||null==e.material?.color||"replace"!==e.material.colorMixMode)return!0}return!1}const oe=v({color:[0,0,0,0],opacity:0});class ne{constructor(){this.edgeMaterial=null,this.material=null,this.castShadows=!0}}function ie(e){const t=new ne;let r=!1,o=!1;for(const n of e.symbolLayers.items)if("fill"===n.type&&n.enabled){const e=n.material,i=n.edges;if(null!=e&&!r){const o=e.color,i=S(e.colorMixMode),s={strength:e.emissive?.strength??j,source:"color"===e.emissive?.source?1:0};t.material=null!=o?{color:[o.r/255,o.g/255,o.b/255],alpha:o.a,colorMixMode:i,emissive:s}:{color:[1,1,1],alpha:1,colorMixMode:1,emissive:s},t.castShadows=n.castShadows,r=!0}null==i||o||(t.edgeMaterial=x(i,{}),o=!0)}return t.material||(t.material={color:[1,1,1],alpha:1,colorMixMode:1,emissive:{strength:j,source:0}}),t}function se(e,t){return(0|e)+(0|t)|0}function ae(e,t,r,n,a,l,c){if(!l||0===l.length||null==t||!e.serviceMbsInIndexSR)return null;const f=w(e.serviceMbsInIndexSR,a,"none",r,t);o(ye,f);let h=null;const y=()=>{if(!h)if(h=ue,p(pe),null!=e.serviceObbInIndexSR){e.serviceObbInIndexSR.transform(me,r,t,a,c),me.getCorners(h);for(const e of h)i(e,e,ye),m(pe,e)}else{const o=e.serviceMbsInIndexSR;if(!o)return;const n=o.radius;u(o.center,r,de,t),i(de,de,ye),de[2]+=a;for(let e=0;e<8;++e){const t=1&e?n:-n,r=2&e?n:-n,o=4&e?n:-n,i=h[e];s(i,[de[0]+t,de[1]+r,de[2]+o]),m(pe,i)}}};let g=1/0,b=-1/0;const v=e=>{if("replace"!==e.type)return;const r=e.geometry;if(!r?.hasZ)return;p(fe);const o=r.spatialReference||n,s=r.rings.reduce((e,r)=>r.reduce((e,r)=>(u(r,o,de,t),i(de,de,ye),m(fe,de),Math.min(de[2],e)),e),1/0);y(),d(pe,fe)&&(g=Math.min(g,s),b=Math.max(b,s))};if(l.forEach(e=>v(e)),g===1/0)return null;const x=(e,t,r)=>{i(de,r,f),e[t]=de[0],e[t+1]=de[1],e[t+2]=de[2],t+=24,r[2]=g,i(de,r,f),e[t]=de[0],e[t+1]=de[1],e[t+2]=de[2],t+=24,r[2]=b,i(de,r,f),e[t]=de[0],e[t+1]=de[1],e[t+2]=de[2]};for(let o=0;o<8;++o)x(he.data,3*o,h[o]);return R(he)}function le(e){return e.radius>=0}function ce(e){null!=e&&(e.radius=-1)}const ue=[a(),a(),a(),a(),a(),a(),a(),a()],fe=f(),pe=f(),me=new M,de=a(),he={data:new Array(72),size:3,exclusive:!0,stride:3},ye=n();export{ne as SymbolInfo,se as addWraparound,_ as checkPointCloudLayerCompatibleWithView,Y as checkPointCloudLayerValid,Q as checkRecyclable,N as checkSceneLayerCompatibleWithView,J as checkSceneLayerValid,z as checkSpatialReference,Z as checkSpatialReferences,ae as computeVisibilityObb,k as containsDraco,T as extractWkid,W as filterInPlace,q as findFieldsCaseInsensitive,U as findIntersectingNodes,A as getClipRect,V as getIndexCrs,ie as getSymbolInfo,$ as getVertexCrs,L as intersectBoundingRectWithMbs,ce as invalidateMbs,D as isSupportedLocalModeProjection,le as isValidMbs,C as objectIdFilter,E as queryAttributesFromCachedAttributesId,re as rendererNeedsTextures,oe as transparentEdgeMaterial,F as whenGraphicAttributes};
5
+ import e from"../../../../request.js";import{binaryIndexOf as t}from"../../../../core/arrayUtils.js";import r from"../../../../core/Error.js";import has from"../../../../core/has.js";import{invert as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{p as i,d as s}from"../../../../chunks/vec32.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{canProjectWithoutEngine as l}from"../../../../geometry/projectionUtils.js";import c from"../../../../geometry/SpatialReference.js";import{projectVectorToVector as u}from"../../../../geometry/projection/projectVectorToVector.js";import{create as f,empty as p,expandPointInPlace as m,intersects as d}from"../../../../geometry/support/aaBoundingRect.js";import{fetchFeaturePopupFeatures as h}from"../../../../layers/support/featurePopupQueryUtils.js";import y from"../../../../rest/support/Query.js";import{readBinaryAttribute as g,getCachedAttributeValue as b}from"./I3SBinaryReader.js";import{computeGlobalTransformation as w}from"./I3SProjectionUtil.js";import{createSolidEdgeMaterial as v,createMaterialFromEdges as x}from"../support/edgeUtils.js";import{parseColorMixMode as S}from"../support/symbolColorUtils.js";import{Obb as M,compute as R}from"../../support/orientedBoundingBox.js";import{emissiveStrengthDefault as j}from"../../webgl-engine/core/shaderLibrary/output/Emissions.glsl.js";import{spatialReferenceIncompatibleError as I}from"../../../support/layerViewUtils.js";function T(e){return e?parseInt(e.slice(e.lastIndexOf("/")+1),10):void 0}function k(e){if(has("disable-feature:i3s-draco")||!e)return!1;for(const t of e)for(const e of t.geometryBuffers)if("draco"===e.compressedAttributes?.encoding)return!0;return!1}function U(e,t,r,o){r.traverse(t,t=>{const r=t.serviceMbsInIndexSR;return 0!==(null!=r&&L(e,r))&&(o(t),!0)})}function W(e,t,r){let o=0,n=0;for(let i=0;i<t.length&&o<e.length;i++)e[o]===t[i]&&(r(i)&&(e[n]=e[o],n++),o++);e.length=n}function C(e,r,o){let n=0,i=0;for(;n<o.length;){t(e,o[n])>=0===r&&(o[i]=o[n],i++),n++}o.length=i}function A(e,t){if(0===t.rotationScale[1]&&0===t.rotationScale[2]&&0===t.rotationScale[3]&&0===t.rotationScale[5]&&0===t.rotationScale[6]&&0===t.rotationScale[7])return K[0]=(e[0]-t.position[0])/t.rotationScale[0],K[1]=(e[1]-t.position[1])/t.rotationScale[4],K[2]=(e[2]-t.position[0])/t.rotationScale[0],K[3]=(e[3]-t.position[1])/t.rotationScale[4],K}const K=f();function L(e,t){const r=t.center[0],o=t.center[1],n=t.radius,i=e[0]-r,s=r-e[2],a=e[1]-o,l=o-e[3],c=Math.max(i,s,0),u=Math.max(a,l,0),f=c*c+u*u;if(f>n*n)return 0;if(f>0)return 1;return-Math.max(i,s,a,l)>n?3:2}function q(e,t,r){const o=[],n=r?.missingFields,i=r?.originalFields;let s=!1;for(const a of e){const e=t.get(a);e?(i?.push(a),o.push(e.name),a!==e.name&&(s=!0)):n?.push(a)}return r&&"hasMismatchedCasing"in r&&(r.hasMismatchedCasing=s),o}async function F(e,t,o,n,i,s){if(0===t.length)return[];const a=e.attributeStorageInfo;if(null!=e.associatedLayer)try{return await B(e.associatedLayer,t,n,s)}catch(l){if(e.associatedLayer.loaded)throw l}if(a){const r=G(e,t,o,i),l=e.parsedUrl.path;return await Promise.allSettled(r.map(t=>O(l,a,t.node,t.indices,n,e.apiKey,e.customParameters,s).then(e=>{for(let r=0;r<t.graphics.length;r++){const o=t.graphics[r],n=e[r];if(o.attributes)for(const e in o.attributes)e in n||(n[e]=o.attributes[e]);o.attributes=n}}))),t}throw new r("scenelayer:no-attribute-source","This scene layer does not have a source for attributes available")}function G({globalIdField:e},t,r,o){const n=new Map,i=[],s=o();for(const a of t){const t=a.attributes?.[r],o=null==t?a.getGlobalId():void 0;for(let r=0;r<s.length;r++){const l=s[r],c=P(l,t,e,o);if(c<0)continue;let u=n.get(l.node);u||(u={node:l.node,indices:[],graphics:[]},i.push(u),n.set(l.node,u)),u.indices.push(c),u.graphics.push(a);for(let e=r;e>0;e--)s[e]=s[e-1];s[0]=l;break}}return i}function P(e,t,r,o){if(null!=t&&"number"==typeof t)return e.featureIds.indexOf(t);if(null==o||null==r)return-1;const n=e.attributeInfo?.attributeData?.[r];return n?n.indexOf(o):-1}async function B(e,t,r,o){const n=[],i={hasMismatchedCasing:!1,originalFields:n},s=q(r,e.fieldsIndex,i),a=new y({outFields:[...s]});if(await h(e,t,a,{updateSourceAttributes:!0,...o}),!i.hasMismatchedCasing)return t;for(let l=0;l<t.length;l++){const e=t[l];if(e.attributes)for(let t=0;t<n.length;t++){const r=n[t],o=s[t];o in e.attributes&&(e.attributes[r]=e.attributes[o],delete e.attributes[o])}}return t}function O(e,t,r,o,n,i,s,a){return E(e,t,r.resources.attributes,o,n,i,s,a)}async function E(t,r,o,n,i,s,a,l){const c=[];for(const e of r)if(e&&i.includes(e.name)){const r=`${t}/nodes/${o}/attributes/${e.key}/0`;c.push({url:r,storageInfo:e})}const u=await Promise.allSettled(c.map(t=>e(t.url,{responseType:"array-buffer",query:{...a,token:s},signal:l?.signal}).then(e=>g(t.storageInfo,e.data)))),f=[];for(const e of n){const t={};for(let r=0;r<u.length;r++){const o=u[r];if("fulfilled"===o.status){const n=o.value;t[c[r].storageInfo.name]=b(n,e)}}f.push(t)}return f}function V(e){const t=e.store,o=t.indexCRS||t.geographicCRS,n=void 0===o?t.indexWKT:void 0;if(n){if(!e.spatialReference)throw new r("layerview:no-store-spatial-reference-wkt-index-and-no-layer-spatial-reference","Found indexWKT in the scene layer store but no layer spatial reference",{});if(n!==e.spatialReference.wkt)throw new r("layerview:store-spatial-reference-wkt-index-incompatible","The indexWKT of the scene layer store does not match the WKT of the layer spatial reference",{})}const i=o?new c(T(o)):e.spatialReference;return i.equals(e.spatialReference)?e.spatialReference:i}function $(e){const t=e.store,o=t.vertexCRS||t.projectedCRS,n=void 0===o?t.vertexWKT:void 0;if(n){if(!e.spatialReference)throw new r("layerview:no-store-spatial-reference-wkt-vertex-and-no-layer-spatial-reference","Found vertexWKT in the scene layer store but no layer spatial reference",{});if(n!==e.spatialReference.wkt)throw new r("layerview:store-spatial-reference-wkt-vertex-incompatible","The vertexWKT of the scene layer store does not match the WKT of the layer spatial reference",{})}const i=o?new c(T(o)):e.spatialReference;return i.equals(e.spatialReference)?e.spatialReference:i}function z(e,t,r){if(!l(e,t))throw I("scene layer",e?.wkid,t?.wkid);if("local"===r&&!D(e,t))throw I("scene layer",e?.wkid,t?.wkid)}function Q(e,t,o){if(e.serviceUpdateTimeStamp?.lastUpdate!==t.serviceUpdateTimeStamp?.lastUpdate||!o.isEmpty||e.associatedLayer?.url!==t.associatedLayer?.url)throw new r("layerview:recycle-failed","Could not recycle layerview")}function D(e,t){return e.equals(t)||e.isWGS84&&t.isWebMercator||e.isWebMercator&&t.isWGS84}function Z(e,t,r){const o=V(e),n=$(e);z(o,t,r),z(n,t,r)}function H(e){return(null==e.geometryType||"triangles"===e.geometryType)&&((null==e.topology||"PerAttributeArray"===e.topology)&&null!=e.vertexAttributes?.position)}function J(e){if(null==e.store?.defaultGeometrySchema||!H(e.store.defaultGeometrySchema))throw new r("scenelayer:unsupported-geometry-schema","The geometry schema of this scene layer is not supported.",{url:e.parsedUrl.path})}function N(e,t){Z(e,t.spatialReference,t.viewingMode)}function X(e){return null!=e.geometryType&&"points"===e.geometryType&&((null==e.topology||"PerAttributeArray"===e.topology)&&((null==e.encoding||""===e.encoding||"lepcc-xyz"===e.encoding)&&null!=e.vertexAttributes?.position))}function Y(e){if(null==e.store?.defaultGeometrySchema||!X(e.store.defaultGeometrySchema))throw new r("pointcloud:unsupported-geometry-schema","The geometry schema of this point cloud scene layer is not supported.",{})}function _(e,t){z(e.spatialReference,t.spatialReference,t.viewingMode)}function ee(e){return"simple"===e.type||"class-breaks"===e.type||"unique-value"===e.type}function te(e){return"mesh-3d"===e.type}function re(e){if(null==e||!ee(e))return!0;if(("unique-value"===e.type||"class-breaks"===e.type)&&null==e.defaultSymbol)return!0;const t=e.symbols;if(0===t.length)return!0;for(const r of t){if(!te(r)||0===r.symbolLayers.length)return!0;for(const e of r.symbolLayers.items)if("fill"!==e.type||null==e.material?.color||"replace"!==e.material.colorMixMode)return!0}return!1}const oe=v({color:[0,0,0,0],opacity:0});class ne{constructor(){this.edgeMaterial=null,this.material=null,this.castShadows=!0}}function ie(e){const t=new ne;let r=!1,o=!1;for(const n of e.symbolLayers.items)if("fill"===n.type&&n.enabled){const e=n.material,i=n.edges;if(null!=e&&!r){const o=e.color,i=S(e.colorMixMode),s={strength:e.emissive?.strength??j,source:"color"===e.emissive?.source?1:0};t.material=null!=o?{color:[o.r/255,o.g/255,o.b/255],alpha:o.a,colorMixMode:i,emissive:s}:{color:[1,1,1],alpha:1,colorMixMode:1,emissive:s},t.castShadows=n.castShadows,r=!0}null==i||o||(t.edgeMaterial=x(i,{}),o=!0)}return t.material||(t.material={color:[1,1,1],alpha:1,colorMixMode:1,emissive:{strength:j,source:0}}),t}function se(e,t){return(0|e)+(0|t)|0}function ae(e,t,r,n,a,l,c){if(!l||0===l.length||null==t||!e.serviceMbsInIndexSR)return null;const f=w(e.serviceMbsInIndexSR,a,"none",r,t);o(de,f);let h=null;const y=()=>{if(!h)if(h=le,p(ue),null!=e.serviceObbInIndexSR){e.serviceObbInIndexSR.transform(fe,r,t,a,c),fe.getCorners(h);for(const e of h)i(e,e,de),m(ue,e)}else{const o=e.serviceMbsInIndexSR;if(!o)return;const n=o.radius;u(o.center,r,pe,t),i(pe,pe,de),pe[2]+=a;for(let e=0;e<8;++e){const t=1&e?n:-n,r=2&e?n:-n,o=4&e?n:-n,i=h[e];s(i,[pe[0]+t,pe[1]+r,pe[2]+o]),m(ue,i)}}};let g=1/0,b=-1/0;const v=e=>{if("replace"!==e.type)return;const r=e.geometry;if(!r?.hasZ)return;p(ce);const o=r.spatialReference||n,s=r.rings.reduce((e,r)=>r.reduce((e,r)=>(u(r,o,pe,t),i(pe,pe,de),m(ce,pe),Math.min(pe[2],e)),e),1/0);y(),d(ue,ce)&&(g=Math.min(g,s),b=Math.max(b,s))};if(l.forEach(e=>v(e)),g===1/0)return null;const x=(e,t,r)=>{i(pe,r,f),e[t]=pe[0],e[t+1]=pe[1],e[t+2]=pe[2],t+=24,r[2]=g,i(pe,r,f),e[t]=pe[0],e[t+1]=pe[1],e[t+2]=pe[2],t+=24,r[2]=b,i(pe,r,f),e[t]=pe[0],e[t+1]=pe[1],e[t+2]=pe[2]};for(let o=0;o<8;++o)x(me.data,3*o,h[o]);return R(me)}const le=[a(),a(),a(),a(),a(),a(),a(),a()],ce=f(),ue=f(),fe=new M,pe=a(),me={data:new Array(72),size:3,exclusive:!0,stride:3},de=n();export{ne as SymbolInfo,se as addWraparound,_ as checkPointCloudLayerCompatibleWithView,Y as checkPointCloudLayerValid,Q as checkRecyclable,N as checkSceneLayerCompatibleWithView,J as checkSceneLayerValid,z as checkSpatialReference,Z as checkSpatialReferences,ae as computeVisibilityObb,k as containsDraco,T as extractWkid,W as filterInPlace,q as findFieldsCaseInsensitive,U as findIntersectingNodes,A as getClipRect,V as getIndexCrs,ie as getSymbolInfo,$ as getVertexCrs,L as intersectBoundingRectWithMbs,D as isSupportedLocalModeProjection,C as objectIdFilter,E as queryAttributesFromCachedAttributesId,re as rendererNeedsTextures,oe as transparentEdgeMaterial,F as whenGraphicAttributes};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{n as e,a as t,g as i,c as s,G as n,e as r,d as o,u as a,w as c,j as u,H as h,s as l,D as d,b as m,F as _,i as p}from"../../../../chunks/vec32.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as v}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as g}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingSphere as b}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as R}from"../../../../geometry/projection/projectors.js";import{create as S,fromMatrix as x,createPoints as M,intersectsSphere as C}from"../../../../geometry/support/frustum.js";import{getNormal as I,signedDistance as P}from"../../../../geometry/support/plane.js";import{isPlateCarree as D}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as E}from"../../../../geometry/support/sphere.js";import{makeDehydratedPoint as O}from"../../../../layers/graphics/dehydratedPoint.js";import{evaluateElevationAlignmentAtPoint as F}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as A}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as V,extractExpressionInfo as B}from"../graphics/featureExpressionInfoUtils.js";import{isValidMbs as y,intersectBoundingRectWithMbs as j}from"./I3SUtil.js";import{Obb as L,computeOffsetObb as w}from"../../support/orientedBoundingBox.js";const q=1e5;class G{get _frustumMbsCenter(){return this._frustumMbs.center}get _frustumMbsRadius(){return this._frustumMbs.radius}get _frustumPlanes(){return this._frustum}constructor(e,t,i,s,n,r,o,a,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=n,this._elevationProvider=r,this._viewingMode=o,this._options=c,this._frustum=S(),this._frustumMbs=new E,this._viewDirection=f(),this._useFrustumCulling=!1,this._poi=f(),this._cameraPOIDirection=f(),this._elevationContext=null,this.minDistance=1/0,this.maxDistance=0,this.maxLodLevel=2,this._tmpObb=new L,this._tmp1=f(),this._tmp2=f(),this._tmp3=f(),this._tmp0=f(),this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this.updateCamera(i,s);const u=this._renderCoordsHelper.spatialReference;this._renderSR=u,this._renderSRSphericalPCPF=g(u),this._isGlobalMode=u===this._renderSRSphericalPCPF,this.updateElevationInfo(a),this._tmpPoint=O(0,0,0,e),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(u.isWebMercator||D(u)),this._indexSREllipsoidRadius=v(this._indexSR).radius,this._indexSRSphericalPCPF=g(e),this._projectorIndexSRToIndexSRSphericalPCPF=R(this._indexSR,this._indexSRSphericalPCPF)}updateElevationInfo(e){null!=e?(this._elevationContext=A.fromElevationInfo(e),this._elevationContext.setFeatureExpressionInfoContext(V(B(e,!1)))):this._elevationContext=null}updateCamera(n,r){if(this._useFrustumCulling=r,e(this._viewDirection,n.viewForward),r){x(n.viewMatrix,n.projectionMatrix,this._frustum,z);{const e=n.eye,r=N;t(r,z[4],e);const o=.5*i(r,r)/i(this._viewDirection,r),a=this._frustumMbs,c=a.center;s(c,e,this._viewDirection,o);const u=1+o;a.radius=u}}this._screenSizeFactor=1/(n.perScreenPixelRatio/2),this._camPos=n.eye,this._updateCameraPOIDirection(),this.minDistance=1/0,this.maxDistance=0}setPointOfInterest(e){this._poi=e,this._updateCameraPOIDirection()}updateScreenSpaceErrorBias(e){const t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,i){if(null==this._elevationContext)return;const s=e.serviceMbsInIndexSR;if(!s)return;const n="relative-to-scene"===this._elevationContext.mode?"scene":"ground",r=this._elevationProvider;if(r.getSphereElevationRange){const e=r.getSphereElevationRange(s,this._indexSR,n);if(e)return void i.expandElevationRange(e)}const[o,a,c]=s.center,u=r.getElevation(o,a,c,this._indexSR,n);u&&i.expandElevationRangeValues(u,u);const h=t?null:r.getRootElevationRange?.();h&&i.expandElevationRange(h)}getServiceMbsInRenderSR(e){const t=e.serviceMbsInRenderSR;if(y(t))return t;const{serviceMbsInIndexSR:i}=e;i&&t.copy(i);const{minElevation:s}=e;if(this._elevationContext&&Number.isFinite(s)){let i=0,n=0;const{maxElevation:r}=e;switch(this._elevationContext.mode){case"relative-to-ground":case"relative-to-scene":i=this._elevationContext.geometryZWithOffset(t.center[2],this._renderCoordsHelper)+s-t.center[2],n=r-s;break;case"on-the-ground":i=s-t.center[2],n=r-s}t.center[2]+=i+.5*n,t.radius+=.5*n}else this._elevationContext&&t.radius<q&&(this._tmpPoint.x=t.center[0],this._tmpPoint.y=t.center[1],this._tmpPoint.z=t.center[2],t.center[2]=F(this._tmpPoint,this._elevationProvider,this._elevationContext,this._renderCoordsHelper));return b(t,this._indexSR,t,this._renderSR),t}getAndUpdateVisibilityObbInRenderSR(e){{const t=e.visibilityObbInRenderSR;if(t)return t}const t=.01*this._indexSREllipsoidRadius,{serviceMbsInIndexSR:i,serviceObbInIndexSR:s}=e;if(null==s||!i||!s.isValid||this._isECEFOBBInLocalMode&&(s.halfSizeX>t||s.halfSizeY>t||s.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(null==t)t=new L,e.serviceObbInRenderSR=t;else if(t.isValid)return t;const n=i.radius;let r=0,o=0;const a=s.centerZ,c=this._renderCoordsHelper,u=this._elevationContext;if(u&&e.elevationRangeValid){const{minElevation:t,maxElevation:i}=e;switch(u.mode){case"relative-to-ground":case"relative-to-scene":r=u.geometryZWithOffset(a,c)+t-a,o=i-t;break;case"on-the-ground":r=t-a,o=i-t}}else if(u&&n<q){const e=this._tmpPoint;e.x=s.centerX,e.y=s.centerY,e.z=a,r=F(e,this._elevationProvider,u,c)-a}const h=o>0,l=h?this._tmpObb:t;return s.transform(l,this._indexSR,this._renderSR,r,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),h&&w(l,0,o,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{const t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}const t=e.serviceObbInIndexSR;return t?(t.transform(Z,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),Z):null}ensureElevationAgnosticBoundingVolume(e){return!e.elevationAgnosticBoundingVolume.valid&&e.level>0&&(1===this._viewingMode?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateCameraPOIDirection(){n(this._poi,this._camPos)?this._cameraPOIDirection=this._viewDirection:(r(this._cameraPOIDirection,this._camPos,this._poi),e(this._cameraPOIDirection,this._cameraPOIDirection))}_updateElevationAgnosticBoundingVolumeGlobal(t){const s=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),n=t.elevationAgnosticBoundingVolume;let r,c=-1;if(s){const t=X;s.getCenter(t),e(t,t),r=t,s.getCorners(Y);for(const s of Y){e(s,s);const r=i(s,t);if(r<=0)return void n.invalidate();const o=Math.sqrt(1-r*r);c=Math.max(c,o)}}else{const i=t.serviceMbsInRenderSR;if(!y(i))return void n.invalidate();{const t=o(X,i.center),s=i.radius,u=a(t);if(u<s)return void n.invalidate();c=s/u,e(t,t),r=t}}const u=.001;n.set(r,c+u)}_updateElevationAgnosticBoundingVolumeLocal(e){const t=e.elevationAgnosticBoundingVolume,i=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(i){const e=i.getCenter(X);e[2]=0;let s=0;const n=J;i.getCorners(Y);for(const t of Y){t[2]=0;const e=c(n,t);s=Math.max(s,e)}t.set(e,Math.sqrt(s))}else{const i=e.serviceMbsInRenderSR;if(y(i)){const e=o(X,i.center);e[2]=0,t.set(e,i.radius)}}}isNodeVisible(e){const t=this.getServiceMbsInRenderSR(e);if(!this._isMBSinClippingArea(t))return!1;if(!this._useFrustumCulling)return!0;const i=this.getAndUpdateVisibilityObbInRenderSR(e);return i?i.doesIntersectFrustumConservativeApproximation(this._frustum):C(this._frustum,t)}isElevationAgnosticBoundingVolumeVisible(e){return!this._useFrustumCulling||(!e.valid||(1===this._viewingMode?this._isConeVisibleInFrustum(e):this._isCylinderVisibleInFrustum(e)))}_isConeVisibleInFrustum(n){if(!this._isConeVisibleInFrustumMbs(n))return!1;const r=n.radius;if(-1===r||r>.9)return!0;const o=this._frustumPlanes,a=this._frustumMbsCenter,c=n.getAxis(ee),h=i(c,a),l=this._frustumMbsRadius,d=h-l,m=h+l;if(d<=0)return!0;const _=u(k,c,d),p=u(H,c,m),f=r/Math.sqrt(1-r*r);for(const v of o){const n=I(v),r=e(W,n),o=i(r,c);if(Math.abs(1-o)<.01)continue;const a=K;u(a,c,o),t(a,a,r),e(a,a);const h=Q;s(h,_,a,d*f);if(P(v,h)<=0)continue;s(h,p,a,m*f);if(P(v,h)<=0)continue;return!1}return!0}_isConeVisibleInFrustumMbs(e){const t=e.radius;if(t>.9)return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,r=a(n);if(r<=s)return!0;const o=e.getAxis(ee),c=i(o,n);{const e=u(T,o,c);if(h(e,n)<s)return!0}const l=c/r;if(c<=0){return-l<s}const d=Math.sqrt(1-l*l);if(d<t)return!0;const m=s/r;return d*Math.sqrt(1-m*m)-m*l<t}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling)return!0;if(!e.valid)return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,r=this._frustumPlanes,o=Y;if(t.getCorners(o),1===this._viewingMode){const t=e.getAxis(ee),a=i(t,n),c=a-s,h=a+s;if(c<=0)return!0;for(const e of r){let s=!0;for(const n of o){const r=i(n,t),o=$;if(u(o,n,c/r),P(e,o)<=0){s=!1;break}const a=$;if(u(a,n,h/r),P(e,a)<=0){s=!1;break}}if(s)return!1}}else{const e=n[2]-s,t=n[2]+s;for(const i of r){let s=!0;const n=I(i),r=n[0],a=n[1],c=n[2],u=i[3];for(const i of o){const n=r*i[0]+a*i[1]+u;if(n+c*e<=0||n+c*t<=0){s=!1;break}}if(s)return!1}}return!0}_isCylinderVisibleInFrustum(e){const t=this._frustumMbsCenter,i=this._frustumMbsRadius,s=o(T,t);s[2]=0;const n=e.radius,r=e.getAxis(ee);return h(s,r)<=n+i}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const t=e.geometryObbInRenderSR;return t?.doesIntersectFrustumConservativeApproximation(this._frustum)??this.isNodeVisible(e)}_isMBSinClippingArea(e){return null==this._clippingArea||0!==j(this._clippingArea,e)}_screenSpaceDiameterMbs(e,t){const i=this.getServiceMbsInRenderSR(e),s=Math.sqrt(l(i.center,this._camPos)),n=s-i.radius;return this._updateMinMaxDistance(s),n<0?.5*Number.MAX_VALUE:t/n*this._screenSizeFactor}calcCameraDistance(e){return this.calcCameraDistanceToCenter(e)-this.getServiceMbsInRenderSR(e).radius}calcCameraDistanceToCenter(e){const t=this.getServiceMbsInRenderSR(e),i=d(t.center,this._camPos);return this._updateMinMaxDistance(i),i}calcAngleDependentLoD(e){const t=this.getServiceMbsInRenderSR(e),i=t.radius,s=(Math.abs(t.center[0]*(t.center[0]-this._camPos[0])+t.center[1]*(t.center[1]-this._camPos[1])+t.center[2]*(t.center[2]-this._camPos[2]))/m(t.center)+i)/d(t.center,this._camPos);return Math.min(1,s)}hasLOD(e){return 0!==e.lodMetric}_getDistanceGlobeMode(e,t){const s=m(t.center),n=m(e)-s;u(this._tmp0,e,i(e,t.center)/_(e));const o=l(t.center,this._tmp0),a=t.radius;if(o<=a*a)return Math.abs(n);{const o=u(this._tmp0,t.center,1/s),c=s,h=a*a/2/c,l=u(this._tmp1,o,c-h),_=e,f=r(this._tmp2,_,l),v=r(this._tmp2,f,u(this._tmp3,o,i(o,f))),g=p(this._tmp2,l,u(this._tmp2,v,a/m(v)));let b=d(_,g);if(n>=2e5){const e=r(this._tmp1,_,g);let t=i(e,o)/m(e);t<.08&&(t=1e-4),b/=t}return b}}_getDistance(e,t){return this._isGlobalMode?this._getDistanceGlobeMode(e,t):U(e,t)}_updateMinMaxDistance(e){e>0?(this.minDistance=Math.min(this.minDistance,e),this.maxDistance=Math.max(this.maxDistance,e)):(this.minDistance=0,this.maxDistance=Math.max(this.maxDistance,-e))}getLodLevel(e){if(0===e.lodMetric)return 0;if(0===e.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const t=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,i)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case 2:{const i=this.getServiceMbsInRenderSR(e),s=this._getDistance(this._camPos,i),n=2*s/this._screenSizeFactor,r=s+i.radius;return this._updateMinMaxDistance(r),e.maxError*t<=n}case 1:{let i=this._screenSpaceDiameterMbs(e,(e.serviceMbsInIndexSR?.radius??0)*t);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(e)),i<e.maxError}case 3:return this._screenSpaceDiameterMbs(e,e.maxError)*t<10;case 4:return this.calcCameraDistance(e)>e.maxError*t}return!1}distToCameraPOIRay(e){if(null==e)return 0;const t=this.getServiceMbsInRenderSR(e),s=t.center,n=i(s,this._cameraPOIDirection),r=n*n,o=_(s)-r;return Math.sqrt(o)-t.radius}distCameraToPOI(){return d(this._camPos,this._poi)}}function U(e,t){const i=e[0]-t.center[0],s=e[1]-t.center[1],n=e[2]-t.center[2],r=i*i+s*s,o=t.radius;if(r<=o*o)return Math.abs(n);const a=Math.sqrt(r)-o;return Math.sqrt(n*n+a*a)}const z=M(),N=f(),T=f(),k=f(),H=f(),W=f(),Z=new L,X=f(),Y=[f(),f(),f(),f(),f(),f(),f(),f()],J=f(),K=f(),Q=f(),$=f(),ee=f();export{G as default};
5
+ import{n as e,a as t,g as i,c as s,h as r,G as n,e as o,d as a,u as c,w as u,j as l,H as h,s as d,D as m,b as _,F as p,i as f}from"../../../../chunks/vec32.js";import{create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as g}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as R}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingSphere as b}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as S}from"../../../../geometry/projection/projectors.js";import{create as M,fromMatrix as x,createPoints as I,intersectsSphere as C}from"../../../../geometry/support/frustum.js";import{getNormal as D,signedDistance as P}from"../../../../geometry/support/plane.js";import{isPlateCarree as E}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as O}from"../../../../geometry/support/sphere.js";import{evaluateElevationAlignmentAtPoint as F}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as V}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as A,extractExpressionInfo as B}from"../graphics/featureExpressionInfoUtils.js";import{intersectBoundingRectWithMbs as L}from"./I3SUtil.js";import{Obb as j,computeOffsetObb as y}from"../../support/orientedBoundingBox.js";const w=1e5;class q{get _frustumMbsCenter(){return this._frustumMbs.center}get _frustumMbsRadius(){return this._frustumMbs.radius}get _frustumPlanes(){return this._frustum}constructor(e,t,i,s,r,n,o,a,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=r,this._elevationProvider=n,this._viewingMode=o,this._options=c,this._frustum=M(),this._frustumMbs=new O,this._viewDirection=v(),this._useFrustumCulling=!1,this._poi=v(),this._cameraPOIDirection=v(),this._elevationContext=null,this.minDistance=1/0,this.maxDistance=0,this.maxLodLevel=2,this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this.updateCamera(i,s);const u=this._renderCoordsHelper.spatialReference;this._renderSR=u,this._renderSRSphericalPCPF=R(u),this._isGlobalMode=u===this._renderSRSphericalPCPF,this.updateElevationInfo(a),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(u.isWebMercator||E(u)),this._indexSREllipsoidRadius=g(this._indexSR).radius,this._indexSRSphericalPCPF=R(e),this._projectorIndexSRToIndexSRSphericalPCPF=S(this._indexSR,this._indexSRSphericalPCPF)}updateElevationInfo(e){null!=e?(this._elevationContext=V.fromElevationInfo(e),this._elevationContext.setFeatureExpressionInfoContext(A(B(e,!1)))):this._elevationContext=null}updateCamera(r,n){if(this._useFrustumCulling=n,e(this._viewDirection,r.viewForward),n){x(r.viewMatrix,r.projectionMatrix,this._frustum,U);{const e=r.eye,n=N;t(n,U[4],e);const o=.5*i(n,n)/i(this._viewDirection,n),a=this._frustumMbs,c=a.center;s(c,e,this._viewDirection,o);const u=1+o;a.radius=u}}this._screenSizeFactor=1/(r.perScreenPixelRatio/2),this._camPos=r.eye,this._updateCameraPOIDirection(),this.minDistance=1/0,this.maxDistance=0}setPointOfInterest(e){this._poi=e,this._updateCameraPOIDirection()}updateScreenSpaceErrorBias(e){const t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,i){if(null==this._elevationContext)return;const s=e.serviceMbsInIndexSR;if(!s)return;const r="relative-to-scene"===this._elevationContext.mode?"scene":"ground",n=this._elevationProvider;if(n.getSphereElevationRange){const e=n.getSphereElevationRange(s,this._indexSR,r);if(e)return void i.expandElevationRange(e)}const[o,a,c]=s.center,u=n.getElevation(o,a,c,this._indexSR,r);u&&i.expandElevationRangeValues(u,u);const l=t?null:n.getRootElevationRange?.();l&&i.expandElevationRange(l)}calculateServiceMbsInRenderSR(e){const{serviceMbsInRenderSR:t}=e;if(t.isValid)return t;const{serviceMbsInIndexSR:i}=e;if(!i)return t;const s=ee;s.copyFrom(i);const{minElevation:r}=e,{_elevationContext:n,_renderCoordsHelper:o}=this,{center:a}=s;if(n&&Number.isFinite(r)){let t=0,i=0;const{maxElevation:c}=e;switch(n.mode){case"relative-to-ground":case"relative-to-scene":t=n.geometryZWithOffset(a[2],o)+r-a[2],i=c-r;break;case"on-the-ground":t=r-a[2],i=c-r}a[2]+=t+.5*i,s.radius+=.5*i}else n&&s.radius<w&&(a[2]=F(a,this._elevationProvider,n,o));return b(s,this._indexSR,s,this._renderSR),e.updateServiceMbsInRenderSR(s)}getAndUpdateVisibilityObbInRenderSR(e){{const t=e.visibilityObbInRenderSR;if(t)return t}const t=.01*this._indexSREllipsoidRadius,{serviceMbsInIndexSR:i,serviceObbInIndexSR:s}=e;if(null==s||!i||!s.isValid||this._isECEFOBBInLocalMode&&(s.halfSizeX>t||s.halfSizeY>t||s.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(null==t)t=new j,e.serviceObbInRenderSR=t;else if(t.isValid)return t;const n=i.radius;let o=0,a=0;const c=s.centerZ,u=this._renderCoordsHelper,l=this._elevationContext;if(l&&e.elevationRangeValid){const{minElevation:t,maxElevation:i}=e;switch(l.mode){case"relative-to-ground":case"relative-to-scene":o=l.geometryZWithOffset(c,u)+t-c,a=i-t;break;case"on-the-ground":o=t-c,a=i-t}}else if(l&&n<w){const e=r(Z,s.centerX,s.centerY,c);o=F(e,this._elevationProvider,l,u)-c}const h=a>0,d=h?W:t;return s.transform(d,this._indexSR,this._renderSR,o,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),h&&y(d,0,a,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{const t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}const t=e.serviceObbInIndexSR;return t?(t.transform(W,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),W):null}ensureElevationAgnosticBoundingVolume(e){return!e.elevationAgnosticBoundingVolume.valid&&e.level>0&&(1===this._viewingMode?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateCameraPOIDirection(){n(this._poi,this._camPos)?this._cameraPOIDirection=this._viewDirection:(o(this._cameraPOIDirection,this._camPos,this._poi),e(this._cameraPOIDirection,this._cameraPOIDirection))}_updateElevationAgnosticBoundingVolumeGlobal(t){const s=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),r=t.elevationAgnosticBoundingVolume;let n,o=-1;if(s){const t=Z;s.getCenter(t),e(t,t),n=t,s.getCorners(X);for(const s of X){e(s,s);const n=i(s,t);if(n<=0)return void r.invalidate();const a=Math.sqrt(1-n*n);o=Math.max(o,a)}}else{const i=t.serviceMbsInRenderSR;if(!i.isValid)return void r.invalidate();const s=a(Z,i.center),u=i.radius,l=c(s);if(l<u)return void r.invalidate();o=u/l,e(s,s),n=s}const u=.001;r.set(n,o+u)}_updateElevationAgnosticBoundingVolumeLocal(e){const t=e.elevationAgnosticBoundingVolume,i=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(i){const e=i.getCenter(Z);e[2]=0;let s=0;const r=Y;i.getCorners(X);for(const t of X){t[2]=0;const e=u(r,t);s=Math.max(s,e)}t.set(e,Math.sqrt(s))}else{const i=e.serviceMbsInRenderSR;if(i.isValid){const e=a(Z,i.center);e[2]=0,t.set(e,i.radius)}}}isNodeVisible(e){const t=this.calculateServiceMbsInRenderSR(e);if(!this._isMBSinClippingArea(t))return!1;if(!this._useFrustumCulling)return!0;const i=this.getAndUpdateVisibilityObbInRenderSR(e);return i?i.doesIntersectFrustumConservativeApproximation(this._frustum):C(this._frustum,t)}isElevationAgnosticBoundingVolumeVisible(e){return!this._useFrustumCulling||(!e.valid||(1===this._viewingMode?this._isConeVisibleInFrustum(e):this._isCylinderVisibleInFrustum(e)))}_isConeVisibleInFrustum(r){if(!this._isConeVisibleInFrustumMbs(r))return!1;const n=r.radius;if(-1===n||n>.9)return!0;const o=this._frustumPlanes,a=this._frustumMbsCenter,c=r.getAxis($),u=i(c,a),h=this._frustumMbsRadius,d=u-h,m=u+h;if(d<=0)return!0;const _=l(k,c,d),p=l(z,c,m),f=n/Math.sqrt(1-n*n);for(const v of o){const r=D(v),n=e(H,r),o=i(n,c);if(Math.abs(1-o)<.01)continue;const a=J;l(a,c,o),t(a,a,n),e(a,a);const u=K;s(u,_,a,d*f);if(P(v,u)<=0)continue;s(u,p,a,m*f);if(P(v,u)<=0)continue;return!1}return!0}_isConeVisibleInFrustumMbs(e){const t=e.radius;if(t>.9)return!0;const s=this._frustumMbsRadius,r=this._frustumMbsCenter,n=c(r);if(n<=s)return!0;const o=e.getAxis($),a=i(o,r);{const e=l(T,o,a);if(h(e,r)<s)return!0}const u=a/n;if(a<=0){return-u<s}const d=Math.sqrt(1-u*u);if(d<t)return!0;const m=s/n;return d*Math.sqrt(1-m*m)-m*u<t}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling)return!0;if(!e.valid)return!0;const s=this._frustumMbsRadius,r=this._frustumMbsCenter,n=this._frustumPlanes,o=X;if(t.getCorners(o),1===this._viewingMode){const t=e.getAxis($),a=i(t,r),c=a-s,u=a+s;if(c<=0)return!0;for(const e of n){let s=!0;for(const r of o){const n=i(r,t),o=Q;if(l(o,r,c/n),P(e,o)<=0){s=!1;break}const a=Q;if(l(a,r,u/n),P(e,a)<=0){s=!1;break}}if(s)return!1}}else{const e=r[2]-s,t=r[2]+s;for(const i of n){let s=!0;const r=D(i),n=r[0],a=r[1],c=r[2],u=i[3];for(const i of o){const r=n*i[0]+a*i[1]+u;if(r+c*e<=0||r+c*t<=0){s=!1;break}}if(s)return!1}}return!0}_isCylinderVisibleInFrustum(e){const t=this._frustumMbsCenter,i=this._frustumMbsRadius,s=a(T,t);s[2]=0;const r=e.radius,n=e.getAxis($);return h(s,n)<=r+i}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const t=e.geometryObbInRenderSR;return t?.doesIntersectFrustumConservativeApproximation(this._frustum)??this.isNodeVisible(e)}_isMBSinClippingArea(e){return null==this._clippingArea||0!==L(this._clippingArea,e)}_screenSpaceDiameterMbs(e,t){const i=this.calculateServiceMbsInRenderSR(e),s=Math.sqrt(d(i.center,this._camPos)),r=s-i.radius;return this._updateMinMaxDistance(s),r<0?.5*Number.MAX_VALUE:t/r*this._screenSizeFactor}calcCameraDistance(e){return this.calcCameraDistanceToCenter(e)-this.calculateServiceMbsInRenderSR(e).radius}calcCameraDistanceToCenter(e){const t=this.calculateServiceMbsInRenderSR(e),i=m(t.center,this._camPos);return this._updateMinMaxDistance(i),i}calcAngleDependentLoD(e){const{center:s,radius:r}=this.calculateServiceMbsInRenderSR(e),n=t(Y,s,this._camPos),o=(Math.abs(i(s,n))/_(s)+r)/_(n);return Math.min(1,o)}hasLOD(e){return 0!==e.lodMetric}_getDistanceGlobeMode(e,t){const s=_(t.center),r=_(e)-s;l(te,e,i(e,t.center)/p(e));const n=d(t.center,te),a=t.radius;if(n<=a*a)return Math.abs(r);{const n=l(te,t.center,1/s),c=l(ie,n,s-a*a/2/s),u=e,h=o(se,u,c),d=o(se,h,l(re,n,i(n,h))),p=f(se,c,l(se,d,a/_(d)));let v=m(u,p);if(r>=2e5){const e=o(ie,u,p);let t=i(e,n)/_(e);t<.08&&(t=1e-4),v/=t}return v}}_getDistance(e,t){return this._isGlobalMode?this._getDistanceGlobeMode(e,t):G(e,t)}_updateMinMaxDistance(e){e>0?(this.minDistance=Math.min(this.minDistance,e),this.maxDistance=Math.max(this.maxDistance,e)):(this.minDistance=0,this.maxDistance=Math.max(this.maxDistance,-e))}getLodLevel(e){if(0===e.lodMetric)return 0;if(0===e.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const t=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,i)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case 2:{const i=this.calculateServiceMbsInRenderSR(e),s=this._getDistance(this._camPos,i),r=2*s/this._screenSizeFactor,n=s+i.radius;return this._updateMinMaxDistance(n),e.maxError*t<=r}case 1:{let i=this._screenSpaceDiameterMbs(e,(e.serviceMbsInIndexSR?.radius??0)*t);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(e)),i<e.maxError}case 3:return this._screenSpaceDiameterMbs(e,e.maxError)*t<10;case 4:return this.calcCameraDistance(e)>e.maxError*t}return!1}distToCameraPOIRay(e){if(null==e)return 0;const t=this.calculateServiceMbsInRenderSR(e),s=t.center,r=i(s,this._cameraPOIDirection),n=r*r,o=p(s)-n;return Math.sqrt(o)-t.radius}distCameraToPOI(){return m(this._camPos,this._poi)}}function G(e,t){const i=e[0]-t.center[0],s=e[1]-t.center[1],r=e[2]-t.center[2],n=i*i+s*s,o=t.radius;if(n<=o*o)return Math.abs(r);const a=Math.sqrt(n)-o;return Math.sqrt(r*r+a*a)}const U=I(),N=v(),T=v(),k=v(),z=v(),H=v(),W=new j,Z=v(),X=[v(),v(),v(),v(),v(),v(),v(),v()],Y=v(),J=v(),K=v(),Q=v(),$=v(),ee=new O,te=v(),ie=v(),se=v(),re=v();export{q as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{a as e,n as i}from"../../../../chunks/vec32.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Tiles3DTarget as n}from"../i3s/Intersector.js";import{ElevationRange as s}from"../../support/ElevationRange.js";import{IntersectorResult as r}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as o,computeInvDir as l,intersectAabbInvDir as a}from"../../webgl-engine/lib/RayIntersections.js";class c{constructor(e){this.layerView=e,this.type=8,this.slicePlaneEnabled=!1,this.isGround=!0,this.layerViewUid=e.uid}intersect(s,c,d,m,p,f){if(s.options.filteredLayerViewUids.includes(this.layerView.uid))return;const{results:h,tolerance:w}=s,g=2===s.options.store,{componentObjectCollection:b}=this.layerView.view.stage.renderView,y=new o(w,f,s.options.normalRequired),V=l(d,m,u),j=e(t(),m,d),R=i(t(),j),v=(e,i,t)=>{if(i>=0){if(null!=c&&!c(d,m,i))return;const e=e=>{const s=new n(this.layerView.layer.uid);e.set(this.type,s,i,t)};if(this.isGround&&(null==h.ground.distance||i<h.ground.distance)&&e(h.ground),s.options.isFiltered)return;if((null==h.min.distance||i<h.min.distance)&&e(h.min),(null==h.max.distance||i>h.max.distance)&&e(h.max),g){const i=new r(s.ray);e(i),s.results.all.push(i)}}};this.layerView.forEachVisibleTile(e=>{if(!e.boundingVolumeIntersectsRay(d,R))return;const{componentObjects:i}=e;for(const t of i)a(t.aabbInWorldCoordinates,d,V,0)&&b.intersect(t,d,m,null,y,v)})}getElevationRange(e){let i=null;return this.layerView.forEachVisibleTile(t=>{t.boundingVolumeIntersectsSphere(e)&&(i||(i=new s),i.expandElevationRange(t.elevationRange))}),i||(i=new s(0,0)),i}}const u=t();export{c as Tiles3DIntersectionHandler};
5
+ import{a as e,n as i}from"../../../../chunks/vec32.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Tiles3DTarget as t}from"../i3s/Intersector.js";import{ElevationRange as s}from"../../support/ElevationRange.js";import{IntersectorResult as r}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as o,computeInvDir as l,intersectAabbInvDir as a}from"../../webgl-engine/lib/RayIntersections.js";class c{constructor(e){this.layerView=e,this.type=8,this.slicePlaneEnabled=!1,this.isGround=!0,this.layerViewUid=e.uid}intersect(s,c,d,m,p,f){if(s.options.filteredLayerViewUids.includes(this.layerView.uid))return;const{results:g,tolerance:h}=s,w=2===s.options.store,{componentObjectCollection:b}=this.layerView.view.stage.renderView,y=new o(h,f,s.options.normalRequired),V=l(d,m,u),R=e(n(),m,d),j=i(n(),R),v=(e,i,n)=>{if(i>=0){if(null!=c&&!c(d,m,i))return;const e=e=>{const s=new t(this.layerView.layer.uid);e.set(this.type,s,i,n)};if(this.isGround&&(null==g.ground.distance||i<g.ground.distance)&&e(g.ground),s.options.isFiltered)return;if((null==g.min.distance||i<g.min.distance)&&e(g.min),(null==g.max.distance||i>g.max.distance)&&e(g.max),w){const i=new r(s.ray);e(i),s.results.all.push(i)}}};this.layerView.forEachVisibleTile(e=>{if(!e.boundingVolumeIntersectsRay(d,j))return;const{componentObjects:i}=e;for(const n of i)a(n.aabbInWorldCoordinates,d,V,0)&&b.intersect(n,d,m,null,y,v)})}getElevationRange(e){let i=null;return this.layerView.forEachVisibleTile(n=>{i?.contains(n.elevationRange)||n.boundingVolumeIntersectsSphere(e)&&(i||(i=new s),i.expandElevationRange(n.elevationRange))}),i||(i=new s(0,0)),i}}const u=n();export{c as Tiles3DIntersectionHandler};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- class i{constructor(i=1/0,a=-1/0){this.minElevation=i,this.maxElevation=a}get elevationRangeValid(){return!Number.isNaN(this.minElevation)}invalidateElevationRange(){this.minElevation=NaN}expandElevationRange(i){this.minElevation=Math.min(this.minElevation,i.minElevation),this.maxElevation=Math.max(this.maxElevation,i.maxElevation)}expandElevationRangeValues(i,a){this.minElevation=Math.min(this.minElevation,i),this.maxElevation=Math.max(this.maxElevation,a)}setElevationRange(i){this.minElevation=i.minElevation,this.maxElevation=i.maxElevation}setElevationRangeValues(i,a){this.minElevation=i,this.maxElevation=a}}export{i as ElevationRange};
5
+ class i{constructor(i=1/0,a=-1/0){this.minElevation=i,this.maxElevation=a}get elevationRangeValid(){return!Number.isNaN(this.minElevation)}contains(i){return this.minElevation<=i.minElevation&&this.maxElevation>=i.maxElevation}invalidateElevationRange(){this.minElevation=NaN}expandElevationRange(i){this.minElevation=Math.min(this.minElevation,i.minElevation),this.maxElevation=Math.max(this.maxElevation,i.maxElevation)}expandElevationRangeValues(i,a){this.minElevation=Math.min(this.minElevation,i),this.maxElevation=Math.max(this.maxElevation,a)}setElevationRange(i){this.minElevation=i.minElevation,this.maxElevation=i.maxElevation}setElevationRangeValues(i,a){this.minElevation=i,this.maxElevation=a}}export{i as ElevationRange};