@arcgis/core 6.0.0-next.33 → 6.0.0-next.35

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 (317) hide show
  1. package/Basemap.d.ts +2 -2
  2. package/README.md +2 -2
  3. package/analysis/ShadowCastAnalysis.d.ts +11 -5
  4. package/applications/Urban/meshUtils.d.ts +1 -0
  5. package/applications/Urban/meshUtils.js +1 -1
  6. package/arcgisGlobal.d.ts +1 -0
  7. package/assets/esri/core/libs/libtess/libtess-f32.wasm +0 -0
  8. package/assets/esri/core/libs/libtess/libtess-f64.wasm +0 -0
  9. package/assets/esri/core/workers/RemoteClient.js +1 -1
  10. package/assets/esri/core/workers/chunks/01f55004d64309f8538b.js +1 -0
  11. package/assets/esri/core/workers/chunks/0202eb8c2b2865f99981.js +1 -0
  12. package/assets/esri/core/workers/chunks/{67e533748435253aaba6.js → 0284f608d25c654fcc11.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{f3dc0bc0e00635855a7a.js → 03daf6f235c6edef6268.js} +1 -1
  14. package/assets/esri/core/workers/chunks/04a1d08c3b5b1dc7628f.js +1 -0
  15. package/assets/esri/core/workers/chunks/{1eaf8bfdd3765a90ccc2.js → 0523f893870a1546d7d9.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{1ee4df0fd61440cb5f02.js → 06102715e9a8f218e07c.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{6029773458ab98600f67.js → 07e5482e1fc69be5de09.js} +1 -1
  18. package/assets/esri/core/workers/chunks/08140725277de5d2e41a.js +1 -0
  19. package/assets/esri/core/workers/chunks/{72d20d3957d612f86431.js → 0a508e25ec05363e1f04.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{2d9a1f23ec6ce90723ac.js → 0d99bfb75dcb9fa29080.js} +1 -1
  21. package/assets/esri/core/workers/chunks/10ad7b35b6800d40444e.js +1 -0
  22. package/assets/esri/core/workers/chunks/1132e28aaa5825b10b6e.js +1 -0
  23. package/assets/esri/core/workers/chunks/{84038dd85005fea413eb.js → 139e753d95cfc9470e74.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{dd30b02c5978c1c5f511.js → 155861fbd0e5fc2db80c.js} +1 -1
  25. package/assets/esri/core/workers/chunks/15950c2fb173b62ee0ec.js +1 -0
  26. package/assets/esri/core/workers/chunks/165ca7a97b611c8f26c4.js +1 -0
  27. package/assets/esri/core/workers/chunks/{418addce122dbb8897b4.js → 1a614bac5db42c6263f8.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{0cc7fba402a93e6d2455.js → 1ae0c9345626e70affd3.js} +2 -2
  29. package/assets/esri/core/workers/chunks/{58c3ae6030def2ed5f31.js → 1b17f5f720f6cf3f6d73.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{cd355baab983033c3ef0.js → 1ec772eaa63eb6937231.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{f9dc38761b314d33890f.js → 1f51567f47c2e2fc8a23.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{5c04835b0b52461183cd.js → 1fd82fcba2758741996a.js} +1 -1
  33. package/assets/esri/core/workers/chunks/21e1d423ee33f916547e.js +1 -0
  34. package/assets/esri/core/workers/chunks/2211ff0a1f1ae8100231.js +1 -0
  35. package/assets/esri/core/workers/chunks/{096b2bf1c0d69d27f20c.js → 247617c0dbae2386ab3b.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{97ec46605f16333144b7.js → 26ea39dfdf887f357fce.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{85de980c5b296ec69323.js → 279089a6a3f08022c678.js} +1 -1
  38. package/assets/esri/core/workers/chunks/29c610ce1c81ebb84a6b.js +1 -0
  39. package/assets/esri/core/workers/chunks/2b4dd42920d37b1ff0a9.js +2 -0
  40. package/assets/esri/core/workers/chunks/{8da2a10318f49d0dc73a.js → 31ef7b7074b3e3829763.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{b657363113f4a37e634b.js → 3223f9fbc76ba9ef8d13.js} +1 -1
  42. package/assets/esri/core/workers/chunks/322b22a5d54e404bebd5.js +1 -0
  43. package/assets/esri/core/workers/chunks/{122e75b21699a4e83b15.js → 338d800d4efcc91cead1.js} +1 -1
  44. package/assets/esri/core/workers/chunks/3537fe95b83a13b156cc.js +1 -0
  45. package/assets/esri/core/workers/chunks/{360c944c610efa2051fc.js → 379db67f78161ebd5468.js} +2 -2
  46. package/assets/esri/core/workers/chunks/{f09bc86cd52224febfcb.js → 3b380e64566a6cce59e2.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{be55771758e4bcef0976.js → 3e406043a374ee17475b.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{e3b212f8af448ec29eef.js → 3fe4c89acd325d36618d.js} +1 -1
  49. package/assets/esri/core/workers/chunks/449a2dee17b54946f245.js +1 -0
  50. package/assets/esri/core/workers/chunks/46c290108a90518ef695.js +1 -0
  51. package/assets/esri/core/workers/chunks/{a596779eaeec7310671d.js → 478a89317a12e9b4d146.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{fcc3902d6d9eda6f09f5.js → 48b8b57f559a53c6c513.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{55a9eaeb152a3abada67.js → 4e5405134d079bdf9b7a.js} +1 -1
  54. package/assets/esri/core/workers/chunks/4f3e0d583cfa9d1d6727.js +2 -0
  55. package/assets/esri/core/workers/chunks/{d070fcb73ce274ab80e4.js → 5504ec9bd9ee4d10af07.js} +1 -1
  56. package/assets/esri/core/workers/chunks/552c36b40e5a5ec117fb.js +1 -0
  57. package/assets/esri/core/workers/chunks/5622f3faa59434772857.js +1 -0
  58. package/assets/esri/core/workers/chunks/{bd46a04a9ee4ea9e6ef1.js → 5864bce1498a13ee5b7e.js} +2 -2
  59. package/assets/esri/core/workers/chunks/59a1b637d2c107504a04.js +1 -0
  60. package/assets/esri/core/workers/chunks/59a88dd53f8806bbec06.js +1 -0
  61. package/assets/esri/core/workers/chunks/{f4d91d470ca5fea0bd26.js → 5bd1414220e42cb8ebcf.js} +1 -1
  62. package/assets/esri/core/workers/chunks/5c2fe67527c9d7b4dba3.js +1 -0
  63. package/assets/esri/core/workers/chunks/5c3aa8386705c5e40358.js +1 -0
  64. package/assets/esri/core/workers/chunks/5d781c2c6204cffffd0d.js +1 -0
  65. package/assets/esri/core/workers/chunks/{176d75e76318bfc25a53.js → 60c8eedd06080edab3e3.js} +1 -1
  66. package/assets/esri/core/workers/chunks/61d36730564c5ac5edab.js +1 -0
  67. package/assets/esri/core/workers/chunks/6604272ef6fe85279032.js +1 -0
  68. package/assets/esri/core/workers/chunks/{29cc6b1705418b1be5d7.js → 687deb918eb48a963c8f.js} +1 -1
  69. package/assets/esri/core/workers/chunks/{0694c7bcfe71692e2ccf.js → 723df53cfa0189837d01.js} +1 -1
  70. package/assets/esri/core/workers/chunks/{90c1d10eae7ae71889b0.js → 7400b8c454b47ee4fb3c.js} +1 -1
  71. package/assets/esri/core/workers/chunks/796c6195b6bf59dcc9bd.js +1 -0
  72. package/assets/esri/core/workers/chunks/7b45ac83e279fe9516a5.js +1 -0
  73. package/assets/esri/core/workers/chunks/{2de077c7b971f2c215a6.js → 7ddbde8fdd1cf3c53f50.js} +1 -1
  74. package/assets/esri/core/workers/chunks/804606b194dc9e71d088.js +1 -0
  75. package/assets/esri/core/workers/chunks/8102f0bf5707c3be3310.js +1 -0
  76. package/assets/esri/core/workers/chunks/{1a8d8274df292d65f82e.js → 81bcc495e6eaf2cf7474.js} +1 -1
  77. package/assets/esri/core/workers/chunks/90360c0bd053d3e3fd77.js +1 -0
  78. package/assets/esri/core/workers/chunks/{d1d6154b4af1c9cc497b.js → 934e1f2153e6fad6ed23.js} +1 -1
  79. package/assets/esri/core/workers/chunks/{e096c1d9d53af74d3207.js → 990e96139b5a1dccb061.js} +1 -1
  80. package/assets/esri/core/workers/chunks/9c3de54513bf8619271c.js +1 -0
  81. package/assets/esri/core/workers/chunks/{f28b63c1179366dac8a2.js → 9e2c30b67bab5795306e.js} +1 -1
  82. package/assets/esri/core/workers/chunks/{9184c947cdefe06bf551.js → a18c3cbe505a19d29569.js} +1 -1
  83. package/assets/esri/core/workers/chunks/aa6ee2aa4ff6e6d41efb.js +1 -0
  84. package/assets/esri/core/workers/chunks/{3fd5c3cd8457ddc68798.js → aa779896fd9e5c341349.js} +1 -1
  85. package/assets/esri/core/workers/chunks/ac10c7d2c4829a150037.js +1 -0
  86. package/assets/esri/core/workers/chunks/{fe6dcb21570395e46ce8.js → afc8a9847f31bb66b13b.js} +1 -1
  87. package/assets/esri/core/workers/chunks/c5bf19da62a3d31009fe.js +2 -0
  88. package/assets/esri/core/workers/chunks/{2226c20c38e20713bcb5.js.LICENSE.txt → c5bf19da62a3d31009fe.js.LICENSE.txt} +1 -1
  89. package/assets/esri/core/workers/chunks/c7adb7b77721c75891f4.js +1 -0
  90. package/assets/esri/core/workers/chunks/cd55cad81accf51d2989.js +1 -0
  91. package/assets/esri/core/workers/chunks/{bead830a677690eeb6fb.js → ce8ef2eec290e1df6b2a.js} +1 -1
  92. package/assets/esri/core/workers/chunks/d3369ffed19f4c264dcd.js +1 -0
  93. package/assets/esri/core/workers/chunks/d3412518a7b518860fbb.js +1 -0
  94. package/assets/esri/core/workers/chunks/{3048e74e6246324ce6fc.js → d5916500514a41a4758f.js} +1 -1
  95. package/assets/esri/core/workers/chunks/{89dc49e784f7ba3b93ea.js → dac69c0047488fdf986d.js} +1 -1
  96. package/assets/esri/core/workers/chunks/db1f7b2562de495b3401.js +2 -0
  97. package/assets/esri/core/workers/chunks/dcc782e4bf9e8a8202f9.js +1 -0
  98. package/assets/esri/core/workers/chunks/dcdf837a452dc0cac582.js +1 -0
  99. package/assets/esri/core/workers/chunks/e0a37d3bcb9a944e53dd.js +1 -0
  100. package/assets/esri/core/workers/chunks/{19a4fa965b70fc6f78f6.js → e209cb1f3f14bf576ebe.js} +1 -1
  101. package/assets/esri/core/workers/chunks/e67ea2f1714e5abeae44.js +1 -0
  102. package/assets/esri/core/workers/chunks/e8fb2ba7b7a4f0916325.js +1 -0
  103. package/assets/esri/core/workers/chunks/{636e9c4ac1f9ae98f9d1.js → ea81f9d71b0842a4be26.js} +1 -1
  104. package/assets/esri/core/workers/chunks/{164c8eeefa8232b2b191.js → eaa0e906b46ae4c84d72.js} +2 -2
  105. package/assets/esri/core/workers/chunks/efcd38aad9aa667001b2.js +1 -0
  106. package/assets/esri/core/workers/chunks/{3aafdb905c697bc9b1ad.js → f372f4eb5527238c46f5.js} +1 -1
  107. package/assets/esri/core/workers/chunks/f497968055af459c5da4.js +1 -0
  108. package/assets/esri/core/workers/chunks/f7123ba1286f64e13e91.js +1 -0
  109. package/assets/esri/core/workers/chunks/fcb4707c2e95099b9f30.js +1 -0
  110. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  111. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  112. package/chunks/BlurEmission.glsl.js +9 -4
  113. package/chunks/GlobalIllumination.glsl.js +55 -46
  114. package/chunks/GlobalIlluminationBlur.glsl.js +13 -9
  115. package/chunks/RibbonLine.glsl.js +90 -88
  116. package/chunks/Terrain.glsl.js +9 -9
  117. package/chunks/libtess-f32.js +1 -1
  118. package/chunks/libtess-f64.js +1 -1
  119. package/chunks/lyr3DMain.js +1 -1
  120. package/chunks/lyr3DWorker.js +2 -2
  121. package/config.d.ts +3 -3
  122. package/config.js +1 -1
  123. package/core/has.js +1 -1
  124. package/core/mathUtils.js +1 -1
  125. package/core/workers.d.ts +1 -0
  126. package/form/FormTemplate.d.ts +1 -1
  127. package/geometry/libtess.js +1 -1
  128. package/geometry/projection/projectors.js +1 -1
  129. package/geometry/support/MeshLocalVertexSpace.d.ts +3 -3
  130. package/geometry/support/aaBoundingRect.js +1 -1
  131. package/geometry/support/meshUtils/convertMeshVertexSpace.js +1 -1
  132. package/geometry/support/meshUtils/vertexSpaceConversion.js +1 -1
  133. package/identity/Credential.d.ts +1 -1
  134. package/identity/IdentityManager.d.ts +1 -1
  135. package/identity/IdentityManagerBase.js +1 -1
  136. package/identity/OAuthInfo.d.ts +1 -1
  137. package/identity/ServerInfo.d.ts +1 -1
  138. package/kernel.d.ts +3 -3
  139. package/kernel.js +1 -1
  140. package/layers/CSVLayer.js +1 -1
  141. package/layers/GaussianSplatLayer.js +1 -1
  142. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  143. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  144. package/layers/VectorTileLayer.d.ts +2 -2
  145. package/layers/VideoLayer.js +1 -1
  146. package/layers/VoxelWasmPerSceneView.js +1 -1
  147. package/layers/WFSLayer.d.ts +8 -4
  148. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  149. package/layers/graphics/sources/CSVSource.js +1 -1
  150. package/layers/graphics/sources/GeoJSONSource.js +1 -1
  151. package/layers/graphics/sources/MemorySource.js +2 -2
  152. package/layers/graphics/sources/WFSSource.js +1 -1
  153. package/layers/graphics/sources/geojson/geojson.js +1 -1
  154. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  155. package/layers/graphics/sources/support/QueryTask.js +1 -1
  156. package/layers/graphics/sources/support/timeQueryUtils.js +2 -0
  157. package/layers/mixins/APIKeyMixin.d.ts +1 -1
  158. package/layers/mixins/ArcGISMapService.d.ts +17 -0
  159. package/layers/mixins/ArcGISMapService.js +1 -1
  160. package/layers/ogc/types.d.ts +1 -1
  161. package/layers/ogc/wfsUtils.d.ts +7 -2
  162. package/layers/ogc/wfsUtils.js +1 -1
  163. package/layers/ogc/xmlUtils.js +1 -1
  164. package/layers/support/TelemetryData.d.ts +28 -4
  165. package/layers/support/TimeInformation.js +1 -1
  166. package/layers/support/tiles3DUtils.js +1 -1
  167. package/layers/support/timeInfoUtils.js +2 -0
  168. package/layers/video/videoUtils.js +1 -1
  169. package/package.json +4 -4
  170. package/rest/query/executeAttributeBinsQuery.js +1 -1
  171. package/rest/query/executeForExtent.js +1 -1
  172. package/rest/query/executeForTopCount.js +1 -1
  173. package/rest/query/executeForTopExtents.js +1 -1
  174. package/rest/query/executeForTopIds.js +1 -1
  175. package/rest/query/executeTopFeaturesQuery.js +1 -1
  176. package/rest/query/operations/query.js +1 -1
  177. package/rest/query/operations/queryAttributeBins.js +1 -1
  178. package/rest/query/operations/queryTopFeatures.js +1 -1
  179. package/rest/route.d.ts +1 -1
  180. package/rest/support/AreasAndLengthsParameters.d.ts +1 -1
  181. package/rest/support/LengthsParameters.d.ts +1 -1
  182. package/rest/support/timeUtils.js +1 -1
  183. package/symbols/TextSymbol.d.ts +0 -1
  184. package/views/2d/engine/webgl/FeatureDisplayList.js +1 -1
  185. package/views/2d/engine/webgl/GlyphMosaic.js +1 -1
  186. package/views/2d/engine/webgl/GlyphWorker.js +1 -1
  187. package/views/2d/engine/webgl/TextureManager.js +1 -1
  188. package/views/2d/engine/webgl/materialKeyUtils.js +2 -0
  189. package/views/2d/engine/webgl/mesh/MeshData.js +1 -1
  190. package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
  191. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerMeshWriter.js +1 -1
  192. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedPolyMeshWriters.js +1 -1
  193. package/views/2d/engine/webgl/shaderGraph/techniques/fill/ComplexOutlineFillMeshWriter.js +1 -1
  194. package/views/2d/engine/webgl/shaderGraph/techniques/fill/GradientFillMeshWriter.js +1 -1
  195. package/views/2d/engine/webgl/shaderGraph/techniques/fill/PatternFillMeshWriter.js +1 -1
  196. package/views/2d/engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillMeshWriter.js +1 -1
  197. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  198. package/views/2d/engine/webgl/shaderGraph/techniques/line/GradientStrokeMeshWriter.js +1 -1
  199. package/views/2d/engine/webgl/shaderGraph/techniques/line/TexturedLineMeshWriter.js +1 -1
  200. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
  201. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
  202. package/views/2d/layers/VideoLayerView2D.js +1 -1
  203. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  204. package/views/3d/FocusAreasView.js +1 -1
  205. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
  206. package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementVisualization.js +1 -1
  207. package/views/3d/analysis/ElevationProfile/ElevationProfileLineSceneComputation.js +1 -1
  208. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  209. package/views/3d/analysis/ShadowCast/ShadowCastError.d.ts +40 -0
  210. package/views/3d/analysis/ShadowCast/ShadowCastError.js +2 -0
  211. package/views/3d/analysis/ShadowCast/sunlightUtils.js +2 -0
  212. package/views/3d/analysis/ShadowCastAnalysisView3D.d.ts +16 -1
  213. package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
  214. package/views/3d/camera/constraintUtils/surfaceCollision.js +1 -1
  215. package/views/3d/camera/intersectionUtils.js +1 -1
  216. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  217. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  218. package/views/3d/layers/Lyr3DWorker.js +1 -1
  219. package/views/3d/layers/graphics/ElevationAligners.js +1 -1
  220. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  221. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  222. package/views/3d/layers/graphics/Graphics3DMeshObject3DGraphicLayer.js +1 -1
  223. package/views/3d/layers/graphics/Graphics3DSymbol.js +1 -1
  224. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  225. package/views/3d/layers/graphics/Graphics3DWebStyleSymbol.js +1 -1
  226. package/views/3d/layers/graphics/MeshFastUpdateProcessor.js +1 -1
  227. package/views/3d/layers/graphics/polygonUtils.js +1 -1
  228. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  229. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  230. package/views/3d/layers/support/FeatureMemory.js +1 -1
  231. package/views/3d/layers/support/FeatureTile.js +1 -1
  232. package/views/3d/navigation/modes/GroundNavigationMode3D.js +1 -1
  233. package/views/3d/state/Constraints.js +1 -1
  234. package/views/3d/state/NearFarHeuristic.js +1 -1
  235. package/views/3d/state/ScreenSizePerspective.js +1 -1
  236. package/views/3d/state/ViewStateManager.js +1 -1
  237. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  238. package/views/3d/state/utils/groundNavigationUtils.js +1 -1
  239. package/views/3d/support/RenderCoordsHelper.js +1 -1
  240. package/views/3d/support/orientedBoundingBox.js +1 -1
  241. package/views/3d/support/sphereExtentUtils.js +1 -1
  242. package/views/3d/terrain/TerrainRenderer.js +1 -1
  243. package/views/3d/terrain/TerrainSurface.js +1 -1
  244. package/views/3d/terrain/TileRenderer.js +1 -1
  245. package/views/3d/terrain/tileUtils.js +1 -1
  246. package/views/3d/webgl-engine/lib/ManagedTexture.js +1 -1
  247. package/views/3d/webgl-engine/lib/NavigationDepthCache.js +1 -1
  248. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  249. package/views/3d/webgl-engine/lib/RibbonLineVertexInfo.js +1 -1
  250. package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
  251. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  252. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  253. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  254. package/views/3d/webgl.d.ts +1 -1
  255. package/views/SceneView.js +1 -1
  256. package/views/support/Scheduler.js +1 -1
  257. package/views/webgl/BufferObject.js +1 -1
  258. package/views/webgl/FramebufferObject.js +1 -1
  259. package/widgets/Directions.d.ts +1 -1
  260. package/widgets/ElevationProfile/ElevationProfileLineView.js +1 -1
  261. package/widgets/HistogramRangeSlider.d.ts +1 -1
  262. package/assets/esri/core/workers/chunks/0e445ec3523de9f2dfa2.js +0 -1
  263. package/assets/esri/core/workers/chunks/0f6c0d42100c21367e5c.js +0 -1
  264. package/assets/esri/core/workers/chunks/131185d26343a997495e.js +0 -1
  265. package/assets/esri/core/workers/chunks/176d0a06ebff5a29dedf.js +0 -1
  266. package/assets/esri/core/workers/chunks/18776a130d96879a68b1.js +0 -1
  267. package/assets/esri/core/workers/chunks/1a3f71c4d97c36050030.js +0 -1
  268. package/assets/esri/core/workers/chunks/20a698709c3c11ff2c16.js +0 -1
  269. package/assets/esri/core/workers/chunks/2226c20c38e20713bcb5.js +0 -2
  270. package/assets/esri/core/workers/chunks/277263466837e1673f56.js +0 -1
  271. package/assets/esri/core/workers/chunks/2981e904ab62f3ed80d0.js +0 -2
  272. package/assets/esri/core/workers/chunks/32cc59e126df8c96a0cf.js +0 -2
  273. package/assets/esri/core/workers/chunks/379ef56f6b32494832a6.js +0 -1
  274. package/assets/esri/core/workers/chunks/38d852676677e5697864.js +0 -1
  275. package/assets/esri/core/workers/chunks/46453ebfee17b5421d9d.js +0 -1
  276. package/assets/esri/core/workers/chunks/5a9b7eb26f936f03d02e.js +0 -1
  277. package/assets/esri/core/workers/chunks/5bb6c255bdc8aa9ba23e.js +0 -1
  278. package/assets/esri/core/workers/chunks/5f07f52bb8b7721f08d3.js +0 -1
  279. package/assets/esri/core/workers/chunks/654f5441227579d2b6b4.js +0 -1
  280. package/assets/esri/core/workers/chunks/6b5c073dddd89d06ed80.js +0 -1
  281. package/assets/esri/core/workers/chunks/6bb191b19ce43a27f205.js +0 -1
  282. package/assets/esri/core/workers/chunks/6ddc29a144640acb1192.js +0 -1
  283. package/assets/esri/core/workers/chunks/6ebe73f69ae822053b70.js +0 -1
  284. package/assets/esri/core/workers/chunks/6f6d1873753a9c6994aa.js +0 -1
  285. package/assets/esri/core/workers/chunks/7084dd6e10c6c1393e92.js +0 -1
  286. package/assets/esri/core/workers/chunks/7566321c6a2913f2852b.js +0 -1
  287. package/assets/esri/core/workers/chunks/7b5cd150a4d0139850be.js +0 -1
  288. package/assets/esri/core/workers/chunks/7cc9d7a88b64e25fce14.js +0 -1
  289. package/assets/esri/core/workers/chunks/7e211d8a8ad6c6a7cf3e.js +0 -1
  290. package/assets/esri/core/workers/chunks/844eedda8f749972f707.js +0 -2
  291. package/assets/esri/core/workers/chunks/849f446c718e892f39ce.js +0 -1
  292. package/assets/esri/core/workers/chunks/87177e0f82e8a6ae3189.js +0 -1
  293. package/assets/esri/core/workers/chunks/9976eaa81085c0d17e14.js +0 -1
  294. package/assets/esri/core/workers/chunks/a2196a49f89d57a0a1c7.js +0 -1
  295. package/assets/esri/core/workers/chunks/a504a5e06cb89a620799.js +0 -1
  296. package/assets/esri/core/workers/chunks/a65951f1d5702cfd996e.js +0 -1
  297. package/assets/esri/core/workers/chunks/aba259a70bee68d2edb7.js +0 -1
  298. package/assets/esri/core/workers/chunks/b8fd7c3b36981261378b.js +0 -1
  299. package/assets/esri/core/workers/chunks/b9cb92858a576eb6aa06.js +0 -1
  300. package/assets/esri/core/workers/chunks/c33a9635c294c8774977.js +0 -1
  301. package/assets/esri/core/workers/chunks/c570b90995c65bbb2e14.js +0 -1
  302. package/assets/esri/core/workers/chunks/c576bef77e34920af188.js +0 -1
  303. package/assets/esri/core/workers/chunks/cf1ec61eb2ad147bb931.js +0 -1
  304. package/assets/esri/core/workers/chunks/daae21cf77864f3293ef.js +0 -1
  305. package/assets/esri/core/workers/chunks/dc2f93453dfa40f623ab.js +0 -1
  306. package/assets/esri/core/workers/chunks/e81173724e8de8c1e65b.js +0 -1
  307. package/assets/esri/core/workers/chunks/e83f9abee611c5b80009.js +0 -1
  308. package/assets/esri/core/workers/chunks/f39c700f3db7db52b522.js +0 -1
  309. package/assets/esri/core/workers/chunks/f45064066e1ab041a0b2.js +0 -1
  310. package/assets/esri/core/workers/chunks/ffe49d9e7df081bef4a5.js +0 -1
  311. package/views/2d/engine/webgl/hashMosaic.js +0 -2
  312. /package/assets/esri/core/workers/chunks/{0cc7fba402a93e6d2455.js.LICENSE.txt → 1ae0c9345626e70affd3.js.LICENSE.txt} +0 -0
  313. /package/assets/esri/core/workers/chunks/{844eedda8f749972f707.js.LICENSE.txt → 2b4dd42920d37b1ff0a9.js.LICENSE.txt} +0 -0
  314. /package/assets/esri/core/workers/chunks/{32cc59e126df8c96a0cf.js.LICENSE.txt → 4f3e0d583cfa9d1d6727.js.LICENSE.txt} +0 -0
  315. /package/assets/esri/core/workers/chunks/{bd46a04a9ee4ea9e6ef1.js.LICENSE.txt → 5864bce1498a13ee5b7e.js.LICENSE.txt} +0 -0
  316. /package/assets/esri/core/workers/chunks/{2981e904ab62f3ed80d0.js.LICENSE.txt → db1f7b2562de495b3401.js.LICENSE.txt} +0 -0
  317. /package/assets/esri/core/workers/chunks/{164c8eeefa8232b2b191.js.LICENSE.txt → eaa0e906b46ae4c84d72.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{isSome as t,equals as n}from"../../../core/arrayUtils.js";import{createTask as r}from"../../../core/asyncUtils.js";import i from"../../../core/Error.js";import"../../../core/has.js";import a from"../../../core/Logger.js";import{abortMaybe as o,destroyMaybe as s}from"../../../core/maybe.js";import{after as c,throwIfAborted as l,isPromiseLike as u}from"../../../core/promiseUtils.js";import{watch as d,syncAndInitial as f}from"../../../core/reactiveUtils.js";import{createScreenPointArray as p,createRenderScreenPointArray as m}from"../../../core/screenUtils.js";import{convertTime as h,offsetDateUTC as g,createZonedDate as _}from"../../../core/timeUtils.js";import{property as v,subclass as y}from"../../../core/accessorSupport/decorators.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as x}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as S}from"../../../core/support/UpdatingHandles.js";import{projectAsync as C}from"../../../geometry/projectionUtils.js";import{containsExecute as w}from"../../../geometry/operators/containsOperator.js";import{equals as T}from"../../../geometry/support/boundedPlane.js";import{polygonToVolume as E}from"../focusAreaUtils.js";import D from"./AnalysisView3D.js";import{registerAnalysisView as O,hideOtherAnalysisViews as k}from"./ShadowCast/analysisViewRegister.js";import{ShadowCastTooltip as A}from"./ShadowCast/ShadowCastTooltip.js";import{ElevationContext as j}from"../layers/graphics/ElevationContext.js";import{longitudeToTimezone as M}from"../support/earthUtils.js";import{computeDirectionsOverTime as N}from"../support/sunUtils.js";import{maxColorRampSize as P}from"../webgl-engine/shaders/colorRampParameters.js";import{breadthFirstBinaryPartitioning as F}from"../../../widgets/support/traversalUtils.js";let I=class extends D{constructor(e){super(e),this.type=`shadow-cast-view-3d`,this.analysis=null,this._updatingHandles=new S,this._stopPreviewingTask=null,this._updatedRecently=!1,this._tooltip=null,this._previousVolume=null}initialize(){this.addHandles([O(this.view,this),d(()=>({dependencies:this._previewDependencies,sceneUpdating:this._sceneUpdating}),()=>{o(this._stopPreviewingTask),this._updatedRecently=!0,this._stopPreviewingTask=r(async e=>{await c(U,e),l(e),this._updatedRecently=!1})},{sync:!0,initial:!0,equals:(e,t)=>V(e.dependencies,t.dependencies)&&(e.sceneUpdating===t.sceneUpdating||!e.sceneUpdating)}),d(()=>({renderer:this._renderer,visible:this.visible}),({renderer:e,visible:t})=>{t&&k(this.view,this),e?.setParameters({shadowCast:{enabled:t}})},f),d(()=>({renderer:this._renderer,parameters:this._visualizationParameters,visible:this.visible}),({renderer:e,parameters:t,visible:n})=>{R(e,n,t)},f),d(()=>({renderer:this._renderer,lightDirections:this._lightDirections,lightDirectionsContext:this._lightDirectionsContext,visible:this.visible}),({renderer:e,lightDirections:t,lightDirectionsContext:n,visible:r})=>{R(e,r,{lightDirections:t,lightDirectionsContext:n})},f),d(()=>({renderer:this._renderer,previewing:this._previewing,visible:this.visible}),({renderer:e,previewing:t,visible:n})=>{R(e,n,{previewing:t})},{sync:!0,initial:!0,equals:()=>!1}),d(()=>({analysisVolume:this._analysisVolume,renderer:this._renderer,visible:this.visible}),({renderer:e,visible:t,analysisVolume:n})=>{R(e,t,{analysisVolume:n})},f)]),this.interactive=!0,this._tooltip=new A({getDuration:(e,t)=>this._getDurationAtScreen(e,t),getMode:()=>this.analysis.mode,getShowsSeparateZeroBucketInHourlyMode:()=>this._showsSeparateZeroBucketInHourlyMode,getTotalDuration:()=>this._totalDuration,getTotalDurationMode:()=>this.analysis.totalDurationOptions.mode,getVisualizeSunlight:()=>this.analysis.visualizeSunlight,isVisible:()=>this.interactive&&this.visible,view:this.view})}destroy(){this.visible&&R(this._renderer,!0,{enabled:!1}),this._tooltip=s(this._tooltip),this._stopPreviewingTask=o(this._stopPreviewingTask),this._updatingHandles=s(this._updatingHandles)}get interactive(){return super.interactive}set interactive(e){super.interactive=e}get updating(){return this._previewing||this._stopPreviewingTask!=null&&!this._stopPreviewingTask.finished||this._tooltip?.updating===!0||this._updatingHandles.updating}get visible(){return super.visible}set visible(e){super.visible=e}get _previewing(){let e=this._updatedRecently,t=this._sceneUpdating;return e||t}get _sceneUpdating(){let{view:e}=this;if(e?.allLayerViews==null)return!0;let{stationary:t,navigating:n,interacting:r,graphicsView:i}=e,a=!t||n||r,o=this._shadowLayerViews.some(e=>e.updating),s=!i?.suspended&&!!i?.updating;return a||o||s}get _effectiveUtcOffset(){return this.analysis.utcOffset??this._utcOffsetAuto}get _utcOffsetAuto(){let e=this._referencePosition;return e==null?0:M(e[0],!1)}get _dateUTCOffset(){let e=this.analysis.date;return e=g(e,-e.getTimezoneOffset(),`minutes`),e=g(e,-this._effectiveUtcOffset,`hours`),e}get _startDateTimeUTC(){return this._getDateTimeUTC(this.analysis.startTimeOfDay)}get _endDateTimeUTC(){return this._getDateTimeUTC(this.analysis.endTimeOfDay)}_getDateTimeUTC(e){let{date:t,timeZone:n}=this.analysis;if(n==null)return g(this._dateUTCOffset,e);let r=_({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()},h(e,`milliseconds`,`minutes`),n);if(r==null)throw RangeError(`Invalid shadow cast date or time zone`);return r}get _referencePosition(){return this.view?.environmentView?.referencePositionGeographic}get _totalDurationInterval(){return this._totalDuration>0?Math.floor(this._totalDuration/(W-1)):W}get _interval(){let e=this._totalDurationInterval;switch(this.analysis.mode){case`min-duration`:return this._totalDuration>0?e:0;case`total-duration`:return e;case`discrete`:return this.analysis.discreteOptions.interval||e}}get _intervalContext(){let{mode:e,minDurationOptions:t}=this.analysis;return e===`min-duration`&&t.contextEnabled?t.contextOptions.interval||this._totalDurationInterval:-1}get _totalDurationSampleCount(){return this._lightDirections.length}get _totalDuration(){return this._endDateTimeUTC.getTime()-this._startDateTimeUTC.getTime()}get _lightDirections(){return this._calculateLightDirections(this._interval)}get _lightDirectionsContext(){return this._calculateLightDirections(this._intervalContext)}_calculateLightDirections(e){let{view:t}=this;if(e<=0)return[];let n=t.viewingMode===`global`?G:this._referencePosition;if(n==null)return[];let r=N(this._startDateTimeUTC,this._endDateTimeUTC,e,n,t.state.viewingMode,W),i=r.length;K.length=0;let a=F(0,i,K),o=Array(i);for(let e=0;e<i;++e)o[e]=r[a[e]];return o}get _analysisVolume(){let{geometry:e}=this.analysis;if(e==null)return this._previousVolume=null,null;try{let t=E(e,this.view,q);return t==null?(this._previousVolume=null,null):u(t)?(this._updatingHandles.consumePromise(t),this._previousVolume):(this._previousVolume=t,t)}catch(t){return a.getLogger(this).error(new i(`shadowcastanalysisview3d:projection-failed`,`Failed to project analysis area geometry to view spatial reference`,{geometry:e,error:t})),null}}get _visualizationParameters(){if(!this.visible)return null;switch(this.analysis.mode){case`min-duration`:return this._minDurationVisualizationParameters;case`total-duration`:return this._durationVisualizationParameters;case`discrete`:return this._discreteVisualizationParameters}}get _minDurationVisualizationParameters(){let{color:e,minDuration:t}=this.analysis.minDurationOptions,n=this._totalDuration;return{rendersSunlight:this.analysis.visualizeSunlight,visualization:2,thresholdColor:e.toUnitRGBA(),threshold:n>0?t/this._totalDuration:0,...this._minDurationContextVisualizationParameters}}get _minDurationContextVisualizationParameters(){let{minDurationOptions:e,visualizeSunlight:t}=this.analysis;if(!e.contextEnabled||t)return{};let{color:n,colorStops:r}=e.contextOptions,i=1/this._lightDirectionsContext.length;return{visualization:3,gradientColorRamp:this._getEffectiveShadowCastColorRamp(n,r,i)}}get _durationVisualizationParameters(){let{color:e,colorStops:t,mode:n}=this.analysis.totalDurationOptions,r=this._totalDuration,i=r>0&&n===`hourly`?H/r:0,a=this._getEffectiveShadowCastColorRamp(e,t,1/r);return i===0?{...this._discreteVisualizationParameters,gradientColorRamp:a}:{rendersSunlight:this.analysis.visualizeSunlight,bandedGradientColorRamp:a,visualization:1,bandSize:i}}get _showsSeparateZeroBucketInHourlyMode(){let{colorStops:e}=this.analysis.totalDurationOptions;return e==null||e.length===0||e.reduce((e,t)=>Math.min(e,t.value),1/0)<=0}get _discreteVisualizationParameters(){let{color:e,colorStops:t}=this.analysis.discreteOptions,n=1/this._lightDirections.length;return{rendersSunlight:this.analysis.visualizeSunlight,gradientColorRamp:this._getEffectiveShadowCastColorRamp(e,t,n),visualization:0}}get _shadowLayerViews(){return this.view.allLayerViews.items.filter(B)}get _previewDependencies(){let{view:e}=this,n=e.slice.plane,r=this._shadowLayerViews,i=r.map(e=>e.layer).filter(t),a=r.map(e=>e.suspended),o=i.map(e=>e.visible),s=i.map(e=>e.opacity),c=!!e.graphicsView?.suspended,l=i.filter(e=>`definitionExpression`in e).map(e=>e.definitionExpression),u=r.filter(e=>`filter`in e).map(e=>e.filter);return{slicePlane:n,startDateUTC:this._startDateTimeUTC,endDateUTC:this._endDateTimeUTC,layerViewSuspended:a,graphicsViewSuspended:c,layerVisibilities:o,layerOpacities:s,filters:u,definitionExpressions:l}}get _renderer(){return this.view?.stage?.renderer}get testData(){}async getDurationAtScreen(e){return this._getDurationAtScreen(e)}async _getDurationAtScreen(e,t){if(!await this._isScreenPointInAnalysisArea(e,t))return-1;let{_renderer:n,_totalDurationSampleCount:r}=this;if(n==null||r===0)return 0;let i=this.view.state.camera.screenToRender(p(e.x,e.y),m()),a=n.readAccumulatedShadow(i);return(this.analysis.visualizeSunlight?1-a:a)*this._totalDuration}async _isScreenPointInAnalysisArea(e,t){let{geometry:n}=this.analysis;if(!n)return!0;let r=await this.view.hitTest(e);l(t);let i=r.results.find(e=>e.mapPoint)?.mapPoint??r?.ground?.mapPoint;if(!i)return!1;let a=await C(i,n.spatialReference,{signal:t});return l(t),a!=null&&w(n,a)}_getEffectiveShadowCastColorRamp(e,t,n){if(t!=null){t.length>P&&a.getLogger(this).warnOnce(`ShadowCastAnalysis supports at most 8 color stops`);let e=t.map(e=>[e.value*n,e.color.toUnitRGBA()]);return e.sort(([e],[t])=>e-t),e}return z(e)}};e([v({readOnly:!0,type:[`shadow-cast-view-3d`]})],I.prototype,`type`,void 0),e([v({constructOnly:!0,nonNullable:!0})],I.prototype,`analysis`,void 0),e([v({readOnly:!0})],I.prototype,`updating`,null),e([v()],I.prototype,`_stopPreviewingTask`,void 0),e([v()],I.prototype,`_updatedRecently`,void 0),e([v()],I.prototype,`_tooltip`,void 0),e([v()],I.prototype,`_sceneUpdating`,null),e([v()],I.prototype,`_effectiveUtcOffset`,null),e([v()],I.prototype,`_utcOffsetAuto`,null),e([v()],I.prototype,`_dateUTCOffset`,null),e([v()],I.prototype,`_startDateTimeUTC`,null),e([v()],I.prototype,`_endDateTimeUTC`,null),e([v()],I.prototype,`_referencePosition`,null),e([v()],I.prototype,`_interval`,null),e([v()],I.prototype,`_intervalContext`,null),e([v()],I.prototype,`_totalDurationSampleCount`,null),e([v()],I.prototype,`_totalDuration`,null),e([v()],I.prototype,`_lightDirections`,null),e([v()],I.prototype,`_lightDirectionsContext`,null),e([v()],I.prototype,`_analysisVolume`,null),e([v()],I.prototype,`_visualizationParameters`,null),e([v()],I.prototype,`_minDurationVisualizationParameters`,null),e([v()],I.prototype,`_minDurationContextVisualizationParameters`,null),e([v()],I.prototype,`_durationVisualizationParameters`,null),e([v()],I.prototype,`_showsSeparateZeroBucketInHourlyMode`,null),e([v()],I.prototype,`_discreteVisualizationParameters`,null),e([v()],I.prototype,`_shadowLayerViews`,null),e([v()],I.prototype,`_previewDependencies`,null),e([v()],I.prototype,`_renderer`,null),I=e([y(`esri.views.3d.analysis.ShadowCastAnalysisView3D`)],I);const L=I;function R(e,t,n){t&&n!=null&&e?.setParameters({shadowCast:n})}function z(e){let t=e.toUnitRGBA();return[[0,x(t[0],t[1],t[2],0)],[1,t]]}function B(e){if(e.suspended)return!1;switch(e.type){case`building-scene-3d`:case`csv-3d`:case`elevation-3d`:case`feature-3d`:case`gaussian-splat-3d`:case`geojson-3d`:case`integrated-mesh-3d`:case`integrated-mesh-3dtiles`:case`ogc-feature-3d`:case`route-3d`:case`scene-layer-3d`:case`scene-layer-graphics-3d`:case`stream-3d`:case`wms-3d`:case`catalog-footprint-3d`:return!0;case`base-dynamic-3d`:case`catalog-3d`:case`catalog-dynamic-group-3d`:case`dimension-3d`:case`imagery-3d`:case`imagery-tile-3d`:case`line-of-sight-3d`:case`map-image-3d`:case`point-cloud-3d`:case`tile-3d`:case`vector-tile-3d`:case`viewshed-3d`:case`voxel-3d`:case`wfs-3d`:case`wmts-3d`:case`media-3d`:return!1;case`group`:return!1;case`graphics-3d`:return e.layer.graphics.some(e=>{let{symbol:t}=e;return t==null||t.type!==`text`&&!(`symbolLayers`in t)||t.type!==`text`&&t.symbolLayers.some(e=>e.type!==`text`)});default:return!1}}function V(e,t){if(e===t||e==null&&t==null)return!0;if(e==null||t==null)return!1;let r=T(e.slicePlane,t.slicePlane),i=e.startDateUTC.valueOf()===t.startDateUTC.valueOf()&&e.endDateUTC.valueOf()===t.endDateUTC.valueOf(),a=n(e.layerViewSuspended,t.layerViewSuspended)&&e.graphicsViewSuspended===t.graphicsViewSuspended,o=n(e.layerVisibilities,t.layerVisibilities),s=n(e.layerOpacities,t.layerOpacities),c=n(e.filters,t.filters),l=n(e.definitionExpressions,t.definitionExpressions);return r&&i&&a&&o&&s&&c&&l}const H=h(1,`hours`,`milliseconds`),U=500,W=255,G=b(),K=[],q=new j;export{L as default};
2
+ import{__decorate as e}from"tslib";import{isSome as t,equals as n}from"../../../core/arrayUtils.js";import{createTask as r}from"../../../core/asyncUtils.js";import i from"../../../core/Error.js";import"../../../core/has.js";import a from"../../../core/Logger.js";import{abortMaybe as o,destroyMaybe as s}from"../../../core/maybe.js";import{after as c,throwIfAborted as l,isPromiseLike as u}from"../../../core/promiseUtils.js";import{watch as d,syncAndInitial as f}from"../../../core/reactiveUtils.js";import{createScreenPointArray as p,createRenderScreenPointArray as m}from"../../../core/screenUtils.js";import{convertTime as h}from"../../../core/timeUtils.js";import{property as g,subclass as _}from"../../../core/accessorSupport/decorators.js";import{create as v}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as y}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as b}from"../../../core/support/UpdatingHandles.js";import{projectAsync as x}from"../../../geometry/projectionUtils.js";import{containsExecute as S}from"../../../geometry/operators/containsOperator.js";import{equals as C}from"../../../geometry/support/boundedPlane.js";import{polygonToVolume as w}from"../focusAreaUtils.js";import T from"./AnalysisView3D.js";import{registerAnalysisView as E,hideOtherAnalysisViews as D}from"./ShadowCast/analysisViewRegister.js";import O from"./ShadowCast/ShadowCastError.js";import{ShadowCastTooltip as k}from"./ShadowCast/ShadowCastTooltip.js";import{getSunlightIntervals as A,getDateTimeUTC as j}from"./ShadowCast/sunlightUtils.js";import{ElevationContext as M}from"../layers/graphics/ElevationContext.js";import{longitudeToTimezone as N}from"../support/earthUtils.js";import{computeDirectionsOverTime as P}from"../support/sunUtils.js";import{maxColorRampSize as F}from"../webgl-engine/shaders/colorRampParameters.js";import{breadthFirstBinaryPartitioning as I}from"../../../widgets/support/traversalUtils.js";let L=class extends T{constructor(e){super(e),this.type=`shadow-cast-view-3d`,this.analysis=null,this._updatingHandles=new b,this._visibleOverride=null,this._stopPreviewingTask=null,this._updatedRecently=!1,this._tooltip=null,this._previousVolume=null}initialize(){this.addHandles([E(this.view,this),d(()=>({dependencies:this._previewDependencies,sceneUpdating:this._sceneUpdating}),()=>{o(this._stopPreviewingTask),this._updatedRecently=!0,this._stopPreviewingTask=r(async e=>{await c(W,e),l(e),this._updatedRecently=!1})},{sync:!0,initial:!0,equals:(e,t)=>H(e.dependencies,t.dependencies)&&(e.sceneUpdating===t.sceneUpdating||!e.sceneUpdating)}),d(()=>({renderer:this._renderer,visible:this.visible}),({renderer:e,visible:t},n)=>{t&&D(this.view,this),(t||n?.visible)&&e?.setParameters({shadowCast:{enabled:t}})},f),d(()=>({renderer:this._renderer,parameters:this._visualizationParameters,visible:this.visible}),({renderer:e,parameters:t,visible:n})=>{z(e,n,t)},f),d(()=>({renderer:this._renderer,lightDirections:this._lightDirections,lightDirectionsContext:this._lightDirectionsContext,visible:this.visible}),({renderer:e,lightDirections:t,lightDirectionsContext:n,visible:r})=>{z(e,r,{lightDirections:t,lightDirectionsContext:n})},f),d(()=>({renderer:this._renderer,previewing:this._previewing,visible:this.visible}),({renderer:e,previewing:t,visible:n})=>{z(e,n,{previewing:t})},{sync:!0,initial:!0,equals:()=>!1}),d(()=>({analysisVolume:this._analysisVolume,renderer:this._renderer,visible:this.visible}),({renderer:e,visible:t,analysisVolume:n})=>{z(e,t,{analysisVolume:n})},f)]),this.interactive=!0,this._tooltip=new k({getDuration:(e,t)=>this._getDurationAtScreen(e,t),getMode:()=>this.analysis.mode,getShowsSeparateZeroBucketInHourlyMode:()=>this._showsSeparateZeroBucketInHourlyMode,getTotalDuration:()=>this._totalDuration,getTotalDurationMode:()=>this.analysis.totalDurationOptions.mode,getVisualizeSunlight:()=>this.analysis.visualizeSunlight,isVisible:()=>this.interactive&&this.visible,view:this.view})}destroy(){this.visible&&z(this._renderer,!0,{enabled:!1}),this._tooltip=s(this._tooltip),this._stopPreviewingTask=o(this._stopPreviewingTask),this._updatingHandles=s(this._updatingHandles)}get interactive(){return super.interactive}set interactive(e){super.interactive=e}get updating(){return this._previewing||this._stopPreviewingTask!=null&&!this._stopPreviewingTask.finished||this._tooltip?.updating===!0||this._updatingHandles.updating}get visible(){let e=(this.parent?.visible&&!this.parent.suspended)??!0;return(this._visibleOverride??e)&&this.error==null}set visible(e){this._visibleOverride=e}get error(){let e=this._sunlightIntervals;switch(e.state){case`ready`:break;case`unavailable`:return new O(e.state,`The camera's geographic reference position is not available.`);default:return new O(e.state,`The selected date, time zone, or daylight calculation could not be resolved.`)}let{startTimeOfDay:t,endTimeOfDay:n}=this.analysis;if(!Number.isFinite(t)||!Number.isFinite(n)||t<0||n>h(1,`days`,`milliseconds`)||n<t)return new O(`invalid`,`The selected time range must be ordered and within the calendar day.`);let r=this._startDateTimeUTC.getTime(),i=this._endDateTimeUTC.getTime();if(!Number.isFinite(r)||!Number.isFinite(i)||i<r)return new O(`invalid`,`The selected time range could not be resolved to ordered UTC instants.`);let{intervals:a}=e;return a.length?a.some(e=>r>=e.start&&i<=e.end)?null:a.length>1?new O(`split-daylight`,`Daylight crosses midnight in the selected time zone and the selected time range includes nighttime.`):new O(`outside-daylight`,`The selected time range includes nighttime at the current camera location.`):new O(`no-daylight`,`No daylight is expected at the current camera location on the selected date.`)}get _sunlightIntervals(){let{date:e,timeZone:t}=this.analysis;return A({date:e,timeZone:t,utcOffset:t==null?this._effectiveUtcOffset:0,position:this._referencePosition})}get _previewing(){let e=this._updatedRecently,t=this._sceneUpdating;return e||t}get _sceneUpdating(){let{view:e}=this;if(e?.allLayerViews==null)return!0;let{stationary:t,navigating:n,interacting:r,graphicsView:i}=e,a=!t||n||r,o=this._shadowLayerViews.some(e=>e.updating),s=!i?.suspended&&!!i?.updating;return a||o||s}get _effectiveUtcOffset(){return this.analysis.utcOffset??this._utcOffsetAuto}get _utcOffsetAuto(){let e=this._referencePosition;return e==null?0:N(e[0],!1)}get _startDateTimeUTC(){return this._getDateTimeUTC(this.analysis.startTimeOfDay)}get _endDateTimeUTC(){return this._getDateTimeUTC(this.analysis.endTimeOfDay)}_getDateTimeUTC(e){let{date:t,timeZone:n}=this.analysis,r=j(t,e,n,n==null?this._effectiveUtcOffset:0);if(r==null)throw RangeError(`Invalid shadow cast date or time zone`);return r}get _referencePosition(){return this.view?.environmentView?.referencePositionGeographic}get _totalDurationInterval(){return this._totalDuration>0?Math.floor(this._totalDuration/(G-1)):G}get _interval(){let e=this._totalDurationInterval;switch(this.analysis.mode){case`min-duration`:return this._totalDuration>0?e:0;case`total-duration`:return e;case`discrete`:return this.analysis.discreteOptions.interval||e}}get _intervalContext(){let{mode:e,minDurationOptions:t}=this.analysis;return e===`min-duration`&&t.contextEnabled?t.contextOptions.interval||this._totalDurationInterval:-1}get _totalDurationSampleCount(){return this._lightDirections.length}get _totalDuration(){return this._endDateTimeUTC.getTime()-this._startDateTimeUTC.getTime()}get _lightDirections(){return this.error==null?this._calculateLightDirections(this._interval):[]}get _lightDirectionsContext(){return this.error==null?this._calculateLightDirections(this._intervalContext):[]}_calculateLightDirections(e){let{view:t}=this;if(e<=0)return[];let n=t.viewingMode===`global`?K:this._referencePosition;if(n==null)return[];let r=P(this._startDateTimeUTC,this._endDateTimeUTC,e,n,t.state.viewingMode,G),i=r.length;q.length=0;let a=I(0,i,q),o=Array(i);for(let e=0;e<i;++e)o[e]=r[a[e]];return o}get _analysisVolume(){let{geometry:e}=this.analysis;if(e==null)return this._previousVolume=null,null;try{let t=w(e,this.view,J);return t==null?(this._previousVolume=null,null):u(t)?(this._updatingHandles.consumePromise(t),this._previousVolume):(this._previousVolume=t,t)}catch(t){return a.getLogger(this).error(new i(`shadowcastanalysisview3d:projection-failed`,`Failed to project analysis area geometry to view spatial reference`,{geometry:e,error:t})),null}}get _visualizationParameters(){if(!this.visible)return null;switch(this.analysis.mode){case`min-duration`:return this._minDurationVisualizationParameters;case`total-duration`:return this._durationVisualizationParameters;case`discrete`:return this._discreteVisualizationParameters}}get _minDurationVisualizationParameters(){let{color:e,minDuration:t}=this.analysis.minDurationOptions,n=this._totalDuration;return{rendersSunlight:this.analysis.visualizeSunlight,visualization:2,thresholdColor:e.toUnitRGBA(),threshold:n>0?t/this._totalDuration:0,...this._minDurationContextVisualizationParameters}}get _minDurationContextVisualizationParameters(){let{minDurationOptions:e,visualizeSunlight:t}=this.analysis;if(!e.contextEnabled||t)return{};let{color:n,colorStops:r}=e.contextOptions,i=1/this._lightDirectionsContext.length;return{visualization:3,gradientColorRamp:this._getEffectiveShadowCastColorRamp(n,r,i)}}get _durationVisualizationParameters(){let{color:e,colorStops:t,mode:n}=this.analysis.totalDurationOptions,r=this._totalDuration,i=r>0&&n===`hourly`?U/r:0,a=this._getEffectiveShadowCastColorRamp(e,t,1/r);return i===0?{...this._discreteVisualizationParameters,gradientColorRamp:a}:{rendersSunlight:this.analysis.visualizeSunlight,bandedGradientColorRamp:a,visualization:1,bandSize:i}}get _showsSeparateZeroBucketInHourlyMode(){let{colorStops:e}=this.analysis.totalDurationOptions;return e==null||e.length===0||e.reduce((e,t)=>Math.min(e,t.value),1/0)<=0}get _discreteVisualizationParameters(){let{color:e,colorStops:t}=this.analysis.discreteOptions,n=1/this._lightDirections.length;return{rendersSunlight:this.analysis.visualizeSunlight,gradientColorRamp:this._getEffectiveShadowCastColorRamp(e,t,n),visualization:0}}get _shadowLayerViews(){return this.view.allLayerViews.items.filter(V)}get _previewDependencies(){if(this.error!=null)return null;let{view:e}=this,n=e.slice.plane,r=this._shadowLayerViews,i=r.map(e=>e.layer).filter(t),a=r.map(e=>e.suspended),o=i.map(e=>e.visible),s=i.map(e=>e.opacity),c=!!e.graphicsView?.suspended,l=i.filter(e=>`definitionExpression`in e).map(e=>e.definitionExpression),u=r.filter(e=>`filter`in e).map(e=>e.filter);return{slicePlane:n,startDateUTC:this._startDateTimeUTC,endDateUTC:this._endDateTimeUTC,layerViewSuspended:a,graphicsViewSuspended:c,layerVisibilities:o,layerOpacities:s,filters:u,definitionExpressions:l}}get _renderer(){return this.view?.stage?.renderer}get testData(){}async getDurationAtScreen(e){return this._getDurationAtScreen(e)}async _getDurationAtScreen(e,t){if(!await this._isScreenPointInAnalysisArea(e,t))return-1;let{_renderer:n,_totalDurationSampleCount:r}=this;if(n==null||r===0)return 0;let i=this.view.state.camera.screenToRender(p(e.x,e.y),m()),a=n.readAccumulatedShadow(i);return(this.analysis.visualizeSunlight?1-a:a)*this._totalDuration}async _isScreenPointInAnalysisArea(e,t){let{geometry:n}=this.analysis;if(!n)return!0;let r=await this.view.hitTest(e);l(t);let i=r.results.find(e=>e.mapPoint)?.mapPoint??r?.ground?.mapPoint;if(!i)return!1;let a=await x(i,n.spatialReference,{signal:t});return l(t),a!=null&&S(n,a)}_getEffectiveShadowCastColorRamp(e,t,n){if(t!=null){t.length>F&&a.getLogger(this).warnOnce(`ShadowCastAnalysis supports at most 8 color stops`);let e=t.map(e=>[e.value*n,e.color.toUnitRGBA()]);return e.sort(([e],[t])=>e-t),e}return B(e)}};e([g({readOnly:!0,type:[`shadow-cast-view-3d`]})],L.prototype,`type`,void 0),e([g({constructOnly:!0,nonNullable:!0})],L.prototype,`analysis`,void 0),e([g({readOnly:!0})],L.prototype,`updating`,null),e([g()],L.prototype,`visible`,null),e([g()],L.prototype,`error`,null),e([g()],L.prototype,`_visibleOverride`,void 0),e([g()],L.prototype,`_sunlightIntervals`,null),e([g()],L.prototype,`_stopPreviewingTask`,void 0),e([g()],L.prototype,`_updatedRecently`,void 0),e([g()],L.prototype,`_tooltip`,void 0),e([g()],L.prototype,`_sceneUpdating`,null),e([g()],L.prototype,`_effectiveUtcOffset`,null),e([g()],L.prototype,`_utcOffsetAuto`,null),e([g()],L.prototype,`_startDateTimeUTC`,null),e([g()],L.prototype,`_endDateTimeUTC`,null),e([g()],L.prototype,`_referencePosition`,null),e([g()],L.prototype,`_interval`,null),e([g()],L.prototype,`_intervalContext`,null),e([g()],L.prototype,`_totalDurationSampleCount`,null),e([g()],L.prototype,`_totalDuration`,null),e([g()],L.prototype,`_lightDirections`,null),e([g()],L.prototype,`_lightDirectionsContext`,null),e([g()],L.prototype,`_analysisVolume`,null),e([g()],L.prototype,`_visualizationParameters`,null),e([g()],L.prototype,`_minDurationVisualizationParameters`,null),e([g()],L.prototype,`_minDurationContextVisualizationParameters`,null),e([g()],L.prototype,`_durationVisualizationParameters`,null),e([g()],L.prototype,`_showsSeparateZeroBucketInHourlyMode`,null),e([g()],L.prototype,`_discreteVisualizationParameters`,null),e([g()],L.prototype,`_shadowLayerViews`,null),e([g()],L.prototype,`_previewDependencies`,null),e([g()],L.prototype,`_renderer`,null),L=e([_(`esri.views.3d.analysis.ShadowCastAnalysisView3D`)],L);const R=L;function z(e,t,n){t&&n!=null&&e?.setParameters({shadowCast:n})}function B(e){let t=e.toUnitRGBA();return[[0,y(t[0],t[1],t[2],0)],[1,t]]}function V(e){if(e.suspended)return!1;switch(e.type){case`building-scene-3d`:case`csv-3d`:case`elevation-3d`:case`feature-3d`:case`gaussian-splat-3d`:case`geojson-3d`:case`integrated-mesh-3d`:case`integrated-mesh-3dtiles`:case`ogc-feature-3d`:case`route-3d`:case`scene-layer-3d`:case`scene-layer-graphics-3d`:case`stream-3d`:case`wms-3d`:case`catalog-footprint-3d`:return!0;case`base-dynamic-3d`:case`catalog-3d`:case`catalog-dynamic-group-3d`:case`dimension-3d`:case`imagery-3d`:case`imagery-tile-3d`:case`line-of-sight-3d`:case`map-image-3d`:case`point-cloud-3d`:case`tile-3d`:case`vector-tile-3d`:case`viewshed-3d`:case`voxel-3d`:case`wfs-3d`:case`wmts-3d`:case`media-3d`:return!1;case`group`:return!1;case`graphics-3d`:return e.layer.graphics.some(e=>{let{symbol:t}=e;return t==null||t.type!==`text`&&!(`symbolLayers`in t)||t.type!==`text`&&t.symbolLayers.some(e=>e.type!==`text`)});default:return!1}}function H(e,t){if(e===t||e==null&&t==null)return!0;if(e==null||t==null)return!1;let r=C(e.slicePlane,t.slicePlane),i=e.startDateUTC.valueOf()===t.startDateUTC.valueOf()&&e.endDateUTC.valueOf()===t.endDateUTC.valueOf(),a=n(e.layerViewSuspended,t.layerViewSuspended)&&e.graphicsViewSuspended===t.graphicsViewSuspended,o=n(e.layerVisibilities,t.layerVisibilities),s=n(e.layerOpacities,t.layerOpacities),c=n(e.filters,t.filters),l=n(e.definitionExpressions,t.definitionExpressions);return r&&i&&a&&o&&s&&c&&l}const U=h(1,`hours`,`milliseconds`),W=500,G=255,K=v(),q=[],J=new M;export{R as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{length as e,subtract as t,add as n,scale as r}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{surfaceElevationBelowRenderLocation as a}from"../intersectionUtils.js";function o(i,o,l,u=0){if(!i.state.constraints.collision.enabled)return!1;let d=o||l,f=a(i,d.eye),p=i.renderCoordsHelper.getAltitude(d.eye),m=f+i.state.constraints.elevationMargin;if(p>=m)return o&&!l.equalsView(o)?(l.copyViewFrom(o),!0):!1;let h=e(d.eye);if(t(s,d.center,d.eye),l.eye=i.renderCoordsHelper.setAltitude(c,m,d.eye),u===1)l.center=n(s,l.eye,s);else if(u===2){let e=(h-p+m)/h;l.center=r(s,d.center,e)}return!0}const s=i(),c=i();export{o as applySurfaceCollisionConstraint};
2
+ import{length as e,subtract as t,add as n,scale as r}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{surfaceElevationBelowRenderLocation as a}from"../intersectionUtils.js";function o(i,o,l,u=0){let d=i.state.constraints.collision;if(!d.enabled)return!1;let f=o||l,p=a(i,f.eye),m=i.renderCoordsHelper.getAltitude(f.eye),h=p+d.elevationMargin;if(m>=h)return o&&!l.equalsView(o)?(l.copyViewFrom(o),!0):!1;let g=e(f.eye);if(t(s,f.center,f.eye),l.eye=i.renderCoordsHelper.setAltitude(c,h,f.eye),u===1)l.center=n(s,l.eye,s);else if(u===2){let e=(g-m+h)/g;l.center=r(s,f.center,e)}return!0}const s=i(),c=i();export{o as applySurfaceCollisionConstraint};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{copy as e,squaredDistance as t,scale as n,subtract as r,add as i,length as a,dot as o,distance as s}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as l}from"../../../geometry/ellipsoidUtils.js";import{containsPoint as u}from"../../../geometry/support/aaBoundingRect.js";import{scaleToDistanceAt as d}from"../support/cameraScaleUtils.js";import{Intersector as f}from"../webgl-engine/lib/Intersector.js";function p(e,t,n,r){return e.renderCoordsHelper.fromRenderCoords(t.eye,S,r)!=null&&u(n,S)}function m(e,t){return e.elevationProvider?e.elevationProvider.getElevation(t[0],t[1],t[2],e.renderCoordsHelper.spatialReference,`ground`)??0:0}function h(a,o,s,c,l){let u=a.state.camera.clone();if(o&&s&&c&&(u.eye=o,u.center=s,u.up=c),l){let e=d(a,u,l);i(C,u.eye,n(C,u.viewForward,e))}else v(a,u.ray,C)||e(C,u.center);let f=a.state.constraints,p=f.minimumPoiDistance;if(t(u.eye,C)<p){let t=f.collision.enabled;e(w,u.viewForward),n(w,w,p),t?u.eye=r(S,C,w):i(C,u.eye,w);let o=a.renderCoordsHelper,s=o.getAltitude(u.eye),c=f.elevationMargin;t&&s<c&&(r(w,C,u.eye),u.eye=o.setAltitude(S,c,u.eye),i(C,u.eye,w))}return u.center=C,u}function g(e,t,n){let{origin:r,direction:i}=t;if(a(r)<e)return!0;let c=-o(i,r)/a(i);return c<0||c>=s(n,r)}function _(e,n,r){if(!e.state.isGlobal||!e.stateManager.constraintsManager)return!1;let i=m(e,n),a=e.stateManager.constraintsManager.nearFarHeuristic.computeFarDistance(n,i,e.stage.renderer.sceneDepthRange.value.far),o=a*a;return t(n,r)>o}function v(e,t,n){let r=b[e.viewingMode];r||(r=new f(e.state.viewingMode),r.options.backfacesTerrain=!e.state.isGlobal,r.options.invisibleTerrain=!0,b[e.viewingMode]=r);let{isGlobal:i}=e.state,a=i?l(e.spatialReference).radius:0;return e.sceneIntersectionHelper.intersectRay(t,r,n)&&!_(e,t.origin,n)&&(!i||g(a,r.ray,n))?!0:!e.renderCoordsHelper.intersectManifold(t,0,n)||_(e,t.origin,n)||i&&!g(a,r.ray,n)?i?y(t,n,a):!1:!0}function y(e,t,r){let s=o(e.origin,e.origin)-r*r,c=s>0?Math.sqrt(s)/3:1;return n(t,e.direction,c/a(e.direction)),i(t,t,e.origin),!0}let b={};function x(){b={}}const S=c(),C=c(),w=c();export{h as cameraOnContentAlongViewDirection,x as cleanupIntersectionUtils,p as eyeWithinExtent,m as surfaceElevationBelowRenderLocation};
2
+ import{copy as e,squaredDistance as t,scale as n,subtract as r,add as i,length as a,dot as o,distance as s}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as l}from"../../../geometry/ellipsoidUtils.js";import{containsPoint as u}from"../../../geometry/support/aaBoundingRect.js";import{scaleToDistanceAt as d}from"../support/cameraScaleUtils.js";import{Intersector as f}from"../webgl-engine/lib/Intersector.js";function p(e,t,n,r){return e.renderCoordsHelper.fromRenderCoords(t.eye,S,r)!=null&&u(n,S)}function m(e,t){return e.elevationProvider?e.elevationProvider.getElevation(t[0],t[1],t[2],e.renderCoordsHelper.spatialReference,`ground`)??0:0}function h(a,o,s,c,l){let u=a.state.camera.clone();if(o&&s&&c&&(u.eye=o,u.center=s,u.up=c),l){let e=d(a,u,l);i(C,u.eye,n(C,u.viewForward,e))}else v(a,u.ray,C)||e(C,u.center);let f=a.state.constraints,p=f.minimumPoiDistance;if(t(u.eye,C)<p){let t=f.collision.enabled;e(w,u.viewForward),n(w,w,p),t?u.eye=r(S,C,w):i(C,u.eye,w);let o=a.renderCoordsHelper,s=o.getAltitude(u.eye),c=f.collision.elevationMargin;t&&s<c&&(r(w,C,u.eye),u.eye=o.setAltitude(S,c,u.eye),i(C,u.eye,w))}return u.center=C,u}function g(e,t,n){let{origin:r,direction:i}=t;if(a(r)<e)return!0;let c=-o(i,r)/a(i);return c<0||c>=s(n,r)}function _(e,n,r){if(!e.state.isGlobal||!e.stateManager.constraintsManager)return!1;let i=m(e,n),a=e.stateManager.constraintsManager.nearFarHeuristic.computeFarDistance(n,i,e.stage.renderer.sceneDepthRange.value.far),o=a*a;return t(n,r)>o}function v(e,t,n){let r=b[e.viewingMode];r||(r=new f(e.state.viewingMode),r.options.backfacesTerrain=!e.state.isGlobal,r.options.invisibleTerrain=!0,b[e.viewingMode]=r);let{isGlobal:i}=e.state,a=i?l(e.spatialReference).radius:0;return e.sceneIntersectionHelper.intersectRay(t,r,n)&&!_(e,t.origin,n)&&(!i||g(a,r.ray,n))?!0:!e.renderCoordsHelper.intersectManifold(t,0,n)||_(e,t.origin,n)||i&&!g(a,r.ray,n)?i?y(t,n,a):!1:!0}function y(e,t,r){let s=o(e.origin,e.origin)-r*r,c=s>0?Math.sqrt(s)/3:1;return n(t,e.direction,c/a(e.direction)),i(t,t,e.origin),!0}let b={};function x(){b={}}const S=c(),C=c(),w=c();export{h as cameraOnContentAlongViewDirection,x as cleanupIntersectionUtils,p as eyeWithinExtent,m as surfaceElevationBelowRenderLocation};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{abortMaybe as n,removeMaybe as r,destroyMaybe as i}from"../../../core/maybe.js";import{throwIfAborted as a}from"../../../core/promiseUtils.js";import{watch as o,whenOnce as s,initial as c}from"../../../core/reactiveUtils.js";import{Milliseconds as l}from"../../../core/time.js";import{isUint32Array as u}from"../../../core/typedArrayUtil.js";import{unitFromRESTJSON as d,convertUnit as f}from"../../../core/units.js";import{property as p,subclass as m}from"../../../core/accessorSupport/decorators.js";import{fromValues as h}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{getReferenceEllipsoid as g}from"../../../geometry/ellipsoidUtils.js";import _ from"../../../geometry/HeightModelInfo.js";import{create as v}from"../../../geometry/support/aaBoundingBox.js";import{isCompatible as y}from"../../../geometry/support/heightModelInfoUtils.js";import{isInEffectiveScaleRange as b}from"../../../geometry/support/scaleUtils.js";import{isPlateCarree as x,isWebMercator as S,equals as C,isGeographic as w}from"../../../geometry/support/spatialReferenceUtils.js";import T from"../../../geometry/support/WKIDUnitConversion.js";import{validateEntity3D as E,makeCacheKey as D,getHeightModelInfoFromVCS as O}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as k}from"../../../support/elevationInfoUtils.js";import{getMetersPerUnit as A}from"../../../symbols/support/unitConversionUtils.js";import{GaussianSplatLayerViewPerformanceInfo as j}from"./GaussianSplatLayerViewPerformanceInfo.js";import{LayerView3D as M}from"./LayerView3D.js";import{addLayerViewToWasm as N,getLyr3DWasm as P,removeLayerViewFromWasm as F}from"./Lyr3DWasm.js";import{LayerElevationProvider as I}from"./i3s/LayerElevationProvider.js";import{ElevationRange as L}from"../support/ElevationRange.js";import{projectToBoundingBox as R}from"../support/extentUtils.js";import{Obb as z}from"../support/orientedBoundingBox.js";import{splatPageSizeInU32 as B,gaussiansPerPage as V,packedGaussianSizeInU32 as H,splatAtlasTextureWidth as U}from"../support/gaussianSplatting/GaussianSplatAtlasPages.js";import{GaussianSplatDataStore as W}from"../support/gaussianSplatting/GaussianSplatDataStore.js";import{GaussianSplatFadeHelper as G}from"../support/gaussianSplatting/GaussianSplatFadeHelper.js";import{GaussianSplatIntersectionHandler as K}from"../support/gaussianSplatting/GaussianSplatIntersectionHandler.js";import{GaussianTile as q}from"../support/gaussianSplatting/GaussianTile.js";import{GaussianSplatDepthRenderer as J}from"../webgl-engine/lib/GaussianSplatDepthRenderer.js";import{GaussianSplatRenderer as Y}from"../webgl-engine/lib/GaussianSplatRenderer.js";import{GaussianSplatShadows as X}from"../webgl-engine/lib/GaussianSplatShadows.js";import Z from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as ee}from"../../support/layerViewUtils.js";import{TaskPriority as te}from"../../support/Scheduler.js";var Q;const ne=()=>t.getLogger(`esri.views.3d.layers.GaussianSplatLayerView3D`),re=(()=>{let e=new Int16Array(256);e[0]=-255;for(let t=1;t<e.length;t++)e[t]=Math.round(16*Math.log(t/255));return e})();let $=class extends M(Z){static{Q=this}static{this.createRenderableBatchSize=64}static{this.uploadBatchPageCount=16}constructor(e){super(e),this.type=`gaussian-splat-3d`,this.ignoresMemoryFactor=!1,this._tileHandles=new Map,this._pageBuffer=new Uint32Array(B*Q.uploadBatchPageCount),this._tmpTilesWithChangedVisibility=[],this._renderablesBeingCreated=new Set,this._currentLyr3dVisibilityChange=0,this._tileFadeInsAwaitingInitialSort=new Set,this._pendingTileFadeOuts=new Map,this._pendingFadeDuration=l(0),this._createRenderableAbortController=new AbortController,this.skipHeightModelInfoValidation=!0,this._initializationController=null,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this._usedTileMemory=0,this._cacheTileMemory=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);let t=e.view.resourceController;this._memCache=t.memoryController.newCache(`GaussianSplat-${this.uid}`,e=>this._deleteTile(e)),this._frameTask=t.scheduler.registerTask(te.GAUSSIAN_SPLAT_TEXTURE_ATLAS)}get _clippingBox(){if(!this.view?.clippingArea)return null;let e=v();return R(this.view.clippingArea,e,this.view.renderSpatialReference)?e:null}get clippingBox(){return this._renderer?.clippingBox??null}initialize(){let{view:e}=this;this.addHandles([o(()=>e.qualitySettings.fadeDuration,e=>{this.data&&(this.fadeHelper.onFadeDurationChanged(e),this.updateFadingTexture())})]),this.addResolvingPromise(this._initializeAsync(e))}async _initializeAsync(e){this._initializationController=new AbortController;let{signal:t}=this._initializationController;if(await s(()=>e?.defaultsFromMap.heightModelInfoReady,t),a(t),!this._canProjectWithoutEngine())throw ee(`layer`,this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);this._wasmLayerId=await N(this,t),a(t),this._renderer=new Y({view:e,layerView:this}),this.data=new W(this._renderer,(e,t)=>this._onSortComplete(e,t),()=>this._freeInvisibleTiles()),this._shadows=new X({view:e,layerView:this}),this.fadeHelper=new G(this),this._prepassDepthRenderer=new J({view:e,layerView:this});let n=new K(this);this._intersectionHandler=n,e.sceneIntersectionHelper.addIntersectionHandler(n),this._elevationProvider=new I({view:e,layerElevationSource:this,intersectionHandler:n}),e.elevationProvider.register(2,this._elevationProvider),this.addHandles([o(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),o(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChanged(e),c)]),this._suspendedHandle=o(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),c),this.addHandles([o(()=>this._clippingBox,e=>{this._renderer&&(this._renderer.clippingBox=e)},c),o(()=>this.maximumGaussianCount,e=>this._wasm?.setMaximumGaussianSplatCount(Math.min(e,this.data.textureAtlas.maximumSupportedVisibleGaussians)),c)]),this._initializationController=null}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get tileHandles(){return this._tileHandles}updateFadingTexture(){this.data.fadingTexture.updateTexture(this.data.textureAtlas.pageAllocator.pageCount)}get _wasm(){return P(this.view)}get usedMemory(){return this._usedTileMemory+(this.data?.usedMemory??0)}get cachedMemory(){return this._cacheTileMemory}get unloadedMemory(){return 0}get useEsriCrs(){return this._useEsriCrs}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return k(this.layer.elevationInfo)}get elevationRange(){let e=this.fullExtent;return e?.zmin&&e?.zmax?new L(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get fullExtent(){return this.layer.fullExtent}get visibleAtCurrentScale(){return b(this.layer.effectiveScaleRange,this.view.scale)}isUpdating(){let e=this._wasm;return this._wasmLayerId<0||e==null?!1:e.isUpdating(this._wasmLayerId)||this.data.updating||this.fadeHelper.updating}updatingFlagChanged(){this.notifyChange(`updating`)}async createRenderable(e){if(this.destroyed||this.destroying)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy`);let{entity3d:t}=e;if(!E(t))throw Error(`entity3D not valid`);let n=t.desc.geometry.prims[t.validPrimitiveIndices[0]].atrbs[0],r=t.assets[n.assetId];if(!r)throw Error(`entity3D not valid`);let i=r.count;if(i===0)return ne().warnOnce(`encountered tile with zero Gaussians`),()=>({memUsageBytes:0,numGaussians:0});let a=null;if(r.dataType===`U32`&&u(r.data))a=r.data;else throw Error(`unexpected GaussianSplat Entity3D asset.data format`);let o=this.extractHeader(a),s=2.048,c=o.tileOrigin.x*s,l=o.tileOrigin.y*s,d=o.tileOrigin.z*s,f=t.desc,p=f.obb.quaternion,m=new z(f.obb.center,f.obb.halfSize,h(...p)),_=this.view.state.isGlobal,v=_?g(this.view.spatialReference).radius:0,y={handle:e.handle,bufferView:a,totalGaussians:i,packedHeader:o.packedHeader,tileOrigin:{x:c,y:l,z:d},invPosScale:o.invPosScale,obb:m,origin:{x:m.centerX,y:m.centerY,z:m.centerZ},isGlobal:_,ellipsoidRadius:v};this._renderablesBeingCreated.add(e.handle);let b;try{b=await this._frameTask.scheduleGenerator(e=>this._createRenderableTask(y,e),this._createRenderableAbortController.signal)}catch(t){throw this._renderablesBeingCreated.delete(e.handle),t}return this._renderablesBeingCreated.delete(e.handle),()=>b}*_createRenderableTask(e,t){let{handle:n,bufferView:r,totalGaussians:i,packedHeader:a,tileOrigin:o,invPosScale:s,obb:c,origin:l,isGlobal:u,ellipsoidRadius:d}=e,f=o.x,p=o.y,m=o.z,h=l.x,g=l.y,_=l.z,v=new Float32Array(i*3),y=new Uint32Array(i),b=new Uint32Array(i),x=[],S=Math.ceil(i/V),C=1/0,w=-1/0,T=1/0,E=-1/0,D=0,O=-1,k=0,A=0;for(let e=0;e<i;e++){let n=e*H,i=r[n],a=r[n+1],o=r[n+2],c=r[n+3],l=a&16383,d=a>>>14&16383,x=a>>>28&15|(o&1023)<<4,S=c>>>24,j=re[S],M=(o>>>10&255)+j,N=(o>>>18&255)+j,P=(o>>>26&63|(c&3)<<6)+j,F=M>0?M:0,I=N>0?N:0,L=P>0?P:0,R=F|I<<8|L<<16,z=Math.max(F,I,L),B=l*s+f,V=d*s+p,U=x*s+m;if(v[D]=B-h,v[D+1]=V-g,v[D+2]=U-_,u){let e=B*B+V*V+U*U;T=Math.min(T,e),E=Math.max(E,e)}else C=Math.min(C,U),w=Math.max(w,U);y[e]=i,b[e]=R,z>O&&(O=z),S>k&&(k=S),D+=3,A++,A===Q.createRenderableBatchSize&&(A=0,t.madeProgress()&&(t=yield))}A>0&&t.madeProgress()&&(t=yield),u&&(C=Math.sqrt(T)-d,w=Math.sqrt(E)-d);let j=this._extractGaussianSplatMbsRadiusSquared(O),{fullExtent:M}=this.layer;M?.hasZ&&M.zmax&&M.zmin&&(C=Math.max(C,M.zmin),w=Math.min(w,M.zmax));let N=new L(C,w),P=this.data.textureAtlas,F=this.data.headerTexture;try{for(let e=0;e<S;e+=Q.uploadBatchPageCount){let n=Math.min(S,e+Q.uploadBatchPageCount);for(let t=e;t<n;t++){let e=P.allocatePage();if(e===null&&(this._freeInvisibleTiles(),e=P.allocatePage()),e===null)throw Error(`ran out of gaussian splat memory`);x.push(e)}for(let t=e;t<n;){let e=x[t],o=t+1;for(;o<n&&x[o]===x[o-1]+1;)o++;let s=o-t,c=i-t*V,l=Math.min(c,s*V),u=t*B,d=l*H;this._pageBuffer.set(r.subarray(u,u+d));let f=e*V,p=f%U,m=Math.floor(f/U);P.update(p,m,this._pageBuffer,s),F.update(e,a,s),t=o}t.madeProgress()&&(t=yield)}}catch(e){throw P.freePages(x),e}let I=new q(n,c,x,v,y,b,i,j,k/255,N);return this._tileHandles.set(n,I),this._cacheTileMemory+=I.usedMemory,this._memCache.put(`${I.handle}`,I),{memUsageBytes:I.usedMemory,numGaussians:i}}_extractGaussianSplatMbsRadiusSquared(e){return Math.exp(e/8-20)*9}freeRenderable(e){this._tileFadeInsAwaitingInitialSort.delete(e),this._pendingTileFadeOuts.delete(e);let t=this.data?.textureAtlas,n=!1,r=this._tileHandles.get(e);if(r){let i=!1;for(let t of this._pendingTileFadeOuts.values())t.incomingTileHandles.has(e)&&(t.visibilityChange=this._currentLyr3dVisibilityChange+1,i=!0);i&&(this._currentLyr3dVisibilityChange++,n=!0),r.lifecycleState===0?this._cacheTileMemory-=r.usedMemory:(n=!0,this.fadeHelper.onTileDiscarded(r),this._usedTileMemory-=r.usedMemory,this._intersectionHandler.removeTile(r)),t&&r.pageIds.forEach(e=>t.freePage(e)),this.freeObject(r),this._tileHandles.delete(e)}n&&this.updateGaussians()}freeObject(e){this._memCache.pop(`${e.handle}`)}notifyTileObbsChanged(e){this._elevationProvider&&this._elevationProvider.notifyObjectsChangedFunctional(e.length,t=>{for(let{obb:n}of e)if(!t(n))break})}setRenderableVisibility(e,t,n){let r=this.fadeHelper.updateFadeDuration(),i=new ie(this._currentLyr3dVisibilityChange+1),a=new Set,o=!1;for(let s=0;s<n;s++){let n=this._tileHandles.get(e[s]);if(!n)continue;let c=t[s]?this._prepareTileFadeIn(n,r):this._prepareTileFadeOut(n,i);t[s]&&i.incomingTileHandles.add(n.handle),c&&a.add(n.handle),o||=c}if(o){if(this._currentLyr3dVisibilityChange++,this._pendingFadeDuration=r,this._updatePendingTileHandoffs(a,i),i.incomingTileHandles.size===0)for(let e of this._tileFadeInsAwaitingInitialSort)i.incomingTileHandles.add(e);this.updateGaussians()}}_updatePendingTileHandoffs(e,t){for(let n of new Set(this._pendingTileFadeOuts.values())){if(n===t)continue;let r=!1;for(let i of e)n.incomingTileHandles.has(i)&&(r=!0,t.incomingTileHandles.size>0&&n.incomingTileHandles.delete(i));if(r){n.visibilityChange=t.visibilityChange;for(let e of t.incomingTileHandles)n.incomingTileHandles.add(e)}}}_prepareTileFadeIn(e,t){let n=this._pendingTileFadeOuts.delete(e.handle);return e.lifecycleState===2?(this.fadeHelper.fadeTile(e,0,t),!1):this._tileFadeInsAwaitingInitialSort.has(e.handle)?n:(e.lifecycleState===0&&this._popTileFromCache(e),e.lifecycleState=1,this._tileFadeInsAwaitingInitialSort.add(e.handle),!0)}_prepareTileFadeOut(e,t){let n=this._tileFadeInsAwaitingInitialSort.delete(e.handle);return n&&e.lifecycleState===1&&(this.moveTileToCache(e),e.lifecycleState=0),e.lifecycleState===2?this._pendingTileFadeOuts.has(e.handle)?n:(this._pendingTileFadeOuts.set(e.handle,t),!0):n}_onSortComplete(e,t){let n=this._tmpTilesWithChangedVisibility;n.length=0,this._triggerFadeIns(e,n);let r=this._triggerFadeOuts(t,n);n.length>0&&this.notifyTileObbsChanged(n),r&&this.updateGaussians()}_triggerFadeIns(e,t){for(let n of e)this._tileHandles.get(n.handle)===n&&this._tileFadeInsAwaitingInitialSort.delete(n.handle)&&(n.lifecycleState=2,t.push(n),this.fadeHelper.fadeTile(n,0,this._pendingFadeDuration))}_triggerFadeOuts(e,t){let n=!1;for(let t of this._pendingTileFadeOuts.values())if(e>=t.visibilityChange){n=!0;break}if(!n)return!1;let r=this._pendingFadeDuration,i=this._pendingFadeDuration;for(let e of this._tileHandles.values()){let{fadeDirection:t,fadeDuration:n,fadeProgress:a}=e;if(t!==0||n==null||a==null)continue;let o=n*(1-a);r=l(Math.max(r,o)),i=l(Math.max(i,n))}let a=!1;for(let[n,o]of this._pendingTileFadeOuts){if(e<o.visibilityChange)continue;this._pendingTileFadeOuts.delete(n);let s=this._tileHandles.get(n);if(s){let e=s.lifecycleState===2,n=s.opacityModifier===1?r:i;this.fadeHelper.fadeTile(s,1,n),e&&s.lifecycleState===0&&(t.push(s),a=!0)}}return a}_popTileFromCache(e){this._usedTileMemory+=e.usedMemory,this._cacheTileMemory-=e.usedMemory,this._intersectionHandler.addTile(e),this._memCache.pop(D(e.handle))}moveTileToCache(e){this._usedTileMemory-=e.usedMemory,this._cacheTileMemory+=e.usedMemory,this._intersectionHandler.removeTile(e),this._memCache.put(D(e.handle),e)}destroy(){this._initializationController=n(this._initializationController),this._createRenderableAbortController.abort(),F(this),this._suspendedHandle&&=r(this._suspendedHandle),this._intersectionHandler&&=(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),null),this._elevationProvider&&this.view.elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(this._tileHandles.size,e=>{for(let{obb:t}of this._tileHandles.values())if(!e(t))break}),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._frameTask.remove(),this._shadows=i(this._shadows),this._prepassDepthRenderer=i(this._prepassDepthRenderer),this._renderer=i(this._renderer),this._memCache.destroy(),this.data=i(this.data)}_canProjectWithoutEngine(){if(this.view.state.viewingMode===1||x(this.view.renderSpatialReference)||S(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&C(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(this.layer.esriCrsSpatialReference.vcsWkid===115700)return!1;let e=O(this.layer.esriCrsSpatialReference);if(!e){let t=this.layer.esriCrsSpatialReference,n=w(t),r=`meters`;!n&&t.wkid&&t.wkid!==-1&&(r=d(T.units[T[t.wkid]])),r&&(e=new _({heightModel:`gravity-related-height`,heightUnit:r}))}let t=this.view.heightModelInfo;return this._useEsriCrs=y(e,t,!1)===0,this._useEsriCrs&&(e&&(this._metersPerVCSUnit=f(1,e.heightUnit,`meters`)),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}_elevationInfoChanged(e){if(!e?.offset)this._wasm?.setLayerOffset(this,0);else if(!this._useEsriCrs)this._wasm?.setLayerOffset(this,k(e));else{let t=A(e?.unit)/this._metersPerVCSUnit,n=e?.offset??0;this._wasm?.setLayerOffset(this,n*t)}}_slicePlaneEnabledChanged(e){this._renderer&&(this._renderer.slicePlaneEnabled=e),this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e)}updateGaussians(){let e=[];for(let t of this._tileHandles.values())t.lifecycleState!==0&&e.push(t);this.data.updateGaussianVisibility(e,this._currentLyr3dVisibilityChange),this.notifyChange(`updating`)}get maximumGaussianCount(){return this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians*this.view.quality}set maximumGaussianCount(e){this._set(`maximumGaussianCount`,e)}_freeInvisibleTiles(){for(let e of this._tileHandles.values())e.lifecycleState===0&&!this._renderablesBeingCreated.has(e.handle)&&this._deleteTile(e)}extractHeader(e){let t=e.length-4,n=this.reinterpretU32AsFloat(e[t]),r=this.reinterpretU32AsFloat(e[t+1]),i=this.reinterpretU32AsFloat(e[t+2]),a=1/(1<<(e[t+3]&255));return{packedHeader:e.subarray(t,t+4),tileOrigin:{x:n,y:r,z:i},invPosScale:a}}_deleteTile(e){this._renderablesBeingCreated.has(e.handle)||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;this._tileHandles.forEach(n=>{n.lifecycleState===0?t++:e++});let n=this.data?.textureAtlasMemory??0,r=this.data?.headerTextureMemory??0,i=this.data?.orderTextureMemory??0,a=this.data?.fadingTextureMemory??0,o=this.data?.sortBufferMemory??0;return new j(this.usedMemory,e,this._usedTileMemory,t,this._cacheTileMemory,n,r,i,a,o)}get test(){}};e([p()],$.prototype,`layer`,void 0),e([p({readOnly:!0})],$.prototype,`_clippingBox`,null),e([p()],$.prototype,`elevationOffset`,null),e([p({readOnly:!0})],$.prototype,`visibleAtCurrentScale`,null),e([p()],$.prototype,`fullExtentInLocalViewSpatialReference`,void 0),e([p()],$.prototype,`maximumGaussianCount`,null),$=Q=e([m(`esri.views.3d.layers.GaussianSplatLayerView3D`)],$);class ie{constructor(e){this.visibilityChange=e,this.incomingTileHandles=new Set}}const ae=$;export{ae as default};
2
+ import{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{abortMaybe as n,removeMaybe as r,destroyMaybe as i}from"../../../core/maybe.js";import{throwIfAborted as a}from"../../../core/promiseUtils.js";import{watch as o,whenOnce as s,initial as c}from"../../../core/reactiveUtils.js";import{Milliseconds as l}from"../../../core/time.js";import{isUint32Array as u}from"../../../core/typedArrayUtil.js";import{unitFromRESTJSON as d,convertUnit as f}from"../../../core/units.js";import{property as p,subclass as m}from"../../../core/accessorSupport/decorators.js";import{fromValues as h}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{getReferenceEllipsoid as g}from"../../../geometry/ellipsoidUtils.js";import _ from"../../../geometry/HeightModelInfo.js";import{create as v}from"../../../geometry/support/aaBoundingBox.js";import{isCompatible as y}from"../../../geometry/support/heightModelInfoUtils.js";import{isInEffectiveScaleRange as b}from"../../../geometry/support/scaleUtils.js";import{isPlateCarree as x,isWebMercator as S,equals as C,isGeographic as w}from"../../../geometry/support/spatialReferenceUtils.js";import T from"../../../geometry/support/WKIDUnitConversion.js";import{validateEntity3D as E,makeCacheKey as D,getHeightModelInfoFromVCS as O}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as k}from"../../../support/elevationInfoUtils.js";import{getMetersPerUnit as A}from"../../../symbols/support/unitConversionUtils.js";import{GaussianSplatLayerViewPerformanceInfo as j}from"./GaussianSplatLayerViewPerformanceInfo.js";import{LayerView3D as M}from"./LayerView3D.js";import{addLayerViewToWasm as N,getLyr3DWasm as P,removeLayerViewFromWasm as F}from"./Lyr3DWasm.js";import{LayerElevationProvider as I}from"./i3s/LayerElevationProvider.js";import{ElevationRange as L}from"../support/ElevationRange.js";import{projectToBoundingBox as R}from"../support/extentUtils.js";import{Obb as z}from"../support/orientedBoundingBox.js";import{splatPageSizeInU32 as B,gaussiansPerPage as V,packedGaussianSizeInU32 as H,splatAtlasTextureWidth as U}from"../support/gaussianSplatting/GaussianSplatAtlasPages.js";import{GaussianSplatDataStore as W}from"../support/gaussianSplatting/GaussianSplatDataStore.js";import{GaussianSplatFadeHelper as G}from"../support/gaussianSplatting/GaussianSplatFadeHelper.js";import{GaussianSplatIntersectionHandler as K}from"../support/gaussianSplatting/GaussianSplatIntersectionHandler.js";import{GaussianTile as q}from"../support/gaussianSplatting/GaussianTile.js";import{GaussianSplatDepthRenderer as J}from"../webgl-engine/lib/GaussianSplatDepthRenderer.js";import{GaussianSplatRenderer as Y}from"../webgl-engine/lib/GaussianSplatRenderer.js";import{GaussianSplatShadows as X}from"../webgl-engine/lib/GaussianSplatShadows.js";import Z from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as ee}from"../../support/layerViewUtils.js";import{TaskPriority as te}from"../../support/Scheduler.js";var Q;const ne=()=>t.getLogger(`esri.views.3d.layers.GaussianSplatLayerView3D`),re=(()=>{let e=new Int16Array(256);e[0]=-255;for(let t=1;t<e.length;t++)e[t]=Math.round(16*Math.log(t/255));return e})();let $=class extends M(Z){static{Q=this}static{this.createRenderableBatchSize=64}static{this.uploadBatchPageCount=16}constructor(e){super(e),this.type=`gaussian-splat-3d`,this.ignoresMemoryFactor=!1,this._tileHandles=new Map,this._pageBuffer=new Uint32Array(B*Q.uploadBatchPageCount),this._tmpTilesWithChangedVisibility=[],this._renderablesBeingCreated=new Set,this._currentLyr3dVisibilityChange=0,this._tileFadeInsAwaitingInitialSort=new Set,this._pendingTileFadeOuts=new Map,this._pendingFadeDuration=l(0),this._createRenderableAbortController=new AbortController,this.skipHeightModelInfoValidation=!0,this._initializationController=null,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this._usedTileMemory=0,this._cacheTileMemory=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);let t=e.view.resourceController;this._memCache=t.memoryController.newCache(`GaussianSplat-${this.uid}`,e=>this._deleteTile(e)),this._frameTask=t.scheduler.registerTask(te.GAUSSIAN_SPLAT_TEXTURE_ATLAS)}get _clippingBox(){if(!this.view?.clippingArea)return null;let e=v();return R(this.view.clippingArea,e,this.view.renderSpatialReference)?e:null}get clippingBox(){return this._renderer?.clippingBox??null}initialize(){let{view:e}=this;this.addHandles([o(()=>e.qualitySettings.fadeDuration,e=>{this.data&&(this.fadeHelper.onFadeDurationChanged(e),this.updateFadingTexture())})]),this.addResolvingPromise(this._initializeAsync(e))}async _initializeAsync(e){this._initializationController=new AbortController;let{signal:t}=this._initializationController;if(await s(()=>e?.defaultsFromMap.heightModelInfoReady,t),a(t),!this._canProjectWithoutEngine())throw ee(`layer`,this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);this._wasmLayerId=await N(this,t),a(t),this._renderer=new Y({view:e,layerView:this}),this.data=new W(this._renderer,(e,t)=>this._onSortComplete(e,t),()=>this._freeInvisibleTiles()),this._shadows=new X({view:e,layerView:this}),this.fadeHelper=new G(this),this._prepassDepthRenderer=new J({view:e,layerView:this});let n=new K(this);this._intersectionHandler=n,e.sceneIntersectionHelper.addIntersectionHandler(n),this._elevationProvider=new I({view:e,layerElevationSource:this,intersectionHandler:n}),e.elevationProvider.register(2,this._elevationProvider),this.addHandles([o(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),o(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChanged(e),c)]),this._suspendedHandle=o(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),c),this.addHandles([o(()=>this._clippingBox,e=>{this._renderer&&(this._renderer.clippingBox=e)},c),o(()=>this.maximumGaussianCount,e=>this._wasm?.setMaximumGaussianSplatCount(Math.min(e,this.data.textureAtlas.maximumSupportedVisibleGaussians)),c)]),this._initializationController=null}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get tileHandles(){return this._tileHandles}updateFadingTexture(){this.data.fadingTexture.updateTexture(this.data.textureAtlas.pageAllocator.pageCount)}get _wasm(){return P(this.view)}get usedMemory(){return this._usedTileMemory+(this.data?.usedMemory??0)}get cachedMemory(){return this._cacheTileMemory}get unloadedMemory(){return 0}get useEsriCrs(){return this._useEsriCrs}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return k(this.layer.elevationInfo)}get elevationRange(){let e=this.fullExtent;return e?.zmin&&e?.zmax?new L(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get fullExtent(){return this.layer.fullExtent}get visibleAtCurrentScale(){return b(this.layer.effectiveScaleRange,this.view.scale)}isUpdating(){let e=this._wasm;return this._wasmLayerId<0||e==null?!1:e.isUpdating(this._wasmLayerId)||this.data.updating||this.fadeHelper.updating}updatingFlagChanged(){this.notifyChange(`updating`)}async createRenderable(e){if(this.destroyed||this.destroying)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy`);let{entity3d:t}=e;if(!E(t))throw Error(`entity3D not valid`);let n=t.desc.geometry.prims[t.validPrimitiveIndices[0]];if(n.atrbs.length<1||n.atrbs[0].sem!==`GSplatPacked`)throw Error(`entity3D not valid`);let r=n.atrbs[0],i=t.assets[r.assetId];if(!i)throw Error(`entity3D not valid`);let a=i.count;if(a===0)return ne().warnOnce(`encountered tile with zero Gaussians`),()=>({memUsageBytes:0,numGaussians:0});let o=null;if(i.dataType===`U32`&&u(i.data))o=i.data;else throw Error(`unexpected GaussianSplat Entity3D asset.data format`);let s=this.extractHeader(o),c=2.048,l=s.tileOrigin.x*c,d=s.tileOrigin.y*c,f=s.tileOrigin.z*c,p=t.desc,m=p.obb.quaternion,_=new z(p.obb.center,p.obb.halfSize,h(...m)),v=this.view.state.isGlobal,y=v?g(this.view.spatialReference).radius:0,b={handle:e.handle,bufferView:o,totalGaussians:a,packedHeader:s.packedHeader,tileOrigin:{x:l,y:d,z:f},invPosScale:s.invPosScale,obb:_,origin:{x:_.centerX,y:_.centerY,z:_.centerZ},isGlobal:v,ellipsoidRadius:y};this._renderablesBeingCreated.add(e.handle);let x;try{x=await this._frameTask.scheduleGenerator(e=>this._createRenderableTask(b,e),this._createRenderableAbortController.signal)}catch(t){throw this._renderablesBeingCreated.delete(e.handle),t}return this._renderablesBeingCreated.delete(e.handle),()=>x}*_createRenderableTask(e,t){let{handle:n,bufferView:r,totalGaussians:i,packedHeader:a,tileOrigin:o,invPosScale:s,obb:c,origin:l,isGlobal:u,ellipsoidRadius:d}=e,f=o.x,p=o.y,m=o.z,h=l.x,g=l.y,_=l.z,v=new Float32Array(i*3),y=new Uint32Array(i),b=new Uint32Array(i),x=[],S=Math.ceil(i/V),C=1/0,w=-1/0,T=1/0,E=-1/0,D=0,O=-1,k=0,A=0;for(let e=0;e<i;e++){let n=e*H,i=r[n],a=r[n+1],o=r[n+2],c=r[n+3],l=a&16383,d=a>>>14&16383,x=a>>>28&15|(o&1023)<<4,S=c>>>24,j=re[S],M=(o>>>10&255)+j,N=(o>>>18&255)+j,P=(o>>>26&63|(c&3)<<6)+j,F=M>0?M:0,I=N>0?N:0,L=P>0?P:0,R=F|I<<8|L<<16,z=Math.max(F,I,L),B=l*s+f,V=d*s+p,U=x*s+m;if(v[D]=B-h,v[D+1]=V-g,v[D+2]=U-_,u){let e=B*B+V*V+U*U;T=Math.min(T,e),E=Math.max(E,e)}else C=Math.min(C,U),w=Math.max(w,U);y[e]=i,b[e]=R,z>O&&(O=z),S>k&&(k=S),D+=3,A++,A===Q.createRenderableBatchSize&&(A=0,t.madeProgress()&&(t=yield))}A>0&&t.madeProgress()&&(t=yield),u&&(C=Math.sqrt(T)-d,w=Math.sqrt(E)-d);let j=this._extractGaussianSplatMbsRadiusSquared(O),{fullExtent:M}=this.layer;M?.hasZ&&M.zmax&&M.zmin&&(C=Math.max(C,M.zmin),w=Math.min(w,M.zmax));let N=new L(C,w),P=this.data.textureAtlas,F=this.data.headerTexture;try{for(let e=0;e<S;e+=Q.uploadBatchPageCount){let n=Math.min(S,e+Q.uploadBatchPageCount);for(let t=e;t<n;t++){let e=P.allocatePage();if(e===null&&(this._freeInvisibleTiles(),e=P.allocatePage()),e===null)throw Error(`ran out of gaussian splat memory`);x.push(e)}for(let t=e;t<n;){let e=x[t],o=t+1;for(;o<n&&x[o]===x[o-1]+1;)o++;let s=o-t,c=i-t*V,l=Math.min(c,s*V),u=t*B,d=l*H;this._pageBuffer.set(r.subarray(u,u+d));let f=e*V,p=f%U,m=Math.floor(f/U);P.update(p,m,this._pageBuffer,s),F.update(e,a,s),t=o}t.madeProgress()&&(t=yield)}}catch(e){throw P.freePages(x),e}let I=new q(n,c,x,v,y,b,i,j,k/255,N);return this._tileHandles.set(n,I),this._cacheTileMemory+=I.usedMemory,this._memCache.put(`${I.handle}`,I),{memUsageBytes:I.usedMemory,numGaussians:i}}_extractGaussianSplatMbsRadiusSquared(e){return Math.exp(e/8-20)*9}freeRenderable(e){this._tileFadeInsAwaitingInitialSort.delete(e),this._pendingTileFadeOuts.delete(e);let t=this.data?.textureAtlas,n=!1,r=this._tileHandles.get(e);if(r){let i=!1;for(let t of this._pendingTileFadeOuts.values())t.incomingTileHandles.has(e)&&(t.visibilityChange=this._currentLyr3dVisibilityChange+1,i=!0);i&&(this._currentLyr3dVisibilityChange++,n=!0),r.lifecycleState===0?this._cacheTileMemory-=r.usedMemory:(n=!0,this.fadeHelper.onTileDiscarded(r),this._usedTileMemory-=r.usedMemory,this._intersectionHandler.removeTile(r)),t&&r.pageIds.forEach(e=>t.freePage(e)),this.freeObject(r),this._tileHandles.delete(e)}n&&this.updateGaussians()}freeObject(e){this._memCache.pop(`${e.handle}`)}notifyTileObbsChanged(e){this._elevationProvider&&this._elevationProvider.notifyObjectsChangedFunctional(e.length,t=>{for(let{obb:n}of e)if(!t(n))break})}setRenderableVisibility(e,t,n){let r=this.fadeHelper.updateFadeDuration(),i=new ie(this._currentLyr3dVisibilityChange+1),a=new Set,o=!1;for(let s=0;s<n;s++){let n=this._tileHandles.get(e[s]);if(!n)continue;let c=t[s]?this._prepareTileFadeIn(n,r):this._prepareTileFadeOut(n,i);t[s]&&i.incomingTileHandles.add(n.handle),c&&a.add(n.handle),o||=c}if(o){if(this._currentLyr3dVisibilityChange++,this._pendingFadeDuration=r,this._updatePendingTileHandoffs(a,i),i.incomingTileHandles.size===0)for(let e of this._tileFadeInsAwaitingInitialSort)i.incomingTileHandles.add(e);this.updateGaussians()}}_updatePendingTileHandoffs(e,t){for(let n of new Set(this._pendingTileFadeOuts.values())){if(n===t)continue;let r=!1;for(let i of e)n.incomingTileHandles.has(i)&&(r=!0,t.incomingTileHandles.size>0&&n.incomingTileHandles.delete(i));if(r){n.visibilityChange=t.visibilityChange;for(let e of t.incomingTileHandles)n.incomingTileHandles.add(e)}}}_prepareTileFadeIn(e,t){let n=this._pendingTileFadeOuts.delete(e.handle);return e.lifecycleState===2?(this.fadeHelper.fadeTile(e,0,t),!1):this._tileFadeInsAwaitingInitialSort.has(e.handle)?n:(e.lifecycleState===0&&this._popTileFromCache(e),e.lifecycleState=1,this._tileFadeInsAwaitingInitialSort.add(e.handle),!0)}_prepareTileFadeOut(e,t){let n=this._tileFadeInsAwaitingInitialSort.delete(e.handle);return n&&e.lifecycleState===1&&(this.moveTileToCache(e),e.lifecycleState=0),e.lifecycleState===2?this._pendingTileFadeOuts.has(e.handle)?n:(this._pendingTileFadeOuts.set(e.handle,t),!0):n}_onSortComplete(e,t){let n=this._tmpTilesWithChangedVisibility;n.length=0,this._triggerFadeIns(e,n);let r=this._triggerFadeOuts(t,n);n.length>0&&this.notifyTileObbsChanged(n),r&&this.updateGaussians()}_triggerFadeIns(e,t){for(let n of e)this._tileHandles.get(n.handle)===n&&this._tileFadeInsAwaitingInitialSort.delete(n.handle)&&(n.lifecycleState=2,t.push(n),this.fadeHelper.fadeTile(n,0,this._pendingFadeDuration))}_triggerFadeOuts(e,t){let n=!1;for(let t of this._pendingTileFadeOuts.values())if(e>=t.visibilityChange){n=!0;break}if(!n)return!1;let r=this._pendingFadeDuration,i=this._pendingFadeDuration;for(let e of this._tileHandles.values()){let{fadeDirection:t,fadeDuration:n,fadeProgress:a}=e;if(t!==0||n==null||a==null)continue;let o=n*(1-a);r=l(Math.max(r,o)),i=l(Math.max(i,n))}let a=!1;for(let[n,o]of this._pendingTileFadeOuts){if(e<o.visibilityChange)continue;this._pendingTileFadeOuts.delete(n);let s=this._tileHandles.get(n);if(s){let e=s.lifecycleState===2,n=s.opacityModifier===1?r:i;this.fadeHelper.fadeTile(s,1,n),e&&s.lifecycleState===0&&(t.push(s),a=!0)}}return a}_popTileFromCache(e){this._usedTileMemory+=e.usedMemory,this._cacheTileMemory-=e.usedMemory,this._intersectionHandler.addTile(e),this._memCache.pop(D(e.handle))}moveTileToCache(e){this._usedTileMemory-=e.usedMemory,this._cacheTileMemory+=e.usedMemory,this._intersectionHandler.removeTile(e),this._memCache.put(D(e.handle),e)}destroy(){this._initializationController=n(this._initializationController),this._createRenderableAbortController.abort(),F(this),this._suspendedHandle&&=r(this._suspendedHandle),this._intersectionHandler&&=(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),null),this._elevationProvider&&this.view.elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(this._tileHandles.size,e=>{for(let{obb:t}of this._tileHandles.values())if(!e(t))break}),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._frameTask.remove(),this._shadows=i(this._shadows),this._prepassDepthRenderer=i(this._prepassDepthRenderer),this._renderer=i(this._renderer),this._memCache.destroy(),this.data=i(this.data)}_canProjectWithoutEngine(){if(this.view.state.viewingMode===1||x(this.view.renderSpatialReference)||S(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&C(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(this.layer.esriCrsSpatialReference.vcsWkid===115700)return!1;let e=O(this.layer.esriCrsSpatialReference);if(!e){let t=this.layer.esriCrsSpatialReference,n=w(t),r=`meters`;!n&&t.wkid&&t.wkid!==-1&&(r=d(T.units[T[t.wkid]])),r&&(e=new _({heightModel:`gravity-related-height`,heightUnit:r}))}let t=this.view.heightModelInfo;return this._useEsriCrs=y(e,t,!1)===0,this._useEsriCrs&&(e&&(this._metersPerVCSUnit=f(1,e.heightUnit,`meters`)),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}_elevationInfoChanged(e){if(!e?.offset)this._wasm?.setLayerOffset(this,0);else if(!this._useEsriCrs)this._wasm?.setLayerOffset(this,k(e));else{let t=A(e?.unit)/this._metersPerVCSUnit,n=e?.offset??0;this._wasm?.setLayerOffset(this,n*t)}}_slicePlaneEnabledChanged(e){this._renderer&&(this._renderer.slicePlaneEnabled=e),this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e)}updateGaussians(){let e=[];for(let t of this._tileHandles.values())t.lifecycleState!==0&&e.push(t);this.data.updateGaussianVisibility(e,this._currentLyr3dVisibilityChange),this.notifyChange(`updating`)}get maximumGaussianCount(){return this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians*this.view.quality}set maximumGaussianCount(e){this._set(`maximumGaussianCount`,e)}_freeInvisibleTiles(){for(let e of this._tileHandles.values())e.lifecycleState===0&&!this._renderablesBeingCreated.has(e.handle)&&this._deleteTile(e)}extractHeader(e){let t=e.length-4,n=this.reinterpretU32AsFloat(e[t]),r=this.reinterpretU32AsFloat(e[t+1]),i=this.reinterpretU32AsFloat(e[t+2]),a=1/(1<<(e[t+3]&255));return{packedHeader:e.subarray(t,t+4),tileOrigin:{x:n,y:r,z:i},invPosScale:a}}_deleteTile(e){this._renderablesBeingCreated.has(e.handle)||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;this._tileHandles.forEach(n=>{n.lifecycleState===0?t++:e++});let n=this.data?.textureAtlasMemory??0,r=this.data?.headerTextureMemory??0,i=this.data?.orderTextureMemory??0,a=this.data?.fadingTextureMemory??0,o=this.data?.sortBufferMemory??0;return new j(this.usedMemory,e,this._usedTileMemory,t,this._cacheTileMemory,n,r,i,a,o)}get test(){}};e([p()],$.prototype,`layer`,void 0),e([p({readOnly:!0})],$.prototype,`_clippingBox`,null),e([p()],$.prototype,`elevationOffset`,null),e([p({readOnly:!0})],$.prototype,`visibleAtCurrentScale`,null),e([p()],$.prototype,`fullExtentInLocalViewSpatialReference`,void 0),e([p()],$.prototype,`maximumGaussianCount`,null),$=Q=e([m(`esri.views.3d.layers.GaussianSplatLayerView3D`)],$);class ie{constructor(e){this.visibilityChange=e,this.incomingTileHandles=new Set}}const ae=$;export{ae as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{abortMaybe as n,destroyMaybe as r,removeMaybe as i}from"../../../core/maybe.js";import{throwIfAborted as a,createAbortError as o}from"../../../core/promiseUtils.js";import{initial as s,whenOnce as c,watch as l,when as u}from"../../../core/reactiveUtils.js";import{schedule as d}from"../../../core/scheduling.js";import{isUint8Array as f,isFloat32Array as p,isUint32Array as m,isUint16Array as h}from"../../../core/typedArrayUtil.js";import{unitFromRESTJSON as g,convertUnit as _}from"../../../core/units.js";import{property as v,subclass as y}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as b,invert as x}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as S,IDENTITY as C}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as T}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as E,sub as D,dot as O,set as k}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as A,freeze as j,clone as ee,ZEROS as te,fromValues as ne}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as re,clone as ie,ONES as ae}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as oe,isMars as se,getReferenceEllipsoid as M,SphericalECEFSpatialReferenceLike as ce}from"../../../geometry/ellipsoidUtils.js";import le from"../../../geometry/HeightModelInfo.js";import{computeTranslationToOriginAndRotation as ue}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as de}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as fe}from"../../../geometry/projection/projectVectorToVector.js";import{create as pe}from"../../../geometry/support/aaBoundingRect.js";import{isCompatible as me}from"../../../geometry/support/heightModelInfoUtils.js";import{isInEffectiveScaleRange as he,validateScaleRange as N}from"../../../geometry/support/scaleUtils.js";import{isPlateCarree as P,isWebMercator as F,equals as I,isGeographic as L,isCGCS2000 as R}from"../../../geometry/support/spatialReferenceUtils.js";import z from"../../../geometry/support/WKIDUnitConversion.js";import{BufferViewVec4u8 as ge,BufferViewVec3u8 as _e,BufferViewVec2f as ve,BufferViewVec3f as B,BufferViewUint32 as V,BufferViewUint16 as H}from"../../../geometry/support/buffer/BufferView.js";import{nullId as U}from"../../../layers/ILyr3DWasmPerSceneView.js";import ye from"../../../layers/support/SceneModification.js";import{getHeightModelInfoFromVCS as be,validateEntity3D as xe,makeCacheKey as W}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as G}from"../../../support/elevationInfoUtils.js";import{IntegratedMesh3DTilesLayerWorkerHandle as Se}from"./IntegratedMesh3DTilesLayerWorkerHandle.js";import{LayerView3D as Ce}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as we}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as Te,removeLayerViewFromWasm as Ee,getLyr3DWasm as De}from"./Lyr3DWasm.js";import{toWasmModification as Oe}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as ke}from"./i3s/LayerElevationProvider.js";import{IntegratedMesh3DTilesLayerView3DSymbol as Ae}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as je,alphaModeConversion as Me,faceCullingConversion as Ne,wrapModeConversion as Pe}from"./support/lyr3dTypeConversions.js";import{makeScheduleFunction as Fe}from"./support/makeScheduleFunction.js";import{Tiles3DMeshIntersectionHandler as Ie}from"./support/Tiles3DMeshIntersectionHandler.js";import{Frustum as Le}from"../state/Frustum.js";import{ElevationRange as K}from"../support/ElevationRange.js";import{toBoundingRect as Re}from"../support/extentUtils.js";import{Obb as ze}from"../support/orientedBoundingBox.js";import{glLayout as Be}from"../support/buffer/glUtil.js";import{getGroundTransparencyModeFromOpacity as Ve}from"../terrain/TransparencyMode.js";import{ComponentGeometryParameters as He,SourceGeometry as Ue}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as We}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Ge}from"../webgl-engine/core/material/RenderTexture.js";import{ManagedTexture as Ke}from"../webgl-engine/lib/ManagedTexture.js";import{compressNormals as qe}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as q}from"../webgl-engine/materials/pbrUtils.js";import Je from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as Ye}from"../../support/layerViewUtils.js";import{TaskPriority as Xe}from"../../support/Scheduler.js";import{CompressedTextureFormat as J,SizedPixelFormat as Y}from"../../webgl/enums.js";import{alphaCutoff as X}from"../../../webscene/support/AlphaCutoff.js";var Z;function Ze(e,t,n){if(t===`image/vnd-ms.dds`)switch(n){case`Dxt1`:return J.COMPRESSED_RGB_S3TC_DXT1_EXT;case`Dxt5`:return J.COMPRESSED_RGBA_S3TC_DXT5_EXT;default:return null}if(t===`image/ktx`)return n===`Etc1`?J.COMPRESSED_RGB8_ETC2:null;switch(e){case 33319:return Y.RG8;case 6407:return Y.RGB8;case 6408:return Y.RGBA8;case 6403:return Y.R8;default:return null}}let Q=class extends Ce(Je){static{Z=Ae}constructor(e){super(e),this[Z]=!0,this.type=`integrated-mesh-3dtiles`,this.skipHeightModelInfoValidation=!0,this.freeze=!1,this._modifications=[],this._visibleGeometryChangedSchedulerHandle=null,this._initializationController=null,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this._useEsriCrs=!1,this.fullExtentInLocalViewSpatialReference=null,this._applySSAO=!has(`disable-feature:im-ssao`),this._imShading=!!has(`enable-feature:im-shading`),this._imVertexNormals=!!has(`enable-feature:im-vertex-normals`),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._dbgFlags=new Set;let t=e.view.resourceController;this._memCache=t.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._replacesTerrain=e.layer.replacesTerrain,this._frameTask=t.scheduler.registerTask(Xe.TILES3D,this),this._frustum=new Le(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{a(t);let n=this.layer.queryElevationCallback;this.layer=e,this.layer.queryElevationCallback=n}):null}canRecycleWith(e){return e.url===this.layer.url&&e.type===`integrated-mesh-3dtiles`&&e.replacesTerrain===this._replacesTerrain}initialize(){this._dbg(2,`Tiles3DLayerView3D initialize() called`);let{view:e}=this;this._workerHandle=new Se(Fe(e.resourceController)),this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),s),this.addResolvingPromise(this._initializeAsync(e))}async _initializeAsync(e){this._initializationController=new AbortController;let{signal:t}=this._initializationController;if(await c(()=>e?.defaultsFromMap.heightModelInfoReady,t),a(t),!this._canProjectWithoutEngine())throw Ye(`layer`,this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);this._wasmLayerId=await Te(this,t),a(t);let n=new Ie(this);this._intersectionHandler=n,e.sceneIntersectionHelper.addIntersectionHandler(n),this._elevationProvider=new ke({view:e,layerElevationSource:this,intersectionHandler:n});let r=this._getElevationContext();e.elevationProvider.register(r,this._elevationProvider),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged()),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.overlayManager.renderer.isEmpty,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),s),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),s),this._updatingHandles.add(()=>this.layer.isUsedAsGroundLayer,()=>this._groundUsageChanged()),e.overlayManager.registerDrapeTarget(this),this.addHandles([l(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),u(()=>this.fullOpacity,()=>this._opacityChange()),l(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),s),l(()=>this.freeze,e=>{e?this._wasm?.incrementFrozenLayerViewCount(this):(this._wasm?.decrementFrozenLayerViewCount(this),this._cameraChanged())})]),this._initializationController=null,this.addHandles(l(()=>this._replacesTerrain&&!!this._wasm?.isTerrainReady||!this._replacesTerrain&&!!has(`enable-feature:im-as-ground`)&&this.layer.isUsedAsGroundLayer,e=>{this.layer.queryElevationCallback=e?(e,t)=>this._queryElevation(e,t):null},s))}destroy(){if(this.freeze=!1,this._initializationController=n(this._initializationController),this._dbg(2,`Tiles3DLayerView3D destroy() called`),this._workerHandle?.destroyContextAndSelf(this.uid),Ee(this),this.layer.queryElevationCallback=null,this._intersectionHandler&&=(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler.destroy(),null),this._elevationProvider){let e=Array.from(this._lyrHandleToObjects.values()),t=e.reduce((e,{componentObjects:t})=>e+t.length,0);this._elevationProvider.notifyObjectsChangedFunctional(t,t=>{for(let{componentObjects:n}of e)for(let{obb:e}of n)if(!t(e))return}),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._frameTask.remove(),this._updatingHandles=r(this._updatingHandles),this.emit(`visible-geometry-changed`),this._visibleGeometryChangedSchedulerHandle=i(this._visibleGeometryChangedSchedulerHandle)}get usedAsGround(){return this.layer.isUsedAsGroundLayer}get replacesTerrain(){return this._replacesTerrain}get fullOpacity(){return has(`enable-feature:im-as-ground`)?this.usedAsGround?this.view.map.ground.opacity:this.layer.opacity:this.replacesTerrain?this.view.map.ground.opacity:1}get opaque(){return this._groundTransparencyMode===0}get invisible(){return this._groundTransparencyMode===3}get _groundTransparencyMode(){return(has(`enable-feature:im-as-ground`)?!this.usedAsGround:!this._replacesTerrain)?0:Ve(this.fullOpacity,this.view.overlayManager.renderer.isEmpty)}get _renderOpacity(){switch(this._groundTransparencyMode){case 3:return 0;case 2:return X;default:return this.fullOpacity}}get hasModifications(){return this._modifications&&this._modifications.length>0}_opacityChange(){let e=this._renderOpacity,t=this._groundTransparencyMode;this.forEachComponentObject(n=>this._collection.updateObjectOpacity(n,e,t))}_getElevationContext(){return this.replacesTerrain?0:has(`enable-feature:im-as-ground`)?this.usedAsGround?1:2:1}_groundUsageChanged(){let e=this._getElevationContext();this.view.elevationProvider.unregister(this._elevationProvider),this.view.elevationProvider.register(e,this._elevationProvider),this._intersectionHandler.isGround=!has(`enable-feature:im-as-ground`)||this.usedAsGround,this._intersectionHandler.slicePlaneEnabled=this.slicePlaneEnabled&&!this.replacesTerrain,this.view.overlayManager.unregisterDrapeTarget(this),this.view.overlayManager.registerDrapeTarget(this),this._loadModifications();let t=has(`enable-feature:im-as-ground`)?this.usedAsGround:this.replacesTerrain,n=this._renderOpacity,r=this._groundTransparencyMode;this.forEachComponentObject(e=>e.updateMaterial({isGround:t,opacity:n,groundTransparencyMode:r}))}_cameraChanged(){if(this.freeze)return;let e=this._frustum;e.update(this.view.state.contentCamera);let t=this._visibleObjects,n=!1;this._loadedObjects.forEach(r=>{let i=r.obb?.intersectsFrustum(e)??!1;i!==r.isVisible&&(r.isVisible=i,i?t.add(r):t.delete(r),r.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,i)),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(i,r.elevationRange))}),n&&this._setVisibleElevationRangeDirty()}intersect(e,t,n,r){this._intersectionHandler.intersectRay(e,t,n,r,null,!1)}get ready(){return!this.replacesTerrain||!!this._wasm?.isTerrainReady}_modificationsChanged(){let e=this.useEsriCrs?this.layer.supportedSpatialReferences[1]:this.layer.supportedSpatialReferences[0],t=Oe(this._layerClippingArea,this._modifications,e,this.view.state.isGlobal);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){let e=this.layer.spatialReference,t=pe();this._layerClippingArea=Re(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=d(()=>{this.emit(`visible-geometry-changed`),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.replacesTerrain),this.forEachComponentObject(t=>t.updateMaterial({slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,G(e))}get _wasm(){return De(this.view)}_queryElevation(e,t){return this.destroying||this.destroyed?Promise.reject(o()):this._wasm?.queryElevation(this,e,t)??Promise.reject(o())}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get useEsriCrs(){return this._useEsriCrs}get visibleAtCurrentScale(){return this.replacesTerrain||he(this.layer.effectiveScaleRange,this.view.scale)}canResume(){let 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.replacesTerrain||N(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,n=0,r=0,i=0,a=0;return this._lyrHandleToObjects.forEach(o=>{o.isLoaded?(e+=o.textureMemoryUsage,t+=o.vboMemoryUsage,i++):(n+=o.textureMemoryUsage,r+=o.vboMemoryUsage,a++)}),new we(this.usedMemory,i,a,$(t),$(e),$(r),$(n))}_canProjectWithoutEngine(){if(this.view.state.viewingMode===1||P(this.view.renderSpatialReference)||F(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&I(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(this.layer.esriCrsSpatialReference.vcsWkid===115700)return!1;let e=be(this.layer.esriCrsSpatialReference);if(!e){let t=this.layer.esriCrsSpatialReference,n=L(t),r=`meters`;!n&&t.wkid&&t.wkid!==-1&&(r=g(z.units[z[t.wkid]])),r&&(e=new le({heightModel:`gravity-related-height`,heightUnit:r}))}let t=this.view.heightModelInfo;return this._useEsriCrs=me(e,t,!1)===0,this._useEsriCrs&&(e&&(this._metersPerVCSUnit=_(1,e.heightUnit,`meters`)),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return G(this.layer.elevationInfo)}get elevationRange(){let e=this.fullExtent;return e?.zmin&&e?.zmax?new K(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){let e=new K;this._visibleObjects.size===0?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this._forEachRelevantVisibleTile(t=>e.expandElevationRange(t.elevationRange)),e.minElevation===1/0&&e.setElevationRangeValues(0,0));let t=this._get(`visibleElevationRange`);return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange(`visibleElevationRange`)}_forEachRelevantVisibleTile(e){let{view:t}=this,{spatialReference:n}=t,r=n.isWGS84||n.isWebMercator||R(n)||oe(n)||se(n);if(this.view.state.isGlobal||!r)return this.forEachVisibleTile(e);let i=M(n).radius,{eye:a,viewForward:o,near:s}=t.state.contentCamera,c=E(A(),o),l=Math.max(a[2],500),u=l+i,d=Math.sqrt(u**2-i**2),f=Math.abs(Math.atan2(d,i))*i,p=l>.5*i?.5*Math.PI*i:f,m=A();this.forEachVisibleTile(t=>{let{mbsRadius:n,mbsCenter:r}=t;if(n<0)return;D(m,r,a);let i=O(m,c);Math.abs(i)<p&&i+n>s&&i-n<p&&e(t)})}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(let t of this._visibleObjects)e(t)}forEachTile(e){for(let t of this._loadedObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(let{componentObjects:n}of e)for(let e of n)t(e)}get drapeTargetType(){return has(`enable-feature:im-as-ground`)?+!this.usedAsGround:+!this.replacesTerrain}isUpdating(){let e=this._wasm;return!this.freeze&&this._wasmLayerId>=0&&e!=null&&e.isUpdating(this._wasmLayerId)}get readyToRun(){return!!this._frameTask?.readyToRun}runTask(e){this._frameTask.processQueue(e)}updatingFlagChanged(){this.notifyChange(`updating`)}async createRenderable(e){if(this.destroyed||this.destroying)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy`);let{entity3d:t}=e;if(!xe(t))throw Error(`entity3D not valid`);let n=new Map,r;try{r=this._createPrimitiveTextureBundles(t,n)}catch(e){throw n.forEach(e=>this._stage?.removeTexture(e)),e}let i=null;try{if(i=await this._createRenderableMain(t,r),this.destroyed)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderable aborted due to destroyed instance`);let{tileObb:a,componentObjects:o,elevationRange:s}=i,c=0,l=0,u=0;for(let e of o){let{texture:t,textureMetallicRoughness:n,textureEmissive:r,textureOcclusion:i,textureNormal:a}=e.renderable.drawParameters;c+=(t?.usedMemory??0)+(n?.usedMemory??0)+(r?.usedMemory??0)+(i?.usedMemory??0)+(a?.usedMemory??0),l+=this._collection.getObjectGPUMemoryUsage(e),u+=e.intersectionGeometry.usedMemory}let d=Array.from(n.values()),f=new $e(e.handle,o,d,u,l,c,a,e.stableNodeId,e.nodeDepth,s);return this._lyrHandleToObjects.set(e.handle,f),()=>{this._memCache.put(W(f.handle),f);let{usedMemory:e}=f;return this._cacheMemory+=e,{memUsageBytes:e}}}catch(e){throw r.forEach(e=>e.cleanup()),i?.componentObjects.forEach(e=>this._collection.destroyObject(e)),n.forEach(e=>this._stage?.removeTexture(e)),e}}_createPrimitiveTextureBundles(e,t){let n=[];try{let r=e.desc.geometry;for(let i of e.validPrimitiveIndices){let a=r.prims[i].materialId,o=e.desc.materials?.materials&&a!=null&&a!==U?e.desc.materials.materials[a]:null,s=Promise.resolve(tt),c=null,l=null,u=null,d=null,f=null;if(o){let n=o.lightingModel===`Pbr`;c=this._getTexture(o.baseColorTex,e,t),l=n?this._getTexture(o.metalTex,e,t):null,u=n?this._getTexture(o.emissiveTex,e,t):null,d=n?this._getTexture(o.occlusionTex,e,t):null,f=n?this._getTexture(o.normalTex,e,t):null;let r=[c,l,u,d,f].map(e=>e?.loadPromise??null);s=Promise.all(r)}n.push(new nt(s,c,l,u,d,f))}}catch(e){throw n.forEach(e=>e.cleanup()),e}return n}async _createRenderableMain(e,t){if(this.destroyed||this.destroying)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderableMain called after destroy`);let n=[],r=e.desc,i=j(...e.origin),a=this.view.groundView.spatialReference,o=this.view.state.isGlobal,s=C;if(o){let e=w();ue(ce,i,e,a),s=b(S(),e)}let c=et(r.obb),l=o?M(this.view.spatialReference).radius:0,u=[];try{let d=-1;for(let n of e.validPrimitiveIndices){d+=1;let i=r.geometry.prims[n],a=t[d];if(this._dbgFlags.has(2)&&this._dbg(2,JSON.stringify(i)),je[i.ptype]==null){this._dbg(2,`[Unsupported Feature] Unsupported primitive mode (`+i.ptype+`). Skipping primitive.`),a.cleanup();continue}let{positionView:o,normalsData:s,colorView:c,texCoord0Data:l,indicesView:f}=this._getBufferViews(i,e);if(o==null||f==null){a.cleanup();continue}let p=o.count,m=(e,t)=>e!=null&&e!==p?(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1):!0;!m(l==null?void 0:l.length/2,`numTexcoord`)||!m(c?.count,`numColors`)||!m(s?.length,`normals`)?a.cleanup():u.push({componentIndex:d,positionView:o,indicesView:f,texCoord0Data:l,colorView:c,normalsData:s})}let f=s!==C,p=f?x(S(),s)??C:C,{vertexProcessingOutputs:m,obbHalfSizeAccumulator:h,elevationRange:g}=await this._workerHandle.processTiles3DVertices(u,i,l,o,s,c,this._imVertexNormals&&!this.usedAsGround);if(this.destroyed)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance`);let _=r.materials;if(await Promise.all(t.map(e=>e.materialPromise)),this.destroyed)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance`);m.length>0&&c.setHalfSize(h);for(let o of m){let{componentIndex:s,positionView:l,indicesView:u,layout:d,textureCoordinateType:m,interleavedVertexData:h,indices:g}=o,v=e.validPrimitiveIndices[s],y=r.geometry.prims[v],b=t[s],x=c.clone(),S=Be(d),C=new Uint32Array([0,u.typedBuffer.length]),w=new He(S,this._imShading?2:0,m,f?2:0),T=new Ue({interleavedVertexData:h,vertexCount:h.byteLength/S[0].stride,indexData:g},{positions:l.typedBuffer,indices:u.typedBuffer},C,w),E=this.view.renderSpatialReference,D=A(),O=[1,1,1];de(i,E,O,a)||this._dbg(3,`Unsupported coordinate system for IM overlay`),fe(i,E,D,a);let k=this._createComponentMaterialInitParameters(_,y.materialId,b);k.baseColorTexture||this._dbg(3,`No colour texture 1`);let j=this._collection.createObject({toMapSpace:re(D[0],D[1],O[0],O[1]),transform:new We(i,p),obb:x,geometry:T,elevationAlignable:!1},k);n.push(j)}let{fullExtent:v}=this.layer;return v?.hasZ&&v.zmax&&v.zmin&&(g.minElevation=Math.max(g.minElevation,v.zmin),g.maxElevation=Math.min(g.maxElevation,v.zmax)),{tileObb:c,componentObjects:n,elevationRange:g}}catch(e){throw n.forEach(e=>this._collection.destroyObject(e)),e}}_createComponentMaterialInitParameters(e,t,n){let r=e?.materials!=null&&t!=null&&t!==U?e.materials[t]:null,i=1,a=r?.baseColorTex?.imageId;if(a!=null&&e&&Array.isArray(e.images)&&a>=0&&a<e.images.length){let t=e.images[a];t.alpha&&(i=Me[t.alpha])}let o=(r==null?`Unlit`:r.lightingModel)===`Pbr`,s=ae,c=X,l=!1,u=2,d=ne(0,0,0),f=ee(q),p=n.baseColorTexture,m=n.metallicRoughnessTexture,h=n.emissionTexture,g=n.occlusionTexture,_=n.normalTexture;return r&&(s=ie(r.baseColorFactor),c=r.alphaCutoff??X,o&&(k(f,r.metallicFactor,r.roughnessFactor,0),r.emissiveFactor&&(d=r.emissiveFactor)),l=r.isDoubleSided,u=Ne[r.faceCulling??`NotSet`]),{isIntegratedMesh:!0,baseColor:s,textureAlphaCutoff:c,mrrFactors:f,baseColorTexture:p,metallicRoughnessTexture:m,normalTexture:_,occlusionTexture:g,emissionTexture:h,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:i,doubleSided:l,cullFace:u,isGround:has(`enable-feature:im-as-ground`)?this.usedAsGround:this.replacesTerrain,groundTransparencyMode:this._groundTransparencyMode,emissiveBaseColor:d,usePBR:o,slicePlaneEnabled:this.slicePlaneEnabled,opacity:this._renderOpacity,polygonOffset:0,ellipsoidMode:1,applySSAO:this._applySSAO}}freeRenderable(e){let t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._intersectionHandler.removeTile(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){let t=W(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,n){if(this.destroyed||this.destroying)return;let r=this._frustum,i=[],a=!1,o=!1;for(let s=0;s<n;++s){if(!t[s])continue;let n=e[s],c=this._lyrHandleToObjects.get(n);if(c){if(c.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${c.stableNodeId}`);continue}a=!0,c.isLoaded=!0,this._loadedObjects.add(c),this._intersectionHandler.addTile(c),this._usedMemory+=c.usedMemory,this._cacheMemory-=c.usedMemory;let e=c.obb?.intersectsFrustum(r)??!0;c.isVisible=e,e&&(this._visibleObjects.add(c),o||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,c.elevationRange)),i.push(c.obb),c.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(W(n))}else this._dbg(3,`Tried to mark Non existent object ${n} as loaded`)}for(let r=0;r<n;++r){let n=e[r];if(t[r])continue;let a=this._lyrHandleToObjects.get(n);if(a){if(!a.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${a.stableNodeId}`);continue}let e=a.isVisible;this._visibleObjects.delete(a),a.isVisible=!1,a.isLoaded=!1,this._loadedObjects.delete(a),this._intersectionHandler.removeTile(a),e&&(this._visibleGeometryChanged(),o||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,a.elevationRange)),this._usedMemory-=a.usedMemory,this._cacheMemory+=a.usedMemory,i.push(a.obb),a.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(W(n),a)}else this._dbg(3,`Tried to mark Non existent object ${n} as not loaded`)}a&&this._visibleGeometryChanged(),i.length>0&&this._elevationProvider.notifyObjectsChanged(i),o&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){let{visibleElevationRange:n}=this,{minElevation:r,maxElevation:i}=t;return e?r<n.minElevation||i>n.maxElevation:r===n.minElevation||i===n.maxElevation}_getTexture(e,t,n){let r=e&&t.desc.materials?.images?.[e.imageId];if(!r||r.data==null||r.data===U)return null;let i=t.assets[r.data];if(!i||i.byteCount<1||i.dataType!==`U8`)return null;let a=n.get(r)??this._createTexture(e,r,i,n);return a?new Ge(this._stage.renderView.textures,a.id):null}_createTexture(e,n,r,i){let a=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,o=n.mipCount?!0:a>1,s=Pe[e.wrapMode??`None`],c=n.alpha?6408:6407,l=new Uint8Array(r.data.buffer,0,r.byteCount),u=null,d=null;switch(n.format){case`Raw`:if(n.pixelFormat===`R8`)u=l,c=6403,d=``;else if(n.pixelFormat===`Rg8`||n.pixelFormat===`Ga8`)u=l,c=33319,d=``;else if(n.pixelFormat===`Rgb8`)u=l,c=6407,d=``;else if(n.pixelFormat===`Rgba8`)u=l,c=6408,d=``;else return t.getLogger(this).error(`Raw texture pixel format ${n.pixelFormat} not supported`),null;break;case`Dxt1`:u=l,c=6407,d=`image/vnd-ms.dds`;break;case`Dxt5`:u=l,c=6408,d=`image/vnd-ms.dds`;break;case`Basis`:u=l,c=6407,d=`image/ktx2`;break;case`Etc1`:u=l,c=6407,d=`image/ktx`;break;default:return t.getLogger(this).error(`${n.format} texture not supported`),null}if(u&&d!=null){let e=Ze(c,d,n.format),t=new Ke(u,{mipmap:o,maxAnisotropy:a,encoding:d,wrap:s,pixelFormat:c,internalFormat:e??void 0,immutable:e!=null,noUnpackFlip:!0,width:n.mip0Width,height:n.mip0Height});return this._stage.addTexture(t),i.set(n,t),t}return null}_getBufferViews(e,t){let n,r,i,a;for(let o=0;o<e.atrbs.length;o++){let s=e.atrbs[o],c=t.assets[s.assetId];if(!c)continue;let l=c.data.buffer,u=c.byteCount;try{switch(s.sem){case`Position`:c.ncomp!==3||c.dataType!==`F32`||!p(c.data)?this._dbg(3,`[Unsupported Feature] Unsupported view for Position (`+c+`)`):n=new B(l,0,void 0,u);break;case`Normal`:if(c.ncomp!==3||c.dataType!==`F32`||!p(c.data))this._dbg(3,`[Unsupported Feature] Unsupported view for Normal (`+c+`)`);else{let e=new B(l,0,void 0,u);a=new Uint32Array(e.count),qe(e.typedBuffer,new Int16Array(a.buffer,a.byteOffset,a.length*2))}break;case`TexCoord`:c.ncomp!==2||c.dataType!==`F32`||!p(c.data)?this._dbg(3,`[Unsupported Feature] Unsupported view for Texcoord (`+c+`)`):i===void 0&&(i=new ve(l,0,void 0,u).typedBuffer);break;case`Color`:c.dataType===`U8`&&f(c.data)&&(c.ncomp===4?r=new ge(l,0,void 0,u):c.ncomp===3&&(r=new _e(l,0,void 0,u))),r??this._dbg(3,`[Unsupported Feature] Unsupported view for Color (`+c+`)`);break;case`FeatureIndex`:break;default:this._dbg(2,`[Unsupported Feature] Unsupported semantic (`+s.sem+`). Skipping vertex attribute.`)}}catch(e){this._dbg(2,`Error Creating buffer (`+e+`). Skipping vertex attribute.`)}}let o,s=!1;if(e.index!=null&&e.index!==U){let n=t.assets[e.index];if(!n)s=!0;else{let e=n.byteCount;switch(n.dataType){case`U16`:n.ncomp===1&&h(n.data)&&(o=new H(n.data.buffer,0,void 0,e));break;case`U32`:n.ncomp===1&&m(n.data)&&(o=new V(n.data.buffer,0,void 0,e))}s=!o}}if(!s&&o==null&&n!=null){let e=n.count;o=o=e<65535?new H(new Uint16Array(e).buffer):new V(new Uint32Array(e).buffer);for(let t=0;t<e;t++)o.set(t,t)}return{positionView:n,colorView:r,texCoord0Data:i,indicesView:o,normalsData:a}}_loadModifications(){if(this.removeHandles(`modifications`),this.layer.modifications==null){this._modifications=[];return}let e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.usedAsGround&&e.type!==`replace`)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info(`Ground layers only support replace modifications. Other modification types have been ignored.`)},s),`modifications`)}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,n){this._dbgFlags.has(e)&&(e===3?t.getLogger(this).error(n):t.getLogger(this).warn(n))}};e([v()],Q.prototype,`freeze`,void 0),e([v()],Q.prototype,`fullOpacity`,null),e([v()],Q.prototype,`opaque`,null),e([v()],Q.prototype,`invisible`,null),e([v({readOnly:!0})],Q.prototype,`ready`,null),e([v({type:[ye]})],Q.prototype,`_modifications`,void 0),e([v()],Q.prototype,`_visibleGeometryChangedSchedulerHandle`,void 0),e([v()],Q.prototype,`layer`,void 0),e([v({readOnly:!0})],Q.prototype,`visibleAtCurrentScale`,null),e([v({readOnly:!0})],Q.prototype,`_collection`,null),e([v()],Q.prototype,`elevationOffset`,null),e([v({readOnly:!0})],Q.prototype,`visibleElevationRange`,null),e([v()],Q.prototype,`fullExtentInLocalViewSpatialReference`,void 0),Q=e([y(`esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D`)],Q);const Qe=Q;class $e{constructor(e,t,n,r,i,a,o,s,c,l){this.handle=e,this.componentObjects=t,this.textures=n,this.cpuMemoryUsage=r,this.vboMemoryUsage=i,this.textureMemoryUsage=a,this.obb=o,this.stableNodeId=s,this.nodeDepth=c,this.elevationRange=l,this.bvhIntersectionGeneration=0,this.isLoaded=!1,this.isVisible=!1;let u=A();o?.getCenter(u),this._obbCenterX=u[0],this._obbCenterY=u[1],this._obbCenterZ=u[2];let d=o?.radius??-1;this._obbRadius=d,this._obbRadiusSquared=d*d,this._obbShortestHalfsize=o?Math.min(o.halfSizeX,o.halfSizeY,o.halfSizeZ):0,this._mbsCenter=o?o.getCenter(A()):te}get usedMemory(){return this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this._mbsCenter}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;let{_obbCenterX:n,_obbCenterY:r,_obbCenterZ:i}=this,a=n-e[0],o=r-e[1],s=i-e[2],c=a*t[0]+o*t[1]+s*t[2];return a*a+o*o+s*s-c*c<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){let t=this._obbRadius;if(t<0)return!0;let n=e.center,r=e.radius,i=t+r,a=this._obbCenterX-n[0];if(a>i)return!1;let o=this._obbCenterY-n[1];if(o>i)return!1;let s=this._obbCenterZ-n[2];if(s>i)return!1;let c=a*a+o*o+s*s;if(c>i*i)return!1;if(c<=(this._obbShortestHalfsize+r)**2)return!0;let l=r-t;return l>0&&c<=l*l?!0:this.obb?.intersectSphere(e)??!0}}function $(e){return Math.round(e/1048.576)/1e3}function et(e){return new ze(e.center,e.halfSize,T(...e.quaternion))}const tt=[];class nt{constructor(e,t,n,r,i,a){this.materialPromise=e,this.baseColorTexture=t,this.metallicRoughnessTexture=n,this.emissionTexture=r,this.occlusionTexture=i,this.normalTexture=a}cleanup(){this.baseColorTexture?.dispose(),this.metallicRoughnessTexture?.dispose(),this.emissionTexture?.dispose(),this.occlusionTexture?.dispose(),this.normalTexture?.dispose()}}export{Qe as default};
2
+ import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{abortMaybe as n,destroyMaybe as r,removeMaybe as i}from"../../../core/maybe.js";import{throwIfAborted as a,createAbortError as o}from"../../../core/promiseUtils.js";import{initial as s,whenOnce as c,watch as l,when as u}from"../../../core/reactiveUtils.js";import{schedule as d}from"../../../core/scheduling.js";import{isUint8Array as f,isFloat32Array as p,isUint32Array as m,isUint16Array as h}from"../../../core/typedArrayUtil.js";import{unitFromRESTJSON as g,convertUnit as _}from"../../../core/units.js";import{property as v,subclass as y}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as b,invert as x}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as S,IDENTITY as C}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as T}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as E,sub as D,dot as O,set as k}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as A,freeze as j,clone as ee,ZEROS as te,fromValues as ne}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as re,clone as ie,ONES as ae}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as oe,isMars as se,getReferenceEllipsoid as M,SphericalECEFSpatialReferenceLike as ce}from"../../../geometry/ellipsoidUtils.js";import le from"../../../geometry/HeightModelInfo.js";import{computeTranslationToOriginAndRotation as ue}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as de}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as fe}from"../../../geometry/projection/projectVectorToVector.js";import{create as pe}from"../../../geometry/support/aaBoundingRect.js";import{isCompatible as me}from"../../../geometry/support/heightModelInfoUtils.js";import{isInEffectiveScaleRange as he,validateScaleRange as ge}from"../../../geometry/support/scaleUtils.js";import{isPlateCarree as N,isWebMercator as P,equals as F,isGeographic as I,isCGCS2000 as L}from"../../../geometry/support/spatialReferenceUtils.js";import R from"../../../geometry/support/WKIDUnitConversion.js";import{BufferViewVec4u8 as _e,BufferViewVec3u8 as ve,BufferViewVec2f as ye,BufferViewVec3f as z,BufferViewUint32 as B,BufferViewUint16 as V}from"../../../geometry/support/buffer/BufferView.js";import{nullId as H}from"../../../layers/ILyr3DWasmPerSceneView.js";import be from"../../../layers/support/SceneModification.js";import{getHeightModelInfoFromVCS as xe,validateEntity3D as Se,makeCacheKey as U,isValidHandle as W}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as G}from"../../../support/elevationInfoUtils.js";import{IntegratedMesh3DTilesLayerWorkerHandle as Ce}from"./IntegratedMesh3DTilesLayerWorkerHandle.js";import{LayerView3D as we}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as Te}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as Ee,removeLayerViewFromWasm as De,getLyr3DWasm as Oe}from"./Lyr3DWasm.js";import{toWasmModification as K}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as ke}from"./i3s/LayerElevationProvider.js";import{IntegratedMesh3DTilesLayerView3DSymbol as Ae}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as je,alphaModeConversion as Me,faceCullingConversion as Ne,wrapModeConversion as Pe}from"./support/lyr3dTypeConversions.js";import{makeScheduleFunction as Fe}from"./support/makeScheduleFunction.js";import{Tiles3DMeshIntersectionHandler as Ie}from"./support/Tiles3DMeshIntersectionHandler.js";import{Frustum as Le}from"../state/Frustum.js";import{ElevationRange as q}from"../support/ElevationRange.js";import{toBoundingRect as Re}from"../support/extentUtils.js";import{Obb as ze}from"../support/orientedBoundingBox.js";import{glLayout as Be}from"../support/buffer/glUtil.js";import{getGroundTransparencyModeFromOpacity as Ve}from"../terrain/TransparencyMode.js";import{ComponentGeometryParameters as He,SourceGeometry as Ue}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as We}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Ge}from"../webgl-engine/core/material/RenderTexture.js";import{ManagedTexture as Ke}from"../webgl-engine/lib/ManagedTexture.js";import{compressNormals as qe}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as Je}from"../webgl-engine/materials/pbrUtils.js";import Ye from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as Xe}from"../../support/layerViewUtils.js";import{TaskPriority as Ze}from"../../support/Scheduler.js";import{CompressedTextureFormat as J,SizedPixelFormat as Y}from"../../webgl/enums.js";import{alphaCutoff as X}from"../../../webscene/support/AlphaCutoff.js";var Z;function Qe(e,t,n){if(t===`image/vnd-ms.dds`)switch(n){case`Dxt1`:return J.COMPRESSED_RGB_S3TC_DXT1_EXT;case`Dxt5`:return J.COMPRESSED_RGBA_S3TC_DXT5_EXT;default:return null}if(t===`image/ktx`)return n===`Etc1`?J.COMPRESSED_RGB8_ETC2:null;switch(e){case 33319:return Y.RG8;case 6407:return Y.RGB8;case 6408:return Y.RGBA8;case 6403:return Y.R8;default:return null}}let Q=class extends we(Ye){static{Z=Ae}constructor(e){super(e),this[Z]=!0,this.type=`integrated-mesh-3dtiles`,this.skipHeightModelInfoValidation=!0,this.freeze=!1,this._modifications=[],this._visibleGeometryChangedSchedulerHandle=null,this._initializationController=null,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this._useEsriCrs=!1,this.fullExtentInLocalViewSpatialReference=null,this._applySSAO=!has(`disable-feature:im-ssao`),this._imShading=!!has(`enable-feature:im-shading`),this._imVertexNormals=!!has(`enable-feature:im-vertex-normals`),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._dbgFlags=new Set;let t=e.view.resourceController;this._memCache=t.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._replacesTerrain=e.layer.replacesTerrain,this._frameTask=t.scheduler.registerTask(Ze.TILES3D,this),this._frustum=new Le(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{a(t);let n=this.layer.queryElevationCallback;this.layer=e,this.layer.queryElevationCallback=n}):null}canRecycleWith(e){return e.url===this.layer.url&&e.type===`integrated-mesh-3dtiles`&&e.replacesTerrain===this._replacesTerrain}initialize(){this._dbg(2,`Tiles3DLayerView3D initialize() called`);let{view:e}=this;this._workerHandle=new Ce(Fe(e.resourceController)),this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),s),this.addResolvingPromise(this._initializeAsync(e))}async _initializeAsync(e){this._initializationController=new AbortController;let{signal:t}=this._initializationController;if(await c(()=>e?.defaultsFromMap.heightModelInfoReady,t),a(t),!this._canProjectWithoutEngine())throw Xe(`layer`,this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);this._wasmLayerId=await Ee(this,t),a(t);let n=new Ie(this);this._intersectionHandler=n,e.sceneIntersectionHelper.addIntersectionHandler(n),this._elevationProvider=new ke({view:e,layerElevationSource:this,intersectionHandler:n});let r=this._getElevationContext();e.elevationProvider.register(r,this._elevationProvider),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged()),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.overlayManager.renderer.isEmpty,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),s),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),s),this._updatingHandles.add(()=>this.layer.isUsedAsGroundLayer,()=>this._groundUsageChanged()),e.overlayManager.registerDrapeTarget(this),this.addHandles([l(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),u(()=>this.fullOpacity,()=>this._opacityChange()),l(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),s),l(()=>this.freeze,e=>{e?this._wasm?.incrementFrozenLayerViewCount(this):(this._wasm?.decrementFrozenLayerViewCount(this),this._cameraChanged())})]),this._initializationController=null,this.addHandles(l(()=>this._replacesTerrain&&!!this._wasm?.isTerrainReady||!this._replacesTerrain&&!!has(`enable-feature:im-as-ground`)&&this.layer.isUsedAsGroundLayer,e=>{this.layer.queryElevationCallback=e?(e,t)=>this._queryElevation(e,t):null},s))}destroy(){if(this.freeze=!1,this._initializationController=n(this._initializationController),this._dbg(2,`Tiles3DLayerView3D destroy() called`),this._workerHandle?.destroyContextAndSelf(this.uid),De(this),this.layer.queryElevationCallback=null,this._intersectionHandler&&=(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler.destroy(),null),this._elevationProvider){let e=Array.from(this._lyrHandleToObjects.values()),t=e.reduce((e,{componentObjects:t})=>e+t.length,0);this._elevationProvider.notifyObjectsChangedFunctional(t,t=>{for(let{componentObjects:n}of e)for(let{obb:e}of n)if(!t(e))return}),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._frameTask.remove(),this._updatingHandles=r(this._updatingHandles),this.emit(`visible-geometry-changed`),this._visibleGeometryChangedSchedulerHandle=i(this._visibleGeometryChangedSchedulerHandle)}get usedAsGround(){return this.layer.isUsedAsGroundLayer}get replacesTerrain(){return this._replacesTerrain}get fullOpacity(){return has(`enable-feature:im-as-ground`)?this.usedAsGround?this.view.map.ground.opacity:this.layer.opacity:this.replacesTerrain?this.view.map.ground.opacity:1}get opaque(){return this._groundTransparencyMode===0}get invisible(){return this._groundTransparencyMode===3}get _groundTransparencyMode(){return(has(`enable-feature:im-as-ground`)?!this.usedAsGround:!this._replacesTerrain)?0:Ve(this.fullOpacity,this.view.overlayManager.renderer.isEmpty)}get _renderOpacity(){switch(this._groundTransparencyMode){case 3:return 0;case 2:return X;default:return this.fullOpacity}}get hasModifications(){return this._modifications&&this._modifications.length>0}_opacityChange(){let e=this._renderOpacity,t=this._groundTransparencyMode;this.forEachComponentObject(n=>this._collection.updateObjectOpacity(n,e,t))}_getElevationContext(){return this.replacesTerrain?0:has(`enable-feature:im-as-ground`)?this.usedAsGround?1:2:1}_groundUsageChanged(){let e=this._getElevationContext();this.view.elevationProvider.unregister(this._elevationProvider),this.view.elevationProvider.register(e,this._elevationProvider),this._intersectionHandler.isGround=!has(`enable-feature:im-as-ground`)||this.usedAsGround,this._intersectionHandler.slicePlaneEnabled=this.slicePlaneEnabled&&!this.replacesTerrain,this.view.overlayManager.unregisterDrapeTarget(this),this.view.overlayManager.registerDrapeTarget(this),this._loadModifications();let t=has(`enable-feature:im-as-ground`)?this.usedAsGround:this.replacesTerrain,n=this._renderOpacity,r=this._groundTransparencyMode;this.forEachComponentObject(e=>e.updateMaterial({isGround:t,opacity:n,groundTransparencyMode:r}))}_cameraChanged(){if(this.freeze)return;let e=this._frustum;e.update(this.view.state.contentCamera);let t=this._visibleObjects,n=!1;this._loadedObjects.forEach(r=>{let i=r.obb?.intersectsFrustum(e)??!1;i!==r.isVisible&&(r.isVisible=i,i?t.add(r):t.delete(r),r.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,i)),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(i,r.elevationRange))}),n&&this._setVisibleElevationRangeDirty()}intersect(e,t,n,r){this._intersectionHandler.intersectRay(e,t,n,r,null,!1)}get ready(){return!this.replacesTerrain||!!this._wasm?.isTerrainReady}_modificationsChanged(){let e=this.useEsriCrs?this.layer.supportedSpatialReferences[1]:this.layer.supportedSpatialReferences[0],t=K(this._layerClippingArea,this._modifications,e,this.view.state.isGlobal);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){let e=this.layer.spatialReference,t=pe();this._layerClippingArea=Re(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=d(()=>{this.emit(`visible-geometry-changed`),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.replacesTerrain),this.forEachComponentObject(t=>t.updateMaterial({slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,G(e))}get _wasm(){return Oe(this.view)}_queryElevation(e,t){return this.destroying||this.destroyed?Promise.reject(o()):this._wasm?.queryElevation(this,e,t)??Promise.reject(o())}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get useEsriCrs(){return this._useEsriCrs}get visibleAtCurrentScale(){return this.replacesTerrain||he(this.layer.effectiveScaleRange,this.view.scale)}canResume(){let 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.replacesTerrain||ge(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,n=0,r=0,i=0,a=0;return this._lyrHandleToObjects.forEach(o=>{o.isLoaded?(e+=o.textureMemoryUsage,t+=o.vboMemoryUsage,i++):(n+=o.textureMemoryUsage,r+=o.vboMemoryUsage,a++)}),new Te(this.usedMemory,i,a,$(t),$(e),$(r),$(n))}_canProjectWithoutEngine(){if(this.view.state.viewingMode===1||N(this.view.renderSpatialReference)||P(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&F(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(this.layer.esriCrsSpatialReference.vcsWkid===115700)return!1;let e=xe(this.layer.esriCrsSpatialReference);if(!e){let t=this.layer.esriCrsSpatialReference,n=I(t),r=`meters`;!n&&t.wkid&&t.wkid!==-1&&(r=g(R.units[R[t.wkid]])),r&&(e=new le({heightModel:`gravity-related-height`,heightUnit:r}))}let t=this.view.heightModelInfo;return this._useEsriCrs=me(e,t,!1)===0,this._useEsriCrs&&(e&&(this._metersPerVCSUnit=_(1,e.heightUnit,`meters`)),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return G(this.layer.elevationInfo)}get elevationRange(){let e=this.fullExtent;return e?.zmin&&e?.zmax?new q(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){let e=new q;this._visibleObjects.size===0?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this._forEachRelevantVisibleTile(t=>e.expandElevationRange(t.elevationRange)),e.minElevation===1/0&&e.setElevationRangeValues(0,0));let t=this._get(`visibleElevationRange`);return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange(`visibleElevationRange`)}_forEachRelevantVisibleTile(e){let{view:t}=this,{spatialReference:n}=t,r=n.isWGS84||n.isWebMercator||L(n)||oe(n)||se(n);if(this.view.state.isGlobal||!r)return this.forEachVisibleTile(e);let i=M(n).radius,{eye:a,viewForward:o,near:s}=t.state.contentCamera,c=E(A(),o),l=Math.max(a[2],500),u=l+i,d=Math.sqrt(u**2-i**2),f=Math.abs(Math.atan2(d,i))*i,p=l>.5*i?.5*Math.PI*i:f,m=A();this.forEachVisibleTile(t=>{let{mbsRadius:n,mbsCenter:r}=t;if(n<0)return;D(m,r,a);let i=O(m,c);Math.abs(i)<p&&i+n>s&&i-n<p&&e(t)})}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(let t of this._visibleObjects)e(t)}forEachTile(e){for(let t of this._loadedObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(let{componentObjects:n}of e)for(let e of n)t(e)}get drapeTargetType(){return has(`enable-feature:im-as-ground`)?+!this.usedAsGround:+!this.replacesTerrain}isUpdating(){let e=this._wasm;return!this.freeze&&this._wasmLayerId>=0&&e!=null&&e.isUpdating(this._wasmLayerId)}get readyToRun(){return!!this._frameTask?.readyToRun}runTask(e){this._frameTask.processQueue(e)}updatingFlagChanged(){this.notifyChange(`updating`)}async createRenderable(e){if(this.destroyed||this.destroying)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy`);let{entity3d:t}=e;if(!Se(t))throw Error(`entity3D not valid`);let n=new Map,r;try{r=this._createPrimitiveTextureBundles(t,n)}catch(e){throw n.forEach(e=>this._stage?.removeTexture(e)),e}let i=null;try{if(i=await this._createRenderableMain(t,r),this.destroyed)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderable aborted due to destroyed instance`);let{tileObb:a,componentObjects:o,elevationRange:s}=i,c=0,l=0,u=0;for(let e of o){let{texture:t,textureMetallicRoughness:n,textureEmissive:r,textureOcclusion:i,textureNormal:a}=e.renderable.drawParameters;c+=(t?.usedMemory??0)+(n?.usedMemory??0)+(r?.usedMemory??0)+(i?.usedMemory??0)+(a?.usedMemory??0),l+=this._collection.getObjectGPUMemoryUsage(e),u+=e.intersectionGeometry.usedMemory}let d=Array.from(n.values()),f=new et(e.handle,o,d,u,l,c,a,e.stableNodeId,e.nodeDepth,s);return this._lyrHandleToObjects.set(e.handle,f),()=>{this._memCache.put(U(f.handle),f);let{usedMemory:e}=f;return this._cacheMemory+=e,{memUsageBytes:e}}}catch(e){throw r.forEach(e=>e.cleanup()),i?.componentObjects.forEach(e=>this._collection.destroyObject(e)),n.forEach(e=>this._stage?.removeTexture(e)),e}}_createPrimitiveTextureBundles(e,t){let n=[];try{let r=e.desc.geometry;for(let i of e.validPrimitiveIndices){let a=r.prims[i].materialId,o=e.desc.materials?.materials&&a!=null&&a!==H?e.desc.materials.materials[a]:null,s=Promise.resolve(nt),c=null,l=null,u=null,d=null,f=null;if(o){let n=o.lightingModel===`Pbr`;c=this._getTexture(o.baseColorTex,e,t),l=n?this._getTexture(o.metalTex,e,t):null,u=n?this._getTexture(o.emissiveTex,e,t):null,d=n?this._getTexture(o.occlusionTex,e,t):null,f=n?this._getTexture(o.normalTex,e,t):null;let r=[c,l,u,d,f].map(e=>e?.loadPromise??null);s=Promise.all(r)}n.push(new rt(s,c,l,u,d,f))}}catch(e){throw n.forEach(e=>e.cleanup()),e}return n}async _createRenderableMain(e,t){if(this.destroyed||this.destroying)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderableMain called after destroy`);let n=[],r=e.desc,i=j(...e.origin),a=this.view.groundView.spatialReference,o=this.view.state.isGlobal,s=C;if(o){let e=w();ue(ce,i,e,a),s=b(S(),e)}let c=tt(r.obb),l=o?M(this.view.spatialReference).radius:0,u=[];try{let d=-1;for(let n of e.validPrimitiveIndices){d+=1;let i=r.geometry.prims[n],a=t[d];if(this._dbgFlags.has(2)&&this._dbg(2,JSON.stringify(i)),je[i.ptype]==null){this._dbg(2,`[Unsupported Feature] Unsupported primitive mode (`+i.ptype+`). Skipping primitive.`),a.cleanup();continue}let{positionView:o,normalsData:s,colorView:c,texCoord0Data:l,indicesView:f}=this._getBufferViews(i,e);if(o==null||f==null){a.cleanup();continue}let p=o.count,m=(e,t)=>e!=null&&e!==p?(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1):!0;!m(l==null?void 0:l.length/2,`numTexcoord`)||!m(c?.count,`numColors`)||!m(s?.length,`normals`)?a.cleanup():u.push({componentIndex:d,positionView:o,indicesView:f,texCoord0Data:l,colorView:c,normalsData:s})}let f=s!==C,p=f?x(S(),s)??C:C,{vertexProcessingOutputs:m,obbHalfSizeAccumulator:h,elevationRange:g}=await this._workerHandle.processTiles3DVertices(u,i,l,o,s,c,this._imVertexNormals&&!this.usedAsGround);if(this.destroyed)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance`);let _=r.materials;if(await Promise.all(t.map(e=>e.materialPromise)),this.destroyed)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance`);m.length>0&&c.setHalfSize(h);for(let o of m){let{componentIndex:s,positionView:l,indicesView:u,layout:d,textureCoordinateType:m,interleavedVertexData:h,indices:g}=o,v=e.validPrimitiveIndices[s],y=r.geometry.prims[v],b=t[s],x=c.clone(),S=Be(d),C=new Uint32Array([0,u.typedBuffer.length]),w=new He(S,this._imShading?2:0,m,f?2:0),T=new Ue({interleavedVertexData:h,vertexCount:h.byteLength/S[0].stride,indexData:g},{positions:l.typedBuffer,indices:u.typedBuffer},C,w),E=this.view.renderSpatialReference,D=A(),O=[1,1,1];de(i,E,O,a)||this._dbg(3,`Unsupported coordinate system for IM overlay`),fe(i,E,D,a);let k=this._createComponentMaterialInitParameters(_,y.materialId,b);k.baseColorTexture||this._dbg(3,`No colour texture 1`);let j=this._collection.createObject({toMapSpace:re(D[0],D[1],O[0],O[1]),transform:new We(i,p),obb:x,geometry:T,elevationAlignable:!1},k);n.push(j)}let{fullExtent:v}=this.layer;return v?.hasZ&&v.zmax&&v.zmin&&(g.minElevation=Math.max(g.minElevation,v.zmin),g.maxElevation=Math.min(g.maxElevation,v.zmax)),{tileObb:c,componentObjects:n,elevationRange:g}}catch(e){throw n.forEach(e=>this._collection.destroyObject(e)),e}}_createComponentMaterialInitParameters(e,t,n){let r=e?.materials!=null&&t!=null&&t!==H?e.materials[t]:null,i=1,a=r?.baseColorTex?.imageId;if(a!=null&&e&&Array.isArray(e.images)&&a>=0&&a<e.images.length){let t=e.images[a];t.alpha&&(i=Me[t.alpha])}let o=(r==null?`Unlit`:r.lightingModel)===`Pbr`,s=ae,c=X,l=!1,u=2,d=ne(0,0,0),f=ee(Je),p=n.baseColorTexture,m=n.metallicRoughnessTexture,h=n.emissionTexture,g=n.occlusionTexture,_=n.normalTexture;return r&&(s=ie(r.baseColorFactor),c=r.alphaCutoff??X,o&&(k(f,r.metallicFactor,r.roughnessFactor,0),r.emissiveFactor&&(d=r.emissiveFactor)),l=r.isDoubleSided,u=Ne[r.faceCulling??`NotSet`]),{isIntegratedMesh:!0,baseColor:s,textureAlphaCutoff:c,mrrFactors:f,baseColorTexture:p,metallicRoughnessTexture:m,normalTexture:_,occlusionTexture:g,emissionTexture:h,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:i,doubleSided:l,cullFace:u,isGround:has(`enable-feature:im-as-ground`)?this.usedAsGround:this.replacesTerrain,groundTransparencyMode:this._groundTransparencyMode,emissiveBaseColor:d,usePBR:o,slicePlaneEnabled:this.slicePlaneEnabled,opacity:this._renderOpacity,polygonOffset:0,ellipsoidMode:1,applySSAO:this._applySSAO}}freeRenderable(e){let t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._intersectionHandler.removeTile(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){let t=U(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,n){if(this.destroyed||this.destroying)return;let r=this._frustum,i=[],a=!1,o=!1;for(let s=0;s<n;++s){if(!t[s])continue;let n=e[s],c=this._lyrHandleToObjects.get(n);if(c){if(c.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${c.stableNodeId}`);continue}a=!0,c.isLoaded=!0,this._loadedObjects.add(c),this._intersectionHandler.addTile(c),this._usedMemory+=c.usedMemory,this._cacheMemory-=c.usedMemory;let e=c.obb?.intersectsFrustum(r)??!0;c.isVisible=e,e&&(this._visibleObjects.add(c),o||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,c.elevationRange)),i.push(c.obb),c.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(U(n))}else this._dbg(3,`Tried to mark Non existent object ${n} as loaded`)}for(let r=0;r<n;++r){let n=e[r];if(t[r])continue;let a=this._lyrHandleToObjects.get(n);if(a){if(!a.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${a.stableNodeId}`);continue}let e=a.isVisible;this._visibleObjects.delete(a),a.isVisible=!1,a.isLoaded=!1,this._loadedObjects.delete(a),this._intersectionHandler.removeTile(a),e&&(this._visibleGeometryChanged(),o||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,a.elevationRange)),this._usedMemory-=a.usedMemory,this._cacheMemory+=a.usedMemory,i.push(a.obb),a.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(U(n),a)}else this._dbg(3,`Tried to mark Non existent object ${n} as not loaded`)}a&&this._visibleGeometryChanged(),i.length>0&&this._elevationProvider.notifyObjectsChanged(i),o&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){let{visibleElevationRange:n}=this,{minElevation:r,maxElevation:i}=t;return e?r<n.minElevation||i>n.maxElevation:r===n.minElevation||i===n.maxElevation}_getTexture(e,t,n){let r=e&&t.desc.materials?.images?.[e.imageId];if(!r||!W(r.data))return null;let i=t.assets[r.data];if(!i||i.byteCount<1||i.dataType!==`U8`)return null;let a=n.get(r)??this._createTexture(e,r,i,n);return a?new Ge(this._stage.renderView.textures,a.id):null}_createTexture(e,n,r,i){let a=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,o=n.mipCount?!0:a>1,s=Pe[e.wrapMode??`None`],c=n.alpha?6408:6407,l=new Uint8Array(r.data.buffer,0,r.byteCount),u=null,d=null;switch(n.format){case`Raw`:if(n.pixelFormat===`R8`)u=l,c=6403,d=``;else if(n.pixelFormat===`Rg8`||n.pixelFormat===`Ga8`)u=l,c=33319,d=``;else if(n.pixelFormat===`Rgb8`)u=l,c=6407,d=``;else if(n.pixelFormat===`Rgba8`)u=l,c=6408,d=``;else return t.getLogger(this).error(`Raw texture pixel format ${n.pixelFormat} not supported`),null;break;case`Dxt1`:u=l,c=6407,d=`image/vnd-ms.dds`;break;case`Dxt5`:u=l,c=6408,d=`image/vnd-ms.dds`;break;case`Basis`:u=l,c=6407,d=`image/ktx2`;break;case`Etc1`:u=l,c=6407,d=`image/ktx`;break;default:return t.getLogger(this).error(`${n.format} texture not supported`),null}if(u&&d!=null){let e=Qe(c,d,n.format),t=new Ke(u,{mipmap:o,maxAnisotropy:a,encoding:d,wrap:s,pixelFormat:c,internalFormat:e??void 0,immutable:e!=null,noUnpackFlip:!0,width:n.mip0Width,height:n.mip0Height});return this._stage.addTexture(t),i.set(n,t),t}return null}_getBufferViews(e,t){let n,r,i,a;for(let o=0;o<e.atrbs.length;o++){let s=e.atrbs[o],c=t.assets[s.assetId];if(!c)continue;let l=c.data.buffer,u=c.byteCount;try{switch(s.sem){case`Position`:c.ncomp!==3||c.dataType!==`F32`||!p(c.data)?this._dbg(3,`[Unsupported Feature] Unsupported view for Position (`+c+`)`):n=new z(l,0,void 0,u);break;case`Normal`:if(c.ncomp!==3||c.dataType!==`F32`||!p(c.data))this._dbg(3,`[Unsupported Feature] Unsupported view for Normal (`+c+`)`);else{let e=new z(l,0,void 0,u);a=new Uint32Array(e.count),qe(e.typedBuffer,new Int16Array(a.buffer,a.byteOffset,a.length*2))}break;case`TexCoord`:c.ncomp!==2||c.dataType!==`F32`||!p(c.data)?this._dbg(3,`[Unsupported Feature] Unsupported view for Texcoord (`+c+`)`):i===void 0&&(i=new ye(l,0,void 0,u).typedBuffer);break;case`Color`:c.dataType===`U8`&&f(c.data)&&(c.ncomp===4?r=new _e(l,0,void 0,u):c.ncomp===3&&(r=new ve(l,0,void 0,u))),r??this._dbg(3,`[Unsupported Feature] Unsupported view for Color (`+c+`)`);break;case`FeatureIndex`:break;default:this._dbg(2,`[Unsupported Feature] Unsupported semantic (`+s.sem+`). Skipping vertex attribute.`)}}catch(e){this._dbg(2,`Error Creating buffer (`+e+`). Skipping vertex attribute.`)}}let o,s=!1;if(W(e.index)){let n=t.assets[e.index];if(!n)s=!0;else{let e=n.byteCount;switch(n.dataType){case`U16`:n.ncomp===1&&h(n.data)&&(o=new V(n.data.buffer,0,void 0,e));break;case`U32`:n.ncomp===1&&m(n.data)&&(o=new B(n.data.buffer,0,void 0,e))}s=!o}}if(!s&&o==null&&n!=null){let e=n.count;o=o=e<65535?new V(new Uint16Array(e).buffer):new B(new Uint32Array(e).buffer);for(let t=0;t<e;t++)o.set(t,t)}return{positionView:n,colorView:r,texCoord0Data:i,indicesView:o,normalsData:a}}_loadModifications(){if(this.removeHandles(`modifications`),this.layer.modifications==null){this._modifications=[];return}let e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.usedAsGround&&e.type!==`replace`)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info(`Ground layers only support replace modifications. Other modification types have been ignored.`)},s),`modifications`)}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,n){this._dbgFlags.has(e)&&(e===3?t.getLogger(this).error(n):t.getLogger(this).warn(n))}};e([v()],Q.prototype,`freeze`,void 0),e([v()],Q.prototype,`fullOpacity`,null),e([v()],Q.prototype,`opaque`,null),e([v()],Q.prototype,`invisible`,null),e([v({readOnly:!0})],Q.prototype,`ready`,null),e([v({type:[be]})],Q.prototype,`_modifications`,void 0),e([v()],Q.prototype,`_visibleGeometryChangedSchedulerHandle`,void 0),e([v()],Q.prototype,`layer`,void 0),e([v({readOnly:!0})],Q.prototype,`visibleAtCurrentScale`,null),e([v({readOnly:!0})],Q.prototype,`_collection`,null),e([v()],Q.prototype,`elevationOffset`,null),e([v({readOnly:!0})],Q.prototype,`visibleElevationRange`,null),e([v()],Q.prototype,`fullExtentInLocalViewSpatialReference`,void 0),Q=e([y(`esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D`)],Q);const $e=Q;class et{constructor(e,t,n,r,i,a,o,s,c,l){this.handle=e,this.componentObjects=t,this.textures=n,this.cpuMemoryUsage=r,this.vboMemoryUsage=i,this.textureMemoryUsage=a,this.obb=o,this.stableNodeId=s,this.nodeDepth=c,this.elevationRange=l,this.bvhIntersectionGeneration=0,this.isLoaded=!1,this.isVisible=!1;let u=A();o?.getCenter(u),this._obbCenterX=u[0],this._obbCenterY=u[1],this._obbCenterZ=u[2];let d=o?.radius??-1;this._obbRadius=d,this._obbRadiusSquared=d*d,this._obbShortestHalfsize=o?Math.min(o.halfSizeX,o.halfSizeY,o.halfSizeZ):0,this._mbsCenter=o?o.getCenter(A()):te}get usedMemory(){return this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this._mbsCenter}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;let{_obbCenterX:n,_obbCenterY:r,_obbCenterZ:i}=this,a=n-e[0],o=r-e[1],s=i-e[2],c=a*t[0]+o*t[1]+s*t[2];return a*a+o*o+s*s-c*c<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){let t=this._obbRadius;if(t<0)return!0;let n=e.center,r=e.radius,i=t+r,a=this._obbCenterX-n[0];if(a>i)return!1;let o=this._obbCenterY-n[1];if(o>i)return!1;let s=this._obbCenterZ-n[2];if(s>i)return!1;let c=a*a+o*o+s*s;if(c>i*i)return!1;if(c<=(this._obbShortestHalfsize+r)**2)return!0;let l=r-t;return l>0&&c<=l*l?!0:this.obb?.intersectSphere(e)??!0}}function $(e){return Math.round(e/1048.576)/1e3}function tt(e){return new ze(e.center,e.halfSize,T(...e.quaternion))}const nt=[];class rt{constructor(e,t,n,r,i,a){this.materialPromise=e,this.baseColorTexture=t,this.metallicRoughnessTexture=n,this.emissionTexture=r,this.occlusionTexture=i,this.normalTexture=a}cleanup(){this.baseColorTexture?.dispose(),this.metallicRoughnessTexture?.dispose(),this.emissionTexture?.dispose(),this.occlusionTexture?.dispose(),this.normalTexture?.dispose()}}export{$e as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{loadLyr3DWorkerWASM as e}from"../../../libs/lyr3d/Lyr3DModule.js";let t,n=null;async function r(e){await s();let t={status:1,error:``,jobDescJson:``,data:new Uint8Array,missingInputUrls:[]};if(e.inputs.length<1)return{result:t,transferList:[]};let r={ptrs:[],sizes:[]};for(let t of e.inputs){let e=n._malloc(t.byteLength);new Uint8Array(n.HEAPU8.buffer,e,t.byteLength).set(new Uint8Array(t)),r.ptrs.push(e),r.sizes.push(t.byteLength)}let i=n.process(e.jobDescJson,e.id,r,e.isMissingResourceCase);t.status=i.status,t.missingInputUrls=i.missingInputUrls.slice();let a=i.status===0&&i.data,o=t.status===2&&t.missingInputUrls.length>0;t.jobDescJson=i.jobDescJson.slice(),t.error=i.error.slice(),a?t.data=i.data.slice():o&&(t.originalInputs=e.inputs.slice());for(let e=0;e<r.ptrs.length;++e)n._free(r.ptrs[e]);let c=[];if(a)c.push(t.data.buffer);else if(o)for(let t of e.inputs)c.push(t);return{result:t,transferList:c}}async function i(e){await s(),n.add_spatial_reference_info(e.sr,e.isGCS,e.toMetersXY,e.toMetersZ)}function a(e){if(!n)return{success:!1,modifications:null};let t=n._malloc(e.modifications.length*8),r=new Float64Array(n.HEAPF64.buffer,t,e.modifications.length);r.set(e.modifications);let i=n.switch_mesh_modification_polygon_vcs(t,e.modifications.length,e.inVCS),a=null;return i&&(a=r.slice()),n._free(t),{success:i,modifications:a}}function o(){n&&=(n.uninitialize_lyr3d_worker_wasm(),null)}function s(){return c()?Promise.resolve():(t||=e().then(e=>{n=e,n.initialize_lyr3d_worker_wasm(),t=null}),t)}function c(){return n!==null}export{i as addSpatialReferenceInfo,o as destroyWasm,s as initialize,c as isInitialized,r as process,a as switchMeshModificationPolygonVCSSync};
2
+ import{loadLyr3DWorkerWASM as e}from"../../../libs/lyr3d/Lyr3DModule.js";let t,n=null;async function r(e){await s();let t={status:1,error:``,jobDescJson:``,data:new Uint8Array,missingInputs:[]};if(e.inputs.length<1)return{result:t,transferList:[]};let r={ptrs:[],sizes:[]};for(let t of e.inputs){let e=n._malloc(t.byteLength);new Uint8Array(n.HEAPU8.buffer,e,t.byteLength).set(new Uint8Array(t)),r.ptrs.push(e),r.sizes.push(t.byteLength)}let i=n.process(e.jobDescJson,e.id,r,e.isMissingResourceCase);t.status=i.status,t.missingInputs=i.missingInputs.slice();let a=i.status===0&&i.data,o=t.status===2&&t.missingInputs.length>0;t.jobDescJson=i.jobDescJson.slice(),t.error=i.error.slice(),a?t.data=i.data.slice():o&&(t.originalInputs=e.inputs.slice());for(let e=0;e<r.ptrs.length;++e)n._free(r.ptrs[e]);let c=[];if(a)c.push(t.data.buffer);else if(o)for(let t of e.inputs)c.push(t);return{result:t,transferList:c}}async function i(e){await s(),n.add_spatial_reference_info(e.sr,e.isGCS,e.toMetersXY,e.toMetersZ)}function a(e){if(!n)return{success:!1,modifications:null};let t=n._malloc(e.modifications.length*8),r=new Float64Array(n.HEAPF64.buffer,t,e.modifications.length);r.set(e.modifications);let i=n.switch_mesh_modification_polygon_vcs(t,e.modifications.length,e.inVCS),a=null;return i&&(a=r.slice()),n._free(t),{success:i,modifications:a}}function o(){n&&=(n.uninitialize_lyr3d_worker_wasm(),null)}function s(){return c()?Promise.resolve():(t||=e().then(e=>{n=e,n.initialize_lyr3d_worker_wasm(),t=null}),t)}function c(){return n!==null}export{i as addSpatialReferenceInfo,o as destroyWasm,s as initialize,c as isInitialized,r as process,a as switchMeshModificationPolygonVCSSync};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{copy as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as n,add as r,subtract as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as a,ZEROS as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as s}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as c}from"../../../../geometry/projection/projectBuffer.js";import{BufferViewVec3f as l}from"../../../../geometry/support/buffer/BufferView.js";import{SampleElevationInfo as u,updateBufferPointGroundDistance as d,computePointTransformation as f,applyBufferPointTransformation as p}from"./elevationAlignmentUtils.js";import{debugFlags as m}from"../../support/debugFlags.js";import{SamplePosition as h}from"../../support/ElevationProvider.js";import{updateObjectVertexField as g,updateVertexFieldVec3f as _}from"../../webgl-engine/lib/bufferGeometryUtils.js";import{isGeometryWithMapPositions as v}from"../../webgl-engine/lib/GeometryWithMapPositions.js";function y(e,t,n,r,i){let a=e.stageObject,o=a.geometries,s=0;for(let e of o){if(!v(e))continue;let{update:o,averageGeometrySampledElevation:c}=N(e,t,n,r,i);s+=c,o&&a.geometryVertexAttributeUpdated(e,`position`)}return s/o.length}function b(t,r,i,a,o,c){let l=t.stageObject,u=r.centerInElevationSR;a(u,M);let d=r.requiresSampledElevationInfo?M.sampledElevation:0,f=e(C,c??l.transformation),p=n(j,f[12],f[13],f[14]);m.ENABLE_OPTIMIZATIONS?o.setAltitudeOfTransformation(M.z,f):(D[0]=u[0],D[1]=u[1],D[2]=M.z,s(i,D,f,o.spatialReference)&&(c?e(c,f):l.transformation=f));let h=E/o.unitInMeters;return(Math.abs(f[12]-p[0])>=h||Math.abs(f[13]-p[1])>=h||Math.abs(f[14]-p[2])>=h)&&(c?e(c,f):l.transformation=f),d}function x(e,t,n,r,i){return S(e,t,n,r,i,o)}function S(e,t,a,o,s,c){let u=t.centerInElevationSR;if(o(u,M),d(e,M.verticalDistanceToGround),m.ENABLE_OPTIMIZATIONS){let t=E/s.unitInMeters;for(let n of e.geometries){let a=n.buffers.vertex.getField(`position`,l),o=n.localOrigin.vec3;a.getVec(0,k),r(D,k,o),i(D,D,c),s.setAltitude(D,M.z),r(D,D,c),i(D,D,o),(Math.abs(D[0]-k[0])>=t||Math.abs(D[1]-k[1])>=t||Math.abs(D[2]-k[2])>=t)&&g(e,_,n,`position`,0,D)}}else n(D,u[0],u[1],M.z),f(D,a,s,C)&&(C[12]+=c[0],C[13]+=c[1],C[14]+=c[2],p(e,C));return M.sampledElevation}const C=t();function w(e,t,r,i,a){let o=e.graphics3DSymbolLayer.lodRenderer;if(o==null)return 0;let c=t.centerInElevationSR;i(c,M);let l=t.mode===`absolute-height`?0:M.sampledElevation,u=o.instanceData,d=e.instanceIndex,f=A;u.getGlobalTransform(d,f);let p=n(j,f[12],f[13],f[14]);m.ENABLE_OPTIMIZATIONS?a.setAltitudeOfTransformation(M.z,f):(D[0]=c[0],D[1]=c[1],D[2]=M.z,s(r,D,f,a.spatialReference)&&u.setGlobalTransform(d,f));let h=E/a.unitInMeters;return(!m.ENABLE_OPTIMIZATIONS||Math.abs(f[12]-p[0])>=h||Math.abs(f[13]-p[1])>=h||Math.abs(f[14]-p[2])>=h)&&u.setGlobalTransform(d,f),l}function T(e,t,n,r,i){let a=e.stageObject,o=a.geometries;if(o.length===0)return 0;let s=0,c=null,l=0,u=!1;for(let e of o){if(!v(e))continue;let o=e.attributes.get(`position`);if(o!==c){let{update:a,averageGeometrySampledElevation:s}=N(e,t,n,r,i);l=s,c=o,u=a}u&&a.geometryVertexAttributeUpdated(e,`position`),s+=l}return s/o.length}const E=.01,D=a(),O=a(),k=a(),A=t(),j=a(),M=new u;function N(e,t,n,r,i){let a=!1,o=e.transformation,s=t.requiresSampledElevationInfo;O[0]=o[12],O[1]=o[13],O[2]=o[14],e.invalidateBoundingInfo();let l=e.getMutableAttribute(`position`),u=l.data,d=l.size,f=u.length/d,p=new h(e.mapPositions,n),g=0,_=0;for(let e=0;e<f;e++){if(k[0]=u[g],k[1]=u[g+1],k[2]=u[g+2],r(p,M),s&&(_+=M.sampledElevation),m.ENABLE_OPTIMIZATIONS){D[0]=u[g]+O[0],D[1]=u[g+1]+O[1],D[2]=u[g+2]+O[2],i.setAltitude(D,M.z),u[g]=D[0]-O[0],u[g+1]=D[1]-O[1],u[g+2]=D[2]-O[2];let e=E/i.unitInMeters;(Math.abs(k[0]-u[g])>=e||Math.abs(k[1]-u[g+1])>=e||Math.abs(k[2]-u[g+2])>=e)&&(a=!0)}else u[g]=p.array[p.offset],u[g+1]=p.array[p.offset+1],u[g+2]=M.z,c(u,n,g,u,i.spatialReference,g,1),u[g]-=O[0],u[g+1]-=O[1],u[g+2]-=O[2],a=!0;g+=d,p.offset+=3}return _/=f,{update:a,averageGeometrySampledElevation:_}}export{x as perBufferPointElevationAligner,w as perLodInstanceElevationAligner,b as perObjectElevationAligner,S as perTranslatedBufferPointElevationAligner,y as perVertexElevationAligner,T as sharedGeometryElevationAligner};
2
+ import{copy as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as n,add as r,subtract as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as a,ZEROS as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as s}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as c}from"../../../../geometry/projection/projectBuffer.js";import{BufferViewVec3f as l}from"../../../../geometry/support/buffer/BufferView.js";import{SampleElevationInfo as u,updateBufferPointGroundDistance as d,computePointTransformation as f,applyBufferPointTransformation as p}from"./elevationAlignmentUtils.js";import{debugFlags as m}from"../../support/debugFlags.js";import{SamplePosition as h}from"../../support/ElevationProvider.js";import{updateVertexFieldVec3f as g,updateObjectVertexField as _}from"../../webgl-engine/lib/bufferGeometryUtils.js";import{isGeometryWithMapPositions as v}from"../../webgl-engine/lib/GeometryWithMapPositions.js";function y(e,t,n,r,i){let a=e.stageObject,o=a.geometries,s=0;for(let e of o){if(!v(e))continue;let{update:o,averageGeometrySampledElevation:c}=P(e,t,n,r,i);s+=c,o&&a.geometryVertexAttributeUpdated(e,`position`)}return s/o.length}function b(e,t,a,o,s){let u=t.requiresSampledElevationInfo,{geometries:d}=e,f=D/s.unitInMeters,p=0;if(d.length===0)return 0;for(let t of d){let d=t.buffers.vertex.getField(`position`,l);if(t.mapPositions==null||d.count===0)continue;let _=t.localOrigin.vec3,v=new h(t.mapPositions,a),y=0,b=!1;for(let e=0;e<d.count;e++,v.offset+=3)o(v,N),u&&(y+=N.sampledElevation),d.getVec(e,A),m.ENABLE_OPTIMIZATIONS?(r(O,A,_),s.setAltitude(O,N.z)):(n(O,v.array[v.offset],v.array[v.offset+1],N.z),c(O,a,0,O,s.spatialReference,0,1)),i(O,O,_),(!m.ENABLE_OPTIMIZATIONS||F(A,O[0],O[1],O[2],f))&&(b=g(t,`position`,e,O)||b);b&&e.geometryVertexAttributeUpdated(t,`position`),p+=y/d.count}return p/d.length}function x(t,r,i,a,o,c){let l=t.stageObject,u=r.centerInElevationSR;a(u,N);let d=r.requiresSampledElevationInfo?N.sampledElevation:0,f=e(w,c??l.transformation),p=n(M,f[12],f[13],f[14]);m.ENABLE_OPTIMIZATIONS?o.setAltitudeOfTransformation(N.z,f):(O[0]=u[0],O[1]=u[1],O[2]=N.z,s(i,O,f,o.spatialReference)&&(c?e(c,f):l.transformation=f));let h=D/o.unitInMeters;return F(p,f[12],f[13],f[14],h)&&(c?e(c,f):l.transformation=f),d}function S(e,t,n,r,i){return C(e,t,n,r,i,o)}function C(e,t,a,o,s,c){let u=t.centerInElevationSR;if(o(u,N),d(e,N.verticalDistanceToGround),m.ENABLE_OPTIMIZATIONS){let t=D/s.unitInMeters;for(let n of e.geometries){let a=n.buffers.vertex.getField(`position`,l),o=n.localOrigin.vec3;a.getVec(0,A),r(O,A,o),i(O,O,c),s.setAltitude(O,N.z),r(O,O,c),i(O,O,o),F(A,O[0],O[1],O[2],t)&&_(e,g,n,`position`,0,O)}}else n(O,u[0],u[1],N.z),f(O,a,s,w)&&(w[12]+=c[0],w[13]+=c[1],w[14]+=c[2],p(e,w));return N.sampledElevation}const w=t();function T(e,t,r,i,a){let o=e.graphics3DSymbolLayer.lodRenderer;if(o==null)return 0;let c=t.centerInElevationSR;i(c,N);let l=t.mode===`absolute-height`?0:N.sampledElevation,u=o.instanceData,d=e.instanceIndex,f=j;u.getGlobalTransform(d,f);let p=n(M,f[12],f[13],f[14]);m.ENABLE_OPTIMIZATIONS?a.setAltitudeOfTransformation(N.z,f):(O[0]=c[0],O[1]=c[1],O[2]=N.z,s(r,O,f,a.spatialReference)&&u.setGlobalTransform(d,f));let h=D/a.unitInMeters;return(!m.ENABLE_OPTIMIZATIONS||F(p,f[12],f[13],f[14],h))&&u.setGlobalTransform(d,f),l}function E(e,t,n,r,i){let a=e.stageObject,o=a.geometries;if(o.length===0)return 0;let s=0,c=null,l=0,u=!1;for(let e of o){if(!v(e))continue;let o=e.attributes.get(`position`);if(o!==c){let{update:a,averageGeometrySampledElevation:s}=P(e,t,n,r,i);l=s,c=o,u=a}u&&a.geometryVertexAttributeUpdated(e,`position`),s+=l}return s/o.length}const D=.01,O=a(),k=a(),A=a(),j=t(),M=a(),N=new u;function P(e,t,n,r,i){let a=!1,o=e.transformation,s=t.requiresSampledElevationInfo;k[0]=o[12],k[1]=o[13],k[2]=o[14],e.invalidateBoundingInfo();let l=e.getMutableAttribute(`position`),u=l.data,d=l.size,f=u.length/d,p=new h(e.mapPositions,n),g=0,_=0;for(let e=0;e<f;e++){if(A[0]=u[g],A[1]=u[g+1],A[2]=u[g+2],r(p,N),s&&(_+=N.sampledElevation),m.ENABLE_OPTIMIZATIONS){O[0]=u[g]+k[0],O[1]=u[g+1]+k[1],O[2]=u[g+2]+k[2],i.setAltitude(O,N.z),u[g]=O[0]-k[0],u[g+1]=O[1]-k[1],u[g+2]=O[2]-k[2];let e=D/i.unitInMeters;F(A,u[g],u[g+1],u[g+2],e)&&(a=!0)}else u[g]=p.array[p.offset],u[g+1]=p.array[p.offset+1],u[g+2]=N.z,c(u,n,g,u,i.spatialReference,g,1),u[g]-=k[0],u[g+1]-=k[1],u[g+2]-=k[2],a=!0;g+=d,p.offset+=3}return _/=f,{update:a,averageGeometrySampledElevation:_}}function F(e,t,n,r,i){return Math.abs(e[0]-t)>=i||Math.abs(e[1]-n)>=i||Math.abs(e[2]-r)>=i}export{S as perBufferPointElevationAligner,b as perBufferVertexElevationAligner,T as perLodInstanceElevationAligner,x as perObjectElevationAligner,C as perTranslatedBufferPointElevationAligner,y as perVertexElevationAligner,E as sharedGeometryElevationAligner};