@arcgis/core 5.0.0-next.69 → 5.0.0-next.70

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 (310) hide show
  1. package/Map.d.ts +3 -1
  2. package/analysis/Analysis.d.ts +1 -0
  3. package/analysis/Dimension/types.d.ts +1 -0
  4. package/analysis/DimensionAnalysis.d.ts +10 -10
  5. package/analysis/DimensionSimpleStyle.d.ts +14 -13
  6. package/analysis/DirectLineMeasurementAnalysis.d.ts +1 -1
  7. package/analysis/DistanceMeasurementAnalysis.d.ts +2 -1
  8. package/analysis/ElevationProfile/ElevationProfileLineScene.d.ts +3 -3
  9. package/analysis/ElevationProfile/ElevationProfileLineViewOptions.d.ts +1 -1
  10. package/analysis/ElevationProfile/types.d.ts +2 -0
  11. package/analysis/LengthDimension.d.ts +22 -21
  12. package/analysis/LineOfSightAnalysis.d.ts +2 -2
  13. package/analysis/ShadowCast/MinDurationOptions.d.ts +2 -2
  14. package/analysis/ShadowCast/types.d.ts +6 -2
  15. package/analysis/Slice/types.d.ts +1 -0
  16. package/analysis/Viewshed.d.ts +22 -20
  17. package/analysis/ViewshedAnalysis.d.ts +13 -13
  18. package/analysis/VolumeMeasurement/VolumeMeasurementDisplayUnits.d.ts +1 -2
  19. package/analysis/VolumeMeasurement/VolumeMeasurementInputUnits.d.ts +2 -2
  20. package/analysis/VolumeMeasurement/types.d.ts +1 -0
  21. package/analysis/VolumeMeasurementAnalysis.d.ts +1 -0
  22. package/analysis/types.d.ts +5 -0
  23. package/arcade.d.ts +2 -2
  24. package/assets/esri/core/workers/RemoteClient.js +1 -1
  25. package/assets/esri/core/workers/chunks/04364f3dd7578c2acb71.js +1 -0
  26. package/assets/esri/core/workers/chunks/18ed69d563986dc2eb21.js +1 -0
  27. package/assets/esri/core/workers/chunks/{4c04c54330b693892cfc.js → 1a45b4b4803337f4b99f.js} +2 -2
  28. package/assets/esri/core/workers/chunks/{60c7f896f2246a8aa6d7.js → 244006d4b0547d574401.js} +53 -53
  29. package/assets/esri/core/workers/chunks/329b10897c6965948b84.js +1 -0
  30. package/assets/esri/core/workers/chunks/4387aaf9d5e8f6d1833d.js +1 -0
  31. package/assets/esri/core/workers/chunks/{944dfa9309da8f49a616.js → 6a3d66d7c92f90cc2a17.js} +1 -1
  32. package/assets/esri/core/workers/chunks/760a759f9697adde6dd4.js +1 -0
  33. package/assets/esri/core/workers/chunks/798d227205bd958de6a7.js +1 -0
  34. package/assets/esri/core/workers/chunks/{9d88b4ba8e511da64583.js → 98d68b145226e7527c84.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{8ad6595ad44c2d60c1ce.js → a79fad422d41019c8232.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{10e474d664b20adcd917.js → db4661fd82dc61162115.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{1d1e25bb61eeeee8ee94.js → df2ba5f9d57080fca183.js} +1 -1
  38. package/assets/esri/themes/base/widgets/_UtilityNetworkAssociations.scss +5 -3
  39. package/assets/esri/themes/base/widgets/_UtilityNetworkValidateTopology.scss +15 -11
  40. package/assets/esri/themes/dark/main.css +1 -1
  41. package/assets/esri/themes/light/main.css +1 -1
  42. package/assets/esri/themes/light/view.css +1 -1
  43. package/chunks/ComponentShader.glsl.js +43 -43
  44. package/chunks/DefaultMaterial.glsl.js +1 -1
  45. package/config.js +1 -1
  46. package/form/elements/inputs/attachments/Input.d.ts +6 -6
  47. package/geometry/Mesh.d.ts +20 -21
  48. package/geometry/Polygon.d.ts +1 -8
  49. package/geometry/Polygon.js +1 -1
  50. package/geometry/geometryEngine.d.ts +19 -19
  51. package/geometry/support/MeshComponent.d.ts +3 -3
  52. package/geometry/support/MeshGeoreferencedVertexSpace.d.ts +2 -2
  53. package/geometry/support/MeshLocalVertexSpace.d.ts +2 -2
  54. package/geometry/support/MeshMaterial.d.ts +8 -8
  55. package/geometry/support/MeshMaterialMetallicRoughness.d.ts +1 -1
  56. package/geometry/support/MeshTexture.d.ts +3 -3
  57. package/geometry/support/MeshTextureTransform.d.ts +3 -3
  58. package/geometry/support/MeshTransform.d.ts +1 -1
  59. package/geometry/support/MeshVertexAttributes.d.ts +13 -5
  60. package/geometry/support/intersects.js +1 -1
  61. package/geometry/support/intersectsBase.js +1 -1
  62. package/geometry/support/meshUtils/centerAt.js +1 -1
  63. package/geometry/support/meshUtils/geographicUtils.js +1 -1
  64. package/geometry/support/meshUtils/georeference.js +1 -1
  65. package/geometry/support/meshUtils/rotate.js +1 -1
  66. package/geometry/support/meshUtils/scale.js +1 -1
  67. package/geometry/support/meshUtils/types.d.ts +44 -52
  68. package/geometry/support/meshUtils.d.ts +6 -50
  69. package/geometry/support/meshUtils.js +1 -1
  70. package/interfaces.d.ts +5 -151
  71. package/kernel.js +1 -1
  72. package/layers/BaseDynamicLayer.d.ts +2 -2
  73. package/layers/BaseElevationLayer.d.ts +2 -2
  74. package/layers/BuildingSceneLayer.d.ts +2 -2
  75. package/layers/CSVLayer.d.ts +2 -2
  76. package/layers/CatalogLayer.d.ts +2 -2
  77. package/layers/DimensionLayer.d.ts +2 -2
  78. package/layers/ElevationLayer.d.ts +2 -2
  79. package/layers/FeatureLayer.d.ts +2 -2
  80. package/layers/GeoJSONLayer.d.ts +2 -2
  81. package/layers/GeoRSSLayer.d.ts +2 -2
  82. package/layers/GraphicsLayer.d.ts +2 -2
  83. package/layers/GroupLayer.d.ts +2 -2
  84. package/layers/ImageryLayer.d.ts +2 -2
  85. package/layers/ImageryTileLayer.d.ts +2 -2
  86. package/layers/IntegratedMesh3DTilesLayer.d.ts +2 -2
  87. package/layers/IntegratedMeshLayer.d.ts +2 -2
  88. package/layers/KMLLayer.d.ts +2 -2
  89. package/layers/Layer.d.ts +9 -7
  90. package/layers/LineOfSightLayer.d.ts +3 -3
  91. package/layers/MapImageLayer.d.ts +2 -2
  92. package/layers/MapNotesLayer.d.ts +2 -2
  93. package/layers/MediaLayer.d.ts +2 -2
  94. package/layers/OGCFeatureLayer.d.ts +2 -2
  95. package/layers/OrientedImageryLayer.d.ts +2 -2
  96. package/layers/ParquetLayer.d.ts +2 -2
  97. package/layers/PointCloudLayer.d.ts +2 -2
  98. package/layers/RouteLayer.d.ts +2 -2
  99. package/layers/SceneLayer.d.ts +2 -2
  100. package/layers/SubtypeGroupLayer.d.ts +2 -2
  101. package/layers/TileLayer.d.ts +2 -2
  102. package/layers/UnknownLayer.d.ts +2 -2
  103. package/layers/UnsupportedLayer.d.ts +2 -2
  104. package/layers/VectorTileLayer.d.ts +2 -2
  105. package/layers/VideoLayer.d.ts +2 -2
  106. package/layers/ViewshedLayer.d.ts +2 -2
  107. package/layers/VoxelLayer.d.ts +2 -2
  108. package/layers/WCSLayer.d.ts +2 -2
  109. package/layers/WFSLayer.d.ts +2 -2
  110. package/layers/WMSLayer.d.ts +2 -2
  111. package/layers/WMTSLayer.d.ts +2 -2
  112. package/layers/catalog/CatalogDynamicGroupLayer.d.ts +2 -2
  113. package/layers/catalog/CatalogFootprintLayer.d.ts +2 -2
  114. package/layers/knowledgeGraph/KnowledgeGraphSublayer.d.ts +2 -2
  115. package/layers/orientedImagery/core/ExposurePoint.js +1 -1
  116. package/layers/orientedImagery/core/coverageUtils.js +1 -1
  117. package/layers/orientedImagery/transformations/utils.js +1 -1
  118. package/layers/raster/types.d.ts +8 -1
  119. package/layers/support/PixelBlock.d.ts +7 -7
  120. package/layers/support/RasterInfo.d.ts +2 -9
  121. package/layers/types.d.ts +77 -2
  122. package/networks/support/CircuitSection.d.ts +20 -2
  123. package/networks/support/CircuitSection.js +1 -1
  124. package/networks/support/Subcircuit.d.ts +12 -10
  125. package/networks/support/Subcircuit.js +1 -1
  126. package/networks/support/typeUtils.d.ts +2 -0
  127. package/networks/support/typeUtils.js +1 -1
  128. package/package.json +2 -2
  129. package/rest/support/AttributeBinsQuery.d.ts +7 -1
  130. package/rest/support/NormalizationBinParametersMixin.d.ts +29 -9
  131. package/support/revision.js +1 -1
  132. package/symbols/patterns/LinePattern3D.d.ts +3 -3
  133. package/symbols/patterns/Pattern3D.d.ts +3 -3
  134. package/unionTypes.d.ts +17 -17
  135. package/views/2d/analysis/AreaMeasurementAnalysisView2D.d.ts +6 -5
  136. package/views/2d/analysis/DistanceMeasurementAnalysisView2D.d.ts +7 -6
  137. package/views/2d/engine/vectorTiles/shaders/sources/shaderRepository.js +1 -1
  138. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  139. package/views/2d/types.d.ts +1 -1
  140. package/views/3d/analysis/AreaMeasurementAnalysisView3D.d.ts +2 -2
  141. package/views/3d/analysis/DirectLineMeasurement/types.d.ts +1 -0
  142. package/views/3d/analysis/ElevationProfile/ElevationProfileLineSceneComputation.js +1 -1
  143. package/views/3d/analysis/VolumeMeasurement/types.d.ts +1 -0
  144. package/views/3d/analysis/types.d.ts +2 -0
  145. package/views/3d/constraints/Constraints.d.ts +2 -2
  146. package/views/3d/environment/ChapmanApproximation.glsl.js +1 -1
  147. package/views/3d/environment/CloudsComposition.js +1 -1
  148. package/views/3d/environment/Fog.js +1 -1
  149. package/views/3d/layers/DimensionLayerView3D.js +1 -1
  150. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  151. package/views/3d/layers/I3SMeshView3D.js +1 -1
  152. package/views/3d/layers/ImageryLayerView3D.js +1 -1
  153. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  154. package/views/3d/layers/LineOfSightLayerView3D.js +1 -1
  155. package/views/3d/layers/ViewshedLayerView3D.js +1 -1
  156. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  157. package/views/3d/support/LayerPerformanceInfo.d.ts +1 -1
  158. package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
  159. package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
  160. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  161. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  162. package/views/3d/webgl-engine/collections/Component/Material/ComponentShader.glsl.js +1 -1
  163. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  164. package/views/3d/webgl-engine/collections/Component/SourceGeometry.js +1 -1
  165. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  166. package/views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepthToWriteShadowMap.glsl.js +1 -1
  167. package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +1 -1
  168. package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +3 -3
  169. package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeNormalTexture.glsl.js +7 -7
  170. package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechnique.js +1 -1
  171. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  172. package/views/3d/webgl-engine/materials/DefaultTechniqueConfiguration.js +1 -1
  173. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  174. package/views/3d/webgl-engine/materials/ViewingModeConfiguration.js +5 -0
  175. package/views/3d/webgl-engine/shaders/SphereDepthInterpolate.glsl.js +2 -2
  176. package/views/BreakpointsOwner.d.ts +9 -10
  177. package/views/MapView.d.ts +18 -17
  178. package/views/SceneView.d.ts +30 -89
  179. package/views/SceneView.js +1 -1
  180. package/views/View2D.d.ts +0 -37
  181. package/views/View2D.js +1 -1
  182. package/views/ViewAnimation.d.ts +2 -3
  183. package/views/analysis/ElevationProfile/types.d.ts +7 -6
  184. package/views/analysis/types.d.ts +1 -0
  185. package/views/animation/types.d.ts +3 -1
  186. package/views/layers/DimensionLayerView.d.ts +97 -4
  187. package/views/layers/DimensionLayerView.js +1 -1
  188. package/views/layers/HighlightLayerViewMixin.d.ts +1 -59
  189. package/views/layers/HighlightLayerViewMixin.js +1 -1
  190. package/views/layers/ImageryLayerViewMixin.d.ts +1 -55
  191. package/views/layers/LineOfSightLayerView.d.ts +77 -4
  192. package/views/layers/LineOfSightLayerView.js +1 -1
  193. package/views/layers/ViewshedLayerView.d.ts +96 -5
  194. package/views/layers/ViewshedLayerView.js +1 -1
  195. package/views/navigation/Navigation.d.ts +1 -22
  196. package/views/navigation/Navigation.js +1 -1
  197. package/views/support/Scheduler.js +1 -1
  198. package/views/types.d.ts +75 -5
  199. package/widgets/AreaMeasurement3D/AreaMeasurement3DViewModel.d.ts +4 -4
  200. package/widgets/AreaMeasurement3D.d.ts +2 -2
  201. package/widgets/BasemapGallery.d.ts +1 -1
  202. package/widgets/BasemapToggle.d.ts +1 -1
  203. package/widgets/Bookmarks.d.ts +1 -1
  204. package/widgets/BuildingExplorer/BuildingExplorerViewModel.d.ts +2 -2
  205. package/widgets/BuildingExplorer/BuildingLevel.d.ts +2 -2
  206. package/widgets/BuildingExplorer/BuildingNumericFilterViewModel.d.ts +2 -2
  207. package/widgets/BuildingExplorer/BuildingPhase.d.ts +2 -2
  208. package/widgets/BuildingExplorer.d.ts +3 -3
  209. package/widgets/Compass.d.ts +1 -1
  210. package/widgets/CoordinateConversion.d.ts +1 -1
  211. package/widgets/Daylight/DaylightViewModel.d.ts +3 -3
  212. package/widgets/Daylight/VisibleElements.d.ts +2 -2
  213. package/widgets/Daylight/types.d.ts +2 -2
  214. package/widgets/Daylight.d.ts +3 -3
  215. package/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.d.ts +4 -4
  216. package/widgets/DirectLineMeasurement3D.d.ts +2 -2
  217. package/widgets/DirectionalPad.d.ts +1 -1
  218. package/widgets/ElevationProfile/ElevationProfileLine.d.ts +2 -2
  219. package/widgets/ElevationProfile/ElevationProfileLineGround.d.ts +2 -2
  220. package/widgets/ElevationProfile/ElevationProfileLineInput.d.ts +2 -2
  221. package/widgets/ElevationProfile/ElevationProfileLineQuery.d.ts +2 -2
  222. package/widgets/ElevationProfile/ElevationProfileLineView.d.ts +3 -3
  223. package/widgets/ElevationProfile/ElevationProfileViewModel.d.ts +2 -2
  224. package/widgets/ElevationProfile/ElevationProfileVisibleElements.d.ts +2 -2
  225. package/widgets/ElevationProfile/types.d.ts +9 -9
  226. package/widgets/ElevationProfile.d.ts +2 -2
  227. package/widgets/Expand/ExpandViewModel.d.ts +1 -1
  228. package/widgets/Expand.d.ts +1 -1
  229. package/widgets/Feature.d.ts +1 -1
  230. package/widgets/FeatureTable/FeatureTableViewModel.d.ts +1 -1
  231. package/widgets/Features.d.ts +1 -1
  232. package/widgets/Fullscreen/FullscreenViewModel.d.ts +1 -1
  233. package/widgets/Fullscreen.d.ts +1 -1
  234. package/widgets/Home.d.ts +1 -1
  235. package/widgets/LayerList.d.ts +12 -0
  236. package/widgets/Legend.d.ts +1 -1
  237. package/widgets/LineOfSight/LineOfSightTarget.d.ts +2 -2
  238. package/widgets/LineOfSight/LineOfSightViewModel.d.ts +2 -2
  239. package/widgets/LineOfSight.d.ts +2 -2
  240. package/widgets/Locate/LocateViewModel.d.ts +1 -1
  241. package/widgets/Locate.d.ts +1 -1
  242. package/widgets/NavigationToggle/NavigationToggleViewModel.d.ts +1 -1
  243. package/widgets/NavigationToggle.d.ts +1 -1
  244. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  245. package/widgets/OrientedImageryViewer/components/Arrow.js +1 -1
  246. package/widgets/OrientedImageryViewer/components/ImageViewer.js +1 -1
  247. package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
  248. package/widgets/OrientedImageryViewer/components/NavigationNode.js +1 -1
  249. package/widgets/OrientedImageryViewer/components/NavigationUI360.js +1 -1
  250. package/widgets/OrientedImageryViewer/components/NavigationUIPanoramicViewModel.js +1 -1
  251. package/widgets/OrientedImageryViewer/components/NavigationUIViewModel.js +1 -1
  252. package/widgets/OrientedImageryViewer/components/SequentialNavigationUI.js +1 -1
  253. package/widgets/OrientedImageryViewer/constants.js +1 -1
  254. package/widgets/OrientedImageryViewer/navigation/NavigationManager.js +1 -1
  255. package/widgets/OrientedImageryViewer/navigation/NavigationManagerPanoramic.js +1 -1
  256. package/widgets/OrientedImageryViewer/navigation/utils.js +1 -1
  257. package/widgets/OrientedImageryViewer/support/MediaPrefetcher.js +5 -0
  258. package/widgets/OrientedImageryViewer/support/NonPanoramicMedia.js +1 -1
  259. package/widgets/OrientedImageryViewer/support/NonPanoramicMediaCollection.js +1 -1
  260. package/widgets/OrientedImageryViewer/support/resolveMediaProps.js +5 -0
  261. package/widgets/OrientedImageryViewer/utils.js +1 -1
  262. package/widgets/OrientedImageryViewer.js +1 -1
  263. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  264. package/widgets/PanoramicViewer.js +1 -1
  265. package/widgets/Print/CustomTemplate.d.ts +1 -1
  266. package/widgets/Print/PrintViewModel.d.ts +1 -1
  267. package/widgets/Print.d.ts +1 -1
  268. package/widgets/ScaleBar.d.ts +1 -1
  269. package/widgets/Search.d.ts +1 -1
  270. package/widgets/ShadowCast/DiscreteOptions.d.ts +2 -2
  271. package/widgets/ShadowCast/DurationOptions.d.ts +2 -2
  272. package/widgets/ShadowCast/ShadowCastViewModel.d.ts +3 -3
  273. package/widgets/ShadowCast/ShadowCastVisibleElements.d.ts +2 -2
  274. package/widgets/ShadowCast/ThresholdOptions.d.ts +2 -2
  275. package/widgets/ShadowCast/types.d.ts +2 -2
  276. package/widgets/ShadowCast.d.ts +1 -1
  277. package/widgets/Slice/SliceViewModel.d.ts +2 -2
  278. package/widgets/Slice.d.ts +2 -2
  279. package/widgets/Swipe.d.ts +1 -1
  280. package/widgets/TimeZoneLabel.d.ts +1 -1
  281. package/widgets/Track.d.ts +1 -1
  282. package/widgets/UtilityNetworkValidateTopology.js +1 -1
  283. package/widgets/VideoPlayer.d.ts +1 -1
  284. package/widgets/VideoPlayer.js +1 -1
  285. package/widgets/Weather/VisibleElements.d.ts +2 -2
  286. package/widgets/Weather/WeatherViewModel.d.ts +2 -2
  287. package/widgets/Weather/types.d.ts +1 -1
  288. package/widgets/Weather.d.ts +2 -2
  289. package/widgets/Zoom.d.ts +1 -1
  290. package/widgets/support/GridControls.d.ts +1 -1
  291. package/assets/esri/core/workers/chunks/35961e71f69ae1d24b9e.js +0 -1
  292. package/assets/esri/core/workers/chunks/3cce8e894bf37c3e598e.js +0 -1
  293. package/assets/esri/core/workers/chunks/7ee68f67f9cc48a328f0.js +0 -1
  294. package/assets/esri/core/workers/chunks/a931515a2569713e743b.js +0 -1
  295. package/assets/esri/core/workers/chunks/bb4574a87ca21e719f0d.js +0 -1
  296. package/assets/esri/core/workers/chunks/c9f868f85d740ee32715.js +0 -1
  297. package/geometry.d.ts +0 -136
  298. package/geometry.js +0 -5
  299. package/pointCloudRenderers.d.ts +0 -112
  300. package/pointCloudRenderers.js +0 -5
  301. package/rasterRenderers.d.ts +0 -151
  302. package/rasterRenderers.js +0 -5
  303. package/renderers.d.ts +0 -166
  304. package/renderers.js +0 -5
  305. package/views/layers/DimensionLayerViewMixin.d.ts +0 -1
  306. package/views/layers/DimensionLayerViewMixin.js +0 -5
  307. package/views/layers/LineOfSightLayerViewMixin.d.ts +0 -1
  308. package/views/layers/LineOfSightLayerViewMixin.js +0 -5
  309. package/views/layers/ViewshedLayerViewMixin.d.ts +0 -98
  310. package/views/layers/ViewshedLayerViewMixin.js +0 -5
@@ -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{lerp as t,smoothstep as s}from"../../../core/mathUtils.js";import{watch as r,syncAndInitial as i}from"../../../core/reactiveUtils.js";import{property as a,subclass as o}from"../../../core/accessorSupport/decorators.js";import{d as n,n as h,g as m,j as c,l as p,b as l}from"../../../chunks/vec32.js";import{fromValues as u,create as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as _}from"../../../geometry/ellipsoidUtils.js";import{InternalRenderCategory as g}from"../webgl.js";import{F as f}from"../../../chunks/Fog.glsl.js";import{FogTechnique as w}from"./FogTechnique.js";import{FogTechniqueConfiguration as P}from"./FogTechniqueConfiguration.js";import{heightLimit as b}from"./weather.js";import{TransparentEnvironment as v}from"../webgl-engine/effects/TransparentEnvironment.js";import{Blit as y}from"../webgl-engine/effects/blit/Blit.js";import{ColorAttachment1 as j,DepthStencilAttachment as F}from"../../webgl/enums.js";const E=.95,R=1;let T=class extends v{constructor(e){super(e),this.consumes={required:[g.TRANSPARENT_ENVIRONMENT]},this._configuration=new P,this._newParameters=new q,this._oldParameters=new q,this._fadedParameters=new q,this._parameters=this._newParameters,this._passParameters=new f,this._blit=null;const t=_(e.view.spatialReference);this._planetRadius=t.radius,this._atmosphereRadius=t.radius+t.atmosphereHeight;const s=e.view.stage.renderView.techniques;s.precompile(w,this._configuration),this._configuration.hasEmissive=!this._configuration.hasEmissive,s.precompile(w,this._configuration),this._configuration.hasEmissive=!this._configuration.hasEmissive}toogle(){this.view.environment.atmosphereEnabled&&this.view.environment.weather?this._enable():this._disable()}initialize(){this.addHandles([r(()=>this.view.environment.atmosphereEnabled,()=>this.toogle(),i),r(()=>this.view.environment.weather,()=>this.toogle(),i),r(()=>this._updateFogParameters(),()=>{},i)]),this.addHandles(r(()=>this._fadeFactor,e=>this._fade(e),i))}get _fadeFactor(){return this.view.stage?.renderer.renderContext.bind.clouds.fadeFactor??1}_fade(e){const{_newParameters:t,_oldParameters:s}=this;e>=1?(this._parameters=t,this._oldParameters.copyFrom(this._newParameters)):e<=0?this._parameters=s:(this._fadedParameters.lerp(s,t,e),this._parameters=this._fadedParameters)}_updateFogParameters(){const e=this.view.environment.weather,s="foggy"===e.type||"snowy"===e.type||"rainy"===e.type;this._newParameters.strength="foggy"===e.type?t(3e-5,.005,e.fogStrength**3):"snowy"===e.type||"rainy"===e.type?t(4e-6,2e-4,(e.precipitation??0)**3):0,this._newParameters.amount=s?1:0,"foggy"!==e.type&&"snowy"!==e.type||n(this._newParameters.color,C),"rainy"===e.type&&n(this._newParameters.color,A),this._fadeFactor>=1&&this._oldParameters.copyFrom(this._newParameters),this.requestRender(2)}render(e){const t=e.find(({name:e})=>e===g.TRANSPARENT_ENVIRONMENT);if(0===this._parameters.amount)return t;if(this._update(),this._passParameters.amount<=0)return t;const s=t.getAttachment(j);this._configuration.hasEmissive=null!=s;const r=this.techniques.get(w,this._configuration);if(!r.compiled)return this.requestRender(1),t;const i=t.getAttachment(F),a=this.renderingContext,{fullWidth:o,fullHeight:n}=this.bindParameters.camera,h=o,m=n;let c=null;return s&&(c=this.fboCache.acquire(h,m,"glow horizontal",8),this._blit??=new y(this.techniques),this._blit.blitTexture(a,s?.attachment,c,this.bindParameters)),t.attachDepth(null),a.bindFramebuffer(t.fbo),s&&(this._passParameters.emission=c?.getTexture()),a.bindTechnique(r,this.bindParameters,this._passParameters),a.screen.draw(),t.attachDepth(i),c?.release(),t}_update(){const e=this.bindParameters.camera;h(N,e.eye);const t=Math.max(0,m(N,this.bindParameters.lighting.mainLight.direction)),r=this._parameters.color;c(x,r,.1),p(this._passParameters.color,x,r,t);const i=l(e.eye);this._passParameters.atmosphereC=i**2-this._atmosphereRadius**2,this._passParameters.amount=(1-s(E*b,R*b,Math.abs(i-this._planetRadius)))*this._parameters.amount,this._passParameters.strength=this._parameters.strength}get test(){return{parameters:this._passParameters}}};e([a()],T.prototype,"consumes",void 0),T=e([o("esri.views.3d.environment.Fog")],T);class q{constructor(){this.color=d(),this.strength=0,this.amount=0}copyFrom(e){this.amount=e.amount,this.strength=e.strength,n(this.color,e.color)}lerp(e,s,r){this.amount=t(e.amount,s.amount,r),this.strength=t(e.strength,s.strength,r),p(this.color,e.color,s.color,r)}}const N=d(),x=d(),A=u(.5,.5,.5),C=u(1.5,1.5,1.5);export{T as Fog,q as FogParameters};
5
+ import{__decorate as e}from"tslib";import{lerp as t,smoothstep as s}from"../../../core/mathUtils.js";import{watch as r,syncAndInitial as i}from"../../../core/reactiveUtils.js";import{subclass as a}from"../../../core/accessorSupport/decorators.js";import{d as o,n,g as h,j as m,l as c,b as p}from"../../../chunks/vec32.js";import{fromValues as l,create as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as d}from"../../../geometry/ellipsoidUtils.js";import{InternalRenderCategory as g}from"../webgl.js";import{F as _}from"../../../chunks/Fog.glsl.js";import{FogTechnique as f}from"./FogTechnique.js";import{FogTechniqueConfiguration as w}from"./FogTechniqueConfiguration.js";import{heightLimit as P}from"./weather.js";import{TransparentEnvironment as b}from"../webgl-engine/effects/TransparentEnvironment.js";import{Blit as v}from"../webgl-engine/effects/blit/Blit.js";import{ColorAttachment1 as y,DepthStencilAttachment as j}from"../../webgl/enums.js";const F=.95,E=1;let R=class extends b{constructor(e){super(e),this._configuration=new w,this._newParameters=new q,this._oldParameters=new q,this._fadedParameters=new q,this._parameters=this._newParameters,this._passParameters=new _,this._blit=null;const t=d(e.view.spatialReference);this._planetRadius=t.radius,this._atmosphereRadius=t.radius+t.atmosphereHeight;const s=e.view.stage.renderView.techniques;s.precompile(f,this._configuration),this._configuration.hasEmissive=!this._configuration.hasEmissive,s.precompile(f,this._configuration),this._configuration.hasEmissive=!this._configuration.hasEmissive}toogle(){this.view.environment.atmosphereEnabled&&this.view.environment.weather?this._enable():this._disable()}initialize(){this.addHandles([r(()=>this.view.environment.atmosphereEnabled,()=>this.toogle(),i),r(()=>this.view.environment.weather,()=>this.toogle(),i),r(()=>this._updateFogParameters(),()=>{},i)]),this.addHandles(r(()=>this._fadeFactor,e=>this._fade(e),i))}get _fadeFactor(){return this.view.stage?.renderer.renderContext.bind.clouds.fadeFactor??1}_fade(e){const{_newParameters:t,_oldParameters:s}=this;e>=1?(this._parameters=t,this._oldParameters.copyFrom(this._newParameters)):e<=0?this._parameters=s:(this._fadedParameters.lerp(s,t,e),this._parameters=this._fadedParameters)}_updateFogParameters(){const e=this.view.environment.weather,s="foggy"===e.type||"snowy"===e.type||"rainy"===e.type;this._newParameters.strength="foggy"===e.type?t(3e-5,.005,e.fogStrength**3):"snowy"===e.type||"rainy"===e.type?t(4e-6,2e-4,(e.precipitation??0)**3):0,this._newParameters.amount=s?1:0,"foggy"!==e.type&&"snowy"!==e.type||o(this._newParameters.color,N),"rainy"===e.type&&o(this._newParameters.color,C),this._fadeFactor>=1&&this._oldParameters.copyFrom(this._newParameters),this.requestRender(2)}render(e){const t=e.find(({name:e})=>e===g.TRANSPARENT_ENVIRONMENT);if(0===this._parameters.amount)return t;if(this._update(),this._passParameters.amount<=0)return t;const s=t.getAttachment(y);this._configuration.hasEmissive=null!=s;const r=this.techniques.get(f,this._configuration);if(!r.compiled)return this.requestRender(1),t;const i=t.getAttachment(j),a=this.renderingContext,{fullWidth:o,fullHeight:n}=this.bindParameters.camera,h=o,m=n;let c=null;return s&&(c=this.fboCache.acquire(h,m,"glow horizontal",8),this._blit??=new v(this.techniques),this._blit.blitTexture(a,s?.attachment,c,this.bindParameters)),t.attachDepth(null),a.bindFramebuffer(t.fbo),s&&(this._passParameters.emission=c?.getTexture()),a.bindTechnique(r,this.bindParameters,this._passParameters),a.screen.draw(),t.attachDepth(i),c?.release(),t}_update(){const e=this.bindParameters.camera;n(T,e.eye);const t=Math.max(0,h(T,this.bindParameters.lighting.mainLight.direction)),r=this._parameters.color;m(x,r,.1),c(this._passParameters.color,x,r,t);const i=p(e.eye);this._passParameters.atmosphereC=i**2-this._atmosphereRadius**2,this._passParameters.amount=(1-s(F*P,E*P,Math.abs(i-this._planetRadius)))*this._parameters.amount,this._passParameters.strength=this._parameters.strength}get test(){return{parameters:this._passParameters}}};R=e([a("esri.views.3d.environment.Fog")],R);class q{constructor(){this.color=u(),this.strength=0,this.amount=0}copyFrom(e){this.amount=e.amount,this.strength=e.strength,o(this.color,e.color)}lerp(e,s,r){this.amount=t(e.amount,s.amount,r),this.strength=t(e.strength,s.strength,r),c(this.color,e.color,s.color,r)}}const T=u(),x=u(),C=l(.5,.5,.5),N=l(1.5,1.5,1.5);export{R as Fog,q as FogParameters};
@@ -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 s}from"tslib";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import{subclass as e}from"../../../core/accessorSupport/decorators/subclass.js";import{LayerView3D as a}from"./LayerView3D.js";import{LayerViewAnalysisViewManager as r}from"./support/LayerViewAnalysisViewManager.js";import{DimensionLayerViewMixin as n}from"../../layers/DimensionLayerViewMixin.js";import t from"../../layers/LayerView.js";var o;let l=class extends(a(n(t))){static{o=this}constructor(s){super(s),this.type="dimension-3d",this._analysisViewManager=null}initialize(){this._analysisViewManager=new r({getAnalysis:()=>this.layer.analysis,loadAnalysisViewModule:o.loadAnalysisViewModule,parent:this}),this.addResolvingPromise(this._analysisViewManager.whenAnalysisView())}destroy(){this._analysisViewManager.destroy()}get analysisView(){return this._analysisViewManager.analysisView}whenAnalysisView(){return this._analysisViewManager.whenAnalysisView()}isUpdating(){return this._analysisViewManager.updating}static{this.loadAnalysisViewModule=()=>import("../analysis/DimensionAnalysisView3D.js")}};s([i()],l.prototype,"type",void 0),s([i()],l.prototype,"_analysisViewManager",void 0),s([i({readOnly:!0})],l.prototype,"analysisView",null),l=o=s([e("esri.views.3d.layers.DimensionLayerView3D")],l);const y=l;export{y as default};
5
+ import{__decorate as s}from"tslib";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import{subclass as e}from"../../../core/accessorSupport/decorators/subclass.js";import{LayerView3D as a}from"./LayerView3D.js";import{LayerViewAnalysisViewManager as r}from"./support/LayerViewAnalysisViewManager.js";import n from"../../layers/DimensionLayerView.js";var t;let o=class extends(a(n)){static{t=this}constructor(s){super(s),this.type="dimension-3d",this._analysisViewManager=null}initialize(){this._analysisViewManager=new r({getAnalysis:()=>this.layer.analysis,loadAnalysisViewModule:t.loadAnalysisViewModule,parent:this}),this.addResolvingPromise(this._analysisViewManager.whenAnalysisView())}destroy(){this._analysisViewManager.destroy()}get analysisView(){return this._analysisViewManager.analysisView}whenAnalysisView(){return this._analysisViewManager.whenAnalysisView()}isUpdating(){return this._analysisViewManager.updating}static{this.loadAnalysisViewModule=()=>import("../analysis/DimensionAnalysisView3D.js")}};s([i()],o.prototype,"type",void 0),s([i()],o.prototype,"_analysisViewManager",void 0),s([i({readOnly:!0})],o.prototype,"analysisView",null),o=t=s([e("esri.views.3d.layers.DimensionLayerView3D")],o);const l=o;export{l 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{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{removeMaybe as s}from"../../../core/maybe.js";import{watch as i,syncAndInitial as r}from"../../../core/reactiveUtils.js";import{convertUnit as a}from"../../../core/units.js";import{property as n,subclass as o}from"../../../core/accessorSupport/decorators.js";import{fromValues as l}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{isCompatible as h}from"../../../geometry/support/heightModelInfoUtils.js";import{isPlateCarree as u,isWebMercator as d,equals as m}from"../../../geometry/support/spatialReferenceUtils.js";import{getHeightModelInfoFromVCS as p}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as f}from"../../../support/elevationInfoUtils.js";import{getMetersPerUnit as c}from"../../../symbols/support/unitConversionUtils.js";import{GaussianSplatLayerViewPerformanceInfo as y}from"./GaussianSplatLayerViewPerformanceInfo.js";import{LayerView3D as _}from"./LayerView3D.js";import{addLayerViewToWasm as g,getLyr3DWasm as w,removeLayerViewFromWasm as b}from"./Lyr3DWasm.js";import{Obb as C}from"../support/orientedBoundingBox.js";import{splatPageSizeInU32 as v,elementsPerSplatPage as S,packedGaussianSizeInU32 as M,splatPageSizeInU32WithoutHeader as x,gaussiansPerSplatPage as H,splatAtlasTextureWidth as U}from"../support/gaussianSplatting/GaussianSplatAtlasPages.js";import{GaussianSplatFadeHelper as V}from"../support/gaussianSplatting/GaussianSplatFadeHelper.js";import{GaussianTile as j}from"../support/gaussianSplatting/GaussianTile.js";import{GaussianSplatRenderNode as G}from"../webgl-engine/lib/GaussianSplatRenderNode.js";import A from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as I,isInEffectiveScaleRange as L}from"../../support/layerViewUtils.js";const O=()=>t.getLogger("esri.views.3d.layers.GaussianSplatLayerView3D");let R=class extends(_(A)){constructor(e){super(e),this.type="gaussian-splat-3d",this.ignoresMemoryFactor=!1,this._tileHandles=new Map,this._pageBuffer=new Uint32Array(v),this._wasmLayerId=-1,this._metersPerVCSUnit=1,this._usedMemory=0,this._cacheMemory=0,this._useEsriCrs=!1,this.fullExtentInLocalViewSpatialReference=null,this._suspendedHandle=null,this._conversionBuffer=new ArrayBuffer(4),this._u32View=new Uint32Array(this._conversionBuffer),this._f32View=new Float32Array(this._conversionBuffer);const{view:t}=e;this._memCache=t.resourceController.memoryController.newCache(`GaussianSplat-${this.uid}`,e=>this._deleteTile(e)),this._fadeHelper=new V(this),this._renderNode=new G({view:t,fadeHelper:this._fadeHelper})}initialize(){if(!this._canProjectWithoutEngine())throw I("layer",this.layer.spatialReference.wkid,this.view.renderSpatialReference?.wkid);const e=g(this).then(e=>{this._wasmLayerId=e,this.addHandles([i(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e))]),this._suspendedHandle=i(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),r),this.setMaximumGaussianCount(this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians)});this.addHandles([i(()=>this.view.qualitySettings.fadeDuration,e=>{this._fadeHelper.onFadeDurationChanged(e),this.data.fadingTexture.updateTexture(this.data.textureAtlas.pageAllocator.pageCount)}),i(()=>this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians,e=>this.setMaximumGaussianCount(e))]),this.addResolvingPromise(e)}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get tileHandles(){return this._tileHandles}get _wasm(){return w(this.view)}get usedMemory(){return this._usedMemory}get cachedMemory(){return this._cacheMemory}get unloadedMemory(){return 0}get useEsriCrs(){return this._useEsriCrs}get data(){return this._renderNode.data}get visibleAtCurrentScale(){return L(this.layer.effectiveScaleRange,this.view.scale)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&(e.isUpdating(this._wasmLayerId)||this._renderNode.data.isUpdating()||this._fadeHelper.isUpdating())}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const s=t.desc.prims[0],i=s.vertexCount,r=s.atrbs[0].view,a=s.atrbs[0].view.byteCount,n=s.atrbs[0].view.byteOffset;let o=null;if("U32"!==r.type)return O().warnOnce("unexpected meshData.data format"),{memUsageBytes:0,numGaussians:0};o=new Uint32Array(t.data.buffer,n,a/4);const h=this.extractHeader(o),u=Math.ceil(i/H),d=new Uint32Array(i),m=[];for(let l=0;l<u;l++){let e=this.data.textureAtlas.requestPage();if(null===e&&(this._freeInvisibleTiles(),e=this.data.textureAtlas.requestPage()),null===e)return O().warnOnce("ran out of gaussian splat memory"),{memUsageBytes:0,numGaussians:0};{m.push(e);const t=i-l*H,s=Math.min(t,H),r=l*H;for(let i=0;i<s;i++)d[i+r]=i+S*e;const a=l*x;this._pageBuffer.set(o.subarray(a,a+s*M)),this._pageBuffer.set(h.packedHeader,x);const n=e*S,u=n%U,p=Math.floor(n/U);this.data.textureAtlas.update(u,p,this._pageBuffer)}}const p=new Float64Array(3*i),f=new Float64Array(i),c=2.048,y=h.tileOrigin.x*c,_=h.tileOrigin.y*c,g=h.tileOrigin.z*c,w=h.invPosScale;let b=0,v=0;for(let l=0;l<i;l++){const e=l*M,{rawX:t,rawY:s,rawZ:i}=this._extractGaussianPosition(o,e),r=this._extractGaussianSphericalScale(o,e);p[b]=t*w+y,p[b+1]=s*w+_,p[b+2]=i*w+g,f[l]=r*r,v=Math.max(v,r),b+=3}let V=null;if(t.desc.obb){const e=t.desc.obb.quaternion;V=new C(t.desc.obb.center,t.desc.obb.halfSize,l(...e))}V||(O().warnOnce("encountered tile without a bounding box"),V=new C);const G=new j(e.handle,V,d,m,p,f,v);return this._memCache.put(`${G.handle}`,G),this._tileHandles.set(e.handle,G),this._cacheMemory+=G.usedMemory,{memUsageBytes:G.usedMemory,numGaussians:i}}_extractGaussianPosition(e,t){const s=e[t+1];return{rawX:16383&s,rawY:s>>>14&16383,rawZ:s>>>28&15|(1023&e[t+2])<<4}}_extractGaussianSphericalScale(e,t){const s=e[t+2],i=s>>>10&255,r=s>>>18&255,a=s>>>26&63|(3&e[t+3])<<6,n=Math.exp(i/16-10),o=Math.exp(r/16-10),l=Math.exp(a/16-10);return Math.max(n,o,l)}freeRenderable(e){const t=this._tileHandles.get(e);t&&(t.isVisible&&!this._fadeHelper.isTileFadingOut(t)?this._usedMemory-=t.usedMemory:this._cacheMemory-=t.usedMemory,t.pageIds.forEach(e=>this.data.textureAtlas.freePage(e)),this.freeObject(t),this._tileHandles.delete(e)),this.updateGaussians()}freeObject(e){this._memCache.pop(`${e.handle}`)}setRenderableVisibility(e,t,s){for(let i=0;i<s;i++){if(!t[i])continue;const s=e[i],r=this._tileHandles.get(s);r&&(r.isVisible&&!this._fadeHelper.isTileFadingOut(r)||(r.isVisible=!0,this._fadeHelper.isTileFadingOut(r)||this._popTileFromCache(r),this._fadeHelper.fadeTile(r,0)))}for(let i=0;i<s;i++){if(t[i])continue;const s=e[i],r=this._tileHandles.get(s);r&&r.isVisible&&this._fadeHelper.fadeTile(r,1)}this.updateGaussians()}_popTileFromCache(e){this._usedMemory+=e.usedMemory,this._cacheMemory-=e.usedMemory,this._memCache.pop(`${e.handle}`)}moveTileToCache(e){this._usedMemory-=e.usedMemory,this._cacheMemory+=e.usedMemory,this._memCache.put(`${e.handle}`,e)}destroy(){b(this),this._suspendedHandle&&(this._suspendedHandle=s(this._suspendedHandle)),this._renderNode.destroy(),this._memCache.destroy()}_canProjectWithoutEngine(){if(1===this.view.state.viewingMode)return!0;if(u(this.view.renderSpatialReference)||d(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&m(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){const e=p(this.layer.esriCrsSpatialReference),t=this.view.heightModelInfo;return this._useEsriCrs=0===h(e,t,!1),this._useEsriCrs&&e&&(this._metersPerVCSUnit=a(1,"meters",e.heightUnit),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}_elevationInfoChanged(e){if(e?.offset)if(this._useEsriCrs){const t=c(e?.unit)/this._metersPerVCSUnit,s=e?.offset??0;this._wasm?.setLayerOffset(this,s*t)}else this._wasm?.setLayerOffset(this,f(e));else this._wasm?.setLayerOffset(this,0)}updateGaussians(){const e=new Array;for(const t of this._tileHandles.values())t.isVisible&&e.push(t);this.data.updateGaussianVisibility(e),this.notifyChange("updating")}setMaximumGaussianCount(e){this._wasm?.setMaximumGaussianSplatCount(e)}_freeInvisibleTiles(){for(const e of this._tileHandles.values())e.isVisible||this._deleteTile(e)}extractHeader(e){const t=e.length-4,s=this.reinterpretU32AsFloat(e[t]),i=this.reinterpretU32AsFloat(e[t+1]),r=this.reinterpretU32AsFloat(e[t+2]),a=1/(1<<(255&e[t+3]));return{packedHeader:e.subarray(t,t+4),tileOrigin:{x:s,y:i,z:r},invPosScale:a}}_deleteTile(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}reinterpretU32AsFloat(e){return this._u32View[0]=e,this._f32View[0]}get performanceInfo(){let e=0,t=0;return this._tileHandles.forEach(s=>{s.isVisible?e++:t++}),new y(this.usedMemory,e,t,this.cachedMemory)}get test(){}};e([n()],R.prototype,"layer",void 0),e([n({readOnly:!0})],R.prototype,"visibleAtCurrentScale",null),e([n()],R.prototype,"fullExtentInLocalViewSpatialReference",void 0),R=e([o("esri.views.3d.layers.GaussianSplatLayerView3D")],R);const E=R;export{E as default};
5
+ import{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{removeMaybe as s}from"../../../core/maybe.js";import{watch as i,syncAndInitial as a}from"../../../core/reactiveUtils.js";import{convertUnit as r}from"../../../core/units.js";import{property as n,subclass as o}from"../../../core/accessorSupport/decorators.js";import{fromValues as l}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{isCompatible as h}from"../../../geometry/support/heightModelInfoUtils.js";import{isPlateCarree as u,isWebMercator as d,equals as m}from"../../../geometry/support/spatialReferenceUtils.js";import{getHeightModelInfoFromVCS as p}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as c}from"../../../support/elevationInfoUtils.js";import{getMetersPerUnit as f}from"../../../symbols/support/unitConversionUtils.js";import{GaussianSplatLayerViewPerformanceInfo as _}from"./GaussianSplatLayerViewPerformanceInfo.js";import{LayerView3D as y}from"./LayerView3D.js";import{addLayerViewToWasm as g,getLyr3DWasm as w,removeLayerViewFromWasm as S}from"./Lyr3DWasm.js";import{Obb as b}from"../support/orientedBoundingBox.js";import{splatPageSizeInU32 as v,elementsPerSplatPage as C,packedGaussianSizeInU32 as M,splatPageSizeInU32WithoutHeader as x,gaussiansPerSplatPage as H,splatAtlasTextureWidth as U}from"../support/gaussianSplatting/GaussianSplatAtlasPages.js";import{GaussianSplatFadeHelper as T}from"../support/gaussianSplatting/GaussianSplatFadeHelper.js";import{GaussianTile as A}from"../support/gaussianSplatting/GaussianTile.js";import{GaussianSplatRenderNode as j}from"../webgl-engine/lib/GaussianSplatRenderNode.js";import V from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as G,isInEffectiveScaleRange as L}from"../../support/layerViewUtils.js";import{TaskPriority as E}from"../../support/Scheduler.js";const I=()=>t.getLogger("esri.views.3d.layers.GaussianSplatLayerView3D");let R=class extends(y(V)){constructor(e){super(e),this.type="gaussian-splat-3d",this.ignoresMemoryFactor=!1,this._tileHandles=new Map,this._pageBuffer=new Uint32Array(v),this._frameTask=null,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this._usedMemory=0,this._cacheMemory=0,this._useEsriCrs=!1,this.fullExtentInLocalViewSpatialReference=null,this._suspendedHandle=null,this._conversionBuffer=new ArrayBuffer(4),this._u32View=new Uint32Array(this._conversionBuffer),this._f32View=new Float32Array(this._conversionBuffer);const{view:t}=e;this._memCache=t.resourceController.memoryController.newCache(`GaussianSplat-${this.uid}`,e=>this._deleteTile(e)),this._fadeHelper=new T(this),this._renderNode=new j({view:t,fadeHelper:this._fadeHelper})}initialize(){if(!this._canProjectWithoutEngine())throw G("layer",this.layer.spatialReference.wkid,this.view.renderSpatialReference?.wkid);const e=g(this).then(e=>{this._wasmLayerId=e,this.addHandles([i(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e))]),this._suspendedHandle=i(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),a),this.setMaximumGaussianCount(this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians)});this.addHandles([i(()=>this.view.qualitySettings.fadeDuration,e=>{this._fadeHelper.onFadeDurationChanged(e),this.data.fadingTexture.updateTexture(this.data.textureAtlas.pageAllocator.pageCount)}),i(()=>this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians,e=>this.setMaximumGaussianCount(e))]),this.addResolvingPromise(e),this._frameTask=this.view.resourceController.scheduler.registerTask(E.GAUSSIAN_SPLAT_TEXTURE_ATLAS)}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get tileHandles(){return this._tileHandles}get _wasm(){return w(this.view)}get usedMemory(){return this._usedMemory}get cachedMemory(){return this._cacheMemory}get unloadedMemory(){return 0}get useEsriCrs(){return this._useEsriCrs}get data(){return this._renderNode.data}get visibleAtCurrentScale(){return L(this.layer.effectiveScaleRange,this.view.scale)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&(e.isUpdating(this._wasmLayerId)||this._renderNode.data.isUpdating()||this._fadeHelper.isUpdating())}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const s=t.desc.prims[0],i=s.vertexCount,a=s.atrbs[0].view,r=s.atrbs[0].view.byteCount,n=s.atrbs[0].view.byteOffset;let o=null;if("U32"!==a.type)return I().warnOnce("unexpected meshData.data format"),{memUsageBytes:0,numGaussians:0};o=new Uint32Array(t.data.buffer,n,r/4);const h=this.extractHeader(o),u=Math.ceil(i/H),d=new Uint32Array(i),m=new Array;let p=!1,c=0;const f=async e=>{for(;c<u&&!e.done&&!p;c++){let t=this.data.textureAtlas.requestPage();if(null===t&&(this._freeInvisibleTiles(),t=this.data.textureAtlas.requestPage()),null!==t){m.push(t);const s=i-c*H,a=Math.min(s,H),r=c*H;for(let e=0;e<a;e++)d[e+r]=e+C*t;const n=c*x;this._pageBuffer.set(o.subarray(n,n+a*M)),this._pageBuffer.set(h.packedHeader,x);const l=t*C,u=l%U,p=Math.floor(l/U);this.data.textureAtlas.update(u,p,this._pageBuffer),e.madeProgress()}else p=!0}c<u&&!p&&await this._frameTask.schedule(f)};if(await this._frameTask.schedule(f),p)return I().warnOnce("ran out of gaussian splat memory"),{memUsageBytes:0,numGaussians:0};const _=new Float64Array(3*i),y=new Float64Array(i),g=2.048,w=h.tileOrigin.x*g,S=h.tileOrigin.y*g,v=h.tileOrigin.z*g,T=h.invPosScale;let j=0,V=0,G=0;const L=async e=>{for(;G<i&&!e.done;G++){const t=G*M,{rawX:s,rawY:i,rawZ:a}=this._extractGaussianPosition(o,t),r=this._extractGaussianSphericalScale(o,t);_[j]=s*T+w,_[j+1]=i*T+S,_[j+2]=a*T+v,y[G]=r*r,V=Math.max(V,r),j+=3,e.madeProgress()}G<i&&await this._frameTask.schedule(L)};await this._frameTask.schedule(L);let E=null;if(t.desc.obb){const e=t.desc.obb.quaternion;E=new b(t.desc.obb.center,t.desc.obb.halfSize,l(...e))}E||(I().warnOnce("encountered tile without a bounding box"),E=new b);const R=new A(e.handle,E,d,m,_,y,V);return this._memCache.put(`${R.handle}`,R),this._tileHandles.set(e.handle,R),this._cacheMemory+=R.usedMemory,{memUsageBytes:R.usedMemory,numGaussians:i}}_extractGaussianPosition(e,t){const s=e[t+1];return{rawX:16383&s,rawY:s>>>14&16383,rawZ:s>>>28&15|(1023&e[t+2])<<4}}_extractGaussianSphericalScale(e,t){const s=e[t+2],i=s>>>10&255,a=s>>>18&255,r=s>>>26&63|(3&e[t+3])<<6,n=Math.exp(i/16-10),o=Math.exp(a/16-10),l=Math.exp(r/16-10);return Math.max(n,o,l)}freeRenderable(e){const t=this._tileHandles.get(e);t&&(t.isVisible&&!this._fadeHelper.isTileFadingOut(t)?this._usedMemory-=t.usedMemory:this._cacheMemory-=t.usedMemory,t.pageIds.forEach(e=>this.data.textureAtlas.freePage(e)),this.freeObject(t),this._tileHandles.delete(e)),this.updateGaussians()}freeObject(e){this._memCache.pop(`${e.handle}`)}setRenderableVisibility(e,t,s){for(let i=0;i<s;i++){if(!t[i])continue;const s=e[i],a=this._tileHandles.get(s);a&&(a.isVisible&&!this._fadeHelper.isTileFadingOut(a)||(a.isVisible=!0,this._fadeHelper.isTileFadingOut(a)||this._popTileFromCache(a),this._fadeHelper.fadeTile(a,0)))}for(let i=0;i<s;i++){if(t[i])continue;const s=e[i],a=this._tileHandles.get(s);a&&a.isVisible&&this._fadeHelper.fadeTile(a,1)}this.updateGaussians()}_popTileFromCache(e){this._usedMemory+=e.usedMemory,this._cacheMemory-=e.usedMemory,this._memCache.pop(`${e.handle}`)}moveTileToCache(e){this._usedMemory-=e.usedMemory,this._cacheMemory+=e.usedMemory,this._memCache.put(`${e.handle}`,e)}destroy(){S(this),this._suspendedHandle&&(this._suspendedHandle=s(this._suspendedHandle)),this._frameTask.remove(),this._renderNode.destroy(),this._memCache.destroy()}_canProjectWithoutEngine(){if(1===this.view.state.viewingMode)return!0;if(u(this.view.renderSpatialReference)||d(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&m(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){const e=p(this.layer.esriCrsSpatialReference),t=this.view.heightModelInfo;return this._useEsriCrs=0===h(e,t,!1),this._useEsriCrs&&e&&(this._metersPerVCSUnit=r(1,"meters",e.heightUnit),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}_elevationInfoChanged(e){if(e?.offset)if(this._useEsriCrs){const t=f(e?.unit)/this._metersPerVCSUnit,s=e?.offset??0;this._wasm?.setLayerOffset(this,s*t)}else this._wasm?.setLayerOffset(this,c(e));else this._wasm?.setLayerOffset(this,0)}updateGaussians(){const e=new Array;for(const t of this._tileHandles.values())t.isVisible&&e.push(t);this.data.updateGaussianVisibility(e),this.notifyChange("updating")}setMaximumGaussianCount(e){this._wasm?.setMaximumGaussianSplatCount(e)}_freeInvisibleTiles(){for(const e of this._tileHandles.values())e.isVisible||this._deleteTile(e)}extractHeader(e){const t=e.length-4,s=this.reinterpretU32AsFloat(e[t]),i=this.reinterpretU32AsFloat(e[t+1]),a=this.reinterpretU32AsFloat(e[t+2]),r=1/(1<<(255&e[t+3]));return{packedHeader:e.subarray(t,t+4),tileOrigin:{x:s,y:i,z:a},invPosScale:r}}_deleteTile(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}reinterpretU32AsFloat(e){return this._u32View[0]=e,this._f32View[0]}get performanceInfo(){let e=0,t=0;return this._tileHandles.forEach(s=>{s.isVisible?e++:t++}),new _(this.usedMemory,e,t,this.cachedMemory)}get test(){}};e([n()],R.prototype,"layer",void 0),e([n({readOnly:!0})],R.prototype,"visibleAtCurrentScale",null),e([n()],R.prototype,"fullExtentInLocalViewSpatialReference",void 0),R=e([o("esri.views.3d.layers.GaussianSplatLayerView3D")],R);const O=R;export{O 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{__decorate as e}from"tslib";import t from"../../../Color.js";import i from"../../../Graphic.js";import{removeUnordered as s,isSome as r}from"../../../core/arrayUtils.js";import has from"../../../core/has.js";import o from"../../../core/Logger.js";import{equals as n}from"../../../core/MapUtils.js";import{destroyMaybe as a}from"../../../core/maybe.js";import l from"../../../core/PooledArray.js";import{ignoreAbortErrors as d,isAbortError as h,throwIfAborted as c,createResolver as u}from"../../../core/promiseUtils.js";import{initial as _,watch as g}from"../../../core/reactiveUtils.js";import{schedule as m}from"../../../core/scheduling.js";import{equals as f}from"../../../core/SetUtils.js";import{isArrayBuffer as p}from"../../../core/typedArrayUtil.js";import{property as y,subclass as b}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as v,invert as I}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as C}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as M,getTranslation as w}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as x,create as S}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as E}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{h as O,p as R,t as j,a as F,i as V,j as D,e as A,u as T}from"../../../chunks/vec32.js";import{create as H}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as N}from"../../../chunks/vec42.js";import{fromValues as P}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as k}from"../../../core/support/UpdatingHandles.js";import{getSphericalPCPF as L}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{localLinearScaleFactors as U}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as G}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as B}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as q}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as z}from"../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as W,create as $,toRect as K}from"../../../geometry/support/aaBoundingBox.js";import{create as Q,intersects as J}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as Y,ensurePackedMat4f64 as X}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as Z}from"../../../geometry/support/FloatArray.js";import{compactIndices as ee}from"../../../geometry/support/Indices.js";import{Sphere as te}from"../../../geometry/support/sphere.js";import{newUByteArray as ie}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as se}from"../../../layers/LayerConstants.js";import re from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as oe}from"../../../layers/support/fieldUtils.js";import ne from"../../../layers/support/SceneModification.js";import{getColor as ae,getOpacity as le}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{isBasemapLayerView as de}from"../../../support/basemapUtils.js";import{getElevationOffset as he}from"../../../support/elevationInfoUtils.js";import{loadArcade as ce}from"../../../support/loadArcade.js";import ue from"../../../symbols/MeshSymbol3D.js";import _e from"../../../symbols/SimpleFillSymbol.js";import{ContentGeometryUpdateEvent as ge}from"./ContentGeometryLayerView.js";import me from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as fe}from"./I3SMeshViewPerformanceInfo.js";import{initialize as pe,setModificationsSync as ye,filterObbsForModificationsSync as be,interpretObbModificationResults as ve}from"./SceneLayerWorker.js";import{SceneLayerWorkerHandle as Ie,toWasmModification as Ce}from"./SceneLayerWorkerHandle.js";import{overrideColor as Me}from"./graphics/graphicUtils.js";import{areLabelsVisible as we}from"./graphics/Labeler.js";import xe from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as Se}from"./i3s/I3SAsyncElevationUpdater.js";import{getCachedAttributeValue as Ee}from"./i3s/I3SBinaryReader.js";import{I3SCrossfadeHelper as Oe,NodeCrossfadeMetaData as Re}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as je}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Fe}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Ve,selectEncoding as De,defaultMaterial as Ae,createTexture as Te,configureMaterial as He}from"./i3s/I3SMaterialUtil.js";import{I3SOverrides as Ne}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as Pe}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as ke,checkSceneLayerValid as Le,checkSceneLayerCompatibleWithView as Ue,whenGraphicAttributes as Ge,computeVisibilityObb as Be,filterInPlace as qe,intersectBoundingRectWithMbs as ze,addWraparound as We,getSymbolInfo as $e,transparentEdgeMaterial as Ke,getClipRect as Qe}from"./i3s/I3SUtil.js";import{IDBCache as Je}from"./i3s/IDBCache.js";import{IDBMockCache as Ye}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as Xe}from"./i3s/LayerElevationProvider.js";import{SymbologyInfo as Ze}from"./i3s/SymbologyInfo.js";import{attributeLookup as et}from"./support/attributeUtils.js";import{normalizeHighlightTarget as tt,emptyHighlightHandle as it}from"./support/highlightUtils.js";import{makeScheduleFunction as st}from"./support/makeScheduleFunction.js";import{debugFlags as rt}from"../support/debugFlags.js";import{ElevationRange as ot}from"../support/ElevationRange.js";import{toBoundingRect as nt}from"../support/extentUtils.js";import{Obb as at,ensurePackedObbData as lt}from"../support/orientedBoundingBox.js";import{updatingProgress as dt}from"../support/updatingProperties.js";import{glLayout as ht}from"../support/buffer/glUtil.js";import{ObjectParameters as ct}from"../webgl-engine/collections/Component/ObjectParameters.js";import{createVertexBufferLayout as ut,SourceParameters as _t,SourceGeometry as gt,GeometryParameters as mt}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as ft}from"../webgl-engine/collections/Component/Transform.js";import{emissiveStrengthDefault as pt}from"../webgl-engine/core/shaderLibrary/output/Emissions.glsl.js";import{loadBasisTranscoder as yt}from"../webgl-engine/lib/BasisUtil.js";import{getHighlightName as bt}from"../../support/highlightOptionsUtils.js";import{TextureCompressionTracker as vt}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as It}from"../../../webscene/support/AlphaCutoff.js";const Ct=[1,1,1,1];class Mt extends Re{constructor(e,t,i,s,r,o,n,a,l){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=n,this.anchorIds=a,this.anchors=l,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0,this.cachedSymbologyStride=5}get usedMemory(){return this.node.memory}get featureExtents(){return this._featureExtents??=new Float64Array(6*this.featureIds.length).fill(Number.POSITIVE_INFINITY),this._featureExtents}}const wt=26,xt=104857600,St=t=>{const p=t;let T=class extends p{constructor(){super(...arguments),this._applySSAO=!0,this._shadeNormals=!0,this._updatingHandles=new k,this._highlights=null,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._compressionTracker=new vt,this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._hasComponentData=!1,this._hasVertexColors=!1,this._nodeColorOverride=null,this.updating=!0,this.holeFilling="auto",this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=new Array,this.ignoresMemoryFactor=!1,this._layerUrl="",this._cacheKeySuffix=null,this._planetRadiusInGlobalMode=0,this._elevationTask=null,this._needFilterResolve=!1,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i,this._crossfadeHelper=new Oe(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerViewUid(){return this.uid}get layerId(){return this.i3slayer.id}get sublayerId(){return null}get _isIntegratedMesh(){return"integrated-mesh"===this.i3slayer.type}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible&&this.fullOpacity>It}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?"yes":"probably-not":"unknown"}get rendererTextureUsage(){return ke(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?63:53:this._usePBR||this._hasLoadedPBRTextures?44:36}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;return null!=e&&"absolute-height"===e.mode?he(e,this.i3slayer.spatialReference):0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return new Lt(0,0);const t=he(e,this.i3slayer.spatialReference);switch(e.mode){case"absolute-height":return new Lt(0,t);case"relative-to-ground":return new Lt(1,t);case"on-the-ground":return new Lt(2,0);default:return new Lt(0,0)}}get supportedTextureEncodings(){return Ve(this.view.stage.renderView.capabilities)}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){const e=this._nodeId2Meta,t=new ot;for(const i of e.values()){const e=i?.node.serviceMbsInIndexSR;e&&t.expandElevationRangeValues(e.center[2]-e.radius,e.center[2]+e.radius)}return t.elevationRangeValid?t:null}get fullExtent(){return this.i3slayer.fullExtent}initialize(){const e=has("enable-feature:idb-mock-cache");this._idbCache=e?new Ye(this.view,e):new Je("esri-scenelayer-cache","geometries"),this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const t=this.view.resourceController,i=t.memoryController;this.i3sOverrides=new Ne({view:this.view,layer:this.i3slayer,memoryController:i}),this._workerHandle=new Ie(st(t)),this.addResolvingPromise(this._workerHandle.promise);const s=this.i3slayer.store;this.addResolvingPromise(this._workerHandle.setLegacySchema(this.uid,s.defaultGeometrySchema).catch(d)),Le(this.i3slayer),Ue(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new re({layerView:this,worker:this._workerHandle}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view.stage,this._collection=this._stage.renderView.componentObjectCollection;const r=s.defaultGeometrySchema;if(this._isIntegratedMesh||!r)this._hasComponentData=!1;else{const e=r.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(r?.vertexAttributes.color??null)&&!this.i3slayer.cachedDrawingInfo?.color;const n=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,e=>this._deleteComponentObject(e));this._memCache=n;const l=this._controller,h=this._nodeId2Meta,c=this._nodeId2MetaReloading,u=e=>{const t=l.index;if(!t)return;const i=t.rootNode;if(!i)return;const s=t=>{const i=t.index,s=h.get(i)||c.get(i);return e(t,s?.objectHandle??null)};t.traverse(i,s)};this._intersectionHandler=new Fe({layerViewUid:this.layerViewUid,sublayerId:this.sublayerId,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:u}),this._elevationProvider=new Xe({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add(()=>this.view.clippingArea,()=>this._clippingAreaChanged(),_),this._updatingHandles.add(()=>this.fullOpacity,e=>this._opacityChange(e)),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this.elevationOffset,(e,t)=>{this._reloadAll(t),this._controller.invalidateVisibilityObbs()}),this._updatingHandles.add(()=>this.elevationInfo,(e,t)=>this._elevationInfoChanged(e,t),_),this._updatingHandles.add(()=>!this.suspended&&0!==this.elevationInfo.mode,(e,t)=>{e?this.addHandles(this.view.basemapTerrain.on("elevation-change",({extent:e})=>this._ensureElevationTask().addExtent(e)),Bt):t&&this.removeHandles(Bt)},_),this._updatingHandles.add(()=>this._usePBR,e=>this._updatePBR(e));const m=()=>{this._reloadAll(),this.clearMemCache()};this._updatingHandles.add(()=>this.rendererTextureUsage,m),this._updatingHandles.add(()=>this.contentVisible,e=>this._contentVisibleChanged(e),_),this._updatingHandles.add(()=>this.i3slayer.labelsVisible,()=>this._labelingChanged(),_),this._updatingHandles.add(()=>this.i3slayer.labelingInfo,()=>this._labelingChanged(),_),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),_),this.addHandles([g(()=>rt.I3S_TREE_SHOW_TILES,e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then(({I3STreeDebugger:t})=>{!this._treeDebugger&&rt.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))})}else e||rt.I3S_TREE_SHOW_TILES||(this._treeDebugger=a(this._treeDebugger))},_),g(()=>rt.I3S_SHOW_MODIFICATIONS,()=>this._showModifications(),_)]),this._cacheKeySuffix=this._getCacheKeySuffix(),this._idbCache.init().catch(e=>o.getLogger(this).warn(`Failed to initialize IndexedDB cache: ${e}`));const{view:f}=this,{viewingMode:p,renderCoordsHelper:y}=f;this._planetRadiusInGlobalMode="local"===p?0:y.referenceEllipsoid.radius}destroy(){this._clearAddTasks(),this._elevationTask=a(this._elevationTask),this.i3sOverrides=a(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.notifyObjectsChanged(this.getVisibleObbs()),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._workerHandle;e&&(e.destroyContextAndSelf(this.uid),this._workerHandle=null),this._removeAllNodeDataFromStage(),this._memCache=a(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=a(this._labeler),this._treeDebugger=a(this._treeDebugger),this._controller=a(this._controller),this._highlights=a(this._highlights),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=a(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null),this._updatingHandles=a(this._updatingHandles)}_memEstimateTextureAdded(e){const t=e.usedMemory;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(null!=e){const t=e.usedMemory;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){const t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){const t=this._collection.getObjectGPUMemoryUsage(e);this._gpuMemoryEstimate-=t,this._geoMemoryEstimate-=t}isNodeLoaded(e){return this._nodeId2Meta.has(e)}isNodeReloading(e){return this._nodeId2MetaReloading.has(e)}get usedMemory(){let e=null!=this._labeler?this._labeler.usedMemory:0;return this._nodeId2Meta.forEach(t=>e+=null!=t?t.node.memory:0),this._nodeId2MetaReloading.forEach(t=>e+=null!=t?t.node.memory:0),e}get unloadedMemory(){return(null!=this._controller?this._controller.unloadedMemoryEstimate:0)+(null!=this._labeler?this._labeler.unloadedMemoryEstimate:0)}_labelingChanged(){if(!(we(this.i3slayer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new me({view:this.view,layer:this.i3slayer,collection:this._collection,overrides:this.i3sOverrides,layerViewUid:this.uid});this._nodeId2Meta.forEach(t=>null!=t&&this._addMetaToLabeler(e,t)),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then(e=>(--this._asyncModuleLoading,e),e=>{throw--this._asyncModuleLoading,e})}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=pe().then(()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()}),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=e=>o.getLogger(this).error("set-modifications-error","Error when setting modifications:",e),t=this.uid,i=this.i3slayer.spatialReference,s=i.isGeographic,r=Ce(this._layerClippingArea,this._modifications,i);this._workerHandle.setModifications(t,r,s).catch(e);try{ye({context:t,modifications:r,isGeodetic:s})}catch(a){e(a)}this._controller.modificationsChanged();const n=this.hasModifications?new l:null;this._nodeId2Meta.forEach((e,t)=>{null==e?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._updateFeatureIdCounts(e,-1),this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):null!=n&&n.push(e.node)}),this.notifyChange("elevationRange"),null!=n&&this._nodeId2MetaReloading.forEach(e=>n.push(e.node)),null!=n&&n.length>0&&(this.updateNodeModificationStatus(n),n.forAll(e=>{if(2!==e.imModificationImpact){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),null!=t?(this._updateFeatureIdCounts(t,-1),this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t),this.notifyChange("elevationRange")):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}})),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(null!=this._modificationGraphics&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!rt.I3S_SHOW_MODIFICATIONS||0===this._modifications.length)return;const e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={outline:{color:[255,255,255],width:1}};this._modificationGraphics=[];for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.i3slayer.spatialReference;const o=new _e({...t,color:e[s.type]});this._modificationGraphics.push(new i({geometry:r,symbol:o}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,(e,t)=>this._createAttributes(e,t))}_contentVisibleChanged(e){e?(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler)):(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);null!=i?.attributeInfo&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);null!=s&&(await this.i3sOverrides.applyAttributeOverrides(s.featureIds,t,i,this._controller.requiredAttributes),s.attributeInfo=t,this._controller.reschedule(()=>{this._nodeId2Meta.get(e)===s&&this._attributeValuesChanged(s)},i).catch(e=>{h(e)||o.getLogger(this).warn("Error while updating attribute values. Layer might not display correctly.",e)}))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.appliedFilters=null,null!=this._labeler&&this._labeler.setNodeMetaAttributes(e,(e,t)=>this._createAttributes(e,t)),this._updateEngineObject(e)}clearMemCache(){null!=this._memCache&&this._memCache.clear(),this._addTasks.forEach(e=>e.allowMemCache=!1)}getVisibleNodes(){const e=new Array;return this._nodeId2Meta.forEach(t=>null!=t&&e.push(t.node)),e}getVisibleObbs(){const e=new Array;return this._nodeId2Meta.forEach(t=>t&&e.push(this._collection.getComponentObb(t.objectHandle))),e}getLoadedNodeIndices(e){this._nodeId2Meta.forEach((t,i)=>e.push(i)),this._nodeId2MetaReloading.forEach((t,i)=>e.push(i))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&2&this.supportedTextureEncodings&&this.i3slayer.textureSetDefinitions?.some(e=>e.formats.some(e=>"basis"===e.format||"ktx2"===e.format))&&yt()}_getVertexBufferLayout(e,t){return ht(ut(this._getGeometryParameters({hasTexture:Dt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion})))}_getObjectIdField(){return this.i3slayer.objectIdField||se}_getGlobalIdField(){return this.i3slayer.globalIdField}_findGraphicNodeAndIndex(e){const t=et(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());for(const i of this._nodeId2Meta.values()){const e=i?.featureIds.indexOf(t);if(null!=e&&e>=0)return{node:i.node,index:e}}return null}_getGraphicIndices(e,t){const i=this._nodeId2Meta.get(e.index);if(null==i)return[];const s=[],r=this._getObjectIdField(),o=this.i3slayer.fieldsIndex;for(const n of t){const e=et(o,n.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this.getAABB(t.node.index,t.index);return null==i?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this.getAABB(e.nodeIndex,e.componentIndex)}getAABB(e,t){const i=this._nodeId2Meta.get(e);if(null==i?.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=je(t,this._collection,s,Y(24),0),o=this.view.renderSpatialReference,n=this.view.spatialReference;return B(r,o,0,r,n,0)?W(r):null}whenGraphicAttributes(e,t){return Ge(this.i3slayer,e,this._getObjectIdField(),t,()=>[...this._nodeId2Meta.values()].filter(r))}getGraphicFromIntersectorTarget(e,t){if(null==e.nodeIndex||null==e.componentIndex)return null;const i=this._nodeId2Meta.get(e.nodeIndex);if(null==i?.featureIds||e.componentIndex>=i.featureIds.length)return null;const s=this._createLayerGraphic(this._createAttributes(e.componentIndex,i));return s?t.defer?(t.defer(async()=>(s.geometry=(await import("./i3s/meshUtils.js")).createMesh({layerView:this,nodeIndex:e.nodeIndex,featureIndex:e.componentIndex}),s)),null):s:null}_getCacheKey(e){return`${this._layerUrl}/v${wt}/${e}${this._cacheKeySuffix}`}_getCacheKeySuffix(){const e=this.view.renderSpatialReference;if(null==e)return zt;if(e===L(e))return Wt;return this.i3slayer.spatialReference.equals(e)?qt:null!=e.wkid?`@${e.wkid}`:null}_getMemCacheKey(e,t=this.elevationOffset){return e+"#"+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&0===this.elevationOffset&&null!=this._cacheKeySuffix}loadCachedGPUData(e){return null!=this._memCache?this._memCache.pop(this._getMemCacheKey(e)):null}deleteCachedGPUData(e){null!=e&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(null==this._memCache)return void this._deleteComponentObject(e);const i=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,i)}loadMissingTextures(e,t,i,s){const r=e?.filter((e,i)=>{if(0===(e.usage&this.rendererTextureUsage))return!1;if(null==t)return!0;const s=De(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(null==r?.data||s&&r.encoding!==s.encoding)})??[];return 0===r.length?Promise.resolve(!1):i(r,s).then(i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0})}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then(s=>null==s?null:(s.globalTrafo=X(s.globalTrafo),s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(0===this.elevationInfo.mode&&(e.geometryObbInRenderSR=at.fromData(s.geometryObbData)),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then(i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=Ht(s.transformedGeometry,s.textureData),s.textureData.every(Tt)&&this._indexedDbSizeCheck(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch(t=>o.getLogger(this).warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`))),c(t),s))))):Promise.resolve(null)}addNode(e,t,i){return At(t)?null==t.geometryBuffer?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,()=>this._transformNode(e,t,i).then(s=>this._safeReschedule(()=>{if(null==s)return e.hasModifications=!1,this._addCachedNodeData(e,null,i);const{obb:r,componentOffsets:n,featureIds:a,anchorIds:l,anchors:d,transformedGeometry:h}=s;e.hasModifications=h.hasModifications;const c=X(s.globalTrafo),u=O(Ut,r.center.x,r.center.y,r.center.z);R(u,u,c);const _=new at(u,[r.extents.x,r.extents.y,r.extents.z],E(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));0===this.elevationInfo.mode&&(e.geometryObbInRenderSR=_),t.geometryData.componentOffsets=n,a&&(t.geometryData.featureIds=Array.from(a)),t.geometryData.anchorIds=l,t.geometryData.anchors=d;const g={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:h,globalTrafo:c,geometryObbData:_.data,byteSize:Ht(h,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&this._indexedDbSizeCheck(e,g)){const t=null!=g.textureData?g.textureData.map(e=>Tt(e)?e:null):null;this._idbCache.put(this._getCacheKey(e.id),{...g,textureData:t}).catch(t=>o.getLogger(this).warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`))}return this._addCachedNodeData(e,g,i)},i))):Promise.reject()}getElevationRange(e){const t=new ot,i=this._controller,{index:s}=i;if(!s)return t;const{rootNode:r}=s;if(!r)return t;const o=this._nodeId2Meta,n=e.radius,a=i.viewportQueries,l=this._planetRadiusInGlobalMode,{view:d}=this,{renderCoordsHelper:h}=d,c=h.referenceEllipsoid.radius,u=this._collection,_=i=>{const{childrenLoaded:s}=i;if(0===s)return!1;const r=a.getAndUpdateVisibilityObbInRenderSR(i);let d=null,_=-1;if(r){if(_=r.radius,!r.intersectSphereWithMBS(e,_))return!1}else d=a.calculateServiceMbsInRenderSRElevationAdjusted(i),d&&(_=d.radius);if(_>=0&&n>=1*_)return null!=r?Qt(t,r,l):d?.isValid&&Jt(t,d,l),!1;const g=Kt;if(g.minElevation=1/0,g.maxElevation=-1/0,(null!=r||null!=d)&&(null!=r?Qt(g,r,l):null!=d&&Jt(g,d,l),g.minElevation>=t.minElevation&&g.maxElevation<=t.maxElevation))return!1;const m=o.get(i.index);if(m){const{geometryObbInRenderSR:s}=i;if(!s||s.intersectSphereWithMBS(e)){if(s){if(n>0*s.radius)return Qt(t,s,l),!1}const{objectHandle:e}=m,i=u.getObjectTransform(e),r=h.getAltitude(i.position);u.expandRangeWithComponentObjectElevationRange(e,r,c,t)}}return s-(m?1:0)>0};return s.traverse(r,_),t}computeVisibilityObb(e){return Be(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications,this.view.renderCoordsHelper.sphericalPCPF)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let f=0;f<s.length;++f)r[f]=this._getVertexBufferLayout(s[f],t.geometryDescriptor);const o=this.i3slayer.normalReferenceFrame,n=t.normalReferenceFrame??o??"none",a=e.serviceMbsInIndexSR,l=this.elevationOffset,d=this._controller.crsIndex,h=this._controller.crsVertex,c=this.view.renderSpatialReference,u=Pe(a,l,n,d,c),_=q(d,h),g=q(h,c);if(null==_||null==g)return Promise.resolve(null);const m={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,globalTrafo:u,mbs:a.toJSON(),obbData:e.serviceObbInIndexSR?.data,elevationOffset:l,needNormals:this._controller.isMeshPyramid,normalReferenceFrame:n,indexToVertexProjector:_,vertexToRenderProjector:g};return this._workerHandle.invoke(m,i)}get _supportsNodeCrossFading(){return!this.view?.stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){const t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,i){if(0===this.elevationInfo.mode&&(e.geometryObbInRenderSR=this._collection.getComponentObb(t.objectHandle).clone()),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);null!=this._labeler&&this._addMetaToLabeler(this._labeler,t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,!0),this._updateMaterial(t),this._setNewNodeOpacity(t),0!==this.elevationInfo.mode&&this._ensureElevationTask().schedule(s),this._updateEngineObject(t),this._highlights?.objectCreated(t),null!=this._treeDebugger&&this._treeDebugger.update()}addCachedNodeData(e,t,i,s){return this._addData(e,i,()=>this._addCachedNodeData(e,t,s))}async deleteCachedNodeData(e){if(this._idbCacheEnabled)return this._idbCache.remove(this._getCacheKey(e))}async _addCachedNodeData(e,t,i){if(!this.contentVisible||!this._controller.isGeometryVisible(e))return void this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);if(null==t)return void this._addNodeMeta(e.index,null);const s=this._addTasks.get(e.index),{geometryData:r,transformedGeometry:n}=t;await this.i3sOverrides.applyAttributeOverrides(r.featureIds,s.attributeInfo,i,this._controller.requiredAttributes);const a=null!=t.textureData?t.textureData.filter(e=>null!=e&&0!==(e.usage&this.rendererTextureUsage)):[];!has("disable-feature:i3s-basis")&&a.some(e=>null!=e&&(2===e.encoding||1===e.encoding))&&await yt(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:h,anchorIds:c,anchors:u}=r,_=this._collection,g=d[0],{layout:m,indices:f,interleavedVertexData:p,positionData:y,hasColors:b}=n,{material:E,geometryParameters:O}=this._materialParameters(g,m),R=l||new Uint32Array([0,f?f.length:p.byteLength/m[0].stride]),V=new _t(m,O.shadeNormals,O.applySSAO,O.textureCoordinateType),D=new gt({data:p,count:p.byteLength/m[0].stride},{positions:Z(y.data),indices:ee(y.indices)},f,R,V),A=g.transformation?x(g.transformation):S(),T=X(t.globalTrafo);M(A,T,A);const N=w(H(),A),k=v(C(),A),L=this.view.renderSpatialReference,G=this.view.basemapTerrain.spatialReference,B=at.fromData(lt(t.geometryObbData)).center,q=[1,1,1];U(B,L,q,G)||o.getLogger(this).errorOnce("Unsupported coordinate system for IM overlay");const W=H();z(B,L,W,G);const $=C();I($,k);const K=H();j(K,F(K,B,N),$);const Q=W[0]-K[0]*q[0],J=W[1]-K[1]*q[1],Y=_.createObject(new ct(P(Q,J,q[0],q[1]),new ft(N,k),at.fromData(lt(t.geometryObbData)),D,!this._isIntegratedMesh)),te=2===O.textureCoordinateType,{textures:ie,texturePromise:se}=this._initMaterialAndTextures(Y,E,a,te,e);e.memory+=this._memEstimateGeometryAdded(Y),e.memory+=ie.reduce((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0),0);const re=!!E.hasParametersFromSource,oe="blend"!==E.alphaMode&&E.metallicRoughness.baseColorFactor[3]>=1,ne=new Mt(e,h,Y,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:re,isOpaque:oe},ie,c,u);s.meta=ne,this._hasTextures||=t.requiredTextures?.some(({usage:e})=>!!(19&e))||!!e.resources.texture,this._hasData=!0,this._hasColors||=b,this.notifyChange("hasTexturesOrVertexColors");const ae=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(ne),se]).then(([t,s])=>(this._addTasks.has(e.index)&&t?.updateObjectVisibility(ne.objectHandle,!1).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),this._safeReschedule(()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,ne),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(Y,!0),t?.updateObjectVisibility(ne.objectHandle,!0).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),ne.attributeInfo=i.attributeInfo;const s=ne.cachedRendererVersion!==this._rendererVersion,r=ae!==this.slicePlaneEnabled;this._updateElevationOffsets(ne);const o=ne.elevationOffsets;this._updateComponentData(ne);const n=this._applyFiltersToNode(ne);(s||null!=t&&(r||n||o))&&this._addOrUpdateEdgeRendering(ne),null!=this._labeler&&this._addMetaToLabeler(this._labeler,ne),this._visibleGeometryChanged(ne,0),this._highlights?.objectCreated(ne),this._updateMaterial(ne),this._setNewNodeOpacity(ne),null!=this._treeDebugger&&this._treeDebugger.update()},i))).catch(e=>{const{meta:t,allowMemCache:i}=s;throw s.meta=null,t&&i?this._cacheGPUData(t):t&&this._deleteComponentObject(t),e})}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){o.getLogger(this).error("Removing duplicated node");const t=this._nodeId2Meta.get(e);t&&(this._deleteComponentObject(t),this._updateFeatureIdCounts(t,-1))}else this._controller.updateLoadStatus(e,!0);t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&kt(t.cachedEdgeMaterials,0),this._updateFeatureIdCounts(t,1)),this._nodeId2Meta.set(e,t),this.notifyChange("elevationRange")}_updateElevationOffsets(e){if(!e.node.serviceMbsInIndexSR)return;const{view:t,elevationInfo:i}=this,s=this._controller.crsIndex,{groundView:r,groundSpatialReference:o,renderSpatialReference:n}=t,a=i.mode;if(null==n||null==o||0===a)return void(e.elevationOffsets=null);const l=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const d=Ut,h=Gt,c=2===a,u=this.view.renderCoordsHelper,_=e.featureIds.length,g=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const t=Y(3*_);e.cachedElevationAnchors=t;const{center:i}=e.node.serviceMbsInIndexSR;for(let r=0;r<_;r++){const a=3*r,c=e.anchorIds?.indexOf(r)??-1;e.anchors&&c>=0?(O(d,e.anchors[3*c],e.anchors[3*c+1],e.anchors[3*c+2]),V(d,d,i),z(d,s,d,o),t[a]=d[0],t[a+1]=d[1],t[a+2]=u.getAltitude(d)):(this._collection.getComponentAabb(e.objectHandle,r,h,!0),O(d,(h[0]+h[3])/2,(h[1]+h[4])/2,h[2]),j(d,d,l.rotationScale),V(d,d,l.position),t[a+2]=u.getAltitude(d),z(d,n,d,o),t[a]=d[0],t[a+1]=d[1])}return t})(),m=i.offset,f=e.elevationOffsets,p=(e,t)=>{const i=c?g[3*e+2]:0;f[e]=m+(t??0)-i};r.getElevations(g,_,p)}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new Se(this.view.resourceController.scheduler,e=>this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference)?.filterInPlace(e=>null!=this._nodeId2Meta.get(e)),e=>this._nodeElevationAlignmentChanged(this._nodeId2Meta.get(e)),()=>this.elevationInfo?.mode)),this._elevationTask}_elevationInfoChanged(e,t){const i=0!==e.mode,s=!!t&&t!==e&&0!==t.mode;this._intersectionHandler.updateElevationAlignState(i,this.view.state.viewingMode),i&&!s&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach(e=>this._nodeElevationAlignmentChanged(e))}_nodeElevationAlignmentChanged(e){null!=e&&(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),null!=this._labeler&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,2),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}_safeReschedule(e,t){return c(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:Ae(),s=t.some(({name:e})=>"uvRegion"===e),r=t.some(({name:e})=>"normalCompressed"===e),o=Dt(i);return{geometryParameters:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s,r){const o=this._stage.renderView,n=e=>{this._gpuMemoryEstimate-=e,this._texMemoryEstimate-=e,r.memory-=e},a=i.map(e=>Te(e,t,s,o,this._compressionTracker,n));this._stage.addTextures(a);let l=null;return this._collection.updateMaterial(e,e=>{l=He(e,t,a,i,this.view.stage.renderView.textures,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference}),this._updateMaterialOverlay(e)}),{textures:a,texturePromise:l}}_getGeometryParameters(e){return new mt(this._hasVertexColors,e.hasTexture?e.hasRegions?2:1:0,e.hasNormals,this._shadeNormals,this._applySSAO)}_addData(e,t,i){let s=this._addTasks.get(e.index);if(s)s.attributeInfo=t;else{const r=u();s=new Pt(t,null,r.promise),this._addTasks.set(e.index,s),i().then(r.resolve,r.reject).then(()=>this._addTasks.delete(e.index)).catch(t=>{throw this._addTasks.delete(e.index),t})}return s.promise}_clearAddTasks(){this._addTasks.forEach(e=>{null!=e.meta&&(this._cacheGPUData(e.meta),e.meta=null)}),this._addTasks.clear()}_clippingAreaChanged(){const e=this.view.renderSpatialReference,t=this.i3slayer.spatialReference,i=Q();this._renderClippingArea=nt(this.view.clippingArea,i,e)?i:null;const s=Q();this._layerClippingArea=nt(this.view.clippingArea,s,t)?s:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){const e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e),this._assertFeatureIdNodeCounts(e)}_assertFeatureIdNodeCounts(e){e&&!this._featureIdCounts?(this._featureIdCounts=ei(this._nodeId2Meta.values()),this._filteredIdCounts=ei(this._nodeId2Meta.values(),1),this._weaklyRemovedIdCounts=ei(this._nodeId2Meta.values(),2),this.addHandles(g(()=>this._controller.updating,e=>{!e&&this._needFilterResolve&&(this.multiGeometryFilterResolve(),this._needFilterResolve=!1,this.notifyUpdate())},{sync:!0}),"updateFinished")):!e&&this._featureIdCounts&&(this._featureIdCounts=null,this._filteredIdCounts=null,this._weaklyRemovedIdCounts=null,this._mismatchShow=null,this._mismatchHide=null,this.removeHandles("updateFinished"),this._needFilterResolve=!1,this.notifyUpdate())}_updateFeatureIdCounts(e,t){this._featureIdCounts&&(this._needFilterResolve=!0,Zt(this._featureIdCounts,e.featureIds,t),Zt(this._filteredIdCounts,e.filteredIds,t),Zt(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,t))}_updateFilteredIdCounts(e,t,i){this._filteredIdCounts&&(this._needFilterResolve=!0,Zt(this._filteredIdCounts,t,-1),Zt(this._filteredIdCounts,e.filteredIds,1),Zt(this._weaklyRemovedIdCounts,i,-1),Zt(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,1))}_checkFeatureIdNodeCountInvariant(){const e=null!=this._featureIdCounts;if(this.hasGeometryFilter!==e&&o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","LayerView should have feature id node counts if and only if it has a geometry filter",{layerView:this,hasNodeCounts:e}),!this._featureIdCounts||!this._filteredIdCounts)return;const t=ei(this._nodeId2Meta.values());n(this._featureIdCounts,t)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _featureIdCounts",{layerView:this,counts:this._featureIdCounts,expected:t});const i=ei(this._nodeId2Meta.values(),1);n(this._filteredIdCounts,i)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _filteredIdCounts",{layerView:this,counts:this._filteredIdCounts,expected:i});const s=ei(this._nodeId2Meta.values(),2);n(this._weaklyRemovedIdCounts,s)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _weaklyRemovedIdCounts",{layerView:this,counts:this._weaklyRemovedIdCounts,expected:i})}multiGeometryFilterResolve(){if(!this._featureIdCounts||!this._filteredIdCounts)return;let e=null,t=null;for(const[i,s]of this._filteredIdCounts){const r=this._featureIdCounts.get(i);if(r!==s){s+(this._weaklyRemovedIdCounts?.get(i)??0)===r?(e??=new Set,e.add(i)):(t??=new Set,t.add(i))}}f(e,this._mismatchShow)&&f(t,this._mismatchHide)||(this._mismatchShow=e,this._mismatchHide=t,this._nodeId2Meta.forEach(e=>{if(!e?.filteredIds)return;const t=Xt(e,this._mismatchShow,this._mismatchHide);this._collection.setAllComponentVisibilities(e.objectHandle,t),this._visibleGeometryChanged(e,2)}))}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach(e=>{e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,2))})}getFilters(){const e=[],t=this._renderClippingArea;return null!=t&&e.push((e,i)=>this._boundingRectFilter(e,i,t)),e}addSqlFilter(e,t,i){if(null!=t){const s=t.fieldNames;e.push((e,r)=>this._sqlFilter(e,r,t,s,i))}}_sqlFilter(e,t,i,s,r){const o={},n=this._createLayerGraphic(o);if(!n)return;const a=this.i3slayer.objectIdField,l=t.featureIds,d=t.attributeInfo?.attributeData;s.every(e=>e===a||null!=d?.[e])&&qe(e,l,e=>{o[a]=l[e];for(const i of s)i!==a&&(o[i]=d?Ee(d[i],e):null);try{return i.testFeature(n)}catch(t){return r(t),!1}})}_boundingRectNodeTest(e,t){return G(e.node.serviceMbsInIndexSR,this._controller.crsIndex,Vt,this.view.renderSpatialReference),ze(t,Vt)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,Et),K(Et,Ot),J(i,Ot)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(3===r)return;if(0===r)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const n=this._transformClippingArea(Rt,i,t.objectHandle);qe(e,t.featureIds,e=>this._boundingRectFeatureTest(t,e,n))}_transformClippingArea(e,t,i){const s=this._collection.getObjectTransform(i),r=s.position,o=s.rotationScale;return e[0]=(t[0]-r[0])/o[0],e[1]=(t[1]-r[1])/o[4],e[2]=(t[2]-r[0])/o[0],e[3]=(t[3]-r[1])/o[4],e}async _addOrUpdateEdgeRendering(e,t=!0){const i=e.objectHandle,{hasEdges:s,perFeatureEdgeMaterials:r}=this._getFilteredEdgeMaterials(e);s&&!this._edgeView&&(this._edgeView=await this._stage.renderer.loadEdgeView());const o=this._edgeView;if(!o)return null;const n=o.hasObject(i);if(s){if(n){if(this.nodeCrossfadingEnabled){kt(r,this.getNodeOpacity(e))}return o.updateAllComponentMaterials(i,r,this.slicePlaneEnabled,t).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),o.updateObjectVisibility(i,!0).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),o.updateAllVerticalOffsets(i,e.elevationOffsets).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),o}const s=await this._collection.addEdges(i,o,r,this.slicePlaneEnabled,e.elevationOffsets);return e.edgeMemoryUsage=s,e.node.memory+=s,o}return n&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,o.removeObject(i)),null}_applyFiltersToNode(e){const{filteredIds:t,weaklyRemovedIds:i}=e,s=this._applyFiltersToNodeComponents(e);return this._updateFilteredIdCounts(e,t,i),s&&this._labeler?.applyFilterChange(e),s}_applyFiltersToNodeComponents(e){const t=this._collection,i=t.getComponentCount(e.objectHandle),s=null!=e.filteredIds,r=0===i.invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!r;if(null!=e.filteredIds&&e.appliedFilters===this._filters||(e.weaklyRemovedIds=null,e.filteredIds=Yt(e,this._filters),e.appliedFilters=this._filters),s&&e.filteredIds===e.featureIds&&(!this._mismatchHide||e.filteredIds.every(e=>!this._mismatchHide?.has(e))))return!r;const o=Xt(e,this._mismatchShow,this._mismatchHide);return t.setAllComponentVisibilities(e.objectHandle,o),!0}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach((t,i)=>this._removeNodeStageData(i,e)),this._nodeId2MetaReloading.forEach((t,i)=>this._removeNodeStageData(i,e,this._nodeId2MetaReloading)),this._elevationTask=a(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),null!=this._elevationTask&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);null!=s?(this._collection.setObjectVisibility(s.objectHandle,!1),null!=this._edgeView&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),this._visibleGeometryChanged(s,1),null!=this._labeler&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights?.objectDeleted(s),i===this._nodeId2Meta?(this._updateFeatureIdCounts(s,-1),this._cacheGPUData(s,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(s)):this._deleteComponentObject(s),null!=this._treeDebugger&&this._treeDebugger.update()):i.delete(e)}_deleteComponentObject(e){if(null!=this._edgeView&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(const t of e.textures)this._memEstimateTextureRemoved(t),this._stage.removeTexture(t)}updateNodeState(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._collection.updateMaterial(i.objectHandle,e=>e.polygonOffsetEnabled=0===t)}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){const i=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,i),this.notifyChange("elevationRange")}const i=this._nodeId2MetaReloading.get(e);i&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,i))}_invalidateAllSymbols(){this._rendererVersion=We(this._rendererVersion,1),this._controller?.requestUpdate()}_getInvalidRendererVersion(){return We(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=We(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.i3slayer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&"arcadeRequired"in e&&e.arcadeRequired&&(this._arcade=await ce()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:o.getLogger(this).warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.symbols)"mesh-3d"!==t.type&&o.getLogger(this).error(`Symbols of type '${t.type}' are not supported for 3D Object Scene Services.`);this._controller&&this._controller.requestUpdate()}_getCachedEdgeMaterials(e){return this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e),e.cachedEdgeMaterials}_getComponentParameters(e){this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e);const t=e.cachedSymbology;return(i,s)=>{const r=i*e.cachedSymbologyStride;N(s.externalColor,t[r]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255);const o=this._stage.renderView.olidRenderHelper;if(o){const t=e.featureIds[i],r=this.sublayerId?`${this.layerViewUid}_${this.sublayerId}`:this.layerViewUid,n=de(this.view,this.uid);o.setUidToObjectAndLayerId(t,t,this.layerId,r,this.layerPopupEnabledAndHasTemplate&&!n,e.node.resources.attributes,i,this.sublayerId),s.olidColor=o.getObjectAndLayerIdColor({graphicUid:t,layerViewUid:r})}s.externalColorMixMode=15&t[r+4],s.castShadows=!!(16&t[r+4]),s.pickable=!!(32&t[r+4]),s.elevationOffset=e.elevationOffsets?.[i]??0,s.emissiveStrength=e.emissiveStrengths?.[i]??1,s.emissiveSource=e.emissiveSources?.[i]??0}}_getSymbolInfo(e,t){const i=e?.getSymbol(t,{arcade:this._arcade});if(!(i instanceof ue))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=$e(i);return this._symbolInfos.set(s,r),r}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=null!=this._symbologyOverrideFields&&this._symbologyOverrideFields.length>0?null!=this._rendererFields&&this._rendererFields.length>0?oe(this.i3slayer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;const t=this._tmpAttributeOnlyGraphic,i={};t.attributes=i;const s=this._currentRenderer,r=e.attributeInfo?.attributeData,o=e.featureIds?this.i3slayer.objectIdField:null,n=null!=r&&null!=this._symbologyFields&&this._symbologyFields.length>0;let a=null,l=null;if(n&&null!=this._symbologyFields){a=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(a.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=ie(e.featureIds.length*e.cachedSymbologyStride));const d=new Ze,h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=1,g=Ke,m=0;for(let f=0;f<e.featureIds.length;f++){if(null!=o&&(i[o]=e.featureIds[f]),n&&a)for(let e=0;e<a.length;e++)i[a[e]]=Ee(l[e],f);const r=s?this._getSymbolInfo(s,t):null;let h,p;if(d.pickable=!0,s&&"visualVariables"in s){if(this._colorVariable){const e=ae(this._colorVariable,t,{color:Ft,arcade:this._arcade});e&&(h=d.color,h[0]=e.r/255,h[1]=e.g/255,h[2]=e.b/255,h[3]=e.a??1,this._opacityVariable||null===e.a||(p=e.a))}this._opacityVariable&&(p=le(this._opacityVariable,t,{arcade:this._arcade}))}if(r?.material){const e=r.material;h=null==h||null==p?Me(h,p,e.color,e.alpha,Ct,d.color):Me(h,p,null,null,Ct,d.color)}h??=N(d.color,1,1,1,1);const y=r?.material;if(d.colorMixMode=y?.colorMixMode??1,d.edgeMaterial=r?.edgeMaterial,this._symbologyOverride?.(t,d),null!=this._nodeColorOverride&&(this._nodeColorOverride(e.node,h),d.colorMixMode=3),d.pickable&&=h[3]>=It,d.castShadows=r?r.castShadows:d.pickable,null!=d.edgeMaterial){const t=h[3]>=1&&(e.material.isOpaque||3===d.colorMixMode)?1:0;d.edgeMaterial===u&&t===_||(g={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,_=t),e.cachedEdgeMaterials[f]=g}else e.cachedEdgeMaterials[f]=Ke;e.cachedSymbology[m++]=Math.round(255*h[0]),e.cachedSymbology[m++]=Math.round(255*h[1]),e.cachedSymbology[m++]=Math.round(255*h[2]),e.cachedSymbology[m++]=Math.round(255*h[3]),e.cachedSymbology[m++]=d.colorMixMode|+d.castShadows<<4|+d.pickable<<5;const b=y?.emissive?.strength??pt;b===pt||e.emissiveStrengths||(e.emissiveStrengths=new Array(e.featureIds.length).fill(pt)),e.emissiveStrengths&&(e.emissiveStrengths[f]=b);const v=y?.emissive?.source||0;0===v||e.emissiveSources||(e.emissiveSources=new Array(e.featureIds.length).fill(0)),e.emissiveSources&&(e.emissiveSources[f]=v)}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||kt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some(e=>e!==Ke),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map((t,o)=>e.featureIds[o]!==i[s]?Ke:(r=r||t!==Ke,s++,t));return{hasEdges:r,perFeatureEdgeMaterials:o}}_updateComponentData(e){if(!this._hasComponentData)return;const t=e.objectHandle,i=this._getComponentParameters(e);this._collection.setComponentData(t,i),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),null!=this._controller&&this._controller.restartNodeLoading()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach(t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,t=>t.objectOpacity=e),kt(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))})}_updateMaterial(e){this._collection.updateMaterial(e.objectHandle,e=>{e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.usePBR=this._usePBR,this._updateMaterialOverlay(e)})}_updateMaterialOverlay(e){}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,2)}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),null!=this._labeler&&(this._labeler.slicePlaneEnabled=e),this._nodeId2Meta.forEach(t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,t=>t.commonMaterialParameters.hasSlicePlane=e),this._updateEdgeRendering(t,!1))})}_updatePBR(e){this._nodeId2Meta.forEach(t=>{null!=t&&this._collection.updateMaterial(t.objectHandle,t=>t.usePBR=e)}),this._hasLoadedPBRTextures=!0}get _usePBR(){return this._shadeNormals&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){null!=this._edgeView&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?(t,i,s)=>s.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?0:e(t,i,s):e}_forAllFeatures(e,t,i){for(const s of this._nodeId2Meta.values())if(!(null==s||t&&s.node.serviceMbsInIndexSR&&1===t(s.node.serviceMbsInIndexSR)))switch(i){case 1:this._forAllFeaturesOfNode(s,e);break;case 0:this._forAllVisibleFeaturesOfNode(s,e);break;case 2:this._forAllQueryableFeaturesOfNode(s,e)}}_forAllFeaturesOfNode(e,t){e.featureIds.forEach((i,s)=>t(i,s,e))}_forAllVisibleFeaturesOfNode(e,t){const i=e.featureIds;this._collection.forEachVisibleComponent(e.objectHandle,s=>0===t(i[s],s,e))}_forAllQueryableFeaturesOfNode(e,t){const i=this._ignoreClientNodeOverriddenFeatures(t);if(null==this._renderClippingArea)return this._forAllFeaturesOfNode(e,i);const s=this._boundingRectNodeTest(e,this._renderClippingArea);if(0===s)return;if(3===s)return this._forAllFeaturesOfNode(e,i);const r=e.featureIds,o=e.objectHandle,n=Qe(this._renderClippingArea,this._collection.getObjectTransform(o));for(let a=0;a<r.length;a++)this._boundingRectFeatureTest(e,a,n)&&i(r[a],a,e)}_createAttributes(e,t){const i={};null!=t.featureIds&&(i[this._getObjectIdField()]=t.featureIds[e]);const s=t.attributeInfo?.attributeData;if(null!=s)for(const r of Object.keys(s))i[r]=Ee(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e,t){const s=tt(e);if(0===s.length)return it;const r=bt(t),o=s[0]instanceof i?this._featureIdsFromGraphics(s):"number"==typeof s[0]?s:null;if(!o)return it;const n=this._ensureHighlights(),{set:a,handle:l}=n.acquireSet(r);return n.setFeatureIds(a,o),l}_featureIdsFromGraphics(e){const t=this.i3slayer.fieldsIndex,i=this._getObjectIdField();return e.map(e=>et(t,e.attributes,i))}_ensureHighlights(){return this._highlights??=new xe({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,1),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)}),this._highlights}resetHighlights(){this._highlights=a(this._highlights)}_visibleGeometryChanged(e,t){this._elevationProvider&&(null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=m(()=>{const{node:t}=e,i=t.visibilityObbInRenderSR??t.geometryObbInRenderSR??t.serviceObbInRenderSR;if(null!=i){const e=$();i.toAaBoundingBox(e),this.emit("visible-geometry-changed",new ge(e))}else this.emit("visible-geometry-changed");this._visibleGeometryChangedSchedulerHandle=null})),this._updateSnappingSources(e,t),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}get performanceInfo(){return new fe(this.usedMemory,this._nodeId2Meta.size,Math.round(this._gpuMemoryEstimate/1048576),Math.round(this._geoMemoryEstimate/1048576),Math.round(this._texMemoryEstimate/1048576),Math.round(this.unloadedMemory/1048576),this._idbCacheEnabled?Math.round(100*this._idbCache.getHitRate()):0)}checkInvariants(){}get test(){}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return null!=e?this._collection.getMaterial(e.objectHandle).objectOpacity:0}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}getNodeComponentHandle(e){return this._nodeId2Meta.get(e)?.objectHandle}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(e)}fadeNode(e,t,i){if(!this.nodeCrossfadingEnabled)return;const s=this._nodeId2Meta.get(e);null!=s&&this._crossfadeHelper.fadeNode(e,s,t,i)}setNodeOpacityByIndex(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._setNodeOpacity(i,t)}_setNodeOpacity(e,t){this._collection.updateMaterial(e.objectHandle,e=>e.objectOpacity=t),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(null==this._edgeView||!e.cachedEdgeMaterials)return;kt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch(e=>this._logEdgeViewError(e,this.i3slayer.title))}get hasModifications(){return this._isIntegratedMesh&&null!=this._layerClippingArea||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){const t=e.length;if(!this.hasModifications||t<=0||!0!==this._i3sWasmLoaded)return;const i=this.uid,s=Nt(e);if(s){const t={context:i,buffer:s.buffer};be(t);const r=new Float64Array(s.buffer);e.forAll((e,t)=>{const i=r[t],s=ve(i);e.imModificationImpact=s,0!==s&&this._controller.invalidateGeometryVisibility(e.index)})}}notifyUpdate(){this.notifyChange("updating")}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!(!this._controller||!this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||null!=this._labeler&&this._labeler.updating||this._crossfadeHelper?.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||null!=this._elevationTask&&this._elevationTask.readyToRun||this._needFilterResolve||this._compressionTracker.compressing}trackSnappingSources(e){const t={events:e,fetchEdgeLocations:async(e,t,i)=>{const s=this._nodeId2Meta.get(e);if(null==s)throw new Error("invalid-node");const{origin:r,buffer:o}=await this._collection.extractEdgeInformation(s.objectHandle,t,i);return this._snappingLocationsApplyElevation(s,o,r),{type:"components",objectIds:s.featureIds,locations:o,origin:r}},remove:()=>s(this._snappingSourcesTrackers,t)};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach((t,i)=>{if(null==t)return;const s=this._controller.getRenderMbs(t.node);s&&e.add(i,s)}),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||0===this.elevationInfo.mode)return;const s=t.position0,r=t.position1,o=t.componentIndex,n=H(),a=H(),l=(e,t)=>{V(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,a),V(e,e,D(a,a,t)),A(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,n),l(n,t),s.setVec(d,n),r.getVec(d,n),l(n,t),r.setVec(d,n)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(null!=s)for(const r of this._snappingSourcesTrackers)1!==t&&2!==t||r.events.remove(i),0!==t&&2!==t||r.events.add(i,s)}_logEdgeViewError(e,t){h(e)||o.getLogger(this).warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}_indexedDbSizeCheck(e,t){return t.byteSize>xt?(o.getLogger(this).warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}get elevationProvider(){return this._elevationProvider}};return e([y()],T.prototype,"_hasLoadedPBRTextures",void 0),e([y()],T.prototype,"_asyncModuleLoading",void 0),e([y()],T.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([y()],T.prototype,"view",void 0),e([y()],T.prototype,"i3slayer",void 0),e([y()],T.prototype,"_controller",void 0),e([y()],T.prototype,"_labeler",void 0),e([y()],T.prototype,"updating",void 0),e([y()],T.prototype,"suspended",void 0),e([y()],T.prototype,"contentVisible",null),e([y({readOnly:!0})],T.prototype,"legendEnabled",null),e([y(dt)],T.prototype,"updatingProgress",void 0),e([y()],T.prototype,"updatingProgressValue",null),e([y()],T.prototype,"hasTexturesOrVertexColors",null),e([y()],T.prototype,"rendererTextureUsage",null),e([y()],T.prototype,"elevationOffset",null),e([y()],T.prototype,"elevationInfo",null),e([y({type:Boolean})],T.prototype,"slicePlaneEnabled",void 0),e([y()],T.prototype,"supportedTextureEncodings",null),e([y({type:[ne]})],T.prototype,"_modifications",void 0),e([y({readOnly:!0})],T.prototype,"clientGeometry",null),e([y()],T.prototype,"elevationRange",null),e([y()],T.prototype,"fullExtent",null),e([y()],T.prototype,"_elevationTask",void 0),e([y({readOnly:!0})],T.prototype,"_usePBR",null),T=e([b("esri.views.3d.layers.I3SMeshView3D")],T),T},Et=$(),Ot=Q(),Rt=Q(),jt=new at,Ft=new t([0,0,0,0]),Vt=new te(0,0,0,0);function Dt(e){if(null==e)return!1;const t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function At(e){return"geometryData"in e}function Tt(e){return null!=e&&p(e.data)}function Ht(e,t){let i=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(null!=t)for(const s of t)null!=s&&p(s.data)&&(i+=s.data.byteLength);return i}function Nt(e){if(0===e.length)return;const t=10*e.length,i=new Float64Array(t);let s=0;return e.forAll(e=>{let t=e.serviceObbInIndexSR;null==t&&(t=jt,e.serviceMbsInIndexSR?(t.center=e.serviceMbsInIndexSR.center,t.halfSize=[e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius]):t.invalidate());const r=t.data;i[s++]=r[0],i[s++]=r[1],i[s++]=r[2],i[s++]=r[3],i[s++]=r[4],i[s++]=r[5],i[s++]=r[6],i[s++]=r[7],i[s++]=r[8],i[s++]=r[9]}),i}class Pt{constructor(e,t,i){this.attributeInfo=e,this.meta=t,this.promise=i,this.allowMemCache=!0}}function kt(e,t){e.forEach(e=>e.opacity=t)}class Lt{constructor(e,t){this.mode=e,this.offset=t}}const Ut=H(),Gt=$(),Bt="elevation-change",qt="",zt="@null",Wt="@ECEF",$t=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],Kt=new ot;function Qt(e,t,i){let s=e.minElevation,r=e.maxElevation;const o=i;if(o>0){t.getCorners($t);for(const e of $t){const t=T(e)-o;s=Math.min(s,t),r=Math.max(r,t)}}else{t.getCorners($t);for(const e of $t){const t=e[2];s=Math.min(s,t),r=Math.max(r,t)}}e.expandElevationRangeValues(s,r)}function Jt(e,t,i){const{center:s,radius:r}=t,o=i>0?T(s)-i:s[2];e.expandElevationRangeValues(o-r,o+r)}function Yt(e,t){const i=e.featureIds.slice();for(const s of t)if(s(i,e),0===i.length)break;return i.length===e.featureIds.length?e.featureIds:i}function Xt(e,t,i){const s=new Array,r=e.filteredIds;if(null==r||t?.size||i?.size){if(null!=r){let o=0;e.featureIds.forEach((e,n)=>{if(r[o]===e)++o;else if(!t?.has(e))return;i?.has(e)||s.push(n)})}}else e.featureIds.forEach((e,t)=>{r[s.length]===e&&s.push(t)});return s}function Zt(e,t,i){if(e&&t)for(const s of t){const t=(e.get(s)??0)+i;t>0?e.set(s,t):e.delete(s)}}function ei(e,t=0){const i=new Map;for(const s of e){Zt(i,0===t?s?.featureIds:1===t?s?.filteredIds:s?.weaklyRemovedIds,1)}return i}export{St as I3SMeshView3D};
5
+ import{__decorate as e}from"tslib";import t from"../../../Color.js";import i from"../../../Graphic.js";import{removeUnordered as s,isSome as r}from"../../../core/arrayUtils.js";import has from"../../../core/has.js";import o from"../../../core/Logger.js";import{equals as n}from"../../../core/MapUtils.js";import{destroyMaybe as a}from"../../../core/maybe.js";import l from"../../../core/PooledArray.js";import{ignoreAbortErrors as d,isAbortError as h,throwIfAborted as c,createResolver as u}from"../../../core/promiseUtils.js";import{initial as _,watch as g}from"../../../core/reactiveUtils.js";import{schedule as m}from"../../../core/scheduling.js";import{equals as f}from"../../../core/SetUtils.js";import{isArrayBuffer as p}from"../../../core/typedArrayUtil.js";import{property as y,subclass as b}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as v,invert as I}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as C}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as M,getTranslation as w}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as x,create as E}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as S}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{h as O,p as R,t as j,a as F,i as V,j as D,e as A,u as T}from"../../../chunks/vec32.js";import{create as H}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as N}from"../../../chunks/vec42.js";import{fromValues as P}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as k}from"../../../core/support/UpdatingHandles.js";import{getSphericalPCPF as L}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{localLinearScaleFactors as U}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as G}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as B}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as q}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as z}from"../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as W,create as $,toRect as K}from"../../../geometry/support/aaBoundingBox.js";import{create as Q,intersects as J}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as Y,ensurePackedMat4f64 as X}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as Z}from"../../../geometry/support/FloatArray.js";import{compactIndices as ee}from"../../../geometry/support/Indices.js";import{Sphere as te}from"../../../geometry/support/sphere.js";import{newUByteArray as ie}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as se}from"../../../layers/LayerConstants.js";import re from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as oe}from"../../../layers/support/fieldUtils.js";import ne from"../../../layers/support/SceneModification.js";import{getColor as ae,getOpacity as le}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{isBasemapLayerView as de}from"../../../support/basemapUtils.js";import{getElevationOffset as he}from"../../../support/elevationInfoUtils.js";import{loadArcade as ce}from"../../../support/loadArcade.js";import ue from"../../../symbols/MeshSymbol3D.js";import _e from"../../../symbols/SimpleFillSymbol.js";import{ContentGeometryUpdateEvent as ge}from"./ContentGeometryLayerView.js";import me from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as fe}from"./I3SMeshViewPerformanceInfo.js";import{initialize as pe,setModificationsSync as ye,filterObbsForModificationsSync as be,interpretObbModificationResults as ve}from"./SceneLayerWorker.js";import{SceneLayerWorkerHandle as Ie,toWasmModification as Ce}from"./SceneLayerWorkerHandle.js";import{overrideColor as Me}from"./graphics/graphicUtils.js";import{areLabelsVisible as we}from"./graphics/Labeler.js";import xe from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as Ee}from"./i3s/I3SAsyncElevationUpdater.js";import{getCachedAttributeValue as Se}from"./i3s/I3SBinaryReader.js";import{I3SCrossfadeHelper as Oe,NodeCrossfadeMetaData as Re}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as je}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Fe}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Ve,selectEncoding as De,defaultMaterial as Ae,createTexture as Te,configureMaterial as He}from"./i3s/I3SMaterialUtil.js";import{I3SOverrides as Ne}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as Pe}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as ke,checkSceneLayerValid as Le,checkSceneLayerCompatibleWithView as Ue,whenGraphicAttributes as Ge,computeVisibilityObb as Be,filterInPlace as qe,intersectBoundingRectWithMbs as ze,addWraparound as We,getSymbolInfo as $e,transparentEdgeMaterial as Ke,getClipRect as Qe}from"./i3s/I3SUtil.js";import{IDBCache as Je}from"./i3s/IDBCache.js";import{IDBMockCache as Ye}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as Xe}from"./i3s/LayerElevationProvider.js";import{SymbologyInfo as Ze}from"./i3s/SymbologyInfo.js";import{attributeLookup as et}from"./support/attributeUtils.js";import{normalizeHighlightTarget as tt,emptyHighlightHandle as it}from"./support/highlightUtils.js";import{makeScheduleFunction as st}from"./support/makeScheduleFunction.js";import{debugFlags as rt}from"../support/debugFlags.js";import{ElevationRange as ot}from"../support/ElevationRange.js";import{toBoundingRect as nt}from"../support/extentUtils.js";import{Obb as at,ensurePackedObbData as lt}from"../support/orientedBoundingBox.js";import{updatingProgress as dt}from"../support/updatingProperties.js";import{glLayout as ht}from"../support/buffer/glUtil.js";import{ObjectParameters as ct}from"../webgl-engine/collections/Component/ObjectParameters.js";import{createVertexBufferLayout as ut,ComponentGeometryParameters as _t,SourceGeometry as gt,GeometryParameters as mt}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as ft}from"../webgl-engine/collections/Component/Transform.js";import{emissiveStrengthDefault as pt}from"../webgl-engine/core/shaderLibrary/output/Emissions.glsl.js";import{loadBasisTranscoder as yt}from"../webgl-engine/lib/BasisUtil.js";import{getHighlightName as bt}from"../../support/highlightOptionsUtils.js";import{TextureCompressionTracker as vt}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as It}from"../../../webscene/support/AlphaCutoff.js";const Ct=[1,1,1,1];class Mt extends Re{constructor(e,t,i,s,r,o,n,a,l){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=n,this.anchorIds=a,this.anchors=l,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0,this.cachedSymbologyStride=5}get usedMemory(){return this.node.memory}get featureExtents(){return this._featureExtents??=new Float64Array(6*this.featureIds.length).fill(Number.POSITIVE_INFINITY),this._featureExtents}}const wt=26,xt=104857600,Et=t=>{const p=t;let T=class extends p{constructor(){super(...arguments),this._applySSAO=!0,this._shadeNormals=!0,this._updatingHandles=new k,this._highlights=null,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._compressionTracker=new vt,this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._hasComponentData=!1,this._hasVertexColors=!1,this._nodeColorOverride=null,this.updating=!0,this.holeFilling="auto",this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=new Array,this.ignoresMemoryFactor=!1,this._layerUrl="",this._cacheKeySuffix=null,this._planetRadiusInGlobalMode=0,this._elevationTask=null,this._needFilterResolve=!1,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i,this._crossfadeHelper=new Oe(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerViewUid(){return this.uid}get layerId(){return this.i3slayer.id}get sublayerId(){return null}get _isIntegratedMesh(){return"integrated-mesh"===this.i3slayer.type}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible&&this.fullOpacity>It}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?"yes":"probably-not":"unknown"}get rendererTextureUsage(){return ke(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?63:53:this._usePBR||this._hasLoadedPBRTextures?44:36}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;return null!=e&&"absolute-height"===e.mode?he(e,this.i3slayer.spatialReference):0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return new Lt(0,0);const t=he(e,this.i3slayer.spatialReference);switch(e.mode){case"absolute-height":return new Lt(0,t);case"relative-to-ground":return new Lt(1,t);case"on-the-ground":return new Lt(2,0);default:return new Lt(0,0)}}get supportedTextureEncodings(){return Ve(this.view.stage.renderView.capabilities)}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){const e=this._nodeId2Meta,t=new ot;for(const i of e.values()){const e=i?.node.serviceMbsInIndexSR;e&&t.expandElevationRangeValues(e.center[2]-e.radius,e.center[2]+e.radius)}return t.elevationRangeValid?t:null}get fullExtent(){return this.i3slayer.fullExtent}initialize(){const e=has("enable-feature:idb-mock-cache");this._idbCache=e?new Ye(this.view,e):new Je("esri-scenelayer-cache","geometries"),this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const t=this.view.resourceController,i=t.memoryController;this.i3sOverrides=new Ne({view:this.view,layer:this.i3slayer,memoryController:i}),this._workerHandle=new Ie(st(t)),this.addResolvingPromise(this._workerHandle.promise);const s=this.i3slayer.store;this.addResolvingPromise(this._workerHandle.setLegacySchema(this.uid,s.defaultGeometrySchema).catch(d)),Le(this.i3slayer),Ue(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new re({layerView:this,worker:this._workerHandle}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view.stage,this._collection=this._stage.renderView.componentObjectCollection;const r=s.defaultGeometrySchema;if(this._isIntegratedMesh||!r)this._hasComponentData=!1;else{const e=r.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(r?.vertexAttributes.color??null)&&!this.i3slayer.cachedDrawingInfo?.color;const n=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,e=>this._deleteComponentObject(e));this._memCache=n;const l=this._controller,h=this._nodeId2Meta,c=this._nodeId2MetaReloading,u=e=>{const t=l.index;if(!t)return;const i=t.rootNode;if(!i)return;const s=t=>{const i=t.index,s=h.get(i)||c.get(i);return e(t,s?.objectHandle??null)};t.traverse(i,s)};this._intersectionHandler=new Fe({layerViewUid:this.layerViewUid,sublayerId:this.sublayerId,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:u}),this._elevationProvider=new Xe({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add(()=>this.view.clippingArea,()=>this._clippingAreaChanged(),_),this._updatingHandles.add(()=>this.fullOpacity,e=>this._opacityChange(e)),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this.elevationOffset,(e,t)=>{this._reloadAll(t),this._controller.invalidateVisibilityObbs()}),this._updatingHandles.add(()=>this.elevationInfo,(e,t)=>this._elevationInfoChanged(e,t),_),this._updatingHandles.add(()=>!this.suspended&&0!==this.elevationInfo.mode,(e,t)=>{e?this.addHandles(this.view.basemapTerrain.on("elevation-change",({extent:e})=>this._ensureElevationTask().addExtent(e)),Bt):t&&this.removeHandles(Bt)},_),this._updatingHandles.add(()=>this._usePBR,e=>this._updatePBR(e));const m=()=>{this._reloadAll(),this.clearMemCache()};this._updatingHandles.add(()=>this.rendererTextureUsage,m),this._updatingHandles.add(()=>this.contentVisible,e=>this._contentVisibleChanged(e),_),this._updatingHandles.add(()=>this.i3slayer.labelsVisible,()=>this._labelingChanged(),_),this._updatingHandles.add(()=>this.i3slayer.labelingInfo,()=>this._labelingChanged(),_),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),_),this.addHandles([g(()=>rt.I3S_TREE_SHOW_TILES,e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then(({I3STreeDebugger:t})=>{!this._treeDebugger&&rt.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))})}else e||rt.I3S_TREE_SHOW_TILES||(this._treeDebugger=a(this._treeDebugger))},_),g(()=>rt.I3S_SHOW_MODIFICATIONS,()=>this._showModifications(),_)]),this._cacheKeySuffix=this._getCacheKeySuffix(),this._idbCache.init().catch(e=>o.getLogger(this).warn(`Failed to initialize IndexedDB cache: ${e}`));const{view:f}=this,{viewingMode:p,renderCoordsHelper:y}=f;this._planetRadiusInGlobalMode="local"===p?0:y.referenceEllipsoid.radius}destroy(){this._clearAddTasks(),this._elevationTask=a(this._elevationTask),this.i3sOverrides=a(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.notifyObjectsChanged(this.getVisibleObbs()),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._workerHandle;e&&(e.destroyContextAndSelf(this.uid),this._workerHandle=null),this._removeAllNodeDataFromStage(),this._memCache=a(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=a(this._labeler),this._treeDebugger=a(this._treeDebugger),this._controller=a(this._controller),this._highlights=a(this._highlights),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=a(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null),this._updatingHandles=a(this._updatingHandles)}_memEstimateTextureAdded(e){const t=e.usedMemory;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(null!=e){const t=e.usedMemory;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){const t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){const t=this._collection.getObjectGPUMemoryUsage(e);this._gpuMemoryEstimate-=t,this._geoMemoryEstimate-=t}isNodeLoaded(e){return this._nodeId2Meta.has(e)}isNodeReloading(e){return this._nodeId2MetaReloading.has(e)}get usedMemory(){let e=null!=this._labeler?this._labeler.usedMemory:0;return this._nodeId2Meta.forEach(t=>e+=null!=t?t.node.memory:0),this._nodeId2MetaReloading.forEach(t=>e+=null!=t?t.node.memory:0),e}get unloadedMemory(){return(null!=this._controller?this._controller.unloadedMemoryEstimate:0)+(null!=this._labeler?this._labeler.unloadedMemoryEstimate:0)}_labelingChanged(){if(!(we(this.i3slayer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new me({view:this.view,layer:this.i3slayer,collection:this._collection,overrides:this.i3sOverrides,layerViewUid:this.uid});this._nodeId2Meta.forEach(t=>null!=t&&this._addMetaToLabeler(e,t)),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then(e=>(--this._asyncModuleLoading,e),e=>{throw--this._asyncModuleLoading,e})}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=pe().then(()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()}),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=e=>o.getLogger(this).error("set-modifications-error","Error when setting modifications:",e),t=this.uid,i=this.i3slayer.spatialReference,s=i.isGeographic,r=Ce(this._layerClippingArea,this._modifications,i);this._workerHandle.setModifications(t,r,s).catch(e);try{ye({context:t,modifications:r,isGeodetic:s})}catch(a){e(a)}this._controller.modificationsChanged();const n=this.hasModifications?new l:null;this._nodeId2Meta.forEach((e,t)=>{null==e?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._updateFeatureIdCounts(e,-1),this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):null!=n&&n.push(e.node)}),this.notifyChange("elevationRange"),null!=n&&this._nodeId2MetaReloading.forEach(e=>n.push(e.node)),null!=n&&n.length>0&&(this.updateNodeModificationStatus(n),n.forAll(e=>{if(2!==e.imModificationImpact){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),null!=t?(this._updateFeatureIdCounts(t,-1),this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t),this.notifyChange("elevationRange")):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}})),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(null!=this._modificationGraphics&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!rt.I3S_SHOW_MODIFICATIONS||0===this._modifications.length)return;const e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={outline:{color:[255,255,255],width:1}};this._modificationGraphics=[];for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.i3slayer.spatialReference;const o=new _e({...t,color:e[s.type]});this._modificationGraphics.push(new i({geometry:r,symbol:o}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,(e,t)=>this._createAttributes(e,t))}_contentVisibleChanged(e){e?(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler)):(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);null!=i?.attributeInfo&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);null!=s&&(await this.i3sOverrides.applyAttributeOverrides(s.featureIds,t,i,this._controller.requiredAttributes),s.attributeInfo=t,this._controller.reschedule(()=>{this._nodeId2Meta.get(e)===s&&this._attributeValuesChanged(s)},i).catch(e=>{h(e)||o.getLogger(this).warn("Error while updating attribute values. Layer might not display correctly.",e)}))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.appliedFilters=null,null!=this._labeler&&this._labeler.setNodeMetaAttributes(e,(e,t)=>this._createAttributes(e,t)),this._updateEngineObject(e)}clearMemCache(){null!=this._memCache&&this._memCache.clear(),this._addTasks.forEach(e=>e.allowMemCache=!1)}getVisibleNodes(){const e=new Array;return this._nodeId2Meta.forEach(t=>null!=t&&e.push(t.node)),e}getVisibleObbs(){const e=new Array;return this._nodeId2Meta.forEach(t=>t&&e.push(this._collection.getComponentObb(t.objectHandle))),e}getLoadedNodeIndices(e){this._nodeId2Meta.forEach((t,i)=>e.push(i)),this._nodeId2MetaReloading.forEach((t,i)=>e.push(i))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&2&this.supportedTextureEncodings&&this.i3slayer.textureSetDefinitions?.some(e=>e.formats.some(e=>"basis"===e.format||"ktx2"===e.format))&&yt()}_getVertexBufferLayout(e,t){return ht(ut(this._getGeometryParameters({hasTexture:Dt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion})))}_getObjectIdField(){return this.i3slayer.objectIdField||se}_getGlobalIdField(){return this.i3slayer.globalIdField}_findGraphicNodeAndIndex(e){const t=et(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());for(const i of this._nodeId2Meta.values()){const e=i?.featureIds.indexOf(t);if(null!=e&&e>=0)return{node:i.node,index:e}}return null}_getGraphicIndices(e,t){const i=this._nodeId2Meta.get(e.index);if(null==i)return[];const s=[],r=this._getObjectIdField(),o=this.i3slayer.fieldsIndex;for(const n of t){const e=et(o,n.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this.getAABB(t.node.index,t.index);return null==i?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this.getAABB(e.nodeIndex,e.componentIndex)}getAABB(e,t){const i=this._nodeId2Meta.get(e);if(null==i?.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=je(t,this._collection,s,Y(24),0),o=this.view.renderSpatialReference,n=this.view.spatialReference;return B(r,o,0,r,n,0)?W(r):null}whenGraphicAttributes(e,t){return Ge(this.i3slayer,e,this._getObjectIdField(),t,()=>[...this._nodeId2Meta.values()].filter(r))}getGraphicFromIntersectorTarget(e,t){if(null==e.nodeIndex||null==e.componentIndex)return null;const i=this._nodeId2Meta.get(e.nodeIndex);if(null==i?.featureIds||e.componentIndex>=i.featureIds.length)return null;const s=this._createLayerGraphic(this._createAttributes(e.componentIndex,i));return s?t.defer?(t.defer(async()=>(s.geometry=(await import("./i3s/meshUtils.js")).createMesh({layerView:this,nodeIndex:e.nodeIndex,featureIndex:e.componentIndex}),s)),null):s:null}_getCacheKey(e){return`${this._layerUrl}/v${wt}/${e}${this._cacheKeySuffix}`}_getCacheKeySuffix(){const e=this.view.renderSpatialReference;if(null==e)return zt;if(e===L(e))return Wt;return this.i3slayer.spatialReference.equals(e)?qt:null!=e.wkid?`@${e.wkid}`:null}_getMemCacheKey(e,t=this.elevationOffset){return e+"#"+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&0===this.elevationOffset&&null!=this._cacheKeySuffix}loadCachedGPUData(e){return null!=this._memCache?this._memCache.pop(this._getMemCacheKey(e)):null}deleteCachedGPUData(e){null!=e&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(null==this._memCache)return void this._deleteComponentObject(e);const i=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,i)}loadMissingTextures(e,t,i,s){const r=e?.filter((e,i)=>{if(0===(e.usage&this.rendererTextureUsage))return!1;if(null==t)return!0;const s=De(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(null==r?.data||s&&r.encoding!==s.encoding)})??[];return 0===r.length?Promise.resolve(!1):i(r,s).then(i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0})}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then(s=>null==s?null:(s.globalTrafo=X(s.globalTrafo),s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(0===this.elevationInfo.mode&&(e.geometryObbInRenderSR=at.fromData(s.geometryObbData)),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then(i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=Ht(s.transformedGeometry,s.textureData),s.textureData.every(Tt)&&this._indexedDbSizeCheck(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch(t=>o.getLogger(this).warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`))),c(t),s))))):Promise.resolve(null)}addNode(e,t,i){return At(t)?null==t.geometryBuffer?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,()=>this._transformNode(e,t,i).then(s=>this._safeReschedule(()=>{if(null==s)return e.hasModifications=!1,this._addCachedNodeData(e,null,i);const{obb:r,componentOffsets:n,featureIds:a,anchorIds:l,anchors:d,transformedGeometry:h}=s;e.hasModifications=h.hasModifications;const c=X(s.globalTrafo),u=O(Ut,r.center.x,r.center.y,r.center.z);R(u,u,c);const _=new at(u,[r.extents.x,r.extents.y,r.extents.z],S(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));0===this.elevationInfo.mode&&(e.geometryObbInRenderSR=_),t.geometryData.componentOffsets=n,a&&(t.geometryData.featureIds=Array.from(a)),t.geometryData.anchorIds=l,t.geometryData.anchors=d;const g={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:h,globalTrafo:c,geometryObbData:_.data,byteSize:Ht(h,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&this._indexedDbSizeCheck(e,g)){const t=null!=g.textureData?g.textureData.map(e=>Tt(e)?e:null):null;this._idbCache.put(this._getCacheKey(e.id),{...g,textureData:t}).catch(t=>o.getLogger(this).warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`))}return this._addCachedNodeData(e,g,i)},i))):Promise.reject()}getElevationRange(e){const t=new ot,i=this._controller,{index:s}=i;if(!s)return t;const{rootNode:r}=s;if(!r)return t;const o=this._nodeId2Meta,n=e.radius,a=i.viewportQueries,l=this._planetRadiusInGlobalMode,{view:d}=this,{renderCoordsHelper:h}=d,c=h.referenceEllipsoid.radius,u=this._collection,_=i=>{const{childrenLoaded:s}=i;if(0===s)return!1;const r=a.getAndUpdateVisibilityObbInRenderSR(i);let d=null,_=-1;if(r){if(_=r.radius,!r.intersectSphereWithMBS(e,_))return!1}else d=a.calculateServiceMbsInRenderSRElevationAdjusted(i),d&&(_=d.radius);if(_>=0&&n>=1*_)return null!=r?Qt(t,r,l):d?.isValid&&Jt(t,d,l),!1;const g=Kt;if(g.minElevation=1/0,g.maxElevation=-1/0,(null!=r||null!=d)&&(null!=r?Qt(g,r,l):null!=d&&Jt(g,d,l),g.minElevation>=t.minElevation&&g.maxElevation<=t.maxElevation))return!1;const m=o.get(i.index);if(m){const{geometryObbInRenderSR:s}=i;if(!s||s.intersectSphereWithMBS(e)){if(s){if(n>0*s.radius)return Qt(t,s,l),!1}const{objectHandle:e}=m,i=u.getObjectTransform(e),r=h.getAltitude(i.position);u.expandRangeWithComponentObjectElevationRange(e,r,c,t)}}return s-(m?1:0)>0};return s.traverse(r,_),t}computeVisibilityObb(e){return Be(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications,this.view.renderCoordsHelper.sphericalPCPF)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let f=0;f<s.length;++f)r[f]=this._getVertexBufferLayout(s[f],t.geometryDescriptor);const o=this.i3slayer.normalReferenceFrame,n=t.normalReferenceFrame??o??"none",a=e.serviceMbsInIndexSR,l=this.elevationOffset,d=this._controller.crsIndex,h=this._controller.crsVertex,c=this.view.renderSpatialReference,u=Pe(a,l,n,d,c),_=q(d,h),g=q(h,c);if(null==_||null==g)return Promise.resolve(null);const m={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,globalTrafo:u,mbs:a.toJSON(),obbData:e.serviceObbInIndexSR?.data,elevationOffset:l,needNormals:this._controller.isMeshPyramid,normalReferenceFrame:n,indexToVertexProjector:_,vertexToRenderProjector:g};return this._workerHandle.invoke(m,i)}get _supportsNodeCrossFading(){return!this.view?.stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){const t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,i){if(0===this.elevationInfo.mode&&(e.geometryObbInRenderSR=this._collection.getComponentObb(t.objectHandle).clone()),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);null!=this._labeler&&this._addMetaToLabeler(this._labeler,t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,!0),this._updateMaterial(t),this._setNewNodeOpacity(t),0!==this.elevationInfo.mode&&this._ensureElevationTask().schedule(s),this._updateEngineObject(t),this._highlights?.objectCreated(t),null!=this._treeDebugger&&this._treeDebugger.update()}addCachedNodeData(e,t,i,s){return this._addData(e,i,()=>this._addCachedNodeData(e,t,s))}async deleteCachedNodeData(e){if(this._idbCacheEnabled)return this._idbCache.remove(this._getCacheKey(e))}async _addCachedNodeData(e,t,i){if(!this.contentVisible||!this._controller.isGeometryVisible(e))return void this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);if(null==t)return void this._addNodeMeta(e.index,null);const s=this._addTasks.get(e.index),{geometryData:r,transformedGeometry:n}=t;await this.i3sOverrides.applyAttributeOverrides(r.featureIds,s.attributeInfo,i,this._controller.requiredAttributes);const a=null!=t.textureData?t.textureData.filter(e=>null!=e&&0!==(e.usage&this.rendererTextureUsage)):[];!has("disable-feature:i3s-basis")&&a.some(e=>null!=e&&(2===e.encoding||1===e.encoding))&&await yt(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:h,anchorIds:c,anchors:u}=r,_=this._collection,g=d[0],{layout:m,indices:f,interleavedVertexData:p,positionData:y,hasColors:b}=n,{material:S,geometryParameters:O}=this._materialParameters(g,m),R=l||new Uint32Array([0,f?f.length:p.byteLength/m[0].stride]),V=new _t(m,O.shadeNormals,O.applySSAO,O.textureCoordinateType),D=new gt({data:p,count:p.byteLength/m[0].stride},{positions:Z(y.data),indices:ee(y.indices)},f,R,V),A=g.transformation?x(g.transformation):E(),T=X(t.globalTrafo);M(A,T,A);const N=w(H(),A),k=v(C(),A),L=this.view.renderSpatialReference,G=this.view.basemapTerrain.spatialReference,B=at.fromData(lt(t.geometryObbData)).center,q=[1,1,1];U(B,L,q,G)||o.getLogger(this).errorOnce("Unsupported coordinate system for IM overlay");const W=H();z(B,L,W,G);const $=C();I($,k);const K=H();j(K,F(K,B,N),$);const Q=W[0]-K[0]*q[0],J=W[1]-K[1]*q[1],Y=2===O.textureCoordinateType,{textures:te,texturePromise:ie,materialParameters:se}=this._initMaterialAndTextures(S,a,Y,e),re=_.createObject(new ct(P(Q,J,q[0],q[1]),new ft(N,k),at.fromData(lt(t.geometryObbData)),D,!this._isIntegratedMesh),se);e.memory+=this._memEstimateGeometryAdded(re),e.memory+=te.reduce((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0),0);const oe=!!S.hasParametersFromSource,ne="blend"!==S.alphaMode&&S.metallicRoughness.baseColorFactor[3]>=1,ae=new Mt(e,h,re,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:oe,isOpaque:ne},te,c,u);s.meta=ae,this._hasTextures||=t.requiredTextures?.some(({usage:e})=>!!(19&e))||!!e.resources.texture,this._hasData=!0,this._hasColors||=b,this.notifyChange("hasTexturesOrVertexColors");const le=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(ae),ie]).then(([t,s])=>(this._addTasks.has(e.index)&&t?.updateObjectVisibility(ae.objectHandle,!1).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),this._safeReschedule(()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,ae),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(re,!0),t?.updateObjectVisibility(ae.objectHandle,!0).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),ae.attributeInfo=i.attributeInfo;const s=ae.cachedRendererVersion!==this._rendererVersion,r=le!==this.slicePlaneEnabled;this._updateElevationOffsets(ae);const o=ae.elevationOffsets;this._updateComponentData(ae);const n=this._applyFiltersToNode(ae);(s||null!=t&&(r||n||o))&&this._addOrUpdateEdgeRendering(ae),null!=this._labeler&&this._addMetaToLabeler(this._labeler,ae),this._visibleGeometryChanged(ae,0),this._highlights?.objectCreated(ae),this._updateMaterial(ae),this._setNewNodeOpacity(ae),null!=this._treeDebugger&&this._treeDebugger.update()},i))).catch(e=>{const{meta:t,allowMemCache:i}=s;throw s.meta=null,t&&i?this._cacheGPUData(t):t&&this._deleteComponentObject(t),e})}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){o.getLogger(this).error("Removing duplicated node");const t=this._nodeId2Meta.get(e);t&&(this._deleteComponentObject(t),this._updateFeatureIdCounts(t,-1))}else this._controller.updateLoadStatus(e,!0);t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&kt(t.cachedEdgeMaterials,0),this._updateFeatureIdCounts(t,1)),this._nodeId2Meta.set(e,t),this.notifyChange("elevationRange")}_updateElevationOffsets(e){if(!e.node.serviceMbsInIndexSR)return;const{view:t,elevationInfo:i}=this,s=this._controller.crsIndex,{groundView:r,groundSpatialReference:o,renderSpatialReference:n}=t,a=i.mode;if(null==n||null==o||0===a)return void(e.elevationOffsets=null);const l=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const d=Ut,h=Gt,c=2===a,u=this.view.renderCoordsHelper,_=e.featureIds.length,g=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const t=Y(3*_);e.cachedElevationAnchors=t;const{center:i}=e.node.serviceMbsInIndexSR;for(let r=0;r<_;r++){const a=3*r,c=e.anchorIds?.indexOf(r)??-1;e.anchors&&c>=0?(O(d,e.anchors[3*c],e.anchors[3*c+1],e.anchors[3*c+2]),V(d,d,i),z(d,s,d,o),t[a]=d[0],t[a+1]=d[1],t[a+2]=u.getAltitude(d)):(this._collection.getComponentAabb(e.objectHandle,r,h,!0),O(d,(h[0]+h[3])/2,(h[1]+h[4])/2,h[2]),j(d,d,l.rotationScale),V(d,d,l.position),t[a+2]=u.getAltitude(d),z(d,n,d,o),t[a]=d[0],t[a+1]=d[1])}return t})(),m=i.offset,f=e.elevationOffsets,p=(e,t)=>{const i=c?g[3*e+2]:0;f[e]=m+(t??0)-i};r.getElevations(g,_,p)}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new Ee(this.view.resourceController.scheduler,e=>this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference)?.filterInPlace(e=>null!=this._nodeId2Meta.get(e)),e=>this._nodeElevationAlignmentChanged(this._nodeId2Meta.get(e)),()=>this.elevationInfo?.mode)),this._elevationTask}_elevationInfoChanged(e,t){const i=0!==e.mode,s=!!t&&t!==e&&0!==t.mode;this._intersectionHandler.updateElevationAlignState(i,this.view.state.viewingMode),i&&!s&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach(e=>this._nodeElevationAlignmentChanged(e))}_nodeElevationAlignmentChanged(e){null!=e&&(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),null!=this._labeler&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,2),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}_safeReschedule(e,t){return c(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:Ae(),s=t.some(({name:e})=>"uvRegion"===e),r=t.some(({name:e})=>"normalCompressed"===e),o=Dt(i);return{geometryParameters:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s){const r=this._stage.renderView,o=e=>{this._gpuMemoryEstimate-=e,this._texMemoryEstimate-=e,s.memory-=e},n=t.map(t=>Te(t,e,i,r,this._compressionTracker,o));this._stage.addTextures(n);const{materialParameters:a,texturePromise:l}=He(e,n,t,this.view.stage.renderView.textures,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference});return{textures:n,texturePromise:l,materialParameters:a}}_getGeometryParameters(e){return new mt(this._hasVertexColors,e.hasTexture?e.hasRegions?2:1:0,e.hasNormals,this._shadeNormals,this._applySSAO)}_addData(e,t,i){let s=this._addTasks.get(e.index);if(s)s.attributeInfo=t;else{const r=u();s=new Pt(t,null,r.promise),this._addTasks.set(e.index,s),i().then(r.resolve,r.reject).then(()=>this._addTasks.delete(e.index)).catch(t=>{throw this._addTasks.delete(e.index),t})}return s.promise}_clearAddTasks(){this._addTasks.forEach(e=>{null!=e.meta&&(this._cacheGPUData(e.meta),e.meta=null)}),this._addTasks.clear()}_clippingAreaChanged(){const e=this.view.renderSpatialReference,t=this.i3slayer.spatialReference,i=Q();this._renderClippingArea=nt(this.view.clippingArea,i,e)?i:null;const s=Q();this._layerClippingArea=nt(this.view.clippingArea,s,t)?s:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){const e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e),this._assertFeatureIdNodeCounts(e)}_assertFeatureIdNodeCounts(e){e&&!this._featureIdCounts?(this._featureIdCounts=ei(this._nodeId2Meta.values()),this._filteredIdCounts=ei(this._nodeId2Meta.values(),1),this._weaklyRemovedIdCounts=ei(this._nodeId2Meta.values(),2),this.addHandles(g(()=>this._controller.updating,e=>{!e&&this._needFilterResolve&&(this.multiGeometryFilterResolve(),this._needFilterResolve=!1,this.notifyUpdate())},{sync:!0}),"updateFinished")):!e&&this._featureIdCounts&&(this._featureIdCounts=null,this._filteredIdCounts=null,this._weaklyRemovedIdCounts=null,this._mismatchShow=null,this._mismatchHide=null,this.removeHandles("updateFinished"),this._needFilterResolve=!1,this.notifyUpdate())}_updateFeatureIdCounts(e,t){this._featureIdCounts&&(this._needFilterResolve=!0,Zt(this._featureIdCounts,e.featureIds,t),Zt(this._filteredIdCounts,e.filteredIds,t),Zt(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,t))}_updateFilteredIdCounts(e,t,i){this._filteredIdCounts&&(this._needFilterResolve=!0,Zt(this._filteredIdCounts,t,-1),Zt(this._filteredIdCounts,e.filteredIds,1),Zt(this._weaklyRemovedIdCounts,i,-1),Zt(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,1))}_checkFeatureIdNodeCountInvariant(){const e=null!=this._featureIdCounts;if(this.hasGeometryFilter!==e&&o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","LayerView should have feature id node counts if and only if it has a geometry filter",{layerView:this,hasNodeCounts:e}),!this._featureIdCounts||!this._filteredIdCounts)return;const t=ei(this._nodeId2Meta.values());n(this._featureIdCounts,t)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _featureIdCounts",{layerView:this,counts:this._featureIdCounts,expected:t});const i=ei(this._nodeId2Meta.values(),1);n(this._filteredIdCounts,i)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _filteredIdCounts",{layerView:this,counts:this._filteredIdCounts,expected:i});const s=ei(this._nodeId2Meta.values(),2);n(this._weaklyRemovedIdCounts,s)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _weaklyRemovedIdCounts",{layerView:this,counts:this._weaklyRemovedIdCounts,expected:i})}multiGeometryFilterResolve(){if(!this._featureIdCounts||!this._filteredIdCounts)return;let e=null,t=null;for(const[i,s]of this._filteredIdCounts){const r=this._featureIdCounts.get(i);if(r!==s){s+(this._weaklyRemovedIdCounts?.get(i)??0)===r?(e??=new Set,e.add(i)):(t??=new Set,t.add(i))}}f(e,this._mismatchShow)&&f(t,this._mismatchHide)||(this._mismatchShow=e,this._mismatchHide=t,this._nodeId2Meta.forEach(e=>{if(!e?.filteredIds)return;const t=Xt(e,this._mismatchShow,this._mismatchHide);this._collection.setAllComponentVisibilities(e.objectHandle,t),this._visibleGeometryChanged(e,2)}))}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach(e=>{e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,2))})}getFilters(){const e=[],t=this._renderClippingArea;return null!=t&&e.push((e,i)=>this._boundingRectFilter(e,i,t)),e}addSqlFilter(e,t,i){if(null!=t){const s=t.fieldNames;e.push((e,r)=>this._sqlFilter(e,r,t,s,i))}}_sqlFilter(e,t,i,s,r){const o={},n=this._createLayerGraphic(o);if(!n)return;const a=this.i3slayer.objectIdField,l=t.featureIds,d=t.attributeInfo?.attributeData;s.every(e=>e===a||null!=d?.[e])&&qe(e,l,e=>{o[a]=l[e];for(const i of s)i!==a&&(o[i]=d?Se(d[i],e):null);try{return i.testFeature(n)}catch(t){return r(t),!1}})}_boundingRectNodeTest(e,t){return G(e.node.serviceMbsInIndexSR,this._controller.crsIndex,Vt,this.view.renderSpatialReference),ze(t,Vt)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,St),K(St,Ot),J(i,Ot)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(3===r)return;if(0===r)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const n=this._transformClippingArea(Rt,i,t.objectHandle);qe(e,t.featureIds,e=>this._boundingRectFeatureTest(t,e,n))}_transformClippingArea(e,t,i){const s=this._collection.getObjectTransform(i),r=s.position,o=s.rotationScale;return e[0]=(t[0]-r[0])/o[0],e[1]=(t[1]-r[1])/o[4],e[2]=(t[2]-r[0])/o[0],e[3]=(t[3]-r[1])/o[4],e}async _addOrUpdateEdgeRendering(e,t=!0){const i=e.objectHandle,{hasEdges:s,perFeatureEdgeMaterials:r}=this._getFilteredEdgeMaterials(e);s&&!this._edgeView&&(this._edgeView=await this._stage.renderer.loadEdgeView());const o=this._edgeView;if(!o)return null;const n=o.hasObject(i);if(s){if(n){if(this.nodeCrossfadingEnabled){kt(r,this.getNodeOpacity(e))}return o.updateAllComponentMaterials(i,r,this.slicePlaneEnabled,t).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),o.updateObjectVisibility(i,!0).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),o.updateAllVerticalOffsets(i,e.elevationOffsets).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),o}const s=await this._collection.addEdges(i,o,r,this.slicePlaneEnabled,e.elevationOffsets);return e.edgeMemoryUsage=s,e.node.memory+=s,o}return n&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,o.removeObject(i)),null}_applyFiltersToNode(e){const{filteredIds:t,weaklyRemovedIds:i}=e,s=this._applyFiltersToNodeComponents(e);return this._updateFilteredIdCounts(e,t,i),s&&this._labeler?.applyFilterChange(e),s}_applyFiltersToNodeComponents(e){const t=this._collection,i=t.getComponentCount(e.objectHandle),s=null!=e.filteredIds,r=0===i.invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!r;if(null!=e.filteredIds&&e.appliedFilters===this._filters||(e.weaklyRemovedIds=null,e.filteredIds=Yt(e,this._filters),e.appliedFilters=this._filters),s&&e.filteredIds===e.featureIds&&(!this._mismatchHide||e.filteredIds.every(e=>!this._mismatchHide?.has(e))))return!r;const o=Xt(e,this._mismatchShow,this._mismatchHide);return t.setAllComponentVisibilities(e.objectHandle,o),!0}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach((t,i)=>this._removeNodeStageData(i,e)),this._nodeId2MetaReloading.forEach((t,i)=>this._removeNodeStageData(i,e,this._nodeId2MetaReloading)),this._elevationTask=a(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),null!=this._elevationTask&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);null!=s?(this._collection.setObjectVisibility(s.objectHandle,!1),null!=this._edgeView&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),this._visibleGeometryChanged(s,1),null!=this._labeler&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights?.objectDeleted(s),i===this._nodeId2Meta?(this._updateFeatureIdCounts(s,-1),this._cacheGPUData(s,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(s)):this._deleteComponentObject(s),null!=this._treeDebugger&&this._treeDebugger.update()):i.delete(e)}_deleteComponentObject(e){if(null!=this._edgeView&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(const t of e.textures)this._memEstimateTextureRemoved(t),this._stage.removeTexture(t)}updateNodeState(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._collection.updateMaterial(i.objectHandle,{polygonOffsetEnabled:0===t})}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){const i=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,i),this.notifyChange("elevationRange")}const i=this._nodeId2MetaReloading.get(e);i&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,i))}_invalidateAllSymbols(){this._rendererVersion=We(this._rendererVersion,1),this._controller?.requestUpdate()}_getInvalidRendererVersion(){return We(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=We(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.i3slayer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&"arcadeRequired"in e&&e.arcadeRequired&&(this._arcade=await ce()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:o.getLogger(this).warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.symbols)"mesh-3d"!==t.type&&o.getLogger(this).error(`Symbols of type '${t.type}' are not supported for 3D Object Scene Services.`);this._controller&&this._controller.requestUpdate()}_getCachedEdgeMaterials(e){return this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e),e.cachedEdgeMaterials}_getComponentParameters(e){this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e);const t=e.cachedSymbology;return(i,s)=>{const r=i*e.cachedSymbologyStride;N(s.externalColor,t[r]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255);const o=this._stage.renderView.olidRenderHelper;if(o){const t=e.featureIds[i],r=this.sublayerId?`${this.layerViewUid}_${this.sublayerId}`:this.layerViewUid,n=de(this.view,this.uid);o.setUidToObjectAndLayerId(t,t,this.layerId,r,this.layerPopupEnabledAndHasTemplate&&!n,e.node.resources.attributes,i,this.sublayerId),s.olidColor=o.getObjectAndLayerIdColor({graphicUid:t,layerViewUid:r})}s.externalColorMixMode=15&t[r+4],s.castShadows=!!(16&t[r+4]),s.pickable=!!(32&t[r+4]),s.elevationOffset=e.elevationOffsets?.[i]??0,s.emissiveStrength=e.emissiveStrengths?.[i]??1,s.emissiveSource=e.emissiveSources?.[i]??0}}_getSymbolInfo(e,t){const i=e?.getSymbol(t,{arcade:this._arcade});if(!(i instanceof ue))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=$e(i);return this._symbolInfos.set(s,r),r}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=null!=this._symbologyOverrideFields&&this._symbologyOverrideFields.length>0?null!=this._rendererFields&&this._rendererFields.length>0?oe(this.i3slayer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;const t=this._tmpAttributeOnlyGraphic,i={};t.attributes=i;const s=this._currentRenderer,r=e.attributeInfo?.attributeData,o=e.featureIds?this.i3slayer.objectIdField:null,n=null!=r&&null!=this._symbologyFields&&this._symbologyFields.length>0;let a=null,l=null;if(n&&null!=this._symbologyFields){a=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(a.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=ie(e.featureIds.length*e.cachedSymbologyStride));const d=new Ze,h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=1,g=Ke,m=0;for(let f=0;f<e.featureIds.length;f++){if(null!=o&&(i[o]=e.featureIds[f]),n&&a)for(let e=0;e<a.length;e++)i[a[e]]=Se(l[e],f);const r=s?this._getSymbolInfo(s,t):null;let h,p;if(d.pickable=!0,s&&"visualVariables"in s){if(this._colorVariable){const e=ae(this._colorVariable,t,{color:Ft,arcade:this._arcade});e&&(h=d.color,h[0]=e.r/255,h[1]=e.g/255,h[2]=e.b/255,h[3]=e.a??1,this._opacityVariable||null===e.a||(p=e.a))}this._opacityVariable&&(p=le(this._opacityVariable,t,{arcade:this._arcade}))}if(r?.material){const e=r.material;h=null==h||null==p?Me(h,p,e.color,e.alpha,Ct,d.color):Me(h,p,null,null,Ct,d.color)}h??=N(d.color,1,1,1,1);const y=r?.material;if(d.colorMixMode=y?.colorMixMode??1,d.edgeMaterial=r?.edgeMaterial,this._symbologyOverride?.(t,d),null!=this._nodeColorOverride&&(this._nodeColorOverride(e.node,h),d.colorMixMode=3),d.pickable&&=h[3]>=It,d.castShadows=r?r.castShadows:d.pickable,null!=d.edgeMaterial){const t=h[3]>=1&&(e.material.isOpaque||3===d.colorMixMode)?1:0;d.edgeMaterial===u&&t===_||(g={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,_=t),e.cachedEdgeMaterials[f]=g}else e.cachedEdgeMaterials[f]=Ke;e.cachedSymbology[m++]=Math.round(255*h[0]),e.cachedSymbology[m++]=Math.round(255*h[1]),e.cachedSymbology[m++]=Math.round(255*h[2]),e.cachedSymbology[m++]=Math.round(255*h[3]),e.cachedSymbology[m++]=d.colorMixMode|+d.castShadows<<4|+d.pickable<<5;const b=y?.emissive?.strength??pt;b===pt||e.emissiveStrengths||(e.emissiveStrengths=new Array(e.featureIds.length).fill(pt)),e.emissiveStrengths&&(e.emissiveStrengths[f]=b);const v=y?.emissive?.source||0;0===v||e.emissiveSources||(e.emissiveSources=new Array(e.featureIds.length).fill(0)),e.emissiveSources&&(e.emissiveSources[f]=v)}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||kt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some(e=>e!==Ke),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map((t,o)=>e.featureIds[o]!==i[s]?Ke:(r=r||t!==Ke,s++,t));return{hasEdges:r,perFeatureEdgeMaterials:o}}_updateComponentData(e){if(!this._hasComponentData)return;const{objectHandle:t}=e,i=this._getComponentParameters(e);this._collection.setComponentData(t,i),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),null!=this._controller&&this._controller.restartNodeLoading()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach(t=>{null!=t&&(this._collection.updateObjectOpacity(t.objectHandle,e),kt(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))})}_updateMaterial(e){this._collection.updateMaterial(e.objectHandle,{slicePlaneEnabled:this.slicePlaneEnabled,usePBR:this._usePBR})}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,2)}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),null!=this._labeler&&(this._labeler.slicePlaneEnabled=e),this._foreachMeta(t=>{this._collection.updateMaterial(t.objectHandle,{slicePlaneEnabled:e}),this._updateEdgeRendering(t,!1)})}_updatePBR(e){this._foreachMeta(t=>this._collection.updateMaterial(t.objectHandle,{usePBR:e})),this._hasLoadedPBRTextures=!0}_foreachMeta(e){this._nodeId2Meta.forEach(t=>{null!=t&&e(t)})}get _usePBR(){return this._shadeNormals&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){null!=this._edgeView&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?(t,i,s)=>s.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?0:e(t,i,s):e}_forAllFeatures(e,t,i){for(const s of this._nodeId2Meta.values())if(!(null==s||t&&s.node.serviceMbsInIndexSR&&1===t(s.node.serviceMbsInIndexSR)))switch(i){case 1:this._forAllFeaturesOfNode(s,e);break;case 0:this._forAllVisibleFeaturesOfNode(s,e);break;case 2:this._forAllQueryableFeaturesOfNode(s,e)}}_forAllFeaturesOfNode(e,t){e.featureIds.forEach((i,s)=>t(i,s,e))}_forAllVisibleFeaturesOfNode(e,t){const i=e.featureIds;this._collection.forEachVisibleComponent(e.objectHandle,s=>0===t(i[s],s,e))}_forAllQueryableFeaturesOfNode(e,t){const i=this._ignoreClientNodeOverriddenFeatures(t);if(null==this._renderClippingArea)return this._forAllFeaturesOfNode(e,i);const s=this._boundingRectNodeTest(e,this._renderClippingArea);if(0===s)return;if(3===s)return this._forAllFeaturesOfNode(e,i);const r=e.featureIds,o=e.objectHandle,n=Qe(this._renderClippingArea,this._collection.getObjectTransform(o));for(let a=0;a<r.length;a++)this._boundingRectFeatureTest(e,a,n)&&i(r[a],a,e)}_createAttributes(e,t){const i={};null!=t.featureIds&&(i[this._getObjectIdField()]=t.featureIds[e]);const s=t.attributeInfo?.attributeData;if(null!=s)for(const r of Object.keys(s))i[r]=Se(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e,t){const s=tt(e);if(0===s.length)return it;const r=bt(t),o=s[0]instanceof i?this._featureIdsFromGraphics(s):"number"==typeof s[0]?s:null;if(!o)return it;const n=this._ensureHighlights(),{set:a,handle:l}=n.acquireSet(r);return n.setFeatureIds(a,o),l}_featureIdsFromGraphics(e){const t=this.i3slayer.fieldsIndex,i=this._getObjectIdField();return e.map(e=>et(t,e.attributes,i))}_ensureHighlights(){return this._highlights??=new xe({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,1),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)}),this._highlights}resetHighlights(){this._highlights=a(this._highlights)}_visibleGeometryChanged(e,t){this._elevationProvider&&(null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=m(()=>{const{node:t}=e,i=t.visibilityObbInRenderSR??t.geometryObbInRenderSR??t.serviceObbInRenderSR;if(null!=i){const e=$();i.toAaBoundingBox(e),this.emit("visible-geometry-changed",new ge(e))}else this.emit("visible-geometry-changed");this._visibleGeometryChangedSchedulerHandle=null})),this._updateSnappingSources(e,t),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}get performanceInfo(){return new fe(this.usedMemory,this._nodeId2Meta.size,Math.round(this._gpuMemoryEstimate/1048576),Math.round(this._geoMemoryEstimate/1048576),Math.round(this._texMemoryEstimate/1048576),Math.round(this.unloadedMemory/1048576),this._idbCacheEnabled?Math.round(100*this._idbCache.getHitRate()):0)}checkInvariants(){}get test(){}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return null!=e?this._collection.getObjectOpacity(e.objectHandle):0}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}getNodeComponentHandle(e){return this._nodeId2Meta.get(e)?.objectHandle}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(e)}fadeNode(e,t,i){if(!this.nodeCrossfadingEnabled)return;const s=this._nodeId2Meta.get(e);null!=s&&this._crossfadeHelper.fadeNode(e,s,t,i)}setNodeOpacityByIndex(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._setNodeOpacity(i,t)}_setNodeOpacity(e,t){this._collection.updateObjectOpacity(e.objectHandle,t),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(null==this._edgeView||!e.cachedEdgeMaterials)return;kt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch(e=>this._logEdgeViewError(e,this.i3slayer.title))}get hasModifications(){return this._isIntegratedMesh&&null!=this._layerClippingArea||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){const t=e.length;if(!this.hasModifications||t<=0||!0!==this._i3sWasmLoaded)return;const i=this.uid,s=Nt(e);if(s){const t={context:i,buffer:s.buffer};be(t);const r=new Float64Array(s.buffer);e.forAll((e,t)=>{const i=r[t],s=ve(i);e.imModificationImpact=s,0!==s&&this._controller.invalidateGeometryVisibility(e.index)})}}notifyUpdate(){this.notifyChange("updating")}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!(!this._controller||!this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||null!=this._labeler&&this._labeler.updating||this._crossfadeHelper?.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||null!=this._elevationTask&&this._elevationTask.readyToRun||this._needFilterResolve||this._compressionTracker.compressing}trackSnappingSources(e){const t={events:e,fetchEdgeLocations:async(e,t,i)=>{const s=this._nodeId2Meta.get(e);if(null==s)throw new Error("invalid-node");const{origin:r,buffer:o}=await this._collection.extractEdgeInformation(s.objectHandle,t,i);return this._snappingLocationsApplyElevation(s,o,r),{type:"components",objectIds:s.featureIds,locations:o,origin:r}},remove:()=>s(this._snappingSourcesTrackers,t)};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach((t,i)=>{if(null==t)return;const s=this._controller.getRenderMbs(t.node);s&&e.add(i,s)}),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||0===this.elevationInfo.mode)return;const s=t.position0,r=t.position1,o=t.componentIndex,n=H(),a=H(),l=(e,t)=>{V(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,a),V(e,e,D(a,a,t)),A(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,n),l(n,t),s.setVec(d,n),r.getVec(d,n),l(n,t),r.setVec(d,n)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(null!=s)for(const r of this._snappingSourcesTrackers)1!==t&&2!==t||r.events.remove(i),0!==t&&2!==t||r.events.add(i,s)}_logEdgeViewError(e,t){h(e)||o.getLogger(this).warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}_indexedDbSizeCheck(e,t){return t.byteSize>xt?(o.getLogger(this).warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}get elevationProvider(){return this._elevationProvider}};return e([y()],T.prototype,"_hasLoadedPBRTextures",void 0),e([y()],T.prototype,"_asyncModuleLoading",void 0),e([y()],T.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([y()],T.prototype,"view",void 0),e([y()],T.prototype,"i3slayer",void 0),e([y()],T.prototype,"_controller",void 0),e([y()],T.prototype,"_labeler",void 0),e([y()],T.prototype,"updating",void 0),e([y()],T.prototype,"suspended",void 0),e([y()],T.prototype,"contentVisible",null),e([y({readOnly:!0})],T.prototype,"legendEnabled",null),e([y(dt)],T.prototype,"updatingProgress",void 0),e([y()],T.prototype,"updatingProgressValue",null),e([y()],T.prototype,"hasTexturesOrVertexColors",null),e([y()],T.prototype,"rendererTextureUsage",null),e([y()],T.prototype,"elevationOffset",null),e([y()],T.prototype,"elevationInfo",null),e([y({type:Boolean})],T.prototype,"slicePlaneEnabled",void 0),e([y()],T.prototype,"supportedTextureEncodings",null),e([y({type:[ne]})],T.prototype,"_modifications",void 0),e([y({readOnly:!0})],T.prototype,"clientGeometry",null),e([y()],T.prototype,"elevationRange",null),e([y()],T.prototype,"fullExtent",null),e([y()],T.prototype,"_elevationTask",void 0),e([y({readOnly:!0})],T.prototype,"_usePBR",null),T=e([b("esri.views.3d.layers.I3SMeshView3D")],T),T},St=$(),Ot=Q(),Rt=Q(),jt=new at,Ft=new t([0,0,0,0]),Vt=new te(0,0,0,0);function Dt(e){if(null==e)return!1;const t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function At(e){return"geometryData"in e}function Tt(e){return null!=e&&p(e.data)}function Ht(e,t){let i=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(null!=t)for(const s of t)null!=s&&p(s.data)&&(i+=s.data.byteLength);return i}function Nt(e){if(0===e.length)return;const t=10*e.length,i=new Float64Array(t);let s=0;return e.forAll(e=>{let t=e.serviceObbInIndexSR;null==t&&(t=jt,e.serviceMbsInIndexSR?(t.center=e.serviceMbsInIndexSR.center,t.halfSize=[e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius]):t.invalidate());const r=t.data;i[s++]=r[0],i[s++]=r[1],i[s++]=r[2],i[s++]=r[3],i[s++]=r[4],i[s++]=r[5],i[s++]=r[6],i[s++]=r[7],i[s++]=r[8],i[s++]=r[9]}),i}class Pt{constructor(e,t,i){this.attributeInfo=e,this.meta=t,this.promise=i,this.allowMemCache=!0}}function kt(e,t){e.forEach(e=>e.opacity=t)}class Lt{constructor(e,t){this.mode=e,this.offset=t}}const Ut=H(),Gt=$(),Bt="elevation-change",qt="",zt="@null",Wt="@ECEF",$t=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],Kt=new ot;function Qt(e,t,i){let s=e.minElevation,r=e.maxElevation;const o=i;if(o>0){t.getCorners($t);for(const e of $t){const t=T(e)-o;s=Math.min(s,t),r=Math.max(r,t)}}else{t.getCorners($t);for(const e of $t){const t=e[2];s=Math.min(s,t),r=Math.max(r,t)}}e.expandElevationRangeValues(s,r)}function Jt(e,t,i){const{center:s,radius:r}=t,o=i>0?T(s)-i:s[2];e.expandElevationRangeValues(o-r,o+r)}function Yt(e,t){const i=e.featureIds.slice();for(const s of t)if(s(i,e),0===i.length)break;return i.length===e.featureIds.length?e.featureIds:i}function Xt(e,t,i){const s=new Array,r=e.filteredIds;if(null==r||t?.size||i?.size){if(null!=r){let o=0;e.featureIds.forEach((e,n)=>{if(r[o]===e)++o;else if(!t?.has(e))return;i?.has(e)||s.push(n)})}}else e.featureIds.forEach((e,t)=>{r[s.length]===e&&s.push(t)});return s}function Zt(e,t,i){if(e&&t)for(const s of t){const t=(e.get(s)??0)+i;t>0?e.set(s,t):e.delete(s)}}function ei(e,t=0){const i=new Map;for(const s of e){Zt(i,0===t?s?.featureIds:1===t?s?.filteredIds:s?.weaklyRemovedIds,1)}return i}export{Et as I3SMeshView3D};
@@ -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 t from"../../../core/Collection.js";import{destroyHandle as i,makeHandle as r}from"../../../core/handleUtils.js";import{watch as s,syncAndInitial as l,initial as o}from"../../../core/reactiveUtils.js";import{property as h,subclass as a}from"../../../core/accessorSupport/decorators.js";import n from"./DynamicLayerView3D.js";import p from"./ImagerySubView3D.js";import{ImageHighlightHelper3D as d}from"./support/ImageHighlightHelper3D.js";import g from"../support/flow/FlowSubViewExtent3D.js";import{ImageryLayerViewMixin as u}from"../../layers/ImageryLayerViewMixin.js";import{isPixelHighlightTarget as m}from"../../layers/support/highlightUtils.js";let y=class extends(u(n)){constructor(){super(...arguments),this.type="imagery-3d"}get highlightOptions(){return null}get pixelData(){return null}initialize(){const e=()=>this._updatingHandles.addPromise(this.refreshDebounced());this._updatingHandles.add(()=>this.layer?.exportImageServiceParameters?.version,e),this._updatingHandles.add(()=>this.layer?.renderer,e),this._updatingHandles.add(()=>this.timeExtent,e),this._highlightHelper=new d({view:this.view,layer:this.layer,updatingHandles:this._updatingHandles}),this.addHandles([i(this._highlightHelper),s(()=>this.suspended,e=>this._highlightHelper.suspended=e,l)])}_initSubView(){this.addHandles([s(()=>this.layer.renderer,e=>this._recreateSubView(e),o)])}_recreateSubView(e){const t="flow"===e?.type,i="flow"===this.subView?.type,r=this.subView;r&&t===i||(this.subView=t?new g({layerView:this}):new p({layerView:this}),r?.destroy())}getFetchOptions(){return{timeExtent:this.timeExtent}}highlight(e,i){if("number"==typeof e||"string"==typeof e||m(e))return r();if(Array.isArray(e)||t.isCollection(e)){const t=e.at(0);if(null==t||"number"==typeof t||"string"==typeof t)return r()}return this._highlightHelper.highlight(e,i)}isUpdating(){return super.isUpdating()||this._highlightHelper.updating}};e([h()],y.prototype,"highlightOptions",null),e([h()],y.prototype,"pixelData",null),y=e([a("esri.views.3d.layers.ImageryLayerView3D")],y);const c=y;export{c as default};
5
+ import{__decorate as e}from"tslib";import t from"../../../core/Collection.js";import{destroyHandle as i,makeHandle as r}from"../../../core/handleUtils.js";import{watch as s,syncAndInitial as a,initial as o}from"../../../core/reactiveUtils.js";import{property as l,subclass as h}from"../../../core/accessorSupport/decorators.js";import n from"./DynamicLayerView3D.js";import p from"./ImagerySubView3D.js";import{ImageHighlightHelper3D as d}from"./support/ImageHighlightHelper3D.js";import g from"../support/flow/FlowSubViewExtent3D.js";import{ImageryLayerViewMixin as u}from"../../layers/ImageryLayerViewMixin.js";import{isPixelHighlightTarget as m}from"../../layers/support/highlightUtils.js";let y=class extends(u(n)){constructor(){super(...arguments),this.type="imagery-3d"}get pixelData(){return null}initialize(){const e=()=>this._updatingHandles.addPromise(this.refreshDebounced());this._updatingHandles.add(()=>this.layer?.exportImageServiceParameters?.version,e),this._updatingHandles.add(()=>this.layer?.renderer,e),this._updatingHandles.add(()=>this.timeExtent,e),this._highlightHelper=new d({view:this.view,layer:this.layer,updatingHandles:this._updatingHandles}),this.addHandles([i(this._highlightHelper),s(()=>this.suspended,e=>this._highlightHelper.suspended=e,a)])}_initSubView(){this.addHandles([s(()=>this.layer.renderer,e=>this._recreateSubView(e),o)])}_recreateSubView(e){const t="flow"===e?.type,i="flow"===this.subView?.type,r=this.subView;r&&t===i||(this.subView=t?new g({layerView:this}):new p({layerView:this}),r?.destroy())}getFetchOptions(){return{timeExtent:this.timeExtent}}highlight(e,i){if("number"==typeof e||"string"==typeof e||m(e))return r();if(Array.isArray(e)||t.isCollection(e)){const t=e.at(0);if(null==t||"number"==typeof t||"string"==typeof t)return r()}return this._highlightHelper.highlight(e,i)}isUpdating(){return super.isUpdating()||this._highlightHelper.updating}};e([l()],y.prototype,"pixelData",null),y=e([h("esri.views.3d.layers.ImageryLayerView3D")],y);const c=y;export{c 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{__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 C}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as M}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as O}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 Z}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as J,alphaModeConversion as X,faceCullingConversion as Y,wrapModeConversion as K,lyr3DTypeToByteSize as Q}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 Ce}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as Me}from"../../../webscene/support/AlphaCutoff.js";class Oe{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._obbCenterX=c[0],this._obbCenterY=c[1],this._obbCenterZ=c[2];const h=n?.radius??-1;this._obbRadius=h,this._obbRadiusSquared=h*h;const m=n?.halfSize;this._obbShortestHalfsize=m?Math.min(m[0],m[1],m[2]):0}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const{_obbCenterX:i,_obbCenterY:s,_obbCenterZ:r}=this,o=i-e[0],n=s-e[1],a=r-e[2],l=o*t[0]+n*t[1]+a*t[2];return o*o+n*n+a*a-l*l<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const t=this._obbRadius;if(t<0)return!0;const i=e.center,s=e.radius,r=t+s,o=this._obbCenterX-i[0];if(o>r)return!1;const n=this._obbCenterY-i[1];if(n>r)return!1;const a=this._obbCenterZ-i[2];if(a>r)return!1;const l=o*o+n*n+a*a;if(l>r*r)return!1;if(l<=(this._obbShortestHalfsize+s)**2)return!0;return Math.sqrt(l)+t<=s||(this.obb?.intersectSphere(e)??!0)}}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 Ce,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 Z({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=0,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)}const{meshData:t}=e;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=v(...t.desc.origin),s=this.view.basemapTerrain.spatialReference;let r,o;if("global"===this.view.viewingMode){const e=f();M(x,i,e,s),r=h(u(),e),o=m(u(),r)}else r=p,o=p;const n=w(),a=He(t.desc.obb);let l=0;const d={textureMemoryUsage:0},c=new Array,b=new Map,E=t.desc.prims.length,R=new Array,V=new ie;try{const e="global"===this.view.viewingMode,h=e?C(this.view.spatialReference).radius:0;for(let m=0;m<E;m++){const u=t.desc.prims[m];this._dbg(2,JSON.stringify(u));if(null==J[u.ptype]||null==t.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+u.ptype+"). Skipping primitive.");continue}const f=t.desc?.materials&&null!=u.materialId?t.desc.materials[u.materialId]:null,v=null!=f?f.lightingModel:"Unlit",{positionView:x,positionAttr:C,normalsView:M,normalsAttr:E,colorAttr:R,texCoord0Attr:H,indicesView:S}=this.getBufferViews(u,t.data.buffer,r);if(null==C||null==x||null==S)continue;const P=x.count,A=(e,t)=>!e||e.data.length/e.size===P||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!A(H,"numTexcoord")||!A(R,"numColors")||!A(E,"normals"))continue;const L=new le(null!=R,H?1:0,null!=M,this._shadeNormals||this.layer.replacesTerrain,this._applySSAO),k=de(L);for(let t=0;t<x.count;t++){x.getVec(t,n),g(n,n,i);const s=e?y(n)-h:n[2];V.expandElevationRangeValues(s,s)}const I=a?.clone()??Ve(C,i);if(r!==p)for(let e=0;e<x.count;e++)x.getVec(e,n),_(n,n,r),x.setVec(e,n);const F=k.createBuffer(P);if(ye("position",C,null,null,F,0),null!=H){const e=F.getField("uv0",U);_e(H,e,0)}null!=R&&ye("color",R,null,null,F,0),null!=E&&ye("normalCompressed",E,null,null,F,0);const D=new Uint32Array([0,S.typedBuffer.length]),B=new ce(ne(k),L.shadeNormals,L.applySSAO,L.textureCoordinateType),G=new he({data:F.buffer,count:F.byteLength/k.stride},{positions:x.typedBuffer,indices:S.typedBuffer},S.typedBuffer,D,B),z=this.view.renderSpatialReference,N=w(),W=[1,1,1];O(i,z,W,s)||this._dbg(3,"Unsupported coordinate system for IM overlay"),T(i,z,N,s);let $=()=>{},q=Promise.resolve(Pe);if(f){const e=e=>this._getTexture(e,t,b,d),i=e(f.baseColorTex),s="Pbr"===v,r=s?e(f.metalTex):null,o=s?e(f.emissiveTex):null,n=s?e(f.occlusionTex):null,a=s?e(f.normalTex):null,l=[i,r,o,n,a].map(e=>e?.loadPromise??null);q=Promise.all(l),$=e=>{e.baseColor=f.baseColorFactor,e.usePBR="Pbr"===v,e.hasParametersFromSource=!1,e.baseColorTexture=i,e.usePBR&&(e.mrrFactors=[f.metallicFactor,f.roughnessFactor,0],e.emissiveBaseColor=f.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=r,e.emissionTexture=o,e.occlusionTexture=n,e.normalTexture=a),e.alphaDiscardMode=X[f.alphaMode],e.objectOpacity=this.fullOpacity,d.textureMemoryUsage+=e.baseColorTexture?.texture?.usedMemory??0,e.usePBR&&(d.textureMemoryUsage+=(e.metallicRoughnessTexture?.texture?.usedMemory??0)+(e.emissionTexture?.texture?.usedMemory??0)+(e.occlusionTexture?.texture?.usedMemory??0)+(e.normalTexture?.texture?.usedMemory??0)),e.commonMaterialParameters.doubleSided=f.isDoubleSided,e.commonMaterialParameters.cullFace=Y[f.faceCulling??"NotSet"],e.commonMaterialParameters.isGround=this.layer.replacesTerrain,e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=0,e.textureAlphaCutoff=f.alphaCutoff??Me,e.alphaDiscardMode=X[f.alphaMode],e.isIntegratedMesh=!0,e.sphereDepthInterpolate=this.layer.hasGoogleUrl,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=pe(this.view.spatialReference)}}const Z=q.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(N[0],N[1],W[0],W[1]),new me(i,o),I,G,!1));return this._collection.updateMaterial(e,$),l+=this._collection.getObjectGPUMemoryUsage(e),e});c.push(Z)}if(R.push(...await Promise.all(c)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(I){throw b.forEach(e=>this._stage.removeTexture(e)),I}const H=R.map(e=>e()),S=new Array;b.forEach(e=>S.push(e));const{fullExtent:P}=this.layer;P?.hasZ&&P.zmax&&P.zmin&&(V.minElevation=Math.max(V.minElevation,P.zmin),V.maxElevation=Math.min(V.maxElevation,P.zmax));const A=H.reduceRight((e,t)=>e+t.intersectionGeometry.usedMemory,0),L=new Oe(e.handle,H,S,A,l,d.textureMemoryUsage,a,e.stableNodeId,e.nodeDepth,V);this._lyrHandleToObjects.set(e.handle,L),this._memCache.put(Se(L.handle),L);const{usedMemory:k}=L;return this._cacheMemory+=k,{memUsageBytes:k}}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=K[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/Q[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};
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 u}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m,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 _,h as v}from"../../../chunks/vec32.js";import{freeze as w,create as j,fromValues as x,clone as C}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as O,clone as M,fromValues as E}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as T,getReferenceEllipsoid as R}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as U}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as V}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as H}from"../../../geometry/projection/projectVectorToVector.js";import{create as S}from"../../../geometry/support/aaBoundingRect.js";import{getContinuousIndexArray as A}from"../../../geometry/support/Indices.js";import{BufferViewVec2f as L,BufferViewVec4f as P,BufferViewVec4u8 as k,BufferViewVec4u16 as I,BufferViewVec3f as F,BufferViewVec3u8 as D,BufferViewVec3u16 as B,BufferViewInt16 as G,BufferViewUint32 as N,BufferViewUint16 as z}from"../../../geometry/support/buffer/BufferView.js";import W from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as $}from"../../../support/elevationInfoUtils.js";import{LayerView3D as q}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as Z}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as J,removeLayerViewFromWasm as X,getLyr3DWasm as Y}from"./Lyr3DWasm.js";import{toWasmModification as K}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as Q}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as ee,alphaModeConversion as te,faceCullingConversion as ie,wrapModeConversion as se,lyr3DTypeToByteSize as re}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as oe}from"./support/Tiles3DIntersectionHandler.js";import{Frustum as ne}from"../state/Frustum.js";import{ElevationRange as ae}from"../support/ElevationRange.js";import{toBoundingRect as le}from"../support/extentUtils.js";import{compute as de,Obb as ce}from"../support/orientedBoundingBox.js";import{glLayout as he}from"../support/buffer/glUtil.js";import{GeometryParameters as ue,createVertexBufferLayout as me,ComponentGeometryParameters as pe,SourceGeometry as fe}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as be}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as ge}from"../webgl-engine/core/material/RenderTexture.js";import{Attribute as ye}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as _e}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as ve}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as we}from"../webgl-engine/materials/pbrUtils.js";import{writeAttribute as je,writeBufferVec2 as xe}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import Ce from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as Oe,isInEffectiveScaleRange as Me,validateScaleRange as Ee}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as Te}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as Re}from"../../../webscene/support/AlphaCutoff.js";class Ue{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=j();n?.getCenter(c),this._obbCenterX=c[0],this._obbCenterY=c[1],this._obbCenterZ=c[2];const h=n?.radius??-1;this._obbRadius=h,this._obbRadiusSquared=h*h;const u=n?.halfSize;this._obbShortestHalfsize=u?Math.min(u[0],u[1],u[2]):0}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const{_obbCenterX:i,_obbCenterY:s,_obbCenterZ:r}=this,o=i-e[0],n=s-e[1],a=r-e[2],l=o*t[0]+n*t[1]+a*t[2];return o*o+n*n+a*a-l*l<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const t=this._obbRadius;if(t<0)return!0;const i=e.center,s=e.radius,r=t+s,o=this._obbCenterX-i[0];if(o>r)return!1;const n=this._obbCenterY-i[1];if(n>r)return!1;const a=this._obbCenterZ-i[2];if(a>r)return!1;const l=o*o+n*n+a*a;if(l>r*r)return!1;if(l<=(this._obbShortestHalfsize+s)**2)return!0;return Math.sqrt(l)+t<=s||(this.obb?.intersectSphere(e)??!0)}}function Ve(e){return Math.round(e/1048.576)/1e3}let He=class extends(q(Ce)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new Te,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 ne(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 Oe("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=J(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new oe(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 Q({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.updateObjectOpacity(t,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"),X(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=0,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=K(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=S();this._layerClippingArea=le(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,{slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,$(e))}get _wasm(){return Y(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||Me(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||Ee(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,Ve(t),Ve(e),Ve(s),Ve(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 $(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new ae(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new ae;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)}const{meshData:t}=e;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=w(...t.desc.origin),s=this.view.basemapTerrain.spatialReference;let r,o;if("global"===this.view.viewingMode){const e=f();U(T,i,e,s),r=h(m(),e),o=u(m(),r)}else r=p,o=p;const n=j(),a=Pe(t.desc.obb);let l=0;const d={textureMemoryUsage:0},c=new Array,b=new Map,S=t.desc.prims.length,A=new Array,P=new ae;try{const e="global"===this.view.viewingMode,h=e?R(this.view.spatialReference).radius:0;for(let u=0;u<S;u++){const m=t.desc.prims[u];this._dbg(2,JSON.stringify(m));if(null==ee[m.ptype]||null==t.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+m.ptype+"). Skipping primitive.");continue}const f=t.desc?.materials&&null!=m.materialId?t.desc.materials[m.materialId]:null,w=null!=f?f.lightingModel:"Unlit",{positionView:T,positionAttr:R,normalsView:U,normalsAttr:S,colorAttr:A,texCoord0Attr:k,indicesView:I}=this.getBufferViews(m,t.data.buffer,r);if(null==R||null==T||null==I)continue;const F=T.count,D=(e,t)=>!e||e.data.length/e.size===F||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!D(k,"numTexcoord")||!D(A,"numColors")||!D(S,"normals"))continue;const B=new ue(null!=A,k?1:0,null!=U,this._shadeNormals||this.layer.replacesTerrain,this._applySSAO),G=me(B);for(let t=0;t<T.count;t++){T.getVec(t,n),g(n,n,i);const s=e?y(n)-h:n[2];P.expandElevationRangeValues(s,s)}const N=a?.clone()??Le(R,i);if(r!==p)for(let e=0;e<T.count;e++)T.getVec(e,n),_(n,n,r),T.setVec(e,n);const z=G.createBuffer(F);if(je("position",R,null,null,z,0),null!=k){const e=z.getField("uv0",L);xe(k,e,0)}null!=A&&je("color",A,null,null,z,0),null!=S&&je("normalCompressed",S,null,null,z,0);const W=new Uint32Array([0,I.typedBuffer.length]),$=new pe(he(G),B.shadeNormals,B.applySSAO,B.textureCoordinateType),q=new fe({data:z.buffer,count:z.byteLength/G.stride},{positions:T.typedBuffer,indices:I.typedBuffer},I.typedBuffer,W,$),Z=this.view.renderSpatialReference,J=j(),X=[1,1,1];V(i,Z,X,s)||this._dbg(3,"Unsupported coordinate system for IM overlay"),H(i,Z,J,s);let Y=Promise.resolve(Ie),K=O,Q=Re,se=null,re=null,oe=null,ne=null,ae=null,le=1,de=!1,ce=2,ge=!1,ye=x(0,0,0);const _e=C(we),ve="Pbr"===w;if(f){const e=e=>this._getTexture(e,t,b,d);se=e(f.baseColorTex),ae=ve?e(f.metalTex):null,re=ve?e(f.emissiveTex):null,ne=ve?e(f.occlusionTex):null,oe=ve?e(f.normalTex):null;const i=[se,ae,re,ne,oe].map(e=>e?.loadPromise??null);Y=Promise.all(i),K=M(f.baseColorFactor),Q=f.alphaCutoff??Re,ve&&(v(_e,f.metallicFactor,f.roughnessFactor,0),f.emissiveFactor&&(ye=f.emissiveFactor)),le=te[f.alphaMode],de=f.isDoubleSided,ce=ie[f.faceCulling??"NotSet"],ge=this.layer.replacesTerrain}const Ce=Y.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)}se||console.error("No colour texture 1");const e=this._collection.createObject({toMapSpace:E(J[0],J[1],X[0],X[1]),transform:new be(i,o),obb:N,geometry:q,elevationAlignable:!1},{isIntegratedMesh:!0,baseColor:K,textureAlphaCutoff:Q,mrrFactors:_e,baseColorTexture:se,metallicRoughnessTexture:ae,normalTexture:oe,occlusionTexture:ne,emissionTexture:re,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:le,doubleSided:de,cullFace:ce,isGround:ge,emissiveBaseColor:ye,usePBR:ve,slicePlaneEnabled:this.slicePlaneEnabled,objectOpacity:this.fullOpacity,polygonOffsetEnabled:!1,ellipsoidMode:1});return d.textureMemoryUsage+=se?.texture?.usedMemory??0,ve&&(d.textureMemoryUsage+=(ae?.texture?.usedMemory??0)+(re?.texture?.usedMemory??0)+(ne?.texture?.usedMemory??0)+(oe?.texture?.usedMemory??0)),l+=this._collection.getObjectGPUMemoryUsage(e),e});c.push(Ce)}if(A.push(...await Promise.all(c)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(N){throw b.forEach(e=>this._stage.removeTexture(e)),N}const k=A.map(e=>e()),I=new Array;b.forEach(e=>I.push(e));const{fullExtent:F}=this.layer;F?.hasZ&&F.zmax&&F.zmin&&(P.minElevation=Math.max(P.minElevation,F.zmin),P.maxElevation=Math.min(P.maxElevation,F.zmax));const D=k.reduceRight((e,t)=>e+t.intersectionGeometry.usedMemory,0),B=new Ue(e.handle,k,I,D,l,d.textureMemoryUsage,a,e.stableNodeId,e.nodeDepth,P);this._lyrHandleToObjects.set(e.handle,B),this._memCache.put(ke(B.handle),B);const{usedMemory:G}=B;return this._cacheMemory+=G,{memUsageBytes:G}}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=ke(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(ke(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(ke(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 ge(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=se[e.wrapMode??"None"];let c=r.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,r.data.byteOffset,r.data.byteCount);let u=null,m=null,p=null;switch(r.format){case"Raw":"R8"===r.pixelFormat?(u=h,c=6403,m=""):"Rgb8"===r.pixelFormat?(u=h,c=6407,m=""):"Rgba8"===r.pixelFormat&&(u=h,c=6408,m="");break;case"Dxt1":u=h,c=6407,m="image/vnd-ms.dds";break;case"Dxt5":u=h,c=6408,m="image/vnd-ms.dds";break;case"Basis":u=h,c=6407,m="image/ktx2";break;case"Png":m="image/png",p=document.createElement("img");break;case"Jpeg":m="image/jpeg",p=document.createElement("img");break;case"Etc2":m="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&&m){const e=new Blob([h],{type:m});p.src=URL.createObjectURL(e),u=p}if(u&&null!=m){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0,t=new _e(u,{mipmap:l,maxAnisotropy:a,encoding:m,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 u=0;u<e.atrbs.length;u++){const d=e.atrbs[u],{view:m}=d,p=void 0,f=m.byteOffset+m.byteCount,b=m.byteCount/re[m.type],g=A(b);try{switch(d.sem){case"Position":3!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+m+")"):(s=new F(t,m.byteOffset,p,f),r=new ye(s.typedBuffer,g,3));break;case"Normal":if(3!==m.ncomp||"F32"!==m.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+m+")");else{const e=new F(t,m.byteOffset,p,f),s=ve(e.typedBuffer,i);a=new G(s.buffer),l=new ye(a.typedBuffer,g,2)}break;case"TexCoord":2!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+m+")"):void 0===n&&(n=new ye(new L(t,m.byteOffset,p,f).typedBuffer,g,2));break;case"Color":4===m.ncomp?("F32"===m.type&&(c=new P(t,m.byteOffset,p,f)),"U8"===m.type&&(c=new k(t,m.byteOffset,p,f)),"U16"===m.type&&(c=new I(t,m.byteOffset,p,f))):3===m.ncomp&&("F32"===m.type&&(c=new F(t,m.byteOffset,p,f)),"U8"===m.type&&(c=new D(t,m.byteOffset,p,f)),"U16"===m.type&&(c=new B(t,m.byteOffset,p,f))),null==c?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+m+")"):o=new ye(c.typedBuffer,g,m.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 z(t,i.byteOffset,s,r);break;case"U32":d=new N(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 z(new Uint16Array(e).buffer):new N(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()],He.prototype,"fullOpacity",null),e([d({readOnly:!0})],He.prototype,"ready",null),e([d({type:[W]})],He.prototype,"_modifications",void 0),e([d()],He.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([d()],He.prototype,"layer",void 0),e([d({readOnly:!0})],He.prototype,"visibleAtCurrentScale",null),e([d({readOnly:!0})],He.prototype,"_collection",null),e([d()],He.prototype,"elevationOffset",null),e([d({readOnly:!0})],He.prototype,"visibleElevationRange",null),He=e([c("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],He);const Se=He,Ae=j();function Le(e,t){const i=de(e);return g(Ae,i.center,t),i.center=Ae,i}function Pe(e){return e?new ce(e.center,e.halfSize,b(...e.quaternion)):null}function ke(e){return`${e}`}const Ie=new Array;export{Se as default};