@arcgis/core 4.29.0-next.20240222 → 4.29.1

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 (279) hide show
  1. package/arcade/treeAnalysis.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{b43fde3e25d0c3b020b5.js → 039a872509872ce67ba4.js} +1 -1
  4. package/assets/esri/core/workers/chunks/0bc21d2a0b65bd4e9d76.js +1 -0
  5. package/assets/esri/core/workers/chunks/{5243f9ff21e768c620c2.js → 23a5d750d93a7829174f.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{47e6119be4a4a5ed640d.js → 2447a4d5886aeb0ff72a.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{7f45a9e9bdbcffc2d6e0.js → 348bcc57b99a975902a8.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{8c9fb2601488998013ba.js → 3523789a2948a4ab8cc8.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{24649b410b757599a549.js → 48db6e0bbb1a9c043193.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{752082be991f1cc8558f.js → 4984e2b79d862114d6a6.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{8d9736fd15cdb54d9855.js → 5227f9eea6988aadad7f.js} +1 -1
  12. package/assets/esri/core/workers/chunks/58723274ef657fe212eb.js +1 -0
  13. package/assets/esri/core/workers/chunks/60ab18c6a04d4b2f1d4c.js +1 -0
  14. package/assets/esri/core/workers/chunks/647515801d94180b8402.js +1 -0
  15. package/assets/esri/core/workers/chunks/6c3ae96ec90e9ed7dd50.js +1 -0
  16. package/assets/esri/core/workers/chunks/7a8bba91769ee18cc39f.js +1 -0
  17. package/assets/esri/core/workers/chunks/7a98d2e026f63a581b1e.js +1 -0
  18. package/assets/esri/core/workers/chunks/8c360923cd1850767d3e.js +1 -0
  19. package/assets/esri/core/workers/chunks/{1a25ba411b89e050fbb7.js → a61f337802ae963d7f65.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{d0c5318d7ef2e923aad0.js → a8ac511280f873960d46.js} +1 -1
  21. package/assets/esri/core/workers/chunks/b125ab84b7761e761734.js +1 -0
  22. package/assets/esri/core/workers/chunks/{b34d6e58b125fe111f91.js → b42a83db83851cb57d44.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{1497dd943df7eede0704.js → b9c55ff1f21db198ce03.js} +1 -1
  24. package/assets/esri/core/workers/chunks/bb3322ddb89c0bd444f0.js +1 -0
  25. package/assets/esri/core/workers/chunks/becfdaeeb07f089d8be7.js +1 -0
  26. package/assets/esri/core/workers/chunks/{b26e39a399963c176d33.js → c527692694688a5b3b07.js} +2 -2
  27. package/assets/esri/core/workers/chunks/{210a93e0b96c5bff44a3.js → c556644bb0cf88770939.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{e7b26c7e9e24dc6255be.js → cacf97b0a7a1057b9f79.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{a5e7b4acae17f88e2208.js → ce93027b6b81428ce9b0.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{b8ece275abac93f3dccf.js → d14f16bfa6c12909929c.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{1594f06a2d7d9439c62e.js → e2147c99cc5839654be1.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{d33ed3a2a0d4b640bd4a.js → e4c7d8c69e4957c9d27c.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{7709248f59520aee6f51.js → eceaa46f622f6fa31128.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{2286db4c83ff1b6fb088.js → ef3e6209e6ac6a56960b.js} +1 -1
  35. package/assets/esri/core/workers/chunks/f59b5ea05caca8a1a398.js +1 -0
  36. package/chunks/Laserlines.glsl.js +3 -3
  37. package/chunks/Precipitation.glsl.js +1 -1
  38. package/chunks/SSAOBlur.glsl.js +2 -2
  39. package/chunks/boundedPlane.js +1 -1
  40. package/chunks/cameraUtilsSpherical.js +1 -1
  41. package/chunks/sphere.js +1 -1
  42. package/chunks/terrainUtilsPlanar.js +1 -1
  43. package/chunks/vec32.js +1 -1
  44. package/config.js +1 -1
  45. package/copyright.txt +56 -28
  46. package/core/libs/gl-matrix-2/math/quat.js +1 -1
  47. package/core/libs/gl-matrix-2/math/vec3.js +1 -1
  48. package/core/libs/gl-matrix-2/vec3.js +1 -1
  49. package/geometry/support/axisAngleDegrees.js +1 -1
  50. package/geometry/support/coordinateSystem.js +1 -1
  51. package/geometry/support/lineSegment.js +1 -1
  52. package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
  53. package/geometry/support/meshUtils/georeference.js +1 -1
  54. package/geometry/support/meshUtils/merge.js +1 -1
  55. package/geometry/support/meshUtils/rotate.js +1 -1
  56. package/geometry/support/meshUtils/scale.js +1 -1
  57. package/geometry/support/meshUtils/vertexSpaceConversion.js +5 -0
  58. package/geometry/support/meshVertexSpaceUtils.js +1 -1
  59. package/geometry/support/plane.js +1 -1
  60. package/geometry/support/ray.js +1 -1
  61. package/geometry/support/triangle.js +1 -1
  62. package/geometry/support/vector.js +1 -1
  63. package/interfaces.d.ts +12 -12
  64. package/kernel.js +1 -1
  65. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  66. package/layers/LinkChartLayer.js +1 -1
  67. package/layers/VoxelWasmPerSceneView.js +1 -1
  68. package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
  69. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  70. package/layers/mixins/FeatureReductionLayer.js +1 -1
  71. package/layers/orientedImagery/core/CameraOrientation.js +1 -1
  72. package/layers/orientedImagery/core/ElevationSourceDefinitions.js +1 -1
  73. package/layers/orientedImagery/core/coverageUtils.js +1 -1
  74. package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
  75. package/layers/orientedImagery/transformations/imageToWorld.js +5 -0
  76. package/layers/orientedImagery/transformations/updateElevation.js +5 -0
  77. package/layers/orientedImagery/transformations/updateElevationUtils.js +5 -0
  78. package/layers/orientedImagery/transformations/utils.js +1 -1
  79. package/layers/orientedImagery/transformations/worldToImage.js +5 -0
  80. package/layers/support/EditingCapabilities.js +1 -1
  81. package/layers/support/editableLayers.js +1 -1
  82. package/layers/support/layerUtils.js +1 -1
  83. package/layers/video/VideoCameraSensorModel.js +1 -1
  84. package/layers/voxel/VoxelVolume.js +1 -1
  85. package/layers/voxel/voxelPlaneUtils.js +1 -1
  86. package/libs/linkchartlayout/LinkChartLayout.js +1 -1
  87. package/package.json +1 -1
  88. package/smartMapping/renderers/pieChart.js +1 -1
  89. package/support/revision.js +1 -1
  90. package/symbols/cim/cimAnalyzer.js +1 -1
  91. package/views/2d/arcade/callExpressionWithCursor.js +1 -1
  92. package/views/2d/engine/webgl/shaderGraph/techniques/createTestMeshData.js +1 -1
  93. package/views/2d/engine/webgl/shaderGraph/techniques/mesh/MeshWriterInputEvaluator.js +1 -1
  94. package/views/2d/interactive/editingTools/TransformTool.js +1 -1
  95. package/views/2d/interactive/editingTools/manipulations/ScaleManipulation.js +1 -1
  96. package/views/2d/layers/features/Processor.js +1 -1
  97. package/views/2d/layers/features/aggregation/GeohashSpatialIndex.js +1 -1
  98. package/views/2d/layers/features/aggregation/GridSpatialIndex.js +1 -1
  99. package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
  100. package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
  101. package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
  102. package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
  103. package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
  104. package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
  105. package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +1 -1
  106. package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
  107. package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
  108. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  109. package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
  110. package/views/2d/layers/features/sources/strategies/chunks/DrillDownTileSourceChunk.js +1 -1
  111. package/views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js +1 -1
  112. package/views/2d/layers/features/sources/strategies/chunks/OverrideChunk.js +1 -1
  113. package/views/2d/layers/features/sources/strategies/chunks/PagedTileSourceChunk.js +1 -1
  114. package/views/2d/layers/features/sources/strategies/chunks/StreamSourceChunk.js +1 -1
  115. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  116. package/views/2d/layers/features/support/FeatureMetadata.js +1 -1
  117. package/views/2d/layers/features/support/GraphicsReader.js +1 -1
  118. package/views/2d/layers/features/support/Tile.js +1 -1
  119. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  120. package/views/2d/tiling/TileKey.js +1 -1
  121. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  122. package/views/3d/analysis/Dimension/lengthDimensionConstraintUtils.js +1 -1
  123. package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
  124. package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
  125. package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementController.js +1 -1
  126. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  127. package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
  128. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  129. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  130. package/views/3d/analysis/support/measurementUtils.js +1 -1
  131. package/views/3d/animation/pointToPoint/Camera.js +1 -1
  132. package/views/3d/camera/constraintUtils/common.js +1 -1
  133. package/views/3d/camera/constraintUtils/distance.js +1 -1
  134. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  135. package/views/3d/camera/intersectionUtils.js +1 -1
  136. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  137. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  138. package/views/3d/environment/Fog.js +1 -1
  139. package/views/3d/environment/MarsAtmosphere.js +1 -1
  140. package/views/3d/environment/SceneViewEnvironmentManager.js +1 -1
  141. package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
  142. package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
  143. package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
  144. package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
  145. package/views/3d/interactive/editingTools/reshapeGraphic/edgeOffsetUtils.js +1 -1
  146. package/views/3d/interactive/editingTools/transformGraphic/ExtentScale.js +1 -1
  147. package/views/3d/interactive/editingTools/transformGraphic/extentUtils.js +1 -1
  148. package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
  149. package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
  150. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  151. package/views/3d/interactive/visualElements/support/Segment.js +1 -1
  152. package/views/3d/layers/I3SMeshView3D.js +1 -1
  153. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  154. package/views/3d/layers/PointCloudWorker.js +1 -1
  155. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  156. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  157. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  158. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  159. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  160. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  161. package/views/3d/layers/i3s/LoDUtil.js +1 -1
  162. package/views/3d/layers/i3s/PointRenderer.js +1 -1
  163. package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
  164. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  165. package/views/3d/layers/support/uvUtils.js +1 -1
  166. package/views/3d/state/Frustum.js +1 -1
  167. package/views/3d/state/NearFarHeuristic.js +1 -1
  168. package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
  169. package/views/3d/state/controllers/RotateController.js +1 -1
  170. package/views/3d/state/controllers/global/PinchAndPanController.js +1 -1
  171. package/views/3d/state/controllers/global/ZoomController.js +1 -1
  172. package/views/3d/state/controllers/global/ZoomStepController.js +1 -1
  173. package/views/3d/state/controllers/local/PinchAndPanController.js +1 -1
  174. package/views/3d/state/controllers/local/ZoomController.js +1 -1
  175. package/views/3d/state/controllers/local/ZoomStepController.js +1 -1
  176. package/views/3d/state/controllers/momentum/ZoomPlanarMomentumController.js +1 -1
  177. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  178. package/views/3d/state/utils/navigationUtils.js +1 -1
  179. package/views/3d/state/utils/viewUtils.js +1 -1
  180. package/views/3d/support/FrustumExtentIntersection.js +1 -1
  181. package/views/3d/support/cameraUtils.js +1 -1
  182. package/views/3d/support/cameraUtilsInternal.js +1 -1
  183. package/views/3d/support/intersectionUtils.js +1 -1
  184. package/views/3d/support/mathUtils.js +1 -1
  185. package/views/3d/support/orientedBoundingBox.js +1 -1
  186. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  187. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  188. package/views/3d/support/pointsOfInterest/Focus.js +1 -1
  189. package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
  190. package/views/3d/support/sunUtils.js +1 -1
  191. package/views/3d/support/viewpointUtils.js +1 -1
  192. package/views/3d/terrain/OverlayManager.js +1 -1
  193. package/views/3d/terrain/PatchRenderData.js +1 -1
  194. package/views/3d/terrain/SphericalPatch.js +1 -1
  195. package/views/3d/terrain/TerrainRenderer.js +1 -1
  196. package/views/3d/terrain/Tile.js +1 -1
  197. package/views/3d/webgl-engine/collections/Component/DepthRange.js +1 -1
  198. package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
  199. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  200. package/views/3d/webgl-engine/core/util/TwoVectorPosition.js +1 -1
  201. package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
  202. package/views/3d/webgl-engine/lib/BoundingInfo.js +1 -1
  203. package/views/3d/webgl-engine/lib/Camera.js +1 -1
  204. package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
  205. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  206. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  207. package/views/3d/webgl-engine/lib/PathVertex.js +1 -1
  208. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  209. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  210. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  211. package/views/3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js +1 -1
  212. package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
  213. package/views/3d/webgl-engine/lib/intersectorUtils.js +1 -1
  214. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  215. package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
  216. package/views/3d/webgl-engine/lighting/SceneLighting.js +1 -1
  217. package/views/3d/webgl-engine/lighting/SphericalHarmonics.js +1 -1
  218. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  219. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  220. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  221. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  222. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  223. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  224. package/views/3d/webgl-engine/materials/pbrUtils.js +1 -1
  225. package/views/SelectionManager.js +1 -1
  226. package/views/draw/support/createUtils.js +1 -1
  227. package/views/draw/support/surfaceCoordinateSystems.js +1 -1
  228. package/views/interactive/GraphicManipulator.js +1 -1
  229. package/views/interactive/SegmentLabels.js +1 -1
  230. package/views/interactive/coordinateHelper.js +1 -1
  231. package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
  232. package/views/interactive/editGeometry/support/editPlaneUtils.js +1 -1
  233. package/views/interactive/sketch/constraints.js +1 -1
  234. package/views/interactive/snapping/RightAngleSnapper.js +1 -1
  235. package/views/interactive/snapping/candidates/ParallelLineSnappingCandidate.js +1 -1
  236. package/views/interactive/snapping/candidates/RightAngleTriangleSnappingCandidate.js +1 -1
  237. package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +1 -1
  238. package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
  239. package/views/interactive/snapping/hints/IntersectionSnappingHint.js +1 -1
  240. package/views/interactive/snapping/hints/LineSnappingHint.js +1 -1
  241. package/views/interactive/snapping/hints/ParallelSnappingHint.js +1 -1
  242. package/views/interactive/snapping/hints/PointSnappingHint.js +1 -1
  243. package/views/interactive/snapping/hints/RightAngleSnappingHint.js +1 -1
  244. package/views/layers/FeatureLayerView.js +1 -1
  245. package/views/layers/support/editableLayerViews.js +5 -0
  246. package/views/navigation/PanSphericalMomentumEstimator.js +1 -1
  247. package/views/support/angularMeasurementUtils.js +1 -1
  248. package/views/support/euclideanAreaMeasurementUtils.js +1 -1
  249. package/views/support/euclideanLengthMeasurementUtils.js +1 -1
  250. package/views/support/geometry3dUtils.js +1 -1
  251. package/widgets/Editor/EditorViewModel.js +1 -1
  252. package/widgets/Editor/support/EditorEditingCapabilities.js +1 -1
  253. package/widgets/Editor/support/EditorItem.js +1 -1
  254. package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
  255. package/widgets/FeatureForm.js +1 -1
  256. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  257. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  258. package/widgets/FeatureTable/support/ColumnTemplateBase.js +1 -1
  259. package/widgets/Features/FeaturesViewModel.js +1 -1
  260. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  261. package/widgets/OrientedImageryViewer.js +1 -1
  262. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  263. package/widgets/PanoramicViewer/utils.js +1 -1
  264. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  265. package/widgets/UtilityNetworkTrace.js +1 -1
  266. package/widgets/support/Selector2D/SelectionOperation.js +1 -1
  267. package/widgets/support/Selector2D/selectorUtils.js +1 -1
  268. package/assets/esri/core/workers/chunks/0e83f3718a0b45652b5e.js +0 -1
  269. package/assets/esri/core/workers/chunks/1fa5c8af69a09a3730b3.js +0 -1
  270. package/assets/esri/core/workers/chunks/25f73748df0ee82d06cb.js +0 -1
  271. package/assets/esri/core/workers/chunks/2d7a18f8c540269ecee9.js +0 -1
  272. package/assets/esri/core/workers/chunks/4736f79b5c94ce103d43.js +0 -1
  273. package/assets/esri/core/workers/chunks/65f7adaaf1f535310c11.js +0 -1
  274. package/assets/esri/core/workers/chunks/79c041b292648c5eaecc.js +0 -1
  275. package/assets/esri/core/workers/chunks/7c4c2c0beddabac672b6.js +0 -1
  276. package/assets/esri/core/workers/chunks/9a758de08dfa57735879.js +0 -1
  277. package/assets/esri/core/workers/chunks/a4c3da057ec2a07bbbe8.js +0 -1
  278. package/assets/esri/core/workers/chunks/b252270b100351779f1f.js +0 -1
  279. package/assets/esri/core/workers/chunks/dc57aa9f2fc69e654559.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.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../core/has.js";import{lerp as t}from"../../../core/mathUtils.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{watch as r,syncAndInitial as i,initial as a,sync as o}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{l,c as d,k as p}from"../../../chunks/vec32.js";import{fromValues as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as m}from"../../../geometry/ellipsoidUtils.js";import{isMoon as c,isEarth as _,isMars as g}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as w}from"../../ViewingMode.js";import{AtmosphereType as f}from"./AtmosphereType.js";import{ChapmanAtmosphere as y}from"./ChapmanAtmosphere.js";import{CloudsComposition as v}from"./CloudsComposition.js";import{isReadyCloudsData as P,CloudsRenderingStages as b}from"./CloudsData.js";import{CloudsGenerator as R}from"./CloudsGenerator.js";import{FadeMode as A}from"./CloudsParameters.js";import{cloudPresets as x}from"./CloudsPresets.js";import{Fog as F,FogParameters as N}from"./Fog.js";import{LocalAtmosphere as W}from"./LocalAtmosphere.js";import j from"./MarsAtmosphere.js";import{Precipitation as C}from"./Precipitation.js";import{Stars as E}from"./Stars.js";import{weatherHeightLimit as M}from"./weather.js";import{SyncRenderPlugin as O,ConsumesDepth as z,ConsumesNone as L}from"../webgl-engine/effects/RenderPlugin.js";import{RenderSlot as T}from"../webgl-engine/lib/RenderSlot.js";import{Update as S}from"../webgl-engine/lib/Update.js";var U;let I=U=class extends O{constructor(e){super(e),this.produces=new Map([[T.ENVIRONMENT_OPAQUE,()=>!(null===this._atmosphere&&null===this._stars)],[T.ENVIRONMENT_TRANSPARENT,()=>!(null===this._atmosphere)]]),this._context=null,this._atmosphere=null,this._oldWeatherParameters=new V,this._newWeatherParameters=new V,this._fadedWeatherParameters=new V,this._weatherParameters=this._newWeatherParameters}initialize(){this.view._stage.addRenderPlugin(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:f.None}consumes(){return this._atmosphereType===f.Realistic?z:L}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 l(this.view.state.camera.eye)-m(this.view.spatialReference).radius<=M}get usedMemory(){return this._clouds?.usedMemory??0}get _stars(){const e=this.view,t=e.environment?.starsEnabled??!1,r=this._get("_stars");return t&&null!=this._context?null!=r?r:new E({view:e,requestRender:()=>this._setNeedsRender()}):(s(r),null)}get _precipitation(){const e=this._get("_precipitation");if(!this._precipitationEnabled||null==this._context)return s(e),null;const t=this.view,r=this._context;return null!=e&&e.context===r?e:(s(e),new C({context:r,view:t}))}get _clouds(){const e=this._get("_clouds");if(!this.weatherEnabled||null==this._context)return s(e),null;if(null!=e)return e;const t=this.view,r=this._context;return s(e),new R({context:r,view:t,requestRender:()=>this._setNeedsRender()})}get _cloudsComposition(){const e=this._get("_cloudsComposition");if(!this.weatherEnabled||null==this._context)return s(e),null;const t=this.view.state.viewingMode,r=this._context.renderContext.rctx,i=m(this.view.spatialReference).radius;return null!=e&&e.viewingMode===t&&e.planetRadius===i?e:(s(e),new v({rctx:r,viewingMode:t,planetRadius:i,requestRender:()=>this._setNeedsRender()}))}get _fog(){const e=this._get("_fog");if(!this.weatherEnabled||null==this._context)return s(e),null;if(null!=e)return e;const t=this.view,r=this._context,i=this._context.renderContext.rctx,a=this.view.state.viewingMode;return new F({context:r,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([r((()=>({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled})),(e=>this._updateAtmosphere(e)),i),r((()=>this._stars),t),r((()=>this._precipitation),t),r((()=>this._clouds),(()=>this._updateWeather()),a),r((()=>this._fog),(()=>this._updateFogHaze()),a),r((()=>this.view.state.mode),(()=>{this._setNeedsRender()}),o),r((()=>this._weatherUpdateParameters),(()=>{this._updateWeather(),this._updateFogHaze()}),i)])}uninitializeRenderContext(){this._context=null,this._atmosphere=s(this._atmosphere),this._set("_stars",s(this._stars)),this._set("_precipitation",s(this._precipitation)),this._set("_clouds",s(this._clouds)),this._set("_cloudsComposition",s(this._cloudsComposition)),this._set("_fog",s(this._fog))}prepareRender(e){e.bindParameters.cloudsFade.data=P(this._clouds)?this._clouds:null,"local"!==this.view.viewingMode&&null!=e.bindParameters.cloudsFade.data?.cubeMap&&(this._updateWeatherFading(e.bindParameters,e.time),e.bindParameters.cloudsFade.renderingStage===b.FINISHED&&null!=this._clouds&&0===this._clouds.coverage&&!1===this._clouds.running&&(this._clouds.destroyFrameBufferCube(),e.bindParameters.cloudsFade.data=null))}renderNode(e){switch(e.bindParameters.slot){case T.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)),e.bindParameters.cloudsFade.isFading&&null!=this._context&&null!=e.bindParameters.cloudsFade.data?.cubeMap&&this._context.requestRender());break;case T.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),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===S.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,t){e.cloudsFade.updateFading(e.camera,this.view.state.mode,t,this.view.qualitySettings.fadeDuration),e.cloudsFade.updateParallax(e.camera),e.weatherFading&&(this._updateLighting(e),this._updateFogAtmoshpere(e))}_updateLighting(e){e.cloudsFade.fadeMode!==A.CROSS_FADE&&e.cloudsFade.fadeMode!==A.FADE_IN?e.fadeLighting(0):e.fadeLighting(e.cloudsFade.fadeFactor)}_updateFogAtmoshpere(e){e.cloudsFade.fadeMode!==A.CROSS_FADE&&e.cloudsFade.fadeMode!==A.FADE_IN?this._fadeWeather(0):this._fadeWeather(e.cloudsFade.fadeFactor)}_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(x[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 s=this._context.renderContext.bindParameters;switch(this._oldWeatherParameters.copyFrom(this._weatherParameters),e.type){case"foggy":this._newWeatherParameters.fog.strength=t(3e-5,.005,e.weatherAdjustment**3),d(this._newWeatherParameters.fog.color,q),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender();break;case"rainy":this._newWeatherParameters.fog.strength=t(4e-6,2e-4,(e.effect??0)**3),d(this._newWeatherParameters.fog.color,k),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=0,this._setNeedsRender();break;case"snowy":this._newWeatherParameters.fog.strength=t(4e-6,2e-4,(e.effect??0)**3),d(this._newWeatherParameters.fog.color,q),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()}s.weatherFading?this._fadeWeather(0):this._fadeWeather(1)}_updateAtmosphere(e){const t=this._selectAtmosphereType(e);if(t!==f.None&&this._context){if(!this._atmosphere||this._atmosphere.type!==t){this._atmosphere=s(this._atmosphere);const e=this._getAtmosphereClass(t);e&&(this._atmosphere=new e(this.view,this._context))}}else this._atmosphere=s(this._atmosphere);this._setNeedsRender()}_getAtmosphereClass(e){switch(e){case f.Realistic:return y;case f.Local:return W;case f.Mars:return j;default:case f.None:return null}}_selectAtmosphereType(e){const{enabled:t,viewingMode:s}=e;return!t||c(this.view.spatialReference)?f.None:s===w.Local?f.Local:null!=this._context&&y.isSupported(this._context)&&_(this.view.spatialReference)?f.Realistic:g(this.view.spatialReference)?f.Mars:f.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=>{D=U.prototype._getAtmosphereClass,U.prototype._getAtmosphereClass=e},restoreGetAtmosphereClass:()=>{U.prototype._getAtmosphereClass=D}}}};e([n({constructOnly:!0})],I.prototype,"view",void 0),e([n({readOnly:!0})],I.prototype,"atmosphere",null),e([n({readOnly:!0})],I.prototype,"_atmosphereType",null),e([n({type:Boolean,readOnly:!0})],I.prototype,"updating",null),e([n({readOnly:!0})],I.prototype,"weatherVisible",null),e([n()],I.prototype,"_context",void 0),e([n()],I.prototype,"_atmosphere",void 0),e([n({readOnly:!0})],I.prototype,"_stars",null),e([n({readOnly:!0})],I.prototype,"_precipitation",null),e([n({readOnly:!0})],I.prototype,"_clouds",null),e([n({readOnly:!0})],I.prototype,"_cloudsComposition",null),e([n({readOnly:!0})],I.prototype,"_fog",null),e([n({readOnly:!0})],I.prototype,"weatherEnabled",null),e([n({readOnly:!0})],I.prototype,"_precipitationEnabled",null),e([n({readOnly:!0})],I.prototype,"_weatherUpdateParameters",null),I=U=e([h("esri.views.3d.environment.EnvironmentRenderer")],I);class V{constructor(){this.fog=new N,this.hazeAmount=1}copyFrom(e){this.fog.amount=e.fog.amount,this.hazeAmount=e.hazeAmount,this.fog.strength=e.fog.strength,d(this.fog.color,e.fog.color)}lerp(e,s,r){this.fog.amount=t(e.fog.amount,s.fog.amount,r),this.hazeAmount=t(e.hazeAmount,s.hazeAmount,r),this.fog.strength=t(e.fog.strength,s.fog.strength,r),p(this.fog.color,e.fog.color,s.fog.color,r)}}const k=u(.5,.5,.5),q=u(1.5,1.5,1.5);let D;export{I as EnvironmentRenderer,V as WeatherParameters};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../core/has.js";import{lerp as t}from"../../../core/mathUtils.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{watch as r,syncAndInitial as i,initial as a,sync as o}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{l,c as d,m as p}from"../../../chunks/vec32.js";import{fromValues as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as m}from"../../../geometry/ellipsoidUtils.js";import{isMoon as c,isEarth as _,isMars as g}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as w}from"../../ViewingMode.js";import{AtmosphereType as f}from"./AtmosphereType.js";import{ChapmanAtmosphere as y}from"./ChapmanAtmosphere.js";import{CloudsComposition as v}from"./CloudsComposition.js";import{isReadyCloudsData as P,CloudsRenderingStages as b}from"./CloudsData.js";import{CloudsGenerator as R}from"./CloudsGenerator.js";import{FadeMode as A}from"./CloudsParameters.js";import{cloudPresets as x}from"./CloudsPresets.js";import{Fog as F,FogParameters as N}from"./Fog.js";import{LocalAtmosphere as W}from"./LocalAtmosphere.js";import j from"./MarsAtmosphere.js";import{Precipitation as C}from"./Precipitation.js";import{Stars as E}from"./Stars.js";import{weatherHeightLimit as M}from"./weather.js";import{SyncRenderPlugin as O,ConsumesDepth as z,ConsumesNone as L}from"../webgl-engine/effects/RenderPlugin.js";import{RenderSlot as T}from"../webgl-engine/lib/RenderSlot.js";import{Update as S}from"../webgl-engine/lib/Update.js";var U;let I=U=class extends O{constructor(e){super(e),this.produces=new Map([[T.ENVIRONMENT_OPAQUE,()=>!(null===this._atmosphere&&null===this._stars)],[T.ENVIRONMENT_TRANSPARENT,()=>!(null===this._atmosphere)]]),this._context=null,this._atmosphere=null,this._oldWeatherParameters=new V,this._newWeatherParameters=new V,this._fadedWeatherParameters=new V,this._weatherParameters=this._newWeatherParameters}initialize(){this.view._stage.addRenderPlugin(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:f.None}consumes(){return this._atmosphereType===f.Realistic?z:L}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 l(this.view.state.camera.eye)-m(this.view.spatialReference).radius<=M}get usedMemory(){return this._clouds?.usedMemory??0}get _stars(){const e=this.view,t=e.environment?.starsEnabled??!1,r=this._get("_stars");return t&&null!=this._context?null!=r?r:new E({view:e,requestRender:()=>this._setNeedsRender()}):(s(r),null)}get _precipitation(){const e=this._get("_precipitation");if(!this._precipitationEnabled||null==this._context)return s(e),null;const t=this.view,r=this._context;return null!=e&&e.context===r?e:(s(e),new C({context:r,view:t}))}get _clouds(){const e=this._get("_clouds");if(!this.weatherEnabled||null==this._context)return s(e),null;if(null!=e)return e;const t=this.view,r=this._context;return s(e),new R({context:r,view:t,requestRender:()=>this._setNeedsRender()})}get _cloudsComposition(){const e=this._get("_cloudsComposition");if(!this.weatherEnabled||null==this._context)return s(e),null;const t=this.view.state.viewingMode,r=this._context.renderContext.rctx,i=m(this.view.spatialReference).radius;return null!=e&&e.viewingMode===t&&e.planetRadius===i?e:(s(e),new v({rctx:r,viewingMode:t,planetRadius:i,requestRender:()=>this._setNeedsRender()}))}get _fog(){const e=this._get("_fog");if(!this.weatherEnabled||null==this._context)return s(e),null;if(null!=e)return e;const t=this.view,r=this._context,i=this._context.renderContext.rctx,a=this.view.state.viewingMode;return new F({context:r,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([r((()=>({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled})),(e=>this._updateAtmosphere(e)),i),r((()=>this._stars),t),r((()=>this._precipitation),t),r((()=>this._clouds),(()=>this._updateWeather()),a),r((()=>this._fog),(()=>this._updateFogHaze()),a),r((()=>this.view.state.mode),(()=>{this._setNeedsRender()}),o),r((()=>this._weatherUpdateParameters),(()=>{this._updateWeather(),this._updateFogHaze()}),i)])}uninitializeRenderContext(){this._context=null,this._atmosphere=s(this._atmosphere),this._set("_stars",s(this._stars)),this._set("_precipitation",s(this._precipitation)),this._set("_clouds",s(this._clouds)),this._set("_cloudsComposition",s(this._cloudsComposition)),this._set("_fog",s(this._fog))}prepareRender(e){e.bindParameters.cloudsFade.data=P(this._clouds)?this._clouds:null,"local"!==this.view.viewingMode&&null!=e.bindParameters.cloudsFade.data?.cubeMap&&(this._updateWeatherFading(e.bindParameters,e.time),e.bindParameters.cloudsFade.renderingStage===b.FINISHED&&null!=this._clouds&&0===this._clouds.coverage&&!1===this._clouds.running&&(this._clouds.destroyFrameBufferCube(),e.bindParameters.cloudsFade.data=null))}renderNode(e){switch(e.bindParameters.slot){case T.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)),e.bindParameters.cloudsFade.isFading&&null!=this._context&&null!=e.bindParameters.cloudsFade.data?.cubeMap&&this._context.requestRender());break;case T.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),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===S.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,t){e.cloudsFade.updateFading(e.camera,this.view.state.mode,t,this.view.qualitySettings.fadeDuration),e.cloudsFade.updateParallax(e.camera),e.weatherFading&&(this._updateLighting(e),this._updateFogAtmoshpere(e))}_updateLighting(e){e.cloudsFade.fadeMode!==A.CROSS_FADE&&e.cloudsFade.fadeMode!==A.FADE_IN?e.fadeLighting(0):e.fadeLighting(e.cloudsFade.fadeFactor)}_updateFogAtmoshpere(e){e.cloudsFade.fadeMode!==A.CROSS_FADE&&e.cloudsFade.fadeMode!==A.FADE_IN?this._fadeWeather(0):this._fadeWeather(e.cloudsFade.fadeFactor)}_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(x[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 s=this._context.renderContext.bindParameters;switch(this._oldWeatherParameters.copyFrom(this._weatherParameters),e.type){case"foggy":this._newWeatherParameters.fog.strength=t(3e-5,.005,e.weatherAdjustment**3),d(this._newWeatherParameters.fog.color,D),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender();break;case"rainy":this._newWeatherParameters.fog.strength=t(4e-6,2e-4,(e.effect??0)**3),d(this._newWeatherParameters.fog.color,q),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=0,this._setNeedsRender();break;case"snowy":this._newWeatherParameters.fog.strength=t(4e-6,2e-4,(e.effect??0)**3),d(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()}s.weatherFading?this._fadeWeather(0):this._fadeWeather(1)}_updateAtmosphere(e){const t=this._selectAtmosphereType(e);if(t!==f.None&&this._context){if(!this._atmosphere||this._atmosphere.type!==t){this._atmosphere=s(this._atmosphere);const e=this._getAtmosphereClass(t);e&&(this._atmosphere=new e(this.view,this._context))}}else this._atmosphere=s(this._atmosphere);this._setNeedsRender()}_getAtmosphereClass(e){switch(e){case f.Realistic:return y;case f.Local:return W;case f.Mars:return j;default:case f.None:return null}}_selectAtmosphereType(e){const{enabled:t,viewingMode:s}=e;return!t||c(this.view.spatialReference)?f.None:s===w.Local?f.Local:null!=this._context&&y.isSupported(this._context)&&_(this.view.spatialReference)?f.Realistic:g(this.view.spatialReference)?f.Mars:f.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=>{H=U.prototype._getAtmosphereClass,U.prototype._getAtmosphereClass=e},restoreGetAtmosphereClass:()=>{U.prototype._getAtmosphereClass=H}}}};e([n({constructOnly:!0})],I.prototype,"view",void 0),e([n({readOnly:!0})],I.prototype,"atmosphere",null),e([n({readOnly:!0})],I.prototype,"_atmosphereType",null),e([n({type:Boolean,readOnly:!0})],I.prototype,"updating",null),e([n({readOnly:!0})],I.prototype,"weatherVisible",null),e([n()],I.prototype,"_context",void 0),e([n()],I.prototype,"_atmosphere",void 0),e([n({readOnly:!0})],I.prototype,"_stars",null),e([n({readOnly:!0})],I.prototype,"_precipitation",null),e([n({readOnly:!0})],I.prototype,"_clouds",null),e([n({readOnly:!0})],I.prototype,"_cloudsComposition",null),e([n({readOnly:!0})],I.prototype,"_fog",null),e([n({readOnly:!0})],I.prototype,"weatherEnabled",null),e([n({readOnly:!0})],I.prototype,"_precipitationEnabled",null),e([n({readOnly:!0})],I.prototype,"_weatherUpdateParameters",null),I=U=e([h("esri.views.3d.environment.EnvironmentRenderer")],I);class V{constructor(){this.fog=new N,this.hazeAmount=1}copyFrom(e){this.fog.amount=e.fog.amount,this.hazeAmount=e.hazeAmount,this.fog.strength=e.fog.strength,d(this.fog.color,e.fog.color)}lerp(e,s,r){this.fog.amount=t(e.fog.amount,s.fog.amount,r),this.hazeAmount=t(e.hazeAmount,s.hazeAmount,r),this.fog.strength=t(e.fog.strength,s.fog.strength,r),p(this.fog.color,e.fog.color,s.fog.color,r)}}const q=u(.5,.5,.5),D=u(1.5,1.5,1.5);let H;export{I as EnvironmentRenderer,V 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.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Accessor.js";import{smoothstep as s}from"../../../core/mathUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{n as i,j as a,h as n,k as c,l as m}from"../../../chunks/vec32.js";import{create as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as h}from"../../../geometry/ellipsoidUtils.js";import{atmosphereHeight as u}from"./atmosphereUtils.js";import{F as d}from"../../../chunks/Fog.glsl.js";import{FogTechnique as l}from"./FogTechnique.js";import{weatherHeightLimit as g}from"./weather.js";import{Pos2Tex as f}from"../webgl-engine/lib/DefaultVertexBufferLayouts.js";import{createQuadVAO as _}from"../webgl-engine/lib/glUtil3D.js";import{PrimitiveType as j}from"../../webgl/enums.js";const b=.95,x=1;let v=class extends e{constructor(t){super(t),this._passParameters=new d;const e=t.context.renderContext.rctx;this._vao=_(e,f),this._technique=new l(t);const s=h(t.view.spatialReference);this._planetRadius=s.radius,this._atmosphereRadius=s.radius+u}destroy(){this._technique.release(),this._vao.dispose()}set strength(t){this._passParameters.fogStrength=t}get strength(){return this._passParameters.fogStrength}render(t,e){if(this._update(t,e),this._passParameters.fogAmount<=0)return;const s=this._technique;if(!s.compiled)return void this.context.requestRender();const r=t.offscreenRenderingHelper;r.renderDepthDetached((()=>{this._passParameters.depthTexture=r.depthTexture;const e=t.rctx.bindTechnique(s,t.bindParameters,this._passParameters);this._renderFog(e,t)}))}_renderFog(t,e){const s=e.rctx;s.bindVAO(this._vao),t.assertCompatibleVertexAttributeLocations(this._vao),s.drawArrays(j.TRIANGLE_STRIP,0,4)}_update(t,e){const r=t.bindParameters.camera;i(P,r.eye);const o=Math.max(0,a(P,t.bindParameters.lighting.mainLight.direction)),p=e.color;n(w,p,.1),c(this._passParameters.fogColor,w,p,o);const h=m(r.eye),u=h*h;this._passParameters.atmosphereC=u-this._atmosphereRadius*this._atmosphereRadius,this._passParameters.fogAmount=(1-s(b*g,x*g,Math.abs(h-this._planetRadius)))*e.amount,this._passParameters.fogStrength=e.strength}static isSupported(t){return t.capabilities.depthTexture}};t([r({constructOnly:!0})],v.prototype,"context",void 0),t([r({constructOnly:!0})],v.prototype,"view",void 0),t([r({constructOnly:!0})],v.prototype,"rctx",void 0),t([r({constructOnly:!0})],v.prototype,"viewingMode",void 0),v=t([o("esri.views.3d.environment.Fog")],v);class y{constructor(){this.color=p(),this.strength=0,this.amount=0}}const P=p(),w=p();export{v as Fog,y as FogParameters};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Accessor.js";import{smoothstep as s}from"../../../core/mathUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{n as i,k as a,h as n,m as c,l as m}from"../../../chunks/vec32.js";import{create as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as h}from"../../../geometry/ellipsoidUtils.js";import{atmosphereHeight as u}from"./atmosphereUtils.js";import{F as d}from"../../../chunks/Fog.glsl.js";import{FogTechnique as l}from"./FogTechnique.js";import{weatherHeightLimit as g}from"./weather.js";import{Pos2Tex as f}from"../webgl-engine/lib/DefaultVertexBufferLayouts.js";import{createQuadVAO as _}from"../webgl-engine/lib/glUtil3D.js";import{PrimitiveType as j}from"../../webgl/enums.js";const b=.95,x=1;let v=class extends e{constructor(t){super(t),this._passParameters=new d;const e=t.context.renderContext.rctx;this._vao=_(e,f),this._technique=new l(t);const s=h(t.view.spatialReference);this._planetRadius=s.radius,this._atmosphereRadius=s.radius+u}destroy(){this._technique.release(),this._vao.dispose()}set strength(t){this._passParameters.fogStrength=t}get strength(){return this._passParameters.fogStrength}render(t,e){if(this._update(t,e),this._passParameters.fogAmount<=0)return;const s=this._technique;if(!s.compiled)return void this.context.requestRender();const r=t.offscreenRenderingHelper;r.renderDepthDetached((()=>{this._passParameters.depthTexture=r.depthTexture;const e=t.rctx.bindTechnique(s,t.bindParameters,this._passParameters);this._renderFog(e,t)}))}_renderFog(t,e){const s=e.rctx;s.bindVAO(this._vao),t.assertCompatibleVertexAttributeLocations(this._vao),s.drawArrays(j.TRIANGLE_STRIP,0,4)}_update(t,e){const r=t.bindParameters.camera;i(P,r.eye);const o=Math.max(0,a(P,t.bindParameters.lighting.mainLight.direction)),p=e.color;n(w,p,.1),c(this._passParameters.fogColor,w,p,o);const h=m(r.eye),u=h*h;this._passParameters.atmosphereC=u-this._atmosphereRadius*this._atmosphereRadius,this._passParameters.fogAmount=(1-s(b*g,x*g,Math.abs(h-this._planetRadius)))*e.amount,this._passParameters.fogStrength=e.strength}static isSupported(t){return t.capabilities.depthTexture}};t([r({constructOnly:!0})],v.prototype,"context",void 0),t([r({constructOnly:!0})],v.prototype,"view",void 0),t([r({constructOnly:!0})],v.prototype,"rctx",void 0),t([r({constructOnly:!0})],v.prototype,"viewingMode",void 0),v=t([o("esri.views.3d.environment.Fog")],v);class y{constructor(){this.color=p(),this.strength=0,this.amount=0}}const P=p(),w=p();export{v as Fog,y as FogParameters};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{lerp as e,clamp as t}from"../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../core/maybe.js";import{watch as r,syncAndInitial as i}from"../../../core/reactiveUtils.js";import{lookAt as o}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as h}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{l as n,h as m,g as p,p as c,b as u,o as l}from"../../../chunks/vec32.js";import{create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as d}from"../../../geometry/ellipsoidUtils.js";import{newFloatArray as f}from"../../../geometry/support/FloatArray.js";import{AtmosphereType as g}from"./AtmosphereType.js";import{computeInnerAltitudeFade as b,innerAtmosphereDepth as x}from"./atmosphereUtils.js";import{S as R}from"../../../chunks/SimpleAtmosphere.glsl.js";import{SimpleAtmosphereTechnique as j}from"./SimpleAtmosphereTechnique.js";import{SimpleAtmosphereTechniqueConfiguration as V,SimpleAtmosphereGeometry as y}from"./SimpleAtmosphereTechniqueConfiguration.js";import{marsAtmosphereTextureSimple as w}from"./resources/MarsAtmosphereTexture.js";import{makePiecewiseLinearFunction as A}from"../support/mathUtils.js";import{glLayout as P}from"../support/buffer/glUtil.js";import{newLayout as T}from"../support/buffer/InterleavedLayout.js";import{Default3D as q}from"../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{createQuadVAO as v}from"../webgl-engine/lib/glUtil3D.js";import{project as S}from"../webgl-engine/lib/Util.js";import{VertexArrayObject as F}from"../webgl-engine/lib/VertexArrayObject.js";import{VertexAttribute as C}from"../webgl-engine/lib/VertexAttribute.js";import{BufferObject as M}from"../../webgl/BufferObject.js";import{TextureWrapMode as U,PrimitiveType as W,Usage as I}from"../../webgl/enums.js";import{Texture as O}from"../../webgl/Texture.js";import{TextureDescriptor as D}from"../../webgl/TextureDescriptor.js";import{vertexCount as L}from"../../webgl/Util.js";const E=128,G=-x,H=0,N=50,k=()=>1-511/512,B=A([[50,.1015625],[500,.21875],[5e3,1-250/512],[5e4,.4140625]]);class z{constructor(e,t){this.view=e,this.type=g.Mars,this._passParameters=new R,this._vaoCount=0,this._texV1=1;const s=d(e.spatialReference);this._planetRadius=s.radius,this._outerRimWidth=s.outerAtmosphereRimWidth,this._innerRimFactor=(this._planetRadius+G)/this._planetRadius,this._middleRimFactor=(this._planetRadius+H)/this._planetRadius,this._outerRimFactor=(this._planetRadius+this._outerRimWidth)/this._planetRadius,this._texV0=H/this._outerRimWidth,this._texVScale=this._texV1-this._texV0,this._techniqueRepository=t.techniqueRepository;const o=t.renderContext.rctx;this._cameraChangeHandle=r((()=>this.view.state?.camera),(()=>t.requestRender()),i),this._vao=this._createRibbon(o),this._vaoCount=L(this._vao,"geometry"),this._fadeVao=v(o),this._fadeVaoCount=L(this._fadeVao,"geometry");const a=new D;a.wrapMode=U.CLAMP_TO_EDGE,a.flipped=!0,a.width=1,a.height=512,this._passParameters.texture=new O(o,a,w);const h=new V;h.geometry=y.Cone,this._coneTechnique=this._techniqueRepository.acquire(j,h),h.geometry=y.Underground,this._undergroundTechnique=this._techniqueRepository.acquire(j,h)}destroy(){this._coneTechnique.release(),this._undergroundTechnique.release(),this._cameraChangeHandle.remove(),this._passParameters.texture=s(this._passParameters.texture),this._fadeVao.dispose(),this._vao.dispose()}render(e){const t=e.bindParameters.camera;this._update(t);const s=e.rctx;this._passParameters.undergroundFadeAlpha<1&&(s.bindTechnique(this._coneTechnique,e.bindParameters,this._passParameters),s.bindVAO(this._vao),s.drawArrays(W.TRIANGLES,0,this._vaoCount)),this._passParameters.undergroundFadeAlpha>0&&(s.bindTechnique(this._undergroundTechnique,e.bindParameters,this._passParameters),s.bindVAO(this._fadeVao),s.drawArrays(W.TRIANGLE_STRIP,0,this._fadeVaoCount))}renderHaze(){}_update(s){const r=_(),i=this._planetRadius,o=n(s.eye),a=o-i;if(a<0){const e=Math.min(-a/5e3,1);this._passParameters.undergroundFadeAlpha=e}else this._passParameters.undergroundFadeAlpha=0;const p=Math.max(N,a),c=i+G;this._passParameters.innerScale=Y(i+p,i,c)-1,this._passParameters.altitudeFade=b(a),m(r,s.eye,(i+N)/o),J(r,s.center,s.up,i,this._passParameters.silhouette);const u=this._computeScreenRimWidth(s,r,s.up,this._passParameters.silhouette),l=k(),d=B(a);let f=this._texV0+l*this._texVScale,g=this._texV0+u*d*this._texVScale;if(a>N){J(s.eye,s.center,s.up,i,this._passParameters.silhouette);const r=this._computeScreenRimWidth(s,s.eye,s.up,this._passParameters.silhouette),o=t((r-1.5)/(u-1.5),0,1);f=this._texV0+o*l*this._texVScale,g=this._texV0+e(this._texV1,u*d,o)*this._texVScale}h(this._passParameters.texV,f,g)}_createRibbon(e){const t=f(3+3*E*3),s=new Uint32Array(3*E*5);t[0]=0,t[1]=0,t[2]=-1;for(let o=0;o<E;o++){const e=9*o+3;t[e]=o,t[e+1]=this._innerRimFactor,t[e+2]=-1,t[e+3]=o,t[e+4]=this._middleRimFactor,t[e+5]=0,t[e+6]=o,t[e+7]=this._outerRimFactor,t[e+8]=1;const r=3*o+1,i=o===E-1?1:r+3,a=15*o;s[a]=r,s[a+1]=r+1,s[a+2]=i+1,s[a+3]=i+1,s[a+4]=i,s[a+5]=r,s[a+6]=r+1,s[a+7]=r+2,s[a+8]=i+2,s[a+9]=i+2,s[a+10]=i+1,s[a+11]=r+1,s[a+12]=r,s[a+13]=i,s[a+14]=0}const r=Z.createBuffer(s.length),i=r.position;for(let o=0;o<s.length;++o){const e=3*s[o];i.set(o,0,t[e]),i.set(o,1,t[e+1]),i.set(o,2,t[e+2])}return new F(e,q,{geometry:P(Z)},{geometry:M.createVertex(e,I.STATIC_DRAW,r.buffer)})}_computeScreenRimWidth(e,t,s,r){return p(Q,r.center,r.v2),m(X,Q,this._outerRimFactor),o(K,t,Q,s),S(Q,K,e.projectionMatrix,e.viewport,Q),S(X,K,e.projectionMatrix,e.viewport,X),c(Q,X)/e.height}}function J(e,t,s,r,i){const o=n(e),a=r*Math.sqrt(o*o-r*r)/o,h=Math.sqrt(r*r-a*a),p=i.v1,c=i.v2;return m(i.center,e,h/o),u(p,e,t),l(p)<1&&u(p,e,s),m(p,p,a/n(p)),u(c,p,e),m(c,c,a/n(c)),a}const K=a(),Q=_(),X=_();function Y(e,t,s){return e*e/(Math.sqrt(e*e-t*t)*Math.sqrt(e*e-s*s)+t*s)}const Z=T().vec3f(C.POSITION);export{z as default};
5
+ import{lerp as e,clamp as t}from"../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../core/maybe.js";import{watch as r,syncAndInitial as i}from"../../../core/reactiveUtils.js";import{lookAt as o}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as h}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{l as n,h as m,g as p,q as c,b as u,p as l}from"../../../chunks/vec32.js";import{create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as d}from"../../../geometry/ellipsoidUtils.js";import{newFloatArray as f}from"../../../geometry/support/FloatArray.js";import{AtmosphereType as g}from"./AtmosphereType.js";import{computeInnerAltitudeFade as b,innerAtmosphereDepth as x}from"./atmosphereUtils.js";import{S as R}from"../../../chunks/SimpleAtmosphere.glsl.js";import{SimpleAtmosphereTechnique as j}from"./SimpleAtmosphereTechnique.js";import{SimpleAtmosphereTechniqueConfiguration as V,SimpleAtmosphereGeometry as y}from"./SimpleAtmosphereTechniqueConfiguration.js";import{marsAtmosphereTextureSimple as w}from"./resources/MarsAtmosphereTexture.js";import{makePiecewiseLinearFunction as A}from"../support/mathUtils.js";import{glLayout as P}from"../support/buffer/glUtil.js";import{newLayout as q}from"../support/buffer/InterleavedLayout.js";import{Default3D as T}from"../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{createQuadVAO as v}from"../webgl-engine/lib/glUtil3D.js";import{project as S}from"../webgl-engine/lib/Util.js";import{VertexArrayObject as F}from"../webgl-engine/lib/VertexArrayObject.js";import{VertexAttribute as C}from"../webgl-engine/lib/VertexAttribute.js";import{BufferObject as M}from"../../webgl/BufferObject.js";import{TextureWrapMode as U,PrimitiveType as W,Usage as I}from"../../webgl/enums.js";import{Texture as O}from"../../webgl/Texture.js";import{TextureDescriptor as D}from"../../webgl/TextureDescriptor.js";import{vertexCount as L}from"../../webgl/Util.js";const E=128,G=-x,H=0,N=50,k=()=>1-511/512,B=A([[50,.1015625],[500,.21875],[5e3,1-250/512],[5e4,.4140625]]);class z{constructor(e,t){this.view=e,this.type=g.Mars,this._passParameters=new R,this._vaoCount=0,this._texV1=1;const s=d(e.spatialReference);this._planetRadius=s.radius,this._outerRimWidth=s.outerAtmosphereRimWidth,this._innerRimFactor=(this._planetRadius+G)/this._planetRadius,this._middleRimFactor=(this._planetRadius+H)/this._planetRadius,this._outerRimFactor=(this._planetRadius+this._outerRimWidth)/this._planetRadius,this._texV0=H/this._outerRimWidth,this._texVScale=this._texV1-this._texV0,this._techniqueRepository=t.techniqueRepository;const o=t.renderContext.rctx;this._cameraChangeHandle=r((()=>this.view.state?.camera),(()=>t.requestRender()),i),this._vao=this._createRibbon(o),this._vaoCount=L(this._vao,"geometry"),this._fadeVao=v(o),this._fadeVaoCount=L(this._fadeVao,"geometry");const a=new D;a.wrapMode=U.CLAMP_TO_EDGE,a.flipped=!0,a.width=1,a.height=512,this._passParameters.texture=new O(o,a,w);const h=new V;h.geometry=y.Cone,this._coneTechnique=this._techniqueRepository.acquire(j,h),h.geometry=y.Underground,this._undergroundTechnique=this._techniqueRepository.acquire(j,h)}destroy(){this._coneTechnique.release(),this._undergroundTechnique.release(),this._cameraChangeHandle.remove(),this._passParameters.texture=s(this._passParameters.texture),this._fadeVao.dispose(),this._vao.dispose()}render(e){const t=e.bindParameters.camera;this._update(t);const s=e.rctx;this._passParameters.undergroundFadeAlpha<1&&(s.bindTechnique(this._coneTechnique,e.bindParameters,this._passParameters),s.bindVAO(this._vao),s.drawArrays(W.TRIANGLES,0,this._vaoCount)),this._passParameters.undergroundFadeAlpha>0&&(s.bindTechnique(this._undergroundTechnique,e.bindParameters,this._passParameters),s.bindVAO(this._fadeVao),s.drawArrays(W.TRIANGLE_STRIP,0,this._fadeVaoCount))}renderHaze(){}_update(s){const r=_(),i=this._planetRadius,o=n(s.eye),a=o-i;if(a<0){const e=Math.min(-a/5e3,1);this._passParameters.undergroundFadeAlpha=e}else this._passParameters.undergroundFadeAlpha=0;const p=Math.max(N,a),c=i+G;this._passParameters.innerScale=Y(i+p,i,c)-1,this._passParameters.altitudeFade=b(a),m(r,s.eye,(i+N)/o),J(r,s.center,s.up,i,this._passParameters.silhouette);const u=this._computeScreenRimWidth(s,r,s.up,this._passParameters.silhouette),l=k(),d=B(a);let f=this._texV0+l*this._texVScale,g=this._texV0+u*d*this._texVScale;if(a>N){J(s.eye,s.center,s.up,i,this._passParameters.silhouette);const r=this._computeScreenRimWidth(s,s.eye,s.up,this._passParameters.silhouette),o=t((r-1.5)/(u-1.5),0,1);f=this._texV0+o*l*this._texVScale,g=this._texV0+e(this._texV1,u*d,o)*this._texVScale}h(this._passParameters.texV,f,g)}_createRibbon(e){const t=f(3+3*E*3),s=new Uint32Array(3*E*5);t[0]=0,t[1]=0,t[2]=-1;for(let o=0;o<E;o++){const e=9*o+3;t[e]=o,t[e+1]=this._innerRimFactor,t[e+2]=-1,t[e+3]=o,t[e+4]=this._middleRimFactor,t[e+5]=0,t[e+6]=o,t[e+7]=this._outerRimFactor,t[e+8]=1;const r=3*o+1,i=o===E-1?1:r+3,a=15*o;s[a]=r,s[a+1]=r+1,s[a+2]=i+1,s[a+3]=i+1,s[a+4]=i,s[a+5]=r,s[a+6]=r+1,s[a+7]=r+2,s[a+8]=i+2,s[a+9]=i+2,s[a+10]=i+1,s[a+11]=r+1,s[a+12]=r,s[a+13]=i,s[a+14]=0}const r=Z.createBuffer(s.length),i=r.position;for(let o=0;o<s.length;++o){const e=3*s[o];i.set(o,0,t[e]),i.set(o,1,t[e+1]),i.set(o,2,t[e+2])}return new F(e,T,{geometry:P(Z)},{geometry:M.createVertex(e,I.STATIC_DRAW,r.buffer)})}_computeScreenRimWidth(e,t,s,r){return p(Q,r.center,r.v2),m(X,Q,this._outerRimFactor),o(K,t,Q,s),S(Q,K,e.projectionMatrix,e.viewport,Q),S(X,K,e.projectionMatrix,e.viewport,X),c(Q,X)/e.height}}function J(e,t,s,r,i){const o=n(e),a=r*Math.sqrt(o*o-r*r)/o,h=Math.sqrt(r*r-a*a),p=i.v1,c=i.v2;return m(i.center,e,h/o),u(p,e,t),l(p)<1&&u(p,e,s),m(p,p,a/n(p)),u(c,p,e),m(c,c,a/n(c)),a}const K=a(),Q=_(),X=_();function Y(e,t,s){return e*e/(Math.sqrt(e*e-t*t)*Math.sqrt(e*e-s*s)+t*s)}const Z=q().vec3f(C.POSITION);export{z 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.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Evented.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{after as i}from"../../../core/promiseUtils.js";import{watch as s,sync as n,syncAndInitial as o}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{s as d,h as l,c,k as p}from"../../../chunks/vec32.js";import{create as _,fromValues as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{canProjectToWGS84ComparableLonLat as m}from"../../../geometry/projection.js";import{projectPointToWGS84ComparableLonLat as f}from"../../../geometry/projection/projectPointToWGS84ComparableLonLat.js";import{isEarth as g}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as P}from"../../ViewingMode.js";import{EnvironmentRenderer as v}from"./EnvironmentRenderer.js";import{positionToTimezoneInfo as b}from"../support/earthUtils.js";import{computeColorAndIntensity as C,computeVirtualLightDirection as w,computeShadowsEnabled as y,ColorAndIntensity as U}from"../support/sunUtils.js";import{Update as S}from"../webgl-engine/lib/Update.js";import{MainLight as T,AmbientLight as R,FillLight as M}from"../webgl-engine/lighting/Lightsources.js";let W=class extends t.EventedAccessor{constructor(){super(),this._referencePointUpdateDelay=200,this._referencePointUpdateInterval=3e3,this._referencePointUpdateDistThreshold=1e6,this._referencePosUpdateQuery=null,this._referencePosMapCoordsRequested=null,this._viewHandlesKey="viewHandles",this._preserveAbsoluteDateTime=!1,this._trackingEnabled=!1,this._referencePosResetPreserveAbsoluteTime=!1,this._referencePosUpdateTimer=null,this._referencePosMapCoords=null,this._mainLight=new T,this._ambientLight=new R,this._moonLight=new M,this.disableQueries=!1,this._disableWeather=!1,this._renderer=null,this._referencePosWGS84Comparable=null,this._resetReferencePosition()}destroy(){this.disconnectView()}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===P.Global&&g(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 v({view:e});const t=()=>this._updateRenderParameters(),r=()=>this._cameraHandler();this.addHandles([s((()=>e.environment.lighting),(e=>this._updateLightingHandler(e)),n),s((()=>"virtual"!==e.environment.lighting.type?e.environment.lighting.date:null),(e=>this._lightingDateHandler(e)),n),s((()=>e.stationary),(()=>this._interactingStationaryHandler())),s((()=>e.environment.lighting.directShadowsEnabled),t,n),s((()=>e.qualitySettings.ambientOcclusion),t,n),s((()=>e.qualitySettings.reflections),t,n),s((()=>e.spatialReference),(()=>this._resetReferencePosition(!0)),n),s((()=>e.environment.weather.type),(()=>this._updateLighting(null,S.Faded)),n),s((()=>this.weatherEnabled),(()=>this._updateLighting(null,S.Faded)),n),s((()=>e.viewingMode),(()=>this._resetReferencePosition(!0)),o),s((()=>"virtual"!==e.environment.lighting.type&&e.environment.lighting.cameraTrackingEnabled),(e=>this._updateCameraTracking(e)),o),s((()=>e.state.camera),r,o),s((()=>this.disableQueries),r)],this._viewHandlesKey),this._updateRenderParameters(),this._updateLighting(),this._cameraHandler(),this.notifyChange("updating")}disconnectView(){this.removeHandles(this._viewHandlesKey),this._resetReferencePosition(),this._renderer=r(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(!m(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=b(this._referencePosWGS84Comparable,j);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=g(this._view.spatialReference);if(r&&!m(this._view.spatialReference))return"virtual"===this._view.environment.lighting.type&&this._updateLighting(),!1;const i=e.position;return null==this._referencePosWGS84Comparable&&(this._referencePosWGS84Comparable=_()),r?f(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=S.Immediate){const r=this._view;e=e||("virtual"===r.environment.lighting.type?null:r.environment.lighting.date);const i=this._referencePosWGS84Comparable,s=i?H:G,n=this.weatherVisible?r.environment.weather.type:"disabled";null!=i?C(e,i,r.state.viewingMode,n,r.state.camera,s):"virtual"===r.environment.lighting.type&&w(r.state.camera,r.state.viewingMode,s.direct.directionToLightSource);const o=this._mainLight,a=s.direct;l(o.intensity,a.color,a.intensity*Math.PI),c(o.direction,a.directionToLightSource),o.specularStrength=s.specularStrength,o.environmentStrength=s.environmentStrength;const h=this._ambientLight;l(h.intensity,s.ambient.color,s.ambient.intensity);const d=this._moonLight;p(d.intensity,q,E,s.globalFactor);const _=(1-.5*s.globalFactor)*(1-.4*s.noonFactor*(1-s.globalFactor));l(d.intensity,d.intensity,_),c(d.direction,a.directionToLightSource),this._renderer.updateLightSources([o,h,d],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=L;r.setTime((t||this._view.environment.lighting.date).getTime());const i=b(e,j);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 t=null==this._referencePosWGS84Comparable||y(this._referencePosWGS84Comparable[2],this._view.state.viewingMode);e.renderer.setParameters({shadowMap:this._view.environment.lighting.directShadowsEnabled&&t,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=i(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=i(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([a({type:Boolean,readOnly:!0})],W.prototype,"updating",null),e([a()],W.prototype,"disableQueries",void 0),e([a()],W.prototype,"_disableWeather",void 0),e([a()],W.prototype,"weatherEnabled",null),e([a()],W.prototype,"weatherVisible",null),e([a()],W.prototype,"referencePositionWGS84Comparable",null),e([a()],W.prototype,"_renderer",void 0),e([a()],W.prototype,"_referencePosWGS84Comparable",void 0),W=e([h("esri.views.3d.environment.SceneViewEnvironmentManager")],W);const H=new U,G=new U,L=new Date,j={hours:0,minutes:0,seconds:0},q=u(.22,.22,.33),E=u(.22,.22,.22);export{W as SceneViewEnvironmentManager};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Evented.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{after as i}from"../../../core/promiseUtils.js";import{watch as s,sync as n,syncAndInitial as o}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{s as d,h as l,c,m as p}from"../../../chunks/vec32.js";import{create as _,fromValues as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{canProjectToWGS84ComparableLonLat as m}from"../../../geometry/projection.js";import{projectPointToWGS84ComparableLonLat as f}from"../../../geometry/projection/projectPointToWGS84ComparableLonLat.js";import{isEarth as g}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as P}from"../../ViewingMode.js";import{EnvironmentRenderer as v}from"./EnvironmentRenderer.js";import{positionToTimezoneInfo as b}from"../support/earthUtils.js";import{computeColorAndIntensity as C,computeVirtualLightDirection as w,computeShadowsEnabled as y,ColorAndIntensity as U}from"../support/sunUtils.js";import{Update as S}from"../webgl-engine/lib/Update.js";import{MainLight as T,AmbientLight as R,FillLight as M}from"../webgl-engine/lighting/Lightsources.js";let W=class extends t.EventedAccessor{constructor(){super(),this._referencePointUpdateDelay=200,this._referencePointUpdateInterval=3e3,this._referencePointUpdateDistThreshold=1e6,this._referencePosUpdateQuery=null,this._referencePosMapCoordsRequested=null,this._viewHandlesKey="viewHandles",this._preserveAbsoluteDateTime=!1,this._trackingEnabled=!1,this._referencePosResetPreserveAbsoluteTime=!1,this._referencePosUpdateTimer=null,this._referencePosMapCoords=null,this._mainLight=new T,this._ambientLight=new R,this._moonLight=new M,this.disableQueries=!1,this._disableWeather=!1,this._renderer=null,this._referencePosWGS84Comparable=null,this._resetReferencePosition()}destroy(){this.disconnectView()}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===P.Global&&g(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 v({view:e});const t=()=>this._updateRenderParameters(),r=()=>this._cameraHandler();this.addHandles([s((()=>e.environment.lighting),(e=>this._updateLightingHandler(e)),n),s((()=>"virtual"!==e.environment.lighting.type?e.environment.lighting.date:null),(e=>this._lightingDateHandler(e)),n),s((()=>e.stationary),(()=>this._interactingStationaryHandler())),s((()=>e.environment.lighting.directShadowsEnabled),t,n),s((()=>e.qualitySettings.ambientOcclusion),t,n),s((()=>e.qualitySettings.reflections),t,n),s((()=>e.spatialReference),(()=>this._resetReferencePosition(!0)),n),s((()=>e.environment.weather.type),(()=>this._updateLighting(null,S.Faded)),n),s((()=>this.weatherEnabled),(()=>this._updateLighting(null,S.Faded)),n),s((()=>e.viewingMode),(()=>this._resetReferencePosition(!0)),o),s((()=>"virtual"!==e.environment.lighting.type&&e.environment.lighting.cameraTrackingEnabled),(e=>this._updateCameraTracking(e)),o),s((()=>e.state.camera),r,o),s((()=>this.disableQueries),r)],this._viewHandlesKey),this._updateRenderParameters(),this._updateLighting(),this._cameraHandler(),this.notifyChange("updating")}disconnectView(){this.removeHandles(this._viewHandlesKey),this._resetReferencePosition(),this._renderer=r(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(!m(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=b(this._referencePosWGS84Comparable,j);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=g(this._view.spatialReference);if(r&&!m(this._view.spatialReference))return"virtual"===this._view.environment.lighting.type&&this._updateLighting(),!1;const i=e.position;return null==this._referencePosWGS84Comparable&&(this._referencePosWGS84Comparable=_()),r?f(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=S.Immediate){const r=this._view;e=e||("virtual"===r.environment.lighting.type?null:r.environment.lighting.date);const i=this._referencePosWGS84Comparable,s=i?H:G,n=this.weatherVisible?r.environment.weather.type:"disabled";null!=i?C(e,i,r.state.viewingMode,n,r.state.camera,s):"virtual"===r.environment.lighting.type&&w(r.state.camera,r.state.viewingMode,s.direct.directionToLightSource);const o=this._mainLight,a=s.direct;l(o.intensity,a.color,a.intensity*Math.PI),c(o.direction,a.directionToLightSource),o.specularStrength=s.specularStrength,o.environmentStrength=s.environmentStrength;const h=this._ambientLight;l(h.intensity,s.ambient.color,s.ambient.intensity);const d=this._moonLight;p(d.intensity,q,E,s.globalFactor);const _=(1-.5*s.globalFactor)*(1-.4*s.noonFactor*(1-s.globalFactor));l(d.intensity,d.intensity,_),c(d.direction,a.directionToLightSource),this._renderer.updateLightSources([o,h,d],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=L;r.setTime((t||this._view.environment.lighting.date).getTime());const i=b(e,j);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 t=null==this._referencePosWGS84Comparable||y(this._referencePosWGS84Comparable[2],this._view.state.viewingMode);e.renderer.setParameters({shadowMap:this._view.environment.lighting.directShadowsEnabled&&t,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=i(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=i(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([a({type:Boolean,readOnly:!0})],W.prototype,"updating",null),e([a()],W.prototype,"disableQueries",void 0),e([a()],W.prototype,"_disableWeather",void 0),e([a()],W.prototype,"weatherEnabled",null),e([a()],W.prototype,"weatherVisible",null),e([a()],W.prototype,"referencePositionWGS84Comparable",null),e([a()],W.prototype,"_renderer",void 0),e([a()],W.prototype,"_referencePosWGS84Comparable",void 0),W=e([h("esri.views.3d.environment.SceneViewEnvironmentManager")],W);const H=new U,G=new U,L=new Date,j={hours:0,minutes:0,seconds:0},q=u(.22,.22,.33),E=u(.22,.22,.22);export{W as SceneViewEnvironmentManager};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../Color.js";import{multiplyOpacity as n}from"../../../core/colorUtils.js";import"../../../core/has.js";import{destroyHandle as i}from"../../../core/handleUtils.js";import{k as t}from"../../../chunks/vec32.js";import{create as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectVectorToVector as o}from"../../../geometry/projection/projectVectorToVector.js";import{onTheGroundElevationInfo as a,absoluteHeightElevationInfo as l}from"../../../support/elevationInfoUtils.js";import{ExtendedLineVisualElement as s,ExtensionType as c}from"./visualElements/ExtendedLineVisualElement.js";import{ParallelLineVisualElement as p}from"./visualElements/ParallelLineVisualElement.js";import{PointVisualElement as d}from"./visualElements/PointVisualElement.js";import{RightAngleQuadVisualElement as u}from"./visualElements/RightAngleQuadVisualElement.js";import{DrapedRenderGroup as m}from"../layers/interfaces.js";import{RenderOccludedFlag as f}from"../webgl-engine/lib/Material.js";import{toDehydratedPoint as g,create as v}from"../../interactive/sketch/normalizedPoint.js";import{defaults as h}from"../../interactive/snapping/Settings.js";import{SnappingDomain as E}from"../../interactive/snapping/SnappingDomain.js";import{LineSegmentHintType as C}from"../../interactive/snapping/snappingUtils.js";import{SnappingVisualizer as S}from"../../interactive/snapping/SnappingVisualizer.js";import{LineSnappingHint as j}from"../../interactive/snapping/hints/LineSnappingHint.js";import{vectorToRender as w}from"../../interactive/support/viewUtils.js";class O extends S{sortUniqueHints(e){return e.sort(((e,n)=>(n instanceof j?n.length:0)-(e instanceof j?e.length:0)))}visualizeIntersectionPoint(e,n){const{spatialReference:t,view:r}=n,o=D(n);return i(new d({view:r,primitive:"circle",geometry:g(e.intersectionPoint,t),elevationInfo:e.isDraped?a:l,size:20,outlineSize:2,color:o.intersectionPointColor,outlineColor:o.intersectionPointOutlineColor,pixelSnappingEnabled:!1,isDecoration:!0,attached:!0}))}visualizePoint(e,n){const{view:t,spatialReference:r}=n,o=D(n),a=R(e.point,e.domain,n);return i(new d({view:t,primitive:"circle",geometry:g(a,r),elevationInfo:x(e,n),size:20,outlineSize:2,color:o.pointColor,outlineColor:o.pointOutlineColor,pixelSnappingEnabled:!1,isDecoration:!0,attached:!0}))}visualizeLine(e,n){const{view:t,spatialReference:r}=n,o=D(n),a=R(e.lineStart,e.domain,n),l=R(e.lineEnd,e.domain,n);return i(this._createLineSegmentHint(e.type,a,l,r,x(e,n),t,o,e.isDraped,e.fadeLeft,e.fadeRight))}visualizeParallelSign(e,n){const{view:r,spatialReference:o}=n,a=D(n),{isDraped:l}=e,s=x(e,n),c=R(e.lineStart,e.domain,n),d=R(e.lineEnd,e.domain,n),u=H(c,o,s,r,l),g=H(d,o,s,r,l),v=t(g,u,g,.5),E=new p({view:r,attached:!1,offset:h.parallelLineHintOffset,length:h.parallelLineHintLength,width:h.parallelLineHintWidth,color:a.parallelSignColor,location:v,renderOccluded:l?f.OccludeAndTransparent:f.Opaque,isDraped:l,renderGroup:m.SnappingHint,isDecoration:!0});return E.setDirectionFromPoints(u,v),E.attached=!0,i(E)}visualizeRightAngleQuad(e,n){const{view:t,spatialReference:r}=n,o=D(n),a=x(e,n),{isDraped:l}=e,s=R(e.previousVertex,e.domain,n),c=R(e.centerVertex,e.domain,n),p=R(e.nextVertex,e.domain,n),d=H(s,r,a,t,l),g=H(c,r,a,t,l),v=H(p,r,a,t,l);return i(new u({view:t,attached:!0,color:l?o.rightAngleColorDraped:o.rightAngleColor,renderOccluded:l?f.OccludeAndTransparent:f.Transparent,outlineRenderOccluded:l?f.OccludeAndTransparent:f.Opaque,outlineColor:o.rightAngleOutlineColor,outlineSize:h.rightAngleHintOutlineSize,size:h.rightAngleHintSize,isDraped:l,geometry:{previous:d,center:g,next:v},renderGroup:m.SnappingHint,isDecoration:!0}))}_createLineSegmentHint(e,n,i,t,r,o,a,l=!1,p=!0,d=!0){const u=H(n,t,r,o,l),g=H(i,t,r,o,l),v=new s({view:o,extensionType:c.FADED,start:u,end:g,isDraped:l,color:a.lineColor,renderOccluded:l?f.OccludeAndTransparent:f.Opaque,renderGroup:m.SnappingHint,isDecoration:!0});switch(e){case C.TARGET:v.width=h.lineHintWidthTarget,v.fadedExtensions={start:0,end:h.lineHintFadedExtensions};break;case C.REFERENCE_EXTENSION:v.width=h.lineHintWidthReference,v.fadedExtensions={start:0,end:0};break;case C.REFERENCE:v.width=h.lineHintWidthReference,v.fadedExtensions={start:p?h.lineHintFadedExtensions:0,end:d?h.lineHintFadedExtensions:0}}return v.attached=!0,v}}function D(i){const{effectiveTheme:t}=i.view,r=e.toUnitRGBA(t.accentColor),o=[0,0,0,0];return{intersectionPointColor:o,intersectionPointOutlineColor:r,pointColor:o,pointOutlineColor:r,lineColor:r,lineOutlineColor:void 0,parallelSignColor:r,rightAngleColor:r,rightAngleColorDraped:e.toUnitRGBA(n(t.accentColor,.5)),rightAngleOutlineColor:r}}function R(e,n,i){const t=A(n,i);return null==t?e:v(e[0],e[1],t)}function x(e,n){return null!=A(e.domain,n)?n.selfSnappingZ.elevationInfo:e.isDraped?a:l}function A(e,{selfSnappingZ:n}){return e===E.SELF&&null!=n?n.value:null}function H(e,n,i,t,a){const l=r();if(a){const i=t.basemapTerrain.overlayManager.renderer.spatialReference;o(e,n,l,i)}else w(e,n,i,t,l);return l}export{O as SnappingVisualizer3D};
5
+ import e from"../../../Color.js";import{multiplyOpacity as n}from"../../../core/colorUtils.js";import"../../../core/has.js";import{destroyHandle as i}from"../../../core/handleUtils.js";import{m as t}from"../../../chunks/vec32.js";import{create as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectVectorToVector as o}from"../../../geometry/projection/projectVectorToVector.js";import{onTheGroundElevationInfo as a,absoluteHeightElevationInfo as l}from"../../../support/elevationInfoUtils.js";import{ExtendedLineVisualElement as s,ExtensionType as c}from"./visualElements/ExtendedLineVisualElement.js";import{ParallelLineVisualElement as p}from"./visualElements/ParallelLineVisualElement.js";import{PointVisualElement as d}from"./visualElements/PointVisualElement.js";import{RightAngleQuadVisualElement as m}from"./visualElements/RightAngleQuadVisualElement.js";import{DrapedRenderGroup as u}from"../layers/interfaces.js";import{RenderOccludedFlag as f}from"../webgl-engine/lib/Material.js";import{toDehydratedPoint as g,create as v}from"../../interactive/sketch/normalizedPoint.js";import{defaults as h}from"../../interactive/snapping/Settings.js";import{SnappingDomain as E}from"../../interactive/snapping/SnappingDomain.js";import{LineSegmentHintType as C}from"../../interactive/snapping/snappingUtils.js";import{SnappingVisualizer as S}from"../../interactive/snapping/SnappingVisualizer.js";import{LineSnappingHint as j}from"../../interactive/snapping/hints/LineSnappingHint.js";import{vectorToRender as w}from"../../interactive/support/viewUtils.js";class O extends S{sortUniqueHints(e){return e.sort(((e,n)=>(n instanceof j?n.length:0)-(e instanceof j?e.length:0)))}visualizeIntersectionPoint(e,n){const{spatialReference:t,view:r}=n,o=D(n);return i(new d({view:r,primitive:"circle",geometry:g(e.intersectionPoint,t),elevationInfo:e.isDraped?a:l,size:20,outlineSize:2,color:o.intersectionPointColor,outlineColor:o.intersectionPointOutlineColor,pixelSnappingEnabled:!1,isDecoration:!0,attached:!0}))}visualizePoint(e,n){const{view:t,spatialReference:r}=n,o=D(n),a=R(e.point,e.domain,n);return i(new d({view:t,primitive:"circle",geometry:g(a,r),elevationInfo:x(e,n),size:20,outlineSize:2,color:o.pointColor,outlineColor:o.pointOutlineColor,pixelSnappingEnabled:!1,isDecoration:!0,attached:!0}))}visualizeLine(e,n){const{view:t,spatialReference:r}=n,o=D(n),a=R(e.lineStart,e.domain,n),l=R(e.lineEnd,e.domain,n);return i(this._createLineSegmentHint(e.type,a,l,r,x(e,n),t,o,e.isDraped,e.fadeLeft,e.fadeRight))}visualizeParallelSign(e,n){const{view:r,spatialReference:o}=n,a=D(n),{isDraped:l}=e,s=x(e,n),c=R(e.lineStart,e.domain,n),d=R(e.lineEnd,e.domain,n),m=H(c,o,s,r,l),g=H(d,o,s,r,l),v=t(g,m,g,.5),E=new p({view:r,attached:!1,offset:h.parallelLineHintOffset,length:h.parallelLineHintLength,width:h.parallelLineHintWidth,color:a.parallelSignColor,location:v,renderOccluded:l?f.OccludeAndTransparent:f.Opaque,isDraped:l,renderGroup:u.SnappingHint,isDecoration:!0});return E.setDirectionFromPoints(m,v),E.attached=!0,i(E)}visualizeRightAngleQuad(e,n){const{view:t,spatialReference:r}=n,o=D(n),a=x(e,n),{isDraped:l}=e,s=R(e.previousVertex,e.domain,n),c=R(e.centerVertex,e.domain,n),p=R(e.nextVertex,e.domain,n),d=H(s,r,a,t,l),g=H(c,r,a,t,l),v=H(p,r,a,t,l);return i(new m({view:t,attached:!0,color:l?o.rightAngleColorDraped:o.rightAngleColor,renderOccluded:l?f.OccludeAndTransparent:f.Transparent,outlineRenderOccluded:l?f.OccludeAndTransparent:f.Opaque,outlineColor:o.rightAngleOutlineColor,outlineSize:h.rightAngleHintOutlineSize,size:h.rightAngleHintSize,isDraped:l,geometry:{previous:d,center:g,next:v},renderGroup:u.SnappingHint,isDecoration:!0}))}_createLineSegmentHint(e,n,i,t,r,o,a,l=!1,p=!0,d=!0){const m=H(n,t,r,o,l),g=H(i,t,r,o,l),v=new s({view:o,extensionType:c.FADED,start:m,end:g,isDraped:l,color:a.lineColor,renderOccluded:l?f.OccludeAndTransparent:f.Opaque,renderGroup:u.SnappingHint,isDecoration:!0});switch(e){case C.TARGET:v.width=h.lineHintWidthTarget,v.fadedExtensions={start:0,end:h.lineHintFadedExtensions};break;case C.REFERENCE_EXTENSION:v.width=h.lineHintWidthReference,v.fadedExtensions={start:0,end:0};break;case C.REFERENCE:v.width=h.lineHintWidthReference,v.fadedExtensions={start:p?h.lineHintFadedExtensions:0,end:d?h.lineHintFadedExtensions:0}}return v.attached=!0,v}}function D(i){const{effectiveTheme:t}=i.view,r=e.toUnitRGBA(t.accentColor),o=[0,0,0,0];return{intersectionPointColor:o,intersectionPointOutlineColor:r,pointColor:o,pointOutlineColor:r,lineColor:r,lineOutlineColor:void 0,parallelSignColor:r,rightAngleColor:r,rightAngleColorDraped:e.toUnitRGBA(n(t.accentColor,.5)),rightAngleOutlineColor:r}}function R(e,n,i){const t=A(n,i);return null==t?e:v(e[0],e[1],t)}function x(e,n){return null!=A(e.domain,n)?n.selfSnappingZ.elevationInfo:e.isDraped?a:l}function A(e,{selfSnappingZ:n}){return e===E.SELF&&null!=n?n.value:null}function H(e,n,i,t,a){const l=r();if(a){const i=t.basemapTerrain.overlayManager.renderer.spatialReference;o(e,n,l,i)}else w(e,n,i,t,l);return l}export{O as SnappingVisualizer3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../geometry.js";import{screenPointObjectToArray as e,castScreenPointArray as n,createScreenPointArray as r}from"../../../../core/screenUtils.js";import{l as t,c as o,b as l,f as s,j as c,h as i,g as a}from"../../../../chunks/vec32.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectPoint as p}from"../../../../geometry/projection.js";import{intersectRay as m,create as d,getNormal as f,fromPositionAndNormal as g}from"../../../../geometry/support/plane.js";import{create as y}from"../../../../geometry/support/ray.js";import{projectPoint as E}from"../../../../geometry/support/vector.js";import{sv2d as j}from"../../../../geometry/support/vectorStacks.js";import{getZForElevationMode as S,getGraphicEffectiveElevationInfo as R}from"../../../../support/elevationInfoUtils.js";import{fromScreen as v}from"../../support/geometryUtils/ray.js";import{newIntersector as x}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as b,IntersectorType as w}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{terrainId as I}from"../../webgl-engine/lib/verticalOffsetUtils.js";import{EventPipeline as H}from"../../../interactive/dragEventPipeline.js";import U from"../../../../geometry/Point.js";function O(e,n){return P(e,(()=>n))}function C(e){return P(e,(e=>e.plane))}function P(r,t){const o=u(),l=u();let s=!1;return c=>{const i=t(c);if("start"===c.action){const t=e(c.screenStart,n(j.get())),l=v(r.state.camera,t,K);null!=l&&(s=m(i,l,o))}if(!s)return null;const a=e(c.screenEnd,n(j.get())),u=v(r.state.camera,a,K);return null==u?null:m(i,u,l)?{...c,renderStart:o,renderEnd:l,plane:i,ray:u}:null}}function T(e,n,t=0,o=null,l=null){let s=null;return c=>{if("start"===c.action&&(s=e.sceneIntersectionHelper.intersectElevationFromScreen(r(c.screenStart.x,c.screenStart.y),n,t,l),null!=s&&null!=o&&!p(s,s,o)))return null;if(null==s)return null;const i=e.sceneIntersectionHelper.intersectElevationFromScreen(r(c.screenEnd.x,c.screenEnd.y),n,t,l);return null!=i&&(null==o||p(i,i,o))?{...c,mapStart:s,mapEnd:i}:null}}function D(e,n,r,t=null,o=null){return T(e,r,S(n,e,r),t,o)}function M(e,n,r,t=null,o=null){return D(e,r,R(n),t,o)}function N(e,n,r,t){const o=n.toMap(e.screenStart,{include:[r]});return null!=o?M(n,r,o,t):null}function h(e,n){const r=B,t=J,o=d();e.renderCoordsHelper.worldUpAtPosition(n,r);const c=l(f(o),r,s(t,n,e.state.camera.eye));return l(c,c,r),g(n,c,o)}function G(e,n,r){let t=null;const o=new H;return o.next(O(e,h(e,n))).next(k(e,n)).next(A(e,r)).next((e=>{e.mapEnd.x=e.mapStart.x,e.mapEnd.y=e.mapStart.y,t=e})),e=>(t=null,o.execute(e),t)}function k(e,n){const r=u(),l=t(n);e.renderCoordsHelper.worldUpAtPosition(n,r);const p=u(),m=u(),d=o=>{if(s(o,o,n),E(r,o,o),"global"===e.viewingMode){t(o)*Math.sign(c(r,o))<.001-l&&s(o,i(o,r,.001),n)}return a(o,o,n),o};return e=>(e.renderStart=d(o(p,e.renderStart)),e.renderEnd=d(o(m,e.renderEnd)),e)}function A(e,n){const r=e.renderCoordsHelper;return e=>{const t=r.fromRenderCoords(e.renderStart,new U({spatialReference:n})),o=r.fromRenderCoords(e.renderEnd,new U({spatialReference:n}));return null!=t&&null!=o?{...e,mapStart:t,mapEnd:o}:null}}var F;function q(e){let n=null;return r=>{switch(r.action){case"start":n=e.disableDisplay();break;case"end":case"cancel":null!=n&&(n.remove(),n=null)}return r}}function z(n,t=null){const o=x(n.state.viewingMode);o.options.selectionMode=!0,o.options.store=b.MIN,o.options.hud=!1;const l=r(),s={requiresGroundFeedback:!0,enableDraped:!0,exclude:new Set},c=u(),i=t??n.spatialReference,a=r=>{n.map.ground&&n.map.ground.opacity<1?s.exclude.add(I):s.exclude.delete(I),n.sceneIntersectionHelper.intersectIntersectorScreen(e(r,l),o,s);const t=o.results.min;let a;if(t.getIntersectionPoint(c))a=t.intersector===w.TERRAIN?F.GROUND:F.OTHER;else{if(!o.results.ground.getIntersectionPoint(c))return null;a=F.GROUND}return{location:n.renderCoordsHelper.fromRenderCoords(c,new U({spatialReference:i})),surfaceType:a}};let p;return e=>{if("start"===e.action){const n=a(e.screenStart);p=null!=n?n.location:null}if(null==p)return null;const n=a(e.screenEnd);return null!=n?.location?{...e,mapStart:p,mapEnd:n.location,surfaceType:n.surfaceType}:null}}!function(e){e[e.GROUND=0]="GROUND",e[e.OTHER=1]="OTHER"}(F||(F={}));const B=u(),J=u(),K=y();export{F as SurfaceType,A as convertToMapCoordinates,q as hideManipulatorWhileDragging,k as projectToWorldUp,z as screenToMap3D,D as screenToMapXYAtLocation,N as screenToMapXYForGraphic,M as screenToMapXYForGraphicAtLocation,O as screenToRenderPlane,C as screenToRenderPlaneFromEvent,G as screenToZConstrained};
5
+ import"../../../../geometry.js";import{screenPointObjectToArray as e,castScreenPointArray as n,createScreenPointArray as r}from"../../../../core/screenUtils.js";import{l as t,c as o,b as l,f as s,k as c,h as i,g as a}from"../../../../chunks/vec32.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectPoint as p}from"../../../../geometry/projection.js";import{intersectRay as m,create as d,getNormal as f,fromPositionAndNormal as g}from"../../../../geometry/support/plane.js";import{create as y}from"../../../../geometry/support/ray.js";import{projectPoint as E}from"../../../../geometry/support/vector.js";import{sv2d as S}from"../../../../geometry/support/vectorStacks.js";import{getZForElevationMode as j,getGraphicEffectiveElevationInfo as R}from"../../../../support/elevationInfoUtils.js";import{fromScreen as v}from"../../support/geometryUtils/ray.js";import{newIntersector as x}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as b,IntersectorType as w}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{terrainId as I}from"../../webgl-engine/lib/verticalOffsetUtils.js";import{EventPipeline as H}from"../../../interactive/dragEventPipeline.js";import U from"../../../../geometry/Point.js";function O(e,n){return P(e,(()=>n))}function C(e){return P(e,(e=>e.plane))}function P(r,t){const o=u(),l=u();let s=!1;return c=>{const i=t(c);if("start"===c.action){const t=e(c.screenStart,n(S.get())),l=v(r.state.camera,t,K);null!=l&&(s=m(i,l,o))}if(!s)return null;const a=e(c.screenEnd,n(S.get())),u=v(r.state.camera,a,K);return null==u?null:m(i,u,l)?{...c,renderStart:o,renderEnd:l,plane:i,ray:u}:null}}function T(e,n,t=0,o=null,l=null){let s=null;return c=>{if("start"===c.action&&(s=e.sceneIntersectionHelper.intersectElevationFromScreen(r(c.screenStart.x,c.screenStart.y),n,t,l),null!=s&&null!=o&&!p(s,s,o)))return null;if(null==s)return null;const i=e.sceneIntersectionHelper.intersectElevationFromScreen(r(c.screenEnd.x,c.screenEnd.y),n,t,l);return null!=i&&(null==o||p(i,i,o))?{...c,mapStart:s,mapEnd:i}:null}}function D(e,n,r,t=null,o=null){return T(e,r,j(n,e,r),t,o)}function M(e,n,r,t=null,o=null){return D(e,r,R(n),t,o)}function N(e,n,r,t){const o=n.toMap(e.screenStart,{include:[r]});return null!=o?M(n,r,o,t):null}function h(e,n){const r=B,t=J,o=d();e.renderCoordsHelper.worldUpAtPosition(n,r);const c=l(f(o),r,s(t,n,e.state.camera.eye));return l(c,c,r),g(n,c,o)}function k(e,n,r){let t=null;const o=new H;return o.next(O(e,h(e,n))).next(G(e,n)).next(A(e,r)).next((e=>{e.mapEnd.x=e.mapStart.x,e.mapEnd.y=e.mapStart.y,t=e})),e=>(t=null,o.execute(e),t)}function G(e,n){const r=u(),l=t(n);e.renderCoordsHelper.worldUpAtPosition(n,r);const p=u(),m=u(),d=o=>{if(s(o,o,n),E(r,o,o),"global"===e.viewingMode){t(o)*Math.sign(c(r,o))<.001-l&&s(o,i(o,r,.001),n)}return a(o,o,n),o};return e=>(e.renderStart=d(o(p,e.renderStart)),e.renderEnd=d(o(m,e.renderEnd)),e)}function A(e,n){const r=e.renderCoordsHelper;return e=>{const t=r.fromRenderCoords(e.renderStart,new U({spatialReference:n})),o=r.fromRenderCoords(e.renderEnd,new U({spatialReference:n}));return null!=t&&null!=o?{...e,mapStart:t,mapEnd:o}:null}}var F;function q(e){let n=null;return r=>{switch(r.action){case"start":n=e.disableDisplay();break;case"end":case"cancel":null!=n&&(n.remove(),n=null)}return r}}function z(n,t=null){const o=x(n.state.viewingMode);o.options.selectionMode=!0,o.options.store=b.MIN,o.options.hud=!1;const l=r(),s={requiresGroundFeedback:!0,enableDraped:!0,exclude:new Set},c=u(),i=t??n.spatialReference,a=r=>{n.map.ground&&n.map.ground.opacity<1?s.exclude.add(I):s.exclude.delete(I),n.sceneIntersectionHelper.intersectIntersectorScreen(e(r,l),o,s);const t=o.results.min;let a;if(t.getIntersectionPoint(c))a=t.intersector===w.TERRAIN?F.GROUND:F.OTHER;else{if(!o.results.ground.getIntersectionPoint(c))return null;a=F.GROUND}return{location:n.renderCoordsHelper.fromRenderCoords(c,new U({spatialReference:i})),surfaceType:a}};let p;return e=>{if("start"===e.action){const n=a(e.screenStart);p=null!=n?n.location:null}if(null==p)return null;const n=a(e.screenEnd);return null!=n?.location?{...e,mapStart:p,mapEnd:n.location,surfaceType:n.surfaceType}:null}}!function(e){e[e.GROUND=0]="GROUND",e[e.OTHER=1]="OTHER"}(F||(F={}));const B=u(),J=u(),K=y();export{F as SurfaceType,A as convertToMapCoordinates,q as hideManipulatorWhileDragging,G as projectToWorldUp,z as screenToMap3D,D as screenToMapXYAtLocation,N as screenToMapXYForGraphic,M as screenToMapXYForGraphicAtLocation,O as screenToRenderPlane,C as screenToRenderPlaneFromEvent,k as screenToZConstrained};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../Color.js";import{darken as t}from"../../../../../core/colorUtils.js";import r from"../../../../../core/Evented.js";import{clamp as i}from"../../../../../core/mathUtils.js";import{removeMaybe as a}from"../../../../../core/maybe.js";import{watch as o}from"../../../../../core/reactiveUtils.js";import{translate as s,rotateX as n,scale as l}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{m,f as d,n as u,j as p,b as h,h as f}from"../../../../../chunks/vec32.js";import{create as _,fromValues as j}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Manipulator3D as g}from"../../Manipulator3D.js";import{createManipulatorMaterial as w}from"../../manipulatorUtils.js";import{RenderObject as v}from"../../RenderObject.js";import{screenToZConstrained as M}from"../dragEventPipeline3D.js";import{ManipulatorType as U}from"../ManipulatorType.js";import{Settings as b}from"../settings.js";import{discRadius as O}from"./config.js";import{Manipulation as C}from"./Manipulation.js";import{createGraphicMoveDragPipeline as D}from"./moveUtils.js";import{createTubeGeometry as y,createConeGeometry as P}from"../../../webgl-engine/lib/GeometryUtil.js";import{RenderOccludedFlag as T}from"../../../webgl-engine/lib/Material.js";import{createManipulatorDragEventPipeline as k,addScreenDelta as z}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateFlags as F}from"../../../../interactive/interfaces.js";class x extends C{constructor(e){super(),this._radius=O,this.events=new r,this._tool=e.tool,this._view=e.view;const t=new b({getTheme:()=>this._view.effectiveTheme});this._settings=t,null!=e.radius&&(this._radius=e.radius);const i=this._view.effectiveTheme.accentColor;this._materials={materialUnfocused:w(this._createDarkenedColor(i,1,.25),T.Occlude),materialFocused:w(this._createDarkenedColor(i,1,0),T.Occlude),materialOccludedUnfocused:w(this._createDarkenedColor(i,.7,0),t.zManipulator.renderOccluded),materialOccludedFocused:w(this._createDarkenedColor(i,.85,0),t.zManipulator.renderOccluded)},this._themeHandle=o((()=>this._view.effectiveTheme.accentColor),(e=>{const t=this._createDarkenedColor(e,1,.25),r=this._createDarkenedColor(e,1,0),i=this._createDarkenedColor(e,.7,0),a=this._createDarkenedColor(e,.85,0),{materialUnfocused:o,materialFocused:s,materialOccludedUnfocused:n,materialOccludedFocused:l}=this._materials;o.setParameters({color:t}),s.setParameters({color:r}),n.setParameters({color:i}),l.setParameters({color:a})})),this._createManipulator(),this.forEachManipulator((e=>this._tool.manipulators.add(e)))}destroy(){this._themeHandle=a(this._themeHandle),this._manipulator.applyObjectTransform=H,this.forEachManipulator((e=>{this._tool.manipulators.remove(e),e.destroy()}))}forEachManipulator(e){e(this._manipulator,U.TRANSLATE_Z)}createGraphicDragPipeline(e,t,r){const i=t.graphic.geometry.spatialReference;return D(t.graphic,r,(t=>this.createDragPipeline(((r,i,a,o,s)=>(({steps:i,cancel:a}=e(r,i,a,o,s)),t(r,i,a))),i)))}createDragPipeline(e,t){const r=this._view;return k(this._manipulator,((i,a,o,s,n)=>{const l=a.next((e=>({...e,manipulatorType:U.TRANSLATE_Z}))).next(M(r,i.renderLocation,t)).next(z());e(i,l,o,s,n)}))}get radius(){return this._radius}set radius(e){e!==this._radius&&(this._radius=e,this._updateManipulator())}_updateManipulator(){const e=this._settings,t=this._radius/O,r=e.zManipulator.height*t,i=e.zManipulator.coneHeight*t,a=e.zManipulator.coneWidth*t,o=e.zManipulator.width*t,m=[j(0,0,0),j(0,0,r)],d=[j(0,0,0),j(0,0,r+i)],u=e=>{const t=c();if(s(t,t,[0,0,r]),n(t,t,Math.PI/2),e){const r=1+2*e/a;l(t,t,[r,r,r])}return t},p=u(0),{materialUnfocused:h,materialFocused:f,materialOccludedUnfocused:_,materialOccludedFocused:g}=this._materials,w=y(h,m,o/2,16,!1),M=P(h,i,a/2,16,!1);M.transformation=p,this._manipulator.renderObjects=[new v(M,F.Unfocused),new v(w,F.Unfocused),new v(M.instantiate({material:f}),F.Focused),new v(w.instantiate({material:f}),F.Focused),new v(M.instantiate({material:_}),F.Unfocused),new v(w.instantiate({material:_}),F.Unfocused),new v(M.instantiate({material:g}),F.Focused),new v(w.instantiate({material:g}),F.Focused)],this._manipulator.radius=o/2+2,this._manipulator.collisionType={type:"line",paths:[d]}}_createManipulator(){const e=this._view,t=new g({view:e,autoScaleRenderObjects:!1,worldSized:!1,selectable:!1,cursor:"ns-resize",elevationInfo:this.elevationInfo,worldOriented:!0,collisionPriority:1.6});t.applyObjectTransform=t=>{const r=e.state.camera,a=A;e.renderCoordsHelper.toRenderCoords(this._manipulator.elevationAlignedLocation,a);const o=m(r.eye,a),s=r.computeRenderPixelSizeAtDist(o),n=d(E,a,r.eye);u(n,n);const l=R;e.renderCoordsHelper.worldUpAtPosition(A,l);const c=Math.abs(p(n,l)),_=h(E,n,l),j=h(E,_,l),g=i(c,.01,1),w=1-Math.sqrt(1-g*g)/g/r.fullWidth,v=this._settings,M=this._radius/O,U=v.zManipulator.width*M;f(j,u(j,j),(1/w-1)*o+s*U),t[12]-=E[0],t[13]-=E[1],t[14]-=E[2]},this._manipulator=t,this._updateManipulator()}_createDarkenedColor(r,i,a){const o=t(r,a);return o.a*=i,e.toUnitRGBA(o)}get test(){return{manipulator:this._manipulator}}}const A=_(),E=_(),R=_(),H=()=>{};export{x as MoveZManipulation};
5
+ import e from"../../../../../Color.js";import{darken as t}from"../../../../../core/colorUtils.js";import r from"../../../../../core/Evented.js";import{clamp as i}from"../../../../../core/mathUtils.js";import{removeMaybe as a}from"../../../../../core/maybe.js";import{watch as o}from"../../../../../core/reactiveUtils.js";import{translate as s,rotateX as n,scale as l}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{o as m,f as d,n as u,k as p,b as h,h as f}from"../../../../../chunks/vec32.js";import{create as _,fromValues as j}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Manipulator3D as g}from"../../Manipulator3D.js";import{createManipulatorMaterial as w}from"../../manipulatorUtils.js";import{RenderObject as v}from"../../RenderObject.js";import{screenToZConstrained as M}from"../dragEventPipeline3D.js";import{ManipulatorType as U}from"../ManipulatorType.js";import{Settings as b}from"../settings.js";import{discRadius as O}from"./config.js";import{Manipulation as C}from"./Manipulation.js";import{createGraphicMoveDragPipeline as D}from"./moveUtils.js";import{createTubeGeometry as y,createConeGeometry as P}from"../../../webgl-engine/lib/GeometryUtil.js";import{RenderOccludedFlag as T}from"../../../webgl-engine/lib/Material.js";import{createManipulatorDragEventPipeline as k,addScreenDelta as z}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateFlags as F}from"../../../../interactive/interfaces.js";class x extends C{constructor(e){super(),this._radius=O,this.events=new r,this._tool=e.tool,this._view=e.view;const t=new b({getTheme:()=>this._view.effectiveTheme});this._settings=t,null!=e.radius&&(this._radius=e.radius);const i=this._view.effectiveTheme.accentColor;this._materials={materialUnfocused:w(this._createDarkenedColor(i,1,.25),T.Occlude),materialFocused:w(this._createDarkenedColor(i,1,0),T.Occlude),materialOccludedUnfocused:w(this._createDarkenedColor(i,.7,0),t.zManipulator.renderOccluded),materialOccludedFocused:w(this._createDarkenedColor(i,.85,0),t.zManipulator.renderOccluded)},this._themeHandle=o((()=>this._view.effectiveTheme.accentColor),(e=>{const t=this._createDarkenedColor(e,1,.25),r=this._createDarkenedColor(e,1,0),i=this._createDarkenedColor(e,.7,0),a=this._createDarkenedColor(e,.85,0),{materialUnfocused:o,materialFocused:s,materialOccludedUnfocused:n,materialOccludedFocused:l}=this._materials;o.setParameters({color:t}),s.setParameters({color:r}),n.setParameters({color:i}),l.setParameters({color:a})})),this._createManipulator(),this.forEachManipulator((e=>this._tool.manipulators.add(e)))}destroy(){this._themeHandle=a(this._themeHandle),this._manipulator.applyObjectTransform=H,this.forEachManipulator((e=>{this._tool.manipulators.remove(e),e.destroy()}))}forEachManipulator(e){e(this._manipulator,U.TRANSLATE_Z)}createGraphicDragPipeline(e,t,r){const i=t.graphic.geometry.spatialReference;return D(t.graphic,r,(t=>this.createDragPipeline(((r,i,a,o,s)=>(({steps:i,cancel:a}=e(r,i,a,o,s)),t(r,i,a))),i)))}createDragPipeline(e,t){const r=this._view;return k(this._manipulator,((i,a,o,s,n)=>{const l=a.next((e=>({...e,manipulatorType:U.TRANSLATE_Z}))).next(M(r,i.renderLocation,t)).next(z());e(i,l,o,s,n)}))}get radius(){return this._radius}set radius(e){e!==this._radius&&(this._radius=e,this._updateManipulator())}_updateManipulator(){const e=this._settings,t=this._radius/O,r=e.zManipulator.height*t,i=e.zManipulator.coneHeight*t,a=e.zManipulator.coneWidth*t,o=e.zManipulator.width*t,m=[j(0,0,0),j(0,0,r)],d=[j(0,0,0),j(0,0,r+i)],u=e=>{const t=c();if(s(t,t,[0,0,r]),n(t,t,Math.PI/2),e){const r=1+2*e/a;l(t,t,[r,r,r])}return t},p=u(0),{materialUnfocused:h,materialFocused:f,materialOccludedUnfocused:_,materialOccludedFocused:g}=this._materials,w=y(h,m,o/2,16,!1),M=P(h,i,a/2,16,!1);M.transformation=p,this._manipulator.renderObjects=[new v(M,F.Unfocused),new v(w,F.Unfocused),new v(M.instantiate({material:f}),F.Focused),new v(w.instantiate({material:f}),F.Focused),new v(M.instantiate({material:_}),F.Unfocused),new v(w.instantiate({material:_}),F.Unfocused),new v(M.instantiate({material:g}),F.Focused),new v(w.instantiate({material:g}),F.Focused)],this._manipulator.radius=o/2+2,this._manipulator.collisionType={type:"line",paths:[d]}}_createManipulator(){const e=this._view,t=new g({view:e,autoScaleRenderObjects:!1,worldSized:!1,selectable:!1,cursor:"ns-resize",elevationInfo:this.elevationInfo,worldOriented:!0,collisionPriority:1.6});t.applyObjectTransform=t=>{const r=e.state.camera,a=A;e.renderCoordsHelper.toRenderCoords(this._manipulator.elevationAlignedLocation,a);const o=m(r.eye,a),s=r.computeRenderPixelSizeAtDist(o),n=d(E,a,r.eye);u(n,n);const l=R;e.renderCoordsHelper.worldUpAtPosition(A,l);const c=Math.abs(p(n,l)),_=h(E,n,l),j=h(E,_,l),g=i(c,.01,1),w=1-Math.sqrt(1-g*g)/g/r.fullWidth,v=this._settings,M=this._radius/O,U=v.zManipulator.width*M;f(j,u(j,j),(1/w-1)*o+s*U),t[12]-=E[0],t[13]-=E[1],t[14]-=E[2]},this._manipulator=t,this._updateManipulator()}_createDarkenedColor(r,i,a){const o=t(r,a);return o.a*=i,e.toUnitRGBA(o)}get test(){return{manipulator:this._manipulator}}}const A=_(),E=_(),R=_(),H=()=>{};export{x as MoveZManipulation};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../../chunks/tslib.es6.js";import"../../../../../geometry.js";import e from"../../../../../core/Accessor.js";import{removeUnordered as i}from"../../../../../core/arrayUtils.js";import{unitRGBAFromColor as a}from"../../../../../core/colorUtils.js";import"../../../../../core/has.js";import n from"../../../../../core/Evented.js";import o from"../../../../../core/Handles.js";import{handlesGroup as s,makeHandle as r,destroyHandle as l}from"../../../../../core/handleUtils.js";import{destroyMaybe as p,removeMaybe as h}from"../../../../../core/maybe.js";import{zeroMeters as d,scale as u,createLength as c}from"../../../../../core/quantityUtils.js";import{watch as m,initial as g}from"../../../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as _}from"../../../../../core/unitUtils.js";import{property as f}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import{subclass as v}from"../../../../../core/accessorSupport/decorators/subclass.js";import{IDENTITY as M}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{l as y,f as x,k as O,s as b,g as E,h as G}from"../../../../../chunks/vec32.js";import{fromValues as I,create as S}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as T}from"../../../../../core/support/UpdatingHandles.js";import w from"../../../../../geometry/Polyline.js";import{hasCompatibleTopology as H}from"../../../../../geometry/support/coordsUtils.js";import{projectPoint as V}from"../../../../../geometry/support/plane.js";import{sv3d as A}from"../../../../../geometry/support/vectorStacks.js";import{makeDehydratedPoint as L}from"../../../../../layers/graphics/dehydratedPoint.js";import{getGraphicEffectiveElevationInfo as D}from"../../../../../support/elevationInfoUtils.js";import{isVolumetricSymbol as j}from"../../../../../symbols/support/utils.js";import{Manipulator3D as k}from"../../Manipulator3D.js";import{createManipulatorMaterial as P,createManipulatorOutlineMaterial as U,placeAtGraphic as C}from"../../manipulatorUtils.js";import{RenderObject as N}from"../../RenderObject.js";import{SegmentLabels3D as R}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as F}from"../../SnappingVisualizer3D.js";import{screenToRenderPlaneFromEvent as z,convertToMapCoordinates as X,screenToMapXYAtLocation as Z,screenToMapXYForGraphicAtLocation as Y}from"../dragEventPipeline3D.js";import{orientation as q}from"../geometryUtils.js";import{ManipulatorType as W}from"../ManipulatorType.js";import{canMoveZ as K}from"../manipulatorUtils.js";import{Settings as B}from"../settings.js";import{createVisualElements as J}from"../visualElementUtils.js";import{discRadiusSmall as Q}from"../manipulations/config.js";import{ManipulationType as $,MoveManipulation as tt}from"../manipulations/MoveManipulation.js";import{axisConstrainedDragSign as et}from"../manipulations/moveUtils.js";import{MoveXYGraphicManipulation as it}from"../manipulations/MoveXYGraphicManipulation.js";import{createEdgeOffsetIntersectionPlane as at,createEdgeOffsetOperation as nt,edgeOffsetRotationMatrix as ot,screenEdgeLengthSquared as st}from"./edgeOffsetUtils.js";import{OutlineVisualElement as rt}from"../../visualElements/OutlineVisualElement.js";import{GraphicState as lt}from"../../../layers/graphics/GraphicState.js";import{createExtrudedTriangle as pt,createSphereGeometry as ht}from"../../../webgl-engine/lib/GeometryUtil.js";import{MouseButton as dt}from"../../../../input/IViewEvents.js";import{sceneSnappingAtLocation as ut,addMapDelta as ct,createManipulatorDragEventPipeline as mt,dragAtLocation as gt,addScreenDelta as _t}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateFlags as ft,ManipulatorStateCustomFlags as vt}from"../../../../interactive/interfaces.js";import{EditGeometryOperations as Mt}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehavior as yt}from"../../../../interactive/editGeometry/interfaces.js";import{SnappingContext as xt}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as Ot}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{ReshapeEdgeOffsetTooltipInfo as bt}from"../../../../interactive/tooltip/ReshapeTooltipInfos.js";import{Tooltip as Et}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateGraphicZTooltipInfo as Gt,TranslateGraphicXYTooltipInfo as It,TranslateGraphicTooltipInfo as St,TranslateVertexZTooltipInfo as Tt,TranslateVertexXYTooltipInfo as wt,TranslateVertexTooltipInfo as Ht}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{makeElevationField as Vt}from"../../../../interactive/tooltip/fields/fields.js";import{autoArea2D as At}from"../../../../support/automaticAreaMeasurementUtils.js";import{autoDistanceBetweenPoints2D as Lt,autoLength2D as Dt}from"../../../../support/automaticLengthMeasurementUtils.js";import{verticalSignedDistanceBetweenPoints as jt,elevationFromPoint as kt}from"../../../../support/euclideanLengthMeasurementUtils.js";import{geodesicDistance as Pt}from"../../../../support/geodesicLengthMeasurementUtils.js";import Ut from"../../../../../geometry/SpatialReference.js";let Ct=class extends(n.EventedMixin(e)){constructor(t){super(t),this._selectedIndex=0,this._manipulatorHandles=new o,this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0,this._reshapeEventState=Yt.NONE,this._updatingHandles=new T,this._recreatingManipulators=!1,this._settings=new B({getTheme:()=>this.view.effectiveTheme}),this._latestTooltipInfo=null,this._translateGraphicTooltipInfo=null,this._translateGraphicXYTooltipInfo=null,this._translateGraphicZTooltipInfo=null,this._translateVertexTooltipInfo=null,this._translateVertexXYTooltipInfo=null,this._translateVertexZTooltipInfo=null,this._edgeOffsetTooltipInfo=null,this.outputGeometry=null,this._vertexLaserLineVisualElement=null}initialize(){const{graphic:t,view:e}=this,i=this._settings.manipulators,n=i.vertex;this._vertexManipulatorMaterial=P(a(n.color),n.renderOccluded),this._vertexManipulatorOutlineMaterial=U(a(n.outlineColor),n.renderOccluded),this._vertexManipulatorHoverOutlineMaterial=U(a(n.hoverOutlineColor),n.renderOccluded);const o=i.edge;this._edgeManipulatorMaterial=P(a(o.color),o.renderOccluded),this._edgeManipulatorOutlineMaterial=U(a(o.outlineColor),o.renderOccluded);const s=i.edgeOffset;this._edgeOffsetManipulatorMaterial=P(a(s.color),s.renderOccluded,!1),this._edgeOffsetManipulatorHoverMaterial=P(a(s.hoverColor),s.renderOccluded,!1);const r=i.selected;this._selectedManipulatorMaterial=P(a(r.color),r.renderOccluded),this._selectedManipulatorOutlineMaterial=U(a(r.outlineColor),r.renderOccluded),this._selectedManipulatorHoverOutlineMaterial=U(a(r.hoverOutlineColor),r.renderOccluded);const l=this._graphicState=new lt({graphic:t});this.tooltip=new Et({view:e}),this.addHandles([m((()=>{const t=this._settings.manipulators;return{vertexSettings:t.vertex,edgeSettings:t.edge,edgeOffsetSettings:t.edgeOffset,selectedSettings:t.selected}}),(({vertexSettings:t,edgeSettings:e,edgeOffsetSettings:i,selectedSettings:a})=>{t.applyColor(this._vertexManipulatorMaterial),t.applyOutline(this._vertexManipulatorOutlineMaterial),t.applyHoverOutline(this._vertexManipulatorHoverOutlineMaterial),e.applyColor(this._edgeManipulatorMaterial),e.applyOutline(this._edgeManipulatorOutlineMaterial),i.applyColor(this._edgeOffsetManipulatorMaterial),i.applyHover(this._edgeOffsetManipulatorHoverMaterial),a.applyColor(this._selectedManipulatorMaterial),a.applyOutline(this._selectedManipulatorOutlineMaterial),a.applyHoverOutline(this._selectedManipulatorHoverOutlineMaterial)})),m((()=>l.displaying),(t=>{for(const e of this._manipulatorInfos)e.manipulator.available=t})),m((()=>({labels:this._segmentLabels,enabled:this.sketchOptions.labels.enabled,edgeOffsetEnabled:this.enableEdgeOffset})),(({labels:t,enabled:e,edgeOffsetEnabled:i})=>{null!=t&&(t.visible=e,t.edgeDistance=i?"far":"default")}),g),m((()=>this.sketchOptions.tooltips.effectiveEnabled),(t=>{this.tooltip.info=t?this._latestTooltipInfo:null}),g),this.view.trackGraphicState(l)])}destroy(){this._segmentLabels=p(this._segmentLabels),this.tooltip=p(this.tooltip),this._removeManipulators(),this._updatingHandles.destroy()}get inputGeometry(){return null!=this._editGeometryOperations?this._editGeometryOperations.data.geometry:null}set inputGeometry(t){this._recreateEditGeometryAndManipulators(t)}get updating(){return this._updatingHandles.updating}get manipulators(){return this.tool.manipulators}get view(){return this.tool.view}get graphic(){return this.tool.graphic}get enableZShape(){return this.tool.enableZShape}get enableZVertex(){return this.tool.enableZVertex}get enableMoveGraphic(){return this.tool.enableMoveGraphic}get enableMidpoints(){return this.tool.enableMidpoints}get enableEdgeOffset(){return this.tool.enableEdgeOffset}get sketchOptions(){return this.tool.sketchOptions}get _accentColor(){return this.view.effectiveTheme.accentColor}removeSelectedVertices(){const t=this._manipulatorInfos.filter((t=>t.manipulator.selected&&"vertex"===t.type));this._removeVertices(t)}onManipulatorSelectionChanged(){this.emit("manipulators-changed")}_removeManipulators(){this._manipulatorHandles.removeAll(),this._moveManipulation=p(this._moveManipulation),this._graphicMoveManipulation=p(this._graphicMoveManipulation),this.manipulators.removeAll(),this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0}_createManipulators(t){if(null==this._editGeometryOperations)return;const e=D(this.graphic);for(const i of this._editGeometryOperations.data.components){const a=t?.byComponentIndex.get(i.index);for(const t of i.vertices){const i=a?.has(t.index);this._createVertexOrEdgeManipulator(t,e,i)}for(const t of i.edges)this._createVertexOrEdgeManipulator(t,e)}this._createGraphicMoveManipulation(),this._createMoveManipulation(e),this._createVisualElements()}get canRedo(){return null!=this._editGeometryOperations&&this._editGeometryOperations.canRedo}get canUndo(){return null!=this._editGeometryOperations&&this._editGeometryOperations.canUndo}redo(){if(null==this._editGeometryOperations)return null;const t=this._editGeometryOperations.redo();return null!=t&&(this.outputGeometry=this._editGeometryOperations.data.geometry,this._recreateManipulators()),t}undo(){if(null==this._editGeometryOperations)return null;this.emit("undo");const t=this._editGeometryOperations.undo();return null!=t&&(this.outputGeometry=this._editGeometryOperations.data.geometry,this._recreateManipulators()),t}_recreateManipulators(){this._recreatingManipulators||(this._recreatingManipulators=!0,this._removeManipulators(),this._hideTooltip(),this._createManipulators(),this._recreatingManipulators=!1)}_recreateEditGeometryAndManipulators(t){const e={byComponentIndex:new Map};if(null!=t&&null!=this.inputGeometry&&H(t,this.inputGeometry))for(const n of this._manipulatorInfos)if("vertex"===n.type&&n.manipulator.selected){const{index:t,component:{index:i}}=n.handle,{byComponentIndex:a}=e,o=a.get(i)||new Set;o.add(t),a.set(i,o)}if(this._recreatingManipulators=!0,this._removeManipulators(),this._hideTooltip(),this._editGeometryOperations=p(this._editGeometryOperations),this._segmentLabels=p(this._segmentLabels),null==t)return void(this._recreatingManipulators=!1);const i="mesh"===t.type?t.anchor:t;this._editGeometryOperations=Mt.fromGeometry(i,this.view.state.viewingMode),this._createManipulators(e);const a=this.sketchOptions.labels;this._segmentLabels=new R({context:{view:this.view,editGeometryOperations:this._editGeometryOperations,elevationInfo:D(this.graphic),labelOptions:a,graphic:this.graphic,graphicState:this._graphicState},visible:a.enabled}),this._recreatingManipulators=!1}_perGraphicManipulatorDragAction(t,e){if("end"===e.action)return e;let i=0;const a=[],n=this._manipulatorInfos.some((t=>"vertex"===t.type&&t.manipulator.selected)),o=t===qt.SELECTED_OR_ALL&&n;for(const s of this._manipulatorInfos)"vertex"===s.type&&(s.manipulator.grabbing||o&&!s.manipulator.selected||a.push(s),i++);if(0===a.length)return e;this._moveVertices(a,e);if(a.length===i){if(this._updateEventState(Yt.MOVING),this.destroyed)return e;this.emit("move",{type:"move",dx:e.screenDeltaX,dy:e.screenDeltaY,mover:this.graphic})}else{if(this._updateEventState(Yt.RESHAPING),this.destroyed)return e;this.emit("reshape",{type:"reshape",mover:this.graphic})}return e}_isMultiVertexSelection(){return this._manipulatorInfos.reduce(((t,e)=>"vertex"===e.type&&e.manipulator.selected?t+1:t),0)>1}_perVertexManipulatorDragAction(t){if(this._updateEventState(Yt.RESHAPING),this.destroyed)return;const{mapDeltaX:e,mapDeltaY:i,mapDeltaZ:a}=t;if(!e&&!i&&!a)return;const n=[];for(const o of this._manipulatorInfos)"vertex"===o.type&&(o.manipulator.selected&&!o.manipulator.grabbing||o===t.info)&&n.push(o);this._moveVertices(n,t,yt.ACCUMULATE_STEPS),this.emit("reshape",{type:"reshape",mover:this.graphic})}_updateEventState(t){if(t===this._reshapeEventState)return!1;switch(t){case Yt.NONE:if(0!==this._numGrabbing||0!==this._numDragging)return!1;switch(this._reshapeEventState){case Yt.MOVING:this.emit("move",{type:"move-stop",dx:0,dy:0,mover:this.graphic});break;case Yt.RESHAPING:this.emit("reshape",{type:"reshape-stop",mover:this.graphic})}break;case Yt.MOVING:switch(this._reshapeEventState){case Yt.NONE:this.emit("move",{type:"move-start",dx:0,dy:0,mover:this.graphic});break;case Yt.RESHAPING:this.emit("reshape",{type:"reshape-stop",mover:this.graphic}),this.destroyed||this.emit("move",{type:"move-start",dx:0,dy:0,mover:this.graphic})}break;case Yt.RESHAPING:switch(this._reshapeEventState){case Yt.NONE:this.emit("reshape",{type:"reshape-start",mover:this.graphic});break;case Yt.MOVING:this.emit("move",{type:"move-stop",dx:0,dy:0,mover:this.graphic}),this.destroyed||this.emit("reshape",{type:"reshape-start",mover:this.graphic})}}if(this.destroyed)return!1;const e=this._reshapeEventState!==t;return this._reshapeEventState=t,e}_createGraphicMoveManipulation(){const{tool:t,view:e}=this,i=this._graphicState;if(this._graphicMoveManipulation=new it({tool:t,view:e,graphicState:i}),this.enableMoveGraphic){let t=null;this._manipulatorHandles.add(this._graphicMoveManipulation.createDragPipeline(((e,i,a)=>{i.next((t=>this._trackNumDragging(t))).next((e=>("start"===e.action&&(t=this._editGeometryOperations.createUndoGroup()),e))).next((t=>this._perGraphicManipulatorDragAction(qt.ALL,t))).next((t=>(this._updateTranslateGraphicTooltip($.XY,t),t))).next((e=>{"end"===e.action&&(this._hideTooltip(),t=h(t))})),a.next((()=>this._onDragCancel(!0,(()=>t=h(t)))))}))),this._graphicMoveManipulation.forEachManipulator((t=>this._manipulatorHandles.add(this._watchAndUpdateGrabState(t,!1))))}else this._graphicMoveManipulation.forEachManipulator((t=>{t.grabbable=!1,t.cursor=null}));this._graphicMoveManipulation.forEachManipulator((t=>this._manipulatorHandles.add(t.events.on("immediate-click",(t=>{this._manipulatorInfos.some((t=>t.manipulator.selected))?this._clearSelection():this.emit("immediate-click",{...t,graphic:this.graphic}),t.stopPropagation()})))))}_createMoveManipulation(t){const{graphic:e,tool:i,view:a}=this,n=this._graphicState;this._moveManipulation=new tt({tool:i,view:a,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZShape&&K(e),snapToScene:!1,radius:tt.radiusForSymbol(e.symbol)}),this._moveManipulation.forEachManipulator((t=>this.addHandles([t.events.on("immediate-click",(i=>{this._moveManipulation.zManipulation.hasManipulator(t)||this._manipulatorInfos.some((t=>t.manipulator.selected))||this.emit("immediate-click",{...i,graphic:e}),i.stopPropagation()})),this._watchAndUpdateGrabState(t,!1)])));const o=t=>e=>{this.addHandles(e.events.on("focus-changed",(({action:e})=>{"focus"===e?this._updateTranslateTooltip(t):this._hideTooltip()})))};this._moveManipulation.xyManipulation.forEachManipulator(o($.XY)),this._moveManipulation.xyAxisManipulation.forEachManipulator(o($.XY_AXIS)),this._moveManipulation.zManipulation.forEachManipulator(o($.Z)),this._moveManipulation.elevationInfo={mode:"absolute-height",offset:0};const s=e.geometry.spatialReference;this.addHandles([this._moveManipulation.createDragPipeline(((a,n,o,s,r)=>{const{snappingStep:l,cancelSnapping:p}=Ot({predicate:t=>!!t.info,snappingManager:i.snappingManager,snappingContext:new xt({editGeometryOperations:this._editGeometryOperations,elevationInfo:t,pointer:r,excludeFeature:e,visualizer:new F}),updatingHandles:this._updatingHandles,useZ:!1});return s=s.next((t=>(this._onDragCancel(),t))).next(p),{steps:o=o.next((t=>this._trackNumDragging(t))).next((t=>{const e=this._manipulatorInfos.filter((t=>"vertex"===t.type&&t.manipulator.selected));return t.manipulatorType===W.TRANSLATE_XY&&1===e.length?{...t,info:e[0],snapOrigin:e[0].handle.pos}:t})).next(ut(this.view,t,e)).next(...l).next(ct()).next((t=>this._perGraphicManipulatorDragAction(qt.SELECTED_OR_ALL,t))).next((t=>(this._updateTranslateTooltip(a,t),t))),cancel:s}}),t,s,e),m((()=>n.displaying),(()=>this._updateMoveManipulationPosition()),g),n.on("changed",(()=>{this._recreatingManipulators||this._updateMoveManipulationPosition()})),m((()=>n.isDraped),(t=>{this._updateMoveManipulationPosition();const e="align-move-manipulation";t?this.addHandles(this.view.elevationProvider.on("elevation-change",(()=>this._updateMoveManipulationPosition())),e):this.removeHandles(e)}),g)])}_createVisualElements(){const{graphic:t,view:e}=this,i=J({view:e,graphic:t,forEachManipulator:t=>{if(!this.destroyed&&!this._recreatingManipulators){this._graphicMoveManipulation.forEachManipulator(t),this._moveManipulation.forEachManipulator(t);for(const e of this._manipulatorInfos)t(e.manipulator,W.TRANSLATE_XY)}},onManipulatorsChanged:t=>this.on("manipulators-changed",t)});null!=i&&(this._outlineVisualElement=i.visualElement instanceof rt?i.visualElement:null),null!=this._outlineVisualElement&&this._manipulatorHandles.add(this._outlineVisualElement.events.on("attachment-origin-changed",(()=>{this._graphicState.isDraped||this._updateMoveManipulationPosition()}))),this._manipulatorHandles.add(i)}_createEdgeOffsetManipulator(t,e=D(this.graphic)){if(t.component.vertices.length<=2)return null;const i=this._settings.manipulators.edgeOffset,a=i.size/2,n=a+i.collisionPadding,o=a/n,r=o*Math.sqrt(3)/2;null==this._edgeOffsetManipulatorGeometryInside&&(this._edgeOffsetManipulatorGeometryInside=pt(this._edgeOffsetManipulatorMaterial,r,o/2,o/2,i.height,i.offset)),null==this._edgeOffsetManipulatorGeometryOutside&&(this._edgeOffsetManipulatorGeometryOutside=pt(this._edgeOffsetManipulatorMaterial,-r,o/2,o/2,i.height,-i.offset));const l=[new N(this._edgeOffsetManipulatorGeometryInside.instantiate(),ft.Unfocused),new N(this._edgeOffsetManipulatorGeometryInside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),ft.Focused),new N(this._edgeOffsetManipulatorGeometryOutside.instantiate(),ft.Unfocused),new N(this._edgeOffsetManipulatorGeometryOutside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),ft.Focused)],p=new k({view:this.view,renderObjects:l,elevationInfo:"on-the-ground"!==e.mode||j(this.graphic.symbol)?{mode:"absolute-height",offset:0}:e,worldOriented:!1,focusMultiplier:1,radius:n,available:!(!this.graphic.visible||!this.graphic.layer?.visible),collisionType:{type:"disc",direction:I(0,0,1)},collisionPriority:1,metadata:{deleting:!1}}),h=new k({view:this.view,worldSized:!0,worldOriented:!1,available:!(!this.graphic.visible||!this.graphic.layer?.visible),collisionPriority:-10,cursor:this.enableMoveGraphic?"move":"default",metadata:{deleting:!1}}),u={manipulator:p,handle:t,locationUpdateHandle:null,type:"edge",selectedIndex:0,edgeManipulator:h,elevationInfo:e,visibilityHandle:null};this._autoHideEdgeOffsetManipulator(u,i.minSquaredEdgeLength),this._updateEdgeOffsetManipulator(u);const c=[];for(const s of[t.leftVertex,t.rightVertex]){const t=this._getManipulatorInfoFromHandle(s);null!=t&&c.push(t.manipulator.events.on("location-update",(()=>this._updateEdgeOffsetManipulator(u))))}u.locationUpdateHandle=s(c),this._manipulatorHandles.add(u.locationUpdateHandle,p),this._manipulatorHandles.add([this._watchAndUpdateGrabState(p,!0),this._watchAndUpdateGrabState(h,!0)],p),this._manipulatorHandles.add(mt(p,this._createEdgeOffsetPipeline(u,e)),p),this._manipulatorHandles.add(mt(h,((t,i,a,n)=>{if("touch"===n){this._createEdgeOffsetPipeline(u,e)(t,i,a)}else if(this.enableMoveGraphic){const n=this.graphic,o=null!=n.geometry?n.geometry.spatialReference:null;i.next((t=>this._trackNumDragging(t))).next(gt(this.view,t.elevationAlignedLocation)).next(Z(this.view,t.elevationAlignedLocation,e,o,n)).next(_t()).next(ct()).next((t=>this._perGraphicManipulatorDragAction(qt.ALL,t))).next((t=>(this._updateTranslateGraphicTooltip($.XY,t),t))).next((t=>{"end"===t.action&&this._hideTooltip()})),a.next((()=>this._onDragCancel(!t.metadata.deleting)))}})),p);const m=t=>{this._manipulatorInfos.some((t=>t.manipulator.selected))?this._clearSelection():this.emit("immediate-click",{...t,graphic:this.graphic}),t.stopPropagation()};return this._manipulatorHandles.add([p.events.on("immediate-click",m),h.events.on("immediate-click",m),p.events.on("focus-changed",(({action:t})=>{const{sketchOptions:e,tooltip:i}=this;if("focus"===t){const t=this._edgeOffsetTooltipInfo??=new bt({sketchOptions:e});t.distance=d,t.sketchOptions=e,this._updateTooltipAreaOrTotalLength(t),this._latestTooltipInfo=t,i.info=e.tooltips.effectiveEnabled?this._latestTooltipInfo:null}else this._hideTooltip()}))],p),this._manipulatorInfos.push(u),this.manipulators.add(p),this.manipulators.add(h),this.emit("manipulators-changed"),u}_autoHideEdgeOffsetManipulator(t,e){const i=t.manipulator,a=t.edgeManipulator,n=()=>{t.visibilityHandle=h(t.visibilityHandle);const n=this._getManipulatorInfoFromHandle(t.handle.leftVertex),o=this._getManipulatorInfoFromHandle(t.handle.rightVertex),l=null!=n&&null!=o&&st(n.manipulator.renderLocation,o.manipulator.renderLocation,this.view.state.camera)<e;(!i.focused&&!a.focused||l)&&(i.grabbable=!l,a.grabbable=!l,t.visibilityHandle=s([i.disableDisplay(),r((()=>{i.grabbable=!0,a.grabbable=this.enableMoveGraphic}))]))};this._manipulatorHandles.add([i.events.on("focus-changed",n),a.events.on("focus-changed",n),r((()=>{h(t.visibilityHandle),a.metadata.deleting=!0,this.manipulators.remove(a)}))],i),n()}_updateEdgeOffsetManipulator(t){this._updateManipulatorPosition(t);const{coordinateHelper:e}=this._editGeometryOperations.data,i=at(this.view,t.manipulator.elevationAlignedLocation,nt(e,t.handle,t.manipulator.elevationInfo)),a=this._getManipulatorInfoFromHandle(t.handle.leftVertex),n=this._getManipulatorInfoFromHandle(t.handle.rightVertex);if(null==a||null==n)return;const o=a.manipulator.renderLocation,s=n.manipulator.renderLocation,r=null!=i?ot(i,o,s):M;t.manipulator.modelTransform=r,t.edgeManipulator.elevationAlignedLocation=t.manipulator.elevationAlignedLocation,t.edgeManipulator.modelTransform=r;const l=y(x(zt,o,s))/2;t.edgeManipulator.collisionType={type:"line",paths:[[[-l,0,0],[l,0,0]]]}}_createEdgeOffsetPipeline(t,e){return(i,a,n)=>{this._clearSelection();const{step:o,cleanup:s}=this._initializeEdgeOffset(t,e);a.next((t=>this._trackNumDragging(t))).next(gt(this.view,i.elevationAlignedLocation)).next(o).next(z(this.view)).next(X(this.view,this._editGeometryOperations.data.spatialReference)).next(ct()).next(this._applyComputeEdgeOffsetDistanceStep()).next(this._applyEdgeOffsetStep(t)).next(this._showEdgeOffsetTooltip()).next((t=>{"end"===t.action&&s()})),n.next((()=>{i.metadata.deleting||(s(),this._onDragCancel())}))}}_initializeEdgeOffset(t,e){const{view:i}=this,n=this._editGeometryOperations,o=nt(n.data.coordinateHelper,t.handle,e),r=n.createUndoGroup(),p=at(i,t.manipulator.elevationAlignedLocation,o);if(o.requiresSplitEdgeLeft){const e=this._getManipulatorInfoFromHandle(t.handle.leftVertex.leftEdge);null!=e&&this._splitEdgeManipulator(e,1)}if(o.requiresSplitEdgeRight){const e=this._getManipulatorInfoFromHandle(t.handle.rightVertex.rightEdge);null!=e&&this._splitEdgeManipulator(e,0)}const d=()=>new w({paths:[[t.handle.leftVertex.pos,t.handle.rightVertex.pos]],spatialReference:n.data.spatialReference}),u=this._settings,c=new rt({view:i,isDraped:this._graphicState.isDraped,geometry:d(),elevationInfo:t.elevationInfo,width:u.visualElements.lineGraphics.outline.width,attached:!1,isDecoration:!0});let _;const f=()=>{this._cleanEdgeOffsetCollapsedEdges(t),_=h(_)},v=this.on("undo",f);return _=s([m((()=>a(this._accentColor)),(t=>c.color=t),g),l(c),m((()=>this._graphicState.isDraped),(t=>c.isDraped=t)),this._graphicState.on("changed",(()=>c.geometry=d())),r,v]),c.attached=!0,{step:t=>null==o||null==p?(f(),null):{...t,operation:o,plane:p},cleanup:f}}_applyEdgeOffsetStep(t){return e=>{if(this.destroyed||null==e.operation)return e;this._updateEventState(Yt.RESHAPING);const{mapDeltaX:i,mapDeltaY:a,mapDeltaZ:n}=e;return(i||a||n)&&(this._offsetEdge(t,e),this.emit("reshape",{type:"reshape",mover:this.graphic})),e}}_applyComputeEdgeOffsetDistanceStep(){return t=>{const{operation:e,mapEnd:i}=t;return null==e||null==i?t:("start"===t.action&&e.selectArrowFromStartPoint(i),{...t,signedDistance:e.signedDistanceToPoint(i)})}}_showEdgeOffsetTooltip(){return t=>{const{mapEnd:e,signedDistance:i,operation:a}=t,{tooltip:n,sketchOptions:o}=this;if(null!=i){const n=this._edgeOffsetTooltipInfo??=new bt({sketchOptions:o});n.sketchOptions=o,n.distance="end"===t.action?d:Rt(this._graphicState.isDraped,i*a.selectedArrow,e,a.plane,this._editGeometryOperations.data.coordinateHelper),this._updateTooltipAreaOrTotalLength(n),this._latestTooltipInfo=n}else this._latestTooltipInfo=null;return n.info=o.tooltips.effectiveEnabled?this._latestTooltipInfo:null,t}}_cleanEdgeOffsetCollapsedEdges(t){const e=t.handle.leftVertex.leftEdge?.leftVertex,i=t.handle.leftVertex,a=t.handle.rightVertex.rightEdge?.rightVertex,n=t.handle.rightVertex,o=this._editGeometryOperations.data.coordinateHelper,s=[];if(e&&o.distance(e.pos,i.pos)<Xt){const t=this._getManipulatorInfoFromHandle(i);null!=t&&s.push(t)}if(o.distance(i.pos,n.pos)<Xt||a&&o.distance(a.pos,n.pos)<Xt){const t=this._getManipulatorInfoFromHandle(n);null!=t&&s.push(t)}s.length&&this._removeVertices(s)}_computeVertexManipulatorSizeAndOutline(t){const e=t.size/2,i=e+t.collisionPadding;return{size:e/i,outlineSize:(e+t.outlineSize)/i}}_createVertexOrEdgeManipulator(t,e=D(this.graphic),i=!1){const{view:a}=this,n=this._settings;if("edge"===t.type){if(this.enableEdgeOffset)return this._createEdgeOffsetManipulator(t,e);if(!this.enableMidpoints)return null}if(null==this._vertexManipulatorGeometry||null==this._vertexManipulatorOutlineGeometry){const{size:t,outlineSize:e}=this._computeVertexManipulatorSizeAndOutline(n.manipulators.vertex);this._vertexManipulatorGeometry=ht(this._vertexManipulatorMaterial,t,16,16),this._vertexManipulatorOutlineGeometry=ht(this._vertexManipulatorOutlineMaterial,e,16,16)}if(null==this._edgeManipulatorGeometry||null==this._edgeManipulatorOutlineGeometry){const{size:t,outlineSize:e}=this._computeVertexManipulatorSizeAndOutline(n.manipulators.edge);this._edgeManipulatorGeometry=ht(this._edgeManipulatorMaterial,t,16,16),this._edgeManipulatorOutlineGeometry=ht(this._edgeManipulatorOutlineMaterial,e,16,16)}const{geometry:o}=this.graphic,r=o?.type,l="point"===r||"mesh"===r?[]:[new N(this._vertexManipulatorGeometry.instantiate(),Zt.Vertex|ft.Unselected),new N(this._vertexManipulatorOutlineGeometry.instantiate(),Zt.Vertex|ft.Unfocused|ft.Unselected),new N(this._vertexManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),Zt.Vertex|ft.Focused|ft.Unselected),new N(this._vertexManipulatorGeometry.instantiate({material:this._selectedManipulatorMaterial}),ft.Selected),new N(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorOutlineMaterial}),ft.Selected|ft.Unfocused),new N(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorHoverOutlineMaterial}),ft.Selected|ft.Focused)];this.enableMidpoints&&l.push(new N(this._edgeManipulatorGeometry.instantiate({material:this._vertexManipulatorMaterial}),Zt.Edge|ft.Focused|ft.Unselected),new N(this._edgeManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),Zt.Edge|ft.Focused|ft.Unselected),new N(this._edgeManipulatorGeometry.instantiate(),Zt.Edge|ft.Unfocused|ft.Unselected),new N(this._edgeManipulatorOutlineGeometry.instantiate(),Zt.Edge|ft.Unfocused|ft.Unselected));const p=new k({view:a,renderObjects:l,elevationInfo:e,focusMultiplier:1,touchMultiplier:1,available:!(!this.graphic.visible||!this.graphic.layer?.visible),metadata:{deleting:!1}});p.selected=i,this._setTypeSpecificManipulatorSettings(p,t,e);const d="edge"===t.type?{manipulator:p,handle:t,locationUpdateHandle:null,type:"edge",selectedIndex:0}:{manipulator:p,handle:t,type:"vertex",selectedIndex:0};if(this._manipulatorInfos.push(d),this.manipulators.add(p),this._updateManipulatorPosition(d),"edge"===d.type){const t=[];for(const e of[d.handle.leftVertex,d.handle.rightVertex]){const i=this._getManipulatorInfoFromHandle(e);null!=i&&t.push(i.manipulator.events.on("location-update",(()=>this._updateManipulatorPosition(d))))}d.locationUpdateHandle=s(t),this._manipulatorHandles.add(d.locationUpdateHandle,p)}this._manipulatorHandles.add(this._watchAndUpdateGrabState(p,!0),p);const u=mt(p,((t,i,a,n)=>{let o=null;const{snappingStep:s,cancelSnapping:r}=Ot({predicate:()=>!this._isMultiVertexSelection(),snappingManager:this.tool.snappingManager,snappingContext:new xt({editGeometryOperations:this._editGeometryOperations,elevationInfo:e,pointer:n,excludeFeature:this.graphic,visualizer:new F}),updatingHandles:this._updatingHandles,useZ:!1});a=a.next((e=>(this._onDragCancel(!t.metadata.deleting,(()=>o=h(o))),e))).next(r),i.next((t=>this._trackNumDragging(t))).next((t=>{if("start"===t.action&&(o=this._editGeometryOperations.createUndoGroup()),"edge"===d.type){const e=this._splitEdgeManipulator(d);return{...t,info:e,snapOrigin:e.handle.pos}}return{...t,info:d,snapOrigin:d.handle.pos}})).next(gt(this.view,t.elevationAlignedLocation)).next(Y(this.view,this.graphic,t.elevationAlignedLocation,t.location.spatialReference,this.graphic)).next(ut(this.view,e,this.graphic)).next(...s).next(ct()).next((e=>{this._perVertexManipulatorDragAction(e),"end"===e.action&&(o=h(o)),this._updateTranslateVertexTooltip(t,$.XY,e)}))}));return this._manipulatorHandles.add([u,p.events.on("immediate-click",(t=>this._manipulatorClickCallback(t,d))),p.events.on("select-changed",(()=>{d.selectedIndex=++this._selectedIndex,this._updateMoveManipulationPosition()})),p.events.on("focus-changed",(({action:t})=>{"focus"===t&&"edge"!==d.type?this._updateTranslateVertexTooltip(p,$.XY):this._hideTooltip()}))],p),this.emit("manipulators-changed"),d}_trackNumDragging(t){switch(t.action){case"start":this._numDragging++;break;case"end":this._numDragging--}return t}_onDragCancel(t=!0,e){switch(this._numDragging--,t&&(this.undo(),this.outputGeometry=null!=this._editGeometryOperations?this._editGeometryOperations.data.geometry:null),null!=this.tool.snappingManager&&this.tool.snappingManager.doneSnapping(),this._hideTooltip(),this._reshapeEventState){case Yt.NONE:break;case Yt.MOVING:this.emit("move",{type:"move",dx:0,dy:0,mover:this.graphic});break;case Yt.RESHAPING:this.emit("reshape",{type:"reshape",mover:this.graphic})}e&&e(),this.destroyed||this._updateEventState(Yt.NONE)}_setTypeSpecificManipulatorSettings(t,e,i){const{graphic:a}=this,n=this._settings;switch(e.type){case"vertex":{t.state=Zt.Vertex,t.selectable=!0,t.cursor="move",t.collisionPriority=2;const{size:e,collisionPadding:o}=n.manipulators.vertex;t.radius=e/2+o,t.elevationInfo=i;const{geometry:s}=a,r=s?.type;t.interactive=null!=r&&"point"!==r&&"mesh"!==r;break}case"edge":{t.state=Zt.Edge,t.selectable=!1,t.cursor="copy",t.collisionPriority=-1;const{size:e,collisionPadding:o}=n.manipulators.edge;t.radius=e/2+o,t.elevationInfo="on-the-ground"!==i.mode||j(a.symbol)?{mode:"absolute-height",offset:0}:i;break}}}_watchAndUpdateGrabState(t,e){return t.events.on("grab-changed",(i=>this._onGrabStateChanged(t,e,i.action,i.pointerType)))}_onGrabStateChanged(t,e,i,a="mouse"){if(!this._recreatingManipulators){if("start"===i)e&&this._updateSelection(t),this._numGrabbing++;else if(this._numGrabbing--,this._updateEventState(Yt.NONE),this.destroyed)return;this._moveManipulation.interactive=!this._numGrabbing,("touch"!==a||this.enableEdgeOffset)&&(this._manipulatorInfos.forEach((t=>{const{manipulator:e}=t,{geometry:i}=this.graphic,a=i?.type;e.interactive=e.grabbing||!this._numGrabbing&&null!=a&&"point"!==a&&"mesh"!==a,"edgeManipulator"in t&&(t.edgeManipulator.interactive=t.edgeManipulator.grabbing||!this._numGrabbing)})),this._graphicMoveManipulation.forEachManipulator((t=>{t.interactive=t.grabbing||!this._numGrabbing})))}}_clearSelection(){for(const t of this._manipulatorInfos)t.manipulator.grabbing||(t.manipulator.selected=!1)}_updateSelection(t){t.grabbing&&!t.selected&&t.selectable&&(this._clearSelection(),t.selected=!0,this.emit("manipulators-changed"))}_removeManipulator(t){null!=t&&(t.manipulator.metadata.deleting=!0,this.manipulators.remove(t.manipulator),this._manipulatorHandles.remove(t.manipulator),i(this._manipulatorInfos,t),this.emit("manipulators-changed"))}_getManipulatorInfoFromHandle(t){if(t)for(const e of this._manipulatorInfos)if(t===e.handle)return e;return null}_updateManipulatorPosition(t){if(null==t)return;const e=this._editGeometryOperations;if("vertex"===t.type)t.manipulator.location=e.data.coordinateHelper.vectorToDehydratedPoint(t.handle.pos,Ft),t.manipulator.grabbing&&null!=this._vertexLaserLineVisualElement&&(this._vertexLaserLineVisualElement.visualElement.intersectsWorldUpAtLocation=t.manipulator.renderLocation);else if("edge"===t.type){const i=this._getManipulatorInfoFromHandle(t.handle.leftVertex),a=this._getManipulatorInfoFromHandle(t.handle.rightVertex);if(null==i||null==a)return;const n=i.manipulator,o=a.manipulator;if(null!=t.manipulator.elevationInfo&&"on-the-ground"===t.manipulator.elevationInfo.mode){const i=n.location,a=o.location,s=.5,r=i.x+s*(a.x-i.x),l=i.y+s*(a.y-i.y),p=i.hasZ&&a.hasZ?0:void 0;t.manipulator.location=L(r,l,p,e.data.spatialReference)}else O(zt,n.renderLocation,o.renderLocation,.5),t.manipulator.renderLocation=zt}}_splitEdgeManipulator(t,e=.5){const i=this._editGeometryOperations,a=i.splitEdge(t.handle,e).createdVertex;t.locationUpdateHandle=h(t.locationUpdateHandle);const n=D(this.graphic);let o;this.enableEdgeOffset?(this._removeManipulator(t),o=this._createVertexOrEdgeManipulator(a)):(o=t,o.handle=a,o.type="vertex",this._setTypeSpecificManipulatorSettings(t.manipulator,t.handle,n)),a.leftEdge&&this._createVertexOrEdgeManipulator(a.leftEdge),a.rightEdge&&this._createVertexOrEdgeManipulator(a.rightEdge),this.outputGeometry=i.data.geometry,this._updateManipulatorPosition(o),this.enableEdgeOffset||this._updateTranslateVertexTooltip(o.manipulator,$.XY),this._updateSelection(t.manipulator);const s=this._updateEventState(Yt.RESHAPING),r=i.data.coordinateHelper.vectorToArray(o.handle.pos),l=i.data.components.indexOf(a.component);return this.emit("vertex-add",{type:"vertex-add",vertices:[{coordinates:r,componentIndex:l,vertexIndex:a.index}],added:r}),s&&this._updateEventState(Yt.NONE),o}_updateMoveManipulationPosition(){const t=b(zt,0,0,0);let e=0,i=!1,a=null,n=null;for(const o of this._manipulatorInfos)"vertex"===o.type&&(o.manipulator.selected?(e++,E(t,t,o.manipulator.renderLocation),null==a||o.selectedIndex>a.selectedIndex?(n=a,a=o):(null==n||o.selectedIndex>n.selectedIndex)&&(n=o)):i=!0);if(0===e){const t=this._graphicState.displaying&&this.enableMoveGraphic;this._moveManipulation.xyManipulation.available=t,this._moveManipulation.xyAxisManipulation.available=t,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=t,this._moveManipulation.zManipulation.available=t&&this.enableZShape&&K(this.graphic),this._moveManipulation.angle=q(this.graphic.geometry),this._moveManipulation.radius=tt.radiusForSymbol(this.graphic.symbol)}else{const t=this._graphicState.displaying;this._moveManipulation.xyManipulation.available=t,this._moveManipulation.xyAxisManipulation.available=t,this._moveManipulation.zManipulation.available=t&&this.enableZVertex&&K(this.graphic),this._moveManipulation.xyAxisManipulation.orthogonalAvailable=t&&1!==e;let i=0;if(null!=a){const t=a.handle.pos,e=null!=n?n.handle.pos:a.handle.leftEdge&&a.handle.leftEdge.leftVertex?a.handle.leftEdge.leftVertex.pos:null,o=null==n&&a.handle.rightEdge&&a.handle.rightEdge.rightVertex?a.handle.rightEdge.rightVertex.pos:null;e&&o?this._moveManipulation.xyAxisManipulation.available=!1:e?i=Nt(e,t):o&&(i=Nt(t,o))}this._moveManipulation.angle=i,this._moveManipulation.radius=Q}0!==e&&i?(G(t,t,1/e),Ft.spatialReference=this._editGeometryOperations.data.spatialReference,Ft.hasZ=!0,this.view.renderCoordsHelper.fromRenderCoords(t,Ft),this._moveManipulation.elevationAlignedLocation=Ft):null==this._outlineVisualElement||this._graphicState.isDraped||null==this._outlineVisualElement.attachmentOrigin?C(this.view,this._moveManipulation,this.graphic):this._moveManipulation.elevationAlignedLocation=this._outlineVisualElement.attachmentOrigin}_removeVertices(t){const e=new Array,i=this._editGeometryOperations;for(const a of t){const t=a.handle.component;if("vertex"===a.type&&i.canRemoveVertex(t)){e.push(a.handle),this._removeManipulator(a),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.leftEdge)),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.rightEdge));const n=i.removeVertices([a.handle]),o=n.removedVertices?.[0].createdEdge;o?this._createVertexOrEdgeManipulator(o):this.enableEdgeOffset&&t.vertices.length<=2&&this._removeManipulator(this._getManipulatorInfoFromHandle(t.edges[0]))}}if(e.length>0){const t=e.map((t=>{const e=i.data.components.indexOf(t.component);return{coordinates:i.data.coordinateHelper.vectorToArray(t.pos),componentIndex:e,vertexIndex:t.index}}));this.outputGeometry=i.data.geometry;const a=this._updateEventState(Yt.RESHAPING);if(this.destroyed)return;if(this.emit("vertex-remove",{type:"vertex-remove",removed:t.map((t=>t.coordinates)),vertices:t}),this.destroyed)return;if(a&&(this._updateEventState(Yt.NONE),this.destroyed))return;this._updateMoveManipulationPosition()}}_moveVertices(t,e,i=("start"===e.action?yt.NEW_STEP:yt.ACCUMULATE_STEPS)){const a=this._editGeometryOperations;a.moveVertices(t.map((t=>t.handle)),e.mapDeltaX,e.mapDeltaY,e.mapDeltaZ,i),this.outputGeometry=a.data.geometry;for(const n of t)this._updateManipulatorPosition(n)}_offsetEdge(t,e){if(null==e.operation||null==e.signedDistance)return;const i=this._editGeometryOperations,a=e.operation.clone();a.distance=e.signedDistance,i.updateVertices([t.handle.leftVertex,t.handle.rightVertex],a),this.outputGeometry=i.data.geometry,this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(t.handle.leftVertex)),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(t.handle.rightVertex))}_manipulatorClickCallback(t,e){t.shiftKey||this._clearSelection(),"vertex"===e.type&&(e.manipulator.selected=!e.manipulator.selected,t.button===dt.Right&&this._removeVertices([e])),"edge"===e.type&&t.button===dt.Left&&this._splitEdgeManipulator(e),t.stopPropagation()}_updateTranslateTooltip(t,e){const i=this._manipulatorInfos.filter((t=>"vertex"===t.type&&t.manipulator.selected));1===i.length?this._updateTranslateVertexTooltip(i[0].manipulator,t,e):this._updateTranslateGraphicTooltip(t,e)}_updateTranslateGraphicTooltip(t,e){const{sketchOptions:i,tooltip:a}=this;switch(t){case $.XY:this._latestTooltipInfo=this._translateGraphicTooltipInfo??=new St({sketchOptions:i}),this._updateTranslateTooltipDistance(this._latestTooltipInfo,e,((t,e)=>Lt(t,e)));break;case $.XY_AXIS:this._latestTooltipInfo=this._translateGraphicXYTooltipInfo??=new It({sketchOptions:i}),this._updateTranslateTooltipDistance(this._latestTooltipInfo,e,((t,i)=>u(Lt(t,i),et(e))));break;case $.Z:this._latestTooltipInfo=this._translateGraphicZTooltipInfo??=new Gt({sketchOptions:i}),this._updateTranslateTooltipDistance(this._latestTooltipInfo,e,jt)}this._latestTooltipInfo.sketchOptions=i,a.info=i.tooltips.effectiveEnabled?this._latestTooltipInfo:null}_updateTranslateVertexTooltip(t,e,i){const{sketchOptions:a,tooltip:n}=this;switch(e){case $.XY:this._latestTooltipInfo=this._translateVertexTooltipInfo??=new Ht({sketchOptions:a}),this._updateTranslateTooltipDistance(this._latestTooltipInfo,i,((t,e)=>Lt(t,e))),this._updateTooltipAreaOrTotalLength(this._latestTooltipInfo);break;case $.XY_AXIS:this._latestTooltipInfo=this._translateVertexXYTooltipInfo??=new wt({sketchOptions:a}),this._updateTranslateTooltipDistance(this._latestTooltipInfo,i,((t,e)=>u(Lt(t,e),et(i)))),this._updateTooltipAreaOrTotalLength(this._latestTooltipInfo);break;case $.Z:this._latestTooltipInfo=this._translateVertexZTooltipInfo??=new Tt({sketchOptions:a}),this._updateTranslateTooltipDistance(this._latestTooltipInfo,i,jt)}const o=kt(t.location);this._latestTooltipInfo.elevation=null!=o?Vt({actual:o}):null,this._latestTooltipInfo.sketchOptions=a,n.info=a.tooltips.effectiveEnabled?this._latestTooltipInfo:null}_updateTranslateTooltipDistance(t,e,i){if(null!=e&&"end"!==e.action){const{mapStart:a,mapEnd:n}=e,o=i(a,n);t.distance=null!=o?o:d}else t.distance=d}_updateTooltipAreaOrTotalLength(t){const{geometry:e}=this.graphic;if(null==e)return t.area=null,void(t.totalLength=null);t.area="polygon"===e.type?At(e):null,t.totalLength="polyline"===e.type?Dt(e):null}_hideTooltip(){this.tooltip.clear(),this._latestTooltipInfo=null}get test(){return{segmentLabels:this._segmentLabels,manipulatorInfos:this._manipulatorInfos}}};function Nt(t,e){return Math.atan2(e[1]-t[1],e[0]-t[0])+Math.PI/2}function Rt(t,e,i,a,n){if(t){const t=n.toXYZ(n.pointToVector(i)),o=V(a,t,A.get()),s=Pt(o,t,n.spatialReference);if(null!=s)return c(s.value*Math.sign(e),s.unit)}return c(e*_(i.spatialReference),"meters")}t([f()],Ct.prototype,"_editGeometryOperations",void 0),t([f()],Ct.prototype,"_segmentLabels",void 0),t([f({constructOnly:!0})],Ct.prototype,"tool",void 0),t([f()],Ct.prototype,"tooltip",void 0),t([f()],Ct.prototype,"inputGeometry",null),t([f()],Ct.prototype,"outputGeometry",void 0),t([f({readOnly:!0})],Ct.prototype,"updating",null),t([f()],Ct.prototype,"manipulators",null),t([f()],Ct.prototype,"view",null),t([f()],Ct.prototype,"graphic",null),t([f()],Ct.prototype,"enableZShape",null),t([f()],Ct.prototype,"enableZVertex",null),t([f()],Ct.prototype,"enableMoveGraphic",null),t([f()],Ct.prototype,"enableMidpoints",null),t([f()],Ct.prototype,"enableEdgeOffset",null),t([f()],Ct.prototype,"sketchOptions",null),t([f()],Ct.prototype,"_accentColor",null),Ct=t([v("esri.views.3d.interactive.editingTools.reshapeGraphic.ReshapeOperation")],Ct);const Ft=L(0,0,void 0,Ut.WGS84),zt=S(),Xt=1e-6;var Zt,Yt,qt;!function(t){t.Vertex=vt.Custom1,t.Edge=vt.Custom2}(Zt||(Zt={})),function(t){t[t.NONE=0]="NONE",t[t.MOVING=1]="MOVING",t[t.RESHAPING=2]="RESHAPING"}(Yt||(Yt={})),function(t){t[t.ALL=0]="ALL",t[t.SELECTED_OR_ALL=1]="SELECTED_OR_ALL"}(qt||(qt={}));export{Ct as ReshapeOperation};
5
+ import{_ as t}from"../../../../../chunks/tslib.es6.js";import"../../../../../geometry.js";import e from"../../../../../core/Accessor.js";import{removeUnordered as i}from"../../../../../core/arrayUtils.js";import{unitRGBAFromColor as a}from"../../../../../core/colorUtils.js";import"../../../../../core/has.js";import n from"../../../../../core/Evented.js";import o from"../../../../../core/Handles.js";import{handlesGroup as s,makeHandle as r,destroyHandle as l}from"../../../../../core/handleUtils.js";import{destroyMaybe as p,removeMaybe as h}from"../../../../../core/maybe.js";import{zeroMeters as d,scale as u,createLength as c}from"../../../../../core/quantityUtils.js";import{watch as m,initial as g}from"../../../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as _}from"../../../../../core/unitUtils.js";import{property as f}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import{subclass as v}from"../../../../../core/accessorSupport/decorators/subclass.js";import{IDENTITY as M}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{l as y,f as x,m as O,s as b,g as E,h as G}from"../../../../../chunks/vec32.js";import{fromValues as I,create as S}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as T}from"../../../../../core/support/UpdatingHandles.js";import w from"../../../../../geometry/Polyline.js";import{hasCompatibleTopology as H}from"../../../../../geometry/support/coordsUtils.js";import{projectPoint as V}from"../../../../../geometry/support/plane.js";import{sv3d as A}from"../../../../../geometry/support/vectorStacks.js";import{makeDehydratedPoint as L}from"../../../../../layers/graphics/dehydratedPoint.js";import{getGraphicEffectiveElevationInfo as D}from"../../../../../support/elevationInfoUtils.js";import{isVolumetricSymbol as j}from"../../../../../symbols/support/utils.js";import{Manipulator3D as k}from"../../Manipulator3D.js";import{createManipulatorMaterial as P,createManipulatorOutlineMaterial as U,placeAtGraphic as C}from"../../manipulatorUtils.js";import{RenderObject as N}from"../../RenderObject.js";import{SegmentLabels3D as R}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as F}from"../../SnappingVisualizer3D.js";import{screenToRenderPlaneFromEvent as z,convertToMapCoordinates as X,screenToMapXYAtLocation as Z,screenToMapXYForGraphicAtLocation as Y}from"../dragEventPipeline3D.js";import{orientation as q}from"../geometryUtils.js";import{ManipulatorType as W}from"../ManipulatorType.js";import{canMoveZ as K}from"../manipulatorUtils.js";import{Settings as B}from"../settings.js";import{createVisualElements as J}from"../visualElementUtils.js";import{discRadiusSmall as Q}from"../manipulations/config.js";import{ManipulationType as $,MoveManipulation as tt}from"../manipulations/MoveManipulation.js";import{axisConstrainedDragSign as et}from"../manipulations/moveUtils.js";import{MoveXYGraphicManipulation as it}from"../manipulations/MoveXYGraphicManipulation.js";import{createEdgeOffsetIntersectionPlane as at,createEdgeOffsetOperation as nt,edgeOffsetRotationMatrix as ot,screenEdgeLengthSquared as st}from"./edgeOffsetUtils.js";import{OutlineVisualElement as rt}from"../../visualElements/OutlineVisualElement.js";import{GraphicState as lt}from"../../../layers/graphics/GraphicState.js";import{createExtrudedTriangle as pt,createSphereGeometry as ht}from"../../../webgl-engine/lib/GeometryUtil.js";import{MouseButton as dt}from"../../../../input/IViewEvents.js";import{sceneSnappingAtLocation as ut,addMapDelta as ct,createManipulatorDragEventPipeline as mt,dragAtLocation as gt,addScreenDelta as _t}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateFlags as ft,ManipulatorStateCustomFlags as vt}from"../../../../interactive/interfaces.js";import{EditGeometryOperations as Mt}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehavior as yt}from"../../../../interactive/editGeometry/interfaces.js";import{SnappingContext as xt}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as Ot}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{ReshapeEdgeOffsetTooltipInfo as bt}from"../../../../interactive/tooltip/ReshapeTooltipInfos.js";import{Tooltip as Et}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateGraphicZTooltipInfo as Gt,TranslateGraphicXYTooltipInfo as It,TranslateGraphicTooltipInfo as St,TranslateVertexZTooltipInfo as Tt,TranslateVertexXYTooltipInfo as wt,TranslateVertexTooltipInfo as Ht}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{makeElevationField as Vt}from"../../../../interactive/tooltip/fields/fields.js";import{autoArea2D as At}from"../../../../support/automaticAreaMeasurementUtils.js";import{autoDistanceBetweenPoints2D as Lt,autoLength2D as Dt}from"../../../../support/automaticLengthMeasurementUtils.js";import{verticalSignedDistanceBetweenPoints as jt,elevationFromPoint as kt}from"../../../../support/euclideanLengthMeasurementUtils.js";import{geodesicDistance as Pt}from"../../../../support/geodesicLengthMeasurementUtils.js";import Ut from"../../../../../geometry/SpatialReference.js";let Ct=class extends(n.EventedMixin(e)){constructor(t){super(t),this._selectedIndex=0,this._manipulatorHandles=new o,this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0,this._reshapeEventState=Yt.NONE,this._updatingHandles=new T,this._recreatingManipulators=!1,this._settings=new B({getTheme:()=>this.view.effectiveTheme}),this._latestTooltipInfo=null,this._translateGraphicTooltipInfo=null,this._translateGraphicXYTooltipInfo=null,this._translateGraphicZTooltipInfo=null,this._translateVertexTooltipInfo=null,this._translateVertexXYTooltipInfo=null,this._translateVertexZTooltipInfo=null,this._edgeOffsetTooltipInfo=null,this.outputGeometry=null,this._vertexLaserLineVisualElement=null}initialize(){const{graphic:t,view:e}=this,i=this._settings.manipulators,n=i.vertex;this._vertexManipulatorMaterial=P(a(n.color),n.renderOccluded),this._vertexManipulatorOutlineMaterial=U(a(n.outlineColor),n.renderOccluded),this._vertexManipulatorHoverOutlineMaterial=U(a(n.hoverOutlineColor),n.renderOccluded);const o=i.edge;this._edgeManipulatorMaterial=P(a(o.color),o.renderOccluded),this._edgeManipulatorOutlineMaterial=U(a(o.outlineColor),o.renderOccluded);const s=i.edgeOffset;this._edgeOffsetManipulatorMaterial=P(a(s.color),s.renderOccluded,!1),this._edgeOffsetManipulatorHoverMaterial=P(a(s.hoverColor),s.renderOccluded,!1);const r=i.selected;this._selectedManipulatorMaterial=P(a(r.color),r.renderOccluded),this._selectedManipulatorOutlineMaterial=U(a(r.outlineColor),r.renderOccluded),this._selectedManipulatorHoverOutlineMaterial=U(a(r.hoverOutlineColor),r.renderOccluded);const l=this._graphicState=new lt({graphic:t});this.tooltip=new Et({view:e}),this.addHandles([m((()=>{const t=this._settings.manipulators;return{vertexSettings:t.vertex,edgeSettings:t.edge,edgeOffsetSettings:t.edgeOffset,selectedSettings:t.selected}}),(({vertexSettings:t,edgeSettings:e,edgeOffsetSettings:i,selectedSettings:a})=>{t.applyColor(this._vertexManipulatorMaterial),t.applyOutline(this._vertexManipulatorOutlineMaterial),t.applyHoverOutline(this._vertexManipulatorHoverOutlineMaterial),e.applyColor(this._edgeManipulatorMaterial),e.applyOutline(this._edgeManipulatorOutlineMaterial),i.applyColor(this._edgeOffsetManipulatorMaterial),i.applyHover(this._edgeOffsetManipulatorHoverMaterial),a.applyColor(this._selectedManipulatorMaterial),a.applyOutline(this._selectedManipulatorOutlineMaterial),a.applyHoverOutline(this._selectedManipulatorHoverOutlineMaterial)})),m((()=>l.displaying),(t=>{for(const e of this._manipulatorInfos)e.manipulator.available=t})),m((()=>({labels:this._segmentLabels,enabled:this.sketchOptions.labels.enabled,edgeOffsetEnabled:this.enableEdgeOffset})),(({labels:t,enabled:e,edgeOffsetEnabled:i})=>{null!=t&&(t.visible=e,t.edgeDistance=i?"far":"default")}),g),m((()=>this.sketchOptions.tooltips.effectiveEnabled),(t=>{this.tooltip.info=t?this._latestTooltipInfo:null}),g),this.view.trackGraphicState(l)])}destroy(){this._segmentLabels=p(this._segmentLabels),this.tooltip=p(this.tooltip),this._removeManipulators(),this._updatingHandles.destroy()}get inputGeometry(){return null!=this._editGeometryOperations?this._editGeometryOperations.data.geometry:null}set inputGeometry(t){this._recreateEditGeometryAndManipulators(t)}get updating(){return this._updatingHandles.updating}get manipulators(){return this.tool.manipulators}get view(){return this.tool.view}get graphic(){return this.tool.graphic}get enableZShape(){return this.tool.enableZShape}get enableZVertex(){return this.tool.enableZVertex}get enableMoveGraphic(){return this.tool.enableMoveGraphic}get enableMidpoints(){return this.tool.enableMidpoints}get enableEdgeOffset(){return this.tool.enableEdgeOffset}get sketchOptions(){return this.tool.sketchOptions}get _accentColor(){return this.view.effectiveTheme.accentColor}removeSelectedVertices(){const t=this._manipulatorInfos.filter((t=>t.manipulator.selected&&"vertex"===t.type));this._removeVertices(t)}onManipulatorSelectionChanged(){this.emit("manipulators-changed")}_removeManipulators(){this._manipulatorHandles.removeAll(),this._moveManipulation=p(this._moveManipulation),this._graphicMoveManipulation=p(this._graphicMoveManipulation),this.manipulators.removeAll(),this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0}_createManipulators(t){if(null==this._editGeometryOperations)return;const e=D(this.graphic);for(const i of this._editGeometryOperations.data.components){const a=t?.byComponentIndex.get(i.index);for(const t of i.vertices){const i=a?.has(t.index);this._createVertexOrEdgeManipulator(t,e,i)}for(const t of i.edges)this._createVertexOrEdgeManipulator(t,e)}this._createGraphicMoveManipulation(),this._createMoveManipulation(e),this._createVisualElements()}get canRedo(){return null!=this._editGeometryOperations&&this._editGeometryOperations.canRedo}get canUndo(){return null!=this._editGeometryOperations&&this._editGeometryOperations.canUndo}redo(){if(null==this._editGeometryOperations)return null;const t=this._editGeometryOperations.redo();return null!=t&&(this.outputGeometry=this._editGeometryOperations.data.geometry,this._recreateManipulators()),t}undo(){if(null==this._editGeometryOperations)return null;this.emit("undo");const t=this._editGeometryOperations.undo();return null!=t&&(this.outputGeometry=this._editGeometryOperations.data.geometry,this._recreateManipulators()),t}_recreateManipulators(){this._recreatingManipulators||(this._recreatingManipulators=!0,this._removeManipulators(),this._hideTooltip(),this._createManipulators(),this._recreatingManipulators=!1)}_recreateEditGeometryAndManipulators(t){const e={byComponentIndex:new Map};if(null!=t&&null!=this.inputGeometry&&H(t,this.inputGeometry))for(const n of this._manipulatorInfos)if("vertex"===n.type&&n.manipulator.selected){const{index:t,component:{index:i}}=n.handle,{byComponentIndex:a}=e,o=a.get(i)||new Set;o.add(t),a.set(i,o)}if(this._recreatingManipulators=!0,this._removeManipulators(),this._hideTooltip(),this._editGeometryOperations=p(this._editGeometryOperations),this._segmentLabels=p(this._segmentLabels),null==t)return void(this._recreatingManipulators=!1);const i="mesh"===t.type?t.anchor:t;this._editGeometryOperations=Mt.fromGeometry(i,this.view.state.viewingMode),this._createManipulators(e);const a=this.sketchOptions.labels;this._segmentLabels=new R({context:{view:this.view,editGeometryOperations:this._editGeometryOperations,elevationInfo:D(this.graphic),labelOptions:a,graphic:this.graphic,graphicState:this._graphicState},visible:a.enabled}),this._recreatingManipulators=!1}_perGraphicManipulatorDragAction(t,e){if("end"===e.action)return e;let i=0;const a=[],n=this._manipulatorInfos.some((t=>"vertex"===t.type&&t.manipulator.selected)),o=t===qt.SELECTED_OR_ALL&&n;for(const s of this._manipulatorInfos)"vertex"===s.type&&(s.manipulator.grabbing||o&&!s.manipulator.selected||a.push(s),i++);if(0===a.length)return e;this._moveVertices(a,e);if(a.length===i){if(this._updateEventState(Yt.MOVING),this.destroyed)return e;this.emit("move",{type:"move",dx:e.screenDeltaX,dy:e.screenDeltaY,mover:this.graphic})}else{if(this._updateEventState(Yt.RESHAPING),this.destroyed)return e;this.emit("reshape",{type:"reshape",mover:this.graphic})}return e}_isMultiVertexSelection(){return this._manipulatorInfos.reduce(((t,e)=>"vertex"===e.type&&e.manipulator.selected?t+1:t),0)>1}_perVertexManipulatorDragAction(t){if(this._updateEventState(Yt.RESHAPING),this.destroyed)return;const{mapDeltaX:e,mapDeltaY:i,mapDeltaZ:a}=t;if(!e&&!i&&!a)return;const n=[];for(const o of this._manipulatorInfos)"vertex"===o.type&&(o.manipulator.selected&&!o.manipulator.grabbing||o===t.info)&&n.push(o);this._moveVertices(n,t,yt.ACCUMULATE_STEPS),this.emit("reshape",{type:"reshape",mover:this.graphic})}_updateEventState(t){if(t===this._reshapeEventState)return!1;switch(t){case Yt.NONE:if(0!==this._numGrabbing||0!==this._numDragging)return!1;switch(this._reshapeEventState){case Yt.MOVING:this.emit("move",{type:"move-stop",dx:0,dy:0,mover:this.graphic});break;case Yt.RESHAPING:this.emit("reshape",{type:"reshape-stop",mover:this.graphic})}break;case Yt.MOVING:switch(this._reshapeEventState){case Yt.NONE:this.emit("move",{type:"move-start",dx:0,dy:0,mover:this.graphic});break;case Yt.RESHAPING:this.emit("reshape",{type:"reshape-stop",mover:this.graphic}),this.destroyed||this.emit("move",{type:"move-start",dx:0,dy:0,mover:this.graphic})}break;case Yt.RESHAPING:switch(this._reshapeEventState){case Yt.NONE:this.emit("reshape",{type:"reshape-start",mover:this.graphic});break;case Yt.MOVING:this.emit("move",{type:"move-stop",dx:0,dy:0,mover:this.graphic}),this.destroyed||this.emit("reshape",{type:"reshape-start",mover:this.graphic})}}if(this.destroyed)return!1;const e=this._reshapeEventState!==t;return this._reshapeEventState=t,e}_createGraphicMoveManipulation(){const{tool:t,view:e}=this,i=this._graphicState;if(this._graphicMoveManipulation=new it({tool:t,view:e,graphicState:i}),this.enableMoveGraphic){let t=null;this._manipulatorHandles.add(this._graphicMoveManipulation.createDragPipeline(((e,i,a)=>{i.next((t=>this._trackNumDragging(t))).next((e=>("start"===e.action&&(t=this._editGeometryOperations.createUndoGroup()),e))).next((t=>this._perGraphicManipulatorDragAction(qt.ALL,t))).next((t=>(this._updateTranslateGraphicTooltip($.XY,t),t))).next((e=>{"end"===e.action&&(this._hideTooltip(),t=h(t))})),a.next((()=>this._onDragCancel(!0,(()=>t=h(t)))))}))),this._graphicMoveManipulation.forEachManipulator((t=>this._manipulatorHandles.add(this._watchAndUpdateGrabState(t,!1))))}else this._graphicMoveManipulation.forEachManipulator((t=>{t.grabbable=!1,t.cursor=null}));this._graphicMoveManipulation.forEachManipulator((t=>this._manipulatorHandles.add(t.events.on("immediate-click",(t=>{this._manipulatorInfos.some((t=>t.manipulator.selected))?this._clearSelection():this.emit("immediate-click",{...t,graphic:this.graphic}),t.stopPropagation()})))))}_createMoveManipulation(t){const{graphic:e,tool:i,view:a}=this,n=this._graphicState;this._moveManipulation=new tt({tool:i,view:a,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZShape&&K(e),snapToScene:!1,radius:tt.radiusForSymbol(e.symbol)}),this._moveManipulation.forEachManipulator((t=>this.addHandles([t.events.on("immediate-click",(i=>{this._moveManipulation.zManipulation.hasManipulator(t)||this._manipulatorInfos.some((t=>t.manipulator.selected))||this.emit("immediate-click",{...i,graphic:e}),i.stopPropagation()})),this._watchAndUpdateGrabState(t,!1)])));const o=t=>e=>{this.addHandles(e.events.on("focus-changed",(({action:e})=>{"focus"===e?this._updateTranslateTooltip(t):this._hideTooltip()})))};this._moveManipulation.xyManipulation.forEachManipulator(o($.XY)),this._moveManipulation.xyAxisManipulation.forEachManipulator(o($.XY_AXIS)),this._moveManipulation.zManipulation.forEachManipulator(o($.Z)),this._moveManipulation.elevationInfo={mode:"absolute-height",offset:0};const s=e.geometry.spatialReference;this.addHandles([this._moveManipulation.createDragPipeline(((a,n,o,s,r)=>{const{snappingStep:l,cancelSnapping:p}=Ot({predicate:t=>!!t.info,snappingManager:i.snappingManager,snappingContext:new xt({editGeometryOperations:this._editGeometryOperations,elevationInfo:t,pointer:r,excludeFeature:e,visualizer:new F}),updatingHandles:this._updatingHandles,useZ:!1});return s=s.next((t=>(this._onDragCancel(),t))).next(p),{steps:o=o.next((t=>this._trackNumDragging(t))).next((t=>{const e=this._manipulatorInfos.filter((t=>"vertex"===t.type&&t.manipulator.selected));return t.manipulatorType===W.TRANSLATE_XY&&1===e.length?{...t,info:e[0],snapOrigin:e[0].handle.pos}:t})).next(ut(this.view,t,e)).next(...l).next(ct()).next((t=>this._perGraphicManipulatorDragAction(qt.SELECTED_OR_ALL,t))).next((t=>(this._updateTranslateTooltip(a,t),t))),cancel:s}}),t,s,e),m((()=>n.displaying),(()=>this._updateMoveManipulationPosition()),g),n.on("changed",(()=>{this._recreatingManipulators||this._updateMoveManipulationPosition()})),m((()=>n.isDraped),(t=>{this._updateMoveManipulationPosition();const e="align-move-manipulation";t?this.addHandles(this.view.elevationProvider.on("elevation-change",(()=>this._updateMoveManipulationPosition())),e):this.removeHandles(e)}),g)])}_createVisualElements(){const{graphic:t,view:e}=this,i=J({view:e,graphic:t,forEachManipulator:t=>{if(!this.destroyed&&!this._recreatingManipulators){this._graphicMoveManipulation.forEachManipulator(t),this._moveManipulation.forEachManipulator(t);for(const e of this._manipulatorInfos)t(e.manipulator,W.TRANSLATE_XY)}},onManipulatorsChanged:t=>this.on("manipulators-changed",t)});null!=i&&(this._outlineVisualElement=i.visualElement instanceof rt?i.visualElement:null),null!=this._outlineVisualElement&&this._manipulatorHandles.add(this._outlineVisualElement.events.on("attachment-origin-changed",(()=>{this._graphicState.isDraped||this._updateMoveManipulationPosition()}))),this._manipulatorHandles.add(i)}_createEdgeOffsetManipulator(t,e=D(this.graphic)){if(t.component.vertices.length<=2)return null;const i=this._settings.manipulators.edgeOffset,a=i.size/2,n=a+i.collisionPadding,o=a/n,r=o*Math.sqrt(3)/2;null==this._edgeOffsetManipulatorGeometryInside&&(this._edgeOffsetManipulatorGeometryInside=pt(this._edgeOffsetManipulatorMaterial,r,o/2,o/2,i.height,i.offset)),null==this._edgeOffsetManipulatorGeometryOutside&&(this._edgeOffsetManipulatorGeometryOutside=pt(this._edgeOffsetManipulatorMaterial,-r,o/2,o/2,i.height,-i.offset));const l=[new N(this._edgeOffsetManipulatorGeometryInside.instantiate(),ft.Unfocused),new N(this._edgeOffsetManipulatorGeometryInside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),ft.Focused),new N(this._edgeOffsetManipulatorGeometryOutside.instantiate(),ft.Unfocused),new N(this._edgeOffsetManipulatorGeometryOutside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),ft.Focused)],p=new k({view:this.view,renderObjects:l,elevationInfo:"on-the-ground"!==e.mode||j(this.graphic.symbol)?{mode:"absolute-height",offset:0}:e,worldOriented:!1,focusMultiplier:1,radius:n,available:!(!this.graphic.visible||!this.graphic.layer?.visible),collisionType:{type:"disc",direction:I(0,0,1)},collisionPriority:1,metadata:{deleting:!1}}),h=new k({view:this.view,worldSized:!0,worldOriented:!1,available:!(!this.graphic.visible||!this.graphic.layer?.visible),collisionPriority:-10,cursor:this.enableMoveGraphic?"move":"default",metadata:{deleting:!1}}),u={manipulator:p,handle:t,locationUpdateHandle:null,type:"edge",selectedIndex:0,edgeManipulator:h,elevationInfo:e,visibilityHandle:null};this._autoHideEdgeOffsetManipulator(u,i.minSquaredEdgeLength),this._updateEdgeOffsetManipulator(u);const c=[];for(const s of[t.leftVertex,t.rightVertex]){const t=this._getManipulatorInfoFromHandle(s);null!=t&&c.push(t.manipulator.events.on("location-update",(()=>this._updateEdgeOffsetManipulator(u))))}u.locationUpdateHandle=s(c),this._manipulatorHandles.add(u.locationUpdateHandle,p),this._manipulatorHandles.add([this._watchAndUpdateGrabState(p,!0),this._watchAndUpdateGrabState(h,!0)],p),this._manipulatorHandles.add(mt(p,this._createEdgeOffsetPipeline(u,e)),p),this._manipulatorHandles.add(mt(h,((t,i,a,n)=>{if("touch"===n){this._createEdgeOffsetPipeline(u,e)(t,i,a)}else if(this.enableMoveGraphic){const n=this.graphic,o=null!=n.geometry?n.geometry.spatialReference:null;i.next((t=>this._trackNumDragging(t))).next(gt(this.view,t.elevationAlignedLocation)).next(Z(this.view,t.elevationAlignedLocation,e,o,n)).next(_t()).next(ct()).next((t=>this._perGraphicManipulatorDragAction(qt.ALL,t))).next((t=>(this._updateTranslateGraphicTooltip($.XY,t),t))).next((t=>{"end"===t.action&&this._hideTooltip()})),a.next((()=>this._onDragCancel(!t.metadata.deleting)))}})),p);const m=t=>{this._manipulatorInfos.some((t=>t.manipulator.selected))?this._clearSelection():this.emit("immediate-click",{...t,graphic:this.graphic}),t.stopPropagation()};return this._manipulatorHandles.add([p.events.on("immediate-click",m),h.events.on("immediate-click",m),p.events.on("focus-changed",(({action:t})=>{const{sketchOptions:e,tooltip:i}=this;if("focus"===t){const t=this._edgeOffsetTooltipInfo??=new bt({sketchOptions:e});t.distance=d,t.sketchOptions=e,this._updateTooltipAreaOrTotalLength(t),this._latestTooltipInfo=t,i.info=e.tooltips.effectiveEnabled?this._latestTooltipInfo:null}else this._hideTooltip()}))],p),this._manipulatorInfos.push(u),this.manipulators.add(p),this.manipulators.add(h),this.emit("manipulators-changed"),u}_autoHideEdgeOffsetManipulator(t,e){const i=t.manipulator,a=t.edgeManipulator,n=()=>{t.visibilityHandle=h(t.visibilityHandle);const n=this._getManipulatorInfoFromHandle(t.handle.leftVertex),o=this._getManipulatorInfoFromHandle(t.handle.rightVertex),l=null!=n&&null!=o&&st(n.manipulator.renderLocation,o.manipulator.renderLocation,this.view.state.camera)<e;(!i.focused&&!a.focused||l)&&(i.grabbable=!l,a.grabbable=!l,t.visibilityHandle=s([i.disableDisplay(),r((()=>{i.grabbable=!0,a.grabbable=this.enableMoveGraphic}))]))};this._manipulatorHandles.add([i.events.on("focus-changed",n),a.events.on("focus-changed",n),r((()=>{h(t.visibilityHandle),a.metadata.deleting=!0,this.manipulators.remove(a)}))],i),n()}_updateEdgeOffsetManipulator(t){this._updateManipulatorPosition(t);const{coordinateHelper:e}=this._editGeometryOperations.data,i=at(this.view,t.manipulator.elevationAlignedLocation,nt(e,t.handle,t.manipulator.elevationInfo)),a=this._getManipulatorInfoFromHandle(t.handle.leftVertex),n=this._getManipulatorInfoFromHandle(t.handle.rightVertex);if(null==a||null==n)return;const o=a.manipulator.renderLocation,s=n.manipulator.renderLocation,r=null!=i?ot(i,o,s):M;t.manipulator.modelTransform=r,t.edgeManipulator.elevationAlignedLocation=t.manipulator.elevationAlignedLocation,t.edgeManipulator.modelTransform=r;const l=y(x(zt,o,s))/2;t.edgeManipulator.collisionType={type:"line",paths:[[[-l,0,0],[l,0,0]]]}}_createEdgeOffsetPipeline(t,e){return(i,a,n)=>{this._clearSelection();const{step:o,cleanup:s}=this._initializeEdgeOffset(t,e);a.next((t=>this._trackNumDragging(t))).next(gt(this.view,i.elevationAlignedLocation)).next(o).next(z(this.view)).next(X(this.view,this._editGeometryOperations.data.spatialReference)).next(ct()).next(this._applyComputeEdgeOffsetDistanceStep()).next(this._applyEdgeOffsetStep(t)).next(this._showEdgeOffsetTooltip()).next((t=>{"end"===t.action&&s()})),n.next((()=>{i.metadata.deleting||(s(),this._onDragCancel())}))}}_initializeEdgeOffset(t,e){const{view:i}=this,n=this._editGeometryOperations,o=nt(n.data.coordinateHelper,t.handle,e),r=n.createUndoGroup(),p=at(i,t.manipulator.elevationAlignedLocation,o);if(o.requiresSplitEdgeLeft){const e=this._getManipulatorInfoFromHandle(t.handle.leftVertex.leftEdge);null!=e&&this._splitEdgeManipulator(e,1)}if(o.requiresSplitEdgeRight){const e=this._getManipulatorInfoFromHandle(t.handle.rightVertex.rightEdge);null!=e&&this._splitEdgeManipulator(e,0)}const d=()=>new w({paths:[[t.handle.leftVertex.pos,t.handle.rightVertex.pos]],spatialReference:n.data.spatialReference}),u=this._settings,c=new rt({view:i,isDraped:this._graphicState.isDraped,geometry:d(),elevationInfo:t.elevationInfo,width:u.visualElements.lineGraphics.outline.width,attached:!1,isDecoration:!0});let _;const f=()=>{this._cleanEdgeOffsetCollapsedEdges(t),_=h(_)},v=this.on("undo",f);return _=s([m((()=>a(this._accentColor)),(t=>c.color=t),g),l(c),m((()=>this._graphicState.isDraped),(t=>c.isDraped=t)),this._graphicState.on("changed",(()=>c.geometry=d())),r,v]),c.attached=!0,{step:t=>null==o||null==p?(f(),null):{...t,operation:o,plane:p},cleanup:f}}_applyEdgeOffsetStep(t){return e=>{if(this.destroyed||null==e.operation)return e;this._updateEventState(Yt.RESHAPING);const{mapDeltaX:i,mapDeltaY:a,mapDeltaZ:n}=e;return(i||a||n)&&(this._offsetEdge(t,e),this.emit("reshape",{type:"reshape",mover:this.graphic})),e}}_applyComputeEdgeOffsetDistanceStep(){return t=>{const{operation:e,mapEnd:i}=t;return null==e||null==i?t:("start"===t.action&&e.selectArrowFromStartPoint(i),{...t,signedDistance:e.signedDistanceToPoint(i)})}}_showEdgeOffsetTooltip(){return t=>{const{mapEnd:e,signedDistance:i,operation:a}=t,{tooltip:n,sketchOptions:o}=this;if(null!=i){const n=this._edgeOffsetTooltipInfo??=new bt({sketchOptions:o});n.sketchOptions=o,n.distance="end"===t.action?d:Rt(this._graphicState.isDraped,i*a.selectedArrow,e,a.plane,this._editGeometryOperations.data.coordinateHelper),this._updateTooltipAreaOrTotalLength(n),this._latestTooltipInfo=n}else this._latestTooltipInfo=null;return n.info=o.tooltips.effectiveEnabled?this._latestTooltipInfo:null,t}}_cleanEdgeOffsetCollapsedEdges(t){const e=t.handle.leftVertex.leftEdge?.leftVertex,i=t.handle.leftVertex,a=t.handle.rightVertex.rightEdge?.rightVertex,n=t.handle.rightVertex,o=this._editGeometryOperations.data.coordinateHelper,s=[];if(e&&o.distance(e.pos,i.pos)<Xt){const t=this._getManipulatorInfoFromHandle(i);null!=t&&s.push(t)}if(o.distance(i.pos,n.pos)<Xt||a&&o.distance(a.pos,n.pos)<Xt){const t=this._getManipulatorInfoFromHandle(n);null!=t&&s.push(t)}s.length&&this._removeVertices(s)}_computeVertexManipulatorSizeAndOutline(t){const e=t.size/2,i=e+t.collisionPadding;return{size:e/i,outlineSize:(e+t.outlineSize)/i}}_createVertexOrEdgeManipulator(t,e=D(this.graphic),i=!1){const{view:a}=this,n=this._settings;if("edge"===t.type){if(this.enableEdgeOffset)return this._createEdgeOffsetManipulator(t,e);if(!this.enableMidpoints)return null}if(null==this._vertexManipulatorGeometry||null==this._vertexManipulatorOutlineGeometry){const{size:t,outlineSize:e}=this._computeVertexManipulatorSizeAndOutline(n.manipulators.vertex);this._vertexManipulatorGeometry=ht(this._vertexManipulatorMaterial,t,16,16),this._vertexManipulatorOutlineGeometry=ht(this._vertexManipulatorOutlineMaterial,e,16,16)}if(null==this._edgeManipulatorGeometry||null==this._edgeManipulatorOutlineGeometry){const{size:t,outlineSize:e}=this._computeVertexManipulatorSizeAndOutline(n.manipulators.edge);this._edgeManipulatorGeometry=ht(this._edgeManipulatorMaterial,t,16,16),this._edgeManipulatorOutlineGeometry=ht(this._edgeManipulatorOutlineMaterial,e,16,16)}const{geometry:o}=this.graphic,r=o?.type,l="point"===r||"mesh"===r?[]:[new N(this._vertexManipulatorGeometry.instantiate(),Zt.Vertex|ft.Unselected),new N(this._vertexManipulatorOutlineGeometry.instantiate(),Zt.Vertex|ft.Unfocused|ft.Unselected),new N(this._vertexManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),Zt.Vertex|ft.Focused|ft.Unselected),new N(this._vertexManipulatorGeometry.instantiate({material:this._selectedManipulatorMaterial}),ft.Selected),new N(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorOutlineMaterial}),ft.Selected|ft.Unfocused),new N(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorHoverOutlineMaterial}),ft.Selected|ft.Focused)];this.enableMidpoints&&l.push(new N(this._edgeManipulatorGeometry.instantiate({material:this._vertexManipulatorMaterial}),Zt.Edge|ft.Focused|ft.Unselected),new N(this._edgeManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),Zt.Edge|ft.Focused|ft.Unselected),new N(this._edgeManipulatorGeometry.instantiate(),Zt.Edge|ft.Unfocused|ft.Unselected),new N(this._edgeManipulatorOutlineGeometry.instantiate(),Zt.Edge|ft.Unfocused|ft.Unselected));const p=new k({view:a,renderObjects:l,elevationInfo:e,focusMultiplier:1,touchMultiplier:1,available:!(!this.graphic.visible||!this.graphic.layer?.visible),metadata:{deleting:!1}});p.selected=i,this._setTypeSpecificManipulatorSettings(p,t,e);const d="edge"===t.type?{manipulator:p,handle:t,locationUpdateHandle:null,type:"edge",selectedIndex:0}:{manipulator:p,handle:t,type:"vertex",selectedIndex:0};if(this._manipulatorInfos.push(d),this.manipulators.add(p),this._updateManipulatorPosition(d),"edge"===d.type){const t=[];for(const e of[d.handle.leftVertex,d.handle.rightVertex]){const i=this._getManipulatorInfoFromHandle(e);null!=i&&t.push(i.manipulator.events.on("location-update",(()=>this._updateManipulatorPosition(d))))}d.locationUpdateHandle=s(t),this._manipulatorHandles.add(d.locationUpdateHandle,p)}this._manipulatorHandles.add(this._watchAndUpdateGrabState(p,!0),p);const u=mt(p,((t,i,a,n)=>{let o=null;const{snappingStep:s,cancelSnapping:r}=Ot({predicate:()=>!this._isMultiVertexSelection(),snappingManager:this.tool.snappingManager,snappingContext:new xt({editGeometryOperations:this._editGeometryOperations,elevationInfo:e,pointer:n,excludeFeature:this.graphic,visualizer:new F}),updatingHandles:this._updatingHandles,useZ:!1});a=a.next((e=>(this._onDragCancel(!t.metadata.deleting,(()=>o=h(o))),e))).next(r),i.next((t=>this._trackNumDragging(t))).next((t=>{if("start"===t.action&&(o=this._editGeometryOperations.createUndoGroup()),"edge"===d.type){const e=this._splitEdgeManipulator(d);return{...t,info:e,snapOrigin:e.handle.pos}}return{...t,info:d,snapOrigin:d.handle.pos}})).next(gt(this.view,t.elevationAlignedLocation)).next(Y(this.view,this.graphic,t.elevationAlignedLocation,t.location.spatialReference,this.graphic)).next(ut(this.view,e,this.graphic)).next(...s).next(ct()).next((e=>{this._perVertexManipulatorDragAction(e),"end"===e.action&&(o=h(o)),this._updateTranslateVertexTooltip(t,$.XY,e)}))}));return this._manipulatorHandles.add([u,p.events.on("immediate-click",(t=>this._manipulatorClickCallback(t,d))),p.events.on("select-changed",(()=>{d.selectedIndex=++this._selectedIndex,this._updateMoveManipulationPosition()})),p.events.on("focus-changed",(({action:t})=>{"focus"===t&&"edge"!==d.type?this._updateTranslateVertexTooltip(p,$.XY):this._hideTooltip()}))],p),this.emit("manipulators-changed"),d}_trackNumDragging(t){switch(t.action){case"start":this._numDragging++;break;case"end":this._numDragging--}return t}_onDragCancel(t=!0,e){switch(this._numDragging--,t&&(this.undo(),this.outputGeometry=null!=this._editGeometryOperations?this._editGeometryOperations.data.geometry:null),null!=this.tool.snappingManager&&this.tool.snappingManager.doneSnapping(),this._hideTooltip(),this._reshapeEventState){case Yt.NONE:break;case Yt.MOVING:this.emit("move",{type:"move",dx:0,dy:0,mover:this.graphic});break;case Yt.RESHAPING:this.emit("reshape",{type:"reshape",mover:this.graphic})}e&&e(),this.destroyed||this._updateEventState(Yt.NONE)}_setTypeSpecificManipulatorSettings(t,e,i){const{graphic:a}=this,n=this._settings;switch(e.type){case"vertex":{t.state=Zt.Vertex,t.selectable=!0,t.cursor="move",t.collisionPriority=2;const{size:e,collisionPadding:o}=n.manipulators.vertex;t.radius=e/2+o,t.elevationInfo=i;const{geometry:s}=a,r=s?.type;t.interactive=null!=r&&"point"!==r&&"mesh"!==r;break}case"edge":{t.state=Zt.Edge,t.selectable=!1,t.cursor="copy",t.collisionPriority=-1;const{size:e,collisionPadding:o}=n.manipulators.edge;t.radius=e/2+o,t.elevationInfo="on-the-ground"!==i.mode||j(a.symbol)?{mode:"absolute-height",offset:0}:i;break}}}_watchAndUpdateGrabState(t,e){return t.events.on("grab-changed",(i=>this._onGrabStateChanged(t,e,i.action,i.pointerType)))}_onGrabStateChanged(t,e,i,a="mouse"){if(!this._recreatingManipulators){if("start"===i)e&&this._updateSelection(t),this._numGrabbing++;else if(this._numGrabbing--,this._updateEventState(Yt.NONE),this.destroyed)return;this._moveManipulation.interactive=!this._numGrabbing,("touch"!==a||this.enableEdgeOffset)&&(this._manipulatorInfos.forEach((t=>{const{manipulator:e}=t,{geometry:i}=this.graphic,a=i?.type;e.interactive=e.grabbing||!this._numGrabbing&&null!=a&&"point"!==a&&"mesh"!==a,"edgeManipulator"in t&&(t.edgeManipulator.interactive=t.edgeManipulator.grabbing||!this._numGrabbing)})),this._graphicMoveManipulation.forEachManipulator((t=>{t.interactive=t.grabbing||!this._numGrabbing})))}}_clearSelection(){for(const t of this._manipulatorInfos)t.manipulator.grabbing||(t.manipulator.selected=!1)}_updateSelection(t){t.grabbing&&!t.selected&&t.selectable&&(this._clearSelection(),t.selected=!0,this.emit("manipulators-changed"))}_removeManipulator(t){null!=t&&(t.manipulator.metadata.deleting=!0,this.manipulators.remove(t.manipulator),this._manipulatorHandles.remove(t.manipulator),i(this._manipulatorInfos,t),this.emit("manipulators-changed"))}_getManipulatorInfoFromHandle(t){if(t)for(const e of this._manipulatorInfos)if(t===e.handle)return e;return null}_updateManipulatorPosition(t){if(null==t)return;const e=this._editGeometryOperations;if("vertex"===t.type)t.manipulator.location=e.data.coordinateHelper.vectorToDehydratedPoint(t.handle.pos,Ft),t.manipulator.grabbing&&null!=this._vertexLaserLineVisualElement&&(this._vertexLaserLineVisualElement.visualElement.intersectsWorldUpAtLocation=t.manipulator.renderLocation);else if("edge"===t.type){const i=this._getManipulatorInfoFromHandle(t.handle.leftVertex),a=this._getManipulatorInfoFromHandle(t.handle.rightVertex);if(null==i||null==a)return;const n=i.manipulator,o=a.manipulator;if(null!=t.manipulator.elevationInfo&&"on-the-ground"===t.manipulator.elevationInfo.mode){const i=n.location,a=o.location,s=.5,r=i.x+s*(a.x-i.x),l=i.y+s*(a.y-i.y),p=i.hasZ&&a.hasZ?0:void 0;t.manipulator.location=L(r,l,p,e.data.spatialReference)}else O(zt,n.renderLocation,o.renderLocation,.5),t.manipulator.renderLocation=zt}}_splitEdgeManipulator(t,e=.5){const i=this._editGeometryOperations,a=i.splitEdge(t.handle,e).createdVertex;t.locationUpdateHandle=h(t.locationUpdateHandle);const n=D(this.graphic);let o;this.enableEdgeOffset?(this._removeManipulator(t),o=this._createVertexOrEdgeManipulator(a)):(o=t,o.handle=a,o.type="vertex",this._setTypeSpecificManipulatorSettings(t.manipulator,t.handle,n)),a.leftEdge&&this._createVertexOrEdgeManipulator(a.leftEdge),a.rightEdge&&this._createVertexOrEdgeManipulator(a.rightEdge),this.outputGeometry=i.data.geometry,this._updateManipulatorPosition(o),this.enableEdgeOffset||this._updateTranslateVertexTooltip(o.manipulator,$.XY),this._updateSelection(t.manipulator);const s=this._updateEventState(Yt.RESHAPING),r=i.data.coordinateHelper.vectorToArray(o.handle.pos),l=i.data.components.indexOf(a.component);return this.emit("vertex-add",{type:"vertex-add",vertices:[{coordinates:r,componentIndex:l,vertexIndex:a.index}],added:r}),s&&this._updateEventState(Yt.NONE),o}_updateMoveManipulationPosition(){const t=b(zt,0,0,0);let e=0,i=!1,a=null,n=null;for(const o of this._manipulatorInfos)"vertex"===o.type&&(o.manipulator.selected?(e++,E(t,t,o.manipulator.renderLocation),null==a||o.selectedIndex>a.selectedIndex?(n=a,a=o):(null==n||o.selectedIndex>n.selectedIndex)&&(n=o)):i=!0);if(0===e){const t=this._graphicState.displaying&&this.enableMoveGraphic;this._moveManipulation.xyManipulation.available=t,this._moveManipulation.xyAxisManipulation.available=t,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=t,this._moveManipulation.zManipulation.available=t&&this.enableZShape&&K(this.graphic),this._moveManipulation.angle=q(this.graphic.geometry),this._moveManipulation.radius=tt.radiusForSymbol(this.graphic.symbol)}else{const t=this._graphicState.displaying;this._moveManipulation.xyManipulation.available=t,this._moveManipulation.xyAxisManipulation.available=t,this._moveManipulation.zManipulation.available=t&&this.enableZVertex&&K(this.graphic),this._moveManipulation.xyAxisManipulation.orthogonalAvailable=t&&1!==e;let i=0;if(null!=a){const t=a.handle.pos,e=null!=n?n.handle.pos:a.handle.leftEdge&&a.handle.leftEdge.leftVertex?a.handle.leftEdge.leftVertex.pos:null,o=null==n&&a.handle.rightEdge&&a.handle.rightEdge.rightVertex?a.handle.rightEdge.rightVertex.pos:null;e&&o?this._moveManipulation.xyAxisManipulation.available=!1:e?i=Nt(e,t):o&&(i=Nt(t,o))}this._moveManipulation.angle=i,this._moveManipulation.radius=Q}0!==e&&i?(G(t,t,1/e),Ft.spatialReference=this._editGeometryOperations.data.spatialReference,Ft.hasZ=!0,this.view.renderCoordsHelper.fromRenderCoords(t,Ft),this._moveManipulation.elevationAlignedLocation=Ft):null==this._outlineVisualElement||this._graphicState.isDraped||null==this._outlineVisualElement.attachmentOrigin?C(this.view,this._moveManipulation,this.graphic):this._moveManipulation.elevationAlignedLocation=this._outlineVisualElement.attachmentOrigin}_removeVertices(t){const e=new Array,i=this._editGeometryOperations;for(const a of t){const t=a.handle.component;if("vertex"===a.type&&i.canRemoveVertex(t)){e.push(a.handle),this._removeManipulator(a),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.leftEdge)),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.rightEdge));const n=i.removeVertices([a.handle]),o=n.removedVertices?.[0].createdEdge;o?this._createVertexOrEdgeManipulator(o):this.enableEdgeOffset&&t.vertices.length<=2&&this._removeManipulator(this._getManipulatorInfoFromHandle(t.edges[0]))}}if(e.length>0){const t=e.map((t=>{const e=i.data.components.indexOf(t.component);return{coordinates:i.data.coordinateHelper.vectorToArray(t.pos),componentIndex:e,vertexIndex:t.index}}));this.outputGeometry=i.data.geometry;const a=this._updateEventState(Yt.RESHAPING);if(this.destroyed)return;if(this.emit("vertex-remove",{type:"vertex-remove",removed:t.map((t=>t.coordinates)),vertices:t}),this.destroyed)return;if(a&&(this._updateEventState(Yt.NONE),this.destroyed))return;this._updateMoveManipulationPosition()}}_moveVertices(t,e,i=("start"===e.action?yt.NEW_STEP:yt.ACCUMULATE_STEPS)){const a=this._editGeometryOperations;a.moveVertices(t.map((t=>t.handle)),e.mapDeltaX,e.mapDeltaY,e.mapDeltaZ,i),this.outputGeometry=a.data.geometry;for(const n of t)this._updateManipulatorPosition(n)}_offsetEdge(t,e){if(null==e.operation||null==e.signedDistance)return;const i=this._editGeometryOperations,a=e.operation.clone();a.distance=e.signedDistance,i.updateVertices([t.handle.leftVertex,t.handle.rightVertex],a),this.outputGeometry=i.data.geometry,this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(t.handle.leftVertex)),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(t.handle.rightVertex))}_manipulatorClickCallback(t,e){t.shiftKey||this._clearSelection(),"vertex"===e.type&&(e.manipulator.selected=!e.manipulator.selected,t.button===dt.Right&&this._removeVertices([e])),"edge"===e.type&&t.button===dt.Left&&this._splitEdgeManipulator(e),t.stopPropagation()}_updateTranslateTooltip(t,e){const i=this._manipulatorInfos.filter((t=>"vertex"===t.type&&t.manipulator.selected));1===i.length?this._updateTranslateVertexTooltip(i[0].manipulator,t,e):this._updateTranslateGraphicTooltip(t,e)}_updateTranslateGraphicTooltip(t,e){const{sketchOptions:i,tooltip:a}=this;switch(t){case $.XY:this._latestTooltipInfo=this._translateGraphicTooltipInfo??=new St({sketchOptions:i}),this._updateTranslateTooltipDistance(this._latestTooltipInfo,e,((t,e)=>Lt(t,e)));break;case $.XY_AXIS:this._latestTooltipInfo=this._translateGraphicXYTooltipInfo??=new It({sketchOptions:i}),this._updateTranslateTooltipDistance(this._latestTooltipInfo,e,((t,i)=>u(Lt(t,i),et(e))));break;case $.Z:this._latestTooltipInfo=this._translateGraphicZTooltipInfo??=new Gt({sketchOptions:i}),this._updateTranslateTooltipDistance(this._latestTooltipInfo,e,jt)}this._latestTooltipInfo.sketchOptions=i,a.info=i.tooltips.effectiveEnabled?this._latestTooltipInfo:null}_updateTranslateVertexTooltip(t,e,i){const{sketchOptions:a,tooltip:n}=this;switch(e){case $.XY:this._latestTooltipInfo=this._translateVertexTooltipInfo??=new Ht({sketchOptions:a}),this._updateTranslateTooltipDistance(this._latestTooltipInfo,i,((t,e)=>Lt(t,e))),this._updateTooltipAreaOrTotalLength(this._latestTooltipInfo);break;case $.XY_AXIS:this._latestTooltipInfo=this._translateVertexXYTooltipInfo??=new wt({sketchOptions:a}),this._updateTranslateTooltipDistance(this._latestTooltipInfo,i,((t,e)=>u(Lt(t,e),et(i)))),this._updateTooltipAreaOrTotalLength(this._latestTooltipInfo);break;case $.Z:this._latestTooltipInfo=this._translateVertexZTooltipInfo??=new Tt({sketchOptions:a}),this._updateTranslateTooltipDistance(this._latestTooltipInfo,i,jt)}const o=kt(t.location);this._latestTooltipInfo.elevation=null!=o?Vt({actual:o}):null,this._latestTooltipInfo.sketchOptions=a,n.info=a.tooltips.effectiveEnabled?this._latestTooltipInfo:null}_updateTranslateTooltipDistance(t,e,i){if(null!=e&&"end"!==e.action){const{mapStart:a,mapEnd:n}=e,o=i(a,n);t.distance=null!=o?o:d}else t.distance=d}_updateTooltipAreaOrTotalLength(t){const{geometry:e}=this.graphic;if(null==e)return t.area=null,void(t.totalLength=null);t.area="polygon"===e.type?At(e):null,t.totalLength="polyline"===e.type?Dt(e):null}_hideTooltip(){this.tooltip.clear(),this._latestTooltipInfo=null}get test(){return{segmentLabels:this._segmentLabels,manipulatorInfos:this._manipulatorInfos}}};function Nt(t,e){return Math.atan2(e[1]-t[1],e[0]-t[0])+Math.PI/2}function Rt(t,e,i,a,n){if(t){const t=n.toXYZ(n.pointToVector(i)),o=V(a,t,A.get()),s=Pt(o,t,n.spatialReference);if(null!=s)return c(s.value*Math.sign(e),s.unit)}return c(e*_(i.spatialReference),"meters")}t([f()],Ct.prototype,"_editGeometryOperations",void 0),t([f()],Ct.prototype,"_segmentLabels",void 0),t([f({constructOnly:!0})],Ct.prototype,"tool",void 0),t([f()],Ct.prototype,"tooltip",void 0),t([f()],Ct.prototype,"inputGeometry",null),t([f()],Ct.prototype,"outputGeometry",void 0),t([f({readOnly:!0})],Ct.prototype,"updating",null),t([f()],Ct.prototype,"manipulators",null),t([f()],Ct.prototype,"view",null),t([f()],Ct.prototype,"graphic",null),t([f()],Ct.prototype,"enableZShape",null),t([f()],Ct.prototype,"enableZVertex",null),t([f()],Ct.prototype,"enableMoveGraphic",null),t([f()],Ct.prototype,"enableMidpoints",null),t([f()],Ct.prototype,"enableEdgeOffset",null),t([f()],Ct.prototype,"sketchOptions",null),t([f()],Ct.prototype,"_accentColor",null),Ct=t([v("esri.views.3d.interactive.editingTools.reshapeGraphic.ReshapeOperation")],Ct);const Ft=L(0,0,void 0,Ut.WGS84),zt=S(),Xt=1e-6;var Zt,Yt,qt;!function(t){t.Vertex=vt.Custom1,t.Edge=vt.Custom2}(Zt||(Zt={})),function(t){t[t.NONE=0]="NONE",t[t.MOVING=1]="MOVING",t[t.RESHAPING=2]="RESHAPING"}(Yt||(Yt={})),function(t){t[t.ALL=0]="ALL",t[t.SELECTED_OR_ALL=1]="SELECTED_OR_ALL"}(qt||(qt={}));export{Ct as ReshapeOperation};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{createRenderScreenPointArray3 as e}from"../../../../../core/screenUtils.js";import{fromValues as r}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{b as o,D as n,o as t,f as s}from"../../../../../chunks/vec32.js";import{create as c}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getNormal as i,fromPositionAndNormal as l,create as d}from"../../../../../geometry/support/plane.js";import{makeDehydratedPoint as f}from"../../../../../layers/graphics/dehydratedPoint.js";import{PlaneType as u,OffsetEdgeVertex as a}from"../../../../interactive/editGeometry/operations/OffsetEdgeVertex.js";function m(e,r,o){const n="on-the-ground"===o.mode?u.XY:u.XYZ;return new a(e,n,r,0)}function p(e,r,n){const t=c();if(!e.renderCoordsHelper.toRenderCoords(r,t))return null;const s=j(e,r,i(n.plane)),f=j(e,r,n.edgeDirection);if(null==s||null==f)return null;const u=o(c(),s,f);return l(t,u,d())}function j(e,r,o){const t=f(r.x+o[0],r.y+o[1],r.z+o[2],r.spatialReference),s=c(),i=c();return e.renderCoordsHelper.toRenderCoords(r,s)&&e.renderCoordsHelper.toRenderCoords(t,i)?n(i,s,i):null}function g(e,t,s){const l=i(e),d=n(c(),t,s),f=o(c(),d,l),u=o(c(),d,f);return r(d[0],d[1],d[2],0,f[0],f[1],f[2],0,u[0],u[1],u[2],0,0,0,0,1)}function C(r,o,n){const c=n.projectToRenderScreen(r,e()),i=n.projectToRenderScreen(o,e());return null!=c&&null!=i?t(s(c,c,i)):0}export{p as createEdgeOffsetIntersectionPlane,m as createEdgeOffsetOperation,g as edgeOffsetRotationMatrix,C as screenEdgeLengthSquared};
5
+ import{createRenderScreenPointArray3 as e}from"../../../../../core/screenUtils.js";import{fromValues as r}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{b as o,E as n,p as t,f as s}from"../../../../../chunks/vec32.js";import{create as c}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getNormal as i,fromPositionAndNormal as l,create as d}from"../../../../../geometry/support/plane.js";import{makeDehydratedPoint as f}from"../../../../../layers/graphics/dehydratedPoint.js";import{PlaneType as u,OffsetEdgeVertex as p}from"../../../../interactive/editGeometry/operations/OffsetEdgeVertex.js";function a(e,r,o){const n="on-the-ground"===o.mode?u.XY:u.XYZ;return new p(e,n,r,0)}function m(e,r,n){const t=c();if(!e.renderCoordsHelper.toRenderCoords(r,t))return null;const s=j(e,r,i(n.plane)),f=j(e,r,n.edgeDirection);if(null==s||null==f)return null;const u=o(c(),s,f);return l(t,u,d())}function j(e,r,o){const t=f(r.x+o[0],r.y+o[1],r.z+o[2],r.spatialReference),s=c(),i=c();return e.renderCoordsHelper.toRenderCoords(r,s)&&e.renderCoordsHelper.toRenderCoords(t,i)?n(i,s,i):null}function g(e,t,s){const l=i(e),d=n(c(),t,s),f=o(c(),d,l),u=o(c(),d,f);return r(d[0],d[1],d[2],0,f[0],f[1],f[2],0,u[0],u[1],u[2],0,0,0,0,1)}function C(r,o,n){const c=n.projectToRenderScreen(r,e()),i=n.projectToRenderScreen(o,e());return null!=c&&null!=i?t(s(c,c,i)):0}export{m as createEdgeOffsetIntersectionPlane,a as createEdgeOffsetOperation,g as edgeOffsetRotationMatrix,C as screenEdgeLengthSquared};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{set as t,normalize as e}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{c as i,q as a,f as r,l as o,j as n}from"../../../../../chunks/vec32.js";import{create as c}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{a as l,c as p}from"../../../../../chunks/boundedPlane.js";import{intersectRay as h}from"../../../../../geometry/support/plane.js";import{sv3d as d}from"../../../../../geometry/support/vectorStacks.js";import{ResizeManipulator as u}from"../../../analysis/Slice/ResizeManipulator.js";import{updateResizeHandle as m,isDiagonalResizeHandle as S,calculateDiagonalResizeHandleScale as _}from"../../../analysis/Slice/sliceToolUtils.js";import{screenToRenderPlane as g}from"../dragEventPipeline3D.js";import{ManipulatorType as y}from"../ManipulatorType.js";import{mapPlaneAutoSize2D as f}from"./extentUtils.js";import{fromScreenNormalized as z}from"../../../support/geometryUtils/ray.js";import{createManipulatorDragEventPipeline as x}from"../../../../interactive/dragEventPipeline.js";import{AccumulationBehavior as M}from"../../../../interactive/editGeometry/interfaces.js";import{AccumulationType as v}from"../../../../interactive/editGeometry/operations/UpdateVertices.js";import{apply as b}from"../../../../interactive/editGeometry/support/editPlaneUtils.js";import{ExtentScaleTooltipInfo as B}from"../../../../interactive/tooltip/ExtentTooltipInfos.js";class j{get zMax(){if(!this._zMaxDirty)return this._zMax;const t=this._editGeometryOperations.data;if(t.geometry.hasZ){const e=t.coordinateHelper;this._zMax=Number.NEGATIVE_INFINITY;for(const s of t.components)for(const t of s.vertices){const s=e.getZ(t.pos)??0;this._zMax=Math.max(s,this._zMax)}}else this._zMax=0;return this._zMaxDirty=!1,this._zMax}constructor(e,i,a,r,o){this._tool=e,this._graphicState=i,this._editGeometryOperations=a,this._bounds=r,this._preserveAspectRatioStep=o,this._resizeHandles=[{direction:[1,0]},{direction:[1,1]},{direction:[0,1]},{direction:[-1,1]},{direction:[-1,0]},{direction:[-1,-1]},{direction:[0,-1]},{direction:[1,-1]}],this._scaleTooltipInfo=null,this._displayBoundsStart=l(),this._displayBoundsMarginStart=0,this._startScale=s(),this._endScale=s(),this._sizeStart=null,this._zMax=0,this._zMaxDirty=!0;const n=this._tool,c=n.view;this.resizeManipulators=this._resizeHandles.map((t=>{const e=new u(c,t);return n.addHandles([e.events.on("grab-changed",(t=>this._onResizeGrab(t))),this._createResizeDragPipeline(e,t)]),e})),n.manipulators.addMany(this.resizeManipulators),n.addHandles([n.on("graphic-scale-start",(e=>{t(this._startScale,e.xScale,e.yScale),t(this._endScale,e.xScale,e.yScale)})),n.on("graphic-scale",(e=>{t(this._endScale,e.xScale,e.yScale)})),n.on("graphic-scale-stop",(()=>{t(this._startScale,0,0),t(this._endScale,0,0)})),this._graphicState.on("changed",(()=>{"resize"!==n.inputState?.type&&(this._zMaxDirty=!0)}))])}destroy(){this.forEachManipulator((t=>{this._tool.manipulators.remove(t),t.destroy()}))}forEachManipulator(t){this.resizeManipulators.forEach((e=>t(e,y.SCALE)))}updateManipulators(t,e){this.resizeManipulators.forEach(((s,i)=>{m(s,this._resizeHandles[i],t,e)}))}getUpdatedTooltipInfo(){return this.resizeManipulators.some((t=>t.focused))?this._computeScaleTooltipInfo():null}_computeScaleTooltipInfo(){const t=this._tool,e=this._scaleTooltipInfo??=new B({sketchOptions:t.sketchOptions}),s=t.graphic.geometry;if(null==s)return null;const i=f(this._bounds.mapBounds,this.zMax,s.spatialReference);return null==i?null:(e.xSize=i.xSize,e.ySize=i.ySize,null!=this._sizeStart&&this.resizeManipulators.some((t=>t.dragging))?(e.xScale=i.xSize.value/this._sizeStart.xSize.value,e.yScale=i.ySize.value/this._sizeStart.ySize.value):(e.xScale=1,e.yScale=1),e)}_onResizeGrab({action:t,screenPoint:e}){const s=this._tool,i=this._bounds;if("start"!==t||!e||!s.graphic.geometry)return;const a=z(s.view.state.camera,e);h(i.displayBounds.plane,a,d.get())&&(i.backupMapBounds(),p(i.displayBounds,this._displayBoundsStart),this._displayBoundsMarginStart=i.displayBoundsMargin,this._sizeStart=f(i.mapBoundsStart,this.zMax,s.graphic.geometry.spatialReference),s.inputState={type:"resize"})}_createResizeDragPipeline(t,e){const s=this._tool,i=s.graphic;return x(t,((t,a,r)=>{null!=s.inputState&&(a.next((t=>("start"===t.action&&s.emit("graphic-scale-start",{graphic:i,xScale:1,yScale:1}),t))).next(g(s.view,this._displayBoundsStart.plane)).next((t=>({...t,handle:e}))).next(this._resizeDragRenderPlaneToFactors()).next(...this._preserveAspectRatioStep()).next(this._resizeDragUpdateGeometry()).next((t=>{const e={graphic:i,xScale:t.factor1,yScale:t.factor2};switch(t.action){case"start":case"update":s.emit("graphic-scale",e);break;case"end":s.inputState=null,s.emit("graphic-scale-stop",e)}return t})),r.next((()=>{null!=s.inputState&&s.emit("graphic-scale-stop",{graphic:i,xScale:1,yScale:1}),s.cancel()})))}))}_resizeDragRenderPlaneToFactors(){const t=this._bounds;return e=>{const s=this._displayBoundsStart,c=e.handle.direction,l=t.displayBoundsMargin,p=this._displayBoundsMarginStart,h=i(d.get(),s.origin);a(h,h,s.basis1,-c[0]),a(h,h,s.basis2,-c[1]);const u=r(d.get(),e.renderEnd,h),m=r(d.get(),e.renderStart,h),g=S(e.handle),y=_(s),f=_(t.displayBounds)/y,z=(t,e)=>{if(0===t)return 1;let s=o(e),i=.5*t*n(e,u)/s;const a=i<0?-1:1;if(g){i+=(s-.5*t*n(e,m)/s)*a*f}const r=s<1.5*p?1:E;return s=Math.max(s-p,E),a>0&&(i-=l),a*Math.max(a*(i/s),r)};return{...e,factor1:z(c[0],s.basis1),factor2:z(c[1],s.basis2)}}}_resizeDragUpdateGeometry(){const r=this._tool,o=this._bounds;return n=>{const l=i(c(),o.mapBoundsStart.origin);a(l,l,o.mapBoundsStart.basis1,-n.handle.direction[0]),a(l,l,o.mapBoundsStart.basis2,-n.handle.direction[1]);const h=t(s(),o.mapBoundsStart.basis1[0],o.mapBoundsStart.basis1[1]);e(h,h);const d=[];for(const t of this._editGeometryOperations.data.components)d.push(...t.vertices);const u="start"===n.action?M.NEW_STEP:M.ACCUMULATE_STEPS,m=this._editGeometryOperations.scaleVertices(d,l,h,n.factor1,n.factor2,u,v.REPLACE);return p(o.mapBoundsStart,o.mapBounds),b(m,o.mapBounds),r.graphic.geometry=this._editGeometryOperations.data.geometry,n}}}const E=1e-6;export{j as ExtentScale,E as scaleEpsilon};
5
+ import{set as t,normalize as e}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{c as i,r as a,f as r,l as o,k as n}from"../../../../../chunks/vec32.js";import{create as c}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{a as l,c as p}from"../../../../../chunks/boundedPlane.js";import{intersectRay as h}from"../../../../../geometry/support/plane.js";import{sv3d as d}from"../../../../../geometry/support/vectorStacks.js";import{ResizeManipulator as u}from"../../../analysis/Slice/ResizeManipulator.js";import{updateResizeHandle as m,isDiagonalResizeHandle as S,calculateDiagonalResizeHandleScale as _}from"../../../analysis/Slice/sliceToolUtils.js";import{screenToRenderPlane as g}from"../dragEventPipeline3D.js";import{ManipulatorType as y}from"../ManipulatorType.js";import{mapPlaneAutoSize2D as f}from"./extentUtils.js";import{fromScreenNormalized as z}from"../../../support/geometryUtils/ray.js";import{createManipulatorDragEventPipeline as x}from"../../../../interactive/dragEventPipeline.js";import{AccumulationBehavior as M}from"../../../../interactive/editGeometry/interfaces.js";import{AccumulationType as v}from"../../../../interactive/editGeometry/operations/UpdateVertices.js";import{apply as b}from"../../../../interactive/editGeometry/support/editPlaneUtils.js";import{ExtentScaleTooltipInfo as B}from"../../../../interactive/tooltip/ExtentTooltipInfos.js";class j{get zMax(){if(!this._zMaxDirty)return this._zMax;const t=this._editGeometryOperations.data;if(t.geometry.hasZ){const e=t.coordinateHelper;this._zMax=Number.NEGATIVE_INFINITY;for(const s of t.components)for(const t of s.vertices){const s=e.getZ(t.pos)??0;this._zMax=Math.max(s,this._zMax)}}else this._zMax=0;return this._zMaxDirty=!1,this._zMax}constructor(e,i,a,r,o){this._tool=e,this._graphicState=i,this._editGeometryOperations=a,this._bounds=r,this._preserveAspectRatioStep=o,this._resizeHandles=[{direction:[1,0]},{direction:[1,1]},{direction:[0,1]},{direction:[-1,1]},{direction:[-1,0]},{direction:[-1,-1]},{direction:[0,-1]},{direction:[1,-1]}],this._scaleTooltipInfo=null,this._displayBoundsStart=l(),this._displayBoundsMarginStart=0,this._startScale=s(),this._endScale=s(),this._sizeStart=null,this._zMax=0,this._zMaxDirty=!0;const n=this._tool,c=n.view;this.resizeManipulators=this._resizeHandles.map((t=>{const e=new u(c,t);return n.addHandles([e.events.on("grab-changed",(t=>this._onResizeGrab(t))),this._createResizeDragPipeline(e,t)]),e})),n.manipulators.addMany(this.resizeManipulators),n.addHandles([n.on("graphic-scale-start",(e=>{t(this._startScale,e.xScale,e.yScale),t(this._endScale,e.xScale,e.yScale)})),n.on("graphic-scale",(e=>{t(this._endScale,e.xScale,e.yScale)})),n.on("graphic-scale-stop",(()=>{t(this._startScale,0,0),t(this._endScale,0,0)})),this._graphicState.on("changed",(()=>{"resize"!==n.inputState?.type&&(this._zMaxDirty=!0)}))])}destroy(){this.forEachManipulator((t=>{this._tool.manipulators.remove(t),t.destroy()}))}forEachManipulator(t){this.resizeManipulators.forEach((e=>t(e,y.SCALE)))}updateManipulators(t,e){this.resizeManipulators.forEach(((s,i)=>{m(s,this._resizeHandles[i],t,e)}))}getUpdatedTooltipInfo(){return this.resizeManipulators.some((t=>t.focused))?this._computeScaleTooltipInfo():null}_computeScaleTooltipInfo(){const t=this._tool,e=this._scaleTooltipInfo??=new B({sketchOptions:t.sketchOptions}),s=t.graphic.geometry;if(null==s)return null;const i=f(this._bounds.mapBounds,this.zMax,s.spatialReference);return null==i?null:(e.xSize=i.xSize,e.ySize=i.ySize,null!=this._sizeStart&&this.resizeManipulators.some((t=>t.dragging))?(e.xScale=i.xSize.value/this._sizeStart.xSize.value,e.yScale=i.ySize.value/this._sizeStart.ySize.value):(e.xScale=1,e.yScale=1),e)}_onResizeGrab({action:t,screenPoint:e}){const s=this._tool,i=this._bounds;if("start"!==t||!e||!s.graphic.geometry)return;const a=z(s.view.state.camera,e);h(i.displayBounds.plane,a,d.get())&&(i.backupMapBounds(),p(i.displayBounds,this._displayBoundsStart),this._displayBoundsMarginStart=i.displayBoundsMargin,this._sizeStart=f(i.mapBoundsStart,this.zMax,s.graphic.geometry.spatialReference),s.inputState={type:"resize"})}_createResizeDragPipeline(t,e){const s=this._tool,i=s.graphic;return x(t,((t,a,r)=>{null!=s.inputState&&(a.next((t=>("start"===t.action&&s.emit("graphic-scale-start",{graphic:i,xScale:1,yScale:1}),t))).next(g(s.view,this._displayBoundsStart.plane)).next((t=>({...t,handle:e}))).next(this._resizeDragRenderPlaneToFactors()).next(...this._preserveAspectRatioStep()).next(this._resizeDragUpdateGeometry()).next((t=>{const e={graphic:i,xScale:t.factor1,yScale:t.factor2};switch(t.action){case"start":case"update":s.emit("graphic-scale",e);break;case"end":s.inputState=null,s.emit("graphic-scale-stop",e)}return t})),r.next((()=>{null!=s.inputState&&s.emit("graphic-scale-stop",{graphic:i,xScale:1,yScale:1}),s.cancel()})))}))}_resizeDragRenderPlaneToFactors(){const t=this._bounds;return e=>{const s=this._displayBoundsStart,c=e.handle.direction,l=t.displayBoundsMargin,p=this._displayBoundsMarginStart,h=i(d.get(),s.origin);a(h,h,s.basis1,-c[0]),a(h,h,s.basis2,-c[1]);const u=r(d.get(),e.renderEnd,h),m=r(d.get(),e.renderStart,h),g=S(e.handle),y=_(s),f=_(t.displayBounds)/y,z=(t,e)=>{if(0===t)return 1;let s=o(e),i=.5*t*n(e,u)/s;const a=i<0?-1:1;if(g){i+=(s-.5*t*n(e,m)/s)*a*f}const r=s<1.5*p?1:E;return s=Math.max(s-p,E),a>0&&(i-=l),a*Math.max(a*(i/s),r)};return{...e,factor1:z(c[0],s.basis1),factor2:z(c[1],s.basis2)}}}_resizeDragUpdateGeometry(){const r=this._tool,o=this._bounds;return n=>{const l=i(c(),o.mapBoundsStart.origin);a(l,l,o.mapBoundsStart.basis1,-n.handle.direction[0]),a(l,l,o.mapBoundsStart.basis2,-n.handle.direction[1]);const h=t(s(),o.mapBoundsStart.basis1[0],o.mapBoundsStart.basis1[1]);e(h,h);const d=[];for(const t of this._editGeometryOperations.data.components)d.push(...t.vertices);const u="start"===n.action?M.NEW_STEP:M.ACCUMULATE_STEPS,m=this._editGeometryOperations.scaleVertices(d,l,h,n.factor1,n.factor2,u,v.REPLACE);return p(o.mapBoundsStart,o.mapBounds),b(m,o.mapBounds),r.graphic.geometry=this._editGeometryOperations.data.geometry,n}}}const E=1e-6;export{j as ExtentScale,E as scaleEpsilon};