@arcgis/core 4.28.0-next.20230621 → 4.28.0-next.20230623

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 (249) hide show
  1. package/Basemap.js +1 -1
  2. package/arcade/ArcadeModuleResolver.js +1 -1
  3. package/arcade/Feature.js +1 -1
  4. package/arcade/arcadeCompiler.js +1 -1
  5. package/arcade/arcadeTimeUtils.js +1 -1
  6. package/arcade/featureset/actions/GroupBy.js +1 -1
  7. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  8. package/arcade/featureset/support/sqlUtils.js +1 -1
  9. package/arcade/functions/date.js +1 -1
  10. package/arcade/functions/geomasync.js +1 -1
  11. package/arcade/functions/geometry.js +1 -1
  12. package/arcade/functions/geomsync.js +1 -1
  13. package/arcade/functions/string.js +1 -1
  14. package/arcade/languageUtils.js +1 -1
  15. package/assets/esri/core/workers/RemoteClient.js +1 -1
  16. package/assets/esri/core/workers/chunks/0380e9f61b6f3ca85139.js +1 -0
  17. package/assets/esri/core/workers/chunks/0bd95f46a0a9005a19f9.js +1 -0
  18. package/assets/esri/core/workers/chunks/0c621046b7211cdde980.js +1 -0
  19. package/assets/esri/core/workers/chunks/0e0267739728e5413f1d.js +1 -0
  20. package/assets/esri/core/workers/chunks/{39079bcfd35ed73c4e34.js → 156e801a3262f0ac79c0.js} +1 -1
  21. package/assets/esri/core/workers/chunks/19b4f02fb2392d964582.js +1 -0
  22. package/assets/esri/core/workers/chunks/1ae75f5282e983f6d768.js +1 -0
  23. package/assets/esri/core/workers/chunks/2179b3e9e532ca8ef982.js +1 -0
  24. package/assets/esri/core/workers/chunks/21aaa7fa0e5482670010.js +1 -0
  25. package/assets/esri/core/workers/chunks/26212a08ea383547335b.js +1 -0
  26. package/assets/esri/core/workers/chunks/{2420ec029236ab31d908.js → 2882a55a971af1f7858b.js} +1 -1
  27. package/assets/esri/core/workers/chunks/294285f2822c101326ec.js +1 -0
  28. package/assets/esri/core/workers/chunks/29f9a380610e4fd98a7c.js +1 -0
  29. package/assets/esri/core/workers/chunks/303238fc2fcdbb277981.js +1 -0
  30. package/assets/esri/core/workers/chunks/{3db8ae98799c752afe60.js → 34958516e604d487c625.js} +1 -1
  31. package/assets/esri/core/workers/chunks/3bee743f4c9370045a5d.js +1 -0
  32. package/assets/esri/core/workers/chunks/{8e08968505483dc58e00.js → 40ee4e0a5000a08c3abd.js} +1 -1
  33. package/assets/esri/core/workers/chunks/4128e45e17c9e5280e11.js +1 -0
  34. package/assets/esri/core/workers/chunks/4f88c4d1d2103843aca8.js +1 -0
  35. package/assets/esri/core/workers/chunks/505792ce8cbbddd2e815.js +1 -0
  36. package/assets/esri/core/workers/chunks/{3d42fa4ab5f8632d690a.js → 5237b3938be0d4bc6045.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{57077e608f20d3a931e8.js → 570e94f4fbefc856d303.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{4b235d1b6a72773cd4f4.js → 57bb8516fa998a0fba78.js} +1 -1
  39. package/assets/esri/core/workers/chunks/57bf3ff01d738cedc292.js +1 -0
  40. package/assets/esri/core/workers/chunks/{1e9e68312cd865358260.js → 60486acc5dacf73f851a.js} +1 -1
  41. package/assets/esri/core/workers/chunks/6208f2dfa9dfd3bca000.js +1 -0
  42. package/assets/esri/core/workers/chunks/64008bde5d3ffd9f2499.js +1 -0
  43. package/assets/esri/core/workers/chunks/69f51a7768bf51c9e346.js +1 -0
  44. package/assets/esri/core/workers/chunks/719f741a0e45c3e694ba.js +1 -0
  45. package/assets/esri/core/workers/chunks/{cfe379a78a983373b3ac.js → 7304f45f5622a68253e4.js} +1 -1
  46. package/assets/esri/core/workers/chunks/733b70d6e5c466a67e9c.js +1 -0
  47. package/assets/esri/core/workers/chunks/7694521b44681d52b713.js +1 -0
  48. package/assets/esri/core/workers/chunks/840fd05ceaa038c476d6.js +1 -0
  49. package/assets/esri/core/workers/chunks/89f7fd2ab92aa14fe0c0.js +1 -0
  50. package/assets/esri/core/workers/chunks/8a6f29f2ebd59783bb1b.js +1 -0
  51. package/assets/esri/core/workers/chunks/9d487b7817ccf5bceff6.js +1 -0
  52. package/assets/esri/core/workers/chunks/{42b6315e21c4c1345ba5.js → 9f5337a80963e0b3c009.js} +1 -1
  53. package/assets/esri/core/workers/chunks/a0face18b3ea567999ef.js +1 -0
  54. package/assets/esri/core/workers/chunks/b773c8854e98384ac8ac.js +1 -0
  55. package/assets/esri/core/workers/chunks/{fb44d872b9dbadcf8ccf.js → b9ef05c22bc3e395bcb3.js} +1 -1
  56. package/assets/esri/core/workers/chunks/bc5e34200776cfc83d5b.js +1 -0
  57. package/assets/esri/core/workers/chunks/{cfc3dcca2b69d20d5375.js → c0b9cc091efd5db827de.js} +1 -1
  58. package/assets/esri/core/workers/chunks/c9f5e949830196ad9458.js +1 -0
  59. package/assets/esri/core/workers/chunks/{036301f545aba2b8e485.js → cc15e28a99694120556d.js} +1 -1
  60. package/assets/esri/core/workers/chunks/ce7f575a6c2053c7ca17.js +1 -0
  61. package/assets/esri/core/workers/chunks/ce9c99cee3d1a3963e7c.js +1 -0
  62. package/assets/esri/core/workers/chunks/cf9a87b53ea74bae6a37.js +1 -0
  63. package/assets/esri/core/workers/chunks/d16850b98a53ade0de10.js +1 -0
  64. package/assets/esri/core/workers/chunks/d24f7ef6eca8c91b90b4.js +1 -0
  65. package/assets/esri/core/workers/chunks/dbd86e4b7983873cbe7c.js +1 -0
  66. package/assets/esri/core/workers/chunks/{3c3f65913006b84b2289.js → de20572d334abd4a7d82.js} +1 -1
  67. package/assets/esri/core/workers/chunks/e009e7f074a572894f48.js +1 -0
  68. package/assets/esri/core/workers/chunks/{cb004c492e22c50f9bfa.js → f3eb89cff63e00f036c6.js} +1 -1
  69. package/assets/esri/core/workers/chunks/{b2a423d9ce8bb784267c.js → f53f20c7100092823487.js} +1 -1
  70. package/assets/esri/core/workers/chunks/f6040205c50e2795a1a0.js +1 -0
  71. package/assets/esri/core/workers/chunks/{915734255a79bff3ef0f.js → fcd54e9e64c2864f183c.js} +1 -1
  72. package/assets/esri/t9n/common.json +1 -1
  73. package/assets/esri/t9n/common_en.json +1 -1
  74. package/assets/esri/themes/base/_core.scss +6 -2
  75. package/assets/esri/themes/base/_mixins.scss +0 -147
  76. package/assets/esri/themes/base/widgets/_AreaMeasurement2D.scss +0 -8
  77. package/assets/esri/themes/base/widgets/_AreaMeasurement3D.scss +0 -8
  78. package/assets/esri/themes/base/widgets/_DirectLineMeasurement3D.scss +0 -1
  79. package/assets/esri/themes/base/widgets/_DistanceMeasurement2D.scss +0 -1
  80. package/assets/esri/themes/base/widgets/_MeasurementWidgetContent.scss +67 -0
  81. package/assets/esri/themes/base/widgets/_Slice.scss +17 -54
  82. package/assets/esri/themes/base/widgets/_UnitSelect.scss +14 -0
  83. package/assets/esri/themes/dark/main.css +1 -1
  84. package/assets/esri/themes/light/main.css +1 -1
  85. package/assets/esri/themes/light/view.css +1 -1
  86. package/assets/esri/widgets/AreaMeasurement2D/t9n/AreaMeasurement2D.json +1 -1
  87. package/assets/esri/widgets/AreaMeasurement2D/t9n/AreaMeasurement2D_en.json +1 -1
  88. package/assets/esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D.json +1 -1
  89. package/assets/esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D_en.json +1 -1
  90. package/assets/esri/widgets/DirectLineMeasurement3D/t9n/DirectLineMeasurement3D.json +1 -1
  91. package/assets/esri/widgets/DirectLineMeasurement3D/t9n/DirectLineMeasurement3D_en.json +1 -1
  92. package/assets/esri/widgets/DistanceMeasurement2D/t9n/DistanceMeasurement2D.json +1 -1
  93. package/assets/esri/widgets/DistanceMeasurement2D/t9n/DistanceMeasurement2D_en.json +1 -1
  94. package/chunks/HUDMaterial.glsl.js +39 -39
  95. package/chunks/HighlightBlur.glsl.js +2 -2
  96. package/chunks/ShadowHighlight.glsl.js +1 -1
  97. package/chunks/arcade.js +1 -1
  98. package/chunks/languageUtils.js +1 -1
  99. package/core/HandleOwner.js +1 -1
  100. package/core/promiseUtils.js +1 -1
  101. package/core/support/{WatchUpdatingTracking.js → UpdatingHandles.js} +1 -1
  102. package/core/workers/workerFactory.js +1 -1
  103. package/geometry/projection.js +1 -1
  104. package/interfaces.d.ts +270 -5
  105. package/kernel.js +1 -1
  106. package/layers/Layer.js +1 -1
  107. package/layers/LinkChartLayer.d.ts +4 -0
  108. package/layers/LinkChartLayer.js +1 -1
  109. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  110. package/layers/mixins/PortalLayer.js +1 -1
  111. package/layers/support/TileInfoTilemapCache.js +1 -1
  112. package/package.json +1 -1
  113. package/support/revision.js +1 -1
  114. package/symbols/cim/cimAnalyzer.js +1 -1
  115. package/views/2d/layers/features/controllers/FeatureController2D.js +1 -1
  116. package/views/2d/layers/features/sources/DataTileSource.js +1 -1
  117. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  118. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  119. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  120. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  121. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  122. package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
  123. package/views/3d/analysis/LineOfSight/LineOfSightVisualization.js +1 -1
  124. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  125. package/views/3d/environment/CloudsGenerator.js +1 -1
  126. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  127. package/views/3d/environment/Precipitation.js +1 -1
  128. package/views/3d/environment/SceneViewEnvironmentManager.js +1 -1
  129. package/views/3d/environment/Stars.js +1 -1
  130. package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
  131. package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
  132. package/views/3d/interactive/editingTools/transformGraphic/GraphicTransformTool.js +1 -1
  133. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
  134. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
  135. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  136. package/views/3d/layers/I3SMeshView3D.js +1 -1
  137. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  138. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  139. package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
  140. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  141. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  142. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  143. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  144. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  145. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  146. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  147. package/views/3d/layers/graphics/Graphics3DScaleVisibility.js +1 -1
  148. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  149. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  150. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  151. package/views/3d/layers/graphics/GraphicsProcessor.js +1 -1
  152. package/views/3d/layers/graphics/Labeler.js +1 -1
  153. package/views/3d/layers/graphics/labelPlacement.js +1 -1
  154. package/views/3d/layers/support/FeatureTileTree3DDebugger.js +1 -1
  155. package/views/3d/layers/support/FeatureVisibilityFilter.js +1 -1
  156. package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
  157. package/views/3d/state/ViewState.js +1 -1
  158. package/views/3d/state/ViewStateManager.js +1 -1
  159. package/views/3d/support/DisplayQualityProfile.js +1 -1
  160. package/views/3d/support/MemoryController.js +1 -1
  161. package/views/3d/support/SceneViewPerformanceInfo.js +1 -1
  162. package/views/3d/support/cameraUtils.js +1 -1
  163. package/views/3d/support/viewpointUtils.js +1 -1
  164. package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
  165. package/views/3d/terrain/OverlayManager.js +1 -1
  166. package/views/3d/terrain/OverlayRenderer.js +1 -1
  167. package/views/3d/terrain/TerrainSurface.js +1 -1
  168. package/views/3d/webgl-engine/Stage.js +1 -1
  169. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  170. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUDOcclusionPass.glsl.js +6 -7
  171. package/views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js +1 -1
  172. package/views/3d/webgl-engine/lib/Highlight.js +1 -1
  173. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  174. package/views/3d/webgl-engine/lib/RenderPluginManager.js +1 -1
  175. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  176. package/views/3d/webgl-engine/lib/SSAOHelper.js +1 -1
  177. package/views/3d/webgl-engine/lib/SmaaRenderPass.js +1 -1
  178. package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
  179. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  180. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  181. package/views/LayerViewManager.js +1 -1
  182. package/views/ToolViewManager.js +1 -1
  183. package/views/draw/DrawOperation.js +1 -1
  184. package/views/draw/PointDrawAction.js +1 -1
  185. package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
  186. package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
  187. package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
  188. package/views/interactive/snapping/featureSources/I3SSnappingSource.js +1 -1
  189. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  190. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
  191. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
  192. package/views/layers/LayerView.js +1 -1
  193. package/views/overlay/ViewOverlay.js +1 -1
  194. package/views/webgl/Texture.js +1 -1
  195. package/widgets/AreaMeasurement2D.js +1 -1
  196. package/widgets/AreaMeasurement3D.js +1 -1
  197. package/widgets/DirectLineMeasurement3D.js +1 -1
  198. package/widgets/DistanceMeasurement2D.js +1 -1
  199. package/widgets/Editor/EditorViewModel.js +1 -1
  200. package/widgets/Editor/Workflow.js +1 -1
  201. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  202. package/widgets/FeatureForm/FieldInput.js +1 -1
  203. package/widgets/FeatureForm/FormExpressionArcadeExecutor.js +1 -1
  204. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  205. package/widgets/OrientedImageryViewer.js +1 -1
  206. package/widgets/Slice.js +1 -1
  207. package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +1 -1
  208. package/widgets/support/MeasurementWidgetContent.js +5 -0
  209. package/widgets/support/UnitSelect.js +5 -0
  210. package/assets/esri/core/workers/chunks/0254165377538522c830.js +0 -1
  211. package/assets/esri/core/workers/chunks/07f16ea775b39a1a4a7b.js +0 -1
  212. package/assets/esri/core/workers/chunks/170c72126d10b1fdb2b0.js +0 -1
  213. package/assets/esri/core/workers/chunks/1bbc868d2430103951eb.js +0 -1
  214. package/assets/esri/core/workers/chunks/1d2ef88a8d028adef102.js +0 -1
  215. package/assets/esri/core/workers/chunks/2ef70c9b2484a11b7435.js +0 -1
  216. package/assets/esri/core/workers/chunks/39ae4b9b766f674bc6f2.js +0 -1
  217. package/assets/esri/core/workers/chunks/3b3d676b609c47a77164.js +0 -1
  218. package/assets/esri/core/workers/chunks/3d9a8cb638cf9b8ca4b3.js +0 -1
  219. package/assets/esri/core/workers/chunks/42f3421740a5479559dc.js +0 -1
  220. package/assets/esri/core/workers/chunks/45629ff775e77234b227.js +0 -1
  221. package/assets/esri/core/workers/chunks/52315f93a6f0ad59bd90.js +0 -1
  222. package/assets/esri/core/workers/chunks/5bb96e602d7cecbecf54.js +0 -1
  223. package/assets/esri/core/workers/chunks/63322229183f1d4eaa70.js +0 -1
  224. package/assets/esri/core/workers/chunks/642510b0371311ff8e16.js +0 -1
  225. package/assets/esri/core/workers/chunks/6995ace1d25d67c98d0e.js +0 -1
  226. package/assets/esri/core/workers/chunks/7e4013f8c31c9a9438c6.js +0 -1
  227. package/assets/esri/core/workers/chunks/82939ead43848a13f765.js +0 -1
  228. package/assets/esri/core/workers/chunks/8b6b963230df56850580.js +0 -1
  229. package/assets/esri/core/workers/chunks/95ff92d7caa34664d58f.js +0 -1
  230. package/assets/esri/core/workers/chunks/9e570cd4a48c30c83ae6.js +0 -1
  231. package/assets/esri/core/workers/chunks/a9e9297267614c4c4f3b.js +0 -1
  232. package/assets/esri/core/workers/chunks/b052463ffb7cb32306dc.js +0 -1
  233. package/assets/esri/core/workers/chunks/b31974524932e638df8c.js +0 -1
  234. package/assets/esri/core/workers/chunks/b75b4b132dbd9cb9d372.js +0 -1
  235. package/assets/esri/core/workers/chunks/c1dfbda75abc748a6ca4.js +0 -1
  236. package/assets/esri/core/workers/chunks/c8702e53a8ad6cf6ab85.js +0 -1
  237. package/assets/esri/core/workers/chunks/c90416e7bf29eb1d4536.js +0 -1
  238. package/assets/esri/core/workers/chunks/cad7a2092ea7f51dbd8b.js +0 -1
  239. package/assets/esri/core/workers/chunks/d0e2b42dca51711f2c6f.js +0 -1
  240. package/assets/esri/core/workers/chunks/d2a127f7bb0e2ba14a13.js +0 -1
  241. package/assets/esri/core/workers/chunks/df96824a6f76bad1370c.js +0 -1
  242. package/assets/esri/core/workers/chunks/e097f41bbfac00250477.js +0 -1
  243. package/assets/esri/core/workers/chunks/e3243d120a23a9b48392.js +0 -1
  244. package/assets/esri/core/workers/chunks/e55f80b774e090a0aa04.js +0 -1
  245. package/assets/esri/core/workers/chunks/e668c7e2e61aae6ca6e0.js +0 -1
  246. package/assets/esri/core/workers/chunks/ef900614353505afb210.js +0 -1
  247. package/assets/esri/core/workers/chunks/f0299d93a95f40ea7cf7.js +0 -1
  248. package/assets/esri/core/workers/chunks/f23b95d7e51a144ad065.js +0 -1
  249. package/assets/esri/core/workers/chunks/f263e73a25fae4beffae.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as t}from"../../../../core/accessorSupport/decorators/subclass.js";import{RasterTileContainer as s}from"../../engine/imagery/RasterTileContainer.js";import{BaseImageryTileSubView2D as i}from"./BaseImageryTileSubView2D.js";import{canUseMajorityInterpolationOnDataSource as n}from"../support/util.js";let o=class extends i{constructor(){super(...arguments),this.type="raster"}attach(){super.attach(),this.container=new s(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this.updateRasterFunctionParameters()}detach(){super.detach(),this.container.removeAllChildren(),this.container=null}canUseWebGLForProcessing(){return this.useWebGLForProcessing&&this.layer.symbolizer.canRenderInWebGL&&!("majority"===this.layer.interpolation&&n(this.layer))}fetchTile(e,r){return this.layer.fetchTile(e.level,e.row,e.col,r)}updateRasterFunctionParameters(){const{raster:e,type:r}=this.layer,{container:t}=this;if("Function"!==e.datasetFormat||"wcs"===r)return t.rasterFunctionChain=null,t.children.forEach((e=>{const{bitmap:r}=e;r&&(r.suspended=!0,r.processed=!1,r.projected&&(r.invalidateTexture(),r.rasterTexture=null))})),void(this._rasterFunctionState="na");const s=this._rasterFunctionState,{rasterFunction:i,primaryRasters:n}=e,o=i.supportsGPU&&(!n||n.rasters.length<=1),a=o?i.flatWebGLFunctionChain:null,{renderer:l}=this.layer,c=!o||!a?.functions.length||"raster-stretch"===l?.type&&l.dynamicRangeAdjustment||!this.canUseWebGLForProcessing();t.rasterFunctionChain=c?null:a;const u=null==i?"na":t.rasterFunctionChain?"gpu":"cpu";t.children.forEach((e=>{const{bitmap:r}=e;r&&(r.suspended=s!==u,r.processed=!1,r.processedTexture=null)})),this._rasterFunctionState=u}async updateTileSource(e,r){const t=this._getBandIds(),s=this._getLayerInterpolation(),i=this.canUseWebGLForProcessing(),{source:n,globalSymbolizerParams:o,suspended:a,coords:l,resolution:c}=r,u=this.layerView.hasTilingEffects?o:r.symbolizerParams,{bitmap:p}=e;if([p.x,p.y]=l,p.resolution=c,n&&null!=n&&null!=n.pixelBlock){const e={extent:n.extent,pixelBlock:n.pixelBlock};if(p.rawPixelData=e,i)p.source=n.pixelBlock,p.isRendereredSource=!1;else{const r=await this.layer.applyRenderer(e,"stretch"===o?.type?o:void 0);p.source=r,p.isRendereredSource=!0}p.symbolizerParameters=i?u:null,i?p.transformGrid||(p.transformGrid=n.transformGrid):p.transformGrid=null}else{const e=this.createEmptyTilePixelBlock();p.source=e,p.symbolizerParameters=i?u:null,p.transformGrid=null}p.bandIds=i?t:null,p.width=this._tileInfoView.tileInfo.size[0],p.height=this._tileInfoView.tileInfo.size[1],p.interpolation=s,p.suspended=a,p.invalidateTexture()}async updateTileSymbolizerParameters(e,r){const{local:t,global:s}=r,i=this._getBandIds(),n=this._getLayerInterpolation(),o=this.canUseWebGLForProcessing(),{bitmap:a}=e,{rawPixelData:l}=a;o||null==l?(a.isRendereredSource&&null!=l&&(a.source=l.pixelBlock),a.isRendereredSource=!1):(a.source=await this.layer.applyRenderer(l,"stretch"===s?.type?s:void 0),a.isRendereredSource=!0),a.symbolizerParameters=o?this.layerView.hasTilingEffects?s:t:null,a.bandIds=o?i:null,a.interpolation=n,a.suspended=!1}_getLayerInterpolation(){const{interpolation:e,renderer:r}=this.layer;if(!r)return e;const t=r.type;return"raster-colormap"===t||"unique-value"===t||"class-breaks"===t?"nearest":"raster-stretch"===r.type&&null!=r.colorRamp?"bilinear"===e||"cubic"===e?"bilinear":"nearest":e}};e([r()],o.prototype,"container",void 0),e([r()],o.prototype,"layer",void 0),e([r()],o.prototype,"type",void 0),o=e([t("esri.views.2d.layers.imagery.ImageryTileView2D")],o);const a=o;export{a as default};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as t}from"../../../../core/accessorSupport/decorators/subclass.js";import{RasterTileContainer as s}from"../../engine/imagery/RasterTileContainer.js";import{BaseImageryTileSubView2D as i}from"./BaseImageryTileSubView2D.js";import{canUseMajorityInterpolationOnDataSource as o}from"../support/util.js";let n=class extends i{constructor(){super(...arguments),this.type="raster"}attach(){super.attach(),this.container=new s(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this.updateRasterFunctionParameters()}detach(){super.detach(),this.container.removeAllChildren(),this.container=null}canUseWebGLForProcessing(){const{symbolizer:e}=this.layer,r=e.lookup?.colormapLut?.indexedColormap,t=r&&r.length>this._maxIndexedColormapSize;return this.useWebGLForProcessing&&e.canRenderInWebGL&&!t&&!("majority"===this.layer.interpolation&&o(this.layer))}fetchTile(e,r){return this.layer.fetchTile(e.level,e.row,e.col,r)}updateRasterFunctionParameters(){const{raster:e,type:r}=this.layer,{container:t}=this;if("Function"!==e.datasetFormat||"wcs"===r)return t.rasterFunctionChain=null,t.children.forEach((e=>{const{bitmap:r}=e;r&&(r.suspended=!0,r.processed=!1,r.projected&&(r.invalidateTexture(),r.rasterTexture=null))})),void(this._rasterFunctionState="na");const s=this._rasterFunctionState,{rasterFunction:i,primaryRasters:o}=e,n=i.supportsGPU&&(!o||o.rasters.length<=1),a=n?i.flatWebGLFunctionChain:null,{renderer:l}=this.layer,c=!n||!a?.functions.length||"raster-stretch"===l?.type&&l.dynamicRangeAdjustment||!this.canUseWebGLForProcessing();t.rasterFunctionChain=c?null:a;const u=null==i?"na":t.rasterFunctionChain?"gpu":"cpu";t.children.forEach((e=>{const{bitmap:r}=e;r&&(r.suspended=s!==u,r.processed=!1,r.processedTexture=null)})),this._rasterFunctionState=u}async updateTileSource(e,r){const t=this._getBandIds(),s=this._getLayerInterpolation(),i=this.canUseWebGLForProcessing(),{source:o,globalSymbolizerParams:n,suspended:a,coords:l,resolution:c}=r,u=this.layerView.hasTilingEffects?n:r.symbolizerParams,{bitmap:p}=e;if([p.x,p.y]=l,p.resolution=c,o&&null!=o&&null!=o.pixelBlock){const e={extent:o.extent,pixelBlock:o.pixelBlock};if(p.rawPixelData=e,i)p.source=o.pixelBlock,p.isRendereredSource=!1;else{const r=await this.layer.applyRenderer(e,"stretch"===n?.type?n:void 0);p.source=r,p.isRendereredSource=!0}p.symbolizerParameters=i?u:null,i?p.transformGrid||(p.transformGrid=o.transformGrid):p.transformGrid=null}else{const e=this.createEmptyTilePixelBlock();p.source=e,p.symbolizerParameters=i?u:null,p.transformGrid=null}p.bandIds=i?t:null,p.width=this._tileInfoView.tileInfo.size[0],p.height=this._tileInfoView.tileInfo.size[1],p.interpolation=s,p.suspended=a,p.invalidateTexture()}async updateTileSymbolizerParameters(e,r){const{local:t,global:s}=r,i=this._getBandIds(),o=this._getLayerInterpolation(),n=this.canUseWebGLForProcessing(),{bitmap:a}=e,{rawPixelData:l}=a;n||null==l?(a.isRendereredSource&&null!=l&&(a.source=l.pixelBlock),a.isRendereredSource=!1):(a.source=await this.layer.applyRenderer(l,"stretch"===s?.type?s:void 0),a.isRendereredSource=!0),a.symbolizerParameters=n?this.layerView.hasTilingEffects?s:t:null,a.bandIds=n?i:null,a.interpolation=o,a.suspended=!1}_getLayerInterpolation(){const{interpolation:e,renderer:r}=this.layer;if(!r)return e;const t=r.type;return"raster-colormap"===t||"unique-value"===t||"class-breaks"===t?"nearest":"raster-stretch"===r.type&&null!=r.colorRamp?"bilinear"===e||"cubic"===e?"bilinear":"nearest":e}};e([r()],n.prototype,"container",void 0),e([r()],n.prototype,"layer",void 0),e([r()],n.prototype,"type",void 0),n=e([t("esri.views.2d.layers.imagery.ImageryTileView2D")],n);const a=n;export{a as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../Color.js";import"../../../../geometry.js";import{LengthDimensionMeasureType as i}from"../../../../analysis/dimensionUtils.js";import n from"../../../../analysis/LengthDimension.js";import a from"../../../../core/Accessor.js";import o from"../../../../core/Handles.js";import{equals as s}from"../../../../core/lang.js";import{destroyMaybe as r}from"../../../../core/maybe.js";import{memoize as p}from"../../../../core/memoize.js";import{ignoreAbortErrors as l}from"../../../../core/promiseUtils.js";import{watch as u,sync as d,syncAndInitial as c,initial as m,when as h}from"../../../../core/reactiveUtils.js";import{property as g}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as f}from"../../../../core/accessorSupport/decorators/subclass.js";import{c as _}from"../../../../chunks/vec3f64.js";import{WatchUpdatingTracking as M}from"../../../../core/support/WatchUpdatingTracking.js";import{clonePoint as y}from"../../../../layers/graphics/hydratedFeatures.js";import{reapplyConstraint as v,LengthDimensionConstraint as C,applyConstraint as S,computeConstraint as b,constraintDependencies as w}from"./lengthDimensionConstraintUtils.js";import{LengthDimensionManipulators as D,createPointManipulator as P,pointManipulatorHandles as O,createOffsetManipulator as j,offsetManipulatorHandles as H,createOrientationManipulator as T,headingManipulatorHandles as G,rotationManipulatorHandles as I,createMeasureTypeManipulator as z,measureTypeManipulatorHandles as x,updateOffsetManipulatorTransform as V,updateHeadingManipulatorTransform as U,updateRotationManipulatorTransform as R,updateMeasureTypeManipulatorTransform as A,unfocusedOffsetWidth as k,focusedOffsetWidth as E,updateOrientationManipulator as F}from"./lengthDimensionManipulatorUtils.js";import{isValidComputation as L,arePointsVerticallyAligned as q,computeGeometryFromDimension as B,computationToGeometryDependencies as N}from"./lengthDimensionUtils.js";import{settings as W}from"./settings.js";import{getRotateHeadingTexture as J}from"../Slice/images/Factory.js";import{SnappingVisualizer3D as K}from"../../interactive/SnappingVisualizer3D.js";import{LineVisualElement as Q}from"../../interactive/visualElements/LineVisualElement.js";import{VerticesVisualElement as X}from"../../interactive/visualElements/VerticesVisualElement.js";import{RenderOccludedFlag as Y}from"../../webgl-engine/lib/Material.js";import{ImageMaterial as Z}from"../../webgl-engine/materials/ImageMaterial.js";import{createStipplePatternSimple as $}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as tt}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{createCoordinateHelper as et}from"../../../interactive/coordinateHelper.js";import{EditGeometry as it}from"../../../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as nt}from"../../../interactive/editGeometry/EditGeometryOperations.js";import{acquire as at}from"../../../interactive/snapping/SceneSnappingManagerPool.js";import{SnappingContext as ot}from"../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as st}from"../../../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as rt}from"../../../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as pt}from"../../../interactive/snapping/snappingUtils.js";import lt from"../../../../geometry/Point.js";let ut=class extends a{constructor(t){super(t),this._stagedDimension=null,this._computationManipulators=new Map,this._computationHandles=new o,this._updatingHandles=new M,this._getSnappingContext=p((t=>new ot({elevationInfo:{mode:"absolute-height",offset:0},pointer:t,editGeometryOperations:new nt(new it("point",et(!0,!1,this.view.spatialReference))),visualizer:new K})));const{view:i}=t;this._snappingManagerResult=at(i),this.addHandles(this._snappingManagerResult),this._unfocusedOffsetManipulatorMaterial=dt(),this._focusedOffsetManipulatorMaterial=dt(),this._thinOffsetManipulatorMaterial=dt(),this._thinOffsetManipulatorMaterial.setParameters({stipplePattern:$(2)}),this._constraintSnappingIndicator=new Q({view:i,attached:!0,width:1,color:e.toUnitRGBA(W.constraint.color),renderOccluded:Y.OccludeAndTransparent,stipplePattern:$(5),isDecoration:!0});const n=e.toUnitRGBA(W.disabledPointIndicator.color);this._stagedStartIndicator=new X({view:i,attached:!1,elevationInfo:{mode:"absolute-height",offset:0},spatialReference:t.view.renderCoordsHelper.spatialReference,color:n,size:2*W.disabledPointIndicator.radius,outlineSize:0,renderOccluded:Y.OccludeAndTransparent,isDecoration:!0})}initialize(){this._snappingOperation=new rt({view:this.view});const{color:t,contrastColor:e}=W.orientationManipulator,i=!this.view._stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result;this._orientationManipulatorTexture=J(this.view.toolViewManager.textures,{accentColor:t,contrastColor:e,preMultiplyAlpha:i}),this._orientationManipulatorMaterial=new Z({transparent:!0,writeDepth:!1,textureId:this._orientationManipulatorTexture.texture.id,renderOccluded:Y.Opaque,isDecoration:!0});const{computations:n}=this.analysisViewData;for(const a of n)this._addComputation(a);this.addHandles([n.on("after-add",(t=>this._addComputation(t.item))),n.on("after-remove",(t=>this._removeComputation(t.item)))]),this.addHandles([u((()=>({stagedPoint:this._snappingOperation.stagedPoint,stagedComputation:this._stagedComputation})),(({stagedPoint:t,stagedComputation:e})=>{if(null==e||null==t)return;const i=y(t,new lt);this._applyPointUpdate(e,{endPoint:i})}),d),u((()=>({stagedDimension:this._stagedDimension,selectedComputation:this.analysisViewData.selectedComputation,firstGrabbedManipulator:this.firstGrabbedManipulator})),((t,e)=>{const{stagedDimension:i,selectedComputation:n,firstGrabbedManipulator:a}=t;if(i===e?.stagedDimension&&a===e?.firstGrabbedManipulator){for(const o of[n,e?.selectedComputation])if(null!=o){const e=this._computationManipulators.get(o);this._updateManipulators(o,e,t)}}else for(const[o,s]of this._computationManipulators)this._updateManipulators(o,s,t)}),c),u((()=>this.analysis.style.lineSize),(t=>{this._updateManipulatorStyle(t)}),m),u((()=>this.view.state.camera),(()=>{null!=this._stagedComputation&&this._updateStagedDimensionOffset(this._stagedComputation)})),u((()=>{const t=this._stagedComputation;if(!t)return null;const e=t.elevationAlignedStartPoint,i=_();return null!=e&&this.view.renderCoordsHelper.toRenderCoords(e,i)?i:null}),(t=>{null!=t?(this._stagedStartIndicator.vertices=[t],this._stagedStartIndicator.attached=!0):this._stagedStartIndicator.attached=!1}))]),this.addHandles(this._constraintHandles),this.addHandles(this._snappingIndicatorHandles),pt(this,(()=>{const t=this._activeComputation,e=this._stagedComputation;if(null==t||null!=e){const t=this.view.inputManager.latestPointerType??"mouse",e=this._getSnappingContext(t);this._updatingHandles.addPromise(l(this._snappingOperation.resnap(this._snappingManager,e)))}if(null!=t){const{start:e,end:i}=this._computationManipulators.get(t);if(e.grabbing||i.grabbing){const i=e.grabbing?"start":"end",n=this._computeConstraint(t);v(t,i,{constraint:n,view:this.view})}}}))}destroy(){this._snappingOperation=r(this._snappingOperation),this._computationHandles.destroy(),this._constraintSnappingIndicator.destroy(),this._stagedStartIndicator.destroy(),this._orientationManipulatorMaterial.dispose(),this._orientationManipulatorTexture.release()}get updating(){return this._updatingHandles.updating||this._snappingManager.updating}get firstGrabbedManipulator(){return this.parentTool.firstGrabbedManipulator}get hasGrabbedManipulators(){return this.parentTool.hasGrabbedManipulators}get snappingOptions(){return this._snappingManager.options}get _snappingManager(){return this._snappingManagerResult.snappingManager}get _activeComputation(){if(null!=this._stagedComputation)return this._stagedComputation;const{selectedComputation:t}=this.analysisViewData;return this.hasGrabbedManipulators&&null!=t?t:null}get _stagedComputation(){const t=this._stagedDimension,e=this.analysisViewData.computations.at(-1);return null==t||null==e||e.dimension!==t?null:e}get _constraintHandles(){return[h((()=>this.analysisViewData.selectedComputation),(t=>{t.previousConstraint=this._computeConstraint(t)}),{...c,equals:s}),u((()=>{const t=this._activeComputation;if(null==t)return null;const{measureType:e,orientation:i}=t.dimension;return{measureType:e,orientation:i,computation:t}}),((t,e)=>{if(null!=t&&null==e){const{measureType:e,orientation:n,computation:a}=t;switch(a.previousConstraint){case C.Horizontal:a.preConstraintProperties={measureType:i.Horizontal,orientation:0};break;case C.Vertical:a.preConstraintProperties={measureType:i.Vertical,orientation:0};break;case C.Direct:a.preConstraintProperties={measureType:i.Direct,orientation:n};break;default:a.preConstraintProperties={measureType:e,orientation:n}}}null==t&&null!=e&&(e.computation.preConstraintProperties=null)}),d)]}get _snappingIndicatorHandles(){const t="snapping-indicator-event-handles";return[u((()=>({stagedComputation:this._stagedComputation,activeComputation:this._activeComputation})),(({stagedComputation:e,activeComputation:i})=>{const n=this._constraintSnappingIndicator;if(this.removeHandles(t),null!=i)if(i===e)n.attached=!0;else{const{start:e,end:a}=this._computationManipulators.get(i),o=()=>{n.attached=e.grabbing||a.grabbing};o(),this.addHandles([e.events.on("grab-changed",o),a.events.on("grab-changed",o)],t)}else n.attached=!1})),u((()=>{const t=this._activeComputation;return null!=t?{geometry:t.geometry,constraint:t.previousConstraint}:{}}),(({geometry:t,constraint:e})=>{const i=this._constraintSnappingIndicator;null!=t&&null!=e&&e!==C.Direct?(i.visible=!0,i.setGeometryFromSegment(t.directSegment)):i.visible=!1}))]}removeStaged(){return null!=this._stagedDimension&&(this.analysis.dimensions.remove(this._stagedDimension),this._stagedDimension=null,!0)}onDeactivate(){this.removeStaged(),this._resetSnappingState()}onClick(t){const{_stagedDimension:e}=this;if(null==e){const e=this._onUnstagedClick(t);return this.analysis.dimensions.add(e),null}return this._onStagedClick(t),e}onPointerMove({mapPoint:t,pointerType:e}){if("touch"===e)return;const i=this._getSnappingContext(e);this._updatingHandles.addPromise(l(this._snappingOperation.snap({point:t},this._snappingManager,i)))}onManipulatorSelectionChanged(){if(null!=this.analysisViewData.selectedComputation){this._computationManipulators.get(this.analysisViewData.selectedComputation).offset.selected||(this.analysisViewData.selectedDimension=null)}}_onUnstagedClick({mapPoint:t,pointerType:e}){let a=t;if("mouse"===e){const i=this._getSnappingContext(e);a=this._snappingManager.update({point:t,context:i})}const o=new n({startPoint:y(a,new lt),endPoint:null,measureType:i.Horizontal});return this._stagedDimension=o,this._resetSnappingState(),o}_onStagedClick({mapPoint:t,pointerType:e}){const i=this._stagedComputation;if(null==i)return;let n=t;if("mouse"===e){const i=this._getSnappingContext(e);n=this._snappingManager.update({point:t,context:i})}const a=y(n,new lt);this._applyPointUpdate(i,{endPoint:a}),this._stagedDimension=null,this._resetSnappingState()}_resetSnappingState(){this._snappingManager.doneSnapping(),this._snappingOperation.abort(),this._snappingOperation.stagedPoint=null}_addComputation(t){if(this._computationManipulators.has(t))return;const e=this._setupPointManipulator(t,{isStart:!0}),n=this._setupPointManipulator(t,{isStart:!1}),a=this._setupOffsetManipulator(t),o=this._setupHeadingManipulator(t),s=this._setupRotationManipulator(t),r=this._setupMeasureTypeManipulator(t,i.Direct),p=this._setupMeasureTypeManipulator(t,i.Horizontal),l=this._setupMeasureTypeManipulator(t,i.Vertical),u=new D({start:e,end:n,offset:a,heading:o,rotation:s,direct:r,horizontal:p,vertical:l});this._setupComputationToManipulatorsSync(t,u),this._computationManipulators.set(t,u),this.manipulators.addMany(u.values())}_removeComputation(t){const e=this._computationManipulators.get(t);if(null!=e){this._computationHandles.remove(t),this._computationManipulators.delete(t);for(const t of e.values())this.manipulators.remove(t)}}_setupComputationToManipulatorsSync(t,e){this._computationHandles.add([u((()=>t.geometry),(()=>this._updateManipulators(t,e)),{...c,equals:s})],t)}_setupPointManipulator(t,e){const{view:i}=this,{dimension:n}=t,a=P(i,{metadata:n}),o=O(a,{isStart:e.isStart,createSnappingPipelineStep:t=>st({snappingContext:this._getSnappingContext(t),snappingManager:this._snappingManager,updatingHandles:this._updatingHandles}),dimension:n,onUpdate:e=>this._applyPointUpdate(t,e),view:i});return this._computationHandles.add(o,t),a}_setupOffsetManipulator(t){const{view:e}=this,i=j(e,{lineSizePt:this.analysis.style.lineSize,unfocusedMaterial:this._unfocusedOffsetManipulatorMaterial,focusedMaterial:this._focusedOffsetManipulatorMaterial,metadata:t.dimension}),n=H(i,{computation:t,view:e});return this._computationHandles.add(n,t),i}_setupHeadingManipulator(t){const{view:e}=this,i=T(e,{lineSizePt:this.analysis.style.lineSize,material:this._orientationManipulatorMaterial,metadata:t.dimension}),n=G(i,{computation:t,view:e});return this._computationHandles.add(n,t),i}_setupRotationManipulator(t){const{view:e}=this,i=T(e,{lineSizePt:this.analysis.style.lineSize,material:this._orientationManipulatorMaterial,metadata:t.dimension}),n=I(i,{computation:t,view:e});return this._computationHandles.add(n,t),i}_setupMeasureTypeManipulator(t,e){const{view:i}=this,n=z(i,{lineSizePt:this.analysis.style.lineSize,unfocusedMaterial:this._unfocusedOffsetManipulatorMaterial,focusedMaterial:this._focusedOffsetManipulatorMaterial,thinOffsetManipulatorMaterial:this._thinOffsetManipulatorMaterial,metadata:t.dimension}),a=x(n,{computation:t,manipulatorMeasureType:e,view:i});return this._computationHandles.add(a,t),n}_updateManipulators(t,e,n={stagedDimension:this._stagedDimension,selectedComputation:this.analysisViewData.selectedComputation,firstGrabbedManipulator:this.firstGrabbedManipulator}){const{stagedDimension:a,selectedComputation:o,firstGrabbedManipulator:s}=n,{start:r,end:p,offset:l,heading:u,rotation:d}=e,c=o===t,m=L(t),{dimension:h}=t;for(const i of e.values()){const t=m&&null==a&&(null==s||i===s);i===l?(i.available=t,i.selected=c):i.available=t&&c}if(!m)return;null!=this._computeConstraint(t)?e.forEachMeasureTypeManipulator((t=>t.available=!1)):e.manipulatorForMeasureType(h.measureType).available=!1;for(const _ of[u,d])h.measureType===i.Direct&&0!==h.offset||(_.available=!1);q(t)?d.available=!1:u.available=!1;const{geometry:g}=t;r.renderLocation=g.directSegment.startRenderSpace,p.renderLocation=g.directSegment.endRenderSpace;const{renderCoordsHelper:f}=this.view;V(l,g,f),u.available&&U(u,t,f),d.available&&R(d,t,f),e.forEachMeasureTypeManipulator(((e,i)=>{e.available&&A(e,t,i,f)}))}_updateManipulatorStyle(t){const e=k(t),i=E(t),n={lineSizePt:t,material:this._orientationManipulatorMaterial};for(const{offset:a,heading:o,rotation:s}of this._computationManipulators.values())a.radius=i/2,F(o,n),F(s,n);this._unfocusedOffsetManipulatorMaterial.setParameters({width:e}),this._focusedOffsetManipulatorMaterial.setParameters({width:i})}_applyPointUpdate(t,e){const{view:i}=this,n=N(t);"startPoint"in e&&(n.elevationAlignedStartPoint=e.startPoint),"endPoint"in e&&(n.elevationAlignedEndPoint=e.endPoint);const a=B(n,i.renderCoordsHelper);if(null==a)return;const o=this._computeConstraint({...n,geometry:a});S(t,e,{...n,constraint:o,unconstrainedGeometry:a,view:i}),t===this._stagedComputation&&this._updateStagedDimensionOffset(t)}_updateStagedDimensionOffset(t){if(null==t.geometry)return;t.geometry.directSegment.eval(.5,ct);const e=this.view.state.camera.computeRenderPixelSizeAt(ct);t.dimension.offset=W.initialOffsetPx*e}_computeConstraint(t){return b(w(t,this._snappingManager.options),this.view)}get testInfo(){const t=t=>this.analysisViewData.computations.find((e=>e.dimension===t));return{disableManipulatorPartialOcclusion:()=>{this._stagedStartIndicator.renderOccluded=Y.Occlude,this.manipulators.forEach((({manipulator:t})=>{for(const{geometry:e}of t.renderObjects)e.material.setParameters({renderOccluded:Y.Occlude})}))},getManipulatorsForDimension:e=>this._computationManipulators.get(t(e)),getComputationForDimension:e=>t(e),getConstraintForDimension:e=>{const i=t(e);return null!=i?this._computeConstraint(i):null},stagedDimension:this._stagedDimension,stagedStartIndicator:this._stagedStartIndicator,constraintSnappingIndicator:this._constraintSnappingIndicator,snappingManager:this._snappingManager}}};function dt(){const{color:t}=W.offsetManipulator;return new tt({color:e.toUnitRGBA(t),width:1,renderOccluded:Y.OccludeAndTransparent,writeDepth:!1,hasPolygonOffset:!0,isDecoration:!0})}t([g({constructOnly:!0})],ut.prototype,"analysis",void 0),t([g({constructOnly:!0})],ut.prototype,"analysisViewData",void 0),t([g({constructOnly:!0})],ut.prototype,"manipulators",void 0),t([g({constructOnly:!0})],ut.prototype,"parentTool",void 0),t([g({constructOnly:!0,nonNullable:!0})],ut.prototype,"view",void 0),t([g({readOnly:!0})],ut.prototype,"updating",null),t([g()],ut.prototype,"firstGrabbedManipulator",null),t([g()],ut.prototype,"hasGrabbedManipulators",null),t([g()],ut.prototype,"snappingOptions",null),t([g()],ut.prototype,"_stagedDimension",void 0),t([g()],ut.prototype,"_activeComputation",null),t([g()],ut.prototype,"_stagedComputation",null),ut=t([f("esri.views.3d.analysis.Dimension.LengthDimensionSubTool")],ut);const ct=_();export{ut as LengthDimensionSubTool};
5
+ import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../Color.js";import"../../../../geometry.js";import{LengthDimensionMeasureType as i}from"../../../../analysis/dimensionUtils.js";import n from"../../../../analysis/LengthDimension.js";import a from"../../../../core/Accessor.js";import o from"../../../../core/Handles.js";import{equals as s}from"../../../../core/lang.js";import{destroyMaybe as r}from"../../../../core/maybe.js";import{memoize as p}from"../../../../core/memoize.js";import{ignoreAbortErrors as l}from"../../../../core/promiseUtils.js";import{watch as u,sync as d,syncAndInitial as c,initial as m,when as h}from"../../../../core/reactiveUtils.js";import{property as g}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as f}from"../../../../core/accessorSupport/decorators/subclass.js";import{c as _}from"../../../../chunks/vec3f64.js";import{UpdatingHandles as M}from"../../../../core/support/UpdatingHandles.js";import{clonePoint as y}from"../../../../layers/graphics/hydratedFeatures.js";import{reapplyConstraint as v,LengthDimensionConstraint as C,applyConstraint as S,computeConstraint as b,constraintDependencies as w}from"./lengthDimensionConstraintUtils.js";import{LengthDimensionManipulators as D,createPointManipulator as P,pointManipulatorHandles as O,createOffsetManipulator as j,offsetManipulatorHandles as H,createOrientationManipulator as T,headingManipulatorHandles as G,rotationManipulatorHandles as I,createMeasureTypeManipulator as z,measureTypeManipulatorHandles as x,updateOffsetManipulatorTransform as V,updateHeadingManipulatorTransform as U,updateRotationManipulatorTransform as R,updateMeasureTypeManipulatorTransform as A,unfocusedOffsetWidth as k,focusedOffsetWidth as E,updateOrientationManipulator as F}from"./lengthDimensionManipulatorUtils.js";import{isValidComputation as L,arePointsVerticallyAligned as q,computeGeometryFromDimension as B,computationToGeometryDependencies as N}from"./lengthDimensionUtils.js";import{settings as J}from"./settings.js";import{getRotateHeadingTexture as K}from"../Slice/images/Factory.js";import{SnappingVisualizer3D as Q}from"../../interactive/SnappingVisualizer3D.js";import{LineVisualElement as W}from"../../interactive/visualElements/LineVisualElement.js";import{VerticesVisualElement as X}from"../../interactive/visualElements/VerticesVisualElement.js";import{RenderOccludedFlag as Y}from"../../webgl-engine/lib/Material.js";import{ImageMaterial as Z}from"../../webgl-engine/materials/ImageMaterial.js";import{createStipplePatternSimple as $}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as tt}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{createCoordinateHelper as et}from"../../../interactive/coordinateHelper.js";import{EditGeometry as it}from"../../../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as nt}from"../../../interactive/editGeometry/EditGeometryOperations.js";import{acquire as at}from"../../../interactive/snapping/SceneSnappingManagerPool.js";import{SnappingContext as ot}from"../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as st}from"../../../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as rt}from"../../../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as pt}from"../../../interactive/snapping/snappingUtils.js";import lt from"../../../../geometry/Point.js";let ut=class extends a{constructor(t){super(t),this._stagedDimension=null,this._computationManipulators=new Map,this._computationHandles=new o,this._updatingHandles=new M,this._getSnappingContext=p((t=>new ot({elevationInfo:{mode:"absolute-height",offset:0},pointer:t,editGeometryOperations:new nt(new it("point",et(!0,!1,this.view.spatialReference))),visualizer:new Q})));const{view:i}=t;this._snappingManagerResult=at(i),this.addHandles(this._snappingManagerResult),this._unfocusedOffsetManipulatorMaterial=dt(),this._focusedOffsetManipulatorMaterial=dt(),this._thinOffsetManipulatorMaterial=dt(),this._thinOffsetManipulatorMaterial.setParameters({stipplePattern:$(2)}),this._constraintSnappingIndicator=new W({view:i,attached:!0,width:1,color:e.toUnitRGBA(J.constraint.color),renderOccluded:Y.OccludeAndTransparent,stipplePattern:$(5),isDecoration:!0});const n=e.toUnitRGBA(J.disabledPointIndicator.color);this._stagedStartIndicator=new X({view:i,attached:!1,elevationInfo:{mode:"absolute-height",offset:0},spatialReference:t.view.renderCoordsHelper.spatialReference,color:n,size:2*J.disabledPointIndicator.radius,outlineSize:0,renderOccluded:Y.OccludeAndTransparent,isDecoration:!0})}initialize(){this._snappingOperation=new rt({view:this.view});const{color:t,contrastColor:e}=J.orientationManipulator,i=!this.view._stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result;this._orientationManipulatorTexture=K(this.view.toolViewManager.textures,{accentColor:t,contrastColor:e,preMultiplyAlpha:i}),this._orientationManipulatorMaterial=new Z({transparent:!0,writeDepth:!1,textureId:this._orientationManipulatorTexture.texture.id,renderOccluded:Y.Opaque,isDecoration:!0});const{computations:n}=this.analysisViewData;for(const a of n)this._addComputation(a);this.addHandles([n.on("after-add",(t=>this._addComputation(t.item))),n.on("after-remove",(t=>this._removeComputation(t.item)))]),this.addHandles([u((()=>({stagedPoint:this._snappingOperation.stagedPoint,stagedComputation:this._stagedComputation})),(({stagedPoint:t,stagedComputation:e})=>{if(null==e||null==t)return;const i=y(t,new lt);this._applyPointUpdate(e,{endPoint:i})}),d),u((()=>({stagedDimension:this._stagedDimension,selectedComputation:this.analysisViewData.selectedComputation,firstGrabbedManipulator:this.firstGrabbedManipulator})),((t,e)=>{const{stagedDimension:i,selectedComputation:n,firstGrabbedManipulator:a}=t;if(i===e?.stagedDimension&&a===e?.firstGrabbedManipulator){for(const o of[n,e?.selectedComputation])if(null!=o){const e=this._computationManipulators.get(o);this._updateManipulators(o,e,t)}}else for(const[o,s]of this._computationManipulators)this._updateManipulators(o,s,t)}),c),u((()=>this.analysis.style.lineSize),(t=>{this._updateManipulatorStyle(t)}),m),u((()=>this.view.state.camera),(()=>{null!=this._stagedComputation&&this._updateStagedDimensionOffset(this._stagedComputation)})),u((()=>{const t=this._stagedComputation;if(!t)return null;const e=t.elevationAlignedStartPoint,i=_();return null!=e&&this.view.renderCoordsHelper.toRenderCoords(e,i)?i:null}),(t=>{null!=t?(this._stagedStartIndicator.vertices=[t],this._stagedStartIndicator.attached=!0):this._stagedStartIndicator.attached=!1}))]),this.addHandles(this._constraintHandles),this.addHandles(this._snappingIndicatorHandles),pt(this,(()=>{const t=this._activeComputation,e=this._stagedComputation;if(null==t||null!=e){const t=this.view.inputManager.latestPointerType??"mouse",e=this._getSnappingContext(t);this._updatingHandles.addPromise(l(this._snappingOperation.resnap(this._snappingManager,e)))}if(null!=t){const{start:e,end:i}=this._computationManipulators.get(t);if(e.grabbing||i.grabbing){const i=e.grabbing?"start":"end",n=this._computeConstraint(t);v(t,i,{constraint:n,view:this.view})}}}))}destroy(){this._snappingOperation=r(this._snappingOperation),this._computationHandles.destroy(),this._constraintSnappingIndicator.destroy(),this._stagedStartIndicator.destroy(),this._orientationManipulatorMaterial.dispose(),this._orientationManipulatorTexture.release()}get updating(){return this._updatingHandles.updating||this._snappingManager.updating}get firstGrabbedManipulator(){return this.parentTool.firstGrabbedManipulator}get hasGrabbedManipulators(){return this.parentTool.hasGrabbedManipulators}get snappingOptions(){return this._snappingManager.options}get _snappingManager(){return this._snappingManagerResult.snappingManager}get _activeComputation(){if(null!=this._stagedComputation)return this._stagedComputation;const{selectedComputation:t}=this.analysisViewData;return this.hasGrabbedManipulators&&null!=t?t:null}get _stagedComputation(){const t=this._stagedDimension,e=this.analysisViewData.computations.at(-1);return null==t||null==e||e.dimension!==t?null:e}get _constraintHandles(){return[h((()=>this.analysisViewData.selectedComputation),(t=>{t.previousConstraint=this._computeConstraint(t)}),{...c,equals:s}),u((()=>{const t=this._activeComputation;if(null==t)return null;const{measureType:e,orientation:i}=t.dimension;return{measureType:e,orientation:i,computation:t}}),((t,e)=>{if(null!=t&&null==e){const{measureType:e,orientation:n,computation:a}=t;switch(a.previousConstraint){case C.Horizontal:a.preConstraintProperties={measureType:i.Horizontal,orientation:0};break;case C.Vertical:a.preConstraintProperties={measureType:i.Vertical,orientation:0};break;case C.Direct:a.preConstraintProperties={measureType:i.Direct,orientation:n};break;default:a.preConstraintProperties={measureType:e,orientation:n}}}null==t&&null!=e&&(e.computation.preConstraintProperties=null)}),d)]}get _snappingIndicatorHandles(){const t="snapping-indicator-event-handles";return[u((()=>({stagedComputation:this._stagedComputation,activeComputation:this._activeComputation})),(({stagedComputation:e,activeComputation:i})=>{const n=this._constraintSnappingIndicator;if(this.removeHandles(t),null!=i)if(i===e)n.attached=!0;else{const{start:e,end:a}=this._computationManipulators.get(i),o=()=>{n.attached=e.grabbing||a.grabbing};o(),this.addHandles([e.events.on("grab-changed",o),a.events.on("grab-changed",o)],t)}else n.attached=!1})),u((()=>{const t=this._activeComputation;return null!=t?{geometry:t.geometry,constraint:t.previousConstraint}:{}}),(({geometry:t,constraint:e})=>{const i=this._constraintSnappingIndicator;null!=t&&null!=e&&e!==C.Direct?(i.visible=!0,i.setGeometryFromSegment(t.directSegment)):i.visible=!1}))]}removeStaged(){return null!=this._stagedDimension&&(this.analysis.dimensions.remove(this._stagedDimension),this._stagedDimension=null,!0)}onDeactivate(){this.removeStaged(),this._resetSnappingState()}onClick(t){const{_stagedDimension:e}=this;if(null==e){const e=this._onUnstagedClick(t);return this.analysis.dimensions.add(e),null}return this._onStagedClick(t),e}onPointerMove({mapPoint:t,pointerType:e}){if("touch"===e)return;const i=this._getSnappingContext(e);this._updatingHandles.addPromise(l(this._snappingOperation.snap({point:t},this._snappingManager,i)))}onManipulatorSelectionChanged(){if(null!=this.analysisViewData.selectedComputation){this._computationManipulators.get(this.analysisViewData.selectedComputation).offset.selected||(this.analysisViewData.selectedDimension=null)}}_onUnstagedClick({mapPoint:t,pointerType:e}){let a=t;if("mouse"===e){const i=this._getSnappingContext(e);a=this._snappingManager.update({point:t,context:i})}const o=new n({startPoint:y(a,new lt),endPoint:null,measureType:i.Horizontal});return this._stagedDimension=o,this._resetSnappingState(),o}_onStagedClick({mapPoint:t,pointerType:e}){const i=this._stagedComputation;if(null==i)return;let n=t;if("mouse"===e){const i=this._getSnappingContext(e);n=this._snappingManager.update({point:t,context:i})}const a=y(n,new lt);this._applyPointUpdate(i,{endPoint:a}),this._stagedDimension=null,this._resetSnappingState()}_resetSnappingState(){this._snappingManager.doneSnapping(),this._snappingOperation.abort(),this._snappingOperation.stagedPoint=null}_addComputation(t){if(this._computationManipulators.has(t))return;const e=this._setupPointManipulator(t,{isStart:!0}),n=this._setupPointManipulator(t,{isStart:!1}),a=this._setupOffsetManipulator(t),o=this._setupHeadingManipulator(t),s=this._setupRotationManipulator(t),r=this._setupMeasureTypeManipulator(t,i.Direct),p=this._setupMeasureTypeManipulator(t,i.Horizontal),l=this._setupMeasureTypeManipulator(t,i.Vertical),u=new D({start:e,end:n,offset:a,heading:o,rotation:s,direct:r,horizontal:p,vertical:l});this._setupComputationToManipulatorsSync(t,u),this._computationManipulators.set(t,u),this.manipulators.addMany(u.values())}_removeComputation(t){const e=this._computationManipulators.get(t);if(null!=e){this._computationHandles.remove(t),this._computationManipulators.delete(t);for(const t of e.values())this.manipulators.remove(t)}}_setupComputationToManipulatorsSync(t,e){this._computationHandles.add([u((()=>t.geometry),(()=>this._updateManipulators(t,e)),{...c,equals:s})],t)}_setupPointManipulator(t,e){const{view:i}=this,{dimension:n}=t,a=P(i,{metadata:n}),o=O(a,{isStart:e.isStart,createSnappingPipelineStep:t=>st({snappingContext:this._getSnappingContext(t),snappingManager:this._snappingManager,updatingHandles:this._updatingHandles}),dimension:n,onUpdate:e=>this._applyPointUpdate(t,e),view:i});return this._computationHandles.add(o,t),a}_setupOffsetManipulator(t){const{view:e}=this,i=j(e,{lineSizePt:this.analysis.style.lineSize,unfocusedMaterial:this._unfocusedOffsetManipulatorMaterial,focusedMaterial:this._focusedOffsetManipulatorMaterial,metadata:t.dimension}),n=H(i,{computation:t,view:e});return this._computationHandles.add(n,t),i}_setupHeadingManipulator(t){const{view:e}=this,i=T(e,{lineSizePt:this.analysis.style.lineSize,material:this._orientationManipulatorMaterial,metadata:t.dimension}),n=G(i,{computation:t,view:e});return this._computationHandles.add(n,t),i}_setupRotationManipulator(t){const{view:e}=this,i=T(e,{lineSizePt:this.analysis.style.lineSize,material:this._orientationManipulatorMaterial,metadata:t.dimension}),n=I(i,{computation:t,view:e});return this._computationHandles.add(n,t),i}_setupMeasureTypeManipulator(t,e){const{view:i}=this,n=z(i,{lineSizePt:this.analysis.style.lineSize,unfocusedMaterial:this._unfocusedOffsetManipulatorMaterial,focusedMaterial:this._focusedOffsetManipulatorMaterial,thinOffsetManipulatorMaterial:this._thinOffsetManipulatorMaterial,metadata:t.dimension}),a=x(n,{computation:t,manipulatorMeasureType:e,view:i});return this._computationHandles.add(a,t),n}_updateManipulators(t,e,n={stagedDimension:this._stagedDimension,selectedComputation:this.analysisViewData.selectedComputation,firstGrabbedManipulator:this.firstGrabbedManipulator}){const{stagedDimension:a,selectedComputation:o,firstGrabbedManipulator:s}=n,{start:r,end:p,offset:l,heading:u,rotation:d}=e,c=o===t,m=L(t),{dimension:h}=t;for(const i of e.values()){const t=m&&null==a&&(null==s||i===s);i===l?(i.available=t,i.selected=c):i.available=t&&c}if(!m)return;null!=this._computeConstraint(t)?e.forEachMeasureTypeManipulator((t=>t.available=!1)):e.manipulatorForMeasureType(h.measureType).available=!1;for(const _ of[u,d])h.measureType===i.Direct&&0!==h.offset||(_.available=!1);q(t)?d.available=!1:u.available=!1;const{geometry:g}=t;r.renderLocation=g.directSegment.startRenderSpace,p.renderLocation=g.directSegment.endRenderSpace;const{renderCoordsHelper:f}=this.view;V(l,g,f),u.available&&U(u,t,f),d.available&&R(d,t,f),e.forEachMeasureTypeManipulator(((e,i)=>{e.available&&A(e,t,i,f)}))}_updateManipulatorStyle(t){const e=k(t),i=E(t),n={lineSizePt:t,material:this._orientationManipulatorMaterial};for(const{offset:a,heading:o,rotation:s}of this._computationManipulators.values())a.radius=i/2,F(o,n),F(s,n);this._unfocusedOffsetManipulatorMaterial.setParameters({width:e}),this._focusedOffsetManipulatorMaterial.setParameters({width:i})}_applyPointUpdate(t,e){const{view:i}=this,n=N(t);"startPoint"in e&&(n.elevationAlignedStartPoint=e.startPoint),"endPoint"in e&&(n.elevationAlignedEndPoint=e.endPoint);const a=B(n,i.renderCoordsHelper);if(null==a)return;const o=this._computeConstraint({...n,geometry:a});S(t,e,{...n,constraint:o,unconstrainedGeometry:a,view:i}),t===this._stagedComputation&&this._updateStagedDimensionOffset(t)}_updateStagedDimensionOffset(t){if(null==t.geometry)return;t.geometry.directSegment.eval(.5,ct);const e=this.view.state.camera.computeRenderPixelSizeAt(ct);t.dimension.offset=J.initialOffsetPx*e}_computeConstraint(t){return b(w(t,this._snappingManager.options),this.view)}get testInfo(){const t=t=>this.analysisViewData.computations.find((e=>e.dimension===t));return{disableManipulatorPartialOcclusion:()=>{this._stagedStartIndicator.renderOccluded=Y.Occlude,this.manipulators.forEach((({manipulator:t})=>{for(const{geometry:e}of t.renderObjects)e.material.setParameters({renderOccluded:Y.Occlude})}))},getManipulatorsForDimension:e=>this._computationManipulators.get(t(e)),getComputationForDimension:e=>t(e),getConstraintForDimension:e=>{const i=t(e);return null!=i?this._computeConstraint(i):null},stagedDimension:this._stagedDimension,stagedStartIndicator:this._stagedStartIndicator,constraintSnappingIndicator:this._constraintSnappingIndicator,snappingManager:this._snappingManager}}};function dt(){const{color:t}=J.offsetManipulator;return new tt({color:e.toUnitRGBA(t),width:1,renderOccluded:Y.OccludeAndTransparent,writeDepth:!1,hasPolygonOffset:!0,isDecoration:!0})}t([g({constructOnly:!0})],ut.prototype,"analysis",void 0),t([g({constructOnly:!0})],ut.prototype,"analysisViewData",void 0),t([g({constructOnly:!0})],ut.prototype,"manipulators",void 0),t([g({constructOnly:!0})],ut.prototype,"parentTool",void 0),t([g({constructOnly:!0,nonNullable:!0})],ut.prototype,"view",void 0),t([g({readOnly:!0})],ut.prototype,"updating",null),t([g()],ut.prototype,"firstGrabbedManipulator",null),t([g()],ut.prototype,"hasGrabbedManipulators",null),t([g()],ut.prototype,"snappingOptions",null),t([g()],ut.prototype,"_stagedDimension",void 0),t([g()],ut.prototype,"_activeComputation",null),t([g()],ut.prototype,"_stagedComputation",null),ut=t([f("esri.views.3d.analysis.Dimension.LengthDimensionSubTool")],ut);const ct=_();export{ut as LengthDimensionSubTool};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import{getFeatureId as t}from"../../../../analysis/featureReferenceUtils.js";import n from"../../../../core/Accessor.js";import{createTask as o}from"../../../../core/asyncUtils.js";import i from"../../../../core/Evented.js";import r from"../../../../core/Handles.js";import{handlesGroup as s,makeHandle as a}from"../../../../core/handleUtils.js";import l from"../../../../core/Logger.js";import{abortMaybe as u}from"../../../../core/maybe.js";import{ignoreAbortErrors as c}from"../../../../core/promiseUtils.js";import{initial as d}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{c as g,i as v,b as m,n as f,g as _,a as b,j as y,A as C}from"../../../../chunks/vec3.js";import{c as I}from"../../../../chunks/vec3f64.js";import{WatchUpdatingTracking as T}from"../../../../core/support/WatchUpdatingTracking.js";import{projectOrLoad as P,projectBoundingRect as O}from"../../../../geometry/projection.js";import{empty as S,containsPointObject as j,intersectsSegment as R}from"../../../../geometry/support/aaBoundingRect.js";import{fromPoints as w,create as A}from"../../../../geometry/support/ray.js";import{zValueInAbsoluteHeightMode as E}from"../../../../support/elevationInfoUtils.js";import{LineOfSightAnalysisResult as H}from"../LineOfSightAnalysisResult.js";import{LineOfSightComputation as F}from"./LineOfSightComputation.js";import{LineOfSightRayIntersector as L}from"./LineOfSightRayIntersector.js";import{logFailedGeometryProjectionError as V}from"../support/projectionUtils.js";import{StoreResults as D}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{toGraphic as x,hasLod as N,getIntersectedFeatureBSRadius as k}from"../../webgl-engine/lib/intersectorUtilsConversions.js";import{ImmediateTask as G,TaskPriority as z}from"../../../support/Scheduler.js";import U from"../../../../geometry/Point.js";const M="esri.views.3d.analysis.LineOfSight.LineOfSightController",Z=l.getLogger(M);let q=class extends(i.EventedMixin(n)){constructor(e){super(e),this.updateOnCameraChange=!0,this._observerGroundOffsetRenderSpace=0,this._effectiveObserverElevationMode="absolute-height",this._observerFeatureId=null,this._updatingHandles=new T,this._frameTask=G,this._computationHandles=new r,this._externalObserverUpdate=!0}initialize(){const e=this.view.resourceController?.scheduler;this._frameTask=e?e.registerTask(z.LINE_OF_SIGHT_TOOL):G,this._intersector=new L({view:this.view}),this.addHandles([this._connectObserver(),this._connectComputations(),this._connectTargets()])}destroy(){this._computationHandles.destroy(),this._computations.removeAll(),this._updatingHandles.destroy()}get updating(){return this._frameTask.updating||this._updatingHandles.updating}get priority(){return this._frameTask.priority}set priority(e){this._frameTask.priority=e}get _computations(){return this.analysisViewData.computations}get _elevationAlignedObserverPositionRenderSpace(){return this.analysisViewData.observerEngineLocation}set _elevationAlignedObserverPositionRenderSpace(e){this.analysisViewData.observerEngineLocation=e}get _screenPixelSize(){return this.view.state.camera.computeScreenPixelSizeAt(this._elevationAlignedObserverPositionRenderSpace)}_computeResult(e){const t=e.computation,{inputPoints:n,computationResult:o}=t,{observerAdjusted:i,targetAdjusted:r}=n,{start:s,end:a}=o;g(s,i),g(a,r);this._canCompute(t)?this._computeIntersection(e):this._interpolateIntersection(e),t.notifyResultChanged(),this.emit("result-changed",{target:e.computation.target,result:t.result})}_updateAdjustedPointsFromFeatures(e){const n=this.view,{sceneIntersectionHelper:o}=n,{inputPoints:i}=e,{observerAdjusted:r,observerFeatureId:s,targetFeatureId:a,targetAdjusted:l}=i;if(null==s&&null==a)return;const u=v(r,l),c=this._intersector.intersector,d=w(i.observer,i.target,J);c.options.store=D.ALL,o.intersectToolIntersectorRay(d,c);let p=null,h=null,g=null,m=null;for(const v of c.results.all){const e=x(v,this.view);if(null==e||null==v.distanceInRenderSpace)continue;const o=t(e);null!=o&&(null!=s&&o===s&&(null==p&&(p=this._getFeatureDistanceThreshold(v,n,u)),v.distanceInRenderSpace<p&&(g=v)),null!=a&&o===a&&(null==h&&(h=this._getFeatureDistanceThreshold(v,n,u)),null==m&&v.distanceInRenderSpace<u&&u-v.distanceInRenderSpace<h&&(m=v)))}null!=g&&g.getIntersectionPoint(r)&&(i.observerSurfaceNormal=g.getTransformedNormal(I())),null!=m&&m.getIntersectionPoint(l)&&(i.targetSurfaceNormal=m.getTransformedNormal(I()))}_getFeatureDistanceThreshold(e,t,n){if(N(e)){const o=k(e,t);if(null!=o)return Math.min(o*Q,n)}return 1e-5*n}_adjustStartEndPositions(e){const t=this._screenPixelSize,n=this.view,{inputPoints:o}=e,{observer:i,observerSurfaceNormal:r,target:s,targetSurfaceNormal:a,observerAdjusted:l,targetAdjusted:u}=o,c=W;g(l,i),g(u,s),this._updateAdjustedPointsFromFeatures(e),null!=r?g(c,r):m(c,u,l);const d=t;f(c,c),_(c,c,Math.min(d,1)),b(l,l,c),null!=a?g(c,a):m(c,l,u);const p=n.state.camera.computeScreenPixelSizeAt(u);f(c,c),_(c,c,Math.min(p,1)),b(u,u,c)}_computeIntersection({computation:e,interpolationInfo:t}){const{view:n}=this,{sceneIntersectionHelper:o,renderCoordsHelper:i}=n;if(null==o)return;const r=this._intersector.intersector,{computationResult:s,inputPoints:a}=e,{observer:l,target:u}=a,{start:c,end:d}=s,p=w(c,d,J);r.options.store=D.MIN,o.intersectToolIntersectorRay(p,r);const h=r.results.min,v=s.intersection,m=W;let f=!0;if(null!=h&&h.getIntersectionPoint(v)){g(t.originalIntersection,v),g(t.originalObserver,c),g(t.originalTarget,d),i.fromRenderCoords(v,m,n.spatialReference);const e=1-y(d,u)/y(c,u);f=y(l,v)>=e*y(l,u)}const _=new U(m,n.spatialReference);{const{result:t,target:o}=e;null!=t?(t.target=o,t.intersectedGraphic=f?null:x(h,n),t.intersectedLocation=f?null:_,t.visible=f):e.result=new H({target:o,elevationAlignedTargetLocation:e.elevationAlignedTargetLocation,intersectedGraphic:f?null:x(h,n),intersectedLocation:f?null:_,visible:f})}s.isValid=a.isValid=!0,s.isTargetVisible=f}_interpolateIntersection({computation:e,interpolationInfo:t}){const{computationResult:n,inputPoints:o}=e,{start:i,end:r,intersection:s}=n,{originalIntersection:a,originalObserver:l,originalTarget:u}=t;if(g(s,a),o.isValid){const e=W,t=y(l,a)/y(l,u);C(e,i,l),_(e,e,1-t),b(s,s,e),C(e,r,u),_(e,e,t),b(s,s,e),n.isValid=!0}else e.result=null,n.isValid=!1,n.isTargetVisible=!1}_canCompute(e){const t=this.analysisViewData.elevationAlignedObserver,n=this.view.frustum;if(null==t||null==e.elevationAlignedTargetLocation||null==n)return!1;const{observerAdjusted:o,targetAdjusted:i}=e.inputPoints,r=n.intersectsPoint(o),s=n.intersectsPoint(i);return r&&s}_onObserverPositionChange(e,n,o,i,r){if(this._externalObserverUpdate=r,null==e)return this.analysisViewData.elevationAlignedObserver=null,void(this._observerFeatureId=null);if(null==n)return V(this.analysis,e.spatialReference,Z),void(this.analysisViewData.elevationAlignedObserver=null);const s=this._getEffectiveElevationInfo(n,o),{absoluteZ:a,elevation:l}=E(n.x,n.y,n.z,this.view.spatialReference,this.view,s),u=n.clone();u.z=a,this._effectiveObserverElevationMode=s.mode,this.analysisViewData.elevationAlignedObserver=u;const c=I();this.view.renderCoordsHelper.toRenderCoords(u,c),this._elevationAlignedObserverPositionRenderSpace=c,this._observerGroundOffsetRenderSpace=a-l,this._observerFeatureId=t(i),this.priority=z.LINE_OF_SIGHT_TOOL_INTERACTIVE}_onObserverRenderSpacePositionChangeForComputation(e,t,n,o,i){const{inputPoints:r}=e;switch(g(r.observer,t),r.observerFeatureId=i,r.observerSurfaceNormal=null,o){case"on-the-ground":case"relative-to-ground":{const e=this._intersector.updateFromGroundIntersection(r.observer,n,r.observer);null==r.observerFeatureId&&(r.observerSurfaceNormal=e)}}this._adjustStartEndPositions(e),e.notifyInputPointsChanged(),this.priority=z.LINE_OF_SIGHT_TOOL_INTERACTIVE}_onTargetPositionChange(e,n,o,i,r,s=!0){const a=e.inputPoints;if(s&&(a.isValid=!1),null==o)return null!=n&&V(this.analysis,n.spatialReference,Z),e.elevationAlignedTargetLocation=null,void e.notifyInputPointsChanged();const l=this._getEffectiveElevationInfo(o,i),{absoluteZ:u,elevation:c}=E(o.x,o.y,o.z,this.view.spatialReference,this.view,l),d=o.clone();switch(d.z=u,e.elevationAlignedTargetLocation=d,this.view.renderCoordsHelper.toRenderCoords(e.elevationAlignedTargetLocation,a.target),a.targetFeatureId=t(r),a.targetSurfaceNormal=null,l.mode){case"on-the-ground":case"relative-to-ground":{const e=this._intersector.updateFromGroundIntersection(a.target,u-c,a.target);null==a.targetFeatureId&&(a.targetSurfaceNormal=e)}}this._adjustStartEndPositions(e),e.notifyInputPointsChanged(),this.priority=z.LINE_OF_SIGHT_TOOL_INTERACTIVE}_connectComputationToTarget(e){return s([this._updatingHandles.add((()=>({computation:e,targetPosition:e.target.position,targetElevationInfo:e.target.elevationInfo,targetFeatureInfo:e.target.feature,projectedTargetPosition:P(e.target.position,this.view.spatialReference)})),(({computation:e,targetPosition:t,targetElevationInfo:n,targetFeatureInfo:o,projectedTargetPosition:i})=>{null==i.pending?this._onTargetPositionChange(e,t,i.geometry,n,o):this._updatingHandles.addPromise(i.pending)}),d)])}_connectComputationToObserver(e){return this._updatingHandles.add((()=>({computation:e,observer:this.analysisViewData.elevationAlignedObserver})),(({computation:e})=>{this._externalObserverUpdate&&(e.inputPoints.isValid=!1,e.notifyInputPointsChanged())}),d)}_connectComputationToRenderSpaceObserver(e){return this._updatingHandles.add((()=>({computation:e,observer:this._elevationAlignedObserverPositionRenderSpace,observerGroundOffset:this._observerGroundOffsetRenderSpace,observerElevationMode:this._effectiveObserverElevationMode,observerFeatureId:this._observerFeatureId})),(({computation:e,observer:t,observerGroundOffset:n,observerElevationMode:o,observerFeatureId:i})=>{this._onObserverRenderSpacePositionChangeForComputation(e,t,n,o,i)}),d)}_connectComputationToCamera(e){return this._updatingHandles.add((()=>({camera:this.view.state.camera,isDirty:this._isCameraDirty})),(({isDirty:t})=>{!this.updateOnCameraChange||e.inputPoints.isValid&&!t||e.notifyInputPointsChanged()}))}_connectComputationToSlicePlane(e){return this._updatingHandles.add((()=>this.view.slicePlane),(()=>{e.inputPoints.isValid=!1,e.notifyInputPointsChanged()}))}_connectComputationToElevation(e){const t=(n,o)=>{const i=this.analysis.observer,r=e.target;let s=null,a=null,l=null,u=null,c=null,d=null;if(null!=i&&null!=i.position){const e=P(i.position,this.view.spatialReference);if(null!=e.pending)return this._updatingHandles.addPromise(e.pending),void e.pending.finally((()=>t(n,o)));s=e.geometry,a=i.elevationInfo,l=i.feature}if(null!=r.position){const e=P(r.position,this.view.spatialReference);if(null!=e.pending)return this._updatingHandles.addPromise(e.pending),void e.pending.finally((()=>t(n,o)));u=e.geometry,c=r.elevationInfo,d=r.feature}null==s&&null==u||(O(n,o,K,this.view.spatialReference),null!=s&&j(K,s)&&this._onObserverPositionChange(null!=i?i.position:null,s,a,l,!1),null!=u&&j(K,u)&&this._onTargetPositionChange(e,r.position,u,c,d,!1),null!=s&&null!=u&&R(K,s,u)&&e.notifyInputPointsChanged())};return this.view.elevationProvider.on("elevation-change",(e=>t(e.extent,e.spatialReference)))}_connectComputationToTask(e){let t=null;const n={computation:e,interpolationInfo:{originalIntersection:I(),originalObserver:I(),originalTarget:I()}};return s([this._updatingHandles.add((()=>e.inputPoints),(()=>{t=u(t),t=o((async e=>{await c(this._frameTask.schedule((()=>this._computeResult(n)),e))}))}),{initial:!0,equals:()=>!1}),a((()=>t=u(t)))])}_connectComputation(e){const t=this._computationHandles;t.has(e)||t.add([this._connectComputationToTarget(e),this._connectComputationToObserver(e),this._connectComputationToRenderSpaceObserver(e),this._connectComputationToCamera(e),this._connectComputationToSlicePlane(e),this._connectComputationToElevation(e),this._connectComputationToTask(e)],e)}_disconnectComputation(e){this._computationHandles.remove(e)}_onComputationCollectionChange({added:e,removed:t}){for(const n of t)this._disconnectComputation(n);for(const n of e)this._connectComputation(n)}_onTargetCollectionChange({added:e,removed:t}){for(const n of t)this._removeTarget(n);for(const n of e)this._addTarget(n)}_onCursorTargetChange(e,t){null!=t&&this._removeTarget(t),null!=e&&this._addTarget(e)}_addTarget(e){this._computations.some((t=>t.target===e))||this._computations.add(new F({target:e}))}_removeTarget(e){const t=this._computations.findIndex((t=>t.target===e));this._computations.removeAt(t)}_connectObserver(){return s([this._updatingHandles.add((()=>({observerPosition:null!=this.analysis.observer?this.analysis.observer.position:null,projectedObserverPosition:P(null!=this.analysis.observer?this.analysis.observer.position:null,this.view.spatialReference),observerElevationInfo:null!=this.analysis.observer?this.analysis.observer.elevationInfo:null,observerFeatureInfo:null!=this.analysis.observer?this.analysis.observer.feature:null})),(({observerPosition:e,projectedObserverPosition:t,observerElevationInfo:n,observerFeatureInfo:o})=>{null==t.pending?this._onObserverPositionChange(e,t.geometry,n,o,!0):this._updatingHandles.addPromise(t.pending)}),d)])}_connectComputations(){return this._updatingHandles.addOnCollectionChange((()=>this._computations),(e=>this._onComputationCollectionChange(e)),{initial:!0,final:!0})}_connectTargets(){return s([this._updatingHandles.addOnCollectionChange((()=>this.analysis.targets),(e=>this._onTargetCollectionChange(e)),{initial:!0,final:!0}),this._updatingHandles.add((()=>this.analysisViewData.cursorTarget),((e,t)=>{this._onCursorTargetChange(e,t)}))])}get _isCameraDirty(){const e=this.analysisViewData.elevationAlignedObserver,{view:t}=this,{renderCoordsHelper:n}=t;if(null==e||null==n)return!1;const o=W;n.toRenderCoords(e,o);const i=t.state.camera.computeScreenPixelSizeAt(o);return Math.abs((i-this._screenPixelSize)/this._screenPixelSize)>B}_getEffectiveElevationInfo(e,t){return e.hasZ?t??{mode:"absolute-height",offset:0}:{mode:"on-the-ground",offset:0}}};e([p({constructOnly:!0})],q.prototype,"analysis",void 0),e([p({constructOnly:!0})],q.prototype,"analysisViewData",void 0),e([p({constructOnly:!0})],q.prototype,"view",void 0),e([p()],q.prototype,"updating",null),e([p()],q.prototype,"priority",null),e([p()],q.prototype,"updateOnCameraChange",void 0),e([p()],q.prototype,"_computations",null),e([p()],q.prototype,"_elevationAlignedObserverPositionRenderSpace",null),e([p()],q.prototype,"_observerGroundOffsetRenderSpace",void 0),e([p()],q.prototype,"_effectiveObserverElevationMode",void 0),e([p()],q.prototype,"_observerFeatureId",void 0),e([p()],q.prototype,"_screenPixelSize",null),e([p({readOnly:!0})],q.prototype,"_updatingHandles",void 0),e([p()],q.prototype,"_frameTask",void 0),e([p()],q.prototype,"_isCameraDirty",null),q=e([h(M)],q);const B=.1,W=I(),J=A(),K=S(),Q=.05;export{q as LineOfSightController};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import{getFeatureId as t}from"../../../../analysis/featureReferenceUtils.js";import n from"../../../../core/Accessor.js";import{createTask as o}from"../../../../core/asyncUtils.js";import i from"../../../../core/Evented.js";import r from"../../../../core/Handles.js";import{handlesGroup as s,makeHandle as a}from"../../../../core/handleUtils.js";import l from"../../../../core/Logger.js";import{abortMaybe as u}from"../../../../core/maybe.js";import{ignoreAbortErrors as c}from"../../../../core/promiseUtils.js";import{initial as d}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{c as g,i as v,b as m,n as f,g as _,a as b,j as y,A as C}from"../../../../chunks/vec3.js";import{c as I}from"../../../../chunks/vec3f64.js";import{UpdatingHandles as T}from"../../../../core/support/UpdatingHandles.js";import{projectOrLoad as P,projectBoundingRect as O}from"../../../../geometry/projection.js";import{empty as S,containsPointObject as j,intersectsSegment as R}from"../../../../geometry/support/aaBoundingRect.js";import{fromPoints as w,create as A}from"../../../../geometry/support/ray.js";import{zValueInAbsoluteHeightMode as E}from"../../../../support/elevationInfoUtils.js";import{LineOfSightAnalysisResult as H}from"../LineOfSightAnalysisResult.js";import{LineOfSightComputation as F}from"./LineOfSightComputation.js";import{LineOfSightRayIntersector as L}from"./LineOfSightRayIntersector.js";import{logFailedGeometryProjectionError as V}from"../support/projectionUtils.js";import{StoreResults as D}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{toGraphic as x,hasLod as N,getIntersectedFeatureBSRadius as G}from"../../webgl-engine/lib/intersectorUtilsConversions.js";import{ImmediateTask as k,TaskPriority as z}from"../../../support/Scheduler.js";import U from"../../../../geometry/Point.js";const M="esri.views.3d.analysis.LineOfSight.LineOfSightController",Z=l.getLogger(M);let q=class extends(i.EventedMixin(n)){constructor(e){super(e),this.updateOnCameraChange=!0,this._observerGroundOffsetRenderSpace=0,this._effectiveObserverElevationMode="absolute-height",this._observerFeatureId=null,this._updatingHandles=new T,this._frameTask=k,this._computationHandles=new r,this._externalObserverUpdate=!0}initialize(){const e=this.view.resourceController?.scheduler;this._frameTask=e?e.registerTask(z.LINE_OF_SIGHT_TOOL):k,this._intersector=new L({view:this.view}),this.addHandles([this._connectObserver(),this._connectComputations(),this._connectTargets()])}destroy(){this._computationHandles.destroy(),this._computations.removeAll(),this._updatingHandles.destroy()}get updating(){return this._frameTask.updating||this._updatingHandles.updating}get priority(){return this._frameTask.priority}set priority(e){this._frameTask.priority=e}get _computations(){return this.analysisViewData.computations}get _elevationAlignedObserverPositionRenderSpace(){return this.analysisViewData.observerEngineLocation}set _elevationAlignedObserverPositionRenderSpace(e){this.analysisViewData.observerEngineLocation=e}get _screenPixelSize(){return this.view.state.camera.computeScreenPixelSizeAt(this._elevationAlignedObserverPositionRenderSpace)}_computeResult(e){const t=e.computation,{inputPoints:n,computationResult:o}=t,{observerAdjusted:i,targetAdjusted:r}=n,{start:s,end:a}=o;g(s,i),g(a,r);this._canCompute(t)?this._computeIntersection(e):this._interpolateIntersection(e),t.notifyResultChanged(),this.emit("result-changed",{target:e.computation.target,result:t.result})}_updateAdjustedPointsFromFeatures(e){const n=this.view,{sceneIntersectionHelper:o}=n,{inputPoints:i}=e,{observerAdjusted:r,observerFeatureId:s,targetFeatureId:a,targetAdjusted:l}=i;if(null==s&&null==a)return;const u=v(r,l),c=this._intersector.intersector,d=w(i.observer,i.target,K);c.options.store=D.ALL,o.intersectToolIntersectorRay(d,c);let p=null,h=null,g=null,m=null;for(const v of c.results.all){const e=x(v,this.view);if(null==e||null==v.distanceInRenderSpace)continue;const o=t(e);null!=o&&(null!=s&&o===s&&(null==p&&(p=this._getFeatureDistanceThreshold(v,n,u)),v.distanceInRenderSpace<p&&(g=v)),null!=a&&o===a&&(null==h&&(h=this._getFeatureDistanceThreshold(v,n,u)),null==m&&v.distanceInRenderSpace<u&&u-v.distanceInRenderSpace<h&&(m=v)))}null!=g&&g.getIntersectionPoint(r)&&(i.observerSurfaceNormal=g.getTransformedNormal(I())),null!=m&&m.getIntersectionPoint(l)&&(i.targetSurfaceNormal=m.getTransformedNormal(I()))}_getFeatureDistanceThreshold(e,t,n){if(N(e)){const o=G(e,t);if(null!=o)return Math.min(o*W,n)}return 1e-5*n}_adjustStartEndPositions(e){const t=this._screenPixelSize,n=this.view,{inputPoints:o}=e,{observer:i,observerSurfaceNormal:r,target:s,targetSurfaceNormal:a,observerAdjusted:l,targetAdjusted:u}=o,c=J;g(l,i),g(u,s),this._updateAdjustedPointsFromFeatures(e),null!=r?g(c,r):m(c,u,l);const d=t;f(c,c),_(c,c,Math.min(d,1)),b(l,l,c),null!=a?g(c,a):m(c,l,u);const p=n.state.camera.computeScreenPixelSizeAt(u);f(c,c),_(c,c,Math.min(p,1)),b(u,u,c)}_computeIntersection({computation:e,interpolationInfo:t}){const{view:n}=this,{sceneIntersectionHelper:o,renderCoordsHelper:i}=n;if(null==o)return;const r=this._intersector.intersector,{computationResult:s,inputPoints:a}=e,{observer:l,target:u}=a,{start:c,end:d}=s,p=w(c,d,K);r.options.store=D.MIN,o.intersectToolIntersectorRay(p,r);const h=r.results.min,v=s.intersection,m=J;let f=!0;if(null!=h&&h.getIntersectionPoint(v)){g(t.originalIntersection,v),g(t.originalObserver,c),g(t.originalTarget,d),i.fromRenderCoords(v,m,n.spatialReference);const e=1-y(d,u)/y(c,u);f=y(l,v)>=e*y(l,u)}const _=new U(m,n.spatialReference);{const{result:t,target:o}=e;null!=t?(t.target=o,t.intersectedGraphic=f?null:x(h,n),t.intersectedLocation=f?null:_,t.visible=f):e.result=new H({target:o,elevationAlignedTargetLocation:e.elevationAlignedTargetLocation,intersectedGraphic:f?null:x(h,n),intersectedLocation:f?null:_,visible:f})}s.isValid=a.isValid=!0,s.isTargetVisible=f}_interpolateIntersection({computation:e,interpolationInfo:t}){const{computationResult:n,inputPoints:o}=e,{start:i,end:r,intersection:s}=n,{originalIntersection:a,originalObserver:l,originalTarget:u}=t;if(g(s,a),o.isValid){const e=J,t=y(l,a)/y(l,u);C(e,i,l),_(e,e,1-t),b(s,s,e),C(e,r,u),_(e,e,t),b(s,s,e),n.isValid=!0}else e.result=null,n.isValid=!1,n.isTargetVisible=!1}_canCompute(e){const t=this.analysisViewData.elevationAlignedObserver,n=this.view.frustum;if(null==t||null==e.elevationAlignedTargetLocation||null==n)return!1;const{observerAdjusted:o,targetAdjusted:i}=e.inputPoints,r=n.intersectsPoint(o),s=n.intersectsPoint(i);return r&&s}_onObserverPositionChange(e,n,o,i,r){if(this._externalObserverUpdate=r,null==e)return this.analysisViewData.elevationAlignedObserver=null,void(this._observerFeatureId=null);if(null==n)return V(this.analysis,e.spatialReference,Z),void(this.analysisViewData.elevationAlignedObserver=null);const s=this._getEffectiveElevationInfo(n,o),{absoluteZ:a,elevation:l}=E(n.x,n.y,n.z,this.view.spatialReference,this.view,s),u=n.clone();u.z=a,this._effectiveObserverElevationMode=s.mode,this.analysisViewData.elevationAlignedObserver=u;const c=I();this.view.renderCoordsHelper.toRenderCoords(u,c),this._elevationAlignedObserverPositionRenderSpace=c,this._observerGroundOffsetRenderSpace=a-l,this._observerFeatureId=t(i),this.priority=z.LINE_OF_SIGHT_TOOL_INTERACTIVE}_onObserverRenderSpacePositionChangeForComputation(e,t,n,o,i){const{inputPoints:r}=e;switch(g(r.observer,t),r.observerFeatureId=i,r.observerSurfaceNormal=null,o){case"on-the-ground":case"relative-to-ground":{const e=this._intersector.updateFromGroundIntersection(r.observer,n,r.observer);null==r.observerFeatureId&&(r.observerSurfaceNormal=e)}}this._adjustStartEndPositions(e),e.notifyInputPointsChanged(),this.priority=z.LINE_OF_SIGHT_TOOL_INTERACTIVE}_onTargetPositionChange(e,n,o,i,r,s=!0){const a=e.inputPoints;if(s&&(a.isValid=!1),null==o)return null!=n&&V(this.analysis,n.spatialReference,Z),e.elevationAlignedTargetLocation=null,void e.notifyInputPointsChanged();const l=this._getEffectiveElevationInfo(o,i),{absoluteZ:u,elevation:c}=E(o.x,o.y,o.z,this.view.spatialReference,this.view,l),d=o.clone();switch(d.z=u,e.elevationAlignedTargetLocation=d,this.view.renderCoordsHelper.toRenderCoords(e.elevationAlignedTargetLocation,a.target),a.targetFeatureId=t(r),a.targetSurfaceNormal=null,l.mode){case"on-the-ground":case"relative-to-ground":{const e=this._intersector.updateFromGroundIntersection(a.target,u-c,a.target);null==a.targetFeatureId&&(a.targetSurfaceNormal=e)}}this._adjustStartEndPositions(e),e.notifyInputPointsChanged(),this.priority=z.LINE_OF_SIGHT_TOOL_INTERACTIVE}_connectComputationToTarget(e){return s([this._updatingHandles.add((()=>({computation:e,targetPosition:e.target.position,targetElevationInfo:e.target.elevationInfo,targetFeatureInfo:e.target.feature,projectedTargetPosition:P(e.target.position,this.view.spatialReference)})),(({computation:e,targetPosition:t,targetElevationInfo:n,targetFeatureInfo:o,projectedTargetPosition:i})=>{null==i.pending?this._onTargetPositionChange(e,t,i.geometry,n,o):this._updatingHandles.addPromise(i.pending)}),d)])}_connectComputationToObserver(e){return this._updatingHandles.add((()=>({computation:e,observer:this.analysisViewData.elevationAlignedObserver})),(({computation:e})=>{this._externalObserverUpdate&&(e.inputPoints.isValid=!1,e.notifyInputPointsChanged())}),d)}_connectComputationToRenderSpaceObserver(e){return this._updatingHandles.add((()=>({computation:e,observer:this._elevationAlignedObserverPositionRenderSpace,observerGroundOffset:this._observerGroundOffsetRenderSpace,observerElevationMode:this._effectiveObserverElevationMode,observerFeatureId:this._observerFeatureId})),(({computation:e,observer:t,observerGroundOffset:n,observerElevationMode:o,observerFeatureId:i})=>{this._onObserverRenderSpacePositionChangeForComputation(e,t,n,o,i)}),d)}_connectComputationToCamera(e){return this._updatingHandles.add((()=>({camera:this.view.state.camera,isDirty:this._isCameraDirty})),(({isDirty:t})=>{!this.updateOnCameraChange||e.inputPoints.isValid&&!t||e.notifyInputPointsChanged()}))}_connectComputationToSlicePlane(e){return this._updatingHandles.add((()=>this.view.slicePlane),(()=>{e.inputPoints.isValid=!1,e.notifyInputPointsChanged()}))}_connectComputationToElevation(e){const t=(n,o)=>{const i=this.analysis.observer,r=e.target;let s=null,a=null,l=null,u=null,c=null,d=null;if(null!=i&&null!=i.position){const e=P(i.position,this.view.spatialReference);if(null!=e.pending)return this._updatingHandles.addPromise(e.pending),void e.pending.finally((()=>t(n,o)));s=e.geometry,a=i.elevationInfo,l=i.feature}if(null!=r.position){const e=P(r.position,this.view.spatialReference);if(null!=e.pending)return this._updatingHandles.addPromise(e.pending),void e.pending.finally((()=>t(n,o)));u=e.geometry,c=r.elevationInfo,d=r.feature}null==s&&null==u||(O(n,o,Q,this.view.spatialReference),null!=s&&j(Q,s)&&this._onObserverPositionChange(null!=i?i.position:null,s,a,l,!1),null!=u&&j(Q,u)&&this._onTargetPositionChange(e,r.position,u,c,d,!1),null!=s&&null!=u&&R(Q,s,u)&&e.notifyInputPointsChanged())};return this.view.elevationProvider.on("elevation-change",(e=>t(e.extent,e.spatialReference)))}_connectComputationToTask(e){let t=null;const n={computation:e,interpolationInfo:{originalIntersection:I(),originalObserver:I(),originalTarget:I()}};return s([this._updatingHandles.add((()=>e.inputPoints),(()=>{t=u(t),t=o((async e=>{await c(this._frameTask.schedule((()=>this._computeResult(n)),e))}))}),{initial:!0,equals:()=>!1}),a((()=>t=u(t)))])}_connectComputation(e){const t=this._computationHandles;t.has(e)||t.add([this._connectComputationToTarget(e),this._connectComputationToObserver(e),this._connectComputationToRenderSpaceObserver(e),this._connectComputationToCamera(e),this._connectComputationToSlicePlane(e),this._connectComputationToElevation(e),this._connectComputationToTask(e)],e)}_disconnectComputation(e){this._computationHandles.remove(e)}_onComputationCollectionChange({added:e,removed:t}){for(const n of t)this._disconnectComputation(n);for(const n of e)this._connectComputation(n)}_onTargetCollectionChange({added:e,removed:t}){for(const n of t)this._removeTarget(n);for(const n of e)this._addTarget(n)}_onCursorTargetChange(e,t){null!=t&&this._removeTarget(t),null!=e&&this._addTarget(e)}_addTarget(e){this._computations.some((t=>t.target===e))||this._computations.add(new F({target:e}))}_removeTarget(e){const t=this._computations.findIndex((t=>t.target===e));this._computations.removeAt(t)}_connectObserver(){return s([this._updatingHandles.add((()=>({observerPosition:null!=this.analysis.observer?this.analysis.observer.position:null,projectedObserverPosition:P(null!=this.analysis.observer?this.analysis.observer.position:null,this.view.spatialReference),observerElevationInfo:null!=this.analysis.observer?this.analysis.observer.elevationInfo:null,observerFeatureInfo:null!=this.analysis.observer?this.analysis.observer.feature:null})),(({observerPosition:e,projectedObserverPosition:t,observerElevationInfo:n,observerFeatureInfo:o})=>{null==t.pending?this._onObserverPositionChange(e,t.geometry,n,o,!0):this._updatingHandles.addPromise(t.pending)}),d)])}_connectComputations(){return this._updatingHandles.addOnCollectionChange((()=>this._computations),(e=>this._onComputationCollectionChange(e)),{initial:!0,final:!0})}_connectTargets(){return s([this._updatingHandles.addOnCollectionChange((()=>this.analysis.targets),(e=>this._onTargetCollectionChange(e)),{initial:!0,final:!0}),this._updatingHandles.add((()=>this.analysisViewData.cursorTarget),((e,t)=>{this._onCursorTargetChange(e,t)}))])}get _isCameraDirty(){const e=this.analysisViewData.elevationAlignedObserver,{view:t}=this,{renderCoordsHelper:n}=t;if(null==e||null==n)return!1;const o=J;n.toRenderCoords(e,o);const i=t.state.camera.computeScreenPixelSizeAt(o);return Math.abs((i-this._screenPixelSize)/this._screenPixelSize)>B}_getEffectiveElevationInfo(e,t){return e.hasZ?t??{mode:"absolute-height",offset:0}:{mode:"on-the-ground",offset:0}}};e([p({constructOnly:!0})],q.prototype,"analysis",void 0),e([p({constructOnly:!0})],q.prototype,"analysisViewData",void 0),e([p({constructOnly:!0})],q.prototype,"view",void 0),e([p()],q.prototype,"updating",null),e([p()],q.prototype,"priority",null),e([p()],q.prototype,"updateOnCameraChange",void 0),e([p()],q.prototype,"_computations",null),e([p()],q.prototype,"_elevationAlignedObserverPositionRenderSpace",null),e([p()],q.prototype,"_observerGroundOffsetRenderSpace",void 0),e([p()],q.prototype,"_effectiveObserverElevationMode",void 0),e([p()],q.prototype,"_observerFeatureId",void 0),e([p()],q.prototype,"_screenPixelSize",null),e([p({readOnly:!0})],q.prototype,"_updatingHandles",void 0),e([p()],q.prototype,"_frameTask",void 0),e([p()],q.prototype,"_isCameraDirty",null),q=e([h(M)],q);const B=.1,J=I(),K=A(),Q=S(),W=.05;export{q as LineOfSightController};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../Color.js";import i from"../../../../analysis/LineOfSightAnalysisObserver.js";import a from"../../../../analysis/LineOfSightAnalysisTarget.js";import r from"../../../../core/Handles.js";import n from"../../../../core/Logger.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{watch as o,syncAndInitial as l,initial as u}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as p}from"../../../../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as h}from"../../../../core/support/WatchUpdatingTracking.js";import{create as d,fromPoints as g}from"../../../../geometry/support/lineSegment.js";import{getGraphicEffectiveElevationInfo as _,getConvertedElevation as m}from"../../../../support/elevationInfoUtils.js";import v from"../../../../symbols/support/ElevationInfo.js";import{LineOfSightRayIntersector as b}from"./LineOfSightRayIntersector.js";import{LineOfSightToolConfiguration as y}from"./LineOfSightToolConfiguration.js";import{createSphereManipulator as f,createSphereManipulatorRenderObjects as T}from"./lineOfSightToolUtils.js";import{LaserlineVisualElement as M}from"../../interactive/visualElements/LaserlineVisualElement.js";import{IntersectorType as C}from"../../webgl-engine/lib/IntersectorInterfaces.js";import"../../../input/ViewEvents.js";import{AnalysisToolBase as w}from"../../../interactive/AnalysisToolBase.js";import{createManipulatorDragEventPipeline as L}from"../../../interactive/dragEventPipeline.js";import{ManipulatorStateCustomFlags as k}from"../../../interactive/interfaces.js";import{createScreenPointFromEvent as V}from"../../../support/screenUtils.js";import{MouseButton as O}from"../../../input/IViewEvents.js";var S;!function(e){e.Ready="ready",e.Creating="creating",e.Created="created"}(S||(S={}));let D=class extends w{constructor(e){super(e),this.removeIncompleteOnCancel=!1,this.configuration=new y,this.analysisViewData=null,this._latestPointerMovePointerType=null,this._laserlineVisualElement=null,this._grabbedManipulator=null,this._analysisHandles=new r,this._updatingHandles=new h,this._manipulatorHandles=new r,this._targetTrackerManipulator=null}initialize(){this._intersector=new b({view:this.view}),this.addHandles(o((()=>this.state),(e=>{e===S.Created&&this.finishToolCreation()}),l)),this._observerManipulator=this._createObserverManipulator(),this.addHandles([this._updatingHandles.add((()=>({...this.configuration.observer})),(()=>this._updateObserverManipulatorStyle())),this._updatingHandles.add((()=>this.analysisViewData?.elevationAlignedObserver),(e=>this._onObserverLocationChange(e)),u),this._updatingHandles.add((()=>({...this.configuration.laserLine})),(()=>this._createVisualElements()),u),this._updatingHandles.add((()=>this._laserLineRendererDependencies()),(e=>this._updateLaserLineRenderer(e))),this._connectComputations(),this._updatingHandles.addWhen((()=>!this._shouldRenderTracker),(()=>this._clearCursorTracker()),u)])}destroy(){this._updatingHandles=s(this._updatingHandles),this._manipulatorHandles=s(this._manipulatorHandles),this._analysisHandles=s(this._analysisHandles),this._observerManipulator=null,this._clearCursorTracker(),this._removeVisualElements(),this._intersector=null,this._set("analysis",null)}get state(){return this.active?this.hasGrabbedManipulators?S.Created:S.Creating:null!=this.analysis.observer&&null!=this.analysis.observer.position?S.Created:S.Ready}get cursor(){return this.active&&this._showTracker?"crosshair":null}get updating(){return null!=this.analysisViewData&&this.analysisViewData.updating||this._updatingHandles.updating}get _showTracker(){return this.active&&"mouse"===this._latestPointerMovePointerType}get _shouldRenderTracker(){return this._showTracker&&null!=this.analysis.observer&&null!=this.analysis.observer.position&&!this.hasGrabbedManipulators}continue(){this.view.activeTool=this}stop(){this.view.activeTool=null}onEditableChange(){this.analysisViewData.editable=this.internallyEditable}onInputEvent(e){switch(e.type){case"immediate-double-click":this._doubleClickHandler(e);break;case"key-down":this._keyDownHandler(e);break;case"pointer-move":this._pointerMoveHandler(e)}}onInputEventAfter(e){if("immediate-click"===e.type)this._clickHandler(e)}onShow(){}onHide(){}onDeactivate(){this._clearCursorTracker()}_connectComputations(){return this._updatingHandles.addOnCollectionChange((()=>this.analysisViewData.computations),(e=>this._onComputationsCollectionChange(e)),{initial:!0,final:!0})}_onComputationsCollectionChange({added:e,removed:t}){for(const i of t)this._disconnectComputation(i);for(const i of e)this._connectComputation(i)}_connectComputation(e){if(this.destroyed)return void n.getLogger(this).warn("Attempting to connect an analysis to a destroyed LineOfSight tool. Ignoring.");const t=this._analysisHandles;if(t.has(e))return;const i=this._createTargetManipulator(e.target);null==this._targetTrackerManipulator&&i.metadata.target===this.analysisViewData.cursorTarget&&(this._targetTrackerManipulator=i,this._targetTrackerManipulator.available=!1,this._targetTrackerManipulator.interactive=!1,this._updateLaserLineRenderer()),t.add([this._updatingHandles.add((()=>this._getLineOfSightManipulatorStateDependencies(e)),(()=>this._updateManipulatorState(i,e)),u),this._updatingHandles.add((()=>e.elevationAlignedTargetLocation),(e=>this._onTargetLocationChange(e,i)),u)],e)}_disconnectComputation(e){if(this.destroyed)return void n.getLogger(this).warn("Attempting to disconnect an analysis from a destroyed LineOfSight tool. Ignoring.");this._analysisHandles.remove(e);const t=this._getTargetManipulator(e.target);null!=t&&(this.manipulators.remove(t),this._manipulatorHandles.remove(t),null!=this._targetTrackerManipulator&&this._targetTrackerManipulator===t&&(this._targetTrackerManipulator=null))}_clearCursorTracker(){this.analysisViewData.cursorTarget=s(this.analysisViewData.cursorTarget)}_createManipulator(e,t,i){const a=f(this.view,e);return a.metadata=i,this._manipulatorHandles.add([t(a),a.events.on("grab-changed",(e=>this._manipulatorGrabChanged(a,e))),a.events.on("immediate-click",(e=>this._manipulatorClick(a,e)))],a),this.manipulators.add(a),a}_createTargetManipulator(e){const t=this.configuration,i={size:t.target.size,customColor1:t.target.visibleColor,customColor2:t.target.occludedColor,customColor3:t.target.undefinedColor,visible:!0},a={target:e,type:"target"},r=this._createManipulator(i,(e=>this._createTargetManipulatorDragPipeline(e)),a);return null!=e.position?r.elevationAlignedLocation=e.position:r.available=!1,r}_getTargetManipulator(e){let t=null;return this.manipulators.forEach((i=>{const a=i.manipulator;null==t&&"target"===a.metadata.type&&a.metadata.target===e&&(t=a)})),t}_createObserverManipulator(){const e=this.configuration,t={size:e.observer.size,color:e.observer.color,visible:!0};return this._createManipulator(t,(e=>this._createObserverManipulatorDragPipeline(e)),{type:"observer",intersection:null})}_updateObserverManipulatorStyle(){const e=this._observerManipulator,t=this.configuration.observer,i={size:t.size,color:t.color,visible:e.available};e.renderObjects=T(i)}_screenToIntersection(){return e=>{const t=this._intersector.getScreenPointIntersection(e.screenEnd);return null==t?null:{...e,intersection:t}}}_createTargetManipulatorDragPipeline(e){return L(e,((t,i,a)=>{i.next(this._screenToIntersection()).next(this._updateTargetDragStep(e)).next((()=>this._updateLaserLineRenderer())),a.next(this._cancelTargetDragStep(e.metadata.target)).next((()=>this._updateLaserLineRenderer()))}))}_createObserverManipulatorDragPipeline(e){return L(e,((e,t,i)=>{t.next(this._screenToIntersection()).next(this._updateObserverDragStep()).next((()=>this._updateLaserLineRenderer())),i.next(this._cancelObserverDragStep()).next((()=>this._updateLaserLineRenderer()))}))}_updateObserverDragStep(){return e=>(null!=e.intersection.mapPoint?(null==this.analysis.observer&&(this.analysis.observer=new i),this._updateFromIntersection(this.analysis.observer,e.intersection)):this.analysis.observer=null,e)}_cancelObserverDragStep(){const e=null!=this.analysis.observer&&null!=this.analysis.observer.position?this.analysis.observer.clone():null;return t=>(this.analysis.observer=e,t)}_updateTargetDragStep(e){return t=>{this._updateFromIntersection(e.metadata.target,t.intersection);const i=t.intersection.mapPoint;return null!=i&&(e.elevationAlignedLocation=i),t}}_cancelTargetDragStep(e){const t=e.position?.clone();return i=>(e.position=t,i)}_manipulatorGrabChanged(e,t){switch(t.action){case"start":this._grabbedManipulator=e;break;case"end":this._grabbedManipulator===e&&(this._grabbedManipulator=null)}}_updateManipulatorState(e,t){const{isValid:i,isTargetVisible:a}=t.computationResult;e.state=i?a?k.Custom1:k.Custom2:k.Custom3}_getLineOfSightManipulatorStateDependencies(e){const{isValid:t,isTargetVisible:i}=e.computationResult;return{isValid:t,isTargetVisible:i}}_laserLineRendererDependencies(){return{laserlineVisualElement:this._laserlineVisualElement,grabbedManipulator:this._grabbedManipulator,shouldRenderTracker:this._shouldRenderTracker,observerPosition:null!=this.analysis.observer?this.analysis.observer.position:null,visible:this.visible}}_updateLaserLineRenderer(e=this._laserLineRendererDependencies()){const{laserlineVisualElement:t,grabbedManipulator:i,shouldRenderTracker:a,observerPosition:r,visible:n}=e;if(null==t)return;const s=null!=i?i:a&&null!=r?this._targetTrackerManipulator:null;this.configuration.laserLine.enabled&&null!=s&&n?(t.visible=!0,t.heightManifoldTarget=s.renderLocation,s!==this._observerManipulator?t.lineVerticalPlaneSegment=g(this._observerManipulator.renderLocation,s.renderLocation,H):t.lineVerticalPlaneSegment=null):(t.visible=!1,t.heightManifoldTarget=null,t.lineVerticalPlaneSegment=null)}_createVisualElements(){const e=this.configuration.laserLine;this._removeVisualElements(),this._laserlineVisualElement=new M({view:this.view,attached:!0,visible:this.visible,style:{glowColor:t.toUnitRGB(e.glowColor),glowWidth:e.glowWidth,innerColor:t.toUnitRGB(e.innerColor),innerWidth:e.innerWidth,globalAlpha:e.globalAlpha},isDecoration:!0})}_removeVisualElements(){null!=this._laserlineVisualElement&&(this._laserlineVisualElement.destroy(),this._laserlineVisualElement=null)}_onObserverLocationChange(e){null!=e?(this._observerManipulator.metadata.intersection=null,this._observerManipulator.available=!0,this._observerManipulator.elevationAlignedLocation=e):this._observerManipulator.available=!1}_onTargetLocationChange(e,t){null!=e?(t.elevationAlignedLocation=e,t!==this._targetTrackerManipulator&&(t.available=!0)):t.available=!1}_addPointFromClickEvent(e){const t=this._intersector.getScreenPointIntersection(e);if(null!=t&&null!=t.mapPoint)if(null!=this.analysis.observer&&null!=this.analysis.observer.position){this._clearCursorTracker();const e=new a;this._updateFromIntersection(e,t),this.analysis.targets.add(e)}else{const e=new i;this._updateFromIntersection(e,t),this.analysis.observer=e}}_clickHandler(e){this.active&&e.button!==O.Right&&(this._addPointFromClickEvent(V(e)),e.stopPropagation())}_doubleClickHandler(e){this.active&&e.button!==O.Right&&(this.stop(),e.stopPropagation())}_keyDownHandler(e){this.active&&"Escape"===e.key&&(this.stop(),e.stopPropagation())}_pointerMoveHandler(e){if(this.hasGrabbedManipulators)return;if(this._latestPointerMovePointerType=e.pointerType,this._updateLaserLineRenderer(),!this._showTracker||null==this.analysis.observer||null==this.analysis.observer.position)return;const t=V(e),i=this._intersector.getScreenPointIntersection(t);null!=i&&null!=i.mapPoint&&(null==this.analysisViewData.cursorTarget&&(this.analysisViewData.cursorTarget=new a),this._updateFromIntersection(this.analysisViewData.cursorTarget,i),this._updateLaserLineRenderer())}_updateFromIntersection(e,t){if(null==t.mapPoint)return e.position=null,e.elevationInfo=null,void(e.feature=null);switch(t.type){case C.OBJECT:if(null!=t.graphic){const i=t.graphic,a=_(i);"on-the-ground"===a.mode&&(a.mode="relative-to-ground",a.offset=0),e.elevationInfo=new v(a),e.feature=i}else e.elevationInfo=null,e.feature=null;break;case C.TERRAIN:case C.I3S:e.elevationInfo=new v({mode:"on-the-ground"}),e.feature=null;break;default:e.elevationInfo=null,e.feature=null}const i=t.mapPoint.clone();i.z=m(this.view,i,{mode:"absolute-height",offset:0},e.elevationInfo),e.position=i}_manipulatorClick(e,t){if("observer"===e.metadata.type||e.grabbing||e.dragging||t.button!==O.Right||this.analysis.targets.length<=1)return;const{target:i}=e.metadata;this.analysis.targets.remove(i),t.stopPropagation()}get testInfo(){return{laserLineVisualElement:this._laserlineVisualElement,getTargetManipulator:e=>this._getTargetManipulator(e)}}};e([c({constructOnly:!0})],D.prototype,"view",void 0),e([c({constructOnly:!0})],D.prototype,"analysis",void 0),e([c({readOnly:!0})],D.prototype,"state",null),e([c({readOnly:!0})],D.prototype,"cursor",null),e([c()],D.prototype,"removeIncompleteOnCancel",void 0),e([c({readOnly:!0})],D.prototype,"updating",null),e([c({type:y})],D.prototype,"configuration",void 0),e([c({constructOnly:!0})],D.prototype,"analysisViewData",void 0),e([c({readOnly:!0})],D.prototype,"_showTracker",null),e([c()],D.prototype,"_latestPointerMovePointerType",void 0),e([c()],D.prototype,"_shouldRenderTracker",null),e([c()],D.prototype,"_laserlineVisualElement",void 0),e([c()],D.prototype,"_grabbedManipulator",void 0),D=e([p("esri.views.3d.interactive.analysisTools.lineOfSight.LineOfSightTool")],D);const H=d();export{D as LineOfSightTool};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../Color.js";import i from"../../../../analysis/LineOfSightAnalysisObserver.js";import a from"../../../../analysis/LineOfSightAnalysisTarget.js";import r from"../../../../core/Handles.js";import n from"../../../../core/Logger.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{watch as o,syncAndInitial as l,initial as u}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as p}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../../../core/support/UpdatingHandles.js";import{create as d,fromPoints as g}from"../../../../geometry/support/lineSegment.js";import{getGraphicEffectiveElevationInfo as _,getConvertedElevation as m}from"../../../../support/elevationInfoUtils.js";import v from"../../../../symbols/support/ElevationInfo.js";import{LineOfSightRayIntersector as b}from"./LineOfSightRayIntersector.js";import{LineOfSightToolConfiguration as y}from"./LineOfSightToolConfiguration.js";import{createSphereManipulator as f,createSphereManipulatorRenderObjects as T}from"./lineOfSightToolUtils.js";import{LaserlineVisualElement as M}from"../../interactive/visualElements/LaserlineVisualElement.js";import{IntersectorType as C}from"../../webgl-engine/lib/IntersectorInterfaces.js";import"../../../input/ViewEvents.js";import{AnalysisToolBase as w}from"../../../interactive/AnalysisToolBase.js";import{createManipulatorDragEventPipeline as L}from"../../../interactive/dragEventPipeline.js";import{ManipulatorStateCustomFlags as k}from"../../../interactive/interfaces.js";import{createScreenPointFromEvent as V}from"../../../support/screenUtils.js";import{MouseButton as O}from"../../../input/IViewEvents.js";var S;!function(e){e.Ready="ready",e.Creating="creating",e.Created="created"}(S||(S={}));let H=class extends w{constructor(e){super(e),this.removeIncompleteOnCancel=!1,this.configuration=new y,this.analysisViewData=null,this._latestPointerMovePointerType=null,this._laserlineVisualElement=null,this._grabbedManipulator=null,this._analysisHandles=new r,this._updatingHandles=new h,this._manipulatorHandles=new r,this._targetTrackerManipulator=null}initialize(){this._intersector=new b({view:this.view}),this.addHandles(o((()=>this.state),(e=>{e===S.Created&&this.finishToolCreation()}),l)),this._observerManipulator=this._createObserverManipulator(),this.addHandles([this._updatingHandles.add((()=>({...this.configuration.observer})),(()=>this._updateObserverManipulatorStyle())),this._updatingHandles.add((()=>this.analysisViewData?.elevationAlignedObserver),(e=>this._onObserverLocationChange(e)),u),this._updatingHandles.add((()=>({...this.configuration.laserLine})),(()=>this._createVisualElements()),u),this._updatingHandles.add((()=>this._laserLineRendererDependencies()),(e=>this._updateLaserLineRenderer(e))),this._connectComputations(),this._updatingHandles.addWhen((()=>!this._shouldRenderTracker),(()=>this._clearCursorTracker()),u)])}destroy(){this._updatingHandles=s(this._updatingHandles),this._manipulatorHandles=s(this._manipulatorHandles),this._analysisHandles=s(this._analysisHandles),this._observerManipulator=null,this._clearCursorTracker(),this._removeVisualElements(),this._intersector=null,this._set("analysis",null)}get state(){return this.active?this.hasGrabbedManipulators?S.Created:S.Creating:null!=this.analysis.observer&&null!=this.analysis.observer.position?S.Created:S.Ready}get cursor(){return this.active&&this._showTracker?"crosshair":null}get updating(){return null!=this.analysisViewData&&this.analysisViewData.updating||this._updatingHandles.updating}get _showTracker(){return this.active&&"mouse"===this._latestPointerMovePointerType}get _shouldRenderTracker(){return this._showTracker&&null!=this.analysis.observer&&null!=this.analysis.observer.position&&!this.hasGrabbedManipulators}continue(){this.view.activeTool=this}stop(){this.view.activeTool=null}onEditableChange(){this.analysisViewData.editable=this.internallyEditable}onInputEvent(e){switch(e.type){case"immediate-double-click":this._doubleClickHandler(e);break;case"key-down":this._keyDownHandler(e);break;case"pointer-move":this._pointerMoveHandler(e)}}onInputEventAfter(e){if("immediate-click"===e.type)this._clickHandler(e)}onShow(){}onHide(){}onDeactivate(){this._clearCursorTracker()}_connectComputations(){return this._updatingHandles.addOnCollectionChange((()=>this.analysisViewData.computations),(e=>this._onComputationsCollectionChange(e)),{initial:!0,final:!0})}_onComputationsCollectionChange({added:e,removed:t}){for(const i of t)this._disconnectComputation(i);for(const i of e)this._connectComputation(i)}_connectComputation(e){if(this.destroyed)return void n.getLogger(this).warn("Attempting to connect an analysis to a destroyed LineOfSight tool. Ignoring.");const t=this._analysisHandles;if(t.has(e))return;const i=this._createTargetManipulator(e.target);null==this._targetTrackerManipulator&&i.metadata.target===this.analysisViewData.cursorTarget&&(this._targetTrackerManipulator=i,this._targetTrackerManipulator.available=!1,this._targetTrackerManipulator.interactive=!1,this._updateLaserLineRenderer()),t.add([this._updatingHandles.add((()=>this._getLineOfSightManipulatorStateDependencies(e)),(()=>this._updateManipulatorState(i,e)),u),this._updatingHandles.add((()=>e.elevationAlignedTargetLocation),(e=>this._onTargetLocationChange(e,i)),u)],e)}_disconnectComputation(e){if(this.destroyed)return void n.getLogger(this).warn("Attempting to disconnect an analysis from a destroyed LineOfSight tool. Ignoring.");this._analysisHandles.remove(e);const t=this._getTargetManipulator(e.target);null!=t&&(this.manipulators.remove(t),this._manipulatorHandles.remove(t),null!=this._targetTrackerManipulator&&this._targetTrackerManipulator===t&&(this._targetTrackerManipulator=null))}_clearCursorTracker(){this.analysisViewData.cursorTarget=s(this.analysisViewData.cursorTarget)}_createManipulator(e,t,i){const a=f(this.view,e);return a.metadata=i,this._manipulatorHandles.add([t(a),a.events.on("grab-changed",(e=>this._manipulatorGrabChanged(a,e))),a.events.on("immediate-click",(e=>this._manipulatorClick(a,e)))],a),this.manipulators.add(a),a}_createTargetManipulator(e){const t=this.configuration,i={size:t.target.size,customColor1:t.target.visibleColor,customColor2:t.target.occludedColor,customColor3:t.target.undefinedColor,visible:!0},a={target:e,type:"target"},r=this._createManipulator(i,(e=>this._createTargetManipulatorDragPipeline(e)),a);return null!=e.position?r.elevationAlignedLocation=e.position:r.available=!1,r}_getTargetManipulator(e){let t=null;return this.manipulators.forEach((i=>{const a=i.manipulator;null==t&&"target"===a.metadata.type&&a.metadata.target===e&&(t=a)})),t}_createObserverManipulator(){const e=this.configuration,t={size:e.observer.size,color:e.observer.color,visible:!0};return this._createManipulator(t,(e=>this._createObserverManipulatorDragPipeline(e)),{type:"observer",intersection:null})}_updateObserverManipulatorStyle(){const e=this._observerManipulator,t=this.configuration.observer,i={size:t.size,color:t.color,visible:e.available};e.renderObjects=T(i)}_screenToIntersection(){return e=>{const t=this._intersector.getScreenPointIntersection(e.screenEnd);return null==t?null:{...e,intersection:t}}}_createTargetManipulatorDragPipeline(e){return L(e,((t,i,a)=>{i.next(this._screenToIntersection()).next(this._updateTargetDragStep(e)).next((()=>this._updateLaserLineRenderer())),a.next(this._cancelTargetDragStep(e.metadata.target)).next((()=>this._updateLaserLineRenderer()))}))}_createObserverManipulatorDragPipeline(e){return L(e,((e,t,i)=>{t.next(this._screenToIntersection()).next(this._updateObserverDragStep()).next((()=>this._updateLaserLineRenderer())),i.next(this._cancelObserverDragStep()).next((()=>this._updateLaserLineRenderer()))}))}_updateObserverDragStep(){return e=>(null!=e.intersection.mapPoint?(null==this.analysis.observer&&(this.analysis.observer=new i),this._updateFromIntersection(this.analysis.observer,e.intersection)):this.analysis.observer=null,e)}_cancelObserverDragStep(){const e=null!=this.analysis.observer&&null!=this.analysis.observer.position?this.analysis.observer.clone():null;return t=>(this.analysis.observer=e,t)}_updateTargetDragStep(e){return t=>{this._updateFromIntersection(e.metadata.target,t.intersection);const i=t.intersection.mapPoint;return null!=i&&(e.elevationAlignedLocation=i),t}}_cancelTargetDragStep(e){const t=e.position?.clone();return i=>(e.position=t,i)}_manipulatorGrabChanged(e,t){switch(t.action){case"start":this._grabbedManipulator=e;break;case"end":this._grabbedManipulator===e&&(this._grabbedManipulator=null)}}_updateManipulatorState(e,t){const{isValid:i,isTargetVisible:a}=t.computationResult;e.state=i?a?k.Custom1:k.Custom2:k.Custom3}_getLineOfSightManipulatorStateDependencies(e){const{isValid:t,isTargetVisible:i}=e.computationResult;return{isValid:t,isTargetVisible:i}}_laserLineRendererDependencies(){return{laserlineVisualElement:this._laserlineVisualElement,grabbedManipulator:this._grabbedManipulator,shouldRenderTracker:this._shouldRenderTracker,observerPosition:null!=this.analysis.observer?this.analysis.observer.position:null,visible:this.visible}}_updateLaserLineRenderer(e=this._laserLineRendererDependencies()){const{laserlineVisualElement:t,grabbedManipulator:i,shouldRenderTracker:a,observerPosition:r,visible:n}=e;if(null==t)return;const s=null!=i?i:a&&null!=r?this._targetTrackerManipulator:null;this.configuration.laserLine.enabled&&null!=s&&n?(t.visible=!0,t.heightManifoldTarget=s.renderLocation,s!==this._observerManipulator?t.lineVerticalPlaneSegment=g(this._observerManipulator.renderLocation,s.renderLocation,D):t.lineVerticalPlaneSegment=null):(t.visible=!1,t.heightManifoldTarget=null,t.lineVerticalPlaneSegment=null)}_createVisualElements(){const e=this.configuration.laserLine;this._removeVisualElements(),this._laserlineVisualElement=new M({view:this.view,attached:!0,visible:this.visible,style:{glowColor:t.toUnitRGB(e.glowColor),glowWidth:e.glowWidth,innerColor:t.toUnitRGB(e.innerColor),innerWidth:e.innerWidth,globalAlpha:e.globalAlpha},isDecoration:!0})}_removeVisualElements(){null!=this._laserlineVisualElement&&(this._laserlineVisualElement.destroy(),this._laserlineVisualElement=null)}_onObserverLocationChange(e){null!=e?(this._observerManipulator.metadata.intersection=null,this._observerManipulator.available=!0,this._observerManipulator.elevationAlignedLocation=e):this._observerManipulator.available=!1}_onTargetLocationChange(e,t){null!=e?(t.elevationAlignedLocation=e,t!==this._targetTrackerManipulator&&(t.available=!0)):t.available=!1}_addPointFromClickEvent(e){const t=this._intersector.getScreenPointIntersection(e);if(null!=t&&null!=t.mapPoint)if(null!=this.analysis.observer&&null!=this.analysis.observer.position){this._clearCursorTracker();const e=new a;this._updateFromIntersection(e,t),this.analysis.targets.add(e)}else{const e=new i;this._updateFromIntersection(e,t),this.analysis.observer=e}}_clickHandler(e){this.active&&e.button!==O.Right&&(this._addPointFromClickEvent(V(e)),e.stopPropagation())}_doubleClickHandler(e){this.active&&e.button!==O.Right&&(this.stop(),e.stopPropagation())}_keyDownHandler(e){this.active&&"Escape"===e.key&&(this.stop(),e.stopPropagation())}_pointerMoveHandler(e){if(this.hasGrabbedManipulators)return;if(this._latestPointerMovePointerType=e.pointerType,this._updateLaserLineRenderer(),!this._showTracker||null==this.analysis.observer||null==this.analysis.observer.position)return;const t=V(e),i=this._intersector.getScreenPointIntersection(t);null!=i&&null!=i.mapPoint&&(null==this.analysisViewData.cursorTarget&&(this.analysisViewData.cursorTarget=new a),this._updateFromIntersection(this.analysisViewData.cursorTarget,i),this._updateLaserLineRenderer())}_updateFromIntersection(e,t){if(null==t.mapPoint)return e.position=null,e.elevationInfo=null,void(e.feature=null);switch(t.type){case C.OBJECT:if(null!=t.graphic){const i=t.graphic,a=_(i);"on-the-ground"===a.mode&&(a.mode="relative-to-ground",a.offset=0),e.elevationInfo=new v(a),e.feature=i}else e.elevationInfo=null,e.feature=null;break;case C.TERRAIN:case C.I3S:e.elevationInfo=new v({mode:"on-the-ground"}),e.feature=null;break;default:e.elevationInfo=null,e.feature=null}const i=t.mapPoint.clone();i.z=m(this.view,i,{mode:"absolute-height",offset:0},e.elevationInfo),e.position=i}_manipulatorClick(e,t){if("observer"===e.metadata.type||e.grabbing||e.dragging||t.button!==O.Right||this.analysis.targets.length<=1)return;const{target:i}=e.metadata;this.analysis.targets.remove(i),t.stopPropagation()}get testInfo(){return{laserLineVisualElement:this._laserlineVisualElement,getTargetManipulator:e=>this._getTargetManipulator(e)}}};e([c({constructOnly:!0})],H.prototype,"view",void 0),e([c({constructOnly:!0})],H.prototype,"analysis",void 0),e([c({readOnly:!0})],H.prototype,"state",null),e([c({readOnly:!0})],H.prototype,"cursor",null),e([c()],H.prototype,"removeIncompleteOnCancel",void 0),e([c({readOnly:!0})],H.prototype,"updating",null),e([c({type:y})],H.prototype,"configuration",void 0),e([c({constructOnly:!0})],H.prototype,"analysisViewData",void 0),e([c({readOnly:!0})],H.prototype,"_showTracker",null),e([c()],H.prototype,"_latestPointerMovePointerType",void 0),e([c()],H.prototype,"_shouldRenderTracker",null),e([c()],H.prototype,"_laserlineVisualElement",void 0),e([c()],H.prototype,"_grabbedManipulator",void 0),H=e([p("esri.views.3d.interactive.analysisTools.lineOfSight.LineOfSightTool")],H);const D=d();export{H as LineOfSightTool};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as i}from"../../../../chunks/tslib.es6.js";import e from"../../../../Color.js";import t from"../../../../core/Accessor.js";import n from"../../../../core/Handles.js";import{makeHandle as o}from"../../../../core/handleUtils.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{initial as r}from"../../../../core/reactiveUtils.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as l}from"../../../../core/accessorSupport/decorators/subclass.js";import{c}from"../../../../chunks/mat4f64.js";import{b as u}from"../../../../chunks/vec3.js";import{g as d,c as m}from"../../../../chunks/vec3f64.js";import{WatchUpdatingTracking as h}from"../../../../core/support/WatchUpdatingTracking.js";import{LineOfSightVisualElement as p}from"./LineOfSightVisualElement.js";import{LineVisualElement as v}from"../../interactive/visualElements/LineVisualElement.js";import{PointVisualElement as g}from"../../interactive/visualElements/PointVisualElement.js";import{RenderOccludedFlag as f}from"../../webgl-engine/lib/Material.js";let b=class extends t{constructor(i){super(i),this._lineOfSightVisualElements=new Array,this._computationHandles=new n,this._updatingHandles=new h}initialize(){this.addHandles(this._connectComputations()),this._createObserverVisualization()}destroy(){this._updatingHandles=s(this._updatingHandles),this._computationHandles=s(this._computationHandles),this._observerVisualElement=s(this._observerVisualElement)}get visible(){return this.analysisViewData.visible}get updating(){return this._updatingHandles.updating}get interactiveAndEditable(){return this.analysisViewData.interactive&&this.analysisViewData.editable}get test(){return{disablePartialOcclusion:()=>{for(const i of this._lineOfSightVisualElements)i.visibleLineVisualElement.renderOccluded=f.Occlude,i.occludedLineVisualElement.renderOccluded=f.Occlude,i.undefinedLineVisualElement.renderOccluded=f.Occlude},visualizations:this._lineOfSightVisualElements}}get _configuration(){return this.analysisViewData.configuration}_createLineOfSightVisualization(){const i=this._configuration,t=this.view,n=this.isDecoration,o={view:t,attached:!0,width:i.outerWidth,innerWidth:i.innerWidth,isDecoration:n},s=e.toUnitRGBA(i.visibleOuterColor),r=e.toUnitRGBA(i.visibleInnerColor),a=e.toUnitRGBA(i.occludedOuterColor),l=e.toUnitRGBA(i.occludedInnerColor),c=e.toUnitRGBA(i.undefinedOuterColor),u=e.toUnitRGBA(i.undefinedInnerColor),d=new v({...o,color:s,innerColor:r}),m=new v({...o,color:a,innerColor:l}),h=new v({...o,color:c,innerColor:u}),f=new g({view:t,attached:!0,..._,size:8,isDecoration:n}),b=new p(d,m,h,f);return this._lineOfSightVisualElements.push(b),b}_destroyLineOfSightVisualization(i){i.destroy(),this._lineOfSightVisualElements.splice(this._lineOfSightVisualElements.indexOf(i),1)}_updateLineOfSightVisualization(i,t,n){const o=this._configuration,{computationResult:s,inputPoints:r}=i,{start:a,end:l,intersection:c,isValid:m,isTargetVisible:h}=s,{observer:p}=r,v=C;v[12]=p[0],v[13]=p[1],v[14]=p[2];const g=u(O,a,p),f=u(y,l,p),b=u(V,c,p),{visibleLineVisualElement:_,occludedLineVisualElement:E,undefinedLineVisualElement:w,targetVisualElement:A}=t,S=null==this.analysisViewData.elevationAlignedObserver||null==i.elevationAlignedTargetLocation,j=this.visible&&!S;_.visible=j,E.visible=j,w.visible=j,A.visible=j,A.attached=!n.interactiveAndEditable,j&&(_.geometry=null,E.geometry=null,w.geometry=null,A.geometry=i.elevationAlignedTargetLocation,m?h?(_.geometry=[[d(g),d(f)]],_.transform=v,_.color=e.toUnitRGBA(o.visibleOuterColor),A.color=e.toUnitRGBA(o.visibleInnerColor)):(_.geometry=[[d(g),d(b)]],_.transform=v,_.color=e.toUnitRGBA(o.occludedOuterColor),E.geometry=[[d(b),d(f)]],E.transform=v,A.color=e.toUnitRGBA(o.occludedInnerColor)):(w.geometry=[[d(g),d(f)]],w.transform=v,A.color=e.toUnitRGBA(o.undefinedInnerColor)))}_getLineOfSightVisualizationDependencies(i){const{computationResult:e}=i,{occludedOuterColor:t,visibleOuterColor:n}=this._configuration;return{computationResult:e,occludedOuterColor:t,visibleOuterColor:n,visible:this.visible,interactiveAndEditable:this.interactiveAndEditable}}_connectComputation(i){const e=this._computationHandles;if(e.has(i))return;const t=this._createLineOfSightVisualization();e.add([this._updatingHandles.add((()=>this._getLineOfSightVisualizationDependencies(i)),(e=>this._updateLineOfSightVisualization(i,t,e)),{initial:!0,equals:()=>!1}),o((()=>this._destroyLineOfSightVisualization(t)))],i)}_disconnectComputation(i){this._computationHandles.remove(i)}_connectComputations(){return this._updatingHandles.addOnCollectionChange((()=>this.analysisViewData.computations),(i=>this._onComputationsCollectionChange(i)),{initial:!0,final:!0})}_onComputationsCollectionChange({added:i,removed:e}){for(const t of e)this._disconnectComputation(t);for(const t of i)this._connectComputation(t)}_createObserverVisualization(){const i=e.toUnitRGBA(this._configuration.visibleInnerColor),t=new g({view:this.view,color:i,..._,isDecoration:this.isDecoration});this._observerVisualElement=t,this.addHandles(this._updatingHandles.add((()=>({observer:this.analysisViewData.elevationAlignedObserver,interactiveAndEditable:this.interactiveAndEditable,visible:this.visible})),(({observer:i,interactiveAndEditable:e,visible:n})=>{null!=i&&!e&&n?(t.geometry=i,this._observerVisualElement.attached=!0):t.attached=!1}),r))}};i([a({constructOnly:!0})],b.prototype,"analysis",void 0),i([a({constructOnly:!0})],b.prototype,"analysisViewData",void 0),i([a({constructOnly:!0})],b.prototype,"view",void 0),i([a({readOnly:!0})],b.prototype,"visible",null),i([a({constructOnly:!0})],b.prototype,"isDecoration",void 0),i([a()],b.prototype,"updating",null),i([a()],b.prototype,"interactiveAndEditable",null),i([a()],b.prototype,"test",null),i([a()],b.prototype,"_configuration",null),b=i([l("esri.views.3d.analysis.LineOfSight.LineOfSightVisualization")],b);const _={size:6,pixelSnappingEnabled:!1,primitive:"circle",elevationInfo:{mode:"absolute-height",offset:0},outlineSize:0},O=m(),y=m(),V=m(),C=c();export{b as LineOfSightVisualization};
5
+ import{_ as i}from"../../../../chunks/tslib.es6.js";import e from"../../../../Color.js";import t from"../../../../core/Accessor.js";import n from"../../../../core/Handles.js";import{makeHandle as o}from"../../../../core/handleUtils.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{initial as r}from"../../../../core/reactiveUtils.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as l}from"../../../../core/accessorSupport/decorators/subclass.js";import{c}from"../../../../chunks/mat4f64.js";import{b as u}from"../../../../chunks/vec3.js";import{g as d,c as m}from"../../../../chunks/vec3f64.js";import{UpdatingHandles as h}from"../../../../core/support/UpdatingHandles.js";import{LineOfSightVisualElement as p}from"./LineOfSightVisualElement.js";import{LineVisualElement as v}from"../../interactive/visualElements/LineVisualElement.js";import{PointVisualElement as g}from"../../interactive/visualElements/PointVisualElement.js";import{RenderOccludedFlag as f}from"../../webgl-engine/lib/Material.js";let b=class extends t{constructor(i){super(i),this._lineOfSightVisualElements=new Array,this._computationHandles=new n,this._updatingHandles=new h}initialize(){this.addHandles(this._connectComputations()),this._createObserverVisualization()}destroy(){this._updatingHandles=s(this._updatingHandles),this._computationHandles=s(this._computationHandles),this._observerVisualElement=s(this._observerVisualElement)}get visible(){return this.analysisViewData.visible}get updating(){return this._updatingHandles.updating}get interactiveAndEditable(){return this.analysisViewData.interactive&&this.analysisViewData.editable}get test(){return{disablePartialOcclusion:()=>{for(const i of this._lineOfSightVisualElements)i.visibleLineVisualElement.renderOccluded=f.Occlude,i.occludedLineVisualElement.renderOccluded=f.Occlude,i.undefinedLineVisualElement.renderOccluded=f.Occlude},visualizations:this._lineOfSightVisualElements}}get _configuration(){return this.analysisViewData.configuration}_createLineOfSightVisualization(){const i=this._configuration,t=this.view,n=this.isDecoration,o={view:t,attached:!0,width:i.outerWidth,innerWidth:i.innerWidth,isDecoration:n},s=e.toUnitRGBA(i.visibleOuterColor),r=e.toUnitRGBA(i.visibleInnerColor),a=e.toUnitRGBA(i.occludedOuterColor),l=e.toUnitRGBA(i.occludedInnerColor),c=e.toUnitRGBA(i.undefinedOuterColor),u=e.toUnitRGBA(i.undefinedInnerColor),d=new v({...o,color:s,innerColor:r}),m=new v({...o,color:a,innerColor:l}),h=new v({...o,color:c,innerColor:u}),f=new g({view:t,attached:!0,..._,size:8,isDecoration:n}),b=new p(d,m,h,f);return this._lineOfSightVisualElements.push(b),b}_destroyLineOfSightVisualization(i){i.destroy(),this._lineOfSightVisualElements.splice(this._lineOfSightVisualElements.indexOf(i),1)}_updateLineOfSightVisualization(i,t,n){const o=this._configuration,{computationResult:s,inputPoints:r}=i,{start:a,end:l,intersection:c,isValid:m,isTargetVisible:h}=s,{observer:p}=r,v=C;v[12]=p[0],v[13]=p[1],v[14]=p[2];const g=u(O,a,p),f=u(y,l,p),b=u(V,c,p),{visibleLineVisualElement:_,occludedLineVisualElement:E,undefinedLineVisualElement:w,targetVisualElement:A}=t,S=null==this.analysisViewData.elevationAlignedObserver||null==i.elevationAlignedTargetLocation,j=this.visible&&!S;_.visible=j,E.visible=j,w.visible=j,A.visible=j,A.attached=!n.interactiveAndEditable,j&&(_.geometry=null,E.geometry=null,w.geometry=null,A.geometry=i.elevationAlignedTargetLocation,m?h?(_.geometry=[[d(g),d(f)]],_.transform=v,_.color=e.toUnitRGBA(o.visibleOuterColor),A.color=e.toUnitRGBA(o.visibleInnerColor)):(_.geometry=[[d(g),d(b)]],_.transform=v,_.color=e.toUnitRGBA(o.occludedOuterColor),E.geometry=[[d(b),d(f)]],E.transform=v,A.color=e.toUnitRGBA(o.occludedInnerColor)):(w.geometry=[[d(g),d(f)]],w.transform=v,A.color=e.toUnitRGBA(o.undefinedInnerColor)))}_getLineOfSightVisualizationDependencies(i){const{computationResult:e}=i,{occludedOuterColor:t,visibleOuterColor:n}=this._configuration;return{computationResult:e,occludedOuterColor:t,visibleOuterColor:n,visible:this.visible,interactiveAndEditable:this.interactiveAndEditable}}_connectComputation(i){const e=this._computationHandles;if(e.has(i))return;const t=this._createLineOfSightVisualization();e.add([this._updatingHandles.add((()=>this._getLineOfSightVisualizationDependencies(i)),(e=>this._updateLineOfSightVisualization(i,t,e)),{initial:!0,equals:()=>!1}),o((()=>this._destroyLineOfSightVisualization(t)))],i)}_disconnectComputation(i){this._computationHandles.remove(i)}_connectComputations(){return this._updatingHandles.addOnCollectionChange((()=>this.analysisViewData.computations),(i=>this._onComputationsCollectionChange(i)),{initial:!0,final:!0})}_onComputationsCollectionChange({added:i,removed:e}){for(const t of e)this._disconnectComputation(t);for(const t of i)this._connectComputation(t)}_createObserverVisualization(){const i=e.toUnitRGBA(this._configuration.visibleInnerColor),t=new g({view:this.view,color:i,..._,isDecoration:this.isDecoration});this._observerVisualElement=t,this.addHandles(this._updatingHandles.add((()=>({observer:this.analysisViewData.elevationAlignedObserver,interactiveAndEditable:this.interactiveAndEditable,visible:this.visible})),(({observer:i,interactiveAndEditable:e,visible:n})=>{null!=i&&!e&&n?(t.geometry=i,this._observerVisualElement.attached=!0):t.attached=!1}),r))}};i([a({constructOnly:!0})],b.prototype,"analysis",void 0),i([a({constructOnly:!0})],b.prototype,"analysisViewData",void 0),i([a({constructOnly:!0})],b.prototype,"view",void 0),i([a({readOnly:!0})],b.prototype,"visible",null),i([a({constructOnly:!0})],b.prototype,"isDecoration",void 0),i([a()],b.prototype,"updating",null),i([a()],b.prototype,"interactiveAndEditable",null),i([a()],b.prototype,"test",null),i([a()],b.prototype,"_configuration",null),b=i([l("esri.views.3d.analysis.LineOfSight.LineOfSightVisualization")],b);const _={size:6,pixelSnappingEnabled:!1,primitive:"circle",elevationInfo:{mode:"absolute-height",offset:0},outlineSize:0},O=m(),y=m(),V=m(),C=c();export{b as LineOfSightVisualization};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Handles.js";import{clamp as t,lerp as s,smoothstep as i}from"../../../core/mathUtils.js";import{watch as r}from"../../../core/reactiveUtils.js";import{s as a}from"../../../chunks/vec2.js";import{s as o,l as n,p as h}from"../../../chunks/vec3.js";import{s as d}from"../../../chunks/vec4.js";import{earth as u}from"../../../geometry/support/Ellipsoid.js";import{AtmosphereType as m}from"./AtmosphereType.js";import{atmosphereHeight as p,innerAtmosphereDepth as l,computeInnerAltitudeFade as c}from"./atmosphereUtils.js";import{ChapmanAtmospherePassParameters as _,ChapmanAtmosphereTechnique as T}from"./ChapmanAtmosphereTechnique.js";import{ChapmanAtmosphereTechniqueConfiguration as b}from"./ChapmanAtmosphereTechniqueConfiguration.js";import{Pos2Tex as f}from"../webgl-engine/lib/DefaultVertexBufferLayouts.js";import{createQuadVAO as v}from"../webgl-engine/lib/glUtil3D.js";import{applyTextureResizeModulo as R}from"../webgl-engine/lib/textureUtils.js";import{PrimitiveType as w}from"../../webgl/enums.js";class q{constructor(t,s){this._view=t,this.type=m.Realistic,this._handles=new e,this._passParameters=new _,this._rootTileElevationMin=NaN,this._lowerBoundEarthRadius=u.radius,this._fadeHaze=0,this._updateRadius(u.radius);const i=s.renderContext.rctx;this._updateRootTileElevationBounds(),this._handles.add([r((()=>this._view?.basemapTerrain?.rootTileElevationBounds),(()=>this._view?.basemapTerrain?this._updateRootTileElevationBounds():null)),r((()=>this._view?.basemapTerrain?.visibleElevationBounds),(()=>this._view?.basemapTerrain?this._updateVisibleElevationBounds():null))]);const a=new b;a.haze=!1,this._atmosphereTechnique=s.techniqueRepository.acquire(T,a),a.haze=!0,this._atmosphereHazeTechnique=s.techniqueRepository.acquire(T,a),a.reduced=!0,a.haze=!1,this._atmosphereReducedTechnique=s.techniqueRepository.acquire(T,a),a.haze=!0,this._atmosphereHazeReducedTechnique=s.techniqueRepository.acquire(T,a),this._vao=v(i,f)}destroy(){this._handles.destroy(),this._atmosphereTechnique.release(),this._atmosphereHazeTechnique.release(),this._atmosphereReducedTechnique.release(),this._atmosphereHazeReducedTechnique.release(),this._vao.dispose()}render(e,t){this._render(e,t?this._atmosphereTechnique:this._atmosphereReducedTechnique,e.offscreenRenderingHelper.depthTexture,t,!1)}renderHaze(e,t,s){this._fadeHaze=t,this._render(e,s?this._atmosphereHazeTechnique:this._atmosphereHazeReducedTechnique,e.bindParameters.linearDepth?.colorTexture,s,!0)}_render(e,t,i,r,a){if(null==i)return;const h=e.offscreenRenderingHelper;this._update(e.bindParameters.camera),this._passParameters.depthTexture=i;const d=h.backgroundColor;o(this._passParameters.backgroundColor,d[0]*d[3],d[1]*d[3],d[2]*d[3]);const m=e.rctx.bindTechnique(t,this._passParameters,e.bindParameters);if(r)h.renderDepthDetached((()=>this._renderCommon(m,e)));else{const t=e.rctx.getViewport(),r=n(e.bindParameters.camera.eye)-u.radius;let o;if(r<p){const e=Math.min(1,Math.max(0,r/p));o=a?s(.4,.5,e):s(.2,.3,e)}else{const e=Math.min(1,Math.max(0,(r-p)/(15*p)));o=a?s(.5,1,e):s(.3,.6,e)}const d=R(Math.round(o*e.bindParameters.camera.fullViewport[2])),l=R(Math.round(o*e.bindParameters.camera.fullViewport[3]));e.rctx.setViewport(0,0,d,l);const c=h.renderToCachedFBO(null,(()=>this._renderCommon(m,e)),[0,0,0,1],null,d,l);e.rctx.setViewport(t.x,t.y,t.width,t.height),h.compositeAtmosphereToMain(e.bindParameters,a,c.colorTexture,i),c.release()}}_renderCommon(e,t){null!=this._vao&&(t.rctx.bindVAO(this._vao),e.assertCompatibleVertexAttributeLocations(this._vao),t.rctx.drawArrays(w.TRIANGLE_STRIP,0,4))}_adjustRadiusForTesselation(e){return e*Math.cos(Math.PI/16/16)}_updateRootTileElevationBounds(){const e=this._view.basemapTerrain.rootTileElevationBounds.min;e!==this._rootTileElevationMin&&(this._rootTileElevationMin=e,this._lowerBoundEarthRadius=u.radius,this._updateVisibleElevationBounds())}_updateVisibleElevationBounds(){const e=this._adjustRadiusForTesselation(u.radius+this._view.basemapTerrain.visibleElevationBounds.min);e<this._lowerBoundEarthRadius&&this._updateRadius(e)}_updateRadius(e){this._lowerBoundEarthRadius=e,a(this._passParameters.radii,e,e+p),this._passParameters.innerFadeDistance=2*Math.sqrt((2*e-l)*l)}_update(e){if(!e)return;const r=h(e.eye),a=Math.sqrt(r),o=r-this._passParameters.radii[1]*this._passParameters.radii[1],n=t((a-this._passParameters.radii[0])/p,0,1);d(this._passParameters.heightParameters,a,r,o,n),this._passParameters.altitudeFade=c(a-this._lowerBoundEarthRadius),this._passParameters.hazeStrength=s(s(.6,1,i(9500,10500,a-u.radius)),1,this._fadeHaze)}static isSupported(e){return e.renderContext.rctx.capabilities.depthTexture}}export{q as ChapmanAtmosphere};
5
+ import e from"../../../core/Handles.js";import{clamp as t,lerp as s,smoothstep as i}from"../../../core/mathUtils.js";import{watch as r}from"../../../core/reactiveUtils.js";import{s as a}from"../../../chunks/vec2.js";import{s as o,l as n,p as h}from"../../../chunks/vec3.js";import{s as d}from"../../../chunks/vec4.js";import{earth as u}from"../../../geometry/support/Ellipsoid.js";import{AtmosphereType as m}from"./AtmosphereType.js";import{atmosphereHeight as p,innerAtmosphereDepth as l,computeInnerAltitudeFade as c}from"./atmosphereUtils.js";import{ChapmanAtmospherePassParameters as _,ChapmanAtmosphereTechnique as T}from"./ChapmanAtmosphereTechnique.js";import{ChapmanAtmosphereTechniqueConfiguration as b}from"./ChapmanAtmosphereTechniqueConfiguration.js";import{ColorFormat as f}from"../webgl-engine/core/FBOCache.js";import{Pos2Tex as v}from"../webgl-engine/lib/DefaultVertexBufferLayouts.js";import{createQuadVAO as R}from"../webgl-engine/lib/glUtil3D.js";import{applyTextureResizeModulo as w}from"../webgl-engine/lib/textureUtils.js";import{PrimitiveType as q}from"../../webgl/enums.js";class x{constructor(t,s){this._view=t,this.type=m.Realistic,this._handles=new e,this._passParameters=new _,this._rootTileElevationMin=NaN,this._lowerBoundEarthRadius=u.radius,this._fadeHaze=0,this._updateRadius(u.radius);const i=s.renderContext.rctx;this._updateRootTileElevationBounds(),this._handles.add([r((()=>this._view?.basemapTerrain?.rootTileElevationBounds),(()=>this._view?.basemapTerrain?this._updateRootTileElevationBounds():null)),r((()=>this._view?.basemapTerrain?.visibleElevationBounds),(()=>this._view?.basemapTerrain?this._updateVisibleElevationBounds():null))]);const a=new b;a.haze=!1,this._atmosphereTechnique=s.techniqueRepository.acquire(T,a),a.haze=!0,this._atmosphereHazeTechnique=s.techniqueRepository.acquire(T,a),a.reduced=!0,a.haze=!1,this._atmosphereReducedTechnique=s.techniqueRepository.acquire(T,a),a.haze=!0,this._atmosphereHazeReducedTechnique=s.techniqueRepository.acquire(T,a),this._vao=R(i,v)}destroy(){this._handles.destroy(),this._atmosphereTechnique.release(),this._atmosphereHazeTechnique.release(),this._atmosphereReducedTechnique.release(),this._atmosphereHazeReducedTechnique.release(),this._vao.dispose()}render(e,t){this._render(e,t?this._atmosphereTechnique:this._atmosphereReducedTechnique,e.offscreenRenderingHelper.depthTexture,t,!1)}renderHaze(e,t,s){this._fadeHaze=t,this._render(e,s?this._atmosphereHazeTechnique:this._atmosphereHazeReducedTechnique,e.bindParameters.linearDepth?.colorTexture,s,!0)}_render(e,t,i,r,a){if(null==i)return;const h=e.offscreenRenderingHelper;this._update(e.bindParameters.camera),this._passParameters.depthTexture=i;const d=h.backgroundColor;o(this._passParameters.backgroundColor,d[0]*d[3],d[1]*d[3],d[2]*d[3]);const m=e.rctx.bindTechnique(t,this._passParameters,e.bindParameters);if(r)h.renderDepthDetached((()=>this._renderCommon(m,e)));else{const t=e.rctx.getViewport(),r=n(e.bindParameters.camera.eye)-u.radius;let o;if(r<p){const e=Math.min(1,Math.max(0,r/p));o=a?s(.4,.5,e):s(.2,.3,e)}else{const e=Math.min(1,Math.max(0,(r-p)/(15*p)));o=a?s(.5,1,e):s(.3,.6,e)}const d=w(Math.round(o*e.bindParameters.camera.fullViewport[2])),l=w(Math.round(o*e.bindParameters.camera.fullViewport[3]));e.rctx.setViewport(0,0,d,l);const c=h.renderToCachedFBO(null,(()=>this._renderCommon(m,e)),[0,0,0,1],f.RGBA,null,d,l);e.rctx.setViewport(t.x,t.y,t.width,t.height),h.compositeAtmosphereToMain(e.bindParameters,a,c.colorTexture,i),c.release()}}_renderCommon(e,t){null!=this._vao&&(t.rctx.bindVAO(this._vao),e.assertCompatibleVertexAttributeLocations(this._vao),t.rctx.drawArrays(q.TRIANGLE_STRIP,0,4))}_adjustRadiusForTesselation(e){return e*Math.cos(Math.PI/16/16)}_updateRootTileElevationBounds(){const e=this._view.basemapTerrain.rootTileElevationBounds.min;e!==this._rootTileElevationMin&&(this._rootTileElevationMin=e,this._lowerBoundEarthRadius=u.radius,this._updateVisibleElevationBounds())}_updateVisibleElevationBounds(){const e=this._adjustRadiusForTesselation(u.radius+this._view.basemapTerrain.visibleElevationBounds.min);e<this._lowerBoundEarthRadius&&this._updateRadius(e)}_updateRadius(e){this._lowerBoundEarthRadius=e,a(this._passParameters.radii,e,e+p),this._passParameters.innerFadeDistance=2*Math.sqrt((2*e-l)*l)}_update(e){if(!e)return;const r=h(e.eye),a=Math.sqrt(r),o=r-this._passParameters.radii[1]*this._passParameters.radii[1],n=t((a-this._passParameters.radii[0])/p,0,1);d(this._passParameters.heightParameters,a,r,o,n),this._passParameters.altitudeFade=c(a-this._lowerBoundEarthRadius),this._passParameters.hazeStrength=s(s(.6,1,i(9500,10500,a-u.radius)),1,this._fadeHaze)}static isSupported(e){return e.renderContext.rctx.capabilities.depthTexture}}export{x as ChapmanAtmosphere};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import s from"../../../core/Handles.js";import{lerp as i}from"../../../core/mathUtils.js";import{releaseMaybe as r,disposeMaybe as a,destroyMaybe as o}from"../../../core/maybe.js";import{watch as n,initial as h}from"../../../core/reactiveUtils.js";import{property as u}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{f as d}from"../../../chunks/mat3.js";import{v as c}from"../../../chunks/mat4.js";import{c as m}from"../../../chunks/mat4f64.js";import{s as p,o as _,j as f}from"../../../chunks/vec2.js";import{a as g}from"../../../chunks/vec2f64.js";import{f as w,z as x}from"../../../chunks/vec3f32.js";import{getReferenceEllipsoid as T}from"../../../geometry/ellipsoidUtils.js";import{C as v,a as C}from"../../../chunks/Clouds.glsl.js";import{CloudsTextureChannels as y,CloudsRenderingStages as b}from"./CloudsData.js";import{cloudPresets as P}from"./CloudsPresets.js";import{CloudsTechnique as S}from"./CloudsTechnique.js";import{CloudsTechniqueConfiguration as j,RayMarchingSteps as I}from"./CloudsTechniqueConfiguration.js";import{NoiseTextureAtlas as E}from"./NoiseTextureAtlas.js";import{BindParameters as D}from"../webgl-engine/lib/BindParameters.js";import{createQuadVAO as z}from"../webgl-engine/lib/glUtil3D.js";import{TaskPriority as M,Task as U}from"../../support/Scheduler.js";import{TextureType as q,TextureWrapMode as F}from"../../webgl/enums.js";import{FramebufferObject as R}from"../../webgl/FramebufferObject.js";import{TextureDescriptor as H}from"../../webgl/TextureDescriptor.js";let B=class extends t{constructor(e){super(e),this._handles=new s,this._techniques=new Array,this._techniqueConfiguration=new j,this._bindParameters=new D(null,null,null),this._passParameters=new v,this._drawParameters=new C,this._weatherTile=g(),this._weatherTileCount=128,this._faceIndex=0,this._tileIndex=0,this.coverage=i(P.default.coverage[0],P.default.coverage[1],.5),this.density=i(P.default.density[0],P.default.density[1],.5),this.absorption=i(P.default.absorption[0],P.default.absorption[1],.5),this.cloudSize=i(P.default.cloudSize[0],P.default.cloudSize[1],.5),this.detailSize=i(P.default.detailSize[0],P.default.detailSize[1],.5),this.smoothness=i(P.default.smoothness[0],P.default.smoothness[1],.5),this.cloudHeight=i(P.default.cloudHeight[0],P.default.cloudHeight[1],.5),this.raymarchingSteps=P.default.raymarchingSteps,this._viewMatrix=m(),this._dirty=!1,this.running=!1,this._vao=z(e.context.renderContext.rctx)}_getTechnique(e){const t=1-this.context.renderContext.bindParameters.cloudsFade.readChannels,s=t===y.RG?2*e:2*e+1,i=this._techniques[s];return i||(this._techniqueConfiguration.writeTextureChannels=t,this._techniqueConfiguration.steps=e,this._techniques[s]=new S({rctx:this.context.renderContext.rctx,viewingMode:this.view.state.viewingMode},this._techniqueConfiguration),this._techniques[s])}updateWeatherTile(){const e=this.view.camera.position.latitude,t=this.view.camera.position.longitude;if(null==e||null==t)return;p(this._weatherTile,(e+90)/180,(t+180)/360);const s=Math.floor(this._weatherTileCount*Math.abs(2*this._weatherTile[0]-1));this._weatherTile[0]=Math.floor(2*this._weatherTileCount*this._weatherTile[0]),this._weatherTile[1]=Math.floor(4*(this._weatherTileCount-s)*this._weatherTile[1]);let i=0,r=0;if(null!=this.view.environment&&"virtual"!==this.view.environment.lighting.type&&null!=this.view.environment.lighting.date){const e=new Date(this.view.environment.lighting.date);e.setUTCHours(this.view.environment.lighting.date.getUTCHours()+(this.view.environment.lighting.displayUTCOffset??0)),i=31*e.getUTCMonth()+e.getUTCDate(),r=e.getUTCFullYear()}this._weatherTile[0]=(this._weatherTile[0]+i)%(2*this._weatherTileCount),this._weatherTile[1]=(this._weatherTile[1]+r%100)%(4*this._weatherTileCount),_(this._passParameters.weatherTile,this._weatherTile)||this.setDirty()}initialize(){const e=T(this.view.spatialReference);this._passParameters.cloudRadius=.5*e.radius,this.setDirty(),this.updateWeatherTile(),this._handles.add([this.view.resourceController.scheduler.registerTask(M.CLOUDS_GENERATOR,this),n((()=>[this.coverage,this.density,this.absorption,this.cloudSize,this.detailSize,this.smoothness,this.cloudHeight,this.raymarchingSteps]),(()=>this.setDirty()),h)])}destroy(){this._handles.destroy(),this._techniques.forEach((e=>r(e))),this._frameBufferCube=a(this._frameBufferCube),this._techniques.length=0,this._vao.dispose(),this._passParameters.noiseTexture=o(this._passParameters.noiseTexture)}get _tilesPerFace(){switch(this._techniqueConfiguration.steps){case I.SIXTEEN:return 1;case I.HUNDRED:return 4;case I.COUNT:case I.TWOHUNDRED:return 8}}_ensureNoiseTexture(){if(null!=this._passParameters.noiseTexture)this._passParameters.noiseTexture.updateWeatherMap(this._passParameters.weatherTile);else{const e=this.context;this._passParameters.noiseTexture=new E({context:e}),this._passParameters.noiseTexture.updateWeatherMap(this._passParameters.weatherTile)}return null!=this._passParameters.noiseTexture.textureAtlas}_ensureFrameBufferCube(e){if(null==this._frameBufferCube){const t=new H(e);t.target=q.TEXTURE_CUBE_MAP,t.wrapMode=F.CLAMP_TO_EDGE,this._frameBufferCube=new R(this.context.renderContext.rctx,t)}return this._frameBufferCube}get cubeMap(){return this._frameBufferCube}destroyFrameBufferCube(){this._frameBufferCube=a(this._frameBufferCube)}applyPreset(e,t){const s=e.median,r=e=>{const r=i(e[0],e[1],s);return t<.5?i(e[0],r,2*t):i(r,e[1],2*(t-.5))};this.coverage=r(e.coverage),this.density=r(e.density),this.absorption=r(e.absorption),this.cloudSize=r(e.cloudSize),this.detailSize=r(e.detailSize),this.smoothness=r(e.smoothness),this.cloudHeight=r(e.cloudHeight),this.raymarchingSteps=e.raymarchingSteps}setDirty(){this._dirty=this.running=!0}runTask(e){0===this._faceIndex&&0===this._tileIndex&&(this._passParameters.raymarchingSteps=this.raymarchingSteps,this.updateWeatherTile(),f(this._passParameters.weatherTile,this._weatherTile));const t=this._getTechnique(this._passParameters.raymarchingSteps);if(!t.compiled)return U.YIELD;if(!this.context.renderContext.bindParameters.cloudsFade.isCameraPositionFinal||this.context.renderContext.bindParameters.cloudsFade.isFading||!this._ensureNoiseTexture())return U.YIELD;0===this._faceIndex&&0===this._tileIndex&&(this.context.renderContext.bindParameters.cloudsFade.renderingStage=b.RENDERING,this._passParameters.absorption=this.absorption,this._passParameters.density=this.density,this._passParameters.cloudSize=this.cloudSize,this._passParameters.detailSize=this.detailSize,this._passParameters.smoothness=this.smoothness,this._passParameters.cloudHeight=this.cloudHeight,this._passParameters.coverage=this.coverage,this._dirty=!1);const s=this.context.renderContext.rctx,i=s.bindTechnique(t,this._passParameters,this._bindParameters);s.bindVAO(this._vao),i.assertCompatibleVertexAttributeLocations(this._vao);const r=s.getViewport(),a=t.configuration.cubeMapSize,o=a/this._tilesPerFace,n=this._tileIndex*o;s.setViewport(0,n,a,o);const h=this._ensureFrameBufferCube(a);s.bindFramebuffer(h);const u=N[this._faceIndex],l=A[this._faceIndex];c(this._viewMatrix,O,u,l),d(this._drawParameters.viewMatrix,this._viewMatrix);const m=q.TEXTURE_CUBE_MAP_POSITIVE_X+this._faceIndex;return h.setColorTextureTarget(m),i.bindDraw(this._drawParameters,this._bindParameters,this._passParameters),s.gl.drawArrays(s.gl.TRIANGLE_STRIP,0,4),s.gl.flush(),s.setViewport(r.x,r.y,r.width,r.height),this.requestRender(),++this._tileIndex,4===this._faceIndex&&this._tileIndex===this._tilesPerFace?(this.running=this._dirty,this._faceIndex=0,this._tileIndex=0,this.context.renderContext.bindParameters.cloudsFade.renderingStage=b.FINISHED_RENDERING):this._tileIndex===this._tilesPerFace&&(++this._faceIndex,this._tileIndex=0),e.madeProgress(),U.YIELD}};e([u({constructOnly:!0})],B.prototype,"context",void 0),e([u({constructOnly:!0})],B.prototype,"view",void 0),e([u({constructOnly:!0})],B.prototype,"requestRender",void 0),e([u()],B.prototype,"coverage",void 0),e([u()],B.prototype,"density",void 0),e([u()],B.prototype,"absorption",void 0),e([u()],B.prototype,"cloudSize",void 0),e([u()],B.prototype,"detailSize",void 0),e([u()],B.prototype,"smoothness",void 0),e([u()],B.prototype,"cloudHeight",void 0),e([u()],B.prototype,"raymarchingSteps",void 0),e([u()],B.prototype,"running",void 0),B=e([l("esri.views.3d.environment.CloudsGenerator")],B);const N=[w(1,0,0),w(-1,0,0),w(0,1,0),w(0,-1,0),w(0,0,1)],A=[w(0,1,0),w(0,1,0),w(0,0,-1),w(0,0,1),w(0,1,0)],O=x();export{B as CloudsGenerator};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import s from"../../../core/Handles.js";import{lerp as i}from"../../../core/mathUtils.js";import{releaseMaybe as r,disposeMaybe as a,destroyMaybe as o}from"../../../core/maybe.js";import{watch as n,initial as h}from"../../../core/reactiveUtils.js";import{property as u}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{f as d}from"../../../chunks/mat3.js";import{v as c}from"../../../chunks/mat4.js";import{c as m}from"../../../chunks/mat4f64.js";import{s as p,o as _,j as f}from"../../../chunks/vec2.js";import{a as g}from"../../../chunks/vec2f64.js";import{f as w,z as x}from"../../../chunks/vec3f32.js";import{getReferenceEllipsoid as T}from"../../../geometry/ellipsoidUtils.js";import{C as y,a as v}from"../../../chunks/Clouds.glsl.js";import{CloudsTextureChannels as C,CloudsRenderingStages as b}from"./CloudsData.js";import{cloudPresets as P}from"./CloudsPresets.js";import{CloudsTechnique as S}from"./CloudsTechnique.js";import{CloudsTechniqueConfiguration as j,RayMarchingSteps as I}from"./CloudsTechniqueConfiguration.js";import{NoiseTextureAtlas as E}from"./NoiseTextureAtlas.js";import{BindParameters as D}from"../webgl-engine/lib/BindParameters.js";import{createQuadVAO as M}from"../webgl-engine/lib/glUtil3D.js";import{TaskPriority as z,Task as U}from"../../support/Scheduler.js";import{TextureType as q,TextureWrapMode as F}from"../../webgl/enums.js";import{FramebufferObject as R}from"../../webgl/FramebufferObject.js";import{TextureDescriptor as B}from"../../webgl/TextureDescriptor.js";let H=class extends t{constructor(e){super(e),this._handles=new s,this._techniques=new Array,this._techniqueConfiguration=new j,this._bindParameters=new D(null,null,null),this._passParameters=new y,this._drawParameters=new v,this._weatherTile=g(),this._weatherTileCount=128,this._faceIndex=0,this._tileIndex=0,this.coverage=i(P.default.coverage[0],P.default.coverage[1],.5),this.density=i(P.default.density[0],P.default.density[1],.5),this.absorption=i(P.default.absorption[0],P.default.absorption[1],.5),this.cloudSize=i(P.default.cloudSize[0],P.default.cloudSize[1],.5),this.detailSize=i(P.default.detailSize[0],P.default.detailSize[1],.5),this.smoothness=i(P.default.smoothness[0],P.default.smoothness[1],.5),this.cloudHeight=i(P.default.cloudHeight[0],P.default.cloudHeight[1],.5),this.raymarchingSteps=P.default.raymarchingSteps,this._viewMatrix=m(),this._dirty=!1,this.running=!1,this._vao=M(e.context.renderContext.rctx)}_getTechnique(e){const t=1-this.context.renderContext.bindParameters.cloudsFade.readChannels,s=t===C.RG?2*e:2*e+1,i=this._techniques[s];return i||(this._techniqueConfiguration.writeTextureChannels=t,this._techniqueConfiguration.steps=e,this._techniques[s]=new S({rctx:this.context.renderContext.rctx,viewingMode:this.view.state.viewingMode},this._techniqueConfiguration),this._techniques[s])}updateWeatherTile(){const e=this.view.camera.position.latitude,t=this.view.camera.position.longitude;if(null==e||null==t)return;p(this._weatherTile,(e+90)/180,(t+180)/360);const s=Math.floor(this._weatherTileCount*Math.abs(2*this._weatherTile[0]-1));this._weatherTile[0]=Math.floor(2*this._weatherTileCount*this._weatherTile[0]),this._weatherTile[1]=Math.floor(4*(this._weatherTileCount-s)*this._weatherTile[1]);let i=0,r=0;if(null!=this.view.environment&&"virtual"!==this.view.environment.lighting.type&&null!=this.view.environment.lighting.date){const e=new Date(this.view.environment.lighting.date);e.setUTCHours(this.view.environment.lighting.date.getUTCHours()+(this.view.environment.lighting.displayUTCOffset??0)),i=31*e.getUTCMonth()+e.getUTCDate(),r=e.getUTCFullYear()}this._weatherTile[0]=(this._weatherTile[0]+i)%(2*this._weatherTileCount),this._weatherTile[1]=(this._weatherTile[1]+r%100)%(4*this._weatherTileCount),_(this._passParameters.weatherTile,this._weatherTile)||this.setDirty()}initialize(){const e=T(this.view.spatialReference);this._passParameters.cloudRadius=.5*e.radius,this.setDirty(),this.updateWeatherTile(),this._handles.add([this.view.resourceController.scheduler.registerTask(z.CLOUDS_GENERATOR,this),n((()=>[this.coverage,this.density,this.absorption,this.cloudSize,this.detailSize,this.smoothness,this.cloudHeight,this.raymarchingSteps]),(()=>this.setDirty()),h)])}destroy(){this._handles.destroy(),this._techniques.forEach((e=>r(e))),this._frameBufferCube=a(this._frameBufferCube),this._techniques.length=0,this._vao.dispose(),this._passParameters.noiseTexture=o(this._passParameters.noiseTexture)}get _tilesPerFace(){switch(this._techniqueConfiguration.steps){case I.SIXTEEN:return 1;case I.HUNDRED:return 4;case I.COUNT:case I.TWOHUNDRED:return 8}}get usedMemory(){return(this._frameBufferCube?.gpuMemoryUsage??0)+(this._passParameters.noiseTexture?.textureAtlas?.gpuMemoryUsage??0)}_ensureNoiseTexture(){if(null!=this._passParameters.noiseTexture)this._passParameters.noiseTexture.updateWeatherMap(this._passParameters.weatherTile);else{const e=this.context;this._passParameters.noiseTexture=new E({context:e}),this._passParameters.noiseTexture.updateWeatherMap(this._passParameters.weatherTile)}return null!=this._passParameters.noiseTexture.textureAtlas}_ensureFrameBufferCube(e){if(null==this._frameBufferCube){const t=new B(e);t.target=q.TEXTURE_CUBE_MAP,t.wrapMode=F.CLAMP_TO_EDGE,this._frameBufferCube=new R(this.context.renderContext.rctx,t)}return this._frameBufferCube}get cubeMap(){return this._frameBufferCube}destroyFrameBufferCube(){this._frameBufferCube=a(this._frameBufferCube)}applyPreset(e,t){const s=e.median,r=e=>{const r=i(e[0],e[1],s);return t<.5?i(e[0],r,2*t):i(r,e[1],2*(t-.5))};this.coverage=r(e.coverage),this.density=r(e.density),this.absorption=r(e.absorption),this.cloudSize=r(e.cloudSize),this.detailSize=r(e.detailSize),this.smoothness=r(e.smoothness),this.cloudHeight=r(e.cloudHeight),this.raymarchingSteps=e.raymarchingSteps}setDirty(){this._dirty=this.running=!0}runTask(e){0===this._faceIndex&&0===this._tileIndex&&(this._passParameters.raymarchingSteps=this.raymarchingSteps,this.updateWeatherTile(),f(this._passParameters.weatherTile,this._weatherTile));const t=this._getTechnique(this._passParameters.raymarchingSteps);if(!t.compiled)return U.YIELD;if(!this.context.renderContext.bindParameters.cloudsFade.isCameraPositionFinal||this.context.renderContext.bindParameters.cloudsFade.isFading||!this._ensureNoiseTexture())return U.YIELD;0===this._faceIndex&&0===this._tileIndex&&(this.context.renderContext.bindParameters.cloudsFade.renderingStage=b.RENDERING,this._passParameters.absorption=this.absorption,this._passParameters.density=this.density,this._passParameters.cloudSize=this.cloudSize,this._passParameters.detailSize=this.detailSize,this._passParameters.smoothness=this.smoothness,this._passParameters.cloudHeight=this.cloudHeight,this._passParameters.coverage=this.coverage,this._dirty=!1);const s=this.context.renderContext.rctx,i=s.bindTechnique(t,this._passParameters,this._bindParameters);s.bindVAO(this._vao),i.assertCompatibleVertexAttributeLocations(this._vao);const r=s.getViewport(),a=t.configuration.cubeMapSize,o=a/this._tilesPerFace,n=this._tileIndex*o;s.setViewport(0,n,a,o);const h=this._ensureFrameBufferCube(a);s.bindFramebuffer(h);const u=N[this._faceIndex],l=A[this._faceIndex];c(this._viewMatrix,O,u,l),d(this._drawParameters.viewMatrix,this._viewMatrix);const m=q.TEXTURE_CUBE_MAP_POSITIVE_X+this._faceIndex;return h.setColorTextureTarget(m),i.bindDraw(this._drawParameters,this._bindParameters,this._passParameters),s.gl.drawArrays(s.gl.TRIANGLE_STRIP,0,4),s.gl.flush(),s.setViewport(r.x,r.y,r.width,r.height),this.requestRender(),++this._tileIndex,4===this._faceIndex&&this._tileIndex===this._tilesPerFace?(this.running=this._dirty,this._faceIndex=0,this._tileIndex=0,this.context.renderContext.bindParameters.cloudsFade.renderingStage=b.FINISHED_RENDERING):this._tileIndex===this._tilesPerFace&&(++this._faceIndex,this._tileIndex=0),e.madeProgress(),U.YIELD}};e([u({constructOnly:!0})],H.prototype,"context",void 0),e([u({constructOnly:!0})],H.prototype,"view",void 0),e([u({constructOnly:!0})],H.prototype,"requestRender",void 0),e([u()],H.prototype,"coverage",void 0),e([u()],H.prototype,"density",void 0),e([u()],H.prototype,"absorption",void 0),e([u()],H.prototype,"cloudSize",void 0),e([u()],H.prototype,"detailSize",void 0),e([u()],H.prototype,"smoothness",void 0),e([u()],H.prototype,"cloudHeight",void 0),e([u()],H.prototype,"raymarchingSteps",void 0),e([u()],H.prototype,"running",void 0),H=e([l("esri.views.3d.environment.CloudsGenerator")],H);const N=[w(1,0,0),w(-1,0,0),w(0,1,0),w(0,-1,0),w(0,0,1)],A=[w(0,1,0),w(0,1,0),w(0,0,-1),w(0,0,1),w(0,1,0)],O=x();export{H as CloudsGenerator};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{lerp as s}from"../../../core/mathUtils.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{watch as i,syncAndInitial as a,initial as o,sync as n}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{l as d,c as p,h as u}from"../../../chunks/vec3.js";import{f as m}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import{isMoon as _,isEarth as g,isMars as f}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as w}from"../../ViewingMode.js";import{AtmosphereType as y}from"./AtmosphereType.js";import{ChapmanAtmosphere as v}from"./ChapmanAtmosphere.js";import{CloudsComposition as P}from"./CloudsComposition.js";import{FadeInStages as b,FadeInOutStages as R}from"./CloudsCompositionParameters.js";import{isReadyCloudsData as x,CloudsRenderingStages as A}from"./CloudsData.js";import{CloudsGenerator as N}from"./CloudsGenerator.js";import{cloudPresets as C}from"./CloudsPresets.js";import{Fog as W,FogParameters as j}from"./Fog.js";import{LocalAtmosphere as E}from"./LocalAtmosphere.js";import F from"./MarsAtmosphere.js";import{Precipitation as O}from"./Precipitation.js";import{Stars as S}from"./Stars.js";import{weatherHeightLimit as M}from"./weather.js";import{updateWeatherFading as T,weatherFadingNeedsRender as z}from"./weatherUtils.js";import{ShaderOutput as I}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{RenderSlot as L}from"../webgl-engine/lib/RenderSlot.js";import{Update as U}from"../webgl-engine/lib/Update.js";var V;const k=[L.POSTPROCESSING_ENVIRONMENT_OPAQUE,L.POSTPROCESSING_ENVIRONMENT_TRANSPARENT];let q=V=class extends t{constructor(e){super(e),this._context=null,this._atmosphere=null,this._oldWeatherParameters=new G,this._newWeatherParameters=new G,this._fadedWeatherParameters=new G,this._weatherParameters=this._newWeatherParameters}initialize(){this.view._stage.addRenderPlugin(k,this)}destroy(){this.removeHandles(),this.uninitializeRenderContext(),null!=this.view?._stage&&this.view._stage.removeRenderPlugin(this),this._set("view",null)}get atmosphere(){return this._atmosphere}get _atmosphereType(){return null!=this.atmosphere?this.atmosphere.type:y.None}get canRender(){return!(null===this._atmosphere&&null===this._stars)}get needsLinearDepth(){return this._atmosphereType===y.Realistic}updateAnimation(e){return null!=this._precipitation&&this._precipitation.update(e)}get updating(){return null!=this._stars&&this._stars.updating||null!=this._clouds&&this._clouds.running}get weatherVisible(){return d(this.view.state.camera.eye)-c(this.view.spatialReference).radius<=M}get _stars(){const e=this.view,t=e.environment?.starsEnabled??!1,s=this._get("_stars");return t&&null!=this._context?null!=s?s:new S({view:e,requestRender:()=>this._setNeedsRender()}):(r(s),null)}get _precipitation(){const e=this._get("_precipitation");if(!this._precipitationEnabled||null==this._context)return r(e),null;const t=this.view,s=this._context;return null!=e&&e.context===s?e:(r(e),new O({context:s,view:t}))}get _clouds(){const e=this._get("_clouds");if(!this.weatherEnabled||null==this._context)return r(e),null;if(null!=e)return e;const t=this.view,s=this._context;return r(e),new N({context:s,view:t,requestRender:()=>this._setNeedsRender()})}get _cloudsComposition(){const e=this._get("_cloudsComposition");if(!this.weatherEnabled||null==this._context)return r(e),null;const t=this.view.state.viewingMode,s=this._context.renderContext.rctx,i=c(this.view.spatialReference).radius;return null!=e&&e.viewingMode===t&&e.planetRadius===i?e:(r(e),new P({rctx:s,viewingMode:t,planetRadius:i,requestRender:()=>this._setNeedsRender()}))}get _fog(){const e=this._get("_fog");if(!this.weatherEnabled||null==this._context)return r(e),null;if(null!=e)return e;const t=this.view,s=this._context,i=this._context.renderContext.rctx,a=this.view.state.viewingMode;return new W({context:s,view:t,rctx:i,viewingMode:a})}get weatherEnabled(){return!!this.view?.environmentManager?.weatherEnabled}get _precipitationEnabled(){return this.weatherEnabled&&("rainy"===this.view.environment.weather.type||"snowy"===this.view.environment.weather.type)}initializeRenderContext(e=null){this._context=e;const t=()=>this._setNeedsRender();this.addHandles([i((()=>({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled})),(e=>this._updateAtmosphere(e)),a),i((()=>this._stars),t),i((()=>this._precipitation),t),i((()=>this._clouds),(()=>this._updateWeather()),o),i((()=>this._fog),(()=>this._updateFogHaze()),o),i((()=>this.view.state.mode),(()=>{this._setNeedsRender()}),n),i((()=>this._weatherUpdateParameters),(()=>{this._updateWeather(),this._updateFogHaze()}),a)])}uninitializeRenderContext(){this._context=null,this._atmosphere=r(this._atmosphere),this._set("_stars",r(this._stars)),this._set("_precipitation",r(this._precipitation)),this._set("_clouds",r(this._clouds)),this._set("_cloudsComposition",r(this._cloudsComposition)),this._set("_fog",r(this._fog))}prepareRender(e){e.bindParameters.cloudsFade.data=x(this._clouds)?this._clouds:null,"local"!==this.view.viewingMode&&null!=e.bindParameters.cloudsFade.data?.cubeMap&&(T(e.bindParameters.cloudsFade,e.bindParameters.camera,this.view.state.mode,e.time,this.view.qualitySettings.fadeDuration),this._updateWeatherFading(e.bindParameters),e.bindParameters.cloudsFade.renderingStage===A.FINISHED&&null!=this._clouds&&0===this._clouds.coverage&&!1===this._clouds.running&&(this._clouds.destroyFrameBufferCube(),e.bindParameters.cloudsFade.data=null))}render(e){if(e.output===I.Color)switch(e.bindParameters.slot){case L.POSTPROCESSING_ENVIRONMENT_OPAQUE:null!=this._stars&&this._stars.render(e),null!=this.atmosphere&&(this.atmosphere.render(e,this.view?._stage?.renderer?.fullResolutionAtmosphere),null!=this._cloudsComposition&&null!=e.bindParameters.cloudsFade.data&&(this.weatherVisible&&null!=this._clouds&&this._clouds.updateWeatherTile(),this._cloudsComposition.render(e)),z(e.bindParameters.cloudsFade)&&null!=this._context&&null!=e.bindParameters.cloudsFade.data?.cubeMap&&this._context.requestRender());break;case L.POSTPROCESSING_ENVIRONMENT_TRANSPARENT:if(null!=this.atmosphere&&(this.atmosphere.renderHaze(e,this._weatherParameters.hazeAmount,this.view?._stage?.renderer?.fullResolutionAtmosphere),this._weatherParameters.fog.amount>0&&null!=this._fog&&this._fog.render(e,this._weatherParameters.fog),null!=this._precipitation)){const t=this.view.environment.weather;"rainy"!==t.type&&"snowy"!==t.type||this._precipitation.render(e,t.precipitation,t.type)}}}updateLightSources(e,t,s,r){if(null!=this._context){const i=this._context.renderContext;i.bindParameters.oldLighting.copyFrom(i.bindParameters.lighting),i.bindParameters.newLighting.noonFactor=t,i.bindParameters.newLighting.globalFactor=s,i.bindParameters.newLighting.set(e);r===U.Faded||i.bindParameters.weatherFading?i.bindParameters.fadeLighting(0):i.bindParameters.fadeLighting(1),this._context.requestRender()}}get _weatherUpdateParameters(){const e=this.weatherEnabled?this.view.environment.weather:null;return null==e?null:"rainy"===e.type||"snowy"===e.type?{type:e.type,weatherAdjustment:e.cloudCover,effect:e.precipitation}:{type:e.type,weatherAdjustment:"foggy"===e.type?e.fogStrength:e.cloudCover}}_updateWeatherFading(e){if(!e.weatherFading)return;const t=e.cloudsFade;return t.fadeIn.stage===b.FADE_IN?(e.fadeLighting(t.fadeIn.factor),void this._fadeWeather(t.fadeIn.factor)):t.fadeInOut.stage===R.FADE_IN?(e.fadeLighting(t.fadeInOut.factor),void this._fadeWeather(t.fadeInOut.factor)):t.crossFade.enabled?(e.fadeLighting(t.crossFade.factor),void this._fadeWeather(t.crossFade.factor)):(e.fadeLighting(0),void this._fadeWeather(0))}_fadeWeather(e){const{_newWeatherParameters:t,_oldWeatherParameters:s}=this;e>=1?this._weatherParameters=t:(this._fadedWeatherParameters.lerp(s,t,e),this._weatherParameters=this._fadedWeatherParameters)}_updateWeather(){const e=this._weatherUpdateParameters;null!=e&&null!=this._clouds&&(this._clouds.applyPreset(C[e.type],e.weatherAdjustment),this._setNeedsRender())}_setNeedsRender(){null!=this._context&&this._context.requestRender()}_updateFogHaze(){const e=this._weatherUpdateParameters;if(null==this._fog||null==e||null==this._context)return;const t=this._context.renderContext.bindParameters;switch(this._oldWeatherParameters.copyFrom(this._weatherParameters),e.type){case"foggy":this._newWeatherParameters.fog.strength=s(3e-5,.005,e.weatherAdjustment**3),p(this._newWeatherParameters.fog.color,D),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender();break;case"rainy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),p(this._newWeatherParameters.fog.color,H),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=0,this._setNeedsRender();break;case"snowy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),p(this._newWeatherParameters.fog.color,D),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender();break;default:this._newWeatherParameters.fog.strength=0,this._newWeatherParameters.fog.amount=0,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender()}t.weatherFading?this._fadeWeather(0):this._fadeWeather(1)}_updateAtmosphere(e){const t=this._selectAtmosphereType(e);if(t!==y.None&&this._context){if(!this._atmosphere||this._atmosphere.type!==t){this._atmosphere=r(this._atmosphere);const e=this._getAtmosphereClass(t);e&&(this._atmosphere=new e(this.view,this._context))}}else this._atmosphere=r(this._atmosphere);this._setNeedsRender()}_getAtmosphereClass(e){switch(e){case y.Realistic:return v;case y.Local:return E;case y.Mars:return F;default:case y.None:return null}}_selectAtmosphereType(e){const{enabled:t,viewingMode:s}=e;return!t||_(this.view.spatialReference)?y.None:s===w.Local?y.Local:null!=this._context&&v.isSupported(this._context)&&g(this.view.spatialReference)?y.Realistic:f(this.view.spatialReference)?y.Mars:y.None}get test(){return{atmosphere:this._atmosphere,clouds:this._clouds,selectAtmosphereType:()=>this._selectAtmosphereType({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled}),stubGetAtmosphereClass:e=>{B=V.prototype._getAtmosphereClass,V.prototype._getAtmosphereClass=e},restoreGetAtmosphereClass:()=>{V.prototype._getAtmosphereClass=B}}}};e([h({constructOnly:!0})],q.prototype,"view",void 0),e([h({readOnly:!0})],q.prototype,"atmosphere",null),e([h({readOnly:!0})],q.prototype,"_atmosphereType",null),e([h({type:Boolean,readOnly:!0})],q.prototype,"updating",null),e([h({readOnly:!0})],q.prototype,"weatherVisible",null),e([h()],q.prototype,"_context",void 0),e([h()],q.prototype,"_atmosphere",void 0),e([h({readOnly:!0})],q.prototype,"_stars",null),e([h({readOnly:!0})],q.prototype,"_precipitation",null),e([h({readOnly:!0})],q.prototype,"_clouds",null),e([h({readOnly:!0})],q.prototype,"_cloudsComposition",null),e([h({readOnly:!0})],q.prototype,"_fog",null),e([h({readOnly:!0})],q.prototype,"weatherEnabled",null),e([h({readOnly:!0})],q.prototype,"_precipitationEnabled",null),e([h({readOnly:!0})],q.prototype,"_weatherUpdateParameters",null),q=V=e([l("esri.views.3d.environment.EnvironmentRenderer")],q);class G{constructor(){this.fog=new j,this.hazeAmount=1}copyFrom(e){this.fog.amount=e.fog.amount,this.hazeAmount=e.hazeAmount,this.fog.strength=e.fog.strength,p(this.fog.color,e.fog.color)}lerp(e,t,r){this.fog.amount=s(e.fog.amount,t.fog.amount,r),this.hazeAmount=s(e.hazeAmount,t.hazeAmount,r),this.fog.strength=s(e.fog.strength,t.fog.strength,r),u(this.fog.color,e.fog.color,t.fog.color,r)}}const H=m(.5,.5,.5),D=m(1.5,1.5,1.5);let B;export{q as EnvironmentRenderer,G as WeatherParameters};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{lerp as s}from"../../../core/mathUtils.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{watch as i,syncAndInitial as a,initial as o,sync as n}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{l as d,c as p,h as u}from"../../../chunks/vec3.js";import{f as m}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import{isMoon as _,isEarth as g,isMars as f}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as w}from"../../ViewingMode.js";import{AtmosphereType as y}from"./AtmosphereType.js";import{ChapmanAtmosphere as v}from"./ChapmanAtmosphere.js";import{CloudsComposition as P}from"./CloudsComposition.js";import{FadeInStages as b,FadeInOutStages as R}from"./CloudsCompositionParameters.js";import{isReadyCloudsData as x,CloudsRenderingStages as A}from"./CloudsData.js";import{CloudsGenerator as N}from"./CloudsGenerator.js";import{cloudPresets as C}from"./CloudsPresets.js";import{Fog as W,FogParameters as j}from"./Fog.js";import{LocalAtmosphere as E}from"./LocalAtmosphere.js";import F from"./MarsAtmosphere.js";import{Precipitation as O}from"./Precipitation.js";import{Stars as S}from"./Stars.js";import{weatherHeightLimit as M}from"./weather.js";import{updateWeatherFading as T,weatherFadingNeedsRender as z}from"./weatherUtils.js";import{ShaderOutput as I}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{RenderSlot as L}from"../webgl-engine/lib/RenderSlot.js";import{Update as U}from"../webgl-engine/lib/Update.js";var V;const k=[L.POSTPROCESSING_ENVIRONMENT_OPAQUE,L.POSTPROCESSING_ENVIRONMENT_TRANSPARENT];let q=V=class extends t{constructor(e){super(e),this._context=null,this._atmosphere=null,this._oldWeatherParameters=new G,this._newWeatherParameters=new G,this._fadedWeatherParameters=new G,this._weatherParameters=this._newWeatherParameters}initialize(){this.view._stage.addRenderPlugin(k,this)}destroy(){this.removeHandles(),this.uninitializeRenderContext(),null!=this.view?._stage&&this.view._stage.removeRenderPlugin(this),this._set("view",null)}get atmosphere(){return this._atmosphere}get _atmosphereType(){return null!=this.atmosphere?this.atmosphere.type:y.None}get canRender(){return!(null===this._atmosphere&&null===this._stars)}get needsLinearDepth(){return this._atmosphereType===y.Realistic}updateAnimation(e){return null!=this._precipitation&&this._precipitation.update(e)}get updating(){return null!=this._stars&&this._stars.updating||null!=this._clouds&&this._clouds.running}get weatherVisible(){return d(this.view.state.camera.eye)-c(this.view.spatialReference).radius<=M}get usedMemory(){return this._clouds?.usedMemory??0}get _stars(){const e=this.view,t=e.environment?.starsEnabled??!1,s=this._get("_stars");return t&&null!=this._context?null!=s?s:new S({view:e,requestRender:()=>this._setNeedsRender()}):(r(s),null)}get _precipitation(){const e=this._get("_precipitation");if(!this._precipitationEnabled||null==this._context)return r(e),null;const t=this.view,s=this._context;return null!=e&&e.context===s?e:(r(e),new O({context:s,view:t}))}get _clouds(){const e=this._get("_clouds");if(!this.weatherEnabled||null==this._context)return r(e),null;if(null!=e)return e;const t=this.view,s=this._context;return r(e),new N({context:s,view:t,requestRender:()=>this._setNeedsRender()})}get _cloudsComposition(){const e=this._get("_cloudsComposition");if(!this.weatherEnabled||null==this._context)return r(e),null;const t=this.view.state.viewingMode,s=this._context.renderContext.rctx,i=c(this.view.spatialReference).radius;return null!=e&&e.viewingMode===t&&e.planetRadius===i?e:(r(e),new P({rctx:s,viewingMode:t,planetRadius:i,requestRender:()=>this._setNeedsRender()}))}get _fog(){const e=this._get("_fog");if(!this.weatherEnabled||null==this._context)return r(e),null;if(null!=e)return e;const t=this.view,s=this._context,i=this._context.renderContext.rctx,a=this.view.state.viewingMode;return new W({context:s,view:t,rctx:i,viewingMode:a})}get weatherEnabled(){return!!this.view?.environmentManager?.weatherEnabled}get _precipitationEnabled(){return this.weatherEnabled&&("rainy"===this.view.environment.weather.type||"snowy"===this.view.environment.weather.type)}initializeRenderContext(e=null){this._context=e;const t=()=>this._setNeedsRender();this.addHandles([i((()=>({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled})),(e=>this._updateAtmosphere(e)),a),i((()=>this._stars),t),i((()=>this._precipitation),t),i((()=>this._clouds),(()=>this._updateWeather()),o),i((()=>this._fog),(()=>this._updateFogHaze()),o),i((()=>this.view.state.mode),(()=>{this._setNeedsRender()}),n),i((()=>this._weatherUpdateParameters),(()=>{this._updateWeather(),this._updateFogHaze()}),a)])}uninitializeRenderContext(){this._context=null,this._atmosphere=r(this._atmosphere),this._set("_stars",r(this._stars)),this._set("_precipitation",r(this._precipitation)),this._set("_clouds",r(this._clouds)),this._set("_cloudsComposition",r(this._cloudsComposition)),this._set("_fog",r(this._fog))}prepareRender(e){e.bindParameters.cloudsFade.data=x(this._clouds)?this._clouds:null,"local"!==this.view.viewingMode&&null!=e.bindParameters.cloudsFade.data?.cubeMap&&(T(e.bindParameters.cloudsFade,e.bindParameters.camera,this.view.state.mode,e.time,this.view.qualitySettings.fadeDuration),this._updateWeatherFading(e.bindParameters),e.bindParameters.cloudsFade.renderingStage===A.FINISHED&&null!=this._clouds&&0===this._clouds.coverage&&!1===this._clouds.running&&(this._clouds.destroyFrameBufferCube(),e.bindParameters.cloudsFade.data=null))}render(e){if(e.output===I.Color)switch(e.bindParameters.slot){case L.POSTPROCESSING_ENVIRONMENT_OPAQUE:null!=this._stars&&this._stars.render(e),null!=this.atmosphere&&(this.atmosphere.render(e,this.view?._stage?.renderer?.fullResolutionAtmosphere),null!=this._cloudsComposition&&null!=e.bindParameters.cloudsFade.data&&(this.weatherVisible&&null!=this._clouds&&this._clouds.updateWeatherTile(),this._cloudsComposition.render(e)),z(e.bindParameters.cloudsFade)&&null!=this._context&&null!=e.bindParameters.cloudsFade.data?.cubeMap&&this._context.requestRender());break;case L.POSTPROCESSING_ENVIRONMENT_TRANSPARENT:if(null!=this.atmosphere&&(this.atmosphere.renderHaze(e,this._weatherParameters.hazeAmount,this.view?._stage?.renderer?.fullResolutionAtmosphere),this._weatherParameters.fog.amount>0&&null!=this._fog&&this._fog.render(e,this._weatherParameters.fog),null!=this._precipitation)){const t=this.view.environment.weather;"rainy"!==t.type&&"snowy"!==t.type||this._precipitation.render(e,t.precipitation,t.type)}}}updateLightSources(e,t,s,r){if(null!=this._context){const i=this._context.renderContext;i.bindParameters.oldLighting.copyFrom(i.bindParameters.lighting),i.bindParameters.newLighting.noonFactor=t,i.bindParameters.newLighting.globalFactor=s,i.bindParameters.newLighting.set(e);r===U.Faded||i.bindParameters.weatherFading?i.bindParameters.fadeLighting(0):i.bindParameters.fadeLighting(1),this._context.requestRender()}}get _weatherUpdateParameters(){const e=this.weatherEnabled?this.view.environment.weather:null;return null==e?null:"rainy"===e.type||"snowy"===e.type?{type:e.type,weatherAdjustment:e.cloudCover,effect:e.precipitation}:{type:e.type,weatherAdjustment:"foggy"===e.type?e.fogStrength:e.cloudCover}}_updateWeatherFading(e){if(!e.weatherFading)return;const t=e.cloudsFade;return t.fadeIn.stage===b.FADE_IN?(e.fadeLighting(t.fadeIn.factor),void this._fadeWeather(t.fadeIn.factor)):t.fadeInOut.stage===R.FADE_IN?(e.fadeLighting(t.fadeInOut.factor),void this._fadeWeather(t.fadeInOut.factor)):t.crossFade.enabled?(e.fadeLighting(t.crossFade.factor),void this._fadeWeather(t.crossFade.factor)):(e.fadeLighting(0),void this._fadeWeather(0))}_fadeWeather(e){const{_newWeatherParameters:t,_oldWeatherParameters:s}=this;e>=1?this._weatherParameters=t:(this._fadedWeatherParameters.lerp(s,t,e),this._weatherParameters=this._fadedWeatherParameters)}_updateWeather(){const e=this._weatherUpdateParameters;null!=e&&null!=this._clouds&&(this._clouds.applyPreset(C[e.type],e.weatherAdjustment),this._setNeedsRender())}_setNeedsRender(){null!=this._context&&this._context.requestRender()}_updateFogHaze(){const e=this._weatherUpdateParameters;if(null==this._fog||null==e||null==this._context)return;const t=this._context.renderContext.bindParameters;switch(this._oldWeatherParameters.copyFrom(this._weatherParameters),e.type){case"foggy":this._newWeatherParameters.fog.strength=s(3e-5,.005,e.weatherAdjustment**3),p(this._newWeatherParameters.fog.color,D),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender();break;case"rainy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),p(this._newWeatherParameters.fog.color,H),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=0,this._setNeedsRender();break;case"snowy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),p(this._newWeatherParameters.fog.color,D),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender();break;default:this._newWeatherParameters.fog.strength=0,this._newWeatherParameters.fog.amount=0,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender()}t.weatherFading?this._fadeWeather(0):this._fadeWeather(1)}_updateAtmosphere(e){const t=this._selectAtmosphereType(e);if(t!==y.None&&this._context){if(!this._atmosphere||this._atmosphere.type!==t){this._atmosphere=r(this._atmosphere);const e=this._getAtmosphereClass(t);e&&(this._atmosphere=new e(this.view,this._context))}}else this._atmosphere=r(this._atmosphere);this._setNeedsRender()}_getAtmosphereClass(e){switch(e){case y.Realistic:return v;case y.Local:return E;case y.Mars:return F;default:case y.None:return null}}_selectAtmosphereType(e){const{enabled:t,viewingMode:s}=e;return!t||_(this.view.spatialReference)?y.None:s===w.Local?y.Local:null!=this._context&&v.isSupported(this._context)&&g(this.view.spatialReference)?y.Realistic:f(this.view.spatialReference)?y.Mars:y.None}get test(){return{atmosphere:this._atmosphere,clouds:this._clouds,selectAtmosphereType:()=>this._selectAtmosphereType({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled}),stubGetAtmosphereClass:e=>{B=V.prototype._getAtmosphereClass,V.prototype._getAtmosphereClass=e},restoreGetAtmosphereClass:()=>{V.prototype._getAtmosphereClass=B}}}};e([h({constructOnly:!0})],q.prototype,"view",void 0),e([h({readOnly:!0})],q.prototype,"atmosphere",null),e([h({readOnly:!0})],q.prototype,"_atmosphereType",null),e([h({type:Boolean,readOnly:!0})],q.prototype,"updating",null),e([h({readOnly:!0})],q.prototype,"weatherVisible",null),e([h()],q.prototype,"_context",void 0),e([h()],q.prototype,"_atmosphere",void 0),e([h({readOnly:!0})],q.prototype,"_stars",null),e([h({readOnly:!0})],q.prototype,"_precipitation",null),e([h({readOnly:!0})],q.prototype,"_clouds",null),e([h({readOnly:!0})],q.prototype,"_cloudsComposition",null),e([h({readOnly:!0})],q.prototype,"_fog",null),e([h({readOnly:!0})],q.prototype,"weatherEnabled",null),e([h({readOnly:!0})],q.prototype,"_precipitationEnabled",null),e([h({readOnly:!0})],q.prototype,"_weatherUpdateParameters",null),q=V=e([l("esri.views.3d.environment.EnvironmentRenderer")],q);class G{constructor(){this.fog=new j,this.hazeAmount=1}copyFrom(e){this.fog.amount=e.fog.amount,this.hazeAmount=e.hazeAmount,this.fog.strength=e.fog.strength,p(this.fog.color,e.fog.color)}lerp(e,t,r){this.fog.amount=s(e.fog.amount,t.fog.amount,r),this.hazeAmount=s(e.hazeAmount,t.hazeAmount,r),this.fog.strength=s(e.fog.strength,t.fog.strength,r),u(this.fog.color,e.fog.color,t.fog.color,r)}}const H=m(.5,.5,.5),D=m(1.5,1.5,1.5);let B;export{q as EnvironmentRenderer,G as WeatherParameters};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{lerp as i}from"../../../core/mathUtils.js";import{releaseMaybe as r,disposeMaybe as s}from"../../../core/maybe.js";import{secondsFromMilliseconds as n}from"../../../core/time.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as c}from"../../../core/support/WatchUpdatingTracking.js";import{getReferenceEllipsoid as u}from"../../../geometry/ellipsoidUtils.js";import{PrecipitationPassParameters as h,PrecipitationTechnique as p,attributeLocations as m}from"./PrecipitationTechnique.js";import{PrecipitationTechniqueConfiguration as d,PrecipitationType as _}from"./PrecipitationTechniqueConfiguration.js";import{glLayout as l}from"../support/buffer/glUtil.js";import{newLayout as f}from"../support/buffer/InterleavedLayout.js";import{AnimationTimer as T}from"../webgl-engine/lib/AnimationTimer.js";import{VertexArrayObject as y}from"../webgl-engine/lib/VertexArrayObject.js";import{VertexAttribute as g}from"../webgl-engine/lib/VertexAttribute.js";import{BufferObject as w}from"../../webgl/BufferObject.js";import{PrimitiveType as b,Usage as j}from"../../webgl/enums.js";import{bindVertexBufferLayout as q,unbindVertexBufferLayout as I}from"../../webgl/Util.js";let A=class extends t{constructor(e){super(e),this._numParticles=25e4,this._rainSpeed=.1,this._snowSpeed=.01,this._passParameters=new h,this._animation=new T,this._updatingTracking=new c,this._passParameters.time=0,this._passParameters.radius=u(e.view.spatialReference).radius,this._techniqueRepository=e.context.techniqueRepository}destroy(){this._updatingTracking.destroy(),this._numParticles=0,this._snowTechniqueCached=r(this._snowTechniqueCached),this._rainTechniqueCached=r(this._rainTechniqueCached),this._vao=s(this._vao),this._instanceIdBuffer=s(this._instanceIdBuffer)}get updating(){return this._updatingTracking.updating}get _rainTechnique(){if(null==this._rainTechniqueCached){const e=new d;e.type=_.Rain,this._rainTechniqueCached=this._techniqueRepository.acquire(p,e)}return this._rainTechniqueCached}get _snowTechnique(){if(null==this._snowTechniqueCached){const e=new d;e.type=_.Snow,this._snowTechniqueCached=this._techniqueRepository.acquire(p,e)}return this._snowTechniqueCached}update(e){return this._animation.advance(e)}render(e,t,r){const s="rainy"===r?this._rainTechnique:this._snowTechnique;if(!s.compiled)return void this.context.requestRender();const o=e.rctx;if(this._ensureResources(o),null==s||null==this._vao||null==this._instanceIdBuffer)return;if(null!=e.bindParameters.cloudsFade.data&&(this._passParameters.opacity=1-e.bindParameters.cloudsFade.fadeInOutHeight.factor),this._passParameters.opacity<=0)return;const a=.35;t=t<.5?i(0,a,2*t):i(a,1,2*(t-.5)),this._passParameters.time=("rainy"===r?this._rainSpeed:this._snowSpeed)*n(this._animation.time)%1e5;const c=o.bindTechnique(s,this._passParameters,e.bindParameters);o.bindVAO(this._vao),c.assertCompatibleVertexAttributeLocations(this._vao),q(o,m,this._instanceIdBuffer,P,0),o.capabilities.instancing?.drawArraysInstanced(b.TRIANGLES,0,3,this._numParticles*t),I(o,m,this._instanceIdBuffer,P)}_ensureResources(e){null==this._vao&&(this._vao=this._createVertexArrayObject(e)),null==this._instanceIdBuffer&&(this._instanceIdBuffer=this._createInstanceIndices(e))}_createInstanceIndices(e){const t=[];for(let i=0;i<this._numParticles;i++)t.push(i);return w.createVertex(e,j.STATIC_DRAW,new Float32Array(t))}_createVertexArrayObject(e){const t=new Float32Array([-1,0,1,1,0,-1,1,0,1]);return new y(e,m,{geometry:l(v)},{geometry:w.createVertex(e,j.STATIC_DRAW,t)})}};e([o({constructOnly:!0})],A.prototype,"context",void 0),e([o({constructOnly:!0})],A.prototype,"view",void 0),e([o({readOnly:!0})],A.prototype,"updating",null),e([o()],A.prototype,"_updatingTracking",void 0),A=e([a("esri.views.3d.environment.Precipitation")],A);const v=f().vec3f(g.POSITION),P=l(f().f32(g.INSTANCEFEATUREATTRIBUTE),1);export{A as Precipitation};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{lerp as i}from"../../../core/mathUtils.js";import{releaseMaybe as r,disposeMaybe as s}from"../../../core/maybe.js";import{secondsFromMilliseconds as n}from"../../../core/time.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as c}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as u}from"../../../geometry/ellipsoidUtils.js";import{PrecipitationPassParameters as h,PrecipitationTechnique as p,attributeLocations as m}from"./PrecipitationTechnique.js";import{PrecipitationTechniqueConfiguration as d,PrecipitationType as _}from"./PrecipitationTechniqueConfiguration.js";import{glLayout as l}from"../support/buffer/glUtil.js";import{newLayout as f}from"../support/buffer/InterleavedLayout.js";import{AnimationTimer as T}from"../webgl-engine/lib/AnimationTimer.js";import{VertexArrayObject as y}from"../webgl-engine/lib/VertexArrayObject.js";import{VertexAttribute as g}from"../webgl-engine/lib/VertexAttribute.js";import{BufferObject as w}from"../../webgl/BufferObject.js";import{PrimitiveType as b,Usage as j}from"../../webgl/enums.js";import{bindVertexBufferLayout as q,unbindVertexBufferLayout as I}from"../../webgl/Util.js";let A=class extends t{constructor(e){super(e),this._numParticles=25e4,this._rainSpeed=.1,this._snowSpeed=.01,this._passParameters=new h,this._animation=new T,this._updatingTracking=new c,this._passParameters.time=0,this._passParameters.radius=u(e.view.spatialReference).radius,this._techniqueRepository=e.context.techniqueRepository}destroy(){this._updatingTracking.destroy(),this._numParticles=0,this._snowTechniqueCached=r(this._snowTechniqueCached),this._rainTechniqueCached=r(this._rainTechniqueCached),this._vao=s(this._vao),this._instanceIdBuffer=s(this._instanceIdBuffer)}get updating(){return this._updatingTracking.updating}get _rainTechnique(){if(null==this._rainTechniqueCached){const e=new d;e.type=_.Rain,this._rainTechniqueCached=this._techniqueRepository.acquire(p,e)}return this._rainTechniqueCached}get _snowTechnique(){if(null==this._snowTechniqueCached){const e=new d;e.type=_.Snow,this._snowTechniqueCached=this._techniqueRepository.acquire(p,e)}return this._snowTechniqueCached}update(e){return this._animation.advance(e)}render(e,t,r){const s="rainy"===r?this._rainTechnique:this._snowTechnique;if(!s.compiled)return void this.context.requestRender();const o=e.rctx;if(this._ensureResources(o),null==s||null==this._vao||null==this._instanceIdBuffer)return;if(null!=e.bindParameters.cloudsFade.data&&(this._passParameters.opacity=1-e.bindParameters.cloudsFade.fadeInOutHeight.factor),this._passParameters.opacity<=0)return;const a=.35;t=t<.5?i(0,a,2*t):i(a,1,2*(t-.5)),this._passParameters.time=("rainy"===r?this._rainSpeed:this._snowSpeed)*n(this._animation.time)%1e5;const c=o.bindTechnique(s,this._passParameters,e.bindParameters);o.bindVAO(this._vao),c.assertCompatibleVertexAttributeLocations(this._vao),q(o,m,this._instanceIdBuffer,P,0),o.capabilities.instancing?.drawArraysInstanced(b.TRIANGLES,0,3,this._numParticles*t),I(o,m,this._instanceIdBuffer,P)}_ensureResources(e){null==this._vao&&(this._vao=this._createVertexArrayObject(e)),null==this._instanceIdBuffer&&(this._instanceIdBuffer=this._createInstanceIndices(e))}_createInstanceIndices(e){const t=[];for(let i=0;i<this._numParticles;i++)t.push(i);return w.createVertex(e,j.STATIC_DRAW,new Float32Array(t))}_createVertexArrayObject(e){const t=new Float32Array([-1,0,1,1,0,-1,1,0,1]);return new y(e,m,{geometry:l(v)},{geometry:w.createVertex(e,j.STATIC_DRAW,t)})}};e([o({constructOnly:!0})],A.prototype,"context",void 0),e([o({constructOnly:!0})],A.prototype,"view",void 0),e([o({readOnly:!0})],A.prototype,"updating",null),e([o()],A.prototype,"_updatingTracking",void 0),A=e([a("esri.views.3d.environment.Precipitation")],A);const v=f().vec3f(g.POSITION),P=l(f().f32(g.INSTANCEFEATUREATTRIBUTE),1);export{A as Precipitation};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import r from"../../../core/Evented.js";import i from"../../../core/Handles.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{after as n}from"../../../core/promiseUtils.js";import{watch as o,sync as a,syncAndInitial as h}from"../../../core/reactiveUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{s as d,g as p,c as _,h as u}from"../../../chunks/vec3.js";import{c as m,f}from"../../../chunks/vec3f64.js";import{b as g,f as P}from"../../../chunks/vec4f64.js";import{canProjectToWGS84ComparableLonLat as v,projectPointToWGS84ComparableLonLat as b}from"../../../geometry/projection.js";import{isEarth as w}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as C}from"../../ViewingMode.js";import{EnvironmentRenderer as y}from"./EnvironmentRenderer.js";import{positionToTimezoneInfo as U}from"../support/earthUtils.js";import{computeColorAndIntensity as S,computeVirtualLightDirection as T,computeShadowsEnabled as R,ColorAndIntensity as M}from"../support/sunUtils.js";import{Update as W}from"../webgl-engine/lib/Update.js";import{MainLight as H,AmbientLight as G,FillLight as j}from"../webgl-engine/lighting/Lightsources.js";import L from"../../../webscene/background/ColorBackground.js";let k=class extends r.EventedAccessor{constructor(){super(),this._referencePointUpdateDelay=200,this._referencePointUpdateInterval=3e3,this._referencePointUpdateDistThreshold=1e6,this._referencePosUpdateQuery=null,this._referencePosMapCoordsRequested=null,this._viewHandles=new i,this._preserveAbsoluteDateTime=!1,this._trackingEnabled=!1,this._referencePosResetPreserveAbsoluteTime=!1,this._referencePosUpdateTimer=null,this._referencePosMapCoords=null,this._mainLight=new H,this._ambientLight=new G,this._moonLight=new j,this.disableQueries=!1,this._disableWeather=!1,this._renderer=null,this._referencePosWGS84Comparable=null,this._resetReferencePosition()}destroy(){this.disconnectView(),this._viewHandles.destroy()}get _view(){return this._renderer?.view}get updating(){return!((this.disableQueries||!this._referencePosUpdateQuery&&!this._referencePosMapCoordsRequested)&&!this._renderer?.updating)}get weatherEnabled(){return this._view?.environment.atmosphereEnabled&&!this._disableWeather&&this._view?.state?.viewingMode===C.Global&&w(this._view.spatialReference)}get weatherVisible(){return this.weatherEnabled&&this._renderer?.weatherVisible}get referencePositionWGS84Comparable(){return this._referencePosWGS84Comparable}connectView(e){if(this._renderer)return;this._renderer=new y({view:e});const t=()=>this._updateRenderParameters(),r=()=>this._cameraHandler();this._viewHandles.add([o((()=>e.environment.lighting),(e=>this._updateLightingHandler(e)),a),o((()=>"virtual"!==e.environment.lighting.type?e.environment.lighting.date:null),(e=>this._lightingDateHandler(e)),a),o((()=>e.stationary),(()=>this._interactingStationaryHandler())),o((()=>e.environment.lighting.directShadowsEnabled),t,a),o((()=>e.qualitySettings.ambientOcclusion),t,a),o((()=>e.qualitySettings.reflections),t,a),o((()=>e.environment.background?.color),t,a),o((()=>e.spatialReference),(()=>this._resetReferencePosition(!0)),a),o((()=>e.environment.weather.type),(()=>this._updateLighting(null,W.Faded)),a),o((()=>this.weatherEnabled),(()=>this._updateLighting(null,W.Faded)),a),o((()=>e.viewingMode),(()=>this._resetReferencePosition(!0)),h),o((()=>"virtual"!==e.environment.lighting.type&&e.environment.lighting.cameraTrackingEnabled),(e=>this._updateCameraTracking(e)),h),o((()=>e.state.camera),r,h),o((()=>this.disableQueries),r)]),this._updateRenderParameters(),this._updateLighting(),this._cameraHandler(),this.notifyChange("updating")}disconnectView(){this._viewHandles.removeAll(),this._resetReferencePosition(),this._renderer=s(this._renderer)}_updateLightingHandler(e){this._updateCameraTracking("virtual"!==e.type&&e.cameraTrackingEnabled),this._lightingDateHandler("virtual"!==e.type?e.date:null),this._updateRenderParameters()}_updateCameraTracking(e){if(this._trackingEnabled=e,e)this._cameraHandler();else{const e=this._view.environment.lighting;"virtual"!==e?.type&&(e.positionTimezoneInfo.autoUpdated=!1)}}_lightingDateHandler(e){const t=this._view.environment.lighting;if("virtual"!==t?.type){if(e){if(!t.positionTimezoneInfo.autoUpdated){this._preserveAbsoluteDateTime=!0;const r=this._view.spatialReference;if(!v(r)){const e=this._view.camera.position;if(!this._referencePosMapCoords||!this._referencePosMapCoords.equals(e))return void this._requestReferencePositionUpdate(e)}if(this._preupdateTracking(e),null!=this._referencePosWGS84Comparable){const e=U(this._referencePosWGS84Comparable,D);null!=e&&(t.autoUpdate(null,e),this._trackingEnabled&&(t.positionTimezoneInfo.autoUpdated=!0))}}this._updateLighting(e)}}else this._updateLighting()}_preupdateTracking(e){!this._trackingEnabled&&"virtual"!==this._view.environment.lighting.type&&this._view.environment.lighting.cameraTrackingEnabled&&this._cameraHandler(e)}_cameraHandler(e=null){const t=this._view;if(!t.ready)return;const r=t.stateManager.camera;r&&(this._cameraHandlerClientSide(r,e)||this._cameraHandlerServerSide(r))}_cameraHandlerClientSide(e,t){const r=w(this._view.spatialReference);if(r&&!v(this._view.spatialReference))return"virtual"===this._view.environment.lighting.type&&this._updateLighting(),!1;const i=e.position;return null==this._referencePosWGS84Comparable&&(this._referencePosWGS84Comparable=m()),r?b(i,this._referencePosWGS84Comparable):d(this._referencePosWGS84Comparable,i.longitude??0,i.latitude??0,i.z??0),this.notifyChange("referencePositionWGS84Comparable"),this._autoUpdateTimezone(this._referencePosWGS84Comparable,t)||this._updateLighting(t),!0}_cameraHandlerServerSide(e){const t=e.position;(!this._referencePosMapCoords||this._referencePosMapCoordsRequested||this._exceedsReferencePosDistThreshold(t))&&this._requestReferencePositionUpdate(t,!0),this._view.mapCoordsHelper&&this._referencePosWGS84Comparable&&(this._referencePosWGS84Comparable[2]=(t.z??0)*this._view.mapCoordsHelper.unitInMeters,this._referencePosChanged())}_interactingStationaryHandler(){this._view.stationary&&this._executePendingReferencePositionUpdate()}_updateLighting(e,t=W.Immediate){const r=this._view;e=e||("virtual"===r.environment.lighting.type?null:r.environment.lighting.date);const i=this._referencePosWGS84Comparable,s=null!=i?q:E,n=this.weatherVisible?r.environment.weather.type:"disabled";null!=i?S(e,i,r.state.viewingMode,n,r.state.camera,s):"virtual"===r.environment.lighting.type&&T(r.state.camera,r.state.viewingMode,s.direct.directionToLightSource);const o=this._mainLight,a=s.direct;p(o.intensity,a.color,a.intensity*Math.PI),_(o.direction,a.directionToLightSource),o.specularStrength=s.specularStrength,o.environmentStrength=s.environmentStrength;const h=this._ambientLight;p(h.intensity,s.ambient.color,s.ambient.intensity);const c=this._moonLight;u(c.intensity,A,I,s.globalFactor);const l=(1-.5*s.globalFactor)*(1-.4*s.noonFactor*(1-s.globalFactor));p(c.intensity,c.intensity,l),_(c.direction,a.directionToLightSource),this._renderer.updateLightSources([o,h,c],s.noonFactor,s.globalFactor,t),this._updateRenderParameters()}_autoUpdateTimezone(e,t=null){if("virtual"===this._view.environment.lighting.type||!this._view.environment.lighting.cameraTrackingEnabled||null==e)return!1;const r=Q;r.setTime((t||this._view.environment.lighting.date).getTime());const i=U(e,D);if(null==i)return!1;let s=this._view.environment.lighting.positionTimezoneInfo;if(s.autoUpdated){if(s.hours===i.hours&&s.minutes===i.minutes&&s.seconds===i.seconds)return!1}else s=i;const n=r.getUTCHours()-(i.hours-s.hours),o=r.getUTCMinutes()-(i.minutes-s.minutes),a=r.getUTCSeconds()-(i.seconds-s.seconds);return r.setUTCHours(n),r.setUTCMinutes(o),r.setUTCSeconds(a),!t&&this._view.environment.lighting.autoUpdate(r,i)}_updateRenderParameters(){const e=this._view._stage;if(!e)return;const r=null==this._referencePosWGS84Comparable||R(this._referencePosWGS84Comparable[2],this._view.state.viewingMode),i=this._view.environment.background,s=i instanceof L?g(t.toUnitRGBA(i.color)):P(0,0,0,1);e.renderer.setParameters({shadowMap:this._view.environment.lighting.directShadowsEnabled&&r,backgroundColor:s,environment:this._view.environment,weatherVisible:this._view.environmentManager.weatherVisible,qualitySettings:this._view.qualitySettings})}_resetReferencePosition(e=!1){this._cancelReferencePosUpdates(),this._referencePosMapCoords=null,this._referencePosMapCoordsRequested=null,this._referencePosResetPreserveAbsoluteTime=null,this._referencePosWGS84Comparable=null,this.notifyChange("updating"),e&&this._cameraHandler()}_requestReferencePositionUpdate(e,t=!1){if(!this.disableQueries&&(this._referencePosMapCoordsRequested?this._referencePosMapCoordsRequested.copy(e):this._referencePosMapCoordsRequested=e.clone(),this._referencePosResetPreserveAbsoluteTime=!!t,!this._referencePosUpdateQuery&&!this._referencePosUpdateTimer&&this._view.stationary)){const e=this._referencePosUpdateQuery=n(this._referencePointUpdateDelay).then((()=>{if(this._referencePosUpdateQuery===e){const t=()=>this._referencePosUpdateQuery!==e;return this._doReferencePositionUpdateQuery(t)}})).catch((e=>{"mapcoordshelper:missing-geometry-service"===e.name&&(this.disableQueries=!0)})).then((()=>{this._referencePosUpdateQuery===e&&(this._referencePosUpdateQuery=null,this._referencePosUpdateTimer||this._executePendingReferencePositionUpdate(),this.notifyChange("updating"))})),t=this._referencePosUpdateTimer=n(this._referencePointUpdateInterval).then((()=>{this._referencePosUpdateTimer===t&&(this._referencePosUpdateTimer=null,this._referencePosUpdateQuery||this._executePendingReferencePositionUpdate())}));this.notifyChange("updating")}}async _doReferencePositionUpdateQuery(e){this._referencePosResetPreserveAbsoluteTime&&(this._preserveAbsoluteDateTime=!1),this._referencePosMapCoords?this._referencePosMapCoords.copy(this._referencePosMapCoordsRequested):this._referencePosMapCoords=this._referencePosMapCoordsRequested.clone(),this._referencePosResetPreserveAbsoluteTime=null,this._referencePosMapCoordsRequested=null;const t=await this._view.mapCoordsHelper.toGeographic(this._referencePosMapCoords);if(!e()&&!isNaN(t[0])&&!isNaN(t[1])){const e=(this._referencePosMapCoords.z??0)*this._view.mapCoordsHelper.unitInMeters;this._referencePosWGS84Comparable?(this._referencePosWGS84Comparable[0]=t[0],this._referencePosWGS84Comparable[1]=t[1],this._referencePosWGS84Comparable[2]=e):this._referencePosWGS84Comparable=[t[0],t[1],e],this._referencePosChanged()}}_executePendingReferencePositionUpdate(){const e=this._referencePosMapCoordsRequested;e&&this._requestReferencePositionUpdate(e,this._referencePosResetPreserveAbsoluteTime)}_referencePosChanged(){this._preserveAbsoluteDateTime?this._updateLighting():this._autoUpdateTimezone(this._referencePosWGS84Comparable)||this._updateLighting(),this.notifyChange("referencePositionWGS84Comparable")}_exceedsReferencePosDistThreshold(e){if(this._referencePosMapCoords){let t=this._referencePosMapCoords.distance(e);return this._view.mapCoordsHelper&&(t*=this._view.mapCoordsHelper.unitInMeters),t>this._referencePointUpdateDistThreshold}return!0}_cancelReferencePosUpdates(){const e=!!this._referencePosUpdateQuery;return this._referencePosUpdateQuery=null,this._referencePosUpdateTimer=null,e}get test(){const e=this;return{get renderer(){return e._renderer},set referencePointUpdateInterval(t){e._referencePointUpdateInterval=t},set referencePointUpdateDistThreshold(t){e._referencePointUpdateDistThreshold=t},set referencePosUpdateTimer(t){e._referencePosUpdateTimer=t},set referencePointUpdateDelay(t){e._referencePointUpdateDelay=t},set disableWeather(t){e._disableWeather=t}}}};e([c({type:Boolean,readOnly:!0})],k.prototype,"updating",null),e([c()],k.prototype,"disableQueries",void 0),e([c()],k.prototype,"_disableWeather",void 0),e([c()],k.prototype,"weatherEnabled",null),e([c()],k.prototype,"weatherVisible",null),e([c()],k.prototype,"referencePositionWGS84Comparable",null),e([c()],k.prototype,"_renderer",void 0),e([c()],k.prototype,"_referencePosWGS84Comparable",void 0),k=e([l("esri.views.3d.environment.SceneViewEnvironmentManager")],k);const q=new M,E=new M,Q=new Date,D={hours:0,minutes:0,seconds:0},A=f(.22,.22,.33),I=f(.22,.22,.22);export{k as SceneViewEnvironmentManager};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import r from"../../../core/Evented.js";import i from"../../../core/Handles.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{after as n}from"../../../core/promiseUtils.js";import{watch as o,sync as a,syncAndInitial as h}from"../../../core/reactiveUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import{s as l,g as p,c as _,h as u}from"../../../chunks/vec3.js";import{c as m,f}from"../../../chunks/vec3f64.js";import{b as g,f as P}from"../../../chunks/vec4f64.js";import{canProjectToWGS84ComparableLonLat as v,projectPointToWGS84ComparableLonLat as b}from"../../../geometry/projection.js";import{isEarth as w}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as C}from"../../ViewingMode.js";import{EnvironmentRenderer as y}from"./EnvironmentRenderer.js";import{positionToTimezoneInfo as U}from"../support/earthUtils.js";import{computeColorAndIntensity as S,computeVirtualLightDirection as T,computeShadowsEnabled as R,ColorAndIntensity as M}from"../support/sunUtils.js";import{Update as W}from"../webgl-engine/lib/Update.js";import{MainLight as H,AmbientLight as G,FillLight as j}from"../webgl-engine/lighting/Lightsources.js";import L from"../../../webscene/background/ColorBackground.js";let k=class extends r.EventedAccessor{constructor(){super(),this._referencePointUpdateDelay=200,this._referencePointUpdateInterval=3e3,this._referencePointUpdateDistThreshold=1e6,this._referencePosUpdateQuery=null,this._referencePosMapCoordsRequested=null,this._viewHandles=new i,this._preserveAbsoluteDateTime=!1,this._trackingEnabled=!1,this._referencePosResetPreserveAbsoluteTime=!1,this._referencePosUpdateTimer=null,this._referencePosMapCoords=null,this._mainLight=new H,this._ambientLight=new G,this._moonLight=new j,this.disableQueries=!1,this._disableWeather=!1,this._renderer=null,this._referencePosWGS84Comparable=null,this._resetReferencePosition()}destroy(){this.disconnectView(),this._viewHandles.destroy()}get _view(){return this._renderer?.view}get updating(){return!((this.disableQueries||!this._referencePosUpdateQuery&&!this._referencePosMapCoordsRequested)&&!this._renderer?.updating)}get usedMemory(){return this._renderer?.usedMemory??0}get weatherEnabled(){return this._view?.environment.atmosphereEnabled&&!this._disableWeather&&this._view?.state?.viewingMode===C.Global&&w(this._view.spatialReference)}get weatherVisible(){return this.weatherEnabled&&this._renderer?.weatherVisible}get referencePositionWGS84Comparable(){return this._referencePosWGS84Comparable}connectView(e){if(this._renderer)return;this._renderer=new y({view:e});const t=()=>this._updateRenderParameters(),r=()=>this._cameraHandler();this._viewHandles.add([o((()=>e.environment.lighting),(e=>this._updateLightingHandler(e)),a),o((()=>"virtual"!==e.environment.lighting.type?e.environment.lighting.date:null),(e=>this._lightingDateHandler(e)),a),o((()=>e.stationary),(()=>this._interactingStationaryHandler())),o((()=>e.environment.lighting.directShadowsEnabled),t,a),o((()=>e.qualitySettings.ambientOcclusion),t,a),o((()=>e.qualitySettings.reflections),t,a),o((()=>e.environment.background?.color),t,a),o((()=>e.spatialReference),(()=>this._resetReferencePosition(!0)),a),o((()=>e.environment.weather.type),(()=>this._updateLighting(null,W.Faded)),a),o((()=>this.weatherEnabled),(()=>this._updateLighting(null,W.Faded)),a),o((()=>e.viewingMode),(()=>this._resetReferencePosition(!0)),h),o((()=>"virtual"!==e.environment.lighting.type&&e.environment.lighting.cameraTrackingEnabled),(e=>this._updateCameraTracking(e)),h),o((()=>e.state.camera),r,h),o((()=>this.disableQueries),r)]),this._updateRenderParameters(),this._updateLighting(),this._cameraHandler(),this.notifyChange("updating")}disconnectView(){this._viewHandles.removeAll(),this._resetReferencePosition(),this._renderer=s(this._renderer)}_updateLightingHandler(e){this._updateCameraTracking("virtual"!==e.type&&e.cameraTrackingEnabled),this._lightingDateHandler("virtual"!==e.type?e.date:null),this._updateRenderParameters()}_updateCameraTracking(e){if(this._trackingEnabled=e,e)this._cameraHandler();else{const e=this._view.environment.lighting;"virtual"!==e?.type&&(e.positionTimezoneInfo.autoUpdated=!1)}}_lightingDateHandler(e){const t=this._view.environment.lighting;if("virtual"!==t?.type){if(e){if(!t.positionTimezoneInfo.autoUpdated){this._preserveAbsoluteDateTime=!0;const r=this._view.spatialReference;if(!v(r)){const e=this._view.camera.position;if(!this._referencePosMapCoords||!this._referencePosMapCoords.equals(e))return void this._requestReferencePositionUpdate(e)}if(this._preupdateTracking(e),null!=this._referencePosWGS84Comparable){const e=U(this._referencePosWGS84Comparable,D);null!=e&&(t.autoUpdate(null,e),this._trackingEnabled&&(t.positionTimezoneInfo.autoUpdated=!0))}}this._updateLighting(e)}}else this._updateLighting()}_preupdateTracking(e){!this._trackingEnabled&&"virtual"!==this._view.environment.lighting.type&&this._view.environment.lighting.cameraTrackingEnabled&&this._cameraHandler(e)}_cameraHandler(e=null){const t=this._view;if(!t.ready)return;const r=t.stateManager.camera;r&&(this._cameraHandlerClientSide(r,e)||this._cameraHandlerServerSide(r))}_cameraHandlerClientSide(e,t){const r=w(this._view.spatialReference);if(r&&!v(this._view.spatialReference))return"virtual"===this._view.environment.lighting.type&&this._updateLighting(),!1;const i=e.position;return null==this._referencePosWGS84Comparable&&(this._referencePosWGS84Comparable=m()),r?b(i,this._referencePosWGS84Comparable):l(this._referencePosWGS84Comparable,i.longitude??0,i.latitude??0,i.z??0),this.notifyChange("referencePositionWGS84Comparable"),this._autoUpdateTimezone(this._referencePosWGS84Comparable,t)||this._updateLighting(t),!0}_cameraHandlerServerSide(e){const t=e.position;(!this._referencePosMapCoords||this._referencePosMapCoordsRequested||this._exceedsReferencePosDistThreshold(t))&&this._requestReferencePositionUpdate(t,!0),this._view.mapCoordsHelper&&this._referencePosWGS84Comparable&&(this._referencePosWGS84Comparable[2]=(t.z??0)*this._view.mapCoordsHelper.unitInMeters,this._referencePosChanged())}_interactingStationaryHandler(){this._view.stationary&&this._executePendingReferencePositionUpdate()}_updateLighting(e,t=W.Immediate){const r=this._view;e=e||("virtual"===r.environment.lighting.type?null:r.environment.lighting.date);const i=this._referencePosWGS84Comparable,s=null!=i?q:E,n=this.weatherVisible?r.environment.weather.type:"disabled";null!=i?S(e,i,r.state.viewingMode,n,r.state.camera,s):"virtual"===r.environment.lighting.type&&T(r.state.camera,r.state.viewingMode,s.direct.directionToLightSource);const o=this._mainLight,a=s.direct;p(o.intensity,a.color,a.intensity*Math.PI),_(o.direction,a.directionToLightSource),o.specularStrength=s.specularStrength,o.environmentStrength=s.environmentStrength;const h=this._ambientLight;p(h.intensity,s.ambient.color,s.ambient.intensity);const c=this._moonLight;u(c.intensity,A,I,s.globalFactor);const d=(1-.5*s.globalFactor)*(1-.4*s.noonFactor*(1-s.globalFactor));p(c.intensity,c.intensity,d),_(c.direction,a.directionToLightSource),this._renderer.updateLightSources([o,h,c],s.noonFactor,s.globalFactor,t),this._updateRenderParameters()}_autoUpdateTimezone(e,t=null){if("virtual"===this._view.environment.lighting.type||!this._view.environment.lighting.cameraTrackingEnabled||null==e)return!1;const r=Q;r.setTime((t||this._view.environment.lighting.date).getTime());const i=U(e,D);if(null==i)return!1;let s=this._view.environment.lighting.positionTimezoneInfo;if(s.autoUpdated){if(s.hours===i.hours&&s.minutes===i.minutes&&s.seconds===i.seconds)return!1}else s=i;const n=r.getUTCHours()-(i.hours-s.hours),o=r.getUTCMinutes()-(i.minutes-s.minutes),a=r.getUTCSeconds()-(i.seconds-s.seconds);return r.setUTCHours(n),r.setUTCMinutes(o),r.setUTCSeconds(a),!t&&this._view.environment.lighting.autoUpdate(r,i)}_updateRenderParameters(){const e=this._view._stage;if(!e)return;const r=null==this._referencePosWGS84Comparable||R(this._referencePosWGS84Comparable[2],this._view.state.viewingMode),i=this._view.environment.background,s=i instanceof L?g(t.toUnitRGBA(i.color)):P(0,0,0,1);e.renderer.setParameters({shadowMap:this._view.environment.lighting.directShadowsEnabled&&r,backgroundColor:s,environment:this._view.environment,weatherVisible:this._view.environmentManager.weatherVisible,qualitySettings:this._view.qualitySettings})}_resetReferencePosition(e=!1){this._cancelReferencePosUpdates(),this._referencePosMapCoords=null,this._referencePosMapCoordsRequested=null,this._referencePosResetPreserveAbsoluteTime=null,this._referencePosWGS84Comparable=null,this.notifyChange("updating"),e&&this._cameraHandler()}_requestReferencePositionUpdate(e,t=!1){if(!this.disableQueries&&(this._referencePosMapCoordsRequested?this._referencePosMapCoordsRequested.copy(e):this._referencePosMapCoordsRequested=e.clone(),this._referencePosResetPreserveAbsoluteTime=!!t,!this._referencePosUpdateQuery&&!this._referencePosUpdateTimer&&this._view.stationary)){const e=this._referencePosUpdateQuery=n(this._referencePointUpdateDelay).then((()=>{if(this._referencePosUpdateQuery===e){const t=()=>this._referencePosUpdateQuery!==e;return this._doReferencePositionUpdateQuery(t)}})).catch((e=>{"mapcoordshelper:missing-geometry-service"===e.name&&(this.disableQueries=!0)})).then((()=>{this._referencePosUpdateQuery===e&&(this._referencePosUpdateQuery=null,this._referencePosUpdateTimer||this._executePendingReferencePositionUpdate(),this.notifyChange("updating"))})),t=this._referencePosUpdateTimer=n(this._referencePointUpdateInterval).then((()=>{this._referencePosUpdateTimer===t&&(this._referencePosUpdateTimer=null,this._referencePosUpdateQuery||this._executePendingReferencePositionUpdate())}));this.notifyChange("updating")}}async _doReferencePositionUpdateQuery(e){this._referencePosResetPreserveAbsoluteTime&&(this._preserveAbsoluteDateTime=!1),this._referencePosMapCoords?this._referencePosMapCoords.copy(this._referencePosMapCoordsRequested):this._referencePosMapCoords=this._referencePosMapCoordsRequested.clone(),this._referencePosResetPreserveAbsoluteTime=null,this._referencePosMapCoordsRequested=null;const t=await this._view.mapCoordsHelper.toGeographic(this._referencePosMapCoords);if(!e()&&!isNaN(t[0])&&!isNaN(t[1])){const e=(this._referencePosMapCoords.z??0)*this._view.mapCoordsHelper.unitInMeters;this._referencePosWGS84Comparable?(this._referencePosWGS84Comparable[0]=t[0],this._referencePosWGS84Comparable[1]=t[1],this._referencePosWGS84Comparable[2]=e):this._referencePosWGS84Comparable=[t[0],t[1],e],this._referencePosChanged()}}_executePendingReferencePositionUpdate(){const e=this._referencePosMapCoordsRequested;e&&this._requestReferencePositionUpdate(e,this._referencePosResetPreserveAbsoluteTime)}_referencePosChanged(){this._preserveAbsoluteDateTime?this._updateLighting():this._autoUpdateTimezone(this._referencePosWGS84Comparable)||this._updateLighting(),this.notifyChange("referencePositionWGS84Comparable")}_exceedsReferencePosDistThreshold(e){if(this._referencePosMapCoords){let t=this._referencePosMapCoords.distance(e);return this._view.mapCoordsHelper&&(t*=this._view.mapCoordsHelper.unitInMeters),t>this._referencePointUpdateDistThreshold}return!0}_cancelReferencePosUpdates(){const e=!!this._referencePosUpdateQuery;return this._referencePosUpdateQuery=null,this._referencePosUpdateTimer=null,e}get test(){const e=this;return{get renderer(){return e._renderer},set referencePointUpdateInterval(t){e._referencePointUpdateInterval=t},set referencePointUpdateDistThreshold(t){e._referencePointUpdateDistThreshold=t},set referencePosUpdateTimer(t){e._referencePosUpdateTimer=t},set referencePointUpdateDelay(t){e._referencePointUpdateDelay=t},set disableWeather(t){e._disableWeather=t}}}};e([c({type:Boolean,readOnly:!0})],k.prototype,"updating",null),e([c()],k.prototype,"disableQueries",void 0),e([c()],k.prototype,"_disableWeather",void 0),e([c()],k.prototype,"weatherEnabled",null),e([c()],k.prototype,"weatherVisible",null),e([c()],k.prototype,"referencePositionWGS84Comparable",null),e([c()],k.prototype,"_renderer",void 0),e([c()],k.prototype,"_referencePosWGS84Comparable",void 0),k=e([d("esri.views.3d.environment.SceneViewEnvironmentManager")],k);const q=new M,E=new M,Q=new Date,D={hours:0,minutes:0,seconds:0},A=f(.22,.22,.33),I=f(.22,.22,.22);export{k as SceneViewEnvironmentManager};