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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (433) hide show
  1. package/Graphic.d.ts +47 -14
  2. package/PopupTemplate.js +1 -1
  3. package/WebScene.d.ts +3 -0
  4. package/analysis/LineOfSightAnalysis.d.ts +1 -1
  5. package/analysis/LineOfSightAnalysisObserver.d.ts +5 -4
  6. package/analysis/LineOfSightAnalysisTarget.d.ts +4 -4
  7. package/analysis/Viewshed.d.ts +4 -4
  8. package/arcade/functions/string.js +1 -1
  9. package/arcgisGlobal.d.ts +0 -5
  10. package/assets/esri/core/workers/RemoteClient.js +1 -1
  11. package/assets/esri/core/workers/chunks/{3c277a0f099d67090d07.js → 02335385b1476fe322eb.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{db9921fbda556f142c4a.js → 04d55ed51e8b2683c4b4.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{435b90168f79c5587a07.js → 04ecf15524ff3838c01c.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{e2f42aec02bff33b25dd.js → 09300e74e5b014ce6269.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{fcb86d24fc7e0666b564.js → 096b2bf1c0d69d27f20c.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{612345f17f5eeb99ea8f.js → 0d9c4c6c571ce26d356b.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{0f725cf79ce00e790a7d.js → 1168bc5c9f0a7e1f63a2.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{4911ce62421a6c3320b0.js → 13c64087be3b2985a21b.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{8e19629899a5becf8e19.js → 150e7a7bd5df25693da7.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{12a7997a40c77f5c9160.js → 151e5799ede763a03ee2.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{a64446a3328a7323e307.js → 173f89c55a5c79ff065b.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{8715661a838361d4211a.js → 1b24a40c0fa197014873.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{ca0d4ce453d8eb35467d.js → 277263466837e1673f56.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{b1d989b72203113a06fe.js → 2a36fe3f3f257a779a1b.js} +1 -1
  25. package/assets/esri/core/workers/chunks/2c0cb214fedb29487eef.js +1 -0
  26. package/assets/esri/core/workers/chunks/{ffcb99693182a621a93e.js → 2cf8172be83b10b11bdc.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{fcaf9450642fcef83286.js → 3048e74e6246324ce6fc.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{95b82cbbe355266c65d7.js → 30af63b3b750142faadb.js} +1 -1
  29. package/assets/esri/core/workers/chunks/30dcf2cfb31cb70de7df.js +1 -0
  30. package/assets/esri/core/workers/chunks/{9f0a973a0dd28953ce25.js → 371e2ddb88cc6b9a41e8.js} +1 -1
  31. package/assets/esri/core/workers/chunks/3fd5c3cd8457ddc68798.js +1 -0
  32. package/assets/esri/core/workers/chunks/{62fec1816907f070f079.js → 3fe04f13215474accb09.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{f47fe4433b05fca5c3ad.js → 42f6194633c2d879c8da.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{cddc3e285f763ccf33c2.js → 4869e097261ded90b8bb.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{d8a7eba588d374b2f961.js → 4bb9a5f4ca944d3fc206.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{2e096537a3a5555a4a93.js → 4cb751dc8d00bdaeb04c.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{8052da8be251c3ff2176.js → 4d93bed14945e3d34d5c.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{65cb5e39c467a35621ca.js → 56e903ccef66cbe18f92.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{44d5508042cacdfcac47.js → 58da3f8cf0f7f6a7e4fa.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{bc915fb182d463d804e6.js → 5c04835b0b52461183cd.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{7e8611cb709f105946f5.js → 6061232c96e11eb7b25d.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{1e514e1c9aabefa04201.js → 64382363d6dc04ff1eac.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{c82daefb193aae895bc0.js → 67e06d606c7fd2064adf.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{434a8ba841a59e0deab9.js → 67e533748435253aaba6.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{feb41abc03d677df6f73.js → 6b9961261241fdce0e94.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{949bee7b304e625a7891.js → 6db0f8fe1402643fbe1a.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{baed828b7846c0863289.js → 6f1d6453184e0a1530ad.js} +22 -18
  48. package/assets/esri/core/workers/chunks/6f897b4e7ddd1dd1672b.js +1 -0
  49. package/assets/esri/core/workers/chunks/{0049b66ccbfb168caa76.js → 7124ad8dc5ad40dc66f3.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{6e107ce73633de8ac257.js → 72f4dad65e16a7d7c58f.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{0df9a906f7823c23d426.js → 7566321c6a2913f2852b.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{c4ddac23bd649d24f3f2.js → 75d551a449bba61ce238.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{af349c7bc8ef41a0e1bd.js → 7748c2886d0122b40eeb.js} +1 -1
  54. package/assets/esri/core/workers/chunks/{b4c3ec081874b49ff89b.js → 78fbe330f16bdbdb886e.js} +1 -1
  55. package/assets/esri/core/workers/chunks/79483c05867ba1386f5a.js +1 -0
  56. package/assets/esri/core/workers/chunks/7b482afb9fd1229f5707.js +1 -0
  57. package/assets/esri/core/workers/chunks/7c631e2947243e2c9bde.js +1 -0
  58. package/assets/esri/core/workers/chunks/{814751e705c05099f864.js → 7c75a8ee266c36baa902.js} +1 -1
  59. package/assets/esri/core/workers/chunks/7db9e615e60d824eac1b.js +1 -0
  60. package/assets/esri/core/workers/chunks/{8a7b02037151767542f1.js → 7dbf4c7480bf9c72820d.js} +1 -1
  61. package/assets/esri/core/workers/chunks/{1b1d3f6916d2cb751435.js → 87177e0f82e8a6ae3189.js} +1 -1
  62. package/assets/esri/core/workers/chunks/{5cb26bbaa08114aec5ce.js → 89cc1a5539b82fb46216.js} +1 -1
  63. package/assets/esri/core/workers/chunks/8b5dcc4282772bf6b675.js +1 -0
  64. package/assets/esri/core/workers/chunks/{8c12269d26f5a4c753cb.js → 8ebaf5754e86a45b0497.js} +1 -1
  65. package/assets/esri/core/workers/chunks/{542e5640ea1b80ef801a.js → 9189dfe19a2a2ccd5173.js} +1 -1
  66. package/assets/esri/core/workers/chunks/{67a35155b8b4d36f171e.js → 926e0a3827eaf16ca8b4.js} +1 -1
  67. package/assets/esri/core/workers/chunks/{dc1761cba0454fda3cf9.js → 9630234267098115de4d.js} +1 -1
  68. package/assets/esri/core/workers/chunks/{10d80e793019dfb45ca2.js → 987424121cf30b0f3c50.js} +1 -1
  69. package/assets/esri/core/workers/chunks/9afc87474cef1fc4fe4a.js +1 -0
  70. package/assets/esri/core/workers/chunks/{facd1ff23203fed67686.js → 9b048f80c2d28d527373.js} +1 -1
  71. package/assets/esri/core/workers/chunks/9dd48e75b4e8d9811d81.js +1 -0
  72. package/assets/esri/core/workers/chunks/{ee08ae5b73439a1ff666.js → a163c6005aba3378edaa.js} +1 -1
  73. package/assets/esri/core/workers/chunks/a4b822ee45810c4c292a.js +1 -0
  74. package/assets/esri/core/workers/chunks/{092e311cb7aea92a6a26.js → acb265a22be5e12f38e5.js} +1 -1
  75. package/assets/esri/core/workers/chunks/{1a411ddae7a47015370c.js → acf4737ba509cbd73cce.js} +1 -1
  76. package/assets/esri/core/workers/chunks/ad96132bc89671e595f3.js +1 -0
  77. package/assets/esri/core/workers/chunks/{d247dd53788d512b9c9f.js → af3c6794334626b94f00.js} +1 -1
  78. package/assets/esri/core/workers/chunks/{532e9cda8ac3601d8892.js → b12acf1f694f82e00df9.js} +1 -1
  79. package/assets/esri/core/workers/chunks/{d08ff41e2a9bcd58b64a.js → ba3d5abff65aefcb8dee.js} +1 -1
  80. package/assets/esri/core/workers/chunks/{504184828048310a052c.js → bdc221d94300c225665a.js} +1 -1
  81. package/assets/esri/core/workers/chunks/c0eb27263f608dc3684b.js +1 -0
  82. package/assets/esri/core/workers/chunks/c2318c014e97ba519be8.js +1 -0
  83. package/assets/esri/core/workers/chunks/{7f8e327acad48c9e75ea.js → c62237c344e341619341.js} +1 -1
  84. package/assets/esri/core/workers/chunks/{a2ad3e620c98e2b2eb06.js → cd355baab983033c3ef0.js} +1 -1
  85. package/assets/esri/core/workers/chunks/{7be6d621a0d1e33dfff4.js → d070fcb73ce274ab80e4.js} +1 -1
  86. package/assets/esri/core/workers/chunks/{6d41444b46677aa762a7.js → db41490bd39d863305bf.js} +1 -1
  87. package/assets/esri/core/workers/chunks/{fc5a36e54929e03efa86.js → dba5f44c4e4a3f075df2.js} +1 -1
  88. package/assets/esri/core/workers/chunks/{3e30b96a8c75bd5b9ae2.js → ddc95cdac6c06fc4794c.js} +1 -1
  89. package/assets/esri/core/workers/chunks/{a5c8f9f5be4ef5063b42.js → df26ec0b508cf4716e0a.js} +1 -1
  90. package/assets/esri/core/workers/chunks/{f426da2210888cc264b4.js → e83f9abee611c5b80009.js} +1 -1
  91. package/assets/esri/core/workers/chunks/{8487727f1197cf7dbf50.js → ef12fa3574d4cbf8b084.js} +1 -1
  92. package/assets/esri/core/workers/chunks/f10c883eb26330e3421c.js +1 -0
  93. package/assets/esri/core/workers/chunks/f46e92c67986c8c09bdd.js +1 -0
  94. package/assets/esri/core/workers/chunks/{709e019885822b1f6f3e.js → f905f1a1aa4c123cbe83.js} +1 -1
  95. package/assets/esri/core/workers/chunks/{5b91e2dffdc84c006539.js → fb37f0848196c28b7fd7.js} +1 -1
  96. package/assets/esri/libs/librust-parquet/pkg/parquet_bg.wasm +0 -0
  97. package/assets/esri/libs/librust-text/pkg/text_bg.wasm +0 -0
  98. package/assets/esri/themes/base/_core.scss +0 -2
  99. package/assets/esri/themes/dark/main.css +1 -1
  100. package/assets/esri/themes/light/main.css +1 -1
  101. package/assets/esri/themes/light/view.css +1 -1
  102. package/chunks/Component.glsl.js +9 -12
  103. package/chunks/DefaultMaterial.glsl.js +4 -5
  104. package/chunks/MultiPathImpl.js +1 -1
  105. package/chunks/OperatorProximityGeodesic.js +1 -1
  106. package/chunks/Path.glsl.js +2 -4
  107. package/chunks/RealisticTree.glsl.js +3 -3
  108. package/chunks/SSAO.glsl.js +1 -2
  109. package/chunks/basis_encoder.js +1 -1
  110. package/chunks/basis_transcoder.js +1 -1
  111. package/chunks/draco_mesh_decoder.js +1 -1
  112. package/chunks/dxt_encoder.js +1 -1
  113. package/chunks/i3s.js +1 -1
  114. package/chunks/lclayout.js +1 -1
  115. package/chunks/lerc-wasm.js +1 -1
  116. package/chunks/libtess-f32.js +1 -1
  117. package/chunks/libtess-f64.js +1 -1
  118. package/chunks/lyr3DMain.js +1 -1
  119. package/chunks/lyr3DWorker.js +1 -1
  120. package/chunks/parquet.js +1 -1
  121. package/chunks/qb3-wasm.js +1 -1
  122. package/chunks/rbush.js +1 -1
  123. package/chunks/text.js +1 -1
  124. package/chunks/vxlLayer.js +1 -1
  125. package/config.js +1 -1
  126. package/core/workers/WorkerFallback.js +4 -2
  127. package/core/workers/workerFactory.js +1 -1
  128. package/core/workers/workers.js +4 -2
  129. package/geometry/support/clipRay.js +1 -1
  130. package/geometry/support/labelPoint.js +1 -1
  131. package/geometry/support/plane.js +1 -1
  132. package/graphic/AnnotationFeatureGraphicOrigin.d.ts +49 -9
  133. package/graphic/BuildingGraphicOrigin.d.ts +49 -0
  134. package/graphic/CSVGraphicOrigin.d.ts +42 -9
  135. package/graphic/CatalogGraphicOrigin.d.ts +42 -9
  136. package/graphic/DimensionFeatureGraphicOrigin.d.ts +42 -9
  137. package/graphic/FeatureGraphicOrigin.d.ts +42 -9
  138. package/graphic/GeoJSONGraphicOrigin.d.ts +42 -9
  139. package/graphic/GeoRSSGraphicOrigin.d.ts +42 -9
  140. package/graphic/GraphicOrigin.d.ts +52 -12
  141. package/graphic/ImageryGraphicOrigin.d.ts +42 -9
  142. package/graphic/ImageryTileGraphicOrigin.d.ts +42 -9
  143. package/graphic/KMLGraphicOrigin.d.ts +47 -10
  144. package/graphic/KnowledgeGraphGraphicOrigin.d.ts +49 -1
  145. package/graphic/LinkChartGraphicOrigin.d.ts +49 -1
  146. package/graphic/MapImageGraphicOrigin.d.ts +49 -1
  147. package/graphic/MapNotesGraphicOrigin.d.ts +48 -1
  148. package/graphic/OGCFeatureGraphicOrigin.d.ts +42 -9
  149. package/graphic/OrientedImageryGraphicOrigin.d.ts +42 -9
  150. package/graphic/ParquetGraphicOrigin.d.ts +42 -9
  151. package/graphic/PointCloudGraphicOrigin.d.ts +43 -0
  152. package/graphic/SceneGraphicOrigin.d.ts +43 -0
  153. package/graphic/SketchGraphicOrigin.d.ts +43 -0
  154. package/graphic/StreamGraphicOrigin.d.ts +43 -0
  155. package/graphic/SubtypeGroupGraphicOrigin.d.ts +49 -1
  156. package/graphic/TileGraphicOrigin.d.ts +49 -1
  157. package/graphic/VectorTileGraphicOrigin.d.ts +43 -14
  158. package/graphic/VoxelGraphicOrigin.d.ts +43 -0
  159. package/graphic/WCSGraphicOrigin.d.ts +43 -0
  160. package/graphic/WFSGraphicOrigin.d.ts +42 -9
  161. package/graphic/getGraphicOriginTitle.d.ts +21 -3
  162. package/interfaces.d.ts +0 -55
  163. package/kernel.js +1 -1
  164. package/layers/ElevationLayer.d.ts +6 -2
  165. package/layers/GaussianSplatLayer.d.ts +2 -1
  166. package/layers/GeoJSONLayer.d.ts +2 -107
  167. package/layers/IntegratedMeshLayer.js +1 -1
  168. package/layers/ParquetLayer.d.ts +24 -1
  169. package/layers/ParquetLayer.js +1 -1
  170. package/layers/SceneLayer.d.ts +40 -16
  171. package/layers/ViewshedLayer.d.ts +10 -4
  172. package/layers/WMSLayer.d.ts +2 -69
  173. package/layers/mixins/ReloadableLayer.js +1 -1
  174. package/layers/mixins/TemporalLayer.d.ts +70 -48
  175. package/layers/mixins/TiledImagery.d.ts +0 -11
  176. package/layers/orientedImagery/transformations/utils.js +1 -1
  177. package/layers/save/featureLayerUtils.js +1 -1
  178. package/layers/save/imageryUtils.js +1 -1
  179. package/layers/save/mapImageLayerUtils.js +1 -1
  180. package/layers/save/mediaLayerUtils.js +1 -1
  181. package/layers/save/parquetLayerUtils.js +2 -0
  182. package/layers/save/streamLayerUtils.js +1 -1
  183. package/layers/support/LabelClass.d.ts +8 -2
  184. package/layers/support/layersMapping.js +1 -1
  185. package/layers/support/rasterJobHelper.js +1 -1
  186. package/layers/video/VideoController.js +5 -5
  187. package/package.json +2 -2
  188. package/popup/content.d.ts +38 -1
  189. package/popup/content.js +1 -1
  190. package/portal/schemas/definitions.js +1 -1
  191. package/portal/schemas/webScene.js +1 -1
  192. package/rest/query/operations/pbfDehydratedFeatureSet.js +1 -1
  193. package/rest/query/operations/pbfFlatFeatureSet.js +1 -1
  194. package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
  195. package/smartMapping/popup/support/clusterUtils.js +1 -1
  196. package/smartMapping/popup/support/utils.js +2 -2
  197. package/smartMapping/renderers/size.js +1 -1
  198. package/smartMapping/renderers/support/regenerateUtils.js +1 -1
  199. package/support/timeUtils.d.ts +11 -0
  200. package/undoredo/support/ApplySet.js +1 -1
  201. package/views/2d/engine/flow/ProcessingTimeEstimate.js +1 -1
  202. package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
  203. package/views/2d/engine/vectorTiles/buckets/SymbolBucket.js +1 -1
  204. package/views/2d/engine/webgl/GlyphWorker.js +1 -1
  205. package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
  206. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
  207. package/views/2d/layers/features/Processor.js +1 -1
  208. package/views/2d/layers/features/aggregation/GeohashSpatialIndex.js +1 -1
  209. package/views/2d/layers/features/aggregation/GridSpatialIndex.js +1 -1
  210. package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
  211. package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
  212. package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
  213. package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
  214. package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
  215. package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
  216. package/views/2d/layers/features/layerAdapters/ParquetLayerAdapter.js +1 -1
  217. package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +1 -1
  218. package/views/2d/layers/features/processor/AggregateStrategy.js +1 -1
  219. package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
  220. package/views/2d/layers/features/processor/bins/BinAdapter.js +1 -1
  221. package/views/2d/layers/features/processor/bins/BinLevelState.js +1 -1
  222. package/views/2d/layers/features/processor/clusters/ClusterAdapter.js +1 -1
  223. package/views/2d/layers/features/processor/clusters/ClusterLevelState.js +1 -1
  224. package/views/2d/layers/features/processor/tracks/TrackAdapter.js +1 -1
  225. package/views/2d/layers/features/processor/tracks/TrackLevelState.js +1 -1
  226. package/views/2d/layers/features/schema/processor/SimpleProcessorSchema.js +1 -1
  227. package/views/2d/layers/features/sources/strategies/chunks/ASourceChunk.js +1 -1
  228. package/views/2d/layers/features/sources/strategies/chunks/ByReferenceTileSourceChunk.js +1 -1
  229. package/views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js +1 -1
  230. package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +1 -1
  231. package/views/2d/layers/features/sources/strategies/chunks/ParquetSnapshotSourceChunk.js +1 -1
  232. package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
  233. package/views/2d/layers/features/sources/strategies/chunks/StreamSourceChunk.js +1 -1
  234. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  235. package/views/2d/layers/features/support/FeatureFilterEvaluator.js +1 -1
  236. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  237. package/views/2d/layers/features/support/GraphicsReader.js +1 -1
  238. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  239. package/views/3d/environment/SunLighting.d.ts +0 -1
  240. package/views/3d/environment/SunLighting.js +1 -1
  241. package/views/3d/environment/VirtualLighting.d.ts +0 -1
  242. package/views/3d/environment/VirtualLighting.js +1 -1
  243. package/views/3d/input/handlers/ground/GroundDoubleClickMove.js +1 -1
  244. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  245. package/views/3d/interactive/placementTools/GroundNavigationPlacementTool3D.js +1 -1
  246. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  247. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  248. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  249. package/views/3d/layers/graphics/ElevationAligners.js +1 -1
  250. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  251. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  252. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  253. package/views/3d/layers/graphics/LabelParameters.js +1 -1
  254. package/views/3d/layers/graphics/Labeler.js +1 -1
  255. package/views/3d/layers/graphics/elevationAlignmentUtils.js +1 -1
  256. package/views/3d/layers/graphics/pointUtils.js +1 -1
  257. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  258. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  259. package/views/3d/layers/support/Tiles3DBVH.js +1 -1
  260. package/views/3d/layers/support/featureTileQuery3D.js +1 -1
  261. package/views/3d/state/controllers/ZoomControllerLocal.js +1 -1
  262. package/views/3d/state/controllers/ZoomStepControllerLocal.js +1 -1
  263. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  264. package/views/3d/state/utils/groundNavigationUtils.js +1 -1
  265. package/views/3d/state/utils/navigationUtils.js +1 -1
  266. package/views/3d/terrain/TerrainRenderer.js +1 -1
  267. package/views/3d/terrain/TerrainSurface.js +1 -1
  268. package/views/3d/webgl-engine/collections/Component/Material/Component.glsl.js +1 -1
  269. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUD.glsl.js +1 -2
  270. package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceRayMarching.glsl.js +1 -2
  271. package/views/3d/webgl-engine/effects/glow/applyEmissiveGlow.glsl.js +9 -4
  272. package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
  273. package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowCastRenderer.js +1 -1
  274. package/views/3d/webgl-engine/effects/snowcover/applySnow.glsl.js +18 -0
  275. package/views/3d/webgl-engine/lib/Intersector.js +1 -1
  276. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  277. package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
  278. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  279. package/views/3d/webgl-engine/lib/screenPolygonTriangleIntersections.js +1 -1
  280. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  281. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  282. package/views/3d/webgl-engine/materials/Path.glsl.js +1 -1
  283. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  284. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  285. package/views/3d/webgl-engine/materials/TriangleMaterial.js +1 -1
  286. package/views/3d/webgl-engine/materials/internal/worldSizedRibbonLineIntersectionUtils.js +2 -0
  287. package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
  288. package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
  289. package/views/DOMContainer.js +1 -1
  290. package/views/draw/SegmentDrawAction.js +1 -1
  291. package/views/interactive/snapping/SnappingManagerPool.js +1 -1
  292. package/views/interactive/tooltip/content/TooltipContent.js +1 -1
  293. package/views/interactive/tooltip/fields/TooltipField.js +1 -1
  294. package/views/layers/LineOfSightLayerView.d.ts +2 -2
  295. package/views/layers/ViewshedLayerView.d.ts +2 -1
  296. package/views/support/LayerViewManager.js +1 -1
  297. package/views/support/ScheduledQueueProcessor.js +1 -1
  298. package/views/support/screenshotUtils.js +1 -1
  299. package/views/ui/UI.js +1 -1
  300. package/webdoc/support/webdocSaveUtils.js +1 -1
  301. package/webscene/Slide.d.ts +1 -2
  302. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  303. package/widgets/Feature/FeatureExpression/FeatureExpressionViewModel.js +1 -1
  304. package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
  305. package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
  306. package/widgets/FeatureTable/RelationshipColumn.js +1 -1
  307. package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
  308. package/widgets/Locate.d.ts +1 -1
  309. package/widgets/OrientedImageryViewer/ImageMeasurementWorker.js +1 -1
  310. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  311. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  312. package/widgets/OrientedImageryViewer/services/ImageMeasurementService.js +1 -1
  313. package/widgets/Search/SearchViewModel.js +1 -1
  314. package/widgets/Search/support/layerSearchUtils.js +1 -1
  315. package/widgets/Sketch/SketchViewModel.js +1 -1
  316. package/widgets/Sketch/support/PluginManager.js +1 -1
  317. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceFeature.js +1 -1
  318. package/widgets/support/GeolocationPositioning.d.ts +1 -2
  319. package/assets/esri/core/workers/chunks/14d5d219e7fe017f23f0.js +0 -1
  320. package/assets/esri/core/workers/chunks/42045cf46497828cd3c0.js +0 -1
  321. package/assets/esri/core/workers/chunks/42753cf4965a94bc91ca.js +0 -1
  322. package/assets/esri/core/workers/chunks/42e985a576d7aaeed0cf.js +0 -1
  323. package/assets/esri/core/workers/chunks/5046214dd32029cb733d.js +0 -1
  324. package/assets/esri/core/workers/chunks/576248e9ae2654569420.js +0 -1
  325. package/assets/esri/core/workers/chunks/58865772bed48141a56a.js +0 -1
  326. package/assets/esri/core/workers/chunks/6059853ef3b6cddbe869.js +0 -1
  327. package/assets/esri/core/workers/chunks/72e6d594b7262430ae55.js +0 -1
  328. package/assets/esri/core/workers/chunks/7d11710e1586a3d75887.js +0 -1
  329. package/assets/esri/core/workers/chunks/8f74d92ac69714b9fd4e.js +0 -1
  330. package/assets/esri/core/workers/chunks/a09d2e1e2540921e4717.js +0 -1
  331. package/assets/esri/core/workers/chunks/a35c69a4751d28c39907.js +0 -1
  332. package/assets/esri/core/workers/chunks/a679207c3458cc0b1fec.js +0 -1
  333. package/assets/esri/core/workers/chunks/dfa5f1311806473e473f.js +0 -1
  334. package/assets/esri/core/workers/chunks/fc76aff0f7d95e517d8f.js +0 -1
  335. package/assets/esri/themes/base/widgets/_DirectionalPad.scss +0 -85
  336. package/assets/esri/widgets/DirectionalPad/t9n/messages.ar.json +0 -1
  337. package/assets/esri/widgets/DirectionalPad/t9n/messages.bg.json +0 -1
  338. package/assets/esri/widgets/DirectionalPad/t9n/messages.bs.json +0 -1
  339. package/assets/esri/widgets/DirectionalPad/t9n/messages.ca.json +0 -1
  340. package/assets/esri/widgets/DirectionalPad/t9n/messages.cs.json +0 -1
  341. package/assets/esri/widgets/DirectionalPad/t9n/messages.da.json +0 -1
  342. package/assets/esri/widgets/DirectionalPad/t9n/messages.de.json +0 -1
  343. package/assets/esri/widgets/DirectionalPad/t9n/messages.el.json +0 -1
  344. package/assets/esri/widgets/DirectionalPad/t9n/messages.en.json +0 -1
  345. package/assets/esri/widgets/DirectionalPad/t9n/messages.es.json +0 -1
  346. package/assets/esri/widgets/DirectionalPad/t9n/messages.et.json +0 -1
  347. package/assets/esri/widgets/DirectionalPad/t9n/messages.fi.json +0 -1
  348. package/assets/esri/widgets/DirectionalPad/t9n/messages.fr.json +0 -1
  349. package/assets/esri/widgets/DirectionalPad/t9n/messages.he.json +0 -1
  350. package/assets/esri/widgets/DirectionalPad/t9n/messages.hr.json +0 -1
  351. package/assets/esri/widgets/DirectionalPad/t9n/messages.hu.json +0 -1
  352. package/assets/esri/widgets/DirectionalPad/t9n/messages.id.json +0 -1
  353. package/assets/esri/widgets/DirectionalPad/t9n/messages.it.json +0 -1
  354. package/assets/esri/widgets/DirectionalPad/t9n/messages.ja.json +0 -1
  355. package/assets/esri/widgets/DirectionalPad/t9n/messages.ko.json +0 -1
  356. package/assets/esri/widgets/DirectionalPad/t9n/messages.lt.json +0 -1
  357. package/assets/esri/widgets/DirectionalPad/t9n/messages.lv.json +0 -1
  358. package/assets/esri/widgets/DirectionalPad/t9n/messages.nl.json +0 -1
  359. package/assets/esri/widgets/DirectionalPad/t9n/messages.no.json +0 -1
  360. package/assets/esri/widgets/DirectionalPad/t9n/messages.pl.json +0 -1
  361. package/assets/esri/widgets/DirectionalPad/t9n/messages.pt-BR.json +0 -1
  362. package/assets/esri/widgets/DirectionalPad/t9n/messages.pt-PT.json +0 -1
  363. package/assets/esri/widgets/DirectionalPad/t9n/messages.ro.json +0 -1
  364. package/assets/esri/widgets/DirectionalPad/t9n/messages.ru.json +0 -1
  365. package/assets/esri/widgets/DirectionalPad/t9n/messages.sk.json +0 -1
  366. package/assets/esri/widgets/DirectionalPad/t9n/messages.sl.json +0 -1
  367. package/assets/esri/widgets/DirectionalPad/t9n/messages.sr.json +0 -1
  368. package/assets/esri/widgets/DirectionalPad/t9n/messages.sv.json +0 -1
  369. package/assets/esri/widgets/DirectionalPad/t9n/messages.th.json +0 -1
  370. package/assets/esri/widgets/DirectionalPad/t9n/messages.tr.json +0 -1
  371. package/assets/esri/widgets/DirectionalPad/t9n/messages.uk.json +0 -1
  372. package/assets/esri/widgets/DirectionalPad/t9n/messages.vi.json +0 -1
  373. package/assets/esri/widgets/DirectionalPad/t9n/messages.zh-CN.json +0 -1
  374. package/assets/esri/widgets/DirectionalPad/t9n/messages.zh-HK.json +0 -1
  375. package/assets/esri/widgets/DirectionalPad/t9n/messages.zh-TW.json +0 -1
  376. package/assets/esri/widgets/Track/t9n/messages.ar.json +0 -1
  377. package/assets/esri/widgets/Track/t9n/messages.bg.json +0 -1
  378. package/assets/esri/widgets/Track/t9n/messages.bs.json +0 -1
  379. package/assets/esri/widgets/Track/t9n/messages.ca.json +0 -1
  380. package/assets/esri/widgets/Track/t9n/messages.cs.json +0 -1
  381. package/assets/esri/widgets/Track/t9n/messages.da.json +0 -1
  382. package/assets/esri/widgets/Track/t9n/messages.de.json +0 -1
  383. package/assets/esri/widgets/Track/t9n/messages.el.json +0 -1
  384. package/assets/esri/widgets/Track/t9n/messages.en.json +0 -1
  385. package/assets/esri/widgets/Track/t9n/messages.es.json +0 -1
  386. package/assets/esri/widgets/Track/t9n/messages.et.json +0 -1
  387. package/assets/esri/widgets/Track/t9n/messages.fi.json +0 -1
  388. package/assets/esri/widgets/Track/t9n/messages.fr.json +0 -1
  389. package/assets/esri/widgets/Track/t9n/messages.he.json +0 -1
  390. package/assets/esri/widgets/Track/t9n/messages.hr.json +0 -1
  391. package/assets/esri/widgets/Track/t9n/messages.hu.json +0 -1
  392. package/assets/esri/widgets/Track/t9n/messages.id.json +0 -1
  393. package/assets/esri/widgets/Track/t9n/messages.it.json +0 -1
  394. package/assets/esri/widgets/Track/t9n/messages.ja.json +0 -1
  395. package/assets/esri/widgets/Track/t9n/messages.ko.json +0 -1
  396. package/assets/esri/widgets/Track/t9n/messages.lt.json +0 -1
  397. package/assets/esri/widgets/Track/t9n/messages.lv.json +0 -1
  398. package/assets/esri/widgets/Track/t9n/messages.nl.json +0 -1
  399. package/assets/esri/widgets/Track/t9n/messages.no.json +0 -1
  400. package/assets/esri/widgets/Track/t9n/messages.pl.json +0 -1
  401. package/assets/esri/widgets/Track/t9n/messages.pt-BR.json +0 -1
  402. package/assets/esri/widgets/Track/t9n/messages.pt-PT.json +0 -1
  403. package/assets/esri/widgets/Track/t9n/messages.ro.json +0 -1
  404. package/assets/esri/widgets/Track/t9n/messages.ru.json +0 -1
  405. package/assets/esri/widgets/Track/t9n/messages.sk.json +0 -1
  406. package/assets/esri/widgets/Track/t9n/messages.sl.json +0 -1
  407. package/assets/esri/widgets/Track/t9n/messages.sr.json +0 -1
  408. package/assets/esri/widgets/Track/t9n/messages.sv.json +0 -1
  409. package/assets/esri/widgets/Track/t9n/messages.th.json +0 -1
  410. package/assets/esri/widgets/Track/t9n/messages.tr.json +0 -1
  411. package/assets/esri/widgets/Track/t9n/messages.uk.json +0 -1
  412. package/assets/esri/widgets/Track/t9n/messages.vi.json +0 -1
  413. package/assets/esri/widgets/Track/t9n/messages.zh-CN.json +0 -1
  414. package/assets/esri/widgets/Track/t9n/messages.zh-HK.json +0 -1
  415. package/assets/esri/widgets/Track/t9n/messages.zh-TW.json +0 -1
  416. package/views/2d/layers/features/FeatureSpatialIndex.js +0 -2
  417. package/views/2d/layers/features/support/FeatureSetReaderIndirect.js +0 -2
  418. package/views/3d/webgl-engine/effects/snowcover/SnowCover.glsl.js +0 -12
  419. package/widgets/DirectionalPad/DirectionalPadViewModel.d.ts +0 -85
  420. package/widgets/DirectionalPad/DirectionalPadViewModel.js +0 -2
  421. package/widgets/DirectionalPad/VisibleElements.d.ts +0 -40
  422. package/widgets/DirectionalPad/VisibleElements.js +0 -2
  423. package/widgets/DirectionalPad/constants.js +0 -2
  424. package/widgets/DirectionalPad/css.js +0 -2
  425. package/widgets/DirectionalPad/types.d.ts +0 -27
  426. package/widgets/DirectionalPad/utils.js +0 -2
  427. package/widgets/DirectionalPad.d.ts +0 -156
  428. package/widgets/DirectionalPad.js +0 -2
  429. package/widgets/Track/TrackViewModel.d.ts +0 -131
  430. package/widgets/Track/TrackViewModel.js +0 -2
  431. package/widgets/Track/types.d.ts +0 -6
  432. package/widgets/Track.d.ts +0 -278
  433. package/widgets/Track.js +0 -2
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import e from"../../../../core/Logger.js";import{createScreenPointArray as t}from"../../../../core/screenUtils.js";import{distance as n,normalize as r,cross as i,add as a,crossAndNormalize as o,subtract as s,dot as c,scaleAndAdd as l,scale as u,copy as d,length as f}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as m}from"../../../../geometry/ellipsoidUtils.js";import{fromValues as h}from"../../../../geometry/support/lineSegment.js";import{create as g,fromPositionAndNormal as _,distance as v,projectPoint as y,projectVector as b,intersectLineSegment as x}from"../../../../geometry/support/plane.js";import{create as S}from"../../../../geometry/support/ray.js";import{Sphere as C}from"../../../../geometry/support/sphere.js";import{fromRenderCamera as w}from"../../webgl.js";import{getVoxelWasm as T}from"../../layers/VoxelWasm.js";import{pickPointAndInitSphere as E,sphereOrPlanePointFromScreenPoint as D,intersectPlaneFromScreenPoint as O,searchAreaSize as k}from"./navigationUtils.js";import{OffsetCorrectionController as ee}from"./OffsetCorrectionController.js";import{fromScreenAtEye as te}from"../../support/geometryUtils/ray.js";import ne from"../../webgl/RenderCamera.js";import{Intersector as A}from"../../webgl-engine/lib/Intersector.js";const j=1.5,M={xSpeedMultiplier:j,ySpeedMultiplier:j,maxElevation:1e4,relativeHorizonPadding:.1,minimumHorizonPadding:12},N=p(),P=p(),re=t(),F=p(),I=g(),L=p(),R=p(),z=p(),B=p(),V=p(),ie=p(),H=p(),U=p(),W=p(),G=p(),K=t(),q=S(),J=new C,Y=p(),ae=g(),X=p(),oe=p();function se(e,t){return b(t,e.viewForward,N),a(P,e.eye,N),e.projectToScreen(P,re),re[1]}function ce(e,t,d){let f=e.eye;if(n(t.center,f)<t.radius)return r(V,f),i(ie,V,e.viewRight),a(P,f,ie),e.projectToScreen(P,K),K[1];let p=e.up;te(e,d,q);let m=t.radius;if(o(F,p,q.direction),_(f,F,I),v(I,t.center)>m)return null;y(I,t.center,L);let h=n(t.center,L),g=Math.sqrt(m**2-h**2);s(R,f,L),r(z,R),o(B,F,z);let b=c(R,z),x=c(R,B),S=Math.sqrt(b**2+x**2),C=Math.sqrt(S**2-g**2),w=g**2/S**2,T=g/S**2*C,E=w*b,D=T*-x,O=w*x,k=T*b,ee=E+D,ne=E-D,A=O+k,j=O-k;return a(H,L,l(H,u(H,z,ee),B,A)),a(U,L,l(U,u(U,z,ne),B,j)),s(W,H,f),r(W,W),s(G,U,f),r(G,G),c(e.viewForward,W)>=c(e.viewForward,G)?e.projectToScreen(H,K):e.projectToScreen(U,K),K[1]}function le(e,t,n=!0){return n?e<t:e<=t}function Z(e,t,n=!0){return n?e>t:e>=t}function ue(e,t,n){return t?e>n:e<n}function Q(e,t){let n=e.fullHeight/e.pixelRatio,r=Math.max(t,n-t);return Math.max(M.minimumHorizonPadding,M.relativeHorizonPadding*r)}function de(e,t){return[fe(e,t),pe(e,t)]}function fe(e,t){let n=e.fullHeight/e.pixelRatio;return Math.min(n,t+Q(e,t))}function pe(e,t){return Math.max(0,t-Q(e,t))}function me(e,t,n){let r={translation:e,location:t};return n&&(r.normal=n),r}function he(e){let{view:t}=e;return t.viewingMode===`global`?ge(e):_e(e)}function ge(e){let{view:t,originalScreenPoint:i,horizonY:a,horizonPadding:o,outTranslation:s,outGrabLocation:c,outGrabNormal:l,intersectionOptions:u,depthSearchSize:f}=e,p=t.state.camera,h=me(s,c,l);J.radius=m(t.spatialReference).radius;let g=E(t,p,i,J.radius,1,u);if(g.scenePickPoint==null)return!1;let _=g.hasGeometryIntersection;d(Y,g.scenePickPoint),d(h.location,Y);let v=g.sphere;h.normal&&g.normal&&d(h.normal,g.normal);let y=ye(i,a,o,_),b=_?n(Y,p.eye):1/0;return y.wasAdjusted&&be({view:t,screenAdjustment:y,intersector:$(t),fallbackCheck:(e,t,n)=>{let i=D(v,p,e,t);return i&&n&&r(n,t),i},output:h,intersectionOptions:u}),Se({view:t,screenPoint:y.adjustedScreenPoint,camera:p,initialDistance:b,depthSearchSize:f??k,output:h}),!0}function _e(e){let{view:t,originalScreenPoint:i,horizonY:a,horizonPadding:o,outTranslation:s,outGrabLocation:c,outGrabNormal:u,intersectionOptions:f,depthSearchSize:p}=e,m=t.sceneIntersectionHelper,h=t.state.camera,g=$(t),v=me(s,c,u);m.intersectIntersectorScreen(i,g,f);let y=g.results.min.getIntersectionPoint(Y),b=y?n(Y,h.eye):1/0;y&&(d(v.location,Y),v.normal&&d(v.normal,g.results.min.normal)),t.renderCoordsHelper.worldUpAtPosition(h.eye,V),l(X,h.eye,V,-h.relativeElevation),_(X,V,ae);let x=ye(i,a,o,y);return x.wasAdjusted&&be({view:t,screenAdjustment:x,intersector:g,fallbackCheck:(e,t,n)=>{let i=O(ae,h,e,t);return i&&n&&r(n,V),i},output:v,intersectionOptions:f}),Se({view:t,screenPoint:x.adjustedScreenPoint,camera:h,initialDistance:b,depthSearchSize:p??k,output:v}),!0}function ve(e,t,n,r){return!r&&le(e,t)||r&&ue(e,!1,n[0])?n[0]:!r&&Z(e,t,!1)?n[1]:null}function ye(e,n,r,i){let a=ve(e[1],n,r,i);return{originalScreenPoint:e,adjustedScreenPoint:t(e[0],a??e[1]),horizonY:n,horizonPadding:r,wasAdjusted:a!==null}}function $(e){let t=new A(e.state.viewingMode);return t.options.selectionMode=!0,t.options.store=0,t.options.hud=!1,t.options.normalRequired=!0,t}function be(e){let{view:t,screenAdjustment:n,fallbackCheck:r,intersector:i,output:a,intersectionOptions:o}=e,s=t.sceneIntersectionHelper;s.intersectIntersectorScreen(n.adjustedScreenPoint,i,{...o,requiresGroundFeedback:!0});let c=i.results.min.getIntersectionPoint(a.location);if(c){a.normal&&d(a.normal,i.results.min.normal);return}let l=xe(n);s.intersectIntersectorScreen(l,i,{...o,requiresGroundFeedback:!0}),c=i.results.min.getIntersectionPoint(a.location),c?a.normal&&d(a.normal,i.results.min.normal):(c=r(n.adjustedScreenPoint,a.location,a.normal),!c&&r(l,a.location,a.normal))}function xe(e){let{originalScreenPoint:n,adjustedScreenPoint:r,horizonY:i,horizonPadding:a}=e,o=Z(r[1],i)?Math.min(a[1],n[1]):Math.max(a[0],n[1]);return t(r[0],o)}function Se(e){Ce(e),we(e)}function Ce(e){let{view:t,camera:n,output:r}=e,{offset:i}=t.navigation.mode;if(!i)return;let{translation:a,location:o}=r;t.renderCoordsHelper.worldUpAtPosition(n.eye,V),l(X,n.eye,V,-i),_(X,V,I),x(I,h(n.eye,s(N,o,n.eye)),X)&&(d(o,X),s(a,o,n.eye))}function we(e){let{view:t,screenPoint:n,camera:i,initialDistance:o,depthSearchSize:c,output:l}=e,d=c>0?t.stage.renderView.getMinimalDepthForArea(T(t),n[0],n[1],i,c):null;s(l.translation,l.location,i.eye);let p=Math.min(f(l.translation),o);d&&d<=p&&(p=d),r(l.translation,l.translation),u(l.translation,l.translation,p),a(l.location,l.translation,i.eye)}async function Te(t,r){if(t.navigation.mode.type!==`ground`){e.getLogger(`esri`).warn(`Can only advance while in ground navigation mode!`);return}let{camera:i}=t.state;t.renderCoordsHelper.worldUpAtPosition(i.eye,V);let c=t.sceneIntersectionHelper,l=$(t),p=o(N,V,i.viewRight);d(q.origin,i.eye),u(q.direction,p,r);let m=c.intersectRay(q,l,Y),h=new ne().copyFrom(i),g=s(oe,i.center,i.eye);return!m||n(Y,i.eye)>r?h.eye=a(N,q.origin,q.direction):(s(N,Y,i.eye),f(N)>2&&(Ee(N,N,.25,2),h.eye=a(N,i.eye,N))),h.center=a(N,h.eye,g),new ee(t).immediatelyCorrectGroundElevation({camera:h,correctionLimit:100}),t.goTo(w(t,h),{duration:500,liftOffDisabled:!0})}function Ee(e,t,n,r){let i=f(e),a=Math.min(n,Math.max(i-r,0)/i);u(t,e,a)}export{Q as computeHorizonPadding,de as computeHorizonPaddingLimits,he as findGroundNavigationGrabLocation,se as findPlaneHorizonY,ce as findSphereHorizonY,Te as groundNavigationAdvance,M as groundNavigationConstants,le as isAboveHorizon,Z as isBelowHorizon,Ee as shortenTranslation,ue as shouldClampScreenY};
2
+ import e from"../../../../core/Logger.js";import{createScreenPointArray as t}from"../../../../core/screenUtils.js";import{distance as n,normalize as r,cross as i,add as a,crossAndNormalize as o,subtract as s,dot as c,scaleAndAdd as l,scale as u,copy as d,length as f}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as m}from"../../../../geometry/ellipsoidUtils.js";import{fromValues as h}from"../../../../geometry/support/lineSegment.js";import{create as g,fromPositionAndNormal as _,distance as v,projectPoint as y,projectVector as b,intersectLineSegment as x}from"../../../../geometry/support/plane.js";import{create as S}from"../../../../geometry/support/ray.js";import{Sphere as C}from"../../../../geometry/support/sphere.js";import{fromRenderCamera as w}from"../../webgl.js";import{getVoxelWasm as T}from"../../layers/VoxelWasm.js";import{pickPointAndInitSphere as E,sphereOrPlanePointFromScreenPoint as D,intersectPlaneFromScreenPoint as O,searchAreaSize as k}from"./navigationUtils.js";import{OffsetCorrectionController as ee}from"./OffsetCorrectionController.js";import{fromScreenAtEye as te}from"../../support/geometryUtils/ray.js";import ne from"../../webgl/RenderCamera.js";import{Intersector as A}from"../../webgl-engine/lib/Intersector.js";const j=1.5,M={xSpeedMultiplier:j,ySpeedMultiplier:j,maxElevation:1e4,relativeHorizonPadding:.1,minimumHorizonPadding:12},N=p(),P=p(),re=t(),F=p(),I=g(),L=p(),R=p(),z=p(),B=p(),V=p(),ie=p(),H=p(),U=p(),W=p(),G=p(),K=t(),q=S(),J=new C,Y=p(),ae=g(),X=p(),oe=p();function se(e,t){return b(t,e.viewForward,N),a(P,e.eye,N),e.projectToScreen(P,re),re[1]}function ce(e,t,d){let f=e.eye;if(n(t.center,f)<t.radius)return r(V,f),i(ie,V,e.viewRight),a(P,f,ie),e.projectToScreen(P,K),K[1];let p=e.up;te(e,d,q);let m=t.radius;if(o(F,p,q.direction),_(f,F,I),v(I,t.center)>m)return null;y(I,t.center,L);let h=n(t.center,L),g=Math.sqrt(m**2-h**2);s(R,f,L),r(z,R),o(B,F,z);let b=c(R,z),x=c(R,B),S=Math.sqrt(b**2+x**2),C=Math.sqrt(S**2-g**2),w=g**2/S**2,T=g/S**2*C,E=w*b,D=T*-x,O=w*x,k=T*b,ee=E+D,ne=E-D,A=O+k,j=O-k;return a(H,L,l(H,u(H,z,ee),B,A)),a(U,L,l(U,u(U,z,ne),B,j)),s(W,H,f),r(W,W),s(G,U,f),r(G,G),c(e.viewForward,W)>=c(e.viewForward,G)?e.projectToScreen(H,K):e.projectToScreen(U,K),K[1]}function le(e,t,n=!0){return n?e<t:e<=t}function Z(e,t,n=!0){return n?e>t:e>=t}function ue(e,t,n){return t?e>n:e<n}function Q(e,t){let n=e.fullHeight/e.pixelRatio,r=Math.max(t,n-t);return Math.max(M.minimumHorizonPadding,M.relativeHorizonPadding*r)}function de(e,t){return[fe(e,t),pe(e,t)]}function fe(e,t){let n=e.fullHeight/e.pixelRatio;return Math.min(n,t+Q(e,t))}function pe(e,t){return Math.max(0,t-Q(e,t))}function me(e,t,n){let r={translation:e,location:t};return n&&(r.normal=n),r}function he(e){let{view:t}=e;return t.viewingMode===`global`?ge(e):_e(e)}function ge(e){let{view:t,originalScreenPoint:i,horizonY:a,horizonPadding:o,outTranslation:s,outGrabLocation:c,outGrabNormal:l,intersectionOptions:u,depthSearchSize:f}=e,p=t.state.camera,h=me(s,c,l);J.radius=m(t.spatialReference).radius;let g=E(t,p,i,J.radius,1,u);if(g.scenePickPoint==null)return!1;let _=g.hasGeometryIntersection;d(Y,g.scenePickPoint),d(h.location,Y);let v=g.sphere;h.normal&&g.normal&&d(h.normal,g.normal);let y=ye(i,a,o,_),b=_?n(Y,p.eye):1/0;return y.wasAdjusted&&be({view:t,screenAdjustment:y,intersector:$(t),fallbackCheck:(e,t,n)=>{let i=D(v,p,e,t);return i&&n&&r(n,t),i},output:h,intersectionOptions:u}),Se({view:t,screenPoint:y.adjustedScreenPoint,camera:p,initialDistance:b,depthSearchSize:f??k,output:h}),!0}function _e(e){let{view:t,originalScreenPoint:i,horizonY:a,horizonPadding:o,outTranslation:s,outGrabLocation:c,outGrabNormal:u,intersectionOptions:f,depthSearchSize:p}=e,m=t.sceneIntersectionHelper,h=t.state.camera,g=$(t),v=me(s,c,u);m.intersectIntersectorScreen(i,g,f);let y=g.results.min.getIntersectionPoint(Y),b=y?n(Y,h.eye):1/0;y&&(d(v.location,Y),v.normal&&d(v.normal,g.results.min.normal)),t.renderCoordsHelper.worldUpAtPosition(h.eye,V),l(X,h.eye,V,-h.relativeElevation),_(X,V,ae);let x=ye(i,a,o,y);return x.wasAdjusted&&be({view:t,screenAdjustment:x,intersector:g,fallbackCheck:(e,t,n)=>{let i=O(ae,h,e,t);return i&&n&&r(n,V),i},output:v,intersectionOptions:f}),Se({view:t,screenPoint:x.adjustedScreenPoint,camera:h,initialDistance:b,depthSearchSize:p??k,output:v}),!0}function ve(e,t,n,r){return!r&&le(e,t)||r&&ue(e,!1,n[0])?n[0]:!r&&Z(e,t,!1)?n[1]:null}function ye(e,n,r,i){let a=ve(e[1],n,r,i);return{originalScreenPoint:e,adjustedScreenPoint:t(e[0],a??e[1]),horizonY:n,horizonPadding:r,wasAdjusted:a!==null}}function $(e){let t=new A(e.state.viewingMode);return t.options.selectionMode=!0,t.options.store=0,t.options.hud=!1,t.options.normalRequired=!0,t}function be(e){let{view:t,screenAdjustment:n,fallbackCheck:r,intersector:i,output:a,intersectionOptions:o}=e,s=t.sceneIntersectionHelper;s.intersectIntersectorScreen(n.adjustedScreenPoint,i,{...o,requiresGroundFeedback:!0});let c=i.results.min.getIntersectionPoint(a.location);if(c){a.normal&&d(a.normal,i.results.min.normal);return}let l=xe(n);s.intersectIntersectorScreen(l,i,{...o,requiresGroundFeedback:!0}),c=i.results.min.getIntersectionPoint(a.location),c?a.normal&&d(a.normal,i.results.min.normal):(c=r(n.adjustedScreenPoint,a.location,a.normal),c||r(l,a.location,a.normal))}function xe(e){let{originalScreenPoint:n,adjustedScreenPoint:r,horizonY:i,horizonPadding:a}=e,o=Z(r[1],i)?Math.min(a[1],n[1]):Math.max(a[0],n[1]);return t(r[0],o)}function Se(e){Ce(e),we(e)}function Ce(e){let{view:t,camera:n,output:r}=e,{offset:i}=t.navigation.mode;if(!i)return;let{translation:a,location:o}=r;t.renderCoordsHelper.worldUpAtPosition(n.eye,V),l(X,n.eye,V,-i),_(X,V,I),x(I,h(n.eye,s(N,o,n.eye)),X)&&(d(o,X),s(a,o,n.eye))}function we(e){let{view:t,screenPoint:n,camera:i,initialDistance:o,depthSearchSize:c,output:l}=e,d=c>0?t.stage.renderView.getMinimalDepthForArea(T(t),n[0],n[1],i,c):null;s(l.translation,l.location,i.eye);let p=Math.min(f(l.translation),o);d&&d<=p&&(p=d),r(l.translation,l.translation),u(l.translation,l.translation,p),a(l.location,l.translation,i.eye)}async function Te(t,r){let i=t.navigation.mode;if(i.type!==`ground`){e.getLogger(`esri`).warn(`Can only advance while in ground navigation mode!`);return}let{camera:c}=t.state;t.renderCoordsHelper.worldUpAtPosition(c.eye,V);let l=t.sceneIntersectionHelper,p=$(t),m=o(N,V,c.viewRight);d(q.origin,c.eye),u(q.direction,m,r);let h=l.intersectRay(q,p,Y,{include:i.include,exclude:i.exclude}),g=new ne().copyFrom(c),_=s(oe,c.center,c.eye);return!h||n(Y,c.eye)>r?g.eye=a(N,q.origin,q.direction):(s(N,Y,c.eye),f(N)>2&&(Ee(N,N,.25,2),g.eye=a(N,c.eye,N))),g.center=a(N,g.eye,_),new ee(t).immediatelyCorrectGroundElevation({camera:g,correctionLimit:100}),t.goTo(w(t,g),{duration:500,liftOffDisabled:!0})}function Ee(e,t,n,r){let i=f(e),a=Math.min(n,Math.max(i-r,0)/i);u(t,e,a)}export{Q as computeHorizonPadding,de as computeHorizonPaddingLimits,he as findGroundNavigationGrabLocation,se as findPlaneHorizonY,ce as findSphereHorizonY,Te as groundNavigationAdvance,M as groundNavigationConstants,le as isAboveHorizon,Z as isBelowHorizon,Ee as shortenTranslation,ue as shouldClampScreenY};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{cyclicalPI as e}from"../../../../core/Cyclical.js";import{deg2rad as t,clamp as n,acosClamped as r,asinClamped as i}from"../../../../core/mathUtils.js";import{createScreenPointArray as a}from"../../../../core/screenUtils.js";import{fromRotation as o,exactEquals as s,multiply as c,rotate as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as u,create as d}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as f}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{exactEquals as ee,length as m,dot as h,subtract as g,normalize as _,squaredDistance as v,copy as y,transformMat4 as b,add as x,distance as te,cross as S,scale as C,lerp as ne,set as re}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{clone as ie,create as w}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as ae,axis as oe,fromPoints as se,wrapAxisAngle as ce}from"../../../../geometry/support/axisAngle.js";import{coordinateSystemFromOneAxisAndNormalVector as le,vectorCoordinates as ue}from"../../../../geometry/support/coordinateSystem.js";import{create as de,fromNormalAndOffset as fe,intersectRay as T}from"../../../../geometry/support/plane.js";import{Sphere as pe}from"../../../../geometry/support/sphere.js";import{sm4d as me,sv3d as E}from"../../../../geometry/support/vectorStacks.js";import{fromScreenAtEye as D,fromScreen as he}from"../../support/geometryUtils/ray.js";import{intersectScreen as ge}from"../../support/geometryUtils/sphere.js";import _e from"../../webgl/RenderCamera.js";import{Intersector as ve}from"../../webgl-engine/lib/Intersector.js";import{terrainId as ye}from"../../webgl-engine/lib/verticalOffsetUtils.js";const be=30,xe=[1,3e8],Se=8,Ce=[200,1508e5],we=5,Te=50,Ee=5,De=10,Oe=90,O=1e-6,ke={exclude:new Set([ye])};function Ae(e,t,n){return n[0]=t[0]/(e.fullWidth/e.pixelRatio),n[1]=t[1]/(e.fullHeight/e.pixelRatio),n}function je(e){for(;e>Math.PI;)e-=2*Math.PI;for(;e<-Math.PI;)e+=2*Math.PI;return e}function k(e,t,n){let r=o(me.get(),n[3],oe(n));r==null||s(r,u)||(g(Y,e.eye,t),b(Y,Y,r),e.eye=x(Y,Y,t),g(Y,e.center,t),b(Y,Y,r),e.center=x(Y,Y,t),e.up=b(Y,e.up,r))}function Me(e,t,n,r){return T(e,he(t,n,dt),r)}function Ne(e,t,n,r){return T(e,D(t,n,dt),r)}function Pe(e,t,n,r){let i=E.get(),a=1-n;g(i,t,e.eye);let o=m(i),s=o*(1-a);a>=0&&s<r&&(s=r,a=-(s-o)/o),!(Math.abs(o-s)<O)&&(C(i,i,a),e.eye=x(Y,e.eye,i),e.center=ne(Y,e.center,t,a))}function Fe(e,t,n){t.getScreenCenter(Ie),ge(e,t,Ie,Y)&&(t.center=Y);let r=t.distance,i=r*n;if(Math.abs(r-i)<O)return;let a=C(E.get(),t.viewForward,i);t.eye=g(Y,t.center,a)}const Ie=a();function Le(e,t){re(t,0,0,0);for(let n of e)x(t,t,n);C(t,t,1/e.length)}function Re(e,t,n,r){return Math.sin(e/m(t))*(n+r.radius)}function ze(e,t,n,r){return Re(Math.PI/2,t,n,r)+(e-Math.PI/2)}const A={Elevation:3e4,Angle:t(16)},j=t(80);function Be(e,t,n,r,i,a){let o=e.sceneIntersectionHelper,s=new ve(e.state.viewingMode);s.options.selectionMode=!1,s.options.store=0,s.options.hud=!1,s.options.normalRequired=!0;let c=null,l=w(),u=new pe,d=!0,f=!0,{eye:p}=t;o.intersectIntersectorScreen(n,s,a);let h=s.results.min;return h.getIntersectionPoint(l)&&!ee(p,l)&&it(p,l,r)?(c=ie(h.normal),u.radius=m(l)):(f=!1,u.radius=!t.aboveGround||i===0?m(t.eye)-t.relativeElevation:Math.max(m(t.center),.9*r),i===1?Ue(u,t,n,l):d=ge(u,t,n,l)),{sphere:u,scenePickPoint:d?l:null,hasGeometryIntersection:f,intersectorType:h.intersector,normal:c}}function Ve(e,t,n,r){let i=e.relativeElevation;if(i>A.Elevation&&r===`global`)return 1;D(e,t,$);let a=Math.sign(i),o=n.worldUpAtPosition(e.eye,Y);return-a*h(o,$.direction)<Math.sin(A.Angle)*m($.direction)?0:1}function He(e,t,n){g(M,n,t),e.eye=g(Y,e.eye,M),e.center=g(Y,e.center,M)}const M=w();function Ue(e,t,n,r){let i=D(t,n,dt);return i!=null&&(e.closestPointOnSilhouette(i,N),e.intersectRay(i,r)?v(N,i.origin)<v(r,i.origin)?(y(r,N),!1):!0:(g(P,t.eye,t.center),_(P,P),fe(P,-h(_(P,P),N),We),T(We,i,r),!1))}const N=w(),P=w(),We=de();function Ge(a,o,s,c,l,u){let d=0;if(S(Q,a,o),g(X,a,o),m(a)<=l||!c.aboveGround){S(s,X,c.eye);let f=h(a,o)/(m(a)*m(o));if(f<.9999)d=r(f);else{let e=m(S(w(),a,o))/(m(a)*m(o));d=i(e)}let p=Math.cos(n(e.normalize(t(u)),0,j));d=-d-Math.max(0,m(o)-l)/(p*l)}else g(Ke,c.eye,c.center),S(s,X,Ke),d=-m(X)/l;return _(s,s),C(s,s,m(Q)),d}const Ke=w();function F(i,a,o,s){let c,l,u=Math.cos(n(e.normalize(t(s)),0,j));return c=a>o?-(a-o)/(u*o):a<-o?Math.PI-(a+o)/(u*o):r(a/o),l=i>o?-(i-o)/(u*o):i<-o?Math.PI-(i+o)/(u*o):r(i/o),(l-c)*o}function qe(e,t,n,r,i,a,o,s,c,l){let u=F(e[2],t[2],a.radius,s),d=c?F(e[0],t[0],a.radius,180):t[0]-e[0],p=Math.sin(o)*d-Math.cos(o)*u,ee=Math.cos(o)*d+Math.sin(o)*u;_(Y,i);let m=c?p/Math.sqrt(Math.abs(a.radius**2-h(n,Y)**2)):p/a.radius,g=ee/Math.sqrt(Math.abs(a.radius**2-h(n,r)**2));f(l,m,g)}function Je(e,t,n,r,i,a,o,s,c,l){S(Q,e,t),le(a.up,a.eye,V,H,U),le([0,0,1],a.eye,z,B,at),y(n,B),y(r,z),_(n,n),C(n,n,m(Q)),ue(e,_(H,H),_(U,U),_(V,V),ot),ue(t,H,U,V,st),qe(ot,st,e,z,B,o,s,c,l,i)}function Ye(e,t,n,r,i,a,s){o(G,i,r),o(K,s,a),c(q,G,K),g(t,e,n),b(t,t,q),x(t,t,n)}function Xe(e,t,n,r,i,a){o(G,r,n),o(K,a,i),c(q,G,K),g(Y,e.eye,t),b(Y,Y,q),e.eye=x(Y,Y,t),g(Y,e.center,t),b(Y,Y,q),e.center=x(Y,Y,t),g(Y,e.up,t),b(Y,Y,q),e.up=x(Y,Y,t)}const I={Pole:.95,Angle:t(18),Tilt:45,TiltHysteresisMargin:1e-7};let L=!1;function R(e,t,n,r,i,a){let o=Math.abs(r)>Math.PI-I.Angle||Math.abs(r)<I.Angle,s=(Math.abs(e[2])<n*I.Pole||Math.abs(t)>n)&&a;return o&&s?!L&&i<I.Tilt-I.TiltHysteresisMargin?L=!0:L&&i>I.Tilt+I.TiltHysteresisMargin&&(L=!1):L=!1,L}function Ze(e,t,n,r,i,a){if(a)se(n,r,ct),k(t,e.center,ct);else{let a=Ge(n,r,lt,t,e.radius,i);k(t,e.center,ce(lt,a))}}function Qe(e,t,n,r,i,a,o){let s=o?20:1;y(J,r),Z.copyFrom(t);let c,l;for(let r=0;r<s&&v(n,J)>1e-12&&(c=v(n,J),Je(n,J,B,z,W,Z,e,i,a,o),Xe(Z,e.center,z,W[1],B,W[0]),Ye(J,J,e.center,z,W[1],B,W[0]),l=v(n,J),l<c||r===0);r++)t.copyFrom(Z)}function $e(n,r,i,a,o,s,c){R(i,h(r.up,i),n.radius,-e.normalize(t(o)),s,r.aboveGround)?Qe(n,r,i,a,-e.normalize(t(o)),s,c):Ze(n,r,i,a,s,c)}function et(e,t,n,r,i,a){let{eye:o}=e;le([0,0,1],o,z,B,at);let s=t.translation[0]*n.pan,c=i.mode===`zoom`?0:t.translation[1]*n.pan,u=Math.max(Math.sqrt(Math.abs(1-h(e.center,z)**2/m(e.center)**2)),.5),d=(Math.sin(a)*c+Math.cos(a)*s)/u,f=-Math.cos(a)*c+Math.sin(a)*s;switch(l(r.pan.matrix,r.pan.matrix,d,z),r.pan.enabled=!0,i.mode){case`pan`:l(r.pan.matrix,r.pan.matrix,f,B),r.pan.enabled=!0;break;case`zoom`:r.zoom=-t.translation[1]*n.zoom}}function tt(e,t,n,r,i){let{eye:a,viewRight:o}=e,s=S(E.get(),o,a),c=t.translation[0]*n.pan;switch(c!==0&&(l(r.pan.matrix,r.pan.matrix,-c,s),r.pan.enabled=!0),i.mode){case`pan`:{let e=t.translation[1]*n.pan;e!==0&&(l(r.pan.matrix,r.pan.matrix,e,o),r.pan.enabled=!0);break}case`zoom`:r.zoom=-t.translation[1]*n.zoom}}function nt(n,r,i,a,o,s,c,l,u){R(n.center,h(n.up,n.center),m(n.center),-e.normalize(t(s)),c,r.aboveGround)?et(r,i,a,l,u,-e.normalize(t(o))):tt(r,i,a,l,u)}function rt(e,t,n=1/0){let r=Math.abs(h(e,t));return Math.min(n,1/r)}function it(e,t,n){let r=te(e,t),i=m(e);return r<Math.max(i,n)}const z=w(),B=w(),at=w(),V=w(),H=w(),U=w(),ot=w(),st=w(),W=p(),ct=ae(),G=d(),K=d(),q=d(),J=w(),Y=w(),X=w();let Z=new _e;const Q=w(),lt=w();function ut(){Z=new _e}const dt={origin:w(),direction:w()},$={origin:w(),direction:w()};export{j as TiltThresholdPanningSpeed,A as VerticalPanTresholds,He as applyPanPlanar,Ze as applyPanSphericalDirectRotation,Qe as applyPanSphericalPreserveHeading,k as applyRotation,Xe as applyRotationWithTwoAxes,Fe as applyZoomOnSphere,Pe as applyZoomToPoint,Le as centroid,ut as cleanupNavigationUtils,O as distanceComparisonTolerance,ke as excludeTerrain,rt as getTiltScaleFactor,Ve as inferNavigationMode,Me as intersectPlaneFromScreenPoint,Ne as intersectPlaneFromScreenPointAtEye,it as isHitOnSamePlanetSide,F as lengthFromPoints,we as maxPanDistanceModifier,Ee as maxRotatePivotDistanceModifier,be as maxZoomPivotDistanceModifier,Se as maxZoomStepDistanceModifier,Te as minPinchAndPanCameraHeight,De as minRotatePivotDistance,Ae as normalizeCoordinate,je as normalizeRotationDelta,ze as offSurfaceTiltToEyeTiltGlobal,Re as onSurfaceTiltToEyeTiltGlobal,nt as panMotionToRotationMatrix,$e as panToPosition,Be as pickPointAndInitSphere,I as preservingHeadingThresholds,Ye as rotatePointAroundTwoAxes,Ge as rotationAngleAndAxisDirectRotation,Je as rotationAnglesAndAxesHeadingPreserving,qe as rotationAnglesHeadingPreserving,Oe as searchAreaSize,R as shouldPreserveHeading,Ue as sphereOrPlanePointFromScreenPoint,xe as zoomPivotDistanceClamp,Ce as zoomStepDistanceClamp};
2
+ import{cyclicalPI as e}from"../../../../core/Cyclical.js";import{deg2rad as t,clamp as n,acosClamped as r,asinClamped as i}from"../../../../core/mathUtils.js";import{createScreenPointArray as a}from"../../../../core/screenUtils.js";import{fromRotation as o,exactEquals as s,multiply as c,rotate as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as u,create as d}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as f}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{exactEquals as ee,length as m,dot as h,subtract as g,normalize as _,squaredDistance as v,copy as y,transformMat4 as b,add as x,distance as te,cross as S,scale as C,lerp as ne,set as re}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{clone as ie,create as w}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as ae,axis as oe,fromPoints as se,wrapAxisAngle as ce}from"../../../../geometry/support/axisAngle.js";import{coordinateSystemFromOneAxisAndNormalVector as le,vectorCoordinates as ue}from"../../../../geometry/support/coordinateSystem.js";import{create as de,fromNormalAndOffset as fe,intersectRay as T}from"../../../../geometry/support/plane.js";import{Sphere as pe}from"../../../../geometry/support/sphere.js";import{sm4d as me,sv3d as E}from"../../../../geometry/support/vectorStacks.js";import{fromScreenAtEye as D,fromScreen as he}from"../../support/geometryUtils/ray.js";import{intersectScreen as ge}from"../../support/geometryUtils/sphere.js";import _e from"../../webgl/RenderCamera.js";import{Intersector as ve}from"../../webgl-engine/lib/Intersector.js";import{terrainId as ye}from"../../webgl-engine/lib/verticalOffsetUtils.js";const be=30,xe=[1,3e8],Se=8,Ce=[200,1508e5],we=5,Te=50,Ee=5,De=10,Oe=90,O=1e-6,ke={exclude:new Set([ye])};function Ae(e,t,n){return n[0]=t[0]/(e.fullWidth/e.pixelRatio),n[1]=t[1]/(e.fullHeight/e.pixelRatio),n}function je(e){for(;e>Math.PI;)e-=2*Math.PI;for(;e<-Math.PI;)e+=2*Math.PI;return e}function k(e,t,n){let r=o(me.get(),n[3],oe(n));r==null||s(r,u)||(g(Y,e.eye,t),b(Y,Y,r),e.eye=x(Y,Y,t),g(Y,e.center,t),b(Y,Y,r),e.center=x(Y,Y,t),e.up=b(Y,e.up,r))}function Me(e,t,n,r){return T(e,he(t,n,dt),r)}function Ne(e,t,n,r){return T(e,D(t,n,dt),r)}function Pe(e,t,n,r){let i=E.get(),a=1-n;g(i,t,e.eye);let o=m(i),s=o*(1-a);a>=0&&s<r&&(s=r,a=-(s-o)/o),Math.abs(o-s)<O||(C(i,i,a),e.eye=x(Y,e.eye,i),e.center=ne(Y,e.center,t,a))}function Fe(e,t,n){t.getScreenCenter(Ie),ge(e,t,Ie,Y)&&(t.center=Y);let r=t.distance,i=r*n;if(Math.abs(r-i)<O)return;let a=C(E.get(),t.viewForward,i);t.eye=g(Y,t.center,a)}const Ie=a();function Le(e,t){re(t,0,0,0);for(let n of e)x(t,t,n);C(t,t,1/e.length)}function Re(e,t,n,r){return Math.sin(e/m(t))*(n+r.radius)}function ze(e,t,n,r){return Re(Math.PI/2,t,n,r)+(e-Math.PI/2)}const A={Elevation:3e4,Angle:t(16)},j=t(80);function Be(e,t,n,r,i,a){let o=e.sceneIntersectionHelper,s=new ve(e.state.viewingMode);s.options.selectionMode=!1,s.options.store=0,s.options.hud=!1,s.options.normalRequired=!0;let c=null,l=w(),u=new pe,d=!0,f=!0,{eye:p}=t;o.intersectIntersectorScreen(n,s,a);let h=s.results.min;return h.getIntersectionPoint(l)&&!ee(p,l)&&it(p,l,r)?(c=ie(h.normal),u.radius=m(l)):(f=!1,u.radius=!t.aboveGround||i===0?m(t.eye)-t.relativeElevation:Math.max(m(t.center),.9*r),i===1?Ue(u,t,n,l):d=ge(u,t,n,l)),{sphere:u,scenePickPoint:d?l:null,hasGeometryIntersection:f,intersectorType:h.intersector,normal:c}}function Ve(e,t,n,r){let i=e.relativeElevation;if(i>A.Elevation&&r===`global`)return 1;D(e,t,$);let a=Math.sign(i),o=n.worldUpAtPosition(e.eye,Y);return-a*h(o,$.direction)<Math.sin(A.Angle)*m($.direction)?0:1}function He(e,t,n){g(M,n,t),e.eye=g(Y,e.eye,M),e.center=g(Y,e.center,M)}const M=w();function Ue(e,t,n,r){let i=D(t,n,dt);return i!=null&&(e.closestPointOnSilhouette(i,N),e.intersectRay(i,r)?v(N,i.origin)<v(r,i.origin)?(y(r,N),!1):!0:(g(P,t.eye,t.center),_(P,P),fe(P,-h(_(P,P),N),We),T(We,i,r),!1))}const N=w(),P=w(),We=de();function Ge(a,o,s,c,l,u){let d=0;if(S(Q,a,o),g(X,a,o),m(a)<=l||!c.aboveGround){S(s,X,c.eye);let f=h(a,o)/(m(a)*m(o));if(f<.9999)d=r(f);else{let e=m(S(w(),a,o))/(m(a)*m(o));d=i(e)}let p=Math.cos(n(e.normalize(t(u)),0,j));d=-d-Math.max(0,m(o)-l)/(p*l)}else g(Ke,c.eye,c.center),S(s,X,Ke),d=-m(X)/l;return _(s,s),C(s,s,m(Q)),d}const Ke=w();function F(i,a,o,s){let c,l,u=Math.cos(n(e.normalize(t(s)),0,j));return c=a>o?-(a-o)/(u*o):a<-o?Math.PI-(a+o)/(u*o):r(a/o),l=i>o?-(i-o)/(u*o):i<-o?Math.PI-(i+o)/(u*o):r(i/o),(l-c)*o}function qe(e,t,n,r,i,a,o,s,c,l){let u=F(e[2],t[2],a.radius,s),d=c?F(e[0],t[0],a.radius,180):t[0]-e[0],p=Math.sin(o)*d-Math.cos(o)*u,ee=Math.cos(o)*d+Math.sin(o)*u;_(Y,i);let m=c?p/Math.sqrt(Math.abs(a.radius**2-h(n,Y)**2)):p/a.radius,g=ee/Math.sqrt(Math.abs(a.radius**2-h(n,r)**2));f(l,m,g)}function Je(e,t,n,r,i,a,o,s,c,l){S(Q,e,t),le(a.up,a.eye,V,H,U),le([0,0,1],a.eye,z,B,at),y(n,B),y(r,z),_(n,n),C(n,n,m(Q)),ue(e,_(H,H),_(U,U),_(V,V),ot),ue(t,H,U,V,st),qe(ot,st,e,z,B,o,s,c,l,i)}function Ye(e,t,n,r,i,a,s){o(G,i,r),o(K,s,a),c(q,G,K),g(t,e,n),b(t,t,q),x(t,t,n)}function Xe(e,t,n,r,i,a){o(G,r,n),o(K,a,i),c(q,G,K),g(Y,e.eye,t),b(Y,Y,q),e.eye=x(Y,Y,t),g(Y,e.center,t),b(Y,Y,q),e.center=x(Y,Y,t),g(Y,e.up,t),b(Y,Y,q),e.up=x(Y,Y,t)}const I={Pole:.95,Angle:t(18),Tilt:45,TiltHysteresisMargin:1e-7};let L=!1;function R(e,t,n,r,i,a){let o=Math.abs(r)>Math.PI-I.Angle||Math.abs(r)<I.Angle,s=(Math.abs(e[2])<n*I.Pole||Math.abs(t)>n)&&a;return o&&s?!L&&i<I.Tilt-I.TiltHysteresisMargin?L=!0:L&&i>I.Tilt+I.TiltHysteresisMargin&&(L=!1):L=!1,L}function Ze(e,t,n,r,i,a){if(a)se(n,r,ct),k(t,e.center,ct);else{let a=Ge(n,r,lt,t,e.radius,i);k(t,e.center,ce(lt,a))}}function Qe(e,t,n,r,i,a,o){let s=o?20:1;y(J,r),Z.copyFrom(t);let c,l;for(let r=0;r<s&&v(n,J)>1e-12&&(c=v(n,J),Je(n,J,B,z,W,Z,e,i,a,o),Xe(Z,e.center,z,W[1],B,W[0]),Ye(J,J,e.center,z,W[1],B,W[0]),l=v(n,J),l<c||r===0);r++)t.copyFrom(Z)}function $e(n,r,i,a,o,s,c){R(i,h(r.up,i),n.radius,-e.normalize(t(o)),s,r.aboveGround)?Qe(n,r,i,a,-e.normalize(t(o)),s,c):Ze(n,r,i,a,s,c)}function et(e,t,n,r,i,a){let{eye:o}=e;le([0,0,1],o,z,B,at);let s=t.translation[0]*n.pan,c=i.mode===`zoom`?0:t.translation[1]*n.pan,u=Math.max(Math.sqrt(Math.abs(1-h(e.center,z)**2/m(e.center)**2)),.5),d=(Math.sin(a)*c+Math.cos(a)*s)/u,f=-Math.cos(a)*c+Math.sin(a)*s;switch(l(r.pan.matrix,r.pan.matrix,d,z),r.pan.enabled=!0,i.mode){case`pan`:l(r.pan.matrix,r.pan.matrix,f,B),r.pan.enabled=!0;break;case`zoom`:r.zoom=-t.translation[1]*n.zoom}}function tt(e,t,n,r,i){let{eye:a,viewRight:o}=e,s=S(E.get(),o,a),c=t.translation[0]*n.pan;switch(c!==0&&(l(r.pan.matrix,r.pan.matrix,-c,s),r.pan.enabled=!0),i.mode){case`pan`:{let e=t.translation[1]*n.pan;e!==0&&(l(r.pan.matrix,r.pan.matrix,e,o),r.pan.enabled=!0);break}case`zoom`:r.zoom=-t.translation[1]*n.zoom}}function nt(n,r,i,a,o,s,c,l,u){R(n.center,h(n.up,n.center),m(n.center),-e.normalize(t(s)),c,r.aboveGround)?et(r,i,a,l,u,-e.normalize(t(o))):tt(r,i,a,l,u)}function rt(e,t,n=1/0){let r=Math.abs(h(e,t));return Math.min(n,1/r)}function it(e,t,n){let r=te(e,t),i=m(e);return r<Math.max(i,n)}const z=w(),B=w(),at=w(),V=w(),H=w(),U=w(),ot=w(),st=w(),W=p(),ct=ae(),G=d(),K=d(),q=d(),J=w(),Y=w(),X=w();let Z=new _e;const Q=w(),lt=w();function ut(){Z=new _e}const dt={origin:w(),direction:w()},$={origin:w(),direction:w()};export{j as TiltThresholdPanningSpeed,A as VerticalPanTresholds,He as applyPanPlanar,Ze as applyPanSphericalDirectRotation,Qe as applyPanSphericalPreserveHeading,k as applyRotation,Xe as applyRotationWithTwoAxes,Fe as applyZoomOnSphere,Pe as applyZoomToPoint,Le as centroid,ut as cleanupNavigationUtils,O as distanceComparisonTolerance,ke as excludeTerrain,rt as getTiltScaleFactor,Ve as inferNavigationMode,Me as intersectPlaneFromScreenPoint,Ne as intersectPlaneFromScreenPointAtEye,it as isHitOnSamePlanetSide,F as lengthFromPoints,we as maxPanDistanceModifier,Ee as maxRotatePivotDistanceModifier,be as maxZoomPivotDistanceModifier,Se as maxZoomStepDistanceModifier,Te as minPinchAndPanCameraHeight,De as minRotatePivotDistance,Ae as normalizeCoordinate,je as normalizeRotationDelta,ze as offSurfaceTiltToEyeTiltGlobal,Re as onSurfaceTiltToEyeTiltGlobal,nt as panMotionToRotationMatrix,$e as panToPosition,Be as pickPointAndInitSphere,I as preservingHeadingThresholds,Ye as rotatePointAroundTwoAxes,Ge as rotationAngleAndAxisDirectRotation,Je as rotationAnglesAndAxesHeadingPreserving,qe as rotationAnglesHeadingPreserving,Oe as searchAreaSize,R as shouldPreserveHeading,Ue as sphereOrPlanePointFromScreenPoint,xe as zoomPivotDistanceClamp,Ce as zoomStepDistanceClamp};
@@ -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{disposeMaybe as t}from"../../../core/maybe.js";import{MemCachePool as n}from"../../../core/MemCachePool.js";import r from"../../../core/ObjectPool.js";import{watch as i,sync as a}from"../../../core/reactiveUtils.js";import{property as o,subclass as s}from"../../../core/accessorSupport/decorators.js";import{subtract as c,set as l,dot as u}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as d,fromValues as f,create as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as m,ZEROS as h}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as g,set as _}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as v}from"../../../geometry/support/buffer/BufferView.js";import{overlayRenderOccludedFlag as y}from"./OverlayRenderer.js";import{PatchRenderData as b}from"./PatchRenderData.js";import{TerrainAttributesCache as x}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as S}from"./terrainUtils.js";import{TileRenderer as C}from"./TileRenderer.js";import{IteratorPreorder as w,fallsWithinLayerView as T,sortTiles as E,compareTiles as D}from"./tileUtils.js";import{getOverlayContentForOutputTerrain as O}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as k}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as A}from"../webgl-engine/lib/Attribute.js";import{IntersectorResultRay as j}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as M,MeshIntersectionOptions as N,intersectTriangles as P}from"../webgl-engine/lib/RayIntersections.js";import{TriangleIntersectionData as F}from"../webgl-engine/lib/TriangleIntersectionData.js";import{terrainId as I,getVerticalOffsetTerrain as L}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as R}from"../webgl-engine/materials/DrawParameters.js";import{hasShadowHighlights as z}from"../webgl-engine/shaders/ReceiveShadowsConfiguration.js";import{T as B}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as V}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as H}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as U}from"../../webgl/enums.js";const W=g();let G=class extends k{get visibleTiles(){return Array.from(this._visiblePatchesByOrigin.values()).flat()}get _isGlobal(){return this._stage.viewingMode===1}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}get renderOccludedFlags(){return this._overlayRenderer.renderOccludedFlags}constructor(e,t,i,a,o){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._compressionTracker=a,this.type=7,this.isGround=!0,this._passParameters=new B,this._drawParameters=new R,this._renderDataPool=new r(()=>new b),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new w,this._castShadows=!1,this._inViewshed=!1,this._cutFillEnabled=!1,this._tileRenderer=null,this._stencilEnabledLayerExtents=[],this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.produces=new Map([[1,()=>this._desiredSlot===1],[7,()=>this._desiredSlot===7],[9,()=>this._produces()&&this.renderOccludedFlags===y]]),this._tileSize=256,this._configuration=new H(t.viewingMode===1),this._tileTextureCache=new n((e,t)=>o.newCache(e,t),`TileTexture`),this.tileGeometryCache=new x(o)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(i(()=>this._overlayRenderer.renderOccludedFlags,()=>this.setNeedsRender(),a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set(`renderingDisabled`,!!e),this.setDirty()}set visible(e){this._set(`visible`,!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange(`renderPatchBorders`))}get layerViewUid(){return I}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,this._tileRenderer!=null&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),!this.reuseTextureFromParent(e)&&this.updateTileTexture(e,32)}reuseTextureFromParent(e){let{parent:t}=e;if(!this._canReuseTextureFromParent(t,e))return!1;let n=m(e.lij[2]&1?.5:0,e.lij[1]&1?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,n)??!1}_canReuseTextureFromParent(e,t){if(!e)return!1;let{layerInfo:n,surface:r}=t;for(let i=0;i<n[1].length;i++){let n=r.layerViewByIndex(i,1);if(T(e,n)!==T(t,n))return!1}return!0}updateTileTexture(e,t){this._tileRenderer!=null&&(this._tileRenderer.updateTileTexture(e,t===32?0:2),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(let t of e.layerInfo[0])t.pendingUpdates&=-9;e.resetPendingUpdate(8);let t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){let t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){let t=Math.max(0,Math.floor((e.level-3)/7)*7);if(this._isGlobal&&t===0)return d;for(;e.parent&&e.level>t;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get(`wireframe`)!==e&&(this._set(`wireframe`,e),this.setNeedsRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new C(this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=t(this._tileRenderer)}intersectRay(e,t,n,r){let i=this._rootTiles;if(!i||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==0)return;let a=K,o=q;c(a,r,n),l(o,1/a[0],1/a[1],1/a[2]);let s=e.results.min,d=e.results.max,f=e.results.ground,p=e.options.store===0,m=!!e.results.ground.target,h=L(e.verticalOffset),g=e.tolerance,y,b=p&&s.distance!=null?s.distance:1/0,x=e.options,S=x.normalRequired||!x.backfacesTerrain,C=new N(g,!1,S),w=i=>{let l=i.renderData;if(!l?.vao)return;let m=l.geometry;_(W,m.boundingBox);let w=l.localOrigin;if(h!=null&&(h.localOrigin=w,h.applyToAabb(W)),J[0]=n[0]-w[0],J[1]=n[1]-w[1],J[2]=n[2]-w[2],!M(W,J,o,g,b))return;let T=(e,t,n,r)=>{e.set(this.type,i,t,n,r),b=p&&s.renderDistance!=null?s.renderDistance:1/0},E=(i,o,c)=>{(!S||c!=null)&&o>=0&&(x.backfacesTerrain||u(c,a)<0)&&(x.invisibleTerrain||!x.selectionMode||t==null||t(n,r,o))&&((f.renderDistance==null||o<f.renderDistance)&&T(f,i,o,c),!x.isFiltered&&(x.store===2&&(y==null?(y=new j(e.ray),T(y,i,o,c),e.results.all.push(y)):o<y.renderDistance&&T(y,i,o,c)),(s.renderDistance==null||o<s.renderDistance)&&T(s,i,o,c),x.store!==0&&(d.renderDistance==null||o>d.renderDistance)&&T(d,i,o,c)))},D=Y;c(D,r,w);let{indices:O,indexCount:k}=m,N=m.vertexAttributes,I=N.getField(`position`,v),L=new A(I.typedBuffer,3,N.stride/4),R=k/3;!h&&R>200?(l.intersectionData??=new F(O,R,L),l.intersectionData.intersectRay(J,D,C,E)):P(J,D,0,R,(e,t)=>I.getVec(O[t],e),h,C,E)},T=this._tileIterator;T.reset(i);let E=e.options.invisibleTerrain;for(let e=T.next();e;e=T.next())(e.visible||E&&e.intersectsClippingArea)&&(h!=null||e.intersectsRay(n,a,g,b))&&(!m||!this._useStencilForTile(e))?w(e):T.skipSubtree()}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(let t of this._visiblePatchesByOrigin.values())for(let n of t)n.renderData?.textureReference!=null&&e.queriesForTile(n);e.process(),t.madeProgress()}}get _desiredSlot(){if(!this._produces())return null;switch(this.transparency){case 0:return 1;case 1:case 2:return 7;case 3:case 4:return null}}acquireTechniques(e){let{shadowMap:t,viewshedEnabled:n,cutFillComputationEnabled:r,slot:i,hasEmission:a,useFloatBlend:o}=e.bind,s=!!has(`enable-feature:terrain-shadows`)&&t.enabled;if(s!==this._castShadows&&(this._castShadows=s,this._patchesByOriginDirty=!0),this._inViewshed!==n&&(this._inViewshed=n,this._patchesByOriginDirty=!0),this._cutFillEnabled!==r&&(this._cutFillEnabled=r,this._patchesByOriginDirty=!0),this.transparency===3)return null;if(i===9){if((e.renderOccludedMask&y)===0)return null}else if(i!==this._desiredSlot)return null;let c=this._configuration;switch(c.receiveGlobalIllumination=c.screenSpaceReflections=c.cloudReflections=c.receiveShadows=c.hasShadowHighlights=c.receiveAmbientOcclusion=c.renderOccluded=c.hasHighlightMixTexture=!1,c.hasEmission=a,c.overlayMode=this._overlayRenderer.mode,c.useFloatBlend=o.value,e.output){case 0:case 1:case 2:{let n=e.bind;c.screenSpaceReflections=n.hasScreenSpaceReflections,c.cloudReflections=n.clouds.data!=null;let r=i===9;return c.receiveShadows=t.ready&&!r,c.hasShadowHighlights=z(c,e.bind),c.renderOccluded=r,c.receiveAmbientOcclusion=!r&&n.ssao!=null,c.receiveGlobalIllumination=!r&&n.globalIlluminationEnabled,this._acquireTechnique(e.output)}case 5:case 7:return this._castShadows?this._acquireTechnique(5):null;case 8:return this._inViewshed?this._acquireTechnique(8):null;case 9:return this._cutFillEnabled?this._acquireTechnique(9):null;case 3:case 4:case 11:return this._acquireTechnique(e.output);case 10:return c.hasHighlightMixTexture=e.bind.highlightMixTexture!=null,this._overlayRenderer.hasHighlights?this._acquireTechnique(10):null}return null}render(e,t){switch(this._updatePatchGroups(),this._passParameters.useStencil=!1,this._passParameters.overlayContent=O(e.output,e.bind),e.output){case 0:case 1:case 2:return this._renderMaterialPass(e,t);case 3:case 4:case 11:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 10:{let n=e.bind.highlight?.name;n&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(n)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 5:case 7:case 8:case 9:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(this._tileRenderer==null)return;let t=this._tileRenderer,n;if(e!=null){let t=e.toUnitRGBA();n=f(t[0]||0,t[1]||0,t[2]||0)}t.setBackground(n),this._allTiles.forAll(e=>t.updateTileTexture(e,0)),this._configuration.tileBlendInput=t.backgroundIsGrid?2:t.backgroundColor==null?0:1,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty){let e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(let n of e)E(n,t);e.sort((e,t)=>D(e[0],t[0])),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this.notifyChange(`visibleTiles`),this._patchSortingDirty=!1}}_rebuildPatchGroups(){let e=this._rootTiles;if(e!=null){e[0]?.surface.checkAllTilesWaterproofness(`render-patch-groups`),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(let t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){let t=this._tileIterator;for(t.resetOne(e);!t.done;){let e=t.next(),n=e.renderData;if(!n){this._numTilesCulled++;continue}let r=n.localOrigin;if(this._castShadows||this._inViewshed||this._cutFillEnabled){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let i=this._visiblePatchesByOrigin.get(r);i||(i=[],this._visiblePatchesByOrigin.set(r,i)),i.push(e),t.skipSubtree()}}_useStencilForTile(e){for(let t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,n){let{rctx:r,bind:i}=e;r.bindTechnique(t,i,this._passParameters);let a=this._stencilEnabledLayerExtents.length>0;n.forEach(n=>{this._drawParameters.origin=n[0].renderData.localOrigin,t.program.bindDraw(i,this._passParameters,this._drawParameters);for(let r=0;r<n.length;r++)this._renderPatch(e,t,n[r],U.TRIANGLES,a,this._passParameters.overlayContent===null)}),r.bindVAO(null)}_renderMaterialPass(e,t){let{rctx:n,bind:r}=e,i=n.bindTechnique(t,r,this._passParameters);this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;let a=r.slot===9;a&&(i.bindTexture(`tex`,n.emptyTexture),i.setUniform3fv(`textureOpacities`,d),i.setUniform4fv(`texOffsetAndScale`,h));let o=this._tileRenderer?.backgroundColor==null?d:this._tileRenderer.backgroundColor;this._configuration.tileBlendInput===1&&i.setUniform3fv(`backgroundColor`,o);let s=this._stencilEnabledLayerExtents.length>0,c=this.wireframe?U.LINES:U.TRIANGLES;this._configuration.textureFadingEnabled&&i.bindTexture(`texNext`,n.emptyTexture);for(let n of this._visiblePatchesByOrigin.values()){this._drawParameters.origin=n[0].renderData.localOrigin,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(let r of n){let n=r.renderData,o=n.textureReference;if(o!=null){if(!a){i.setUniform4fv(`texOffsetAndScale`,o.offsetAndScale),i.bindTexture(`tex`,o.texture.texture);let e=n.textureFadeFactor,t=e<1?n.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(i.setUniform1f(`fadeFactor`,e),i.setUniform4fv(`nextTexOffsetAndScale`,t.offsetAndScale),i.setUniform3fv(`nextTexOpacities`,t.opacities),i.bindTexture(`texNext`,t.texture.texture)):i.setUniform1f(`fadeFactor`,1),n.textureIsFading&&this.setNeedsRender(2),i.setUniform3fv(`textureOpacities`,o.opacities)}this._renderPatch(e,t,r,c,s),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}n.bindVAO(null)}_renderPatch(e,t,n,r,i,a=!1){let o=n.renderData,s=o.vao,c=s?.indexBuffer;if(!s||c==null){S&&console.error(`Rendered tile with no indices: `,n.lij,` : `,o);return}let l=t.program;!a&&!this._overlayRenderer.isEmpty&&this._bindOverlayPatchData(l,o.overlay);let{rctx:u,bind:d}=e;i&&(this._passParameters.useStencil=this._useStencilForTile(n),u.setPipelineState(t.getPipeline(d,this._passParameters)));let f=o.geometry.indexCount;u.bindVAO(s),l.assertCompatibleVertexAttributeLocations(s),u.drawElements(r,f,c.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv(`overlayTexOffset`,t.offsets),e.setUniform4fv(`overlayTexScale`,t.scales)}_acquireTechnique(e){return this._configuration.output=e,this._techniques.get(V,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([o({readOnly:!0})],G.prototype,`visibleTiles`,null),e([o({readOnly:!0})],G.prototype,`_isGlobal`,null),e([o()],G.prototype,`renderOccludedFlags`,null),e([o({value:!1})],G.prototype,`renderingDisabled`,null),e([o({value:!0})],G.prototype,`visible`,null),e([o()],G.prototype,`renderPatchBorders`,null),e([o()],G.prototype,`wireframe`,null),G=e([s(`esri.views.3d.terrain.TerrainRenderer`)],G);const K=p(),q=p(),J=p(),Y=p();export{G as TerrainRenderer};
2
+ import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{disposeMaybe as t}from"../../../core/maybe.js";import{MemCachePool as n}from"../../../core/MemCachePool.js";import r from"../../../core/ObjectPool.js";import{watch as i,sync as a}from"../../../core/reactiveUtils.js";import{property as o,subclass as s}from"../../../core/accessorSupport/decorators.js";import{subtract as c,set as l,dot as u}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as d,fromValues as f,create as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as m,ZEROS as h}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as g,set as _}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as v}from"../../../geometry/support/buffer/BufferView.js";import{overlayRenderOccludedFlag as y}from"./OverlayRenderer.js";import{PatchRenderData as b}from"./PatchRenderData.js";import{TerrainAttributesCache as x}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as S}from"./terrainUtils.js";import{TileRenderer as C}from"./TileRenderer.js";import{IteratorPreorder as w,fallsWithinLayerView as T,sortTiles as E,compareTiles as D}from"./tileUtils.js";import{getOverlayContentForOutputTerrain as O}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as k}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as A}from"../webgl-engine/lib/Attribute.js";import{IntersectorResultRay as j}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as M,MeshIntersectionOptions as N,intersectTriangles as P}from"../webgl-engine/lib/RayIntersections.js";import{TriangleIntersectionData as F}from"../webgl-engine/lib/TriangleIntersectionData.js";import{terrainId as I,getVerticalOffsetTerrain as L}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as R}from"../webgl-engine/materials/DrawParameters.js";import{hasShadowHighlights as z}from"../webgl-engine/shaders/ReceiveShadowsConfiguration.js";import{T as B}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as V}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as H}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as U}from"../../webgl/enums.js";const W=g();let G=class extends k{get visibleTiles(){return Array.from(this._visiblePatchesByOrigin.values()).flat()}get _isGlobal(){return this._stage.viewingMode===1}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}get renderOccludedFlags(){return this._overlayRenderer.renderOccludedFlags}constructor(e,t,i,a,o){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._compressionTracker=a,this.type=7,this.isGround=!0,this._passParameters=new B,this._drawParameters=new R,this._renderDataPool=new r(()=>new b),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new w,this._castShadows=!1,this._inViewshed=!1,this._cutFillEnabled=!1,this._tileRenderer=null,this._stencilEnabledLayerExtents=[],this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.produces=new Map([[1,()=>this._desiredSlot===1],[7,()=>this._desiredSlot===7],[9,()=>this._produces()&&this.renderOccludedFlags===y]]),this._tileSize=256,this._configuration=new H(t.viewingMode===1),this._tileTextureCache=new n((e,t)=>o.newCache(e,t),`TileTexture`),this.tileGeometryCache=new x(o)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(i(()=>this._overlayRenderer.renderOccludedFlags,()=>this.setNeedsRender(),a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set(`renderingDisabled`,!!e),this.setDirty()}set visible(e){this._set(`visible`,!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange(`renderPatchBorders`))}get layerViewUid(){return I}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,this._tileRenderer!=null&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,32)}reuseTextureFromParent(e){let{parent:t}=e;if(!this._canReuseTextureFromParent(t,e))return!1;let n=m(e.lij[2]&1?.5:0,e.lij[1]&1?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,n)??!1}_canReuseTextureFromParent(e,t){if(!e)return!1;let{layerInfo:n,surface:r}=t;for(let i=0;i<n[1].length;i++){let n=r.layerViewByIndex(i,1);if(T(e,n)!==T(t,n))return!1}return!0}updateTileTexture(e,t){this._tileRenderer!=null&&(this._tileRenderer.updateTileTexture(e,t===32?0:2),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(let t of e.layerInfo[0])t.pendingUpdates&=-9;e.resetPendingUpdate(8);let t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){let t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){let t=Math.max(0,Math.floor((e.level-3)/7)*7);if(this._isGlobal&&t===0)return d;for(;e.parent&&e.level>t;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get(`wireframe`)!==e&&(this._set(`wireframe`,e),this.setNeedsRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new C(this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=t(this._tileRenderer)}intersectRay(e,t,n,r){let i=this._rootTiles;if(!i||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==0)return;let a=K,o=q;c(a,r,n),l(o,1/a[0],1/a[1],1/a[2]);let s=e.results.min,d=e.results.max,f=e.results.ground,p=e.options.store===0,m=!!e.results.ground.target,h=L(e.verticalOffset),g=e.tolerance,y,b=p&&s.distance!=null?s.distance:1/0,x=e.options,S=x.normalRequired||!x.backfacesTerrain,C=new N(g,!1,S),w=i=>{let l=i.renderData;if(!l?.vao)return;let m=l.geometry;_(W,m.boundingBox);let w=l.localOrigin;if(h!=null&&(h.localOrigin=w,h.applyToAabb(W)),J[0]=n[0]-w[0],J[1]=n[1]-w[1],J[2]=n[2]-w[2],!M(W,J,o,g,b))return;let T=(e,t,n,r)=>{e.set(this.type,i,t,n,r),b=p&&s.renderDistance!=null?s.renderDistance:1/0},E=(i,o,c)=>{(!S||c!=null)&&o>=0&&(x.backfacesTerrain||u(c,a)<0)&&(x.invisibleTerrain||!x.selectionMode||t==null||t(n,r,o))&&((f.renderDistance==null||o<f.renderDistance)&&T(f,i,o,c),x.isFiltered||(x.store===2&&(y==null?(y=new j(e.ray),T(y,i,o,c),e.results.all.push(y)):o<y.renderDistance&&T(y,i,o,c)),(s.renderDistance==null||o<s.renderDistance)&&T(s,i,o,c),x.store!==0&&(d.renderDistance==null||o>d.renderDistance)&&T(d,i,o,c)))},D=Y;c(D,r,w);let{indices:O,indexCount:k}=m,N=m.vertexAttributes,I=N.getField(`position`,v),L=new A(I.typedBuffer,3,N.stride/4),R=k/3;!h&&R>200?(l.intersectionData??=new F(O,R,L),l.intersectionData.intersectRay(J,D,C,E)):P(J,D,0,R,(e,t)=>I.getVec(O[t],e),h,C,E)},T=this._tileIterator;T.reset(i);let E=e.options.invisibleTerrain;for(let e=T.next();e;e=T.next())(e.visible||E&&e.intersectsClippingArea)&&(h!=null||e.intersectsRay(n,a,g,b))&&(!m||!this._useStencilForTile(e))?w(e):T.skipSubtree()}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(let t of this._visiblePatchesByOrigin.values())for(let n of t)n.renderData?.textureReference!=null&&e.queriesForTile(n);e.process(),t.madeProgress()}}get _desiredSlot(){if(!this._produces())return null;switch(this.transparency){case 0:return 1;case 1:case 2:return 7;case 3:case 4:return null}}acquireTechniques(e){let{shadowMap:t,viewshedEnabled:n,cutFillComputationEnabled:r,slot:i,hasEmission:a,useFloatBlend:o}=e.bind,s=!!has(`enable-feature:terrain-shadows`)&&t.enabled;if(s!==this._castShadows&&(this._castShadows=s,this._patchesByOriginDirty=!0),this._inViewshed!==n&&(this._inViewshed=n,this._patchesByOriginDirty=!0),this._cutFillEnabled!==r&&(this._cutFillEnabled=r,this._patchesByOriginDirty=!0),this.transparency===3)return null;if(i===9){if((e.renderOccludedMask&y)===0)return null}else if(i!==this._desiredSlot)return null;let c=this._configuration;switch(c.receiveGlobalIllumination=c.screenSpaceReflections=c.cloudReflections=c.receiveShadows=c.hasShadowHighlights=c.receiveAmbientOcclusion=c.renderOccluded=c.hasHighlightMixTexture=!1,c.hasEmission=a,c.overlayMode=this._overlayRenderer.mode,c.useFloatBlend=o.value,e.output){case 0:case 1:case 2:{let n=e.bind;c.screenSpaceReflections=n.hasScreenSpaceReflections,c.cloudReflections=n.clouds.data!=null;let r=i===9;return c.receiveShadows=t.ready&&!r,c.hasShadowHighlights=z(c,e.bind),c.renderOccluded=r,c.receiveAmbientOcclusion=!r&&n.ssao!=null,c.receiveGlobalIllumination=!r&&n.globalIlluminationEnabled,this._acquireTechnique(e.output)}case 5:case 7:return this._castShadows?this._acquireTechnique(5):null;case 8:return this._inViewshed?this._acquireTechnique(8):null;case 9:return this._cutFillEnabled?this._acquireTechnique(9):null;case 3:case 4:case 11:return this._acquireTechnique(e.output);case 10:return c.hasHighlightMixTexture=e.bind.highlightMixTexture!=null,this._overlayRenderer.hasHighlights?this._acquireTechnique(10):null}return null}render(e,t){switch(this._updatePatchGroups(),this._passParameters.useStencil=!1,this._passParameters.overlayContent=O(e.output,e.bind),e.output){case 0:case 1:case 2:return this._renderMaterialPass(e,t);case 3:case 4:case 11:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 10:{let n=e.bind.highlight?.name;n&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(n)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 5:case 7:case 8:case 9:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(this._tileRenderer==null)return;let t=this._tileRenderer,n;if(e!=null){let t=e.toUnitRGBA();n=f(t[0]||0,t[1]||0,t[2]||0)}t.setBackground(n),this._allTiles.forAll(e=>t.updateTileTexture(e,0)),this._configuration.tileBlendInput=t.backgroundIsGrid?2:t.backgroundColor==null?0:1,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty){let e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(let n of e)E(n,t);e.sort((e,t)=>D(e[0],t[0])),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this.notifyChange(`visibleTiles`),this._patchSortingDirty=!1}}_rebuildPatchGroups(){let e=this._rootTiles;if(e!=null){e[0]?.surface.checkAllTilesWaterproofness(`render-patch-groups`),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(let t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){let t=this._tileIterator;for(t.resetOne(e);!t.done;){let e=t.next(),n=e.renderData;if(!n){this._numTilesCulled++;continue}let r=n.localOrigin;if(this._castShadows||this._inViewshed||this._cutFillEnabled){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let i=this._visiblePatchesByOrigin.get(r);i||(i=[],this._visiblePatchesByOrigin.set(r,i)),i.push(e),t.skipSubtree()}}_useStencilForTile(e){for(let t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,n){let{rctx:r,bind:i}=e;r.bindTechnique(t,i,this._passParameters);let a=this._stencilEnabledLayerExtents.length>0;n.forEach(n=>{this._drawParameters.origin=n[0].renderData.localOrigin,t.program.bindDraw(i,this._passParameters,this._drawParameters);for(let r=0;r<n.length;r++)this._renderPatch(e,t,n[r],U.TRIANGLES,a,this._passParameters.overlayContent===null)}),r.bindVAO(null)}_renderMaterialPass(e,t){let{rctx:n,bind:r}=e,i=n.bindTechnique(t,r,this._passParameters);this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;let a=r.slot===9;a&&(i.bindTexture(`tex`,n.emptyTexture),i.setUniform3fv(`textureOpacities`,d),i.setUniform4fv(`texOffsetAndScale`,h));let o=this._tileRenderer?.backgroundColor==null?d:this._tileRenderer.backgroundColor;this._configuration.tileBlendInput===1&&i.setUniform3fv(`backgroundColor`,o);let s=this._stencilEnabledLayerExtents.length>0,c=this.wireframe?U.LINES:U.TRIANGLES;this._configuration.textureFadingEnabled&&i.bindTexture(`texNext`,n.emptyTexture);for(let n of this._visiblePatchesByOrigin.values()){this._drawParameters.origin=n[0].renderData.localOrigin,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(let r of n){let n=r.renderData,o=n.textureReference;if(o!=null){if(!a){i.setUniform4fv(`texOffsetAndScale`,o.offsetAndScale),i.bindTexture(`tex`,o.texture.texture);let e=n.textureFadeFactor,t=e<1?n.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(i.setUniform1f(`fadeFactor`,e),i.setUniform4fv(`nextTexOffsetAndScale`,t.offsetAndScale),i.setUniform3fv(`nextTexOpacities`,t.opacities),i.bindTexture(`texNext`,t.texture.texture)):i.setUniform1f(`fadeFactor`,1),n.textureIsFading&&this.setNeedsRender(2),i.setUniform3fv(`textureOpacities`,o.opacities)}this._renderPatch(e,t,r,c,s),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}n.bindVAO(null)}_renderPatch(e,t,n,r,i,a=!1){let o=n.renderData,s=o.vao,c=s?.indexBuffer;if(!s||c==null){S&&console.error(`Rendered tile with no indices: `,n.lij,` : `,o);return}let l=t.program;!a&&!this._overlayRenderer.isEmpty&&this._bindOverlayPatchData(l,o.overlay);let{rctx:u,bind:d}=e;i&&(this._passParameters.useStencil=this._useStencilForTile(n),u.setPipelineState(t.getPipeline(d,this._passParameters)));let f=o.geometry.indexCount;u.bindVAO(s),l.assertCompatibleVertexAttributeLocations(s),u.drawElements(r,f,c.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv(`overlayTexOffset`,t.offsets),e.setUniform4fv(`overlayTexScale`,t.scales)}_acquireTechnique(e){return this._configuration.output=e,this._techniques.get(V,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([o({readOnly:!0})],G.prototype,`visibleTiles`,null),e([o({readOnly:!0})],G.prototype,`_isGlobal`,null),e([o()],G.prototype,`renderOccludedFlags`,null),e([o({value:!1})],G.prototype,`renderingDisabled`,null),e([o({value:!0})],G.prototype,`visible`,null),e([o()],G.prototype,`renderPatchBorders`,null),e([o()],G.prototype,`wireframe`,null),G=e([s(`esri.views.3d.terrain.TerrainRenderer`)],G);const K=p(),q=p(),J=p(),Y=p();export{G as TerrainRenderer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../Color.js";import{filterInPlace as n,difference as r}from"../../../core/arrayUtils.js";import i from"../../../core/CollectionFlattener.js";import{toConst as a}from"../../../core/compilerUtils.js";import{EventedAccessor as o}from"../../../core/Evented.js";import"../../../core/has.js";import s from"../../../core/Logger.js";import{clamp as c}from"../../../core/mathUtils.js";import{removeMaybe as l,destroyMaybe as u}from"../../../core/maybe.js";import{MemCachePool as ee}from"../../../core/MemCachePool.js";import d from"../../../core/ObjectPool.js";import f from"../../../core/PooledArray.js";import{throwIfAborted as te,isAbortError as p,isAborted as m}from"../../../core/promiseUtils.js";import{watch as h,syncAndInitial as g,initial as _,sync as v}from"../../../core/reactiveUtils.js";import"../../../core/scheduling.js";import{getMetersPerUnitForSR as ne}from"../../../core/units.js";import{property as y,subclass as re}from"../../../core/accessorSupport/decorators.js";import{exactEquals as ie,set as ae,copy as oe}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as se}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as ce,radiusModifier as le}from"../../../geometry/ellipsoidUtils.js";import x from"../../../geometry/SpatialReference.js";import{getProjector as S}from"../../../geometry/projection/projectors.js";import{projectPointToVector as C}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as ue}from"../../../geometry/projection/projectVectorToVector.js";import{create as w,equals as T,intersection as de,intersectsSphere as fe}from"../../../geometry/support/aaBoundingRect.js";import{copy as pe,create as me}from"../../../geometry/support/frustumPlanes.js";import{createSpatialReferenceCyclical as he}from"../../../geometry/support/normalizeUtils.js";import{isPlateCarree as ge}from"../../../geometry/support/spatialReferenceUtils.js";import{Sphere as _e}from"../../../geometry/support/sphere.js";import{ElevationQueryTileCache as ve}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as ye}from"../../../layers/support/layerUtils.js";import{queueHighPriority as be}from"../../../request/queue.js";import{debugFlags as E}from"../support/debugFlags.js";import{ElevationRange as D}from"../support/ElevationRange.js";import{ElevationUpdateEvent as xe}from"../support/ElevationUpdateEvent.js";import{calculateElevationUpdateExtents as Se}from"../support/elevationUpdateExtentUtils.js";import{toBoundingRect as Ce}from"../support/extentUtils.js";import{updatingProgress as we}from"../support/updatingProperties.js";import{ElevationBounds as O}from"./ElevationBounds.js";import{ElevationData as Te,sampleElevation as Ee}from"./ElevationData.js";import{create as De}from"./ExtentHelper.js";import{LayerClasses as Oe}from"./LayerClass.js";import{OverlayManager as ke}from"./OverlayManager.js";import{PlanarPatch as Ae}from"./PlanarPatch.js";import{Queue as je}from"./Queue.js";import{ScaleRangeQueries as Me}from"./ScaleRangeQueries.js";import{SphericalPatch as Ne}from"./SphericalPatch.js";import{SplitLimits as Pe}from"./SplitLimits.js";import{maxRootTiles as k,tooManyRootTilesAfterChangeError as Fe,tooManyRootTilesForLayerError as Ie,maxTileNeighborLevelDelta as A,maxMemoryLodBias as Le}from"./TerrainConst.js";import{TerrainRenderer as Re}from"./TerrainRenderer.js";import ze from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as j,isVectorTileLayerView as M,internalAssert as N,oppositeEdge as Be,neighborEdgeIndices as P,isSurfaceLayerView as F,isGroupLayerView as I,isMapTileLayerView as L,isBlendableLayerView as R,isElevationLayerView as z,releaseTerrainData as B,oppositeCorner as Ve,enableTerrainInternalChecks as V,enableWaterproofTests as He,enableInternalTerrainChecks as Ue,enableTerrainWaterproofChecks as We,neighborCornerIndices as Ge}from"./terrainUtils.js";import{Tile as Ke,lijEquals as H}from"./Tile.js";import{printAllocations as qe}from"./TilePerLayerInfo.js";import{sortTiles as Je,IteratorPreorder as Ye,IteratorPostorder as Xe,compareTilesByLij as U,hasLoadableSiblings as Ze,sortTilesByPOI as Qe,traverseTilesPreorder as W}from"./tileUtils.js";import{TilingSchemeLogic as $e}from"./TilingSchemeLogic.js";import{getGroundTransparencyModeFromOpacity as et}from"./TransparencyMode.js";import{UpsampleInfo as tt}from"./UpsampleInfo.js";import{isCompositeBlendMode as nt,blendModeFromString as rt}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{hasLayerBasedScaleVisibility as it}from"../../support/layerViewUtils.js";import{ImmediateTask as G,TaskPriority as at,noBudget as ot}from"../../support/Scheduler.js";import{TextureCompressionTracker as st}from"../../support/TextureCompressionTracker.js";import{Yield as ct}from"../../support/Yield.js";var K;let q=class extends o{static{K=this}get allTilesCreated(){return this._allTilesCreated}get allTiles(){return a(this._allTiles)}get renderedTiles(){return Je(n(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get demResolution(){let{_allTiles:e,tilingScheme:t}=this;if(e.length===0)return{min:1,max:1};let n=ne(t.spatialReference),r=1/0,i=-1/0;for(let a of e){let e=t.resolutionAtLevel(a.level)*n;r=Math.min(r,e),i=Math.max(i,e)}return{min:r,max:i}}constructor(e){super(e),this.terrainTextureCompressionTracker=new st,this._iteratorPool=new d(()=>new Ye,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new Xe,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._allTilesCreated=!1,this._usedMemory=null,this._performanceInfo=new ze,this._waterproofnessErrorHandle=null,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=b(),this._eyePosSurfaceSR=b(),this._splitLimits=new Pe,this._layerViews=[[],[]],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._updatingHandles=new se,this._poiWatchHandle=null,this._frameTask=G,this._allTiles=new f,this._upsampleInfoPool=new d(()=>new tt),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=w(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=x.WebMercator,this._elevationProjectorCache=new Map,this.visibleElevationRange=new D(1/0,-1/0),this._rootTileElevationRange=new D(1/0,-1/0),this._projectorCache=new Map,this._tilingSchemeSpatialReference=null,this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1,this.enabled=!0;let{view:t}=e;this.overlayManager=new ke({...e,terrainSurface:this}),this._isGlobal=!t.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?Ne:Ae,this._ellipsoid=ce(t.spatialReference),this._renderer=new Re(this.overlayManager.renderer,t.stage,this._allTiles,this.terrainTextureCompressionTracker,t.resourceController.memoryController),it()||(this._scaleRangeQueries=new Me)}initialize(){let{view:e}=this,{resourceController:t}=e,{memoryController:n}=t;this._tileCache=new ee((e,t)=>n.newCache(e,t),`terrain-tile`),this._upsampleMapCache=n.newCache(`terrain-upsample`,({tile:e})=>e.unloadMapData()),this._elevationQueryCache=new ve(n.newCache(`elevation-query`));let r=this.overlayManager;this.addHandles([h(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),h(()=>this.renderer.visible,e=>this.freeze=!e),h(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)},g)],`overlayManager`),this._updatingHandles.add(()=>({heading:e.camera?.heading,state:e.state?.mode}),({heading:e,state:t})=>{if(e==null)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree){this.heading=Math.round(e/90)*90%360;return}let n=Math.round(e)%360,r=Math.abs(n-this.heading);(t===2||Math.min(r,360-r)>=30)&&(this.heading=n)},_),this.addHandles([h(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},g),h(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),g),h(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},v),h(()=>this.snapLevel,()=>this._viewChanged=!0,v),h(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._poiWatchHandle=l(this._poiWatchHandle),e&&(this._poiWatchHandle=this._updatingHandles.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:ie}))}),h(()=>E.TERRAIN_TILE_TREE_SHOW_TILES,t=>{t&&!this._treeDebugger?import(`../layers/support/TerrainTileTree3DDebugger.js`).then(({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&E.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))}):t||(this._treeDebugger=u(this._treeDebugger))},_)]);let{spatialReference:a}=e;this._extentHelper=De(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});let o=new i({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&`layers`in e?e.layers:null}),s=new $e({layers:o,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set(`tilingSchemeLogic`,s),this._updateTilingScheme();let c=t.scheduler;this._frameTask=c.registerTask(at.TERRAIN_SURFACE,this),this.addHandles([h(()=>this._extentHelper.stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),_),h(()=>this.tilingSchemeLogic.tilingScheme,()=>this._updateTilingScheme(),v),h(()=>this.groundExtent,()=>this._updateRootTiles(),_),e.on(`resize`,()=>this._viewChangeUpdate()),h(()=>{let t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),g),h(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,_),h(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,_),h(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>this._updateAllTileGeometries()),h(()=>this.userClippingExtent,()=>this._updateClippingExtent(),v)]),this.addHandles(e.allLayerViews.on(`after-changes`,()=>this._layerViewsDirty=!0)),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}clearHandles(){this._updatingHandles?.removeAll(),this.removeAllHandles(),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear()}destroy(){this._waterproofnessErrorHandle?.remove(),this._waterproofnessErrorHandle=null,this._frameTask.remove(),this._frameTask=G,this._updatingHandles?.destroy(),this._removeAllTiles(),this._set(`tilingSchemeLogic`,u(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._set(`overlayManager`,u(this.overlayManager)),this._tileCache=u(this._tileCache),this._allTiles.prune(),Ke.prune(),this._treeDebugger=u(this._treeDebugger),this._renderer.destroyed||this._renderer.destroy(),this._renderer=null,this._iteratorPool=u(this._iteratorPool),this._upsampleMapCache=u(this._upsampleMapCache),this._elevationQueryCache=u(this._elevationQueryCache),this._set(`view`,null),this._extentHelper=u(this._extentHelper),this._upsampleInfoPool=u(this._upsampleInfoPool),qe(),this._layerViews.forEach(e=>e.length=0),this._performanceInfo=null}get renderer(){return this._renderer}get frustum(){return this.view.state.camera.frustum}get snapLevel(){return this.lodSnappingEnabled?this.view.terrainLevel:null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return this._extentHelper.stencilEnabledExtents.length>0}get userClippingExtent(){let{spatialReference:e}=this,t=this.view?.clippingArea;if(t==null||e==null)return null;let n=w(),r=Ce(t,n,e)?n:null,i=this._get(`userClippingExtent`);return T(r,i)?i:r}get rootTilesExtent(){return this._rootTilesExtent}get groundExtent(){let e=de(this.fullGroundExtent,this.userClippingExtent,w()),t=this._get(`groundExtent`);return T(e,t)?t:e}get fullGroundExtent(){return this._tilingSchemeExtent==null?this._rootTilesExtent:this._tilingSchemeExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),this.enabled&&!!((this.readyToRun||this._updatingHandles?.updating||this._asyncWorkItems>0)&&this.ready&&!this.freeze||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get readyToRun(){return this.enabled&&(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._hasElevationSourceUpdates||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.freeze}get _hasElevationSourceUpdates(){return this._allTiles.some(e=>e.needsElevationSourceUpdate())}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return!this.enabled||this._rootTiles!=null}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set(`slicePlaneEnabled`,e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===0}get invisible(){return this._renderer.transparency===3}set freeze(e){this._set(`freeze`,e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,n,r){this._renderer.intersectRay(e,t,n,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}get _xNormalizer(){return he(this._spatialReference)}getElevation(e,t,n,r){let i=this._rootTiles;if(!i?.length||!this.enabled||i[0].layerInfo[0].length===0)return null;let a=this._elevationProjectorCache.get(r);if(a===void 0&&(a=S(r,this._spatialReference)??null,this._elevationProjectorCache.set(r,a)),a==null)return s.getLogger(this).error(`TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system`),null;let o=ae(J,e,t,n);a(o,0,o,0);let c=this._xNormalizer?.normalize(o[0])??o[0],l=o[1];return ft(i,c,l)}getElevations(e,t,n){let r=this._rootTiles,i=r?r[0].layerInfo[0].length:0;if(!r?.length||i===0||!this.enabled)for(let e=0;e<t;++e)n(e,null);else for(let i=0;i<t;++i){let t=i*3,a=e[t],o=e[t+1],s=ft(r,a,o);n(i,s)}}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}getScale(e){if(!this.tilingScheme)return null;if(!C(e,J,this.spatialReference))return s.getLogger(this).error(`TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system`),null;let t=this._rootTiles;if(t!=null){for(let e of t)if(e?.containsPoint(J)){let t=e;for(;t.children[0]&&!t.rendered;){let e=t.children[0].extent,n=0;J[0]>e[2]&&(n+=1),J[1]<e[1]&&(n+=2),t=t.children[n]}return this._getLodBiasCorrectedScale(t.level)}}return 1/0}_ensureProjector(e){let t=this._projectorCache.get(e);if(t)return t;let n=S(e,this._tilingSchemeSpatialReference)??null;return this._projectorCache.set(e,n),n}getSphereElevationRange(e,t){if(!this.enabled||this._rootTiles==null)return null;let n=this._ensureProjector(t);if(n==null)return s.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project given point to tiling scheme coordinate system`),null;Y.copyFrom(e),n(Y.center,0,Y.center,0);let r=new D,i=this._rootTiles;if(i!=null){let e=[];for(let t of i)e.push(t);let t=0;for(;t<e.length;){let n=e[t];if(++t,!fe(n.extent,Y))continue;let i=n.children;if(i[0]==null||n.rendered)r.expandElevationRangeValues(n.elevationBoundsMin,n.elevationBoundsMax);else for(let t of i)e.push(t)}}return r}getRootElevationRange(){return this.enabled&&this._rootTiles!=null?new D(this._rootTileElevationRange.minElevation,this._rootTileElevationRange.maxElevation):null}getLowerBoundRadius(){let e=(this._ellipsoid.radius+this.visibleElevationRange.minElevation)*le;return Math.min(e,this._ellipsoid.radius)}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!C(e,Y.center,this.spatialReference))return s.getLogger(this).error(`TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system`),null;Y.radius=t;let n=null,r=e=>{if(e&&fe(e.extent,Y)){let t=e.children;if(t[0]&&!e.rendered)for(let e of t)r(e);else{let t=this._getLodBiasCorrectedScale(e.level);n=n==null?t:Math.min(n,t)}}},i=this._rootTiles;if(i!=null)for(let e of i)r(e);return n}queryVisibleScaleRange(e,t,n,r){if(!this._scaleRangeQueries)return;let i=t?this.tilingScheme.levelAtScale(t):0,a=n?this.tilingScheme.levelAtScale(n):1/0,o=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,i+o,a+o,r)}_evaluateTransparency(){let e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,n=this._renderer.transparency,r=this._isFullyTransparent?et(0,t):e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?0:1;return this._renderer.transparency=r,n!==r&&(this.notifyChange(`opaque`),this.notifyChange(`invisible`),!0)}_updateTilingScheme(){let{tilingScheme:e}=this.tilingSchemeLogic;if(e===this.tilingScheme)return;j(!!e,`tiling scheme cannot be reset to undefined`),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();let t=e?.spatialReference??x.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&ge(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,this._set(`tilingScheme`,e),this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference,this._projectorCache.clear(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey=`TerrainTileMemcache`}_acquireTile(e,t,n,r){let i=this._tileCache.pop(K._tileMemcacheKey);return i?(i.init(e,t,n,r,this),i):new this._tileConstructor(e,t,n,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){let{groundExtent:e,tilingScheme:t}=this;if(!t)return;if(!this.enabled){this._setRootTiles(null);return}let n=ut,i=t.rootTilesInExtent(e,n,k*5);if(this._rootTiles!=null){if(i.length>k){s.getLogger(this).warn(Fe);return}let e=this._rootTiles.map(e=>e.lij),t=r(e,i,H);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){let e=this._rootTiles.filter(e=>t.removed.findIndex(t=>H(t,e.lij))>-1?(this._purgeTile(e),!1):!0);t.added.forEach(t=>e.push(this._newRootTile(t))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,i.length>k&&(s.getLogger(this).warn(Ie),i=t.rootTilesInExtent(e,n,k)),this._setRootTiles(i.map(e=>this._newRootTile(e)));T(n,this._rootTilesExtent)||(this._rootTilesExtent=w(n)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange(`ready`),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness(`root-tiles-updated`)}_updateAllTileGeometries(){let e=this._allTiles.filter(e=>this._canUpdateTileGeometry(e));e.length===0||(e.sort(U),e.forEach(e=>this._renderer.updateTileGeometryState(e)),e.forEach(e=>e.renderData.updateNeighborData()),this._updateTilesGeometries(e)),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){let t=e.filter(e=>this._canUpdateTileGeometry(e));if(t.length===0)return;let n=this.renderer;for(let e of t)n.updateGeometryIfNeeded(e);for(let e of t)this._pendingTilesForElevationUpdateEvent.add(e)}_canUpdateTileGeometry(e){return e.loaded&&e.intersectsClippingArea&&e.hasGeometryState}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===1}_newRootTile(e){let t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(1),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationRange(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),e!=null){let t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.freeze&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.groundExtent)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(e==null)return;let t=Ze(e),n=this.visibleElevationRange,r=t?n.minElevation:1/0,i=t?n.maxElevation:-1/0,a=this.groundExtent,o=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty(!1);let s=this._iteratorPool.acquire();for(s.reset(e);!s.done;){let e=s.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(o),e.renderData&&(r=Math.min(e.elevationBoundsMin,r),i=Math.max(e.elevationBoundsMax,i))}s.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(i)&&(n.minElevation!==r||n.maxElevation!==i)&&(this.visibleElevationRange=new O(r,i))}_updateRootTileElevationRange(){let e=1/0,t=-1/0;this._rootTiles?.forEach(({elevationBoundsMin:n,elevationBoundsMax:r})=>{e=Math.min(e,n),t=Math.max(t,r)});let n=this._rootTileElevationRange;(n.minElevation!==e||n.maxElevation!==t)&&(this._rootTileElevationRange=new O(e,t))}_updateViewDependentParameters(){let{camera:e,contentCamera:t}=this.view.state,n=Math.tan(t.fovX*.5),r=Math.tan(t.fovY*.5),i=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=n,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=i/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=i/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=pe(this._splitLimits.frustum??me(),t.frustum):this._splitLimits.frustum=null,oe(this._eyePosRenderSR,t.eye),ue(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility();let t=this._renderer.updateTileGeometryState(e);e.needsElevationSourceUpdate()&&(e.updateAgents(0),e.markElevationSourceUpdateRequested(),this.requestUpdate()),t&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){e.forEachLoadedNeighbor(e=>{this._layerViews[1].some(M)&&e.setPendingUpdate(32),this._pendingTilesToUpdate.add(e)})}_updateTileTexture(e,t){let n=e.resetPendingUpdate(32)?32:e.resetPendingUpdate(16)?16:!1;n&&(this._renderer.updateTileTexture(e,n),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;let e=this._pendingTilesForElevationUpdateEvent;if(e.size>0){let t=new Float64Array(4*e.size),n=0;for(let r of e)t.set(r.extent,4*n),++n;e.clear();for(let e of Se(t,this.spatialReference)){let t=new xe(this.spatialReference,e,`ground`);this.emit(`elevation-change`,t)}}this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);let t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),this._updateElevation(e),this._updateElevationSources(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty();let n=this._pendingTilesToUpdate.size>0,r=n&&this._hasPendingGeometryWithoutIndices();if((!e.done||r)&&this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&(e.hasProgressed||n&&!r)&&this.requestUpdate(),this.notifyChange(`updatingProgressValue`),!e.hasProgressed)return ct}_checkTileInvariant(){}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;let t=!1,n=new je(this._allTiles.length);n.pushAll(this._rootTiles);let r=this.snapLevel,i=this._splitLimits,a=this._eyePosRenderSR;this._allTiles.forAll(e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0});let o=this.view.state.contentCamera.viewProjectionMatrix;for(;!n.empty;){let e=n.pop(),s=e.parent?.hasPendingUpdate(4),c=s?4:e.shouldSplit(i,a,r),l=c===1;e.leaf?Z(e,l):n.pushAll(e.children),s?(e.resetPendingUpdate(1),e.leaf||(e.setPendingUpdate(4),t=!0),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(o)):l?(e.resetPendingUpdate(4),e.leaf&&(e.setPendingUpdate(1),t=!0)):(e.resetPendingUpdate(1)&&e.updateAgentSuspension(),c===2&&e.updateAgents(0),e.leaf||(e.setPendingUpdate(4),e.resetPendingUpdate(1),t=!0))}this._allTilesDirty=t,this.requestUpdate(),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){!e.done&&!this._allTilesSorted&&this.view.pointsOfInterest?.focus&&(Qe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger?.update(),e.madeProgress())}_markTileToUpdate(e){N(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_hasPendingGeometryWithoutIndices(){for(let e of this._pendingTilesToUpdate)if(e.loaded&&e.intersectsClippingArea&&e.renderData?.vao?.indexBuffer==null)return!0;return!1}_updatePendingTileGeometries(){let e=this._pendingTilesToUpdate,t=[];if(e.forEach(e=>{this._canUpdateTileGeometry(e)&&t.push(e)}),t.length===0){e.clear();return}let n=(n,r)=>{!r||!this._canUpdateTileGeometry(r)||r.level<n.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(U);let r=t.length;for(let i=0;i<r;++i){let r=t[i];N(r.loaded),N(r.intersectsClippingArea);let a=r.renderData;if(!a?.geometryState)continue;a.updateNeighborData();let o=a.dirtyEdgeResolutions,s=a.geometryState,c=e=>{let t=Ge[e];n(r,s.cornerPeerNeighbors[e]?.findCorner(Ve(t),e=>e.loaded))};for(let t=0;t<4;++t)if(o&1<<t){let i=a.geometryState.edgePeerNeighbors[t];i&&i?.level>=r.level&&i.forAllSubtreeOnSide(Be(P[t]),t=>this._canUpdateTileGeometry(t)?(N(e.has(t)||U(r,t)<0),n(r,t),!0):!1),c((t+1)%4),c(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,V&&He&&this.checkAllTilesWaterproofness(`pending-geometries-updated`)}_mergeAndSplit(e,t){if(this.freeze||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let n=!1,r=this.view.state.fixedContentCamera,i=!1;for(;!e.done;){i=!0;let a=!1,o=!this._allTiles.some(i=>{if(!n&&!r&&!i.visible)return e.done;let o=i;if(i.hasPendingUpdate(4)){if(!t||i.unmergableChildCount>0)return e.done;for(i.resetPendingUpdate(4);o.parent!=null&&o.parent.unmergableChildCount===0&&o.parent.resetPendingUpdate(4);)o=o.parent;this._mergeTile(o),a=!0,e.madeProgress()}else if(i.resetPendingUpdate(1)){let t=!0,n=i.level;if(n>=A){let e=e=>e.leaf||n-e.level<A;for(let r=0;r<4;++r){let a=i.findNeighborTile(P[r],e);a!=null&&n-a.level===A&&(t=!1,V&&(N(a.leaf),N(a.hasPendingUpdate(1))))}}t?(this._splitTile(i),e.madeProgress(),a=!0):i.setPendingUpdate(1)}return e.done});if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0),o){if(!n){n=!0;continue}if(!a)break}else this._allTilesDirty=!0}i?e.madeProgress():this._allTilesDirty=!0,this._allTilesCreated=!this.allTiles.some(e=>e.hasPendingUpdate(1)||e.hasPendingUpdate(4)&&e.unmergableChildCount===0),this._sortTiles(e)}_updateElevation(e){e.done||this._allTiles.some(t=>(t.resetPendingUpdate(8)&&(this._updateTileGeometryState(t),e.madeProgress()),e.done))}_updateElevationSources(e){e.done||this._allTiles.some(t=>(t.needsElevationSourceUpdate()&&(t.updateAgents(0),t.markElevationSourceUpdateRequested(),e.madeProgress()),e.done))}_updateTextures(e){e.done||this._allTiles.some(t=>(this._updateTileTexture(t,e),e.done))}_updateClippingExtent(){this.spatialReference&&(this.updateOverlayParameters(),this.requestRender(1),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){return this.view.qualitySettings.tiledSurface.lodBias-(1-this.view.quality)*Le}_getLodBiasCorrectedScale(e){let t=this.tilingScheme.levels,n=c(e-this._lodBias,0,t.length-1),r=n-Math.floor(n),i=t[Math.floor(n)].scale,a=t[Math.ceil(n)].scale;return i*(1-r)+a*r}_removeAllTiles(){this._pendingTilesToUpdate.clear(),this._pendingTilesForElevationUpdateEvent.clear(),this._rootTiles!=null&&(this._rootTiles.forEach(e=>this._purgeTile(e)),this._setRootTiles(null),this.notifyChange(`ready`)),this._allTiles.clear(),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles}),this.renderer.visible=!1}_purgeSubtree(e){let t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?mt(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(K._tileMemcacheKey,e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){j(e.leaf,`Tile that is already split should not be split again!`),j(e.rendered,`Tile marked to split is not rendered`),mt(e);let t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles}),e.updateAgentSuspension(),j(e.rendered,`parent should be rendered`),t.forEach(e=>this._loadTile(e)),t.forEach(e=>this._pendingTilesToUpdate.add(e)),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach(e=>Z(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){X.spatialReference=this.spatialReference,X.extent=e.extent,X.scale=this._getLodBiasCorrectedScale(t),this.emit(`scale-change`,X)}createTile(e,t,n,r){j(!!r,`createTile sanity check`);let i=this._acquireTile(e,t,n,r);return i.updateClippingStatus(this.groundExtent),i.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(i)&&i.setPendingUpdate(1),i}get _shortBatches(){return this.view.state.mode!==2}_mergeTile(e){j(!e.hasPendingUpdate(1),`_mergeTile sanity check`),j(!e.leaf,`Cannot merge a leaf`),!e.leaf&&(this._purgeSubtree(e),j(!e.renderData,`Merging tile with existing render data?`),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),Z(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&e.updateOverlayParameters(this.overlayManager)}_handleLayerViewChanges(e=ot){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1,n=new Set,r=-1;for(let e=this.view.allLayerViews.length-1;e>=0;e--){let i=this.view.allLayerViews.items[e];if(n.add(i.uid),F(i)||I(i)){if(this._basemapLayerViewHandles.has(i.uid)&&!I(i)){let e=this._layerClassFromLayerView(i),n=this.getLayerIndexByUID(e,i.uid);n!=null&&((n<r||r==null)&&(t=!0),r=n)}else this._registerTiledLayerView(i),i.layer.loaded&&(t=!0)}}this._basemapLayerViewHandles.forEach((e,r)=>{n.has(r)||(this._unregisterTiledLayerView(r),t=!0)}),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(let e of this.view.allLayerViews.items)if(L(e)&&!ye(e.layer)&&e.fullOpacity!==0)return!1;return!0}_hasCompositeBlendMode(){for(let e of this.view.allLayerViews.items)if((R(e)||I(e))&&nt(rt[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return+!z(e)}_registerTiledLayerView(e){let t=[];if((R(e)||I(e))&&t.push(h(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!I(e)){let n=this._layerClassFromLayerView(e);t.push(h(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(h(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));let{layer:r}=e;`effectiveScaleRange`in r&&t.push(h(()=>!e.destroyed&&r.effectiveScaleRange,()=>this._restartAllAgents(n))),t.push(e.on(`data-changed`,()=>{let t=this.getLayerIndexByUID(n,e.uid);t!=null&&this._invalidateLayerData(t,n)}))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){let t=this._basemapLayerViewHandles.get(e);if(t){for(let e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;let e=this.view.allLayerViews,t=[[],[]],n=null;e.forEach(e=>{if(!e.layer||e.suspended||!F(e)||!e.fullExtent)return;let r=this._layerClassFromLayerView(e);if(r===1){let t=e.displayLevelRange.maxLevel;t!==1/0&&(n===null||t>n)&&(n=t)}t[r].push(e)});for(let e of Oe){let n=this._layerViews[e],r=t[e];r.reverse();let i=r.length,a=n.length!==i,o=Array(i),s=Array(n.length);this._layerIndexByUid[e].clear();for(let t=0;t<i;t++){let i=r[t].uid;this._layerIndexByUid[e].set(i,t);let c=n.indexOf(r[t]);o[t]=c,t!==c&&(a=!0),c>-1&&(s[c]=t)}if(a){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;)t.next().modifyLayers(s,o,e);this._layerViews[e]=r,this._restartAllAgents(e),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(n)&&(this._viewChangeUpdate(),this.notifyChange(`tilingScheme`))}_restartAllAgents(e){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){let n=t.next();n.restartAgents(e),e===0&&n.computeElevationBounds()}this._updateRootTileElevationRange()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll(t=>{t.updateAgents(1),e===1?this.renderer.updateTileTexture(t,16):t.updateRenderData(1,e)}),this._evaluateTransparency()}_invalidateLayerData(e,t){this._rootTiles!=null&&(W(this._rootTiles,n=>n.removeLayerAgent(e,t)),W(this._rootTiles,n=>{n.invalidateLayerData(e,t),n.restartAgents(t)}))}setTileTreeDirty(e){this._allTilesDirty=!0,e&&(this._allTilesCreated=!1)}requestRender(e=1){this.renderer.setNeedsRender(e)}requestUpdate(){++this._pendingUpdates===1&&(this._hasPendingUpdates=!0)}requestTileData(e,t,n,r){let i=this.layerViewByIndex(t,n),{tilemapCache:a}=i;return!a||M(i)?this._requestTileData(e,n,i,r):(++this._asyncWorkItems,a.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).catch(t=>{throw te(r),p(t)||this._dataMissing(e,n,i),t}).then(()=>this._frameTask.schedule(()=>this._requestTileData(e,n,i,r),r.signal)).finally(()=>--this._asyncWorkItems))}_requestTileData(e,t,n,r){return this.destroying?Promise.resolve():t===0?z(n)?this._requestElevationTileData(e,n,r):Promise.reject():L(n)?this._requestMapTileData(e,n,r):Promise.reject()}_requestElevationTileData(e,t,n){++this._asyncWorkItems;let r=r=>{!m(n)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},i=n=>{p(n)||(s.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${n}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,{...be,...n}).then(e=>this._frameTask.schedule(()=>r(e)),i).finally(()=>--this._asyncWorkItems)}_elevationDataArrived(e,t,n){let r=this._layerIndexByUid[0].get(t.uid);if(r==null){s.getLogger(this).warn(`TerrainSurface: received data from unknown layer %d %s`,0,e.lij.toString());return}let i=new Te(e.lij,e.extent,n);e.dataArrived(r,0,i),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:0});let a=[e],o=e.level,c=this._iteratorPool.acquire();for(c.reset(a);!c.done;){let e=c.next();e.findElevationBoundsForLayer(r,o),e.computeElevationBounds()}o===0&&this._updateRootTileElevationRange(),c.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,n){++this._asyncWorkItems;let r=(r,i)=>{B(i),m(n)||(console.error(`Tile ${e.lij.toString()} layer 1/${t.uid} error ${r}`),this._dataMissing(e,1,t),this.requestUpdate())},i=e=>t=>r(t,e);return t.fetchTile(e.lij,n).then(r=>this._frameTask.schedule(()=>{this.requestUpdate(),m(n)?B(r):this._mapTileDataArrived(e,t,r)},n.signal,i(r)).catch(i(r)),(e,t=null)=>this._frameTask.schedule(()=>r(e,t))).finally(()=>--this._asyncWorkItems)}_mapTileDataArrived(e,t,n){let r=this.getLayerIndexByUID(1,t.uid);r==null?(B(n),s.getLogger(this).warn(`TerrainSurface: received data from unknown layer`)):(e.dataArrived(r,1,n),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:1}))}_dataMissing(e,t,n){let r=this.getLayerIndexByUID(t,n.uid);r==null?s.getLogger(this).warn(`TerrainSurface: received data from unknown layer`):(e.dataMissing(r,t),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:t}))}get performanceInfo(){let e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll(t=>{t.leaf&&e.numLeaves++;let n=t.level;t.renderData&&(e.numLoadedPerLevel[n]=(e.numLoadedPerLevel[n]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[n]=(e.numRenderedPerLevel[n]||0)+1,e.numRendered++))}),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(this._usedMemory??=this._recalculateUsedMemory(),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce((e,t)=>e+t.usedMemory,0)):null}getUsedMemoryForLayerView(e){let t=0,n=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(n,e.uid);return r!=null&&this._allTiles.forAll(e=>t+=e.getUsedMemoryForLayer(n,r)),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(e=`render-patch-groups`){}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&e[2]===0}lijEastEnd(e){return 1<<e+ +!!this._isGeographic}wrapEastWest(e){let t=this.lijEastEnd(e[0]),n=e[2];if(0<=n&&n<t)return e;if(!this._isGlobal)return null;let r=(n+(n<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){Ue(e)}enableWaterproofnessChecks(e){We(e)}static cleanupTerrainSurface(){dt.prune()}enable(e){e!==this.enabled&&(this._set(`enabled`,e),e?(this._updateRootTiles(),this.freeze=!1,this.view.elevationProvider.register(0,this)):(this.view.elevationProvider.unregister(this),this.freeze=!0,this._removeAllTiles(),this._setRootTiles(null)),this.notifyChange(`ready`))}updateOverlayParameters(){let{overlayManager:e}=this;this.allTiles.forAll(t=>t.updateOverlayParameters(e))}};e([y()],q.prototype,`_renderer`,void 0),e([y({constructOnly:!0})],q.prototype,`_scaleRangeQueries`,void 0),e([y({constructOnly:!0})],q.prototype,`view`,void 0),e([y({constructOnly:!0})],q.prototype,`overlayManager`,void 0),e([y({constructOnly:!0})],q.prototype,`terrainTextureCompressionTracker`,void 0),e([y()],q.prototype,`_hasPendingUpdates`,void 0),e([y()],q.prototype,`_asyncWorkItems`,void 0),e([y()],q.prototype,`_allTilesDirty`,void 0),e([y()],q.prototype,`_allTilesSorted`,void 0),e([y()],q.prototype,`allTilesCreated`,null),e([y()],q.prototype,`_allTilesCreated`,void 0),e([y()],q.prototype,`_viewChanged`,void 0),e([y({type:Number})],q.prototype,`heading`,void 0),e([y()],q.prototype,`_splitLimits`,void 0),e([y()],q.prototype,`_frameTask`,void 0),e([y()],q.prototype,`demResolution`,null),e([y({readOnly:!0})],q.prototype,`snapLevel`,null),e([y({readOnly:!0})],q.prototype,`lodSnappingEnabled`,null),e([y({readOnly:!0})],q.prototype,`userClippingExtent`,null),e([y()],q.prototype,`_rootTilesExtent`,void 0),e([y({readOnly:!0})],q.prototype,`groundExtent`,null),e([y({readOnly:!0})],q.prototype,`fullGroundExtent`,null),e([y({readOnly:!0})],q.prototype,`_tilingSchemeExtent`,null),e([y({readOnly:!0})],q.prototype,`updating`,null),e([y({readOnly:!0})],q.prototype,`readyToRun`,null),e([y(we)],q.prototype,`updatingProgress`,void 0),e([y({readOnly:!0})],q.prototype,`updatingProgressValue`,null),e([y()],q.prototype,`_maxNumUpdating`,void 0),e([y()],q.prototype,`baseOpacity`,null),e([y()],q.prototype,`hasCompositeBlendMode`,void 0),e([y({readOnly:!0})],q.prototype,`viewingMode`,null),e([y()],q.prototype,`maxTextureScale`,void 0),e([y({readOnly:!0})],q.prototype,`ready`,null),e([y({readOnly:!0})],q.prototype,`rootTiles`,null),e([y()],q.prototype,`_rootTiles`,void 0),e([y({readOnly:!0})],q.prototype,`spatialReference`,null),e([y({type:t})],q.prototype,`backgroundColor`,null),e([y({value:!1})],q.prototype,`slicePlaneEnabled`,null),e([y({readOnly:!0})],q.prototype,`tilingScheme`,void 0),e([y({readOnly:!0})],q.prototype,`tilingSchemeLocked`,null),e([y({readOnly:!0})],q.prototype,`tilingSchemeLogic`,void 0),e([y()],q.prototype,`wireframe`,null),e([y()],q.prototype,`opaque`,null),e([y()],q.prototype,`invisible`,null),e([y({value:!1})],q.prototype,`freeze`,null),e([y()],q.prototype,`fadeDuration`,null),e([y()],q.prototype,`_xNormalizer`,null),e([y()],q.prototype,`visibleElevationRange`,void 0),e([y()],q.prototype,`_rootTileElevationRange`,void 0),e([y()],q.prototype,`_layerViewsDirty`,void 0),e([y()],q.prototype,`renderPatchBorders`,null),e([y()],q.prototype,`renderingDisabled`,null),e([y({readOnly:!0})],q.prototype,`enabled`,void 0),q=K=e([re(`esri.views.3d.terrain.TerrainSurface`)],q);const lt=q,J=b(),Y=new _e,ut=w(),dt=new f,X={spatialReference:null,extent:null,scale:0};function ft(e,t,n){for(let r of e){if(!r.containsPointXY(t,n))continue;let e=r;for(;e&&!e.renderData;){let r=+(t>e.extentMidX)+(n<e.extentMidY?2:0);e=e.children[r]}let i=e?.renderData?.geometryState.samplerData??null;return Ee(t,n,i)}return null}function Z(e,t){!e.leaf||e.level<A||$(e,e=>{t&&pt(e);let n=Q(e);if(e.maxLevelDeltaNeighborCount++,n){let t=e.parent;for(;t;){let e=Q(t);if(t.unmergableChildCount++,e)t=t.parent;else break}}})}function pt(e){if(e.hasPendingUpdate(1))return;let t=e.parent;for(;t?.resetPendingUpdate(4);)t=t.parent;e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1),!(e.level<A)&&$(e,e=>{pt(e)})}function mt(e){e.level<A||$(e,e=>{if(e.maxLevelDeltaNeighborCount--,e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0){let t=e.parent;for(;t&&(t.unmergableChildCount--,Q(t));)t=t.parent}})}function Q(e){return e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0}function $(e,t){if(e.level<A)return;let n=e.level-A,r=e.lij[1]>>A,i=e.lij[2]>>A,a=e=>e.leaf||e.level===n;for(let o=0;o<4;++o){let s=e.findNeighborTile(P[o],a);if(!s||s.level!==n)continue;let c=s.lij;(c[1]!==r||c[2]!==i)&&t(s)}}export{lt as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../Color.js";import{filterInPlace as n,difference as r}from"../../../core/arrayUtils.js";import i from"../../../core/CollectionFlattener.js";import{toConst as a}from"../../../core/compilerUtils.js";import{EventedAccessor as o}from"../../../core/Evented.js";import"../../../core/has.js";import s from"../../../core/Logger.js";import{clamp as c}from"../../../core/mathUtils.js";import{removeMaybe as l,destroyMaybe as u}from"../../../core/maybe.js";import{MemCachePool as ee}from"../../../core/MemCachePool.js";import d from"../../../core/ObjectPool.js";import f from"../../../core/PooledArray.js";import{throwIfAborted as te,isAbortError as p,isAborted as m}from"../../../core/promiseUtils.js";import{watch as h,syncAndInitial as g,initial as _,sync as v}from"../../../core/reactiveUtils.js";import"../../../core/scheduling.js";import{getMetersPerUnitForSR as ne}from"../../../core/units.js";import{property as y,subclass as re}from"../../../core/accessorSupport/decorators.js";import{exactEquals as ie,set as ae,copy as oe}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as se}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as ce,radiusModifier as le}from"../../../geometry/ellipsoidUtils.js";import x from"../../../geometry/SpatialReference.js";import{getProjector as S}from"../../../geometry/projection/projectors.js";import{projectPointToVector as C}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as ue}from"../../../geometry/projection/projectVectorToVector.js";import{create as w,equals as T,intersection as de,intersectsSphere as fe}from"../../../geometry/support/aaBoundingRect.js";import{copy as pe,create as me}from"../../../geometry/support/frustumPlanes.js";import{createSpatialReferenceCyclical as he}from"../../../geometry/support/normalizeUtils.js";import{isPlateCarree as ge}from"../../../geometry/support/spatialReferenceUtils.js";import{Sphere as _e}from"../../../geometry/support/sphere.js";import{ElevationQueryTileCache as ve}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as ye}from"../../../layers/support/layerUtils.js";import{queueHighPriority as be}from"../../../request/queue.js";import{debugFlags as E}from"../support/debugFlags.js";import{ElevationRange as D}from"../support/ElevationRange.js";import{ElevationUpdateEvent as xe}from"../support/ElevationUpdateEvent.js";import{calculateElevationUpdateExtents as Se}from"../support/elevationUpdateExtentUtils.js";import{toBoundingRect as Ce}from"../support/extentUtils.js";import{updatingProgress as we}from"../support/updatingProperties.js";import{ElevationBounds as O}from"./ElevationBounds.js";import{ElevationData as Te,sampleElevation as Ee}from"./ElevationData.js";import{create as De}from"./ExtentHelper.js";import{LayerClasses as Oe}from"./LayerClass.js";import{OverlayManager as ke}from"./OverlayManager.js";import{PlanarPatch as Ae}from"./PlanarPatch.js";import{Queue as je}from"./Queue.js";import{ScaleRangeQueries as Me}from"./ScaleRangeQueries.js";import{SphericalPatch as Ne}from"./SphericalPatch.js";import{SplitLimits as Pe}from"./SplitLimits.js";import{maxRootTiles as k,tooManyRootTilesAfterChangeError as Fe,tooManyRootTilesForLayerError as Ie,maxTileNeighborLevelDelta as A,maxMemoryLodBias as Le}from"./TerrainConst.js";import{TerrainRenderer as Re}from"./TerrainRenderer.js";import ze from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as j,isVectorTileLayerView as M,internalAssert as N,oppositeEdge as Be,neighborEdgeIndices as P,isSurfaceLayerView as F,isGroupLayerView as I,isMapTileLayerView as L,isBlendableLayerView as R,isElevationLayerView as z,releaseTerrainData as B,oppositeCorner as Ve,enableTerrainInternalChecks as V,enableWaterproofTests as He,enableInternalTerrainChecks as Ue,enableTerrainWaterproofChecks as We,neighborCornerIndices as Ge}from"./terrainUtils.js";import{Tile as Ke,lijEquals as H}from"./Tile.js";import{printAllocations as qe}from"./TilePerLayerInfo.js";import{sortTiles as Je,IteratorPreorder as Ye,IteratorPostorder as Xe,compareTilesByLij as U,hasLoadableSiblings as Ze,sortTilesByPOI as Qe,traverseTilesPreorder as W}from"./tileUtils.js";import{TilingSchemeLogic as $e}from"./TilingSchemeLogic.js";import{getGroundTransparencyModeFromOpacity as et}from"./TransparencyMode.js";import{UpsampleInfo as tt}from"./UpsampleInfo.js";import{isCompositeBlendMode as nt,blendModeFromString as rt}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{hasLayerBasedScaleVisibility as it}from"../../support/layerViewUtils.js";import{ImmediateTask as G,TaskPriority as at,noBudget as ot}from"../../support/Scheduler.js";import{TextureCompressionTracker as st}from"../../support/TextureCompressionTracker.js";import{Yield as ct}from"../../support/Yield.js";var K;let q=class extends o{static{K=this}get allTilesCreated(){return this._allTilesCreated}get allTiles(){return a(this._allTiles)}get renderedTiles(){return Je(n(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get demResolution(){let{_allTiles:e,tilingScheme:t}=this;if(e.length===0)return{min:1,max:1};let n=ne(t.spatialReference),r=1/0,i=-1/0;for(let a of e){let e=t.resolutionAtLevel(a.level)*n;r=Math.min(r,e),i=Math.max(i,e)}return{min:r,max:i}}constructor(e){super(e),this.terrainTextureCompressionTracker=new st,this._iteratorPool=new d(()=>new Ye,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new Xe,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._allTilesCreated=!1,this._usedMemory=null,this._performanceInfo=new ze,this._waterproofnessErrorHandle=null,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=b(),this._eyePosSurfaceSR=b(),this._splitLimits=new Pe,this._layerViews=[[],[]],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._updatingHandles=new se,this._poiWatchHandle=null,this._frameTask=G,this._allTiles=new f,this._upsampleInfoPool=new d(()=>new tt),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=w(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=x.WebMercator,this._elevationProjectorCache=new Map,this.visibleElevationRange=new D(1/0,-1/0),this._rootTileElevationRange=new D(1/0,-1/0),this._projectorCache=new Map,this._tilingSchemeSpatialReference=null,this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1,this.enabled=!0;let{view:t}=e;this.overlayManager=new ke({...e,terrainSurface:this}),this._isGlobal=!t.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?Ne:Ae,this._ellipsoid=ce(t.spatialReference),this._renderer=new Re(this.overlayManager.renderer,t.stage,this._allTiles,this.terrainTextureCompressionTracker,t.resourceController.memoryController),it()||(this._scaleRangeQueries=new Me)}initialize(){let{view:e}=this,{resourceController:t}=e,{memoryController:n}=t;this._tileCache=new ee((e,t)=>n.newCache(e,t),`terrain-tile`),this._upsampleMapCache=n.newCache(`terrain-upsample`,({tile:e})=>e.unloadMapData()),this._elevationQueryCache=new ve(n.newCache(`elevation-query`));let r=this.overlayManager;this.addHandles([h(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),h(()=>this.renderer.visible,e=>this.freeze=!e),h(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)},g)],`overlayManager`),this._updatingHandles.add(()=>({heading:e.camera?.heading,state:e.state?.mode}),({heading:e,state:t})=>{if(e==null)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree){this.heading=Math.round(e/90)*90%360;return}let n=Math.round(e)%360,r=Math.abs(n-this.heading);(t===2||Math.min(r,360-r)>=30)&&(this.heading=n)},_),this.addHandles([h(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},g),h(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),g),h(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},v),h(()=>this.snapLevel,()=>this._viewChanged=!0,v),h(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._poiWatchHandle=l(this._poiWatchHandle),e&&(this._poiWatchHandle=this._updatingHandles.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:ie}))}),h(()=>E.TERRAIN_TILE_TREE_SHOW_TILES,t=>{t&&!this._treeDebugger?import(`../layers/support/TerrainTileTree3DDebugger.js`).then(({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&E.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))}):t||(this._treeDebugger=u(this._treeDebugger))},_)]);let{spatialReference:a}=e;this._extentHelper=De(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});let o=new i({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&`layers`in e?e.layers:null}),s=new $e({layers:o,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set(`tilingSchemeLogic`,s),this._updateTilingScheme();let c=t.scheduler;this._frameTask=c.registerTask(at.TERRAIN_SURFACE,this),this.addHandles([h(()=>this._extentHelper.stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),_),h(()=>this.tilingSchemeLogic.tilingScheme,()=>this._updateTilingScheme(),v),h(()=>this.groundExtent,()=>this._updateRootTiles(),_),e.on(`resize`,()=>this._viewChangeUpdate()),h(()=>{let t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),g),h(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,_),h(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,_),h(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>this._updateAllTileGeometries()),h(()=>this.userClippingExtent,()=>this._updateClippingExtent(),v)]),this.addHandles(e.allLayerViews.on(`after-changes`,()=>this._layerViewsDirty=!0)),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}clearHandles(){this._updatingHandles?.removeAll(),this.removeAllHandles(),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear()}destroy(){this._waterproofnessErrorHandle?.remove(),this._waterproofnessErrorHandle=null,this._frameTask.remove(),this._frameTask=G,this._updatingHandles?.destroy(),this._removeAllTiles(),this._set(`tilingSchemeLogic`,u(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._set(`overlayManager`,u(this.overlayManager)),this._tileCache=u(this._tileCache),this._allTiles.prune(),Ke.prune(),this._treeDebugger=u(this._treeDebugger),this._renderer.destroyed||this._renderer.destroy(),this._renderer=null,this._iteratorPool=u(this._iteratorPool),this._upsampleMapCache=u(this._upsampleMapCache),this._elevationQueryCache=u(this._elevationQueryCache),this._set(`view`,null),this._extentHelper=u(this._extentHelper),this._upsampleInfoPool=u(this._upsampleInfoPool),qe(),this._layerViews.forEach(e=>e.length=0),this._performanceInfo=null}get renderer(){return this._renderer}get frustum(){return this.view.state.camera.frustum}get snapLevel(){return this.lodSnappingEnabled?this.view.terrainLevel:null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return this._extentHelper.stencilEnabledExtents.length>0}get userClippingExtent(){let{spatialReference:e}=this,t=this.view?.clippingArea;if(t==null||e==null)return null;let n=w(),r=Ce(t,n,e)?n:null,i=this._get(`userClippingExtent`);return T(r,i)?i:r}get rootTilesExtent(){return this._rootTilesExtent}get groundExtent(){let e=de(this.fullGroundExtent,this.userClippingExtent,w()),t=this._get(`groundExtent`);return T(e,t)?t:e}get fullGroundExtent(){return this._tilingSchemeExtent==null?this._rootTilesExtent:this._tilingSchemeExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),this.enabled&&!!((this.readyToRun||this._updatingHandles?.updating||this._asyncWorkItems>0)&&this.ready&&!this.freeze||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get readyToRun(){return this.enabled&&(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._hasElevationSourceUpdates||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.freeze}get _hasElevationSourceUpdates(){return this._allTiles.some(e=>e.needsElevationSourceUpdate())}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return!this.enabled||this._rootTiles!=null}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set(`slicePlaneEnabled`,e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===0}get invisible(){return this._renderer.transparency===3}set freeze(e){this._set(`freeze`,e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,n,r){this._renderer.intersectRay(e,t,n,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}get _xNormalizer(){return he(this._spatialReference)}getElevation(e,t,n,r){let i=this._rootTiles;if(!i?.length||!this.enabled||i[0].layerInfo[0].length===0)return null;let a=this._elevationProjectorCache.get(r);if(a===void 0&&(a=S(r,this._spatialReference)??null,this._elevationProjectorCache.set(r,a)),a==null)return s.getLogger(this).error(`TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system`),null;let o=ae(J,e,t,n);a(o,0,o,0);let c=this._xNormalizer?.normalize(o[0])??o[0],l=o[1];return ft(i,c,l)}getElevations(e,t,n){let r=this._rootTiles,i=r?r[0].layerInfo[0].length:0;if(!r?.length||i===0||!this.enabled)for(let e=0;e<t;++e)n(e,null);else for(let i=0;i<t;++i){let t=i*3,a=e[t],o=e[t+1],s=ft(r,a,o);n(i,s)}}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}getScale(e){if(!this.tilingScheme)return null;if(!C(e,J,this.spatialReference))return s.getLogger(this).error(`TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system`),null;let t=this._rootTiles;if(t!=null){for(let e of t)if(e?.containsPoint(J)){let t=e;for(;t.children[0]&&!t.rendered;){let e=t.children[0].extent,n=0;J[0]>e[2]&&(n+=1),J[1]<e[1]&&(n+=2),t=t.children[n]}return this._getLodBiasCorrectedScale(t.level)}}return 1/0}_ensureProjector(e){let t=this._projectorCache.get(e);if(t)return t;let n=S(e,this._tilingSchemeSpatialReference)??null;return this._projectorCache.set(e,n),n}getSphereElevationRange(e,t){if(!this.enabled||this._rootTiles==null)return null;let n=this._ensureProjector(t);if(n==null)return s.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project given point to tiling scheme coordinate system`),null;Y.copyFrom(e),n(Y.center,0,Y.center,0);let r=new D,i=this._rootTiles;if(i!=null){let e=[];for(let t of i)e.push(t);let t=0;for(;t<e.length;){let n=e[t];if(++t,!fe(n.extent,Y))continue;let i=n.children;if(i[0]==null||n.rendered)r.expandElevationRangeValues(n.elevationBoundsMin,n.elevationBoundsMax);else for(let t of i)e.push(t)}}return r}getRootElevationRange(){return this.enabled&&this._rootTiles!=null?new D(this._rootTileElevationRange.minElevation,this._rootTileElevationRange.maxElevation):null}getLowerBoundRadius(){let e=(this._ellipsoid.radius+this.visibleElevationRange.minElevation)*le;return Math.min(e,this._ellipsoid.radius)}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!C(e,Y.center,this.spatialReference))return s.getLogger(this).error(`TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system`),null;Y.radius=t;let n=null,r=e=>{if(e&&fe(e.extent,Y)){let t=e.children;if(t[0]&&!e.rendered)for(let e of t)r(e);else{let t=this._getLodBiasCorrectedScale(e.level);n=n==null?t:Math.min(n,t)}}},i=this._rootTiles;if(i!=null)for(let e of i)r(e);return n}queryVisibleScaleRange(e,t,n,r){if(!this._scaleRangeQueries)return;let i=t?this.tilingScheme.levelAtScale(t):0,a=n?this.tilingScheme.levelAtScale(n):1/0,o=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,i+o,a+o,r)}_evaluateTransparency(){let e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,n=this._renderer.transparency,r=this._isFullyTransparent?et(0,t):e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?0:1;return this._renderer.transparency=r,n!==r&&(this.notifyChange(`opaque`),this.notifyChange(`invisible`),!0)}_updateTilingScheme(){let{tilingScheme:e}=this.tilingSchemeLogic;if(e===this.tilingScheme)return;j(!!e,`tiling scheme cannot be reset to undefined`),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();let t=e?.spatialReference??x.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&ge(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,this._set(`tilingScheme`,e),this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference,this._projectorCache.clear(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey=`TerrainTileMemcache`}_acquireTile(e,t,n,r){let i=this._tileCache.pop(K._tileMemcacheKey);return i?(i.init(e,t,n,r,this),i):new this._tileConstructor(e,t,n,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){let{groundExtent:e,tilingScheme:t}=this;if(!t)return;if(!this.enabled){this._setRootTiles(null);return}let n=ut,i=t.rootTilesInExtent(e,n,k*5);if(this._rootTiles!=null){if(i.length>k){s.getLogger(this).warn(Fe);return}let e=this._rootTiles.map(e=>e.lij),t=r(e,i,H);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){let e=this._rootTiles.filter(e=>t.removed.findIndex(t=>H(t,e.lij))>-1?(this._purgeTile(e),!1):!0);t.added.forEach(t=>e.push(this._newRootTile(t))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,i.length>k&&(s.getLogger(this).warn(Ie),i=t.rootTilesInExtent(e,n,k)),this._setRootTiles(i.map(e=>this._newRootTile(e)));T(n,this._rootTilesExtent)||(this._rootTilesExtent=w(n)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange(`ready`),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness(`root-tiles-updated`)}_updateAllTileGeometries(){let e=this._allTiles.filter(e=>this._canUpdateTileGeometry(e));e.length===0||(e.sort(U),e.forEach(e=>this._renderer.updateTileGeometryState(e)),e.forEach(e=>e.renderData.updateNeighborData()),this._updateTilesGeometries(e)),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){let t=e.filter(e=>this._canUpdateTileGeometry(e));if(t.length===0)return;let n=this.renderer;for(let e of t)n.updateGeometryIfNeeded(e);for(let e of t)this._pendingTilesForElevationUpdateEvent.add(e)}_canUpdateTileGeometry(e){return e.loaded&&e.intersectsClippingArea&&e.hasGeometryState}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===1}_newRootTile(e){let t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(1),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationRange(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),e!=null){let t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.freeze&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.groundExtent)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(e==null)return;let t=Ze(e),n=this.visibleElevationRange,r=t?n.minElevation:1/0,i=t?n.maxElevation:-1/0,a=this.groundExtent,o=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty(!1);let s=this._iteratorPool.acquire();for(s.reset(e);!s.done;){let e=s.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(o),e.renderData&&(r=Math.min(e.elevationBoundsMin,r),i=Math.max(e.elevationBoundsMax,i))}s.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(i)&&(n.minElevation!==r||n.maxElevation!==i)&&(this.visibleElevationRange=new O(r,i))}_updateRootTileElevationRange(){let e=1/0,t=-1/0;this._rootTiles?.forEach(({elevationBoundsMin:n,elevationBoundsMax:r})=>{e=Math.min(e,n),t=Math.max(t,r)});let n=this._rootTileElevationRange;(n.minElevation!==e||n.maxElevation!==t)&&(this._rootTileElevationRange=new O(e,t))}_updateViewDependentParameters(){let{camera:e,contentCamera:t}=this.view.state,n=Math.tan(t.fovX*.5),r=Math.tan(t.fovY*.5),i=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=n,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=i/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=i/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=pe(this._splitLimits.frustum??me(),t.frustum):this._splitLimits.frustum=null,oe(this._eyePosRenderSR,t.eye),ue(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility();let t=this._renderer.updateTileGeometryState(e);e.needsElevationSourceUpdate()&&(e.updateAgents(0),e.markElevationSourceUpdateRequested(),this.requestUpdate()),t&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){e.forEachLoadedNeighbor(e=>{this._layerViews[1].some(M)&&e.setPendingUpdate(32),this._pendingTilesToUpdate.add(e)})}_updateTileTexture(e,t){let n=e.resetPendingUpdate(32)?32:e.resetPendingUpdate(16)?16:!1;n&&(this._renderer.updateTileTexture(e,n),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;let e=this._pendingTilesForElevationUpdateEvent;if(e.size>0){let t=new Float64Array(4*e.size),n=0;for(let r of e)t.set(r.extent,4*n),++n;e.clear();for(let e of Se(t,this.spatialReference)){let t=new xe(this.spatialReference,e,`ground`);this.emit(`elevation-change`,t)}}this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);let t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),this._updateElevation(e),this._updateElevationSources(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty();let n=this._pendingTilesToUpdate.size>0,r=n&&this._hasPendingGeometryWithoutIndices();if((!e.done||r)&&this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&(e.hasProgressed||n&&!r)&&this.requestUpdate(),this.notifyChange(`updatingProgressValue`),!e.hasProgressed)return ct}_checkTileInvariant(){}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;let t=!1,n=new je(this._allTiles.length);n.pushAll(this._rootTiles);let r=this.snapLevel,i=this._splitLimits,a=this._eyePosRenderSR;this._allTiles.forAll(e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0});let o=this.view.state.contentCamera.viewProjectionMatrix;for(;!n.empty;){let e=n.pop(),s=e.parent?.hasPendingUpdate(4),c=s?4:e.shouldSplit(i,a,r),l=c===1;e.leaf?Z(e,l):n.pushAll(e.children),s?(e.resetPendingUpdate(1),e.leaf||(e.setPendingUpdate(4),t=!0),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(o)):l?(e.resetPendingUpdate(4),e.leaf&&(e.setPendingUpdate(1),t=!0)):(e.resetPendingUpdate(1)&&e.updateAgentSuspension(),c===2&&e.updateAgents(0),e.leaf||(e.setPendingUpdate(4),e.resetPendingUpdate(1),t=!0))}this._allTilesDirty=t,this.requestUpdate(),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){!e.done&&!this._allTilesSorted&&this.view.pointsOfInterest?.focus&&(Qe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger?.update(),e.madeProgress())}_markTileToUpdate(e){N(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_hasPendingGeometryWithoutIndices(){for(let e of this._pendingTilesToUpdate)if(e.loaded&&e.intersectsClippingArea&&e.renderData?.vao?.indexBuffer==null)return!0;return!1}_updatePendingTileGeometries(){let e=this._pendingTilesToUpdate,t=[];if(e.forEach(e=>{this._canUpdateTileGeometry(e)&&t.push(e)}),t.length===0){e.clear();return}let n=(n,r)=>{!r||!this._canUpdateTileGeometry(r)||r.level<n.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(U);let r=t.length;for(let i=0;i<r;++i){let r=t[i];N(r.loaded),N(r.intersectsClippingArea);let a=r.renderData;if(!a?.geometryState)continue;a.updateNeighborData();let o=a.dirtyEdgeResolutions,s=a.geometryState,c=e=>{let t=Ge[e];n(r,s.cornerPeerNeighbors[e]?.findCorner(Ve(t),e=>e.loaded))};for(let t=0;t<4;++t)if(o&1<<t){let i=a.geometryState.edgePeerNeighbors[t];i&&i?.level>=r.level&&i.forAllSubtreeOnSide(Be(P[t]),t=>this._canUpdateTileGeometry(t)?(N(e.has(t)||U(r,t)<0),n(r,t),!0):!1),c((t+1)%4),c(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,V&&He&&this.checkAllTilesWaterproofness(`pending-geometries-updated`)}_mergeAndSplit(e,t){if(this.freeze||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let n=!1,r=this.view.state.fixedContentCamera,i=!1;for(;!e.done;){i=!0;let a=!1,o=!this._allTiles.some(i=>{if(!n&&!r&&!i.visible)return e.done;let o=i;if(i.hasPendingUpdate(4)){if(!t||i.unmergableChildCount>0)return e.done;for(i.resetPendingUpdate(4);o.parent!=null&&o.parent.unmergableChildCount===0&&o.parent.resetPendingUpdate(4);)o=o.parent;this._mergeTile(o),a=!0,e.madeProgress()}else if(i.resetPendingUpdate(1)){let t=!0,n=i.level;if(n>=A){let e=e=>e.leaf||n-e.level<A;for(let r=0;r<4;++r){let a=i.findNeighborTile(P[r],e);a!=null&&n-a.level===A&&(t=!1,V&&(N(a.leaf),N(a.hasPendingUpdate(1))))}}t?(this._splitTile(i),e.madeProgress(),a=!0):i.setPendingUpdate(1)}return e.done});if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0),o){if(!n){n=!0;continue}if(!a)break}else this._allTilesDirty=!0}i?e.madeProgress():this._allTilesDirty=!0,this._allTilesCreated=!this.allTiles.some(e=>e.hasPendingUpdate(1)||e.hasPendingUpdate(4)&&e.unmergableChildCount===0),this._sortTiles(e)}_updateElevation(e){e.done||this._allTiles.some(t=>(t.resetPendingUpdate(8)&&(this._updateTileGeometryState(t),e.madeProgress()),e.done))}_updateElevationSources(e){e.done||this._allTiles.some(t=>(t.needsElevationSourceUpdate()&&(t.updateAgents(0),t.markElevationSourceUpdateRequested(),e.madeProgress()),e.done))}_updateTextures(e){e.done||this._allTiles.some(t=>(this._updateTileTexture(t,e),e.done))}_updateClippingExtent(){this.spatialReference&&(this.updateOverlayParameters(),this.requestRender(1),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){return this.view.qualitySettings.tiledSurface.lodBias-(1-this.view.quality)*Le}_getLodBiasCorrectedScale(e){let t=this.tilingScheme.levels,n=c(e-this._lodBias,0,t.length-1),r=n-Math.floor(n),i=t[Math.floor(n)].scale,a=t[Math.ceil(n)].scale;return i*(1-r)+a*r}_removeAllTiles(){this._pendingTilesToUpdate.clear(),this._pendingTilesForElevationUpdateEvent.clear(),this._rootTiles!=null&&(this._rootTiles.forEach(e=>this._purgeTile(e)),this._setRootTiles(null),this.notifyChange(`ready`)),this._allTiles.clear(),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles}),this.renderer.visible=!1}_purgeSubtree(e){let t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?mt(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(K._tileMemcacheKey,e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){j(e.leaf,`Tile that is already split should not be split again!`),j(e.rendered,`Tile marked to split is not rendered`),mt(e);let t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles}),e.updateAgentSuspension(),j(e.rendered,`parent should be rendered`),t.forEach(e=>this._loadTile(e)),t.forEach(e=>this._pendingTilesToUpdate.add(e)),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach(e=>Z(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){X.spatialReference=this.spatialReference,X.extent=e.extent,X.scale=this._getLodBiasCorrectedScale(t),this.emit(`scale-change`,X)}createTile(e,t,n,r){j(!!r,`createTile sanity check`);let i=this._acquireTile(e,t,n,r);return i.updateClippingStatus(this.groundExtent),i.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(i)&&i.setPendingUpdate(1),i}get _shortBatches(){return this.view.state.mode!==2}_mergeTile(e){j(!e.hasPendingUpdate(1),`_mergeTile sanity check`),j(!e.leaf,`Cannot merge a leaf`),e.leaf||(this._purgeSubtree(e),j(!e.renderData,`Merging tile with existing render data?`),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),Z(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&e.updateOverlayParameters(this.overlayManager)}_handleLayerViewChanges(e=ot){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1,n=new Set,r=-1;for(let e=this.view.allLayerViews.length-1;e>=0;e--){let i=this.view.allLayerViews.items[e];if(n.add(i.uid),F(i)||I(i)){if(this._basemapLayerViewHandles.has(i.uid)&&!I(i)){let e=this._layerClassFromLayerView(i),n=this.getLayerIndexByUID(e,i.uid);n!=null&&((n<r||r==null)&&(t=!0),r=n)}else this._registerTiledLayerView(i),i.layer.loaded&&(t=!0)}}this._basemapLayerViewHandles.forEach((e,r)=>{n.has(r)||(this._unregisterTiledLayerView(r),t=!0)}),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(let e of this.view.allLayerViews.items)if(L(e)&&!ye(e.layer)&&e.fullOpacity!==0)return!1;return!0}_hasCompositeBlendMode(){for(let e of this.view.allLayerViews.items)if((R(e)||I(e))&&nt(rt[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return+!z(e)}_registerTiledLayerView(e){let t=[];if((R(e)||I(e))&&t.push(h(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!I(e)){let n=this._layerClassFromLayerView(e);t.push(h(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(h(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));let{layer:r}=e;`effectiveScaleRange`in r&&t.push(h(()=>!e.destroyed&&r.effectiveScaleRange,()=>this._restartAllAgents(n))),t.push(e.on(`data-changed`,()=>{let t=this.getLayerIndexByUID(n,e.uid);t!=null&&this._invalidateLayerData(t,n)}))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){let t=this._basemapLayerViewHandles.get(e);if(t){for(let e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;let e=this.view.allLayerViews,t=[[],[]],n=null;e.forEach(e=>{if(!e.layer||e.suspended||!F(e)||!e.fullExtent)return;let r=this._layerClassFromLayerView(e);if(r===1){let t=e.displayLevelRange.maxLevel;t!==1/0&&(n===null||t>n)&&(n=t)}t[r].push(e)});for(let e of Oe){let n=this._layerViews[e],r=t[e];r.reverse();let i=r.length,a=n.length!==i,o=Array(i),s=Array(n.length);this._layerIndexByUid[e].clear();for(let t=0;t<i;t++){let i=r[t].uid;this._layerIndexByUid[e].set(i,t);let c=n.indexOf(r[t]);o[t]=c,t!==c&&(a=!0),c>-1&&(s[c]=t)}if(a){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;)t.next().modifyLayers(s,o,e);this._layerViews[e]=r,this._restartAllAgents(e),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(n)&&(this._viewChangeUpdate(),this.notifyChange(`tilingScheme`))}_restartAllAgents(e){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){let n=t.next();n.restartAgents(e),e===0&&n.computeElevationBounds()}this._updateRootTileElevationRange()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll(t=>{t.updateAgents(1),e===1?this.renderer.updateTileTexture(t,16):t.updateRenderData(1,e)}),this._evaluateTransparency()}_invalidateLayerData(e,t){this._rootTiles!=null&&(W(this._rootTiles,n=>n.removeLayerAgent(e,t)),W(this._rootTiles,n=>{n.invalidateLayerData(e,t),n.restartAgents(t)}))}setTileTreeDirty(e){this._allTilesDirty=!0,e&&(this._allTilesCreated=!1)}requestRender(e=1){this.renderer.setNeedsRender(e)}requestUpdate(){++this._pendingUpdates===1&&(this._hasPendingUpdates=!0)}requestTileData(e,t,n,r){let i=this.layerViewByIndex(t,n),{tilemapCache:a}=i;return!a||M(i)?this._requestTileData(e,n,i,r):(++this._asyncWorkItems,a.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).catch(t=>{throw te(r),p(t)||this._dataMissing(e,n,i),t}).then(()=>this._frameTask.schedule(()=>this._requestTileData(e,n,i,r),r.signal)).finally(()=>--this._asyncWorkItems))}_requestTileData(e,t,n,r){return this.destroying?Promise.resolve():t===0?z(n)?this._requestElevationTileData(e,n,r):Promise.reject():L(n)?this._requestMapTileData(e,n,r):Promise.reject()}_requestElevationTileData(e,t,n){++this._asyncWorkItems;let r=r=>{!m(n)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},i=n=>{p(n)||(s.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${n}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,{...be,...n}).then(e=>this._frameTask.schedule(()=>r(e)),i).finally(()=>--this._asyncWorkItems)}_elevationDataArrived(e,t,n){let r=this._layerIndexByUid[0].get(t.uid);if(r==null){s.getLogger(this).warn(`TerrainSurface: received data from unknown layer %d %s`,0,e.lij.toString());return}let i=new Te(e.lij,e.extent,n);e.dataArrived(r,0,i),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:0});let a=[e],o=e.level,c=this._iteratorPool.acquire();for(c.reset(a);!c.done;){let e=c.next();e.findElevationBoundsForLayer(r,o),e.computeElevationBounds()}o===0&&this._updateRootTileElevationRange(),c.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,n){++this._asyncWorkItems;let r=(r,i)=>{B(i),m(n)||(console.error(`Tile ${e.lij.toString()} layer 1/${t.uid} error ${r}`),this._dataMissing(e,1,t),this.requestUpdate())},i=e=>t=>r(t,e);return t.fetchTile(e.lij,n).then(r=>this._frameTask.schedule(()=>{this.requestUpdate(),m(n)?B(r):this._mapTileDataArrived(e,t,r)},n.signal,i(r)).catch(i(r)),(e,t=null)=>this._frameTask.schedule(()=>r(e,t))).finally(()=>--this._asyncWorkItems)}_mapTileDataArrived(e,t,n){let r=this.getLayerIndexByUID(1,t.uid);r==null?(B(n),s.getLogger(this).warn(`TerrainSurface: received data from unknown layer`)):(e.dataArrived(r,1,n),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:1}))}_dataMissing(e,t,n){let r=this.getLayerIndexByUID(t,n.uid);r==null?s.getLogger(this).warn(`TerrainSurface: received data from unknown layer`):(e.dataMissing(r,t),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:t}))}get performanceInfo(){let e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll(t=>{t.leaf&&e.numLeaves++;let n=t.level;t.renderData&&(e.numLoadedPerLevel[n]=(e.numLoadedPerLevel[n]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[n]=(e.numRenderedPerLevel[n]||0)+1,e.numRendered++))}),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(this._usedMemory??=this._recalculateUsedMemory(),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce((e,t)=>e+t.usedMemory,0)):null}getUsedMemoryForLayerView(e){let t=0,n=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(n,e.uid);return r!=null&&this._allTiles.forAll(e=>t+=e.getUsedMemoryForLayer(n,r)),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(e=`render-patch-groups`){}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&e[2]===0}lijEastEnd(e){return 1<<e+ +!!this._isGeographic}wrapEastWest(e){let t=this.lijEastEnd(e[0]),n=e[2];if(0<=n&&n<t)return e;if(!this._isGlobal)return null;let r=(n+(n<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){Ue(e)}enableWaterproofnessChecks(e){We(e)}static cleanupTerrainSurface(){dt.prune()}enable(e){e!==this.enabled&&(this._set(`enabled`,e),e?(this._updateRootTiles(),this.freeze=!1,this.view.elevationProvider.register(0,this)):(this.view.elevationProvider.unregister(this),this.freeze=!0,this._removeAllTiles(),this._setRootTiles(null)),this.notifyChange(`ready`))}updateOverlayParameters(){let{overlayManager:e}=this;this.allTiles.forAll(t=>t.updateOverlayParameters(e))}};e([y()],q.prototype,`_renderer`,void 0),e([y({constructOnly:!0})],q.prototype,`_scaleRangeQueries`,void 0),e([y({constructOnly:!0})],q.prototype,`view`,void 0),e([y({constructOnly:!0})],q.prototype,`overlayManager`,void 0),e([y({constructOnly:!0})],q.prototype,`terrainTextureCompressionTracker`,void 0),e([y()],q.prototype,`_hasPendingUpdates`,void 0),e([y()],q.prototype,`_asyncWorkItems`,void 0),e([y()],q.prototype,`_allTilesDirty`,void 0),e([y()],q.prototype,`_allTilesSorted`,void 0),e([y()],q.prototype,`allTilesCreated`,null),e([y()],q.prototype,`_allTilesCreated`,void 0),e([y()],q.prototype,`_viewChanged`,void 0),e([y({type:Number})],q.prototype,`heading`,void 0),e([y()],q.prototype,`_splitLimits`,void 0),e([y()],q.prototype,`_frameTask`,void 0),e([y()],q.prototype,`demResolution`,null),e([y({readOnly:!0})],q.prototype,`snapLevel`,null),e([y({readOnly:!0})],q.prototype,`lodSnappingEnabled`,null),e([y({readOnly:!0})],q.prototype,`userClippingExtent`,null),e([y()],q.prototype,`_rootTilesExtent`,void 0),e([y({readOnly:!0})],q.prototype,`groundExtent`,null),e([y({readOnly:!0})],q.prototype,`fullGroundExtent`,null),e([y({readOnly:!0})],q.prototype,`_tilingSchemeExtent`,null),e([y({readOnly:!0})],q.prototype,`updating`,null),e([y({readOnly:!0})],q.prototype,`readyToRun`,null),e([y(we)],q.prototype,`updatingProgress`,void 0),e([y({readOnly:!0})],q.prototype,`updatingProgressValue`,null),e([y()],q.prototype,`_maxNumUpdating`,void 0),e([y()],q.prototype,`baseOpacity`,null),e([y()],q.prototype,`hasCompositeBlendMode`,void 0),e([y({readOnly:!0})],q.prototype,`viewingMode`,null),e([y()],q.prototype,`maxTextureScale`,void 0),e([y({readOnly:!0})],q.prototype,`ready`,null),e([y({readOnly:!0})],q.prototype,`rootTiles`,null),e([y()],q.prototype,`_rootTiles`,void 0),e([y({readOnly:!0})],q.prototype,`spatialReference`,null),e([y({type:t})],q.prototype,`backgroundColor`,null),e([y({value:!1})],q.prototype,`slicePlaneEnabled`,null),e([y({readOnly:!0})],q.prototype,`tilingScheme`,void 0),e([y({readOnly:!0})],q.prototype,`tilingSchemeLocked`,null),e([y({readOnly:!0})],q.prototype,`tilingSchemeLogic`,void 0),e([y()],q.prototype,`wireframe`,null),e([y()],q.prototype,`opaque`,null),e([y()],q.prototype,`invisible`,null),e([y({value:!1})],q.prototype,`freeze`,null),e([y()],q.prototype,`fadeDuration`,null),e([y()],q.prototype,`_xNormalizer`,null),e([y()],q.prototype,`visibleElevationRange`,void 0),e([y()],q.prototype,`_rootTileElevationRange`,void 0),e([y()],q.prototype,`_layerViewsDirty`,void 0),e([y()],q.prototype,`renderPatchBorders`,null),e([y()],q.prototype,`renderingDisabled`,null),e([y({readOnly:!0})],q.prototype,`enabled`,void 0),q=K=e([re(`esri.views.3d.terrain.TerrainSurface`)],q);const lt=q,J=b(),Y=new _e,ut=w(),dt=new f,X={spatialReference:null,extent:null,scale:0};function ft(e,t,n){for(let r of e){if(!r.containsPointXY(t,n))continue;let e=r;for(;e&&!e.renderData;){let r=+(t>e.extentMidX)+(n<e.extentMidY?2:0);e=e.children[r]}let i=e?.renderData?.geometryState.samplerData??null;return Ee(t,n,i)}return null}function Z(e,t){!e.leaf||e.level<A||$(e,e=>{t&&pt(e);let n=Q(e);if(e.maxLevelDeltaNeighborCount++,n){let t=e.parent;for(;t;){let e=Q(t);if(t.unmergableChildCount++,e)t=t.parent;else break}}})}function pt(e){if(e.hasPendingUpdate(1))return;let t=e.parent;for(;t?.resetPendingUpdate(4);)t=t.parent;e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1),e.level<A||$(e,e=>{pt(e)})}function mt(e){e.level<A||$(e,e=>{if(e.maxLevelDeltaNeighborCount--,e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0){let t=e.parent;for(;t&&(t.unmergableChildCount--,Q(t));)t=t.parent}})}function Q(e){return e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0}function $(e,t){if(e.level<A)return;let n=e.level-A,r=e.lij[1]>>A,i=e.lij[2]>>A,a=e=>e.leaf||e.level===n;for(let o=0;o<4;++o){let s=e.findNeighborTile(P[o],a);if(!s||s.level!==n)continue;let c=s.lij;(c[1]!==r||c[2]!==i)&&t(s)}}export{lt as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import"./ComponentData.glsl.js";import"../../../core/shaderLibrary/bindUniforms.js";import"../../../core/shaderLibrary/forwardLinearDepthToWriteShadow.glsl.js";import"../../../core/shaderLibrary/ShaderOutput.js";import"../../../core/shaderLibrary/Slice.glsl.js";import"../../../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import"../../../core/shaderLibrary/attributes/VertexColor.glsl.js";import"../../../core/shaderLibrary/attributes/VertexNormal.glsl.js";import"../../../core/shaderLibrary/attributes/VertexPosition.glsl.js";import"../../../core/shaderLibrary/output/DepthConversion.glsl.js";import"../../../core/shaderLibrary/output/OutputDepth.glsl.js";import"../../../core/shaderLibrary/output/OutputHighlight.glsl.js";import"../../../core/shaderLibrary/output/OutputHighlightOverlay.js";import"../../../core/shaderLibrary/shading/ComputeFragmentNormals.glsl.js";import"../../../core/shaderLibrary/shading/ComputeMaterialColor.glsl.js";import"../../../core/shaderLibrary/shading/ComputeNormalTexture.glsl.js";import"../../../core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import"../../../core/shaderLibrary/shading/lightingUniforms.js";import"../../../core/shaderLibrary/shading/NormalUtils.glsl.js";import"../../../core/shaderLibrary/shading/pbrGlobals.glsl.js";import"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import"../../../core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js";import"../../../core/shaderLibrary/shading/readShadow.glsl.js";import"../../../core/shaderLibrary/terrain/Overlay.glsl.js";import"../../../core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js";import"../../../core/shaderModules/BooleanDrawUniform.js";import"../../../core/shaderModules/FloatDrawUniform.js";import"../../../core/shaderModules/glsl.js";import"../../../effects/snowcover/SnowCover.glsl.js";import"../../../shaders/alphaCutoff.glsl.js";import"../../../shaders/OutputColorHighlightOLID.glsl.js";import"../../../shaders/SphereDepthInterpolate.glsl.js";import"../../../../../webgl/ShaderBuilder.js";export{b as build}from"../../../../../../chunks/Component.glsl.js";
2
+ import"./ComponentData.glsl.js";import"../../../core/shaderLibrary/bindUniforms.js";import"../../../core/shaderLibrary/forwardLinearDepthToWriteShadow.glsl.js";import"../../../core/shaderLibrary/ShaderOutput.js";import"../../../core/shaderLibrary/Slice.glsl.js";import"../../../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import"../../../core/shaderLibrary/attributes/VertexColor.glsl.js";import"../../../core/shaderLibrary/attributes/VertexNormal.glsl.js";import"../../../core/shaderLibrary/attributes/VertexPosition.glsl.js";import"../../../core/shaderLibrary/output/DepthConversion.glsl.js";import"../../../core/shaderLibrary/output/OutputDepth.glsl.js";import"../../../core/shaderLibrary/output/OutputHighlight.glsl.js";import"../../../core/shaderLibrary/output/OutputHighlightOverlay.js";import"../../../core/shaderLibrary/shading/ComputeFragmentNormals.glsl.js";import"../../../core/shaderLibrary/shading/ComputeMaterialColor.glsl.js";import"../../../core/shaderLibrary/shading/ComputeNormalTexture.glsl.js";import"../../../core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import"../../../core/shaderLibrary/shading/lightingUniforms.js";import"../../../core/shaderLibrary/shading/NormalUtils.glsl.js";import"../../../core/shaderLibrary/shading/pbrGlobals.glsl.js";import"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import"../../../core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js";import"../../../core/shaderLibrary/shading/readShadow.glsl.js";import"../../../core/shaderLibrary/terrain/Overlay.glsl.js";import"../../../core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js";import"../../../core/shaderModules/BooleanDrawUniform.js";import"../../../core/shaderModules/FloatDrawUniform.js";import"../../../core/shaderModules/glsl.js";import"../../../effects/snowcover/applySnow.glsl.js";import"../../../shaders/alphaCutoff.glsl.js";import"../../../shaders/OutputColorHighlightOLID.glsl.js";import"../../../shaders/SphereDepthInterpolate.glsl.js";import"../../../../../webgl/ShaderBuilder.js";export{b as build}from"../../../../../../chunks/Component.glsl.js";
@@ -69,8 +69,7 @@ return groundRelative;
69
69
  aux.posModel += modelOffset;
70
70
  vec3 viewOffset = (viewNormal * vec4(modelOffset, 1.0)).xyz;
71
71
  aux.posView += viewOffset;
72
- // Since we elevate the object, we need to take that into account
73
- // in the distance to ground
72
+ // Since we elevate the object, we need to take that into account in the distance to ground
74
73
  pointGroundDistance += worldOffset;`:``}
75
74
 
76
75
  float groundRelative = applyHUDViewDependentPolygonOffset(pointGroundDistance, aux.absCosAngle, aux.posView);
@@ -69,8 +69,7 @@ import{depthMap as e}from"../bindUniforms.js";import{ReadDepth as t}from"../outp
69
69
 
70
70
  float projectedCoordDirectionLength = length(projectedCoordDirection);
71
71
 
72
- // normalize the projection direction depending on maximum steps
73
- // this determines how blocky the ray march looks
72
+ // normalize the projection direction depending on maximum steps this determines how blocky the ray march looks
74
73
  vec2 projectedStep = clampedRayMarchDistance * projectedCoordDirection / (rayMarchMaxSteps * projectedCoordDirectionLength);
75
74
 
76
75
  // Normalize the homogeneous camera space coordinates
@@ -25,13 +25,18 @@ float dispersionPerPixel = getDistanceFalloff(depth, rayDir, scattering * 0.5);
25
25
  float mainPoint = pow(dispersionPerPixel, 2.0);
26
26
  vec3 emission = vec3(0.0);
27
27
  float weights = 0.0;
28
- float sigmaSq = (0.1 / maxScattering * scattering + 0.003) + 0.03 * (boost - 1.0);
29
- for(float level = floor(mainPoint); level < levels; ++level) {
28
+ float baseSigmaSq = 0.003 + 0.03 * (boost - 1.0);
29
+ float sigmaSq = baseSigmaSq + 0.1 * scattering / maxScattering;
30
+ float minPoint = mainPoint - 0.5;
31
+ float fullPoint = (minPoint + mainPoint) * 0.5;
32
+ for(float level = 0.0; level < levels; ++level) {
30
33
  float point = level / levels;
31
- float dist = abs(point - mainPoint);
32
- float weight = gauss(dist, sigmaSq);
34
+ float dist = point - mainPoint;
35
+ float weight = gauss(dist, sigmaSq) * smoothstep(minPoint, fullPoint, point);
36
+ if(weight > 0.0) {
33
37
  emission += readEmission(point) * weight;
34
38
  weights += weight;
35
39
  }
40
+ }
36
41
  return emission * boost / weights;
37
42
  }`)}export{d as BlurEmissionPassParameters,f as applyEmissiveGlow};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{createTask as t}from"../../../../../core/asyncUtils.js";import{clamp as n}from"../../../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../../../core/maybe.js";import{watch as i,syncAndInitial as a}from"../../../../../core/reactiveUtils.js";import{createScreenPointArray as o,createRenderScreenPointArray as s,screenPointObjectToArray as c}from"../../../../../core/screenUtils.js";import{isSVG as l}from"../../../../../core/urlUtils.js";import{property as u,subclass as d}from"../../../../../core/accessorSupport/decorators.js";import{requestImage as f}from"../../../../../request/image.js";import{InternalRenderCategory as p}from"../../../webgl.js";import m from"../../../webgl/RenderNode.js";import{M as h}from"../../../../../chunks/Magnifier.glsl.js";import{MagnifierTechnique as g}from"./MagnifierTechnique.js";import{createQuadVAO as _}from"../../lib/glUtil3D.js";import{loadMagnifierResources as v}from"../../../../magnifier/resources.js";import{ColorAttachment0 as y,PrimitiveType as b}from"../../../../webgl/enums.js";import x from"../../../../webgl/Texture.js";import{TextureDescriptor as S}from"../../../../webgl/TextureDescriptor.js";let C=class extends m{constructor(){super(...arguments),this.consumes={required:[p.MAGNIFIER]},this.produces=p.MAGNIFIER,this._imageSources=null,this._imageLoadTask=null,this._passParameters=new h,this._magnifier=null,this._tmpScreenPoint=o(),this._tmpRenderPoint=s()}initialize(){this.addHandles([i(()=>this.view.magnifier,e=>this._update(e),a)])}_update(e){if(e===this._magnifier)return;this.removeAllHandles(),this._magnifier=e;let t=()=>{let e=this._validMagnifier;e?(this._loadResources(e),this.produces=p.MAGNIFIER):this.produces=`disabled`,this.requestRender()};this._magnifier&&this.addHandles(i(()=>this._magnifier?.version,t)),t()}get _validMagnifier(){return this._magnifier?.visible&&this._magnifier?.position&&this._magnifier?.size>0?this._magnifier:null}get _factor(){return this._magnifier?.factor||1}destroy(){this._magnifier=null,this._imageLoadTask!=null&&(this._imageLoadTask.task.abort(),this._imageLoadTask=null),this._disposeTextures(),this._vao=r(this._vao)}_disposeTextures(){this._passParameters.mask=r(this._passParameters.mask),this._passParameters.overlay=r(this._passParameters.overlay),this._passParameters.input=r(this._passParameters.input)}render(){let e=this._validMagnifier,t=this.input;if(e==null)return t;if(this._imageSources==null)return this.requestRender(1),t;let r=this.renderingContext,i=this.camera.pixelRatio,a=Math.ceil(i*e.size);this._vao??=_(r,0,0,1);let o=this.techniques.getCompiled(g);if(this._ensureTextureResources(r,a),!o||!this._passParameters.input)return this.requestRender(1),t;let s=Math.ceil(1/this._factor*a),l=this._passParameters.input;l.resize(s,s),c(e.position,this._tmpScreenPoint);let u=this.camera.screenToRender(this._tmpScreenPoint,this._tmpRenderPoint),d=this.camera.fullWidth,f=this.camera.fullHeight,p=.5*s,m=.5*s;u[0]=n(u[0],p,d-p-1),u[1]=n(u[1],m,f-m-1);let h=Math.floor(u[0]-p),v=Math.floor(u[1]-m);return r.bindFramebuffer(t.fbo),o.program.bindTexture(`textureInput`,l),r.gl.copyTexImage2D(l.descriptor.target,0,l.descriptor.pixelFormat,h,v,s,s,0),this._passParameters.magnifier=e,r.bindTechnique(o,this.bindParameters,this._passParameters),r.setDrawBuffers([y]),r.bindVAO(this._vao),r.drawArrays(b.TRIANGLE_STRIP,0,4),t}_loadResources(e){let{maskUrl:n,overlayUrl:r}=e;(this._imageLoadTask?.maskUrl!==n||this._imageLoadTask?.overlayUrl!==r)&&(this._imageLoadTask?.task.abort(),this._imageLoadTask=this._imageSources=null),!(this._imageSources||this._imageLoadTask)&&(this._imageLoadTask={maskUrl:n,overlayUrl:r,task:t(async e=>{let t=n==null||r==null?v(e):null,i=n==null?t.then(e=>e.mask):f(n,{signal:e}),a=r==null?t.then(e=>e.overlay):f(r,{signal:e});this._imageSources={mask:await i,overlay:await a}})})}_ensureTextureResources(e,t){this._imageSources==null||this._passParameters.size===t&&this._passParameters.input&&this._passParameters.mask&&this._passParameters.overlay||(this._disposeTextures(),this._imageSources.overlay.width=this._imageSources.mask.width=t,this._imageSources.overlay.height=this._imageSources.mask.height=t,this._passParameters.overlay=new x(e,this._createTextureDescriptor(t,6408,this._imageSources.overlay),this._imageSources.overlay),this._passParameters.mask=new x(e,this._createTextureDescriptor(t,6406,this._imageSources.mask),this._imageSources.mask),this._passParameters.input=new x(e,this._createTextureDescriptor(t,6408,null)))}_createTextureDescriptor(e,t,n){let r=this.renderingContext,i=new S(e);return i.pixelFormat=i.internalFormat=t,i.wrapMode=33071,i.flipped=!!n,i.preMultiplyAlpha=!(t!==6408||!n||l(n.src)&&r.driverTest.svgPremultipliesAlpha.result),i}};e([u()],C.prototype,`consumes`,void 0),e([u()],C.prototype,`produces`,void 0),e([u()],C.prototype,`_imageSources`,void 0),e([u()],C.prototype,`_imageLoadTask`,void 0),C=e([d(`esri.views.3d.webgl-engine.effects.magnifier.Magnifier`)],C);export{C as Magnifier};
2
+ import{__decorate as e}from"tslib";import{createTask as t}from"../../../../../core/asyncUtils.js";import{clamp as n}from"../../../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../../../core/maybe.js";import{watch as i,syncAndInitial as a}from"../../../../../core/reactiveUtils.js";import{createScreenPointArray as o,createRenderScreenPointArray as s,screenPointObjectToArray as c}from"../../../../../core/screenUtils.js";import{isSVG as l}from"../../../../../core/urlUtils.js";import{property as u,subclass as d}from"../../../../../core/accessorSupport/decorators.js";import{requestImage as f}from"../../../../../request/image.js";import{InternalRenderCategory as p}from"../../../webgl.js";import m from"../../../webgl/RenderNode.js";import{M as h}from"../../../../../chunks/Magnifier.glsl.js";import{MagnifierTechnique as g}from"./MagnifierTechnique.js";import{createQuadVAO as _}from"../../lib/glUtil3D.js";import{loadMagnifierResources as v}from"../../../../magnifier/resources.js";import{ColorAttachment0 as y,PrimitiveType as b}from"../../../../webgl/enums.js";import x from"../../../../webgl/Texture.js";import{TextureDescriptor as S}from"../../../../webgl/TextureDescriptor.js";let C=class extends m{constructor(){super(...arguments),this.consumes={required:[p.MAGNIFIER]},this.produces=p.MAGNIFIER,this._imageSources=null,this._imageLoadTask=null,this._passParameters=new h,this._magnifier=null,this._tmpScreenPoint=o(),this._tmpRenderPoint=s()}initialize(){this.addHandles([i(()=>this.view.magnifier,e=>this._update(e),a)])}_update(e){if(e===this._magnifier)return;this.removeAllHandles(),this._magnifier=e;let t=()=>{let e=this._validMagnifier;e?(this._loadResources(e),this.produces=p.MAGNIFIER):this.produces=`disabled`,this.requestRender()};this._magnifier&&this.addHandles(i(()=>this._magnifier?.version,t)),t()}get _validMagnifier(){return this._magnifier?.visible&&this._magnifier?.position&&this._magnifier?.size>0?this._magnifier:null}get _factor(){return this._magnifier?.factor||1}destroy(){this._magnifier=null,this._imageLoadTask!=null&&(this._imageLoadTask.task.abort(),this._imageLoadTask=null),this._disposeTextures(),this._vao=r(this._vao)}_disposeTextures(){this._passParameters.mask=r(this._passParameters.mask),this._passParameters.overlay=r(this._passParameters.overlay),this._passParameters.input=r(this._passParameters.input)}render(){let e=this._validMagnifier,t=this.input;if(e==null)return t;if(this._imageSources==null)return this.requestRender(1),t;let r=this.renderingContext,i=this.camera.pixelRatio,a=Math.ceil(i*e.size);this._vao??=_(r,0,0,1);let o=this.techniques.getCompiled(g);if(this._ensureTextureResources(r,a),!o||!this._passParameters.input)return this.requestRender(1),t;let s=Math.ceil(1/this._factor*a),l=this._passParameters.input;l.resize(s,s),c(e.position,this._tmpScreenPoint);let u=this.camera.screenToRender(this._tmpScreenPoint,this._tmpRenderPoint),d=this.camera.fullWidth,f=this.camera.fullHeight,p=.5*s,m=.5*s;u[0]=n(u[0],p,d-p-1),u[1]=n(u[1],m,f-m-1);let h=Math.floor(u[0]-p),v=Math.floor(u[1]-m);return r.bindFramebuffer(t.fbo),o.program.bindTexture(`textureInput`,l),r.gl.copyTexImage2D(l.descriptor.target,0,l.descriptor.pixelFormat,h,v,s,s,0),this._passParameters.magnifier=e,r.bindTechnique(o,this.bindParameters,this._passParameters),r.setDrawBuffers([y]),r.bindVAO(this._vao),r.drawArrays(b.TRIANGLE_STRIP,0,4),t}_loadResources(e){let{maskUrl:n,overlayUrl:r}=e;(this._imageLoadTask?.maskUrl!==n||this._imageLoadTask?.overlayUrl!==r)&&(this._imageLoadTask?.task.abort(),this._imageLoadTask=this._imageSources=null),this._imageSources||this._imageLoadTask||(this._imageLoadTask={maskUrl:n,overlayUrl:r,task:t(async e=>{let t=n==null||r==null?v(e):null,i=n==null?t.then(e=>e.mask):f(n,{signal:e}),a=r==null?t.then(e=>e.overlay):f(r,{signal:e});this._imageSources={mask:await i,overlay:await a}})})}_ensureTextureResources(e,t){this._imageSources==null||this._passParameters.size===t&&this._passParameters.input&&this._passParameters.mask&&this._passParameters.overlay||(this._disposeTextures(),this._imageSources.overlay.width=this._imageSources.mask.width=t,this._imageSources.overlay.height=this._imageSources.mask.height=t,this._passParameters.overlay=new x(e,this._createTextureDescriptor(t,6408,this._imageSources.overlay),this._imageSources.overlay),this._passParameters.mask=new x(e,this._createTextureDescriptor(t,6406,this._imageSources.mask),this._imageSources.mask),this._passParameters.input=new x(e,this._createTextureDescriptor(t,6408,null)))}_createTextureDescriptor(e,t,n){let r=this.renderingContext,i=new S(e);return i.pixelFormat=i.internalFormat=t,i.wrapMode=33071,i.flipped=!!n,i.preMultiplyAlpha=!(t!==6408||!n||l(n.src)&&r.driverTest.svgPremultipliesAlpha.result),i}};e([u()],C.prototype,`consumes`,void 0),e([u()],C.prototype,`produces`,void 0),e([u()],C.prototype,`_imageSources`,void 0),e([u()],C.prototype,`_imageLoadTask`,void 0),C=e([d(`esri.views.3d.webgl-engine.effects.magnifier.Magnifier`)],C);export{C as Magnifier};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{equals as t}from"../../../../../core/arrayUtils.js";import{smoothstep as n}from"../../../../../core/mathUtils.js";import{watch as r,syncAndInitial as i}from"../../../../../core/reactiveUtils.js";import{property as a,subclass as o}from"../../../../../core/accessorSupport/decorators.js";import{exactEquals as s,copy as c,equals as l}from"../../../../../core/libs/gl-matrix-2/math/vec4.js";import{InternalRenderCategory as u}from"../../../webgl.js";import d from"../../../webgl/RenderNode.js";import{S as f}from"../../../../../chunks/ShadowCastVisualize.glsl.js";import{ShadowCastVisualizeTechnique as p}from"./ShadowCastVisualizeTechnique.js";import{ShadowCastVisualizeTechniqueConfiguration as m}from"./ShadowCastVisualizeTechniqueConfiguration.js";import{vvColorNumber as h}from"../../materials/VisualVariablePassParameters.js";import{ColorAttachment0 as g}from"../../../../webgl/enums.js";let _=class extends d{constructor(e){super(e),this.produces=u.TRANSPARENT_NO_DEPTH,this.consumes={required:[u.TRANSPARENT_NO_DEPTH]},this.enabled=!1,this._configuration=new m,this._stencilMask=null,this._disableElevation={min:4e4,max:5e4,threshold:1/512},this._passParameters=new f(e.data)}initialize(){this.addHandles([r(()=>this.enabled,e=>{this.produces=e?u.TRANSPARENT_NO_DEPTH:`disabled`,this.requestRender(1)},i)])}precompile(){this._showVisualization&&this.techniques.precompile(p,this._configuration)}render(){let e=this.input;if(!this._showVisualization)return e;let[t,n]=this.data.computedSamples;this._passParameters.sampleScale=[t?1/t:0,n?1/n:0];let r=this.techniques.get(p,this._configuration),i=this._stencilMask!=null,a=this.renderingContext,o=this.bindParameters,s=a.boundFramebuffer,c=null;return i&&(c=this.fboCache.acquire(o.camera.width,o.camera.height,`shadow cast masked draw`),c.attachDepth(this._stencilMask),a.bindFramebuffer(c.fbo),a.blitFramebuffer(s,c.fbo,16384)),a.bindTechnique(r,o,this._passParameters),a.setDrawBuffers([g]),a.screen.draw(),c!=null&&(a.bindFramebuffer(s),a.blitFramebuffer(c.fbo,s,16384),c.detachDepth(),c.release()),e}setStencilMask(e){this._stencilMask=e}setOptions(e){e.enabled!==void 0&&(this.enabled=e.enabled),e.thresholdColor!==void 0&&(s(this._passParameters.thresholdColor,e.thresholdColor)||(c(this._passParameters.thresholdColor,e.thresholdColor),this._requestRenderIfEnabled())),e.gradientColorRamp!==void 0&&this._modifyGradientColorRamp(e.gradientColorRamp),e.bandedGradientColorRamp!==void 0&&this._modifyGradientColorRamp(e.bandedGradientColorRamp,!0),e.threshold!==void 0&&this._passParameters.threshold!==e.threshold&&(this._passParameters.threshold=e.threshold,this._requestRenderIfEnabled()),e.rendersSunlight!==void 0&&this._configuration.rendersSunlight!==e.rendersSunlight&&(this._configuration.rendersSunlight=e.rendersSunlight,this._requestRenderIfEnabled()),e.visualization!==void 0&&this._configuration.visualization!==e.visualization&&(this._configuration.visualization=e.visualization,this._requestRenderIfEnabled()),e.bandSize!==void 0&&this._passParameters.bandSize!==e.bandSize&&(this._passParameters.bandSize=e.bandSize,this._requestRenderIfEnabled()),e.analysisVolume!==void 0&&(this._configuration.useMask=e.analysisVolume!==null)}get isAboveElevationThreshold(){return this._passParameters.opacityFromElevation>this._disableElevation.threshold}setOpacityFromElevation(e){this._passParameters.opacityFromElevation=1-n(this._disableElevation.min,this._disableElevation.max,e)}get _showVisualization(){return this.enabled&&(this.data.computedSamples[0]>0||this.data.computedSamples[1]>0)&&this.isAboveElevationThreshold}_modifyGradientColorRamp(e,t=!1){e.length>h&&(e=e.slice(0,h)),!v(t?this._passParameters.bandedGradientColorRamp:this._passParameters.gradientColorRamp,e)&&(t?this._passParameters.bandedGradientColorRamp=e:this._passParameters.gradientColorRamp=e,this._requestRenderIfEnabled())}_requestRenderIfEnabled(){this.enabled&&this.requestRender(1)}};e([a()],_.prototype,`produces`,void 0),e([a()],_.prototype,`consumes`,void 0),e([a()],_.prototype,`enabled`,void 0),e([a({constructOnly:!0})],_.prototype,`data`,void 0),_=e([o(`esri.views.3d.webgl-engine.effects.shadowAccumulation.ShadowCastRenderer`)],_);function v(e,n){return t(e,n,([e,t],[n,r])=>e===n&&l(t,r))}export{_ as ShadowCastRenderer};
2
+ import{__decorate as e}from"tslib";import{equals as t}from"../../../../../core/arrayUtils.js";import{smoothstep as n}from"../../../../../core/mathUtils.js";import{watch as r,syncAndInitial as i}from"../../../../../core/reactiveUtils.js";import{property as a,subclass as o}from"../../../../../core/accessorSupport/decorators.js";import{exactEquals as s,copy as c,equals as l}from"../../../../../core/libs/gl-matrix-2/math/vec4.js";import{InternalRenderCategory as u}from"../../../webgl.js";import d from"../../../webgl/RenderNode.js";import{S as f}from"../../../../../chunks/ShadowCastVisualize.glsl.js";import{ShadowCastVisualizeTechnique as p}from"./ShadowCastVisualizeTechnique.js";import{ShadowCastVisualizeTechniqueConfiguration as m}from"./ShadowCastVisualizeTechniqueConfiguration.js";import{vvColorNumber as h}from"../../materials/VisualVariablePassParameters.js";import{ColorAttachment0 as g}from"../../../../webgl/enums.js";let _=class extends d{constructor(e){super(e),this.produces=u.TRANSPARENT_NO_DEPTH,this.consumes={required:[u.TRANSPARENT_NO_DEPTH]},this.enabled=!1,this._configuration=new m,this._stencilMask=null,this._disableElevation={min:4e4,max:5e4,threshold:1/512},this._passParameters=new f(e.data)}initialize(){this.addHandles([r(()=>this.enabled,e=>{this.produces=e?u.TRANSPARENT_NO_DEPTH:`disabled`,this.requestRender(1)},i)])}precompile(){this._showVisualization&&this.techniques.precompile(p,this._configuration)}render(){let e=this.input;if(!this._showVisualization)return e;let[t,n]=this.data.computedSamples;this._passParameters.sampleScale=[t?1/t:0,n?1/n:0];let r=this.techniques.get(p,this._configuration),i=this._stencilMask!=null,a=this.renderingContext,o=this.bindParameters,s=a.boundFramebuffer,c=null;return i&&(c=this.fboCache.acquire(o.camera.width,o.camera.height,`shadow cast masked draw`),c.attachDepth(this._stencilMask),a.bindFramebuffer(c.fbo),a.blitFramebuffer(s,c.fbo,16384)),a.bindTechnique(r,o,this._passParameters),a.setDrawBuffers([g]),a.screen.draw(),c!=null&&(a.bindFramebuffer(s),a.blitFramebuffer(c.fbo,s,16384),c.detachDepth(),c.release()),e}setStencilMask(e){this._stencilMask=e}setOptions(e){e.enabled!==void 0&&(this.enabled=e.enabled),e.thresholdColor!==void 0&&(s(this._passParameters.thresholdColor,e.thresholdColor)||(c(this._passParameters.thresholdColor,e.thresholdColor),this._requestRenderIfEnabled())),e.gradientColorRamp!==void 0&&this._modifyGradientColorRamp(e.gradientColorRamp),e.bandedGradientColorRamp!==void 0&&this._modifyGradientColorRamp(e.bandedGradientColorRamp,!0),e.threshold!==void 0&&this._passParameters.threshold!==e.threshold&&(this._passParameters.threshold=e.threshold,this._requestRenderIfEnabled()),e.rendersSunlight!==void 0&&this._configuration.rendersSunlight!==e.rendersSunlight&&(this._configuration.rendersSunlight=e.rendersSunlight,this._requestRenderIfEnabled()),e.visualization!==void 0&&this._configuration.visualization!==e.visualization&&(this._configuration.visualization=e.visualization,this._requestRenderIfEnabled()),e.bandSize!==void 0&&this._passParameters.bandSize!==e.bandSize&&(this._passParameters.bandSize=e.bandSize,this._requestRenderIfEnabled()),e.analysisVolume!==void 0&&(this._configuration.useMask=e.analysisVolume!==null)}get isAboveElevationThreshold(){return this._passParameters.opacityFromElevation>this._disableElevation.threshold}setOpacityFromElevation(e){this._passParameters.opacityFromElevation=1-n(this._disableElevation.min,this._disableElevation.max,e)}get _showVisualization(){return this.enabled&&(this.data.computedSamples[0]>0||this.data.computedSamples[1]>0)&&this.isAboveElevationThreshold}_modifyGradientColorRamp(e,t=!1){e.length>h&&(e=e.slice(0,h)),v(t?this._passParameters.bandedGradientColorRamp:this._passParameters.gradientColorRamp,e)||(t?this._passParameters.bandedGradientColorRamp=e:this._passParameters.gradientColorRamp=e,this._requestRenderIfEnabled())}_requestRenderIfEnabled(){this.enabled&&this.requestRender(1)}};e([a()],_.prototype,`produces`,void 0),e([a()],_.prototype,`consumes`,void 0),e([a()],_.prototype,`enabled`,void 0),e([a({constructOnly:!0})],_.prototype,`data`,void 0),_=e([o(`esri.views.3d.webgl-engine.effects.shadowAccumulation.ShadowCastRenderer`)],_);function v(e,n){return t(e,n,([e,t],[n,r])=>e===n&&l(t,r))}export{_ as ShadowCastRenderer};
@@ -0,0 +1,18 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
+ import{Gamma as e}from"../../core/shaderLibrary/shading/Gamma.glsl.js";import{pbrGlobals as t}from"../../core/shaderLibrary/shading/pbrGlobals.glsl.js";import{FloatBindUniform as n}from"../../core/shaderModules/FloatBindUniform.js";import{glsl as r}from"../../core/shaderModules/glsl.js";function i(i,a){a.snowCover&&(i.include(e),i.uniforms.add(new n(`snowCover`,e=>e.snowCover)).code.add(r`float applySnow(vec3 normal, vec3 groundNormal, inout vec3 albedo, inout float ssao) {
3
+ float snow = smoothstep(0.5, 0.55, dot(normal, groundNormal)) * snowCover;
4
+ albedo = delinearizeGamma(mix(linearizeGamma(albedo), vec3(1), snow));
5
+ ssao = mix(ssao, 0.5 + 0.5 * ssao, snow);
6
+ return snow;
7
+ }
8
+ float applyRealisticTreeSnow(vec3 faceNormal, vec3 shadingNormal, vec3 groundNormal, inout vec3 albedo, inout float ssao) {
9
+ float snow = min(1.0, smoothstep(0.5, 0.55, dot(faceNormal, groundNormal)) +
10
+ smoothstep(0.5, 0.55, dot(-faceNormal, groundNormal)) +
11
+ smoothstep(0.0, 0.1, dot(shadingNormal, groundNormal))) *
12
+ snowCover;
13
+ albedo = delinearizeGamma(mix(linearizeGamma(albedo), vec3(1), snow));
14
+ ssao = mix(ssao, 0.5 + 0.5 * ssao, snow);
15
+ return snow;
16
+ }`),i.include(t),i.code.add(r`void applySnowToMRR(float snow) {
17
+ mrr = mix(mrr, vec3(0.0, 1.0, 0.04), snow);
18
+ }`))}export{i as applySnow};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{fromTranslation 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{add as n,transformMat4 as r,copy as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as o}from"../../../../geometry/support/frustumPlanes.js";import{create as s,fromPoints as c,copy as l}from"../../../../geometry/support/ray.js";import u from"../../webgl/RenderCamera.js";import{HUDTarget as d,HUDIntersectorResult as f}from"./HUDIntersectorResult.js";import{IntersectorOptions as p}from"./IntersectorInterfaces.js";import{IntersectorResultRay as m,compareOrderedIntersectionHits as h}from"./IntersectorResult.js";import{ObjectTarget as g}from"./ObjectTarget.js";import{PolygonIntersectionResults as _}from"./PolygonIntersectionResults.js";import{IntersectorTransform as v,getVerticalOffsetObject3D as y}from"./verticalOffsetUtils.js";const b=1e-5,x=t();class S{constructor(e){this.options=new p,this._results=new C,this.polygonResults=new _,this.transform=new v,this.camera=new u,this.screenPolygonPrimitiveProcessor=w,this.tolerance=b,this.verticalOffset=null,this._ray=s(),this._rayEnd=a(),this._rayBeginTransformed=a(),this._rayEndTransformed=a(),this.viewingMode=e??1}get results(){return this._results}get ray(){return this._ray}get rayBegin(){return this._ray.origin}get rayEnd(){return this._rayEnd}reset(e,t,n){this.resetWithRay(c(e,t,this._ray),n)}resetWithRay(e,t){this.camera=t,e!==this._ray&&l(e,this._ray),this.options.verticalOffset===0?this.verticalOffset=null:this.viewingMode===2?this._ray.origin[2]-=this.options.verticalOffset:this.verticalOffset=this.options.verticalOffset,n(this._rayEnd,this._ray.origin,this._ray.direction),this._results.init(this._ray),this.polygonResults.init()}intersect(e=null,t,n,r,i){this.point=t,this.filterPredicate=r,this.tolerance=n??b;let a=y(this.verticalOffset);if(e&&e.length>0){let t=i?e=>{i(e)&&this.intersectObject(e)}:e=>{this.intersectObject(e)};for(let n of e){let e=n.getSpatialQueryAccelerator?.();e==null?n.objects.forEach(e=>t(e)):(a==null?e.forEachAlongRay(this._ray.origin,this._ray.direction,t):e.forEachAlongRayWithVerticalOffset(this._ray.origin,this._ray.direction,t,a),this.options.selectionMode&&this.options.hud&&e.forEachDegenerateObject(t))}}this.sortResults()}*intersectScreenPolygon(e=null,t){if(this.verticalOffset=null,e?.length)for(let n of e){let e=n.getSpatialQueryAccelerator?.();if(e!=null)for(let n of e.intersectingFrustumValues(t.broadPhaseFrustum,e=>e.visible))yield*this._intersectScreenPolygonObject(n,t);else for(let e of n.objects.values())e.visible&&o(t.broadPhaseFrustum,e.boundingVolumeWorldSpace.sphere)&&(yield*this._intersectScreenPolygonObject(e,t))}}*intersectHUDScreenPolygon(e=null,t){if(this.verticalOffset=null,this.options.selectionMode&&this.options.hud&&e?.length)for(let n of e){let e=(n.getSpatialQueryAccelerator?.())?.degenerateObjectValues()??n.objects.values();for(let n of e)yield*this._intersectScreenPolygonObject(n,t)}}*_intersectScreenPolygonObject(e,t){let n=e.geometries;if(!e.visible||!n)return;let r=e.effectiveTransformation;for(let i of n){if(!i.visible)continue;let{material:n,id:a}=i;if(!n.visible||!n.intersectScreenPolygon)continue;this._setGeometryTransform(r,i);let o=n.intersectScreenPolygon(i,this.transform.transform,this,t);o?.valid&&this._handleObjectScreenPolygonIntersection(o.type,new g(e,a,o.primitiveIndex),o.distance,o.renderDistance,o.point),yield}}intersectObject(e){let t=e.geometries;if(!t)return;let n=e.effectiveTransformation,i=y(this.verticalOffset);for(let a of t){if(!a.visible)continue;let{material:t,id:o}=a;if(!t.visible)continue;this._setGeometryTransform(n,a),r(this._rayBeginTransformed,this.rayBegin,this.transform.inverse),r(this._rayEndTransformed,this.rayEnd,this.transform.inverse);let s=this.transform.transform;i!=null&&(i.objectTransform=this.transform),t.intersectRay(a,this.transform.transform,this,this._rayBeginTransformed,this._rayEndTransformed,(t,n,r,i,a)=>this.handleObjectIntersection({object:e,geometryId:o,primitiveIndex:i},t,n,r,s,a))}}_setGeometryTransform(t,n){let r=n.type===1?e(x,n.localOrigin.vec3):n.transformation;this.transform.setAndInvalidateLazyTransforms(t,r)}handleObjectIntersection(e,t,n,r,i,a){if(t<0||this.filterPredicate!=null&&!this.filterPredicate(this._ray.origin,this._rayEnd,n))return;let o=a?this._results.hud:this._results;e=a?new d(e,a):e;let s=a?i=>i.set(1,e,t,n,r):a=>a.set(4,e,t,n,r,i);if((o.min.renderDistance==null||n<o.min.renderDistance)&&s(o.min),this.options.store!==0&&(o.max.renderDistance==null||n>o.max.renderDistance)&&s(o.max),this.options.store===2){if(a){let e=new f(this._ray);s(e),this._results.hud.all.push(e)}else{let e=new m(this._ray);s(e),this._results.all.push(e)}}}_handleObjectScreenPolygonIntersection(e,t,n,r,i){n<0||(this.filterPredicate==null||i!=null&&this.filterPredicate(this.camera.eye,i,1))&&this.polygonResults.add(e,e===1&&i?new d(t,i):t,n,r)}sortResults(e=this._results.all){e.sort(h)}}class C{constructor(){this.min=new m(s()),this.max=new m(s()),this.hud={min:new f(s()),max:new f(s()),all:[]},this.ground=new m(s()),this.all=[]}init(e){this.min.init(e),this.max.init(e),this.ground.init(e),this.all.length=0,this.hud.min.init(e),this.hud.max.init(e),this.hud.all.length=0}}const w={*processTriangle(e){yield e},*processLineSegment(e,t,n){i(e[0],t),i(e[1],n),yield e},validatePoint(){return!0}};export{S as Intersector,w as defaultScreenPolygonPrimitiveProcessor,b as defaultTolerance};
2
+ import{fromTranslation 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{add as n,transformMat4 as r,copy as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as o}from"../../../../geometry/support/frustumPlanes.js";import{create as s,fromPoints as c,copy as l}from"../../../../geometry/support/ray.js";import u from"../../webgl/RenderCamera.js";import{HUDTarget as d,HUDIntersectorResult as f}from"./HUDIntersectorResult.js";import{IntersectorOptions as p}from"./IntersectorInterfaces.js";import{IntersectorResultRay as m,compareOrderedIntersectionHits as h}from"./IntersectorResult.js";import{ObjectTarget as g}from"./ObjectTarget.js";import{PolygonIntersectionResults as _}from"./PolygonIntersectionResults.js";import{IntersectorTransform as v,getVerticalOffsetObject3D as y}from"./verticalOffsetUtils.js";const b=1e-5,x=t();class S{constructor(e){this.options=new p,this._results=new C,this.polygonResults=new _,this.transform=new v,this.camera=new u,this.metersPerRenderUnit=1,this.screenPolygonPrimitiveProcessor=w,this.tolerance=b,this.verticalOffset=null,this._ray=s(),this._rayEnd=a(),this._rayBeginTransformed=a(),this._rayEndTransformed=a(),this.viewingMode=e??1}get results(){return this._results}get ray(){return this._ray}get rayBegin(){return this._ray.origin}get rayEnd(){return this._rayEnd}reset(e,t,n){this.resetWithRay(c(e,t,this._ray),n)}resetWithRay(e,t){this.camera=t,e!==this._ray&&l(e,this._ray),this.options.verticalOffset===0?this.verticalOffset=null:this.viewingMode===2?this._ray.origin[2]-=this.options.verticalOffset:this.verticalOffset=this.options.verticalOffset,n(this._rayEnd,this._ray.origin,this._ray.direction),this._results.init(this._ray),this.polygonResults.init()}intersect(e=null,t,n,r,i){this.point=t,this.filterPredicate=r,this.tolerance=n??b;let a=y(this.verticalOffset);if(e&&e.length>0){let t=i?e=>{i(e)&&this.intersectObject(e)}:e=>{this.intersectObject(e)};for(let n of e){let e=n.getSpatialQueryAccelerator?.();e==null?n.objects.forEach(e=>t(e)):(a==null?e.forEachAlongRay(this._ray.origin,this._ray.direction,t):e.forEachAlongRayWithVerticalOffset(this._ray.origin,this._ray.direction,t,a),this.options.selectionMode&&this.options.hud&&e.forEachDegenerateObject(t))}}this.sortResults()}*intersectScreenPolygon(e=null,t){if(this.verticalOffset=null,e?.length)for(let n of e){let e=n.getSpatialQueryAccelerator?.();if(e!=null)for(let n of e.intersectingFrustumValues(t.broadPhaseFrustum,e=>e.visible))yield*this._intersectScreenPolygonObject(n,t);else for(let e of n.objects.values())e.visible&&o(t.broadPhaseFrustum,e.boundingVolumeWorldSpace.sphere)&&(yield*this._intersectScreenPolygonObject(e,t))}}*intersectHUDScreenPolygon(e=null,t){if(this.verticalOffset=null,this.options.selectionMode&&this.options.hud&&e?.length)for(let n of e){let e=(n.getSpatialQueryAccelerator?.())?.degenerateObjectValues()??n.objects.values();for(let n of e)yield*this._intersectScreenPolygonObject(n,t)}}*_intersectScreenPolygonObject(e,t){let n=e.geometries;if(!e.visible||!n)return;let r=e.effectiveTransformation;for(let i of n){if(!i.visible)continue;let{material:n,id:a}=i;if(!n.visible||!n.intersectScreenPolygon)continue;this._setGeometryTransform(r,i);let o=n.intersectScreenPolygon(i,this.transform.transform,this,t);o?.valid&&this._handleObjectScreenPolygonIntersection(o.type,new g(e,a,o.primitiveIndex),o.distance,o.renderDistance,o.point),yield}}intersectObject(e){let t=e.geometries;if(!t)return;let n=e.effectiveTransformation,i=y(this.verticalOffset);for(let a of t){if(!a.visible)continue;let{material:t,id:o}=a;if(!t.visible)continue;this._setGeometryTransform(n,a),r(this._rayBeginTransformed,this.rayBegin,this.transform.inverse),r(this._rayEndTransformed,this.rayEnd,this.transform.inverse);let s=this.transform.transform;i!=null&&(i.objectTransform=this.transform),t.intersectRay(a,this.transform.transform,this,this._rayBeginTransformed,this._rayEndTransformed,(t,n,r,i,a)=>this.handleObjectIntersection({object:e,geometryId:o,primitiveIndex:i},t,n,r,s,a))}}_setGeometryTransform(t,n){let r=n.type===1?e(x,n.localOrigin.vec3):n.transformation;this.transform.setAndInvalidateLazyTransforms(t,r)}handleObjectIntersection(e,t,n,r,i,a){if(t<0||this.filterPredicate!=null&&!this.filterPredicate(this._ray.origin,this._rayEnd,n))return;let o=a?this._results.hud:this._results;e=a?new d(e,a):e;let s=a?i=>i.set(1,e,t,n,r):a=>a.set(4,e,t,n,r,i);if((o.min.renderDistance==null||n<o.min.renderDistance)&&s(o.min),this.options.store!==0&&(o.max.renderDistance==null||n>o.max.renderDistance)&&s(o.max),this.options.store===2){if(a){let e=new f(this._ray);s(e),this._results.hud.all.push(e)}else{let e=new m(this._ray);s(e),this._results.all.push(e)}}}_handleObjectScreenPolygonIntersection(e,t,n,r,i){n<0||(this.filterPredicate==null||i!=null&&this.filterPredicate(this.camera.eye,i,1))&&this.polygonResults.add(e,e===1&&i?new d(t,i):t,n,r)}sortResults(e=this._results.all){e.sort(h)}}class C{constructor(){this.min=new m(s()),this.max=new m(s()),this.hud={min:new f(s()),max:new f(s()),all:[]},this.ground=new m(s()),this.all=[]}init(e){this.min.init(e),this.max.init(e),this.ground.init(e),this.all.length=0,this.hud.min.init(e),this.hud.max.init(e),this.hud.all.length=0}}const w={*processTriangle(e){yield e},*processLineSegment(e,t,n){i(e[0],t),i(e[1],n),yield e},validatePoint(){return!0}};export{S as Intersector,w as defaultScreenPolygonPrimitiveProcessor,b as defaultTolerance};